dal-code 1.0.53 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/NOTICE +11 -0
- package/dist/bundle/chunks/{anthropic-messages-Y6ZFHUZY.js → anthropic-messages-LJWWEQIU.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-M6NPMDKK.js → azure-openai-responses-GK4VH6GM.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-FBHNYUW7.js → chunk-2XX4WZT6.js} +1 -1
- package/dist/bundle/chunks/{chunk-EHKSTDLR.js → chunk-3ANBT7AT.js} +1 -1
- package/dist/bundle/chunks/{chunk-EGEFD4CT.js → chunk-44EXLOHK.js} +1 -1
- package/dist/bundle/chunks/{chunk-3KP6IUMV.js → chunk-5TGFM4KW.js} +2 -2
- package/dist/bundle/chunks/{chunk-YALY2HLR.js → chunk-6U37J6E7.js} +343 -345
- package/dist/bundle/chunks/{chunk-EH7SFF47.js → chunk-AL3DFAIM.js} +2 -2
- package/dist/bundle/chunks/{chunk-GHZXS4EI.js → chunk-D3HKK2ZD.js} +1 -1
- package/dist/bundle/chunks/{chunk-22WV5HKU.js → chunk-DBT5OS5V.js} +1 -1
- package/dist/bundle/chunks/{chunk-QYQJQJ5B.js → chunk-DWMC4U2M.js} +1 -1
- package/dist/bundle/chunks/{chunk-K7VBBYTT.js → chunk-F5SIUTR7.js} +1 -1
- package/dist/bundle/chunks/{chunk-HBTEG3CS.js → chunk-GX37DI5S.js} +1 -1
- package/dist/bundle/chunks/{chunk-XQY5ZHQA.js → chunk-KSF7BFGS.js} +1 -1
- package/dist/bundle/chunks/{chunk-N2RRGQFI.js → chunk-NMU45EFT.js} +1 -1
- package/dist/bundle/chunks/{chunk-6VVU2U7I.js → chunk-PRBATF6B.js} +1 -1
- package/dist/bundle/chunks/{chunk-2IIG5FH4.js → chunk-SCSGNIU5.js} +1 -1
- package/dist/bundle/chunks/{chunk-BY4XL3JS.js → chunk-SMPERFJU.js} +1 -1
- package/dist/bundle/chunks/{chunk-YZQKKXBH.js → chunk-SNBVCTMQ.js} +2 -2
- package/dist/bundle/chunks/{chunk-YIBYUMGO.js → chunk-YDOF6JVP.js} +2 -2
- package/dist/bundle/chunks/{chunk-6GCEEEP2.js → chunk-ZYP3V3TD.js} +1 -1
- package/dist/bundle/chunks/{cli-UYQ4R2DI.js → cli-VKNCK5P5.js} +1 -1
- package/dist/bundle/chunks/{cli-DZWQCYIH.js → cli-Z44UHMMU.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-HI7IU5IW.js → cloudflare-workers-ai-system-one-G4E4L26A.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-5TFBCTIS.js → easter-egg-3d-W2F3ROZ6.js} +1 -1
- package/dist/bundle/chunks/{execute-B5PKAASV.js → execute-3FWM3EMV.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-DA5V3QPV.js → google-generative-ai-HVFDKPI3.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-BT23CSDX.js → google-vertex-6E4HATAC.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-T62K6I4H.js → llama-cpp-classify-3HAEJDKO.js} +1 -1
- package/dist/bundle/chunks/{mcp-KRPDZMNU.js → mcp-SGBPG7LV.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-NAYQLEXL.js → mistral-conversations-6UC2WYUC.js} +1 -1
- package/dist/bundle/chunks/{office-UYJNMMJ5.js → office-2F4B572E.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-NN7VPVPU.js → openai-codex-responses-WPSZR4EE.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-OWUZLSV4.js → openai-completions-2RGIFVKJ.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-RU4UQIAZ.js → openai-decisions-BLZVYNRQ.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-NPZBVAJQ.js → openai-responses-N65DO7MB.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-YX7ATNAW.js → openrouter-images-LQ4VP5P7.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-IDL3P2ML.js → pi-messages-VYTRLMVB.js} +1 -1
- package/dist/bundle/chunks/{review-34VIXKJ7.js → review-MKITXKSI.js} +1 -1
- package/dist/bundle/chunks/{router-WVWEQNZR.js → router-RL7OYANY.js} +1 -1
- package/dist/bundle/chunks/{runtime-WJYFTWKS.js → runtime-KB5ZUQB6.js} +1 -1
- package/dist/bundle/chunks/{sdk-BGOXS6X2.js → sdk-C5BAFGNR.js} +1 -1
- package/dist/bundle/chunks/sync-AQUDRXHM.js +7 -0
- package/dist/bundle/chunks/{typesafe-system-one-64X2E56P.js → typesafe-system-one-6ZFGVJMV.js} +1 -1
- package/dist/bundle/chunks/{usage-VBIOUGRZ.js → usage-CK3QZLTW.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-JXLCYYRR.js → virtual-modules-GRXCAWTO.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/types.d.ts +9 -5
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/tools/bash.js +14 -14
- package/dist/core/tools/edit.js +2 -3
- package/dist/core/tools/renderers/bash.js +8 -8
- package/dist/core/tools/renderers/edit.js +2 -2
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
- package/dist/modes/interactive/components/diff.d.ts +22 -0
- package/dist/modes/interactive/components/diff.js +4 -3
- package/dist/modes/interactive/components/keybinding-hints.js +1 -1
- package/dist/modes/interactive/components/panel-line.js +1 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +23 -1
- package/dist/modes/interactive/components/status-indicator.js +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -2
- package/dist/modes/interactive/components/tool-execution.js +5 -5
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.js +18 -18
- package/dist/modes/interactive/theme/dark.json +4 -0
- package/dist/modes/interactive/theme/light.json +4 -0
- package/dist/modes/interactive/theme/system-theme.js +1 -1
- package/dist/modes/interactive/theme/theme-tokens.d.ts +10 -0
- package/dist/modes/interactive/theme/theme-tokens.js +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -6
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/engine.js +2 -2
- package/dist/node_modules/@dalcode/dal-learn/src/index.js +14 -14
- package/dist/node_modules/@dalcode/dal-learn/src/lessons.js +4 -4
- package/dist/node_modules/@dalcode/dal-learn/src/safety.js +2 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -4
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-schema/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/bundle/chunks/sync-D7K3QQKF.js +0 -7
package/dist/core/tools/bash.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as
|
|
2
|
-
Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",
|
|
3
|
-
${E.fg("muted",`
|
|
1
|
+
var Le=Object.defineProperty;var s=(t,e)=>Le(t,"name",{value:e,configurable:!0});import{constants as Te}from"node:fs";import{access as Ce}from"node:fs/promises";import{constants as Pe}from"node:os";import{ToolExecutionError as ue}from"@earendil-works/pi-agent-core";import{Container as De,Text as V,truncateToWidth as ve}from"@earendil-works/pi-tui";import{spawn as Ie}from"child_process";import{Type as l}from"typebox";import{fill as Y,t as A}from"../../dal/i18n.js";import{keyHint as Ae}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as ke}from"../../modes/interactive/components/visual-truncate.js";import{theme as E}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as Me}from"../../utils/child-process.js";import{writeOutputFile as Fe}from"../../utils/output-files.js";import{getShellConfig as ce,getShellEnv as me,killProcessTree as pe,trackDetachedChildPid as Ne,untrackDetachedChildPid as Be}from"../../utils/shell.js";import{missingManagedToolHint as Re}from"../../utils/tools-manager.js";import{describeDenialForModel as Ue}from"../sandbox/denial.js";import{getProcessShellSandbox as Ge}from"../sandbox/shell-sandbox.js";import{toolDenial as He,withToolDenial as je}from"../tool-denial.js";import{isReadOnlyBashCommand as We}from"./bash-read-only.js";import{OutputAccumulator as Ve}from"./output-accumulator.js";import{condenseShellOutput as Ye,outputCondenseDisabled as Xe}from"./output-condense.js";import{countOutputLines as Ke,formatCollapsedSummary as qe,getTextOutput as fe,invalidArgText as ze,str as he,truncateDisplay as Je}from"./render-utils.js";import{wrapToolDefinition as Qe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as Ze,formatSize as et,SHELL_OUTPUT_MAX_CHARS as ee,truncateHeadTail as tt}from"./truncate.js";const we=2147483647,Se=1024*1024,nt=8*1024*1024,ot=we/1e3,te=12e4,ne=30;function it(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>we)throw new Error(`Invalid timeout: maximum is ${ot} seconds`);return e}s(it,"resolveTimeoutMs");const xe=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."}))}),st=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."})),rt=l.Object({...xe.properties,sandbox_escalation:st}),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()});class Ee extends Error{static{s(this,"ShellTimeoutError")}shellExit;constructor(e,n){super(`timeout:${e}`),this.shellExit=n}}function dt(t,e){return{exec:s(async(n,o,{onData:u,signal:i,timeout:L,env:w,yieldTo:c})=>{const $=it(L);if(i?.aborted)throw new Error("aborted");const S=e();try{await Ce(o,Te.F_OK)}catch{throw new Error(`Working directory does not exist: ${o}
|
|
2
|
+
Cannot execute ${t} commands.`)}const x=S.commandTransport==="stdin",r=Ie(S.shell,x?S.args:[...S.args,n],{cwd:o,detached:process.platform!=="win32",env:w??me(),stdio:[x?"pipe":"ignore","pipe","pipe"],windowsHide:!0});x&&(r.stdin?.on("error",()=>{}),r.stdin?.end(n)),r.pid&&Ne(r.pid);const a=performance.now();let p;r.once("exit",()=>{p=performance.now()-a});let h=!1,m=!1,f;const T=new Promise(U=>{f=s(()=>U("yielded"),"onYielded")});let R,D;const k=s(()=>{r.pid&&pe(r.pid)},"onAbort");try{$!==void 0&&(D=setTimeout(()=>{if(c&&r.exitCode===null&&r.signalCode===null&&c(r)){m=!0,f?.();return}h=!0,R=p,r.pid&&pe(r.pid)},$)),r.stdout?.on("data",u),r.stderr?.on("data",u),i&&(i.aborted?k():i.addEventListener("abort",k,{once:!0}));const U=Me(r),C=await Promise.race([U,T]);if(C==="yielded")return U.catch(()=>{}),{exitCode:null,yielded:!0};const O=C;if(i?.aborted)throw new Error("aborted");const g=r.signalCode,M=O??(g?128+(Pe.signals[g]??0):1);if(h)throw new Ee(($??te)/1e3,R!==void 0?{exitCode:M,afterSeconds:Math.round(R/100)/10}:void 0);return{exitCode:M}}finally{r.pid&&!m&&Be(r.pid),D&&clearTimeout(D),i&&i.removeEventListener("abort",k)}},"exec")}}s(dt,"createLocalShellOperations");function lt(t){return dt("bash",()=>ce(t?.shellPath))}s(lt,"createLocalBashOperations");const oe=Symbol.for("dal.shell.executionGuards"),ie=globalThis;ie[oe]instanceof Set||(ie[oe]=new Set);const se=ie[oe];function Kt(t){return se.add(t),()=>{se.delete(t)}}s(Kt,"registerShellExecutionGuard");async function ut(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}}s(ut,"shellExecutionRefusal");const ct=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function mt(t,e,n,o,u){const i={...me()};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 c=u.sessionManager.getSessionFile();c&&(i.PI_SESSION_FILE=c),w&&(i.PI_PROVIDER=w.provider,i.PI_MODEL=w.id),u.thinkingLevel&&(i.PI_REASONING_LEVEL=u.thinkingLevel)}for(const w of ct){delete i[`DAL_${w}`];const c=i[`PI_${w}`];c!==void 0&&(i[`DAL_${w}`]=c)}const L={command:t,cwd:e,env:i};return n?n(L):L}s(mt,"resolveSpawnContext");const pt=5,ft=100;class ht extends De{static{s(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function wt(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`}s(wt,"formatDuration");function St(t,e,n=!1){const o=he(t?.command),u=he(t?.description)?.trim(),i="";if(u){const w=E.fg("toolTitle",E.bold(u))+i;return!n||!o?w:`${w}
|
|
3
|
+
${E.fg("muted",` ${e} ${o.trim()}`)}`}const L=o===null?ze(E):o?E.fg("dim",Je(o.replace(/\s+/g," ").trim(),42)):E.fg("dim","\u2026");return`${E.fg("toolTitle",E.bold(e))} ${L}${i}`}s(St,"formatShellCall");function xt(t,e,n,o,u,i,L,w){const c=t.state;t.clear();const $=bt(n,u,i,w);if(!n.expanded&&!L){const a=fe(e,o),p=Ke(a),h=[];p>0&&h.push(Y(A("{count} \u884C"),{count:p})),$&&h.push($);const m=qe(E,h);m&&t.addChild(new V(m,0,0));return}let S=fe(e,o).trim();const x=e.details?.truncation,r=e.details?.fullOutputPath;if(!n.isPartial&&x?.truncated&&r&&S.endsWith("]")){const a=S.lastIndexOf(`
|
|
4
4
|
|
|
5
|
-
[`);
|
|
5
|
+
[`);a!==-1&&S.slice(a).includes(r)&&(S=S.slice(0,a).trimEnd())}if(S){const a=S.split(`
|
|
6
6
|
`).map(p=>E.fg("toolOutput",p)).join(`
|
|
7
|
-
`);n.expanded?t.addChild(new
|
|
8
|
-
${
|
|
9
|
-
${E.fg("warning",`[${
|
|
10
|
-
${E.fg("muted"
|
|
11
|
-
${T}`:T,C=mt(U,f?.cwd||t
|
|
7
|
+
`);n.expanded?t.addChild(new V(`
|
|
8
|
+
${a}`,0,0)):t.addChild({render:s(p=>{if(c.cachedLines===void 0||c.cachedWidth!==p){const h=ke(a,pt,p);c.cachedLines=h.visualLines,c.cachedSkipped=h.skippedCount,c.cachedWidth=p}if(c.cachedSkipped&&c.cachedSkipped>0){const h=E.fg("muted",Y(A("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:c.cachedSkipped}))+` ${Ae("app.tools.expand",A("\u5373\u53EF\u5C55\u5F00"))}${E.fg("muted",")")}`;return["",ve(h,p,"..."),...c.cachedLines??[]]}return["",...c.cachedLines??[]]},"render"),invalidate:s(()=>{c.cachedWidth=void 0,c.cachedLines=void 0,c.cachedSkipped=void 0},"invalidate")})}if(x?.truncated||r){const a=[];r&&a.push(Y(A("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:r})),x?.truncated&&(x.truncatedBy==="lines"?a.push(Y(A("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:x.outputLines,total:x.totalLines})):a.push(Y(A("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:x.outputLines,limit:et(x.maxBytes??Ze)}))),t.addChild(new V(`
|
|
9
|
+
${E.fg("warning",`[${a.join(". ")}]`)}`,0,0))}$&&t.addChild(new V(`
|
|
10
|
+
${E.fg("muted",$)}`,0,0))}s(xt,"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?A("\u5DF2\u8FD0\u884C"):A("\u8017\u65F6")} ${wt(u)}`}s(bt,"bashTimingLabel");function Et(t,e,n){const o=n?.operations??e.defaultOperations?.()??lt({shellPath:n?.shellPath}),u=n?.commandPrefix,i=n?.exposeSessionEnvironment??!0,L=n?.spawnHook,w=n?.sandbox,c=n?.operations===void 0,$=w?.describeForModel(),S=n?.background;let x=!1;const r=s(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:r(!1),prepareLoadout:S&&c?a=>(x=a.declared.some(p=>p.name==="process"),x?{descriptions:{[e.name]:r(!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?rt:xe,outputSchema:at,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(a,p,h,m,f){const{command:T,timeout:R}=p;m&&m({content:[],details:void 0});const D=w??(c?Ge():void 0),k=await ut({toolName:e.name,command:T,cwd:f?.cwd||t,sessionFile:f?.sessionManager?.getSessionFile(),...D?.active?{tempDir:D.scratchDir()}:{}});if(k!==void 0)throw new ue(k,je(void 0,He("dangerous-command",k)));const U=u?`${u}
|
|
11
|
+
${T}`:T,C=mt(U,f?.cwd||t,L,i,f);let O;if(D?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${D.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);O=await D.prepare({command:C.command,cwd:C.cwd,shell:e.sandboxShell(n?.shellPath),shellKind:e.sandboxShellKind??"bash",env:C.env,toolCallId:a,toolName:e.name,escalation:p.sandbox_escalation,ctx:f,signal:h})}const g=new Ve({tempFilePrefix:e.tempFilePrefix,maxBytes:ee});let M=!0,W,K=!1,re=0;const q=s(()=>{if(!m||!K)return;K=!1,re=Date.now();const d=g.snapshot({persistIfTruncated:!0});m({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),z=s(()=>{W&&(clearTimeout(W),W=void 0)},"clearUpdateTimer"),_e=s(()=>{if(!m)return;K=!0;const d=ft-(Date.now()-re);if(d<=0){z(),q();return}W??=setTimeout(()=>{W=void 0,q()},d)},"scheduleOutputUpdate"),Oe=s(d=>{M&&(g.append(d),_e())},"handleData"),ge=s(async()=>{M=!1,g.finish(),z(),q();const d=g.snapshot({persistIfTruncated:!0});return await g.closeTempFile(),d},"finishOutput"),J=s(async(d="(no output)")=>{const y=await ge(),F=await g.readFullOutput(nt),P=Xe()?void 0:Ye(F.content),_=tt(P?.text??F.content,ee);let I=y.fullOutputPath;(_.truncated||P)&&!I&&(I=await Fe(e.tempFilePrefix,".log",F.content));let N=_.content||d,H;const j=y.truncation.totalLines;return _.truncated?(H={truncation:{content:_.content,truncated:!0,truncatedBy:"bytes",totalLines:j,totalBytes:y.truncation.totalBytes,outputLines:_.headLines+_.tailLines,outputBytes:Buffer.byteLength(_.content,"utf-8"),lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:j,maxBytes:ee},fullOutputPath:I},N+=`
|
|
12
12
|
|
|
13
|
-
[Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${
|
|
13
|
+
[Truncated: first ${_.headLines} and last ${_.tailLines} of ${_.totalLines} lines shown${P?`, after condensing ${j} lines (${P.summary})`:""}; read more with read (offset/limit) or grep. Full output: ${I}]`):P&&(H={fullOutputPath:I},N+=`
|
|
14
14
|
|
|
15
|
-
[Condensed: ${P.summary}. Full output: ${
|
|
15
|
+
[Condensed: ${P.summary}. Full output: ${I}]`),{text:N,details:H,snapshot:y}},"modelOutput"),G=s((d,y)=>`${d?`${d}
|
|
16
16
|
|
|
17
|
-
`:""}${y}`,"appendStatus"),ae=performance.now();let
|
|
17
|
+
`:""}${y}`,"appendStatus"),ae=performance.now();let v;const Q=S&&c&&x?d=>{M=!1;try{return v=S.adopt({child:d,command:T,cwd:C.cwd,...O?{prepared:O}:{},...g.handOff()}),!0}catch{return M=!0,!1}}:void 0;try{let d;try{const b=await o.exec(O?.command??C.command,C.cwd,{onData:Oe,signal:h,timeout:R??(Q?ne:void 0),env:C.env,...Q?{yieldTo:Q}:{}});if(b.yielded&&v){const{text:B,details:de}=await J(""),X=R??ne,ye=v.urls.length>0?` It printed ${v.urls.join(" ")}.`:"",$e=`[Still running after ${X}s, now in the background as ${v.id}.${ye} For new output and the exit code call process with action "poll" and id "${v.id}"; "kill" stops it.]`,le=await g.readFullOutput(Se);return{content:[{type:"text",text:G(B,$e)}],details:{...de,background:v},structuredContent:{output:le.content,truncated:le.truncated,exit_code:-1,background_id:v.id,wall_time_seconds:Math.round((performance.now()-ae)/100)/10}}}d=b.exitCode}catch(b){const{text:B}=await J("");if(await O?.finish(null,""),b instanceof Error&&b.message==="aborted")throw new Error(G(B,"Command aborted"));if(b instanceof Error&&b.message.startsWith("timeout:")){let X=`Command timed out after ${b.message.split(":")[1]} seconds`;throw b instanceof Ee&&b.shellExit&&(X+=`. The shell exited with code ${b.shellExit.exitCode} after ${b.shellExit.afterSeconds} seconds, but background processes it started kept writing output until the timeout.`),new Error(G(B,X))}throw b}const{text:y,details:F,snapshot:P}=await J(),_=await O?.finish(d,P.content||"");if(_&&O)throw new ue(`${G(y,`Command exited with code ${d??"(none)"}`)}
|
|
18
18
|
|
|
19
|
-
${Ue(_)}`,{...F,sandbox:O.details});if(
|
|
20
|
-
${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(
|
|
19
|
+
${Ue(_)}`,{...F,sandbox:O.details});if(d===null)throw new Error(G(y,"Command terminated without an exit code"));const I=Math.round((performance.now()-ae)/100)/10,N=await g.readFullOutput(Se),H={output:N.content,truncated:N.truncated,...N.truncated&&P.fullOutputPath?{full_output_path:P.fullOutputPath}:{},exit_code:d,wall_time_seconds:I},j=O?.details.escalation?O.details:void 0,Z=j?{...F,sandbox:j}:F;if(d!==0){const b=d===127?await Re(y):void 0,B=G(y,`Command exited with code ${d}`);return{content:[{type:"text",text:b?`${B}
|
|
20
|
+
${b}`:B}],details:Z,structuredContent:H,isError:!0}}return{content:[{type:"text",text:y}],details:Z,structuredContent:H}}finally{z()}},renderCall(a,p,h){const m=h.state;h.executionStarted&&m.startedAt===void 0&&(m.startedAt=Date.now(),m.endedAt=void 0);const f=h.lastComponent??new V("",0,0);return f.setText(St(a,e.prompt,h.expanded===!0)),f},renderResult(a,p,h,m){const f=m.state;f.startedAt!==void 0&&p.isPartial&&!f.interval&&(f.interval=setInterval(()=>m.invalidate(),1e3)),(!p.isPartial||m.isError)&&(f.endedAt??=Date.now(),f.interval&&(clearInterval(f.interval),f.interval=void 0));const T=m.lastComponent??new ht;return xt(T,a,p,m.showImages,f.startedAt,f.endedAt,m.isError,m.durationMs),T.invalidate(),T}}}s(Et,"createShellToolDefinition");const _t={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:be.snippet,promptGuidelines:be.guidelines,tempFilePrefix:"dal-bash",readOnlyCommand:We,sandboxShell:s(t=>ce(t).shell,"sandboxShell")};function Ot(t,e){return Et(t,_t,e)}s(Ot,"createBashToolDefinition");function qt(t,e){const n=Ot(t,e),o=Qe(n);return Object.assign(o,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),o}s(qt,"createBashTool");export{be as bashToolSystemPromptContribution,qt as createBashTool,Ot as createBashToolDefinition,lt as createLocalBashOperations,dt as createLocalShellOperations,Et as createShellToolDefinition,Kt as registerShellExecutionGuard,st as sandboxEscalationSchema,ut as shellExecutionRefusal};
|
package/dist/core/tools/edit.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)
|
|
3
|
-
`);return!c||c===o?void 0:r.fg("error",c)}const s=i.details?.diff;if(s&&s!==n)return S(s,{filePath:a??void 0})}d(de,"formatEditResult");function ae(e,t,i){return e?"error"in e?r=>i.bg("toolErrorBg",r):r=>i.bg("toolSuccessBg",r):t?r=>i.bg("toolErrorBg",r):r=>i.bg("toolPendingBg",r)}d(ae,"getEditHeaderBg");function K(e,t,i,r,f,a){e.setPaddingX(a),e.setBgFn("error"in(e.preview??{})||e.settledError?ae(e.preview,e.settledError,i):void 0),e.clear();let n=se(t,i,r);if(!f&&e.preview&&!("error"in e.preview)){const{additions:s,removals:c}=oe(e.preview.diff);n+=i.fg("muted",` +${s} / -${c}`)}if(e.addChild(new E(n,0,0)),!e.preview||!f&&!("error"in e.preview))return e;const o="error"in e.preview?i.fg("error",e.preview.error):S(e.preview.diff);return e.addChild(new x(1)),e.addChild(new E(o,0,0)),e}d(K,"buildEditCallComponent");function _(e,t,i){const r=e.preview,f=r===void 0||("error"in r&&"error"in t?r.error!==t.error:"error"in r!="error"in t)||!("error"in r)&&!("error"in t)&&(r.diff!==t.diff||r.firstChangedLine!==t.firstChangedLine);return e.preview=t,e.previewArgsKey=i,e.previewPending=!1,f}d(_,"setEditPreview");function le(e,t){const i=t?.operations??ee;return{name:"edit",label:"edit",description:"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.",promptSnippet:D.snippet,promptGuidelines:[...D.guidelines],parameters:Z,constrainedSampling:{type:"json_schema",strict:"prefer"},renderShell:"self",prepareArguments:te,async execute(r,f,a,n,o){const{path:s,edits:c}=re(f),l=Q(s,o?.cwd||e);return H(l,async()=>{const p=d(()=>{if(a?.aborted)throw new Error("Operation aborted")},"throwIfAborted");p();try{await i.access(l)}catch(y){p();const B=y instanceof Error&&"code"in y?`Error code: ${y.code}`:String(y);throw new Error(`Could not edit file: ${s}. ${B}.`)}p();const w=(await i.readFile(l)).toString("utf-8");p();const{bom:u,text:m}=N(w),T=G(m),{baseContent:I,newContent:C,replacements:v}=z(T,c,s),R=U(s,I,C,v);p();const j=u+(m===T?C:J(m,v));return await i.writeFile(l,j),p(),{content:[{type:"text",text:`Successfully replaced ${c.length} block(s) in ${s}.`}],details:R}})},renderCall(r,f,a){const n=ne(a.state,a.lastComponent),o=F(r),s=o?JSON.stringify({path:o.path,edits:o.edits}):void 0;if(n.previewArgsKey!==s&&(n.preview=void 0,n.previewArgsKey=s,n.previewPending=!1,n.settledError=!1),a.argsComplete&&o&&!n.preview&&!n.previewPending){n.previewPending=!0;const c=s;M(o.path,o.edits,a.cwd).then(l=>{n.previewArgsKey===c&&(_(n,l,c),a.invalidate())})}return K(n,r,f,a.cwd,a.expanded,a.outputPad)},renderResult(r,f,a,n){const o=n.state.callComponent,s=F(n.args),c=s?JSON.stringify({path:s.path,edits:s.edits}):void 0,l=r,p=n.isError?void 0:l.details?.diff;let h=!1;o&&(typeof p=="string"&&(h=_(o,{diff:p,firstChangedLine:l.details?.firstChangedLine},c)||h),o.settledError!==n.isError&&(o.settledError=n.isError,h=!0),h&&K(o,n.args,a,n.cwd,f.expanded,n.outputPad));const w=de(n.args,o?.preview,l,a,n.isError),u=n.lastComponent??new W;return u.clear(),w&&(u.addChild(new x(1)),u.addChild(new E(w,1+n.outputPad,0))),u}}}d(le,"createEditToolDefinition");function ve(e,t){return V(le(e,t))}d(ve,"createEditTool");export{ve as createEditTool,le as createEditToolDefinition,D as editToolSystemPromptContribution};
|
|
1
|
+
var B=Object.defineProperty;var d=(e,t)=>B(e,"name",{value:t,configurable:!0});import{Box as E,Container as $,Spacer as x,Text as C}from"@earendil-works/pi-tui";import{constants as A}from"fs";import{access as L,readFile as k,writeFile as q}from"fs/promises";import{Type as h}from"typebox";import{DiffView as S,diffLineCounts as N,formatDiffLineCounts as z}from"../../modes/interactive/components/diff.js";import{splitBom as J}from"../../utils/text.js";import{applyEditsToNormalizedContent as M,applyReplacementsToOriginal as U,computeEditsDiff as W,generateEditDiff as G,normalizeToLF as H}from"./edit-diff.js";import{withFileMutationQueue as Q}from"./file-mutation-queue.js";import{resolveToCwd as V}from"./path-utils.js";import{renderToolPath as X,str as Y}from"./render-utils.js";import{wrapToolDefinition as Z}from"./tool-definition-wrapper.js";const ee=h.Object({oldText:h.String({description:"Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call."}),newText:h.String({description:"Replacement text for this targeted edit."})},{}),te=h.Object({path:h.String({description:"Path to the file to edit (relative or absolute)"}),edits:h.Array(ee,{description:"One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead."})},{}),P={snippet:"Make precise file edits with exact text replacement, including multiple disjoint edits in one call",guidelines:["Use edit for targeted changes. Batch changes to one file in a single call.","Each edits[].oldText must exactly and uniquely match the original file. Keep matches short and non-overlapping; merge nearby changes without including large unchanged regions."]};function D(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return typeof t.oldText=="string"&&typeof t.newText=="string"}d(D,"isSingleEditInput");const re={readFile:d(e=>k(e),"readFile"),writeFile:d((e,t)=>q(e,t,"utf-8"),"writeFile"),access:d(e=>L(e,A.R_OK|A.W_OK),"access")};function ie(e){if(!e||typeof e!="object")return e;const t=e;if(typeof t.edits=="string")try{const o=JSON.parse(t.edits);Array.isArray(o)?t.edits=o:D(o)&&(t.edits=[o])}catch{}else D(t.edits)&&(t.edits=[t.edits]);const r=t;if(typeof r.oldText!="string"||typeof r.newText!="string")return t;const i=Array.isArray(r.edits)?[...r.edits]:[];i.push({oldText:r.oldText,newText:r.newText});const{oldText:l,newText:s,...n}=r;return{...n,edits:i}}d(ie,"prepareEditArguments");function ne(e){if(!Array.isArray(e.edits)||e.edits.length===0)throw new Error("Edit tool input is invalid. edits must contain at least one replacement.");return{path:e.path,edits:e.edits}}d(ne,"validateEditInput");function oe(){return Object.assign(new E(0,0),{preview:void 0,previewArgsKey:void 0,previewPending:!1,settledError:!1})}d(oe,"createEditCallRenderComponent");function se(e,t){if(t instanceof E){const i=t;return e.callComponent=i,i}if(e.callComponent)return e.callComponent;const r=oe();return e.callComponent=r,r}d(se,"getEditCallRenderComponent");function O(e){if(!e)return null;const t=typeof e.path=="string"?e.path:typeof e.file_path=="string"?e.file_path:null;return t?Array.isArray(e.edits)&&e.edits.length>0&&e.edits.every(r=>typeof r?.oldText=="string"&&typeof r?.newText=="string")?{path:t,edits:e.edits}:typeof e.oldText=="string"&&typeof e.newText=="string"?{path:t,edits:[{oldText:e.oldText,newText:e.newText}]}:null:null}d(O,"getRenderablePreviewInput");function de(e,t,r){const i=X(Y(e?.file_path??e?.path),t,r);return`${t.fg("toolTitle",t.bold("edit"))} ${i}`}d(de,"formatEditCall");function ae(e,t,r,i,l){const s=t&&!("error"in t)?t.diff:void 0,n=t&&"error"in t?t.error:void 0;if(l){const a=r.content.filter(f=>f.type==="text").map(f=>f.text||"").join(`
|
|
2
|
+
`);return!a||a===n?void 0:new C(i.fg("error",a),0,0)}const o=r.details?.diff;if(o&&o!==s)return new S(o)}d(ae,"formatEditResult");function le(e,t,r){return e?"error"in e?i=>r.bg("toolErrorBg",i):i=>r.bg("toolSuccessBg",i):t?i=>r.bg("toolErrorBg",i):i=>r.bg("toolPendingBg",i)}d(le,"getEditHeaderBg");function F(e,t,r,i,l,s){e.setPaddingX(s),e.setBgFn("error"in(e.preview??{})||e.settledError?le(e.preview,e.settledError,r):void 0),e.clear();let n=de(t,r,i);if(!l&&e.preview&&!("error"in e.preview)){const o=z(N(e.preview.diff));o&&(n+=r.fg("muted",` ${o}`))}return e.addChild(new C(n,0,0)),!e.preview||!l&&!("error"in e.preview)||(e.addChild(new x(1)),e.addChild("error"in e.preview?new C(r.fg("error",e.preview.error),0,0):new S(e.preview.diff))),e}d(F,"buildEditCallComponent");function K(e,t,r){const i=e.preview,l=i===void 0||("error"in i&&"error"in t?i.error!==t.error:"error"in i!="error"in t)||!("error"in i)&&!("error"in t)&&(i.diff!==t.diff||i.firstChangedLine!==t.firstChangedLine);return e.preview=t,e.previewArgsKey=r,e.previewPending=!1,l}d(K,"setEditPreview");function fe(e,t){const r=t?.operations??re;return{name:"edit",label:"edit",description:"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.",promptSnippet:P.snippet,promptGuidelines:[...P.guidelines],parameters:te,constrainedSampling:{type:"json_schema",strict:"prefer"},renderShell:"self",prepareArguments:ie,async execute(i,l,s,n,o){const{path:a,edits:f}=ne(l),c=V(a,o?.cwd||e);return Q(c,async()=>{const p=d(()=>{if(s?.aborted)throw new Error("Operation aborted")},"throwIfAborted");p();try{await r.access(c)}catch(m){p();const j=m instanceof Error&&"code"in m?`Error code: ${m.code}`:String(m);throw new Error(`Could not edit file: ${a}. ${j}.`)}p();const y=(await r.readFile(c)).toString("utf-8");p();const{bom:u,text:g}=J(y),T=H(g),{baseContent:_,newContent:b,replacements:v}=M(T,f,a),I=G(a,_,b,v);p();const R=u+(g===T?b:U(g,v));return await r.writeFile(c,R),p(),{content:[{type:"text",text:`Successfully replaced ${f.length} block(s) in ${a}.`}],details:I}})},renderCall(i,l,s){const n=se(s.state,s.lastComponent),o=O(i),a=o?JSON.stringify({path:o.path,edits:o.edits}):void 0;if(n.previewArgsKey!==a&&(n.preview=void 0,n.previewArgsKey=a,n.previewPending=!1,n.settledError=!1),s.argsComplete&&o&&!n.preview&&!n.previewPending){n.previewPending=!0;const f=a;W(o.path,o.edits,s.cwd).then(c=>{n.previewArgsKey===f&&(K(n,c,f),s.invalidate())})}return F(n,i,l,s.cwd,s.expanded,s.outputPad)},renderResult(i,l,s,n){const o=n.state.callComponent,a=O(n.args),f=a?JSON.stringify({path:a.path,edits:a.edits}):void 0,c=i,p=n.isError?void 0:c.details?.diff;let w=!1;o&&(typeof p=="string"&&(w=K(o,{diff:p,firstChangedLine:c.details?.firstChangedLine},f)||w),o.settledError!==n.isError&&(o.settledError=n.isError,w=!0),w&&F(o,n.args,s,n.cwd,l.expanded,n.outputPad));const y=ae(n.args,o?.preview,c,s,n.isError),u=n.lastComponent??new $;if(u.clear(),!y)return u;u.addChild(new x(1));const g=new E(1+n.outputPad,0);return g.addChild(y),u.addChild(g),u}}}d(fe,"createEditToolDefinition");function ve(e,t){return Z(fe(e,t))}d(ve,"createEditTool");export{ve as createEditTool,fe as createEditToolDefinition,P as editToolSystemPromptContribution};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var S=Object.defineProperty;var c=(
|
|
2
|
-
${d.fg("muted",`
|
|
1
|
+
var S=Object.defineProperty;var c=(n,i)=>S(n,"name",{value:i,configurable:!0});import{Container as A,Spacer as C,Text as p}from"@earendil-works/pi-tui";import{fill as $,t as f}from"../../../dal/i18n.js";import{keyHint as v}from"../../../modes/interactive/components/keybinding-hints.js";import{VisualLinePreview as P}from"../../../modes/interactive/components/visual-truncate.js";import{theme as d}from"../../../modes/interactive/theme/theme.js";import{getTextOutput as E,invalidArgText as x,str as w}from"../render-utils.js";import{DEFAULT_MAX_BYTES as _,formatSize as L}from"../truncate.js";const O=5,k=100;function g(n){const i=n/1e3;if(i<60)return`${i.toFixed(1)}s`;const r=Math.floor(i),e=Math.floor(r/60),t=r%60;return e<60?`${e}m ${t}s`:`${Math.floor(e/60)}h ${e%60}m ${t}s`}c(g,"formatDuration");function D(n,i,r){const e=w(n?.command),t=w(n?.description)?.trim(),a="",l=e===null?x(d):e||d.fg("toolOutput","...");if(!t)return d.fg("toolTitle",d.bold(`${i} ${l}`))+a;const o=d.fg("toolTitle",d.bold(t))+a;return r?`${o}
|
|
2
|
+
${d.fg("muted",` ${i} ${e??""}`.trimEnd())}`:o}c(D,"formatShellCall");function B(n,i,r,e,t,a,l){n.clear();let o=E(i,e).trim();const u=i.details?.truncation,h=i.details?.fullOutputPath;if(!r.isPartial&&u?.truncated&&h&&o.endsWith("]")){const s=o.lastIndexOf(`
|
|
3
3
|
|
|
4
|
-
[`);s!==-1&&
|
|
4
|
+
[`);s!==-1&&o.slice(s).includes(h)&&(o=o.slice(0,s).trimEnd())}if(o){const s=o.split(`
|
|
5
5
|
`).map(m=>d.fg("toolOutput",m)).join(`
|
|
6
|
-
`);r.expanded?
|
|
7
|
-
${s}`,0,0)):(
|
|
8
|
-
${d.fg("warning",`[${s.join(". ")}]`)}`,0,0))}if(!r.isPartial&&l!==void 0)l>=100&&
|
|
9
|
-
${d.fg("muted",`${f("\u8017\u65F6")} ${g(l)}`)}`,0,0));else if(t!==void 0){const m=(a??Date.now())-t;if(r.isPartial||m>=100){const T=r.isPartial?f("\u5DF2\u8FD0\u884C"):f("\u8017\u65F6");
|
|
10
|
-
${d.fg("muted",`${T} ${g(m)}`)}`,0,0))}}}c(B,"rebuildBashResultRenderComponent");function F(
|
|
6
|
+
`);r.expanded?n.addChild(new p(`
|
|
7
|
+
${s}`,0,0)):(n.addChild(new C(1)),n.addChild(new P({text:s,maxVisualLines:O,keep:"end",formatHint:c(m=>d.fg("muted",$(f("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:m}))+` ${v("app.tools.expand",f("\u5373\u53EF\u5C55\u5F00"))}${d.fg("muted",")")}`,"formatHint")})))}if(u?.truncated||h){const s=[];h&&s.push($(f("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:h})),u?.truncated&&(u.truncatedBy==="lines"?s.push($(f("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:u.outputLines,total:u.totalLines})):s.push($(f("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:u.outputLines,limit:L(u.maxBytes??_)}))),n.addChild(new p(`
|
|
8
|
+
${d.fg("warning",`[${s.join(". ")}]`)}`,0,0))}if(!r.isPartial&&l!==void 0)l>=100&&n.addChild(new p(`
|
|
9
|
+
${d.fg("muted",`${f("\u8017\u65F6")} ${g(l)}`)}`,0,0));else if(t!==void 0){const m=(a??Date.now())-t;if(r.isPartial||m>=100){const T=r.isPartial?f("\u5DF2\u8FD0\u884C"):f("\u8017\u65F6");n.addChild(new p(`
|
|
10
|
+
${d.fg("muted",`${T} ${g(m)}`)}`,0,0))}}}c(B,"rebuildBashResultRenderComponent");function F(n){return{renderCall(i,r,e){const t=e.state;e.executionStarted&&t.startedAt===void 0&&(t.startedAt=Date.now(),t.endedAt=void 0);const a=i,l=e.lastComponent??new p("",0,0);return l.setText(D(a,n,e.expanded===!0)),l},renderResult(i,r,e,t){const a=t.state;a.startedAt!==void 0&&r.isPartial&&!a.interval&&(a.interval=setInterval(()=>t.invalidate(),1e3)),(!r.isPartial||t.isError)&&(a.endedAt??=Date.now(),a.interval&&(clearInterval(a.interval),a.interval=void 0));const l=t.lastComponent??new A;return B(l,i,r,t.showImages,a.startedAt,a.endedAt,t.durationMs),l.invalidate(),l}}}c(F,"createShellRenderers");export{k as BASH_UPDATE_THROTTLE_MS,F as createShellRenderers};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var P=Object.defineProperty;var
|
|
2
|
-
`);return!
|
|
1
|
+
var P=Object.defineProperty;var s=(e,i)=>P(e,"name",{value:i,configurable:!0});import{Box as p,Container as T,Spacer as c,Text as g}from"@earendil-works/pi-tui";import{DiffView as y,diffLineCounts as b,formatDiffLineCounts as K}from"../../../modes/interactive/components/diff.js";import{computeEditsDiff as A}from"../edit-diff.js";import{renderToolPath as B,str as D}from"../render-utils.js";function R(){return Object.assign(new p(1,1,e=>e),{preview:void 0,previewArgsKey:void 0,previewPending:!1,settledError:!1})}s(R,"createEditCallRenderComponent");function L(e,i){if(i instanceof p){const r=i;return e.callComponent=r,r}if(e.callComponent)return e.callComponent;const n=R();return e.callComponent=n,n}s(L,"getEditCallRenderComponent");function v(e){if(!e)return null;const i=typeof e.path=="string"?e.path:typeof e.file_path=="string"?e.file_path:null;return i?Array.isArray(e.edits)&&e.edits.length>0&&e.edits.every(n=>typeof n?.oldText=="string"&&typeof n?.newText=="string")?{path:i,edits:e.edits}:typeof e.oldText=="string"&&typeof e.newText=="string"?{path:i,edits:[{oldText:e.oldText,newText:e.newText}]}:null:null}s(v,"getRenderablePreviewInput");function _(e,i,n){const r=B(D(e?.file_path??e?.path),i,n);return`${i.fg("toolTitle",i.bold("edit"))} ${r}`}s(_,"formatEditCall");function S(e,i,n,r,t){const d=i&&!("error"in i)?i.diff:void 0,f=i&&"error"in i?i.error:void 0;if(t){const u=n.content.filter(l=>l.type==="text").map(l=>l.text||"").join(`
|
|
2
|
+
`);return!u||u===f?void 0:new g(r.fg("error",u),0,0)}const o=n.details?.diff;if(o&&o!==d)return new y(o)}s(S,"formatEditResult");function I(e,i,n){return e?"error"in e?r=>n.bg("toolErrorBg",r):r=>n.bg("toolSuccessBg",r):i?r=>n.bg("toolErrorBg",r):r=>n.bg("toolPendingBg",r)}s(I,"getEditHeaderBg");function h(e,i,n,r,t){e.setBgFn(I(e.preview,e.settledError,n)),e.setPaddingX(t),e.clear();let d=_(i,n,r);if(e.preview&&!("error"in e.preview)){const f=K(b(e.preview.diff));f&&(d+=n.fg("muted",` ${f}`))}return e.addChild(new g(d,0,0)),e.preview&&(e.addChild(new c(1)),e.addChild("error"in e.preview?new g(n.fg("error",e.preview.error),0,0):new y(e.preview.diff))),e}s(h,"buildEditCallComponent");function E(e,i,n){const r=e.preview,t=r===void 0||("error"in r&&"error"in i?r.error!==i.error:"error"in r!="error"in i)||!("error"in r)&&!("error"in i)&&(r.diff!==i.diff||r.firstChangedLine!==i.firstChangedLine);return e.preview=i,e.previewArgsKey=n,e.previewPending=!1,t}s(E,"setEditPreview");const m={renderCall(e,i,n){const r=L(n.state,n.lastComponent),t=v(e),d=t?JSON.stringify({path:t.path,edits:t.edits}):void 0;if(r.previewArgsKey!==d&&(r.preview=void 0,r.previewArgsKey=d,r.previewPending=!1,r.settledError=!1),n.argsComplete&&t&&!r.preview&&!r.previewPending){r.previewPending=!0;const f=d;A(t.path,t.edits,n.cwd).then(o=>{r.previewArgsKey===f&&(E(r,o,f),n.invalidate())})}return h(r,e,i,n.cwd,n.outputPad)},renderResult(e,i,n,r){const t=r.state.callComponent,d=v(r.args),f=d?JSON.stringify({path:d.path,edits:d.edits}):void 0,o=e,u=r.isError?void 0:o.details?.diff;let l=!1;t&&(typeof u=="string"&&(l=E(t,{diff:u,firstChangedLine:o.details?.firstChangedLine},f)||l),t.settledError!==r.isError&&(t.settledError=r.isError,l=!0),l&&h(t,r.args,n,r.cwd,r.outputPad));const w=S(r.args,t?.preview,o,n,r.isError),a=r.lastComponent??new T;if(a.clear(),!w)return a;a.addChild(new c(1));const C=new p(r.outputPad,0);return C.addChild(w),a.addChild(C),a}};export{m as editRenderers};
|
|
@@ -16,6 +16,7 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
16
16
|
private messageId?;
|
|
17
17
|
private timestamp?;
|
|
18
18
|
private thinkingVisibilityOverrides;
|
|
19
|
+
private thinkingTimes;
|
|
19
20
|
private markdownSlots;
|
|
20
21
|
constructor(message?: AssistantMessage, hideThinkingBlock?: boolean, markdownTheme?: MarkdownTheme, hiddenThinkingLabel?: string, outputPad?: number, markdownTransformers?: readonly MarkdownTransformer[], messageId?: string, timestamp?: string);
|
|
21
22
|
isBlank(): boolean;
|
|
@@ -25,5 +26,7 @@ export declare class AssistantMessageComponent extends Container {
|
|
|
25
26
|
isThinkingLive(): boolean;
|
|
26
27
|
setOutputPad(padding: number): void;
|
|
27
28
|
render(width: number): string[];
|
|
29
|
+
private trackThinkingRun;
|
|
30
|
+
private thoughtLine;
|
|
28
31
|
updateContent(message: AssistantMessage, isStreaming?: boolean): void;
|
|
29
32
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var R=Object.defineProperty;var w=(b,t)=>R(b,"name",{value:t,configurable:!0});import{Container as B,Markdown as L,MouseRegion as O,Spacer as l,Text as c}from"@earendil-works/pi-tui";import{fill as M,t as r}from"../../../dal/i18n.js";import{getMarkdownTheme as V,theme as o}from"../theme/theme.js";import{keyText as I}from"./keybinding-hints.js";import{createMarkdownTransform as v}from"./markdown-transform.js";import{formatWorkingElapsed as A}from"./status-indicator.js";const _="\x1B]133;A\x07",E="\x1B]133;B\x07",N="\x1B]133;C\x07";class W extends B{static{w(this,"AssistantMessageComponent")}contentContainer;hideThinkingBlock;markdownTheme;hiddenThinkingLabel;outputPad;markdownTransformers;lastMessage;hasToolCalls=!1;blank=!0;isStreaming=!1;thinkingLive=!1;messageId;timestamp;thinkingVisibilityOverrides=new Map;thinkingTimes=new Map;markdownSlots=[];constructor(t,n=!1,a=V(),e=r("\u601D\u8003\u4E2D\u2026"),u=1,m=[],p,T){super(),this.hideThinkingBlock=n,this.markdownTheme=a,this.hiddenThinkingLabel=e,this.outputPad=u,this.markdownTransformers=m,this.messageId=p,this.timestamp=T,this.contentContainer=new B,this.addChild(this.contentContainer),t&&this.updateContent(t)}isBlank(){return this.blank}invalidate(){super.invalidate(),this.lastMessage&&this.updateContent(this.lastMessage)}setHideThinkingBlock(t){this.hideThinkingBlock=t,this.thinkingVisibilityOverrides.clear(),this.lastMessage&&this.updateContent(this.lastMessage)}setHiddenThinkingLabel(t){this.hiddenThinkingLabel=t,this.lastMessage&&this.updateContent(this.lastMessage)}isThinkingLive(){return this.thinkingLive}setOutputPad(t){this.outputPad=t,this.markdownSlots=[],this.lastMessage&&this.updateContent(this.lastMessage)}render(t){const n=super.render(t);return this.hasToolCalls||n.length===0||(n[0]=_+n[0],n[n.length-1]=E+N+n[n.length-1]),n}trackThinkingRun(t,n){const a=Date.now();let e=this.thinkingTimes.get(t);!e&&this.isStreaming&&(e={start:a},this.thinkingTimes.set(t,e)),e&&n&&e.end===void 0&&(e.end=a)}thoughtLine(t){const n=this.thinkingTimes.get(t),a=n?.end!==void 0?M(r("\u5DF2\u601D\u8003 {duration}"),{duration:A(Math.max(1e3,Math.round((n.end-n.start)/1e3)*1e3))}):r("\u5DF2\u601D\u8003"),e=I("app.thinking.toggle"),u=e?o.fg("dim",M(r("\uFF08{key} \u5C55\u5F00\uFF09"),{key:e})):"";return`${o.fg("dim","\u273B")} ${o.italic(o.fg("thinkingText",a))}${u}`}updateContent(t,n=this.isStreaming){this.lastMessage=t,this.isStreaming=n,this.thinkingLive=!1,this.contentContainer.clear();const a=this.markdownSlots;this.markdownSlots=[];const e=w((i,g,d)=>{const k=a[this.markdownSlots.length],h=k?.kind===i?k.markdown:d();return h.setText(g),this.markdownSlots.push({kind:i,markdown:h}),h},"markdownBlock"),u=!this.hideThinkingBlock||this.isStreaming,m=t.content.some(i=>i.type==="text"&&i.text.trim()||i.type==="thinking"&&i.thinking.trim()&&u),p=t.content.some(i=>i.type==="text"&&i.text.trim().length>0);this.blank=!m,m&&this.contentContainer.addChild(new l(1));let T=0;for(let i=0;i<t.content.length;i++){const g=t.content[i];if(g.type==="text"&&g.text.trim()){const d=g.text.trim();this.contentContainer.addChild(e("text",d,()=>new L(d,this.outputPad,0,this.markdownTheme,void 0,{transform:v("assistant",()=>this.isStreaming,this.markdownTransformers,this.messageId,this.timestamp)})))}else if(g.type==="thinking"){const d=[];for(;i<t.content.length;i++){const s=t.content[i];if(s.type!=="thinking")break;const f=s.thinking.trim();f&&d.push(f)}if(i--,d.length===0)continue;const k=t.content.slice(i+1).some(s=>s.type==="text"&&s.text.trim()||s.type==="thinking"&&s.thinking.trim()),h=T++,y=!this.isStreaming||k;this.trackThinkingRun(h,y);const S=this.hideThinkingBlock&&this.thinkingVisibilityOverrides.get(h)===!0;if(this.hideThinkingBlock&&!S)y?p&&(this.contentContainer.addChild(new O(new c(this.thoughtLine(h),this.outputPad,0),s=>{if(!(s.type!=="click"||s.button!=="left"))return this.thinkingVisibilityOverrides.set(h,!0),this.lastMessage&&this.updateContent(this.lastMessage),{handled:!0}})),k&&this.contentContainer.addChild(new l(1))):this.thinkingLive=!0;else{const s=this.hideThinkingBlock?!1:this.thinkingVisibilityOverrides.get(h)??!1,f=d.join(`
|
|
2
2
|
|
|
3
|
-
`),
|
|
3
|
+
`),P=s?new c(o.italic(o.fg("thinkingText",this.hiddenThinkingLabel)),this.outputPad,0):e("thinking",f,()=>new L(f,this.outputPad,0,this.markdownTheme,{color:w(C=>o.fg("thinkingText",C),"color"),italic:!0},{transform:v("assistant-thinking",()=>this.isStreaming,this.markdownTransformers,this.messageId,this.timestamp)}));this.contentContainer.addChild(new O(P,C=>{if(!(C.type!=="click"||C.button!=="left"))return this.thinkingVisibilityOverrides.set(h,this.hideThinkingBlock?!1:!s),this.lastMessage&&this.updateContent(this.lastMessage),{handled:!0}}))}k&&(!this.hideThinkingBlock||S)&&this.contentContainer.addChild(new l(1))}}const x=t.content.some(i=>i.type==="toolCall");if(this.hasToolCalls=x,t.stopReason==="length")this.contentContainer.addChild(new l(1)),this.contentContainer.addChild(new c(o.fg("error",r("\u56DE\u590D\u5728\u5B8C\u6210\u524D\u88AB\u622A\u65AD\u4E86\u3002")),this.outputPad,0));else if(!x)if(t.stopReason==="aborted"){const i=t.errorMessage&&t.errorMessage!=="Request was aborted"?t.errorMessage:r("\u64CD\u4F5C\u5DF2\u4E2D\u6B62");this.contentContainer.addChild(new l(1)),this.contentContainer.addChild(new c(o.fg("error",i),this.outputPad,0))}else if(t.stopReason==="error"){const i=t.errorMessage||r("\u672A\u77E5\u9519\u8BEF");this.contentContainer.addChild(new l(1)),this.contentContainer.addChild(new c(o.fg("error",M(r("\u9519\u8BEF\uFF1A{error}"),{error:i})),this.outputPad,0))}else t.stopReason==="stop"&&(p||(this.contentContainer.addChild(new l(1)),this.contentContainer.addChild(new c(o.fg("error",r("\u9519\u8BEF\uFF1A\u6A21\u578B\u8FD4\u56DE\u4E86\u7A7A\u56DE\u590D\u3002")),this.outputPad,0))))}}export{W as AssistantMessageComponent};
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
`,r=x("summary",()=>!1,this.markdownTransformers,this.messageId,this.timestamp);e.addChild(new g(this.message.summary,0,0,this.markdownTheme,{color:o(s=>m.fg("customMessageText",s),"color")},{transform:o((s,l)=>t+r(s,l),"transform")}))}else e.addChild(new h(`${n} ${m.fg("customMessageText",p(d("\u5DF2\u538B\u7F29 {count} \u4E2A token"),{count:a}))}`,0,0));this.addChild(new k(e,t=>{if(!(t.type!=="click"||t.button!=="left"))return this.setExpanded(!this.expanded),{handled:!0}}))}}export{D as CompactionSummaryMessageComponent};
|
|
1
|
+
var h=Object.defineProperty;var d=(i,e)=>h(i,"name",{value:e,configurable:!0});import{Box as p,Container as l,Markdown as u,MouseRegion as f,Text as m}from"@earendil-works/pi-tui";import{t as c}from"../../../dal/i18n.js";import{getMarkdownTheme as w,theme as o}from"../theme/theme.js";import{createMarkdownTransform as g}from"./markdown-transform.js";class M extends p{static{d(this,"CompactionSummaryMessageComponent")}markdownTransformers=[];messageId;timestamp;expanded=!1;message;markdownTheme;constructor(e,a=w(),s=0,r=[],t,n){super(s,0),this.markdownTransformers=r,this.messageId=t,this.timestamp=n,this.message=e,this.markdownTheme=a,this.updateDisplay()}setExpanded(e){this.expanded=e,this.updateDisplay()}setOutputPad(e){this.setPaddingX(e)}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){this.clear();const e=new l,a=o.fg("muted",c("\u8F83\u65E9\u7684\u5BF9\u8BDD\u5DF2\u6574\u7406\u4E3A\u6458\u8981"));if(this.expanded){e.addChild(new m(a,0,0));const s="",r=g("summary",()=>!1,this.markdownTransformers,this.messageId,this.timestamp);e.addChild(new u(this.message.summary,0,0,this.markdownTheme,{color:d(t=>o.fg("customMessageText",t),"color")},{transform:d((t,n)=>s+r(t,n),"transform")}))}else e.addChild(new m(a,0,0));this.addChild(new f(e,s=>{if(!(s.type!=="click"||s.button!=="left"))return this.setExpanded(!this.expanded),{handled:!0}}))}}export{M as CompactionSummaryMessageComponent};
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
+
import { type Component } from "@earendil-works/pi-tui";
|
|
2
|
+
export type DiffRowKind = "added" | "removed" | "context" | "gap" | "other";
|
|
3
|
+
export interface DiffRow {
|
|
4
|
+
kind: DiffRowKind;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function diffRows(diffText: string): DiffRow[];
|
|
1
8
|
export interface RenderDiffOptions {
|
|
2
9
|
filePath?: string;
|
|
3
10
|
}
|
|
4
11
|
export declare function renderDiff(diffText: string, _options?: RenderDiffOptions): string;
|
|
12
|
+
export declare function diffLineCounts(diffText: string): {
|
|
13
|
+
added: number;
|
|
14
|
+
removed: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function formatDiffLineCounts(counts: {
|
|
17
|
+
added: number;
|
|
18
|
+
removed: number;
|
|
19
|
+
}): string;
|
|
20
|
+
export declare class DiffView implements Component {
|
|
21
|
+
private readonly rows;
|
|
22
|
+
private cache?;
|
|
23
|
+
constructor(diffText: string);
|
|
24
|
+
invalidate(): void;
|
|
25
|
+
render(width: number): string[];
|
|
26
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
3
|
-
`)}
|
|
1
|
+
var k=Object.defineProperty;var a=(e,t)=>k(e,"name",{value:t,configurable:!0});import{visibleWidth as N,wrapTextWithAnsi as L}from"@earendil-works/pi-tui";import*as w from"diff";import{fill as v,t as g}from"../../../dal/i18n.js";import{theme as c}from"../theme/theme.js";function p(e){const t=e.match(/^([+-\s])(\s*\d*)\s(.*)$/);return t?{prefix:t[1],lineNum:t[2],content:t[3]}:null}a(p,"parseDiffLine");function x(e){return/^\s*\.\.\.\s*$/.test(e)}a(x,"isGapLine");function h(e){return e.replace(/\t/g," ")}a(h,"replaceTabs");function W(e,t){let n=0;for(;n<e.length&&e[n]===t[n]&&/\s/.test(e[n]);)n++;const f=e.slice(0,n),o=w.diffWords(e.slice(n),t.slice(n));let r=f,d=f,l=!0,u=!0;for(const i of o)if(i.removed){let s=i.value;if(l){const m=s.match(/^(\s*)/)?.[1]||"";s=s.slice(m.length),r+=m,l=!1}s&&(r+=c.inverse(s))}else if(i.added){let s=i.value;if(u){const m=s.match(/^(\s*)/)?.[1]||"";s=s.slice(m.length),d+=m,u=!1}s&&(d+=c.inverse(s))}else r+=i.value,d+=i.value;return{removedLine:r,addedLine:d}}a(W,"renderIntraLineDiff");function $(e){const t=e.split(`
|
|
2
|
+
`),n=[];let f=0;for(const r of t){if(x(r))continue;const d=p(r);if(d&&/\d/.test(d.lineNum)){f=d.lineNum.length;break}}let o=0;for(;o<t.length;){const r=t[o];if(x(r)){const l=" ".repeat(f);n.push({kind:"gap",text:c.fg("dim",`${l}\u22EE`)}),o++;continue}const d=p(r);if(!d){n.push({kind:"other",text:c.fg("toolDiffContext",r)}),o++;continue}if(d.prefix==="-"){const l=[];for(;o<t.length;){const i=p(t[o]);if(!i||i.prefix!=="-")break;l.push({lineNum:i.lineNum,content:i.content}),o++}const u=[];for(;o<t.length;){const i=p(t[o]);if(!i||i.prefix!=="+")break;u.push({lineNum:i.lineNum,content:i.content}),o++}if(l.length===1&&u.length===1){const i=l[0],s=u[0],{removedLine:m,addedLine:D}=W(h(i.content),h(s.content));n.push({kind:"removed",text:c.fg("toolDiffRemoved",`-${i.lineNum} ${m}`)}),n.push({kind:"added",text:c.fg("toolDiffAdded",`+${s.lineNum} ${D}`)})}else{for(const i of l)n.push({kind:"removed",text:c.fg("toolDiffRemoved",`-${i.lineNum} ${h(i.content)}`)});for(const i of u)n.push({kind:"added",text:c.fg("toolDiffAdded",`+${i.lineNum} ${h(i.content)}`)})}}else d.prefix==="+"?(n.push({kind:"added",text:c.fg("toolDiffAdded",`+${d.lineNum} ${h(d.content)}`)}),o++):(n.push({kind:"context",text:c.fg("toolDiffContext",` ${d.lineNum} ${h(d.content)}`)}),o++)}return n}a($,"diffRows");function F(e,t={}){return $(e).map(n=>n.text).join(`
|
|
3
|
+
`)}a(F,"renderDiff");function M(e){let t=0,n=0;for(const f of e.split(`
|
|
4
|
+
`))f.startsWith("+")&&!f.startsWith("+++")?t++:f.startsWith("-")&&!f.startsWith("---")&&n++;return{added:t,removed:n}}a(M,"diffLineCounts");function T(e){return e.added>0&&e.removed>0?v(g("\u589E {added} \u884C\uFF0C\u5220 {removed} \u884C"),{added:e.added,removed:e.removed}):e.added>0?v(g("\u589E {added} \u884C"),{added:e.added}):e.removed>0?v(g("\u5220 {removed} \u884C"),{removed:e.removed}):""}a(T,"formatDiffLineCounts");function b(e,t,n){const o=`${e}${" ".repeat(Math.max(0,t-N(e)))}`.replace(/\u001b\[(?:0|49)m/g,r=>`${r}${n}`);return`${n}${o}\x1B[49m`}a(b,"onBackground");class j{static{a(this,"DiffView")}rows;cache;constructor(t){this.rows=$(t)}invalidate(){this.cache=void 0}render(t){if(this.cache?.width===t)return this.cache.lines;const n=[],f=c.getBgAnsi("toolDiffAddedBg"),o=c.getBgAnsi("toolDiffRemovedBg");for(const r of this.rows){const d=L(r.text,Math.max(1,t)),l=r.kind==="added"?f:r.kind==="removed"?o:void 0;for(const u of d.length>0?d:[""])n.push(l?b(u,t,l):u)}return this.cache={width:t,lines:n},n}}export{j as DiffView,M as diffLineCounts,$ as diffRows,T as formatDiffLineCounts,F as renderDiff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var u=Object.defineProperty;var r=(t,e)=>u(t,"name",{value:e,configurable:!0});import{getKeybindings as o}from"@earendil-works/pi-tui";import{theme as i}from"../theme/theme.js";function
|
|
1
|
+
var u=Object.defineProperty;var r=(t,e)=>u(t,"name",{value:e,configurable:!0});import{getKeybindings as o}from"@earendil-works/pi-tui";import{theme as i}from"../theme/theme.js";function s(t,e){const n=process.platform==="darwin"&&t.toLowerCase()==="alt"?"option":t;return e.capitalize?n.toLowerCase()==="escape"?"Esc":n.charAt(0).toUpperCase()+n.slice(1):n}r(s,"formatKeyPart");function a(t,e={}){return t.split("/").map(n=>n.split("+").map(p=>s(p,e)).join("+")).join("/")}r(a,"formatKeyText");function f(t,e={}){return t.length===0?"":a(t.join("/"),e)}r(f,"formatKeys");function c(t){return f(o().getKeys(t))}r(c,"keyText");function g(t){return f(o().getKeys(t),{capitalize:!0})}r(g,"keyDisplayText");function x(t,e){return i.fg("dim",c(t))+i.fg("muted",` ${e}`)}r(x,"keyHint");function d(t,e){return i.fg("dim",a(t))+i.fg("muted",` ${e}`)}r(d,"rawKeyHint");export{a as formatKeyText,g as keyDisplayText,x as keyHint,c as keyText,d as rawKeyHint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var n=(e,r)=>c(e,"name",{value:r,configurable:!0});import{theme as t}from"../theme/theme.js";function a(e,r){switch(r){case"active":return t.fg("accent",t.bold(e));case"done":return t.fg("dim",t.strikethrough(e));case"muted":return t.fg("dim",e);default:return e}}n(a,"styleExtensionPanelLine");export{a as styleExtensionPanelLine};
|
|
@@ -11,8 +11,30 @@ export declare class StatusIndicator extends Loader {
|
|
|
11
11
|
dispose(): void;
|
|
12
12
|
render(width: number): string[];
|
|
13
13
|
}
|
|
14
|
+
export declare function formatWorkingElapsed(ms: number): string;
|
|
15
|
+
export declare function formatWorkingTokens(tokens: number): string;
|
|
16
|
+
export declare function estimateOutputTokens(message: {
|
|
17
|
+
content?: ReadonlyArray<{
|
|
18
|
+
type: string;
|
|
19
|
+
text?: string;
|
|
20
|
+
thinking?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
arguments?: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
}): number;
|
|
25
|
+
export interface WorkingDetail {
|
|
26
|
+
startedAt: number;
|
|
27
|
+
outputTokens: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function formatWorkingDetail(detail: WorkingDetail, now?: number): string;
|
|
14
30
|
export declare class WorkingStatusIndicator extends StatusIndicator {
|
|
15
|
-
|
|
31
|
+
private baseMessage;
|
|
32
|
+
private readonly detail?;
|
|
33
|
+
private detailTimer;
|
|
34
|
+
constructor(ui: TUI, message: string, indicator?: WorkingIndicatorOptions, colorFn?: (text: string) => string, detail?: () => WorkingDetail | undefined);
|
|
35
|
+
setMessage(message: string): void;
|
|
36
|
+
private composeMessage;
|
|
37
|
+
dispose(): void;
|
|
16
38
|
}
|
|
17
39
|
export declare class RetryStatusIndicator extends StatusIndicator {
|
|
18
40
|
private countdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var M=Object.defineProperty;var a=(s,e)=>M(s,"name",{value:e,configurable:!0});import{Loader as k,truncateToWidth as m}from"@earendil-works/pi-tui";import{fill as c,t as d}from"../../../dal/i18n.js";import{theme as o}from"../theme/theme.js";import{CountdownTimer as x}from"./countdown-timer.js";import{DAL_SPINNER_FRAMES as f,DAL_SPINNER_INTERVAL_MS as g}from"./dal-brand.js";import{keyDisplayText as h}from"./keybinding-hints.js";class l extends k{static{a(this,"StatusIndicator")}kind;brandSpinnerColor;constructor(e,t,r,n,u,i){super(t,r,n,u,i??{frames:f,intervalMs:g}),this.kind=e,i||(this.brandSpinnerColor=r,this.invalidate())}getRenderedIndicator(){const e=super.getRenderedIndicator();return this.brandSpinnerColor?this.brandSpinnerColor(e):e}renderInBorder(e){const t=super.render(e+2)[1]??"";return m(t.startsWith(" ")?t.slice(1).trimEnd():t.trimEnd(),e,"")}renderSpinnerInBorder(e){return m(this.getRenderedIndicator(),e,"")}dispose(){this.stop()}render(e){const t=super.render(e);return t[0]===""?t.slice(1):t}}function I(s){const e=Math.max(0,Math.floor(s/1e3));if(e<60)return c(d("{seconds} \u79D2"),{seconds:e});const t=Math.floor(e/60);return c(d("{minutes} \u5206 {seconds} \u79D2"),{minutes:t,seconds:String(e%60).padStart(2,"0")})}a(I,"formatWorkingElapsed");function y(s){if(s<1e3)return String(Math.round(s));const e=s/1e3;return`${e<10?e.toFixed(1).replace(/\.0$/,""):Math.round(e)}k`}a(y,"formatWorkingTokens");function L(s){let e=0;for(const t of s.content??[])t.type==="text"?e+=t.text?.length??0:t.type==="thinking"?e+=t.thinking?.length??0:t.type==="toolCall"&&(e+=(t.name?.length??0)+JSON.stringify(t.arguments??{}).length);return Math.ceil(e/4)}a(L,"estimateOutputTokens");function S(s,e=Date.now()){const t=[I(e-s.startedAt)];s.outputTokens>0&&t.push(`\u2193${y(s.outputTokens)}`);const r=h("app.interrupt");return r&&t.push(c(d("{key} \u4E2D\u65AD"),{key:r})),`(${t.join(" \xB7 ")})`}a(S,"formatWorkingDetail");class C extends l{static{a(this,"WorkingStatusIndicator")}baseMessage;detail;detailTimer;constructor(e,t,r,n,u){super("working",e,n??(i=>o.fg("accent",i)),n??(i=>o.fg("muted",i)),t,r),this.baseMessage=t,this.detail=u,u&&(super.setMessage(this.composeMessage()),this.detailTimer=setInterval(()=>super.setMessage(this.composeMessage()),1e3),this.detailTimer.unref?.())}setMessage(e){this.baseMessage=e,super.setMessage(this.composeMessage())}composeMessage(){const e=this.detail?.();return e?`${this.baseMessage} ${S(e)}`:this.baseMessage}dispose(){this.detailTimer&&(clearInterval(this.detailTimer),this.detailTimer=void 0),super.dispose()}}class N extends l{static{a(this,"RetryStatusIndicator")}countdown;constructor(e,t,r,n,u="provider"){const i=a(p=>c(u==="network"?d("\u7F51\u7EDC\u4E2D\u65AD\uFF0C{seconds} \u79D2\u540E\u91CD\u8FDE\uFF08\u7B2C {attempt}/{max} \u6B21\uFF09\u2026\uFF08\u6309 {key} \u53D6\u6D88\uFF09"):d("{seconds} \u79D2\u540E\u91CD\u8BD5\uFF08\u7B2C {attempt}/{max} \u6B21\uFF09\u2026\uFF08\u6309 {key} \u53D6\u6D88\uFF09"),{seconds:p,attempt:t,max:r,key:h("app.interrupt")}),"retryMessage");super("retry",e,p=>o.fg("warning",p),p=>o.fg("muted",p),i(Math.ceil(n/1e3))),this.countdown=new x(n,e,p=>{this.setMessage(i(p))},()=>{this.countdown=void 0})}dispose(){this.countdown?.dispose(),this.countdown=void 0,super.dispose()}}class W extends l{static{a(this,"CompactionStatusIndicator")}constructor(e,t,r){const n=c(d("\uFF08\u6309 {key} \u53D6\u6D88\uFF09"),{key:h("app.interrupt")}),u=t==="manual"?c(d("\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587\u2026 {hint}"),{hint:n}):t==="overflow"?c(d("\u4E0A\u4E0B\u6587\u8D85\u51FA\u4E0A\u9650\uFF0C\u6B63\u5728\u81EA\u52A8\u538B\u7F29\u2026 {hint}"),{hint:n}):c(d("\u6B63\u5728\u81EA\u52A8\u538B\u7F29\u2026 {hint}"),{hint:n});super("compaction",e,r??(i=>o.fg("accent",i)),r??(i=>o.fg("muted",i)),u)}}class _ extends l{static{a(this,"BranchSummaryStatusIndicator")}constructor(e){super("branchSummary",e,t=>o.fg("accent",t),t=>o.fg("muted",t),c(d("\u6B63\u5728\u603B\u7ED3\u5206\u652F\u2026\uFF08\u6309 {key} \u53D6\u6D88\uFF09"),{key:h("app.interrupt")}))}}class A{static{a(this,"PulseLabel")}frame=0;intervalId=null;ui;message;frames;intervalMs;constructor(e,t,r=f,n=g){this.ui=e,this.message=t,this.frames=r,this.intervalMs=n,this.ui&&this.frames.length>1&&(this.intervalId=setInterval(()=>{this.frame=(this.frame+1)%this.frames.length,this.ui?.requestRender()},this.intervalMs),this.intervalId.unref?.())}invalidate(){}dispose(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}render(e){const t=this.frames[this.frame]??this.frames[0]??"\xB7",r=o.fg("accent",t);return this.message?[`${r} ${o.italic(o.fg("thinkingText",this.message))}`]:[r]}}class D{static{a(this,"IdleStatus")}invalidate(){}render(e){return[" ".repeat(e)]}}export{_ as BranchSummaryStatusIndicator,W as CompactionStatusIndicator,D as IdleStatus,A as PulseLabel,N as RetryStatusIndicator,l as StatusIndicator,C as WorkingStatusIndicator,L as estimateOutputTokens,S as formatWorkingDetail,I as formatWorkingElapsed,y as formatWorkingTokens};
|
|
@@ -34,7 +34,6 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
34
34
|
private argsPending;
|
|
35
35
|
private result?;
|
|
36
36
|
private hideComponent;
|
|
37
|
-
private activityPulse?;
|
|
38
37
|
private collapsedAway;
|
|
39
38
|
private focused;
|
|
40
39
|
private leadingStreak;
|
|
@@ -72,7 +71,8 @@ export declare class ToolExecutionComponent extends Container {
|
|
|
72
71
|
invalidate(): void;
|
|
73
72
|
render(width: number): string[];
|
|
74
73
|
private updateDisplay;
|
|
75
|
-
private
|
|
74
|
+
private selfPadding;
|
|
75
|
+
private rowGutter;
|
|
76
76
|
private getTextOutput;
|
|
77
77
|
private isBlankComponent;
|
|
78
78
|
private formatToolExecution;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
1
|
+
var F=Object.defineProperty;var u=(r,t)=>F(r,"name",{value:t,configurable:!0});import{Box as S,Container as b,getCapabilities as O,Image as M,Spacer as A,Text as f,truncateToWidth as B}from"@earendil-works/pi-tui";import{createAllToolDefinitions as L}from"../../../core/tools/index.js";import{compactToolArgHint as D,countOutputLines as k,formatCollapsedSummary as y,formatToolCallWithArgs as N,getTextOutput as W,prettyToolLabel as P}from"../../../core/tools/render-utils.js";import{fill as w,t as g}from"../../../dal/i18n.js";import{stripAnsi as x}from"../../../utils/ansi.js";import{ensurePngTranscoder as _}from"../../../utils/image-convert.js";import{theme as l}from"../theme/theme.js";import{DAL_SPINNER_FRAMES as q}from"./dal-brand.js";import{keyHint as I,keyText as Q}from"./keybinding-hints.js";const G=0,m=" ",H="\u23FA",j="\u23BF";function K(r){return r.focusMarker?r.focusMarker:r.running?`${l.fg("accent",q[0]??"\xB7")} `:`${l.fg(r.isError?"error":"success",H)} `}u(K,"toolRowGutter");function R(r,t,i){if(t<=0)return`${i}${r}`;let e=0,n=0;for(;e<r.length&&n<t;){if(r[e]==="\x1B"){const s=/^\u001b(?:\[[0-9;?]*[ -/]*[@-~]|\][^\u0007\u001b]*(?:\u0007|\u001b\\)|_[^\u001b]*\u001b\\)/.exec(r.slice(e));if(!s)break;e+=s[0].length;continue}if(r[e]!==" ")break;e++,n++}return n<t?`${i}${r}`:`${r.slice(0,e)}${i}${r.slice(e)}`}u(R,"insertAfterPadding");class U{static{u(this,"ResultConnectorRow")}inner;constructor(t){this.inner=t}invalidate(){this.inner.invalidate?.()}render(t){const i=`${m}${l.fg("dim",j)} `,e=m.length+2,n=this.inner.render(Math.max(1,t-e)),s=n.findIndex(a=>x(a).trim()!=="");if(s<0)return[];const o=" ".repeat(e);return n.slice(s).map((a,h)=>`${h===0?i:o}${a}`)}}class X{static{u(this,"CollapsedToolRow")}call;result;gutter;pad;constructor(t,i,e=m,n=0){this.call=t,this.result=i,this.gutter=e,this.pad=n}invalidate(){this.call.invalidate?.(),this.result?.invalidate?.()}render(t){const i=Math.max(1,t-m.length),e=(this.call.render(i)[0]??"").replace(/\s+$/,""),n=x((this.result?.render(i)??[]).map(a=>a.trim()).filter(a=>a.length>0).join(" \xB7 "));if(!e.trim()&&!n)return[];const s=n?`${e} ${l.fg("dim",n)}`:e,o=R(s,this.pad,this.gutter);return[B(o,Math.max(1,t),l.fg("dim","..."))]}}class J{static{u(this,"FocusMarkerRow")}inner;marker;pad;constructor(t,i,e=0){this.inner=t,this.marker=i,this.pad=e}invalidate(){this.inner.invalidate?.()}render(t){const i=x(this.marker).length,e=this.inner.render(Math.max(1,t-i));if(e.length===0)return e;const n=" ".repeat(i);return[R(e[0],this.pad,this.marker),...e.slice(1).map(s=>R(s,this.pad,n))]}}class c extends b{static{u(this,"ToolExecutionComponent")}contentBox;contentText;selfRenderContainer;callRendererComponent;resultRendererComponent;rendererState={};imageComponents=[];imageSources=[];imageSpacers=[];toolName;toolCallId;args;expanded=!1;showImages;imageWidthCells;outputPad;isPartial=!0;toolDefinition;builtInToolDefinition;ui;cwd;executionStarted=!1;argsComplete=!1;argsPending=!1;result;hideComponent=!1;collapsedAway=!1;focused=!1;leadingStreak=0;constructor(t,i,e,n={},s,o,a){super(),this.toolName=t,this.toolCallId=i,this.args=e,this.toolDefinition=s,this.builtInToolDefinition=L(a)[t],this.showImages=n.showImages??!0,this.imageWidthCells=n.imageWidthCells??60,this.outputPad=n.outputPad??1,this.ui=o,this.cwd=a,this.contentBox=new S(0,0),this.contentText=new f("",0,0),this.selfRenderContainer=new b,this.hasRendererDefinition()?this.addChild(this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox):this.addChild(this.contentText),this.updateDisplay()}dispose(){}isQuietFoldable(){return!this.expanded&&!!this.result&&!this.result.isError&&!this.isPartial}focusMarker(){return this.focused?l.fg("accent",this.expanded?"\u25BE ":"\u25B8 "):""}setFocused(t){this.focused!==t&&(this.focused=t,this.invalidate())}setStreakPresentation(t,i=0){this.collapsedAway=t,this.leadingStreak=t?0:i}getCallRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderCall??this.builtInToolDefinition.renderCall:this.builtInToolDefinition.renderCall:this.toolDefinition?.renderCall}getResultRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderResult??this.builtInToolDefinition.renderResult:this.builtInToolDefinition.renderResult:this.toolDefinition?.renderResult}hasRendererDefinition(){return this.builtInToolDefinition!==void 0||this.toolDefinition!==void 0}getRenderShell(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderShell??this.builtInToolDefinition.renderShell??"default":this.builtInToolDefinition.renderShell??"default":this.toolDefinition?.renderShell??"default"}getRenderContext(t){return{args:this.args,toolCallId:this.toolCallId,invalidate:u(()=>{this.invalidate(),this.ui.requestRender()},"invalidate"),lastComponent:t,state:this.rendererState,keyText:u(i=>Q(i),"keyText"),keyHint:u((i,e)=>I(i,e),"keyHint"),cwd:this.cwd,executionStarted:this.executionStarted,argsComplete:this.argsComplete,isPartial:this.isPartial,expanded:this.expanded,showImages:this.showImages,isError:this.result?.isError??!1,durationMs:this.isPartial?void 0:this.result?.durationMs,outputPad:this.outputPad}}createCallFallback(){const t=P(this.toolName);if(this.expanded)return new f(N(t,this.args,l,!0),0,0);const i=D(this.args),e=l.fg("toolTitle",l.bold(t));return new f(i?`${e} ${l.fg("dim",i)}`:e,0,0)}createResultFallback(){const t=this.getTextOutput();if(!t)return;if(!this.expanded&&!this.result?.isError){const o=k(t),a=y(l,o>0?[w(g("{count} \u884C"),{count:o})]:[]);return a?new f(a,0,0):void 0}const i=t.split(`
|
|
2
|
+
`),e=this.expanded?i:i.slice(0,Math.max(G,0)),n=i.length-e.length;let s=e.map(o=>l.fg("toolOutput",o)).join(`
|
|
3
3
|
`);return n>0&&(s+=`${l.fg("muted",`
|
|
4
|
-
${
|
|
5
|
-
${l.fg("dim",JSON.stringify(this.args))}`),n&&(
|
|
6
|
-
${l.fg("toolOutput",n)}`);else if(n){const s=
|
|
4
|
+
${w(g("... (\u8FD8\u6709 {count} \u884C,"),{count:n})}`)} ${I("app.tools.expand",g("\u5C55\u5F00\u67E5\u770B"))}${l.fg("muted",")")}`),s?new f(s,0,0):void 0}updateArgs(t){this.args=t,this.argsPending=!0,this.ui.requestRender()}markExecutionStarted(){this.executionStarted=!0,this.updateDisplay(),this.ui.requestRender()}setArgsComplete(){this.argsComplete=!0,this.updateDisplay(),this.ui.requestRender()}updateResult(t,i=!1){this.result=t,this.isPartial=i,this.updateDisplay()}setExpanded(t){this.expanded=t,this.updateDisplay()}setOutputPad(t){this.outputPad=t,this.updateDisplay()}setShowImages(t){this.showImages=t,this.updateDisplay()}setImageWidthCells(t){this.imageWidthCells=Math.max(1,Math.floor(t)),this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}render(t){if(this.argsPending&&this.updateDisplay(),this.hideComponent||this.collapsedAway)return[];let i;if(this.hasRendererDefinition()&&this.getRenderShell()==="self"){const e=this.selfRenderContainer.render(t);if(this.imageComponents.length===0&&e.every(n=>n.trim()===""))return[];i=[],e.length>0&&i.push(...e);for(let n=0;n<this.imageComponents.length;n++){const s=this.imageSpacers[n];s&&i.push(...s.render(t));const o=this.imageComponents[n];o&&i.push(...o.render(t))}}else i=super.render(t);return this.leadingStreak>0?[l.fg("dim",`${this.leadingStreak} ${g("\u4E2A\u5DE5\u5177")}`),...i]:i}updateDisplay(){this.argsPending=!1;const t=this.result?.isError&&!this.isPartial?s=>l.bg("toolErrorBg",s):void 0;let i=!1;if(this.hideComponent=!1,this.hasRendererDefinition()){const s=this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox;s instanceof S&&(s.setBgFn(t),s.setPaddingX(this.outputPad)),s.clear();let o;const a=this.getCallRenderer();if(!a)o=this.createCallFallback();else try{o=a(this.args,l,this.getRenderContext(this.callRendererComponent)),this.callRendererComponent=o}catch{this.callRendererComponent=void 0,o=this.createCallFallback()}let h;if(this.result){const p=this.getResultRenderer();if(!p)h=this.createResultFallback();else try{h=p({content:this.result.content,details:this.result.details},{expanded:this.expanded,isPartial:this.isPartial},l,this.getRenderContext(this.resultRendererComponent)),this.resultRendererComponent=h}catch{this.resultRendererComponent=void 0,h=this.createResultFallback()}h&&this.isBlankComponent(h)&&(h=void 0)}!this.expanded&&!this.result?.isError&&!!o&&o.render(240).length<=1&&o?(s.addChild(new X(o,h,this.rowGutter(),this.selfPadding())),i=!0):(o&&(s.addChild(new J(o,this.rowGutter(),this.selfPadding())),i=!0),h&&(s.addChild(this.expanded&&!this.result?.isError?new U(h):h),i=!0))}else this.contentText.setCustomBgFn(t),this.contentText.setPaddingX(this.outputPad),this.contentText.setText(this.formatToolExecution()),i=!0;const e=this.imageComponents,n=this.imageSources;for(const s of this.imageComponents)this.removeChild(s);this.imageComponents=[],this.imageSources=[];for(const s of this.imageSpacers)this.removeChild(s);if(this.imageSpacers=[],this.result){const s=this.result.content.filter(a=>a.type==="image"),o=O();for(const a of s)if(o.images&&this.showImages&&a.data&&a.mimeType){const h=new A(1);this.addChild(h),this.imageSpacers.push(h);const d={data:a.data,mimeType:a.mimeType,widthCells:this.imageWidthCells},p=this.imageComponents.length,C=n[p],T=C?.data===d.data&&C.mimeType===d.mimeType&&C.widthCells===d.widthCells?e[p]:new M(d.data,d.mimeType,{fallbackColor:u(v=>l.fg("toolOutput",v),"fallbackColor")},{maxWidthCells:d.widthCells});d.mimeType!=="image/png"&&_(()=>{this.invalidate(),this.ui.requestRender()}),this.imageComponents.push(T),this.imageSources.push(d),this.addChild(T)}}this.hasRendererDefinition()&&!i&&this.imageComponents.length===0&&(this.hideComponent=!0)}selfPadding(){return this.getRenderShell()==="self"?this.outputPad:0}rowGutter(){return K({focusMarker:this.focusMarker(),running:!this.result||this.isPartial,isError:this.result?.isError??!1})}getTextOutput(){return W(this.result,this.showImages)}isBlankComponent(t){return t instanceof f?t.render(120).every(e=>e.trim()===""):!1}formatToolExecution(){const t=P(this.toolName),i=D(this.args);let e=l.fg("toolTitle",l.bold(t));i&&(e+=` ${l.fg("dim",i)}`);const n=this.getTextOutput();if(this.expanded||this.result?.isError)this.args&&this.expanded&&(e+=`
|
|
5
|
+
${l.fg("dim",JSON.stringify(this.args))}`),n&&(e+=`
|
|
6
|
+
${l.fg("toolOutput",n)}`);else if(n){const s=k(n);s>0&&(e+=y(l,[`${s} lines`]))}return e}}const V=3;function $(r){const t=r.isBlank;if(typeof t!="function")return!1;try{return t.call(r)===!0}catch{return!1}}u($,"rendersNothing");function ht(r,t="tail"){if(t==="all"){for(const n of r)n instanceof c&&n.setStreakPresentation(!1,0);let e=0;for(;e<r.length;){const n=z(r,e);if(n===null){e++;continue}E(n.members),e=Math.max(n.end,e+1)}return}const i=Y(r);i.length>0&&E(i)}u(ht,"foldQuietToolStreak");function E(r){if(!(r.length<V)){for(let t=0;t<r.length-1;t++)r[t].setStreakPresentation(!0,0);r[r.length-1].setStreakPresentation(!1,r.length-1)}}u(E,"applyRun");function z(r,t){const i=r[t];if(!(i instanceof c)||!i.isQuietFoldable())return null;const e=[i];let n=t+1,s=t+1;for(;s<r.length;){const o=r[s];if(o instanceof c&&o.isQuietFoldable()){e.push(o),s++,n=s;continue}if(!(o instanceof c)&&$(o)){s++;continue}break}return{members:e,end:n}}u(z,"collectRunFrom");function Y(r){const t=[];for(let i=r.length-1;i>=0;i--){const e=r[i];if(e instanceof c&&e.isQuietFoldable()){t.unshift(e);continue}if(!(!(e instanceof c)&&$(e)))break}return t}u(Y,"collectTrailingRun");export{c as ToolExecutionComponent,ht as foldQuietToolStreak};
|
|
@@ -58,6 +58,8 @@ export declare class InteractiveMode {
|
|
|
58
58
|
private stallNotice;
|
|
59
59
|
private workingVisible;
|
|
60
60
|
private workingIndicatorOptions;
|
|
61
|
+
private runStartedAt;
|
|
62
|
+
private runOutputTokens;
|
|
61
63
|
private get defaultWorkingMessage();
|
|
62
64
|
private get defaultHiddenThinkingLabel();
|
|
63
65
|
private hiddenThinkingLabel;
|
|
@@ -191,6 +193,7 @@ export declare class InteractiveMode {
|
|
|
191
193
|
private handleStallReport;
|
|
192
194
|
private refreshWorkingDock;
|
|
193
195
|
private showWorkingStatusIndicator;
|
|
196
|
+
private workingDetail;
|
|
194
197
|
private applyComposerPlaceholder;
|
|
195
198
|
private setWorkingIndicator;
|
|
196
199
|
private setHiddenThinkingLabel;
|