eve 0.30.2 → 0.30.4

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 (51) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -2
  3. package/dist/src/cli/dev/tui/terminal-renderer.js +1 -1
  4. package/dist/src/compiler/manifest.d.ts +3 -1
  5. package/dist/src/compiler/manifest.js +1 -1
  6. package/dist/src/compiler/normalize-manifest.js +2 -2
  7. package/dist/src/compiler/normalize-subagent.js +1 -1
  8. package/dist/src/discover/discover-agent.d.ts +24 -1
  9. package/dist/src/discover/discover-agent.js +1 -1
  10. package/dist/src/discover/discover-subagent.js +1 -1
  11. package/dist/src/discover/filesystem.d.ts +1 -1
  12. package/dist/src/discover/filesystem.js +1 -1
  13. package/dist/src/execution/sandbox/bindings/just-bash-runtime.d.ts +2 -0
  14. package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
  15. package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
  16. package/dist/src/execution/sandbox/glob-tool.js +2 -2
  17. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  18. package/dist/src/execution/sandbox/ripgrep-probe.d.ts +1 -1
  19. package/dist/src/execution/sandbox/ripgrep-probe.js +1 -1
  20. package/dist/src/internal/application/package.js +1 -1
  21. package/dist/src/internal/authored-module-loader.js +1 -1
  22. package/dist/src/internal/authored-module-map-loader.js +1 -1
  23. package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
  24. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  25. package/dist/src/internal/nitro/host/dev-host-fingerprint.js +1 -1
  26. package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -1
  27. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  28. package/dist/src/public/definitions/agent.d.ts +10 -7
  29. package/dist/src/public/definitions/agent.js +1 -1
  30. package/dist/src/public/sandbox/just-bash-sandbox.d.ts +21 -0
  31. package/dist/src/public/sandbox/just-bash.d.ts +1 -1
  32. package/dist/src/runtime/resolve-dynamic-subagent.js +1 -1
  33. package/dist/src/setup/integrations/linear/connect.d.ts +42 -0
  34. package/dist/src/setup/integrations/linear/connect.js +1 -0
  35. package/dist/src/setup/integrations/linear/setup.d.ts +19 -0
  36. package/dist/src/setup/integrations/linear/setup.js +7 -0
  37. package/dist/src/setup/integrations/registry.js +1 -1
  38. package/dist/src/setup/scaffold/create/project.js +1 -1
  39. package/docs/README.md +5 -5
  40. package/docs/channels/linear.mdx +6 -11
  41. package/docs/channels/overview.mdx +6 -4
  42. package/docs/connections/overview.mdx +1 -1
  43. package/docs/extensions.md +2 -2
  44. package/docs/guides/hooks.md +1 -1
  45. package/docs/guides/instrumentation.md +2 -2
  46. package/docs/guides/state.md +1 -1
  47. package/docs/patterns/multi-tenant-memory.md +1 -1
  48. package/docs/reference/meta.json +1 -1
  49. package/docs/subagents.mdx +29 -0
  50. package/docs/tools/human-in-the-loop.md +1 -1
  51. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # eve
2
2
 
3
+ ## 0.30.4
4
+
5
+ ### Patch Changes
6
+
7
+ - fc87d23: Dev runtime snapshots no longer copy the `.workflow-vitest` test cache. In
8
+ workspaces that had run integration tests, this directory was duplicated into
9
+ every generation under `.eve/dev-runtime/snapshots` — tens of megabytes per
10
+ rebuild that nothing at dev runtime reads.
11
+
12
+ ## 0.30.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 601fb13: Allow just-bash sandboxes to compose a custom filesystem around eve's durable, session-owned workspace.
17
+ - c8bd9c0: Allow declared local subagents to mount extensions under their own `extensions/` directory. Contributions, configuration, and overrides are scoped to that subagent and do not extend the root agent.
18
+ - 279b5e6: Use compatible POSIX search fallbacks in sandboxes whose `rg` implementation lacks the options required by eve, and surface command errors instead of reporting them as empty results.
19
+ - c10ca06: Allow dynamic subagents to declare compile-time `build.externalDependencies`, so their authored modules can safely use packages that must remain external before runtime resolution.
20
+ - 95b4183: Configure new Linear connectors to receive only Agent Session webhook events, avoiding unrelated default Linear webhook deliveries.
21
+ - 95b4183: Add guided Linear Agent channel setup through `eve add channel/linear-agent`. The flow provisions a Vercel Connect Linear app, routes verified Agent Session events, scaffolds the channel, and explains how to install and use the agent in Linear.
22
+
3
23
  ## 0.30.2
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -140,7 +140,7 @@ CLI commands:
140
140
 
141
141
  ## Deploying
142
142
 
143
- eve is built to be durable. The runtime is Nitro + Workflows. Read the [deployment guide](https://eve.dev/docs/guides/deployment) for the deployment path, environment variables, and configuration.
143
+ eve is built to be durable. The runtime is Nitro + Workflows. Read the [deployment guide](https://eve.dev/docs/guides/deployment/overview) for the deployment path, environment variables, and configuration.
144
144
 
145
145
  ## Read Next
146
146
 
@@ -151,7 +151,7 @@ These files ship inside the installed package at `node_modules/eve/docs/`:
151
151
  - [Project Layout](https://eve.dev/docs/reference/project-layout) — every authored directory in depth
152
152
  - [`agent.ts`](https://eve.dev/docs/agent-config) — agent config reference
153
153
  - [TypeScript API](https://eve.dev/docs/reference/typescript-api) — complete `define*` and runtime helper reference
154
- - [Vercel Deployment](https://eve.dev/docs/guides/deployment) — deploy to production
154
+ - [Vercel Deployment](https://eve.dev/docs/guides/deployment/overview) — deploy to production
155
155
 
156
156
  By authoring concern: [Tools](https://eve.dev/docs/tools) · [Channels](https://eve.dev/docs/channels/overview) · [Hooks](https://eve.dev/docs/guides/hooks) · [Skills](https://eve.dev/docs/skills) · [Sandbox](https://eve.dev/docs/sandbox) · [Connections](https://eve.dev/docs/connections) · [Subagents](https://eve.dev/docs/subagents) · [Schedules](https://eve.dev/docs/schedules) · [Evals](https://eve.dev/docs/evals/overview)
157
157
 
@@ -3,7 +3,7 @@ import{PROMPT_COMMANDS,isPromptControlCommand,parsePromptCommand}from"./prompt-c
3
3
  `).map(stripPromptControlCharacters).join(`
4
4
  `),i=stripPromptControlCharacters(e?.initialDraft??this.#V.text),a=lineOf(r===void 0?i:i.length===0?r:`${r}\n\n${i}`);return this.#V=EMPTY_LINE,this.#P.begin(a.text),this.#Ge(a),this.#I=typeaheadFor(this.#f,a.text),this.#jt(),this.#in(),await new Promise((e,r)=>{this.#W=r;let apply=e=>{a=e,this.#Nt(),this.#Ge(a),this.#I=typeaheadFor(this.#f,e.text,this.#I),this.#in()},recall=e=>{e!==void 0&&apply(lineOf(e))},interrupt=()=>{this.#I=void 0,this.#Mt(),this.#St(),r(interruptedError())},suggestions=()=>this.#I!==void 0&&isTypeaheadOpen(this.#I)?this.#I:void 0,highlighted=()=>{let e=suggestions();return e===void 0?void 0:selectedTypeaheadCommand(e)};this.#ce=r=>{r.type!==`ctrl-c`&&this.#$&&(this.#$=!1,this.#in());let i=applyLineEditorKey(a,r,{multiline:!0});if(i!==void 0){apply(i);return}switch(r.type){case`up`:case`ctrl-p`:{let e=suggestions();if(e!==void 0){this.#I=moveTypeaheadSelection(e,-1),this.#in();break}let t=movePromptLine(a,`up`);t===void 0?recall(this.#P.previous(a.text)):apply(t);break}case`down`:case`ctrl-n`:{let e=suggestions();if(e!==void 0){this.#I=moveTypeaheadSelection(e,1),this.#in();break}let t=movePromptLine(a,`down`);t===void 0?recall(this.#P.next()):apply(t);break}case`tab`:{let e=highlighted();e!==void 0&&apply(lineOf(typeaheadCompletion(e)));break}case`escape`:{let e=suggestions();e!==void 0&&(this.#I=dismissTypeahead(e),this.#in());break}case`enter`:{let r=highlighted(),i=r!==void 0&&parsePromptCommand(a.text)===null?typeaheadCompletion(r).trimEnd():a.text;if(i.trim().length===0)break;this.#I=void 0,this.#P.add(i),this.#F=!1,this.#Mt(),this.#G=STATUS.processing,isPromptControlCommand(i)?this.#Lt({kind:`command`,body:stripTerminalControls(i.trim()),live:!1}):(this.#Ft(),this.#Rt(i),this.#Oe=i,this.#B.arm()),this.#Ge(EMPTY_LINE),this.#in(),this.#wt(),e(i);break}case`ctrl-d`:a.text.length===0?(this.#gt(),interrupt()):apply(deleteForward(a));break;case`ctrl-l`:this.#sn();break;case`ctrl-r`:this.#in();break;case`ctrl-c`:if(this.#$){this.#gt(),interrupt();break}this.#$=!0,apply(EMPTY_LINE);break;default:break}},this.#Ct()})}#Ge(e){this.#M=e.text,this.#N=e.cursor}takeQueuedPrompt(){let e=this.#Pe.view().steering,t=this.#Pe.takePrompt();return t!==void 0&&(this.#Re=e?`steer`:`queue`),t}async renderStream(e,t){this.#bt(t),this.#g.clear(),this.#F=!1,this.#U.kind!==`waiting`&&(this.#U={kind:`waiting`,startedAtMs:Date.now()}),this.#G=this.#k>0?STATUS.connectionAuth:STATUS.processing,this.#Bt(t?.submittedPrompt),t?.submittedPrompt!==void 0&&this.#d?.recordPrompt(),t?.submittedPrompt!==void 0&&!this.#B.armed&&this.#B.arm(),this.#Z=!1,this.#Ie=!1,this.#ze=!1,this.#Be=t?.submittedPrompt,this.#Pe.beginTurn(),this.#Fe=e.cancel,this.#ge=void 0,this.#_e=void 0,this.#ye=void 0,this.#be=void 0,this.#xe=Date.now();let n={tools:t?.tools??this.#a,reasoning:t?.reasoning??this.#o,assistantResponseStats:t?.assistantResponseStats??this.#l};this.#Pt(),this.#H=!0,this.#in();let r=new Promise(e=>{this.#pe=e});this.#ce=e=>this.#At(e),this.#Ct();let i={text:new Map,reasoning:new Map,tools:new Map};try{for await(let t of takeUntil(iterateTUIStream(e.events),r)){if(this.#Z)break;this.#Kt(t,n,i)}}catch(e){let t=summarizeKnownError(e);t===null?this.#Vt(`Error`,toErrorMessage(e),{detail:inspectError(e)}):this.#Vt(t.name,t.message,{detail:inspectError(e),hint:t.hint})}finally{this.#pe=void 0,this.#Z&&e.abort?.(),this.#Fe=void 0,this.#wt(),this.#It(),this.#H=!1,this.#U.kind===`waiting`&&(this.#U={kind:`idle`}),this.#G=completedTurnStatus({interrupted:this.#Z,cancelled:this.#Ie,continueSession:t?.continueSession===!0}),this.#$t(i),(this.#Z||this.#Ie)&&this.#Qt(),this.#Gt(),this.#d?.reportStats(),this.#in(),t?.continueSession||this.#St()}}async readToolApproval(e,t){return this.#bt(t),this.#It(),this.#F=!1,this.#U={kind:`idle`},this.#G=`Approve ${formatToolApprovalTitle(e)}? (y/n)`,this.#Z=!1,this.#in(),await new Promise((t,n)=>{this.#W=n,this.#ce=r=>{switch(r.type){case`text`:{if(r.framing!==`unframed`)break;let n=r.value.toLowerCase();n===`y`?(this.#Ft(),this.#G=STATUS.processing,this.#wt(),this.#in(),t({approved:!0})):n===`n`&&(this.#Ft(),this.#G=STATUS.processing,this.#qe(e.toolCallId),this.#wt(),this.#in(),t({approved:!1,reason:`Denied by user.`}));break}case`ctrl-r`:this.#in();break;case`ctrl-c`:this.#Z=!0,this.#St(),n(interruptedError());break;default:break}},this.#Ct()})}async readInputQuestion(e,t){this.#bt(t),this.#It(),this.#F=!1,this.#L=!1,this.#U={kind:`idle`},this.#Z=!1;let n=e.options??[],r=n.length>0,i=(e.allowFreeform===!0||!r)&&r,a=n.length+ +!!i,o=questionSectionId(e.requestId),s=r?`overlay`:`text`,c=0,l=EMPTY_LINE,isOnFreeformRow=()=>i&&c===n.length,overlayPanel=t=>renderQuestionPanel({prompt:stripTerminalControls(e.prompt),options:n,cursor:c,allowFreeform:i,editor:l,caretVisible:this.#te},this.#i,t),renderTextSection=()=>{this.#Ut({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:formatQuestionContent(e,void 0,this.#i),preformatted:!0,live:!0})},syncFreeformCaret=()=>{isOnFreeformRow()?this.#jt():(this.#Mt(),this.#Nt())};s===`overlay`?(s=`overlay`,this.#F=!1,this.#Wt(o),this.#ke=overlayPanel,this.#G=``,syncFreeformCaret(),this.#in()):(s=`text`,this.#ke=void 0,renderTextSection(),this.#F=!0,this.#Ge(l),this.#G=``,this.#jt(),this.#in());let finalize=t=>{this.#ke=void 0,this.#Ut({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${stripTerminalControls(t.label)}`,preformatted:!0,live:!1}),this.#F=!1,this.#Ft(),this.#G=STATUS.processing,this.#Mt(),this.#wt(),this.#in();let n={};return t.optionId!==void 0&&(n.optionId=t.optionId),t.text!==void 0&&(n.text=t.text),n},dismiss=()=>{this.#ke=void 0,this.#Ut({id:o,kind:`question`,title:stripTerminalControls(e.prompt),body:`${this.#i.colors.dim(this.#i.glyph.elbow)} ${this.#i.colors.dim(`Dismissed.`)}`,preformatted:!0,live:!1}),this.#F=!1,this.#G=``,this.#Mt(),this.#wt(),this.#in(),u(void 0)},moveCursor=e=>{a!==0&&(c=(c+e+a)%a,syncFreeformCaret(),this.#in())},selectOptionAt=e=>{let t=n[e];t&&u(finalize({optionId:t.id,label:t.label}))},u;return await new Promise((t,r)=>{this.#W=r,u=t,this.#ce=t=>{if(t.type===`ctrl-c`){if((s===`text`||isOnFreeformRow())&&l.text.length>0){l=EMPTY_LINE,this.#Nt(),s===`text`&&this.#Ge(l),this.#in();return}this.#Z=!0,this.#ke=void 0,this.#Mt(),this.#St(),r(interruptedError());return}if(t.type===`ctrl-r`){this.#in();return}if(s===`overlay`){switch(t.type){case`up`:case`ctrl-p`:moveCursor(-1);break;case`down`:case`ctrl-n`:moveCursor(1);break;case`enter`:if(isOnFreeformRow()){let t=resolveQuestionText(l.text,e);t!==void 0&&u(finalize(t));break}selectOptionAt(c);break;case`escape`:if(isOnFreeformRow()&&l.text.length>0){l=EMPTY_LINE,this.#Nt(),this.#in();break}dismiss();break;default:if(isOnFreeformRow()){let e=applyLineEditorKey(l,t);e!==void 0&&(l=e,this.#Nt(),this.#in());break}if(t.type===`text`&&/^[1-9]$/u.test(t.value)){let e=Number(t.value)-1;e<n.length?selectOptionAt(e):e===n.length&&i&&(c=e,syncFreeformCaret(),this.#in())}break}return}let a=applyLineEditorKey(l,t,{multiline:!0});if(a!==void 0){l=a,this.#Nt(),this.#Ge(l),this.#in();return}switch(t.type){case`up`:case`down`:{let e=movePromptLine(l,t.type);e!==void 0&&(l=e,this.#Nt(),this.#Ge(l),this.#in());break}case`enter`:{let t=resolveQuestionText(l.text,e);if(t===void 0)break;u(finalize(t));break}case`escape`:if(l.text.length>0){l=EMPTY_LINE,this.#Nt(),this.#Ge(l),this.#in();break}dismiss();break;default:break}},this.#Ct()})}upsertSubagentStep(e){if(this.#d?.recordSubagentDispatch(e.callId),this.#s===`hidden`)return;let t=stripTerminalControls(e.reasoning??``).trim(),n=stripTerminalControls(e.message??``).trim();if(!(t.length===0&&n.length===0)){if(this.#Ht(e.callId,e.subagentName),this.#s===`collapsed`){this.#in();return}this.#Ut({id:subagentStepSectionId(e.callId,e.sectionKey),kind:`subagent-step`,subagentCallId:e.callId,depth:1,reasoning:t,body:n,collapsed:this.#s!==`full`,live:!e.finalized}),this.#in()}}upsertSubagentTool(e){if(this.#d?.recordSubagentDispatch(e.callId),e.status===`failed`&&e.errorText!==void 0&&this.#d?.append({source:`tool`,summary:`${e.toolName} failed (subagent ${e.subagentName})`,detail:e.errorText}),this.#s===`hidden`)return;if(this.#Ht(e.callId,e.subagentName),this.#s===`collapsed`){this.#in();return}let t=subagentToolStatus(e.status),n=e.status===`preparing`?presentPreparingTool(e.toolName):presentTool(e.toolName,e.input,this.#Xt({input:e.input,output:e.output,toolCallId:e.childCallId,toolName:e.toolName})),r={id:subagentToolSectionId(e.callId,e.childCallId),kind:`subagent-tool`,subagentCallId:e.callId,depth:1,title:stripTerminalControls(n.title),subtitle:stripTerminalControls(n.subtitle),status:t,live:t===`running`||t===`approval`,expanded:this.#s===`full`,toolName:e.toolName,toolGroup:n.group,toolInput:e.input};n.doneTitle!==void 0&&(r.doneTitle=stripTerminalControls(n.doneTitle)),n.detail!==void 0&&(r.detailLines=n.detail,r.keepDetailWhenDone=n.keepDetailWhenDone===!0),e.output===void 0?e.errorText!==void 0&&(r.result=stripTerminalControls(e.errorText)):(r.result=n.summarizeResult(e.output),r.toolOutput=e.output),this.#Ut(r),this.#Ke(e.callId),this.#in()}#Ke(e){applyCohortLiveness(this.#m.filter(t=>t.kind===`subagent-tool`&&t.subagentCallId===e).map(e=>({block:e,active:isActiveToolStatus(e.status)})))}removeSubagentTool(e){this.#Wt(subagentToolSectionId(e.callId,e.childCallId)),this.#in()}subagents={begin:e=>this.beginSubagent(e),upsertStep:e=>this.upsertSubagentStep(e),upsertTool:e=>this.upsertSubagentTool(e),removeTool:e=>this.removeSubagentTool(e),complete:e=>this.completeSubagent(e),markChildToolCallId:e=>this.markChildToolCallId(e)};beginSubagent(e){if(this.#s===`hidden`)return;this.#Ht(e.callId,e.name);let t=this.#h.get(subagentHeaderId(e.callId));t?.status===`done`&&delete t.status,this.#in()}completeSubagent(e){let t=this.#h.get(subagentHeaderId(e.callId));t!==void 0&&(t.status=`done`,this.#in())}markChildToolCallId(e){this.#v.add(e);let t=this.#y.get(e);t!==void 0&&(this.#Wt(t),this.#y.delete(e),this.#in())}#qe(e){let t=this.#h.get(toolSectionId(e));t!==void 0&&(t.status=`denied`,t.live=!1)}upsertConnectionAuth(e){if(this.#c===`hidden`)return;let t=connectionAuthTerminalMessage(e.state);this.#Ut({id:connectionAuthSectionId(e.name),kind:`connection-auth`,title:`${stripTerminalControls(e.name)} · authorization · ${e.state}`,body:formatConnectionAuthContent(e,t),preformatted:!0,live:t===void 0}),this.#in()}setConnectionAuthPendingCount(e){let t=Math.max(0,e);if(t===this.#k)return;let n=this.#k>0;this.#k=t,t>0?(this.#G=STATUS.connectionAuth,this.#in()):n&&(this.#G=STATUS.processing,this.#in())}setVercelStatus(e){this.#A=e,this.#in()}setRemoteConnectionStatus(e){this.#j=e,this.#in()}reset(){this.#m=[],this.#h.clear(),this.#g.clear(),this.#O=void 0,this.#D.length=0,this.#_.length=0,this.#T=!1,this.#E=void 0,this.#Je(),this.#z=!1,this.#Oe=void 0,this.#Ee=void 0,this.#k=0,this.#ge=void 0,this.#_e=void 0,this.#ye=void 0,this.#be=void 0,this.#xe=void 0,this.#J&&(this.#n.clearAll(),this.#in())}renderSessionBoundary(){this.#zt(),this.#Je();let e=this.#i.colors,t=this.#i.glyph,n=e.dim(`${t.cornerOpen}${t.dash.repeat(2)} Session restarted, clear context.`);this.#Lt({kind:`session-boundary`,body:n,live:!1}),this.#in()}#Je(){this.#v.clear(),this.#y.clear(),this.#C.clear(),this.#x.clear(),this.#Me=void 0,this.#Ne=void 0,this.#Pe.reset(),this.#Re=void 0,this.#S.clear(),this.#B.reset()}renderNotice(e){let t=stripTerminalControls(e);t.trim().length!==0&&(this.#bt(),this.#Lt({kind:`notice`,body:t,live:!1}),this.#in())}renderSandboxLog(e){let t=parseSandboxLogLine(stripTerminalControls(e));t!==void 0&&(this.#d?.append({source:`sandbox`,detail:t}),this.#bt(),this.#Lt({kind:`sandbox`,body:t,live:!1}),this.#in())}renderSetupWarning(e){let t=stripTerminalControls(e);if(t.trim().length===0){this.#Ye();return}this.#bt(),this.#je=t,this.#in()}clearSetupWarning(){this.#Ye()}#Ye(){this.#je!==void 0&&(this.#je=void 0,this.#in())}renderCommandInvocation(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;this.#bt();let r={kind:`command`,body:n,live:!1};t===`failed`&&(r.status=`error`),this.#Lt(r),this.#in()}renderCommandResult(e,t){let n=stripTerminalControls(e);n.trim().length!==0&&(this.#bt(),this.#Lt(t===`success`?{kind:`result`,body:n,live:!1,status:`done`}:t===`error`?{kind:`flow`,title:t,body:n,live:!1}:{kind:`result`,body:n,live:!1}),this.#in())}#Xe(e,t=`spinner`){this.#bt(),this.#F=!1,this.#U={kind:`idle`},this.#G=``;let n=t===`pulse`?{kind:`pulse`,startedAtMs:Date.now()}:{kind:`spinner`};this.#Ae={title:stripTerminalControls(e),indicator:n,lines:[],outputBuffer:[]},this.#Pt(),this.#in()}#Ze(e){this.#Ve=void 0,this.#dt();let t=this.#Ae;if(t!==void 0){if(this.#Ae=void 0,this.#It(),e){let e=[];for(let n of t.lines){if(n.evidence===!0){e.push(n.text);continue}(n.tone===`warning`||n.tone===`error`)&&(e.length>0&&this.#Lt({kind:`flow`,title:`info`,body:e.join(`
5
5
  `),live:!1}),this.#Lt({kind:`flow`,title:n.tone,body:n.text,live:!1})),e=[]}}this.#in()}}async#Qe(e){let t=this.#at(),n=isMultiSelectRequest(e),r=e.kind===`search`?e.searchAction:void 0,i=e.options,a={options:i,searchAction:r,submitRow:n};`initialValue`in e&&e.initialValue!==void 0&&(a.defaultValue=e.initialValue),`initialValues`in e&&e.initialValues!==void 0&&(a.initialValues=e.initialValues);let o=initialSelectState(a),s,c=!1,l=0,isCurrentSearch=e=>e===l,clearSearch=()=>{l+=1,c=!1,o=reduceSelect(o,{type:`clear`},{options:i,searchAction:r,submitRow:n}),this.#in()},loadSearch=async(e,t)=>{c=!0,s=void 0;let a=++l;this.#in();try{let s=await t(e);if(!isCurrentSearch(a))return;let c=o.filter;i=s,o={...initialSelectState({options:s,searchAction:r,submitRow:n}),filter:c}}catch(e){isCurrentSearch(a)&&(s=toErrorMessage(e))}finally{isCurrentSearch(a)&&(c=!1,this.#in())}},u=e.notices;if(e.kind===`task-list`||e.kind===`search`&&e.layout===`task-list`){let n=t.taskListLineStart??t.lines.length,r=t.lines.slice(n).filter(e=>e.tone===`success`||e.tone===`warning`||e.tone===`error`).map(e=>({tone:e.tone,text:e.text}));u=[...e.notices??[],...r],t.taskListLineStart=t.lines.length,t.hideLinesWhileQuestion=!0}let panelState=()=>{let t={...e,options:i,select:o};return u!==void 0&&u.length>0&&(t.notices=u),s!==void 0&&(t.error=s),c&&(t.loadingFrame=this.#dn()),t};return t.question=e=>renderSelectQuestion(panelState(),this.#i,e),this.#in(),await this.#ct((t,a)=>{let close=e=>{l+=1,a(e)};if(c){t.type===`ctrl-c`?close(void 0):t.type===`escape`?clearSearch():t.type===`ctrl-r`&&this.#in();return}let u={key:t,options:i,searchAction:r,select:o},d=reduceSetupSelectInput(n?{...u,kind:e.kind,required:e.required}:{...u,kind:e.kind});switch(d.kind){case`cancel`:close(void 0);return;case`repaint`:this.#in();return;case`update`:o=d.select,s=void 0,this.#in();return;case`submit`:{let e=searchActionQuery(d.values[0]??``),t=r?.load;if(e===void 0||t===void 0){close(d.values);return}loadSearch(e,t);return}case`error`:s=d.message,this.#in();return;case`ignore`:return}}).promise}#$e(e){this.#bt();let t=this.#ot();t.status={kind:`progress`,text:stripTerminalControls(e.status),startedAtMs:Date.now()};let n;t.question=t=>renderSelectQuestion({kind:`actions`,context:e.context,actions:e.actions,cursor:n},this.#i,t),this.#in();let r=this.#ct((t,r)=>{let i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:r(void 0);return;case`move`:n=moveActionCursor(n,i.direction,e.actions.length),this.#in();return;case`repaint`:this.#in();return;case`submit`:n!==void 0&&r(e.actions[n].value);return;case void 0:return}},()=>{t.status=void 0});return{choice:r.promise,close:()=>r.settle(void 0)}}async#et(e){let t=this.#at(),n={options:e.options};e.initialValue!==void 0&&(n.defaultValue=e.initialValue);let r=initialSelectState(n),i=lineOf(``),a;t.question=t=>{let n={kind:`inline-edit`,layout:`task-list`,message:e.message,options:e.options,select:r,edit:{optionValue:e.editable.value,caretVisible:this.#te,editor:{kind:`rename`,editor:i,defaultValue:e.editable.defaultValue,formatHint:e.editable.formatHint}}};return a!==void 0&&(n.error=a),renderSelectQuestion(n,this.#i,t)};let onEditableRow=()=>selectValueAtCursor([...e.options],r.cursor)===e.editable.value,syncEditableRow=()=>{onEditableRow()?this.#jt():(i=lineOf(``),this.#Mt())};return syncEditableRow(),this.#in(),await this.#ct((t,n)=>{let applyEditor=e=>{i=e,a=void 0,this.#Nt(),this.#in()},applySelect=t=>{r=reduceSelect(r,t,{options:e.options}),a=void 0,syncEditableRow(),this.#in()},submit=()=>{let t=selectValueAtCursor([...e.options],r.cursor);if(t===void 0)return;if(t!==e.editable.value){n({kind:`selected`,value:t});return}let o=(i.text||e.editable.defaultValue).trim(),s=e.editable.validate?.(o);if(s!==void 0){a=s,this.#in();return}n(o===e.editable.defaultValue?{kind:`selected`,value:t}:{kind:`edited`,value:t,text:o})},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:n(void 0);return;case`move`:applySelect({type:o.direction});return;case`submit`:submit();return;case`repaint`:this.#in();return;case void 0:break}if(!onEditableRow())return;let s=applyLineEditorKey(i,t);s!==void 0&&applyEditor(s)},()=>this.#Mt()).promise}async#tt(e){let t=this.#at(),n=initialProviderPickerState(e.options,e.initialValue),r,cursorBadge=()=>{if(n.phase.kind!==`inactive`)return;let t=selectValueAtCursor([...e.options],n.select.cursor),r=e.options.find(e=>e.value===t);if(r!==void 0)return enterBadge(this.#i,r.checked===!0?`change`:void 0)};t.question=t=>{let r=cursorBadge(),i={kind:`inline-edit`,layout:`stacked`,message:e.message,options:e.options,select:n.select,edit:{optionValue:`own-key`,caretVisible:this.#te,editor:{kind:`key`,phase:n.phase}}};return r!==void 0&&(i.cursorBadge=r),renderSelectQuestion(i,this.#i,t)};let syncCaret=()=>{n.phase.kind===`editing`||n.phase.kind===`invalid`?this.#jt():this.#Mt()};return syncCaret(),this.#in(),await this.#ct((t,i,a)=>{let dispatch=t=>{let o=transitionProviderPicker(n,t,e.options);switch(o.kind){case`ignore`:return;case`clear`:r?.abort(),r=void 0,n=o.state,syncCaret(),this.#in();return;case`cancel`:i(void 0);return;case`render`:n=o.state,syncCaret(),this.#in();return;case`validate`:{n=o.state,syncCaret(),this.#in();let t=new AbortController;r=t;let i;try{i=e.validateInlineKey(o.key,t.signal)}catch(e){a(e);return}i.then(e=>{r!==t||t.signal.aborted||(r=void 0,dispatch({type:`validated`,validation:e}))},e=>{r!==t||t.signal.aborted||(r=void 0,a(e))});return}case`settle`:i(o.result);return}},o=setupSelectionIntent(t);switch(o?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:o.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#in();return;case void 0:break}if(n.phase.kind!==`editing`&&n.phase.kind!==`invalid`)return;let s=applyLineEditorKey(n.phase.editor,t);s!==void 0&&(this.#Nt(),dispatch({type:`edit`,editor:s}))},()=>{r?.abort(),r=void 0,this.#Mt()}).promise}async#nt(e){let t=this.#at(),n=initialModelEditorState(e);return t.question=t=>renderModelEditorQuestion({request:e,state:n},this.#i,t),this.#in(),await this.#ct((t,r)=>{let dispatch=t=>{let i=transitionModelEditor(n,t,e);switch(i.kind){case`ignore`:return;case`render`:n=i.state,this.#in();return;case`cancel`:r(void 0);return;case`settle`:r(i.result);return}},i=setupSelectionIntent(t);switch(i?.kind){case`cancel`:dispatch({type:`cancel`});return;case`move`:dispatch({type:`move`,direction:i.direction});return;case`submit`:dispatch({type:`submit`});return;case`repaint`:this.#in();return;case void 0:break}if(t.type===`left`||t.type===`right`){dispatch({type:`adjust`,direction:t.type});return}if(t.type===`tab`){dispatch({type:`adjust`,direction:`right`});return}if(t.type===`backspace`){dispatch({type:`backspace`});return}if(t.type===`text`)for(let e of t.value.replaceAll(`
6
- `,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#rt(e){let t=this.#at(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder!==void 0&&(i.placeholder=e.placeholder),e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#te)},this.#jt(),this.#in(),await this.#ct((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Nt(),this.#in()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#in();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#in();return}i(t);return}default:return}},()=>this.#Mt()).promise}async#it(e){let t=this.#at();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#i,t),this.#in(),await this.#ct((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#in();return;default:return}}).promise}#at(){return this.#bt(),this.#F=!1,this.#U={kind:`idle`},this.#G=``,this.#ot()}#ot(){return this.#Ae===void 0&&(this.#Ae={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ae}#st(){this.#Ae?.implicit===!0?this.#Ae=void 0:this.#Ae!==void 0&&(this.#Ae.question=void 0,this.#Ae.hideLinesWhileQuestion=!1),this.#ce=void 0,this.#wt(),this.#Ae!==void 0&&this.#ut(),this.#in()}#ct(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#st(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#st(),i(e))};return this.#kt(),this.#ce=t=>{t.type===`ctrl-c`&&this.#gt(),e(t,settle,reject)},this.#Ct(),{promise:a,settle}}#lt(e){let t,n=new Promise(e=>{t=e});return this.#Ve=t,this.#ut(e?.interruptible??!0),{promise:n,dispose:()=>{this.#Ve===t&&(this.#Ve=void 0,this.#dt())}}}#ut(e=!0){if(this.#Ve===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#gt();let e=this.#Ve;this.#Ve=void 0,this.#dt(),e?.();return}t.type===`ctrl-r`&&this.#in()};this.#He=consumer,this.#kt(),this.#ce=consumer,this.#Ct()}#dt(){this.#He!==void 0&&(this.#ce===this.#He&&this.#wt(),this.#He=void 0)}#ft(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ae!==void 0){this.#Ae.status=t,t===void 0&&(this.#Ae.preview=void 0),this.#in();return}if(!(this.#F||this.#H)){if(t===void 0){this.#U={kind:`idle`},this.#K=void 0,this.#It(),this.#in();return}this.#bt(),this.#Ft(),this.#K=t.text,this.#in()}}#pt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ae;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#in();return}this.#bt(),this.#Lt({kind:`flow`,title:t,body:n,live:!1}),this.#in()}#mt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ae;if(n===void 0){this.#pt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#in()}async#ht(e){this.#le=``,this.#kt(),this.#Ve=void 0,this.#dt(),this.#wt(),this.#It(),this.#n.clear(),this.#n.showCursor(),this.#En(),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#le=``,this.#kt(),this.#n.hideCursor(),this.#Tn(),this.#Ae!==void 0&&(this.#Pt(),this.#ut()),this.#n.reset(),this.#in()}}setSessionId(e){this.#Le=e}shutdown(){if(this.#St(),this.#Y&&!this.#X){this.#X=!0;let e=this.#Le===void 0?``:` ${this.#i.glyph.dot} session ${this.#Le}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}requestInterrupt(){this.#Z=!0,this.#Ae!==void 0&&this.#ce?.({type:`ctrl-c`}),this.#pe?.(),this.#St()}exitRequested(){return this.#Q}#gt(){this.#Q=!0,this.#ee?.()}async#_t(e){if(this.#Ue!==void 0||!this.#J)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Cn(),height:this.#wn()}),paint:e=>this.#r.paint(e,this.#wn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#We});this.#Ue=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#yt=e,this.#ce=e=>{t.handleKey(e)===`close`&&this.#vt()},this.#Ct(),t.start()})}#vt(){let e=this.#Ue;if(e===void 0)return;this.#Ue=void 0,e.dispose(),this.#wt(),this.#r.exit(),this.#n.hideCursor(),this.#in(),this.#n.showCursor();let t=this.#yt;this.#yt=void 0,t?.()}#yt;#bt(e){this.#q=e?.title??this.#q,e?.contextSize!==void 0&&(this.#ve=e.contextSize),!this.#J&&(this.#J=!0,this.#Y=!0,this.#n.reset(),this.#n.hideCursor(),this.#Tn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#fe=()=>this.#in(),this.#t.on(`resize`,this.#fe),process.on(`exit`,this.#xt))}#xt=()=>{this.#J&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#St(){this.#vt();let e=this.#W;if(this.#W=void 0,e?.(interruptedError()),this.#wt(),this.#Mt(),this.#It(),this.#oe!==void 0&&(clearTimeout(this.#oe),this.#oe=void 0),this.#se=!1,this.#J){this.#Pn();for(let e of this.#m)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#in(),this.#n.clear(),this.#n.showCursor(),this.#En(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#fe&&=(this.#t.off(`resize`,this.#fe),void 0),process.off(`exit`,this.#xt),this.#J=!1}}#Ct(){this.#e.off(`data`,this.#Tt),this.#e.on(`data`,this.#Tt),this.#le.length>0&&queueMicrotask(()=>{this.#ce!==void 0&&this.#le.length>0&&(this.#Dt(),this.#Et())})}#wt(){this.#e.off(`data`,this.#Tt),this.#kt(),this.#ce=void 0}#Tt=e=>{this.#kt(),this.#le+=this.#ue.write(e),this.#Dt(),this.#Et()};#Et(){if(this.#le===`\x1B`){this.#de=setTimeout(()=>{this.#le===`\x1B`&&(this.#le=``,this.#ce?.({type:`escape`}))},30),this.#de.unref?.();return}if(isIncompletePaste(this.#le)){let e=this.#le;this.#de=setTimeout(()=>{if(this.#le!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#le=``,t.length>0&&this.#ce?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#de.unref?.();return}if(isIncompleteOsc(this.#le)){let e=this.#le;this.#de=setTimeout(()=>{this.#le===e&&(this.#le=``)},incompletePasteFlushMs),this.#de.unref?.()}}#Dt(){for(;this.#le.length>0;){let e=nextKey(this.#le);if(e.incomplete)return;if(this.#le=this.#le.slice(e.consumed),!(e.key===void 0||e.key.type===`ignore`)){if(e.key.type===`osc`){this.#Ot(e.key.value);continue}this.#ce?.(e.key)}}}#Ot(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#We=t,this.#Ue?.setTerminalBackground(t))}#kt(){this.#de&&=(clearTimeout(this.#de),void 0)}#At(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#in();break;case`enter`:{let e=this.#V.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Fe!==void 0){this.#V=EMPTY_LINE,this.#Pe.requestCancellation(),this.#ze=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Fe(),this.#in();break}this.#Pe.enqueue(e)&&(this.#V=EMPTY_LINE),this.#in();break}case`ctrl-c`:case`escape`:if(this.#Pe.idle&&this.#Fe===void 0)break;this.#Pe.handleEscape(),this.#ze=!0,this.#Fe?.(),this.#in();break;default:{let t=applyLineEditorKey(this.#V,e,{multiline:!0});t!==void 0&&(this.#V=t,this.#in());break}}}#jt(){this.#Mt(),this.#Nt(),this.#ie=setInterval(()=>{this.#te=!this.#te,this.#in()},500),this.#ie.unref?.()}#Mt(){this.#ie&&=(clearInterval(this.#ie),void 0),this.#te=!0}#Nt(){this.#te=!0}#Pt(){this.#It(),this.#ae=setInterval(()=>{this.#ne+=1,this.#in()},90),this.#ae.unref?.()}#Ft(){let e=Date.now();this.#re=e,this.#U={kind:`waiting`,startedAtMs:e},this.#Pt()}#It(){this.#ae&&=(clearInterval(this.#ae),void 0)}#Lt(e){e.id!==this.#Ee?.id&&this.#Pn(),e.updateSeq=++this.#b,this.#m.push(e),e.id&&this.#h.set(e.id,e)}#Rt(e){this.#z=!0,this.#Lt({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#in()}#zt(){let e=this.#B.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#gn(e.elapsedMs)}`,n=this.#_e??0;if(this.#ve!==void 0&&this.#ve>0&&n>0){let e=Math.round(n/this.#ve*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#Lt({kind:`turn-stats`,body:t,live:!1})}#Bt(e){if(e==null)return;let t=this.#Re;if(this.#Re=void 0,this.#Oe===e){this.#Oe=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#Lt(n)}#Vt(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#d?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#d===void 0?a:`details: ${this.#d.displayPath}`),this.#Lt(c),this.#in()}#Ht(e,t){if(this.#C.has(e))return;this.#C.add(e);let n=stripTerminalControls(t),r=this.#x.get(n)??[];if(r.push(e),this.#x.set(n,r),r.length===2){let e=this.#h.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#Lt(i)}#Ut(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#Lt(e)}#Wt(e){this.#m=this.#m.filter(t=>t.id!==e),this.#h.delete(e)}#Gt(){for(let e of this.#m)e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#Kt(e,t,n){switch(e.type){case`step-finish`:this.#d?.recordStepUsage(e.usage),e.usage!==void 0&&this.#B.addUsage(e.usage),this.#$t(n),this.#rn(e.usage),this.#in();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#qt(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;n.text.set(e.id,r),this.#qt(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#Jt(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#Jt(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#Yt({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#d?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#Yt({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#Yt({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#nn(e.toolCallId,n);if(r===void 0)break;this.#Yt({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#nn(e.toolCallId,n);if(this.#d?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#Yt({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#nn(e.toolCallId,n);if(r===void 0)break;this.#Yt({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#Vt(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:this.#Ie=!0,!this.#ze&&this.#Be!==void 0&&this.#V.text.length===0&&(this.#V=lineOf(this.#Be),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#rn(e.usage),this.#in();break}}#qt(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#Ut({id:e,kind:`assistant`,body:r,live:n}),this.#in())}#Jt(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Ut({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#in())}#Yt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#v.has(e.toolCallId)||this.#en(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#y.set(e.toolCallId,r);let i=this.#Xt(e);this.#Ut(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#tn(n),this.#in()}#Xt(e){e.output!==void 0&&this.#S.observeRead(e.output);let t={};this.#Zt(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#S.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#Zt(e){let t=this.#w?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#Qt(){for(let e of this.#m)e.kind!==`tool`&&e.kind!==`subagent-tool`||e.status===`running`&&(e.status=`error`,e.result=`interrupted`,e.live=!1)}#$t(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#y.get(t)??toolSectionId(t);this.#Wt(r),this.#y.delete(t)}}#en(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Ne!==e&&(this.#Ne=e,this.#Lt({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Cn(),this.#i).join(`
6
+ `,` `))e>=` `&&e!==``&&dispatch({type:`char`,char:e})}).promise}async#rt(e){let t=this.#at(),n=lineOf(``),r;return t.question=t=>{let i={message:e.message,editor:n,mask:e.mask===!0};return e.placeholder===void 0?e.defaultValue!==void 0&&(i.placeholder=e.defaultValue):i.placeholder=e.placeholder,e.notices!==void 0&&(i.notices=e.notices),r!==void 0&&(i.error=r),renderTextQuestion(i,this.#i,t,this.#te)},this.#jt(),this.#in(),await this.#ct((t,i)=>{let apply=e=>{n=e,r=void 0,this.#Nt(),this.#in()},a=applyLineEditorKey(n,t);if(a!==void 0){apply(a);return}switch(t.type){case`ctrl-c`:case`escape`:i(void 0);return;case`ctrl-r`:this.#in();return;case`enter`:{let t=n.text.length>0?n.text:e.defaultValue??``,a=e.validate?.(t);if(a!==void 0){r=a,this.#in();return}i(t);return}default:return}},()=>this.#Mt()).promise}async#it(e){let t=this.#at();return t.question=t=>renderAcknowledgeQuestion({message:e.message,lines:e.lines},this.#i,t),this.#in(),await this.#ct((e,t)=>{switch(e.type){case`enter`:case`escape`:case`ctrl-c`:t();return;case`ctrl-r`:this.#in();return;default:return}}).promise}#at(){return this.#bt(),this.#F=!1,this.#U={kind:`idle`},this.#G=``,this.#ot()}#ot(){return this.#Ae===void 0&&(this.#Ae={title:``,indicator:{kind:`spinner`},lines:[],outputBuffer:[],implicit:!0}),this.#Ae}#st(){this.#Ae?.implicit===!0?this.#Ae=void 0:this.#Ae!==void 0&&(this.#Ae.question=void 0,this.#Ae.hideLinesWhileQuestion=!1),this.#ce=void 0,this.#wt(),this.#Ae!==void 0&&this.#ut(),this.#in()}#ct(e,t){let n=!1,r,i,a=new Promise((e,t)=>{r=e,i=t}),settle=e=>{n||(n=!0,t?.(),this.#st(),r(e))},reject=e=>{n||(n=!0,t?.(),this.#st(),i(e))};return this.#kt(),this.#ce=t=>{t.type===`ctrl-c`&&this.#gt(),e(t,settle,reject)},this.#Ct(),{promise:a,settle}}#lt(e){let t,n=new Promise(e=>{t=e});return this.#Ve=t,this.#ut(e?.interruptible??!0),{promise:n,dispose:()=>{this.#Ve===t&&(this.#Ve=void 0,this.#dt())}}}#ut(e=!0){if(this.#Ve===void 0)return;let consumer=t=>{if(e&&(t.type===`ctrl-c`||t.type===`escape`)){t.type===`ctrl-c`&&this.#gt();let e=this.#Ve;this.#Ve=void 0,this.#dt(),e?.();return}t.type===`ctrl-r`&&this.#in()};this.#He=consumer,this.#kt(),this.#ce=consumer,this.#Ct()}#dt(){this.#He!==void 0&&(this.#ce===this.#He&&this.#wt(),this.#He=void 0)}#ft(e){let t=e===void 0?void 0:typeof e==`string`?{kind:`progress`,text:stripTerminalControls(e),startedAtMs:Date.now()}:{kind:`external-action`,text:stripTerminalControls(e.text),emphasis:stripTerminalControls(e.emphasis),startedAtMs:Date.now()};if(this.#Ae!==void 0){this.#Ae.status=t,t===void 0&&(this.#Ae.preview=void 0),this.#in();return}if(!(this.#F||this.#H)){if(t===void 0){this.#U={kind:`idle`},this.#K=void 0,this.#It(),this.#in();return}this.#bt(),this.#Ft(),this.#K=t.text,this.#in()}}#pt(e,t){let n=stripTerminalControls(e);if(n.trim().length===0)return;let r=this.#Ae;if(r!==void 0){if(r.preview=void 0,t===`warning`||t===`error`)for(let e of r.outputBuffer)r.lines.push({text:e,tone:`info`,evidence:!0});r.outputBuffer=[],r.lines.push({text:n,tone:t}),this.#in();return}this.#bt(),this.#Lt({kind:`flow`,title:t,body:n,live:!1}),this.#in()}#mt(e){let t=stripTerminalControls(e);if(t.trim().length===0)return;let n=this.#Ae;if(n===void 0){this.#pt(t,`info`);return}n.preview=t,n.outputBuffer.push(t),n.outputBuffer.length>40&&n.outputBuffer.shift(),this.#in()}async#ht(e){this.#le=``,this.#kt(),this.#Ve=void 0,this.#dt(),this.#wt(),this.#It(),this.#n.clear(),this.#n.showCursor(),this.#En(),this.#e.isTTY&&this.#e.setRawMode?.(!1),this.#e.pause();try{return await e()}finally{this.#e.isTTY&&this.#e.setRawMode?.(!0),this.#e.resume(),this.#le=``,this.#kt(),this.#n.hideCursor(),this.#Tn(),this.#Ae!==void 0&&(this.#Pt(),this.#ut()),this.#n.reset(),this.#in()}}setSessionId(e){this.#Le=e}shutdown(){if(this.#St(),this.#Y&&!this.#X){this.#X=!0;let e=this.#Le===void 0?``:` ${this.#i.glyph.dot} session ${this.#Le}`;this.#t.write(`${this.#i.colors.dim(`${eveVersionTag()}${e}`)}\n`)}}requestInterrupt(){this.#Z=!0,this.#Ae!==void 0&&this.#ce?.({type:`ctrl-c`}),this.#pe?.(),this.#St()}exitRequested(){return this.#Q}#gt(){this.#Q=!0,this.#ee?.()}async#_t(e){if(this.#Ue!==void 0||!this.#J)return;let t=new TraceViewerSession({...e,theme:this.#i,dimensions:()=>({width:this.#Cn(),height:this.#wn()}),paint:e=>this.#r.paint(e,this.#wn()),tracingDisabled:process.env.EVE_TRACES===`off`,copyText:e=>copyTextToClipboard(e,e=>this.#r.writeRaw(e)),terminalBackground:this.#We});this.#Ue=t,this.#r.enter(),this.#i.color&&this.#r.writeRaw(BACKGROUND_COLOR_QUERY),await new Promise(e=>{this.#yt=e,this.#ce=e=>{t.handleKey(e)===`close`&&this.#vt()},this.#Ct(),t.start()})}#vt(){let e=this.#Ue;if(e===void 0)return;this.#Ue=void 0,e.dispose(),this.#wt(),this.#r.exit(),this.#n.hideCursor(),this.#in(),this.#n.showCursor();let t=this.#yt;this.#yt=void 0,t?.()}#yt;#bt(e){this.#q=e?.title??this.#q,e?.contextSize!==void 0&&(this.#ve=e.contextSize),!this.#J&&(this.#J=!0,this.#Y=!0,this.#n.reset(),this.#n.hideCursor(),this.#Tn(),this.#e.isTTY&&(this.#e.setRawMode?.(!0),this.#e.resume(),this.#n.emitBracketedPaste(!0)),this.#fe=()=>this.#in(),this.#t.on(`resize`,this.#fe),process.on(`exit`,this.#xt))}#xt=()=>{this.#J&&(this.#r.exit(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1)),this.#n.showCursor())};#St(){this.#vt();let e=this.#W;if(this.#W=void 0,e?.(interruptedError()),this.#wt(),this.#Mt(),this.#It(),this.#oe!==void 0&&(clearTimeout(this.#oe),this.#oe=void 0),this.#se=!1,this.#J){this.#Pn();for(let e of this.#m)e.kind===`log`&&e.id===void 0&&(e.live=!1);this.#in(),this.#n.clear(),this.#n.showCursor(),this.#En(),this.#n.newline(),this.#e.isTTY&&(this.#n.emitBracketedPaste(!1),this.#e.setRawMode?.(!1),this.#e.pause()),this.#fe&&=(this.#t.off(`resize`,this.#fe),void 0),process.off(`exit`,this.#xt),this.#J=!1}}#Ct(){this.#e.off(`data`,this.#Tt),this.#e.on(`data`,this.#Tt),this.#le.length>0&&queueMicrotask(()=>{this.#ce!==void 0&&this.#le.length>0&&(this.#Dt(),this.#Et())})}#wt(){this.#e.off(`data`,this.#Tt),this.#kt(),this.#ce=void 0}#Tt=e=>{this.#kt(),this.#le+=this.#ue.write(e),this.#Dt(),this.#Et()};#Et(){if(this.#le===`\x1B`){this.#de=setTimeout(()=>{this.#le===`\x1B`&&(this.#le=``,this.#ce?.({type:`escape`}))},30),this.#de.unref?.();return}if(isIncompletePaste(this.#le)){let e=this.#le;this.#de=setTimeout(()=>{if(this.#le!==e)return;let t=sanitizePastedText(stripPasteStart(e));this.#le=``,t.length>0&&this.#ce?.({type:`text`,value:t,framing:`bracketed-paste`})},incompletePasteFlushMs),this.#de.unref?.();return}if(isIncompleteOsc(this.#le)){let e=this.#le;this.#de=setTimeout(()=>{this.#le===e&&(this.#le=``)},incompletePasteFlushMs),this.#de.unref?.()}}#Dt(){for(;this.#le.length>0;){let e=nextKey(this.#le);if(e.incomplete)return;if(this.#le=this.#le.slice(e.consumed),!(e.key===void 0||e.key.type===`ignore`)){if(e.key.type===`osc`){this.#Ot(e.key.value);continue}this.#ce?.(e.key)}}}#Ot(e){let t=parseBackgroundColorReply(e);t!==void 0&&(this.#We=t,this.#Ue?.setTerminalBackground(t))}#kt(){this.#de&&=(clearTimeout(this.#de),void 0)}#At(e){switch(e.type){case`ctrl-l`:case`ctrl-r`:this.#in();break;case`enter`:{let e=this.#V.text;if(e.trim().length===0)break;if(parsePromptCommand(e)?.type===`cancel`&&this.#Fe!==void 0){this.#V=EMPTY_LINE,this.#Pe.requestCancellation(),this.#ze=!0,this.renderCommandInvocation(e.trim()),this.renderCommandResult(`Turn cancellation requested.`),this.#Fe(),this.#in();break}this.#Pe.enqueue(e)&&(this.#V=EMPTY_LINE),this.#in();break}case`ctrl-c`:case`escape`:if(this.#Pe.idle&&this.#Fe===void 0)break;this.#Pe.handleEscape(),this.#ze=!0,this.#Fe?.(),this.#in();break;default:{let t=applyLineEditorKey(this.#V,e,{multiline:!0});t!==void 0&&(this.#V=t,this.#in());break}}}#jt(){this.#Mt(),this.#Nt(),this.#ie=setInterval(()=>{this.#te=!this.#te,this.#in()},500),this.#ie.unref?.()}#Mt(){this.#ie&&=(clearInterval(this.#ie),void 0),this.#te=!0}#Nt(){this.#te=!0}#Pt(){this.#It(),this.#ae=setInterval(()=>{this.#ne+=1,this.#in()},90),this.#ae.unref?.()}#Ft(){let e=Date.now();this.#re=e,this.#U={kind:`waiting`,startedAtMs:e},this.#Pt()}#It(){this.#ae&&=(clearInterval(this.#ae),void 0)}#Lt(e){e.id!==this.#Ee?.id&&this.#Pn(),e.updateSeq=++this.#b,this.#m.push(e),e.id&&this.#h.set(e.id,e)}#Rt(e){this.#z=!0,this.#Lt({kind:`user`,body:stripTerminalControls(e),live:!1}),this.#in()}#zt(){let e=this.#B.settle();if(e===void 0||e.elapsedMs<=1e4&&e.inputTokens<=2e4)return;let t=`Done in ${this.#gn(e.elapsedMs)}`,n=this.#_e??0;if(this.#ve!==void 0&&this.#ve>0&&n>0){let e=Math.round(n/this.#ve*100);t+=` ${this.#i.glyph.dot} ${e}% context`}this.#Lt({kind:`turn-stats`,body:t,live:!1})}#Bt(e){if(e==null)return;let t=this.#Re;if(this.#Re=void 0,this.#Oe===e){this.#Oe=void 0;return}let n={kind:`user`,body:stripTerminalControls(e),live:!1};t!==void 0&&(n.promptOrigin=t),this.#Lt(n)}#Vt(e,t,n={}){let r=stripTerminalControls(e),i=stripTerminalControls(t),a=n.detail===void 0?void 0:stripTerminalControls(n.detail),o=n.hint===void 0?void 0:stripTerminalControls(n.hint),s={source:`workflow`,summary:`${r}: ${i}`,detail:a??i};this.#d?.append(o===void 0?s:{...s,hint:o});let c={kind:`error`,title:r,body:i,live:!1};o!==void 0&&(c.hint=o),a!==void 0&&(c.detail=this.#d===void 0?a:`details: ${this.#d.displayPath}`),this.#Lt(c),this.#in()}#Ht(e,t){if(this.#C.has(e))return;this.#C.add(e);let n=stripTerminalControls(t),r=this.#x.get(n)??[];if(r.push(e),this.#x.set(n,r),r.length===2){let e=this.#h.get(subagentHeaderId(r[0]));e!==void 0&&(e.subtitle=`#1`)}let i={id:subagentHeaderId(e),kind:`subagent`,subagentCallId:e,title:n,live:!0};r.length>1&&(i.subtitle=`#${r.length}`),this.#Lt(i)}#Ut(e){if(e.id&&this.#g.has(e.id))return;let t=e.id?this.#h.get(e.id):void 0;if(t){Object.assign(t,e),t.updateSeq=++this.#b;return}this.#Lt(e)}#Wt(e){this.#m=this.#m.filter(t=>t.id!==e),this.#h.delete(e)}#Gt(){for(let e of this.#m)e.status===`approval`||e.status===`running`||e.kind===`connection-auth`&&e.live||(e.live=!1)}#Kt(e,t,n){switch(e.type){case`step-finish`:this.#d?.recordStepUsage(e.usage),e.usage!==void 0&&this.#B.addUsage(e.usage),this.#$t(n),this.#rn(e.usage),this.#in();break;case`assistant-delta`:{let t=(n.text.get(e.id)??``)+stripTerminalControls(e.delta);n.text.set(e.id,t),this.#qt(e.id,t,!0);break}case`assistant-complete`:{let t=n.text.get(e.id)??``,r=e.text!==void 0&&t.length===0?stripTerminalControls(e.text??``):t;n.text.set(e.id,r),this.#qt(e.id,r,!1);break}case`reasoning-delta`:{if(t.reasoning===`hidden`)break;let r=(n.reasoning.get(e.id)??``)+stripTerminalControls(e.delta);if(n.reasoning.set(e.id,r),t.reasoning===`full`){this.#Jt(e.id,r,!0,t);break}break}case`reasoning-complete`:{if(t.reasoning===`hidden`)break;let r=n.reasoning.get(e.id)??``;if(t.reasoning===`full`){this.#Jt(e.id,r,!1,t);break}break}case`tool-call-preparing`:if(t.tools===`hidden`||isPanelRoutedTool(e.toolName))break;this.#Yt({input:void 0,preparing:!0,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-call`:if(this.#d?.recordToolCall(e.toolName),t.tools===`hidden`)break;this.#Yt({input:e.input,status:`running`,toolCallId:e.toolCallId,toolName:e.toolName},t,n);break;case`tool-approval-request`:{if(t.tools===`hidden`)break;let r=n.tools.get(e.toolCallId);if(r===void 0)break;this.#Yt({...r,status:`approval`},t,n);break}case`tool-result`:{if(t.tools===`hidden`)break;let r=this.#nn(e.toolCallId,n);if(r===void 0)break;this.#Yt({...r,output:e.output,status:`done`},t,n);break}case`tool-error`:{let r=this.#nn(e.toolCallId,n);if(this.#d?.append({source:`tool`,summary:`${r?.toolName??e.toolCallId} failed`,detail:e.errorText}),t.tools===`hidden`||r===void 0)break;this.#Yt({...r,errorText:e.errorText,status:`error`},t,n);break}case`tool-rejected`:{if(t.tools===`hidden`)break;let r=this.#nn(e.toolCallId,n);if(r===void 0)break;this.#Yt({...r,errorText:e.reason,status:`denied`},t,n);break}case`error`:this.#Vt(`Error`,e.errorText,{detail:e.detail,hint:e.hint});break;case`turn-cancelled`:this.#Ie=!0,!this.#ze&&this.#Be!==void 0&&this.#V.text.length===0&&(this.#V=lineOf(this.#Be),this.renderNotice(`The turn was cancelled from outside this prompt — the message was restored to the input.`));break;case`finish`:this.#rn(e.usage),this.#in();break}}#qt(e,t,n){let r=stripTerminalControls(t).trim();r.length!==0&&(this.#Ut({id:e,kind:`assistant`,body:r,live:n}),this.#in())}#Jt(e,t,n,r){let i=stripTerminalControls(t).trim();i.length!==0&&(this.#Ut({id:e,kind:`reasoning`,body:i,collapsed:collapseReasoning(r.reasoning,n),live:n}),this.#in())}#Yt(e,t,n){if(n.tools.set(e.toolCallId,e),this.#v.has(e.toolCallId)||this.#en(e)||toolBaseName(e.toolName)===`ask_question`)return;let r=toolSectionId(e.toolCallId);this.#y.set(e.toolCallId,r);let i=this.#Xt(e);this.#Ut(renderNativeToolBlock(e,r,t.tools===`full`,i)),this.#tn(n),this.#in()}#Xt(e){e.output!==void 0&&this.#S.observeRead(e.output);let t={};this.#Zt(e.toolName)&&(t.isSubagent=!0);let n=readWriteFileInput(e.toolName,e.input);if(n===void 0)return t.isSubagent===!0?t:void 0;let r=this.#S.observeWrite({path:n.path,content:n.content,callId:e.toolCallId});r!==void 0&&(t.previousContent=r);let i=writeExistedFlag(e.output);return i!==void 0&&(t.existed=i),t}#Zt(e){let t=this.#w?.info?.subagents.local;if(t===void 0||t.length===0)return!1;let n=toolBaseName(e);return t.some(e=>e.name===n)}#Qt(){for(let e of this.#m)e.kind!==`tool`&&e.kind!==`subagent-tool`||e.status===`running`&&(e.status=`error`,e.result=`interrupted`,e.live=!1)}#$t(e){for(let[t,n]of e.tools){if(n.preparing!==!0)continue;e.tools.delete(t);let r=this.#y.get(t)??toolSectionId(t);this.#Wt(r),this.#y.delete(t)}}#en(e){let t=readTodoToolItems(e.toolName,e.input);if(t===void 0)return!1;if(t.length>0&&allTodoItemsSettled(t)){let e=JSON.stringify(t);this.#Ne!==e&&(this.#Ne=e,this.#Lt({kind:`todo-list`,body:renderFinishedTodoRows(t,this.#Cn(),this.#i).join(`
7
7
  `),live:!1})),this.#Me=void 0}else this.#Me=t.length>0?t:void 0,this.#Ne=void 0;return this.#in(),!0}#tn(e){let t=[];for(let n of e.tools.values()){if(this.#v.has(n.toolCallId))continue;let e=this.#y.get(n.toolCallId)??toolSectionId(n.toolCallId),r=this.#h.get(e);r?.kind===`tool`&&t.push({block:r,active:isActiveToolStatus(n.status)})}applyCohortLiveness(t)}#nn(e,t){let n=t.tools.get(e);if(n!==void 0)return n;let r=this.#y.get(e)??toolSectionId(e),i=this.#h.get(r);if(!(i===void 0||i.kind!==`tool`))return{errorText:i.status===`error`&&typeof i.result==`string`?i.result:void 0,input:i.toolInput,output:i.toolOutput,status:i.status??`running`,toolCallId:e,toolName:i.toolName??i.title??`tool`}}#rn(e){if(e===void 0)return;let{inputTokens:t,outputTokens:n}=e;if((t!=null||n!=null)&&(this.#ge=(t??0)+(n??0)),this.#_e=t??this.#_e,this.#ye=n??this.#ye,this.#ye!=null&&this.#xe!==void 0){let e=(Date.now()-this.#xe)/1e3;e>0&&(this.#be=this.#ye/e)}}#in(){if(this.#J){if(this.#me){this.#he=!0;return}this.#me=!0;try{do this.#he=!1,this.#an();while(this.#he)}finally{this.#me=!1}}}#an(){if(!this.#J)return;if(this.#Ue!==void 0){this.#Ue.repaint();return}let e=this.#Cn(),t=this.#mn(e),n=Math.max(1,this.#wn()-t.length),r=[],i=this.#O,a=groupToolBlocksForDisplay(this.#m),o=0;for(;o<a.length&&a[o].display.live===!1;)o+=1;if(o>0){let e=new Set(a.slice(0,o).flatMap(e=>e.members));for(let t=this.#m.length-1;t>=0;--t)e.has(this.#m[t])&&this.#m.splice(t,1)}for(let t of a.slice(0,o)){for(let e of t.members)this.#_.push(e),e.id&&(this.#g.add(e.id),this.#h.delete(e.id));if(this.#In(t.display))continue;let n=this.#un(t.display,e,i);i=previousBlockOf(t.display),this.#O=i,r.push(...n),this.#D.push(...n)}let s=[];for(let{display:t}of a.slice(o)){if(this.#In(t))continue;let n=this.#un(t,e,i);i=previousBlockOf(t);for(let e=0;e<n.length;e+=1)s.push({block:t,row:n[e]})}let c=[...clipLiveRows(s.map(e=>e.row),n,e,this.#i),...t];r.length>0?this.#n.flush(r,c):this.#n.update(c)}#on(){if(!this.#J)return;let e=this.#Cn(),t=this.#mn(e),n=Math.max(1,this.#wn()-t.length),r=this.#O,i=[];for(let{display:t}of groupToolBlocksForDisplay(this.#m)){if(this.#In(t))continue;let n=this.#un(t,e,r);r=previousBlockOf(t),i.push(...n)}let a=[...clipLiveRows(i,n,e,this.#i),...t];this.#n.clearAll(),this.#n.flush([...this.#ln(),...this.#D],a)}logDisplayMode(){return this.#p}setLogDisplayMode(e){e!==this.#p&&(this.#p=e,e===`all`&&this.flushDelayedDevBuildErrors(),this.#cn(),this.#J&&this.#on())}flushDelayedDevBuildErrors(){let e=this.#Te;e!==void 0&&(this.#Te=void 0,this.#Lt({kind:`log`,title:`stderr`,body:e,live:!0}),this.#in())}#sn(){this.#se=!0,this.#oe!==void 0&&clearTimeout(this.#oe),this.#oe=setTimeout(()=>{this.#se=!1,this.#oe=void 0,this.#in()},5e3),this.setLogDisplayMode(nextLogDisplayMode(this.#p)),this.#in()}#cn(){let e=this.#Cn();this.#D.length=0;let t;for(let{display:n}of groupToolBlocksForDisplay(this.#_,{logCoalescing:`runs`})){if(this.#In(n))continue;let r=this.#un(n,e,t);t=previousBlockOf(n),this.#D.push(...r)}this.#O=t}#ln(){let e=this.#w;if(e===void 0)return[];let t={name:e.name,theme:this.#i,width:this.#Cn()};return e.info!==void 0&&(t.info=e.info),e.tip!==void 0&&(t.tip=e.tip),buildAgentHeader(t)}#un(e,t,n){let r={activityPulse:this.#fn(this.#re,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)};n!==void 0&&(r.previous=n);let i=renderBlockLines(e,t,this.#i,r);return(e.depth??0)===0&&leadsWithGap(e,n)?[``,...i]:i}#dn(){return this.#i.spinner[this.#ne%this.#i.spinner.length]??``}#fn(e,t){return isProgressPulseVisible(Date.now()-e)?t:` `}#pn(e,t){return e.indicator.kind===`spinner`?{glyph:this.#dn(),color:`yellow`}:{glyph:this.#fn(e.indicator.startedAtMs,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),color:t?.kind===`external-action`?`yellow`:`green`}}#mn(e){let n=this.#i.colors,r=[``];if(this.#ke!==void 0)return r.push(...this.#ke(e),``),this.#bn(r,e),r;let a=this.#Ae;if(a!==void 0){let t=this.#pn(a,a.status),n;if(a.status!==void 0){let{startedAtMs:e,...r}=a.status,i=Date.now()-e,o=i>=5e3?` ${formatTurnDuration(i)}`:``;n={...r,text:`${r.text}${o}`,indicator:t}}let i;if(a.question!==void 0){let t=a.question(e);i={kind:`question`,rows:t},n!==void 0&&(i={kind:`question`,rows:t,status:n})}else n===void 0?i=a.preview===void 0?{kind:`idle`,indicator:t}:{kind:`preview`,text:a.preview,indicator:t}:(i={kind:`status`,status:n},a.preview!==void 0&&(i={kind:`status`,status:n,preview:a.preview}));let o={title:a.title,lines:a.hideLinesWhileQuestion===!0?[]:a.lines,content:i};return r.push(...renderFlowPanel(o,this.#i,e)),this.#xn(r,e),r}this.#je!==void 0&&r.push(...renderAttentionRows(this.#je,e,this.#i),``),this.#Me!==void 0&&r.push(...renderTodoPanelRows({items:this.#Me,width:e,theme:this.#i,working:this.#H||this.#U.kind===`waiting`,pulse:this.#fn(this.#re,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH)}),``);let o=renderMessageQueueRows({view:this.#Pe.view(),width:e,theme:this.#i,working:this.#H});if(o.length>0&&r.push(...o,``),this.#F){let i=this.#I===void 0?void 0:inlineCommandHint(this.#I);i===void 0&&this.#I!==void 0&&isTypeaheadOpen(this.#I)&&r.push(...renderCommandSuggestions(this.#I,this.#i,e)),this.#$&&r.push(clip(n.dim(`Press Ctrl+C again to exit`),e),``);let a=isPromptControlCommand(this.#M),o=i?n.dim(` ${i}`):``,s=[];this.#bn(s,e);let u=Math.max(1,this.#wn()-1-r.length-1-s.length),f={text:this.#M,cursor:this.#N,width:e,theme:this.#i,caretVisible:this.#te,isCommand:a,ghost:o,maxRows:u};return this.#L&&this.#M.length===0&&(f.placeholder=this.#z?``:promptPlaceholder(Date.now()-this.#R)),r.push(...promptInputRows(f)),r.push(...s),r}let s=this.#U.kind===`waiting`&&this.#K===void 0;if(this.#H||s){r.push(this.#hn(e)),this.#vn(r,e);let t=[];return this.#bn(t,e),!this.#H&&t.length>0&&r.push(``),r.push(...t),r}if(this.#V.text.length>0)return this.#yn(r,e,{inert:!1}),this.#bn(r,e),r;let u=this.#K??(this.#G.length>0?this.#G:`Ready`),f=this.#Sn(),p=n.dim(this.#i.glyph.dot),m=f?`${p} ${u} ${n.dim(this.#i.glyph.dot)} ${f}`:`${p} ${u}`;return r.push(clip(m,e)),this.#bn(r,e),r}#hn(e){let t=this.#i.colors,n=this.#fn(this.#re,this.#i.unicode?PROGRESS_PULSE_GLYPH:PROGRESS_PULSE_ASCII_GLYPH),r=this.#U,i=this.#B.startedAtMs??this.#xe??(r.kind===`waiting`?r.startedAtMs:Date.now()),a=Date.now()-i,o=`${typewriterText(`Working for`,a,80)} ${this.#gn(a)}`;return clip(`${t.yellow(n)} ${t.dim(o)}`,e)}#gn(e){return`${formatTurnDuration(e)}${this.#_n()}`}#_n(){let{inputTokens:e,outputTokens:t}=this.#B.usage;return e===0&&t===0?``:` ${this.#i.glyph.dash.repeat(2)} ${formatTokenFlow({inputTokens:e,outputTokens:t},this.#i.glyph)}`}#vn(e,t){this.#H&&this.#yn(e,t,{inert:!0})}#yn(e,t,n){e.push(``);let r={text:this.#V.text,cursor:this.#V.cursor,width:t,theme:this.#i,caretVisible:!0,isCommand:!1,ghost:``,maxRows:4,inert:n.inert};n.inert&&this.#V.text.length===0&&(r.placeholder=``),e.push(...promptInputRows(r))}#bn(e,t){let n=this.#j===void 0?``:` `,r=Math.max(1,t-n.length),i={theme:this.#i,width:r};this.#se&&(i.logLevel=this.#p);let a=this.#w?.serverUrl;if(a!==void 0&&this.#j===void 0){let e=new URL(a).port;e.length>0&&(i.serverPort=e)}let o=this.#w?.info?.agent.model;o?.id!==void 0&&(i.model=o.id),o?.reasoning!==void 0&&o.reasoning!==`provider-default`&&(i.reasoning=o.reasoning),readGatewayServiceTier(o?.providerOptions).kind===`priority`&&(i.fastMode=!0);let s=o?.endpoint;s!==void 0&&(i.endpoint=s),this.#A!==void 0&&(i.vercel=this.#A),this.#j!==void 0&&(i.remote=this.#j);let c=buildStatusLine(i);c!==void 0&&e.push(clip(`${n}${c}`,t))}#xn(e,t){if(this.#j===void 0)return;let n=Math.max(1,t-2),r=buildStatusLine({remote:this.#j,theme:this.#i,width:n});r!==void 0&&e.push(``,clip(` ${r}`,t))}#Sn(){let e=this.#i.colors,t=[],n=formatAssistantResponseStats({totalTokens:this.#ge,outputTokens:this.#ye,tokensPerSecond:this.#be},this.#l);return n&&t.push(n),t.length>0?e.dim(t.join(` ${this.#i.glyph.dot} `)):``}#Cn(){return Math.max(20,this.#t.columns||80)}#wn(){return Math.max(8,this.#t.rows||24)}#Tn(){if(this.#Se!==void 0||!this.#u)return;this.#Ce=``,this.#we=``;let capture=(e,t)=>{let n=e.write.bind(e);return e.write=((e,n,r)=>{let i=typeof n==`string`?n:void 0,a=typeof n==`function`?n:r;return this.#On(t,chunkToString(e,i)),a?.(),!0}),()=>{e.write=n}},e=capture(process.stdout,`stdout`),t=capture(process.stderr,`stderr`);this.#d?.subscribeLogRecords(e=>this.#Dn(e)),this.#Se=()=>{this.#d?.unsubscribeLogRecords(),e(),t()}}#En(){let e=this.#Se;e!==void 0&&(this.#Se=void 0,e(),this.#Ce.length>0&&(this.#d?.append({source:`stdout`,detail:this.#Ce}),this.#Fn(`stdout`)&&process.stdout.write(`${this.#Ce}\n`),this.#Ce=``),this.#we.length>0&&(this.#d?.append({source:`stderr`,detail:this.#we}),this.#Fn(`stderr`)&&process.stderr.write(`${this.#we}\n`),this.#we=``))}#Dn(e){let t=e.fields===void 0?``:` ${JSON.stringify(e.fields)}`;this.#An(`[eve:${e.namespace}] ${e.message}${t}`),this.#in()}#On(e,t){let n=(e===`stdout`?this.#Ce:this.#we)+t;if(e===`stdout`&&parseDevRebuildLogLine(n.trimEnd())!==void 0){this.#Ce=``,this.#d?.append({source:e,detail:n.trimEnd()}),this.#kn(n.trimEnd()),this.#in();return}let r=n.lastIndexOf(`
8
8
  `),i=r===-1?n:n.slice(r+1);if(e===`stdout`?this.#Ce=i:this.#we=i,r===-1)return;let a=stripAnsi(n.slice(0,r)).replace(/\s+$/u,``);a.trim().length!==0&&(this.#d?.append({source:e,detail:a}),e===`stdout`?this.#kn(a):this.#An(a),this.#in())}#kn(e){let t=[],flushPending=()=>{if(t.length===0)return;let e=t.join(`
9
9
  `);t=[],e.trim().length!==0&&this.#Lt({kind:`log`,title:`stdout`,body:e,live:!0})};for(let n of e.split(`
@@ -305,6 +305,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
305
305
  dynamicInstructions: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicInstructionsDefinition, unknown>>>>;
306
306
  dynamicSkills: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicSkillDefinition, unknown>>>>;
307
307
  dynamicTools: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicToolDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicToolDefinition, unknown>>>>;
308
+ extensionMounts: z.ZodDefault<z.ZodArray<z.ZodType<CompiledExtensionMount, unknown, z.core.$ZodTypeInternals<CompiledExtensionMount, unknown>>>>;
308
309
  hooks: z.ZodArray<z.ZodType<CompiledHookDefinition, unknown, z.core.$ZodTypeInternals<CompiledHookDefinition, unknown>>>;
309
310
  sandbox: z.ZodNullable<z.ZodObject<{
310
311
  backendName: z.ZodOptional<z.ZodString>;
@@ -367,7 +368,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
367
368
  }, z.core.$strict>;
368
369
  }, z.core.$strict>;
369
370
  /**
370
- * One mounted extension recorded on the root compiled manifest. The runtime
371
+ * One mounted extension recorded on a compiled agent manifest. The runtime
371
372
  * evaluates {@link mountLogicalPath} at module-map load so the mount's factory
372
373
  * call binds the extension's config before any tool runs.
373
374
  */
@@ -509,6 +510,7 @@ export declare function createCompiledAgentNodeManifest(input: {
509
510
  readonly dynamicInstructions?: readonly CompiledDynamicInstructionsDefinition[];
510
511
  readonly dynamicSkills?: readonly CompiledDynamicSkillDefinition[];
511
512
  readonly dynamicTools?: readonly CompiledDynamicToolDefinition[];
513
+ readonly extensionMounts?: readonly CompiledExtensionMount[];
512
514
  readonly hooks?: readonly CompiledHookDefinition[];
513
515
  readonly remoteAgents?: readonly CompiledRemoteAgentNode[];
514
516
  readonly sandbox?: CompiledSandboxDefinition | null;
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=39,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),sessionTimeoutSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional(),sessionTimeoutMs:sessionTimeoutSchema.optional()}).strict(),compiledWorkflowToolDefinitionSchema=z.object({maxSubagents:z.number().int().positive().optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({subagentPersistentSessions:z.boolean().optional(),workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSubagentNodeBaseFields={agent:z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),webSearchProvider:z.enum([`exa`,`parallel`]).optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()},compiledDynamicSubagentDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly()}).strict(),compiledSubagentNodeSchema=z.union([z.object({...compiledSubagentNodeBaseFields,description:z.string()}).strict(),z.object({...compiledSubagentNodeBaseFields,dynamic:compiledDynamicSubagentDefinitionSchema}).strict()]),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledExtensionMountSchema=z.object({namespace:z.string(),packageName:z.string(),packageNamespace:z.string(),sourceRoot:z.string(),mountSourceId:z.string(),mountLogicalPath:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),extensionMounts:z.array(compiledExtensionMountSchema).default([]),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),webSearchProvider:z.enum([`exa`,`parallel`]).optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(39),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{subagentPersistentSessions:e.config.experimental.subagentPersistentSessions,workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowTool:e.workflowTool===void 0?void 0:{maxSubagents:e.workflowTool.maxSubagents},webSearchProvider:e.webSearchProvider,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,extensionMounts:[...e.extensionMounts??[]],subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:39}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
1
+ import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=39,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),sessionTimeoutSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional(),sessionTimeoutMs:sessionTimeoutSchema.optional()}).strict(),compiledWorkflowToolDefinitionSchema=z.object({maxSubagents:z.number().int().positive().optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({subagentPersistentSessions:z.boolean().optional(),workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledExtensionMountSchema=z.object({namespace:z.string(),packageName:z.string(),packageNamespace:z.string(),sourceRoot:z.string(),mountSourceId:z.string(),mountLogicalPath:z.string()}).strict(),compiledSubagentNodeBaseFields={agent:z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),webSearchProvider:z.enum([`exa`,`parallel`]).optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),extensionMounts:z.array(compiledExtensionMountSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()},compiledDynamicSubagentDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly()}).strict(),compiledSubagentNodeSchema=z.union([z.object({...compiledSubagentNodeBaseFields,description:z.string()}).strict(),z.object({...compiledSubagentNodeBaseFields,dynamic:compiledDynamicSubagentDefinitionSchema}).strict()]),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),extensionMounts:z.array(compiledExtensionMountSchema).default([]),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),webSearchProvider:z.enum([`exa`,`parallel`]).optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(39),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{subagentPersistentSessions:e.config.experimental.subagentPersistentSessions,workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowTool:e.workflowTool===void 0?void 0:{maxSubagents:e.workflowTool.maxSubagents},webSearchProvider:e.webSearchProvider,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],extensionMounts:[...e.extensionMounts??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,extensionMounts:[...e.extensionMounts??[]],subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:39}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
@@ -1,3 +1,3 @@
1
- import{compileChannelDefinition}from"#compiler/normalize-channel.js";import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest,createCompiledAgentNodeManifest}from"#compiler/manifest.js";import{compileConnectionDefinition}from"#compiler/normalize-connection.js";import{compileHookEntry}from"#compiler/normalize-hook.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{mountRefNamespace,packageStateNamespace}from"#discover/extensions.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{compileAgentConfig}from"#compiler/normalize-agent-config.js";import{compileExtensionContributions}from"#compiler/normalize-extension.js";import{compileSandboxDefinition}from"#compiler/normalize-sandbox.js";import{compileScheduleDefinition}from"#compiler/normalize-schedule.js";import{compileSubagentGraph}from"#compiler/normalize-subagent.js";async function compileAgentManifest(e){let r={modelCatalog:createCompiledRuntimeModelCatalogLoader(e.appRoot)},i=await compileAgentNodeManifest(e,r),a=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest,context:r,externalDependencies:i.config.build?.externalDependencies??[],parentNodeId:ROOT_COMPILED_AGENT_NODE_ID,subagents:e.subagents}),o=e.resolvedExtensions.map(t=>{let n=e.extensions.find(e=>mountRefNamespace(e.logicalPath)===t.namespace);return{namespace:t.namespace,packageName:t.packageName,packageNamespace:packageStateNamespace(t.packageName),sourceRoot:t.sourceRoot,mountSourceId:n?.sourceId??`extensions/${t.namespace}`,mountLogicalPath:n?.logicalPath??`extensions/${t.namespace}`}});return createCompiledAgentManifest({...i,extensionMounts:o,remoteAgents:a.remoteAgents,subagentEdges:a.edges,subagents:a.nodes})}async function compileAgentNodeManifest(t,n,s={}){let c=Object.hasOwn(s,`agentConfigDefinition`)?await compileAgentConfig(t,n,{definition:s.agentConfigDefinition}):await compileAgentConfig(t,n);if(s.allowWorkflowConfig===!1&&c.experimental?.workflow!==void 0)throw Error(`Workflow runtime configuration is only supported on the root agent config. Remove "experimental.workflow" from "${t.agentId}".`);let l=mergeExternalDependencies(s.externalDependencies,c.build?.externalDependencies),u=l.length===0?c:{...c,build:{...c.build,externalDependencies:l}},d=await Promise.all(t.tools.map(e=>compileToolEntry(t.agentRoot,e,{externalDependencies:l}))),f=[],p=[],m=[],h,g;for(let e of d)e.kind===`tool`?f.push(e.definition):e.kind===`dynamic-tool`?p.push(e.definition):e.kind===`workflow-tool`?h={maxSubagents:e.maxSubagents}:e.kind===`web-search-tool`?g=e.provider:m.push(e.name);let _=(await Promise.all(t.channels.map(n=>compileChannelDefinition(t.agentRoot,n,{externalDependencies:l})))).flat(),v=await Promise.all(t.skills.map(e=>compileSkillSource(t.agentRoot,e,{externalDependencies:l}))),y=[],b=[];for(let e of v)e.kind===`skill`?y.push(e.definition):b.push(e.definition);let x=await Promise.all(t.instructions.map(e=>compileInstructionsEntry(t.agentRoot,e,{externalDependencies:l}))),S=[],C=[];for(let e of x)e.kind===`instructions`?S.push(e.definition):C.push(e.definition);let w=await Promise.all(t.connections.map(e=>compileConnectionDefinition(t.agentRoot,e,{externalDependencies:l}))),T=t.hooks.map(e=>compileHookEntry(e)),E=await Promise.all(t.schedules.map(e=>compileScheduleDefinition(t.agentRoot,e,{externalDependencies:l}))),D=new Set(f.map(e=>e.name)),O=new Set(p.map(e=>e.slug)),k=new Set(w.map(e=>e.connectionName)),A=new Set(y.map(e=>e.name)),j=[];for(let e of[...t.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let r=await compileExtensionContributions({mount:e,context:n,consumerAgentRoot:t.agentRoot,externalDependencies:l});for(let e of r.tools)D.has(e.name)||(D.add(e.name),f.push(e));for(let e of r.dynamicTools)O.has(e.slug)||(O.add(e.slug),p.push(e));for(let e of r.connections)k.has(e.connectionName)||(k.add(e.connectionName),w.push(e));for(let e of r.skills)A.has(e.name)||(A.add(e.name),y.push(e));T.push(...r.hooks),b.push(...r.dynamicSkills),C.push(...r.dynamicInstructions),j.push(...r.instructionFragments)}let M=[...S.map(e=>e.markdown),...j],N=M.length===0?void 0:S.length===1&&j.length===0?S[0]:{name:`instructions`,logicalPath:`instructions`,markdown:M.join(`
1
+ import{compileChannelDefinition}from"#compiler/normalize-channel.js";import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest,createCompiledAgentNodeManifest}from"#compiler/manifest.js";import{compileConnectionDefinition}from"#compiler/normalize-connection.js";import{compileHookEntry}from"#compiler/normalize-hook.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{mountRefNamespace,packageStateNamespace}from"#discover/extensions.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{compileAgentConfig}from"#compiler/normalize-agent-config.js";import{compileExtensionContributions}from"#compiler/normalize-extension.js";import{compileSandboxDefinition}from"#compiler/normalize-sandbox.js";import{compileScheduleDefinition}from"#compiler/normalize-schedule.js";import{compileSubagentGraph}from"#compiler/normalize-subagent.js";async function compileAgentManifest(e){let r={modelCatalog:createCompiledRuntimeModelCatalogLoader(e.appRoot)},i=await compileAgentNodeManifest(e,r),a=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest,context:r,externalDependencies:i.config.build?.externalDependencies??[],parentNodeId:ROOT_COMPILED_AGENT_NODE_ID,subagents:e.subagents});return createCompiledAgentManifest({...i,extensionMounts:i.extensionMounts,remoteAgents:a.remoteAgents,subagentEdges:a.edges,subagents:a.nodes})}async function compileAgentNodeManifest(t,n,o={}){let s=Object.hasOwn(o,`agentConfigDefinition`)?await compileAgentConfig(t,n,{definition:o.agentConfigDefinition}):await compileAgentConfig(t,n);if(o.allowWorkflowConfig===!1&&s.experimental?.workflow!==void 0)throw Error(`Workflow runtime configuration is only supported on the root agent config. Remove "experimental.workflow" from "${t.agentId}".`);let c=mergeExternalDependencies(o.externalDependencies,s.build?.externalDependencies),l=c.length===0?s:{...s,build:{...s.build,externalDependencies:c}},u=await Promise.all(t.tools.map(e=>compileToolEntry(t.agentRoot,e,{externalDependencies:c}))),d=[],f=[],p=[],m,h;for(let e of u)e.kind===`tool`?d.push(e.definition):e.kind===`dynamic-tool`?f.push(e.definition):e.kind===`workflow-tool`?m={maxSubagents:e.maxSubagents}:e.kind===`web-search-tool`?h=e.provider:p.push(e.name);let g=(await Promise.all(t.channels.map(n=>compileChannelDefinition(t.agentRoot,n,{externalDependencies:c})))).flat(),_=await Promise.all(t.skills.map(e=>compileSkillSource(t.agentRoot,e,{externalDependencies:c}))),v=[],y=[];for(let e of _)e.kind===`skill`?v.push(e.definition):y.push(e.definition);let b=await Promise.all(t.instructions.map(e=>compileInstructionsEntry(t.agentRoot,e,{externalDependencies:c}))),x=[],S=[];for(let e of b)e.kind===`instructions`?x.push(e.definition):S.push(e.definition);let C=await Promise.all(t.connections.map(e=>compileConnectionDefinition(t.agentRoot,e,{externalDependencies:c}))),w=t.hooks.map(e=>compileHookEntry(e)),T=await Promise.all(t.schedules.map(e=>compileScheduleDefinition(t.agentRoot,e,{externalDependencies:c}))),E=new Set(d.map(e=>e.name)),D=new Set(f.map(e=>e.slug)),O=new Set(C.map(e=>e.connectionName)),k=new Set(v.map(e=>e.name)),A=[];for(let e of[...t.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let r=await compileExtensionContributions({mount:e,context:n,consumerAgentRoot:t.agentRoot,externalDependencies:c});for(let e of r.tools)E.has(e.name)||(E.add(e.name),d.push(e));for(let e of r.dynamicTools)D.has(e.slug)||(D.add(e.slug),f.push(e));for(let e of r.connections)O.has(e.connectionName)||(O.add(e.connectionName),C.push(e));for(let e of r.skills)k.has(e.name)||(k.add(e.name),v.push(e));w.push(...r.hooks),y.push(...r.dynamicSkills),S.push(...r.dynamicInstructions),A.push(...r.instructionFragments)}let j=[...x.map(e=>e.markdown),...A],M=j.length===0?void 0:x.length===1&&A.length===0?x[0]:{name:`instructions`,logicalPath:`instructions`,markdown:j.join(`
2
2
 
3
- `),sourceId:S[0]?.sourceId??`instructions`,sourceKind:`module`};return createCompiledAgentNodeManifest({agentRoot:t.agentRoot,appRoot:t.appRoot,channels:_,config:u,connections:w,diagnosticsSummary:t.diagnosticsSummary,disabledFrameworkTools:m,workflowTool:h,webSearchProvider:g,dynamicSkills:b,dynamicTools:p,hooks:T,sandbox:t.sandbox===null?null:await compileSandboxDefinition(t.agentRoot,t.sandbox,{externalDependencies:l}),sandboxWorkspaces:t.sandboxWorkspaces.map(e=>({logicalPath:e.logicalPath,rootEntries:[...e.rootEntries],sourceId:e.sourceId,sourcePath:e.sourcePath})),schedules:E,dynamicInstructions:C,skills:y,instructions:N,tools:f})}function mergeExternalDependencies(...e){let t=new Set;for(let n of e)for(let e of n??[])t.add(e);return[...t]}export{compileAgentManifest};
3
+ `),sourceId:x[0]?.sourceId??`instructions`,sourceKind:`module`};return createCompiledAgentNodeManifest({agentRoot:t.agentRoot,appRoot:t.appRoot,channels:g,extensionMounts:compileExtensionMounts(t),config:l,connections:C,diagnosticsSummary:t.diagnosticsSummary,disabledFrameworkTools:p,workflowTool:m,webSearchProvider:h,dynamicSkills:y,dynamicTools:f,hooks:w,sandbox:t.sandbox===null?null:await compileSandboxDefinition(t.agentRoot,t.sandbox,{externalDependencies:c}),sandboxWorkspaces:t.sandboxWorkspaces.map(e=>({logicalPath:e.logicalPath,rootEntries:[...e.rootEntries],sourceId:e.sourceId,sourcePath:e.sourcePath})),schedules:T,dynamicInstructions:S,skills:v,instructions:M,tools:d})}function compileExtensionMounts(e){return e.resolvedExtensions.map(t=>{let n=e.extensions.find(e=>mountRefNamespace(e.logicalPath)===t.namespace);return{namespace:t.namespace,packageName:t.packageName,packageNamespace:packageStateNamespace(t.packageName),sourceRoot:t.sourceRoot,mountSourceId:n?.sourceId??`extensions/${t.namespace}`,mountLogicalPath:n?.logicalPath??`extensions/${t.namespace}`}})}function mergeExternalDependencies(...e){let t=new Set;for(let n of e)for(let e of n??[])t.add(e);return[...t]}export{compileAgentManifest};
@@ -1 +1 @@
1
- import{expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel}from"#shared/dynamic-tool-definition.js";import{createPathDerivedSourceId}from"#discover/manifest.js";const ALLOWED_DYNAMIC_SUBAGENT_EVENTS=new Set([`session.started`,`turn.started`]);async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t}),i=normalizeDynamicSubagentDefinition(r,`Expected the dynamic subagent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`);return i===void 0&&readAgentDefinitionKind(r)===`remote`?{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})}:{kind:`local`,...await compileLocalSubagent({...e,agentConfigDefinition:i===void 0?r:{model:DEFAULT_AGENT_MODEL_ID},dynamic:i?.definition})}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{agentConfigDefinition:e.agentConfigDefinition,allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description,a;if(e.dynamic!==void 0)a={dynamic:e.dynamic};else{if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);a={description:i}}let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},...a,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function normalizeDynamicSubagentDefinition(e,i){if(!isDynamicSentinel(e))return;let a=expectObjectRecord(e,i);if(Object.hasOwn(a,`fallback`))throw Error(`${i} Dynamic subagent definitions do not support "fallback". Return defineAgent(...) or defineRemoteAgent(...) from an event handler instead.`);expectOnlyKnownKeys(a,[`events`,`kind`],i);let o=expectObjectRecord(a.events,i),s=[];for(let[e,n]of Object.entries(o)){if(!ALLOWED_DYNAMIC_SUBAGENT_EVENTS.has(e))throw Error(`${i} Dynamic subagents support only "session.started" and "turn.started" handlers.`);expectFunction(n,i),s.push(e)}return{definition:{eventNames:s}}}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(t,o){let c=expectObjectRecord(t,o);if(expectOnlyKnownKeys(c,[`auth`,`description`,`forwardPrincipal`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),c.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return c.forwardPrincipal!==void 0&&expectBoolean(c.forwardPrincipal,`${o} Expected "forwardPrincipal" to be a boolean.`),{description:expectString(c.description,o),outputSchema:serializeOutputSchema(c.outputSchema),path:c.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(c.path,o),url:typeof c.url==`function`?void 0:expectString(c.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
1
+ import{expectBoolean,expectFunction,expectObjectRecord,expectOnlyKnownKeys,expectString}from"#internal/authored-module.js";import{EVE_CREATE_SESSION_ROUTE_PATH}from"#protocol/routes.js";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{createCompiledSubagentNodeId}from"#compiler/manifest.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{isDynamicSentinel}from"#shared/dynamic-tool-definition.js";import{createPathDerivedSourceId}from"#discover/manifest.js";const ALLOWED_DYNAMIC_SUBAGENT_EVENTS=new Set([`session.started`,`turn.started`]);async function compileSubagentGraph(e){let t=[],n=[],r=[];for(let i of e.subagents){let a=await compileSubagentDefinition({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:e.externalDependencies,parentNodeId:e.parentNodeId,source:i});if(a.kind===`remote`){r.push(a.node);continue}t.push(a.node,...a.descendants.nodes),n.push({childNodeId:a.node.nodeId,parentNodeId:e.parentNodeId},...a.descendants.edges)}return{edges:n,nodes:t,remoteAgents:r}}async function compileSubagentDefinition(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Subagent "${e.source.logicalPath}" is missing an agent config module.`);let n=createSubagentConfigModuleSourceRef(e.source,t),r=await loadModuleBackedDefinition({agentRoot:e.source.manifest.agentRoot,displayPath:n.logicalPath,externalDependencies:e.externalDependencies,kind:`subagent config`,source:t}),i=normalizeDynamicSubagentDefinition(r,`Expected the dynamic subagent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`);if(i===void 0&&readAgentDefinitionKind(r)===`remote`)return{kind:`remote`,node:compileRemoteAgent({source:e.source,value:r})};let a=r;if(i!==void 0){let e={model:DEFAULT_AGENT_MODEL_ID};i.build!==void 0&&(e.build=i.build),a=e}return{kind:`local`,...await compileLocalSubagent({...e,agentConfigDefinition:a,dynamic:i?.definition})}}async function compileSubagent(e){let t=createCompiledSubagentNodeId(e.parentNodeId,e.source.sourceId),n=e.source.subagentId,r=await e.compileAgentNodeManifest({...e.source.manifest,appRoot:e.appRoot},e.context,{agentConfigDefinition:e.agentConfigDefinition,allowWorkflowConfig:!1,externalDependencies:e.externalDependencies}),i=r.config.description,a;if(e.dynamic!==void 0)a={dynamic:e.dynamic};else{if(!i)throw Error(`Local subagent "${e.source.logicalPath}" is missing a "description" field on its agent config. Add \`description\` to \`defineAgent({ ... })\` so the parent agent can decide when to delegate to this subagent.`);a={description:i}}let o=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest:e.compileAgentNodeManifest,context:e.context,externalDependencies:r.config.build?.externalDependencies,parentNodeId:t,subagents:e.source.manifest.subagents});return{descendants:o,node:{agent:{...r,remoteAgents:[...o.remoteAgents]},...a,entryPath:e.source.entryPath,logicalPath:e.source.logicalPath,name:n,nodeId:t,rootPath:e.source.rootPath,sourceId:e.source.sourceId,sourceKind:`module`}}}const compileLocalSubagent=compileSubagent;function compileRemoteAgent(e){let t=e.source.manifest.configModule;if(t===void 0)throw Error(`Remote agent "${e.source.logicalPath}" is missing a config module.`);assertRemoteAgentDefinitionHasNoLocalPackageEntries(e.source);let n=createSubagentConfigModuleSourceRef(e.source,t),r=normalizeRemoteAgentDefinition(e.value,`Expected the remote agent config export "${t.exportName??`default`}" from "${n.logicalPath}" to match the public eve shape.`),i={...n,description:r.description,entryPath:e.source.entryPath,name:e.source.subagentId,nodeId:e.source.sourceId,outputSchema:r.outputSchema,path:r.path,rootPath:e.source.rootPath};return r.url===void 0?i:{...i,url:r.url}}function normalizeDynamicSubagentDefinition(e,i){if(!isDynamicSentinel(e))return;let a=expectObjectRecord(e,i);if(Object.hasOwn(a,`fallback`))throw Error(`${i} Dynamic subagent definitions do not support "fallback". Return defineAgent(...) or defineRemoteAgent(...) from an event handler instead.`);expectOnlyKnownKeys(a,[`build`,`events`,`kind`],i);let s=a.build===void 0?void 0:normalizeAgentDefinition({build:a.build,model:DEFAULT_AGENT_MODEL_ID},i).build,c=expectObjectRecord(a.events,i),l=[];for(let[e,n]of Object.entries(c)){if(!ALLOWED_DYNAMIC_SUBAGENT_EVENTS.has(e))throw Error(`${i} Dynamic subagents support only "session.started" and "turn.started" handlers.`);expectFunction(n,i),l.push(e)}let u={definition:{eventNames:l}};return s!==void 0&&(u.build=s),u}function createSubagentConfigModuleSourceRef(e,t){let n=e.logicalPath===t.logicalPath?t.logicalPath:`${e.logicalPath}/${t.logicalPath}`,r={logicalPath:n,sourceId:createPathDerivedSourceId(n),sourceKind:`module`};return t.exportName!==void 0&&(r.exportName=t.exportName),r}function readAgentDefinitionKind(e){return typeof e!=`object`||!e?`local`:e.kind===`remote`?`remote`:`local`}function normalizeRemoteAgentDefinition(t,o){let c=expectObjectRecord(t,o);if(expectOnlyKnownKeys(c,[`auth`,`description`,`forwardPrincipal`,`headers`,`kind`,`outputSchema`,`path`,`url`],o),c.kind!==`remote`)throw Error(`${o} Expected "kind" to be "remote".`);return c.forwardPrincipal!==void 0&&expectBoolean(c.forwardPrincipal,`${o} Expected "forwardPrincipal" to be a boolean.`),{description:expectString(c.description,o),outputSchema:serializeOutputSchema(c.outputSchema),path:c.path===void 0?EVE_CREATE_SESSION_ROUTE_PATH:expectString(c.path,o),url:typeof c.url==`function`?void 0:expectString(c.url,o)}}function assertRemoteAgentDefinitionHasNoLocalPackageEntries(e){let t=e.manifest,n=[t.connections.length>0?`connections/`:void 0,t.hooks.length>0?`hooks/`:void 0,t.instructions.length>0?`instructions`:void 0,t.lib.length>0?`lib/`:void 0,t.sandbox===null?void 0:`sandbox/`,t.sandboxWorkspaces.length>0?`sandbox/workspace/`:void 0,t.schedules.length>0?`schedules/`:void 0,t.skills.length>0?`skills/`:void 0,t.subagents.length>0?`subagents/`:void 0,t.tools.length>0?`tools/`:void 0].filter(e=>e!==void 0);if(n.length!==0)throw Error(`Remote subagent definition "${e.logicalPath}" cannot include local package entries. Remove unsupported entries: ${n.join(`, `)}.`)}export{compileSubagentGraph};
@@ -1,5 +1,5 @@
1
1
  import { type DiscoverDiagnostic } from "#discover/diagnostics.js";
2
- import { type AgentSourceManifest, type ExtensionSourceRef } from "#discover/manifest.js";
2
+ import { type AgentSourceManifest, type ExtensionSourceRef, type ResolvedExtensionMount } from "#discover/manifest.js";
3
3
  import { type ProjectSource } from "#discover/project-source.js";
4
4
  /**
5
5
  * Input for discovering the authored agent source graph from resolved roots.
@@ -39,6 +39,16 @@ export declare function discoverAgent(input: DiscoverAgentInput): Promise<Discov
39
39
  * file form (`extensions/crm.ts`) or the directory form
40
40
  * (`extensions/crm/extension.ts` with optional override slots).
41
41
  */
42
+ /** Resolves extension declarations into their discovered source manifests. */
43
+ export declare function resolveExtensionMounts(input: {
44
+ readonly agentRoot: string;
45
+ readonly appRoot: string;
46
+ readonly mounts: readonly ExtensionMountDescriptor[];
47
+ readonly source: ProjectSource;
48
+ }): Promise<{
49
+ readonly diagnostics: readonly DiscoverDiagnostic[];
50
+ readonly mounts: readonly ResolvedExtensionMount[];
51
+ }>;
42
52
  export interface ExtensionMountDescriptor {
43
53
  /** Mount namespace prefixed onto every composed contribution. */
44
54
  readonly namespace: string;
@@ -62,4 +72,17 @@ export declare function discoverExtensionMountDeclarations(input: {
62
72
  diagnostics: DiscoverDiagnostic[];
63
73
  mounts: ExtensionMountDescriptor[];
64
74
  }>;
75
+ /**
76
+ * Flags agent-root contributions whose composed name uses a mounted extension's
77
+ * `<ns>__` prefix. That prefix is reserved for the extension and its co-located
78
+ * overrides, so a root-level `<ns>__…` file would override the extension from
79
+ * outside its mount directory — rejected here.
80
+ */
81
+ export declare function detectRootNamespaceCollisions(input: {
82
+ readonly agentRoot: string;
83
+ readonly namespaces: readonly string[];
84
+ readonly sources: ReadonlyArray<{
85
+ readonly logicalPath: string;
86
+ }>;
87
+ }): DiscoverDiagnostic[];
65
88
  export {};
@@ -1 +1 @@
1
- import{join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,mountNamespace}from"#discover/extensions.js";import{createAgentSourceManifest,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_EXTENSIONS_DIRECTORY_INVALID,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createChannelNameDiagnostic,createExtensionNameDiagnostic,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverSubagents}from"#discover/discover-subagent.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverScheduleSources}from"#discover/schedules.js";import{discoverSkills}from"#discover/skills.js";import{stripNpmPackageScope}from"#shared/package-name.js";async function discoverAgent(r){let a=r.source??createDiskProjectSource(),c=resolve(r.appRoot),l=resolve(r.agentRoot),d=r.role??`agent`,h=[],g=await tryReadPackageJsonName(a,c),_=await readSortedDirectoryEntries(a,l);h.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyAgentRootEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the agent root.`},rootEntries:_,rootPath:l}));let v=await discoverInstructionsSource({rootEntries:_,rootPath:l,source:a,required:d!==`extension`});h.push(...v.diagnostics);let y=discoverFlatModuleSource({rootEntries:_,rootPath:l,slotName:`agent`});h.push(...y.diagnostics);let b=await discoverNamedSourceDirectory({directoryName:`channels`,invalidDirectoryCode:DISCOVER_CHANNELS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`channels`)}" to be a directory of authored channels.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createChannelNameDiagnostic});h.push(...b.diagnostics);let x=await discoverLibSources({agentRoot:l,rootEntries:_,source:a});h.push(...x.diagnostics);let S=await discoverScheduleSources({agentRoot:l,rootEntries:_,source:a});h.push(...S.diagnostics);let C=await discoverConnectionSources({rootEntries:_,rootPath:l,source:a});h.push(...C.diagnostics);let w=await discoverSandboxSource({rootEntries:_,rootPath:l,source:a});if(h.push(...w.diagnostics),d===`extension`){y.module!==void 0&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,message:`An extension may not declare agent config (agent.ts) — model, limits, and sandbox are the consuming agent's to own.`,sourcePath:join(l,y.module.logicalPath)})),w.sandbox!==null&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,message:`An extension may not declare a sandbox — it is the consuming agent's to own.`,sourcePath:join(l,w.sandbox.logicalPath)}));let[t]=S.schedules;t!==void 0&&h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,message:`An extension may not declare schedules — background scheduling runs on the consuming agent's deployment under its limits, so it is the consuming agent's to own.`,sourcePath:join(l,t.logicalPath)}))}let T=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createToolNameDiagnostic});h.push(...T.diagnostics);let E=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:_,rootPath:l,source:a,validateSegment:createHookNameDiagnostic});h.push(...E.diagnostics);let D=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:_,rootPath:l,source:a,validateSegment:createExtensionNameDiagnostic});h.push(...D.diagnostics);let O=await discoverSkills({agentRoot:l,source:a});h.push(...O.diagnostics);let k=await discoverSubagents({agentRoot:l,appRoot:c,source:a});h.push(...k.diagnostics);let A=await collectExtensionMounts({agentRoot:l,fileMounts:D.sources,rootEntries:_,source:a});h.push(...A.diagnostics),h.push(...detectRootNamespaceCollisions({agentRoot:l,namespaces:A.mounts.map(e=>e.namespace),sources:[...T.sources,...C.connections,...O.skills,...S.schedules]}));let j=[];if(d!==`agent`)for(let t of A.mounts)h.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,message:`"${t.mountRef.logicalPath}" mounts an extension from inside an extension, which is not supported yet. Extensions cannot mount other extensions; remove the "extensions/" slot.`,sourcePath:join(l,t.mountRef.logicalPath)}));else for(let e of A.mounts){let t=await locateExtensionMount({source:a,agentRoot:l,appRoot:c,mount:e.mountRef,namespace:e.namespace});if(h.push(...t.diagnostics),t.location===void 0)continue;let n=await discoverAgent({agentRoot:t.location.sourceRoot,appRoot:t.location.packageRoot,source:a,role:`extension`});h.push(...n.diagnostics);let r;if(e.overridesRoot!==void 0){let t=await discoverAgent({agentRoot:e.overridesRoot,appRoot:c,source:a,role:`extension`});h.push(...t.diagnostics),r=t.manifest}let i={namespace:t.location.namespace,specifier:t.location.specifier,packageName:t.location.packageName,packageRoot:t.location.packageRoot,sourceRoot:t.location.sourceRoot,manifest:n.manifest};r!==void 0&&(i.overrides=r),j.push(i)}let M={agentRoot:l,appRoot:c,channels:b.sources,connections:C.connections,packageName:g,diagnostics:h,extensions:A.mounts.map(e=>e.mountRef),resolvedExtensions:j,hooks:E.sources,lib:x.lib,instructions:v.instructions,sandbox:w.sandbox,sandboxWorkspaces:w.sandboxWorkspace===null?[]:[w.sandboxWorkspace],schedules:S.schedules,skills:O.skills,tools:T.sources,subagents:k.subagents};return y.module!==void 0&&(M.configModule=y.module),{diagnostics:h,manifest:createAgentSourceManifest(M)}}async function discoverExtensionMountDeclarations(n){let r=n.source??createDiskProjectSource(),i=resolve(n.agentRoot),a=await readSortedDirectoryEntries(r,i),s=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(i,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:a,rootPath:i,source:r,validateSegment:createExtensionNameDiagnostic}),c=await collectExtensionMounts({agentRoot:i,fileMounts:s.sources,rootEntries:a,source:r});return{diagnostics:[...s.diagnostics,...c.diagnostics],mounts:c.mounts}}async function collectExtensionMounts(t){let r=[],i=join(t.agentRoot,`extensions`),o=t.fileMounts.map(e=>({namespace:mountNamespace(e.logicalPath),mountRef:e})),s=new Set(o.map(e=>e.namespace)),u=t.rootEntries.find(e=>e.name===`extensions`),d=[],f=new Set;if(u?.isDirectory()===!0){let o=await readSortedDirectoryEntries(t.source,i);for(let c of o){if(!c.isDirectory())continue;let o=c.name,u=join(i,o),p=createExtensionNameDiagnostic(o,u);if(p!==null){r.push(p);continue}let m=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(t.source,u),rootPath:u,slotName:`extension`});if(r.push(...m.diagnostics),m.module===void 0){r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,message:`Extension mount directory "extensions/${o}/" must declare its mount in "extension.ts" (or another supported module extension).`,sourcePath:u}));continue}s.has(o)&&f.add(o),d.push({namespace:o,mountRef:createModuleSourceRef({logicalPath:normalizeLogicalPath(join(`extensions`,o,m.module.logicalPath))}),overridesRoot:u})}}for(let e of f)r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,message:`Extension namespace "${e}" is claimed by both a file mount ("extensions/${e}.ts") and a directory mount ("extensions/${e}/"). Keep only one.`,sourcePath:i}));return{diagnostics:r,mounts:[...o,...d].filter(e=>!f.has(e.namespace))}}function detectRootNamespaceCollisions(t){if(t.namespaces.length===0)return[];let r=[];for(let i of t.sources){let a=rootContributionName(i.logicalPath),o=t.namespaces.find(e=>a.startsWith(`${e}__`));o!==void 0&&r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,message:`"${i.logicalPath}" uses the "${o}__" prefix reserved for the mounted extension "${o}". Override an extension's contributions inside its mount directory ("extensions/${o}/…"), not at the agent root.`,sourcePath:join(t.agentRoot,i.logicalPath)}))}return r}function rootContributionName(e){let t=e.slice(e.indexOf(`/`)+1),n=t.split(`/`)[0]??t;for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(n.toLowerCase().endsWith(e))return n.slice(0,n.length-e.length);return n}async function tryReadPackageJsonName(t,n){try{let r=join(n,`package.json`),i=JSON.parse(await t.readTextFile(r)).name;return typeof i!=`string`||i.length===0?void 0:stripNpmPackageScope(i)}catch{return}}export{discoverAgent,discoverExtensionMountDeclarations};
1
+ import{join,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,locateExtensionMount,mountNamespace}from"#discover/extensions.js";import{createAgentSourceManifest,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_CHANNELS_DIRECTORY_INVALID,DISCOVER_EXTENSIONS_DIRECTORY_INVALID,DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createChannelNameDiagnostic,createExtensionNameDiagnostic,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverSubagents}from"#discover/discover-subagent.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverScheduleSources}from"#discover/schedules.js";import{discoverSkills}from"#discover/skills.js";import{stripNpmPackageScope}from"#shared/package-name.js";async function discoverAgent(r){let a=r.source??createDiskProjectSource(),c=resolve(r.appRoot),l=resolve(r.agentRoot),d=r.role??`agent`,m=[],h=await tryReadPackageJsonName(a,c),g=await readSortedDirectoryEntries(a,l);m.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyAgentRootEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the agent root.`},rootEntries:g,rootPath:l}));let _=await discoverInstructionsSource({rootEntries:g,rootPath:l,source:a,required:d!==`extension`});m.push(..._.diagnostics);let v=discoverFlatModuleSource({rootEntries:g,rootPath:l,slotName:`agent`});m.push(...v.diagnostics);let y=await discoverNamedSourceDirectory({directoryName:`channels`,invalidDirectoryCode:DISCOVER_CHANNELS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`channels`)}" to be a directory of authored channels.`,recursive:!0,rootEntries:g,rootPath:l,source:a,validateSegment:createChannelNameDiagnostic});m.push(...y.diagnostics);let b=await discoverLibSources({agentRoot:l,rootEntries:g,source:a});m.push(...b.diagnostics);let x=await discoverScheduleSources({agentRoot:l,rootEntries:g,source:a});m.push(...x.diagnostics);let S=await discoverConnectionSources({rootEntries:g,rootPath:l,source:a});m.push(...S.diagnostics);let C=await discoverSandboxSource({rootEntries:g,rootPath:l,source:a});if(m.push(...C.diagnostics),d===`extension`){v.module!==void 0&&m.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_AGENT_CONFIG_UNSUPPORTED,message:`An extension may not declare agent config (agent.ts) — model, limits, and sandbox are the consuming agent's to own.`,sourcePath:join(l,v.module.logicalPath)})),C.sandbox!==null&&m.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SANDBOX_UNSUPPORTED,message:`An extension may not declare a sandbox — it is the consuming agent's to own.`,sourcePath:join(l,C.sandbox.logicalPath)}));let[t]=x.schedules;t!==void 0&&m.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_SCHEDULE_UNSUPPORTED,message:`An extension may not declare schedules — background scheduling runs on the consuming agent's deployment under its limits, so it is the consuming agent's to own.`,sourcePath:join(l,t.logicalPath)}))}let w=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:g,rootPath:l,source:a,validateSegment:createToolNameDiagnostic});m.push(...w.diagnostics);let T=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:g,rootPath:l,source:a,validateSegment:createHookNameDiagnostic});m.push(...T.diagnostics);let E=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(l,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:g,rootPath:l,source:a,validateSegment:createExtensionNameDiagnostic});m.push(...E.diagnostics);let D=await discoverSkills({agentRoot:l,source:a});m.push(...D.diagnostics);let O=await discoverSubagents({agentRoot:l,appRoot:c,source:a});m.push(...O.diagnostics);let k=await collectExtensionMounts({agentRoot:l,fileMounts:E.sources,rootEntries:g,source:a});m.push(...k.diagnostics),m.push(...detectRootNamespaceCollisions({agentRoot:l,namespaces:k.mounts.map(e=>e.namespace),sources:[...w.sources,...S.connections,...D.skills,...x.schedules]}));let A=[];if(d!==`agent`)for(let t of k.mounts)m.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_NESTED_MOUNT_UNSUPPORTED,message:`"${t.mountRef.logicalPath}" mounts an extension from inside an extension, which is not supported yet. Extensions cannot mount other extensions; remove the "extensions/" slot.`,sourcePath:join(l,t.mountRef.logicalPath)}));else{let e=await resolveExtensionMounts({agentRoot:l,appRoot:c,mounts:k.mounts,source:a});m.push(...e.diagnostics),A=e.mounts}let j={agentRoot:l,appRoot:c,channels:y.sources,connections:S.connections,packageName:h,diagnostics:m,extensions:k.mounts.map(e=>e.mountRef),resolvedExtensions:A,hooks:T.sources,lib:b.lib,instructions:_.instructions,sandbox:C.sandbox,sandboxWorkspaces:C.sandboxWorkspace===null?[]:[C.sandboxWorkspace],schedules:x.schedules,skills:D.skills,tools:w.sources,subagents:O.subagents};return v.module!==void 0&&(j.configModule=v.module),{diagnostics:m,manifest:createAgentSourceManifest(j)}}async function resolveExtensionMounts(e){let t=[],n=[];for(let r of e.mounts){let i=await locateExtensionMount({source:e.source,agentRoot:e.agentRoot,appRoot:e.appRoot,mount:r.mountRef,namespace:r.namespace});if(t.push(...i.diagnostics),i.location===void 0)continue;let a=await discoverAgent({agentRoot:i.location.sourceRoot,appRoot:i.location.packageRoot,source:e.source,role:`extension`});t.push(...a.diagnostics);let o;if(r.overridesRoot!==void 0){let n=await discoverAgent({agentRoot:r.overridesRoot,appRoot:e.appRoot,source:e.source,role:`extension`});t.push(...n.diagnostics),o=n.manifest}n.push({namespace:i.location.namespace,specifier:i.location.specifier,packageName:i.location.packageName,packageRoot:i.location.packageRoot,sourceRoot:i.location.sourceRoot,manifest:a.manifest,overrides:o})}return{diagnostics:t,mounts:n}}async function discoverExtensionMountDeclarations(n){let r=n.source??createDiskProjectSource(),i=resolve(n.agentRoot),a=await readSortedDirectoryEntries(r,i),s=await discoverNamedSourceDirectory({directoryName:`extensions`,invalidDirectoryCode:DISCOVER_EXTENSIONS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(i,`extensions`)}" to be a directory of extension mounts.`,recursive:!1,rootEntries:a,rootPath:i,source:r,validateSegment:createExtensionNameDiagnostic}),c=await collectExtensionMounts({agentRoot:i,fileMounts:s.sources,rootEntries:a,source:r});return{diagnostics:[...s.diagnostics,...c.diagnostics],mounts:c.mounts}}async function collectExtensionMounts(t){let r=[],i=join(t.agentRoot,`extensions`),o=t.fileMounts.map(e=>({namespace:mountNamespace(e.logicalPath),mountRef:e})),s=new Set(o.map(e=>e.namespace)),u=t.rootEntries.find(e=>e.name===`extensions`),d=[],f=new Set;if(u?.isDirectory()===!0){let o=await readSortedDirectoryEntries(t.source,i);for(let c of o){if(!c.isDirectory())continue;let o=c.name,u=join(i,o),p=createExtensionNameDiagnostic(o,u);if(p!==null){r.push(p);continue}let m=discoverFlatModuleSource({rootEntries:await readSortedDirectoryEntries(t.source,u),rootPath:u,slotName:`extension`});if(r.push(...m.diagnostics),m.module===void 0){r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_MISSING_DECLARATION,message:`Extension mount directory "extensions/${o}/" must declare its mount in "extension.ts" (or another supported module extension).`,sourcePath:u}));continue}s.has(o)&&f.add(o),d.push({namespace:o,mountRef:createModuleSourceRef({logicalPath:normalizeLogicalPath(join(`extensions`,o,m.module.logicalPath))}),overridesRoot:u})}}for(let e of f)r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_MOUNT_AMBIGUOUS,message:`Extension namespace "${e}" is claimed by both a file mount ("extensions/${e}.ts") and a directory mount ("extensions/${e}/"). Keep only one.`,sourcePath:i}));return{diagnostics:r,mounts:[...o,...d].filter(e=>!f.has(e.namespace))}}function detectRootNamespaceCollisions(t){if(t.namespaces.length===0)return[];let r=[];for(let i of t.sources){let a=rootContributionName(i.logicalPath),o=t.namespaces.find(e=>a.startsWith(`${e}__`));o!==void 0&&r.push(createDiscoverErrorDiagnostic({code:DISCOVER_EXTENSION_OVERRIDE_OUTSIDE_MOUNT,message:`"${i.logicalPath}" uses the "${o}__" prefix reserved for the mounted extension "${o}". Override an extension's contributions inside its mount directory ("extensions/${o}/…"), not at the agent root.`,sourcePath:join(t.agentRoot,i.logicalPath)}))}return r}function rootContributionName(e){let t=e.slice(e.indexOf(`/`)+1),n=t.split(`/`)[0]??t;for(let e of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(n.toLowerCase().endsWith(e))return n.slice(0,n.length-e.length);return n}async function tryReadPackageJsonName(t,n){try{let r=join(n,`package.json`),i=JSON.parse(await t.readTextFile(r)).name;return typeof i!=`string`||i.length===0?void 0:stripNpmPackageScope(i)}catch{return}}export{detectRootNamespaceCollisions,discoverAgent,discoverExtensionMountDeclarations,resolveExtensionMounts};
@@ -1 +1 @@
1
- import{join,relative,resolve}from"node:path";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyLocalSubagentEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createAgentSourceManifest,createLocalSubagentSourceRef,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverSkills}from"#discover/skills.js";const DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID=`discover/local-subagent-schedules-invalid`,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING=`discover/required-subagent-config-module-missing`,DISCOVER_SUBAGENTS_DIRECTORY_INVALID=`discover/subagents-directory-invalid`;async function discoverSubagents(i){let a=i.source??createDiskProjectSource(),l=resolve(i.agentRoot),u=resolve(i.subagentsDirectoryPath??join(l,`subagents`)),d=normalizeLogicalPath(i.subagentsLogicalPath??relative(l,u)),f=await a.stat(u);if(f===`missing`)return{diagnostics:[],subagents:[]};if(f!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SUBAGENTS_DIRECTORY_INVALID,message:`Expected "${u}" to be a directory of authored subagents.`,sourcePath:u})],subagents:[]};let p=await readSortedDirectoryEntries(a,u),m=[],h=[];for(let t of p){if(t.isFile()){let n=getSupportedModuleBaseName(t.name);if(n===null)continue;h.push(discoverSingleFileSubagent({agentRoot:l,appRoot:i.appRoot,subagentId:n,subagentLogicalPath:join(d,t.name),subagentPath:join(u,t.name)}));continue}if(!t.isDirectory())continue;let n=await discoverLocalSubagentPackage({appRoot:i.appRoot,source:a,subagentId:t.name,subagentLogicalPath:join(d,t.name),subagentRoot:join(u,t.name)});m.push(...n.diagnostics),h.push(n.subagent)}return{diagnostics:m,subagents:h}}function discoverSingleFileSubagent(e){let t=createModuleSourceRef({logicalPath:e.subagentLogicalPath}),n=createAgentSourceManifest({agentId:e.subagentId,agentRoot:e.agentRoot,appRoot:e.appRoot,configModule:t});return createLocalSubagentSourceRef({entryPath:e.subagentPath,logicalPath:e.subagentLogicalPath,manifest:n,rootPath:e.agentRoot,subagentId:e.subagentId})}async function discoverLocalSubagentPackage(t){let n=[],r=await readSortedDirectoryEntries(t.source,t.subagentRoot);n.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyLocalSubagentEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the local subagent root.`},rootEntries:r,rootPath:t.subagentRoot}));let a=await discoverInstructionsSource({required:!1,rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...a.diagnostics);let o=discoverFlatModuleSource({missingDiagnostic:{code:DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,message:`Expected one authored subagent config module at "agent.ts", "agent.cts", "agent.mts", "agent.js", "agent.cjs", or "agent.mjs".`},rootEntries:r,rootPath:t.subagentRoot,slotName:`agent`});n.push(...o.diagnostics);let s=await discoverConnectionSources({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...s.diagnostics);let c=await discoverSandboxSource({rootEntries:r,rootPath:t.subagentRoot,source:t.source});n.push(...c.diagnostics);let d=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createToolNameDiagnostic});n.push(...d.diagnostics);let g=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:r,rootPath:t.subagentRoot,source:t.source,validateSegment:createHookNameDiagnostic});n.push(...g.diagnostics);let _=await discoverLibSources({agentRoot:t.subagentRoot,rootEntries:r,source:t.source});n.push(..._.diagnostics),n.push(...createLocalSubagentScheduleDiagnostics(t.subagentRoot,r));let v=await discoverSkills({agentRoot:t.subagentRoot,source:t.source});n.push(...v.diagnostics);let y=await discoverSubagents({agentRoot:t.subagentRoot,appRoot:t.appRoot,source:t.source});n.push(...y.diagnostics);let b={agentRoot:t.subagentRoot,appRoot:t.appRoot,connections:s.connections,diagnostics:n,hooks:g.sources,lib:_.lib,instructions:a.instructions,sandbox:c.sandbox,sandboxWorkspaces:c.sandboxWorkspace===null?[]:[c.sandboxWorkspace],skills:v.skills,tools:d.sources,subagents:y.subagents};o.module!==void 0&&(b.configModule=o.module);let x=createAgentSourceManifest(b);return{diagnostics:n,subagent:createLocalSubagentSourceRef({entryPath:t.subagentRoot,logicalPath:t.subagentLogicalPath,manifest:x,rootPath:t.subagentRoot,subagentId:t.subagentId})}}function createLocalSubagentScheduleDiagnostics(t,n){return n.flatMap(n=>classifyLocalSubagentEntry(n.name,getDirectoryEntryType(n))===`invalid-schedules-directory`?[createDiscoverErrorDiagnostic({code:DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,message:`Local subagent packages cannot define schedules at "${join(t,n.name)}".`,sourcePath:join(t,n.name)})]:[])}export{DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,DISCOVER_SUBAGENTS_DIRECTORY_INVALID,discoverSubagents};
1
+ import{join,relative,resolve}from"node:path";import{detectRootNamespaceCollisions,discoverExtensionMountDeclarations,resolveExtensionMounts}from"#discover/discover-agent.js";import{createDiscoverErrorDiagnostic}from"#discover/diagnostics.js";import{classifyLocalSubagentEntry,getDirectoryEntryType,getSupportedModuleBaseName,normalizeLogicalPath}from"#discover/filesystem.js";import{createDiskProjectSource}from"#discover/project-source.js";import{createAgentSourceManifest,createLocalSubagentSourceRef,createModuleSourceRef}from"#discover/manifest.js";import{DISCOVER_HOOKS_DIRECTORY_INVALID,DISCOVER_TOOLS_DIRECTORY_INVALID,createHookNameDiagnostic,createToolNameDiagnostic,createUnsupportedRootDirectoryDiagnostics,discoverFlatModuleSource,discoverInstructionsSource,discoverNamedSourceDirectory,readSortedDirectoryEntries}from"#discover/grammar.js";import{discoverConnectionSources}from"#discover/connections.js";import{discoverLibSources}from"#discover/lib.js";import{discoverSandboxSource}from"#discover/sandbox.js";import{discoverSkills}from"#discover/skills.js";const DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID=`discover/local-subagent-schedules-invalid`,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING=`discover/required-subagent-config-module-missing`,DISCOVER_SUBAGENTS_DIRECTORY_INVALID=`discover/subagents-directory-invalid`;async function discoverSubagents(r){let i=r.source??createDiskProjectSource(),a=resolve(r.agentRoot),s=resolve(r.subagentsDirectoryPath??join(a,`subagents`)),c=normalizeLogicalPath(r.subagentsLogicalPath??relative(a,s)),f=await i.stat(s);if(f===`missing`)return{diagnostics:[],subagents:[]};if(f!==`directory`)return{diagnostics:[createDiscoverErrorDiagnostic({code:DISCOVER_SUBAGENTS_DIRECTORY_INVALID,message:`Expected "${s}" to be a directory of authored subagents.`,sourcePath:s})],subagents:[]};let p=await readSortedDirectoryEntries(i,s),m=[],h=[];for(let t of p){if(t.isFile()){let n=getSupportedModuleBaseName(t.name);if(n===null)continue;h.push(discoverSingleFileSubagent({agentRoot:a,appRoot:r.appRoot,subagentId:n,subagentLogicalPath:join(c,t.name),subagentPath:join(s,t.name)}));continue}if(!t.isDirectory())continue;let n=await discoverLocalSubagentPackage({appRoot:r.appRoot,source:i,subagentId:t.name,subagentLogicalPath:join(c,t.name),subagentRoot:join(s,t.name)});m.push(...n.diagnostics),h.push(n.subagent)}return{diagnostics:m,subagents:h}}function discoverSingleFileSubagent(e){let t=createModuleSourceRef({logicalPath:e.subagentLogicalPath}),n=createAgentSourceManifest({agentId:e.subagentId,agentRoot:e.agentRoot,appRoot:e.appRoot,configModule:t});return createLocalSubagentSourceRef({entryPath:e.subagentPath,logicalPath:e.subagentLogicalPath,manifest:n,rootPath:e.agentRoot,subagentId:e.subagentId})}async function discoverLocalSubagentPackage(t){let n=[],o=await readSortedDirectoryEntries(t.source,t.subagentRoot);n.push(...createUnsupportedRootDirectoryDiagnostics({classifyEntry:classifyLocalSubagentEntry,createUnsupportedDirectoryMessage(e){return`Ignoring unsupported directory "${e}/" in the local subagent root.`},rootEntries:o,rootPath:t.subagentRoot}));let c=await discoverInstructionsSource({required:!1,rootEntries:o,rootPath:t.subagentRoot,source:t.source});n.push(...c.diagnostics);let l=discoverFlatModuleSource({missingDiagnostic:{code:DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,message:`Expected one authored subagent config module at "agent.ts", "agent.cts", "agent.mts", "agent.js", "agent.cjs", or "agent.mjs".`},rootEntries:o,rootPath:t.subagentRoot,slotName:`agent`});n.push(...l.diagnostics);let u=await discoverConnectionSources({rootEntries:o,rootPath:t.subagentRoot,source:t.source});n.push(...u.diagnostics);let d=await discoverSandboxSource({rootEntries:o,rootPath:t.subagentRoot,source:t.source});n.push(...d.diagnostics);let m=await discoverNamedSourceDirectory({directoryName:`tools`,invalidDirectoryCode:DISCOVER_TOOLS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`tools`)}" to be a directory of authored tools.`,recursive:!0,rootEntries:o,rootPath:t.subagentRoot,source:t.source,validateSegment:createToolNameDiagnostic});n.push(...m.diagnostics);let g=await discoverNamedSourceDirectory({directoryName:`hooks`,invalidDirectoryCode:DISCOVER_HOOKS_DIRECTORY_INVALID,invalidDirectoryMessage:`Expected "${join(t.subagentRoot,`hooks`)}" to be a directory of authored hooks.`,recursive:!0,rootEntries:o,rootPath:t.subagentRoot,source:t.source,validateSegment:createHookNameDiagnostic});n.push(...g.diagnostics);let _=await discoverLibSources({agentRoot:t.subagentRoot,rootEntries:o,source:t.source});n.push(..._.diagnostics),n.push(...createLocalSubagentScheduleDiagnostics(t.subagentRoot,o));let v=await discoverSkills({agentRoot:t.subagentRoot,source:t.source});n.push(...v.diagnostics);let y=await discoverSubagents({agentRoot:t.subagentRoot,appRoot:t.appRoot,source:t.source});n.push(...y.diagnostics);let b=await discoverExtensionMountDeclarations({agentRoot:t.subagentRoot,source:t.source});n.push(...b.diagnostics),n.push(...detectRootNamespaceCollisions({agentRoot:t.subagentRoot,namespaces:b.mounts.map(e=>e.namespace),sources:[...m.sources,...u.connections,...v.skills]}));let x=await resolveExtensionMounts({agentRoot:t.subagentRoot,appRoot:t.appRoot,mounts:b.mounts,source:t.source});n.push(...x.diagnostics);let S={agentRoot:t.subagentRoot,appRoot:t.appRoot,connections:u.connections,diagnostics:n,extensions:b.mounts.map(e=>e.mountRef),resolvedExtensions:x.mounts,hooks:g.sources,lib:_.lib,instructions:c.instructions,sandbox:d.sandbox,sandboxWorkspaces:d.sandboxWorkspace===null?[]:[d.sandboxWorkspace],skills:v.skills,tools:m.sources,subagents:y.subagents};l.module!==void 0&&(S.configModule=l.module);let C=createAgentSourceManifest(S);return{diagnostics:n,subagent:createLocalSubagentSourceRef({entryPath:t.subagentRoot,logicalPath:t.subagentLogicalPath,manifest:C,rootPath:t.subagentRoot,subagentId:t.subagentId})}}function createLocalSubagentScheduleDiagnostics(t,n){return n.flatMap(n=>classifyLocalSubagentEntry(n.name,getDirectoryEntryType(n))===`invalid-schedules-directory`?[createDiscoverErrorDiagnostic({code:DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,message:`Local subagent packages cannot define schedules at "${join(t,n.name)}".`,sourcePath:join(t,n.name)})]:[])}export{DISCOVER_LOCAL_SUBAGENT_SCHEDULES_INVALID,DISCOVER_REQUIRED_SUBAGENT_CONFIG_MODULE_MISSING,DISCOVER_SUBAGENTS_DIRECTORY_INVALID,discoverSubagents};
@@ -19,7 +19,7 @@ export type AgentRootEntryKind = "agent-config-module" | "channels-directory" |
19
19
  /**
20
20
  * Classified local-subagent root entry.
21
21
  */
22
- export type LocalSubagentEntryKind = "agent-config-module" | "connections-directory" | "hooks-directory" | "ignored-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "invalid-schedules-directory" | "lib-directory" | "sandbox-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
22
+ export type LocalSubagentEntryKind = "agent-config-module" | "connections-directory" | "extensions-directory" | "hooks-directory" | "ignored-directory" | "instructions-directory" | "instructions-markdown" | "instructions-module" | "invalid-schedules-directory" | "lib-directory" | "sandbox-directory" | "skills-directory" | "system-markdown" | "system-module" | "tools-directory" | "unknown" | "subagents-directory";
23
23
  /**
24
24
  * Classified Agent Skills package entry.
25
25
  */
@@ -1 +1 @@
1
- import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES),GENERATED_AGENT_DIRECTORY_NAMES=new Set([`.eve`,`.next`,`.output`,`.vercel`,`node_modules`]);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`connections`)return`connections-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(isTypeScriptDeclarationFileName(e))return`ignored-declaration`;if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){if(isTypeScriptDeclarationFileName(e))return null;for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function isTypeScriptDeclarationFileName(e){return/\.d\.(?:cts|mts|ts)$/.test(e)}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,isTypeScriptDeclarationFileName,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
1
+ import{sep}from"node:path";const SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS=[`.cts`,`.mts`,`.cjs`,`.mjs`,`.ts`,`.js`],PROJECT_MARKER_FILE_NAMES=[`package.json`,`vercel.json`],PROJECT_MARKER_FILE_NAME_SET=new Set(PROJECT_MARKER_FILE_NAMES),GENERATED_AGENT_DIRECTORY_NAMES=new Set([`.eve`,`.next`,`.output`,`.vercel`,`node_modules`]);function getDirectoryEntryType(e){return e.isDirectory()?`directory`:e.isFile()?`file`:`other`}function isProjectMarkerEntry(e,t){return t===`file`&&PROJECT_MARKER_FILE_NAME_SET.has(e)}function classifyAgentRootEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`channels`)return`channels-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`skills`)return`skills-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`tools`)return`tools-directory`;if(e===`schedules`)return`schedules-directory`;if(e===`subagents`)return`subagents-directory`}return`unknown`}function classifyLocalSubagentEntry(e,t){if(t===`file`)return matchesSupportedModuleBaseName(e,`agent`)?`agent-config-module`:e.toLowerCase()===`instructions.md`?`instructions-markdown`:matchesSupportedModuleBaseName(e,`instructions`)?`instructions-module`:e.toLowerCase()===`system.md`?`system-markdown`:matchesSupportedModuleBaseName(e,`system`)?`system-module`:`unknown`;if(t===`directory`){if(GENERATED_AGENT_DIRECTORY_NAMES.has(e))return`ignored-directory`;if(e===`connections`)return`connections-directory`;if(e===`extensions`)return`extensions-directory`;if(e===`hooks`)return`hooks-directory`;if(e===`instructions`)return`instructions-directory`;if(e===`lib`)return`lib-directory`;if(e===`sandbox`)return`sandbox-directory`;if(e===`skills`)return`skills-directory`;if(e===`tools`)return`tools-directory`;if(e===`subagents`)return`subagents-directory`;if(e===`schedules`)return`invalid-schedules-directory`}return`unknown`}function classifySkillPackageEntry(e,t){if(t===`file`)return e.toLowerCase()===`skill.md`?`skill-markdown`:`skill-resource`;if(t===`directory`){if(e===`scripts`)return`skill-scripts-directory`;if(e===`references`)return`skill-references-directory`;if(e===`assets`)return`skill-assets-directory`}return`skill-resource`}function classifySkillsDirectoryEntry(e,t){if(t===`directory`)return`skill-package-directory`;if(t===`file`){if(isTypeScriptDeclarationFileName(e))return`ignored-declaration`;if(e.toLowerCase().endsWith(`.md`))return`flat-skill-markdown`;if(getSupportedModuleBaseName(e)!==null)return`flat-skill-module`}return`unknown`}function normalizeLogicalPath(t){return t.replaceAll(sep,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function getSupportedModuleBaseName(e){if(isTypeScriptDeclarationFileName(e))return null;for(let n of SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS)if(e.endsWith(n)&&e.length>n.length)return e.slice(0,-n.length);return null}function isTypeScriptDeclarationFileName(e){return/\.d\.(?:cts|mts|ts)$/.test(e)}function matchesSupportedModuleBaseName(e,t){return getSupportedModuleBaseName(e)===t}function stripLogicalPathExtension(e){let t=normalizeLogicalPath(e),n=t.lastIndexOf(`/`),r=t.lastIndexOf(`.`);return r===-1||r<n?t:t.slice(0,r)}export{PROJECT_MARKER_FILE_NAMES,SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS,classifyAgentRootEntry,classifyLocalSubagentEntry,classifySkillPackageEntry,classifySkillsDirectoryEntry,getDirectoryEntryType,getSupportedModuleBaseName,isProjectMarkerEntry,isTypeScriptDeclarationFileName,matchesSupportedModuleBaseName,normalizeLogicalPath,stripLogicalPathExtension};
@@ -1,4 +1,5 @@
1
1
  import type { SandboxBackendHandle } from "#public/definitions/sandbox-backend.js";
2
+ import type { JustBashSandboxCreateOptions } from "#public/sandbox/just-bash-sandbox.js";
2
3
  import type { SandboxProcess, SandboxRemovePathOptions, SandboxSpawnOptions } from "#shared/sandbox-session.js";
3
4
  export interface BashSandbox {
4
5
  captureState(): Promise<Record<string, unknown> | null>;
@@ -16,6 +17,7 @@ export interface BashSandbox {
16
17
  export declare function createBashSandbox(input: {
17
18
  readonly appRoot: string;
18
19
  readonly autoInstall: boolean;
20
+ readonly filesystem?: JustBashSandboxCreateOptions["filesystem"];
19
21
  readonly rootPath: string;
20
22
  readonly sessionKey: string;
21
23
  }): Promise<BashSandbox>;
@@ -1 +1 @@
1
- import{mkdir,readFile,writeFile}from"node:fs/promises";import{dirname}from"node:path";import{loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{createFileBackedInternalSandboxSession,pathExists}from"#execution/sandbox/bindings/local-backend-utils.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";let justBashModulePromise;async function loadJustBashModule(e){return justBashModulePromise??=loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.autoInstall,importModule:async()=>await import(`just-bash`),missingMessage:"The just-bash sandbox backend requires the `just-bash` package, which is not bundled with eve. Install it in your application (for example `pnpm add -D just-bash`), or use docker() / defaultSandbox() instead.",packageName:`just-bash`}).catch(e=>{throw justBashModulePromise=void 0,e}),await justBashModulePromise}async function createBashSandbox(t){let{ReadWriteFs:n,Sandbox:r}=await loadJustBashModule({appRoot:t.appRoot,autoInstall:t.autoInstall}),i=resolveLocalSandboxFilesystemRootPath(t.rootPath),a=resolveLocalSandboxMetadataPath(t.rootPath),o=await readLocalMetadata(a);await mkdir(i,{recursive:!0});let s=new n({allowSymlinks:!0,maxFileReadSize:2**53-1,root:i});await ensureLocalSandboxDirectories(s);let c=await r.create({cwd:WORKSPACE_ROOT,env:o?.env,fs:s,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureState(){return await writeLocalMetadata(a,{env:{...c.bashEnvInstance.getEnv()},version:1}),{rootPath:t.rootPath}},async dispose(){await c.stop()},async readFileBytes(e){let t;try{t=await s.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async removePath(e){await s.rm(e.path,{force:e.force,recursive:e.recursive})},rootPath:t.rootPath,sessionKey:t.sessionKey,async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${shellQuote(e.workingDirectory)} && ${e.command} )`;return adaptMultiplexedCommandToSandboxProcess({command:await c.runCommand({args:[t],cmd:`eval`,detached:!0,env:e.env,signal:e.abortSignal}),getOutput:e=>e.type})},async writeFiles(e){for(let t of e){let e=dirname(t.path);await s.mkdir(e,{recursive:!0}),await s.writeFile(t.path,t.content)}}}}async function justBashSetNetworkPolicyUnsupported(){throw Error(`setNetworkPolicy() is not supported on the just-bash sandbox backend. just-bash applies its network policy only at sandbox creation (no run-time update) and does not run git or other binaries. Use docker() for coarse egress control or vercel() / microsandbox() for credential brokering.`)}function createJustBashHandle(e,t){let n=buildSandboxSession(createFileBackedInternalSandboxSession({id:e.sessionKey,sandbox:e}),justBashSetNetworkPolicyUnsupported);return{session:n,useSessionFn:async()=>n,async captureState(){return{backendName:t,metadata:await e.captureState()??{},sessionKey:e.sessionKey}},async shutdown(){await e.dispose()}}}function resolveLocalSandboxFilesystemRootPath(e){return`${e}/fs`}function resolveLocalSandboxMetadataPath(e){return`${e}/metadata.json`}async function ensureLocalSandboxDirectories(e){await e.mkdir(WORKSPACE_ROOT,{recursive:!0})}async function readLocalMetadata(e){if(!await pathExists(e))return null;let n=JSON.parse(await readFile(e,`utf8`));return n.version!==1||!isStringRecord(n.env)?null:{env:n.env,version:1}}async function writeLocalMetadata(t,r){await mkdir(dirname(t),{recursive:!0}),await writeFile(t,`${JSON.stringify(r,null,2)}\n`)}function isStringRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`)}export{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported};
1
+ import{mkdir,readFile,writeFile}from"node:fs/promises";import{dirname}from"node:path";import{loadOptionalEnginePackage}from"#internal/application/optional-package-install.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{createFileBackedInternalSandboxSession,pathExists}from"#execution/sandbox/bindings/local-backend-utils.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";let justBashModulePromise;async function loadJustBashModule(e){return justBashModulePromise??=loadOptionalEnginePackage({appRoot:e.appRoot,autoInstall:e.autoInstall,importModule:async()=>await import(`just-bash`),missingMessage:"The just-bash sandbox backend requires the `just-bash` package, which is not bundled with eve. Install it in your application (for example `pnpm add -D just-bash`), or use docker() / defaultSandbox() instead.",packageName:`just-bash`}).catch(e=>{throw justBashModulePromise=void 0,e}),await justBashModulePromise}async function createBashSandbox(t){let{ReadWriteFs:n,Sandbox:r}=await loadJustBashModule({appRoot:t.appRoot,autoInstall:t.autoInstall}),i=resolveLocalSandboxFilesystemRootPath(t.rootPath),a=resolveLocalSandboxMetadataPath(t.rootPath),o=await readLocalMetadata(a);await mkdir(i,{recursive:!0});let s=new n({allowSymlinks:!0,maxFileReadSize:2**53-1,root:i}),c=s;if(t.filesystem!==void 0)try{c=await t.filesystem({appRoot:t.appRoot,defaultFilesystem:s})}catch(e){throw Error(`Failed to create the custom just-bash filesystem.`,{cause:e})}await ensureLocalSandboxDirectories(c);let l=await r.create({cwd:WORKSPACE_ROOT,env:o?.env,fs:c,network:{dangerouslyAllowFullInternetAccess:!0}});return{async captureState(){return await writeLocalMetadata(a,{env:{...l.bashEnvInstance.getEnv()},version:1}),{rootPath:t.rootPath}},async dispose(){await l.stop()},async readFileBytes(e){let t;try{t=await c.readFileBuffer(e)}catch{return null}return Buffer.from(t)},async removePath(e){await c.rm(e.path,{force:e.force,recursive:e.recursive})},rootPath:t.rootPath,sessionKey:t.sessionKey,async spawn(e){if(e.abortSignal?.aborted)throw new DOMException(`The operation was aborted.`,`AbortError`);let t=e.workingDirectory===void 0?e.command:`( cd ${shellQuote(e.workingDirectory)} && ${e.command} )`;return adaptMultiplexedCommandToSandboxProcess({command:await l.runCommand({args:[t],cmd:`eval`,detached:!0,env:e.env,signal:e.abortSignal}),getOutput:e=>e.type})},async writeFiles(e){for(let t of e){let e=dirname(t.path);await c.mkdir(e,{recursive:!0}),await c.writeFile(t.path,t.content)}}}}async function justBashSetNetworkPolicyUnsupported(){throw Error(`setNetworkPolicy() is not supported on the just-bash sandbox backend. just-bash applies its network policy only at sandbox creation (no run-time update) and does not run git or other binaries. Use docker() for coarse egress control or vercel() / microsandbox() for credential brokering.`)}function createJustBashHandle(e,t){let n=buildSandboxSession(createFileBackedInternalSandboxSession({id:e.sessionKey,sandbox:e}),justBashSetNetworkPolicyUnsupported);return{session:n,useSessionFn:async()=>n,async captureState(){return{backendName:t,metadata:await e.captureState()??{},sessionKey:e.sessionKey}},async shutdown(){await e.dispose()}}}function resolveLocalSandboxFilesystemRootPath(e){return`${e}/fs`}function resolveLocalSandboxMetadataPath(e){return`${e}/metadata.json`}async function ensureLocalSandboxDirectories(e){await e.mkdir(WORKSPACE_ROOT,{recursive:!0})}async function readLocalMetadata(e){if(!await pathExists(e))return null;let n=JSON.parse(await readFile(e,`utf8`));return n.version!==1||!isStringRecord(n.env)?null:{env:n.env,version:1}}async function writeLocalMetadata(t,r){await mkdir(dirname(t),{recursive:!0}),await writeFile(t,`${JSON.stringify(r,null,2)}\n`)}function isStringRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`)}export{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported};
@@ -1 +1 @@
1
- import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import"node:fs";import{dirname,join}from"node:path";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{copyDirectoryAtomically,createFileBackedInternalSandboxSession,pathExists,resolveLocalBackendSessionRootPath,resolveLocalBackendTemplateRootPath,resolveLocalBackendTemplatesDirectory,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported}from"#execution/sandbox/bindings/just-bash-runtime.js";const JUST_BASH_CACHE_DIRECTORY_NAME=`just-bash`,JUST_BASH_BACKEND_NAME=`just-bash`;function createJustBashSandboxBackend(n={}){let i=n.createOptions?.autoInstall??!0;return{name:JUST_BASH_BACKEND_NAME,async prewarm(n){let o=resolveTemplateRootPath(resolveSandboxCacheDirectory(n.runtimeContext.appRoot),n.templateKey);if(await pathExists(o))return await touchDirectory(o),{reused:!0};let s=`${o}.${randomUUID()}.tmp`,u=!1,d=await createBashSandbox({appRoot:n.runtimeContext.appRoot,autoInstall:i,rootPath:s,sessionKey:n.templateKey}),f=buildSandboxSession(createFileBackedInternalSandboxSession({id:d.sessionKey,sandbox:d}),justBashSetNetworkPolicyUnsupported);try{if(await writeSandboxSeedFiles(f,n.seedFiles),n.bootstrap!==void 0&&(n.log?.(`running sandbox bootstrap`),await n.bootstrap({use:async()=>createLoggingSandboxSession({log:n.log,session:f})})),await d.captureState()===null)throw Error(`Failed to capture local sandbox template state for "${n.templateKey}".`);await mkdir(dirname(o),{recursive:!0});try{await rename(s,o),u=!0}catch(e){if(await pathExists(o))return{reused:!0};throw e}}finally{await d.dispose(),u||await rm(s,{force:!0,recursive:!0}).catch(()=>{})}return{reused:!1}},async create(e){let n=resolveSandboxCacheDirectory(e.runtimeContext.appRoot),r=getLocalRootPath(e.existingMetadata)??resolveSessionRootPath(n,e.sessionKey);if(!await pathExists(r))if(e.templateKey===null)await mkdir(r,{recursive:!0});else{let t=resolveTemplateRootPath(n,e.templateKey);if(!await pathExists(t))throw new SandboxTemplateNotProvisionedError({backendName:JUST_BASH_BACKEND_NAME,templateKey:e.templateKey});await copyDirectoryAtomically(t,r)}return createJustBashHandle(await createBashSandbox({appRoot:e.runtimeContext.appRoot,autoInstall:i,rootPath:r,sessionKey:e.sessionKey}),JUST_BASH_BACKEND_NAME)}}}async function pruneJustBashSandboxTemplates(e){let t=resolveLocalBackendTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot),JUST_BASH_CACHE_DIRECTORY_NAME),r=e.now??Date.now(),a=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,s=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,c;try{c=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let l=await Promise.all(c.filter(e=>e.isDirectory()).map(async e=>{let n=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),mtimeMs:(await stat(n)).mtimeMs,path:n}})),u=selectStaleTemplateEntries(l.filter(e=>!e.isTemporary),{now:r,recentWindowMs:a,retainCount:s}),d=selectStaleTemplateEntries(l.filter(e=>e.isTemporary),{now:r,recentWindowMs:a,retainCount:0});await Promise.all([...u,...d].map(async e=>await rm(e.path,{force:!0,recursive:!0})))}function resolveTemplateRootPath(e,t){return resolveLocalBackendTemplateRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function resolveSessionRootPath(e,t){return resolveLocalBackendSessionRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function getLocalRootPath(e){let t=e?.rootPath;return typeof t==`string`?t:void 0}export{JUST_BASH_BACKEND_NAME,createJustBashSandboxBackend,pruneJustBashSandboxTemplates};
1
+ import{randomUUID}from"node:crypto";import{mkdir,readdir,rename,rm,stat}from"node:fs/promises";import"node:fs";import{dirname,join}from"node:path";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";import{copyDirectoryAtomically,createFileBackedInternalSandboxSession,pathExists,resolveLocalBackendSessionRootPath,resolveLocalBackendTemplateRootPath,resolveLocalBackendTemplatesDirectory,touchDirectory,writeSandboxSeedFiles}from"#execution/sandbox/bindings/local-backend-utils.js";import{LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,selectStaleTemplateEntries}from"#execution/sandbox/bindings/local-template-prune.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{createBashSandbox,createJustBashHandle,justBashSetNetworkPolicyUnsupported}from"#execution/sandbox/bindings/just-bash-runtime.js";const JUST_BASH_CACHE_DIRECTORY_NAME=`just-bash`,JUST_BASH_BACKEND_NAME=`just-bash`;function createJustBashSandboxBackend(n={}){let i=n.createOptions?.autoInstall??!0,o=n.createOptions?.filesystem;return{name:JUST_BASH_BACKEND_NAME,async prewarm(n){let o=resolveTemplateRootPath(resolveSandboxCacheDirectory(n.runtimeContext.appRoot),n.templateKey);if(await pathExists(o))return await touchDirectory(o),{reused:!0};let s=`${o}.${randomUUID()}.tmp`,u=!1,d=await createBashSandbox({appRoot:n.runtimeContext.appRoot,autoInstall:i,rootPath:s,sessionKey:n.templateKey}),f=buildSandboxSession(createFileBackedInternalSandboxSession({id:d.sessionKey,sandbox:d}),justBashSetNetworkPolicyUnsupported);try{if(await writeSandboxSeedFiles(f,n.seedFiles),n.bootstrap!==void 0&&(n.log?.(`running sandbox bootstrap`),await n.bootstrap({use:async()=>createLoggingSandboxSession({log:n.log,session:f})})),await d.captureState()===null)throw Error(`Failed to capture local sandbox template state for "${n.templateKey}".`);await mkdir(dirname(o),{recursive:!0});try{await rename(s,o),u=!0}catch(e){if(await pathExists(o))return{reused:!0};throw e}}finally{await d.dispose(),u||await rm(s,{force:!0,recursive:!0}).catch(()=>{})}return{reused:!1}},async create(e){let n=resolveSandboxCacheDirectory(e.runtimeContext.appRoot),r=getLocalRootPath(e.existingMetadata)??resolveSessionRootPath(n,e.sessionKey);if(!await pathExists(r))if(e.templateKey===null)await mkdir(r,{recursive:!0});else{let t=resolveTemplateRootPath(n,e.templateKey);if(!await pathExists(t))throw new SandboxTemplateNotProvisionedError({backendName:JUST_BASH_BACKEND_NAME,templateKey:e.templateKey});await copyDirectoryAtomically(t,r)}return createJustBashHandle(await createBashSandbox({appRoot:e.runtimeContext.appRoot,autoInstall:i,filesystem:o,rootPath:r,sessionKey:e.sessionKey}),JUST_BASH_BACKEND_NAME)}}}async function pruneJustBashSandboxTemplates(e){let t=resolveLocalBackendTemplatesDirectory(resolveSandboxCacheDirectory(e.appRoot),JUST_BASH_CACHE_DIRECTORY_NAME),r=e.now??Date.now(),a=e.recentWindowMs??LOCAL_SANDBOX_TEMPLATE_RECENT_WINDOW_MS,s=e.retainCount??LOCAL_SANDBOX_TEMPLATE_RETAIN_COUNT,c;try{c=await readdir(t,{withFileTypes:!0})}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}let l=await Promise.all(c.filter(e=>e.isDirectory()).map(async e=>{let n=join(t,e.name);return{isTemporary:e.name.endsWith(`.tmp`),mtimeMs:(await stat(n)).mtimeMs,path:n}})),u=selectStaleTemplateEntries(l.filter(e=>!e.isTemporary),{now:r,recentWindowMs:a,retainCount:s}),d=selectStaleTemplateEntries(l.filter(e=>e.isTemporary),{now:r,recentWindowMs:a,retainCount:0});await Promise.all([...u,...d].map(async e=>await rm(e.path,{force:!0,recursive:!0})))}function resolveTemplateRootPath(e,t){return resolveLocalBackendTemplateRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function resolveSessionRootPath(e,t){return resolveLocalBackendSessionRootPath(e,JUST_BASH_CACHE_DIRECTORY_NAME,t)}function getLocalRootPath(e){let t=e?.rootPath;return typeof t==`string`?t:void 0}export{JUST_BASH_BACKEND_NAME,createJustBashSandboxBackend,pruneJustBashSandboxTemplates};
@@ -1,3 +1,3 @@
1
- import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGlobOnSandbox(n,a){let o=normalizeModelPath(await resolveAbsoluteFilePath(n,a.path??`/workspace`)),s=Math.min(Math.max(1,a.limit??100),1e3),c=await ripgrepIsAvailable(n)?buildRipgrepCommand({normalizedPath:o,pattern:a.pattern}):buildPosixFindCommand({normalizedPath:o,pattern:a.pattern}),l=await n.run({command:c});if(l.exitCode!==0&&l.exitCode!==1)throw buildGlobExecutionError(c,l.exitCode,l.stderr);let u=l.stdout.split(`
1
+ import{normalizeModelPath}from"#runtime/framework-tools/file-state.js";import{MAX_OUTPUT_BYTES}from"#execution/sandbox/truncate-output.js";import{shellQuote}from"#execution/sandbox/shell-quote.js";import{resolveAbsoluteFilePath}from"#execution/sandbox/require-sandbox.js";import{ripgrepIsAvailable}from"#execution/sandbox/ripgrep-probe.js";async function executeGlobOnSandbox(n,a){let o=normalizeModelPath(await resolveAbsoluteFilePath(n,a.path??`/workspace`)),s=Math.min(Math.max(1,a.limit??100),1e3),c=await ripgrepIsAvailable(n)?buildRipgrepCommand({normalizedPath:o,pattern:a.pattern}):buildPosixFindCommand({normalizedPath:o,pattern:a.pattern}),l=await n.run({command:c});if(l.exitCode!==0&&l.exitCode!==1||l.exitCode===1&&l.stderr.trim().length>0)throw buildGlobExecutionError(c,l.exitCode,l.stderr);let u=l.stdout.split(`
2
2
  `).filter(e=>e.length>0),d=u.length>s,f=d?u.slice(0,s):u,p=[],m=0,h=!1;for(let n of f){let r=normalizeModelPath(n),i=Buffer.byteLength(r,`utf8`)+1;if(m+i>MAX_OUTPUT_BYTES&&p.length>0){h=!0;break}p.push(r),m+=i}if(p.length===0)return{content:`No files found`,count:0,path:o,truncated:!1};let g=d||h,_=[...p];return g&&(_.push(``),_.push(`(Results truncated: showing first ${p.length} results out of more. Use a more specific path or pattern to narrow results.)`)),{content:_.join(`
3
- `),count:p.length,path:o,truncated:g}}function buildRipgrepCommand(e){return[`rg --files --hidden`,`--glob '!.git/*'`,`--glob ${shellQuote(e.pattern)}`,`-- ${shellQuote(e.normalizedPath)}`].join(` `)}function buildPosixFindCommand(e){let t=translateGlobToFindPattern(e.pattern),r=t.includes(`/`)?`-path ${shellQuote(`*/${t}`)}`:`-name ${shellQuote(t)}`;return[`find ${shellQuote(e.normalizedPath)}`,`-type f`,`-not -path '*/.git/*'`,r].join(` `)}function translateGlobToFindPattern(e){let t=e.replaceAll(`**`,`*`);for(;t.startsWith(`*/`);)t=t.slice(2);return t}function buildGlobExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`glob failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGlobOnSandbox};
3
+ `),count:p.length,path:o,truncated:g}}function buildRipgrepCommand(e){return[`rg --files --hidden`,`--glob '!.git/*'`,`--glob ${shellQuote(e.pattern)}`,shellQuote(e.normalizedPath)].join(` `)}function buildPosixFindCommand(e){let t=translateGlobToFindPattern(e.pattern),r=t.includes(`/`)?`-path ${shellQuote(`*/${t}`)}`:`-name ${shellQuote(t)}`;return[`find ${shellQuote(e.normalizedPath)}`,`-type f`,`-not -path '*/.git/*'`,r].join(` `)}function translateGlobToFindPattern(e){let t=e.replaceAll(`**`,`*`);for(;t.startsWith(`*/`);)t=t.slice(2);return t}function buildGlobExecutionError(e,t,n){let r=n.trim(),i=r.length>0?r:`no stderr output`;return Error(`glob failed (exit ${t}): ${i}\nCommand: ${e}`)}export{executeGlobOnSandbox};