dal-code 1.0.25 → 1.0.27

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 (175) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/NOTICE +7 -0
  3. package/dal-docs/README.md +13 -0
  4. package/dal-docs/settings.md +18 -2
  5. package/dist/cli/args.d.ts +3 -0
  6. package/dist/cli/args.js +14 -14
  7. package/dist/core/agent-session-services.d.ts +2 -0
  8. package/dist/core/agent-session-services.js +1 -1
  9. package/dist/core/agent-session.d.ts +27 -1
  10. package/dist/core/agent-session.js +9 -8
  11. package/dist/core/background-processes.d.ts +73 -0
  12. package/dist/core/background-processes.js +7 -0
  13. package/dist/core/extensions/index.d.ts +1 -1
  14. package/dist/core/extensions/loader.js +1 -1
  15. package/dist/core/extensions/permission-surface.js +1 -1
  16. package/dist/core/extensions/runner.js +1 -1
  17. package/dist/core/extensions/types.d.ts +6 -0
  18. package/dist/core/host-capabilities.d.ts +50 -0
  19. package/dist/core/host-capabilities.js +2 -0
  20. package/dist/core/permissions/rules.d.ts +45 -0
  21. package/dist/core/permissions/rules.js +1 -0
  22. package/dist/core/permissions/shell-words.js +2 -0
  23. package/dist/core/permissions/tool-policy.d.ts +46 -0
  24. package/dist/core/permissions/tool-policy.js +1 -0
  25. package/dist/core/sandbox/availability.d.ts +14 -0
  26. package/dist/core/sandbox/availability.js +1 -0
  27. package/dist/core/sandbox/denial.d.ts +25 -0
  28. package/dist/core/sandbox/denial.js +3 -0
  29. package/dist/core/sandbox/index.d.ts +5 -0
  30. package/dist/core/sandbox/index.js +1 -0
  31. package/dist/core/sandbox/policy.d.ts +66 -0
  32. package/dist/core/sandbox/policy.js +1 -0
  33. package/dist/core/sandbox/runtime.d.ts +41 -0
  34. package/dist/core/sandbox/runtime.js +1 -0
  35. package/dist/core/sandbox/shell-sandbox.d.ts +125 -0
  36. package/dist/core/sandbox/shell-sandbox.js +5 -0
  37. package/dist/core/sandbox/windows.d.ts +122 -0
  38. package/dist/core/sandbox/windows.js +5 -0
  39. package/dist/core/sdk.d.ts +3 -0
  40. package/dist/core/sdk.js +1 -1
  41. package/dist/core/settings-manager.d.ts +20 -0
  42. package/dist/core/settings-manager.js +1 -1
  43. package/dist/core/tools/bash.d.ts +16 -1
  44. package/dist/core/tools/bash.js +16 -14
  45. package/dist/core/tools/find.js +11 -11
  46. package/dist/core/tools/grep.js +10 -10
  47. package/dist/core/tools/index.d.ts +1 -0
  48. package/dist/core/tools/index.js +1 -1
  49. package/dist/core/tools/ls.js +6 -6
  50. package/dist/core/tools/powershell.d.ts +1 -1
  51. package/dist/core/tools/powershell.js +2 -2
  52. package/dist/core/tools/process.d.ts +26 -0
  53. package/dist/core/tools/process.js +22 -0
  54. package/dist/core/tools/read.js +15 -15
  55. package/dist/dal/builtins.js +2 -2
  56. package/dist/dal/child-env.js +1 -1
  57. package/dist/dal/manifest.d.ts +32 -0
  58. package/dist/dal/manifest.js +1 -0
  59. package/dist/index.d.ts +8 -3
  60. package/dist/index.js +1 -1
  61. package/dist/main.js +4 -4
  62. package/dist/modes/index.d.ts +2 -2
  63. package/dist/modes/print-mode.js +6 -4
  64. package/dist/modes/rpc/environment-update.js +1 -0
  65. package/dist/modes/rpc/rpc-client.d.ts +38 -1
  66. package/dist/modes/rpc/rpc-client.js +4 -1
  67. package/dist/modes/rpc/rpc-mode.d.ts +1 -0
  68. package/dist/modes/rpc/rpc-mode.js +1 -1
  69. package/dist/modes/rpc/rpc-types.d.ts +95 -0
  70. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  71. package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
  72. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  73. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  74. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  75. package/dist/node_modules/@dalcode/dal-interactive/LICENSE +21 -0
  76. package/dist/node_modules/@dalcode/dal-interactive/package.json +33 -0
  77. package/dist/node_modules/@dalcode/dal-interactive/src/handoff.js +28 -0
  78. package/dist/node_modules/@dalcode/dal-interactive/src/index.js +1 -0
  79. package/dist/node_modules/@dalcode/dal-interactive/src/interactive-shell.js +1 -0
  80. package/dist/node_modules/@dalcode/dal-interactive/src/questionnaire.js +3 -0
  81. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  82. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  83. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  84. package/dist/node_modules/@dalcode/dal-mcp/src/add-wizard.js +1 -1
  85. package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +1 -1
  86. package/dist/node_modules/@dalcode/dal-mcp/src/config.js +1 -1
  87. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +18 -18
  88. package/dist/node_modules/@dalcode/dal-mcp/src/proxy.js +6 -6
  89. package/dist/node_modules/@dalcode/dal-mcp/src/report.js +1 -1
  90. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +1 -1
  91. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  92. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  93. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  94. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
  95. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  96. package/dist/node_modules/@dalcode/dal-review/LICENSE +21 -0
  97. package/dist/node_modules/@dalcode/dal-review/package.json +34 -0
  98. package/dist/node_modules/@dalcode/dal-review/src/args.d.ts +13 -0
  99. package/dist/node_modules/@dalcode/dal-review/src/args.js +1 -0
  100. package/dist/node_modules/@dalcode/dal-review/src/core.d.ts +6 -0
  101. package/dist/node_modules/@dalcode/dal-review/src/core.js +1 -0
  102. package/dist/node_modules/@dalcode/dal-review/src/findings.d.ts +23 -0
  103. package/dist/node_modules/@dalcode/dal-review/src/findings.js +4 -0
  104. package/dist/node_modules/@dalcode/dal-review/src/index.js +1 -0
  105. package/dist/node_modules/@dalcode/dal-review/src/prompt.d.ts +3 -0
  106. package/dist/node_modules/@dalcode/dal-review/src/prompt.js +29 -0
  107. package/dist/node_modules/@dalcode/dal-review/src/runner.d.ts +91 -0
  108. package/dist/node_modules/@dalcode/dal-review/src/runner.js +2 -0
  109. package/dist/node_modules/@dalcode/dal-review/src/targets.d.ts +33 -0
  110. package/dist/node_modules/@dalcode/dal-review/src/targets.js +17 -0
  111. package/dist/node_modules/@dalcode/dal-review/src/types.d.ts +94 -0
  112. package/dist/node_modules/@dalcode/dal-review/src/types.js +1 -0
  113. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  114. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  115. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  116. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  117. package/dist/node_modules/@dalcode/dal-subagent/src/agents.js +2 -2
  118. package/dist/node_modules/@dalcode/dal-subagent/src/index.js +12 -12
  119. package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
  120. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  121. package/dist/node_modules/@dalcode/dal-terminal/LICENSE +21 -0
  122. package/dist/node_modules/@dalcode/dal-terminal/package.json +33 -0
  123. package/dist/node_modules/@dalcode/dal-terminal/src/contract.d.ts +60 -0
  124. package/dist/node_modules/@dalcode/dal-terminal/src/contract.js +7 -0
  125. package/dist/node_modules/@dalcode/dal-terminal/src/index.js +6 -0
  126. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  127. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  128. package/dist/node_modules/@dalcode/dal-web/src/config.js +2 -2
  129. package/dist/node_modules/@dalcode/dal-web/src/index.js +4 -4
  130. package/dist/node_modules/@dalcode/dal-web/src/search.js +4 -4
  131. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  132. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  133. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
  134. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  135. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  136. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +4 -0
  137. package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +1 -1
  138. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  139. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  140. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  141. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  142. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  143. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  144. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  145. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  146. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  147. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  148. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  149. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  150. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  151. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  152. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  153. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  154. package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
  155. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
  156. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  157. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  158. package/dist/sdk/index.d.ts +6 -2
  159. package/dist/sdk/index.js +1 -1
  160. package/dist/sdk/review.d.ts +1 -0
  161. package/dist/sdk/review.js +1 -0
  162. package/dist/sdk/subagents.d.ts +8 -0
  163. package/dist/sdk/subagents.js +1 -0
  164. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  165. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  166. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  167. package/examples/extensions/gondolin/package-lock.json +2 -2
  168. package/examples/extensions/gondolin/package.json +1 -1
  169. package/examples/extensions/sandbox/index.ts +6 -0
  170. package/examples/extensions/sandbox/package-lock.json +2 -2
  171. package/examples/extensions/sandbox/package.json +1 -1
  172. package/examples/extensions/with-deps/package-lock.json +2 -2
  173. package/examples/extensions/with-deps/package.json +1 -1
  174. package/npm-shrinkwrap.json +83 -5
  175. package/package.json +14 -1
@@ -1 +1 @@
1
- var v=Object.defineProperty;var a=(l,e)=>v(l,"name",{value:e,configurable:!0});import{getCurrentSystemMessage as P}from"@earendil-works/pi-ai";import{theme as w}from"../../modes/interactive/theme/theme.js";import{buildSystemPrompt as E,normalizeBuildSystemPromptOptions as p}from"../system-prompt.js";const S=["app.interrupt","app.clear","app.exit","app.suspend","app.thinking.cycle","app.model.cycleForward","app.model.cycleBackward","app.model.select","app.tools.expand","app.thinking.toggle","app.editor.external","app.message.copy","app.message.followUp","tui.input.submit","tui.select.confirm","tui.select.cancel","tui.input.copy","tui.editor.deleteToLineEnd"],k=a(l=>{const e={};for(const[s,t]of Object.entries(l)){if(t===void 0)continue;const o=Array.isArray(t)?t:[t],i=S.includes(s);for(const n of o){const r=n.toLowerCase();e[r]?.restrictOverride&&!i||(e[r]={keybinding:s,restrictOverride:i})}}return e},"buildBuiltinKeybindings");function _(l){if(typeof l!="object"||l===null)return!1;const e=l,s=e.operations!==void 0,t=e.result!==void 0;if(s===t)return!1;if(s){const n=e.operations;return typeof n!="object"||n===null?!1:typeof n.exec=="function"}const o=e.result;if(typeof o!="object"||o===null)return!1;const i=o;return typeof i.output=="string"&&"exitCode"in i&&(i.exitCode===void 0||typeof i.exitCode=="number")&&typeof i.cancelled=="boolean"&&typeof i.truncated=="boolean"&&(i.fullOutputPath===void 0||typeof i.fullOutputPath=="string")}a(_,"isUserBashEventResult");async function F(l,e){return l.hasHandlers("session_shutdown")?(await l.emit(e),!0):!1}a(F,"emitSessionShutdownEvent");function m(l,e){return l.map(s=>({ext:s,handlers:s.handlers.get(e)?.slice()??[]}))}a(m,"snapshotEventHandlers");function y(l,e){return l.length===e.length&&l.every((s,t)=>s===e[t])}a(y,"sameMessages");function C(l,e,s){if(y(s,e))return l;const t=P(l);return t?[t,...s]:s}a(C,"restoreSystemMessages");async function I(l,e,s){const t=[];for(const{ext:o,handlers:i}of m(l.extensions,"project_trust"))for(const n of i)try{const r=await n(e,s);if(r.trusted==="undecided")continue;return{result:r,errors:t}}catch(r){t.push({extensionPath:o.path,event:e.type,error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}return{errors:t}}a(I,"emitProjectTrustEvent");const x={select:a(async()=>{},"select"),confirm:a(async()=>!1,"confirm"),input:a(async()=>{},"input"),notify:a(()=>{},"notify"),setPanel:a(()=>{},"setPanel"),requestInput:a(async()=>{},"requestInput"),requestChoice:a(async()=>{},"requestChoice"),onTerminalInput:a(()=>()=>{},"onTerminalInput"),setStatus:a(()=>{},"setStatus"),setWorkingMessage:a(()=>{},"setWorkingMessage"),setWorkingVisible:a(()=>{},"setWorkingVisible"),setWorkingIndicator:a(()=>{},"setWorkingIndicator"),setHiddenThinkingLabel:a(()=>{},"setHiddenThinkingLabel"),setWidget:a(()=>{},"setWidget"),setFooter:a(()=>{},"setFooter"),setHeader:a(()=>{},"setHeader"),setTitle:a(()=>{},"setTitle"),custom:a(async()=>{},"custom"),pasteToEditor:a(()=>{},"pasteToEditor"),setEditorText:a(()=>{},"setEditorText"),getEditorText:a(()=>"","getEditorText"),editor:a(async()=>{},"editor"),addAutocompleteProvider:a(()=>{},"addAutocompleteProvider"),setEditorComponent:a(()=>{},"setEditorComponent"),getEditorComponent:a(()=>{},"getEditorComponent"),get theme(){return w},getAllThemes:a(()=>[],"getAllThemes"),getTheme:a(()=>{},"getTheme"),setTheme:a(l=>({success:!1,error:"UI not available"}),"setTheme"),getToolsExpanded:a(()=>!1,"getToolsExpanded"),setToolsExpanded:a(()=>{},"setToolsExpanded")};class U{static{a(this,"ExtensionRunner")}extensions;runtime;uiContext;mode="print";cwd;sessionManager;modelRegistry;errorListeners=new Set;getModel=a(()=>{},"getModel");getScopedModels=a(()=>[],"getScopedModels");isIdleFn=a(()=>!0,"isIdleFn");isProjectTrustedFn=a(()=>!0,"isProjectTrustedFn");getSignalFn=a(()=>{},"getSignalFn");waitForIdleFn=a(async()=>{},"waitForIdleFn");abortFn=a(()=>{},"abortFn");hasPendingMessagesFn=a(()=>!1,"hasPendingMessagesFn");getContextUsageFn=a(()=>{},"getContextUsageFn");compactFn=a(()=>{},"compactFn");getSystemPromptFn=a(()=>"","getSystemPromptFn");getSystemPromptOptionsFn=a(()=>p({cwd:this.cwd}),"getSystemPromptOptionsFn");newSessionHandler=a(async()=>({cancelled:!1}),"newSessionHandler");forkHandler=a(async()=>({cancelled:!1}),"forkHandler");navigateTreeHandler=a(async()=>({cancelled:!1}),"navigateTreeHandler");switchSessionHandler=a(async()=>({cancelled:!1}),"switchSessionHandler");reloadHandler=a(async()=>{},"reloadHandler");shutdownHandler=a(()=>{},"shutdownHandler");shortcutDiagnostics=[];commandDiagnostics=[];staleMessage;uiPromptDepth=0;activeUIPrompt;constructor(e,s,t,o,i){this.extensions=e,this.runtime=s,this.uiContext=x,this.cwd=t,this.sessionManager=o,this.modelRegistry=i}bindCore(e,s,t){this.runtime.sendMessage=e.sendMessage,this.runtime.sendUserMessage=e.sendUserMessage,this.runtime.appendEntry=e.appendEntry,this.runtime.setSessionName=e.setSessionName,this.runtime.getSessionName=e.getSessionName,this.runtime.setLabel=e.setLabel,this.runtime.getActiveTools=e.getActiveTools,this.runtime.getAllTools=e.getAllTools,this.runtime.setActiveTools=e.setActiveTools,this.runtime.isToolAllowed=e.isToolAllowed,this.runtime.getToolAllowlist=e.getToolAllowlist,this.runtime.refreshTools=e.refreshTools,this.runtime.getCommands=e.getCommands,this.runtime.setModel=e.setModel,this.runtime.getThinkingLevel=e.getThinkingLevel,this.runtime.setThinkingLevel=e.setThinkingLevel,this.getModel=s.getModel,this.getScopedModels=s.getScopedModels,this.isIdleFn=s.isIdle,this.isProjectTrustedFn=s.isProjectTrusted,this.getSignalFn=s.getSignal,this.abortFn=s.abort,this.hasPendingMessagesFn=s.hasPendingMessages,this.shutdownHandler=s.shutdown,this.getContextUsageFn=s.getContextUsage,this.compactFn=s.compact,this.getSystemPromptFn=s.getSystemPrompt,this.getSystemPromptOptionsFn=s.getSystemPromptOptions??(()=>p({cwd:this.cwd}));for(const{name:o,config:i,extensionPath:n}of this.runtime.pendingProviderRegistrations)try{t?.registerProvider?t.registerProvider(o,i):this.modelRegistry.registerProvider(o,i)}catch(r){this.emitError({extensionPath:n,event:"register_provider",error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}this.runtime.pendingProviderRegistrations=[];for(const{provider:o,extensionPath:i}of this.runtime.pendingNativeProviderRegistrations)try{t?.registerNativeProvider?t.registerNativeProvider(o):this.modelRegistry.registerProvider(o)}catch(n){this.emitError({extensionPath:i,event:"register_provider",error:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:void 0})}this.runtime.pendingNativeProviderRegistrations=[],this.runtime.registerProvider=(o,i)=>{if(t?.registerProvider){t.registerProvider(o,i);return}this.modelRegistry.registerProvider(o,i)},this.runtime.registerNativeProvider=o=>{if(t?.registerNativeProvider){t.registerNativeProvider(o);return}this.modelRegistry.registerProvider(o)},this.runtime.unregisterProvider=o=>{if(t?.unregisterProvider){t.unregisterProvider(o);return}this.modelRegistry.unregisterProvider(o)}}bindCommandContext(e){if(e){this.waitForIdleFn=e.waitForIdle,this.newSessionHandler=e.newSession,this.forkHandler=e.fork,this.navigateTreeHandler=e.navigateTree,this.switchSessionHandler=e.switchSession,this.reloadHandler=e.reload;return}this.waitForIdleFn=async()=>{},this.newSessionHandler=async()=>({cancelled:!1}),this.forkHandler=async()=>({cancelled:!1}),this.navigateTreeHandler=async()=>({cancelled:!1}),this.switchSessionHandler=async()=>({cancelled:!1}),this.reloadHandler=async()=>{}}setUIContext(e,s="print"){this.uiContext=e?this.wrapUIPromptContext(e):x,this.mode=s}wrapUIPromptContext(e){return{...e,select:a((s,t,o)=>this.withUIPrompt("select",s,()=>e.select(s,t,o)),"select"),confirm:a((s,t,o)=>this.withUIPrompt("confirm",s,()=>e.confirm(s,t,o)),"confirm"),input:a((s,t,o)=>this.withUIPrompt("input",s,()=>e.input(s,t,o)),"input"),editor:a((s,t)=>this.withUIPrompt("editor",s,()=>e.editor(s,t)),"editor"),custom:a((s,t)=>this.withUIPrompt("custom",void 0,()=>e.custom(s,t)),"custom")}}withUIPrompt(e,s,t){this.uiPromptDepth++===0&&(this.activeUIPrompt={kind:e,title:s},this.emitUIPromptEvent({type:"ui_prompt_start",reason:"ui_prompt",kind:e,...s?{title:s}:{}}));const i=a(()=>{if(--this.uiPromptDepth>0)return;this.uiPromptDepth=0;const n=this.activeUIPrompt??{kind:e,title:s};this.activeUIPrompt=void 0,this.emitUIPromptEvent({type:"ui_prompt_end",reason:"ui_prompt",kind:n.kind,...n.title?{title:n.title}:{}})},"finish");try{return t().finally(i)}catch(n){throw i(),n}}emitUIPromptEvent(e){queueMicrotask(()=>{this.emit(e)})}getUIContext(){return this.uiContext}hasUI(){return this.uiContext!==x}getExtensionPaths(){return this.extensions.map(e=>e.path)}getAllRegisteredTools(){const e=new Map;for(const s of this.extensions)for(const t of s.tools.values())e.has(t.definition.name)||e.set(t.definition.name,t);return Array.from(e.values())}getToolDefinition(e){for(const s of this.extensions){const t=s.tools.get(e);if(t)return t.definition}}getFlags(){const e=new Map;for(const s of this.extensions)for(const[t,o]of s.flags)e.has(t)||e.set(t,o);return e}setFlagValue(e,s){this.runtime.flagValues.set(e,s)}getFlagValues(){return new Map(this.runtime.flagValues)}getShortcuts(e){this.shortcutDiagnostics=[];const s=k(e),t=new Map,o=a((i,n)=>{this.shortcutDiagnostics.push({type:"warning",message:i,path:n}),this.hasUI()||console.warn(i)},"addDiagnostic");for(const i of this.extensions)for(const[n,r]of i.shortcuts){const c=n.toLowerCase(),h=s[c];if(h?.restrictOverride===!0){o(`Extension shortcut '${n}' from ${r.extensionPath} conflicts with built-in shortcut. Skipping.`,r.extensionPath);continue}h?.restrictOverride===!1&&o(`Extension shortcut conflict: '${n}' is built-in shortcut for ${h.keybinding} and ${r.extensionPath}. Using ${r.extensionPath}.`,r.extensionPath);const f=t.get(c);f&&o(`Extension shortcut conflict: '${n}' registered by both ${f.extensionPath} and ${r.extensionPath}. Using ${r.extensionPath}.`,r.extensionPath),t.set(c,r)}return t}getShortcutDiagnostics(){return this.shortcutDiagnostics}invalidate(e="This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload()."){this.staleMessage||(this.staleMessage=e,this.runtime.invalidate(e))}assertActive(){if(this.staleMessage)throw new Error(this.staleMessage)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}emitError(e){for(const s of this.errorListeners)s(e)}hasHandlers(e){for(const s of this.extensions){const t=s.handlers.get(e);if(t&&t.length>0)return!0}return!1}getMessageRenderer(e){for(const s of this.extensions){const t=s.messageRenderers.get(e);if(t)return t}}getMarkdownTransformers(){return this.extensions.flatMap(e=>e.markdownTransformer?[e.markdownTransformer]:[])}getModelPickerEntries(){return this.extensions.flatMap(e=>[...e.modelPickerEntries?.values()??[]])}getEntryRenderer(e){for(const s of this.extensions){const t=s.entryRenderers?.get(e);if(t)return t}}resolveRegisteredCommands(){const e=[],s=new Map;for(const i of this.extensions)for(const n of i.commands.values())e.push(n),s.set(n.name,(s.get(n.name)??0)+1);const t=new Map,o=new Set;return e.map(i=>{const n=(t.get(i.name)??0)+1;t.set(i.name,n);let r=(s.get(i.name)??0)>1?`${i.name}:${n}`:i.name;if(o.has(r)){let c=n;do c++,r=`${i.name}:${c}`;while(o.has(r))}return o.add(r),{...i,invocationName:r}})}getModelRegistry(){return this.modelRegistry}getRegisteredCommands(){return this.commandDiagnostics=[],this.resolveRegisteredCommands()}getCommandDiagnostics(){return this.commandDiagnostics}getCommand(e){return this.resolveRegisteredCommands().find(s=>s.invocationName===e)}shutdown(){this.shutdownHandler()}getActiveTools(){return this.assertActive(),this.runtime.getActiveTools()}createContext(){const e=this,s=this.getModel,t=this.getScopedModels;return{get ui(){return e.assertActive(),e.uiContext},get mode(){return e.assertActive(),e.mode},get hasUI(){return e.assertActive(),e.hasUI()},get cwd(){return e.assertActive(),e.cwd},get sessionManager(){return e.assertActive(),e.sessionManager},get modelRegistry(){return e.assertActive(),e.modelRegistry},get model(){return e.assertActive(),s()},get scopedModels(){return e.assertActive(),t()},get thinkingLevel(){return e.assertActive(),e.runtime.getThinkingLevel()},isIdle:a(()=>(e.assertActive(),e.isIdleFn()),"isIdle"),isProjectTrusted:a(()=>(e.assertActive(),e.isProjectTrustedFn()),"isProjectTrusted"),get signal(){return e.assertActive(),e.getSignalFn()},abort:a(()=>{e.assertActive(),e.abortFn()},"abort"),hasPendingMessages:a(()=>(e.assertActive(),e.hasPendingMessagesFn()),"hasPendingMessages"),shutdown:a(()=>{e.assertActive(),e.shutdownHandler()},"shutdown"),getContextUsage:a(()=>(e.assertActive(),e.getContextUsageFn()),"getContextUsage"),compact:a(o=>{e.assertActive(),e.compactFn(o)},"compact"),getSystemPrompt:a(()=>(e.assertActive(),e.getSystemPromptFn()),"getSystemPrompt")}}createCommandContext(){const e=Object.defineProperties({},Object.getOwnPropertyDescriptors(this.createContext()));return e.getSystemPromptOptions=()=>(this.assertActive(),this.getSystemPromptOptionsFn()),e.waitForIdle=()=>(this.assertActive(),this.waitForIdleFn()),e.newSession=s=>(this.assertActive(),this.newSessionHandler(s)),e.fork=(s,t)=>(this.assertActive(),this.forkHandler(s,t)),e.navigateTree=(s,t)=>(this.assertActive(),this.navigateTreeHandler(s,t)),e.switchSession=(s,t)=>(this.assertActive(),this.switchSessionHandler(s,t)),e.reload=()=>(this.assertActive(),this.reloadHandler()),e}async emitBoundary(e,s){const t=this.createContext();let o=[],i=!1,n=await s(o),r=!0;for(const{ext:c,handlers:h}of m(this.extensions,e.type))for(const f of h){const u={...e,entries:o,continue:i,context:n};try{const d=await f(u,t);d?.entries!==void 0&&(o=d.entries),d?.continue!==void 0&&(i=d.continue)}catch(d){this.emitError({extensionPath:c.path,event:e.type,error:d instanceof Error?d.message:String(d),stack:d instanceof Error?d.stack:void 0})}try{n=await s(o),r=!0}catch(d){r=!1,this.emitError({extensionPath:c.path,event:e.type,error:`Invalid boundary entries: ${d instanceof Error?d.message:String(d)}`,stack:d instanceof Error?d.stack:void 0})}}return r?{entries:o,continue:i,context:n,valid:!0}:{entries:[],continue:!1,context:n,valid:!1}}isSessionBeforeEvent(e){return e.type==="session_before_switch"||e.type==="session_before_fork"||e.type==="session_before_compact"||e.type==="session_before_tree"}async emit(e){const s=this.createContext();let t;for(const{ext:o,handlers:i}of m(this.extensions,e.type))for(const n of i)try{const r=await n(e,s);if(this.isSessionBeforeEvent(e)&&r&&(t=r,t.cancel))return t}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:e.type,error:c,stack:h})}return t}async emitCacheWarmingDecision(e){const s=this.createContext();let t=e.action;for(const{ext:o,handlers:i}of m(this.extensions,e.type))for(const n of i)try{const r=await n(e,s);r?.action!==void 0&&(t=r.action)}catch(r){this.emitError({extensionPath:o.path,event:e.type,error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}return t}async emitMessageEnd(e){const s=this.createContext();let t=e.message,o=!1;for(const{ext:i,handlers:n}of m(this.extensions,"message_end"))for(const r of n)try{const c={...e,message:t},h=await r(c,s);if(!h?.message)continue;if(h.message.role!==t.role){this.emitError({extensionPath:i.path,event:"message_end",error:"message_end handlers must return a message with the same role"});continue}t=h.message,o=!0}catch(c){const h=c instanceof Error?c.message:String(c),f=c instanceof Error?c.stack:void 0;this.emitError({extensionPath:i.path,event:"message_end",error:h,stack:f})}return o?t:void 0}async emitToolResult(e){const s=this.createContext(),t={...e};let o=!1;for(const{ext:i,handlers:n}of m(this.extensions,"tool_result"))for(const r of n)try{const c=await r(t,s);if(!c)continue;c.content!==void 0&&(t.content=c.content,o=!0),c.details!==void 0&&(t.details=c.details,o=!0),c.isError!==void 0&&(t.isError=c.isError,o=!0),c.usage!==void 0&&(t.usage=c.usage,o=!0)}catch(c){const h=c instanceof Error?c.message:String(c),f=c instanceof Error?c.stack:void 0;this.emitError({extensionPath:i.path,event:"tool_result",error:h,stack:f})}if(o)return{content:t.content,details:t.details,isError:t.isError,usage:t.usage}}async emitToolCall(e){const s=this.createContext();let t;for(const{handlers:o}of m(this.extensions,"tool_call"))for(const i of o){const n=await i(e,s);if(n&&(t=n,t.block))return t}return t}async emitUserBash(e){const s=this.createContext();for(const{ext:t,handlers:o}of m(this.extensions,"user_bash"))for(const i of o)try{const n=await i(e,s);if(n===void 0)continue;if(!_(n))throw new Error("Invalid user_bash handler result: return undefined for local execution or exactly one valid { operations } or { result } object");return n}catch(n){const r=n instanceof Error?n.message:String(n),c=n instanceof Error?n.stack:void 0;throw this.emitError({extensionPath:t.path,event:"user_bash",error:r,stack:c}),n}}async emitContext(e){const s=this.createContext();let t=structuredClone(e);for(const{ext:o,handlers:i}of m(this.extensions,"context"))for(const n of i)try{const r=t.filter(d=>d.role!=="system"),c=r.slice(),u=(await n({type:"context",messages:r},s))?.messages??(y(r,c)?void 0:r);if(!u)continue;t=C(t,c,u)}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"context",error:c,stack:h})}for(const{ext:o,handlers:i}of m(this.extensions,"context_with_system"))for(const n of i)try{const r=t[0]?.role==="system";t=(await n({type:"context_with_system",messages:t},s))?.messages??t,r&&t[0]?.role!=="system"&&this.emitError({extensionPath:o.path,event:"context_with_system",error:"Handler removed the leading system message; the request has no prompt or initial tool declarations. Keep it at index 0 or replace a dropped prefix with getCurrentSystemMessage()."})}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"context_with_system",error:c,stack:h})}return t}async emitBeforeProviderRequest(e){const s=this.createContext();let t=e;for(const{ext:o,handlers:i}of m(this.extensions,"before_provider_request"))for(const n of i)try{const c=await n({type:"before_provider_request",payload:t},s);c!==void 0&&(t=c)}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"before_provider_request",error:c,stack:h})}return t}async emitBeforeProviderHeaders(e){const s=this.createContext();for(const{ext:t,handlers:o}of m(this.extensions,"before_provider_headers"))for(const i of o)try{await i({type:"before_provider_headers",headers:e},s)}catch(n){const r=n instanceof Error?n.message:String(n),c=n instanceof Error?n.stack:void 0;this.emitError({extensionPath:t.path,event:"before_provider_headers",error:r,stack:c})}return e}async emitBeforeAgentStart(e,s,t){const o=p(t),i=a(()=>E(o),"renderCurrentSystemPrompt"),n=Object.defineProperties({},Object.getOwnPropertyDescriptors(this.createContext()));n.getSystemPrompt=()=>(this.assertActive(),i());const r=[];for(const{ext:c,handlers:h}of m(this.extensions,"before_agent_start"))for(const f of h)try{const d=await f({type:"before_agent_start",prompt:e,images:s,get systemPrompt(){return i()},systemPromptOptions:o},n);if(d){const g=d;g.message&&r.push(g.message),g.systemPrompt!==void 0&&(o.forceSystemPrompt=g.systemPrompt)}}catch(u){const d=u instanceof Error?u.message:String(u),g=u instanceof Error?u.stack:void 0;this.emitError({extensionPath:c.path,event:"before_agent_start",error:d,stack:g})}return{messages:r,systemPromptOptions:o}}async emitResourcesDiscover(e,s){const t=this.createContext(),o=[],i=[],n=[];for(const{ext:r,handlers:c}of m(this.extensions,"resources_discover"))for(const h of c)try{const d=await h({type:"resources_discover",cwd:e,reason:s},t);d?.skillPaths?.length&&o.push(...d.skillPaths.map(g=>({path:g,extensionPath:r.path}))),d?.promptPaths?.length&&i.push(...d.promptPaths.map(g=>({path:g,extensionPath:r.path}))),d?.themePaths?.length&&n.push(...d.themePaths.map(g=>({path:g,extensionPath:r.path})))}catch(f){const u=f instanceof Error?f.message:String(f),d=f instanceof Error?f.stack:void 0;this.emitError({extensionPath:r.path,event:"resources_discover",error:u,stack:d})}return{skillPaths:o,promptPaths:i,themePaths:n}}async emitInput(e,s,t,o){const i=this.createContext();let n=e,r=s;for(const{ext:c,handlers:h}of m(this.extensions,"input"))for(const f of h)try{const d=await f({type:"input",text:n,images:r,source:t,streamingBehavior:o},i);if(d?.action==="handled")return d;d?.action==="transform"&&(n=d.text,r=d.images??r)}catch(u){this.emitError({extensionPath:c.path,event:"input",error:u instanceof Error?u.message:String(u),stack:u instanceof Error?u.stack:void 0})}return n!==e||r!==s?{action:"transform",text:n,images:r}:{action:"continue"}}}export{U as ExtensionRunner,I as emitProjectTrustEvent,F as emitSessionShutdownEvent};
1
+ var v=Object.defineProperty;var a=(l,e)=>v(l,"name",{value:e,configurable:!0});import{getCurrentSystemMessage as P}from"@earendil-works/pi-ai";import{theme as w}from"../../modes/interactive/theme/theme.js";import{buildSystemPrompt as E,normalizeBuildSystemPromptOptions as p}from"../system-prompt.js";const S=["app.interrupt","app.clear","app.exit","app.suspend","app.thinking.cycle","app.model.cycleForward","app.model.cycleBackward","app.model.select","app.tools.expand","app.thinking.toggle","app.editor.external","app.message.copy","app.message.followUp","tui.input.submit","tui.select.confirm","tui.select.cancel","tui.input.copy","tui.editor.deleteToLineEnd"],k=a(l=>{const e={};for(const[s,t]of Object.entries(l)){if(t===void 0)continue;const o=Array.isArray(t)?t:[t],i=S.includes(s);for(const n of o){const r=n.toLowerCase();e[r]?.restrictOverride&&!i||(e[r]={keybinding:s,restrictOverride:i})}}return e},"buildBuiltinKeybindings");function _(l){if(typeof l!="object"||l===null)return!1;const e=l,s=e.operations!==void 0,t=e.result!==void 0;if(s===t)return!1;if(s){const n=e.operations;return typeof n!="object"||n===null?!1:typeof n.exec=="function"}const o=e.result;if(typeof o!="object"||o===null)return!1;const i=o;return typeof i.output=="string"&&"exitCode"in i&&(i.exitCode===void 0||typeof i.exitCode=="number")&&typeof i.cancelled=="boolean"&&typeof i.truncated=="boolean"&&(i.fullOutputPath===void 0||typeof i.fullOutputPath=="string")}a(_,"isUserBashEventResult");async function F(l,e){return l.hasHandlers("session_shutdown")?(await l.emit(e),!0):!1}a(F,"emitSessionShutdownEvent");function m(l,e){return l.map(s=>({ext:s,handlers:s.handlers.get(e)?.slice()??[]}))}a(m,"snapshotEventHandlers");function x(l,e){return l.length===e.length&&l.every((s,t)=>s===e[t])}a(x,"sameMessages");function C(l,e,s){if(x(s,e))return l;const t=P(l);return t?[t,...s]:s}a(C,"restoreSystemMessages");async function I(l,e,s){const t=[];for(const{ext:o,handlers:i}of m(l.extensions,"project_trust"))for(const n of i)try{const r=await n(e,s);if(r.trusted==="undecided")continue;return{result:r,errors:t}}catch(r){t.push({extensionPath:o.path,event:e.type,error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}return{errors:t}}a(I,"emitProjectTrustEvent");const y={select:a(async()=>{},"select"),confirm:a(async()=>!1,"confirm"),input:a(async()=>{},"input"),notify:a(()=>{},"notify"),setPanel:a(()=>{},"setPanel"),requestInput:a(async()=>{},"requestInput"),requestChoice:a(async()=>{},"requestChoice"),onTerminalInput:a(()=>()=>{},"onTerminalInput"),setStatus:a(()=>{},"setStatus"),setWorkingMessage:a(()=>{},"setWorkingMessage"),setWorkingVisible:a(()=>{},"setWorkingVisible"),setWorkingIndicator:a(()=>{},"setWorkingIndicator"),setHiddenThinkingLabel:a(()=>{},"setHiddenThinkingLabel"),setWidget:a(()=>{},"setWidget"),setFooter:a(()=>{},"setFooter"),setHeader:a(()=>{},"setHeader"),setTitle:a(()=>{},"setTitle"),custom:a(async()=>{},"custom"),pasteToEditor:a(()=>{},"pasteToEditor"),setEditorText:a(()=>{},"setEditorText"),getEditorText:a(()=>"","getEditorText"),editor:a(async()=>{},"editor"),addAutocompleteProvider:a(()=>{},"addAutocompleteProvider"),setEditorComponent:a(()=>{},"setEditorComponent"),getEditorComponent:a(()=>{},"getEditorComponent"),get theme(){return w},getAllThemes:a(()=>[],"getAllThemes"),getTheme:a(()=>{},"getTheme"),setTheme:a(l=>({success:!1,error:"UI not available"}),"setTheme"),getToolsExpanded:a(()=>!1,"getToolsExpanded"),setToolsExpanded:a(()=>{},"setToolsExpanded")};class U{static{a(this,"ExtensionRunner")}extensions;runtime;uiContext;mode="print";cwd;sessionManager;modelRegistry;errorListeners=new Set;getModel=a(()=>{},"getModel");getScopedModels=a(()=>[],"getScopedModels");isIdleFn=a(()=>!0,"isIdleFn");isProjectTrustedFn=a(()=>!0,"isProjectTrustedFn");getSignalFn=a(()=>{},"getSignalFn");waitForIdleFn=a(async()=>{},"waitForIdleFn");abortFn=a(()=>{},"abortFn");hasPendingMessagesFn=a(()=>!1,"hasPendingMessagesFn");getContextUsageFn=a(()=>{},"getContextUsageFn");compactFn=a(()=>{},"compactFn");getSystemPromptFn=a(()=>"","getSystemPromptFn");getSystemPromptOptionsFn=a(()=>p({cwd:this.cwd}),"getSystemPromptOptionsFn");newSessionHandler=a(async()=>({cancelled:!1}),"newSessionHandler");forkHandler=a(async()=>({cancelled:!1}),"forkHandler");navigateTreeHandler=a(async()=>({cancelled:!1}),"navigateTreeHandler");switchSessionHandler=a(async()=>({cancelled:!1}),"switchSessionHandler");reloadHandler=a(async()=>{},"reloadHandler");shutdownHandler=a(()=>{},"shutdownHandler");shortcutDiagnostics=[];commandDiagnostics=[];staleMessage;uiPromptDepth=0;activeUIPrompt;constructor(e,s,t,o,i){this.extensions=e,this.runtime=s,this.uiContext=y,this.cwd=t,this.sessionManager=o,this.modelRegistry=i}bindCore(e,s,t){this.runtime.sendMessage=e.sendMessage,this.runtime.sendUserMessage=e.sendUserMessage,this.runtime.appendEntry=e.appendEntry,this.runtime.emitHostEvent=e.emitHostEvent??(()=>{}),this.runtime.setSessionName=e.setSessionName,this.runtime.getSessionName=e.getSessionName,this.runtime.setLabel=e.setLabel,this.runtime.getActiveTools=e.getActiveTools,this.runtime.getAllTools=e.getAllTools,this.runtime.setActiveTools=e.setActiveTools,this.runtime.isToolAllowed=e.isToolAllowed,this.runtime.getToolAllowlist=e.getToolAllowlist,this.runtime.getToolDenylist=e.getToolDenylist,this.runtime.refreshTools=e.refreshTools,this.runtime.getCommands=e.getCommands,this.runtime.setModel=e.setModel,this.runtime.getThinkingLevel=e.getThinkingLevel,this.runtime.setThinkingLevel=e.setThinkingLevel,this.getModel=s.getModel,this.getScopedModels=s.getScopedModels,this.isIdleFn=s.isIdle,this.isProjectTrustedFn=s.isProjectTrusted,this.getSignalFn=s.getSignal,this.abortFn=s.abort,this.hasPendingMessagesFn=s.hasPendingMessages,this.shutdownHandler=s.shutdown,this.getContextUsageFn=s.getContextUsage,this.compactFn=s.compact,this.getSystemPromptFn=s.getSystemPrompt,this.getSystemPromptOptionsFn=s.getSystemPromptOptions??(()=>p({cwd:this.cwd}));for(const{name:o,config:i,extensionPath:n}of this.runtime.pendingProviderRegistrations)try{t?.registerProvider?t.registerProvider(o,i):this.modelRegistry.registerProvider(o,i)}catch(r){this.emitError({extensionPath:n,event:"register_provider",error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}this.runtime.pendingProviderRegistrations=[];for(const{provider:o,extensionPath:i}of this.runtime.pendingNativeProviderRegistrations)try{t?.registerNativeProvider?t.registerNativeProvider(o):this.modelRegistry.registerProvider(o)}catch(n){this.emitError({extensionPath:i,event:"register_provider",error:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:void 0})}this.runtime.pendingNativeProviderRegistrations=[],this.runtime.registerProvider=(o,i)=>{if(t?.registerProvider){t.registerProvider(o,i);return}this.modelRegistry.registerProvider(o,i)},this.runtime.registerNativeProvider=o=>{if(t?.registerNativeProvider){t.registerNativeProvider(o);return}this.modelRegistry.registerProvider(o)},this.runtime.unregisterProvider=o=>{if(t?.unregisterProvider){t.unregisterProvider(o);return}this.modelRegistry.unregisterProvider(o)}}bindCommandContext(e){if(e){this.waitForIdleFn=e.waitForIdle,this.newSessionHandler=e.newSession,this.forkHandler=e.fork,this.navigateTreeHandler=e.navigateTree,this.switchSessionHandler=e.switchSession,this.reloadHandler=e.reload;return}this.waitForIdleFn=async()=>{},this.newSessionHandler=async()=>({cancelled:!1}),this.forkHandler=async()=>({cancelled:!1}),this.navigateTreeHandler=async()=>({cancelled:!1}),this.switchSessionHandler=async()=>({cancelled:!1}),this.reloadHandler=async()=>{}}setUIContext(e,s="print"){this.uiContext=e?this.wrapUIPromptContext(e):y,this.mode=s}wrapUIPromptContext(e){return{...e,select:a((s,t,o)=>this.withUIPrompt("select",s,()=>e.select(s,t,o)),"select"),confirm:a((s,t,o)=>this.withUIPrompt("confirm",s,()=>e.confirm(s,t,o)),"confirm"),input:a((s,t,o)=>this.withUIPrompt("input",s,()=>e.input(s,t,o)),"input"),editor:a((s,t)=>this.withUIPrompt("editor",s,()=>e.editor(s,t)),"editor"),custom:a((s,t)=>this.withUIPrompt("custom",void 0,()=>e.custom(s,t)),"custom")}}withUIPrompt(e,s,t){this.uiPromptDepth++===0&&(this.activeUIPrompt={kind:e,title:s},this.emitUIPromptEvent({type:"ui_prompt_start",reason:"ui_prompt",kind:e,...s?{title:s}:{}}));const i=a(()=>{if(--this.uiPromptDepth>0)return;this.uiPromptDepth=0;const n=this.activeUIPrompt??{kind:e,title:s};this.activeUIPrompt=void 0,this.emitUIPromptEvent({type:"ui_prompt_end",reason:"ui_prompt",kind:n.kind,...n.title?{title:n.title}:{}})},"finish");try{return t().finally(i)}catch(n){throw i(),n}}emitUIPromptEvent(e){queueMicrotask(()=>{this.emit(e)})}getUIContext(){return this.uiContext}hasUI(){return this.uiContext!==y}getExtensionPaths(){return this.extensions.map(e=>e.path)}getAllRegisteredTools(){const e=new Map;for(const s of this.extensions)for(const t of s.tools.values())e.has(t.definition.name)||e.set(t.definition.name,t);return Array.from(e.values())}getToolDefinition(e){for(const s of this.extensions){const t=s.tools.get(e);if(t)return t.definition}}getFlags(){const e=new Map;for(const s of this.extensions)for(const[t,o]of s.flags)e.has(t)||e.set(t,o);return e}setFlagValue(e,s){this.runtime.flagValues.set(e,s)}getFlagValues(){return new Map(this.runtime.flagValues)}getShortcuts(e){this.shortcutDiagnostics=[];const s=k(e),t=new Map,o=a((i,n)=>{this.shortcutDiagnostics.push({type:"warning",message:i,path:n}),this.hasUI()||console.warn(i)},"addDiagnostic");for(const i of this.extensions)for(const[n,r]of i.shortcuts){const c=n.toLowerCase(),h=s[c];if(h?.restrictOverride===!0){o(`Extension shortcut '${n}' from ${r.extensionPath} conflicts with built-in shortcut. Skipping.`,r.extensionPath);continue}h?.restrictOverride===!1&&o(`Extension shortcut conflict: '${n}' is built-in shortcut for ${h.keybinding} and ${r.extensionPath}. Using ${r.extensionPath}.`,r.extensionPath);const f=t.get(c);f&&o(`Extension shortcut conflict: '${n}' registered by both ${f.extensionPath} and ${r.extensionPath}. Using ${r.extensionPath}.`,r.extensionPath),t.set(c,r)}return t}getShortcutDiagnostics(){return this.shortcutDiagnostics}invalidate(e="This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload()."){this.staleMessage||(this.staleMessage=e,this.runtime.invalidate(e))}assertActive(){if(this.staleMessage)throw new Error(this.staleMessage)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}emitError(e){for(const s of this.errorListeners)s(e)}hasHandlers(e){for(const s of this.extensions){const t=s.handlers.get(e);if(t&&t.length>0)return!0}return!1}getMessageRenderer(e){for(const s of this.extensions){const t=s.messageRenderers.get(e);if(t)return t}}getMarkdownTransformers(){return this.extensions.flatMap(e=>e.markdownTransformer?[e.markdownTransformer]:[])}getModelPickerEntries(){return this.extensions.flatMap(e=>[...e.modelPickerEntries?.values()??[]])}getEntryRenderer(e){for(const s of this.extensions){const t=s.entryRenderers?.get(e);if(t)return t}}resolveRegisteredCommands(){const e=[],s=new Map;for(const i of this.extensions)for(const n of i.commands.values())e.push(n),s.set(n.name,(s.get(n.name)??0)+1);const t=new Map,o=new Set;return e.map(i=>{const n=(t.get(i.name)??0)+1;t.set(i.name,n);let r=(s.get(i.name)??0)>1?`${i.name}:${n}`:i.name;if(o.has(r)){let c=n;do c++,r=`${i.name}:${c}`;while(o.has(r))}return o.add(r),{...i,invocationName:r}})}getModelRegistry(){return this.modelRegistry}getRegisteredCommands(){return this.commandDiagnostics=[],this.resolveRegisteredCommands()}getCommandDiagnostics(){return this.commandDiagnostics}getCommand(e){return this.resolveRegisteredCommands().find(s=>s.invocationName===e)}shutdown(){this.shutdownHandler()}getActiveTools(){return this.assertActive(),this.runtime.getActiveTools()}createContext(){const e=this,s=this.getModel,t=this.getScopedModels;return{get ui(){return e.assertActive(),e.uiContext},get mode(){return e.assertActive(),e.mode},get hasUI(){return e.assertActive(),e.hasUI()},get cwd(){return e.assertActive(),e.cwd},get sessionManager(){return e.assertActive(),e.sessionManager},get modelRegistry(){return e.assertActive(),e.modelRegistry},get model(){return e.assertActive(),s()},get scopedModels(){return e.assertActive(),t()},get thinkingLevel(){return e.assertActive(),e.runtime.getThinkingLevel()},isIdle:a(()=>(e.assertActive(),e.isIdleFn()),"isIdle"),isProjectTrusted:a(()=>(e.assertActive(),e.isProjectTrustedFn()),"isProjectTrusted"),get signal(){return e.assertActive(),e.getSignalFn()},abort:a(()=>{e.assertActive(),e.abortFn()},"abort"),hasPendingMessages:a(()=>(e.assertActive(),e.hasPendingMessagesFn()),"hasPendingMessages"),shutdown:a(()=>{e.assertActive(),e.shutdownHandler()},"shutdown"),getContextUsage:a(()=>(e.assertActive(),e.getContextUsageFn()),"getContextUsage"),compact:a(o=>{e.assertActive(),e.compactFn(o)},"compact"),getSystemPrompt:a(()=>(e.assertActive(),e.getSystemPromptFn()),"getSystemPrompt")}}createCommandContext(){const e=Object.defineProperties({},Object.getOwnPropertyDescriptors(this.createContext()));return e.getSystemPromptOptions=()=>(this.assertActive(),this.getSystemPromptOptionsFn()),e.waitForIdle=()=>(this.assertActive(),this.waitForIdleFn()),e.newSession=s=>(this.assertActive(),this.newSessionHandler(s)),e.fork=(s,t)=>(this.assertActive(),this.forkHandler(s,t)),e.navigateTree=(s,t)=>(this.assertActive(),this.navigateTreeHandler(s,t)),e.switchSession=(s,t)=>(this.assertActive(),this.switchSessionHandler(s,t)),e.reload=()=>(this.assertActive(),this.reloadHandler()),e}async emitBoundary(e,s){const t=this.createContext();let o=[],i=!1,n=await s(o),r=!0;for(const{ext:c,handlers:h}of m(this.extensions,e.type))for(const f of h){const u={...e,entries:o,continue:i,context:n};try{const d=await f(u,t);d?.entries!==void 0&&(o=d.entries),d?.continue!==void 0&&(i=d.continue)}catch(d){this.emitError({extensionPath:c.path,event:e.type,error:d instanceof Error?d.message:String(d),stack:d instanceof Error?d.stack:void 0})}try{n=await s(o),r=!0}catch(d){r=!1,this.emitError({extensionPath:c.path,event:e.type,error:`Invalid boundary entries: ${d instanceof Error?d.message:String(d)}`,stack:d instanceof Error?d.stack:void 0})}}return r?{entries:o,continue:i,context:n,valid:!0}:{entries:[],continue:!1,context:n,valid:!1}}isSessionBeforeEvent(e){return e.type==="session_before_switch"||e.type==="session_before_fork"||e.type==="session_before_compact"||e.type==="session_before_tree"}async emit(e){const s=this.createContext();let t;for(const{ext:o,handlers:i}of m(this.extensions,e.type))for(const n of i)try{const r=await n(e,s);if(this.isSessionBeforeEvent(e)&&r&&(t=r,t.cancel))return t}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:e.type,error:c,stack:h})}return t}async emitCacheWarmingDecision(e){const s=this.createContext();let t=e.action;for(const{ext:o,handlers:i}of m(this.extensions,e.type))for(const n of i)try{const r=await n(e,s);r?.action!==void 0&&(t=r.action)}catch(r){this.emitError({extensionPath:o.path,event:e.type,error:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0})}return t}async emitMessageEnd(e){const s=this.createContext();let t=e.message,o=!1;for(const{ext:i,handlers:n}of m(this.extensions,"message_end"))for(const r of n)try{const c={...e,message:t},h=await r(c,s);if(!h?.message)continue;if(h.message.role!==t.role){this.emitError({extensionPath:i.path,event:"message_end",error:"message_end handlers must return a message with the same role"});continue}t=h.message,o=!0}catch(c){const h=c instanceof Error?c.message:String(c),f=c instanceof Error?c.stack:void 0;this.emitError({extensionPath:i.path,event:"message_end",error:h,stack:f})}return o?t:void 0}async emitToolResult(e){const s=this.createContext(),t={...e};let o=!1;for(const{ext:i,handlers:n}of m(this.extensions,"tool_result"))for(const r of n)try{const c=await r(t,s);if(!c)continue;c.content!==void 0&&(t.content=c.content,o=!0),c.details!==void 0&&(t.details=c.details,o=!0),c.isError!==void 0&&(t.isError=c.isError,o=!0),c.usage!==void 0&&(t.usage=c.usage,o=!0)}catch(c){const h=c instanceof Error?c.message:String(c),f=c instanceof Error?c.stack:void 0;this.emitError({extensionPath:i.path,event:"tool_result",error:h,stack:f})}if(o)return{content:t.content,details:t.details,isError:t.isError,usage:t.usage}}async emitToolCall(e){const s=this.createContext();let t;for(const{handlers:o}of m(this.extensions,"tool_call"))for(const i of o){const n=await i(e,s);if(n&&(t=n,t.block))return t}return t}async emitUserBash(e){const s=this.createContext();for(const{ext:t,handlers:o}of m(this.extensions,"user_bash"))for(const i of o)try{const n=await i(e,s);if(n===void 0)continue;if(!_(n))throw new Error("Invalid user_bash handler result: return undefined for local execution or exactly one valid { operations } or { result } object");return n}catch(n){const r=n instanceof Error?n.message:String(n),c=n instanceof Error?n.stack:void 0;throw this.emitError({extensionPath:t.path,event:"user_bash",error:r,stack:c}),n}}async emitContext(e){const s=this.createContext();let t=structuredClone(e);for(const{ext:o,handlers:i}of m(this.extensions,"context"))for(const n of i)try{const r=t.filter(d=>d.role!=="system"),c=r.slice(),u=(await n({type:"context",messages:r},s))?.messages??(x(r,c)?void 0:r);if(!u)continue;t=C(t,c,u)}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"context",error:c,stack:h})}for(const{ext:o,handlers:i}of m(this.extensions,"context_with_system"))for(const n of i)try{const r=t[0]?.role==="system";t=(await n({type:"context_with_system",messages:t},s))?.messages??t,r&&t[0]?.role!=="system"&&this.emitError({extensionPath:o.path,event:"context_with_system",error:"Handler removed the leading system message; the request has no prompt or initial tool declarations. Keep it at index 0 or replace a dropped prefix with getCurrentSystemMessage()."})}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"context_with_system",error:c,stack:h})}return t}async emitBeforeProviderRequest(e){const s=this.createContext();let t=e;for(const{ext:o,handlers:i}of m(this.extensions,"before_provider_request"))for(const n of i)try{const c=await n({type:"before_provider_request",payload:t},s);c!==void 0&&(t=c)}catch(r){const c=r instanceof Error?r.message:String(r),h=r instanceof Error?r.stack:void 0;this.emitError({extensionPath:o.path,event:"before_provider_request",error:c,stack:h})}return t}async emitBeforeProviderHeaders(e){const s=this.createContext();for(const{ext:t,handlers:o}of m(this.extensions,"before_provider_headers"))for(const i of o)try{await i({type:"before_provider_headers",headers:e},s)}catch(n){const r=n instanceof Error?n.message:String(n),c=n instanceof Error?n.stack:void 0;this.emitError({extensionPath:t.path,event:"before_provider_headers",error:r,stack:c})}return e}async emitBeforeAgentStart(e,s,t){const o=p(t),i=a(()=>E(o),"renderCurrentSystemPrompt"),n=Object.defineProperties({},Object.getOwnPropertyDescriptors(this.createContext()));n.getSystemPrompt=()=>(this.assertActive(),i());const r=[];for(const{ext:c,handlers:h}of m(this.extensions,"before_agent_start"))for(const f of h)try{const d=await f({type:"before_agent_start",prompt:e,images:s,get systemPrompt(){return i()},systemPromptOptions:o},n);if(d){const g=d;g.message&&r.push(g.message),g.systemPrompt!==void 0&&(o.forceSystemPrompt=g.systemPrompt)}}catch(u){const d=u instanceof Error?u.message:String(u),g=u instanceof Error?u.stack:void 0;this.emitError({extensionPath:c.path,event:"before_agent_start",error:d,stack:g})}return{messages:r,systemPromptOptions:o}}async emitResourcesDiscover(e,s){const t=this.createContext(),o=[],i=[],n=[];for(const{ext:r,handlers:c}of m(this.extensions,"resources_discover"))for(const h of c)try{const d=await h({type:"resources_discover",cwd:e,reason:s},t);d?.skillPaths?.length&&o.push(...d.skillPaths.map(g=>({path:g,extensionPath:r.path}))),d?.promptPaths?.length&&i.push(...d.promptPaths.map(g=>({path:g,extensionPath:r.path}))),d?.themePaths?.length&&n.push(...d.themePaths.map(g=>({path:g,extensionPath:r.path})))}catch(f){const u=f instanceof Error?f.message:String(f),d=f instanceof Error?f.stack:void 0;this.emitError({extensionPath:r.path,event:"resources_discover",error:u,stack:d})}return{skillPaths:o,promptPaths:i,themePaths:n}}async emitInput(e,s,t,o){const i=this.createContext();let n=e,r=s;for(const{ext:c,handlers:h}of m(this.extensions,"input"))for(const f of h)try{const d=await f({type:"input",text:n,images:r,source:t,streamingBehavior:o},i);if(d?.action==="handled")return d;d?.action==="transform"&&(n=d.text,r=d.images??r)}catch(u){this.emitError({extensionPath:c.path,event:"input",error:u instanceof Error?u.message:String(u),stack:u instanceof Error?u.stack:void 0})}return n!==e||r!==s?{action:"transform",text:n,images:r}:{action:"continue"}}}export{U as ExtensionRunner,I as emitProjectTrustEvent,F as emitSessionShutdownEvent};
@@ -783,6 +783,7 @@ export interface ExtensionAPI {
783
783
  expandPromptTemplates?: boolean;
784
784
  }): Promise<void>;
785
785
  appendEntry<T = unknown>(customType: string, data?: T): void;
786
+ emitHostEvent(name: string, data?: unknown): void;
786
787
  setSessionName(name: string): void;
787
788
  getSessionName(): string | undefined;
788
789
  setLabel(entryId: string, label: string | undefined): void;
@@ -792,6 +793,7 @@ export interface ExtensionAPI {
792
793
  setActiveTools(toolNames: string[]): void;
793
794
  isToolAllowed(name: string): boolean;
794
795
  getToolAllowlist(): string[] | undefined;
796
+ getToolDenylist(): string[] | undefined;
795
797
  getCommands(): SlashCommandInfo[];
796
798
  setModel(model: Model<any>): Promise<boolean>;
797
799
  getThinkingLevel(): ThinkingLevel;
@@ -871,6 +873,7 @@ export type SendUserMessageHandler = (content: string | (TextContent | ImageCont
871
873
  expandPromptTemplates?: boolean;
872
874
  }) => void;
873
875
  export type AppendEntryHandler = <T = unknown>(customType: string, data?: T) => void;
876
+ export type EmitHostEventHandler = (name: string, data?: unknown) => void;
874
877
  export type SetSessionNameHandler = (name: string) => void;
875
878
  export type GetSessionNameHandler = () => string | undefined;
876
879
  export type GetActiveToolsHandler = () => string[];
@@ -882,6 +885,7 @@ export type GetCommandsHandler = () => SlashCommandInfo[];
882
885
  export type SetActiveToolsHandler = (toolNames: string[]) => void;
883
886
  export type IsToolAllowedHandler = (name: string) => boolean;
884
887
  export type GetToolAllowlistHandler = () => string[] | undefined;
888
+ export type GetToolDenylistHandler = () => string[] | undefined;
885
889
  export type RefreshToolsHandler = () => void;
886
890
  export type SetModelHandler = (model: Model<any>) => Promise<boolean>;
887
891
  export type GetThinkingLevelHandler = () => ThinkingLevel;
@@ -909,6 +913,7 @@ export interface ExtensionActions {
909
913
  sendMessage: SendMessageHandler;
910
914
  sendUserMessage: SendUserMessageHandler;
911
915
  appendEntry: AppendEntryHandler;
916
+ emitHostEvent?: EmitHostEventHandler;
912
917
  setSessionName: SetSessionNameHandler;
913
918
  getSessionName: GetSessionNameHandler;
914
919
  setLabel: SetLabelHandler;
@@ -917,6 +922,7 @@ export interface ExtensionActions {
917
922
  setActiveTools: SetActiveToolsHandler;
918
923
  isToolAllowed: IsToolAllowedHandler;
919
924
  getToolAllowlist: GetToolAllowlistHandler;
925
+ getToolDenylist?: GetToolDenylistHandler;
920
926
  refreshTools: RefreshToolsHandler;
921
927
  getCommands: GetCommandsHandler;
922
928
  setModel: SetModelHandler;
@@ -0,0 +1,50 @@
1
+ export interface HostCapability {
2
+ name: string;
3
+ version: number;
4
+ }
5
+ export type HostCapabilitySource = "env" | "rpc" | "sdk";
6
+ export interface HostCallRequest {
7
+ capability: string;
8
+ method: string;
9
+ params: Record<string, unknown>;
10
+ }
11
+ export interface HostCallOptions {
12
+ signal?: AbortSignal;
13
+ timeoutMs?: number;
14
+ }
15
+ export type HostTransport = (request: HostCallRequest, options: HostCallOptions) => Promise<unknown>;
16
+ export type HostCallErrorCode = "unavailable" | "timeout" | "aborted" | "host_error" | "bad_response";
17
+ export declare class HostCallError extends Error {
18
+ readonly code: HostCallErrorCode;
19
+ constructor(code: HostCallErrorCode, message: string);
20
+ }
21
+ export declare const HOST_CAPABILITIES_ENV = "DAL_HOST_CAPABILITIES";
22
+ export declare const HOST_URL_ENV = "DAL_HOST_URL";
23
+ export declare const HOST_TOKEN_ENV = "DAL_HOST_TOKEN";
24
+ export declare const HOST_TOKEN_HEADER = "x-dal-host-token";
25
+ export declare const DEFAULT_HOST_CALL_TIMEOUT_MS = 30000;
26
+ export declare function parseHostCapabilities(raw: unknown): HostCapability[];
27
+ export type HostCapabilitiesListener = (capabilities: readonly HostCapability[]) => void;
28
+ export declare class HostCapabilities {
29
+ private readonly entries;
30
+ private readonly listeners;
31
+ list(): HostCapability[];
32
+ get(name: string): HostCapability | undefined;
33
+ has(name: string, minVersion?: number): boolean;
34
+ set(source: HostCapabilitySource, capabilities: readonly HostCapability[], transport: HostTransport): void;
35
+ clear(source: HostCapabilitySource): void;
36
+ onChange(listener: HostCapabilitiesListener): () => void;
37
+ call<T = unknown>(capability: string, method: string, params?: Record<string, unknown>, options?: HostCallOptions): Promise<T>;
38
+ private notify;
39
+ }
40
+ export type HostFetch = (input: string, init: RequestInit) => Promise<Response>;
41
+ export declare function createHttpHostTransport(config: {
42
+ baseUrl: string;
43
+ token: string;
44
+ fetch?: HostFetch;
45
+ }): HostTransport;
46
+ export declare function readHostCapabilitiesFromEnv(env?: NodeJS.ProcessEnv, onError?: (message: string) => void, fetchImpl?: HostFetch): {
47
+ capabilities: HostCapability[];
48
+ transport: HostTransport;
49
+ } | undefined;
50
+ export declare function getHostCapabilities(): HostCapabilities;
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var a=(o,t)=>y(o,"name",{value:t,configurable:!0});class l extends Error{static{a(this,"HostCallError")}code;constructor(t,e){super(e),this.name="HostCallError",this.code=t}}const b="DAL_HOST_CAPABILITIES",m="DAL_HOST_URL",w="DAL_HOST_TOKEN",E="x-dal-host-token",g=3e4,T=/^[a-z][a-z0-9._-]{0,63}$/;function _(o){if(!Array.isArray(o))throw new Error("host capabilities must be an array");const t=new Map;for(const e of o){const n=typeof e=="string"?S(e):e;if(typeof n!="object"||n===null)throw new Error("host capability must be an object");const{name:r,version:s}=n;if(typeof r!="string"||!T.test(r))throw new Error(`invalid host capability name: ${JSON.stringify(r)}`);const i=s===void 0?1:s;if(typeof i!="number"||!Number.isInteger(i)||i<1)throw new Error(`invalid version for host capability ${r}: ${JSON.stringify(s)}`);t.set(r,{name:r,version:i})}return[...t.values()]}a(_,"parseHostCapabilities");function S(o){const[t,e]=o.trim().split("@");return e===void 0?{name:t,version:1}:{name:t,version:Number(e)}}a(S,"parseShortCapability");class v{static{a(this,"HostCapabilities")}entries=new Map;listeners=new Set;list(){return[...this.entries.values()].map(t=>({...t.capability}))}get(t){const e=this.entries.get(t);return e?{...e.capability}:void 0}has(t,e=1){const n=this.entries.get(t);return n!==void 0&&n.capability.version>=e}set(t,e,n){for(const[r,s]of this.entries)s.source===t&&this.entries.delete(r);for(const r of e)this.entries.set(r.name,{capability:{...r},source:t,transport:n});this.notify()}clear(t){let e=!1;for(const[n,r]of this.entries)r.source===t&&(this.entries.delete(n),e=!0);e&&this.notify()}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}async call(t,e,n={},r={}){const s=this.entries.get(t);if(!s)throw new l("unavailable",`host does not offer the "${t}" capability`);if(r.signal?.aborted)throw new l("aborted","host call aborted");return await s.transport({capability:t,method:e,params:n},r)}notify(){const t=this.list();for(const e of[...this.listeners])try{e(t)}catch{}}}function O(o){const t=o.baseUrl.replace(/\/+$/,""),e=o.fetch??((n,r)=>fetch(n,r));return async(n,r)=>{const s=new AbortController;let i=!1;const h=setTimeout(()=>{i=!0,s.abort()},r.timeoutMs??g),d=a(()=>s.abort(),"onAbort");r.signal?.addEventListener("abort",d,{once:!0});let p;try{p=await e(`${t}/${encodeURIComponent(n.capability)}/${encodeURIComponent(n.method)}`,{method:"POST",headers:{"content-type":"application/json",[E]:o.token},body:JSON.stringify(n.params),signal:s.signal})}catch(f){throw i?new l("timeout","host did not answer in time"):r.signal?.aborted?new l("aborted","host call aborted"):new l("unavailable",`host unreachable: ${f instanceof Error?f.message:String(f)}`)}finally{clearTimeout(h),r.signal?.removeEventListener("abort",d)}let c;try{c=await p.json()}catch{c=void 0}if(!p.ok){const f=typeof c=="object"&&c!==null&&typeof c.error=="string"?c.error:`HTTP ${p.status}`;throw new l("host_error",f)}if(c===void 0)throw new l("bad_response","host answered without a JSON body");return c}}a(O,"createHttpHostTransport");function H(o=process.env,t=()=>{},e){const n=o[b]?.trim(),r=o[m]?.trim(),s=o[w];if(!n||!r||!s)return;let i;try{i=_(n.startsWith("[")?JSON.parse(n):n.split(","))}catch(h){t(`${b}: ${h instanceof Error?h.message:String(h)}`);return}return{capabilities:i,transport:O({baseUrl:r,token:s,fetch:e})}}a(H,"readHostCapabilitiesFromEnv");const u=Symbol.for("dal.host-capabilities");function C(){const o=globalThis;let t=o[u];if(!t){t=new v,o[u]=t;const e=H(process.env,n=>{process.stderr.write(`dal: ignoring host capabilities \u2014 ${n}
2
+ `)});e&&t.set("env",e.capabilities,e.transport)}return t}a(C,"getHostCapabilities");export{g as DEFAULT_HOST_CALL_TIMEOUT_MS,b as HOST_CAPABILITIES_ENV,w as HOST_TOKEN_ENV,E as HOST_TOKEN_HEADER,m as HOST_URL_ENV,l as HostCallError,v as HostCapabilities,O as createHttpHostTransport,C as getHostCapabilities,_ as parseHostCapabilities,H as readHostCapabilitiesFromEnv};
@@ -0,0 +1,45 @@
1
+ export type PermissionBehavior = "allow" | "deny" | "ask";
2
+ export type PermissionRuleSource = "user" | "project";
3
+ export interface PermissionRule {
4
+ readonly text: string;
5
+ readonly toolName: string;
6
+ readonly content?: string;
7
+ readonly source: PermissionRuleSource;
8
+ }
9
+ export interface PermissionRuleSet {
10
+ readonly allow: readonly PermissionRule[];
11
+ readonly deny: readonly PermissionRule[];
12
+ readonly ask: readonly PermissionRule[];
13
+ }
14
+ export interface RuleCall {
15
+ readonly toolName: string;
16
+ readonly input: Record<string, unknown>;
17
+ readonly cwd: string;
18
+ }
19
+ export interface RuleVerdict {
20
+ readonly behavior: PermissionBehavior;
21
+ readonly rule: string;
22
+ readonly source: PermissionRuleSource;
23
+ }
24
+ export type ReadOnlySegment = (segment: string) => boolean;
25
+ export declare const EMPTY_RULE_SET: PermissionRuleSet;
26
+ export declare function parsePermissionRule(text: string, source: PermissionRuleSource): PermissionRule | undefined;
27
+ export declare function buildRuleSet(sources: {
28
+ user?: {
29
+ allow?: unknown;
30
+ deny?: unknown;
31
+ ask?: unknown;
32
+ };
33
+ project?: {
34
+ allow?: unknown;
35
+ deny?: unknown;
36
+ ask?: unknown;
37
+ };
38
+ }): PermissionRuleSet;
39
+ export declare function targetPathOf(call: RuleCall): string | undefined;
40
+ export declare function pathPatternMatches(pattern: string, absolutePath: string, cwd: string): boolean;
41
+ export declare function matchPermissionRules(rules: PermissionRuleSet, call: RuleCall, readOnly: ReadOnlySegment): RuleVerdict | undefined;
42
+ export declare function readDenyPatterns(rules: PermissionRuleSet): Array<{
43
+ pattern: string;
44
+ rule: string;
45
+ }>;
@@ -0,0 +1 @@
1
+ var _=Object.defineProperty;var o=(n,e)=>_(n,"name",{value:e,configurable:!0});import{homedir as b}from"node:os";import{resolve as p,sep as h}from"node:path";import{resolveToCwd as R}from"../tools/path-utils.js";import{simpleCommands as N,unwrapCommand as W}from"./shell-words.js";const Z={allow:[],deny:[],ask:[]};function P(n,e){const t=n.trim();if(t.length===0||t.length>2e3)return;const r=t.indexOf("("),i=(r===-1?t:t.slice(0,r)).trim();if(!/^(?:\*|[A-Za-z_][A-Za-z0-9_.*-]*)$/.test(i))return;if(r===-1)return{text:t,toolName:i,source:e};if(!t.endsWith(")"))return;const s=t.slice(r+1,-1);if(s.trim().length!==0)return{text:t,toolName:i,content:s,source:e}}o(P,"parsePermissionRule");function Y(n){const e=o(t=>{const r=[];for(const i of["user","project"]){const s=n[i]?.[t];if(Array.isArray(s))for(const f of s){if(typeof f!="string")continue;const u=P(f,i);u&&r.push(u)}}return r},"collect");return{allow:e("allow"),deny:e("deny"),ask:e("ask")}}o(Y,"buildRuleSet");const E=new Set(["read","grep","find","ls","lsp"]);function a(n){switch(n.toolName){case"bash":case"powershell":return"bash";case"process":return n.input.action==="start"?"bash":"other";case"edit":return"edit";case"write":return"write";default:return E.has(n.toolName)?"read":"other"}}o(a,"familyOf");const O={Grep:"grep",Glob:"find",LS:"ls"};function m(n,e){const t=e.toolName;if(n==="*"||n===t)return!0;const r=a(e);switch(n){case"Bash":return r==="bash";case"Edit":case"MultiEdit":return r==="edit"||r==="write";case"Write":return r==="write";case"Read":return r==="read"}if(n.startsWith("mcp__")&&t.startsWith("mcp__")){const i=n.split("__"),s=t.split("__");return s.length>=3&&i[1]===s[1]?i.length===2||i.length===3&&i[2]==="*":!1}return O[n]===t}o(m,"ruleToolMatches");function S(n){for(let e=0;e<n.length;e++){if(n[e]!=="*")continue;let t=0;for(let r=e-1;r>=0&&n[r]==="\\";r--)t++;if(t%2===0)return!0}return!1}o(S,"hasUnescapedStar");function w(n){const e=/^(.+):\*$/.exec(n)?.[1];return e!==void 0?{type:"prefix",prefix:e}:S(n)?{type:"wildcard",pattern:n}:{type:"exact",command:n}}o(w,"parseShellPattern");function k(n,e){const t=n.trim();let r="",i=0;for(let s=0;s<t.length;s++){const f=t[s];f==="\\"&&(t[s+1]==="*"||t[s+1]==="\\")?(r+=`\\${t[s+1]}`,s++):f==="*"?(r+=".*",i++):r+=f.replace(/[.+?^${}()|[\]\\'"]/g,"\\$&")}return i===1&&r.endsWith(" .*")&&(r=`${r.slice(0,-3)}( .*)?`),new RegExp(`^${r}$`,"s").test(e)}o(k,"wildcardMatches");function c(n,e){const t=w(n);switch(t.type){case"exact":return t.command===e;case"prefix":return e===t.prefix||e.startsWith(`${t.prefix} `);case"wildcard":return k(t.pattern,e)}}o(c,"shellPatternMatches");const g=/\$\(|`|<\(|>\(/;function M(n){const e=n.words.map(f=>f.value),t=W(e);let r=t.words;if(t.opaque)for(r=r.slice(1);r[0]?.startsWith("-");)r=r.slice(1);const i=r.join(" "),s=e.join(" ");return{text:s,...i!==s&&i.length>0?{unwrapped:i}:{},redirects:n.redirects,dynamic:n.words.some(f=>f.dynamic)}}o(M,"segmentOf");function x(n){return n.split(g).flatMap(e=>N(e)).map(M).filter(e=>e.text.length>0)}o(x,"segmentsOf");function y(n){return typeof n.input.command=="string"?n.input.command.trim():""}o(y,"commandOf");function v(n,e){return e.length===0?!1:c(n,e)?!0:x(e).some(t=>c(n,t.text)||t.unwrapped!==void 0&&c(n,t.unwrapped))}o(v,"shellRuleHits");function A(n,e,t){if(e.length===0)return;const r=n.find(f=>{const u=w(f.content);return u.type==="exact"&&u.command===e});if(r)return r;if(g.test(e))return;const i=x(e);if(i.length===0)return;let s;for(const f of i){if(f.redirects||f.dynamic)return;const u=n.find($=>c($.content,f.text));if(u){s??=u;continue}if(!t(f.text))return}return s}o(A,"shellAllowRule");function d(n){return h==="/"?n:n.split(h).join("/")}o(d,"toSlashes");function j(n){let e="";for(let t=0;t<n.length;t++){const r=n[t];r==="*"?n[t+1]==="*"?n[t+2]==="/"?(e+="(?:.*/)?",t+=2):(e+=".*",t+=1):e+="[^/]*":r==="?"?e+="[^/]":e+=r.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${e}$`,process.platform==="win32"||process.platform==="darwin"?"i":"")}o(j,"globToRegExp");function U(n,e){let t=n.trim();if(t.endsWith("/")&&(t+="**"),t.startsWith("//"))return t.slice(1);if(t==="~"||t.startsWith("~/"))return d(b())+t.slice(1);const r=d(p(e)).replace(/\/$/,"");if(t.startsWith("/"))return r+t;const i=t.startsWith("./")?t.slice(2):t;return i.includes("/")?`${r}/${i}`:`${r}/**/${i}`}o(U,"absoluteGlob");function C(n){for(const e of["file_path","path","filePath"]){const t=n.input[e];if(typeof t=="string"&&t.length>0)return t}if(n.toolName==="grep"||n.toolName==="find"||n.toolName==="ls")return"."}o(C,"targetPathOf");function L(n,e,t){const r=j(U(n,t));let i=d(p(e));for(;;){if(r.test(i)||r.test(`${i}/`))return!0;const s=i.slice(0,i.lastIndexOf("/"));if(s.length===0||s===i)return!1;i=s}}o(L,"pathPatternMatches");function T(n,e){const t=C(e);return t===void 0?!1:L(n,R(t,e.cwd),e.cwd)}o(T,"pathRuleMatches");function D(n){for(const e of["command","file_path","path","filePath","url","query"]){const t=n.input[e];if(typeof t=="string"&&t.length>0)return t}}o(D,"contentOf");function l(n,e){if(!m(n.toolName,e))return!1;if(n.content===void 0)return!0;switch(a(e)){case"bash":return v(n.content,y(e));case"edit":case"write":case"read":return T(n.content,e);default:{const t=D(e);return t!==void 0&&c(n.content,t)}}}o(l,"ruleHits");function G(n,e,t){const r=n.filter(s=>m(s.toolName,e)),i=r.find(s=>s.content===void 0);return i||(a(e)==="bash"?A(r,y(e),t):r.find(s=>l(s,e)))}o(G,"allowingRule");function F(n,e,t){const r=n.deny.find(f=>l(f,e));if(r)return{behavior:"deny",rule:r.text,source:r.source};const i=n.ask.find(f=>l(f,e));if(i)return{behavior:"ask",rule:i.text,source:i.source};const s=G(n.allow,e,t);return s?{behavior:"allow",rule:s.text,source:s.source}:void 0}o(F,"matchPermissionRules");function J(n){return n.deny.filter(e=>e.toolName==="Read"&&e.content!==void 0).map(e=>({pattern:e.content,rule:e.text}))}o(J,"readDenyPatterns");export{Z as EMPTY_RULE_SET,Y as buildRuleSet,F as matchPermissionRules,P as parsePermissionRule,L as pathPatternMatches,J as readDenyPatterns,C as targetPathOf};
@@ -0,0 +1,2 @@
1
+ var a=Object.defineProperty;var f=(e,t)=>a(e,"name",{value:t,configurable:!0});function h(e){const t=[];let n="",i=!1,r=!1;const u=f(()=>{r&&t.push({kind:"word",word:{value:n,dynamic:i}}),n="",i=!1,r=!1},"flush");for(let s=0;s<e.length;s++){const l=e[s];if(l==="\\"&&s+1<e.length){n+=e[++s],r=!0;continue}if(l==="'"){const o=e.indexOf("'",s+1);n+=e.slice(s+1,o===-1?void 0:o),s=o===-1?e.length:o,r=!0;continue}if(l==='"'){for(s++;s<e.length&&e[s]!=='"';)e[s]==="\\"&&s+1<e.length&&'"\\$`'.includes(e[s+1])?s++:(e[s]==="$"||e[s]==="`")&&(i=!0),n+=e[s],s++;r=!0;continue}if(l==="$"||l==="`"){i=!0,n+=l,r=!0;continue}if(/\s/.test(l)){if(l===`
2
+ `){u(),t.push({kind:"separator"});continue}u();continue}if(l===";"||l==="|"||l==="("||l===")"){u(),t.push({kind:"separator"});continue}if(l==="&"){if(e[s+1]===">"){u(),s+=e[s+2]===">"?2:1,t.push({kind:"redirectOut"});continue}u(),t.push({kind:"separator"});continue}if(l===">"||l==="<"){if(r&&/^\d+$/.test(n)&&!i&&(n="",r=!1),u(),l==="<"){t.push({kind:"redirectOther"});continue}if((e[s+1]===">"||e[s+1]==="|")&&s++,e[s+1]==="&"){s++,t.push({kind:"redirectOther"});continue}t.push({kind:"redirectOut"});continue}n+=l,r=!0}return u(),t}f(h,"tokenize");function x(e){const t=[];let n=[],i=!1;const r=f(()=>{(n.length>0||i)&&t.push({words:n,redirects:i}),n=[],i=!1},"end");for(const u of h(e))u.kind==="separator"?r():u.kind==="word"?n.push(u.word):i=!0;return r(),t}f(x,"simpleCommands");const d=/^[A-Za-z_][A-Za-z0-9_]*=/,p=new Set(["sudo","doas","su","pkexec","runas"]);function k(e,t,n){let i=0;for(;i<e.length;){const r=e[i];if(r==="--")return i+1;if(!r.startsWith("-")||r==="-")return i;if(t.has(r)){i++;continue}if(n.has(r)){i+=2;continue}const u=r.indexOf("=");if(r.startsWith("--")&&u>0&&n.has(r.slice(0,u))){i++;continue}if(!r.startsWith("--")&&r.length>2&&n.has(r.slice(0,2))){i++;continue}return}return i}f(k,"skipOptions");function c(e,t,n){const i=new Set(e),r=new Set(t);return u=>{const s=k(u,i,r);if(s===void 0)return;const l=u.slice(s),o=n?n(l):l;return o===void 0?void 0:{rest:o}}}f(c,"readWith");const w=new Map([["env",e=>{let t=0,n=!1;for(;t<e.length;){const i=e[t];if(i==="--"){t++;break}if(d.test(i))n=!0;else if(i==="-u"||i==="--unset")t++;else if(!(i==="-i"||i==="-"||i==="--ignore-environment"||i==="-0"||i==="--null"||i==="-v"||i==="--debug"||i.startsWith("--unset=")||/^-u./.test(i))){if(i.startsWith("-"))return;break}t++}for(;t<e.length&&d.test(e[t]);)n=!0,t++;return{rest:e.slice(t),setsEnvironment:n}}],["command",e=>{let t=0,n=!1;for(;t<e.length&&/^-[pvV]+$/.test(e[t]);t++)n||=/[vV]/.test(e[t]);return{rest:n?["type",...e.slice(t)]:e.slice(t)}}],["builtin",e=>({rest:e})],["nohup",e=>({rest:e})],["time",c(["-p","-l","-h"],[])],["nice",e=>{let t=0;for(;t<e.length;){const n=e[t];if(n==="-n"||n==="--adjustment")t+=2;else if(/^-n?-?\d+$/.test(n)||n.startsWith("--adjustment="))t++;else if(n==="--"){t++;break}else{if(n.startsWith("-"))return;break}}return{rest:e.slice(t)}}],["timeout",c(["--preserve-status","--foreground","-v","--verbose"],["-s","--signal","-k","--kill-after"],e=>e.length>0?e.slice(1):void 0)],["xargs",c(["-0","--null","-r","--no-run-if-empty","-t","--verbose","-x","--exit","-p","--interactive","-o","--open-tty","-i","-e","-l"],["-I","-L","-n","-P","-s","-d","-E","-a","--arg-file","--delimiter","--max-args","--max-lines","--max-procs","--max-chars","--replace","--eof"],e=>e.length>0?e:["echo"])],["caffeinate",c(["-d","-i","-m","-s","-u"],["-t","-w"])],["stdbuf",c([],["-i","-o","-e","--input","--output","--error"])],["exec",c(["-c","-l","-cl","-lc"],["-a"])]]);function g(e){let t=e,n=!1;for(;;){const i=t[0];if(i===void 0)return{words:t,setsEnvironment:n,opaque:!1};if(d.test(i)){n=!0,t=t.slice(1);continue}const r=i.slice(i.lastIndexOf("/")+1);if(p.has(r))return{words:t,setsEnvironment:n,opaque:!0};const u=w.get(r);if(!u)return{words:t,setsEnvironment:n,opaque:!1};const s=u(t.slice(1));if(!s)return{words:t,setsEnvironment:n,opaque:!0};n||=s.setsEnvironment===!0,t=s.rest}}f(g,"unwrapCommand");export{x as simpleCommands,h as tokenize,g as unwrapCommand};
@@ -0,0 +1,46 @@
1
+ import type { ExtensionContext } from "../extensions/types.ts";
2
+ import { type PermissionRuleSet, type RuleCall, type RuleVerdict } from "./rules.ts";
3
+ export interface PermissionAskRequest {
4
+ toolCallId: string;
5
+ toolName: string;
6
+ input: Record<string, unknown>;
7
+ cwd: string;
8
+ rule: string;
9
+ source: RuleVerdict["source"];
10
+ }
11
+ export type PermissionAskHandler = (request: PermissionAskRequest, ctx: ExtensionContext) => Promise<{
12
+ approved: boolean;
13
+ message?: string;
14
+ } | undefined> | {
15
+ approved: boolean;
16
+ message?: string;
17
+ } | undefined;
18
+ export declare function registerPermissionAskHandler(handler: PermissionAskHandler): () => void;
19
+ export declare function permissionAskHandlers(): readonly PermissionAskHandler[];
20
+ export interface ReadGuard {
21
+ readonly deniedPaths: readonly string[];
22
+ readonly deniedPatterns: ReadonlyArray<{
23
+ pattern: string;
24
+ rule: string;
25
+ }>;
26
+ readonly cwd: string;
27
+ }
28
+ export declare function setProcessReadGuard(guard: ReadGuard | undefined): void;
29
+ export declare function readAccessDenial(absolutePath: string, guard?: ReadGuard | undefined): string | undefined;
30
+ export type ToolPolicyDecision = {
31
+ behavior: "deny";
32
+ reason: string;
33
+ } | {
34
+ behavior: "ask";
35
+ rule: string;
36
+ source: RuleVerdict["source"];
37
+ } | undefined;
38
+ export declare function evaluateToolPolicy(call: RuleCall, options: {
39
+ rules: PermissionRuleSet;
40
+ readGuard?: ReadGuard;
41
+ }): ToolPolicyDecision;
42
+ export declare function buildReadGuard(options: {
43
+ cwd: string;
44
+ rules: PermissionRuleSet;
45
+ protectedReads?: readonly string[];
46
+ }): ReadGuard | undefined;
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var t=(e,n)=>m(e,"name",{value:n,configurable:!0});import{existsSync as h,realpathSync as p}from"node:fs";import{isAbsolute as y,relative as b,resolve as v}from"node:path";import{isReadOnlyBashCommand as R}from"../tools/bash-read-only.js";import{resolveToCwd as k}from"../tools/path-utils.js";import{matchPermissionRules as S,pathPatternMatches as g,readDenyPatterns as w,targetPathOf as x}from"./rules.js";const d=Symbol.for("dal.permissions.askHandlers"),a=globalThis;a[d]instanceof Set||(a[d]=new Set);const c=a[d];function O(e){return c.add(e),()=>{c.delete(e)}}t(O,"registerPermissionAskHandler");function j(){return[...c]}t(j,"permissionAskHandlers");let u;function B(e){u=e}t(B,"setProcessReadGuard");function l(e,n){const r=b(n,e);return r===""||!r.startsWith("..")&&!y(r)}t(l,"isWithin");function f(e){try{return h(e)?p(e):e}catch{return e}}t(f,"realpathOrSelf");function P(e,n=u){if(!n)return;const r=[...new Set([v(e),f(e)])];for(const s of n.deniedPaths){const o=f(s);if(r.some(i=>l(i,s)||l(i,o)))return`Reading ${e} is blocked: it is a protected credential location (${s}). The sandbox keeps it unreadable for every tool.`}for(const{pattern:s,rule:o}of n.deniedPatterns)if(r.some(i=>g(s,i,n.cwd)))return`Reading ${e} is blocked by the permission rule ${o}.`}t(P,"readAccessDenial");const A=new Set(["read","grep","find","ls","lsp"]);function C(e,n){if(A.has(e.toolName)&&n.readGuard){const s=x(e);if(s!==void 0){const o=P(k(s,e.cwd),n.readGuard);if(o)return{behavior:"deny",reason:o}}}const r=S(n.rules,e,R);if(r?.behavior==="deny")return{behavior:"deny",reason:`Blocked by the permission rule ${r.rule} (${r.source==="user"?"~/.dal/agent/settings.json":".dal/settings.json"}).`};if(r?.behavior==="ask")return{behavior:"ask",rule:r.rule,source:r.source}}t(C,"evaluateToolPolicy");function L(e){const n=w(e.rules),r=e.protectedReads??[];if(!(r.length===0&&n.length===0))return{cwd:e.cwd,deniedPaths:r,deniedPatterns:n}}t(L,"buildReadGuard");export{L as buildReadGuard,C as evaluateToolPolicy,j as permissionAskHandlers,P as readAccessDenial,O as registerPermissionAskHandler,B as setProcessReadGuard};
@@ -0,0 +1,14 @@
1
+ import { type MxcRuntime } from "./windows.ts";
2
+ export interface SandboxAvailability {
3
+ available: boolean;
4
+ platform: NodeJS.Platform;
5
+ mechanism?: "seatbelt" | "bubblewrap" | "mxc";
6
+ reason?: string;
7
+ ripgrep?: string;
8
+ mxc?: MxcRuntime;
9
+ isolationTier?: string;
10
+ isolationWarnings?: string[];
11
+ limitations?: readonly string[];
12
+ }
13
+ export declare function detectSandboxAvailability(): SandboxAvailability;
14
+ export declare function setSandboxAvailabilityForTesting(value: SandboxAvailability | undefined): void;
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var a=(e,r)=>c(e,"name",{value:r,configurable:!0});import{spawnSync as t}from"node:child_process";import{existsSync as m}from"node:fs";import{getToolPath as l}from"../../utils/tools-manager.js";import{loadMxcRuntime as b,probeWindowsSandbox as f,WINDOWS_SANDBOX_LIMITATIONS as d}from"./windows.js";let n,i;function p(e){const r=t("which",[e],{encoding:"utf8",timeout:2e3});return r.status===0&&r.stdout.trim()||void 0}a(p,"which");function u(e){return`${e.stderr??""}${e.stdout??""}`.trim()||(e.error?e.error.message:`exit code ${e.status}`)}a(u,"probeOutput");function h(){const e="/usr/bin/sandbox-exec";if(!m(e))return{available:!1,platform:"darwin",reason:`${e} is missing.`};const r=t(e,["-p","(version 1)(allow default)","/usr/bin/true"],{encoding:"utf8",timeout:5e3});return r.status!==0?{available:!1,platform:"darwin",mechanism:"seatbelt",reason:`sandbox-exec cannot apply a profile here (${u(r)}). This happens when dal itself runs inside another sandbox.`}:{available:!0,platform:"darwin",mechanism:"seatbelt",ripgrep:l("rg")??"rg"}}a(h,"detectDarwin");function w(){const e=[],r=p("bwrap");r||e.push("bubblewrap (bwrap)");const o=l("rg")??p("rg");if(o||e.push("ripgrep (rg)"),e.length>0)return{available:!1,platform:"linux",mechanism:"bubblewrap",reason:`missing ${e.join(", ")}. Install them (e.g. \`apt install bubblewrap socat ripgrep\`).`};const s=t(r,["--new-session","--die-with-parent","--ro-bind","/","/","--dev","/dev","--unshare-net","--unshare-pid","--proc","/proc","--","true"],{encoding:"utf8",timeout:5e3});return s.status!==0?{available:!1,platform:"linux",mechanism:"bubblewrap",reason:`bubblewrap cannot create its namespaces here (${u(s)}). Containers often forbid unprivileged user namespaces.`}:{available:!0,platform:"linux",mechanism:"bubblewrap",ripgrep:o}}a(w,"detectLinux");function x(){const e=b();if("error"in e)return{available:!1,platform:"win32",mechanism:"mxc",reason:e.error};const r=f(e);return r.ok?{available:!0,platform:"win32",mechanism:"mxc",mxc:e,...r.support.isolationTier?{isolationTier:r.support.isolationTier}:{},...r.support.isolationWarnings?.length?{isolationWarnings:r.support.isolationWarnings}:{},limitations:d}:{available:!1,platform:"win32",mechanism:"mxc",reason:r.reason}}a(x,"detectWindows");function W(){if(i)return i;if(n)return n;switch(process.platform){case"darwin":n=h();break;case"linux":n=w();break;case"win32":n=x();break;default:n={available:!1,platform:process.platform,reason:`the OS sandbox does not support ${process.platform}.`}}return n}a(W,"detectSandboxAvailability");function y(e){i=e}a(y,"setSandboxAvailabilityForTesting");export{W as detectSandboxAvailability,y as setSandboxAvailabilityForTesting};
@@ -0,0 +1,25 @@
1
+ import type { SandboxViolationEvent } from "@anthropic-ai/sandbox-runtime";
2
+ import type { SandboxLevel } from "./policy.ts";
3
+ import type { NetworkRefusal } from "./runtime.ts";
4
+ export interface SandboxBlockedAccess {
5
+ kind: "file-read" | "file-write" | "network";
6
+ target: string;
7
+ source: "proxy" | "kernel" | "output";
8
+ detail?: string;
9
+ }
10
+ export interface SandboxDenial {
11
+ level: SandboxLevel;
12
+ platform: NodeJS.Platform;
13
+ command: string;
14
+ cwd: string;
15
+ blocked: SandboxBlockedAccess[];
16
+ networkProxyError?: string;
17
+ }
18
+ export declare function parseViolationLine(line: string): SandboxBlockedAccess | undefined;
19
+ export declare function parseOutput(output: string): SandboxBlockedAccess[];
20
+ export declare function collectBlockedAccesses(input: {
21
+ refusals: readonly NetworkRefusal[];
22
+ violations: readonly SandboxViolationEvent[];
23
+ output: string;
24
+ }): SandboxBlockedAccess[] | undefined;
25
+ export declare function describeDenialForModel(denial: SandboxDenial): string;
@@ -0,0 +1,3 @@
1
+ var u=Object.defineProperty;var s=(o,t)=>u(o,"name",{value:t,configurable:!0});const m=20;function f(o){const t=/deny(?:\(\d+\))?\s+(?<operation>[\w-]+)\s+(?<target>.+?)\s*$/.exec(o);if(!t?.groups)return;const{operation:r,target:e}=t.groups;if(r.startsWith("file-write"))return{kind:"file-write",target:e,source:"kernel",detail:r};if(r.startsWith("file-read"))return{kind:"file-read",target:e,source:"kernel",detail:r};if(r.startsWith("network"))return{kind:"network",target:e,source:"kernel",detail:r}}s(f,"parseViolationLine");const g=[{regex:/(?<target>\/[^\s:'"`]+)['"`]?:\s*Read-only file system/,kind:"file-write"},{regex:/Read-only file system[^/\n]*(?<target>\/[^\s'"`]+)/,kind:"file-write"},{regex:/['"`]?(?<target>\/[^\s:'"`]+)['"`]?:\s*Operation not permitted/,kind:"file-write"},{regex:/EPERM: operation not permitted, \w+ ['"](?<target>(?:\/|[A-Za-z]:\\)[^'"]+)['"]/,kind:"file-write"},{regex:/EROFS: read-only file system, \w+ ['"](?<target>\/[^'"]+)['"]/,kind:"file-write"},{regex:/EACCES: permission denied, \w+ ['"](?<target>[A-Za-z]:\\[^'"]+)['"]/,kind:"file-write"},{regex:/Access to the path ['"](?<target>[A-Za-z]:\\[^'"]+)['"] is denied/,kind:"file-write"},{regex:/['"`](?<target>\/[A-Za-z]\/[^'"`]+)['"`]:\s*Permission denied/,kind:"file-write"},{regex:/Could not resolve host:\s*(?<target>[\w.-]+)/,kind:"network"},{regex:/getaddrinfo (?:ENOTFOUND|EAI_AGAIN) (?<target>[\w.-]+)/,kind:"network"},{regex:/Failed to connect to (?<target>[\w.-]+) port (?<port>\d+)/,kind:"network"},{regex:/Temporary failure in name resolution.*?(?<target>[\w-]+(?:\.[\w-]+)+)?/,kind:"network"}],p=/^(?:\S*\/)?(?:cat|head|tail|less|more|grep|rg|ls|find|wc|stat|file|diff|cmp|od|xxd|strings|base64|sha\d*sum|md5|openssl)\b[^:]*:/;function k(o){const t=[];for(const r of o.split(`
2
+ `)){const e=r.trim();for(const{regex:i,kind:n}of g){const a=i.exec(e);if(!a)continue;const d=a.groups?.target;if(!d){n==="network"&&t.push({kind:n,target:"(unknown host)",source:"output",detail:e});break}const l=a.groups?.port,c=n==="file-write"&&/Operation not permitted|Permission denied/.test(e)&&p.test(e)?"file-read":n;t.push({kind:c,target:l?`${d}:${l}`:d,source:"output",detail:e.slice(0,200)});break}}return t}s(k,"parseOutput");function w(o){const t=new Set,r=[];for(const e of o){const i=`${e.kind}\0${e.target}`;if(!t.has(i)&&(t.add(i),r.push(e),r.length>=20))break}return r}s(w,"dedupe");function x(o){const t=[...o.refusals.map(e=>({kind:"network",target:e.port!==void 0?`${e.host}:${e.port}`:e.host,source:"proxy"})),...o.violations.flatMap(e=>{const i=f(e.line);return i?[i]:[]})];(t.length===0||t.every(e=>e.kind==="network"&&e.target.startsWith("/")))&&t.push(...k(o.output));const r=w(t);return r.length>0?r:void 0}s(x,"collectBlockedAccesses");function b(o){const t=[`[sandbox] The OS sandbox (${o.level}, network off except allowlisted domains) blocked this command:`];for(const n of o.blocked){const a=n.source==="output"?" (inferred from the output)":"";t.push(` - ${n.kind}: ${n.target}${a}`)}o.networkProxyError&&t.push(` (allowlisted domains are unreachable too: the network proxy could not start: ${o.networkProxyError})`);const r=o.blocked.filter(n=>n.kind==="network"&&!n.target.startsWith("/")),e=o.blocked.filter(n=>n.kind==="file-write"),i={mode:"allow",justification:"<why this is needed>"};return r.length>0&&(i.allow_domains=r.map(n=>n.target.replace(/:\d+$/,""))),e.length>0&&(i.allow_write=e.map(n=>n.target)),t.push(`Do not try to work around the sandbox. If the task genuinely needs this access, call the tool again with the same command and sandbox_escalation: ${JSON.stringify(r.length>0||e.length>0?i:{mode:"unsandboxed",justification:"<why this is needed>"})} (or mode "unsandboxed" to run outside the sandbox). The user will be asked to approve.`),t.join(`
3
+ `)}s(b,"describeDenialForModel");export{x as collectBlockedAccesses,b as describeDenialForModel,k as parseOutput,f as parseViolationLine};
@@ -0,0 +1,5 @@
1
+ export { detectSandboxAvailability, type SandboxAvailability, setSandboxAvailabilityForTesting, } from "./availability.ts";
2
+ export { collectBlockedAccesses, describeDenialForModel, parseOutput, parseViolationLine, type SandboxBlockedAccess, type SandboxDenial, } from "./denial.ts";
3
+ export { domainMatches, filesystemRules, isAlwaysBlockedHost, isSandboxLevel, PROTECTED_HOME_READS, PROTECTED_HOME_WRITES, PROTECTED_WRITE_NAMES, type ResolvedSandboxPolicy, readSandboxEnvironment, resolveSandboxPolicy, SANDBOX_ENV, SANDBOX_LEVELS, type SandboxLevel, type SandboxOverride, type SandboxSettings, type SandboxSettingsSources, sandboxEnvironmentValue, stricterLevel, } from "./policy.ts";
4
+ export { decideNetworkRequest, type NetworkGrant, registerNetworkGrant, resetSandboxRuntime } from "./runtime.ts";
5
+ export { getProcessShellSandbox, type PreparedCommand, registerSandboxEscalationHandler, type SandboxEscalationDecision, type SandboxEscalationHandler, type SandboxEscalationInput, type SandboxEscalationRequest, type SandboxEvent, type SandboxOptions, type SandboxRunDetails, type SandboxStatus, ShellSandbox, type ShellSandboxOptions, setProcessShellSandbox, } from "./shell-sandbox.ts";
@@ -0,0 +1 @@
1
+ import{detectSandboxAvailability as t,setSandboxAvailabilityForTesting as r}from"./availability.js";import{collectBlockedAccesses as a,describeDenialForModel as l,parseOutput as n,parseViolationLine as i}from"./denial.js";import{domainMatches as S,filesystemRules as E,isAlwaysBlockedHost as x,isSandboxLevel as c,PROTECTED_HOME_READS as b,PROTECTED_HOME_WRITES as m,PROTECTED_WRITE_NAMES as R,readSandboxEnvironment as T,resolveSandboxPolicy as p,SANDBOX_ENV as A,SANDBOX_LEVELS as O,sandboxEnvironmentValue as _,stricterLevel as v}from"./policy.js";import{decideNetworkRequest as f,registerNetworkGrant as u,resetSandboxRuntime as N}from"./runtime.js";import{getProcessShellSandbox as y,registerSandboxEscalationHandler as L,ShellSandbox as M,setProcessShellSandbox as g}from"./shell-sandbox.js";export{b as PROTECTED_HOME_READS,m as PROTECTED_HOME_WRITES,R as PROTECTED_WRITE_NAMES,A as SANDBOX_ENV,O as SANDBOX_LEVELS,M as ShellSandbox,a as collectBlockedAccesses,f as decideNetworkRequest,l as describeDenialForModel,t as detectSandboxAvailability,S as domainMatches,E as filesystemRules,y as getProcessShellSandbox,x as isAlwaysBlockedHost,c as isSandboxLevel,n as parseOutput,i as parseViolationLine,T as readSandboxEnvironment,u as registerNetworkGrant,L as registerSandboxEscalationHandler,N as resetSandboxRuntime,p as resolveSandboxPolicy,_ as sandboxEnvironmentValue,g as setProcessShellSandbox,r as setSandboxAvailabilityForTesting,v as stricterLevel};
@@ -0,0 +1,66 @@
1
+ export type SandboxLevel = "read-only" | "workspace-write" | "off";
2
+ export declare const SANDBOX_LEVELS: readonly SandboxLevel[];
3
+ export interface SandboxSettings {
4
+ level?: SandboxLevel;
5
+ network?: {
6
+ allowedDomains?: string[];
7
+ deniedDomains?: string[];
8
+ allowLocalBinding?: boolean;
9
+ };
10
+ filesystem?: {
11
+ allowWrite?: string[];
12
+ denyRead?: string[];
13
+ denyWrite?: string[];
14
+ allowRead?: string[];
15
+ };
16
+ }
17
+ export interface SandboxOverride {
18
+ level?: SandboxLevel;
19
+ allowedDomains?: string[];
20
+ }
21
+ export interface SandboxSettingsSources {
22
+ global?: SandboxSettings;
23
+ project?: SandboxSettings;
24
+ }
25
+ export interface ResolvedSandboxPolicy {
26
+ level: SandboxLevel;
27
+ levelSource: "override" | "environment" | "settings" | "project" | "default";
28
+ network: {
29
+ allowedDomains: string[];
30
+ deniedDomains: string[];
31
+ allowLocalBinding: boolean;
32
+ };
33
+ filesystem: {
34
+ allowWrite: string[];
35
+ denyRead: string[];
36
+ denyWrite: string[];
37
+ allowRead: string[];
38
+ };
39
+ }
40
+ export declare const SANDBOX_ENV = "DAL_SANDBOX";
41
+ export declare function isSandboxLevel(value: unknown): value is SandboxLevel;
42
+ export declare function stricterLevel(a: SandboxLevel, b: SandboxLevel): SandboxLevel;
43
+ export declare function readSandboxEnvironment(env?: NodeJS.ProcessEnv): SandboxOverride | undefined;
44
+ export declare function sandboxEnvironmentValue(policy: ResolvedSandboxPolicy): string;
45
+ export declare function resolveSandboxPolicy(options: {
46
+ settings?: SandboxSettingsSources;
47
+ override?: SandboxOverride;
48
+ env?: NodeJS.ProcessEnv;
49
+ defaultLevel: SandboxLevel;
50
+ }): ResolvedSandboxPolicy;
51
+ export declare const PROTECTED_WRITE_NAMES: readonly string[];
52
+ export declare const PROTECTED_HOME_WRITES: readonly string[];
53
+ export declare const PROTECTED_HOME_READS: readonly string[];
54
+ export declare function expandPath(path: string, cwd: string): string;
55
+ export interface CommandFilesystemRules {
56
+ allowWrite: string[];
57
+ denyWrite: string[];
58
+ denyRead: string[];
59
+ }
60
+ export declare function filesystemRules(policy: ResolvedSandboxPolicy, cwd: string, options?: {
61
+ gitDirs?: string[];
62
+ extraWrite?: string[];
63
+ scratchDir?: string;
64
+ }): CommandFilesystemRules;
65
+ export declare function domainMatches(host: string, pattern: string): boolean;
66
+ export declare function isAlwaysBlockedHost(host: string): boolean;
@@ -0,0 +1 @@
1
+ var L=Object.defineProperty;var i=(e,t)=>L(e,"name",{value:t,configurable:!0});import{existsSync as A,readdirSync as O,realpathSync as N}from"node:fs";import{homedir as h}from"node:os";import{isAbsolute as W,join as u,relative as T,resolve as _}from"node:path";const C=["read-only","workspace-write","off"],g="DAL_SANDBOX",x={off:0,"workspace-write":1,"read-only":2};function y(e){return typeof e=="string"&&C.includes(e)}i(y,"isSandboxLevel");function j(e,t){return x[t]>x[e]?t:e}i(j,"stricterLevel");function a(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}i(a,"strings");function f(e){return[...new Set(e)]}i(f,"unique");const B=process.env[g];function I(e={[g]:B}){const t=e[g];if(t)try{const r=JSON.parse(t);return y(r.level)?{level:r.level,allowedDomains:a(r.allowedDomains)}:void 0}catch{return}}i(I,"readSandboxEnvironment");function q(e){return JSON.stringify({level:e.level,allowedDomains:e.network.allowedDomains})}i(q,"sandboxEnvironmentValue");function G(e){const t=e.settings?.global??{},r=e.settings?.project??{},s=I(e.env),l=e.override??{};let o,c;return l.level?(o=l.level,c="override"):s?.level?(o=s.level,c="environment"):y(t.level)?(o=t.level,c="settings"):(o=e.defaultLevel,c="default"),!l.level&&y(r.level)&&j(o,r.level)!==o&&(o=r.level,c="project"),{level:o,levelSource:c,network:{allowedDomains:f([...a(t.network?.allowedDomains),...a(s?.allowedDomains),...a(l.allowedDomains)]),deniedDomains:f([...a(t.network?.deniedDomains),...a(r.network?.deniedDomains)]),allowLocalBinding:t.network?.allowLocalBinding===!0},filesystem:{allowWrite:a(t.filesystem?.allowWrite),denyRead:f([...a(t.filesystem?.denyRead),...a(r.filesystem?.denyRead)]),denyWrite:f([...a(t.filesystem?.denyWrite),...a(r.filesystem?.denyWrite)]),allowRead:a(t.filesystem?.allowRead)}}}i(G,"resolveSandboxPolicy");const P=[".git/hooks",".git/config",".gitmodules",".dal",".claude",".agents",".mcp.json",".cursor",".vscode",".idea",".env"],z=[".gitconfig",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".config/fish",".dal"],H=[".ssh",".gnupg",".aws",".config/gcloud",".azure",".kube",".docker/config.json",".netrc",".npmrc",".pypirc",".git-credentials",".config/gh","Library/Keychains","Library/Application Support/Google/Chrome","Library/Application Support/Firefox","Library/Safari",".mozilla",".config/google-chrome",".config/chromium",".dal/agent/auth.json"];function m(e,t){return e==="~"?h():e.startsWith("~/")?u(h(),e.slice(2)):W(e)?e:_(t,e)}i(m,"expandPath");function v(e){try{return N(e)}catch{return e}}i(v,"realpathOrSelf");function D(e,t){const r=T(t,e);return r===""||!r.startsWith("..")&&!W(r)}i(D,"isWithin");function K(e,t,r={}){const s=h(),l=e.level==="workspace-write"?f([t,v(t),...e.filesystem.allowWrite.map(n=>m(n,t))]):[],o=e.level==="workspace-write"?r.gitDirs??[]:[],c=(r.extraWrite??[]).map(n=>m(n,t)),E=r.scratchDir?[r.scratchDir,v(r.scratchDir)]:[],k=f([...l,...o,...c,...E]),d=[];if(e.level==="read-only"){const n=f([t,v(t)]);c.some(w=>n.some(S=>D(w,S)||D(S,w)))||d.push(...n)}for(const n of[...l,...c]){for(const p of P)d.push(u(n,p));d.push(u(n,".env.*"));for(const p of M(n))d.push(u(n,p))}for(const n of o)d.push(u(n,"hooks"),u(n,"config"));for(const n of z)d.push(u(s,n));d.push(...e.filesystem.denyWrite.map(n=>m(n,t)));const R=new Set(e.filesystem.allowRead.map(n=>m(n,t))),b=[...H.map(n=>u(s,n)).filter(n=>!R.has(n)),...e.filesystem.denyRead.map(n=>m(n,t))];return{allowWrite:k,denyWrite:f(d),denyRead:f(b)}}i(K,"filesystemRules");function M(e){if(!A(e))return[];try{return O(e).filter(t=>t.startsWith(".env."))}catch{return[]}}i(M,"listEnvFiles");function $(e,t){const r=e.toLowerCase(),s=t.toLowerCase();return s.startsWith("*.")?r.endsWith(s.slice(1)):r===s}i($,"domainMatches");function Q(e){const t=e.toLowerCase().replace(/^\[|\]$/g,"");if(t==="localhost"||t.endsWith(".localhost")||t==="::1"||t==="0.0.0.0")return!0;if(t.startsWith("fe80:")||t.startsWith("fc")||t.startsWith("fd"))return t.includes(":");const r=t.split(".").map(o=>Number(o));if(r.length!==4||r.some(o=>!Number.isInteger(o)||o<0||o>255))return!1;const[s,l]=r;return s===127||s===10||s===172&&l>=16&&l<=31||s===192&&l===168||s===169&&l===254}i(Q,"isAlwaysBlockedHost");export{H as PROTECTED_HOME_READS,z as PROTECTED_HOME_WRITES,P as PROTECTED_WRITE_NAMES,g as SANDBOX_ENV,C as SANDBOX_LEVELS,$ as domainMatches,m as expandPath,K as filesystemRules,Q as isAlwaysBlockedHost,y as isSandboxLevel,I as readSandboxEnvironment,G as resolveSandboxPolicy,q as sandboxEnvironmentValue,j as stricterLevel};
@@ -0,0 +1,41 @@
1
+ import type { SandboxViolationEvent } from "@anthropic-ai/sandbox-runtime";
2
+ export interface NetworkRefusal {
3
+ host: string;
4
+ port?: number;
5
+ }
6
+ export interface NetworkGrant {
7
+ allowedDomains: readonly string[];
8
+ deniedDomains: readonly string[];
9
+ refusals: NetworkRefusal[];
10
+ }
11
+ export interface WrapRequest {
12
+ command: string;
13
+ shell: string;
14
+ allowWrite: string[];
15
+ denyWrite: string[];
16
+ denyRead: string[];
17
+ allowLocalBinding: boolean;
18
+ ripgrep?: string;
19
+ }
20
+ export declare function registerNetworkGrant(grant: NetworkGrant): () => void;
21
+ export declare function decideNetworkRequest(host: string, port: number | undefined): boolean;
22
+ export declare function proxyUnavailableReason(): string | undefined;
23
+ export declare function setFilteringProxyStarterForTesting(starter: (() => Promise<{
24
+ port: number;
25
+ } | {
26
+ error: string;
27
+ }>) | undefined): void;
28
+ export declare function ensureFilteringProxy(): Promise<{
29
+ port: number;
30
+ } | {
31
+ error: string;
32
+ }>;
33
+ export declare function acquireSandboxRuntime(): void;
34
+ export declare function releaseSandboxRuntime(): Promise<void>;
35
+ export declare function wrapCommand(request: WrapRequest, grant: NetworkGrant): Promise<{
36
+ command: string;
37
+ release: () => void;
38
+ proxied: boolean;
39
+ }>;
40
+ export declare function violationsForCommand(command: string, since: number, waitMs: number): Promise<SandboxViolationEvent[]>;
41
+ export declare function resetSandboxRuntime(): Promise<void>;
@@ -0,0 +1 @@
1
+ var D=Object.defineProperty;var t=(e,r)=>D(e,"name",{value:r,configurable:!0});import{domainMatches as x,isAlwaysBlockedHost as T}from"./policy.js";const S="dal-sandbox.invalid",f=new Set;let d,c,w,P=Promise.resolve(),p=0;async function I(){return d??=import("@anthropic-ai/sandbox-runtime").then(e=>e.SandboxManager),d}t(I,"loadManager");function h(e){return{network:{allowedDomains:[S],deniedDomains:[],allowLocalBinding:e.allowLocalBinding},filesystem:{denyRead:[],allowWrite:[],denyWrite:[]},...e.ripgrep?{ripgrep:{command:e.ripgrep}}:{}}}t(h,"baseConfig");function G(e){return f.add(e),()=>{f.delete(e)}}t(G,"registerNetworkGrant");function v(e,r){let i=!1;if(!T(e))for(const a of f)a.deniedDomains.some(n=>x(e,n))||a.allowedDomains.some(n=>x(e,n))&&(i=!0);if(!i)for(const a of f)a.refusals.some(n=>n.host===e&&n.port===r)||a.refusals.push({host:e,...r!==void 0?{port:r}:{}});return i}t(v,"decideNetworkRequest");function R(){const e=process._getActiveHandles;return new Set(typeof e=="function"?e.call(process):[])}t(R,"activeHandles");async function k(e,r){c||(w??=(async()=>{const i={SIGINT:new Set(process.listeners("SIGINT")),SIGTERM:new Set(process.listeners("SIGTERM"))},a=R();try{await e.initialize(h(r),async({host:n,port:s})=>v(n,s),!1),c={ready:!0}}catch(n){c={ready:!1,error:n instanceof Error?n.message:String(n)}}finally{for(const n of["SIGINT","SIGTERM"])for(const s of process.listeners(n))i[n].has(s)||process.removeListener(n,s);for(const n of R())!a.has(n)&&typeof n.unref=="function"&&n.unref()}})(),await w)}t(k,"ensureProxy");function L(){return c&&!c.ready?c.error:o&&"error"in o?o.error:void 0}t(L,"proxyUnavailableReason");let o,m,b;function N(e){b=e?async()=>{const r=await e();return"error"in r?r:{port:r.port,server:{close:t(()=>{},"close")}}}:void 0,o=void 0,m=void 0}t(N,"setFilteringProxyStarterForTesting");async function C(){try{const{createHttpProxyServer:e}=await import("@anthropic-ai/sandbox-runtime/dist/sandbox/http-proxy.js"),r=e({filter:t((a,n)=>v(n,a),"filter")}),i=await new Promise((a,n)=>{r.once("error",n),r.listen(0,"127.0.0.1",()=>{const s=r.address();a(typeof s=="object"&&s?s.port:0)})});return r.unref(),{port:i,server:r}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}t(C,"startFilteringProxy");async function H(){return o?"error"in o?o:{port:o.port}:(m??=(b??C)(),o=await m,"error"in o?o:{port:o.port})}t(H,"ensureFilteringProxy");function B(){p++}t(B,"acquireSandboxRuntime");async function A(){p=Math.max(0,p-1),p===0&&await E()}t(A,"releaseSandboxRuntime");async function O(e,r){const i=await I(),a=r.allowedDomains.length>0;a&&await k(i,e);const n=t(async()=>{const y={denyRead:e.denyRead,allowWrite:e.allowWrite,denyWrite:e.denyWrite};i.updateConfig({...h(e),filesystem:y});const g=a&&c?.ready===!0;return{wrapped:await i.wrapWithSandbox(e.command,e.shell,{network:{allowedDomains:g?[S]:[],deniedDomains:[]},filesystem:y}),proxied:g}},"run"),s=P.then(n,n);P=s.catch(()=>{});const{wrapped:u,proxied:l}=await s;return{command:u,proxied:l,release:G(r)}}t(O,"wrapCommand");async function V(e,r,i){if(!d)return[];const n=(await d).getSandboxViolationStore();if(n.getTotalCount()===0)return[];const s=Date.now()+i;for(;;){const u=n.getViolationsForCommand(e).filter(l=>l.timestamp.getTime()>=r-1e3);if(u.length>0||Date.now()>=s)return u;await new Promise(l=>setTimeout(l,50))}}t(V,"violationsForCommand");async function E(){f.clear(),o&&"server"in o&&o.server.close(),o=void 0,m=void 0;const e=c!==void 0;if(c=void 0,w=void 0,!e||!d)return;await(await d).reset()}t(E,"resetSandboxRuntime");export{B as acquireSandboxRuntime,v as decideNetworkRequest,H as ensureFilteringProxy,L as proxyUnavailableReason,G as registerNetworkGrant,A as releaseSandboxRuntime,E as resetSandboxRuntime,N as setFilteringProxyStarterForTesting,V as violationsForCommand,O as wrapCommand};