import{n as e,o as t,r as n}from"./chunk-DR8-3Aex.js";import{n as r,t as i}from"./memoize-DNnuA2aU.js";import{l as a,s as o,u as s}from"./envUtils-BWeoiL4Y.js";import{n as c,t as l}from"./defineProperty-80gRi2ZW.js";import{Cn as u,Ln as d,Xn as f,wn as p}from"./schemas-BGAvj1T4.js";import{t as ee}from"./v4-f1i_CNUT.js";import{t as te}from"./ajv-B_OpU_Uh.js";import{St as ne,cn as re,n as ie,ut as ae,vn as oe}from"./state-sIHsFpDu.js";import{Bo as se,Dr as ce,Ho as le,Ko as ue,Pr as de,Ro as fe,S as pe,Vo as me,_ as he,v as ge,zo as _e}from"./paths-Ci1iwL5Y.js";import{E as ve,I as ye,K as be,O as xe,U as Se,_ as Ce,h as we,l as Te,p as Ee}from"./debug-otxXY3j-.js";import{J as De,et as Oe,o as ke,s as Ae}from"./log-DSV4Ht5l.js";import{i as je,o as Me}from"./platform-mh9ypxS8.js";import{s as Ne,u as Pe}from"./types-KeqFPzY5.js";import{n as Fe,t as Ie}from"./lazySchema-B0QShMaQ.js";import{i as Le,r as Re,t as ze}from"./cron-g_P3I5uT.js";import{join as Be}from"path";import{join as m,parse as Ve,resolve as h,sep as He}from"node:path";import{readFileSync as Ue}from"fs";import{createHash as We}from"node:crypto";import{randomUUID as Ge}from"crypto";import{mkdir as Ke,writeFile as qe}from"fs/promises";import{appendFile as Je,mkdir as Ye,readFile as g,readdir as Xe,rm as Ze,writeFile as Qe}from"node:fs/promises";function $e(e){return e.filter(e=>e.data?.type!==`hook_progress`)}function et(e,t){return e.name===t||(e.aliases?.includes(t)??!1)}function tt(e,t){return e.find(e=>et(e,t))}function nt(e){return{...it,userFacingName:()=>e.name,...e}}var rt,it,at=e((()=>{rt=()=>({mode:`default`,additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!0}),it={isEnabled:()=>!0,isConcurrencySafe:e=>!1,isReadOnly:e=>!1,isDestructive:e=>!1,checkPermissions:(e,t)=>Promise.resolve({behavior:`allow`,updatedInput:e}),toAutoClassifierInput:e=>``,userFacingName:e=>``}})),_,ot=e((()=>{_=`Bash`}));function st(){return`A powerful search tool built on ripgrep

  Usage:
  - ALWAYS use ${v} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${_} command. The ${v} tool has been optimized for correct permissions and access.
  - Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
  - Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
  - Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
  - Use ${le} tool for open-ended searches requiring multiple rounds
  - Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
  - Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
`}var v,ct=e((()=>{ue(),ot(),v=`Grep`})),lt,ut,dt,ft,pt=e((()=>{lt=`Edit`,ut=`/.claude/**`,dt=`~/.claude/**`,ft=`File has been unexpectedly modified. Read it again before attempting to write it.`}));function mt(e){let t=e.trim();if(!t)return null;if(t.endsWith(`-`)){let e=parseInt(t.slice(0,-1),10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:1/0}}let n=t.indexOf(`-`);if(n===-1){let e=parseInt(t,10);return isNaN(e)||e<1?null:{firstPage:e,lastPage:e}}let r=parseInt(t.slice(0,n),10),i=parseInt(t.slice(n+1),10);return isNaN(r)||isNaN(i)||r<1||i<1||i<r?null:{firstPage:r,lastPage:i}}function ht(){return!ce().toLowerCase().includes(`claude-3-haiku`)}function gt(e){let t=e.startsWith(`.`)?e.slice(1):e;return _t.has(t.toLowerCase())}var _t,vt=e((()=>{de(),_t=new Set([`pdf`])}));function yt(e,t,n){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.

Usage:
- The file_path parameter must be an absolute path, not a relative path
- By default, it reads up to ${xt} lines starting from the beginning of the file${t}
${n}
${e}
- This tool allows Claude Code to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Claude Code is a multimodal LLM.${ht()?`
- This tool can read PDF files (.pdf). For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges (e.g., pages: "1-5"). Reading a large PDF without the pages parameter will fail. Maximum 20 pages per request.`:``}
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
- This tool can only read files, not directories. To read a directory, use an ls command via the ${_} tool.
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`}var y,bt,xt,St,Ct,wt,Tt,Et=e((()=>{vt(),ot(),y=`Read`,bt=`File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current — refer to that instead of re-reading.`,xt=2e3,St=`Read a file from the local filesystem.`,Ct=`- Results are returned using cat -n format, with line numbers starting at 1`,wt=`- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters`,Tt=`- When you already know which part of the file you need, only read that part. This can be important for larger files.`}));function Dt(){return`\n- If this is an existing file, you MUST use the ${y} tool first to read the file's contents. This tool will fail if you did not read the file first.`}function Ot(){return`Writes a file to the local filesystem.

Usage:
- This tool will overwrite the existing file if there is one at the provided path.${Dt()}
- Prefer the Edit tool for modifying existing files \u2014 it only sends the diff. Only use this tool to create new files or for complete rewrites.
- NEVER create documentation files (*.md) or README files unless explicitly requested by the User.
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`}var b,kt=e((()=>{Et(),b=`Write`})),At,jt,Mt=e((()=>{At=`Glob`,jt=`- Fast file pattern matching tool that works with any codebase size
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
- Returns matching file paths sorted by modification time
- Use this tool when you need to find files by name patterns
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead`})),Nt,Pt=e((()=>{Nt=`NotebookEdit`}));function Ft(e,t,n){return`
Web page content:
---
${e}
---

${t}

${n?`Provide a concise response based on the content above. Include relevant details, code examples, and documentation excerpts as needed.`:`Provide a concise response based only on the content above. In your response:
 - Enforce a strict 125-character maximum for quotes from any source document. Open Source Software is ok as long as we respect the license.
 - Use quotation marks for exact language from articles; any language outside of the quotation should never be word-for-word the same.
 - You are not a lawyer and never comment on the legality of your own prompts and responses.
 - Never produce or reproduce exact song lyrics.`}
`}var It,Lt,Rt=e((()=>{It=`WebFetch`,Lt=`
- Fetches content from a specified URL and processes it using an AI model
- Takes a URL and a prompt as input
- Fetches the URL content, converts HTML to markdown
- Processes the content with the prompt using a small, fast model
- Returns the model's response about the content
- Use this tool when you need to retrieve and analyze web content

Usage notes:
  - IMPORTANT: If an MCP-provided web fetch tool is available, prefer using that tool instead of this one, as it may have fewer restrictions.
  - The URL must be a fully-formed valid URL
  - HTTP URLs will be automatically upgraded to HTTPS
  - The prompt should describe what information you want to extract from the page
  - This tool is read-only and does not modify any files
  - Results may be summarized if the content is very large
  - Includes a self-cleaning 15-minute cache for faster responses when repeatedly accessing the same URL
  - When a URL redirects to a different host, the tool will inform you and provide the redirect URL in a special format. You should then make a new WebFetch request with the redirect URL to fetch the content.
  - For GitHub URLs, prefer using the gh CLI via Bash instead (e.g., gh pr view, gh issue view, gh api).
`})),x,zt,Bt=e((()=>{x=`ExitPlanMode`,zt=`ExitPlanMode`})),S,Vt=e((()=>{S=`EnterPlanMode`})),C,Ht,Ut,Wt,Gt=e((()=>{Bt(),C=`AskUserQuestion`,Ht=`Asks the user multiple choice questions to gather information, clarify ambiguity, understand preferences, make decisions or offer them choices.`,Ut={markdown:`
Preview feature:
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
- ASCII mockups of UI layouts or components
- Code snippets showing different implementations
- Diagram variations
- Configuration examples

Preview content is rendered as markdown in a monospace box. Multi-line text with newlines is supported. When any option has a preview, the UI switches to a side-by-side layout with a vertical option list on the left and preview on the right. Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
`,html:`
Preview feature:
Use the optional \`preview\` field on options when presenting concrete artifacts that users need to visually compare:
- HTML mockups of UI layouts or components
- Formatted code snippets showing different implementations
- Visual comparisons or diagrams

Preview content must be a self-contained HTML fragment (no <html>/<body> wrapper, no <script> or <style> tags — use inline style attributes instead). Do not use previews for simple preference questions where labels and descriptions suffice. Note: previews are only supported for single-select questions (not multiSelect).
`},Wt=`Use this tool when you need to ask the user questions during execution. This allows you to:
1. Gather user preferences or requirements
2. Clarify ambiguous instructions
3. Get decisions on implementation choices as you work
4. Offer choices to the user about what direction to take.

Usage notes:
- Users will always be able to select "Other" to provide custom text input
- Use multiSelect: true to allow multiple answers to be selected for a question
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label

Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ${x} for plan approval. IMPORTANT: Do not reference "the plan" in your questions (e.g., "Do you have feedback about the plan?", "Does the plan look good?") because the user cannot see the plan in the UI until you call ${x}. If you need plan approval, use ${x} instead.
`}));function Kt(){if(process.env.CLAUDE_CODE_OVERRIDE_DATE)return process.env.CLAUDE_CODE_OVERRIDE_DATE;let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function qt(){return(process.env.CLAUDE_CODE_OVERRIDE_DATE?new Date(process.env.CLAUDE_CODE_OVERRIDE_DATE):new Date).toLocaleString(`en-US`,{month:`long`,year:`numeric`})}var Jt,Yt=e((()=>{i(),Jt=r(Kt)}));function Xt(){return`
- Allows Claude to search the web and use the results to inform responses
- Provides up-to-date information for current events and recent data
- Returns search result information formatted as search result blocks, including links as markdown hyperlinks
- Use this tool for accessing information beyond Claude's knowledge cutoff
- Searches are performed automatically within a single API call

CRITICAL REQUIREMENT - You MUST follow this:
  - After answering the user's question, you MUST include a "Sources:" section at the end of your response
  - In the Sources section, list all relevant URLs from the search results as markdown hyperlinks: [Title](URL)
  - This is MANDATORY - never skip including sources in your response
  - Example format:

    [Your answer here]

    Sources:
    - [Source Title 1](https://example.com/1)
    - [Source Title 2](https://example.com/2)

Usage notes:
  - Domain filtering is supported to include or block specific websites
  - Web search is only available in the US

IMPORTANT - Use the correct year in search queries:
  - The current month is ${qt()}. You MUST use this year when searching for recent information, documentation, or current events.
  - Example: If the user asks for "latest React docs", search for "React documentation" with the current year, NOT last year
`}var w,Zt=e((()=>{Yt(),w=`WebSearch`})),T,Qt=e((()=>{T=`TodoWrite`})),$t,en=e((()=>{$t=`PowerShell`}));function tn(){return je()===`windows`?process.env.USER_TYPE===`ant`?!a(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):s(process.env.CLAUDE_CODE_USE_POWERSHELL_TOOL):!1}var E,nn=e((()=>{ot(),en(),o(),Me(),E=[_,$t]})),D,rn=e((()=>{D=`Skill`})),O,an=e((()=>{O=`SendMessage`})),k,on=e((()=>{k=`TaskCreate`})),A,sn=e((()=>{A=`TaskGet`})),j,cn=e((()=>{j=`TaskList`})),M,ln=e((()=>{M=`TaskUpdate`})),N,un=e((()=>{N=`SearchExtraTools`}));function dn(e){return e.isNonInteractiveSession}function fn(e){let t=vn.get(e);if(t)return t;let n=pn(e);return vn.set(e,n),n}function pn(e){try{let t=new mn.Ajv({allErrors:!0});if(!t.validateSchema(e))return{error:t.errorsText(t.errors)};let n=t.compile(e);return{tool:{..._n,inputJSONSchema:e,async call(e){if(!n(e)){let e=n.errors?.map(e=>`${e.instancePath||`root`}: ${e.message}`).join(`, `);throw new ye(`Output does not match required schema: ${e}`,`StructuredOutput schema mismatch: ${(e??``).slice(0,150)}`)}return{data:`Structured output provided successfully`,structured_output:e}}}}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}var mn,hn,gn,P,_n,vn,yn=e((()=>{mn=t(te(),1),ee(),at(),Se(),Ie(),ve(),hn=Fe(()=>p({}).passthrough()),gn=Fe(()=>d().describe(`Structured output tool result`)),P=`StructuredOutput`,_n=nt({isMcp:!1,isEnabled(){return!0},isConcurrencySafe(){return!0},isReadOnly(){return!0},isOpenWorld(){return!1},name:P,searchHint:`return the final response as structured JSON`,maxResultSizeChars:1e5,async description(){return`Return structured output in the requested format`},async prompt(){return`Use this tool to return your final response in the requested structured format. You MUST call this tool exactly once at the end of your response to provide the structured output.`},get inputSchema(){return hn()},get outputSchema(){return gn()},async call(e){return{data:`Structured output provided successfully`,structured_output:e}},async checkPermissions(e){return{behavior:`allow`,updatedInput:e}},renderToolUseMessage(e){let t=Object.keys(e);return t.length===0?null:t.length<=3?t.map(t=>`${t}: ${xe(e[t])}`).join(`, `):`${t.length} fields: ${t.slice(0,3).join(`, `)}…`},renderToolUseRejectedMessage(){return`Structured output rejected`},renderToolUseErrorMessage(){return`Structured output error`},renderToolUseProgressMessage(){return null},renderToolResultMessage(e){return e},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:e}}}),vn=new WeakMap})),bn,xn,Sn,Cn=e((()=>{Oe(),bn=`Sleep`,xn=`Wait for a specified duration`,Sn=`Wait for a specified duration. The user can interrupt the sleep at any time.

Use this when the user tells you to sleep or rest, when you have nothing to do, or when you're waiting for something.

You may receive <${De}> prompts — these are periodic check-ins. Look for useful work to do before sleeping.

You can call this concurrently with other tools — it won't interfere with them.

Prefer this over \`Bash(sleep ...)\` — it doesn't hold a shell process.

Each wake-up costs an API call, but the prompt cache expires after 5 minutes of inactivity — balance accordingly.`})),wn,Tn=e((()=>{wn=`Interact with Language Server Protocol (LSP) servers to get code intelligence features.

Supported operations:
- goToDefinition: Find where a symbol is defined
- findReferences: Find all references to a symbol
- hover: Get hover information (documentation, type info) for a symbol
- documentSymbol: Get all symbols (functions, classes, variables) in a document
- workspaceSymbol: Search for symbols across the entire workspace
- goToImplementation: Find implementations of an interface or abstract method
- prepareCallHierarchy: Get call hierarchy item at a position (functions/methods)
- incomingCalls: Find all functions/methods that call the function at a position
- outgoingCalls: Find all functions/methods called by the function at a position

All operations require:
- filePath: The file to operate on
- line: The line number (1-based, as shown in editors)
- character: The character offset (1-based, as shown in editors)

Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.`})),En=n({VERIFY_PLAN_EXECUTION_TOOL_NAME:()=>F}),F,Dn=e((()=>{F=`VerifyPlanExecution`})),I,On=e((()=>{I=`ExecuteExtraTool`})),kn,An=e((()=>{kn=`EnterWorktree`})),jn,Mn=e((()=>{jn=`ExitWorktree`})),Nn=e((()=>{})),L,R,Pn,z,Fn,B,V=e((()=>{L=`Workflow`,R=`.claude/workflows`,Pn=`.claude/workflow-runs`,z=[`.ts`,`.js`,`.mjs`],Fn=1e3,B=4096}));function In(e){return{[H]:e}}function Ln(e){return typeof e==`object`&&!!e&&H in e}function Rn(e){return e[H]}var H,zn=e((()=>{H=Symbol(`workflow.hostHandle`)}));function Bn(e,t){return e.kind===`agentType`?t.agentType===e.agentType:e.kind===`model`?typeof t.model==`string`&&t.model.startsWith(e.pattern):e.match(t)}var Vn,Hn,Un=e((()=>{c(),Vn=class extends Error{constructor(e){super(e),this.name=`AdapterNotFoundError`}},Hn=class{constructor(){l(this,`adapters`,new Map),l(this,`rules`,[]),l(this,`defaultId`,null)}register(e){return this.adapters.set(e.id,e),this}default(e){return this.defaultId=e,this}route(e){return this.rules.push(e),this}has(e){return this.adapters.has(e)}get(e){return this.adapters.get(e)}resolve(e){for(let t of this.rules)if(Bn(t,e)){let e=this.adapters.get(t.adapter);if(e)return e}if(this.defaultId){let e=this.adapters.get(this.defaultId);if(e)return e}throw new Vn(`No adapter matched (rules=${this.rules.length}, default=${this.defaultId??`none`})`)}async initializeAll(){for(let e of this.adapters.values())await e.initialize?.()}async disposeAll(){for(let e of this.adapters.values())await e.dispose?.()}}}));function Wn(){return 3}function Gn(e){return e===void 0||Number.isNaN(e)?3:Math.max(1,Math.min(Math.trunc(e),16))}var Kn,qn=e((()=>{V(),c(),Kn=class{constructor(e){l(this,`available`,void 0),l(this,`waiters`,[]),this.available=Math.max(1,Math.floor(e))}async acquire(e){if(e?.aborted)throw Error(`Semaphore.acquire aborted (signal already aborted)`);return this.available>0?(--this.available,()=>this.release()):new Promise((t,n)=>{let r=()=>{let e=this.waiters.indexOf(i);e>=0&&this.waiters.splice(e,1),n(Error(`Semaphore.acquire aborted`))},i={wake:()=>{e?.removeEventListener(`abort`,r),t(()=>this.release())},cleanup:()=>e?.removeEventListener(`abort`,r)};e?.addEventListener(`abort`,r,{once:!0}),this.waiters.push(i)})}release(){let e=this.waiters.shift();e?e.wake():this.available+=1}}}));function Jn(e){let t=$n.exec(e);if(!t)return{meta:null,body:e};let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]!==`{`)throw new W("meta must be an object literal `{ ... }`");let r=0,i=n,a=null;for(;n<e.length;n++){let t=e[n];if(a){if(t===`\\`){n++;continue}t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`"){a=t;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0)){n++;break}}if(r!==0)throw new W(`meta literal braces are not closed`);let o=e.slice(i,n),s;try{s=Function(`return (${o})`)()}catch(e){throw new W(`meta must be a plain literal (no variable/function calls/interpolation): ${e.message}`)}return{meta:Yn(s),body:e.slice(0,t.index)+e.slice(n).replace(/^[ \t]*;[ \t]*\n/,`
`)}}function Yn(e){if(typeof e!=`object`||!e||Array.isArray(e))throw new W(`meta must be an object`);let t=e;if(typeof t.name!=`string`||typeof t.description!=`string`)throw new W(`meta must include string name and description`);return t}function Xn(){let e=function(...e){if(e.length===0)throw new er(`Date.now()/new Date()`);return new Date(...e)};return e.now=()=>{throw new er(`Date.now()`)},e.parse=Date.parse,e.UTC=Date.UTC,e}function Zn(){return new Proxy(Math,{get(e,t,n){return t===`random`?()=>{throw new er(`Math.random()`)}:Reflect.get(e,t,n)}})}function Qn(e){if(/^\s*import\b/m.test(e))throw new W(`workflow scripts are the body of new AsyncFunction (not ESM modules); import is not supported. agent / parallel / pipeline / phase / log / workflow / args / budget are injected as parameters — use them directly.`);if(/\bimport\s*\(/m.test(e))throw new W(`dynamic import(...) is forbidden in workflow scripts: it bypasses the Date/Math sandbox and breaks resume determinism. The sandbox does not guarantee security (same trust level as the LLM), but explicit escapes are prohibited. Inject external dependencies via args.`);if(/^\s*export\b/m.test(e))throw new W(`workflow scripts allow only one export const meta = {...} (already extracted by the engine). Remove other export / export default statements; use top-level return for the result.`)}function U(e){let{meta:t,body:n}=Jn(e);Qn(n);let r;try{r=new tr(`agent`,`parallel`,`pipeline`,`phase`,`log`,`workflow`,`args`,`budget`,`Date`,`Math`,n)}catch(e){throw new W(`Script syntax error: ${e.message}`)}let i=Xn(),a=Zn();return{meta:t,async execute(e,t,n){return r(e.agent,e.parallel,e.pipeline,e.phase,e.log,e.workflow,t,n,i,a)}}}var W,$n,er,tr,nr=e((()=>{W=class extends Error{constructor(e){super(e),this.name=`ScriptError`}},$n=/export\s+const\s+meta\s*=\s*/,er=class extends Error{constructor(e){super(`${e} is not available in workflow scripts (would break resume determinism). Pass timestamps/random seeds via args.`),this.name=`NonDeterministicError`}},tr=Object.getPrototypeOf(async function(){}).constructor}));function rr(e){let{label:t,phase:n,...r}=e,i=Object.keys(r).sort(),a={};for(let e of i)a[e]=r[e];return JSON.stringify(a)}function ir(e,t){return We(`sha256`).update(e+`
`+rr(t)).digest(`hex`)}function ar(e){let t=t=>m(e,t,`journal.jsonl`);return{async read(e){try{return(await g(t(e),`utf-8`)).split(`
`).filter(e=>e.trim().length>0).map(e=>JSON.parse(e)).sort((e,t)=>(e.seq??0)-(t.seq??0))}catch{return[]}},async append(n,r){await Ye(m(e,n),{recursive:!0}),await Je(t(n),JSON.stringify(r)+`
`,`utf-8`)},async truncate(t){await Ze(m(e,t),{recursive:!0,force:!0})}}}var or=e((()=>{})),sr,cr,lr=e((()=>{c(),sr=class extends Error{constructor(){super(`workflow token budget exhausted (budget.total reached the cap)`),this.name=`BudgetExhaustedError`}},cr=class{constructor(e){l(this,`spentTokens`,0),this.total=e}spent(){return this.spentTokens}remaining(){return this.total==null?1/0:Math.max(0,this.total-this.spentTokens)}addOutputTokens(e){e>0&&(this.spentTokens+=e)}assertCanSpend(){if(this.total!=null&&this.spentTokens>=this.total)throw new sr}}}));function ur(e,t){let n=fr.get(t);n||(n=new dr.Ajv({allErrors:!0,strict:!1}).compile(t),fr.set(t,n));let r=n(e);return{valid:r,errors:r?[]:(n.errors??[]).map(e=>e.message??`validation error`)}}var dr,fr,pr=e((()=>{dr=t(te(),1),fr=new WeakMap}));function mr(e,t){let n=h(e),r=h(n,t);return r===n?!0:r.startsWith(n+He)}function hr(e){return typeof e!=`string`||e.length===0||e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e===`.`||e===`..`?null:e}var gr=e((()=>{}));function _r(e){return z.includes(e.toLowerCase())}async function vr(e,t){for(let n of z){let r=h(e,t+n);if(!mr(e,r))return null;try{return{path:r,content:await g(r,`utf-8`)}}catch{}}return null}async function yr(e){let t;try{t=await Xe(e)}catch{return[]}return t.filter(e=>_r(Ve(e).ext)).map(e=>Ve(e).name).sort()}var br=e((()=>{V(),gr()})),G,K,xr=e((()=>{G=class extends Error{constructor(e){super(e),this.name=`WorkflowError`}},K=class extends Error{constructor(){super(`workflow has been aborted`),this.name=`WorkflowAbortedError`}}}));function Sr(e,t){return{semaphore:new Kn(Gn(t)),budget:new cr(e),agentCountBox:{value:0},agentIdSeq:{value:0},depth:0}}function Cr(e){let t=Sr(e.budgetTotal,e.maxConcurrency);return{ports:e.ports,host:e.host,signal:e.signal,runId:e.runId,workflowName:e.workflowName,cwd:e.cwd,resources:t,journal:e.journal?[...e.journal]:[],journalIndex:0,journalInvalidated:!1,currentPhase:null}}var wr=e((()=>{lr(),qn()}));function Tr(e,t){let n=t=>{e.ports.progressEmitter.emit({runId:e.runId,...t})};return{agent:async(t,r={})=>{let i=e.resources;if(i.agentCountBox.value>=1e3)throw new G(`workflow exceeds total agent cap (${Fn})`);let a=i.agentIdSeq.value++,o={prompt:t,...r},s=ir(t,o),c=r.label,l=r.phase??e.currentPhase??void 0;if(!e.journalInvalidated&&e.journalIndex<e.journal.length){let t=e.journal[e.journalIndex];if(t.key===s)return e.journalIndex++,n({type:`agent_done`,agentId:a,label:c,phase:l,result:t.result}),Er(t.result);e.journalInvalidated=!0,e.journal=e.journal.slice(0,e.journalIndex),await e.ports.journalStore.truncate(e.runId)}let u;try{u=await e.resources.semaphore.acquire(e.signal)}catch{throw new K}try{if(e.signal.aborted)throw new K;if(i.budget.assertCanSpend(),e.ports.taskRegistrar.pendingAction(e.runId)?.kind===`skip`)return n({type:`agent_done`,agentId:a,label:c,phase:l,result:{kind:`skipped`}}),null;e.resources.agentCountBox.value++,n({type:`agent_started`,agentId:a,label:c,phase:l});let t=e.ports.agentAdapterRegistry,r=t?{host:e.host,signal:e.signal,runId:e.runId,agentId:a,onProgress:e=>{n({type:`agent_progress`,agentId:a,label:c,phase:l,...e})},...e.ports.taskRegistrar.registerAgentAbort?{registerAgentAbort:(t,n)=>{e.ports.taskRegistrar.registerAgentAbort?.(e.runId,t,n)}}:{},...e.ports.taskRegistrar.unregisterAgentAbort?{unregisterAgentAbort:t=>{e.ports.taskRegistrar.unregisterAgentAbort?.(e.runId,t)}}:{}}:null,u=t?t.resolve(o):null,d=()=>u?u.run(o,r):e.ports.agentRunner.runAgentToResult(o,e.host),f;try{if(f=await d(),f.kind===`dead`){let t=typeof f.detail==`string`?f.detail:``;e.ports.logger.warn?.(`agent "${c??`#${a}`}" returned dead`+(f.reason?` (${f.reason})`:``)+(t?`: ${t.slice(0,150)}`:``)+`; retrying once`),f=await d()}}catch(t){if(t instanceof K)throw t;let n=t instanceof Error?t.message:String(t);e.ports.logger.warn?.(`agent "${c??`#${a}`}" threw (${n}); retrying once`);try{f=await d()}catch(e){if(e instanceof K)throw e;f={kind:`dead`,reason:`runagent-threw`,detail:e instanceof Error?e.message:String(e)}}}f.kind===`ok`&&e.resources.budget.addOutputTokens(f.usage.outputTokens),n({type:`agent_done`,agentId:a,label:c,phase:l,result:f});let p={key:s,seq:a,result:f};return e.journal.push(p),e.journalIndex++,await e.ports.journalStore.append(e.runId,p),Er(f)}finally{u()}},parallel:async t=>{if(t.length>4096)throw new G(`parallel exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,n)=>{try{return await t()}catch(t){return e.ports.logger.warn?.(`parallel thunk #${n} failed: ${t.message}`),null}}))},pipeline:async(t,...n)=>{if(t.length>4096)throw new G(`pipeline exceeds the per-call items cap (${B})`);return Promise.all(t.map(async(t,r)=>{try{let e=t;for(let i of n)e=await i(e,t,r);return e}catch(t){return e.ports.logger.warn?.(`pipeline item #${r} failed: ${t.message}`),null}}))},phase:t=>{e.currentPhase&&n({type:`phase_done`,phase:e.currentPhase}),e.currentPhase=t,n({type:`phase_started`,phase:t})},log:e=>{n({type:`log`,message:e})},workflow:async(n,r)=>{if(e.resources.depth>=1)throw new G(`workflow() nesting allows only one level`);return t({...typeof n==`string`?{name:n}:{scriptPath:n.scriptPath},args:r})}}}function Er(e){return e.kind===`ok`?e.output:null}var Dr=e((()=>{V(),xr(),or()}));async function Or(e){let{ports:t}=e,n;try{n=U(e.script)}catch(n){let r=n.message;return t.progressEmitter.emit({type:`run_done`,runId:e.runId,status:`failed`,error:r}),{status:`failed`,error:r}}let r=e.workflowName??n.meta?.name??`workflow`,i=[],a=!1;e.resume&&!e.scriptChanged?i=await t.journalStore.read(e.runId):e.scriptChanged&&(await t.journalStore.truncate(e.runId),a=!0);let o=Cr({ports:t,host:e.host,signal:e.signal,runId:e.runId,workflowName:r,cwd:e.cwd,budgetTotal:e.budgetTotal,maxConcurrency:e.maxConcurrency,journal:i});a&&(o.journalInvalidated=!0),t.progressEmitter.emit({type:`run_started`,runId:e.runId,workflowName:r,meta:n.meta});let s=async t=>{let n=await kr(t,e.cwd),r;try{r=U(n)}catch(e){throw new G(`Sub-workflow script error: ${e.message}`)}let i=o.resources.depth;o.resources.depth+=1;try{let e=Tr(o,s);return await r.execute(e,t.args,o.resources.budget)}finally{o.resources.depth=i}},c=Tr(o,s),l=()=>{o.currentPhase&&t.progressEmitter.emit({type:`phase_done`,runId:e.runId,phase:o.currentPhase})},u;try{u={status:`completed`,returnValue:await n.execute(c,e.args,o.resources.budget)}}catch(e){u=e instanceof K?{status:`killed`}:{status:`failed`,error:e.message}}return l(),t.progressEmitter.emit({type:`run_done`,runId:e.runId,...u}),u}async function kr(e,t){if(e.script)return e.script;if(e.scriptPath)return await g(e.scriptPath,`utf-8`);if(e.name){let n=await vr(m(t,R),e.name);if(!n)throw new G(`Sub-workflow "${e.name}" not found`);return n.content}throw new G(`workflow() requires name or scriptPath`)}var Ar=e((()=>{V(),wr(),xr(),Dr(),br(),nr()}));function jr(e){return{emit:e}}function Mr(){let e=[];return{emitter:{emit:t=>void e.push(t)},events:e}}var Nr=e((()=>{})),Pr,Fr=e((()=>{ee(),Pr=p({script:d().optional().describe(`Self-contained workflow script source (inline)`),name:d().optional().describe(`Named workflow, resolved to .claude/workflows/<name>.ts|js|mjs`),scriptPath:d().optional().describe(`Absolute path to an existing script file`),args:f().optional().describe(`The args global variable passed through to the script. Pass a real JSON value (object/array/string), not a JSON string.`),resumeFromRunId:d().optional().describe(`Resume the specified run, replaying the journal`),description:d().optional().describe(`A short description of this invocation (3-5 words)`),title:d().optional().describe(`Progress viewer title`),maxConcurrency:u().int().min(1).max(16).optional().describe(`Concurrency cap for agent(). Defaults to 3 (max 16). When the workflow contains heavy parallel/pipeline fan-out, you may confirm the desired concurrency with the user via AskUserQuestion before launching.`)})}));async function Ir(e,t,n){let r=m(n,Pn,t);await Ye(r,{recursive:!0});let i=m(r,`script.js`);return await Qe(i,e,`utf-8`),i}var Lr=e((()=>{V()}));function Rr(e){return{name:L,inputSchema:Pr,isEnabled:()=>!0,isReadOnly:()=>!1,async description(){return`Execute a workflow script that orchestrates multiple subagents to complete a task`},async prompt(){return Ur},renderToolUseMessage(e){return e.resumeFromRunId?`Workflow resume: ${e.resumeFromRunId}`:`Workflow: ${e.name??e.scriptPath??(e.script?`inline`:`unknown`)}`},async call(t,n,r,i){let a=e.hostFactory({context:n,canUseTool:r,parentMessage:i}),o,s;try{let e=await Hr(t,a.cwd);o=e.script,s=e.workflowFile}catch(e){return{data:{output:`Error: ${e.message}`}}}try{U(o)}catch(e){return{data:{output:`Error: script validation failed: ${e.message}`}}}let c=t.name??t.title??`workflow`,{runId:l,signal:u}=e.taskRegistrar.register({workflowName:c,...s?{workflowFile:s}:{},...t.description?{summary:t.description}:{},...a.toolUseId?{toolUseId:a.toolUseId}:{},...t.resumeFromRunId?{runId:t.resumeFromRunId}:{}},a.handle);if(!s&&t.script)try{s=await Ir(t.script,l,a.cwd)}catch(t){e.logger.warn?.(`inline script persist failed: ${t.message}`)}Or({script:o,...t.args===void 0?{}:{args:Vr(t.args)},runId:l,workflowName:c,ports:e,host:a.handle,signal:u,cwd:a.cwd,budgetTotal:a.budgetTotal,...t.maxConcurrency===void 0?{}:{maxConcurrency:t.maxConcurrency},...t.resumeFromRunId?{resume:!0}:{}}).then(t=>zr(e,t,l)).catch(t=>e.taskRegistrar.fail(l,t.message));let d=s??`<inline run ${l}>`;return{data:{output:[`Workflow started (running in the background).`,`run_id: ${l}`,`workflow: ${c}`,`script: ${d}`,``,`You will be notified on completion. Use /workflows to view live progress.`].join(`
`)}}},mapToolResultToToolResultBlockParam(e,t){return{tool_use_id:t,type:`tool_result`,content:[{type:`text`,text:e.output}]}}}}function zr(e,t,n){if(t.status===`completed`){let r=t.returnValue==null?`(no return value)`:Br(t.returnValue);e.taskRegistrar.complete(n,r)}else t.status===`failed`?e.taskRegistrar.fail(n,t.error??`workflow failed`):e.taskRegistrar.kill(n)}function Br(e){if(typeof e==`string`)return e.slice(0,500);try{return JSON.stringify(e).slice(0,500)}catch{return String(e)}}function Vr(e){if(typeof e!=`string`)return e;try{let t=JSON.parse(e);return typeof t==`object`&&t?t:e}catch{return e}}async function Hr(e,t){if(e.script)return{script:e.script};if(e.scriptPath){let n=h(t,e.scriptPath);if(!mr(t,n))throw Error(`scriptPath "${e.scriptPath}" is out of bounds (after resolve, ${n} is not within cwd ${t})`);return{script:await g(n,`utf-8`),workflowFile:n}}if(e.name){if(hr(e.name)===null)throw Error(`Named workflow name "${e.name}" is invalid (contains path separators or is . / ..)`);let n=await vr(m(t,R),e.name);if(!n)throw Error(`Named workflow "${e.name}" not found (looked in ${R}/)`);return{script:n.content,workflowFile:n.path}}throw Error(`One of script, name, or scriptPath must be provided`)}var Ur,Wr=e((()=>{V(),br(),Ar(),nr(),gr(),Fr(),Lr(),Ur='Use the Workflow tool to execute a workflow script that orchestrates multiple subagents deterministically. The script runs in the background; you receive a run_id immediately and are notified on completion.\n\nProvide the script inline via "script", or reference a named workflow via "name" (resolved from .claude/workflows/), or an existing file via "scriptPath". Pass "args" as a real JSON value (object/array/string), not a stringified string.\n\nUse "resumeFromRunId" to resume a prior run — completed agent() calls replay from the journal instantly.\n\nConcurrency: default is 3 (hard ceiling 16). OMIT maxConcurrency to use 3. To set maxConcurrency to ANY value other than 3, you MUST first ask the user via AskUserQuestion — propose 3 / 6 / 9 (or other tiers matching the fan-out width) with 3 marked "(Recommended)". The ONLY exception: the user has ALREADY specified a concurrency number in this session ("use 6", "maxConcurrency 9") — then honor it without re-asking. Never silently raise concurrency above 3 just because the workflow fans out; 3 is the recommended default.\n\nScript execution model (common pitfalls — getting these wrong is the #1 cause of script errors): the script is the body of `new AsyncFunction` — NOT an ESM module, and TypeScript is NOT transpiled. Therefore:\n- Do NOT use `import` — `agent`, `parallel`, `pipeline`, `phase`, `log`, `workflow`, `args`, and `budget` are injected as parameters; reference them directly.\n- Do NOT use TS type annotations, `interface`, `enum`, `as`, or generics — the engine does not transpile, so even a .ts file with type syntax fails to parse.\n- Keep EXACTLY ONE `export const meta = {...}` (plain literal) and remove every other `export` / `export default`.\n- Return the result with a top-level `return`.\nPrefer .js / .mjs. See /ultracode for the full playbook and quality patterns.'})),Gr=e((()=>{V()})),Kr=n({AdapterNotFoundError:()=>Vn,AgentAdapterRegistry:()=>Hn,Budget:()=>cr,BudgetExhaustedError:()=>sr,DEFAULT_MAX_CONCURRENCY:()=>3,MAX_CONCURRENCY_CAP:()=>16,MAX_ITEMS_PER_CALL:()=>B,MAX_TOTAL_AGENTS:()=>Fn,ScriptError:()=>W,Semaphore:()=>Kn,WORKFLOW_DIR_NAME:()=>R,WORKFLOW_RUNS_DIR:()=>Pn,WORKFLOW_SCRIPT_EXTENSIONS:()=>z,WORKFLOW_TOOL_NAME:()=>L,WorkflowAbortedError:()=>K,WorkflowError:()=>G,agentCallKey:()=>ir,clampMaxConcurrency:()=>Gn,createBufferingEmitter:()=>Mr,createEngineContext:()=>Cr,createFileJournalStore:()=>ar,createHostHandle:()=>In,createProgressEmitter:()=>jr,createSharedResources:()=>Sr,createWorkflowTool:()=>Rr,extractMeta:()=>Jn,isHostHandle:()=>Ln,listNamedWorkflows:()=>yr,makeHooks:()=>Tr,maxConcurrency:()=>Wn,parseScript:()=>U,persistInlineScript:()=>Ir,resolveNamedWorkflow:()=>vr,runWorkflow:()=>Or,unwrapHostHandle:()=>Rn,validateAgainstSchema:()=>ur,workflowInputSchema:()=>Pr}),qr=e((()=>{Nn(),V(),zn(),Un(),qn(),nr(),or(),lr(),pr(),br(),xr(),wr(),Dr(),Ar(),Nr(),Wr(),Fr(),Lr(),Gr()}));function Jr(e){return Be(e??ae(),ai)}async function q(e){let t=we(),n;try{n=await t.readFile(Jr(e),{encoding:`utf-8`})}catch(e){return be(e)||Ae(e),[]}let r=Pe(n,!1);if(!r||typeof r!=`object`)return[];let i=r;if(!Array.isArray(i.tasks))return[];let a=[];for(let e of i.tasks){if(!e||typeof e.id!=`string`||typeof e.cron!=`string`||typeof e.prompt!=`string`||typeof e.createdAt!=`number`){Ee(`[ScheduledTasks] skipping malformed task: ${xe(e)}`);continue}if(!Le(e.cron)){Ee(`[ScheduledTasks] skipping task ${e.id} with invalid cron '${e.cron}'`);continue}a.push({id:e.id,cron:e.cron,prompt:e.prompt,createdAt:e.createdAt,...typeof e.lastFiredAt==`number`?{lastFiredAt:e.lastFiredAt}:{},...e.recurring?{recurring:!0}:{},...e.permanent?{permanent:!0}:{}})}return a}function Yr(e){let t;try{t=Ue(Jr(e),`utf-8`)}catch{return!1}let n=Pe(t,!1);if(!n||typeof n!=`object`)return!1;let r=n.tasks;return Array.isArray(r)&&r.length>0}async function Xr(e,t){let n=t??ae();await Ke(Be(n,`.claude`),{recursive:!0});let r={tasks:e.map(({durable:e,...t})=>t)};await qe(Jr(n),xe(r,null,2)+`
`,`utf-8`)}async function Zr(e,t,n,r,i){let a=Ge().slice(0,8),o={id:a,cron:e,prompt:t,createdAt:Date.now(),...n?{recurring:!0}:{}};if(!r)return ie({...o,...i?{agentId:i}:{}}),a;let s=await q();return s.push(o),await Xr(s),a}async function Qr(e,t){if(e.length===0||t===void 0&&oe(e)===e.length)return;let n=new Set(e),r=await q(t),i=r.filter(e=>!n.has(e.id));i.length!==r.length&&await Xr(i,t)}async function $r(e,t,n){if(e.length===0)return;let r=new Set(e),i=await q(n),a=!1;for(let e of i)r.has(e.id)&&(e.lastFiredAt=t,a=!0);a&&await Xr(i,n)}async function ei(e){let t=await q(e);if(e!==void 0)return t;let n=ne().map(e=>({...e,durable:!1}));return[...t,...n]}function J(e,t){let n=Le(e);if(!n)return null;let r=ze(n,new Date(t));return r?r.getTime():null}function ti(e){let t=parseInt(e.slice(0,8),16)/4294967296;return Number.isFinite(t)?t:0}function ni(e,t,n,r=Y){let i=J(e,t);if(i===null)return null;let a=J(e,i);return a===null?i:i+Math.min(ti(n)*r.recurringFrac*(a-i),r.recurringCapMs)}function ri(e,t,n,r=Y){let i=J(e,t);if(i===null)return null;if(new Date(i).getMinutes()%r.oneShotMinuteMod!==0)return i;let a=r.oneShotFloorMs+ti(n)*(r.oneShotMaxMs-r.oneShotFloorMs);return Math.max(i-a,t)}function ii(e,t){return e.filter(e=>{let n=J(e.cron,e.createdAt);return n!==null&&n<t})}var ai,Y,oi=e((()=>{re(),Re(),Te(),Se(),Ce(),Ne(),ke(),ve(),ai=Be(`.claude`,`scheduled_tasks.json`),Y={recurringFrac:.1,recurringCapMs:900*1e3,oneShotMaxMs:90*1e3,oneShotFloorMs:0,oneShotMinuteMod:30,recurringMaxAgeMs:10080*60*1e3}})),si=n({CRON_CREATE_TOOL_NAME:()=>Z,CRON_DELETE_DESCRIPTION:()=>hi,CRON_DELETE_TOOL_NAME:()=>Q,CRON_LIST_DESCRIPTION:()=>gi,CRON_LIST_TOOL_NAME:()=>$,DEFAULT_MAX_AGE_DAYS:()=>X,buildCronCreateDescription:()=>ui,buildCronCreatePrompt:()=>di,buildCronDeletePrompt:()=>fi,buildCronListPrompt:()=>pi,isDurableCronEnabled:()=>li,isKairosCronEnabled:()=>ci});function ci(){return!s(process.env.CLAUDE_CODE_DISABLE_CRON)}function li(){return ge(`tengu_kairos_cron_durable`,!0,mi)}function ui(e){return e?`Schedule a prompt to run at a future time — either recurring on a cron schedule, or once at a specific time. Pass durable: true to persist to .claude/scheduled_tasks.json; otherwise session-only.`:`Schedule a prompt to run at a future time within this Claude session — either recurring on a cron schedule, or once at a specific time.`}function di(e){return`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.

Uses standard 5-field cron in the user's local timezone: minute hour day-of-month month day-of-week. "0 9 * * *" means 9am local — no timezone conversion needed.

## One-shot tasks (recurring: false)

For "remind me at X" or "at <time>, do Y" requests — fire once then auto-delete.
Pin minute/hour/day-of-month/month to specific values:
  "remind me at 2:30pm today to check the deploy" → cron: "30 14 <today_dom> <today_month> *", recurring: false
  "tomorrow morning, run the smoke test" → cron: "57 8 <tomorrow_dom> <tomorrow_month> *", recurring: false

## Recurring jobs (recurring: true, the default)

For "every N minutes" / "every hour" / "weekdays at 9am" requests:
  "*/5 * * * *" (every 5 min), "0 * * * *" (hourly), "0 9 * * 1-5" (weekdays at 9am local)

## Avoid the :00 and :30 minute marks when the task allows it

Every user who asks for "9am" gets \`0 9\`, and every user who asks for "hourly" gets \`0 *\` — which means requests from across the planet land on the API at the same instant. When the user's request is approximate, pick a minute that is NOT 0 or 30:
  "every morning around 9" → "57 8 * * *" or "3 9 * * *" (not "0 9 * * *")
  "hourly" → "7 * * * *" (not "0 * * * *")
  "in an hour or so, remind me to..." → pick whatever minute you land on, don't round

Only use minute 0 or 30 when the user names that exact time and clearly means it ("at 9:00 sharp", "at half past", coordinating with a meeting). When in doubt, nudge a few minutes early or late — the user will not notice, and the fleet will.

${e?`## Durability

By default (durable: false) the job lives only in this Claude session — nothing is written to disk, and the job is gone when Claude exits. Pass durable: true to write to .claude/scheduled_tasks.json so the job survives restarts. Only use durable: true when the user explicitly asks for the task to persist ("keep doing this every day", "set this up permanently"). Most "remind me in 5 minutes" / "check back in an hour" requests should stay session-only.`:`## Session-only

Jobs live only in this Claude session — nothing is written to disk, and the job is gone when Claude exits.`}

## Runtime behavior

Jobs only fire while the REPL is idle (not mid-query). ${e?`Durable jobs persist to .claude/scheduled_tasks.json and survive session restarts — on next launch they resume automatically. One-shot durable tasks that were missed while the REPL was closed are surfaced for catch-up. Session-only jobs die with the process. `:``}The scheduler adds a small deterministic jitter on top of whatever you pick: recurring tasks fire up to 10% of their period late (max 15 min); one-shot tasks landing on :00 or :30 fire up to 90 s early. Picking an off-minute is still the bigger lever.

Recurring tasks auto-expire after ${X} days — they fire one final time, then are deleted. This bounds session lifetime. Tell the user about the ${X}-day limit when scheduling recurring jobs.

Returns a job ID you can pass to ${Q}.`}function fi(e){return e?`Cancel a cron job previously scheduled with ${Z}. Removes it from .claude/scheduled_tasks.json (durable jobs) or the in-memory session store (session-only jobs).`:`Cancel a cron job previously scheduled with ${Z}. Removes it from the in-memory session store.`}function pi(e){return e?`List all cron jobs scheduled via ${Z}, both durable (.claude/scheduled_tasks.json) and session-only.`:`List all cron jobs scheduled via ${Z} in this session.`}var mi,X,Z,Q,$,hi,gi,_i=e((()=>{pe(),oi(),o(),mi=300*1e3,X=Y.recurringMaxAgeMs/(1440*60*1e3),Z=`CronCreate`,Q=`CronDelete`,$=`CronList`,hi=`Cancel a scheduled cron job by ID`,gi=`List scheduled cron jobs`})),vi,yi,bi,xi,Si,Ci,wi=e((()=>{vi=`LocalMemoryRecall`,yi=100*1024,bi=2*1024,xi=50*1024,Si=4*1024,Ci=8*1024})),Ti,Ei,Di,Oi=e((()=>{Ti=`VaultHttpFetch`,Ei=1048576,Di=3e4})),ki,Ai,ji,Mi,Ni,Pi,Fi=e((()=>{me(),Bt(),Vt(),ue(),Gt(),_e(),Et(),Zt(),Qt(),ct(),Rt(),Mt(),nn(),pt(),kt(),Pt(),rn(),an(),on(),sn(),cn(),ln(),un(),yn(),Cn(),Tn(),Dn(),On(),An(),Mn(),qr(),_i(),wi(),Oi(),ki=new Set([se,zt,S,...process.env.USER_TYPE===`ant`?[]:[le],C,fe,...[L],vi,Ti]),Ai=new Set([...ki]),ji=new Set([y,w,T,v,It,At,...E,lt,b,Nt,D,P,N,I,kn,jn]),Mi=new Set([k,A,j,M,O,Z,Q,$]),Ni=new Set([le,fe,O,P]),Pi=new Set([...E,y,lt,b,At,v,Nt,le,C,se,fe,k,A,j,M,T,S,zt,F,It,w,`LSP`,D,L,bn,N,I,P])}));function Ii(){return process.env.USER_TYPE===`ant`||he(`tengu_glacier_2xr`,!1)?`Deferred tools appear by name in <system-reminder> messages.`:`Deferred tools appear by name in <available-deferred-tools> messages.`}function Li(e){return!(e.alwaysLoad===!0||Pi.has(e.name))}function Ri(e){return e.name}function zi(){return Bi+Ii()+Vi}var Bi,Vi,Hi=e((()=>{pe(),Fi(),un(),Bi=`Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, cron scheduling, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.

`,Vi=` Returns matching tool names.

## Two-step workflow (MUST follow exactly)

Deferred tools CANNOT be called directly. You MUST use this two-step pattern:

Step 1 — Search: Call this tool (SearchExtraTools) to discover the target tool.
  Input: {"query": "select:CronCreate"}
  Response: "Found 1 deferred tool(s): CronCreate. Use ExecuteExtraTool with {"tool_name": "<name>", "params": {...}} to invoke."

Step 2 — Execute: Call ExecuteExtraTool to run the discovered tool.
  Input: {"tool_name": "CronCreate", "params": {"schedule": "*/5 * * * *", "prompt": "check the deploy"}}
  Response: the actual tool result.

## Example: user asks "schedule a cron to check deploy every 5 minutes"

1. SearchExtraTools({"query": "select:CronCreate"})
   → Response: Found deferred tool CronCreate
2. ExecuteExtraTool({"tool_name": "CronCreate", "params": {"schedule": "*/5 * * * *", "prompt": "check the deploy"}})
   → Response: Cron job created successfully

If you don't know the exact tool name, use keyword search first:
1. SearchExtraTools({"query": "cron schedule"})
   → Response: Found deferred tool(s): CronCreate
2. ExecuteExtraTool({"tool_name": "CronCreate", "params": {...}})

## Query forms
- "select:CronCreate" — exact tool name (fastest, preferred when you know the name from <available-deferred-tools>)
- "select:CronCreate,CronList" — comma-separated multi-select
- "discover:schedule cron job" — returns tool name + description + schema without loading. Use to understand a tool before calling it.
- "notebook jupyter" — keyword search, up to max_results best matches
- "+slack send" — require "slack" in the name, rank by remaining terms

## Failure policy
If ExecuteExtraTool fails, do NOT re-search for the same tool — it will loop. Stop and tell the user what failed.`}));export{Pr as $,et as $n,Zt as $t,fi as A,wt as An,dn as At,Yr as B,ft as Bn,O as Bt,hi as C,Ot as Cn,bn as Ct,X as D,bt as Dn,_n as Dt,$ as E,y as En,P as Et,si as F,gt as Fn,cn as Ft,J as G,ct as Gn,nn as Gt,ni as H,pt as Hn,D as Ht,Y as I,ht as In,A as It,Qr as J,nt as Jn,en as Jt,ri as K,_ as Kn,tn as Kt,Zr as L,mt as Ln,sn as Lt,_i as M,Et as Mn,M as Mt,li as N,yt as Nn,ln as Nt,ui as O,Ct as On,fn as Ot,ci as P,vt as Pn,j as Pt,Ir as Q,at as Qn,Xt as Qt,ii as R,ut as Rn,k as Rt,Z as S,b as Sn,xn as St,gi as T,St as Tn,Cn as Tt,ei as U,v as Un,rn as Ut,oi as V,dt as Vn,an as Vt,$r as W,st as Wn,E as Wt,Kr as X,tt as Xn,Qt as Xt,qr as Y,$e as Yn,T as Yt,Rr as Z,rt as Zn,w as Zt,Si as _,Nt as _n,F as _t,ki as a,Ht as an,U as at,bi as b,At as bn,wn as bt,Ai as c,S as cn,Rn as ct,Di as d,zt as dn,jn as dt,Kt as en,Or as et,Ei as f,Bt as fn,Mn as ft,Ci as g,Ft as gn,On as gt,xi as h,Rt as hn,I as ht,Li as i,Wt as in,ar as it,pi as j,Tt as jn,N as jt,di as k,xt as kn,yn as kt,Mi as l,Vt as ln,R as lt,Oi as m,It as mn,An as mt,zi as n,Yt as nn,yr as nt,ji as o,Ut as on,Hn as ot,Ti as p,Lt as pn,kn as pt,q,ot as qn,$t as qt,Hi as r,C as rn,vr as rt,Ni as s,Gt as sn,In as st,Ri as t,Jt as tn,K as tt,Fi as u,x as un,L as ut,vi as v,Pt as vn,En as vt,Q as w,kt as wn,Sn as wt,wi as x,Mt as xn,Tn as xt,yi as y,jt as yn,Dn as yt,Jr as z,lt as zn,on as zt};