dal-code 1.0.32 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/sdk.js +1 -1
  3. package/dist/core/system-prompt.d.ts +3 -0
  4. package/dist/core/system-prompt.js +19 -13
  5. package/dist/core/tools/bash.d.ts +1 -1
  6. package/dist/core/tools/bash.js +15 -15
  7. package/dist/core/tools/powershell.d.ts +1 -1
  8. package/dist/core/tools/powershell.js +1 -1
  9. package/dist/modes/interactive/interactive-mode.js +13 -13
  10. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  11. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  12. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  13. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  14. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  15. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  16. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  17. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  18. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  19. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +1 -1
  20. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  21. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +1 -1
  22. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  23. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  24. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  25. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  26. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  27. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  28. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +14 -13
  29. package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
  30. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  31. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  32. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  33. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  34. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  35. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  36. package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
  37. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  38. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  39. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  40. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  41. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +1 -0
  42. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  43. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  44. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  45. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  46. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  47. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  48. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  49. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  50. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  51. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  52. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  53. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  54. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  55. package/examples/extensions/gondolin/package-lock.json +2 -2
  56. package/examples/extensions/gondolin/package.json +1 -1
  57. package/examples/extensions/sandbox/package-lock.json +2 -2
  58. package/examples/extensions/sandbox/package.json +1 -1
  59. package/examples/extensions/with-deps/package-lock.json +2 -2
  60. package/examples/extensions/with-deps/package.json +1 -1
  61. package/npm-shrinkwrap.json +2 -2
  62. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,12 @@ DAL Code 的发布说明。这里只写用户看得见的变化。
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [1.0.33] - 2026-10-15
12
+
13
+ - 新开的对话第一轮就能用上缓存,响应更快,费用更低。
14
+ - 账户或模型通道余额不足时立即停下并告诉你原因(充值,或换个模型),不再反复重试,子任务也会一起停下。
15
+ - 修复:服务器的请求编号里碰巧含有 502 等数字时,会被误当成服务器故障反复重试。
16
+
11
17
  ## [1.0.32] - 2026-10-15
12
18
 
13
19
  - 沙箱里装依赖(npm、pnpm、yarn、pip、uv、cargo、go 等)现在执行前只问一次是否允许联网,同意后直接装好;会自动使用你配置的镜像源。
package/dist/core/sdk.js CHANGED
@@ -1 +1 @@
1
- var z=Object.defineProperty;var d=(r,u)=>z(r,"name",{value:u,configurable:!0});import{join as A}from"node:path";import{Agent as J,setDefaultStreamFn as X}from"@earendil-works/pi-agent-core";import{clampThinkingLevel as Y,streamSimple as Z}from"@earendil-works/pi-ai/compat";import{getAgentDir as ee}from"../config.js";import{resolvePath as b}from"../utils/paths.js";import{AgentSession as te}from"./agent-session.js";import{formatNoModelsAvailableMessage as re}from"./auth-guidance.js";import{CacheWarmer as oe}from"./cache-warmer.js";import{DEFAULT_THINKING_LEVEL as B}from"./defaults.js";import{createToolNameMatcher as ne}from"./mcp-servers.js";import{convertToLlm as se}from"./messages.js";import{findInitialModel as ie}from"./model-resolver.js";import{ModelRuntime as ae}from"./model-runtime.js";import{mergeProviderAttributionHeaders as de}from"./provider-attribution.js";import{DefaultResourceLoader as le}from"./resource-loader.js";import{getDefaultSessionDir as ce,SessionManager as me}from"./session-manager.js";import{applyToolModifiers as ue,DEFAULT_TOOL_NAMES as ge,getToolListError as fe,isToolModifier as ve,SettingsManager as Te}from"./settings-manager.js";import{time as he}from"./timings.js";import{createBashTool as pe,createCodingTools as Me,createEditTool as ye,createFindTool as xe,createGrepTool as Le,createLsTool as ke,createPowerShellTool as De,createReadOnlyTools as Re,createReadTool as Se,createWriteTool as Ie,withFileMutationQueue as we}from"./tools/index.js";import{getBranchSelection as Ce}from"./virtual-models.js";X(Z);export*from"./agent-session-runtime.js";function Pe(){return ee()}d(Pe,"getDefaultAgentDir");async function Ye(r={}){const u=b(r.cwd??r.sessionManager?.getCwd()??process.cwd()),T=r.agentDir?b(r.agentDir):Pe();let h=r.resourceLoader;const N=r.agentDir?A(T,"auth.json"):void 0,H=r.agentDir?A(T,"models.json"):void 0,g=r.modelRuntime??await ae.create({authPath:N,modelsPath:H}),o=r.settingsManager??Te.create(u,T),l=r.sessionManager??me.create(u,ce(u,T));h||(h=new le({cwd:u,agentDir:T,settingsManager:o}),await h.reload(),he("resourceLoader.reload"));const R=l.buildSessionContext(),L=R.messages.length>0,w=l.getBranch().some(e=>e.type==="thinking_level_change");let n=r.model,p,S;const f=Ce(l.getBranch(),(e,t)=>g.getModel(e,t));if(!n&&L&&f){const e=g.getModel(f.provider,f.modelId);e&&g.hasConfiguredAuth(e.provider)&&(n=e),n||(p=`Could not restore model ${f.provider}/${f.modelId}`,S={provider:f.provider,modelId:f.modelId})}if(!n){const e=o.getDefaultProvider(),t=o.getDefaultModel();n=(await ie({scopedModels:[],isContinuing:L,defaultProvider:e,defaultModelId:t,defaultThinkingLevel:o.getDefaultThinkingLevel(),modelThinkingLevels:o.getAllModelThinkingLevels(),modelRuntime:g})).model,n?p&&(p+=`. Using ${n.provider}/${n.id}`):p=re(),e&&t&&(!n||n.provider!==e||n.id!==t)&&(S={provider:e,modelId:t})}let i=r.thinkingLevel;if(i===void 0&&L&&(i=w?R.thinkingLevel:o.getDefaultThinkingLevel()??B),i===void 0&&n){const e=o.getModelThinkingLevel(n.provider,n.id);e&&(i=e)}i===void 0&&(i=o.getDefaultThinkingLevel()??B),n?i=Y(n,i):i="off";const C=r.tools?fe(r.tools):void 0;if(C)throw new Error(`Invalid tools option: ${C}`);const P=r.noTools?[]:o.getDefaultTools()??r.defaultActiveTools??ge,M=r.tools?.some(ve)?r.tools:void 0,_=M?ue(P,M):r.tools,F=M?r.noTools==="all"?_:void 0:r.tools??(r.noTools==="all"?[]:void 0),I=r.excludeTools,W=I?ne(I):void 0,O=(_??P).filter(e=>!W?.(e)),U=d(e=>{const t=se(e);return o.getBlockImages()?t.map(s=>{if(s.role==="user"||s.role==="toolResult"){const a=s.content;if(Array.isArray(a)&&a.some(c=>c.type==="image")){const c=a.map(m=>m.type==="image"?{type:"text",text:"Image reading is disabled."}:m).filter((m,y,x)=>!(m.type==="text"&&m.text==="Image reading is disabled."&&y>0&&x[y-1].type==="text"&&x[y-1].text==="Image reading is disabled."));return{...s,content:c}}}return s}):t},"convertToLlmWithBlockImages"),v={},E=new oe(g,l,()=>o.getCacheWarmingMode(),async e=>v.current?.emitCacheWarmingDecision(e)??e.action),$=d((e,t={})=>{const s=o.getProviderRetrySettings(),a=o.getHttpIdleTimeoutMs(),D=a===0?2147483647:a,c=v.current,m=o.getOutputTokenLimit(e.maxTokens);return{...t,maxTokens:t.maxTokens??(m!==e.maxTokens?m:void 0),timeoutMs:t.timeoutMs??s.timeoutMs??D,websocketConnectTimeoutMs:t.websocketConnectTimeoutMs??o.getWebSocketConnectTimeoutMs(),maxRetries:t.maxRetries??s.maxRetries,maxRetryDelayMs:t.maxRetryDelayMs??s.maxRetryDelayMs,transformHeaders:d(async y=>{const x=de(e,o,t.sessionId,y);return c?.hasHandlers("before_provider_headers")?c.emitBeforeProviderHeaders(x??{}):x??{}},"transformHeaders")}},"buildRequestOptions"),j=d(e=>{const t=k.state.messages;return()=>{const s=k.state.model,a=k.state.messages;return s.provider===e.provider&&s.id===e.id&&t.length<=a.length&&t.every((D,c)=>a[c]===D)}},"cacheContextIsCurrent"),G=d(async e=>{const t=v.current;return t?.hasHandlers("before_provider_request")?t.emitBeforeProviderRequest(e):e},"transformProviderPayload"),q=d(async e=>{const t=v.current;t?.hasHandlers("after_provider_response")&&await t.emit({type:"after_provider_response",status:e.status,headers:e.headers})},"handleProviderResponse"),K=d(async(e,t)=>{const s=v.current;s?.hasHandlers("provider_stream_event")&&await s.emit({data:e,type:"provider_stream_event",provider:t.provider,api:t.api,model:t.id})},"handleProviderStreamEvent"),k=new J({initialState:{systemPrompt:"",model:n,thinkingLevel:i,tools:[],messages:R.messages},convertToLlm:U,streamFn:d(async(e,t,s)=>{const a=$(e,s);return s?.sessionId===l.getSessionId()&&E.start({model:e,context:t,options:a},j(e)),g.streamSimple(e,t,a)},"streamFn"),onPayload:G,onResponse:q,onProviderStreamEvent:K,sessionId:l.getSessionId(),transformContext:d(async e=>{const t=v.current;return t?t.emitContext(e):e},"transformContext"),steeringMode:o.getSteeringMode(),followUpMode:o.getFollowUpMode(),transport:o.getTransport(),thinkingBudgets:o.getThinkingBudgets(),maxRetryDelayMs:o.getProviderRetrySettings().maxRetryDelayMs});L?w||l.appendThinkingLevelChange(i):(n&&l.appendModelChange(n.provider,n.id),l.appendThinkingLevelChange(i));const Q=new te({agent:k,sessionManager:l,settingsManager:o,cwd:u,scopedModels:r.scopedModels,resourceLoader:h,customTools:r.customTools,modelRuntime:g,cacheWarmer:E,initialActiveToolNames:O,usesDefaultTools:(r.tools===void 0||M!==void 0)&&!r.noTools,defaultToolModifiers:M,allowedToolNames:F,excludedToolNames:I,extensionRunnerRef:v,sessionStartEvent:r.sessionStartEvent,desiredModel:S,sandbox:r.sandbox}),V=h.getExtensions();return{session:Q,extensionsResult:V,modelFallbackMessage:p}}d(Ye,"createAgentSession");export{Ye as createAgentSession,pe as createBashTool,Me as createCodingTools,ye as createEditTool,xe as createFindTool,Le as createGrepTool,ke as createLsTool,De as createPowerShellTool,Re as createReadOnlyTools,Se as createReadTool,Ie as createWriteTool,we as withFileMutationQueue};
1
+ var z=Object.defineProperty;var d=(o,u)=>z(o,"name",{value:u,configurable:!0});import{join as A}from"node:path";import{Agent as J,setDefaultStreamFn as X}from"@earendil-works/pi-agent-core";import{clampThinkingLevel as Y,streamSimple as Z}from"@earendil-works/pi-ai/compat";import{getAgentDir as ee}from"../config.js";import{resolvePath as b}from"../utils/paths.js";import{AgentSession as te}from"./agent-session.js";import{formatNoModelsAvailableMessage as oe}from"./auth-guidance.js";import{CacheWarmer as re}from"./cache-warmer.js";import{DEFAULT_THINKING_LEVEL as B}from"./defaults.js";import{createToolNameMatcher as ne}from"./mcp-servers.js";import{convertToLlm as se}from"./messages.js";import{findInitialModel as ie}from"./model-resolver.js";import{ModelRuntime as ae}from"./model-runtime.js";import{mergeProviderAttributionHeaders as de}from"./provider-attribution.js";import{DefaultResourceLoader as le}from"./resource-loader.js";import{getDefaultSessionDir as me,SessionManager as ce}from"./session-manager.js";import{applyToolModifiers as ue,DEFAULT_TOOL_NAMES as ge,getToolListError as fe,isToolModifier as ve,SettingsManager as Te}from"./settings-manager.js";import{moveSessionEnvironmentOutOfSystemPrompt as he}from"./system-prompt.js";import{time as pe}from"./timings.js";import{createBashTool as Me,createCodingTools as ye,createEditTool as xe,createFindTool as Le,createGrepTool as ke,createLsTool as Se,createPowerShellTool as De,createReadOnlyTools as Re,createReadTool as Ie,createWriteTool as we,withFileMutationQueue as Ce}from"./tools/index.js";import{getBranchSelection as Pe}from"./virtual-models.js";X(Z);export*from"./agent-session-runtime.js";function Ee(){return ee()}d(Ee,"getDefaultAgentDir");async function et(o={}){const u=b(o.cwd??o.sessionManager?.getCwd()??process.cwd()),h=o.agentDir?b(o.agentDir):Ee();let p=o.resourceLoader;const N=o.agentDir?A(h,"auth.json"):void 0,H=o.agentDir?A(h,"models.json"):void 0,g=o.modelRuntime??await ae.create({authPath:N,modelsPath:H}),r=o.settingsManager??Te.create(u,h),l=o.sessionManager??ce.create(u,me(u,h));p||(p=new le({cwd:u,agentDir:h,settingsManager:r}),await p.reload(),pe("resourceLoader.reload"));const D=l.buildSessionContext(),k=D.messages.length>0,w=l.getBranch().some(e=>e.type==="thinking_level_change");let n=o.model,M,R;const f=Pe(l.getBranch(),(e,t)=>g.getModel(e,t));if(!n&&k&&f){const e=g.getModel(f.provider,f.modelId);e&&g.hasConfiguredAuth(e.provider)&&(n=e),n||(M=`Could not restore model ${f.provider}/${f.modelId}`,R={provider:f.provider,modelId:f.modelId})}if(!n){const e=r.getDefaultProvider(),t=r.getDefaultModel();n=(await ie({scopedModels:[],isContinuing:k,defaultProvider:e,defaultModelId:t,defaultThinkingLevel:r.getDefaultThinkingLevel(),modelThinkingLevels:r.getAllModelThinkingLevels(),modelRuntime:g})).model,n?M&&(M+=`. Using ${n.provider}/${n.id}`):M=oe(),e&&t&&(!n||n.provider!==e||n.id!==t)&&(R={provider:e,modelId:t})}let i=o.thinkingLevel;if(i===void 0&&k&&(i=w?D.thinkingLevel:r.getDefaultThinkingLevel()??B),i===void 0&&n){const e=r.getModelThinkingLevel(n.provider,n.id);e&&(i=e)}i===void 0&&(i=r.getDefaultThinkingLevel()??B),n?i=Y(n,i):i="off";const C=o.tools?fe(o.tools):void 0;if(C)throw new Error(`Invalid tools option: ${C}`);const P=o.noTools?[]:r.getDefaultTools()??o.defaultActiveTools??ge,y=o.tools?.some(ve)?o.tools:void 0,E=y?ue(P,y):o.tools,F=y?o.noTools==="all"?E:void 0:o.tools??(o.noTools==="all"?[]:void 0),I=o.excludeTools,O=I?ne(I):void 0,W=(E??P).filter(e=>!O?.(e)),U=d(e=>{const t=se(e);return r.getBlockImages()?t.map(s=>{if(s.role==="user"||s.role==="toolResult"){const a=s.content;if(Array.isArray(a)&&a.some(m=>m.type==="image")){const m=a.map(c=>c.type==="image"?{type:"text",text:"Image reading is disabled."}:c).filter((c,x,L)=>!(c.type==="text"&&c.text==="Image reading is disabled."&&x>0&&L[x-1].type==="text"&&L[x-1].text==="Image reading is disabled."));return{...s,content:m}}}return s}):t},"convertToLlmWithBlockImages"),v={},_=new re(g,l,()=>r.getCacheWarmingMode(),async e=>v.current?.emitCacheWarmingDecision(e)??e.action),$=d((e,t={})=>{const s=r.getProviderRetrySettings(),a=r.getHttpIdleTimeoutMs(),T=a===0?2147483647:a,m=v.current,c=r.getOutputTokenLimit(e.maxTokens);return{...t,maxTokens:t.maxTokens??(c!==e.maxTokens?c:void 0),timeoutMs:t.timeoutMs??s.timeoutMs??T,websocketConnectTimeoutMs:t.websocketConnectTimeoutMs??r.getWebSocketConnectTimeoutMs(),maxRetries:t.maxRetries??s.maxRetries,maxRetryDelayMs:t.maxRetryDelayMs??s.maxRetryDelayMs,transformHeaders:d(async x=>{const L=de(e,r,t.sessionId,x);return m?.hasHandlers("before_provider_headers")?m.emitBeforeProviderHeaders(L??{}):L??{}},"transformHeaders")}},"buildRequestOptions"),j=d(e=>{const t=S.state.messages;return()=>{const s=S.state.model,a=S.state.messages;return s.provider===e.provider&&s.id===e.id&&t.length<=a.length&&t.every((T,m)=>a[m]===T)}},"cacheContextIsCurrent"),q=d(async e=>{const t=v.current;return t?.hasHandlers("before_provider_request")?t.emitBeforeProviderRequest(e):e},"transformProviderPayload"),G=d(async e=>{const t=v.current;t?.hasHandlers("after_provider_response")&&await t.emit({type:"after_provider_response",status:e.status,headers:e.headers})},"handleProviderResponse"),K=d(async(e,t)=>{const s=v.current;s?.hasHandlers("provider_stream_event")&&await s.emit({data:e,type:"provider_stream_event",provider:t.provider,api:t.api,model:t.id})},"handleProviderStreamEvent"),S=new J({initialState:{systemPrompt:"",model:n,thinkingLevel:i,tools:[],messages:D.messages},convertToLlm:U,streamFn:d(async(e,t,s)=>{const a=$(e,s),T={...t,messages:he(t.messages)};return s?.sessionId===l.getSessionId()&&_.start({model:e,context:T,options:a},j(e)),g.streamSimple(e,T,a)},"streamFn"),onPayload:q,onResponse:G,onProviderStreamEvent:K,sessionId:l.getSessionId(),transformContext:d(async e=>{const t=v.current;return t?t.emitContext(e):e},"transformContext"),steeringMode:r.getSteeringMode(),followUpMode:r.getFollowUpMode(),transport:r.getTransport(),thinkingBudgets:r.getThinkingBudgets(),maxRetryDelayMs:r.getProviderRetrySettings().maxRetryDelayMs});k?w||l.appendThinkingLevelChange(i):(n&&l.appendModelChange(n.provider,n.id),l.appendThinkingLevelChange(i));const Q=new te({agent:S,sessionManager:l,settingsManager:r,cwd:u,scopedModels:o.scopedModels,resourceLoader:p,customTools:o.customTools,modelRuntime:g,cacheWarmer:_,initialActiveToolNames:W,usesDefaultTools:(o.tools===void 0||y!==void 0)&&!o.noTools,defaultToolModifiers:y,allowedToolNames:F,excludedToolNames:I,extensionRunnerRef:v,sessionStartEvent:o.sessionStartEvent,desiredModel:R,sandbox:o.sandbox}),V=p.getExtensions();return{session:Q,extensionsResult:V,modelFallbackMessage:M}}d(et,"createAgentSession");export{et as createAgentSession,Me as createBashTool,ye as createCodingTools,xe as createEditTool,Le as createFindTool,ke as createGrepTool,Se as createLsTool,De as createPowerShellTool,Re as createReadOnlyTools,Ie as createReadTool,we as createWriteTool,Ce as withFileMutationQueue};
@@ -1,3 +1,4 @@
1
+ import { type Message } from "@earendil-works/pi-ai";
1
2
  import { type Skill } from "./skills.ts";
2
3
  export interface BuildSystemPromptOptions {
3
4
  customPrompt?: string;
@@ -33,6 +34,8 @@ export type NormalizedBuildSystemPromptOptions = BuildSystemPromptOptions & {
33
34
  export type SystemPromptSections = Record<string, string>;
34
35
  export declare function normalizeBuildSystemPromptOptions(input: BuildSystemPromptOptions): NormalizedBuildSystemPromptOptions;
35
36
  export declare function buildSystemPromptSections(input: BuildSystemPromptOptions): SystemPromptSections;
37
+ export declare const SESSION_ENVIRONMENT_FIRST_SECTION = "cwd";
38
+ export declare function moveSessionEnvironmentOutOfSystemPrompt(messages: Message[]): Message[];
36
39
  export declare function buildSystemPromptState(input: BuildSystemPromptOptions): {
37
40
  content: string;
38
41
  sections?: SystemPromptSections;
@@ -1,22 +1,28 @@
1
- var x=Object.defineProperty;var l=(e,s)=>x(e,"name",{value:s,configurable:!0});import{join as $}from"node:path";import{getSystemMessageText as j}from"@earendil-works/pi-ai";import{APP_NAME as v,APP_TITLE as p,getDalDocsPath as E,getDocsPath as T,getExamplesPath as I,getReadmePath as _,IS_WHITE_LABEL_BUILD as A}from"../config.js";import{formatSkillsForPrompt as D}from"./skills.js";const O=/^[a-z][a-z0-9_-]*$/;function M(e){return{customPrompt:e.customPrompt,forceSystemPrompt:e.forceSystemPrompt,selectedTools:[...e.selectedTools??["read","bash","edit","write"]],hiddenTools:[...e.hiddenTools??[]],toolSnippets:{...e.toolSnippets??{}},toolGuidelines:Object.fromEntries(Object.entries(e.toolGuidelines??{}).map(([s,n])=>[s,[...n]])),promptGuidelines:[...e.promptGuidelines??[]],appendSystemPrompt:e.appendSystemPrompt??"",sections:{...e.sections??{}},cwd:e.cwd,contextFiles:(e.contextFiles??[]).map(s=>({...s})),skills:(e.skills??[]).map(s=>({...s}))}}l(M,"normalizeBuildSystemPromptOptions");function R(e){return["Project-specific instructions and guidelines:",...e.map(({path:s,content:n})=>`<project_instructions path="${s}">
2
- ${n}
1
+ var x=Object.defineProperty;var l=(e,t)=>x(e,"name",{value:t,configurable:!0});import{join as v}from"node:path";import{getSystemMessageText as E}from"@earendil-works/pi-ai";import{APP_NAME as $,APP_TITLE as h,getDalDocsPath as j,getDocsPath as O,getExamplesPath as T,getReadmePath as _,IS_WHITE_LABEL_BUILD as I}from"../config.js";import{formatSkillsForPrompt as N}from"./skills.js";const A=/^[a-z][a-z0-9_-]*$/;function D(e){return{customPrompt:e.customPrompt,forceSystemPrompt:e.forceSystemPrompt,selectedTools:[...e.selectedTools??["read","bash","edit","write"]],hiddenTools:[...e.hiddenTools??[]],toolSnippets:{...e.toolSnippets??{}},toolGuidelines:Object.fromEntries(Object.entries(e.toolGuidelines??{}).map(([t,o])=>[t,[...o]])),promptGuidelines:[...e.promptGuidelines??[]],appendSystemPrompt:e.appendSystemPrompt??"",sections:{...e.sections??{}},cwd:e.cwd,contextFiles:(e.contextFiles??[]).map(t=>({...t})),skills:(e.skills??[]).map(t=>({...t}))}}l(D,"normalizeBuildSystemPromptOptions");function M(e){return["Project-specific instructions and guidelines:",...e.map(({path:t,content:o})=>`<project_instructions path="${t}">
2
+ ${o}
3
3
  </project_instructions>`)].join(`
4
4
 
5
- `)}l(R,"renderProjectContext");function G(e,s,n){const r=[],a=new Set,t=l(d=>{const c=d.trim();!c||a.has(c)||(a.add(c),r.push(c))},"addRule"),u=e.includes("bash"),f=e.includes("powershell"),h=e.includes("grep"),g=e.includes("find"),w=e.includes("ls");(u||f)&&!h&&!g&&!w&&t(u&&f?"Use bash or PowerShell for file operations like listing, searching, and finding files":f?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const d of e)for(const c of s[d]??[])t(c);for(const d of n)t(d);return e.length>0&&(t("When several tool calls do not depend on each other's results (reading multiple files, independent searches or commands), make them all in one response; they run in parallel. Each extra round trip costs the user seconds"),t("Answer as soon as you can: once you know enough, give the answer or your best current conclusion, then offer to dig further. Do not investigate everything before saying anything"),t("During longer work, tell the user every few tool rounds, in a sentence or two, what you found and what you will check next"),t("If you cannot tell which product, project or file the user means, ask instead of searching widely on a guess. When the user writes while you are working, respond to that message first: it may change the direction")),t("Be concise in your responses"),t("Show file paths clearly when working with files"),r.map(d=>`- ${d}`).join(`
6
- `)}l(G,"buildRules");function L(e){const s=M(e),{customPrompt:n,selectedTools:r,hiddenTools:a,toolSnippets:t,toolGuidelines:u,promptGuidelines:f,appendSystemPrompt:h,sections:g,cwd:w,contextFiles:d,skills:c}=s;for(const o of Object.keys(g))if(!O.test(o)||o==="preamble")throw new Error(`Invalid system prompt section name: ${o}`);const b=r.filter(o=>!a.includes(o)),i={};if(n)i.preamble=n;else{i.preamble=`You are an expert coding assistant operating inside ${p} (${v}). You help users by reading files, executing commands, editing code, and writing new files.`;const o=b.filter(y=>!!t[y]),m=o.length>0?o.map(y=>`- ${y}: ${t[y]}`).join(`
7
- `):"(none)";i.tools=`${m}
5
+ `)}l(M,"renderProjectContext");function R(e,t,o){const i=[],d=new Set,n=l(a=>{const m=a.trim();!m||d.has(m)||(d.add(m),i.push(m))},"addRule"),p=e.includes("bash"),f=e.includes("powershell"),r=e.includes("grep"),g=e.includes("find"),S=e.includes("ls");(p||f)&&!r&&!g&&!S&&n(p&&f?"Use bash or PowerShell for file operations like listing, searching, and finding files":f?"Use PowerShell for file operations like listing, searching, and finding files":"Use bash for file operations like ls, rg, find");for(const a of e)for(const m of t[a]??[])n(m);for(const a of o)n(a);return e.length>0&&(n("When several tool calls do not depend on each other's results (reading multiple files, independent searches or commands), make them all in one response; they run in parallel. Each extra round trip costs the user seconds"),n("Answer as soon as you can: once you know enough, give the answer or your best current conclusion, then offer to dig further. Do not investigate everything before saying anything"),n("During longer work, tell the user every few tool rounds, in a sentence or two, what you found and what you will check next"),n("If you cannot tell which product, project or file the user means, ask instead of searching widely on a guess. When the user writes while you are working, respond to that message first: it may change the direction")),n("Be concise in your responses"),n("Show file paths clearly when working with files"),i.map(a=>`- ${a}`).join(`
6
+ `)}l(R,"buildRules");function L(e){const t=D(e),{customPrompt:o,selectedTools:i,hiddenTools:d,toolSnippets:n,toolGuidelines:p,promptGuidelines:f,appendSystemPrompt:r,sections:g,cwd:S,contextFiles:a,skills:m}=t;for(const s of Object.keys(g))if(!A.test(s)||s==="preamble")throw new Error(`Invalid system prompt section name: ${s}`);const b=i.filter(s=>!d.includes(s)),c={};if(o)c.preamble=o;else{c.preamble=`You are an expert coding assistant operating inside ${h} (${$}). You help users by reading files, executing commands, editing code, and writing new files.`;const s=b.filter(y=>!!n[y]),u=s.length>0?s.map(y=>`- ${y}: ${n[y]}`).join(`
7
+ `):"(none)";c.tools=`${u}
8
8
 
9
- In addition to the tools above, you may have access to other custom tools depending on the project.`,i.rules=G(b,u,f),i.docs=F()}h&&(i.addendum=h),d.length>0&&(i.project_context=R(d));const k=["read","bash"],S=k.find(o=>b.includes(o))??(k.some(o=>r.includes(o))?"indirect":void 0);if(S&&c.length>0){const o=D(c,S).trim();o&&(i.skills=o)}i.cwd=w.replace(/\\/g,"/");for(const[o,m]of Object.entries(g))m&&(i[o]=m);const P={preamble:i.preamble};for(const[o,m]of Object.entries(i))o!=="preamble"&&(P[o]=`<${o}>
10
- ${m}
11
- </${o}>`);return P}l(L,"buildSystemPromptSections");function U(e){return e.forceSystemPrompt!==void 0?{content:e.forceSystemPrompt}:{content:"",sections:L(e)}}l(U,"buildSystemPromptState");function N(e){return j({role:"system",...U(e),timestamp:0})}l(N,"buildSystemPrompt");function Y(e,s){const n={};for(const[r,a]of Object.entries(s))e[r]!==a&&(n[r]=a);for(const r of Object.keys(e))s[r]===void 0&&(n[r]=null);return Object.keys(n).length>0?n:void 0}l(Y,"diffSystemPromptSections");function F(){if(A){const e=E();return`${p} documentation (read only when the user asks about ${p} itself: its commands, settings, skills, prompt templates, extensions, packages, themes or keybindings):
12
- - Start with: ${$(e,"README.md")}
9
+ In addition to the tools above, you may have access to other custom tools depending on the project.`,c.rules=R(b,p,f),c.docs=W()}r&&(c.addendum=r),a.length>0&&(c.project_context=M(a));const k=["read","bash"],w=k.find(s=>b.includes(s))??(k.some(s=>i.includes(s))?"indirect":void 0);if(w&&m.length>0){const s=N(m,w).trim();s&&(c.skills=s)}c.cwd=S.replace(/\\/g,"/");for(const[s,u]of Object.entries(g))u&&(c[s]=u);const P={preamble:c.preamble};for(const[s,u]of Object.entries(c))s!=="preamble"&&(P[s]=`<${s}>
10
+ ${u}
11
+ </${s}>`);return P}l(L,"buildSystemPromptSections");const F="cwd",G="Environment of this session, part of the system prompt. Later updates to these sections arrive as system prompt updates.";function V(e){const t=e[0];if(!t||t.role!=="system"||!t.sections)return e;const o=Object.keys(t.sections),i=o.indexOf(F);if(i===-1)return e;const d=o.slice(i).map(r=>t.sections?.[r]).filter(r=>typeof r=="string"&&r.length>0),n=Object.fromEntries(o.slice(0,i).map(r=>[r,t.sections?.[r]??null])),p={...t,sections:n};if(d.length===0)return[p,...e.slice(1)];const f={role:"user",content:[{type:"text",text:`<session_environment>
12
+ ${G}
13
+
14
+ ${d.join(`
15
+
16
+ `)}
17
+ </session_environment>`}],timestamp:t.timestamp};return[p,f,...e.slice(1)]}l(V,"moveSessionEnvironmentOutOfSystemPrompt");function U(e){return e.forceSystemPrompt!==void 0?{content:e.forceSystemPrompt}:{content:"",sections:L(e)}}l(U,"buildSystemPromptState");function H(e){return E({role:"system",...U(e),timestamp:0})}l(H,"buildSystemPrompt");function q(e,t){const o={};for(const[i,d]of Object.entries(t))e[i]!==d&&(o[i]=d);for(const i of Object.keys(e))t[i]===void 0&&(o[i]=null);return Object.keys(o).length>0?o:void 0}l(q,"diffSystemPromptSections");function W(){if(I){const e=j();return`${h} documentation (read only when the user asks about ${h} itself: its commands, settings, skills, prompt templates, extensions, packages, themes or keybindings):
18
+ - Start with: ${v(e,"README.md")}
13
19
  - Topics, in the same folder: skills.md, prompt-templates.md, extensions.md, packages.md, themes.md, keybindings.md, settings.md
14
20
  - Resolve those file names under ${e}, not the current working directory
15
- - Read the relevant file completely before answering or implementing, and describe the product as ${p}`}return`${p} documentation (read only when the user asks about ${p} itself, its SDK, extensions, themes, skills, or TUI):
21
+ - Read the relevant file completely before answering or implementing, and describe the product as ${h}`}return`${h} documentation (read only when the user asks about ${h} itself, its SDK, extensions, themes, skills, or TUI):
16
22
  - Main documentation: ${_()}
17
- - Additional docs: ${T()}
18
- - Examples: ${I()} (extensions, custom tools, SDK)
23
+ - Additional docs: ${O()}
24
+ - Examples: ${T()} (extensions, custom tools, SDK)
19
25
  - When reading these docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory
20
26
  - When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), packages (docs/packages.md), environment variables (docs/environment-variables.md), MCP servers (docs/mcp.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)
21
27
  - When working on these topics, read the docs and examples, and follow .md cross-references before implementing
22
- - Always read these .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`}l(F,"buildDocumentationSection");export{N as buildSystemPrompt,L as buildSystemPromptSections,U as buildSystemPromptState,Y as diffSystemPromptSections,M as normalizeBuildSystemPromptOptions};
28
+ - Always read these .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`}l(W,"buildDocumentationSection");export{F as SESSION_ENVIRONMENT_FIRST_SECTION,H as buildSystemPrompt,L as buildSystemPromptSections,U as buildSystemPromptState,q as diffSystemPromptSections,V as moveSessionEnvironmentOutOfSystemPrompt,D as normalizeBuildSystemPromptOptions};
@@ -17,7 +17,7 @@ export declare const sandboxEscalationSchema: Type.TOptional<Type.TObject<{
17
17
  }>>;
18
18
  export declare const bashToolSystemPromptContribution: {
19
19
  readonly snippet: "Execute bash commands (ls, grep, find, etc.)";
20
- readonly guidelines: readonly ["You can inspect PI_* environment variables for current model and session details."];
20
+ readonly guidelines: readonly ["You can inspect DAL_* environment variables for current model and session details."];
21
21
  };
22
22
  export type BashToolInput = Static<typeof bashSchema>;
23
23
  declare const bashOutputSchema: Type.TObject<{
@@ -1,21 +1,21 @@
1
- var pe=Object.defineProperty;var l=(t,e)=>pe(t,"name",{value:e,configurable:!0});import{constants as fe}from"node:fs";import{access as he}from"node:fs/promises";import{constants as we}from"node:os";import{ToolExecutionError as Se}from"@earendil-works/pi-agent-core";import{Container as be,Text as F,truncateToWidth as xe}from"@earendil-works/pi-tui";import{spawn as Oe}from"child_process";import{Type as m}from"typebox";import{fill as v,t as E}from"../../dal/i18n.js";import{keyHint as Ee}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as _e}from"../../modes/interactive/components/visual-truncate.js";import{theme as S}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as $e}from"../../utils/child-process.js";import{getShellConfig as Q,getShellEnv as Z,killProcessTree as ee,trackDetachedChildPid as ye,untrackDetachedChildPid as Te}from"../../utils/shell.js";import{describeDenialForModel as Pe}from"../sandbox/denial.js";import{getProcessShellSandbox as ge}from"../sandbox/shell-sandbox.js";import{isReadOnlyBashCommand as Ce}from"./bash-read-only.js";import{OutputAccumulator as Le}from"./output-accumulator.js";import{countOutputLines as ve,formatCollapsedSummary as Ie,getTextOutput as te,invalidArgText as De,str as ne,truncateDisplay as Ae}from"./render-utils.js";import{wrapToolDefinition as Fe}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as G,DEFAULT_MAX_LINES as Me,formatSize as N}from"./truncate.js";const ie=2147483647,ke=1024*1024,Ne=ie/1e3,oe=12e4;function Be(t){if(t===void 0)return oe;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>ie)throw new Error(`Invalid timeout: maximum is ${Ne} seconds`);return e}l(Be,"resolveTimeoutMs");const se=m.Object({command:m.String({description:"Shell command to execute"}),description:m.String({description:`One short line, in the user's language, saying what this command does and why \u2014 shown in place of the command itself. Describe the intent, not the syntax: "Find hardcoded key names", not "run grep with --exclude-dir". 3-10 words.`}),timeout:m.Optional(m.Number({description:"Timeout in seconds. Defaults to 120; raise it for genuinely long-running commands."}))}),Re=m.Optional(m.Object({mode:m.Union([m.Literal("allow"),m.Literal("unsandboxed")],{description:'"allow": run sandboxed with the extra domains / writable paths below. "unsandboxed": run outside the sandbox entirely.'}),justification:m.String({description:"One sentence for the user saying why this access is needed. The user must approve it."}),allow_domains:m.Optional(m.Array(m.String(),{description:"Domains to allow, e.g. registry.npmjs.org"})),allow_write:m.Optional(m.Array(m.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: ask the user for the access it needs. Never use it pre-emptively."})),Ue=m.Object({...se.properties,sandbox_escalation:Re}),re={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect PI_* environment variables for current model and session details."]},je=m.Object({output:m.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:m.Boolean(),full_output_path:m.Optional(m.String({description:"Full output, when truncated"})),exit_code:m.Number(),wall_time_seconds:m.Number()});function Ge(t,e){return{exec:l(async(i,s,{onData:u,signal:d,timeout:O,env:b})=>{const c=Be(O);if(d?.aborted)throw new Error("aborted");const x=e();try{await he(s,fe.F_OK)}catch{throw new Error(`Working directory does not exist: ${s}
2
- Cannot execute ${t} commands.`)}const p=x.commandTransport==="stdin",r=Oe(x.shell,p?x.args:[...x.args,i],{cwd:s,detached:process.platform!=="win32",env:b??Z(),stdio:[p?"pipe":"ignore","pipe","pipe"],windowsHide:!0});p&&(r.stdin?.on("error",()=>{}),r.stdin?.end(i)),r.pid&&ye(r.pid);let h=!1,n;const o=l(()=>{r.pid&&ee(r.pid)},"onAbort");try{c!==void 0&&(n=setTimeout(()=>{h=!0,r.pid&&ee(r.pid)},c)),r.stdout?.on("data",u),r.stderr?.on("data",u),d&&(d.aborted?o():d.addEventListener("abort",o,{once:!0}));const f=await $e(r);if(d?.aborted)throw new Error("aborted");if(h)throw new Error(`timeout:${(c??oe)/1e3}`);const T=r.signalCode;return{exitCode:f??(T?128+(we.signals[T]??0):1)}}finally{r.pid&&Te(r.pid),n&&clearTimeout(n),d&&d.removeEventListener("abort",o)}},"exec")}}l(Ge,"createLocalShellOperations");function We(t){return Ge("bash",()=>Q(t?.shellPath))}l(We,"createLocalBashOperations");const W=new Set;function $t(t){return W.add(t),()=>{W.delete(t)}}l($t,"registerShellExecutionGuard");async function He(t){for(const e of W){let i;try{i=await e(t)}catch(s){return`Command refused: the safety check could not run (${s instanceof Error?s.message:String(s)}).`}if(i!==void 0)return i}}l(He,"shellExecutionRefusal");function Ve(t,e,i,s,u){const d={...Z()};if(delete d.PI_SESSION_ID,delete d.PI_SESSION_FILE,delete d.PI_PROVIDER,delete d.PI_MODEL,delete d.PI_REASONING_LEVEL,s&&u){const b=u.model;d.PI_SESSION_ID=u.sessionManager.getSessionId();const c=u.sessionManager.getSessionFile();c&&(d.PI_SESSION_FILE=c),b&&(d.PI_PROVIDER=b.provider,d.PI_MODEL=b.id),u.thinkingLevel&&(d.PI_REASONING_LEVEL=u.thinkingLevel)}const O={command:t,cwd:e,env:d};return i?i(O):O}l(Ve,"resolveSpawnContext");const Xe=5,Ke=100;class Ye extends be{static{l(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function ze(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const i=Math.floor(e),s=Math.floor(i/60),u=i%60;return s<60?`${s}m ${u}s`:`${Math.floor(s/60)}h ${s%60}m ${u}s`}l(ze,"formatDuration");function qe(t,e,i=!1){const s=ne(t?.command),u=ne(t?.description)?.trim(),d=t?.timeout,O=d?S.fg("muted",v(E(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:d})):"";if(u){const c=S.fg("toolTitle",S.bold(u))+O;return!i||!s?c:`${c}
3
- ${S.fg("muted",` \u23BF ${e} ${s.trim()}`)}`}const b=s===null?De(S):s?S.fg("dim",Ae(s.replace(/\s+/g," ").trim(),42)):S.fg("dim","\u2026");return`${S.fg("toolTitle",S.bold(e))} ${b}${O}`}l(qe,"formatShellCall");function Je(t,e,i,s,u,d,O,b){const c=t.state;t.clear();const x=Qe(i,u,d,b);if(!i.expanded&&!O){const n=te(e,s),o=ve(n),f=[];o>0&&f.push(v(E("{count} \u884C"),{count:o})),x&&f.push(x);const T=Ie(S,f);T&&t.addChild(new F(T,0,0));return}let p=te(e,s).trim();const r=e.details?.truncation,h=e.details?.fullOutputPath;if(!i.isPartial&&r?.truncated&&h&&p.endsWith("]")){const n=p.lastIndexOf(`
1
+ var pe=Object.defineProperty;var u=(t,e)=>pe(t,"name",{value:e,configurable:!0});import{constants as fe}from"node:fs";import{access as he}from"node:fs/promises";import{constants as Se}from"node:os";import{ToolExecutionError as we}from"@earendil-works/pi-agent-core";import{Container as be,Text as M,truncateToWidth as xe}from"@earendil-works/pi-tui";import{spawn as Ee}from"child_process";import{Type as m}from"typebox";import{fill as v,t as O}from"../../dal/i18n.js";import{keyHint as Oe}from"../../modes/interactive/components/keybinding-hints.js";import{truncateToVisualLines as _e}from"../../modes/interactive/components/visual-truncate.js";import{theme as b}from"../../modes/interactive/theme/theme.js";import{waitForChildProcess as $e}from"../../utils/child-process.js";import{getShellConfig as Q,getShellEnv as Z,killProcessTree as ee,trackDetachedChildPid as Le,untrackDetachedChildPid as ye}from"../../utils/shell.js";import{describeDenialForModel as Te}from"../sandbox/denial.js";import{getProcessShellSandbox as Pe}from"../sandbox/shell-sandbox.js";import{isReadOnlyBashCommand as ge}from"./bash-read-only.js";import{OutputAccumulator as Ce}from"./output-accumulator.js";import{countOutputLines as ve,formatCollapsedSummary as Ie,getTextOutput as te,invalidArgText as De,str as ne,truncateDisplay as Ae}from"./render-utils.js";import{wrapToolDefinition as Me}from"./tool-definition-wrapper.js";import{DEFAULT_MAX_BYTES as j,DEFAULT_MAX_LINES as Ne,formatSize as k}from"./truncate.js";const oe=2147483647,Fe=1024*1024,ke=oe/1e3,ie=12e4;function Re(t){if(t===void 0)return ie;if(!Number.isFinite(t)||t<=0)throw new Error("Invalid timeout: must be a finite number of seconds");const e=t*1e3;if(e>oe)throw new Error(`Invalid timeout: maximum is ${ke} seconds`);return e}u(Re,"resolveTimeoutMs");const se=m.Object({command:m.String({description:"Shell command to execute"}),description:m.String({description:`One short line, in the user's language, saying what this command does and why \u2014 shown in place of the command itself. Describe the intent, not the syntax: "Find hardcoded key names", not "run grep with --exclude-dir". 3-10 words.`}),timeout:m.Optional(m.Number({description:"Timeout in seconds. Defaults to 120; raise it for genuinely long-running commands."}))}),Be=m.Optional(m.Object({mode:m.Union([m.Literal("allow"),m.Literal("unsandboxed")],{description:'"allow": run sandboxed with the extra domains / writable paths below. "unsandboxed": run outside the sandbox entirely.'}),justification:m.String({description:"One sentence for the user saying why this access is needed. The user must approve it."}),allow_domains:m.Optional(m.Array(m.String(),{description:"Domains to allow, e.g. registry.npmjs.org"})),allow_write:m.Optional(m.Array(m.String(),{description:"Paths to make writable"}))},{description:"Only after the sandbox blocked this command: ask the user for the access it needs. Never use it pre-emptively."})),Ue=m.Object({...se.properties,sandbox_escalation:Be}),re={snippet:"Execute bash commands (ls, grep, find, etc.)",guidelines:["You can inspect DAL_* environment variables for current model and session details."]},Ge=m.Object({output:m.String({description:"Combined stdout and stderr, possibly truncated"}),truncated:m.Boolean(),full_output_path:m.Optional(m.String({description:"Full output, when truncated"})),exit_code:m.Number(),wall_time_seconds:m.Number()});function je(t,e){return{exec:u(async(o,s,{onData:c,signal:a,timeout:E,env:h})=>{const l=Re(E);if(a?.aborted)throw new Error("aborted");const x=e();try{await he(s,fe.F_OK)}catch{throw new Error(`Working directory does not exist: ${s}
2
+ Cannot execute ${t} commands.`)}const p=x.commandTransport==="stdin",r=Ee(x.shell,p?x.args:[...x.args,o],{cwd:s,detached:process.platform!=="win32",env:h??Z(),stdio:[p?"pipe":"ignore","pipe","pipe"],windowsHide:!0});p&&(r.stdin?.on("error",()=>{}),r.stdin?.end(o)),r.pid&&Le(r.pid);let S=!1,n;const i=u(()=>{r.pid&&ee(r.pid)},"onAbort");try{l!==void 0&&(n=setTimeout(()=>{S=!0,r.pid&&ee(r.pid)},l)),r.stdout?.on("data",c),r.stderr?.on("data",c),a&&(a.aborted?i():a.addEventListener("abort",i,{once:!0}));const f=await $e(r);if(a?.aborted)throw new Error("aborted");if(S)throw new Error(`timeout:${(l??ie)/1e3}`);const y=r.signalCode;return{exitCode:f??(y?128+(Se.signals[y]??0):1)}}finally{r.pid&&ye(r.pid),n&&clearTimeout(n),a&&a.removeEventListener("abort",i)}},"exec")}}u(je,"createLocalShellOperations");function Ve(t){return je("bash",()=>Q(t?.shellPath))}u(Ve,"createLocalBashOperations");const V=new Set;function Lt(t){return V.add(t),()=>{V.delete(t)}}u(Lt,"registerShellExecutionGuard");async function We(t){for(const e of V){let o;try{o=await e(t)}catch(s){return`Command refused: the safety check could not run (${s instanceof Error?s.message:String(s)}).`}if(o!==void 0)return o}}u(We,"shellExecutionRefusal");const He=["SESSION_ID","SESSION_FILE","PROVIDER","MODEL","REASONING_LEVEL"];function Xe(t,e,o,s,c){const a={...Z()};if(delete a.PI_SESSION_ID,delete a.PI_SESSION_FILE,delete a.PI_PROVIDER,delete a.PI_MODEL,delete a.PI_REASONING_LEVEL,s&&c){const h=c.model;a.PI_SESSION_ID=c.sessionManager.getSessionId();const l=c.sessionManager.getSessionFile();l&&(a.PI_SESSION_FILE=l),h&&(a.PI_PROVIDER=h.provider,a.PI_MODEL=h.id),c.thinkingLevel&&(a.PI_REASONING_LEVEL=c.thinkingLevel)}for(const h of He){delete a[`DAL_${h}`];const l=a[`PI_${h}`];l!==void 0&&(a[`DAL_${h}`]=l)}const E={command:t,cwd:e,env:a};return o?o(E):E}u(Xe,"resolveSpawnContext");const Ke=5,Ye=100;class ze extends be{static{u(this,"BashResultRenderComponent")}state={cachedWidth:void 0,cachedLines:void 0,cachedSkipped:void 0}}function qe(t){const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const o=Math.floor(e),s=Math.floor(o/60),c=o%60;return s<60?`${s}m ${c}s`:`${Math.floor(s/60)}h ${s%60}m ${c}s`}u(qe,"formatDuration");function Je(t,e,o=!1){const s=ne(t?.command),c=ne(t?.description)?.trim(),a=t?.timeout,E=a?b.fg("muted",v(O(" (\u8D85\u65F6 {seconds} \u79D2)"),{seconds:a})):"";if(c){const l=b.fg("toolTitle",b.bold(c))+E;return!o||!s?l:`${l}
3
+ ${b.fg("muted",` \u23BF ${e} ${s.trim()}`)}`}const h=s===null?De(b):s?b.fg("dim",Ae(s.replace(/\s+/g," ").trim(),42)):b.fg("dim","\u2026");return`${b.fg("toolTitle",b.bold(e))} ${h}${E}`}u(Je,"formatShellCall");function Qe(t,e,o,s,c,a,E,h){const l=t.state;t.clear();const x=Ze(o,c,a,h);if(!o.expanded&&!E){const n=te(e,s),i=ve(n),f=[];i>0&&f.push(v(O("{count} \u884C"),{count:i})),x&&f.push(x);const y=Ie(b,f);y&&t.addChild(new M(y,0,0));return}let p=te(e,s).trim();const r=e.details?.truncation,S=e.details?.fullOutputPath;if(!o.isPartial&&r?.truncated&&S&&p.endsWith("]")){const n=p.lastIndexOf(`
4
4
 
5
- [`);n!==-1&&p.slice(n).includes(h)&&(p=p.slice(0,n).trimEnd())}if(p){const n=p.split(`
6
- `).map(o=>S.fg("toolOutput",o)).join(`
7
- `);i.expanded?t.addChild(new F(`
8
- ${n}`,0,0)):t.addChild({render:l(o=>{if(c.cachedLines===void 0||c.cachedWidth!==o){const f=_e(n,Xe,o);c.cachedLines=f.visualLines,c.cachedSkipped=f.skippedCount,c.cachedWidth=o}if(c.cachedSkipped&&c.cachedSkipped>0){const f=S.fg("muted",v(E("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:c.cachedSkipped}))+` ${Ee("app.tools.expand",E("\u5373\u53EF\u5C55\u5F00"))}${S.fg("muted",")")}`;return["",xe(f,o,"..."),...c.cachedLines??[]]}return["",...c.cachedLines??[]]},"render"),invalidate:l(()=>{c.cachedWidth=void 0,c.cachedLines=void 0,c.cachedSkipped=void 0},"invalidate")})}if(r?.truncated||h){const n=[];h&&n.push(v(E("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:h})),r?.truncated&&(r.truncatedBy==="lines"?n.push(v(E("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:r.outputLines,total:r.totalLines})):n.push(v(E("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:r.outputLines,limit:N(r.maxBytes??G)}))),t.addChild(new F(`
9
- ${S.fg("warning",`[${n.join(". ")}]`)}`,0,0))}x&&t.addChild(new F(`
10
- ${S.fg("muted",x)}`,0,0))}l(Je,"rebuildBashResultRenderComponent");function Qe(t,e,i,s){let u;if(!t.isPartial&&s!==void 0)u=s;else if(e!==void 0)u=(i??Date.now())-e;else return;if(!(!t.isPartial&&u<100))return`${t.isPartial?E("\u5DF2\u8FD0\u884C"):E("\u8017\u65F6")} ${ze(u)}`}l(Qe,"bashTimingLabel");function Ze(t,e,i){const s=i?.operations??e.defaultOperations?.()??We({shellPath:i?.shellPath}),u=i?.commandPrefix,d=i?.exposeSessionEnvironment??!0,O=i?.spawnHook,b=i?.sandbox,c=i?.operations===void 0,x=b?.describeForModel();return{name:e.name,label:e.label,description:`Execute a ${e.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${Me} lines or ${G/1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.${x?` ${x}`:""}`,promptSnippet:e.promptSnippet,promptGuidelines:d&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!u?p=>e.readOnlyCommand?.(p?.command)?"parallel":void 0:void 0,parameters:b?.active?Ue:se,outputSchema:je,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(p,r,h,n,o){const{command:f,timeout:T}=r;n&&n({content:[],details:void 0});const H=await He({toolName:e.name,command:f,cwd:o?.cwd||t,sessionFile:o?.sessionManager?.getSessionFile()});if(H!==void 0)throw new Error(H);const ae=u?`${u}
11
- ${f}`:f,L=Ve(ae,o?.cwd||t,O,d,o),B=b??(c?ge():void 0);let _;if(B?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${B.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);_=await B.prepare({command:L.command,cwd:L.cwd,shell:e.sandboxShell(i?.shellPath),shellKind:e.sandboxShellKind??"bash",env:L.env,toolCallId:p,toolName:e.name,escalation:r.sandbox_escalation,ctx:o,signal:h})}const P=new Le({tempFilePrefix:e.tempFilePrefix});let V=!0,I,R=!1,X=0;const U=l(()=>{if(!n||!R)return;R=!1,X=Date.now();const a=P.snapshot({persistIfTruncated:!0});n({content:[{type:"text",text:a.content||""}],details:{truncation:a.truncation.truncated?a.truncation:void 0,fullOutputPath:a.fullOutputPath}})},"emitOutputUpdate"),j=l(()=>{I&&(clearTimeout(I),I=void 0)},"clearUpdateTimer"),de=l(()=>{if(!n)return;R=!0;const a=Ke-(Date.now()-X);if(a<=0){j(),U();return}I??=setTimeout(()=>{I=void 0,U()},a)},"scheduleOutputUpdate"),le=l(a=>{V&&(P.append(a),de())},"handleData"),K=l(async()=>{V=!1,P.finish(),j(),U();const a=P.snapshot({persistIfTruncated:!0});return await P.closeTempFile(),a},"finishOutput"),Y=l((a,$="(no output)")=>{const w=a.truncation;let y=a.content||$,A;if(w.truncated){A={truncation:w,fullOutputPath:a.fullOutputPath};const M=w.totalLines-w.outputLines+1,g=w.totalLines;if(w.lastLinePartial){const k=N(P.getLastLineBytes());y+=`
5
+ [`);n!==-1&&p.slice(n).includes(S)&&(p=p.slice(0,n).trimEnd())}if(p){const n=p.split(`
6
+ `).map(i=>b.fg("toolOutput",i)).join(`
7
+ `);o.expanded?t.addChild(new M(`
8
+ ${n}`,0,0)):t.addChild({render:u(i=>{if(l.cachedLines===void 0||l.cachedWidth!==i){const f=_e(n,Ke,i);l.cachedLines=f.visualLines,l.cachedSkipped=f.skippedCount,l.cachedWidth=i}if(l.cachedSkipped&&l.cachedSkipped>0){const f=b.fg("muted",v(O("... (\u524D\u9762\u8FD8\u6709 {count} \u884C\uFF0C"),{count:l.cachedSkipped}))+` ${Oe("app.tools.expand",O("\u5373\u53EF\u5C55\u5F00"))}${b.fg("muted",")")}`;return["",xe(f,i,"..."),...l.cachedLines??[]]}return["",...l.cachedLines??[]]},"render"),invalidate:u(()=>{l.cachedWidth=void 0,l.cachedLines=void 0,l.cachedSkipped=void 0},"invalidate")})}if(r?.truncated||S){const n=[];S&&n.push(v(O("\u5B8C\u6574\u8F93\u51FA\uFF1A{path}"),{path:S})),r?.truncated&&(r.truncatedBy==="lines"?n.push(v(O("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A {shown}/{total} \u884C"),{shown:r.outputLines,total:r.totalLines})):n.push(v(O("\u5DF2\u622A\u65AD\uFF1A\u663E\u793A\u4E86 {shown} \u884C\uFF08\u4E0A\u9650 {limit}\uFF09"),{shown:r.outputLines,limit:k(r.maxBytes??j)}))),t.addChild(new M(`
9
+ ${b.fg("warning",`[${n.join(". ")}]`)}`,0,0))}x&&t.addChild(new M(`
10
+ ${b.fg("muted",x)}`,0,0))}u(Qe,"rebuildBashResultRenderComponent");function Ze(t,e,o,s){let c;if(!t.isPartial&&s!==void 0)c=s;else if(e!==void 0)c=(o??Date.now())-e;else return;if(!(!t.isPartial&&c<100))return`${t.isPartial?O("\u5DF2\u8FD0\u884C"):O("\u8017\u65F6")} ${qe(c)}`}u(Ze,"bashTimingLabel");function et(t,e,o){const s=o?.operations??e.defaultOperations?.()??Ve({shellPath:o?.shellPath}),c=o?.commandPrefix,a=o?.exposeSessionEnvironment??!0,E=o?.spawnHook,h=o?.sandbox,l=o?.operations===void 0,x=h?.describeForModel();return{name:e.name,label:e.label,description:`Execute a ${e.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${Ne} lines or ${j/1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.${x?` ${x}`:""}`,promptSnippet:e.promptSnippet,promptGuidelines:a&&e.promptGuidelines?[...e.promptGuidelines]:void 0,executionMode:"sequential",executionModeFor:e.readOnlyCommand&&!c?p=>e.readOnlyCommand?.(p?.command)?"parallel":void 0:void 0,parameters:h?.active?Ue:se,outputSchema:Ge,constrainedSampling:{type:"json_schema",strict:"prefer"},async execute(p,r,S,n,i){const{command:f,timeout:y}=r;n&&n({content:[],details:void 0});const W=await We({toolName:e.name,command:f,cwd:i?.cwd||t,sessionFile:i?.sessionManager?.getSessionFile()});if(W!==void 0)throw new Error(W);const ae=c?`${c}
11
+ ${f}`:f,C=Xe(ae,i?.cwd||t,E,a,i),R=h??(l?Pe():void 0);let _;if(R?.active){if(!e.sandboxShell)throw new Error(`Command refused: ${e.shellName} commands cannot run inside the OS sandbox yet, and the sandbox level is "${R.level}". Use the bash tool, or the user can opt out with \`dal --sandbox off\`.`);_=await R.prepare({command:C.command,cwd:C.cwd,shell:e.sandboxShell(o?.shellPath),shellKind:e.sandboxShellKind??"bash",env:C.env,toolCallId:p,toolName:e.name,escalation:r.sandbox_escalation,ctx:i,signal:S})}const T=new Ce({tempFilePrefix:e.tempFilePrefix});let H=!0,I,B=!1,X=0;const U=u(()=>{if(!n||!B)return;B=!1,X=Date.now();const d=T.snapshot({persistIfTruncated:!0});n({content:[{type:"text",text:d.content||""}],details:{truncation:d.truncation.truncated?d.truncation:void 0,fullOutputPath:d.fullOutputPath}})},"emitOutputUpdate"),G=u(()=>{I&&(clearTimeout(I),I=void 0)},"clearUpdateTimer"),de=u(()=>{if(!n)return;B=!0;const d=Ye-(Date.now()-X);if(d<=0){G(),U();return}I??=setTimeout(()=>{I=void 0,U()},d)},"scheduleOutputUpdate"),le=u(d=>{H&&(T.append(d),de())},"handleData"),K=u(async()=>{H=!1,T.finish(),G(),U();const d=T.snapshot({persistIfTruncated:!0});return await T.closeTempFile(),d},"finishOutput"),Y=u((d,$="(no output)")=>{const w=d.truncation;let L=d.content||$,A;if(w.truncated){A={truncation:w,fullOutputPath:d.fullOutputPath};const N=w.totalLines-w.outputLines+1,P=w.totalLines;if(w.lastLinePartial){const F=k(T.getLastLineBytes());L+=`
12
12
 
13
- [Showing last ${N(w.outputBytes)} of line ${g} (line is ${k}). Full output: ${a.fullOutputPath}]`}else w.truncatedBy==="lines"?y+=`
13
+ [Showing last ${k(w.outputBytes)} of line ${P} (line is ${F}). Full output: ${d.fullOutputPath}]`}else w.truncatedBy==="lines"?L+=`
14
14
 
15
- [Showing lines ${M}-${g} of ${w.totalLines}. Full output: ${a.fullOutputPath}]`:y+=`
15
+ [Showing lines ${N}-${P} of ${w.totalLines}. Full output: ${d.fullOutputPath}]`:L+=`
16
16
 
17
- [Showing lines ${M}-${g} of ${w.totalLines} (${N(G)} limit). Full output: ${a.fullOutputPath}]`}return{text:y,details:A}},"formatOutput"),D=l((a,$)=>`${a?`${a}
17
+ [Showing lines ${N}-${P} of ${w.totalLines} (${k(j)} limit). Full output: ${d.fullOutputPath}]`}return{text:L,details:A}},"formatOutput"),D=u((d,$)=>`${d?`${d}
18
18
 
19
- `:""}${$}`,"appendStatus"),ue=performance.now();try{let a;try{a=(await s.exec(_?.command??L.command,L.cwd,{onData:le,signal:h,timeout:T,env:L.env})).exitCode}catch(C){const ce=await K(),{text:J}=Y(ce,"");if(await _?.finish(null,""),C instanceof Error&&C.message==="aborted")throw new Error(D(J,"Command aborted"));if(C instanceof Error&&C.message.startsWith("timeout:")){const me=C.message.split(":")[1];throw new Error(D(J,`Command timed out after ${me} seconds`))}throw C}const $=await K(),{text:w,details:y}=Y($),A=await _?.finish(a,$.content||"");if(A&&_)throw new Se(`${D(w,`Command exited with code ${a??"(none)"}`)}
19
+ `:""}${$}`,"appendStatus"),ue=performance.now();try{let d;try{d=(await s.exec(_?.command??C.command,C.cwd,{onData:le,signal:S,timeout:y,env:C.env})).exitCode}catch(g){const ce=await K(),{text:J}=Y(ce,"");if(await _?.finish(null,""),g instanceof Error&&g.message==="aborted")throw new Error(D(J,"Command aborted"));if(g instanceof Error&&g.message.startsWith("timeout:")){const me=g.message.split(":")[1];throw new Error(D(J,`Command timed out after ${me} seconds`))}throw g}const $=await K(),{text:w,details:L}=Y($),A=await _?.finish(d,$.content||"");if(A&&_)throw new we(`${D(w,`Command exited with code ${d??"(none)"}`)}
20
20
 
21
- ${Pe(A)}`,{...y,sandbox:_.details});if(a===null)throw new Error(D(w,"Command terminated without an exit code"));const M=Math.round((performance.now()-ue)/100)/10,g=await P.readFullOutput(ke),k={output:g.content,truncated:g.truncated,...g.truncated&&$.fullOutputPath?{full_output_path:$.fullOutputPath}:{},exit_code:a,wall_time_seconds:M},z=_?.details.escalation?_.details:void 0,q=z?{...y,sandbox:z}:y;return a!==0?{content:[{type:"text",text:D(w,`Command exited with code ${a}`)}],details:q,structuredContent:k,isError:!0}:{content:[{type:"text",text:w}],details:q,structuredContent:k}}finally{j()}},renderCall(p,r,h){const n=h.state;h.executionStarted&&n.startedAt===void 0&&(n.startedAt=Date.now(),n.endedAt=void 0);const o=h.lastComponent??new F("",0,0);return o.setText(qe(p,e.prompt,h.expanded===!0)),o},renderResult(p,r,h,n){const o=n.state;o.startedAt!==void 0&&r.isPartial&&!o.interval&&(o.interval=setInterval(()=>n.invalidate(),1e3)),(!r.isPartial||n.isError)&&(o.endedAt??=Date.now(),o.interval&&(clearInterval(o.interval),o.interval=void 0));const f=n.lastComponent??new Ye;return Je(f,p,r,n.showImages,o.startedAt,o.endedAt,n.isError,n.durationMs),f.invalidate(),f}}}l(Ze,"createShellToolDefinition");const et={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:re.snippet,promptGuidelines:re.guidelines,tempFilePrefix:"pi-bash",readOnlyCommand:Ce,sandboxShell:l(t=>Q(t).shell,"sandboxShell")};function tt(t,e){return Ze(t,et,e)}l(tt,"createBashToolDefinition");function yt(t,e){const i=tt(t,e),s=Fe(i);return Object.assign(s,{promptSnippet:i.promptSnippet,promptGuidelines:i.promptGuidelines}),s}l(yt,"createBashTool");export{re as bashToolSystemPromptContribution,yt as createBashTool,tt as createBashToolDefinition,We as createLocalBashOperations,Ge as createLocalShellOperations,Ze as createShellToolDefinition,$t as registerShellExecutionGuard,Re as sandboxEscalationSchema};
21
+ ${Te(A)}`,{...L,sandbox:_.details});if(d===null)throw new Error(D(w,"Command terminated without an exit code"));const N=Math.round((performance.now()-ue)/100)/10,P=await T.readFullOutput(Fe),F={output:P.content,truncated:P.truncated,...P.truncated&&$.fullOutputPath?{full_output_path:$.fullOutputPath}:{},exit_code:d,wall_time_seconds:N},z=_?.details.escalation?_.details:void 0,q=z?{...L,sandbox:z}:L;return d!==0?{content:[{type:"text",text:D(w,`Command exited with code ${d}`)}],details:q,structuredContent:F,isError:!0}:{content:[{type:"text",text:w}],details:q,structuredContent:F}}finally{G()}},renderCall(p,r,S){const n=S.state;S.executionStarted&&n.startedAt===void 0&&(n.startedAt=Date.now(),n.endedAt=void 0);const i=S.lastComponent??new M("",0,0);return i.setText(Je(p,e.prompt,S.expanded===!0)),i},renderResult(p,r,S,n){const i=n.state;i.startedAt!==void 0&&r.isPartial&&!i.interval&&(i.interval=setInterval(()=>n.invalidate(),1e3)),(!r.isPartial||n.isError)&&(i.endedAt??=Date.now(),i.interval&&(clearInterval(i.interval),i.interval=void 0));const f=n.lastComponent??new ze;return Qe(f,p,r,n.showImages,i.startedAt,i.endedAt,n.isError,n.durationMs),f.invalidate(),f}}}u(et,"createShellToolDefinition");const tt={name:"bash",label:"bash",shellName:"bash",prompt:"$",promptSnippet:re.snippet,promptGuidelines:re.guidelines,tempFilePrefix:"pi-bash",readOnlyCommand:ge,sandboxShell:u(t=>Q(t).shell,"sandboxShell")};function nt(t,e){return et(t,tt,e)}u(nt,"createBashToolDefinition");function yt(t,e){const o=nt(t,e),s=Me(o);return Object.assign(s,{promptSnippet:o.promptSnippet,promptGuidelines:o.promptGuidelines}),s}u(yt,"createBashTool");export{re as bashToolSystemPromptContribution,yt as createBashTool,nt as createBashToolDefinition,Ve as createLocalBashOperations,je as createLocalShellOperations,et as createShellToolDefinition,Lt as registerShellExecutionGuard,Be as sandboxEscalationSchema};
@@ -1,7 +1,7 @@
1
1
  import { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, type createBashTool, createShellToolDefinition } from "./bash.ts";
2
2
  export declare const powershellToolSystemPromptContribution: {
3
3
  readonly snippet: "Execute PowerShell commands";
4
- readonly guidelines: readonly ["You can inspect PI_* environment variables for current model and session details."];
4
+ readonly guidelines: readonly ["You can inspect DAL_* environment variables for current model and session details."];
5
5
  };
6
6
  export type PowerShellOperations = BashOperations;
7
7
  export type PowerShellSpawnContext = BashSpawnContext;
@@ -1,2 +1,2 @@
1
1
  var p=Object.defineProperty;var t=(e,o)=>p(e,"name",{value:o,configurable:!0});import{getPowerShellConfig as r}from"../../utils/shell.js";import{createLocalShellOperations as s,createShellToolDefinition as c}from"./bash.js";import{wrapToolDefinition as a}from"./tool-definition-wrapper.js";const m=`try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}
2
- `,i={snippet:"Execute PowerShell commands",guidelines:["You can inspect PI_* environment variables for current model and session details."]};function h(){const e=s("PowerShell",r);return{exec:t((o,n,l)=>e.exec(`${m}${o}`,n,l),"exec")}}t(h,"createLocalPowerShellOperations");const u={name:"powershell",label:"powershell",shellName:"PowerShell",prompt:"PS>",promptSnippet:i.snippet,promptGuidelines:i.guidelines,tempFilePrefix:"pi-powershell",defaultOperations:h,sandboxShell:t(()=>process.platform==="win32"?r().shell:"pwsh","sandboxShell"),sandboxShellKind:"powershell"};function S(e,o){return c(e,u,o)}t(S,"createPowerShellToolDefinition");function x(e,o){const n=S(e,o),l=a(n);return Object.assign(l,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),l}t(x,"createPowerShellTool");export{h as createLocalPowerShellOperations,x as createPowerShellTool,S as createPowerShellToolDefinition,i as powershellToolSystemPromptContribution};
2
+ `,i={snippet:"Execute PowerShell commands",guidelines:["You can inspect DAL_* environment variables for current model and session details."]};function h(){const e=s("PowerShell",r);return{exec:t((o,n,l)=>e.exec(`${m}${o}`,n,l),"exec")}}t(h,"createLocalPowerShellOperations");const u={name:"powershell",label:"powershell",shellName:"PowerShell",prompt:"PS>",promptSnippet:i.snippet,promptGuidelines:i.guidelines,tempFilePrefix:"pi-powershell",defaultOperations:h,sandboxShell:t(()=>process.platform==="win32"?r().shell:"pwsh","sandboxShell"),sandboxShellKind:"powershell"};function S(e,o){return c(e,u,o)}t(S,"createPowerShellToolDefinition");function x(e,o){const n=S(e,o),l=a(n);return Object.assign(l,{promptSnippet:n.promptSnippet,promptGuidelines:n.promptGuidelines}),l}t(x,"createPowerShellTool");export{h as createLocalPowerShellOperations,x as createPowerShellTool,S as createPowerShellToolDefinition,i as powershellToolSystemPromptContribution};