dal-code 1.0.43 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/agent-session.js +7 -7
  3. package/dist/core/extensions/types.d.ts +2 -0
  4. package/dist/core/permissions/tool-policy.d.ts +2 -1
  5. package/dist/core/permissions/tool-policy.js +1 -1
  6. package/dist/core/sandbox/shell-sandbox.js +6 -6
  7. package/dist/core/tool-denial.d.ts +13 -0
  8. package/dist/core/tool-denial.js +1 -0
  9. package/dist/core/tools/bash.js +13 -13
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -1
  12. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  13. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  14. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  15. package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
  16. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  17. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  18. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  19. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  20. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  21. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  22. package/dist/node_modules/@dalcode/dal-guard/src/index.js +2 -2
  23. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  24. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  25. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  26. package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
  27. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  28. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  29. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  30. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  31. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  32. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
  33. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  34. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  35. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  36. package/dist/node_modules/@dalcode/dal-remote/src/cli.js +14 -9
  37. package/dist/node_modules/@dalcode/dal-remote/src/processes.js +2 -0
  38. package/dist/node_modules/@dalcode/dal-remote/src/service.js +7 -7
  39. package/dist/node_modules/@dalcode/dal-remote/src/spec.js +1 -1
  40. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  41. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  42. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  43. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  44. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  45. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  46. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  47. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  48. package/dist/node_modules/@dalcode/dal-subagent/src/background.js +8 -8
  49. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +21 -21
  50. package/dist/node_modules/@dalcode/dal-subagent/src/progress.js +1 -1
  51. package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
  52. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  53. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  54. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  55. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  56. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  57. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  58. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  59. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
  60. package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +1 -0
  61. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  62. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  63. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  64. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  65. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  66. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  67. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  68. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  69. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  70. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  71. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  72. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  73. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  74. package/examples/extensions/gondolin/package-lock.json +2 -2
  75. package/examples/extensions/gondolin/package.json +1 -1
  76. package/examples/extensions/sandbox/package-lock.json +2 -2
  77. package/examples/extensions/sandbox/package.json +1 -1
  78. package/examples/extensions/with-deps/package-lock.json +2 -2
  79. package/examples/extensions/with-deps/package.json +1 -1
  80. package/npm-shrinkwrap.json +2 -2
  81. package/package.json +1 -1
@@ -1,20 +1,20 @@
1
- var ye=Object.defineProperty;var r=(t,e)=>ye(t,"name",{value:e,configurable:!0});import{constants as $e}from"node:fs";import{access as Le}from"node:fs/promises";import{constants as Te}from"node:os";import{ToolExecutionError as Ce}from"@earendil-works/pi-agent-core";import{Container as Pe,Text as j,truncateToWidth as Ie}from"@earendil-works/pi-tui";import{spawn as ve}from"child_process";import{Type as l}from"typebox";import{fill as U,t as I}from"../../dal/i18n.js";import{keyHint as De}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as Ae}from"../../modes/interactive/components/visual-truncate.js";import{theme as x}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as ke}from"../../utils/child-process.js";import{writeOutputFile as Me}from"../../utils/output-files.js";import{getShellConfig as le,getShellEnv as ue,killProcessTree as ce,trackDetachedChildPid as Fe,untrackDetachedChildPid as Ne}from"../../utils/shell.js";import{missingManagedToolHint as Be}from"../../utils/tools-manager.js";import{describeDenialForModel as Re}from"../sandbox/denial.js";import{getProcessShellSandbox as Ue}from"../sandbox/shell-sandbox.js";import{isReadOnlyBashCommand as Ge}from"./bash-read-only.js";import{OutputAccumulator as He}from"./output-accumulator.js";import{condenseShellOutput as je,outputCondenseDisabled as We}from"./output-condense.js";import{countOutputLines as Ve,formatCollapsedSummary as Ye,getTextOutput as me,invalidArgText as Xe,str as pe,truncateDisplay as Ke}from"./render-utils.js";import{wrapToolDefinition as qe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as ze,formatSize as Je,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as Qe}from"./truncate.js";const fe=2147483647,he=1024*1024,Ze=8*1024*1024,et=fe/1e3,te=12e4,ne=30;function tt(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>fe)throw new Error(`Invalid timeout: maximum is ${et} seconds`);return e}r(tt,"resolveTimeoutMs");const we=l.Object({command:l.String({description:"Shell command to execute"}),description:l.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:l.Optional(l.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),nt=l.Optional(l.Object({mode:l.Union([l.Literal("allow"),l.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:l.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:l.Optional(l.Array(l.String(),{description:"e.g. registry.npmjs.org"})),allow_write:l.Optional(l.Array(l.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),ot=l.Object({...we.properties,sandbox_escalation:nt}),Se={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},it=l.Object({output:l.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:l.Boolean(),full_output_path:l.Optional(l.String({description:"Full output, when truncated"})),exit_code:l.Number({description:"-1 while the command runs in the background"}),background_id:l.Optional(l.String({description:"Background process id, when it is still running"})),wall_time_seconds:l.Number()});function st(t,e){return{exec:r(async(n,o,{onData:u,signal:i,timeout:y,env:w,yieldTo:s})=>{const $=tt(y);if(i?.aborted)throw new Error("aborted");const S=e();try{await Le(o,$e.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
2
- Cannot execute ${t} commands.`)}const b=S.commandTransport==="stdin",c=ve(S.shell,b?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??ue(),stdio:[b?"pipe":"ignore","pipe","pipe"],windowsHide:!0});b&&(c.stdin?.on("error",()=>{}),c.stdin?.end(n)),c.pid&&Fe(c.pid);let a=!1,m=!1,h;const p=new Promise(A=>{h=r(()=>A("yielded"),"onYielded")});let f;const _=r(()=>{c.pid&&ce(c.pid)},"onAbort");try{$!==void 0&&(f=setTimeout(()=>{if(s&&c.exitCode===null&&c.signalCode===null&&s(c)){m=!0,h?.();return}a=!0,c.pid&&ce(c.pid)},$)),c.stdout?.on("data",u),c.stderr?.on("data",u),i&&(i.aborted?_():i.addEventListener("abort",_,{once:!0}));const A=ke(c),G=await Promise.race([A,p]);if(G==="yielded")return A.catch(()=>{}),{exitCode:null,yielded:!0};const V=G;if(i?.aborted)throw new Error("aborted");if(a)throw new Error(`timeout:${($??te)/1e3}`);const L=c.signalCode;return{exitCode:V??(L?128+(Te.signals[L]??0):1)}}finally{c.pid&&!m&&Ne(c.pid),f&&clearTimeout(f),i&&i.removeEventListener("abort",_)}},"exec")}}r(st,"createLocalShellOperations");function rt(t){return st("bash",()=>le(t?.shellPath))}r(rt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Wt(t){return se.add(t),()=>{se.delete(t)}}r(Wt,"registerShellExecutionGuard");async function at(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}r(at,"shellExecutionRefusal");const dt=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function lt(t,e,n,o,u){const i={...ue()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&u){const w=u.model;i.PI_SESSION_ID=u.sessionManager.getSessionId();const s=u.sessionManager.getSessionFile();s&&(i.PI_SESSION_FILE=s),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),u.thinkingLevel&&(i.PI_REASONING_LEVEL=u.thinkingLevel)}for(const w of dt){delete i[`DAL_${w}`];const s=i[`PI_${w}`];s!==void 0&&(i[`DAL_${w}`]=s)}const y={command:t,cwd:e,env:i};return n?n(y):y}r(lt,"resolveSpawnContext");const ut=5,ct=100;class mt extends Pe{static{r(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function pt(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),u=n%60;return o<60?`${o}m ${u}s`:`${Math.floor(o/60)}h ${o%60}m ${u}s`}r(pt,"formatDuration");function ft(t,e,n=!1){const o=pe(t?.command),u=pe(t?.description)?.trim(),i=t?.timeout,y=i?x.fg("muted",U(I(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:i})):"";if(u){const s=x.fg("toolTitle",x.bold(u))+y;return!n||!o?s:`${s}
3
- ${x.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const w=o===null?Xe(x):o?x.fg("dim",Ke(o.replace(/\s+/g," ").trim(),42)):x.fg("dim","\u2026");return`${x.fg("toolTitle",x.bold(e))} ${w}${y}`}r(ft,"formatShellCall");function ht(t,e,n,o,u,i,y,w){const s=t.state;t.clear();const $=wt(n,u,i,w);if(!n.expanded&&!y){const a=me(e,o),m=Ve(a),h=[];m>0&&h.push(U(I("{count} \u884C"),{count:m})),$&&h.push($);const p=Ye(x,h);p&&t.addChild(new j(p,0,0));return}let S=me(e,o).trim();const b=e.details?.truncation,c=e.details?.fullOutputPath;if(!n.isPartial&&b?.truncated&&c&&S.endsWith("]")){const a=S.lastIndexOf(`
1
+ var $e=Object.defineProperty;var a=(t,e)=>$e(t,"name",{value:e,configurable:!0});import{constants as Le}from"node:fs";import{access as Te}from"node:fs/promises";import{constants as Ce}from"node:os";import{ToolExecutionError as le}from"@earendil-works/pi-agent-core";import{Container as Pe,Text as j,truncateToWidth as Ie}from"@earendil-works/pi-tui";import{spawn as ve}from"child_process";import{Type as l}from"typebox";import{fill as G,t as I}from"../../dal/i18n.js";import{keyHint as De}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as Ae}from"../../modes/interactive/components/visual-truncate.js";import{theme as x}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as ke}from"../../utils/child-process.js";import{writeOutputFile as Me}from"../../utils/output-files.js";import{getShellConfig as ue,getShellEnv as ce,killProcessTree as me,trackDetachedChildPid as Fe,untrackDetachedChildPid as Ne}from"../../utils/shell.js";import{missingManagedToolHint as Be}from"../../utils/tools-manager.js";import{describeDenialForModel as Re}from"../sandbox/denial.js";import{getProcessShellSandbox as Ue}from"../sandbox/shell-sandbox.js";import{toolDenial as Ge,withToolDenial as He}from"../tool-denial.js";import{isReadOnlyBashCommand as je}from"./bash-read-only.js";import{OutputAccumulator as We}from"./output-accumulator.js";import{condenseShellOutput as Ve,outputCondenseDisabled as Ye}from"./output-condense.js";import{countOutputLines as Xe,formatCollapsedSummary as Ke,getTextOutput as pe,invalidArgText as qe,str as fe,truncateDisplay as ze}from"./render-utils.js";import{wrapToolDefinition as Je}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Qe,formatSize as Ze,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as et}from"./truncate.js";const he=2147483647,we=1024*1024,tt=8*1024*1024,nt=he/1e3,te=12e4,ne=30;function ot(t){if(t===void 0)return te;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>he)throw new Error(`Invalid timeout: maximum is ${nt} seconds`);return e}a(ot,"resolveTimeoutMs");const Se=l.Object({command:l.String({description:"Shell command to execute"}),description:l.String({description:`What it does and why, 3-10 words in the user's language, shown instead of the command: "Find hardcoded key names", not "run grep"`}),timeout:l.Optional(l.Number({description:"Seconds to wait for the command (default in the tool description). Raise it for long builds."}))}),it=l.Optional(l.Object({mode:l.Union([l.Literal("allow"),l.Literal("unsandboxed")],{description:'"allow": stay sandboxed with the domains/paths below; "unsandboxed": run outside the sandbox'}),justification:l.String({description:"Why, in one sentence for the user, who must approve it"}),allow_domains:l.Optional(l.Array(l.String(),{description:"e.g. registry.npmjs.org"})),allow_write:l.Optional(l.Array(l.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: the access it needs. Never pre-emptively."})),st=l.Object({...Se.properties,sandbox_escalation:it}),be={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},at=l.Object({output:l.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:l.Boolean(),full_output_path:l.Optional(l.String({description:"Full output, when truncated"})),exit_code:l.Number({description:"-1 while the command runs in the background"}),background_id:l.Optional(l.String({description:"Background process id, when it is still running"})),wall_time_seconds:l.Number()});function rt(t,e){return{exec:a(async(n,o,{onData:u,signal:i,timeout:y,env:w,yieldTo:s})=>{const $=ot(y);if(i?.aborted)throw new Error("aborted");const S=e();try{await Te(o,Le.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
2
+ Cannot execute ${t} commands.`)}const b=S.commandTransport==="stdin",c=ve(S.shell,b?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??ce(),stdio:[b?"pipe":"ignore","pipe","pipe"],windowsHide:!0});b&&(c.stdin?.on("error",()=>{}),c.stdin?.end(n)),c.pid&&Fe(c.pid);let r=!1,m=!1,h;const p=new Promise(A=>{h=a(()=>A("yielded"),"onYielded")});let f;const _=a(()=>{c.pid&&me(c.pid)},"onAbort");try{$!==void 0&&(f=setTimeout(()=>{if(s&&c.exitCode===null&&c.signalCode===null&&s(c)){m=!0,h?.();return}r=!0,c.pid&&me(c.pid)},$)),c.stdout?.on("data",u),c.stderr?.on("data",u),i&&(i.aborted?_():i.addEventListener("abort",_,{once:!0}));const A=ke(c),N=await Promise.race([A,p]);if(N==="yielded")return A.catch(()=>{}),{exitCode:null,yielded:!0};const V=N;if(i?.aborted)throw new Error("aborted");if(r)throw new Error(`timeout:${($??te)/1e3}`);const L=c.signalCode;return{exitCode:V??(L?128+(Ce.signals[L]??0):1)}}finally{c.pid&&!m&&Ne(c.pid),f&&clearTimeout(f),i&&i.removeEventListener("abort",_)}},"exec")}}a(rt,"createLocalShellOperations");function dt(t){return rt("bash",()=>ue(t?.shellPath))}a(dt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Xt(t){return se.add(t),()=>{se.delete(t)}}a(Xt,"registerShellExecutionGuard");async function lt(t){for(const e of se){let n;try{n=await e(t)}catch(o){return`Command refused: the safety check could not run (${o instanceof Error?o.message:String(o)}).`}if(n!==void 0)return n}}a(lt,"shellExecutionRefusal");const ut=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function ct(t,e,n,o,u){const i={...ce()};if(delete i.PI_SESSION_ID,delete i.PI_SESSION_FILE,delete i.PI_PROVIDER,delete i.PI_MODEL,delete i.PI_REASONING_LEVEL,o&&u){const w=u.model;i.PI_SESSION_ID=u.sessionManager.getSessionId();const s=u.sessionManager.getSessionFile();s&&(i.PI_SESSION_FILE=s),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),u.thinkingLevel&&(i.PI_REASONING_LEVEL=u.thinkingLevel)}for(const w of ut){delete i[`DAL_${w}`];const s=i[`PI_${w}`];s!==void 0&&(i[`DAL_${w}`]=s)}const y={command:t,cwd:e,env:i};return n?n(y):y}a(ct,"resolveSpawnContext");const mt=5,pt=100;class ft extends Pe{static{a(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function ht(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e),o=Math.floor(n/60),u=n%60;return o<60?`${o}m ${u}s`:`${Math.floor(o/60)}h ${o%60}m ${u}s`}a(ht,"formatDuration");function wt(t,e,n=!1){const o=fe(t?.command),u=fe(t?.description)?.trim(),i=t?.timeout,y=i?x.fg("muted",G(I(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:i})):"";if(u){const s=x.fg("toolTitle",x.bold(u))+y;return!n||!o?s:`${s}
3
+ ${x.fg("muted",` \u23BF ${e} ${o.trim()}`)}`}const w=o===null?qe(x):o?x.fg("dim",ze(o.replace(/\s+/g," ").trim(),42)):x.fg("dim","\u2026");return`${x.fg("toolTitle",x.bold(e))} ${w}${y}`}a(wt,"formatShellCall");function St(t,e,n,o,u,i,y,w){const s=t.state;t.clear();const $=bt(n,u,i,w);if(!n.expanded&&!y){const r=pe(e,o),m=Xe(r),h=[];m>0&&h.push(G(I("{count} \u884C"),{count:m})),$&&h.push($);const p=Ke(x,h);p&&t.addChild(new j(p,0,0));return}let S=pe(e,o).trim();const b=e.details?.truncation,c=e.details?.fullOutputPath;if(!n.isPartial&&b?.truncated&&c&&S.endsWith("]")){const r=S.lastIndexOf(`
4
4
 
5
- [`);a!==-1&&S.slice(a).includes(c)&&(S=S.slice(0,a).trimEnd())}if(S){const a=S.split(`
5
+ [`);r!==-1&&S.slice(r).includes(c)&&(S=S.slice(0,r).trimEnd())}if(S){const r=S.split(`
6
6
  `).map(m=>x.fg("toolOutput",m)).join(`
7
7
  `);n.expanded?t.addChild(new j(`
8
- ${a}`,0,0)):t.addChild({render:r(m=>{if(s.cachedLines===void 0||s.cachedWidth!==m){const h=Ae(a,ut,m);s.cachedLines=h.visualLines,s.cachedSkipped=h.skippedCount,s.cachedWidth=m}if(s.cachedSkipped&&s.cachedSkipped>0){const h=x.fg("muted",U(I("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:s.cachedSkipped}))+` ${De("app.tools.expand",I("\u5373\u53EF\u5C55\u5F00"))}${x.fg("muted",")")}`;return["",Ie(h,m,"..."),...s.cachedLines??[]]}return["",...s.cachedLines??[]]},"render"),invalidate:r(()=>{s.cachedWidth=void 0,s.cachedLines=void 0,s.cachedSkipped=void 0},"invalidate")})}if(b?.truncated||c){const a=[];c&&a.push(U(I("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:c})),b?.truncated&&(b.truncatedBy==="lines"?a.push(U(I("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:b.outputLines,total:b.totalLines})):a.push(U(I("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:b.outputLines,limit:Je(b.maxBytes??ze)}))),t.addChild(new j(`
9
- ${x.fg("warning",`[${a.join(". ")}]`)}`,0,0))}$&&t.addChild(new j(`
10
- ${x.fg("muted",$)}`,0,0))}r(ht,"rebuildBashResultRenderComponent");function wt(t,e,n,o){let u;if(!t.isPartial&&o!==void 0)u=o;else if(e!==void 0)u=(n??Date.now())-e;else return;if(!(!t.isPartial&&u<100))return`${t.isPartial?I("\u5DF2\u8FD0\u884C"):I("\u8017\u65F6")} ${pt(u)}`}r(wt,"bashTimingLabel");function St(t,e,n){const o=n?.operations??e.defaultOperations?.()??rt({shellPath:n?.shellPath}),u=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,y=n?.spawnHook,w=n?.sandbox,s=n?.operations===void 0,$=w?.describeForModel(),S=n?.background;let b=!1;const c=r(a=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${a?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${$?` ${$}`:""}`,"describe");return{name:e.name,label:e.label,description:c(!1),prepareLoadout:S&&s?a=>(b=a.declared.some(m=>m.name==="process"),b?{descriptions:{[e.name]:c(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!u?a=>e.readOnlyCommand?.(a?.command)?"parallel":void 0:void 0,parameters:w?.active?ot:we,outputSchema:it,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(a,m,h,p,f){const{command:_,timeout:A}=m;p&&p({content:[],details:void 0});const G=await at({toolName:e.name,command:_,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile()});if(G!==void 0)throw new Error(G);const V=u?`${u}
11
- ${_}`:_,L=lt(V,f?.cwd||t,y,i,f),Y=w??(s?Ue():void 0);let T;if(Y?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${Y.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);T=await Y.prepare({command:L.command,cwd:L.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:L.env,toolCallId:a,toolName:e.name,escalation:m.sandbox_escalation,ctx:f,signal:h})}const P=new He({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let W=!0,H,X=!1,re=0;const K=r(()=>{if(!p||!X)return;X=!1,re=Date.now();const d=P.snapshot({persistIfTruncated:!0});p({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),q=r(()=>{H&&(clearTimeout(H),H=void 0)},"clearUpdateTimer"),be=r(()=>{if(!p)return;X=!0;const d=ct-(Date.now()-re);if(d<=0){q(),K();return}H??=setTimeout(()=>{H=void 0,K()},d)},"scheduleOutputUpdate"),xe=r(d=>{W&&(P.append(d),be())},"handleData"),Ee=r(async()=>{W=!1,P.finish(),q(),K();const d=P.snapshot({persistIfTruncated:!0});return await P.closeTempFile(),d},"finishOutput"),z=r(async(d="(no output)")=>{const O=await Ee(),k=await P.readFullOutput(Ze),C=We()?void 0:je(k.content),E=Qe(C?.text??k.content,ee);let D=O.fullOutputPath;(E.truncated||C)&&!D&&(D=await Me(e.tempFilePrefix,".log",k.content));let M=E.content||d,B;const R=O.truncation.totalLines;return E.truncated?(B={truncation:{content:E.content,truncated:!0,truncatedBy:"bytes",totalLines:R,totalBytes:O.truncation.totalBytes,outputLines:E.headLines+E.tailLines,outputBytes:Buffer.byteLength(E.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:R,maxBytes:ee},fullOutputPath:D},M+=`
8
+ ${r}`,0,0)):t.addChild({render:a(m=>{if(s.cachedLines===void 0||s.cachedWidth!==m){const h=Ae(r,mt,m);s.cachedLines=h.visualLines,s.cachedSkipped=h.skippedCount,s.cachedWidth=m}if(s.cachedSkipped&&s.cachedSkipped>0){const h=x.fg("muted",G(I("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:s.cachedSkipped}))+` ${De("app.tools.expand",I("\u5373\u53EF\u5C55\u5F00"))}${x.fg("muted",")")}`;return["",Ie(h,m,"..."),...s.cachedLines??[]]}return["",...s.cachedLines??[]]},"render"),invalidate:a(()=>{s.cachedWidth=void 0,s.cachedLines=void 0,s.cachedSkipped=void 0},"invalidate")})}if(b?.truncated||c){const r=[];c&&r.push(G(I("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:c})),b?.truncated&&(b.truncatedBy==="lines"?r.push(G(I("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:b.outputLines,total:b.totalLines})):r.push(G(I("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:b.outputLines,limit:Ze(b.maxBytes??Qe)}))),t.addChild(new j(`
9
+ ${x.fg("warning",`[${r.join(". ")}]`)}`,0,0))}$&&t.addChild(new j(`
10
+ ${x.fg("muted",$)}`,0,0))}a(St,"rebuildBashResultRenderComponent");function bt(t,e,n,o){let u;if(!t.isPartial&&o!==void 0)u=o;else if(e!==void 0)u=(n??Date.now())-e;else return;if(!(!t.isPartial&&u<100))return`${t.isPartial?I("\u5DF2\u8FD0\u884C"):I("\u8017\u65F6")} ${ht(u)}`}a(bt,"bashTimingLabel");function xt(t,e,n){const o=n?.operations??e.defaultOperations?.()??dt({shellPath:n?.shellPath}),u=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,y=n?.spawnHook,w=n?.sandbox,s=n?.operations===void 0,$=w?.describeForModel(),S=n?.background;let b=!1;const c=a(r=>`Execute a ${e.shellName} command in the current working directory; returns stdout and stderr. Long output is cut to its start and end (error lines kept) and the full output saved to a file named in the result. ${r?`A command still running after \`timeout\` seconds (default ${ne}) keeps running in the background: you get its id and the output so far, then use the process tool to poll or kill it.`:`A command still running after \`timeout\` seconds (default ${te/1e3}) is killed.`}${$?` ${$}`:""}`,"describe");return{name:e.name,label:e.label,description:c(!1),prepareLoadout:S&&s?r=>(b=r.declared.some(m=>m.name==="process"),b?{descriptions:{[e.name]:c(!0)}}:void 0):void 0,promptSnippet:e.promptSnippet,promptGuidelines:i&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!u?r=>e.readOnlyCommand?.(r?.command)?"parallel":void 0:void 0,parameters:w?.active?st:Se,outputSchema:at,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(r,m,h,p,f){const{command:_,timeout:A}=m;p&&p({content:[],details:void 0});const N=await lt({toolName:e.name,command:_,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile()});if(N!==void 0)throw new le(N,He(void 0,Ge("dangerous-command",N)));const V=u?`${u}
11
+ ${_}`:_,L=ct(V,f?.cwd||t,y,i,f),Y=w??(s?Ue():void 0);let T;if(Y?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${Y.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);T=await Y.prepare({command:L.command,cwd:L.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:L.env,toolCallId:r,toolName:e.name,escalation:m.sandbox_escalation,ctx:f,signal:h})}const P=new We({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let W=!0,H,X=!1,ae=0;const K=a(()=>{if(!p||!X)return;X=!1,ae=Date.now();const d=P.snapshot({persistIfTruncated:!0});p({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),q=a(()=>{H&&(clearTimeout(H),H=void 0)},"clearUpdateTimer"),xe=a(()=>{if(!p)return;X=!0;const d=pt-(Date.now()-ae);if(d<=0){q(),K();return}H??=setTimeout(()=>{H=void 0,K()},d)},"scheduleOutputUpdate"),Ee=a(d=>{W&&(P.append(d),xe())},"handleData"),_e=a(async()=>{W=!1,P.finish(),q(),K();const d=P.snapshot({persistIfTruncated:!0});return await P.closeTempFile(),d},"finishOutput"),z=a(async(d="(no output)")=>{const O=await _e(),k=await P.readFullOutput(tt),C=Ye()?void 0:Ve(k.content),E=et(C?.text??k.content,ee);let D=O.fullOutputPath;(E.truncated||C)&&!D&&(D=await Me(e.tempFilePrefix,".log",k.content));let M=E.content||d,R;const U=O.truncation.totalLines;return E.truncated?(R={truncation:{content:E.content,truncated:!0,truncatedBy:"bytes",totalLines:U,totalBytes:O.truncation.totalBytes,outputLines:E.headLines+E.tailLines,outputBytes:Buffer.byteLength(E.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:U,maxBytes:ee},fullOutputPath:D},M+=`
12
12
 
13
- [Truncated: first ${E.headLines} and last ${E.tailLines} of ${E.totalLines} lines shown${C?`, after condensing ${R} lines (${C.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${D}]`):C&&(B={fullOutputPath:D},M+=`
13
+ [Truncated: first ${E.headLines} and last ${E.tailLines} of ${E.totalLines} lines shown${C?`, after condensing ${U} lines (${C.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${D}]`):C&&(R={fullOutputPath:D},M+=`
14
14
 
15
- [Condensed: ${C.summary}. Full output: ${D}]`),{text:M,details:B,snapshot:O}},"modelOutput"),N=r((d,O)=>`${d?`${d}
15
+ [Condensed: ${C.summary}. Full output: ${D}]`),{text:M,details:R,snapshot:O}},"modelOutput"),B=a((d,O)=>`${d?`${d}
16
16
 
17
- `:""}${O}`,"appendStatus"),ae=performance.now();let v;const J=S&&s&&b?d=>{W=!1;try{return v=S.adopt({child:d,command:_,cwd:L.cwd,...T?{prepared:T}:{},...P.handOff()}),!0}catch{return W=!0,!1}}:void 0;try{let d;try{const g=await o.exec(T?.command??L.command,L.cwd,{onData:xe,signal:h,timeout:A??(J?ne:void 0),env:L.env,...J?{yieldTo:J}:{}});if(g.yielded&&v){const{text:F,details:Z}=await z(""),_e=A??ne,Oe=v.urls.length>0?` It printed ${v.urls.join(" ")}.`:"",ge=`[Still running after ${_e}s, now in the background as ${v.id}.${Oe} For new output and the exit code call process with action "poll" and id "${v.id}"; "kill" stops it.]`,de=await P.readFullOutput(he);return{content:[{type:"text",text:N(F,ge)}],details:{...Z,background:v},structuredContent:{output:de.content,truncated:de.truncated,exit_code:-1,background_id:v.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}d=g.exitCode}catch(g){const{text:F}=await z("");if(await T?.finish(null,""),g instanceof Error&&g.message==="aborted")throw new Error(N(F,"Command aborted"));if(g instanceof Error&&g.message.startsWith("timeout:")){const Z=g.message.split(":")[1];throw new Error(N(F,`Command timed out after ${Z} seconds`))}throw g}const{text:O,details:k,snapshot:C}=await z(),E=await T?.finish(d,C.content||"");if(E&&T)throw new Ce(`${N(O,`Command exited with code ${d??"(none)"}`)}
17
+ `:""}${O}`,"appendStatus"),re=performance.now();let v;const J=S&&s&&b?d=>{W=!1;try{return v=S.adopt({child:d,command:_,cwd:L.cwd,...T?{prepared:T}:{},...P.handOff()}),!0}catch{return W=!0,!1}}:void 0;try{let d;try{const g=await o.exec(T?.command??L.command,L.cwd,{onData:Ee,signal:h,timeout:A??(J?ne:void 0),env:L.env,...J?{yieldTo:J}:{}});if(g.yielded&&v){const{text:F,details:Z}=await z(""),Oe=A??ne,ge=v.urls.length>0?` It printed ${v.urls.join(" ")}.`:"",ye=`[Still running after ${Oe}s, now in the background as ${v.id}.${ge} For new output and the exit code call process with action "poll" and id "${v.id}"; "kill" stops it.]`,de=await P.readFullOutput(we);return{content:[{type:"text",text:B(F,ye)}],details:{...Z,background:v},structuredContent:{output:de.content,truncated:de.truncated,exit_code:-1,background_id:v.id,wall_time_seconds:Math.round((performance.now()-re)/100)/10}}}d=g.exitCode}catch(g){const{text:F}=await z("");if(await T?.finish(null,""),g instanceof Error&&g.message==="aborted")throw new Error(B(F,"Command aborted"));if(g instanceof Error&&g.message.startsWith("timeout:")){const Z=g.message.split(":")[1];throw new Error(B(F,`Command timed out after ${Z} seconds`))}throw g}const{text:O,details:k,snapshot:C}=await z(),E=await T?.finish(d,C.content||"");if(E&&T)throw new le(`${B(O,`Command exited with code ${d??"(none)"}`)}
18
18
 
19
- ${Re(E)}`,{...k,sandbox:T.details});if(d===null)throw new Error(N(O,"Command terminated without an exit code"));const D=Math.round((performance.now()-ae)/100)/10,M=await P.readFullOutput(he),B={output:M.content,truncated:M.truncated,...M.truncated&&C.fullOutputPath?{full_output_path:C.fullOutputPath}:{},exit_code:d,wall_time_seconds:D},R=T?.details.escalation?T.details:void 0,Q=R?{...k,sandbox:R}:k;if(d!==0){const g=d===127?await Be(O):void 0,F=N(O,`Command exited with code ${d}`);return{content:[{type:"text",text:g?`${F}
20
- ${g}`:F}],details:Q,structuredContent:B,isError:!0}}return{content:[{type:"text",text:O}],details:Q,structuredContent:B}}finally{q()}},renderCall(a,m,h){const p=h.state;h.executionStarted&&p.startedAt===void 0&&(p.startedAt=Date.now(),p.endedAt=void 0);const f=h.lastComponent??new j("",0,0);return f.setText(ft(a,e.prompt,h.expanded===!0)),f},renderResult(a,m,h,p){const f=p.state;f.startedAt!==void 0&&m.isPartial&&!f.interval&&(f.interval=setInterval(()=>p.invalidate(),1e3)),(!m.isPartial||p.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const _=p.lastComponent??new mt;return ht(_,a,m,p.showImages,f.startedAt,f.endedAt,p.isError,p.durationMs),_.invalidate(),_}}}r(St,"createShellToolDefinition");const bt={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:Se.snippet,promptGuidelines:Se.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:Ge,sandboxShell:r(t=>le(t).shell,"sandboxShell")};function xt(t,e){return St(t,bt,e)}r(xt,"createBashToolDefinition");function Vt(t,e){const n=xt(t,e),o=qe(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}r(Vt,"createBashTool");export{Se as bashToolSystemPromptContribution,Vt as createBashTool,xt as createBashToolDefinition,rt as createLocalBashOperations,st as createLocalShellOperations,St as createShellToolDefinition,Wt as registerShellExecutionGuard,nt as sandboxEscalationSchema,at as shellExecutionRefusal};
19
+ ${Re(E)}`,{...k,sandbox:T.details});if(d===null)throw new Error(B(O,"Command terminated without an exit code"));const D=Math.round((performance.now()-re)/100)/10,M=await P.readFullOutput(we),R={output:M.content,truncated:M.truncated,...M.truncated&&C.fullOutputPath?{full_output_path:C.fullOutputPath}:{},exit_code:d,wall_time_seconds:D},U=T?.details.escalation?T.details:void 0,Q=U?{...k,sandbox:U}:k;if(d!==0){const g=d===127?await Be(O):void 0,F=B(O,`Command exited with code ${d}`);return{content:[{type:"text",text:g?`${F}
20
+ ${g}`:F}],details:Q,structuredContent:R,isError:!0}}return{content:[{type:"text",text:O}],details:Q,structuredContent:R}}finally{q()}},renderCall(r,m,h){const p=h.state;h.executionStarted&&p.startedAt===void 0&&(p.startedAt=Date.now(),p.endedAt=void 0);const f=h.lastComponent??new j("",0,0);return f.setText(wt(r,e.prompt,h.expanded===!0)),f},renderResult(r,m,h,p){const f=p.state;f.startedAt!==void 0&&m.isPartial&&!f.interval&&(f.interval=setInterval(()=>p.invalidate(),1e3)),(!m.isPartial||p.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const _=p.lastComponent??new ft;return St(_,r,m,p.showImages,f.startedAt,f.endedAt,p.isError,p.durationMs),_.invalidate(),_}}}a(xt,"createShellToolDefinition");const Et={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:je,sandboxShell:a(t=>ue(t).shell,"sandboxShell")};function _t(t,e){return xt(t,Et,e)}a(_t,"createBashToolDefinition");function Kt(t,e){const n=_t(t,e),o=Je(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}a(Kt,"createBashTool");export{be as bashToolSystemPromptContribution,Kt as createBashTool,_t as createBashToolDefinition,dt as createLocalBashOperations,rt as createLocalShellOperations,xt as createShellToolDefinition,Xt as registerShellExecutionGuard,it as sandboxEscalationSchema,lt as shellExecutionRefusal};
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { type BranchSummaryEntry, buildContextEntries, buildSessionContext, buil
29
29
  export { type CacheWarmingMode, type CompactionModelOverride, type CompactionSettings, type DefaultProjectTrust, type FullscreenExitOutput, type ImageSettings, type PackageSource, type QuietStartup, type RetrySettings, SettingsManager, type SettingsManagerCreateOptions, type TuiMode, } from "./core/settings-manager.ts";
30
30
  export { formatSkillsForPrompt, type LoadSkillsFromDirOptions, type LoadSkillsResult, loadSkills, loadSkillsFromDir, type Skill, type SkillFrontmatter, } from "./core/skills.ts";
31
31
  export { createSyntheticSourceInfo } from "./core/source-info.ts";
32
+ export { getToolDenial, type ToolDenial, type ToolDenialHint, type ToolDenialSource, } from "./core/tool-denial.ts";
32
33
  export { type EditDiffResult, generateDiffString, generateUnifiedPatch, normalizeForFuzzyMatch, } from "./core/tools/edit-diff.ts";
33
34
  export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLocalPowerShellOperations, createLsToolDefinition, createPowerShellToolDefinition, createProcessToolDefinition, createReadToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type PowerShellOperations, type PowerShellSpawnContext, type PowerShellSpawnHook, type PowerShellToolDetails, type PowerShellToolInput, type PowerShellToolOptions, type ProcessToolDetails, type ProcessToolInput, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, registerShellExecutionGuard, type ShellExecutionGuard, type ShellExecutionRequest, shellExecutionRefusal, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
34
35
  export { resolveToCwd } from "./core/tools/path-utils.ts";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{parseArgs as t}from"./cli/args.js";import{CONFIG_DIR_NAME as n,getAgentDir as a,getDocsPath as i,getExamplesPath as s,getPackageDir as l,getReadmePath as m,SHARED_SKILL_CONFIG_DIRS as c,VERSION as p}from"./config.js";import{AgentSession as d,parseSkillBlock as T}from"./core/agent-session.js";import{readStoredCredential as f}from"./core/auth-storage.js";import{BackgroundProcessManager as x,MAX_BACKGROUND_PROCESSES as C}from"./core/background-processes.js";import{calculateContextTokens as h,collectEntriesForBranchSummary as P,compact as R,DEFAULT_COMPACTION_SETTINGS as A,estimateTokens as D,findCutPoint as M,findTurnStartIndex as L,generateBranchSummary as _,generateSummary as k,generateSummaryWithUsage as y,getLastAssistantUsage as I,prepareBranchEntries as F,serializeConversation as O,shouldCompact as N}from"./core/compaction/index.js";import{createEventBus as H}from"./core/event-bus.js";import{createExtensionRuntime as b,defineTool as w,discoverAndLoadExtensions as U,ExtensionRunner as j,isBashToolResult as G,isEditToolResult as K,isFindToolResult as V,isGrepToolResult as W,isLsToolResult as z,isPowerShellToolResult as X,isReadToolResult as Y,isToolCallEventType as q,isWriteToolResult as Q,wrapRegisteredTool as J,wrapRegisteredTools as Z}from"./core/extensions/index.js";import{getHostCapabilities as ee,HOST_CAPABILITIES_ENV as oe,HOST_TOKEN_ENV as te,HOST_TOKEN_HEADER as re,HOST_URL_ENV as ne,HostCallError as ae,HostCapabilities as ie,parseHostCapabilities as se}from"./core/host-capabilities.js";import{convertToLlm as me}from"./core/messages.js";import{ModelRegistry as pe}from"./core/model-registry.js";import{resolveCliModel as de,resolveModelScopeWithDiagnostics as Te}from"./core/model-resolver.js";import{CredentialSynchronizationError as fe,ModelRuntime as Ee}from"./core/model-runtime.js";import{DefaultPackageManager as Ce}from"./core/package-manager.js";import{buildRuleSet as he,matchPermissionRules as Pe,parsePermissionRule as Re}from"./core/permissions/rules.js";import{evaluateToolPolicy as De,readAccessDenial as Me,registerPermissionAskHandler as Le}from"./core/permissions/tool-policy.js";import{describeProjectFacts as ke,detectProjectFacts as ye,projectPackageManager as Ie}from"./core/project-facts.js";import{buildProjectMap as Oe,formatProjectMapPrompt as Ne}from"./core/project-map.js";import{DefaultResourceLoader as He,loadProjectContextFiles as Be}from"./core/resource-loader.js";import{detectSandboxAvailability as we,getProcessShellSandbox as Ue,registerSandboxEscalationHandler as je,resolveSandboxPolicy as Ge,SANDBOX_ENV as Ke,ShellSandbox as Ve}from"./core/sandbox/index.js";import{AgentSessionRuntime as ze,createAgentSession as Xe,createAgentSessionFromServices as Ye,createAgentSessionRuntime as qe,createAgentSessionServices as Qe,createBashTool as Je,createCodingTools as Ze,createEditTool as $e,createFindTool as eo,createGrepTool as oo,createLsTool as to,createPowerShellTool as ro,createReadOnlyTools as no,createReadTool as ao,createWriteTool as io}from"./core/sdk.js";import{buildContextEntries as lo,buildSessionContext as mo,buildSessionProjection as co,CURRENT_SESSION_VERSION as po,getLatestCompactionEntry as So,migrateSessionEntries as To,parseSessionEntries as go,SessionManager as fo,sessionEntryToContextMessages as Eo}from"./core/session-manager.js";import{SettingsManager as Co}from"./core/settings-manager.js";import{formatSkillsForPrompt as ho,loadSkills as Po,loadSkillsFromDir as Ro}from"./core/skills.js";import{createSyntheticSourceInfo as Do}from"./core/source-info.js";import{generateDiffString as Lo,generateUnifiedPatch as _o,normalizeForFuzzyMatch as ko}from"./core/tools/edit-diff.js";import{createBashToolDefinition as Io,createEditToolDefinition as Fo,createFindToolDefinition as Oo,createGrepToolDefinition as No,createLocalBashOperations as vo,createLocalPowerShellOperations as Ho,createLsToolDefinition as Bo,createPowerShellToolDefinition as bo,createProcessToolDefinition as wo,createReadToolDefinition as Uo,createWriteToolDefinition as jo,DEFAULT_MAX_BYTES as Go,DEFAULT_MAX_LINES as Ko,formatSize as Vo,registerShellExecutionGuard as Wo,shellExecutionRefusal as zo,truncateHead as Xo,truncateLine as Yo,truncateTail as qo,withFileMutationQueue as Qo}from"./core/tools/index.js";import{resolveToCwd as Zo}from"./core/tools/path-utils.js";import{hasTrustRequiringProjectResources as et,ProjectTrustStore as ot}from"./core/trust-manager.js";import{VIRTUAL_MODEL_STATE_ENTRY as rt}from"./core/virtual-models.js";import{claimWorkspace as at,gitDirOf as it,readWorkspaceLock as st,releaseWorkspace as lt,STALE_AFTER_MS as mt,shellCommandDirectory as ct,WORKSPACE_LOCK_FILE as pt,workspaceLockIsLive as St,workspaceOwnerSessionId as dt}from"./core/workspace-lock.js";import{applyShellEnvironmentPolicy as gt,DEFAULT_SHELL_ENV_EXCLUDES as ft,isDalCodeCredentialName as Et,withoutDalCodeCredentials as xt}from"./dal/child-env.js";import{ADAPTATION_FILE as ut,adaptationState as ht,adaptPackage as Pt,applyCommunityEnv as Rt,communityEnv as At,ensurePackageAdapted as Dt,isAdaptablePackage as Mt,readAdaptation as Lt,scanHardcodedPiPaths as _t,tryEnsurePackageAdapted as kt,verifyAdaptation as yt}from"./dal/extension-compat.js";export*from"./dal/hooks/index.js";import{isHostExtensionPath as Ot,markHostExtensionPaths as Nt}from"./dal/host-extensions.js";import{ENGINE_MARKET_CACHE_FILE as Ht,fetchSignedMarket as Bt,MARKET_SECTIONS as bt,marketCacheDir as wt,readSignedSection as Ut,resolveMarketEndpoint as jt,verifySignedSection as Gt}from"./dal/reviewed/market.js";import{createCodemodeExtension as Vt}from"./extensions/codemode/index.js";import{createMcpExtension as zt}from"./extensions/mcp/index.js";import{loadMcpRuntime as Yt}from"./extensions/mcp/runtime.lazy.js";import{createToolSearchExtension as Qt}from"./extensions/tool-search/index.js";import{main as Zt}from"./main.js";import{InteractiveMode as er,RpcClient as or,runPrintMode as tr,runRpcMode as rr}from"./modes/index.js";import{ArminComponent as ar,AssistantMessageComponent as ir,BashExecutionComponent as sr,BorderedLoader as lr,BranchSummaryMessageComponent as mr,CompactionSummaryMessageComponent as cr,CustomEditor as pr,CustomMessageComponent as Sr,DynamicBorder as dr,ExtensionEditorComponent as Tr,ExtensionInputComponent as gr,ExtensionSelectorComponent as fr,FooterComponent as Er,keyHint as xr,keyText as Cr,LoginDialogComponent as ur,ModelSelectorComponent as hr,OAuthSelectorComponent as Pr,rawKeyHint as Rr,renderDiff as Ar,SessionSelectorComponent as Dr,SettingsSelectorComponent as Mr,ShowImagesSelectorComponent as Lr,SkillInvocationMessageComponent as _r,ThemeSelectorComponent as kr,ThinkingSelectorComponent as yr,ToolExecutionComponent as Ir,TreeSelectorComponent as Fr,truncateToVisualLines as Or,UserMessageComponent as Nr,UserMessageSelectorComponent as vr}from"./modes/interactive/components/index.js";import{getLanguageFromPath as Br,getMarkdownTheme as br,getSelectListTheme as wr,getSettingsListTheme as Ur,highlightCode as jr,initTheme as Gr,Theme as Kr}from"./modes/interactive/theme/theme.js";import{copyToClipboard as Wr}from"./utils/clipboard.js";import{parseFrontmatter as Xr,stripFrontmatter as Yr}from"./utils/frontmatter.js";import{convertToPng as Qr}from"./utils/image-convert.js";import{formatDimensionNote as Zr,resizeImage as $r}from"./utils/image-resize.js";import{detectSupportedImageMimeTypeFromFile as on}from"./utils/mime.js";import{openBrowser as rn}from"./utils/open-browser.js";import{getPowerShellConfig as an,getShellConfig as sn,getShellEnv as ln}from"./utils/shell.js";export{ut as ADAPTATION_FILE,d as AgentSession,ze as AgentSessionRuntime,ar as ArminComponent,ir as AssistantMessageComponent,x as BackgroundProcessManager,sr as BashExecutionComponent,lr as BorderedLoader,mr as BranchSummaryMessageComponent,n as CONFIG_DIR_NAME,po as CURRENT_SESSION_VERSION,cr as CompactionSummaryMessageComponent,fe as CredentialSynchronizationError,pr as CustomEditor,Sr as CustomMessageComponent,A as DEFAULT_COMPACTION_SETTINGS,Go as DEFAULT_MAX_BYTES,Ko as DEFAULT_MAX_LINES,ft as DEFAULT_SHELL_ENV_EXCLUDES,Ce as DefaultPackageManager,He as DefaultResourceLoader,dr as DynamicBorder,Ht as ENGINE_MARKET_CACHE_FILE,Tr as ExtensionEditorComponent,gr as ExtensionInputComponent,j as ExtensionRunner,fr as ExtensionSelectorComponent,Er as FooterComponent,oe as HOST_CAPABILITIES_ENV,te as HOST_TOKEN_ENV,re as HOST_TOKEN_HEADER,ne as HOST_URL_ENV,ae as HostCallError,ie as HostCapabilities,er as InteractiveMode,ur as LoginDialogComponent,bt as MARKET_SECTIONS,C as MAX_BACKGROUND_PROCESSES,pe as ModelRegistry,Ee as ModelRuntime,hr as ModelSelectorComponent,Pr as OAuthSelectorComponent,ot as ProjectTrustStore,or as RpcClient,Ke as SANDBOX_ENV,c as SHARED_SKILL_CONFIG_DIRS,mt as STALE_AFTER_MS,fo as SessionManager,Dr as SessionSelectorComponent,Co as SettingsManager,Mr as SettingsSelectorComponent,Ve as ShellSandbox,Lr as ShowImagesSelectorComponent,_r as SkillInvocationMessageComponent,Kr as Theme,kr as ThemeSelectorComponent,yr as ThinkingSelectorComponent,Ir as ToolExecutionComponent,Fr as TreeSelectorComponent,Nr as UserMessageComponent,vr as UserMessageSelectorComponent,p as VERSION,rt as VIRTUAL_MODEL_STATE_ENTRY,pt as WORKSPACE_LOCK_FILE,Pt as adaptPackage,ht as adaptationState,Rt as applyCommunityEnv,gt as applyShellEnvironmentPolicy,lo as buildContextEntries,Oe as buildProjectMap,he as buildRuleSet,mo as buildSessionContext,co as buildSessionProjection,h as calculateContextTokens,at as claimWorkspace,P as collectEntriesForBranchSummary,At as communityEnv,R as compact,me as convertToLlm,Qr as convertToPng,Wr as copyToClipboard,Xe as createAgentSession,Ye as createAgentSessionFromServices,qe as createAgentSessionRuntime,Qe as createAgentSessionServices,Je as createBashTool,Io as createBashToolDefinition,Vt as createCodemodeExtension,Ze as createCodingTools,$e as createEditTool,Fo as createEditToolDefinition,H as createEventBus,b as createExtensionRuntime,eo as createFindTool,Oo as createFindToolDefinition,oo as createGrepTool,No as createGrepToolDefinition,vo as createLocalBashOperations,Ho as createLocalPowerShellOperations,to as createLsTool,Bo as createLsToolDefinition,zt as createMcpExtension,ro as createPowerShellTool,bo as createPowerShellToolDefinition,wo as createProcessToolDefinition,no as createReadOnlyTools,ao as createReadTool,Uo as createReadToolDefinition,Do as createSyntheticSourceInfo,Qt as createToolSearchExtension,io as createWriteTool,jo as createWriteToolDefinition,w as defineTool,ke as describeProjectFacts,ye as detectProjectFacts,we as detectSandboxAvailability,on as detectSupportedImageMimeTypeFromFile,U as discoverAndLoadExtensions,Dt as ensurePackageAdapted,D as estimateTokens,De as evaluateToolPolicy,Bt as fetchSignedMarket,M as findCutPoint,L as findTurnStartIndex,Zr as formatDimensionNote,Ne as formatProjectMapPrompt,Vo as formatSize,ho as formatSkillsForPrompt,_ as generateBranchSummary,Lo as generateDiffString,k as generateSummary,y as generateSummaryWithUsage,_o as generateUnifiedPatch,a as getAgentDir,i as getDocsPath,s as getExamplesPath,ee as getHostCapabilities,Br as getLanguageFromPath,I as getLastAssistantUsage,So as getLatestCompactionEntry,br as getMarkdownTheme,l as getPackageDir,an as getPowerShellConfig,Ue as getProcessShellSandbox,m as getReadmePath,wr as getSelectListTheme,Ur as getSettingsListTheme,sn as getShellConfig,ln as getShellEnv,it as gitDirOf,et as hasTrustRequiringProjectResources,jr as highlightCode,Gr as initTheme,Mt as isAdaptablePackage,G as isBashToolResult,Et as isDalCodeCredentialName,K as isEditToolResult,V as isFindToolResult,W as isGrepToolResult,Ot as isHostExtensionPath,z as isLsToolResult,X as isPowerShellToolResult,Y as isReadToolResult,q as isToolCallEventType,Q as isWriteToolResult,xr as keyHint,Cr as keyText,Yt as loadMcpRuntime,Be as loadProjectContextFiles,Po as loadSkills,Ro as loadSkillsFromDir,Zt as main,Nt as markHostExtensionPaths,wt as marketCacheDir,Pe as matchPermissionRules,To as migrateSessionEntries,ko as normalizeForFuzzyMatch,rn as openBrowser,t as parseArgs,Xr as parseFrontmatter,se as parseHostCapabilities,Re as parsePermissionRule,go as parseSessionEntries,T as parseSkillBlock,F as prepareBranchEntries,Ie as projectPackageManager,Rr as rawKeyHint,Me as readAccessDenial,Lt as readAdaptation,Ut as readSignedSection,f as readStoredCredential,st as readWorkspaceLock,Le as registerPermissionAskHandler,je as registerSandboxEscalationHandler,Wo as registerShellExecutionGuard,lt as releaseWorkspace,Ar as renderDiff,$r as resizeImage,de as resolveCliModel,jt as resolveMarketEndpoint,Te as resolveModelScopeWithDiagnostics,Ge as resolveSandboxPolicy,Zo as resolveToCwd,tr as runPrintMode,rr as runRpcMode,_t as scanHardcodedPiPaths,O as serializeConversation,Eo as sessionEntryToContextMessages,ct as shellCommandDirectory,zo as shellExecutionRefusal,N as shouldCompact,Yr as stripFrontmatter,Xo as truncateHead,Yo as truncateLine,qo as truncateTail,Or as truncateToVisualLines,kt as tryEnsurePackageAdapted,yt as verifyAdaptation,Gt as verifySignedSection,Qo as withFileMutationQueue,xt as withoutDalCodeCredentials,St as workspaceLockIsLive,dt as workspaceOwnerSessionId,J as wrapRegisteredTool,Z as wrapRegisteredTools};
1
+ import{parseArgs as t}from"./cli/args.js";import{CONFIG_DIR_NAME as n,getAgentDir as a,getDocsPath as i,getExamplesPath as s,getPackageDir as l,getReadmePath as m,SHARED_SKILL_CONFIG_DIRS as c,VERSION as p}from"./config.js";import{AgentSession as d,parseSkillBlock as T}from"./core/agent-session.js";import{readStoredCredential as f}from"./core/auth-storage.js";import{BackgroundProcessManager as x,MAX_BACKGROUND_PROCESSES as C}from"./core/background-processes.js";import{calculateContextTokens as h,collectEntriesForBranchSummary as P,compact as R,DEFAULT_COMPACTION_SETTINGS as A,estimateTokens as D,findCutPoint as M,findTurnStartIndex as L,generateBranchSummary as _,generateSummary as k,generateSummaryWithUsage as y,getLastAssistantUsage as I,prepareBranchEntries as F,serializeConversation as O,shouldCompact as N}from"./core/compaction/index.js";import{createEventBus as H}from"./core/event-bus.js";import{createExtensionRuntime as b,defineTool as w,discoverAndLoadExtensions as U,ExtensionRunner as j,isBashToolResult as G,isEditToolResult as K,isFindToolResult as V,isGrepToolResult as W,isLsToolResult as z,isPowerShellToolResult as X,isReadToolResult as Y,isToolCallEventType as q,isWriteToolResult as Q,wrapRegisteredTool as J,wrapRegisteredTools as Z}from"./core/extensions/index.js";import{getHostCapabilities as ee,HOST_CAPABILITIES_ENV as oe,HOST_TOKEN_ENV as te,HOST_TOKEN_HEADER as re,HOST_URL_ENV as ne,HostCallError as ae,HostCapabilities as ie,parseHostCapabilities as se}from"./core/host-capabilities.js";import{convertToLlm as me}from"./core/messages.js";import{ModelRegistry as pe}from"./core/model-registry.js";import{resolveCliModel as de,resolveModelScopeWithDiagnostics as Te}from"./core/model-resolver.js";import{CredentialSynchronizationError as fe,ModelRuntime as Ee}from"./core/model-runtime.js";import{DefaultPackageManager as Ce}from"./core/package-manager.js";import{buildRuleSet as he,matchPermissionRules as Pe,parsePermissionRule as Re}from"./core/permissions/rules.js";import{evaluateToolPolicy as De,readAccessDenial as Me,registerPermissionAskHandler as Le}from"./core/permissions/tool-policy.js";import{describeProjectFacts as ke,detectProjectFacts as ye,projectPackageManager as Ie}from"./core/project-facts.js";import{buildProjectMap as Oe,formatProjectMapPrompt as Ne}from"./core/project-map.js";import{DefaultResourceLoader as He,loadProjectContextFiles as Be}from"./core/resource-loader.js";import{detectSandboxAvailability as we,getProcessShellSandbox as Ue,registerSandboxEscalationHandler as je,resolveSandboxPolicy as Ge,SANDBOX_ENV as Ke,ShellSandbox as Ve}from"./core/sandbox/index.js";import{AgentSessionRuntime as ze,createAgentSession as Xe,createAgentSessionFromServices as Ye,createAgentSessionRuntime as qe,createAgentSessionServices as Qe,createBashTool as Je,createCodingTools as Ze,createEditTool as $e,createFindTool as eo,createGrepTool as oo,createLsTool as to,createPowerShellTool as ro,createReadOnlyTools as no,createReadTool as ao,createWriteTool as io}from"./core/sdk.js";import{buildContextEntries as lo,buildSessionContext as mo,buildSessionProjection as co,CURRENT_SESSION_VERSION as po,getLatestCompactionEntry as So,migrateSessionEntries as To,parseSessionEntries as go,SessionManager as fo,sessionEntryToContextMessages as Eo}from"./core/session-manager.js";import{SettingsManager as Co}from"./core/settings-manager.js";import{formatSkillsForPrompt as ho,loadSkills as Po,loadSkillsFromDir as Ro}from"./core/skills.js";import{createSyntheticSourceInfo as Do}from"./core/source-info.js";import{getToolDenial as Lo}from"./core/tool-denial.js";import{generateDiffString as ko,generateUnifiedPatch as yo,normalizeForFuzzyMatch as Io}from"./core/tools/edit-diff.js";import{createBashToolDefinition as Oo,createEditToolDefinition as No,createFindToolDefinition as vo,createGrepToolDefinition as Ho,createLocalBashOperations as Bo,createLocalPowerShellOperations as bo,createLsToolDefinition as wo,createPowerShellToolDefinition as Uo,createProcessToolDefinition as jo,createReadToolDefinition as Go,createWriteToolDefinition as Ko,DEFAULT_MAX_BYTES as Vo,DEFAULT_MAX_LINES as Wo,formatSize as zo,registerShellExecutionGuard as Xo,shellExecutionRefusal as Yo,truncateHead as qo,truncateLine as Qo,truncateTail as Jo,withFileMutationQueue as Zo}from"./core/tools/index.js";import{resolveToCwd as et}from"./core/tools/path-utils.js";import{hasTrustRequiringProjectResources as tt,ProjectTrustStore as rt}from"./core/trust-manager.js";import{VIRTUAL_MODEL_STATE_ENTRY as at}from"./core/virtual-models.js";import{claimWorkspace as st,gitDirOf as lt,readWorkspaceLock as mt,releaseWorkspace as ct,STALE_AFTER_MS as pt,shellCommandDirectory as St,WORKSPACE_LOCK_FILE as dt,workspaceLockIsLive as Tt,workspaceOwnerSessionId as gt}from"./core/workspace-lock.js";import{applyShellEnvironmentPolicy as Et,DEFAULT_SHELL_ENV_EXCLUDES as xt,isDalCodeCredentialName as Ct,withoutDalCodeCredentials as ut}from"./dal/child-env.js";import{ADAPTATION_FILE as Pt,adaptationState as Rt,adaptPackage as At,applyCommunityEnv as Dt,communityEnv as Mt,ensurePackageAdapted as Lt,isAdaptablePackage as _t,readAdaptation as kt,scanHardcodedPiPaths as yt,tryEnsurePackageAdapted as It,verifyAdaptation as Ft}from"./dal/extension-compat.js";export*from"./dal/hooks/index.js";import{isHostExtensionPath as vt,markHostExtensionPaths as Ht}from"./dal/host-extensions.js";import{ENGINE_MARKET_CACHE_FILE as bt,fetchSignedMarket as wt,MARKET_SECTIONS as Ut,marketCacheDir as jt,readSignedSection as Gt,resolveMarketEndpoint as Kt,verifySignedSection as Vt}from"./dal/reviewed/market.js";import{createCodemodeExtension as zt}from"./extensions/codemode/index.js";import{createMcpExtension as Yt}from"./extensions/mcp/index.js";import{loadMcpRuntime as Qt}from"./extensions/mcp/runtime.lazy.js";import{createToolSearchExtension as Zt}from"./extensions/tool-search/index.js";import{main as er}from"./main.js";import{InteractiveMode as tr,RpcClient as rr,runPrintMode as nr,runRpcMode as ar}from"./modes/index.js";import{ArminComponent as sr,AssistantMessageComponent as lr,BashExecutionComponent as mr,BorderedLoader as cr,BranchSummaryMessageComponent as pr,CompactionSummaryMessageComponent as Sr,CustomEditor as dr,CustomMessageComponent as Tr,DynamicBorder as gr,ExtensionEditorComponent as fr,ExtensionInputComponent as Er,ExtensionSelectorComponent as xr,FooterComponent as Cr,keyHint as ur,keyText as hr,LoginDialogComponent as Pr,ModelSelectorComponent as Rr,OAuthSelectorComponent as Ar,rawKeyHint as Dr,renderDiff as Mr,SessionSelectorComponent as Lr,SettingsSelectorComponent as _r,ShowImagesSelectorComponent as kr,SkillInvocationMessageComponent as yr,ThemeSelectorComponent as Ir,ThinkingSelectorComponent as Fr,ToolExecutionComponent as Or,TreeSelectorComponent as Nr,truncateToVisualLines as vr,UserMessageComponent as Hr,UserMessageSelectorComponent as Br}from"./modes/interactive/components/index.js";import{getLanguageFromPath as wr,getMarkdownTheme as Ur,getSelectListTheme as jr,getSettingsListTheme as Gr,highlightCode as Kr,initTheme as Vr,Theme as Wr}from"./modes/interactive/theme/theme.js";import{copyToClipboard as Xr}from"./utils/clipboard.js";import{parseFrontmatter as qr,stripFrontmatter as Qr}from"./utils/frontmatter.js";import{convertToPng as Zr}from"./utils/image-convert.js";import{formatDimensionNote as en,resizeImage as on}from"./utils/image-resize.js";import{detectSupportedImageMimeTypeFromFile as rn}from"./utils/mime.js";import{openBrowser as an}from"./utils/open-browser.js";import{getPowerShellConfig as ln,getShellConfig as mn,getShellEnv as cn}from"./utils/shell.js";export{Pt as ADAPTATION_FILE,d as AgentSession,ze as AgentSessionRuntime,sr as ArminComponent,lr as AssistantMessageComponent,x as BackgroundProcessManager,mr as BashExecutionComponent,cr as BorderedLoader,pr as BranchSummaryMessageComponent,n as CONFIG_DIR_NAME,po as CURRENT_SESSION_VERSION,Sr as CompactionSummaryMessageComponent,fe as CredentialSynchronizationError,dr as CustomEditor,Tr as CustomMessageComponent,A as DEFAULT_COMPACTION_SETTINGS,Vo as DEFAULT_MAX_BYTES,Wo as DEFAULT_MAX_LINES,xt as DEFAULT_SHELL_ENV_EXCLUDES,Ce as DefaultPackageManager,He as DefaultResourceLoader,gr as DynamicBorder,bt as ENGINE_MARKET_CACHE_FILE,fr as ExtensionEditorComponent,Er as ExtensionInputComponent,j as ExtensionRunner,xr as ExtensionSelectorComponent,Cr as FooterComponent,oe as HOST_CAPABILITIES_ENV,te as HOST_TOKEN_ENV,re as HOST_TOKEN_HEADER,ne as HOST_URL_ENV,ae as HostCallError,ie as HostCapabilities,tr as InteractiveMode,Pr as LoginDialogComponent,Ut as MARKET_SECTIONS,C as MAX_BACKGROUND_PROCESSES,pe as ModelRegistry,Ee as ModelRuntime,Rr as ModelSelectorComponent,Ar as OAuthSelectorComponent,rt as ProjectTrustStore,rr as RpcClient,Ke as SANDBOX_ENV,c as SHARED_SKILL_CONFIG_DIRS,pt as STALE_AFTER_MS,fo as SessionManager,Lr as SessionSelectorComponent,Co as SettingsManager,_r as SettingsSelectorComponent,Ve as ShellSandbox,kr as ShowImagesSelectorComponent,yr as SkillInvocationMessageComponent,Wr as Theme,Ir as ThemeSelectorComponent,Fr as ThinkingSelectorComponent,Or as ToolExecutionComponent,Nr as TreeSelectorComponent,Hr as UserMessageComponent,Br as UserMessageSelectorComponent,p as VERSION,at as VIRTUAL_MODEL_STATE_ENTRY,dt as WORKSPACE_LOCK_FILE,At as adaptPackage,Rt as adaptationState,Dt as applyCommunityEnv,Et as applyShellEnvironmentPolicy,lo as buildContextEntries,Oe as buildProjectMap,he as buildRuleSet,mo as buildSessionContext,co as buildSessionProjection,h as calculateContextTokens,st as claimWorkspace,P as collectEntriesForBranchSummary,Mt as communityEnv,R as compact,me as convertToLlm,Zr as convertToPng,Xr as copyToClipboard,Xe as createAgentSession,Ye as createAgentSessionFromServices,qe as createAgentSessionRuntime,Qe as createAgentSessionServices,Je as createBashTool,Oo as createBashToolDefinition,zt as createCodemodeExtension,Ze as createCodingTools,$e as createEditTool,No as createEditToolDefinition,H as createEventBus,b as createExtensionRuntime,eo as createFindTool,vo as createFindToolDefinition,oo as createGrepTool,Ho as createGrepToolDefinition,Bo as createLocalBashOperations,bo as createLocalPowerShellOperations,to as createLsTool,wo as createLsToolDefinition,Yt as createMcpExtension,ro as createPowerShellTool,Uo as createPowerShellToolDefinition,jo as createProcessToolDefinition,no as createReadOnlyTools,ao as createReadTool,Go as createReadToolDefinition,Do as createSyntheticSourceInfo,Zt as createToolSearchExtension,io as createWriteTool,Ko as createWriteToolDefinition,w as defineTool,ke as describeProjectFacts,ye as detectProjectFacts,we as detectSandboxAvailability,rn as detectSupportedImageMimeTypeFromFile,U as discoverAndLoadExtensions,Lt as ensurePackageAdapted,D as estimateTokens,De as evaluateToolPolicy,wt as fetchSignedMarket,M as findCutPoint,L as findTurnStartIndex,en as formatDimensionNote,Ne as formatProjectMapPrompt,zo as formatSize,ho as formatSkillsForPrompt,_ as generateBranchSummary,ko as generateDiffString,k as generateSummary,y as generateSummaryWithUsage,yo as generateUnifiedPatch,a as getAgentDir,i as getDocsPath,s as getExamplesPath,ee as getHostCapabilities,wr as getLanguageFromPath,I as getLastAssistantUsage,So as getLatestCompactionEntry,Ur as getMarkdownTheme,l as getPackageDir,ln as getPowerShellConfig,Ue as getProcessShellSandbox,m as getReadmePath,jr as getSelectListTheme,Gr as getSettingsListTheme,mn as getShellConfig,cn as getShellEnv,Lo as getToolDenial,lt as gitDirOf,tt as hasTrustRequiringProjectResources,Kr as highlightCode,Vr as initTheme,_t as isAdaptablePackage,G as isBashToolResult,Ct as isDalCodeCredentialName,K as isEditToolResult,V as isFindToolResult,W as isGrepToolResult,vt as isHostExtensionPath,z as isLsToolResult,X as isPowerShellToolResult,Y as isReadToolResult,q as isToolCallEventType,Q as isWriteToolResult,ur as keyHint,hr as keyText,Qt as loadMcpRuntime,Be as loadProjectContextFiles,Po as loadSkills,Ro as loadSkillsFromDir,er as main,Ht as markHostExtensionPaths,jt as marketCacheDir,Pe as matchPermissionRules,To as migrateSessionEntries,Io as normalizeForFuzzyMatch,an as openBrowser,t as parseArgs,qr as parseFrontmatter,se as parseHostCapabilities,Re as parsePermissionRule,go as parseSessionEntries,T as parseSkillBlock,F as prepareBranchEntries,Ie as projectPackageManager,Dr as rawKeyHint,Me as readAccessDenial,kt as readAdaptation,Gt as readSignedSection,f as readStoredCredential,mt as readWorkspaceLock,Le as registerPermissionAskHandler,je as registerSandboxEscalationHandler,Xo as registerShellExecutionGuard,ct as releaseWorkspace,Mr as renderDiff,on as resizeImage,de as resolveCliModel,Kt as resolveMarketEndpoint,Te as resolveModelScopeWithDiagnostics,Ge as resolveSandboxPolicy,et as resolveToCwd,nr as runPrintMode,ar as runRpcMode,yt as scanHardcodedPiPaths,O as serializeConversation,Eo as sessionEntryToContextMessages,St as shellCommandDirectory,Yo as shellExecutionRefusal,N as shouldCompact,Qr as stripFrontmatter,qo as truncateHead,Qo as truncateLine,Jo as truncateTail,vr as truncateToVisualLines,It as tryEnsurePackageAdapted,Ft as verifyAdaptation,Vt as verifySignedSection,Zo as withFileMutationQueue,ut as withoutDalCodeCredentials,Tt as workspaceLockIsLive,gt as workspaceOwnerSessionId,J as wrapRegisteredTool,Z as wrapRegisteredTools};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-advisor",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "advisor: the model asks another strong model to review its current plan and point out risks. Adapted from @juicesharp/rpiv-advisor 2.13.8 (MIT).",
6
6
  "license": "MIT",
@@ -20,8 +20,8 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.43",
24
- "@dalcode/dal-router": "1.0.43",
23
+ "@dalcode/dal-pi-kit": "1.0.44",
24
+ "@dalcode/dal-router": "1.0.44",
25
25
  "typebox": "1.3.27"
26
26
  },
27
27
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-awake",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Keeps the computer from going to sleep while a long agent run is in progress, and lets it sleep again when the run ends. Adapted from @narumitw/pi-caffeinate (MIT).",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.43"
21
+ "@dalcode/dal-pi-kit": "1.0.44"
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-bridge",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
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.43",
21
+ "@dalcode/dal-pi-kit": "1.0.44",
22
22
  "typebox": "1.3.7"
23
23
  },
24
24
  "peerDependencies": {
@@ -1 +1 @@
1
- var j=Object.defineProperty;var A=(o,F)=>j(o,"name",{value:F,configurable:!0});var H=Object.defineProperty,d=A((o,F)=>H(o,"name",{value:F,configurable:!0}),"d");import{t}from"@dalcode/dal-pi-kit";import{getProcessShellSandbox as R,registerPermissionAskHandler as q,registerSandboxEscalationHandler as V}from"@earendil-works/pi-coding-agent";import{Type as m}from"typebox";import{AskUserInputError as W,askUserSchema as G,buildAskUserRequest as z,describeAnswers as J,THUMBNAIL_CHANNEL as K}from"./ask-user.js";import{askUserTimeoutMs as Q,BridgeClient as X,planTimeoutMs as Y,readBridgeConfig as Z,readSubagentAttribution as uu}from"./client.js";const eu=m.Object({goal:m.String({description:t("\u8FD9\u4E2A\u8BA1\u5212\u8981\u8FBE\u6210\u4EC0\u4E48\uFF0C\u4E00\u53E5\u8BDD\u8BF4\u660E")}),reasoning:m.Optional(m.String({description:t("\u4E3A\u4EC0\u4E48\u9009\u8FD9\u4E2A\u65B9\u6848")})),steps:m.Array(m.Object({title:m.String({description:t("\u8FD9\u4E00\u6B65\u505A\u4EC0\u4E48")}),description:m.Optional(m.String({description:t("\u8FD9\u4E00\u6B65\u7684\u7EC6\u8282")}))}),{description:t("\u6309\u987A\u5E8F\u6392\u5217\u7684\u6267\u884C\u6B65\u9AA4")})}),tu=new Set(["read","grep","ripgrep","find","fd","ls","glob","todo_read","todo","lsp","terminal_read","review_report"]),ou=new Set(["read","grep","ripgrep","find","fd","ls","glob","lsp"]),S="DALCODE_BRIDGE_EVALUATE_READ_TOOLS",ru="submit_plan",I="ask_user";function x(o){return o.scope==="session"?"session":"once"}A(x,"ee"),d(x,"escalationScope");function k(o){const F=o.grant,p=d(l=>Array.isArray(l)?l.filter(E=>typeof E=="string"&&E.length>0):[],"list"),n=p(F?.allowDomains),s=p(F?.allowWrite);return{approved:!0,scope:x(o),...n.length>0||s.length>0?{grant:{allowDomains:n,allowWrite:s}}:{}}}A(k,"h"),d(k,"escalationApproval");function _(o){const F=o.input;for(const p of["command","file_path","path","filePath"]){const n=F[p];if(typeof n=="string"&&n.length>0)return n}}A(_,"R"),d(_,"ruleContentFor");function N(o,F){const p=o.input,n=o.toolName==="process";if(o.toolName!=="bash"&&!(n&&p.action==="start")||typeof p.command!="string"||p.command.length===0)return;const s=R(),l=s?.planNetworkEscalation({command:p.command,cwd:F.cwd});if(!(!s||!l))return{toolCallId:o.toolCallId,toolName:o.toolName,command:p.command,cwd:F.cwd,level:s.level,mode:"allow",justification:l.justification,allowDomains:l.allow_domains,allowWrite:[],background:n,trigger:l.trigger}}A(N,"ne"),d(N,"plannedNetworkEscalation");let g,T=!1,B,P=!1;function L(o,F){const p=Z();if(!p)return;const n=new X(p,F),s=uu();function l(u){const e=u.sessionManager.getSessionId();return s?{sessionId:s.parentSessionId,subagent:{id:s.subagentId,sessionId:e,...s.parentTaskId?{parentTaskId:s.parentTaskId}:{},...s.parentSubagentId?{parentSubagentId:s.parentSubagentId}:{},...s.label?{label:s.label}:{}}}:{sessionId:e}}A(l,"c"),d(l,"caller");let E,b=0;function f(u){const e=u.model;return{provider:e?.provider??"unknown",model:e?.id??e?.name??"unknown"}}A(f,"_"),d(f,"describeModel");const w=new Map,C=new Set,O=process.env[S]==="1";o.on("tool_call",async(u,e)=>{const r=ou.has(u.toolName);if((r?!O:tu.has(u.toolName))||u.toolName===ru||u.toolName===I)return;const i=u.input.sandbox_escalation,c=i?void 0:N(u,e),a=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:u.input,ruleContent:_(u),...i||c?{category:"sandbox_escalation"}:{},...c?{sandboxEscalation:c}:{},...r?{readOnly:!0}:{}});if(!a)return{block:!0,reason:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")};if(a.decision==="deny")return{block:!0,reason:a.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")};(i||c)&&w.set(u.toolCallId,k(a)),C.add(u.toolCallId),C.size>1e3&&C.delete(C.values().next().value)});const y=d(async(u,e)=>{if(C.delete(u.toolCallId))return{approved:!0};const r=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:u.input,ruleContent:_({input:u.input}),category:"permission_rule",rule:u.rule,ruleSource:u.source});return r?r.decision==="allow"?{approved:!0}:{approved:!1,message:r.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveRule");B=y,P||(q((u,e)=>B?.(u,e)),P=!0);const h=d(async(u,e)=>{const r=w.get(u.toolCallId);if(r)return w.delete(u.toolCallId),r;if(!e)return;const i=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:{command:u.command},ruleContent:u.command,category:"sandbox_escalation",sandboxEscalation:u});return i?i.decision==="allow"?k(i):{approved:!1,message:i.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveEscalation");g=h,T||(V((u,e)=>g?.(u,e)),T=!0),o.on("session_shutdown",()=>{g===h&&(g=void 0),B===y&&(B=void 0)}),o.on("after_provider_response",(u,e)=>{u.status>=400?E={...f(e),reason:`HTTP ${u.status}`}:(E=void 0,b=0)}),o.on("before_provider_request",async(u,e)=>{if(!E)return;const r=f(e);if(r.provider===E.provider&&r.model===E.model)return;b+=1;const i={provider:E.provider,model:E.model},c=E.reason;E=void 0,await n.post("/api/internal/pi-bridge/provider-fallback",{...l(e),from:i,to:r,reason:c,attempt:b,blocked:!0});const a=new Error(t("dal-bridge\uFF1A\u8BF7\u6C42\u5931\u8D25\u540E\u4E0D\u5141\u8BB8\u81EA\u52A8\u6362\u6A21\u578B\u3002")+` ${i.provider}/${i.model} \u2192 ${r.provider}/${r.model} (${c})`);throw a.name="ProviderSwapAborted",a}),o.registerTool({name:"submit_plan",label:t("\u63D0\u4EA4\u8BA1\u5212\u5F85\u5BA1\u6279"),description:t(t("\u5728\u52A8\u624B\u6539\u52A8\u4E4B\u524D\uFF0C\u628A\u8BA1\u5212\u63D0\u4EA4\u7ED9\u7528\u6237\u5BA1\u6279\u3002\u8FD4\u56DE\u662F\u5426\u7EE7\u7EED\u6267\u884C\uFF0C\u4EE5\u53CA\u7528\u6237\u7ED9\u51FA\u7684\u53CD\u9988\u3002")+t("\u5F53\u4EFB\u52A1\u662F\u591A\u6B65\u9AA4\u7684\u3001\u6216\u4F1A\u6539\u52A8\u591A\u4E2A\u6587\u4EF6\u65F6\u4F7F\u7528\u3002")),promptSnippet:t("submit_plan - \u591A\u6B65\u9AA4\u4EFB\u52A1\u52A8\u624B\u524D\u5148\u63D0\u4EA4\u8BA1\u5212\u5F85\u7528\u6237\u5BA1\u6279"),parameters:eu,execute:d(async(u,e,r,i,c)=>{const a=await n.post("/api/internal/pi-bridge/plan",{...l(c),goal:e.goal,reasoning:e.reasoning,steps:e.steps},{timeoutMs:Y()});return!a||a.decision==="cancel"?{content:[{type:"text",text:a?.feedback?`Plan not approved. User feedback: ${a.feedback}`:"Plan not approved. Stop and wait for further instructions."}],details:{approved:!1,...a?.feedback?{feedback:a.feedback}:{}}}:{content:[{type:"text",text:"Plan approved. Proceed with the steps."}],details:{approved:!0}}},"execute")});const U=d((u,e)=>{let r;return o.events.emit(K,{ref:u,...e!==void 0?{title:e}:{},reply:d(i=>{r=i},"reply")}),r},"resolveThumbnail");o.registerTool({name:I,label:t("\u8BE2\u95EE\u7528\u6237"),description:t("\u52A8\u624B\u505A PPT\u3001\u6587\u6863\u3001\u8868\u683C\u3001\u9875\u9762\u4E4B\u524D\uFF0C\u7528\u4E00\u5F20\u5361\u7247\u5411\u7528\u6237\u786E\u8BA4\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF09\u3002\u9898\u578B\uFF1Achoice \u9009\u9879\uFF08\u53EF\u5E26\u7F29\u7565\u56FE\uFF09\u3001swatch \u914D\u8272\u3001outline \u53EF\u6392\u5E8F\u5927\u7EB2\u3001slider \u6570\u503C\u3001text \u81EA\u7531\u6587\u672C\u3002\u6BCF\u9898\u90FD\u8981\u6709\u63A8\u8350\u9879\u3002"),promptSnippet:t("ask_user - \u5F00\u5DE5\u524D\u7528\u4E00\u5F20\u5361\u7247\u786E\u8BA4\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF0C\u6BCF\u9898\u6709\u63A8\u8350\u9879\uFF09"),promptGuidelines:[t("ask_user \u53EA\u5728\u5F00\u5DE5\u524D\u95EE\u4E00\u6B21\uFF0C\u4E00\u8F6E\u6700\u591A 3 \u9898\uFF1B\u540C\u4E00\u4EFB\u52A1\u4E4B\u540E\u4E0D\u518D\u8FFD\u95EE\uFF0C\u9664\u975E\u7528\u6237\u4E3B\u52A8\u8981\u6C42\u3002"),t("\u53EA\u95EE\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u51B3\u5B9A\uFF08\u53D7\u4F17/\u7528\u9014\u3001\u98CE\u683C\u6216\u4E3B\u9898\u3001\u7BC7\u5E45\u3001\u5927\u7EB2\u987A\u5E8F\uFF09\uFF1B\u80FD\u4ECE\u7528\u6237\u539F\u8BDD\u3001\u9644\u4EF6\u6216\u9879\u76EE\u6587\u4EF6\u63A8\u65AD\u51FA\u7684\u4E0D\u95EE\u3002"),t("\u7528\u6237\u8BF4\u4E86\u300C\u76F4\u63A5\u505A / \u4F60\u51B3\u5B9A / \u5FEB\u901F\u51FA\u4E00\u7248\u300D\uFF0C\u6216\u662F\u5728\u4FEE\u6539\u5DF2\u6709\u6587\u4EF6\uFF08\u5E26\u5B9A\u4F4D\u3001\u300C\u628A\u7B2C 3 \u9875\u6539\u6210\u2026\u300D\uFF09\u65F6\uFF0C\u4E0D\u8981\u8C03\u7528 ask_user\u3002"),t("\u6BCF\u9898\u90FD\u6807\u51FA\u63A8\u8350\u9879\uFF08recommended\uFF09\uFF1B\u98CE\u683C\u9898\u4F18\u5148\u7528 thumbnail \u7F29\u7565\u56FE\uFF08theme:\u2026 / page:\u2026 / doc:\u2026\uFF09\uFF0C\u914D\u8272\u7528 swatch\u3002"),t("\u7528\u6237\u8DF3\u8FC7\u65F6\u6309\u63A8\u8350\u9879\u7EE7\u7EED\uFF0C\u5E76\u5728\u56DE\u590D\u91CC\u7528\u4E00\u53E5\u8BDD\u8BF4\u660E\u7528\u4E86\u54EA\u4E9B\u63A8\u8350\u9879\u3002")],parameters:G,execute:d(async(u,e,r,i,c)=>{let a;try{a=z(e,c.cwd,U)}catch(v){throw v instanceof W?new Error(`ask_user: ${v.message}`):v}const D=await n.post("/api/internal/pi-bridge/ask-user",{...l(c),...a},{timeoutMs:Q()});if(!D||D.cancelled)return{content:[{type:"text",text:"User did not answer. Stop and wait for further instructions."}],details:{answered:!1,request:a}};const{text:M,skipped:$}=J(a,D);return{content:[{type:"text",text:M}],details:{answered:!0,answers:D.answers??{},...D.structured?{structured:D.structured}:{},...D.summary?{summary:D.summary}:{},skipped:$,request:a}}},"execute")})}A(L,"te"),d(L,"default");export{S as EVALUATE_READS_ENV,L as default};
1
+ var j=Object.defineProperty;var A=(o,F)=>j(o,"name",{value:F,configurable:!0});var H=Object.defineProperty,d=A((o,F)=>H(o,"name",{value:F,configurable:!0}),"d");import{t}from"@dalcode/dal-pi-kit";import{getProcessShellSandbox as R,registerPermissionAskHandler as q,registerSandboxEscalationHandler as V}from"@earendil-works/pi-coding-agent";import{Type as m}from"typebox";import{AskUserInputError as W,askUserSchema as G,buildAskUserRequest as z,describeAnswers as J,THUMBNAIL_CHANNEL as K}from"./ask-user.js";import{askUserTimeoutMs as Q,BridgeClient as X,planTimeoutMs as Y,readBridgeConfig as Z,readSubagentAttribution as uu}from"./client.js";const eu=m.Object({goal:m.String({description:t("\u8FD9\u4E2A\u8BA1\u5212\u8981\u8FBE\u6210\u4EC0\u4E48\uFF0C\u4E00\u53E5\u8BDD\u8BF4\u660E")}),reasoning:m.Optional(m.String({description:t("\u4E3A\u4EC0\u4E48\u9009\u8FD9\u4E2A\u65B9\u6848")})),steps:m.Array(m.Object({title:m.String({description:t("\u8FD9\u4E00\u6B65\u505A\u4EC0\u4E48")}),description:m.Optional(m.String({description:t("\u8FD9\u4E00\u6B65\u7684\u7EC6\u8282")}))}),{description:t("\u6309\u987A\u5E8F\u6392\u5217\u7684\u6267\u884C\u6B65\u9AA4")})}),tu=new Set(["read","grep","ripgrep","find","fd","ls","glob","todo_read","todo","lsp","terminal_read","review_report"]),ou=new Set(["read","grep","ripgrep","find","fd","ls","glob","lsp"]),I="DALCODE_BRIDGE_EVALUATE_READ_TOOLS",ru="submit_plan",S="ask_user";function x(o){return o.scope==="session"?"session":"once"}A(x,"ee"),d(x,"escalationScope");function k(o){const F=o.grant,p=d(l=>Array.isArray(l)?l.filter(E=>typeof E=="string"&&E.length>0):[],"list"),n=p(F?.allowDomains),s=p(F?.allowWrite);return{approved:!0,scope:x(o),...n.length>0||s.length>0?{grant:{allowDomains:n,allowWrite:s}}:{}}}A(k,"h"),d(k,"escalationApproval");function _(o){const F=o.input;for(const p of["command","file_path","path","filePath"]){const n=F[p];if(typeof n=="string"&&n.length>0)return n}}A(_,"R"),d(_,"ruleContentFor");function N(o,F){const p=o.input,n=o.toolName==="process";if(o.toolName!=="bash"&&!(n&&p.action==="start")||typeof p.command!="string"||p.command.length===0)return;const s=R(),l=s?.planNetworkEscalation({command:p.command,cwd:F.cwd});if(!(!s||!l))return{toolCallId:o.toolCallId,toolName:o.toolName,command:p.command,cwd:F.cwd,level:s.level,mode:"allow",justification:l.justification,allowDomains:l.allow_domains,allowWrite:[],background:n,trigger:l.trigger}}A(N,"ne"),d(N,"plannedNetworkEscalation");let g,T=!1,B,P=!1;function L(o,F){const p=Z();if(!p)return;const n=new X(p,F),s=uu();function l(u){const e=u.sessionManager.getSessionId();return s?{sessionId:s.parentSessionId,subagent:{id:s.subagentId,sessionId:e,...s.parentTaskId?{parentTaskId:s.parentTaskId}:{},...s.parentSubagentId?{parentSubagentId:s.parentSubagentId}:{},...s.label?{label:s.label}:{}}}:{sessionId:e}}A(l,"c"),d(l,"caller");let E,b=0;function f(u){const e=u.model;return{provider:e?.provider??"unknown",model:e?.id??e?.name??"unknown"}}A(f,"_"),d(f,"describeModel");const w=new Map,C=new Set,O=process.env[I]==="1";o.on("tool_call",async(u,e)=>{const r=ou.has(u.toolName);if((r?!O:tu.has(u.toolName))||u.toolName===ru||u.toolName===S)return;const i=u.input.sandbox_escalation,c=i?void 0:N(u,e),a=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:u.input,ruleContent:_(u),...i||c?{category:"sandbox_escalation"}:{},...c?{sandboxEscalation:c}:{},...r?{readOnly:!0}:{}});if(!a)return{block:!0,reason:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002"),denied:{source:"bridge",ruleId:"unreachable"}};if(a.decision==="deny")return{block:!0,reason:a.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002"),denied:{source:"bridge"}};(i||c)&&w.set(u.toolCallId,k(a)),C.add(u.toolCallId),C.size>1e3&&C.delete(C.values().next().value)});const y=d(async(u,e)=>{if(C.delete(u.toolCallId))return{approved:!0};const r=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:u.input,ruleContent:_({input:u.input}),category:"permission_rule",rule:u.rule,ruleSource:u.source});return r?r.decision==="allow"?{approved:!0}:{approved:!1,message:r.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveRule");B=y,P||(q((u,e)=>B?.(u,e)),P=!0);const h=d(async(u,e)=>{const r=w.get(u.toolCallId);if(r)return w.delete(u.toolCallId),r;if(!e)return;const i=await n.post("/api/internal/pi-bridge/permission",{...l(e),toolName:u.toolName,toolInput:{command:u.command},ruleContent:u.command,category:"sandbox_escalation",sandboxEscalation:u});return i?i.decision==="allow"?k(i):{approved:!1,message:i.message??t("dal-bridge\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\u8BE5\u64CD\u4F5C\u3002")}:{approved:!1,message:t("dal-bridge\uFF1A\u65E0\u6CD5\u8054\u7CFB DAL Code \u53D6\u5F97\u6388\u6743\uFF0C\u5DF2\u62D2\u7EDD\u6267\u884C\u3002")}},"approveEscalation");g=h,T||(V((u,e)=>g?.(u,e)),T=!0),o.on("session_shutdown",()=>{g===h&&(g=void 0),B===y&&(B=void 0)}),o.on("after_provider_response",(u,e)=>{u.status>=400?E={...f(e),reason:`HTTP ${u.status}`}:(E=void 0,b=0)}),o.on("before_provider_request",async(u,e)=>{if(!E)return;const r=f(e);if(r.provider===E.provider&&r.model===E.model)return;b+=1;const i={provider:E.provider,model:E.model},c=E.reason;E=void 0,await n.post("/api/internal/pi-bridge/provider-fallback",{...l(e),from:i,to:r,reason:c,attempt:b,blocked:!0});const a=new Error(t("dal-bridge\uFF1A\u8BF7\u6C42\u5931\u8D25\u540E\u4E0D\u5141\u8BB8\u81EA\u52A8\u6362\u6A21\u578B\u3002")+` ${i.provider}/${i.model} \u2192 ${r.provider}/${r.model} (${c})`);throw a.name="ProviderSwapAborted",a}),o.registerTool({name:"submit_plan",label:t("\u63D0\u4EA4\u8BA1\u5212\u5F85\u5BA1\u6279"),description:t(t("\u5728\u52A8\u624B\u6539\u52A8\u4E4B\u524D\uFF0C\u628A\u8BA1\u5212\u63D0\u4EA4\u7ED9\u7528\u6237\u5BA1\u6279\u3002\u8FD4\u56DE\u662F\u5426\u7EE7\u7EED\u6267\u884C\uFF0C\u4EE5\u53CA\u7528\u6237\u7ED9\u51FA\u7684\u53CD\u9988\u3002")+t("\u5F53\u4EFB\u52A1\u662F\u591A\u6B65\u9AA4\u7684\u3001\u6216\u4F1A\u6539\u52A8\u591A\u4E2A\u6587\u4EF6\u65F6\u4F7F\u7528\u3002")),promptSnippet:t("submit_plan - \u591A\u6B65\u9AA4\u4EFB\u52A1\u52A8\u624B\u524D\u5148\u63D0\u4EA4\u8BA1\u5212\u5F85\u7528\u6237\u5BA1\u6279"),parameters:eu,execute:d(async(u,e,r,i,c)=>{const a=await n.post("/api/internal/pi-bridge/plan",{...l(c),goal:e.goal,reasoning:e.reasoning,steps:e.steps},{timeoutMs:Y()});return!a||a.decision==="cancel"?{content:[{type:"text",text:a?.feedback?`Plan not approved. User feedback: ${a.feedback}`:"Plan not approved. Stop and wait for further instructions."}],details:{approved:!1,...a?.feedback?{feedback:a.feedback}:{}}}:{content:[{type:"text",text:"Plan approved. Proceed with the steps."}],details:{approved:!0}}},"execute")});const U=d((u,e)=>{let r;return o.events.emit(K,{ref:u,...e!==void 0?{title:e}:{},reply:d(i=>{r=i},"reply")}),r},"resolveThumbnail");o.registerTool({name:S,label:t("\u8BE2\u95EE\u7528\u6237"),description:t("\u52A8\u624B\u505A PPT\u3001\u6587\u6863\u3001\u8868\u683C\u3001\u9875\u9762\u4E4B\u524D\uFF0C\u7528\u4E00\u5F20\u5361\u7247\u5411\u7528\u6237\u786E\u8BA4\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF09\u3002\u9898\u578B\uFF1Achoice \u9009\u9879\uFF08\u53EF\u5E26\u7F29\u7565\u56FE\uFF09\u3001swatch \u914D\u8272\u3001outline \u53EF\u6392\u5E8F\u5927\u7EB2\u3001slider \u6570\u503C\u3001text \u81EA\u7531\u6587\u672C\u3002\u6BCF\u9898\u90FD\u8981\u6709\u63A8\u8350\u9879\u3002"),promptSnippet:t("ask_user - \u5F00\u5DE5\u524D\u7528\u4E00\u5F20\u5361\u7247\u786E\u8BA4\u5173\u952E\u51B3\u5B9A\uFF08\u6700\u591A 3 \u9898\uFF0C\u6BCF\u9898\u6709\u63A8\u8350\u9879\uFF09"),promptGuidelines:[t("ask_user \u53EA\u5728\u5F00\u5DE5\u524D\u95EE\u4E00\u6B21\uFF0C\u4E00\u8F6E\u6700\u591A 3 \u9898\uFF1B\u540C\u4E00\u4EFB\u52A1\u4E4B\u540E\u4E0D\u518D\u8FFD\u95EE\uFF0C\u9664\u975E\u7528\u6237\u4E3B\u52A8\u8981\u6C42\u3002"),t("\u53EA\u95EE\u4F1A\u6539\u53D8\u4EA7\u51FA\u7684\u51B3\u5B9A\uFF08\u53D7\u4F17/\u7528\u9014\u3001\u98CE\u683C\u6216\u4E3B\u9898\u3001\u7BC7\u5E45\u3001\u5927\u7EB2\u987A\u5E8F\uFF09\uFF1B\u80FD\u4ECE\u7528\u6237\u539F\u8BDD\u3001\u9644\u4EF6\u6216\u9879\u76EE\u6587\u4EF6\u63A8\u65AD\u51FA\u7684\u4E0D\u95EE\u3002"),t("\u7528\u6237\u8BF4\u4E86\u300C\u76F4\u63A5\u505A / \u4F60\u51B3\u5B9A / \u5FEB\u901F\u51FA\u4E00\u7248\u300D\uFF0C\u6216\u662F\u5728\u4FEE\u6539\u5DF2\u6709\u6587\u4EF6\uFF08\u5E26\u5B9A\u4F4D\u3001\u300C\u628A\u7B2C 3 \u9875\u6539\u6210\u2026\u300D\uFF09\u65F6\uFF0C\u4E0D\u8981\u8C03\u7528 ask_user\u3002"),t("\u6BCF\u9898\u90FD\u6807\u51FA\u63A8\u8350\u9879\uFF08recommended\uFF09\uFF1B\u98CE\u683C\u9898\u4F18\u5148\u7528 thumbnail \u7F29\u7565\u56FE\uFF08theme:\u2026 / page:\u2026 / doc:\u2026\uFF09\uFF0C\u914D\u8272\u7528 swatch\u3002"),t("\u7528\u6237\u8DF3\u8FC7\u65F6\u6309\u63A8\u8350\u9879\u7EE7\u7EED\uFF0C\u5E76\u5728\u56DE\u590D\u91CC\u7528\u4E00\u53E5\u8BDD\u8BF4\u660E\u7528\u4E86\u54EA\u4E9B\u63A8\u8350\u9879\u3002")],parameters:G,execute:d(async(u,e,r,i,c)=>{let a;try{a=z(e,c.cwd,U)}catch(v){throw v instanceof W?new Error(`ask_user: ${v.message}`):v}const D=await n.post("/api/internal/pi-bridge/ask-user",{...l(c),...a},{timeoutMs:Q()});if(!D||D.cancelled)return{content:[{type:"text",text:"User did not answer. Stop and wait for further instructions."}],details:{answered:!1,request:a}};const{text:M,skipped:$}=J(a,D);return{content:[{type:"text",text:M}],details:{answered:!0,answers:D.answers??{},...D.structured?{structured:D.structured}:{},...D.summary?{summary:D.summary}:{},skipped:$,request:a}}},"execute")})}A(L,"te"),d(L,"default");export{I as EVALUATE_READS_ENV,L as default};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-capabilities",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Capability center for DAL: switches on the reviewed MCP connectors, skills and engine packages a task needs (installed automatically from the signed DAL market), with /capabilities to list, disable and enable them.",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  ]
24
24
  },
25
25
  "dependencies": {
26
- "@dalcode/dal-mcp": "1.0.43",
27
- "@dalcode/dal-pi-kit": "1.0.43",
28
- "@dalcode/deepailab": "1.0.43"
26
+ "@dalcode/dal-mcp": "1.0.44",
27
+ "@dalcode/dal-pi-kit": "1.0.44",
28
+ "@dalcode/deepailab": "1.0.44"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-compat",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Claude Code compatibility: the user's and project's .claude/rules/ and .claude/CLAUDE.md apply in DAL. Grown from the claude-rules extension example.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.43",
21
+ "@dalcode/dal-pi-kit": "1.0.44",
22
22
  "minimatch": "10.2.6"
23
23
  },
24
24
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-dap",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Debugger for DAL: breakpoints, stepping, call stacks and variables in Node.js and Python programs over the Debug Adapter Protocol, installing the adapter on first use. The DAP client is adapted from oh-my-pi's src/dap (MIT).",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  ]
25
25
  },
26
26
  "dependencies": {
27
- "@dalcode/dal-pi-kit": "1.0.43",
27
+ "@dalcode/dal-pi-kit": "1.0.44",
28
28
  "typebox": "1.3.27"
29
29
  },
30
30
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-gateway",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
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/deepailab": "1.0.43"
20
+ "@dalcode/deepailab": "1.0.44"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-goal",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Goal mode for DAL: /goal keeps the agent working on one objective until it is verified complete, with token and continuation limits. Adapted from @narumitw/pi-goal 0.54.11 (MIT, narumiruna); the independent completion check adapts pi-goal-x 0.32.3 (MIT, Lucas).",
6
6
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  ]
22
22
  },
23
23
  "dependencies": {
24
- "@dalcode/dal-pi-kit": "1.0.43",
25
- "@dalcode/dal-subagent": "1.0.43",
24
+ "@dalcode/dal-pi-kit": "1.0.44",
25
+ "@dalcode/dal-subagent": "1.0.44",
26
26
  "typebox": "1.3.27"
27
27
  },
28
28
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-guard",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -20,9 +20,9 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.43",
24
- "@dalcode/dal-bridge": "1.0.43",
25
- "@dalcode/dal-halo": "1.0.43"
23
+ "@dalcode/dal-pi-kit": "1.0.44",
24
+ "@dalcode/dal-bridge": "1.0.44",
25
+ "@dalcode/dal-halo": "1.0.44"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,2 +1,2 @@
1
- var J=Object.defineProperty;var d=(u,a)=>J(u,"name",{value:a,configurable:!0});var K=Object.defineProperty,i=d((u,a)=>K(u,"name",{value:a,configurable:!0}),"l");import{realpathSync as G}from"node:fs";import{basename as Z,dirname as Q,isAbsolute as X,join as Y,relative as uu,resolve as eu,sep as au}from"node:path";import{readBridgeConfig as p}from"@dalcode/dal-bridge/client";import{getOwnTty as ou,requestHaloApproval as tu}from"@dalcode/dal-halo";import{hasChosenLanguage as su,t as e}from"@dalcode/dal-pi-kit";import{DAL_HOOK_NOTIFICATION_CHANNEL as ru,getAgentDir as D,registerSandboxEscalationHandler as nu,resolveToCwd as iu,shellExecutionRefusal as lu}from"@earendil-works/pi-coding-agent";import{DAL_CO_AUTHOR as O,foreignAttributionInMessageFile as du,rewriteCommitAttribution as Fu}from"./attribution.js";import{credentialBlockReason as cu,namesDalCredential as Eu,readsDalSecretCopy as Au,redactContent as mu,secretCopyBlockReason as fu}from"./credentials.js";import{exportGuardMode as Cu,saveGuardMode as P,shouldAskGuardMode as pu,startupGuardMode as Du}from"./mode.js";import{wrongPackageManager as Bu}from"./package-manager.js";import{reviewBashCommand as gu}from"./review.js";import{createWorkspaceGate as hu}from"./workspace.js";import{DAL_CO_AUTHOR as bu,foreignAttributionInMessageFile as vu,foreignCoAuthors as yu,isGitCommit as wu,rewriteCommitAttribution as $u}from"./attribution.js";import{dalSecretValues as ku,fileHoldsDalSecret as _u,namesDalCredential as Iu,REDACTED as Mu,readsDalSecretCopy as Nu,redactContent as Su,redactDalSecrets as Gu,shellPathCandidates as Ou}from"./credentials.js";import{GUARD_MODE_ENV as Pu,savedGuardMode as Ru,saveGuardMode as Tu,shouldAskGuardMode as xu,startupGuardMode as Uu}from"./mode.js";import{installingManager as ju,wrongPackageManager as Hu}from"./package-manager.js";import{reviewBashCommand as Lu,suspicionFor as zu}from"./review.js";import{createWorkspaceGate as Wu,modifiedDirectory as Vu}from"./workspace.js";const R=new Set;function T(u,a){if(u.toolName!=="bash"&&u.toolName!=="powershell")return;const o=u.input;if(typeof o.command!="string")return;const t=du(o.command,a);if(t)return{block:!0,reason:e("dal-guard\uFF1A\u63D0\u4EA4\u8BF4\u660E\u6587\u4EF6 {file} \u628A\u53E6\u4E00\u4E2A\u4EA7\u54C1\u7684\u52A9\u624B\uFF08Claude\u3001Codex\u3001Copilot \u7B49\uFF09\u5199\u6210\u4E86\u5171\u540C\u4F5C\u8005\u3002\u4F60\u662F DAL Code\uFF1A\u628A\u90A3\u884C\u6539\u6210 {trailer} \u6216\u5220\u6389\uFF0C\u518D\u63D0\u4EA4\u3002").replace("{file}",t).replace("{trailer}",O)};const s=Fu(o.command);s!==void 0&&(o.command=s,R.add(u.toolCallId))}d(T,"ce"),i(T,"checkCommitAttribution");function v(u){try{return G(u)}catch{try{return Y(G(Q(u)),Z(u))}catch{return u}}}d(v,"G"),i(v,"realPathBestEffort");const A=i(u=>a=>u.test(a),"has"),qu=[{id:"sudo",level:"high",label:e("\u7279\u6743\u6267\u884C\uFF08sudo/doas\uFF09"),test:A(/(^|[;&|\n]\s*)(sudo|doas)\s/)},{id:"force-push",level:"high",label:e("\u5F3A\u5236\u63A8\u9001\u5C06\u6539\u5199\u8FDC\u7A0B\u5386\u53F2"),test:A(/git\s+push\b[^;&|]*(--force\b|--force-with-lease\b|\s-f\b)/)},{id:"hard-reset",level:"high",label:e("\u786C\u91CD\u7F6E\u4F1A\u4E22\u5F03\u672C\u5730\u6539\u52A8"),test:A(/git\s+reset\b[^;&|]*--hard/)},{id:"git-clean",level:"high",label:e("git clean \u4F1A\u5220\u9664\u672A\u8DDF\u8E2A\u6587\u4EF6"),test:A(/git\s+clean\b[^;&|]*(-[a-z]*f|--force)/)},{id:"pipe-to-shell",level:"high",label:e("\u5C06\u4E0B\u8F7D\u5185\u5BB9\u76F4\u63A5\u7BA1\u9053\u6267\u884C"),test:A(/(curl|wget)\b[^;&|]*\|\s*(ba|z|da|fi)?sh\b/)},{id:"exec-download",level:"high",label:e("\u6267\u884C\u4E0B\u8F7D\u7684\u811A\u672C"),test:A(/\b(ba|z|da|fi)?sh\s+<\(\s*(curl|wget)\b|eval\b[^;&|\n]*\$\(\s*(curl|wget)\b/)},{id:"recursive-perms",label:e("\u9012\u5F52\u4FEE\u6539\u6743\u9650/\u5C5E\u4E3B"),test:A(/(chmod|chown)\b[^;&|]*-[a-zA-Z]*R/)},{id:"publish",label:e("\u53D1\u5E03\u8F6F\u4EF6\u5305"),test:A(/(npm|pnpm|yarn)\s+publish\b/)},{id:"kill",label:e("\u6309\u540D\u79F0\u7ED3\u675F\u8FDB\u7A0B"),test:A(/(^|[;&|\n]\s*)(killall|pkill)\s/)},{id:"disk",level:"high",label:e("\u5E95\u5C42\u78C1\u76D8\u64CD\u4F5C"),test:A(/(^|[;&|\n]\s*)(dd|mkfs\w*|diskutil|fdisk)\s/)}];function y(u){return qu.find(a=>a.test(u))}d(y,"me"),i(y,"riskForBash");function w(u,a){const o=v(iu(u,a)),t=v(eu(a)),s=uu(t,o);return s===".."||s.startsWith(`..${au}`)||X(s)}d(w,"pe"),i(w,"pathOutsideProject");function $(u,a){if(u.toolName.startsWith("mcp__")){const o=u.toolName.split("__")[1]||"unknown",t=JSON.stringify(u.input??{});return{ruleId:`mcp:${o}`,title:`${e("\u7B2C\u4E09\u65B9 MCP \u5DE5\u5177\u8C03\u7528\uFF08")}${o}${e("\uFF09")}`,detail:`${u.toolName} ${t.length>200?`${t.slice(0,200)}\u2026`:t}`,level:"medium"}}if(u.toolName==="bash"){const o=String(u.input.command??""),t=y(o);return t?{ruleId:`bash:${t.id}`,title:t.label,detail:o,level:t.level??"medium"}:void 0}if(u.toolName==="edit"||u.toolName==="write"){const o=String(u.input.path??u.input.file_path??"");if(o&&w(o,a))return{ruleId:`${u.toolName}:outside-project`,title:e("\u9879\u76EE\u76EE\u5F55\u4E4B\u5916\u7684\u6587\u4EF6\u6539\u52A8"),detail:o,level:"medium"}}}d($,"ge"),i($,"classify");async function x(u,a){if(u.toolName!=="bash")return;const o=String(u.input.command??""),t=await gu(o,a);if(t)return{ruleId:`bash:jev-${t.suspicion.id}`,title:`${e("jev \u590D\u6838\u5224\u5B9A\u53EF\u7591")} (${Math.round(t.confidence*100)}%)`,detail:o,level:"medium"}}d(x,"he"),i(x,"secondOpinion");const Ju=i(()=>e("\u4EC5\u672C\u6B21\u5141\u8BB8"),"allowOnce"),Ku=i(()=>e("\u672C\u6B21\u4F1A\u8BDD\u5185\u5141\u8BB8\uFF08\u540C\u7C7B\u64CD\u4F5C\uFF09"),"allowSession"),Zu=i(()=>e("\u62D2\u7EDD"),"deny"),U=Symbol.for("dalcode.guard.state"),j=globalThis;j[U]??={mode:"default",sessionAllows:new Set};const F=j[U];function B(u){F.mode=u,Cu(u)}d(B,"A"),i(B,"setGuardMode");function H(){F.escalationApprover||(F.escalationApprover=nu(()=>{if(!(F.mode!=="yolo"||p(process.env)))return{approved:!0,scope:"once"}}))}d(H,"we"),i(H,"registerEscalationApprover");const g=F.sessionAllows;async function k(u,a,o,t,s,r=process.env,n){if(Eu(u,a))return{block:!0,reason:cu()};const c=Au(u,a);if(c)return{block:!0,reason:fu(c)};const E=T(u,a);if(E)return E;const m=Bu(u,a);if(m)return{block:!0,reason:m};const f=await L(u,a);if(f)return f;if(F.mode==="yolo"||p(r))return;const l=$(u,a)??await x(u,a);if(!l||g.has(l.ruleId))return;if(!o||!t)return{block:!0,reason:`${e('dal-guard\uFF1A"')}${l.title}${e('"\u9700\u8981\u4EA4\u4E92\u5F0F\u5BA1\u6279\uFF08')}${l.detail}${e("\uFF09\u3002\u8BF7\u5728\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u91CD\u8BD5\uFF0C\u6216\u7528 /guard yolo \u5173\u95ED\u5BA1\u6279\u95E8\u3002")}`};const h=s?tu({session_id:s.sessionId,cwd:a,event:"PermissionRequest",status:"waiting_for_approval",pid:process.pid,tty:ou(),tool:u.toolName,tool_input:{command:l.detail},tool_use_id:u.toolCallId,productName:"dal"}):void 0;n?.({type:"permission_prompt",message:`DAL needs your permission to use ${u.toolName}`});const _=new AbortController,[b,I,M]=[Ju(),Ku(),Zu()],V=t.select(`${e("\u9700\u8981\u5BA1\u6279\uFF1A")}${l.title} \u2014 ${l.detail}`,[b,I,M],{signal:_.signal,approval:{source:"guard",toolCallId:u.toolCallId,toolName:u.toolName,args:u.input,risk:{level:l.level,reason:l.title,ruleId:l.ruleId},title:l.title,description:l.detail,options:["allow_once","allow_session","deny"]}}).then(C=>({surface:"terminal",choice:C})),q=h?h.decision.then(C=>C===void 0?new Promise(()=>{}):{surface:"halo",choice:C==="allow"?b:M}):new Promise(()=>{}),N=await Promise.race([V,q]);N.surface==="halo"?_.abort():h?.cancel();const S=N.choice;if(S!==b){if(S===I){g.add(l.ruleId);return}return{block:!0,reason:`${e("dal-guard\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\uFF08")}${l.title}${e("\uFF09\u3002")}`}}}d(k,"ke"),i(k,"evaluateToolCall");const Qu=new Set(["bash","powershell"]);async function L(u,a){if(!Qu.has(u.toolName))return;const o=u.input.command;if(typeof o!="string"||!o.trim())return;const t=await lu({toolName:u.toolName,command:o,cwd:a});if(t!==void 0)return{block:!0,reason:`${e("dal-guard\uFF1A\u8FD9\u6761\u547D\u4EE4\u4F1A\u88AB\u5371\u9669\u547D\u4EE4\u62E6\u622A\u6321\u4E0B\uFF0C\u6CA1\u6709\u8FD0\u884C\uFF0C\u4E5F\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\u3002")}
2
- ${t}`}}d(L,"_e"),i(L,"destructiveCommandRefusal");async function z(u){const a=e("\u5168\u81EA\u52A8\uFF1A\u4E0D\u518D\u8BE2\u95EE\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\uFF08\u63A8\u8350\u719F\u6089\u7684\u7528\u6237\uFF09"),o=e("\u6BCF\u6B21\u8BE2\u95EE\uFF1A\u9AD8\u98CE\u9669\u64CD\u4F5C\u548C\u8D8A\u51FA\u6C99\u7BB1\u524D\u5148\u95EE\u6211"),t=await u.ui.select(e("\u9009\u62E9 dal \u7684\u5DE5\u4F5C\u65B9\u5F0F\uFF08\u4EE5\u540E\u53EF\u7528 /guard \u4FEE\u6539\uFF09"),[a,o]);if(t===void 0)return;const s=t===a?"yolo":"default";B(s);try{P(D(),s)}catch(r){u.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${r instanceof Error?r.message:String(r)}`,"error");return}u.ui.notify(s==="yolo"?e("\u5DF2\u8BBE\u4E3A\u5168\u81EA\u52A8\u3002\u6539\u56DE\u6BCF\u6B21\u8BE2\u95EE\uFF1A/guard default save"):e("\u5DF2\u8BBE\u4E3A\u6BCF\u6B21\u8BE2\u95EE\u3002\u6539\u6210\u5168\u81EA\u52A8\uFF1A/guard yolo save"),"info")}d(z,"Ie"),i(z,"askGuardModeOnce");function W(u){u.registerFlag("yolo",{description:e("\u4EE5\u5168\u81EA\u52A8\u6A21\u5F0F\u542F\u52A8\uFF1A\u4E0D\u518D\u5F39\u51FA\u4EFB\u4F55\u5BA1\u6279\uFF08\u542B\u6C99\u7BB1\u8D8A\u6743\uFF09\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E"),type:"boolean",default:!1}),H();let a="default";u.on("session_start",async(s,r)=>{if(a="default",F.started)return;F.started=!0;const n=u.getFlag("yolo")===!0;B(Du(D(),n)),s.reason==="startup"&&pu({agentDir:D(),mode:r.mode,hasUI:r.hasUI,flag:n,underDalCode:!!p(process.env),languageChosen:su()})&&await z(r)}),u.on("before_agent_start",async()=>{if(!(F.mode===a||p(process.env)))return a=F.mode,{message:{customType:"dal-guard-mode",content:F.mode==="yolo"?e("[\u5168\u81EA\u52A8\u6A21\u5F0F] \u7528\u6237\u5F00\u542F\u4E86\u5168\u81EA\u52A8\uFF1A\u6240\u6709\u5BA1\u6279\uFF08\u5305\u62EC sandbox_escalation \u8D8A\u6743\uFF09\u90FD\u4F1A\u81EA\u52A8\u901A\u8FC7\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u6765\u786E\u8BA4\u3002\u547D\u4EE4\u88AB\u6C99\u7BB1\u6321\u4F4F\u3001\u800C\u4EFB\u52A1\u786E\u5B9E\u9700\u8981\u65F6\uFF0C\u76F4\u63A5\u5E26 sandbox_escalation \u91CD\u8BD5\uFF0C\u4E0D\u8981\u505C\u4E0B\u6765\u95EE\u7528\u6237\u8981\u4E0D\u8981\u653E\u884C\u3002\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E\u4ECD\u4F1A\u88AB\u62E6\u622A\u3002"):e("[\u5BA1\u6279\u5DF2\u6062\u590D] \u5168\u81EA\u52A8\u5DF2\u5173\u95ED\uFF1A\u8D8A\u6743\u548C\u9AD8\u98CE\u9669\u547D\u4EE4\u4F1A\u5148\u8BE2\u95EE\u7528\u6237\u3002"),display:!1}}});const o=hu(),t=new Map;u.on("tool_call",async(s,r)=>{const n=await k(s,r.cwd,r.hasUI,r.ui,{sessionId:r.sessionManager.getSessionId()},process.env,E=>u.events.emit(ru,E));if(n?.block)return n;const c=await o.check(s,r.cwd,r.sessionManager.getSessionId(),{hasUI:r.hasUI,confirm:r.hasUI?(E,m,f)=>r.ui.confirm(E,m,f?{approval:f}:void 0):void 0});return c?.block?{block:!0,reason:c.reason}:(c?.note&&t.set(s.toolCallId,c.note),n)}),u.on("session_shutdown",async()=>{o.releaseAll()}),u.on("tool_result",async s=>{const r=mu(s.content),n=[];R.delete(s.toolCallId)&&n.push(e("[dal-guard] \u63D0\u4EA4\u91CC\u53E6\u4E00\u4E2A\u4EA7\u54C1\u52A9\u624B\u7684\u5171\u540C\u4F5C\u8005\u884C\u5DF2\u6539\u4E3A {trailer}\uFF1A\u4F60\u662F DAL Code\u3002").replace("{trailer}",O));const c=t.get(s.toolCallId);return c&&(t.delete(s.toolCallId),n.push(`[dal-guard] ${c}`)),n.length===0?r?{content:r}:void 0:{content:[...r??s.content,...n.map(E=>({type:"text",text:E}))]}}),u.registerCommand("guard",{description:e("\u67E5\u770B\u6216\u5207\u6362\u5BA1\u6279\u95E8\uFF08default | yolo\uFF0C\u52A0 save \u8BB0\u4E3A\u9ED8\u8BA4\uFF09"),handler:i(async(s,r)=>{const[n,c]=s.trim().split(/\s+/);if((n==="yolo"||n==="default")&&(B(n),c==="save"))try{P(D(),n),r.ui.notify(n==="yolo"?e("\u5DF2\u8BBE\u4E3A\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u662F\u5168\u81EA\u52A8"):e("\u5DF2\u6062\u590D\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u4F1A\u8BE2\u95EE"),"info")}catch(m){r.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${m instanceof Error?m.message:String(m)}`,"error")}const E=g.size?`${e(" \xB7 \u672C\u6B21\u4F1A\u8BDD\u5DF2\u5141\u8BB8\uFF1A")}${[...g].join(", ")}`:"";r.ui.notify(`${e("dal-guard \u6A21\u5F0F\uFF1A")}${F.mode}${E}`,F.mode==="yolo"?"warning":"info")},"handler")})}d(W,"$e"),i(W,"default");export{bu as DAL_CO_AUTHOR,Pu as GUARD_MODE_ENV,Mu as REDACTED,$ as classify,Wu as createWorkspaceGate,ku as dalSecretValues,W as default,k as evaluateToolCall,_u as fileHoldsDalSecret,vu as foreignAttributionInMessageFile,yu as foreignCoAuthors,ju as installingManager,wu as isGitCommit,Vu as modifiedDirectory,Iu as namesDalCredential,w as pathOutsideProject,Nu as readsDalSecretCopy,Su as redactContent,Gu as redactDalSecrets,Lu as reviewBashCommand,$u as rewriteCommitAttribution,y as riskForBash,Tu as saveGuardMode,Ru as savedGuardMode,Ou as shellPathCandidates,xu as shouldAskGuardMode,Uu as startupGuardMode,zu as suspicionFor,Hu as wrongPackageManager};
1
+ var J=Object.defineProperty;var d=(u,a)=>J(u,"name",{value:a,configurable:!0});var K=Object.defineProperty,i=d((u,a)=>K(u,"name",{value:a,configurable:!0}),"l");import{realpathSync as G}from"node:fs";import{basename as Z,dirname as Q,isAbsolute as X,join as Y,relative as uu,resolve as eu,sep as au}from"node:path";import{readBridgeConfig as p}from"@dalcode/dal-bridge/client";import{getOwnTty as ou,requestHaloApproval as tu}from"@dalcode/dal-halo";import{hasChosenLanguage as su,t as e}from"@dalcode/dal-pi-kit";import{DAL_HOOK_NOTIFICATION_CHANNEL as ru,getAgentDir as D,registerSandboxEscalationHandler as nu,resolveToCwd as iu,shellExecutionRefusal as lu}from"@earendil-works/pi-coding-agent";import{DAL_CO_AUTHOR as O,foreignAttributionInMessageFile as du,rewriteCommitAttribution as cu}from"./attribution.js";import{credentialBlockReason as Fu,namesDalCredential as Eu,readsDalSecretCopy as Au,redactContent as mu,secretCopyBlockReason as fu}from"./credentials.js";import{exportGuardMode as Cu,saveGuardMode as P,shouldAskGuardMode as pu,startupGuardMode as Du}from"./mode.js";import{wrongPackageManager as gu}from"./package-manager.js";import{reviewBashCommand as Bu}from"./review.js";import{createWorkspaceGate as hu}from"./workspace.js";import{DAL_CO_AUTHOR as bu,foreignAttributionInMessageFile as vu,foreignCoAuthors as yu,isGitCommit as wu,rewriteCommitAttribution as Iu}from"./attribution.js";import{dalSecretValues as $u,fileHoldsDalSecret as ku,namesDalCredential as _u,REDACTED as Mu,readsDalSecretCopy as Nu,redactContent as Su,redactDalSecrets as Gu,shellPathCandidates as Ou}from"./credentials.js";import{GUARD_MODE_ENV as Pu,savedGuardMode as Ru,saveGuardMode as Tu,shouldAskGuardMode as xu,startupGuardMode as Uu}from"./mode.js";import{installingManager as ju,wrongPackageManager as Hu}from"./package-manager.js";import{reviewBashCommand as Lu,suspicionFor as zu}from"./review.js";import{createWorkspaceGate as Wu,modifiedDirectory as Vu}from"./workspace.js";const R=new Set;function T(u,a){if(u.toolName!=="bash"&&u.toolName!=="powershell")return;const o=u.input;if(typeof o.command!="string")return;const t=du(o.command,a);if(t)return{block:!0,denied:{source:"dal-guard",ruleId:"commit:attribution"},reason:e("dal-guard\uFF1A\u63D0\u4EA4\u8BF4\u660E\u6587\u4EF6 {file} \u628A\u53E6\u4E00\u4E2A\u4EA7\u54C1\u7684\u52A9\u624B\uFF08Claude\u3001Codex\u3001Copilot \u7B49\uFF09\u5199\u6210\u4E86\u5171\u540C\u4F5C\u8005\u3002\u4F60\u662F DAL Code\uFF1A\u628A\u90A3\u884C\u6539\u6210 {trailer} \u6216\u5220\u6389\uFF0C\u518D\u63D0\u4EA4\u3002").replace("{file}",t).replace("{trailer}",O)};const s=cu(o.command);s!==void 0&&(o.command=s,R.add(u.toolCallId))}d(T,"ce"),i(T,"checkCommitAttribution");function v(u){try{return G(u)}catch{try{return Y(G(Q(u)),Z(u))}catch{return u}}}d(v,"G"),i(v,"realPathBestEffort");const A=i(u=>a=>u.test(a),"has"),qu=[{id:"sudo",level:"high",label:e("\u7279\u6743\u6267\u884C\uFF08sudo/doas\uFF09"),test:A(/(^|[;&|\n]\s*)(sudo|doas)\s/)},{id:"force-push",level:"high",label:e("\u5F3A\u5236\u63A8\u9001\u5C06\u6539\u5199\u8FDC\u7A0B\u5386\u53F2"),test:A(/git\s+push\b[^;&|]*(--force\b|--force-with-lease\b|\s-f\b)/)},{id:"hard-reset",level:"high",label:e("\u786C\u91CD\u7F6E\u4F1A\u4E22\u5F03\u672C\u5730\u6539\u52A8"),test:A(/git\s+reset\b[^;&|]*--hard/)},{id:"git-clean",level:"high",label:e("git clean \u4F1A\u5220\u9664\u672A\u8DDF\u8E2A\u6587\u4EF6"),test:A(/git\s+clean\b[^;&|]*(-[a-z]*f|--force)/)},{id:"pipe-to-shell",level:"high",label:e("\u5C06\u4E0B\u8F7D\u5185\u5BB9\u76F4\u63A5\u7BA1\u9053\u6267\u884C"),test:A(/(curl|wget)\b[^;&|]*\|\s*(ba|z|da|fi)?sh\b/)},{id:"exec-download",level:"high",label:e("\u6267\u884C\u4E0B\u8F7D\u7684\u811A\u672C"),test:A(/\b(ba|z|da|fi)?sh\s+<\(\s*(curl|wget)\b|eval\b[^;&|\n]*\$\(\s*(curl|wget)\b/)},{id:"recursive-perms",label:e("\u9012\u5F52\u4FEE\u6539\u6743\u9650/\u5C5E\u4E3B"),test:A(/(chmod|chown)\b[^;&|]*-[a-zA-Z]*R/)},{id:"publish",label:e("\u53D1\u5E03\u8F6F\u4EF6\u5305"),test:A(/(npm|pnpm|yarn)\s+publish\b/)},{id:"kill",label:e("\u6309\u540D\u79F0\u7ED3\u675F\u8FDB\u7A0B"),test:A(/(^|[;&|\n]\s*)(killall|pkill)\s/)},{id:"disk",level:"high",label:e("\u5E95\u5C42\u78C1\u76D8\u64CD\u4F5C"),test:A(/(^|[;&|\n]\s*)(dd|mkfs\w*|diskutil|fdisk)\s/)}];function y(u){return qu.find(a=>a.test(u))}d(y,"me"),i(y,"riskForBash");function w(u,a){const o=v(iu(u,a)),t=v(eu(a)),s=uu(t,o);return s===".."||s.startsWith(`..${au}`)||X(s)}d(w,"ge"),i(w,"pathOutsideProject");function I(u,a){if(u.toolName.startsWith("mcp__")){const o=u.toolName.split("__")[1]||"unknown",t=JSON.stringify(u.input??{});return{ruleId:`mcp:${o}`,title:`${e("\u7B2C\u4E09\u65B9 MCP \u5DE5\u5177\u8C03\u7528\uFF08")}${o}${e("\uFF09")}`,detail:`${u.toolName} ${t.length>200?`${t.slice(0,200)}\u2026`:t}`,level:"medium"}}if(u.toolName==="bash"){const o=String(u.input.command??""),t=y(o);return t?{ruleId:`bash:${t.id}`,title:t.label,detail:o,level:t.level??"medium"}:void 0}if(u.toolName==="edit"||u.toolName==="write"){const o=String(u.input.path??u.input.file_path??"");if(o&&w(o,a))return{ruleId:`${u.toolName}:outside-project`,title:e("\u9879\u76EE\u76EE\u5F55\u4E4B\u5916\u7684\u6587\u4EF6\u6539\u52A8"),detail:o,level:"medium"}}}d(I,"pe"),i(I,"classify");async function x(u,a){if(u.toolName!=="bash")return;const o=String(u.input.command??""),t=await Bu(o,a);if(t)return{ruleId:`bash:jev-${t.suspicion.id}`,title:`${e("jev \u590D\u6838\u5224\u5B9A\u53EF\u7591")} (${Math.round(t.confidence*100)}%)`,detail:o,level:"medium"}}d(x,"he"),i(x,"secondOpinion");const Ju=i(()=>e("\u4EC5\u672C\u6B21\u5141\u8BB8"),"allowOnce"),Ku=i(()=>e("\u672C\u6B21\u4F1A\u8BDD\u5185\u5141\u8BB8\uFF08\u540C\u7C7B\u64CD\u4F5C\uFF09"),"allowSession"),Zu=i(()=>e("\u62D2\u7EDD"),"deny"),U=Symbol.for("dalcode.guard.state"),j=globalThis;j[U]??={mode:"default",sessionAllows:new Set};const c=j[U];function g(u){c.mode=u,Cu(u)}d(g,"I"),i(g,"setGuardMode");function H(){c.escalationApprover||(c.escalationApprover=nu(()=>{if(!(c.mode!=="yolo"||p(process.env)))return{approved:!0,scope:"once"}}))}d(H,"we"),i(H,"registerEscalationApprover");const B=c.sessionAllows;async function $(u,a,o,t,s,r=process.env,n){if(Eu(u,a))return{block:!0,reason:Fu(),denied:{source:"dal-guard",ruleId:"credential"}};const F=Au(u,a);if(F)return{block:!0,reason:fu(F),denied:{source:"dal-guard",ruleId:"credential:copy"}};const E=T(u,a);if(E)return E;const m=gu(u,a);if(m)return{block:!0,reason:m,denied:{source:"dal-guard",ruleId:"package-manager"}};const f=await L(u,a);if(f)return f;if(c.mode==="yolo"||p(r))return;const l=I(u,a)??await x(u,a);if(!l||B.has(l.ruleId))return;if(!o||!t)return{block:!0,denied:{source:"dal-guard",ruleId:l.ruleId},reason:`${e('dal-guard\uFF1A"')}${l.title}${e('"\u9700\u8981\u4EA4\u4E92\u5F0F\u5BA1\u6279\uFF08')}${l.detail}${e("\uFF09\u3002\u8BF7\u5728\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u91CD\u8BD5\uFF0C\u6216\u7528 /guard yolo \u5173\u95ED\u5BA1\u6279\u95E8\u3002")}`};const h=s?tu({session_id:s.sessionId,cwd:a,event:"PermissionRequest",status:"waiting_for_approval",pid:process.pid,tty:ou(),tool:u.toolName,tool_input:{command:l.detail},tool_use_id:u.toolCallId,productName:"dal"}):void 0;n?.({type:"permission_prompt",message:`DAL needs your permission to use ${u.toolName}`});const k=new AbortController,[b,_,M]=[Ju(),Ku(),Zu()],V=t.select(`${e("\u9700\u8981\u5BA1\u6279\uFF1A")}${l.title} \u2014 ${l.detail}`,[b,_,M],{signal:k.signal,approval:{source:"guard",toolCallId:u.toolCallId,toolName:u.toolName,args:u.input,risk:{level:l.level,reason:l.title,ruleId:l.ruleId},title:l.title,description:l.detail,options:["allow_once","allow_session","deny"]}}).then(C=>({surface:"terminal",choice:C})),q=h?h.decision.then(C=>C===void 0?new Promise(()=>{}):{surface:"halo",choice:C==="allow"?b:M}):new Promise(()=>{}),N=await Promise.race([V,q]);N.surface==="halo"?k.abort():h?.cancel();const S=N.choice;if(S!==b){if(S===_){B.add(l.ruleId);return}return{block:!0,reason:`${e("dal-guard\uFF1A\u7528\u6237\u5DF2\u62D2\u7EDD\uFF08")}${l.title}${e("\uFF09\u3002")}`,denied:{source:"dal-guard",ruleId:l.ruleId}}}}d($,"ke"),i($,"evaluateToolCall");const Qu=new Set(["bash","powershell"]);async function L(u,a){if(!Qu.has(u.toolName))return;const o=u.input.command;if(typeof o!="string"||!o.trim())return;const t=await lu({toolName:u.toolName,command:o,cwd:a});if(t!==void 0)return{block:!0,denied:{source:"dangerous-command"},reason:`${e("dal-guard\uFF1A\u8FD9\u6761\u547D\u4EE4\u4F1A\u88AB\u5371\u9669\u547D\u4EE4\u62E6\u622A\u6321\u4E0B\uFF0C\u6CA1\u6709\u8FD0\u884C\uFF0C\u4E5F\u4E0D\u518D\u8BF7\u4F60\u786E\u8BA4\u3002")}
2
+ ${t}`}}d(L,"Ae"),i(L,"destructiveCommandRefusal");async function z(u){const a=e("\u5168\u81EA\u52A8\uFF1A\u4E0D\u518D\u8BE2\u95EE\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\uFF08\u63A8\u8350\u719F\u6089\u7684\u7528\u6237\uFF09"),o=e("\u6BCF\u6B21\u8BE2\u95EE\uFF1A\u9AD8\u98CE\u9669\u64CD\u4F5C\u548C\u8D8A\u51FA\u6C99\u7BB1\u524D\u5148\u95EE\u6211"),t=await u.ui.select(e("\u9009\u62E9 dal \u7684\u5DE5\u4F5C\u65B9\u5F0F\uFF08\u4EE5\u540E\u53EF\u7528 /guard \u4FEE\u6539\uFF09"),[a,o]);if(t===void 0)return;const s=t===a?"yolo":"default";g(s);try{P(D(),s)}catch(r){u.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${r instanceof Error?r.message:String(r)}`,"error");return}u.ui.notify(s==="yolo"?e("\u5DF2\u8BBE\u4E3A\u5168\u81EA\u52A8\u3002\u6539\u56DE\u6BCF\u6B21\u8BE2\u95EE\uFF1A/guard default save"):e("\u5DF2\u8BBE\u4E3A\u6BCF\u6B21\u8BE2\u95EE\u3002\u6539\u6210\u5168\u81EA\u52A8\uFF1A/guard yolo save"),"info")}d(z,"_e"),i(z,"askGuardModeOnce");function W(u){u.registerFlag("yolo",{description:e("\u4EE5\u5168\u81EA\u52A8\u6A21\u5F0F\u542F\u52A8\uFF1A\u4E0D\u518D\u5F39\u51FA\u4EFB\u4F55\u5BA1\u6279\uFF08\u542B\u6C99\u7BB1\u8D8A\u6743\uFF09\uFF0C\u53EA\u62E6\u622A\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E"),type:"boolean",default:!1}),H();let a="default";u.on("session_start",async(s,r)=>{if(a="default",c.started)return;c.started=!0;const n=u.getFlag("yolo")===!0;g(Du(D(),n)),s.reason==="startup"&&pu({agentDir:D(),mode:r.mode,hasUI:r.hasUI,flag:n,underDalCode:!!p(process.env),languageChosen:su()})&&await z(r)}),u.on("before_agent_start",async()=>{if(!(c.mode===a||p(process.env)))return a=c.mode,{message:{customType:"dal-guard-mode",content:c.mode==="yolo"?e("[\u5168\u81EA\u52A8\u6A21\u5F0F] \u7528\u6237\u5F00\u542F\u4E86\u5168\u81EA\u52A8\uFF1A\u6240\u6709\u5BA1\u6279\uFF08\u5305\u62EC sandbox_escalation \u8D8A\u6743\uFF09\u90FD\u4F1A\u81EA\u52A8\u901A\u8FC7\uFF0C\u4E0D\u4F1A\u6709\u4EBA\u6765\u786E\u8BA4\u3002\u547D\u4EE4\u88AB\u6C99\u7BB1\u6321\u4F4F\u3001\u800C\u4EFB\u52A1\u786E\u5B9E\u9700\u8981\u65F6\uFF0C\u76F4\u63A5\u5E26 sandbox_escalation \u91CD\u8BD5\uFF0C\u4E0D\u8981\u505C\u4E0B\u6765\u95EE\u7528\u6237\u8981\u4E0D\u8981\u653E\u884C\u3002\u7834\u574F\u6027\u547D\u4EE4\u548C\u767B\u5F55\u51ED\u636E\u4ECD\u4F1A\u88AB\u62E6\u622A\u3002"):e("[\u5BA1\u6279\u5DF2\u6062\u590D] \u5168\u81EA\u52A8\u5DF2\u5173\u95ED\uFF1A\u8D8A\u6743\u548C\u9AD8\u98CE\u9669\u547D\u4EE4\u4F1A\u5148\u8BE2\u95EE\u7528\u6237\u3002"),display:!1}}});const o=hu(),t=new Map;u.on("tool_call",async(s,r)=>{const n=await $(s,r.cwd,r.hasUI,r.ui,{sessionId:r.sessionManager.getSessionId()},process.env,E=>u.events.emit(ru,E));if(n?.block)return n;const F=await o.check(s,r.cwd,r.sessionManager.getSessionId(),{hasUI:r.hasUI,confirm:r.hasUI?(E,m,f)=>r.ui.confirm(E,m,f?{approval:f}:void 0):void 0});return F?.block?{block:!0,reason:F.reason,denied:{source:"dal-guard",ruleId:"workspace:occupied"}}:(F?.note&&t.set(s.toolCallId,F.note),n)}),u.on("session_shutdown",async()=>{o.releaseAll()}),u.on("tool_result",async s=>{const r=mu(s.content),n=[];R.delete(s.toolCallId)&&n.push(e("[dal-guard] \u63D0\u4EA4\u91CC\u53E6\u4E00\u4E2A\u4EA7\u54C1\u52A9\u624B\u7684\u5171\u540C\u4F5C\u8005\u884C\u5DF2\u6539\u4E3A {trailer}\uFF1A\u4F60\u662F DAL Code\u3002").replace("{trailer}",O));const F=t.get(s.toolCallId);return F&&(t.delete(s.toolCallId),n.push(`[dal-guard] ${F}`)),n.length===0?r?{content:r}:void 0:{content:[...r??s.content,...n.map(E=>({type:"text",text:E}))]}}),u.registerCommand("guard",{description:e("\u67E5\u770B\u6216\u5207\u6362\u5BA1\u6279\u95E8\uFF08default | yolo\uFF0C\u52A0 save \u8BB0\u4E3A\u9ED8\u8BA4\uFF09"),handler:i(async(s,r)=>{const[n,F]=s.trim().split(/\s+/);if((n==="yolo"||n==="default")&&(g(n),F==="save"))try{P(D(),n),r.ui.notify(n==="yolo"?e("\u5DF2\u8BBE\u4E3A\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u662F\u5168\u81EA\u52A8"):e("\u5DF2\u6062\u590D\u9ED8\u8BA4\uFF1A\u4EE5\u540E\u542F\u52A8\u90FD\u4F1A\u8BE2\u95EE"),"info")}catch(m){r.ui.notify(`${e("\u4FDD\u5B58\u5931\u8D25\uFF1A")}${m instanceof Error?m.message:String(m)}`,"error")}const E=B.size?`${e(" \xB7 \u672C\u6B21\u4F1A\u8BDD\u5DF2\u5141\u8BB8\uFF1A")}${[...B].join(", ")}`:"";r.ui.notify(`${e("dal-guard \u6A21\u5F0F\uFF1A")}${c.mode}${E}`,c.mode==="yolo"?"warning":"info")},"handler")})}d(W,"$e"),i(W,"default");export{bu as DAL_CO_AUTHOR,Pu as GUARD_MODE_ENV,Mu as REDACTED,I as classify,Wu as createWorkspaceGate,$u as dalSecretValues,W as default,$ as evaluateToolCall,ku as fileHoldsDalSecret,vu as foreignAttributionInMessageFile,yu as foreignCoAuthors,ju as installingManager,wu as isGitCommit,Vu as modifiedDirectory,_u as namesDalCredential,w as pathOutsideProject,Nu as readsDalSecretCopy,Su as redactContent,Gu as redactDalSecrets,Lu as reviewBashCommand,Iu as rewriteCommitAttribution,y as riskForBash,Tu as saveGuardMode,Ru as savedGuardMode,Ou as shellPathCandidates,xu as shouldAskGuardMode,Uu as startupGuardMode,zu as suspicionFor,Hu as wrongPackageManager};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-halo",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-interactive",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Terminal-UI conveniences adopted from pi's example extensions: the questionnaire tool (the model asks you questions), /handoff (carry context into a new session) and interactive ! commands (vim, git rebase -i, htop). Active only in the TUI; stands down under DAL Code.",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@dalcode/dal-pi-kit": "1.0.43",
23
+ "@dalcode/dal-pi-kit": "1.0.44",
24
24
  "typebox": "1.3.7"
25
25
  },
26
26
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lang",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -17,8 +17,8 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.43",
21
- "@dalcode/dal-bridge": "1.0.43"
20
+ "@dalcode/dal-pi-kit": "1.0.44",
21
+ "@dalcode/dal-bridge": "1.0.44"
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-learn",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "private": true,
5
5
  "description": "Self-evolution for DAL: lessons learned from earlier sessions (project and personal), a project map of verified commands and locations, effect tracking, and skill proposals for recurring procedures (/lessons).",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  ]
26
26
  },
27
27
  "dependencies": {
28
- "@dalcode/dal-pi-kit": "1.0.43"
28
+ "@dalcode/dal-pi-kit": "1.0.44"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lsp",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
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-bridge": "1.0.43",
24
- "@dalcode/dal-pi-kit": "1.0.43",
23
+ "@dalcode/dal-bridge": "1.0.44",
24
+ "@dalcode/dal-pi-kit": "1.0.44",
25
25
  "cross-spawn": "7.0.6",
26
26
  "typebox": "1.3.7",
27
27
  "typescript": "5.9.3",