@kodax-ai/kodax 0.7.97-beta.2 → 0.7.97-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/README.md +55 -2
- package/README_CN.md +37 -1
- package/dist/artifacts/dist/contract.js +1 -1
- package/dist/artifacts/dist/contract.js.map +1 -1
- package/dist/artifacts/dist/document-render.d.ts +1 -1
- package/dist/artifacts/dist/document-render.js +41 -10
- package/dist/artifacts/dist/document-render.js.map +1 -1
- package/dist/artifacts/dist/kodax.js +1 -1
- package/dist/artifacts/dist/kodax.js.map +1 -1
- package/dist/artifacts/dist/libreoffice.d.ts +6 -1
- package/dist/artifacts/dist/libreoffice.js +37 -13
- package/dist/artifacts/dist/libreoffice.js.map +1 -1
- package/dist/artifacts/dist/runtime.js +13 -6
- package/dist/artifacts/dist/runtime.js.map +1 -1
- package/dist/artifacts/skills/artifact-review/SKILL.md +5 -1
- package/dist/chunks/agent-NWQPMZ7B.js +2 -0
- package/dist/chunks/agent-adapter-V3IPADCX.js +2 -0
- package/dist/chunks/argument-completer-VNKHT4X4.js +2 -0
- package/dist/chunks/{bedrock-native-Z5VNWF5U.js → bedrock-native-OEPOBW6W.js} +1 -1
- package/dist/chunks/{chunk-NSR4RW2F.js → chunk-3I2MIS4D.js} +1 -1
- package/dist/chunks/{chunk-RYBUYHDL.js → chunk-3Y5PBEOD.js} +1 -1
- package/dist/chunks/chunk-4FVCMKG2.js +20 -0
- package/dist/chunks/{chunk-F6GJXQNA.js → chunk-4GYXZTOD.js} +7 -7
- package/dist/chunks/{chunk-EISRVOBJ.js → chunk-4Z7ZHL6V.js} +2 -2
- package/dist/chunks/{chunk-W2CWO4PQ.js → chunk-576AAIQM.js} +1 -1
- package/dist/chunks/chunk-5E2P4RYS.js +4 -0
- package/dist/chunks/{chunk-X5M7TLJV.js → chunk-5LFQ5FVY.js} +1 -1
- package/dist/chunks/{chunk-WMMESRP3.js → chunk-6RDMSU4B.js} +1 -1
- package/dist/chunks/{chunk-3CP7AUWY.js → chunk-7BA4TSKC.js} +1 -1
- package/dist/chunks/{chunk-I325ER7D.js → chunk-AUU3N4V4.js} +1 -1
- package/dist/chunks/{chunk-DCE7XQUG.js → chunk-AYDLX2UK.js} +1 -1
- package/dist/chunks/{chunk-D36OIMV7.js → chunk-BP3NAYKY.js} +64 -64
- package/dist/chunks/{chunk-6TITQQAI.js → chunk-BSCSKJNC.js} +230 -229
- package/dist/chunks/{chunk-2HH5AS7E.js → chunk-DAQGOWKD.js} +88 -462
- package/dist/chunks/{chunk-UF3GZ5PO.js → chunk-EZF6ZRCO.js} +1 -1
- package/dist/chunks/chunk-F2TFWNVZ.js +2 -0
- package/dist/chunks/{chunk-53CJDQS2.js → chunk-FVXZ5L33.js} +1 -1
- package/dist/chunks/{chunk-MCDZNQWD.js → chunk-G32BMSHH.js} +75 -71
- package/dist/chunks/chunk-HJLYZ5AX.js +361 -0
- package/dist/chunks/{chunk-P55RJIOG.js → chunk-IOIFCU46.js} +1 -1
- package/dist/chunks/{chunk-DV5YPYLW.js → chunk-IR46ZHXU.js} +1 -1
- package/dist/chunks/chunk-NJDR5EEF.js +6 -0
- package/dist/chunks/{chunk-KDSO7V4O.js → chunk-OC3DQXN6.js} +1 -1
- package/dist/chunks/{chunk-J2L2NK6E.js → chunk-OMVAPRQI.js} +90 -57
- package/dist/chunks/chunk-OXCB2TRF.js +42 -0
- package/dist/chunks/{chunk-C6JGLEYD.js → chunk-P6R6V7EW.js} +1 -1
- package/dist/chunks/{chunk-SK3RRGHJ.js → chunk-PFBZ4ZXO.js} +28 -28
- package/dist/chunks/{chunk-V2XJSFFE.js → chunk-QDE6THC5.js} +1 -1
- package/dist/chunks/{chunk-EPK6EWRI.js → chunk-QRYEP34M.js} +1 -1
- package/dist/chunks/chunk-ROWYE472.js +460 -0
- package/dist/chunks/{chunk-R42S4BLA.js → chunk-SQGESMNC.js} +1 -1
- package/dist/chunks/{chunk-XZSFUGPN.js → chunk-U73VEVMP.js} +1 -1
- package/dist/chunks/{chunk-D425EZGC.js → chunk-V2TG7GNW.js} +1 -1
- package/dist/chunks/{chunk-QSZCR5GC.js → chunk-VRO2CDBY.js} +97 -97
- package/dist/chunks/{chunk-BBZWF2EA.js → chunk-WMQQQY3D.js} +1 -1
- package/dist/chunks/{chunk-JAF2YLZO.js → chunk-X3YYJJTF.js} +2 -2
- package/dist/chunks/{chunk-UL6YIT4M.js → chunk-XYRI6ER5.js} +1 -1
- package/dist/chunks/chunk-YRPB3LID.js +3 -0
- package/dist/chunks/{chunk-5MUVRFMU.js → chunk-ZDAU3LZ2.js} +1 -1
- package/dist/chunks/{chunk-WWPVEK6B.js → chunk-ZP3YSYWM.js} +10 -10
- package/dist/chunks/{client-LTIFNED5.js → client-NJ32JBC3.js} +1 -1
- package/dist/chunks/compaction-config-JBQGU3NO.js +2 -0
- package/dist/chunks/{construction-bootstrap-OAZKGI5Y.js → construction-bootstrap-CM47ZXG7.js} +1 -1
- package/dist/chunks/dist-O6BHIQEP.js +2 -0
- package/dist/chunks/{google-native-WLL27OV7.js → google-native-BV5GKT5B.js} +1 -1
- package/dist/chunks/host-PI5NL4W4.js +2 -0
- package/dist/chunks/{mistral-native-JXPIDDYZ.js → mistral-native-X42JCFZH.js} +1 -1
- package/dist/chunks/{model-DZF6URW3.js → model-MT3WJX76.js} +1 -1
- package/dist/chunks/{permission-YVVMLQ5I.js → permission-YVDVSE6H.js} +1 -1
- package/dist/chunks/{pi-messages-5LLOZH57.js → pi-messages-DVJANXV5.js} +1 -1
- package/dist/chunks/readline-helpers-5JS7UGTE.js +2 -0
- package/dist/chunks/run-manager-Y6VYEWSJ.js +2 -0
- package/dist/chunks/running-session-ANMBA5XV.js +2 -0
- package/dist/chunks/skills-XL2XIBWV.js +2 -0
- package/dist/chunks/{tool-dispatch-MLM3QTSU.js → tool-dispatch-2FOG65FC.js} +1 -1
- package/dist/chunks/{utils-2QNMYRGA.js → utils-XZ22R6VB.js} +1 -1
- package/dist/client-history.js +2 -0
- package/dist/history-turn.js +3 -0
- package/dist/index.d.ts +19 -19
- package/dist/index.js +2 -2
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1472 -1810
- package/dist/kodax_doctor.js +1 -1
- package/dist/maintenance-scheduler.js +2 -0
- package/dist/manual-topics.json +32 -3
- package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
- package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/one-shot-task.js +1 -1
- package/dist/provider-auth-cli.js +1 -1
- package/dist/runtime-daemon-schema.json +1 -1
- package/dist/sandbox-network-broker.js +93 -441
- package/dist/sdk-a2a.d.ts +13 -13
- package/dist/sdk-a2a.js +1 -1
- package/dist/sdk-agent.d.ts +17 -12
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-client.d.ts +6 -6
- package/dist/sdk-client.js +1 -1
- package/dist/sdk-coding.d.ts +17 -17
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.d.ts +2 -2
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-llm.d.ts +4 -2
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.d.ts +13 -13
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +16 -16
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-runtime.d.ts +46 -46
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +7 -7
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +87 -435
- package/dist/storage-repair-cli.js +1 -1
- package/dist/types-chunks/{bash-prefix-extractor.d-CJliu5-D.d.ts → bash-prefix-extractor.d-BghXa_md.d.ts} +9 -3
- package/dist/types-chunks/{capsule.d-EMwSALqK.d.ts → capsule.d-BTlvC5qq.d.ts} +4 -4
- package/dist/types-chunks/{client-contract-B7q69yMA.d.ts → client-contract-B7ZSFKTv.d.ts} +52 -4
- package/dist/types-chunks/{controller.d-C0SAuNKu.d.ts → controller.d-Btu5FDdw.d.ts} +1 -1
- package/dist/types-chunks/{controller.d-D-hPLKaA.d.ts → controller.d-D6rEz5LS.d.ts} +3 -3
- package/dist/types-chunks/{history-retrieval.d-BwEUR9cb.d.ts → history-retrieval.d-B_AriUJp.d.ts} +1 -1
- package/dist/types-chunks/{manifest.d-YE3-AIeO.d.ts → manifest.d-Yyce-hHj.d.ts} +1 -1
- package/dist/types-chunks/{public-api.d-BhDU643p.d.ts → public-api.d-BLv3lFmw.d.ts} +9 -4
- package/dist/types-chunks/{review-inbox.d-Bgt46S7L.d.ts → review-inbox.d-yREk25Vf.d.ts} +2 -0
- package/dist/types-chunks/{review-packet.d-ChOfJaNI.d.ts → review-packet.d-xwXxHmML.d.ts} +1 -1
- package/dist/types-chunks/{run-manager.d-ChzguipG.d.ts → run-manager.d-D4sa9JYz.d.ts} +26 -12
- package/dist/types-chunks/{runtime-client-info-P_mRDG7j.d.ts → runtime-client-info-oRMrkHmb.d.ts} +2 -2
- package/dist/types-chunks/{runtime-event-BW5Pla7a.d.ts → runtime-event-BOyaILWg.d.ts} +3 -1
- package/dist/types-chunks/{sdk-runtime-cDe7qmN3.d.ts → sdk-runtime-CYyXmQok.d.ts} +27 -13
- package/dist/types-chunks/{sdk-session-D3pcSbnA.d.ts → sdk-session-D6mS5qgO.d.ts} +6 -3
- package/dist/types-chunks/{skill-invocation-error.d-gsNNDnnt.d.ts → skill-invocation-error.d-Be3qg4JQ.d.ts} +3 -3
- package/dist/types-chunks/{trusted-repl-entry-Bbkd2HlO.d.ts → trusted-repl-entry-YWNc4m-Z.d.ts} +7 -7
- package/dist/types-chunks/{types.d-BlXTogOo.d.ts → types.d-BQ-hbni4.d.ts} +1 -1
- package/dist/types-chunks/{utils.d-CxHyBvO6.d.ts → utils.d-C0F3Uf2X.d.ts} +6 -6
- package/dist/windows-effect-job-programs.json +4 -0
- package/docs/ARTIFACT_SDK.md +3 -3
- package/docs/CLIENT_CONTRACT.md +4 -2
- package/docs/SDK_MIGRATION.md +9 -5
- package/docs/SPACE_SDK_SEAMS.md +12 -1
- package/package.json +4 -3
- package/public_docs/README.md +10 -3
- package/public_docs/sdk/embedder-guide.md +1 -1
- package/dist/chunks/agent-DS7M57WD.js +0 -2
- package/dist/chunks/agent-adapter-TLWGGK3V.js +0 -2
- package/dist/chunks/argument-completer-OGCXKTRQ.js +0 -2
- package/dist/chunks/chunk-GJXOTOZB.js +0 -465
- package/dist/chunks/chunk-KE2NBMAP.js +0 -20
- package/dist/chunks/chunk-OGTRDK4Q.js +0 -359
- package/dist/chunks/chunk-R2HTPDI7.js +0 -2
- package/dist/chunks/chunk-SDPZFH6M.js +0 -4
- package/dist/chunks/chunk-XDMNJW6J.js +0 -42
- package/dist/chunks/compaction-config-ECMOFP5H.js +0 -2
- package/dist/chunks/dist-5J53DGAO.js +0 -2
- package/dist/chunks/host-65E5NM5P.js +0 -2
- package/dist/chunks/readline-helpers-UZXWBRXQ.js +0 -2
- package/dist/chunks/run-manager-ZFACIZM2.js +0 -2
- package/dist/chunks/running-session-Q5Y6A2QV.js +0 -2
- package/dist/chunks/skills-TJP6BLZJ.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{ja as Ne,la as Te}from"./chunk-D36OIMV7.js";import{Sa as De}from"./chunk-2HH5AS7E.js";import{b as Ce,j as Le}from"./chunk-J2L2NK6E.js";import{F as _e,G as Me,H as Oe,I as Ae,J as Ie,K as ae,S as Re,T as N,X as ce,ga as ue,la as ke,q as Pe}from"./chunk-SK3RRGHJ.js";import{N as oe,Q as ie,R as xe,S as se}from"./chunk-KE2NBMAP.js";import{a as o}from"./chunk-V4WSBIXB.js";import g from"fs";import m from"path";import{exec as Vt,spawnSync as Wt}from"child_process";import{promisify as Ht}from"util";import{fileURLToPath as qt}from"url";var le="en";function pt(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}o(pt,"detectSystemLocale");function je(e){if(!e||e==="auto"){le=pt();return}le=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}o(je,"setLocale");var $e={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.approved_session":"Approved (this session)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",cancelled:"[Cancelled] Operation cancelled by user",cancellationRequested:"[Cancelling] Stop requested for the current reply",cancellationAccepted:"Stop request accepted; waiting for execution to settle.",cancellationConfirmed:"Stop confirmed:",cancellationRejected:"Stop request failed:"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88",cancellationRequested:"[\u6B63\u5728\u53D6\u6D88] \u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u56DE\u590D",cancellationAccepted:"\u505C\u6B62\u8BF7\u6C42\u5DF2\u63A5\u53D7\uFF0C\u6B63\u5728\u7B49\u5F85\u6267\u884C\u6536\u5C3E\u3002",cancellationConfirmed:"\u505C\u6B62\u5DF2\u786E\u8BA4\uFF1A",cancellationRejected:"\u505C\u6B62\u8BF7\u6C42\u5931\u8D25\uFF1A"}};function Sn(e,t){let r=$e[le][e]??$e.en[e]??e;if(t)for(let[i,s]of Object.entries(t))r=r.replace(`{${i}}`,String(s));return r}o(Sn,"t");import{existsSync as mt,readFileSync as gt}from"node:fs";import T from"node:path";import{fileURLToPath as ht}from"node:url";var Fe=T.dirname(ht(import.meta.url)),Ke=process.env.KODAX_BUNDLED==="true"?[T.join(T.dirname(process.execPath),"generated-config-templates.json")]:[T.join(Fe,"generated-config-templates.json"),T.join(Fe,"..","generated-config-templates.json")],$=JSON.parse(gt(Ke.find(mt)??Ke[0],"utf8"));if(!$||typeof $!="object"||Array.isArray($)||!["core","mcp","a2a","extensions"].every(e=>typeof Reflect.get($,e)=="string"))throw new Error("Invalid package configuration templates.");var Xe=$;function Ue(e){return Xe[e]}o(Ue,"getConfigTemplate");import{closeSync as _t,existsSync as p,fsyncSync as Mt,linkSync as Ot,mkdirSync as ge,openSync as At,readFileSync as tt,renameSync as It,statSync as Rt,unlinkSync as Be,watch as kt,writeFileSync as Dt}from"node:fs";import{createHash as Lt}from"node:crypto";import d from"node:path";import{closeSync as W,mkdirSync as vt,openSync as Ve,rmSync as C,readFileSync as x,writeFileSync as We,fsyncSync as He,linkSync as yt,renameSync as Ge,lstatSync as qe,realpathSync as wt}from"node:fs";import{createHash as Et,randomUUID as J}from"node:crypto";import St from"node:path";var H=class extends Error{static{o(this,"CoreConfigWriteConflictError")}code="conflict";data={source:"configuration",reason:"lock_busy"};constructor(t,n=ze(t)){super(`Core configuration lock is busy or its ownership cannot be safely recovered: ${t}. Retained lock: ${n}. Use kodax doctor for offline recovery guidance; never remove a lock while shared writers may be active.`),this.name="CoreConfigWriteConflictError"}},j=class extends Error{static{o(this,"CoreConfigReadError")}code="internal_error";data={source:"configuration",reason:"read_failed"};constructor(t){super(`Core configuration is unreadable or invalid: ${t}. Retain and repair the original before continuing.`),this.name="CoreConfigReadError"}};function Je(e){try{qe(e)}catch(t){if(v(t)==="ENOENT")return{};throw new j(e)}try{let t=JSON.parse(x(e,"utf8"));if(t===null||typeof t!="object"||Array.isArray(t))throw new j(e);return t}catch{throw new j(e)}}o(Je,"readCoreConfig");var q=new Map;function bt(e){let t=q.get(e);if(t!==void 0){try{x(e,"utf8")===t&&C(e)}catch(n){if(v(n)!=="ENOENT")throw n}q.delete(e)}}o(bt,"retryInactiveRelease");function ze(e){return`${e}.write.lock`}o(ze,"coreConfigWriteLockPath");function P(e,t){let n=!1;try{n=qe(e).isSymbolicLink()}catch(s){if(v(s)!=="ENOENT")throw s}n&&(e=wt(e));let r=`${e}.${J()}.tmp`,i;try{i=Ve(r,"wx",384),We(i,t),He(i);let s=i;i=void 0,W(s),Ct(r,e)}finally{try{i!==void 0&&W(i)}finally{C(r,{force:!0})}}}o(P,"writeCoreConfigAtomically");function Ct(e,t){try{Ge(e,t)}catch(n){if(process.platform!=="win32"||v(n)!=="EPERM")throw n;let r=performance.now()+1e3,i=new Int32Array(new SharedArrayBuffer(4));for(;;){let s=r-performance.now();if(s<=0||(Atomics.wait(i,0,0,Math.min(10,s)),performance.now()>=r))throw n;try{Ge(e,t);return}catch(a){if(v(a)!=="EPERM")throw a}}}}o(Ct,"publishCoreConfigReplacement");function v(e){if(!(!(e instanceof Error)||!("code"in e)))return typeof e.code=="string"?e.code:void 0}o(v,"errorCode");function fe(e,t){let n=`${e}.${J()}.tmp`,r,i=!1,s;try{r=Ve(n,"wx",384),We(r,t),He(r);let a=r;r=void 0,W(a);try{yt(n,e),i=!0}catch(c){if(v(c)!=="EEXIST")throw c}return i}catch(a){throw s=a,a}finally{try{try{r!==void 0&&W(r)}finally{C(n,{force:!0})}}catch(a){if(i&&x(e,"utf8")===t)try{C(e)}catch(c){throw new AggregateError([a,c],"Configuration lock cleanup failed.")}throw s!==void 0?new AggregateError([s,a],"Configuration lock publication and cleanup failed."):new AggregateError([a],a instanceof Error?a.message:"Configuration lock cleanup failed.")}}}o(fe,"publishConfigLock");function xt(e){let t,n;try{t=x(e,"utf8"),n=JSON.parse(t)}catch(r){return v(r)==="ENOENT"}if(!n||n.version!==1||!Number.isSafeInteger(n.pid)||n.pid<=0||typeof n.nonce!="string"||!n.nonce)return!1;try{return process.kill(n.pid,0),!1}catch(r){if(v(r)!=="ESRCH")return!1}return!Pt(e,n.nonce)||x(e,"utf8")!==t?!1:(C(e),!0)}o(xt,"reclaim");function Pt(e,t){let n=`${e}.reclaim.${Et("sha256").update(t).digest("hex")}`;return fe(n,JSON.stringify({pid:process.pid,nonce:J()}))}o(Pt,"claimConfigLockReclamation");function de(e,t,n){vt(St.dirname(t),{recursive:!0,mode:448}),bt(t);let r=JSON.stringify({version:1,pid:process.pid,nonce:J()});if(!fe(t,r)&&(!xt(t)||!fe(t,r)))throw new H(e,t);let i;try{return n()}catch(s){throw i=s,s}finally{try{if(q.set(t,r),x(t,"utf8")!==r)throw new H(e,t);C(t),q.delete(t)}catch(s){throw i!==void 0?new AggregateError([i,s],"Configuration write and lock release failed."):s}}}o(de,"withConfigWriteLock");function S(e,t){return de(e,ze(e),t)}o(S,"withCoreConfigWriteLock");var M=class extends Error{static{o(this,"IntegrationConfigConflictError")}constructor(t,n,r){super(`Integration configuration revision changed for ${d.basename(t)} (expected ${n??"missing"}, actual ${r??"missing"}).`),this.name="IntegrationConfigConflictError"}},Nt={mcp:"mcp.json",a2a:"a2a.json",extensions:"extensions.json"},Tt=new Set(["type","command","args","cwd","env","url","headers","connect","startupTimeoutMs","requestTimeoutMs","auth"]);function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(_,"isRecord");function O(e,t){if(!_(e))throw new Error(`${t} must be an object.`);return e}o(O,"requireRecord");function B(e,t,n){let r=Object.keys(e).find(i=>!t.has(i));if(r!==void 0)throw new Error(`${n} has unknown field "${r}".`)}o(B,"assertNoUnknownKeys");function nt(e,t){if(e.version!==1)throw new Error(`${t} version must be 1.`)}o(nt,"requireVersionOne");function Ye(e,t){let n=O(e,t);for(let[r,i]of Object.entries(n))if(r.trim().length===0||typeof i!="string")throw new Error(`${t} must contain non-empty string keys and string values.`);return structuredClone(n)}o(Ye,"requireStringMap");function me(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`${t} must be an array of non-empty strings.`);return e.map(n=>n.trim())}o(me,"requireStringArray");function pe(e,t){if(e!==void 0&&(!Number.isFinite(e)||Number(e)<=0))throw new Error(`${t} must be a positive number.`)}o(pe,"validatePositiveNumber");function $t(e,t){if(e.trim().length===0)throw new Error("MCP server names must not be empty.");let n=O(t,`MCP server "${e}"`);B(n,Tt,`MCP server "${e}"`);let r=n.type??"stdio";if(!["stdio","sse","streamable-http","http"].includes(String(r)))throw new Error(`MCP server "${e}" has an unsupported transport type.`);if(r==="stdio"){if(typeof n.command!="string"||n.command.trim().length===0)throw new Error(`MCP server "${e}" stdio transport requires command.`)}else if(typeof n.url!="string"||n.url.trim().length===0)throw new Error(`MCP server "${e}" ${String(r)} transport requires url.`);if(n.args!==void 0&&me(n.args,`MCP server "${e}" args`),n.cwd!==void 0&&typeof n.cwd!="string")throw new Error(`MCP server "${e}" cwd must be a string.`);if(n.env!==void 0&&Ye(n.env,`MCP server "${e}" env`),n.headers!==void 0&&Ye(n.headers,`MCP server "${e}" headers`),n.connect!==void 0&&!["lazy","prewarm","disabled"].includes(String(n.connect)))throw new Error(`MCP server "${e}" has an unsupported connect mode.`);if(pe(n.startupTimeoutMs,`MCP server "${e}" startupTimeoutMs`),pe(n.requestTimeoutMs,`MCP server "${e}" requestTimeoutMs`),n.auth!==void 0){let i=O(n.auth,`MCP server "${e}" auth`);if(B(i,new Set(["type","clientId","authorizationUrl","tokenUrl","scopes","redirectPort"]),`MCP server "${e}" auth`),i.type!=="oauth2")throw new Error(`MCP server "${e}" auth type must be oauth2.`);for(let a of["clientId","authorizationUrl","tokenUrl"])if(i[a]!==void 0&&typeof i[a]!="string")throw new Error(`MCP server "${e}" auth.${a} must be a string.`);i.scopes!==void 0&&me(i.scopes,`MCP server "${e}" auth.scopes`),pe(i.redirectPort,`MCP server "${e}" auth.redirectPort`)}return structuredClone(n)}o($t,"parseMcpServer");function A(e){let t=O(e,"MCP integration config");B(t,new Set(["version","servers"]),"MCP integration config"),nt(t,"MCP integration config");let n=O(t.servers,"MCP integration config servers"),r={};for(let[i,s]of Object.entries(n))r[i]=$t(i,s);return{version:1,servers:r}}o(A,"parseMcpIntegrationDocument");function I(e){let t=O(e,"Extensions integration config");B(t,new Set(["version","paths"]),"Extensions integration config"),nt(t,"Extensions integration config");let n=me(t.paths,"Extensions integration config paths");if(new Set(n).size!==n.length)throw new Error("Extensions integration config paths must not contain duplicates.");return{version:1,paths:n}}o(I,"parseExtensionsIntegrationDocument");function R(e,t){return d.join(d.resolve(t),"integrations",Nt[e])}o(R,"resolveIntegrationConfigPath");function D(e){return d.join(d.resolve(e),"config.json")}o(D,"coreConfigPath");function rt(e){return Lt("sha256").update(e).digest("hex")}o(rt,"hashText");function ot(e){let t=tt(e,"utf8");try{return{raw:t,value:JSON.parse(t)}}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Invalid JSON: ${r}`)}}o(ot,"readJsonFile");function k(e){return{domain:e.domain,source:e.source,path:e.path,revision:rt(e.raw),document:structuredClone(e.document),loadedAt:new Date().toISOString()}}o(k,"snapshot");function Y(e){return Je(D(e))}o(Y,"readCoreConfig");function Q(e){let t=R("mcp",e);if(p(t)){let s=ot(t);return k({domain:"mcp",source:"user",path:t,raw:s.raw,document:A(s.value)})}let n=D(e),r=Y(e).mcpServers,i=A({version:1,servers:r===void 0?{}:r});return k({domain:"mcp",source:r===void 0?"default":"legacy-user",path:r===void 0?t:n,raw:JSON.stringify(i),document:i})}o(Q,"readMcpIntegration");function Z(e){let t=R("extensions",e);if(p(t)){let s=ot(t);return k({domain:"extensions",source:"user",path:t,raw:s.raw,document:I(s.value)})}let n=D(e),r=Y(e).extensions,i=I({version:1,paths:r===void 0?[]:r});return k({domain:"extensions",source:r===void 0?"default":"legacy-user",path:r===void 0?t:n,raw:JSON.stringify(i),document:i})}o(Z,"readExtensionsIntegration");function jt(e){if(!_(e))return[];let t=[],n=/(token|secret|password|api[_-]?key|authorization)/i;for(let[r,i]of Object.entries(e))if(_(i))for(let s of["env","headers"]){let a=i[s];if(_(a))for(let[c,u]of Object.entries(a))n.test(c)&&typeof u=="string"&&!u.startsWith("${env:")&&t.push(`MCP server "${r}" ${s}.${c} may contain a literal secret.`)}return t}o(jt,"likelySecretWarnings");function Ft(e){let t=Y(e),n=R("mcp",e),r=R("extensions",e),i=t.mcpServers,s=t.extensions,a=_(i)?Object.keys(i).length:0,c=Array.isArray(s)?s.length:0,u=o((h,G,V)=>p(h)?{action:"none",entries:G,destination:h,reason:"destination-exists"}:V?{action:"create",entries:G,destination:h}:{action:"none",entries:0,destination:h,reason:"legacy-absent"},"domainPlan");return{mcp:u(n,a,i!==void 0),extensions:u(r,c,s!==void 0),warnings:jt(i)}}o(Ft,"planLegacyIntegrationMigration");function Kt(e,t){let n=D(e);ge(d.dirname(n),{recursive:!0,mode:448});try{P(n,`${JSON.stringify(t,null,2)}
|
|
2
|
+
import{ja as Ne,la as Te}from"./chunk-BP3NAYKY.js";import{Sa as De}from"./chunk-DAQGOWKD.js";import{b as Ce,j as Le}from"./chunk-OMVAPRQI.js";import{F as _e,G as Me,H as Oe,I as Ae,J as Ie,K as ae,S as Re,T as N,X as ce,ga as ue,la as ke,q as Pe}from"./chunk-PFBZ4ZXO.js";import{N as oe,Q as ie,R as xe,S as se}from"./chunk-4FVCMKG2.js";import{a as o}from"./chunk-V4WSBIXB.js";import g from"fs";import m from"path";import{exec as Vt,spawnSync as Wt}from"child_process";import{promisify as Ht}from"util";import{fileURLToPath as qt}from"url";var le="en";function pt(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}o(pt,"detectSystemLocale");function je(e){if(!e||e==="auto"){le=pt();return}le=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}o(je,"setLocale");var $e={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.approved_session":"Approved (this session)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",cancelled:"[Cancelled] Operation cancelled by user",cancellationRequested:"[Cancelling] Stop requested for the current reply",cancellationAccepted:"Stop request accepted; waiting for execution to settle.",cancellationConfirmed:"Stop confirmed:",cancellationRejected:"Stop request failed:"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88",cancellationRequested:"[\u6B63\u5728\u53D6\u6D88] \u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u56DE\u590D",cancellationAccepted:"\u505C\u6B62\u8BF7\u6C42\u5DF2\u63A5\u53D7\uFF0C\u6B63\u5728\u7B49\u5F85\u6267\u884C\u6536\u5C3E\u3002",cancellationConfirmed:"\u505C\u6B62\u5DF2\u786E\u8BA4\uFF1A",cancellationRejected:"\u505C\u6B62\u8BF7\u6C42\u5931\u8D25\uFF1A"}};function Sn(e,t){let r=$e[le][e]??$e.en[e]??e;if(t)for(let[i,s]of Object.entries(t))r=r.replace(`{${i}}`,String(s));return r}o(Sn,"t");import{existsSync as mt,readFileSync as gt}from"node:fs";import T from"node:path";import{fileURLToPath as ht}from"node:url";var Fe=T.dirname(ht(import.meta.url)),Ke=process.env.KODAX_BUNDLED==="true"?[T.join(T.dirname(process.execPath),"generated-config-templates.json")]:[T.join(Fe,"generated-config-templates.json"),T.join(Fe,"..","generated-config-templates.json")],$=JSON.parse(gt(Ke.find(mt)??Ke[0],"utf8"));if(!$||typeof $!="object"||Array.isArray($)||!["core","mcp","a2a","extensions"].every(e=>typeof Reflect.get($,e)=="string"))throw new Error("Invalid package configuration templates.");var Xe=$;function Ue(e){return Xe[e]}o(Ue,"getConfigTemplate");import{closeSync as _t,existsSync as p,fsyncSync as Mt,linkSync as Ot,mkdirSync as ge,openSync as At,readFileSync as tt,renameSync as It,statSync as Rt,unlinkSync as Be,watch as kt,writeFileSync as Dt}from"node:fs";import{createHash as Lt}from"node:crypto";import d from"node:path";import{closeSync as W,mkdirSync as vt,openSync as Ve,rmSync as C,readFileSync as x,writeFileSync as We,fsyncSync as He,linkSync as yt,renameSync as Ge,lstatSync as qe,realpathSync as wt}from"node:fs";import{createHash as Et,randomUUID as J}from"node:crypto";import St from"node:path";var H=class extends Error{static{o(this,"CoreConfigWriteConflictError")}code="conflict";data={source:"configuration",reason:"lock_busy"};constructor(t,n=ze(t)){super(`Core configuration lock is busy or its ownership cannot be safely recovered: ${t}. Retained lock: ${n}. Use kodax doctor for offline recovery guidance; never remove a lock while shared writers may be active.`),this.name="CoreConfigWriteConflictError"}},j=class extends Error{static{o(this,"CoreConfigReadError")}code="internal_error";data={source:"configuration",reason:"read_failed"};constructor(t){super(`Core configuration is unreadable or invalid: ${t}. Retain and repair the original before continuing.`),this.name="CoreConfigReadError"}};function Je(e){try{qe(e)}catch(t){if(v(t)==="ENOENT")return{};throw new j(e)}try{let t=JSON.parse(x(e,"utf8"));if(t===null||typeof t!="object"||Array.isArray(t))throw new j(e);return t}catch{throw new j(e)}}o(Je,"readCoreConfig");var q=new Map;function bt(e){let t=q.get(e);if(t!==void 0){try{x(e,"utf8")===t&&C(e)}catch(n){if(v(n)!=="ENOENT")throw n}q.delete(e)}}o(bt,"retryInactiveRelease");function ze(e){return`${e}.write.lock`}o(ze,"coreConfigWriteLockPath");function P(e,t){let n=!1;try{n=qe(e).isSymbolicLink()}catch(s){if(v(s)!=="ENOENT")throw s}n&&(e=wt(e));let r=`${e}.${J()}.tmp`,i;try{i=Ve(r,"wx",384),We(i,t),He(i);let s=i;i=void 0,W(s),Ct(r,e)}finally{try{i!==void 0&&W(i)}finally{C(r,{force:!0})}}}o(P,"writeCoreConfigAtomically");function Ct(e,t){try{Ge(e,t)}catch(n){if(process.platform!=="win32"||v(n)!=="EPERM")throw n;let r=performance.now()+1e3,i=new Int32Array(new SharedArrayBuffer(4));for(;;){let s=r-performance.now();if(s<=0||(Atomics.wait(i,0,0,Math.min(10,s)),performance.now()>=r))throw n;try{Ge(e,t);return}catch(a){if(v(a)!=="EPERM")throw a}}}}o(Ct,"publishCoreConfigReplacement");function v(e){if(!(!(e instanceof Error)||!("code"in e)))return typeof e.code=="string"?e.code:void 0}o(v,"errorCode");function fe(e,t){let n=`${e}.${J()}.tmp`,r,i=!1,s;try{r=Ve(n,"wx",384),We(r,t),He(r);let a=r;r=void 0,W(a);try{yt(n,e),i=!0}catch(c){if(v(c)!=="EEXIST")throw c}return i}catch(a){throw s=a,a}finally{try{try{r!==void 0&&W(r)}finally{C(n,{force:!0})}}catch(a){if(i&&x(e,"utf8")===t)try{C(e)}catch(c){throw new AggregateError([a,c],"Configuration lock cleanup failed.")}throw s!==void 0?new AggregateError([s,a],"Configuration lock publication and cleanup failed."):new AggregateError([a],a instanceof Error?a.message:"Configuration lock cleanup failed.")}}}o(fe,"publishConfigLock");function xt(e){let t,n;try{t=x(e,"utf8"),n=JSON.parse(t)}catch(r){return v(r)==="ENOENT"}if(!n||n.version!==1||!Number.isSafeInteger(n.pid)||n.pid<=0||typeof n.nonce!="string"||!n.nonce)return!1;try{return process.kill(n.pid,0),!1}catch(r){if(v(r)!=="ESRCH")return!1}return!Pt(e,n.nonce)||x(e,"utf8")!==t?!1:(C(e),!0)}o(xt,"reclaim");function Pt(e,t){let n=`${e}.reclaim.${Et("sha256").update(t).digest("hex")}`;return fe(n,JSON.stringify({pid:process.pid,nonce:J()}))}o(Pt,"claimConfigLockReclamation");function de(e,t,n){vt(St.dirname(t),{recursive:!0,mode:448}),bt(t);let r=JSON.stringify({version:1,pid:process.pid,nonce:J()});if(!fe(t,r)&&(!xt(t)||!fe(t,r)))throw new H(e,t);let i;try{return n()}catch(s){throw i=s,s}finally{try{if(q.set(t,r),x(t,"utf8")!==r)throw new H(e,t);C(t),q.delete(t)}catch(s){throw i!==void 0?new AggregateError([i,s],"Configuration write and lock release failed."):s}}}o(de,"withConfigWriteLock");function S(e,t){return de(e,ze(e),t)}o(S,"withCoreConfigWriteLock");var M=class extends Error{static{o(this,"IntegrationConfigConflictError")}constructor(t,n,r){super(`Integration configuration revision changed for ${d.basename(t)} (expected ${n??"missing"}, actual ${r??"missing"}).`),this.name="IntegrationConfigConflictError"}},Nt={mcp:"mcp.json",a2a:"a2a.json",extensions:"extensions.json"},Tt=new Set(["type","command","args","cwd","env","url","headers","connect","startupTimeoutMs","requestTimeoutMs","auth"]);function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(_,"isRecord");function O(e,t){if(!_(e))throw new Error(`${t} must be an object.`);return e}o(O,"requireRecord");function B(e,t,n){let r=Object.keys(e).find(i=>!t.has(i));if(r!==void 0)throw new Error(`${n} has unknown field "${r}".`)}o(B,"assertNoUnknownKeys");function nt(e,t){if(e.version!==1)throw new Error(`${t} version must be 1.`)}o(nt,"requireVersionOne");function Ye(e,t){let n=O(e,t);for(let[r,i]of Object.entries(n))if(r.trim().length===0||typeof i!="string")throw new Error(`${t} must contain non-empty string keys and string values.`);return structuredClone(n)}o(Ye,"requireStringMap");function me(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`${t} must be an array of non-empty strings.`);return e.map(n=>n.trim())}o(me,"requireStringArray");function pe(e,t){if(e!==void 0&&(!Number.isFinite(e)||Number(e)<=0))throw new Error(`${t} must be a positive number.`)}o(pe,"validatePositiveNumber");function $t(e,t){if(e.trim().length===0)throw new Error("MCP server names must not be empty.");let n=O(t,`MCP server "${e}"`);B(n,Tt,`MCP server "${e}"`);let r=n.type??"stdio";if(!["stdio","sse","streamable-http","http"].includes(String(r)))throw new Error(`MCP server "${e}" has an unsupported transport type.`);if(r==="stdio"){if(typeof n.command!="string"||n.command.trim().length===0)throw new Error(`MCP server "${e}" stdio transport requires command.`)}else if(typeof n.url!="string"||n.url.trim().length===0)throw new Error(`MCP server "${e}" ${String(r)} transport requires url.`);if(n.args!==void 0&&me(n.args,`MCP server "${e}" args`),n.cwd!==void 0&&typeof n.cwd!="string")throw new Error(`MCP server "${e}" cwd must be a string.`);if(n.env!==void 0&&Ye(n.env,`MCP server "${e}" env`),n.headers!==void 0&&Ye(n.headers,`MCP server "${e}" headers`),n.connect!==void 0&&!["lazy","prewarm","disabled"].includes(String(n.connect)))throw new Error(`MCP server "${e}" has an unsupported connect mode.`);if(pe(n.startupTimeoutMs,`MCP server "${e}" startupTimeoutMs`),pe(n.requestTimeoutMs,`MCP server "${e}" requestTimeoutMs`),n.auth!==void 0){let i=O(n.auth,`MCP server "${e}" auth`);if(B(i,new Set(["type","clientId","authorizationUrl","tokenUrl","scopes","redirectPort"]),`MCP server "${e}" auth`),i.type!=="oauth2")throw new Error(`MCP server "${e}" auth type must be oauth2.`);for(let a of["clientId","authorizationUrl","tokenUrl"])if(i[a]!==void 0&&typeof i[a]!="string")throw new Error(`MCP server "${e}" auth.${a} must be a string.`);i.scopes!==void 0&&me(i.scopes,`MCP server "${e}" auth.scopes`),pe(i.redirectPort,`MCP server "${e}" auth.redirectPort`)}return structuredClone(n)}o($t,"parseMcpServer");function A(e){let t=O(e,"MCP integration config");B(t,new Set(["version","servers"]),"MCP integration config"),nt(t,"MCP integration config");let n=O(t.servers,"MCP integration config servers"),r={};for(let[i,s]of Object.entries(n))r[i]=$t(i,s);return{version:1,servers:r}}o(A,"parseMcpIntegrationDocument");function I(e){let t=O(e,"Extensions integration config");B(t,new Set(["version","paths"]),"Extensions integration config"),nt(t,"Extensions integration config");let n=me(t.paths,"Extensions integration config paths");if(new Set(n).size!==n.length)throw new Error("Extensions integration config paths must not contain duplicates.");return{version:1,paths:n}}o(I,"parseExtensionsIntegrationDocument");function R(e,t){return d.join(d.resolve(t),"integrations",Nt[e])}o(R,"resolveIntegrationConfigPath");function D(e){return d.join(d.resolve(e),"config.json")}o(D,"coreConfigPath");function rt(e){return Lt("sha256").update(e).digest("hex")}o(rt,"hashText");function ot(e){let t=tt(e,"utf8");try{return{raw:t,value:JSON.parse(t)}}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Invalid JSON: ${r}`)}}o(ot,"readJsonFile");function k(e){return{domain:e.domain,source:e.source,path:e.path,revision:rt(e.raw),document:structuredClone(e.document),loadedAt:new Date().toISOString()}}o(k,"snapshot");function Y(e){return Je(D(e))}o(Y,"readCoreConfig");function Q(e){let t=R("mcp",e);if(p(t)){let s=ot(t);return k({domain:"mcp",source:"user",path:t,raw:s.raw,document:A(s.value)})}let n=D(e),r=Y(e).mcpServers,i=A({version:1,servers:r===void 0?{}:r});return k({domain:"mcp",source:r===void 0?"default":"legacy-user",path:r===void 0?t:n,raw:JSON.stringify(i),document:i})}o(Q,"readMcpIntegration");function Z(e){let t=R("extensions",e);if(p(t)){let s=ot(t);return k({domain:"extensions",source:"user",path:t,raw:s.raw,document:I(s.value)})}let n=D(e),r=Y(e).extensions,i=I({version:1,paths:r===void 0?[]:r});return k({domain:"extensions",source:r===void 0?"default":"legacy-user",path:r===void 0?t:n,raw:JSON.stringify(i),document:i})}o(Z,"readExtensionsIntegration");function jt(e){if(!_(e))return[];let t=[],n=/(token|secret|password|api[_-]?key|authorization)/i;for(let[r,i]of Object.entries(e))if(_(i))for(let s of["env","headers"]){let a=i[s];if(_(a))for(let[c,u]of Object.entries(a))n.test(c)&&typeof u=="string"&&!u.startsWith("${env:")&&t.push(`MCP server "${r}" ${s}.${c} may contain a literal secret.`)}return t}o(jt,"likelySecretWarnings");function Ft(e){let t=Y(e),n=R("mcp",e),r=R("extensions",e),i=t.mcpServers,s=t.extensions,a=_(i)?Object.keys(i).length:0,c=Array.isArray(s)?s.length:0,u=o((h,G,V)=>p(h)?{action:"none",entries:G,destination:h,reason:"destination-exists"}:V?{action:"create",entries:G,destination:h}:{action:"none",entries:0,destination:h,reason:"legacy-absent"},"domainPlan");return{mcp:u(n,a,i!==void 0),extensions:u(r,c,s!==void 0),warnings:jt(i)}}o(Ft,"planLegacyIntegrationMigration");function Kt(e,t){let n=D(e);ge(d.dirname(n),{recursive:!0,mode:448});try{P(n,`${JSON.stringify(t,null,2)}
|
|
3
3
|
`)}catch(r){throw new Error("Failed to atomically clean legacy integration fields.",{cause:r})}}o(Kt,"writeCoreConfigAtomically");function jn(e){return S(D(e.configHome),()=>Xt(e))}o(jn,"migrateLegacyIntegrationConfig");function Xt(e){let t=Ft(e.configHome),n=Y(e.configHome),r=t.mcp.action==="create"?A({version:1,servers:_(n.mcpServers)?n.mcpServers:{}}):void 0,i=t.extensions.action==="create"?I({version:1,paths:Array.isArray(n.extensions)?n.extensions:[]}):void 0,s=[];if(r)try{F({domain:"mcp",configHome:e.configHome,expectedRevision:null,document:r,validate:A}),s.push("mcp")}catch(c){if(!(c instanceof M))throw c}if(i)try{F({domain:"extensions",configHome:e.configHome,expectedRevision:null,document:i,validate:I}),s.push("extensions")}catch(c){if(!(c instanceof M))throw c}let a=!1;if(e.cleanupLegacy&&p(D(e.configHome))){let c={...n};p(t.mcp.destination)&&delete c.mcpServers,p(t.extensions.destination)&&delete c.extensions,Ut(n,c)||(Kt(e.configHome,c),a=!0)}return{...t,applied:s,cleanedLegacy:a}}o(Xt,"migrateLegacyIntegrationConfigUnlocked");function Ut(e,t){return JSON.stringify(e)===JSON.stringify(t)}o(Ut,"isDeepStrictEqualForConfig");function Qe(e){return p(e)?rt(tt(e,"utf8")):void 0}o(Qe,"currentUserRevision");function F(e){let t=R(e.domain,e.configHome),n=e.validate(e.document);return ge(d.dirname(t),{recursive:!0,mode:448}),de(t,`${t}.lock`,()=>{let r=Qe(t),i=e.expectedRevision===null?void 0:e.expectedRevision;if(e.expectedRevision!==void 0&&r!==i)throw new M(t,i,r);let s=`${JSON.stringify(n,null,2)}
|
|
4
|
-
`,a=`${t}.${process.pid}.${Date.now()}.tmp`,c=At(a,"wx",384);try{Dt(c,s,"utf8"),Mt(c)}finally{_t(c)}try{e.expectedRevision===null?(Ot(a,t),Be(a)):It(a,t)}catch(u){throw p(a)&&Be(a),e.expectedRevision===null&&p(t)?new M(t,void 0,Qe(t)):new Error(`Failed to atomically replace ${d.basename(t)}.`,{cause:u})}return k({domain:e.domain,source:"user",path:t,raw:s,document:n})})}o(F,"writeIntegrationDocument");function Gt(e){if(!p(e))return"missing";let t=Rt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}o(Gt,"metadataSignature");function Ze(e){return e.map(t=>`${t}:${Gt(t)}`).join("|")}o(Ze,"observationSignature");function z(e,t){return{code:e,message:t,time:new Date().toISOString()}}o(z,"safeDiagnostic");var et=class{static{o(this,"IntegrationConfigController")}#f;#n;#o;#a;#m;#d;#p;#e;#t;#c;#u;#g="";#s=[];#r;#i;#h=Promise.resolve();#l=new Set;constructor(t){this.#f=t.domain,this.#n=R(t.domain,t.configHome),this.#o=t.fallbackPath===void 0?void 0:d.resolve(t.fallbackPath),this.#a=this.#o===void 0?[this.#n]:[this.#n,this.#o],this.#d=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#d(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=k({domain:this.#f,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#u:void 0;return{domain:this.#f,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#l.add(t),()=>{this.#l.delete(t)}}reload(){let t=this.#h.then(()=>this.#v());return this.#h=t.then(()=>{},()=>{}),t}async#v(){this.#g=Ze(this.#a);let t;try{t=this.#m(),this.#d(t.document)}catch{let r=this.#y();return this.#c=r.path,this.#u=r.source,this.#t=z("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let r of this.#l)await r(structuredClone(t),n)}catch{return this.#c=t.path,this.#u=t.source,this.#t=z("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#u=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Ze(this.#a)===this.#g&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;ge(d.dirname(this.#n),{recursive:!0,mode:448});let r=new Map;for(let i of this.#a){let s=d.dirname(i),a=r.get(s)??new Set;a.add(d.basename(i)),r.set(s,a)}for(let[i,s]of r)try{let a=kt(i,(c,u)=>{u!==null&&!s.has(u.toString())||(this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=void 0,this.reload()},t),this.#r.unref?.())});a.unref(),a.on("error",()=>{this.#t=z("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=z("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#r&&clearTimeout(this.#r),this.#r=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#l.clear()}#y(){return p(this.#n)?{path:this.#n,source:"user"}:this.#o&&p(this.#o)?{path:this.#o,source:"legacy-user"}:{path:this.#n,source:"default"}}};var Jt=Ht(Vt),it=2,st=!1,l=Ce(),Zn=m.join(l,"sessions"),f=m.join(l,"config.json"),er=60,y=null,ve=!1,zt="dumb";function Bt(e){let t=m.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",r=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",r],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",r]:["-lc",r],sentinel:n}}o(Bt,"buildShellEnvCommand");function Yt(e,t){let n=`${t}\0`,r=e.lastIndexOf(n);if(r===-1)return{};let i=e.slice(r+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}o(Yt,"parseNullDelimitedShellEnv");function Qt(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let r=e.shell??t.SHELL;if(!r||!m.isAbsolute(r))return!1;let{args:i,sentinel:s}=Bt(r),a=e.run??Wt,c={...t,TERM:zt},u=a(r,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(u.status!==0||!u.stdout)return!1;let h=typeof u.stdout=="string"?u.stdout:u.stdout.toString("utf8"),G=Yt(h,s),V=!1;for(let[re,dt]of Object.entries(G))re!=="TERM"&&t[re]===void 0&&(t[re]=dt,V=!0);return V}o(Qt,"hydrateProcessEnvFromShell");function Zt(){if(!ve){ve=!0;try{Qt()}catch{}}}o(Zt,"ensureShellEnvironmentHydrated");function tr(){ve=!1}o(tr,"resetShellEnvironmentHydrationForTesting");function en(e){Re(e.customProviders??[])}o(en,"registerConfiguredCustomProviders");function ye(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}o(ye,"normalizeConfiguredExtensions");function Ee(){let e=g.readFileSync(f,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}o(Ee,"readPersistedCoreConfig");function ut(e){P(f,JSON.stringify(e,null,2))}o(ut,"writePersistedCoreConfig");function tn(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{S(f,()=>{let n=Ee();n?.value.permissionMode==="default"&&ut({...n.value,permissionMode:"accept-edits"})})}catch{}return t}o(tn,"migrateLegacyPermissionModeInConfig");function nn(e){if(e.permissionMode!=="auto-in-project")return e;try{S(f,()=>{let t=Ee();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&P(f,n)})}catch{}return{...e,permissionMode:"auto"}}o(nn,"migrateAutoInProjectAliasInConfig");function rn(){if(y)return y;let e="0.7.97-beta.2";if(e)return y=e,y;let t=m.join(m.dirname(qt(import.meta.url)),"../../package.json");if(g.existsSync(t))try{return y=JSON.parse(g.readFileSync(t,"utf-8")).version??"0.0.0",y??"0.0.0"}catch{}return y="0.0.0",y}o(rn,"getVersion");var nr=rn();function on(e){return Me(e)}o(on,"getProviderModel");function we(e,t){let n=new Set(e.map(i=>i.toLowerCase())),r=[...e];for(let i of t)n.has(i.toLowerCase())||r.push(i);return r}o(we,"mergeModels");function sn(e,t){t||(t=Se().providerModels);let n=t?.[e];if(n&&n.length>0){try{let r=ae(e);if(r.length>0)return we(n,r)}catch{}try{let r=N(e);if(r)return we(n,r.getAvailableModels())}catch{}return n}try{let r=ae(e);if(r.length>0)return r}catch{}try{let r=N(e);if(r)return r.getAvailableModels()}catch{}return[]}o(sn,"getProviderAvailableModels");function an(e,t){let n=Oe(e,t);if(n!=="unknown")return n;try{let r=N(e);if(r)return r.getReasoningCapability(t)}catch{}return"unknown"}o(an,"getProviderReasoningCapability");function cn(e){let t=Ae(e);if(t)return t;try{return ce().find(r=>r.name===e)?.capabilityProfile??null}catch{return null}}o(cn,"getProviderCapabilityProfile");function lt(e,t){let n=cn(e),r=an(e,t);if(n)return{capabilityProfile:n,reasoningCapability:r};try{let i=ue(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}o(lt,"getProviderCapabilityMetadata");function rr(e,t){let n=lt(e,t);return n?Ne({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}o(rr,"getProviderCapabilitySnapshot");function un(e,t,n,r){let i=lt(e,t);return i?Te({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:r}):null}o(un,"getProviderPolicyDecision");function or(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",r=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${r}`}o(or,"describeProviderCapabilitySummary");function ir(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}o(ir,"formatReasoningCapabilityShort");function L(e){if(e)return e==="none"?"off":e}o(L,"formatReasoningEffortForDisplay");function ee(e,t){let n=L(t);n&&!e.includes(n)&&e.push(n)}o(ee,"pushUniqueEffortDisplay");function sr(e,t,n){let r=["auto"],i=ne(e,t,n),s=i?.supportedEfforts?.filter(a=>a.isUserVisible!==!1);if(!s||s.length===0){for(let a of["off","low","medium","high"])ee(r,a);return r}for(let a of s)a.value==="none"&&i?.supportsDisabledThinking===!1||ee(r,a.value);return r}o(sr,"getProviderReasoningEffortOptions");function ar(e,t){let n=ne(e,t),r=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(u=>u.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let u of["low","medium","high"])ee(s,u);a=!0}else for(let u of i){if(u.value==="none"){n?.supportsDisabledThinking!==!1&&(a=!0);continue}if(r.has(u.value)){n?.supportsDisabledThinking!==!1&&(a=!0);continue}ee(s,u.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}o(ar,"getProviderReasoningEffortCycle");function ln(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}o(ln,"legacyReasoningModeToEffortDisplay");function ne(e,t,n){let r=t??on(e);if(!r)return;let i=ke(e,r)?.reasoningProfile;if(i)return ue(e).usesScopedReasoningLearning?.()?i:Pe(i,De(e,r,n))}o(ne,"resolveReasoningProfileForDisplay");function cr(e){let t=L(e.effort)??ln(e.reasoningMode,e.thinking),n=ne(e.provider,e.model);if(!n)return t;try{let r=xe({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=L(r.configuredEffort)??t,a=r.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(r.configuredEffort)===!0?"off":L(r.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let r=se({currentEffort:e.effort,capability:n}),i=L(e.effort)??t,s=L(r.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}o(cr,"formatReasoningEffortStatusLabel");function ur(e){let t=wn(e);if(!t)return{preserved:!0};let n=ne(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let r=se({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:r.effectiveEffort,preserved:r.preserved,diagnostic:r.diagnostic}}o(ur,"resolveProviderReasoningRuntimeEffort");function fn(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}o(fn,"describeReasoningCapabilityControl");function lr(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}o(lr,"describeReasoningExecution");function fr(e){let t=[];e||(e=Se().providerModels);for(let n of Ie())t.push({name:n.name,model:n.model,models:sn(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=ce().map(r=>({...r,models:(()=>{let i=e?.[r.name];return i&&i.length>0?we(i,r.models):r.models})()}));t.push(...n)}catch{}return t}o(fr,"getProviderList");function dr(e){if(_e(e))return!0;try{return N(e)?.isConfigured()??!1}catch{return!1}}o(dr,"isProviderConfigured");var te=class extends Error{static{o(this,"InvalidAgentModeConfigError")}};function dn(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new te(`Invalid agentMode "${t}" in ${f}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,it)};try{S(f,()=>{let r=Ee();if(!r)return;let i=r.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||ut({...r.value,agentMode:"ama",schemaVersion:Math.max(typeof r.value.schemaVersion=="number"?r.value.schemaVersion:0,it)})})}catch{}return st||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),st=!0),n}o(dn,"migrateLegacyAgentModeConfig");function Se(){try{let n=!1;try{g.lstatSync(f),n=!0}catch(r){if(r.code!=="ENOENT")throw r}if(n){let r=JSON.parse(g.readFileSync(f,"utf-8"));if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Invalid core configuration object.");let i=dn(r),s=i.reasoningCeiling??i.reasoningMode,a=[],c={};try{a=[...Z(l).document.paths]}catch{}try{c=Q(l).document.servers}catch{}let{sandbox:u,...h}=i;return nn(tn({...h,reasoningMode:s,extensions:ye(a),mcpServers:c}))}}catch(n){throw n instanceof te?n:new Error(`Core configuration is unreadable or invalid: ${f}. Repair the retained original before continuing. Use kodax doctor --json for a read-only syntax diagnostic.`)}let e,t;try{let n=Z(l);n.source!=="default"&&(e=ye([...n.document.paths]))}catch{}try{let n=Q(l);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}o(Se,"loadConfig");var pn=m.join(l,"config.example.jsonc"),he={mcp:m.join(l,"integrations","mcp.example.jsonc"),a2a:m.join(l,"integrations","a2a.example.jsonc"),extensions:m.join(l,"integrations","extensions.example.jsonc")},mn=[{name:"core",path:pn},{name:"mcp",path:he.mcp},{name:"a2a",path:he.a2a},{name:"extensions",path:he.extensions}];function gn(){let e=[];for(let t of mn)try{if(g.existsSync(t.path))continue;g.mkdirSync(m.dirname(t.path),{recursive:!0}),g.writeFileSync(t.path,Ue(t.name),"utf8"),e.push(t.path)}catch{}return e}o(gn,"ensureExampleConfigFiles");function pr(){return gn()[0]}o(pr,"ensureExampleConfigFile");var U=new Map;function mr(e){let t=process.env[e];return t===void 0?"unset":U.get(e)===t?"persisted":"environment"}o(mr,"inspectConfigEnvironmentSource");function ft(e,t,n=!1){let r=process.env[e],i=U.get(e),s=i!==void 0&&r===i;if(r!==void 0&&!s&&!n){U.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],U.delete(e);return}process.env[e]=t,U.set(e,t)}o(ft,"projectConfigEnvironment");var be=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:o(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:o(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:o(e=>K(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:o(e=>K(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:o(e=>vn(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:o(e=>w(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:o(e=>w(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:o(e=>w(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:o(e=>w(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:o(e=>w(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:o(e=>w(e.effort),"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:o(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:o(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:o(e=>K(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:o(e=>K(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:o(e=>K(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:o(e=>w(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:o(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:o(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:o(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:o(e=>w(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:o(e=>b(e.workflow?.maxConcurrency),"value")}];function hn(e){for(let t of be)ft(t.env,t.value(e))}o(hn,"applyConfigSurfaceBridges");function w(e){return e?.trim()||void 0}o(w,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}o(b,"configNumberString");function K(e){return e===void 0?void 0:e?"1":"0"}o(K,"configBooleanString");function vn(e){return e?.filter(t=>t.trim().length>0).join(",")}o(vn,"configStringList");var gr=[...be.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function yn(e){hn(e)}o(yn,"applyConfigEnvironment");function hr(e,t=!1){for(let n of be)["fallbackProviders","stallLog"].includes(n.configPath)&&(t&&!Object.hasOwn(e,n.configPath)||ft(n.env,n.value(e),t))}o(hr,"applyExecutionConfigEnvironment");function vr(){Zt();let e=Se();return yn(e),en(e),je(e.locale),e}o(vr,"prepareRuntimeConfig");function yr(e){let{extensions:t,mcpServers:n,...r}=e;if(S(f,()=>{let i={};if(g.existsSync(f)){let a=g.readFileSync(f,"utf8"),c;try{c=JSON.parse(a)}catch{throw new Error("Core configuration is unreadable; retain and repair the original before saving.")}if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Invalid core configuration; retain and repair the original before saving.");i=c}let s={...i,...r};for(let a of Object.keys(r))r[a]===void 0&&delete s[a];P(f,JSON.stringify(s,null,2))}),t!==void 0){let i=Z(l);F({domain:"extensions",configHome:l,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:ye(t)??[]},validate:I})}if(n!==void 0){let i=Q(l);F({domain:"mcp",configHome:l,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:A})}}o(yr,"saveConfig");function wr(e,t,n){return e.effort!==void 0||ie(n).kind==="value"||t.effort!==void 0}o(wr,"resolveInitialEffortOverride");function E(e){return e?.trim()?e:void 0}o(E,"nonEmptySelection");function Er(e){return E(e.explicitProvider)??E(e.environmentProvider)??E(e.configuredProvider)??e.defaultProvider}o(Er,"resolveRuntimeProviderSelection");function Sr(e){let t=E(e.explicitModel);if(t)return t;let n=E(e.configuredModel);if(!n)return;let r=E(e.explicitProvider)??E(e.environmentProvider);return r?E(e.configuredProvider)===r?n:void 0:n}o(Sr,"resolveRuntimeModelSelection");function br(e){if(e.explicitEffort!==void 0)return oe(e.explicitEffort);let t=ie(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:oe(e.configuredEffort)}o(br,"resolveRuntimeEffortSelection");function wn(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}o(wn,"resolvePermissionModeEffort");async function Cr(e){try{await Le({cwd:e});let{stdout:t}=await Jt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}o(Cr,"getGitRoot");function En(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}o(En,"formatProviderSourceKind");function xr(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${En(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${fn(e.reasoningCapability)}`]}o(xr,"formatProviderCapabilityDetailLines");function Pr(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:un(e,t,n,i.hints)})).filter(i=>i.decision!==null)}o(Pr,"getProviderCommonPolicyScenarios");var at=.5,ct=0,X={locked:!1,queue:[]};async function _r(e){for(;X.locked;)await new Promise(t=>X.queue.push(t));X.locked=!0;try{let t=(Date.now()-ct)/1e3;t<at&&await new Promise(r=>setTimeout(r,(at-t)*1e3));let n=await e();return ct=Date.now(),n}finally{X.locked=!1;let t=X.queue.shift();t&&t()}}o(_r,"rateLimitedCall");export{Sn as a,Xe as b,Ue as c,H as d,j as e,Je as f,ze as g,P as h,fe as i,Pt as j,S as k,M as l,A as m,I as n,R as o,Q as p,Z as q,Ft as r,jn as s,F as t,et as u,l as v,Zn as w,f as x,er as y,Qt as z,tr as A,en as B,rn as C,nr as D,on as E,sn as F,an as G,cn as H,rr as I,un as J,or as K,ir as L,L as M,sr as N,ar as O,cr as P,ur as Q,fn as R,lr as S,fr as T,dr as U,Se as V,pn as W,he as X,gn as Y,pr as Z,mr as _,gr as $,yn as aa,hr as ba,vr as ca,yr as da,wr as ea,Er as fa,Sr as ga,br as ha,wn as ia,Cr as ja,En as ka,xr as la,Pr as ma,_r as na};
|
|
4
|
+
`,a=`${t}.${process.pid}.${Date.now()}.tmp`,c=At(a,"wx",384);try{Dt(c,s,"utf8"),Mt(c)}finally{_t(c)}try{e.expectedRevision===null?(Ot(a,t),Be(a)):It(a,t)}catch(u){throw p(a)&&Be(a),e.expectedRevision===null&&p(t)?new M(t,void 0,Qe(t)):new Error(`Failed to atomically replace ${d.basename(t)}.`,{cause:u})}return k({domain:e.domain,source:"user",path:t,raw:s,document:n})})}o(F,"writeIntegrationDocument");function Gt(e){if(!p(e))return"missing";let t=Rt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}o(Gt,"metadataSignature");function Ze(e){return e.map(t=>`${t}:${Gt(t)}`).join("|")}o(Ze,"observationSignature");function z(e,t){return{code:e,message:t,time:new Date().toISOString()}}o(z,"safeDiagnostic");var et=class{static{o(this,"IntegrationConfigController")}#f;#n;#o;#a;#m;#d;#p;#e;#t;#c;#u;#g="";#s=[];#r;#i;#h=Promise.resolve();#l=new Set;constructor(t){this.#f=t.domain,this.#n=R(t.domain,t.configHome),this.#o=t.fallbackPath===void 0?void 0:d.resolve(t.fallbackPath),this.#a=this.#o===void 0?[this.#n]:[this.#n,this.#o],this.#d=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#d(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=k({domain:this.#f,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#u:void 0;return{domain:this.#f,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#l.add(t),()=>{this.#l.delete(t)}}reload(){let t=this.#h.then(()=>this.#v());return this.#h=t.then(()=>{},()=>{}),t}async#v(){this.#g=Ze(this.#a);let t;try{t=this.#m(),this.#d(t.document)}catch{let r=this.#y();return this.#c=r.path,this.#u=r.source,this.#t=z("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let r of this.#l)await r(structuredClone(t),n)}catch{return this.#c=t.path,this.#u=t.source,this.#t=z("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#u=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return Ze(this.#a)===this.#g&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;ge(d.dirname(this.#n),{recursive:!0,mode:448});let r=new Map;for(let i of this.#a){let s=d.dirname(i),a=r.get(s)??new Set;a.add(d.basename(i)),r.set(s,a)}for(let[i,s]of r)try{let a=kt(i,(c,u)=>{u!==null&&!s.has(u.toString())||(this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=void 0,this.reload()},t),this.#r.unref?.())});a.unref(),a.on("error",()=>{this.#t=z("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=z("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#r&&clearTimeout(this.#r),this.#r=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#l.clear()}#y(){return p(this.#n)?{path:this.#n,source:"user"}:this.#o&&p(this.#o)?{path:this.#o,source:"legacy-user"}:{path:this.#n,source:"default"}}};var Jt=Ht(Vt),it=2,st=!1,l=Ce(),Zn=m.join(l,"sessions"),f=m.join(l,"config.json"),er=60,y=null,ve=!1,zt="dumb";function Bt(e){let t=m.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",r=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",r],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",r]:["-lc",r],sentinel:n}}o(Bt,"buildShellEnvCommand");function Yt(e,t){let n=`${t}\0`,r=e.lastIndexOf(n);if(r===-1)return{};let i=e.slice(r+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}o(Yt,"parseNullDelimitedShellEnv");function Qt(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let r=e.shell??t.SHELL;if(!r||!m.isAbsolute(r))return!1;let{args:i,sentinel:s}=Bt(r),a=e.run??Wt,c={...t,TERM:zt},u=a(r,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(u.status!==0||!u.stdout)return!1;let h=typeof u.stdout=="string"?u.stdout:u.stdout.toString("utf8"),G=Yt(h,s),V=!1;for(let[re,dt]of Object.entries(G))re!=="TERM"&&t[re]===void 0&&(t[re]=dt,V=!0);return V}o(Qt,"hydrateProcessEnvFromShell");function Zt(){if(!ve){ve=!0;try{Qt()}catch{}}}o(Zt,"ensureShellEnvironmentHydrated");function tr(){ve=!1}o(tr,"resetShellEnvironmentHydrationForTesting");function en(e){Re(e.customProviders??[])}o(en,"registerConfiguredCustomProviders");function ye(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}o(ye,"normalizeConfiguredExtensions");function Ee(){let e=g.readFileSync(f,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}o(Ee,"readPersistedCoreConfig");function ut(e){P(f,JSON.stringify(e,null,2))}o(ut,"writePersistedCoreConfig");function tn(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{S(f,()=>{let n=Ee();n?.value.permissionMode==="default"&&ut({...n.value,permissionMode:"accept-edits"})})}catch{}return t}o(tn,"migrateLegacyPermissionModeInConfig");function nn(e){if(e.permissionMode!=="auto-in-project")return e;try{S(f,()=>{let t=Ee();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&P(f,n)})}catch{}return{...e,permissionMode:"auto"}}o(nn,"migrateAutoInProjectAliasInConfig");function rn(){if(y)return y;let e="0.7.97-beta.3";if(e)return y=e,y;let t=m.join(m.dirname(qt(import.meta.url)),"../../package.json");if(g.existsSync(t))try{return y=JSON.parse(g.readFileSync(t,"utf-8")).version??"0.0.0",y??"0.0.0"}catch{}return y="0.0.0",y}o(rn,"getVersion");var nr=rn();function on(e){return Me(e)}o(on,"getProviderModel");function we(e,t){let n=new Set(e.map(i=>i.toLowerCase())),r=[...e];for(let i of t)n.has(i.toLowerCase())||r.push(i);return r}o(we,"mergeModels");function sn(e,t){t||(t=Se().providerModels);let n=t?.[e];if(n&&n.length>0){try{let r=ae(e);if(r.length>0)return we(n,r)}catch{}try{let r=N(e);if(r)return we(n,r.getAvailableModels())}catch{}return n}try{let r=ae(e);if(r.length>0)return r}catch{}try{let r=N(e);if(r)return r.getAvailableModels()}catch{}return[]}o(sn,"getProviderAvailableModels");function an(e,t){let n=Oe(e,t);if(n!=="unknown")return n;try{let r=N(e);if(r)return r.getReasoningCapability(t)}catch{}return"unknown"}o(an,"getProviderReasoningCapability");function cn(e){let t=Ae(e);if(t)return t;try{return ce().find(r=>r.name===e)?.capabilityProfile??null}catch{return null}}o(cn,"getProviderCapabilityProfile");function lt(e,t){let n=cn(e),r=an(e,t);if(n)return{capabilityProfile:n,reasoningCapability:r};try{let i=ue(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}o(lt,"getProviderCapabilityMetadata");function rr(e,t){let n=lt(e,t);return n?Ne({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}o(rr,"getProviderCapabilitySnapshot");function un(e,t,n,r){let i=lt(e,t);return i?Te({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:r}):null}o(un,"getProviderPolicyDecision");function or(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",r=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${r}`}o(or,"describeProviderCapabilitySummary");function ir(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}o(ir,"formatReasoningCapabilityShort");function L(e){if(e)return e==="none"?"off":e}o(L,"formatReasoningEffortForDisplay");function ee(e,t){let n=L(t);n&&!e.includes(n)&&e.push(n)}o(ee,"pushUniqueEffortDisplay");function sr(e,t,n){let r=["auto"],i=ne(e,t,n),s=i?.supportedEfforts?.filter(a=>a.isUserVisible!==!1);if(!s||s.length===0){for(let a of["off","low","medium","high"])ee(r,a);return r}for(let a of s)a.value==="none"&&i?.supportsDisabledThinking===!1||ee(r,a.value);return r}o(sr,"getProviderReasoningEffortOptions");function ar(e,t){let n=ne(e,t),r=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(u=>u.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let u of["low","medium","high"])ee(s,u);a=!0}else for(let u of i){if(u.value==="none"){n?.supportsDisabledThinking!==!1&&(a=!0);continue}if(r.has(u.value)){n?.supportsDisabledThinking!==!1&&(a=!0);continue}ee(s,u.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}o(ar,"getProviderReasoningEffortCycle");function ln(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}o(ln,"legacyReasoningModeToEffortDisplay");function ne(e,t,n){let r=t??on(e);if(!r)return;let i=ke(e,r)?.reasoningProfile;if(i)return ue(e).usesScopedReasoningLearning?.()?i:Pe(i,De(e,r,n))}o(ne,"resolveReasoningProfileForDisplay");function cr(e){let t=L(e.effort)??ln(e.reasoningMode,e.thinking),n=ne(e.provider,e.model);if(!n)return t;try{let r=xe({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=L(r.configuredEffort)??t,a=r.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(r.configuredEffort)===!0?"off":L(r.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let r=se({currentEffort:e.effort,capability:n}),i=L(e.effort)??t,s=L(r.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}o(cr,"formatReasoningEffortStatusLabel");function ur(e){let t=wn(e);if(!t)return{preserved:!0};let n=ne(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let r=se({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:r.effectiveEffort,preserved:r.preserved,diagnostic:r.diagnostic}}o(ur,"resolveProviderReasoningRuntimeEffort");function fn(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}o(fn,"describeReasoningCapabilityControl");function lr(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}o(lr,"describeReasoningExecution");function fr(e){let t=[];e||(e=Se().providerModels);for(let n of Ie())t.push({name:n.name,model:n.model,models:sn(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=ce().map(r=>({...r,models:(()=>{let i=e?.[r.name];return i&&i.length>0?we(i,r.models):r.models})()}));t.push(...n)}catch{}return t}o(fr,"getProviderList");function dr(e){if(_e(e))return!0;try{return N(e)?.isConfigured()??!1}catch{return!1}}o(dr,"isProviderConfigured");var te=class extends Error{static{o(this,"InvalidAgentModeConfigError")}};function dn(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new te(`Invalid agentMode "${t}" in ${f}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,it)};try{S(f,()=>{let r=Ee();if(!r)return;let i=r.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||ut({...r.value,agentMode:"ama",schemaVersion:Math.max(typeof r.value.schemaVersion=="number"?r.value.schemaVersion:0,it)})})}catch{}return st||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),st=!0),n}o(dn,"migrateLegacyAgentModeConfig");function Se(){try{let n=!1;try{g.lstatSync(f),n=!0}catch(r){if(r.code!=="ENOENT")throw r}if(n){let r=JSON.parse(g.readFileSync(f,"utf-8"));if(!r||typeof r!="object"||Array.isArray(r))throw new Error("Invalid core configuration object.");let i=dn(r),s=i.reasoningCeiling??i.reasoningMode,a=[],c={};try{a=[...Z(l).document.paths]}catch{}try{c=Q(l).document.servers}catch{}let{sandbox:u,...h}=i;return nn(tn({...h,reasoningMode:s,extensions:ye(a),mcpServers:c}))}}catch(n){throw n instanceof te?n:new Error(`Core configuration is unreadable or invalid: ${f}. Repair the retained original before continuing. Use kodax doctor --json for a read-only syntax diagnostic.`)}let e,t;try{let n=Z(l);n.source!=="default"&&(e=ye([...n.document.paths]))}catch{}try{let n=Q(l);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}o(Se,"loadConfig");var pn=m.join(l,"config.example.jsonc"),he={mcp:m.join(l,"integrations","mcp.example.jsonc"),a2a:m.join(l,"integrations","a2a.example.jsonc"),extensions:m.join(l,"integrations","extensions.example.jsonc")},mn=[{name:"core",path:pn},{name:"mcp",path:he.mcp},{name:"a2a",path:he.a2a},{name:"extensions",path:he.extensions}];function gn(){let e=[];for(let t of mn)try{if(g.existsSync(t.path))continue;g.mkdirSync(m.dirname(t.path),{recursive:!0}),g.writeFileSync(t.path,Ue(t.name),"utf8"),e.push(t.path)}catch{}return e}o(gn,"ensureExampleConfigFiles");function pr(){return gn()[0]}o(pr,"ensureExampleConfigFile");var U=new Map;function mr(e){let t=process.env[e];return t===void 0?"unset":U.get(e)===t?"persisted":"environment"}o(mr,"inspectConfigEnvironmentSource");function ft(e,t,n=!1){let r=process.env[e],i=U.get(e),s=i!==void 0&&r===i;if(r!==void 0&&!s&&!n){U.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],U.delete(e);return}process.env[e]=t,U.set(e,t)}o(ft,"projectConfigEnvironment");var be=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:o(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:o(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:o(e=>K(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:o(e=>K(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:o(e=>vn(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:o(e=>w(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:o(e=>w(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:o(e=>w(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:o(e=>w(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:o(e=>w(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:o(e=>w(e.effort),"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:o(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:o(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:o(e=>K(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:o(e=>K(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:o(e=>K(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:o(e=>w(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:o(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:o(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:o(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:o(e=>w(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:o(e=>b(e.workflow?.maxConcurrency),"value")}];function hn(e){for(let t of be)ft(t.env,t.value(e))}o(hn,"applyConfigSurfaceBridges");function w(e){return e?.trim()||void 0}o(w,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}o(b,"configNumberString");function K(e){return e===void 0?void 0:e?"1":"0"}o(K,"configBooleanString");function vn(e){return e?.filter(t=>t.trim().length>0).join(",")}o(vn,"configStringList");var gr=[...be.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function yn(e){hn(e)}o(yn,"applyConfigEnvironment");function hr(e,t=!1){for(let n of be)["fallbackProviders","stallLog"].includes(n.configPath)&&(t&&!Object.hasOwn(e,n.configPath)||ft(n.env,n.value(e),t))}o(hr,"applyExecutionConfigEnvironment");function vr(){Zt();let e=Se();return yn(e),en(e),je(e.locale),e}o(vr,"prepareRuntimeConfig");function yr(e){let{extensions:t,mcpServers:n,...r}=e;if(S(f,()=>{let i={};if(g.existsSync(f)){let a=g.readFileSync(f,"utf8"),c;try{c=JSON.parse(a)}catch{throw new Error("Core configuration is unreadable; retain and repair the original before saving.")}if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Invalid core configuration; retain and repair the original before saving.");i=c}let s={...i,...r};for(let a of Object.keys(r))r[a]===void 0&&delete s[a];P(f,JSON.stringify(s,null,2))}),t!==void 0){let i=Z(l);F({domain:"extensions",configHome:l,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:ye(t)??[]},validate:I})}if(n!==void 0){let i=Q(l);F({domain:"mcp",configHome:l,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:A})}}o(yr,"saveConfig");function wr(e,t,n){return e.effort!==void 0||ie(n).kind==="value"||t.effort!==void 0}o(wr,"resolveInitialEffortOverride");function E(e){return e?.trim()?e:void 0}o(E,"nonEmptySelection");function Er(e){return E(e.explicitProvider)??E(e.environmentProvider)??E(e.configuredProvider)??e.defaultProvider}o(Er,"resolveRuntimeProviderSelection");function Sr(e){let t=E(e.explicitModel);if(t)return t;let n=E(e.configuredModel);if(!n)return;let r=E(e.explicitProvider)??E(e.environmentProvider);return r?E(e.configuredProvider)===r?n:void 0:n}o(Sr,"resolveRuntimeModelSelection");function br(e){if(e.explicitEffort!==void 0)return oe(e.explicitEffort);let t=ie(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:oe(e.configuredEffort)}o(br,"resolveRuntimeEffortSelection");function wn(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}o(wn,"resolvePermissionModeEffort");async function Cr(e){try{await Le({cwd:e});let{stdout:t}=await Jt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}o(Cr,"getGitRoot");function En(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}o(En,"formatProviderSourceKind");function xr(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${En(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${fn(e.reasoningCapability)}`]}o(xr,"formatProviderCapabilityDetailLines");function Pr(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:un(e,t,n,i.hints)})).filter(i=>i.decision!==null)}o(Pr,"getProviderCommonPolicyScenarios");var at=.5,ct=0,X={locked:!1,queue:[]};async function _r(e){for(;X.locked;)await new Promise(t=>X.queue.push(t));X.locked=!0;try{let t=(Date.now()-ct)/1e3;t<at&&await new Promise(r=>setTimeout(r,(at-t)*1e3));let n=await e();return ct=Date.now(),n}finally{X.locked=!1;let t=X.queue.shift();t&&t()}}o(_r,"rateLimitedCall");export{Sn as a,Xe as b,Ue as c,H as d,j as e,Je as f,ze as g,P as h,fe as i,Pt as j,S as k,M as l,A as m,I as n,R as o,Q as p,Z as q,Ft as r,jn as s,F as t,et as u,l as v,Zn as w,f as x,er as y,Qt as z,tr as A,en as B,rn as C,nr as D,on as E,sn as F,an as G,cn as H,rr as I,un as J,or as K,ir as L,L as M,sr as N,ar as O,cr as P,ur as Q,fn as R,lr as S,fr as T,dr as U,Se as V,pn as W,he as X,gn as Y,pr as Z,mr as _,gr as $,yn as aa,hr as ba,vr as ca,yr as da,wr as ea,Er as fa,Sr as ga,br as ha,wn as ia,Cr as ja,En as ka,xr as la,Pr as ma,_r as na};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{cb as o}from"./chunk-
|
|
2
|
+
import{cb as o}from"./chunk-DAQGOWKD.js";import{a as r}from"./chunk-V4WSBIXB.js";var p=Object.freeze({".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"typescriptreact",".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"javascriptreact",".py":"python",".pyi":"python",".go":"go",".rs":"rust",".java":"java"});function f(e){let t=e.lastIndexOf(".");if(t<0)return;let s=e.slice(t).toLowerCase();return p[s]}r(f,"languageIdForPath");var a=process.platform==="win32";function v(e){let t=e.replace(/\\/g,"/");return a?t.toLowerCase():t}r(v,"normalizeFsPath");import{spawn as c}from"child_process";function u(e){return process.platform==="win32"&&e!==process.execPath&&!/\.exe$/i.test(e)}r(u,"needsShell");function I(e,t,s,i=e===process.execPath?"javascript":"native"){if(u(e)){let n=[l(e),...t].join(" ");return c(n,{...s,shell:!0,windowsHide:!0})}if(i==="javascript"){let n=o({args:t,env:s.env??process.env,isElectron:process.versions.electron!==void 0,executable:e});return c(n.command,n.args,{...s,env:n.env,shell:!1,windowsHide:!0})}return c(e,[...t],{...s,shell:!1,windowsHide:!0})}r(I,"spawnLspProcess");function l(e){return/[\s"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}r(l,"quoteIfNeeded");export{f as a,v as b,I as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{p as h}from"./chunk-OMVAPRQI.js";import{a as i}from"./chunk-V4WSBIXB.js";import{createHash as J,randomUUID as F}from"node:crypto";import*as t from"node:fs";import a from"node:path";var E,b=!1;function A(e){return e!==process.pid?h(e):(b||(E=h(e),b=!0),E)}i(A,"readRuntimeOwnerProcessStartIdentity");function C(e,n="default"){let r=W(n),o=a.resolve(e),s=a.join(o,"runtime","daemon",r);return{profile:r,configHome:o,rootDir:s,stateFile:a.join(s,"daemon.json"),lockFile:a.join(s,"daemon.lock"),tokenFile:a.join(s,"daemon.token"),logFile:a.join(s,"daemon.log"),runsDir:a.join(s,"runs"),eventsDir:a.join(s,"events"),ownerPolicyFile:a.join(s,"owner-policy.json"),ownerPolicyLockFile:a.join(s,"owner-policy.lock")}}i(C,"resolveRuntimeDaemonPathsFromConfigHome");function T(e,n){let r=i(o=>{let s=a.resolve(o);return process.platform==="win32"?s.toLowerCase():s},"resolveIdentity");return r(e)===r(n)}i(T,"isSameRuntimeDaemonPath");function te(e,n){let r=a.resolve(e);return T(n,a.join(r,".kodax"))?r:a.resolve(n)}i(te,"resolveRuntimeDaemonEndpointScope");function O(e){if(!t.existsSync(e.ownerPolicyFile))return{mode:"daemon",revision:0,updatedAt:new Date(0).toISOString()};try{let n=JSON.parse(t.readFileSync(e.ownerPolicyFile,"utf8"));if(I(n)&&(n.mode==="daemon"||n.mode==="inline"||n.mode==="host")&&typeof n.revision=="number"&&Number.isSafeInteger(n.revision)&&n.revision>=0&&typeof n.updatedAt=="string")return{mode:n.mode==="host"?"daemon":n.mode,revision:n.revision,updatedAt:n.updatedAt,...n.mode==="host"?{unified:!0}:{}}}catch{}throw new Error("Runtime owner policy is corrupt; refusing to choose an owner.")}i(O,"readRuntimeOwnerPolicy");function re(e,n,r){B(e);let o=O(e);if(o.unified&&!r)return o;t.mkdirSync(n,{recursive:!0});let s=a.join(t.realpathSync(n),".product-host");t.mkdirSync(s,{recursive:!0});let d={ownerPolicyLockFile:a.join(s,"owner-policy.lock")},l=S(d);if(!l)throw new Error("Session storage owner transition is already in progress.");try{let f=S(e);if(!f)throw new Error("Runtime owner transition is already in progress.");try{let c=O(e);if(c.unified&&!r)return c;let u=p(e.lockFile);if(!u&&t.existsSync(e.lockFile))throw new Error("Cannot migrate an unreadable Runtime owner lock.");let k=j(e);if(!k&&t.existsSync(e.stateFile))throw new Error("Cannot migrate an unreadable Host descriptor.");if(k&&(!u||k.runtimeId!==u.runtimeId||k.pid!==u.pid)&&w({pid:k.pid})!=="gone")throw new Error("Cannot migrate a live or unverified Host descriptor without its matching owner lock.");let x=a.join(s,"owner.lock"),y=p(x);if(!y&&t.existsSync(x))throw new Error("Cannot migrate an unreadable Session storage owner lock.");let m=r?U(e.configHome,n):void 0,R=m?p(C(e.configHome,m.profile).lockFile):void 0;if(r&&(!m||m.profile!==r.profile||m.profile===e.profile||m.ownerFile!==r.ownerFile||!P(m.owner,r.owner)||!m.owner.processStartIdentity||w(m.owner)!=="alive"||!R||R.runtimeId!==m.owner.runtimeId||R.pid!==m.owner.pid||R.processStartIdentity!==m.owner.processStartIdentity||R.kind==="inline"))throw new Error("The verified shared Host changed before requested-profile migration.");if(y&&w(y)!=="gone"){if(!r&&c.mode==="daemon"&&u&&u.kind!=="inline"&&y.kind==="daemon"&&y.runtimeId===u.runtimeId&&y.pid===u.pid&&y.processStartIdentity===u.processStartIdentity&&w(u)==="alive")return c;if(!m||!P(y,m.owner))throw new Error("Cannot migrate while Session storage has an active or unverified owner.")}if(u){let L=w(u);if(!r&&L==="alive"&&c.mode==="daemon"&&u.kind!=="inline")return c;if(L!=="gone")throw new Error("Cannot migrate while the Runtime owner is active or its liveness is unverified.");if(c.mode==="inline"&&u.kind!=="inline")throw new Error("Cannot migrate ambiguous legacy Runtime ownership.")}return c.unified?c:M(e,"daemon",c.revision,f.nonce,!0)}finally{g(e,f)}}finally{g(d,l)}}i(re,"prepareRuntimeDaemonOwner");function M(e,n,r,o,s=!1){let d=O(e);if(d.unified&&!s)throw new Error("Legacy Runtime ownership changes are retired for this profile.");if(d.revision!==r)throw _(`Runtime owner policy conflict: expected ${r}, current ${d.revision}.`);let l={mode:n,revision:d.revision+1,updatedAt:new Date().toISOString(),...s?{unified:!0}:{}},f=`${e.ownerPolicyFile}.${process.pid}.${o}.tmp`;try{let c=t.openSync(f,"wx",384);try{let u=s?{mode:"host",revision:l.revision,updatedAt:l.updatedAt}:l;t.writeFileSync(c,`${JSON.stringify(u,null,2)}
|
|
3
|
+
`,"utf8"),t.fsyncSync(c)}finally{t.closeSync(c)}return t.renameSync(f,e.ownerPolicyFile),l}finally{t.rmSync(f,{force:!0})}}i(M,"writeRuntimeOwnerPolicy");function _(e){let n=new Error(e);return n.code="conflict",n}i(_,"runtimeOwnerPolicyConflict");var D=new Map;function S(e,n=!0){let r=D.get(e.ownerPolicyLockFile);r!==void 0&&g(e,r);let o=F(),s=A(process.pid),d={runtimeId:`owner-transition-${o}`,pid:process.pid,createdAt:new Date().toISOString(),...s===void 0?{}:{processStartIdentity:s}},l={...d,nonce:o};if($({rootDir:a.dirname(e.ownerPolicyLockFile),lockFile:e.ownerPolicyLockFile},l))return{nonce:o,owner:d};if(n&&q(e))return S(e,!1)}i(S,"tryAcquireRuntimeOwnerCoordination");function q(e){let n=v(e);if(!n||w(n.owner)!=="gone")return!1;let r=`${e.ownerPolicyLockFile}.reclaim.${J("sha256").update(n.nonce).digest("hex")}`;if(!$({rootDir:a.dirname(r),lockFile:r},{runtimeId:`owner-reclaim-${F()}`,pid:process.pid,createdAt:new Date().toISOString()}))return!1;try{let s=v(e);return!s||s.nonce!==n.nonce?!1:(t.unlinkSync(e.ownerPolicyLockFile),!0)}catch{return!1}}i(q,"removeAbandonedRuntimeOwnerCoordination");function v(e){try{let n=JSON.parse(t.readFileSync(e.ownerPolicyLockFile,"utf8"));return!I(n)||typeof n.nonce!="string"||!N(n)||!n.runtimeId.startsWith("owner-transition-")?void 0:{nonce:n.nonce,owner:n}}catch{return}}i(v,"readRuntimeOwnerCoordinationHandle");function g(e,n){try{let r=JSON.parse(t.readFileSync(e.ownerPolicyLockFile,"utf8"));I(r)&&r.nonce===n.nonce&&t.unlinkSync(e.ownerPolicyLockFile),D.delete(e.ownerPolicyLockFile)}catch(r){if(r.code==="ENOENT"){D.delete(e.ownerPolicyLockFile);return}throw D.set(e.ownerPolicyLockFile,n),r}}i(g,"releaseRuntimeOwnerCoordination");function W(e){let n=e.trim()||"default";if(n==="."||n===".."||!/^[A-Za-z0-9_.-]+$/.test(n))throw new Error(`Invalid runtime daemon profile: ${e}`);return n}i(W,"normalizeRuntimeDaemonProfile");function B(e){t.mkdirSync(e.rootDir,{recursive:!0}),t.mkdirSync(e.runsDir,{recursive:!0}),t.mkdirSync(e.eventsDir,{recursive:!0})}i(B,"ensureRuntimeDaemonDirectories");function oe(e){try{let n=t.readFileSync(e.tokenFile,"utf8").trim();return n.length>0?n:void 0}catch(n){if(n.code==="ENOENT")return;throw n}}i(oe,"readRuntimeDaemonToken");function j(e){if(t.existsSync(e.stateFile))try{let n=JSON.parse(t.readFileSync(e.stateFile,"utf8"));return Z(n)?n:void 0}catch{return}}i(j,"readRuntimeDaemonState");function w(e){if(!Number.isSafeInteger(e.pid)||e.pid<=0)return"gone";try{process.kill(e.pid,0)}catch(r){return H(r)&&r.code==="ESRCH"?"gone":"unknown"}if(process.platform==="linux")try{let r=t.readFileSync(`/proc/${e.pid}/stat`,"utf8"),o=/^\d+ \(.*\) ([A-Za-z]) /s.exec(r);if(o&&["Z","X","x"].includes(o[1]))return"gone";if(!o)return"unknown"}catch{return"unknown"}if(e.processStartIdentity===void 0)return"alive";let n=A(e.pid);return n===void 0?"unknown":n===e.processStartIdentity?"alive":"gone"}i(w,"runtimeOwnerProcessState");function z(e,n){return a.join(e.rootDir,`shutdown-outcome.${encodeURIComponent(n.runtimeId)}.${n.pid}.json`)}i(z,"runtimeDaemonShutdownOutcomePath");function ie(e,n){try{let r=JSON.parse(t.readFileSync(z(e,n),"utf8"));return X(r)&&r.runtimeId===n.runtimeId&&r.pid===n.pid?r:void 0}catch{return}}i(ie,"readRuntimeDaemonShutdownOutcome");function $(e,n){t.mkdirSync(e.rootDir,{recursive:!0});let r=`${e.lockFile}.${F()}.tmp`,o,s=!1;try{o=t.openSync(r,"wx",384),t.writeFileSync(o,`${JSON.stringify(n,null,2)}
|
|
4
|
+
`,"utf8"),t.fsyncSync(o);let d=o;return o=void 0,t.closeSync(d),t.linkSync(r,e.lockFile),s=!0,{file:e.lockFile,owner:n}}catch(d){if(H(d)&&d.code==="EEXIST")return;throw d}finally{try{try{o!==void 0&&t.closeSync(o)}finally{t.rmSync(r,{force:!0})}}catch(d){if(s&&P(p(e.lockFile),n))try{t.unlinkSync(e.lockFile)}catch(l){throw new AggregateError([d,l],"Runtime owner publication cleanup failed.")}throw d}}}i($,"tryAcquireRuntimeDaemonLock");function se(e){t.mkdirSync(e,{recursive:!0});let n=a.join(t.realpathSync(e),".product-host");t.mkdirSync(n,{recursive:!0});let r={ownerPolicyLockFile:a.join(n,"startup.lock")},o=S(r);return o===void 0?void 0:()=>g(r,o)}i(se,"tryAcquireRuntimeSessionStorageStartup");function U(e,n){if(!t.existsSync(n))return;let r=a.join(t.realpathSync(n),".product-host","owner.lock"),o=p(r);if(!o||o.kind!=="daemon"||w(o)==="gone")return;let s=a.join(a.resolve(e),"runtime","daemon");for(let d of t.existsSync(s)?t.readdirSync(s,{withFileTypes:!0}):[]){if(!d.isDirectory()||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(d.name))continue;let l=C(e,d.name),f=j(l),c=p(l.lockFile);if(!(f?.profile!==d.name||f.runtimeId!==o.runtimeId||f.pid!==o.pid||c?.runtimeId!==o.runtimeId||c.pid!==o.pid||c.kind!==void 0&&c.kind!=="daemon"||c.processStartIdentity!==void 0&&c.processStartIdentity!==o.processStartIdentity))return{profile:d.name,ownerFile:r,owner:o}}throw Object.assign(new Error(`The shared Session storage owner ${o.runtimeId} (PID ${o.pid}) cannot be attached yet. Waiting for its verified daemon descriptor.`),{code:"session_storage_owned",retryable:!0})}i(U,"findRuntimeSessionStorageHost");function ae(e){if(!["daemon.lock","owner.lock"].includes(a.basename(e)))throw new Error("Unsupported Runtime ownership repair target.");let n={ownerPolicyLockFile:a.join(a.dirname(e),"owner-policy.lock")},r=S(n);return r?()=>g(n,r):void 0}i(ae,"tryAcquireRuntimeLockMaintenance");function p(e){if(t.existsSync(e))try{let n=JSON.parse(t.readFileSync(e,"utf8"));return N(n)?n:void 0}catch{return}}i(p,"readRuntimeDaemonLockOwner");function P(e,n){return e===void 0||n===void 0?e===n:e.runtimeId===n.runtimeId&&e.pid===n.pid&&e.createdAt===n.createdAt&&e.kind===n.kind&&e.processStartIdentity===n.processStartIdentity&&e.processContainment===n.processContainment&&e.supervisorPid===n.supervisorPid&&e.supervisorProcessStartIdentity===n.supervisorProcessStartIdentity&&e.windowsJobName===n.windowsJobName&&e.windowsBootIdentity===n.windowsBootIdentity}i(P,"sameRuntimeLockOwner");function de(e){return e.state?e.endpointReachable&&!e.identityMatches?"mismatch":e.pidAlive&&e.endpointReachable&&e.identityMatches?"healthy":!e.pidAlive&&!e.endpointReachable?"stale":"unhealthy":"missing"}i(de,"classifyRuntimeDaemonHealth");function Z(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.runtimeId=="string"&&typeof n.profile=="string"&&typeof n.pid=="number"&&typeof n.startedAt=="string"&&typeof n.endpoint=="string"&&typeof n.version=="string"&&K(n.status)&&(n.configHome===void 0||typeof n.configHome=="string")&&(n.lastError===void 0||typeof n.lastError=="string")}i(Z,"isRuntimeDaemonState");function X(e){return G(e)?e.version===1&&typeof e.runtimeId=="string"&&typeof e.pid=="number"&&(e.status==="succeeded"||e.status==="failed")&&typeof e.completedAt=="string"&&(e.error===void 0||typeof e.error=="string"):!1}i(X,"isRuntimeDaemonShutdownOutcome");function G(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}i(G,"isPlainRecord");function N(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.runtimeId=="string"&&typeof n.pid=="number"&&Number.isSafeInteger(n.pid)&&n.pid>0&&typeof n.createdAt=="string"&&(n.kind===void 0||n.kind==="daemon"||n.kind==="inline")&&(n.processStartIdentity===void 0||typeof n.processStartIdentity=="string"&&n.processStartIdentity.length>0)&&(n.processContainment===void 0||n.processContainment==="windows-job")&&(n.windowsJobName===void 0||n.processContainment==="windows-job"&&typeof n.windowsJobName=="string"&&/^Global\\KodaXDaemonJob-[0-9a-f-]{36}$/i.test(n.windowsJobName))&&(n.windowsBootIdentity===void 0||n.processContainment==="windows-job"&&typeof n.windowsBootIdentity=="string"&&/^windows-boot-\d+$/.test(n.windowsBootIdentity))&&(n.supervisorProcessStartIdentity===void 0||typeof n.supervisorProcessStartIdentity=="string"&&n.supervisorProcessStartIdentity.length>0)&&(n.processContainment==="windows-job"?Number.isSafeInteger(n.supervisorPid)&&n.supervisorPid>0:n.supervisorPid===void 0&&n.supervisorProcessStartIdentity===void 0)}i(N,"isRuntimeDaemonLockOwner");function K(e){return e==="starting"||e==="ready"||e==="draining"||e==="stopping"||e==="unhealthy"||e==="crashed"}i(K,"isRuntimeDaemonStatus");function H(e){return e instanceof Error&&"code"in e}i(H,"isNodeFileError");function I(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}i(I,"isRecord");export{C as a,te as b,O as c,re as d,W as e,B as f,oe as g,j as h,w as i,ie as j,$ as k,se as l,U as m,ae as n,p as o,de as p};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{a as D,b as I}from"./chunk-4Y6U7AH4.js";import{$d as ne,B as v,C as k,D as Q,F as ee,Zd as te}from"./chunk-OGTRDK4Q.js";import{b as P,d as S,e as G,h as J}from"./chunk-J2L2NK6E.js";import{a as c}from"./chunk-V4WSBIXB.js";import L from"fs";import d from"path";import A from"os";var re=te(),ie=new Set(re.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),wn=new Set(re.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),se=new Set(["npm install","npm i","npm uninstall","npm remove","npm update","npm ci","yarn add","yarn remove","yarn upgrade","pnpm add","pnpm remove","pnpm update","git clean","git reset","git checkout","git switch","git merge","git rebase","git cherry-pick","git revert","git commit","git push","git pull","rm","mv","cp","mkdir","rmdir","touch","chmod","chown","del","erase","rd","copy","move","ren","curl","wget","dd","tar","kill","pkill","killall"]),oe=new Set(["ls","cat","pwd","echo","whoami","date","which","whereis","tree","dir","type","get-childitem","get-content","select-string","get-location","where","grep","find","head","tail","more","wc","findstr","git status","git diff","git log","git show","git branch","git remote","git ls-files","git rev-parse","git grep","git tag","git stash list","git describe","git config --get","npm","tsc","go","cargo","rustc"]);import T from"node:path";var Ne={verbose:"switch",debug:"switch",erroraction:"value",warningaction:"value",informationaction:"value",progressaction:"value",errorvariable:"value",warningvariable:"value",informationvariable:"value",outvariable:"value",outbuffer:"value",pipelinevariable:"value",whatif:"switch",confirm:"switch",usetransaction:"switch"},b={path:"value",literalpath:"value",filter:"value",include:"value",exclude:"value"},ce={"copy-item":x(["path","destination"],{...b,destination:"value",container:"switch",recurse:"switch",force:"switch",passthru:"switch",credential:"value",fromsession:"value",tosession:"value"}),"move-item":x(["path","destination"],{...b,destination:"value",force:"switch",passthru:"switch",credential:"value"}),"set-content":x(["path","value"],{...b,value:"value",passthru:"switch",force:"switch",credential:"value",nonewline:"switch",encoding:"value",asbytestream:"switch",stream:"value"}),"add-content":x(["path","value"],{...b,value:"value",passthru:"switch",force:"switch",credential:"value",nonewline:"switch",encoding:"value",asbytestream:"switch",stream:"value"}),"out-file":x(["filepath","encoding"],{filepath:"value",literalpath:"value",inputobject:"value",encoding:"value",append:"switch",force:"switch",noclobber:"switch",width:"value",nonewline:"switch"}),"new-item":x(["path"],{path:"value",name:"value",itemtype:"value",value:"value",force:"switch",credential:"value"}),ni:x(["path"],{path:"value",name:"value",itemtype:"value",value:"value",force:"switch",credential:"value"}),"remove-item":x(["path"],{...b,recurse:"switch",force:"switch",credential:"value",stream:"value"}),"rename-item":x(["path","newname"],{path:"value",literalpath:"value",newname:"value",force:"switch",passthru:"switch",credential:"value"})},Ge={ea:"erroraction",ev:"errorvariable",wa:"warningaction",wv:"warningvariable",ia:"informationaction",infa:"informationaction",iv:"informationvariable",ov:"outvariable",ob:"outbuffer",pv:"pipelinevariable",vb:"verbose",db:"debug",wi:"whatif",cf:"confirm",usetx:"usetransaction",pspath:"literalpath",nooverwrite:"noclobber",type:"itemtype",target:"value"};function x(e,t){return{positionals:e,parameters:{...Ne,...t}}}c(x,"spec");function xn(e){return ce[e.toLowerCase()]!==void 0}c(xn,"isPowerShellMutationCommand");function ue(e){let t=Xe(e[0]??""),n=ce[t];if(!n)return _(`unsupported PowerShell command: ${t||"<empty>"}`);let r=De(e.slice(1),n);if(!r.complete)return _(r.reason??"PowerShell parameter binding is incomplete");if(r.values.has("fromsession")||r.values.has("tosession"))return _("PowerShell remoting changes the filesystem host");if((t==="new-item"||t==="ni")&&/^(?:symboliclink|junction|hardlink)$/i.test(r.values.get("itemtype")??""))return _("PowerShell link creation has an unmodelled target relationship");if(Ue(r))return _("PowerShell path contains bracket wildcard syntax");let i=ke(r);if(!i)return _("PowerShell path array contains an empty target");let s=i.map(a=>ze(t,a));if(s.some(a=>a===void 0))return _("PowerShell mutation target is missing or ambiguous");let o=s.filter(a=>a!==void 0);return["filter","include","exclude"].some(a=>r.values.has(a))?{status:"incomplete",operations:o,reason:"PowerShell provider selectors make the concrete target set unresolved"}:o.some(a=>Fe(a).some(Be))?{status:"incomplete",operations:o,reason:"PowerShell path contains dynamic, wildcard, or array syntax"}:{status:"complete",operations:o}}c(ue,"analyzePowerShellMutation");function ke(e){let t=["path","literalpath"].find(i=>e.values.has(i));if(!t)return[e];let n=e.values.get(t);if(!n.includes(","))return[e];let r=n.split(",").map(i=>i.trim());if(!r.some(i=>!i))return r.map(i=>{let s=new Map(e.values);return s.set(t,i),{...e,values:s}})}c(ke,"expandStaticPathArray");function De(e,t){let n=new Map,r=new Set,i=0,s=!1;for(let o=0;o<e.length;o+=1){let a=e[o];if(a==="--"){s=!0;continue}if(!s&&a.startsWith("-")){let l=Ve(a,t);if(!l)return y(n,r,`unknown or ambiguous parameter ${a}`);if(l.kind==="switch"){let p=je(l.inlineValue);if(p===void 0)return y(n,r,`switch ${a} has an unsupported value`);p&&r.add(l.name);continue}let f=l.inlineValue??e[o+1];if(f===void 0||l.inlineValue===void 0&&f.startsWith("-"))return y(n,r,`parameter ${a} has no bound value`);if(n.has(l.name))return y(n,r,`parameter ${a} is repeated`);n.set(l.name,f),l.inlineValue===void 0&&(o+=1);continue}for(;t.positionals[i]&&n.has(t.positionals[i]);)i+=1;let u=t.positionals[i];if(!u||n.has(u))return y(n,r,`unexpected positional argument ${a}`);n.set(u,a),i+=1}return{complete:!0,values:n,switches:r}}c(De,"bindArguments");function Ve(e,t){let n=/^--?([^:]+)(?::(.*))?$/.exec(e);if(!n)return;let r=n[1].toLowerCase(),i=Ge[r],s=Object.keys(t.parameters),o=i&&t.parameters[i]!==void 0?[i]:s.filter(l=>l.startsWith(r));if(o.length!==1)return;let a=o[0],u=t.parameters[a];return n[2]===void 0?{name:a,kind:u}:{name:a,kind:u,inlineValue:n[2]}}c(Ve,"parseParameter");function ze(e,t){let n=ae(t,"path","literalpath"),r=t.switches.has("force"),i=t.switches.has("whatif")?{whatIf:!0}:{};if(e==="copy-item"||e==="move-item"){if(!n)return;let o=t.values.get("destination")??qe(n);return{kind:e==="copy-item"?"copy":"move",source:n,destination:o,options:{force:r,...i,recursive:e==="copy-item"&&t.switches.has("recurse"),overwritePossible:!0}}}if(e==="rename-item"){let o=t.values.get("newname");return!n||!o||/[\\/]/.test(o)?void 0:{kind:"rename",source:n,destination:Ze(n,o),options:{force:r,...i}}}if(e==="new-item"||e==="ni"){let o=t.values.get("name"),a=o?Ke(t.values.get("path")??".",o):t.values.get("path"),u=t.values.get("itemtype"),l=u?{force:r,...i,itemType:u}:{force:r,...i};return a?{kind:"create",target:a,options:l}:void 0}let s=e==="out-file"?ae(t,"filepath","literalpath"):n;if(s)return e==="remove-item"?{kind:"delete",target:s,options:{force:r,...i,recursive:t.switches.has("recurse")}}:{kind:"write",target:s,options:{force:r,...i,append:e==="add-content"||t.switches.has("append")}}}c(ze,"buildOperation");function ae(e,...t){let n=t.map(r=>e.values.get(r)).filter(r=>!!r);return n.length===1?n[0]:void 0}c(ae,"pathValue");function Fe(e){return"target"in e?[e.target]:[e.source,e.destination]}c(Fe,"operationPaths");function Be(e){return/^\$env:(?:temp|tmp)(?=$|[\\/])/i.test(e)?!1:/[,*?`$]|@\(|[{}]/.test(e)||He(e)}c(Be,"isAmbiguousPathExpression");function Ue(e){return["path","filepath","destination","newname","name"].some(t=>/[\[\]]/.test(e.values.get(t)??""))}c(Ue,"hasUnmodelledBracketWildcard");function He(e){return/^[a-z]:[\\/]/i.test(e)?!1:/^[a-z][a-z0-9_.-]*:/i.test(e)}c(He,"isPowerShellProviderPath");function je(e){if(e===void 0||/^\$?true$|^1$/i.test(e))return!0;if(/^\$?false$|^0$/i.test(e))return!1}c(je,"parseSwitchValue");function qe(e){let t=/^[a-z]:|\\/i.test(e)?T.win32:T.posix;return t.join(".",t.basename(e))}c(qe,"defaultDestination");function Ze(e,t){let n=/^[a-z]:|\\/i.test(e)?T.win32:T.posix;return n.join(n.dirname(e),t)}c(Ze,"joinSourceParent");function Ke(e,t){return(/^[a-z]:|\\/i.test(e)?T.win32:T.posix).join(e,t)}c(Ke,"joinPath");function Xe(e){return e.replace(/\\/g,"/").split("/").at(-1)?.toLowerCase()??""}c(Xe,"commandName");function y(e,t,n){return{complete:!1,values:e,switches:t,reason:n}}c(y,"failed");function _(e){return{status:"incomplete",operations:[],reason:e}}c(_,"incomplete");var Ye=d.join(".agent","plan_mode_doc.md"),R=new Map,$=null,Je=new Set(["status","log","diff","show","ls-files","rev-parse","grep","describe"]),V=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]),le=new Set(["--git-dir","--work-tree"]),Qe=new Set(["--bare","--no-pager","--no-replace-objects","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs","--no-optional-locks"]),et=new Set(["-d","-D","-m","-M","-c","-C","-f","-t","-u","--delete","--move","--copy","--force","--edit-description","--set-upstream-to","--unset-upstream","--create-reflog","--track","--no-track","--recurse-submodules"]),tt=new Set(["-a","-s","-u","-d","-f","-m","-F","--annotate","--sign","--local-user","--delete","--force","--message","--file","--create-reflog"]),fe=new Set(["--ext-diff","--textconv","--open-files-in-pager","--output","--ext-grep","--help"]),nt=new Set(["--add","--replace-all","--unset","--unset-all","--rename-section","--remove-section","--edit","-e"]),rt=new Set(["--get","--get-all","--get-regexp","--get-urlmatch","--list","-l"]),it=new Set(["set","unset","rename-section","remove-section","edit"]);function Se(e,t,n){let r=1;for(;r<e.length&&e[r].startsWith("-");){let i=e[r],s=i.toLowerCase();if(i==="-c"||i.startsWith("-c")&&i.length>2||s==="--config-env"||s.startsWith("--config-env="))return;if(i==="-C"||le.has(s)){let l=e[r+1];if(!l)return;t?.add(r+1),n?.add(l),r+=2;continue}let a=[...le].find(l=>s.startsWith(`${l}=`)),u=a?i.slice(a.length+1):i.startsWith("-C")&&i.length>2?i.slice(2):void 0;if(u!==void 0){if(!u)return;t?.add(r),n?.add(u),r+=1;continue}if(Qe.has(s)){r+=1;continue}if(V.has(i)||V.has(s)){if(e[r+1]===void 0)return;r+=2;continue}if([...V].some(l=>i.startsWith(`${l}=`)||s.startsWith(`${l}=`))||i.startsWith("-C")&&i.length>2){r+=1;continue}return}return r}c(Se,"consumeGitGlobalOptions");function st(e){return Se(e)}c(st,"findGitSubcommandIndex");function z(e,t,n){let r=[];for(let i=0;i<e.length;i+=1){let s=e[i];if(s==="--")break;if(!t.find(u=>M(s,u)))continue;let a=s.indexOf("=");a>=0?r.push(s.slice(a+1)):n&&e[i+1]!==void 0&&(r.push(e[i+1]),i+=1)}return r}c(z,"gitFormatValues");function xe(e,t){for(let n=0;n<e.length;n+=1){if(e[n]!=="%")continue;let r=n+1;for(;e[r]==="%";)r+=1;if((r-n)%2===1&&t(e.slice(r)))return!0;n=r-1}return!1}c(xe,"hasActiveGitFormatSequence");function ve(e){return xe(e,t=>/^[+\- ]?G[?GSKFPT]/.test(t))}c(ve,"hasGitPrettySignaturePlaceholder");function ot(e){return xe(e,t=>/^\(\*?signature(?::[^)]*)?\)/i.test(t))}c(ot,"hasGitRefSignatureAtom");var at=new Set(["oneline","short","medium","full","fuller","reference","email","raw","mboxrd"]);function ct(e){if(ve(e))return!0;let t=e.toLowerCase();return t.startsWith("format:")||t.startsWith("tformat:")||e.includes("%")?!1:!at.has(t)}c(ct,"gitPrettyFormatMayVerifySignature");function _e(e,t){if(e==="stash"&&t[0]?.toLowerCase()==="list")return _e("log",t.slice(1));let n=t.indexOf("--"),r=n<0?t:t.slice(0,n);return e==="tag"&&r.some(i=>i==="-v"||M(i,"--verify"))||(e==="log"||e==="show")&&r.some(i=>M(i,"--show-signature"))?!0:e==="log"||e==="show"?z(t,["--format"],!0).some(ve)||z(t,["--pretty"],!1).some(ct):e==="branch"||e==="tag"?z(t,["--format"],!0).some(ot):!1}c(_e,"gitSignatureInspectionMayExecute");function de(e,t){let n=new Set([...t].filter(r=>/^-[^-]$/.test(r)).map(r=>r.slice(1)));return e.some(r=>t.has(r)||[...t].some(i=>i.startsWith("--")&&r.startsWith(`${i}=`))||Te(r,n,new Set))||e.some(r=>!r.startsWith("-"))}c(de,"hasGitMutationArguments");function Ae(e){if(!e.startsWith("-")||e.startsWith("--")||e.length<2)return{pager:!1,consumesNext:!1};for(let t=1;t<e.length;t+=1){let n=e[t];if(n==="O")return{pager:!0,consumesNext:!1};let r=n==="e"?"pattern":n==="f"?"pattern-file":"mABC".includes(n)?"other":void 0;if(r){let i=e.slice(t+1)||void 0;return{pager:!1,valueKind:r,attachedValue:i,consumesNext:i===void 0}}}return{pager:!1,consumesNext:!1}}c(Ae,"parseGitGrepShortOption");function ut(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return!1;if(n==="--regexp"||n==="--file"){t+=1;continue}let r=Ae(n);if(r.pager)return!0;r.consumesNext&&(t+=1)}return!1}c(ut,"hasGitGrepPagerOption");function lt(e){let t=st(e);if(t===void 0)return!1;let n=e[t];if(!n)return!1;let r=n.toLowerCase(),i=e.slice(t+1),s=i.map(u=>u.toLowerCase()),o=s.indexOf("--");if((o<0?s:s.slice(0,o)).some(u=>fe.has(u)||[...fe].some(l=>u.startsWith(`${l}=`)))||r==="grep"&&ut(i))return!1;if(Je.has(r))return!0;if(r==="stash")return s[0]==="list"||s[0]==="show";if(r==="config"){let u=s[0];return it.has(u??"")?!1:(u==="get"||u==="list"||s.some(f=>rt.has(f)))&&!s.some(f=>nt.has(f))}if(r==="branch"){let u=s.some(f=>["--list","-l","--contains","--no-contains","--merged","--no-merged","--points-at","--show-current","--all","-a","--remotes","-r"].includes(f)||["--list=","--contains=","--no-contains=","--merged=","--no-merged=","--points-at="].some(p=>f.startsWith(p))),l=i.some(f=>!f.startsWith("-"));return!de(i.filter(f=>f.startsWith("-")),et)&&(!l||u)}if(r==="tag")return _e(r,i)?!0:(i.length===0||s.every(l=>l.startsWith("-"))||s.includes("-l")||s.includes("--list"))&&!de(i.filter(l=>l.startsWith("-")),tt);if(r==="remote"){let u=s.find(l=>!l.startsWith("-"));return u===void 0||u==="get-url"?!0:u!=="show"?!1:s.includes("-n")||s.includes("--no-query")}return!1}c(lt,"isGitReadCommand");var ft=/(?:^|_)(?:api_?key|access_?key|secret|token|password|passwd|credential|private_?key|auth|cookie)(?:_|$)/i,dt=new Set(["-eq","-ne","-gt","-ge","-lt","-le","-like","-notlike","-match","-notmatch","-contains","-notcontains","-in","-notin"]);function ht(e){return e.length>0&&!/[${};&|<>`]/.test(e)&&!e.includes("$(")}c(ht,"isSafePowerShellLiteral");function pt(e){let t=/^\$env:([a-z_][a-z0-9_]*)$/i.exec(e[0]??"");return!t||ft.test(t[1])?!1:e.length===1?!0:e.length===3&&["-split","-like","-notlike","-match","-notmatch"].includes(e[1]?.toLowerCase()??"")&&(e[2]?.length??0)>0&&!/[{}&|<>`]/.test(e[2]??"")&&!(e[2]??"").includes("$(")}c(pt,"isSafePowerShellEnvironmentRead");function mt(e){let t=e.slice(1),n=t[0]==="{"&&t.at(-1)==="}"?t.slice(1,-1):t;if(n.length!==3)return!1;let[r,i,s]=n;return/^\$_(?:(?:\.)?[a-z_][a-z0-9_]*)?$/i.test(r??"")&&dt.has(i?.toLowerCase()??"")&&ht(s??"")}c(mt,"isSafeWhereObjectRead");function wt(e){let t=new Set(["-unique","-wait"]),n=new Set(["-first","-last","-skip","-index"]),r=new Set(["-property","-expandproperty"]);for(let i=1;i<e.length;i+=1){let s=e[i]??"",o=s.toLowerCase();if(!t.has(o)){if(n.has(o)){if(!/^\d+(?:,\d+)*$/.test(e[++i]??""))return!1;continue}if(r.has(o)){if(!/^(?:\*|[a-z_][a-z0-9_]*)(?:,(?:\*|[a-z_][a-z0-9_]*))*$/i.test(e[++i]??""))return!1;continue}if(!/^(?:\*|[a-z_][a-z0-9_]*)(?:,(?:\*|[a-z_][a-z0-9_]*))*$/i.test(s))return!1}}return!0}c(wt,"isSafeSelectObjectRead");function gt(e){return!e.slice(1).some(t=>/^--pre(?:=|$)/i.test(t)||/^--hostname-bin(?:=|$)/i.test(t))}c(gt,"isSafeRipgrepRead");var St=/^(?:-delete|-exec|-execdir|-ok|-okdir|-fprint|-fprint0|-fprintf|-fls)$/i;function xt(e){return!e.slice(1).some(t=>St.test(t))}c(xt,"isSafeFindRead");var Ie=new Set(["H","I","L","P","T"]);var B=new Set(["o"]),vt=new Set(["--charset","--filelimit","--output","--sort","--timefmt"]);function M(e,t){let n=e.indexOf("="),r=(n>=0?e.slice(0,n):e).toLowerCase();return r.startsWith("--")&&r.length>=3&&t.startsWith(r)}c(M,"longOptionCouldMatch");function Te(e,t,n){if(!/^-[^-]/.test(e))return!1;for(let r of e.slice(1)){if(t.has(r))return!0;if(n.has(r))return!1}return!1}c(Te,"shortOptionClusterContains");function _t(e){return!e.slice(1).some(t=>Te(t,B,Ie)||M(t,"--output"))}c(_t,"isSafeTreeRead");function At(e){let t=e.slice(1);if(t.length===0)return!0;for(let n=0;n<t.length;n+=1){let r=t[n]??"",i=r.toLowerCase();if(!(i==="/t"||i==="--help"||i==="--version"||r.startsWith("+"))){if(i==="-s"||i==="--set"||i.startsWith("--set="))return!1;if(["-d","--date","-r","--reference"].includes(i)){if(t[++n]===void 0)return!1;continue}if(!/^--(?:date|reference)=/i.test(r)&&!(/^(?:-u|--utc|--universal|-R|--rfc-email|--resolution|--debug)$/i.test(r)||/^--(?:iso-8601|rfc-3339)(?:=|$)/i.test(r)))return!1}}return!0}c(At,"isSafeDateRead");function It(e){return e.length>0&&!/[\\/]/.test(e)}c(It,"isBareShellExecutable");function Tt(e){if(e.length===0||!It(e[0]??""))return!1;if(pt(e))return!0;let t=(e[0]??"").toLowerCase(),n=E(e[0]??"");if(t==="where.exe")return!0;if(n==="where-object"||t==="where"||t==="?")return mt(["where-object",...e.slice(1)]);if(n==="select-object")return wt(e);if(n==="rg"||n==="ripgrep")return gt(e);if(n==="find")return xt(e);if(n==="less")return!1;if(n==="tree")return _t(e);if(n==="date")return At(e);let i=[n,...e.slice(1).map(s=>s.toLowerCase())].join(" ");if(n==="git")return lt([n,...e.slice(1)]);for(let s of oe)if(i===s||i.startsWith(s+" ")){if(["npm","tsc","go","cargo","rustc"].includes(s)){let a=i.split(/\s+/).slice(1);if(a.length>0&&!a.every(u=>/^(-v|--version|-h|--help)$/.test(u)))return!1}return!0}return!1}c(Tt,"isShellReadOnlyArgv");var Et=/^[a-zA-Z0-9]+$/;function Ln(e){let t=e.trim();if(!t.endsWith("--help")||t.includes('"')||t.includes("'"))return!1;let n=!1;for(let r of t.split(/\s+/))if(r.startsWith("-"))if(r==="--help")n=!0;else return!1;else if(!Et.test(r))return!1;return n}c(Ln,"isHelpCommand");function Z(e){if(!e||!e.trim())return!1;let t=I(e.trim());if(t.unparseable||t.statements.length===0)return!1;let n=t.statements.length>1||(t.statements[0]?.stages.length??0)>1;for(let r of t.statements){if(r.precedingOp!==null&&r.precedingOp!=="&&"&&r.precedingOp!==";")return!1;for(let i of r.stages){for(let o of i.redirections)if(!o.descriptorDuplication&&(o.input||!D(o.target)))return!1;if(i.argv.join(" ")&&!(n&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Tt(i.argv))return!1}}return!0}c(Z,"isBashReadCommand");function Rn(e){let t=e.trim();return t?Z(t)?null:"[Blocked] Direct !command execution only supports safe read-only commands. Use the bash tool for commands that write files, invoke shells, or require confirmation.":"[Shell: No command provided]"}c(Rn,"getDirectShellBypassBlockReason");var Ee=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]),Ot={bash:new Set(["-c"]),dash:new Set(["-c"]),sh:new Set(["-c"]),zsh:new Set(["-c"]),cmd:new Set(["/c"]),powershell:new Set(["-command","-c"]),pwsh:new Set(["-command","-c"])};function U(e){let t=e[0]?.replace(/\\/g,"/"),n=t?.slice(t.lastIndexOf("/")+1).replace(/\.exe$/i,"").toLowerCase();if(!n)return;let r=Ot[n];if(!r)return;let i=e.findIndex((s,o)=>o>0&&r.has(s.toLowerCase()));return i>=0?e[i+1]:void 0}c(U,"getNestedShellCommand");function Oe(e){return Pe(e,0)}c(Oe,"isBashWriteCommand");function Pe(e,t){if(!e||!e.trim())return!1;let n=I(e);if(n.unparseable)return!1;for(let r of n.statements)for(let i of r.stages){let s=i.argv.map(a=>a.toLowerCase());if(s.length>0){let a=s[0],u=s.length>=2?`${s[0]} ${s[1]}`:null;for(let l of se)if(l===a||u!==null&&l===u)return!0}for(let a of s)if(Ee.has(a))return!0;for(let a of i.redirections)if(!a.descriptorDuplication&&!a.input&&!D(a.target))return!0;let o=t<3?U(i.argv):void 0;if(o!==void 0&&Pe(o,t+1))return!0}return!1}c(Pe,"isBashWriteCommandAtDepth");function Pt(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\((.+)\)$/);return t?{tool:t[1].toLowerCase(),pattern:t[2]}:{tool:e.toLowerCase(),pattern:null}}c(Pt,"parseAllowedToolPattern");function bt(e,t){if(t==="*"||/[;&|<>\r\n`$()%!^{}]/u.test(e))return!1;let n=I(e);if(n.unparseable||n.statements.length!==1||n.statements[0].stages.length!==1)return!1;let r=n.statements[0].stages[0];if(r.redirections.length)return!1;if(!t.endsWith(":*"))return e===t;let i=t.slice(0,-2);if(!/^[\w./-]+(?:[ \t]+[\w./-]+)*$/u.test(i))return!1;let s=i.split(/[ \t]+/u);return r.argv.length>=s.length&&s.every((o,a)=>r.argv[a]===o)}c(bt,"matchesBashPatternWithoutExtractor");function yt(e,t){if(t==="*")return!1;if(t.endsWith(":*")){let n=t.slice(0,-2);return e===n}return e===t}c(yt,"matchesBashPatternByExtractedPrefix");async function $n(e,t,n,r,i){if(e.toLowerCase()!=="bash")return!1;let s=typeof t.command=="string"?t.command:"",o=[];for(let a of n){let u=Pt(a);if(u.tool==="bash"){if(u.pattern===null)return!0;o.push({pattern:u.pattern})}}if(o.length===0)return!1;if(r){let a;try{a=await r.extract(s,i)}catch{return!1}if(a.kind!=="prefix")return!1;for(let{pattern:u}of o)if(u&&yt(a.value,u))return!0;return!1}for(let{pattern:a}of o)if(a&&bt(s,a))return!0;return!1}c($n,"isToolCallAllowed");function Wn(e,t,n){if(e.toLowerCase()!=="bash")return"";let r=t.command??"",i=r.split(" ");return i.length>1?`Bash(${i.slice(0,2).join(" ")}:*)`:`Bash(${r})`}c(Wn,"generateSavePattern");function Ct(e,t){try{let n=d.resolve(e),r=d.resolve(t);if(S(n,d.join(r,".kodax")))return!0;let i=v(n),s=v(r),o=v(d.join(r,".kodax"));if(i===void 0||s===void 0||o===void 0)throw new Error("Protected-path identity could not be resolved.");let a=d.resolve(P());if(S(i,o))return!0;let u=v(a)??a,l=v(i);return S(i,a)?l===void 0||!S(l,u)||!k(l,u):l!==void 0&&S(l,u)?!k(l,u):!(S(i,s)||Re().some(p=>S(i,p)))}catch(n){return J({source:"permission:protected-path",level:"warn",message:"Cannot resolve protected-path policy; confirmation is required.",detail:n}),!0}}c(Ct,"isAlwaysConfirmPath");function W(e){return!e||e.startsWith("-")?!1:/^\.\.?[/\\]/.test(e)||e.startsWith("~/")||e.startsWith("~\\")||/^[a-zA-Z]:[/\\]/.test(e)||/^\\\\/.test(e)?!0:e.startsWith("/")&&e.length>1?!(process.platform==="win32"&&H.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e)||e.split(/[/\\]+/).includes(".."))}c(W,"looksLikePath");var H=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/,he={python:new Set(["-c"]),py:new Set(["-c"]),node:new Set(["-e","--eval","-p","--print"]),ruby:new Set(["-e"]),perl:new Set(["-e"])},Lt=new Set(["rg","ripgrep","grep","egrep","fgrep","findstr","select-string","sls","sed","awk"]),Rt=new Set(["-e","--regexp","--regex","-pattern"]),$t=new Set(["-f","--file"]),pe=new Set(["-g","--glob","--iglob","-r","--replace"]),F=new Set(["--include","--exclude","--exclude-dir"]),Wt={rg:pe,ripgrep:pe,grep:F,egrep:F,fgrep:F,awk:new Set(["-v","--assign"]),"select-string":new Set(["-inputobject"])},Mt={rg:new Set(["--ignore-file"]),ripgrep:new Set(["--ignore-file"]),grep:new Set(["--exclude-from"]),egrep:new Set(["--exclude-from"]),fgrep:new Set(["--exclude-from"]),"select-string":new Set(["-path","-literalpath"])},Nt=["path","literalpath","include","exclude","pattern","simplematch","casesensitive","quiet","list","allmatches","notmatch","encoding","context","raw","culture","inputobject","noemphasis","verbose","debug","erroraction","warningaction","informationaction","errorvariable","warningvariable","informationvariable","outvariable","outbuffer","pipelinevariable","progressaction"],Gt=new Set(["simplematch","casesensitive","quiet","list","allmatches","notmatch","raw","noemphasis","verbose","debug"]),kt={pspath:"literalpath",vb:"verbose",db:"debug",ea:"erroraction",wa:"warningaction",infa:"informationaction",ev:"errorvariable",wv:"warningvariable",iv:"informationvariable",ov:"outvariable",ob:"outbuffer",pv:"pipelinevariable"},Dt=new Set(["-f","--file","--blob"]),Vt=new Set(["-g","-s","--format","--pretty","--date","--encoding","--diff-algorithm","--word-diff-regex","--diff-filter","--find-object","--line-prefix","--src-prefix","--dst-prefix","--grep","--author","--committer","--since","--after","--until","--before","--max-count","-n","--skip","--min-parents","--max-parents","--inter-hunk-context","--anchored"]),zt=new Set(["--max-count","--after-context","--before-context","--context","--threads"]);function E(e){let t=e.replace(/\\/g,"/");return(t.split("/").pop()??t).toLowerCase().replace(/\.exe$/,"")}c(E,"commandBasename");function Ft(){return{sourceIndexes:new Set,pathIndexes:new Set,pathValues:new Set}}c(Ft,"createCommandArgumentRoles");function m(e,t,n,r){let i=e[t];i!==void 0&&(n.add(t),r?.add(i))}c(m,"addIndexedValue");function be(e,t,n){let r=e[t];if(!r)return;let i=/^%[A-Za-z_][A-Za-z0-9_]*%[/\\]/.test(r)||/^\$(?:env:)?(?:\{[A-Za-z_][A-Za-z0-9_]*\}|[A-Za-z_][A-Za-z0-9_]*)[/\\]/i.test(r),s=/[*?[\]]/.test(r)||/\{[^{}]*,[^{}]*\}/.test(r);(W(r)||i||s)&&m(e,t,n.pathIndexes,n.pathValues)}c(be,"addGitPathCandidate");function N(e,t){let n=e.toLowerCase();if(t.startsWith("--")){let r=`${t}=`;return n.startsWith(r)?e.slice(r.length):void 0}return n.startsWith(t)&&e.length>t.length?e.slice(t.length):void 0}c(N,"attachedOptionValue");function Bt(e,t,n){for(let r=1;r<e.length;r+=1){let i=e[r]??"",s=i.toLowerCase();for(let o of t){if(s===o){m(e,r+1,n.sourceIndexes);break}if(N(i,o)!==void 0){n.sourceIndexes.add(r);break}}}}c(Bt,"collectScriptSourceRoles");function j(e,t,n,r){if(t)for(let i=1;i<e.length;i+=1){let s=e[i]??"";if(s==="--")break;let o=s.toLowerCase();for(let a of t){if(o===a){m(e,i+1,n,r);break}let u=N(s,a);if(u!==void 0){n.add(i),r?.add(u);break}}}}c(j,"collectFlagValueRoles");function Ut(e,t,n){let r=!1,i=!1;for(let s=t+1;s<e.length;s+=1){let o=e[s]??"";if(o==="--"){i=!0;continue}let a=o.toLowerCase();if(!i&&a==="--file"){m(e,s+1,n.pathIndexes,n.pathValues),r=!0,s+=1;continue}if(!i&&a.startsWith("--file=")){n.pathIndexes.add(s),n.pathValues.add(o.slice(o.indexOf("=")+1)),r=!0;continue}if(!i&&(a==="--regexp"||a==="-e")){m(e,s+1,n.sourceIndexes),r=!0,s+=1;continue}if(!i&&a.startsWith("--regexp=")){n.sourceIndexes.add(s),r=!0;continue}if(!i&&zt.has(a)){m(e,s+1,n.sourceIndexes),s+=1;continue}if(!i){let u=Ae(o);if(u.valueKind==="pattern-file"){u.attachedValue!==void 0?(n.pathIndexes.add(s),n.pathValues.add(u.attachedValue)):(m(e,s+1,n.pathIndexes,n.pathValues),s+=1),r=!0;continue}if(u.valueKind==="pattern"){u.attachedValue!==void 0?n.sourceIndexes.add(s):(m(e,s+1,n.sourceIndexes),s+=1),r=!0;continue}if(u.valueKind==="other"){u.consumesNext&&(m(e,s+1,n.sourceIndexes),s+=1);continue}if(o.startsWith("-"))continue}if(!r){n.sourceIndexes.add(s),r=!0;continue}be(e,s,n)}}c(Ut,"collectGitGrepArgumentRoles");function Ht(e,t,n){let r=!1;for(let i=t+1;i<e.length;i+=1){let s=e[i]??"";if(s==="--"){r=!0;continue}if(!r&&Vt.has(s.toLowerCase())){m(e,i+1,n.sourceIndexes),i+=1;continue}!r&&s.startsWith("-")||be(e,i,n)}}c(Ht,"collectGitReadPathRoles");function jt(e){let t=/^-([^:]+)(?::(.*))?$/s.exec(e);if(!t)return;let n=t[1]?.toLowerCase()??"",r=kt[n],i=r?[r]:Nt.filter(s=>s.startsWith(n));if(i.length===1)return{name:i[0],...t[2]!==void 0?{attachedValue:t[2]}:{}}}c(jt,"resolvePowerShellSelectStringParameter");function qt(e,t){let n=!1;for(let r=1;r<e.length;r+=1){let i=e[r]??"",s=jt(i);if(s){if(Gt.has(s.name))continue;let o=s.attachedValue===void 0?r+1:r,a=s.attachedValue??e[o];if(a===void 0)continue;s.name==="path"||s.name==="literalpath"?(t.pathIndexes.add(o),t.pathValues.add(a)):t.sourceIndexes.add(o),s.name==="pattern"&&(n=!0),s.attachedValue===void 0&&(r+=1);continue}if(!i.startsWith("-")){if(!n){t.sourceIndexes.add(r),n=!0;continue}m(e,r,t.pathIndexes,t.pathValues)}}}c(qt,"collectPowerShellSelectStringArgumentRoles");function Zt(e,t){let n=E(e[0]??"");if(n==="select-string"||n==="sls"){qt(e,t);return}j(e,Wt[n],t.sourceIndexes),j(e,Mt[n],t.pathIndexes,t.pathValues);let r=!1;for(let s=1;s<e.length;s+=1){let o=e[s]??"";if(o==="--")break;let a=o.toLowerCase();if(n==="findstr"&&a.startsWith("/f:")){t.pathIndexes.add(s),t.pathValues.add(o.slice(3));continue}if(n==="findstr"&&a.startsWith("/c:")){t.sourceIndexes.add(s),r=!0;continue}if(n==="findstr"&&a.startsWith("/g:")){t.pathIndexes.add(s),t.pathValues.add(o.slice(3)),r=!0;continue}for(let u of Rt){if(a===u){m(e,s+1,t.sourceIndexes),r=!0;break}if(N(o,u)!==void 0){t.sourceIndexes.add(s),r=!0;break}}for(let u of $t){if(a===u){m(e,s+1,t.pathIndexes,t.pathValues),r=!0;break}let l=N(o,u);if(l!==void 0){t.pathValues.add(l),r=!0;break}}}if(!r){let s=!1;for(let o=1;o<e.length;o+=1){let a=e[o]??"";if(a==="--"){s=!0;continue}if(!(t.sourceIndexes.has(o)||t.pathIndexes.has(o))&&!(!s&&a.startsWith("-"))&&!(n==="findstr"&&H.test(a))){m(e,o,t.sourceIndexes);break}}}let i=!1;for(let s=1;s<e.length;s+=1){let o=e[s]??"";if(o==="--"){i=!0;continue}!i&&o.startsWith("-")||t.sourceIndexes.has(s)||t.pathIndexes.has(s)||n==="findstr"&&H.test(o)||m(e,s,t.pathIndexes,t.pathValues)}}c(Zt,"collectRegexArgumentRoles");function Kt(e,t){if(!e.slice(1).some(i=>/^--from(?:tab)?file(?:=|$)/i.test(i)))return;let r=!1;for(let i=1;i<e.length;i+=1){let s=e[i]??"",o=/^--from(?:tab)?file=(.*)$/i.exec(s)?.[1];if(o!==void 0){t.pathIndexes.add(i),o&&t.pathValues.add(o);continue}if(/^--from(?:tab)?file$/i.test(s)||s==="--"){t.sourceIndexes.add(i),s==="--"&&(r=!0);continue}if(!r&&/^-[^-]/.test(s)){let a=s.slice(1),u=[...a].findIndex(l=>Ie.has(l)||B.has(l));if(t.sourceIndexes.add(i),u>=0&&a.slice(u+1).length===0){let l=B.has(a[u]??"");m(e,i+1,l?t.pathIndexes:t.sourceIndexes,l?t.pathValues:void 0),i+=1}continue}if(!r&&s.startsWith("--")){let a=s.split("=",1)[0]?.toLowerCase()??"";if(t.sourceIndexes.add(i),vt.has(a)&&!s.includes("=")){let u=a==="--output";m(e,i+1,u?t.pathIndexes:t.sourceIndexes,u?t.pathValues:void 0),i+=1}continue}m(e,i,t.pathIndexes,t.pathValues)}}c(Kt,"collectTreeFileListRoles");function q(e){let t=Ft(),n=E(e[0]??"");if(n==="git"){let i=Se(e,t.pathIndexes,t.pathValues),s=i===void 0?void 0:e[i]?.toLowerCase();i!==void 0&&s==="grep"?Ut(e,i,t):i!==void 0&&(s==="diff"||s==="log"||s==="show")?Ht(e,i,t):s==="config"&&j(e,Dt,t.pathIndexes,t.pathValues)}let r=/^python(?:\d+(?:\.\d+)*)?$/.test(n)?he.python:he[n];return r&&Bt(e,r,t),Lt.has(n)&&Zt(e,t),n==="tree"&&Kt(e,t),t}c(q,"collectCommandArgumentRoles");function K(e){let t=[],n=[],r="",i=-1,s,o=c(u=>{i<0||(n.push({value:r,start:i,end:u}),r="",i=-1)},"finishWord"),a=c(()=>{n.length>0&&t.push(n),n=[]},"finishStage");for(let u=0;u<e.length;u+=1){let l=e[u];if(s){l===s?s=void 0:s==='"'&&l==="\\"&&e[u+1]==='"'?(r+=`${l}${e[u+1]}`,u+=1):r+=l;continue}l==='"'||l==="'"?(i<0&&(i=u),s=l):/\s/.test(l)?o(u):l==="|"||l==="&"||l===";"?(o(u),a()):(i<0&&(i=u),r+=l)}return s?[]:(o(e.length),a(),t)}c(K,"tokenizeRawCommandStages");function ye(e){let t=e.split("");for(let n of K(e)){let r=q(n.map(i=>i.value));for(let i of r.sourceIndexes){let s=n[i];if(s)for(let o=s.start;o<s.end;o+=1)t[o]=" "}}return t.join("")}c(ye,"maskRawInlineSources");function Xt(e){let t=[],n;for(let s of[/"([A-Za-z]:\\[^"\r\n]+)"/g,/'([A-Za-z]:\\[^'\r\n]+)'/g])for(;(n=s.exec(e))!==null;)t.push(n[1]);let r=/(?:^|\s)(\.\.?\/[^\s]+|\.\.?\\[^\s]+|~\/[^\s]+|\.[^\s]*[/\\][^\s]*)/g;for(;(n=r.exec(e))!==null;)t.push(n[1]);let i=/(?:^|[\s:=<>])([a-zA-Z]:\\[^\s"'|;&<>]+)/g;for(;(n=i.exec(e))!==null;)t.push(n[1]);return t}c(Xt,"legacyRegexPathScan");function Ce(e){let t=new Set,n=I(e);if(n.unparseable)return[];for(let r of K(e)){let i=r.map(o=>o.value),s=q(i);for(let o of s.pathValues)t.add(o);if(process.platform==="win32")for(let o=0;o<i.length;o+=1){if(s.sourceIndexes.has(o)||s.pathIndexes.has(o))continue;let a=i[o];W(a)&&t.add(a)}}for(let r of n.statements)for(let i of r.stages){let s=q(i.argv);if(process.platform!=="win32")for(let o of s.pathValues)t.add(o);for(let o=0;o<i.argv.length;o+=1){let a=i.argv[o];s.sourceIndexes.has(o)||s.pathIndexes.has(o)||W(a)&&t.add(a)}for(let o of i.redirections)o.descriptorDuplication||W(o.target)&&t.add(o.target)}for(let r of Xt(ye(e)))t.add(r);return Array.from(t)}c(Ce,"extractPathsFromCommand");function Yt(e,t,n=t){let r=Z(e),i=Ce(e);for(let s of i){let o=G(s,n);if(r&&ee(o,n))return!0;if(!(r&&Jt(o))&&Ct(o,t))return!0}return!1}c(Yt,"isCommandOnProtectedPath");function Jt(e){try{let t=v(P())??d.resolve(P()),n=v(e);return n!==void 0&&S(n,t)}catch{return!1}}c(Jt,"isReadableAgentHomeTarget");function Mn(e,t,n=t){return Z(e)&&!Yt(e,t,n)}c(Mn,"isBashReadCommandAutoAllowed");function me(e){let t=d.normalize(e);return process.platform==="win32"?t.toLowerCase():t}c(me,"normalizePathForComparison");function Qt(e,t){return me(e)===me(t)}c(Qt,"pathsEqual");function en(e,t){try{let n=d.resolve(t),r=d.resolve(n,Le(Y(e)));return S(r,n)}catch{return!1}}c(en,"isPathInsideProject");function tn(e){let t=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return t?t.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}c(tn,"collectAbsolutePathCandidates");function X(e){let t=d.resolve(e),n=R.get(t);if(n)return n;if(L.existsSync(t)){let a=L.realpathSync.native(t);return R.set(t,a),a}let r=[],i=t;for(;!L.existsSync(i);){let a=d.dirname(i);if(a===i)return R.set(t,t),t;r.unshift(d.basename(i)),i=a}let s=L.realpathSync.native(i),o=d.join(s,...r);return R.set(t,o),o}c(X,"resolveExistingPathPrefix");function Y(e){return e==="~"?A.homedir():e.startsWith(`~${d.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?d.join(A.homedir(),e.slice(2)):e}c(Y,"expandHomeDirectory");function Le(e){let t=A.tmpdir(),n=[[/^%temp%/i,t],[/^%tmp%/i,t],[/^\$env:temp\b/i,t],[/^\$env:tmp\b/i,t],[/^\$tmpdir\b/i,t],[/^\$temp\b/i,t],[/^\$tmp\b/i,t]];for(let[r,i]of n)if(r.test(e))return e.replace(r,i);return e}c(Le,"expandSystemTempAlias");function nn(e,t,n=t){let r=d.resolve(n??t??process.cwd()),i=Le(Y(e)),s=d.isAbsolute(i)?d.resolve(i):d.resolve(r,i);return X(s)}c(nn,"resolvePermissionPath");function Re(){if($)return $;let e=new Set,t=[A.tmpdir(),process.env.TEMP,process.env.TMP,process.env.TMPDIR].filter(n=>typeof n=="string"&&n.trim().length>0);for(let n of t)try{e.add(X(n))}catch{}return $=Array.from(e),$}c(Re,"getSystemTempDirectories");function $e(e){let t=X(e??process.cwd());return{projectPlanDoc:d.join(t,Ye),systemTempDirs:Re()}}c($e,"getPlanModeAllowedWritablePaths");function we(e,t,n=t){let r=nn(e,t,n),{projectPlanDoc:i,systemTempDirs:s}=$e(t);return Qt(r,i)?!0:s.some(o=>S(r,o))}c(we,"isPlanModeAllowedPath");function rn(e){let{projectPlanDoc:t,systemTempDirs:n}=$e(e),r=n[0]??A.tmpdir();return`${t} or the system temp directory (${r})`}c(rn,"formatPlanModeAllowedLocations");var sn=new Set(["-a","--append","-i","--ignore-interrupts"]);function on(e){let t=[];for(let n=1;n<e.argv.length;n+=1){let r=e.argv[n];sn.has(r)||r.startsWith("-")||t.push(r)}return t}c(on,"collectTeeTargets");function an(e){let t=ue(e.argv),n=[];for(let r of t.operations)"target"in r?n.push(r.target):r.kind==="copy"?n.push(r.destination):n.push(r.source,r.destination);return n}c(an,"collectPowerShellWriteTargets");function We(e){return C(e,0,!0)}c(We,"collectBashWriteTargets");function Nn(e){return C(e,0,!1)}c(Nn,"collectDeterministicBashWriteTargets");var cn=new Set(["rm","rmdir","mkdir","touch","mv","move","ren","del","erase","rd"]),un=new Set(["cp","copy"]),ln={copy:new Set(["/a","/b","/d","/j","/l","/n","/v","/y","/-y","/z"]),del:new Set(["/p","/f","/s","/q","/a"]),erase:new Set(["/p","/f","/s","/q","/a"]),move:new Set(["/y","/-y"]),rd:new Set(["/s","/q"]),rmdir:new Set(["/s","/q"])};function fn(e,t){let n=t.toLowerCase(),r=n.slice(0,n.indexOf(":")>=0?n.indexOf(":"):n.length);return ln[e]?.has(r)===!0}c(fn,"isCmdMutationSwitch");function dn(e,t,n=1){let r=[],i=!1;for(let s=n;s<t.length;s+=1){let o=t[s];if(!i&&["touch","chmod","chown"].includes(e)){if(e==="touch"&&o==="-r"||o==="--reference"){s+=1;continue}if(/^--reference=/.test(o)||e==="touch"&&/^-r.+/.test(o))continue}o==="--"?i=!0:(i||!o.startsWith("-")&&!fn(e,o))&&r.push(o)}return r}c(dn,"collectPositionalArgs");function hn(e){let t=E(e.argv[0]??""),n=dn(t,e.argv);if(cn.has(t))return n;if(un.has(t)){let r=e.argv.findIndex(s=>s==="-t"||s==="--target-directory");if(r>=0){let s=e.argv[r+1];return s?[s]:[]}let i=e.argv.find(s=>s.startsWith("--target-directory="));return i?[i.slice(19)]:n.slice(-1)}if(t==="chmod"||t==="chown")return e.argv.some(i=>i==="--reference"||i.startsWith("--reference="))?n:n.slice(1);if(t==="dd"){let r=e.argv.find(i=>i.startsWith("of="));return r?[r.slice(3)]:[]}return[]}c(hn,"collectDirectCommandWriteTargets");function pn(e){let t=[],n=ye(e),r;for(let i=0;i<n.length;i+=1){let s=n[i];if(r!==void 0){s===r?r=void 0:s==="\\"&&r==='"'&&(i+=1);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="\\"){i+=1;continue}if(s!==">")continue;for(n[i+1]===">"&&(i+=1);/\s/.test(n[i+1]??"");)i+=1;let o=n[i+1],a=i+(o==='"'||o==="'"?2:1),u=a;for(;u<n.length;){let l=n[u];if(o==='"'||o==="'"){if(l===o)break}else if(/\s|[|;&<>]/.test(l))break;u+=1}u>a&&t.push(n.slice(a,u)),i=u}return t}c(pn,"collectRawOutputRedirectionTargets");var ge=new Set(["rm","rmdir","rd","del","erase","remove-item","ri","mv","move","move-item","rename-item","ren","rename"]);function C(e,t,n,r,i,s){let o=new Set,a=I(e),u=r,l=c(p=>{let h=Y(p).replace(/^(?:\$env:KODAX_(?:CONFIG_)?HOME|\$\{KODAX_(?:CONFIG_)?HOME\}|\$KODAX_(?:CONFIG_)?HOME|%KODAX_(?:CONFIG_)?HOME%)(?=$|[\\/])/iu,()=>i??P());process.platform==="win32"&&(h=h.replace(/^(?:%USERPROFILE%|\$env:USERPROFILE)(?=$|[\\/])/iu,()=>process.env.USERPROFILE??A.homedir()));let w=process.platform==="win32"?/^(?:\$HOME|\$\{HOME\})(?=$|[\\/])/iu:/^(?:\$HOME|\$\{HOME\})(?=$|[\\/])/u;return h=h.replace(w,()=>A.homedir()),u===void 0?p:G(h,u)},"resolveTarget"),f=c((p,h=!1)=>{let w=p?.trim();if(w){let O=l(w);o.add(O),h&&s?.add(O)}},"pushTarget");if(n)for(let p of Ce(e))f(p);else if(r===void 0||a.unparseable)for(let p of pn(e))f(p);if(a.unparseable){if(t<3)for(let p of K(e)){let h=U(p.map(w=>w.value));if(h!==void 0)for(let w of C(h,t+1,n,u,i,s))f(w)}return Array.from(o)}for(let p of a.statements)for(let h of p.stages){if(u!==void 0&&["cd","chdir","set-location","sl"].includes(h.argv[0]?.toLowerCase()??"")){let g=h.argv.filter(Me=>!["/d","-path","-literalpath","--"].includes(Me.toLowerCase())).at(-1);g&&h.argv.length>1&&(u=l(g))}for(let g of h.redirections)g.descriptorDuplication||g.input||f(g.target);let w=h.argv[0]?.toLowerCase();if(!w)continue;if(w==="tee")for(let g of on(h))f(g);else if(Ee.has(w))for(let g of an(h))f(g,ge.has(E(w)));if(!n)for(let g of hn(h))f(g,ge.has(E(w)));let O=t<3?U(h.argv):void 0;if(O!==void 0)for(let g of C(O,t+1,n,u,i,s))f(g)}return Array.from(o)}c(C,"collectBashWriteTargetsAtDepth");function Gn(e,t,n){let r=new Set;return C(e,0,!1,t,n,r).some(i=>Q(i,t,n,r.has(i)))?"[Tool Error] Shell mutation of governed Memory is denied; use the Memory Control Plane.":void 0}c(Gn,"getGovernedMemoryShellWriteDenial");function kn(e,t){if(!Oe(e))return{dangerous:!1};let n=new Set([...We(e),...tn(e)]);for(let r of n)if(!en(r,t))return{dangerous:!0,reason:`Command may modify file outside project: ${r}`};return{dangerous:!1}}c(kn,"getBashOutsideProjectWriteRisk");function Dn(e,t,n,r=n,i){let s=rn(n);if(ne(e,i))return null;if(ie.has(e)){let o=typeof t.path=="string"?t.path:"";return o?we(o,n,r)?null:`[Blocked] Plan mode only allows file modifications in ${s}. Requested path: ${o}`:`[Blocked] Tool '${e}' is not allowed in plan mode unless it targets ${s}.`}if(e==="bash"){let o=t.command??"";if(!Oe(o))return null;let a=We(o);if(a.length===0)return`[Blocked] Plan mode only allows bash write operations when every target is either ${s}. Could not determine a safe target from: ${o.slice(0,80)}${o.length>80?"...":""}`;let u=a.find(l=>!we(l,n,r));return u?`[Blocked] Plan mode only allows bash write operations in ${s}. Blocked target: ${u}`:null}return`[Blocked] Tool '${e}' has side effects and is not permitted in plan mode. Switch to accept-edits or auto mode to use it, or work within ${s}.`}c(Dn,"getPlanModeBlockReason");function Vn(e){return e.mode==="ask"?"plan":e.auto||e.confirmTools&&e.confirmTools.size===0?"auto":(e.confirmTools&&!e.confirmTools.has("write")&&!e.confirmTools.has("edit"),"accept-edits")}c(Vn,"inferPermissionMode");export{ie as a,wn as b,se as c,oe as d,xn as e,ue as f,st as g,_e as h,Ae as i,Tt as j,Ln as k,Z as l,Rn as m,Oe as n,Pt as o,$n as p,Wn as q,Ct as r,K as s,Ce as t,Yt as u,Mn as v,en as w,$e as x,we as y,We as z,Nn as A,Gn as B,kn as C,Dn as D,Vn as E};
|
|
2
|
+
import{a as D,b as I}from"./chunk-4Y6U7AH4.js";import{C as v,D as k,E as Q,G as ee,_d as te,ae as ne}from"./chunk-HJLYZ5AX.js";import{b as P,d as S,e as G,h as J}from"./chunk-OMVAPRQI.js";import{a as c}from"./chunk-V4WSBIXB.js";import L from"fs";import d from"path";import A from"os";var re=te(),ie=new Set(re.filter(e=>e.sideEffect==="mutates-fs"&&e.requiredParams.includes("path")).map(e=>e.name)),wn=new Set(re.filter(e=>e.sideEffect!=="readonly").map(e=>e.name)),se=new Set(["npm install","npm i","npm uninstall","npm remove","npm update","npm ci","yarn add","yarn remove","yarn upgrade","pnpm add","pnpm remove","pnpm update","git clean","git reset","git checkout","git switch","git merge","git rebase","git cherry-pick","git revert","git commit","git push","git pull","rm","mv","cp","mkdir","rmdir","touch","chmod","chown","del","erase","rd","copy","move","ren","curl","wget","dd","tar","kill","pkill","killall"]),oe=new Set(["ls","cat","pwd","echo","whoami","date","which","whereis","tree","dir","type","get-childitem","get-content","select-string","get-location","where","grep","find","head","tail","more","wc","findstr","git status","git diff","git log","git show","git branch","git remote","git ls-files","git rev-parse","git grep","git tag","git stash list","git describe","git config --get","npm","tsc","go","cargo","rustc"]);import T from"node:path";var Ne={verbose:"switch",debug:"switch",erroraction:"value",warningaction:"value",informationaction:"value",progressaction:"value",errorvariable:"value",warningvariable:"value",informationvariable:"value",outvariable:"value",outbuffer:"value",pipelinevariable:"value",whatif:"switch",confirm:"switch",usetransaction:"switch"},b={path:"value",literalpath:"value",filter:"value",include:"value",exclude:"value"},ce={"copy-item":x(["path","destination"],{...b,destination:"value",container:"switch",recurse:"switch",force:"switch",passthru:"switch",credential:"value",fromsession:"value",tosession:"value"}),"move-item":x(["path","destination"],{...b,destination:"value",force:"switch",passthru:"switch",credential:"value"}),"set-content":x(["path","value"],{...b,value:"value",passthru:"switch",force:"switch",credential:"value",nonewline:"switch",encoding:"value",asbytestream:"switch",stream:"value"}),"add-content":x(["path","value"],{...b,value:"value",passthru:"switch",force:"switch",credential:"value",nonewline:"switch",encoding:"value",asbytestream:"switch",stream:"value"}),"out-file":x(["filepath","encoding"],{filepath:"value",literalpath:"value",inputobject:"value",encoding:"value",append:"switch",force:"switch",noclobber:"switch",width:"value",nonewline:"switch"}),"new-item":x(["path"],{path:"value",name:"value",itemtype:"value",value:"value",force:"switch",credential:"value"}),ni:x(["path"],{path:"value",name:"value",itemtype:"value",value:"value",force:"switch",credential:"value"}),"remove-item":x(["path"],{...b,recurse:"switch",force:"switch",credential:"value",stream:"value"}),"rename-item":x(["path","newname"],{path:"value",literalpath:"value",newname:"value",force:"switch",passthru:"switch",credential:"value"})},Ge={ea:"erroraction",ev:"errorvariable",wa:"warningaction",wv:"warningvariable",ia:"informationaction",infa:"informationaction",iv:"informationvariable",ov:"outvariable",ob:"outbuffer",pv:"pipelinevariable",vb:"verbose",db:"debug",wi:"whatif",cf:"confirm",usetx:"usetransaction",pspath:"literalpath",nooverwrite:"noclobber",type:"itemtype",target:"value"};function x(e,t){return{positionals:e,parameters:{...Ne,...t}}}c(x,"spec");function xn(e){return ce[e.toLowerCase()]!==void 0}c(xn,"isPowerShellMutationCommand");function ue(e){let t=Xe(e[0]??""),n=ce[t];if(!n)return _(`unsupported PowerShell command: ${t||"<empty>"}`);let r=De(e.slice(1),n);if(!r.complete)return _(r.reason??"PowerShell parameter binding is incomplete");if(r.values.has("fromsession")||r.values.has("tosession"))return _("PowerShell remoting changes the filesystem host");if((t==="new-item"||t==="ni")&&/^(?:symboliclink|junction|hardlink)$/i.test(r.values.get("itemtype")??""))return _("PowerShell link creation has an unmodelled target relationship");if(Ue(r))return _("PowerShell path contains bracket wildcard syntax");let i=ke(r);if(!i)return _("PowerShell path array contains an empty target");let s=i.map(a=>ze(t,a));if(s.some(a=>a===void 0))return _("PowerShell mutation target is missing or ambiguous");let o=s.filter(a=>a!==void 0);return["filter","include","exclude"].some(a=>r.values.has(a))?{status:"incomplete",operations:o,reason:"PowerShell provider selectors make the concrete target set unresolved"}:o.some(a=>Fe(a).some(Be))?{status:"incomplete",operations:o,reason:"PowerShell path contains dynamic, wildcard, or array syntax"}:{status:"complete",operations:o}}c(ue,"analyzePowerShellMutation");function ke(e){let t=["path","literalpath"].find(i=>e.values.has(i));if(!t)return[e];let n=e.values.get(t);if(!n.includes(","))return[e];let r=n.split(",").map(i=>i.trim());if(!r.some(i=>!i))return r.map(i=>{let s=new Map(e.values);return s.set(t,i),{...e,values:s}})}c(ke,"expandStaticPathArray");function De(e,t){let n=new Map,r=new Set,i=0,s=!1;for(let o=0;o<e.length;o+=1){let a=e[o];if(a==="--"){s=!0;continue}if(!s&&a.startsWith("-")){let l=Ve(a,t);if(!l)return y(n,r,`unknown or ambiguous parameter ${a}`);if(l.kind==="switch"){let p=je(l.inlineValue);if(p===void 0)return y(n,r,`switch ${a} has an unsupported value`);p&&r.add(l.name);continue}let f=l.inlineValue??e[o+1];if(f===void 0||l.inlineValue===void 0&&f.startsWith("-"))return y(n,r,`parameter ${a} has no bound value`);if(n.has(l.name))return y(n,r,`parameter ${a} is repeated`);n.set(l.name,f),l.inlineValue===void 0&&(o+=1);continue}for(;t.positionals[i]&&n.has(t.positionals[i]);)i+=1;let u=t.positionals[i];if(!u||n.has(u))return y(n,r,`unexpected positional argument ${a}`);n.set(u,a),i+=1}return{complete:!0,values:n,switches:r}}c(De,"bindArguments");function Ve(e,t){let n=/^--?([^:]+)(?::(.*))?$/.exec(e);if(!n)return;let r=n[1].toLowerCase(),i=Ge[r],s=Object.keys(t.parameters),o=i&&t.parameters[i]!==void 0?[i]:s.filter(l=>l.startsWith(r));if(o.length!==1)return;let a=o[0],u=t.parameters[a];return n[2]===void 0?{name:a,kind:u}:{name:a,kind:u,inlineValue:n[2]}}c(Ve,"parseParameter");function ze(e,t){let n=ae(t,"path","literalpath"),r=t.switches.has("force"),i=t.switches.has("whatif")?{whatIf:!0}:{};if(e==="copy-item"||e==="move-item"){if(!n)return;let o=t.values.get("destination")??qe(n);return{kind:e==="copy-item"?"copy":"move",source:n,destination:o,options:{force:r,...i,recursive:e==="copy-item"&&t.switches.has("recurse"),overwritePossible:!0}}}if(e==="rename-item"){let o=t.values.get("newname");return!n||!o||/[\\/]/.test(o)?void 0:{kind:"rename",source:n,destination:Ze(n,o),options:{force:r,...i}}}if(e==="new-item"||e==="ni"){let o=t.values.get("name"),a=o?Ke(t.values.get("path")??".",o):t.values.get("path"),u=t.values.get("itemtype"),l=u?{force:r,...i,itemType:u}:{force:r,...i};return a?{kind:"create",target:a,options:l}:void 0}let s=e==="out-file"?ae(t,"filepath","literalpath"):n;if(s)return e==="remove-item"?{kind:"delete",target:s,options:{force:r,...i,recursive:t.switches.has("recurse")}}:{kind:"write",target:s,options:{force:r,...i,append:e==="add-content"||t.switches.has("append")}}}c(ze,"buildOperation");function ae(e,...t){let n=t.map(r=>e.values.get(r)).filter(r=>!!r);return n.length===1?n[0]:void 0}c(ae,"pathValue");function Fe(e){return"target"in e?[e.target]:[e.source,e.destination]}c(Fe,"operationPaths");function Be(e){return/^\$env:(?:temp|tmp)(?=$|[\\/])/i.test(e)?!1:/[,*?`$]|@\(|[{}]/.test(e)||He(e)}c(Be,"isAmbiguousPathExpression");function Ue(e){return["path","filepath","destination","newname","name"].some(t=>/[\[\]]/.test(e.values.get(t)??""))}c(Ue,"hasUnmodelledBracketWildcard");function He(e){return/^[a-z]:[\\/]/i.test(e)?!1:/^[a-z][a-z0-9_.-]*:/i.test(e)}c(He,"isPowerShellProviderPath");function je(e){if(e===void 0||/^\$?true$|^1$/i.test(e))return!0;if(/^\$?false$|^0$/i.test(e))return!1}c(je,"parseSwitchValue");function qe(e){let t=/^[a-z]:|\\/i.test(e)?T.win32:T.posix;return t.join(".",t.basename(e))}c(qe,"defaultDestination");function Ze(e,t){let n=/^[a-z]:|\\/i.test(e)?T.win32:T.posix;return n.join(n.dirname(e),t)}c(Ze,"joinSourceParent");function Ke(e,t){return(/^[a-z]:|\\/i.test(e)?T.win32:T.posix).join(e,t)}c(Ke,"joinPath");function Xe(e){return e.replace(/\\/g,"/").split("/").at(-1)?.toLowerCase()??""}c(Xe,"commandName");function y(e,t,n){return{complete:!1,values:e,switches:t,reason:n}}c(y,"failed");function _(e){return{status:"incomplete",operations:[],reason:e}}c(_,"incomplete");var Ye=d.join(".agent","plan_mode_doc.md"),R=new Map,$=null,Je=new Set(["status","log","diff","show","ls-files","rev-parse","grep","describe"]),V=new Set(["-C","--git-dir","--work-tree","--namespace","--super-prefix"]),le=new Set(["--git-dir","--work-tree"]),Qe=new Set(["--bare","--no-pager","--no-replace-objects","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs","--no-optional-locks"]),et=new Set(["-d","-D","-m","-M","-c","-C","-f","-t","-u","--delete","--move","--copy","--force","--edit-description","--set-upstream-to","--unset-upstream","--create-reflog","--track","--no-track","--recurse-submodules"]),tt=new Set(["-a","-s","-u","-d","-f","-m","-F","--annotate","--sign","--local-user","--delete","--force","--message","--file","--create-reflog"]),fe=new Set(["--ext-diff","--textconv","--open-files-in-pager","--output","--ext-grep","--help"]),nt=new Set(["--add","--replace-all","--unset","--unset-all","--rename-section","--remove-section","--edit","-e"]),rt=new Set(["--get","--get-all","--get-regexp","--get-urlmatch","--list","-l"]),it=new Set(["set","unset","rename-section","remove-section","edit"]);function Se(e,t,n){let r=1;for(;r<e.length&&e[r].startsWith("-");){let i=e[r],s=i.toLowerCase();if(i==="-c"||i.startsWith("-c")&&i.length>2||s==="--config-env"||s.startsWith("--config-env="))return;if(i==="-C"||le.has(s)){let l=e[r+1];if(!l)return;t?.add(r+1),n?.add(l),r+=2;continue}let a=[...le].find(l=>s.startsWith(`${l}=`)),u=a?i.slice(a.length+1):i.startsWith("-C")&&i.length>2?i.slice(2):void 0;if(u!==void 0){if(!u)return;t?.add(r),n?.add(u),r+=1;continue}if(Qe.has(s)){r+=1;continue}if(V.has(i)||V.has(s)){if(e[r+1]===void 0)return;r+=2;continue}if([...V].some(l=>i.startsWith(`${l}=`)||s.startsWith(`${l}=`))||i.startsWith("-C")&&i.length>2){r+=1;continue}return}return r}c(Se,"consumeGitGlobalOptions");function st(e){return Se(e)}c(st,"findGitSubcommandIndex");function z(e,t,n){let r=[];for(let i=0;i<e.length;i+=1){let s=e[i];if(s==="--")break;if(!t.find(u=>M(s,u)))continue;let a=s.indexOf("=");a>=0?r.push(s.slice(a+1)):n&&e[i+1]!==void 0&&(r.push(e[i+1]),i+=1)}return r}c(z,"gitFormatValues");function xe(e,t){for(let n=0;n<e.length;n+=1){if(e[n]!=="%")continue;let r=n+1;for(;e[r]==="%";)r+=1;if((r-n)%2===1&&t(e.slice(r)))return!0;n=r-1}return!1}c(xe,"hasActiveGitFormatSequence");function ve(e){return xe(e,t=>/^[+\- ]?G[?GSKFPT]/.test(t))}c(ve,"hasGitPrettySignaturePlaceholder");function ot(e){return xe(e,t=>/^\(\*?signature(?::[^)]*)?\)/i.test(t))}c(ot,"hasGitRefSignatureAtom");var at=new Set(["oneline","short","medium","full","fuller","reference","email","raw","mboxrd"]);function ct(e){if(ve(e))return!0;let t=e.toLowerCase();return t.startsWith("format:")||t.startsWith("tformat:")||e.includes("%")?!1:!at.has(t)}c(ct,"gitPrettyFormatMayVerifySignature");function _e(e,t){if(e==="stash"&&t[0]?.toLowerCase()==="list")return _e("log",t.slice(1));let n=t.indexOf("--"),r=n<0?t:t.slice(0,n);return e==="tag"&&r.some(i=>i==="-v"||M(i,"--verify"))||(e==="log"||e==="show")&&r.some(i=>M(i,"--show-signature"))?!0:e==="log"||e==="show"?z(t,["--format"],!0).some(ve)||z(t,["--pretty"],!1).some(ct):e==="branch"||e==="tag"?z(t,["--format"],!0).some(ot):!1}c(_e,"gitSignatureInspectionMayExecute");function de(e,t){let n=new Set([...t].filter(r=>/^-[^-]$/.test(r)).map(r=>r.slice(1)));return e.some(r=>t.has(r)||[...t].some(i=>i.startsWith("--")&&r.startsWith(`${i}=`))||Te(r,n,new Set))||e.some(r=>!r.startsWith("-"))}c(de,"hasGitMutationArguments");function Ae(e){if(!e.startsWith("-")||e.startsWith("--")||e.length<2)return{pager:!1,consumesNext:!1};for(let t=1;t<e.length;t+=1){let n=e[t];if(n==="O")return{pager:!0,consumesNext:!1};let r=n==="e"?"pattern":n==="f"?"pattern-file":"mABC".includes(n)?"other":void 0;if(r){let i=e.slice(t+1)||void 0;return{pager:!1,valueKind:r,attachedValue:i,consumesNext:i===void 0}}}return{pager:!1,consumesNext:!1}}c(Ae,"parseGitGrepShortOption");function ut(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return!1;if(n==="--regexp"||n==="--file"){t+=1;continue}let r=Ae(n);if(r.pager)return!0;r.consumesNext&&(t+=1)}return!1}c(ut,"hasGitGrepPagerOption");function lt(e){let t=st(e);if(t===void 0)return!1;let n=e[t];if(!n)return!1;let r=n.toLowerCase(),i=e.slice(t+1),s=i.map(u=>u.toLowerCase()),o=s.indexOf("--");if((o<0?s:s.slice(0,o)).some(u=>fe.has(u)||[...fe].some(l=>u.startsWith(`${l}=`)))||r==="grep"&&ut(i))return!1;if(Je.has(r))return!0;if(r==="stash")return s[0]==="list"||s[0]==="show";if(r==="config"){let u=s[0];return it.has(u??"")?!1:(u==="get"||u==="list"||s.some(f=>rt.has(f)))&&!s.some(f=>nt.has(f))}if(r==="branch"){let u=s.some(f=>["--list","-l","--contains","--no-contains","--merged","--no-merged","--points-at","--show-current","--all","-a","--remotes","-r"].includes(f)||["--list=","--contains=","--no-contains=","--merged=","--no-merged=","--points-at="].some(p=>f.startsWith(p))),l=i.some(f=>!f.startsWith("-"));return!de(i.filter(f=>f.startsWith("-")),et)&&(!l||u)}if(r==="tag")return _e(r,i)?!0:(i.length===0||s.every(l=>l.startsWith("-"))||s.includes("-l")||s.includes("--list"))&&!de(i.filter(l=>l.startsWith("-")),tt);if(r==="remote"){let u=s.find(l=>!l.startsWith("-"));return u===void 0||u==="get-url"?!0:u!=="show"?!1:s.includes("-n")||s.includes("--no-query")}return!1}c(lt,"isGitReadCommand");var ft=/(?:^|_)(?:api_?key|access_?key|secret|token|password|passwd|credential|private_?key|auth|cookie)(?:_|$)/i,dt=new Set(["-eq","-ne","-gt","-ge","-lt","-le","-like","-notlike","-match","-notmatch","-contains","-notcontains","-in","-notin"]);function ht(e){return e.length>0&&!/[${};&|<>`]/.test(e)&&!e.includes("$(")}c(ht,"isSafePowerShellLiteral");function pt(e){let t=/^\$env:([a-z_][a-z0-9_]*)$/i.exec(e[0]??"");return!t||ft.test(t[1])?!1:e.length===1?!0:e.length===3&&["-split","-like","-notlike","-match","-notmatch"].includes(e[1]?.toLowerCase()??"")&&(e[2]?.length??0)>0&&!/[{}&|<>`]/.test(e[2]??"")&&!(e[2]??"").includes("$(")}c(pt,"isSafePowerShellEnvironmentRead");function mt(e){let t=e.slice(1),n=t[0]==="{"&&t.at(-1)==="}"?t.slice(1,-1):t;if(n.length!==3)return!1;let[r,i,s]=n;return/^\$_(?:(?:\.)?[a-z_][a-z0-9_]*)?$/i.test(r??"")&&dt.has(i?.toLowerCase()??"")&&ht(s??"")}c(mt,"isSafeWhereObjectRead");function wt(e){let t=new Set(["-unique","-wait"]),n=new Set(["-first","-last","-skip","-index"]),r=new Set(["-property","-expandproperty"]);for(let i=1;i<e.length;i+=1){let s=e[i]??"",o=s.toLowerCase();if(!t.has(o)){if(n.has(o)){if(!/^\d+(?:,\d+)*$/.test(e[++i]??""))return!1;continue}if(r.has(o)){if(!/^(?:\*|[a-z_][a-z0-9_]*)(?:,(?:\*|[a-z_][a-z0-9_]*))*$/i.test(e[++i]??""))return!1;continue}if(!/^(?:\*|[a-z_][a-z0-9_]*)(?:,(?:\*|[a-z_][a-z0-9_]*))*$/i.test(s))return!1}}return!0}c(wt,"isSafeSelectObjectRead");function gt(e){return!e.slice(1).some(t=>/^--pre(?:=|$)/i.test(t)||/^--hostname-bin(?:=|$)/i.test(t))}c(gt,"isSafeRipgrepRead");var St=/^(?:-delete|-exec|-execdir|-ok|-okdir|-fprint|-fprint0|-fprintf|-fls)$/i;function xt(e){return!e.slice(1).some(t=>St.test(t))}c(xt,"isSafeFindRead");var Ie=new Set(["H","I","L","P","T"]);var B=new Set(["o"]),vt=new Set(["--charset","--filelimit","--output","--sort","--timefmt"]);function M(e,t){let n=e.indexOf("="),r=(n>=0?e.slice(0,n):e).toLowerCase();return r.startsWith("--")&&r.length>=3&&t.startsWith(r)}c(M,"longOptionCouldMatch");function Te(e,t,n){if(!/^-[^-]/.test(e))return!1;for(let r of e.slice(1)){if(t.has(r))return!0;if(n.has(r))return!1}return!1}c(Te,"shortOptionClusterContains");function _t(e){return!e.slice(1).some(t=>Te(t,B,Ie)||M(t,"--output"))}c(_t,"isSafeTreeRead");function At(e){let t=e.slice(1);if(t.length===0)return!0;for(let n=0;n<t.length;n+=1){let r=t[n]??"",i=r.toLowerCase();if(!(i==="/t"||i==="--help"||i==="--version"||r.startsWith("+"))){if(i==="-s"||i==="--set"||i.startsWith("--set="))return!1;if(["-d","--date","-r","--reference"].includes(i)){if(t[++n]===void 0)return!1;continue}if(!/^--(?:date|reference)=/i.test(r)&&!(/^(?:-u|--utc|--universal|-R|--rfc-email|--resolution|--debug)$/i.test(r)||/^--(?:iso-8601|rfc-3339)(?:=|$)/i.test(r)))return!1}}return!0}c(At,"isSafeDateRead");function It(e){return e.length>0&&!/[\\/]/.test(e)}c(It,"isBareShellExecutable");function Tt(e){if(e.length===0||!It(e[0]??""))return!1;if(pt(e))return!0;let t=(e[0]??"").toLowerCase(),n=E(e[0]??"");if(t==="where.exe")return!0;if(n==="where-object"||t==="where"||t==="?")return mt(["where-object",...e.slice(1)]);if(n==="select-object")return wt(e);if(n==="rg"||n==="ripgrep")return gt(e);if(n==="find")return xt(e);if(n==="less")return!1;if(n==="tree")return _t(e);if(n==="date")return At(e);let i=[n,...e.slice(1).map(s=>s.toLowerCase())].join(" ");if(n==="git")return lt([n,...e.slice(1)]);for(let s of oe)if(i===s||i.startsWith(s+" ")){if(["npm","tsc","go","cargo","rustc"].includes(s)){let a=i.split(/\s+/).slice(1);if(a.length>0&&!a.every(u=>/^(-v|--version|-h|--help)$/.test(u)))return!1}return!0}return!1}c(Tt,"isShellReadOnlyArgv");var Et=/^[a-zA-Z0-9]+$/;function Ln(e){let t=e.trim();if(!t.endsWith("--help")||t.includes('"')||t.includes("'"))return!1;let n=!1;for(let r of t.split(/\s+/))if(r.startsWith("-"))if(r==="--help")n=!0;else return!1;else if(!Et.test(r))return!1;return n}c(Ln,"isHelpCommand");function Z(e){if(!e||!e.trim())return!1;let t=I(e.trim());if(t.unparseable||t.statements.length===0)return!1;let n=t.statements.length>1||(t.statements[0]?.stages.length??0)>1;for(let r of t.statements){if(r.precedingOp!==null&&r.precedingOp!=="&&"&&r.precedingOp!==";")return!1;for(let i of r.stages){for(let o of i.redirections)if(!o.descriptorDuplication&&(o.input||!D(o.target)))return!1;if(i.argv.join(" ")&&!(n&&i.argv[0]?.toLowerCase()==="cd"&&i.argv.length>=2)&&!Tt(i.argv))return!1}}return!0}c(Z,"isBashReadCommand");function Rn(e){let t=e.trim();return t?Z(t)?null:"[Blocked] Direct !command execution only supports safe read-only commands. Use the bash tool for commands that write files, invoke shells, or require confirmation.":"[Shell: No command provided]"}c(Rn,"getDirectShellBypassBlockReason");var Ee=new Set(["remove-item","set-content","add-content","out-file","new-item","copy-item","move-item","rename-item","ni"]),Ot={bash:new Set(["-c"]),dash:new Set(["-c"]),sh:new Set(["-c"]),zsh:new Set(["-c"]),cmd:new Set(["/c"]),powershell:new Set(["-command","-c"]),pwsh:new Set(["-command","-c"])};function U(e){let t=e[0]?.replace(/\\/g,"/"),n=t?.slice(t.lastIndexOf("/")+1).replace(/\.exe$/i,"").toLowerCase();if(!n)return;let r=Ot[n];if(!r)return;let i=e.findIndex((s,o)=>o>0&&r.has(s.toLowerCase()));return i>=0?e[i+1]:void 0}c(U,"getNestedShellCommand");function Oe(e){return Pe(e,0)}c(Oe,"isBashWriteCommand");function Pe(e,t){if(!e||!e.trim())return!1;let n=I(e);if(n.unparseable)return!1;for(let r of n.statements)for(let i of r.stages){let s=i.argv.map(a=>a.toLowerCase());if(s.length>0){let a=s[0],u=s.length>=2?`${s[0]} ${s[1]}`:null;for(let l of se)if(l===a||u!==null&&l===u)return!0}for(let a of s)if(Ee.has(a))return!0;for(let a of i.redirections)if(!a.descriptorDuplication&&!a.input&&!D(a.target))return!0;let o=t<3?U(i.argv):void 0;if(o!==void 0&&Pe(o,t+1))return!0}return!1}c(Pe,"isBashWriteCommandAtDepth");function Pt(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\((.+)\)$/);return t?{tool:t[1].toLowerCase(),pattern:t[2]}:{tool:e.toLowerCase(),pattern:null}}c(Pt,"parseAllowedToolPattern");function bt(e,t){if(t==="*"||/[;&|<>\r\n`$()%!^{}]/u.test(e))return!1;let n=I(e);if(n.unparseable||n.statements.length!==1||n.statements[0].stages.length!==1)return!1;let r=n.statements[0].stages[0];if(r.redirections.length)return!1;if(!t.endsWith(":*"))return e===t;let i=t.slice(0,-2);if(!/^[\w./-]+(?:[ \t]+[\w./-]+)*$/u.test(i))return!1;let s=i.split(/[ \t]+/u);return r.argv.length>=s.length&&s.every((o,a)=>r.argv[a]===o)}c(bt,"matchesBashPatternWithoutExtractor");function yt(e,t){if(t==="*")return!1;if(t.endsWith(":*")){let n=t.slice(0,-2);return e===n}return e===t}c(yt,"matchesBashPatternByExtractedPrefix");async function $n(e,t,n,r,i){if(e.toLowerCase()!=="bash")return!1;let s=typeof t.command=="string"?t.command:"",o=[];for(let a of n){let u=Pt(a);if(u.tool==="bash"){if(u.pattern===null)return!0;o.push({pattern:u.pattern})}}if(o.length===0)return!1;if(r){let a;try{a=await r.extract(s,i)}catch{return!1}if(a.kind!=="prefix")return!1;for(let{pattern:u}of o)if(u&&yt(a.value,u))return!0;return!1}for(let{pattern:a}of o)if(a&&bt(s,a))return!0;return!1}c($n,"isToolCallAllowed");function Wn(e,t,n){if(e.toLowerCase()!=="bash")return"";let r=t.command??"",i=r.split(" ");return i.length>1?`Bash(${i.slice(0,2).join(" ")}:*)`:`Bash(${r})`}c(Wn,"generateSavePattern");function Ct(e,t){try{let n=d.resolve(e),r=d.resolve(t);if(S(n,d.join(r,".kodax")))return!0;let i=v(n),s=v(r),o=v(d.join(r,".kodax"));if(i===void 0||s===void 0||o===void 0)throw new Error("Protected-path identity could not be resolved.");let a=d.resolve(P());if(S(i,o))return!0;let u=v(a)??a,l=v(i);return S(i,a)?l===void 0||!S(l,u)||!k(l,u):l!==void 0&&S(l,u)?!k(l,u):!(S(i,s)||Re().some(p=>S(i,p)))}catch(n){return J({source:"permission:protected-path",level:"warn",message:"Cannot resolve protected-path policy; confirmation is required.",detail:n}),!0}}c(Ct,"isAlwaysConfirmPath");function W(e){return!e||e.startsWith("-")?!1:/^\.\.?[/\\]/.test(e)||e.startsWith("~/")||e.startsWith("~\\")||/^[a-zA-Z]:[/\\]/.test(e)||/^\\\\/.test(e)?!0:e.startsWith("/")&&e.length>1?!(process.platform==="win32"&&H.test(e)):!!(e.startsWith(".")&&/[/\\]/.test(e)||e.split(/[/\\]+/).includes(".."))}c(W,"looksLikePath");var H=/^\/[A-Za-z][A-Za-z0-9]*(?::[A-Za-z0-9]+)?$/,he={python:new Set(["-c"]),py:new Set(["-c"]),node:new Set(["-e","--eval","-p","--print"]),ruby:new Set(["-e"]),perl:new Set(["-e"])},Lt=new Set(["rg","ripgrep","grep","egrep","fgrep","findstr","select-string","sls","sed","awk"]),Rt=new Set(["-e","--regexp","--regex","-pattern"]),$t=new Set(["-f","--file"]),pe=new Set(["-g","--glob","--iglob","-r","--replace"]),F=new Set(["--include","--exclude","--exclude-dir"]),Wt={rg:pe,ripgrep:pe,grep:F,egrep:F,fgrep:F,awk:new Set(["-v","--assign"]),"select-string":new Set(["-inputobject"])},Mt={rg:new Set(["--ignore-file"]),ripgrep:new Set(["--ignore-file"]),grep:new Set(["--exclude-from"]),egrep:new Set(["--exclude-from"]),fgrep:new Set(["--exclude-from"]),"select-string":new Set(["-path","-literalpath"])},Nt=["path","literalpath","include","exclude","pattern","simplematch","casesensitive","quiet","list","allmatches","notmatch","encoding","context","raw","culture","inputobject","noemphasis","verbose","debug","erroraction","warningaction","informationaction","errorvariable","warningvariable","informationvariable","outvariable","outbuffer","pipelinevariable","progressaction"],Gt=new Set(["simplematch","casesensitive","quiet","list","allmatches","notmatch","raw","noemphasis","verbose","debug"]),kt={pspath:"literalpath",vb:"verbose",db:"debug",ea:"erroraction",wa:"warningaction",infa:"informationaction",ev:"errorvariable",wv:"warningvariable",iv:"informationvariable",ov:"outvariable",ob:"outbuffer",pv:"pipelinevariable"},Dt=new Set(["-f","--file","--blob"]),Vt=new Set(["-g","-s","--format","--pretty","--date","--encoding","--diff-algorithm","--word-diff-regex","--diff-filter","--find-object","--line-prefix","--src-prefix","--dst-prefix","--grep","--author","--committer","--since","--after","--until","--before","--max-count","-n","--skip","--min-parents","--max-parents","--inter-hunk-context","--anchored"]),zt=new Set(["--max-count","--after-context","--before-context","--context","--threads"]);function E(e){let t=e.replace(/\\/g,"/");return(t.split("/").pop()??t).toLowerCase().replace(/\.exe$/,"")}c(E,"commandBasename");function Ft(){return{sourceIndexes:new Set,pathIndexes:new Set,pathValues:new Set}}c(Ft,"createCommandArgumentRoles");function m(e,t,n,r){let i=e[t];i!==void 0&&(n.add(t),r?.add(i))}c(m,"addIndexedValue");function be(e,t,n){let r=e[t];if(!r)return;let i=/^%[A-Za-z_][A-Za-z0-9_]*%[/\\]/.test(r)||/^\$(?:env:)?(?:\{[A-Za-z_][A-Za-z0-9_]*\}|[A-Za-z_][A-Za-z0-9_]*)[/\\]/i.test(r),s=/[*?[\]]/.test(r)||/\{[^{}]*,[^{}]*\}/.test(r);(W(r)||i||s)&&m(e,t,n.pathIndexes,n.pathValues)}c(be,"addGitPathCandidate");function N(e,t){let n=e.toLowerCase();if(t.startsWith("--")){let r=`${t}=`;return n.startsWith(r)?e.slice(r.length):void 0}return n.startsWith(t)&&e.length>t.length?e.slice(t.length):void 0}c(N,"attachedOptionValue");function Bt(e,t,n){for(let r=1;r<e.length;r+=1){let i=e[r]??"",s=i.toLowerCase();for(let o of t){if(s===o){m(e,r+1,n.sourceIndexes);break}if(N(i,o)!==void 0){n.sourceIndexes.add(r);break}}}}c(Bt,"collectScriptSourceRoles");function j(e,t,n,r){if(t)for(let i=1;i<e.length;i+=1){let s=e[i]??"";if(s==="--")break;let o=s.toLowerCase();for(let a of t){if(o===a){m(e,i+1,n,r);break}let u=N(s,a);if(u!==void 0){n.add(i),r?.add(u);break}}}}c(j,"collectFlagValueRoles");function Ut(e,t,n){let r=!1,i=!1;for(let s=t+1;s<e.length;s+=1){let o=e[s]??"";if(o==="--"){i=!0;continue}let a=o.toLowerCase();if(!i&&a==="--file"){m(e,s+1,n.pathIndexes,n.pathValues),r=!0,s+=1;continue}if(!i&&a.startsWith("--file=")){n.pathIndexes.add(s),n.pathValues.add(o.slice(o.indexOf("=")+1)),r=!0;continue}if(!i&&(a==="--regexp"||a==="-e")){m(e,s+1,n.sourceIndexes),r=!0,s+=1;continue}if(!i&&a.startsWith("--regexp=")){n.sourceIndexes.add(s),r=!0;continue}if(!i&&zt.has(a)){m(e,s+1,n.sourceIndexes),s+=1;continue}if(!i){let u=Ae(o);if(u.valueKind==="pattern-file"){u.attachedValue!==void 0?(n.pathIndexes.add(s),n.pathValues.add(u.attachedValue)):(m(e,s+1,n.pathIndexes,n.pathValues),s+=1),r=!0;continue}if(u.valueKind==="pattern"){u.attachedValue!==void 0?n.sourceIndexes.add(s):(m(e,s+1,n.sourceIndexes),s+=1),r=!0;continue}if(u.valueKind==="other"){u.consumesNext&&(m(e,s+1,n.sourceIndexes),s+=1);continue}if(o.startsWith("-"))continue}if(!r){n.sourceIndexes.add(s),r=!0;continue}be(e,s,n)}}c(Ut,"collectGitGrepArgumentRoles");function Ht(e,t,n){let r=!1;for(let i=t+1;i<e.length;i+=1){let s=e[i]??"";if(s==="--"){r=!0;continue}if(!r&&Vt.has(s.toLowerCase())){m(e,i+1,n.sourceIndexes),i+=1;continue}!r&&s.startsWith("-")||be(e,i,n)}}c(Ht,"collectGitReadPathRoles");function jt(e){let t=/^-([^:]+)(?::(.*))?$/s.exec(e);if(!t)return;let n=t[1]?.toLowerCase()??"",r=kt[n],i=r?[r]:Nt.filter(s=>s.startsWith(n));if(i.length===1)return{name:i[0],...t[2]!==void 0?{attachedValue:t[2]}:{}}}c(jt,"resolvePowerShellSelectStringParameter");function qt(e,t){let n=!1;for(let r=1;r<e.length;r+=1){let i=e[r]??"",s=jt(i);if(s){if(Gt.has(s.name))continue;let o=s.attachedValue===void 0?r+1:r,a=s.attachedValue??e[o];if(a===void 0)continue;s.name==="path"||s.name==="literalpath"?(t.pathIndexes.add(o),t.pathValues.add(a)):t.sourceIndexes.add(o),s.name==="pattern"&&(n=!0),s.attachedValue===void 0&&(r+=1);continue}if(!i.startsWith("-")){if(!n){t.sourceIndexes.add(r),n=!0;continue}m(e,r,t.pathIndexes,t.pathValues)}}}c(qt,"collectPowerShellSelectStringArgumentRoles");function Zt(e,t){let n=E(e[0]??"");if(n==="select-string"||n==="sls"){qt(e,t);return}j(e,Wt[n],t.sourceIndexes),j(e,Mt[n],t.pathIndexes,t.pathValues);let r=!1;for(let s=1;s<e.length;s+=1){let o=e[s]??"";if(o==="--")break;let a=o.toLowerCase();if(n==="findstr"&&a.startsWith("/f:")){t.pathIndexes.add(s),t.pathValues.add(o.slice(3));continue}if(n==="findstr"&&a.startsWith("/c:")){t.sourceIndexes.add(s),r=!0;continue}if(n==="findstr"&&a.startsWith("/g:")){t.pathIndexes.add(s),t.pathValues.add(o.slice(3)),r=!0;continue}for(let u of Rt){if(a===u){m(e,s+1,t.sourceIndexes),r=!0;break}if(N(o,u)!==void 0){t.sourceIndexes.add(s),r=!0;break}}for(let u of $t){if(a===u){m(e,s+1,t.pathIndexes,t.pathValues),r=!0;break}let l=N(o,u);if(l!==void 0){t.pathValues.add(l),r=!0;break}}}if(!r){let s=!1;for(let o=1;o<e.length;o+=1){let a=e[o]??"";if(a==="--"){s=!0;continue}if(!(t.sourceIndexes.has(o)||t.pathIndexes.has(o))&&!(!s&&a.startsWith("-"))&&!(n==="findstr"&&H.test(a))){m(e,o,t.sourceIndexes);break}}}let i=!1;for(let s=1;s<e.length;s+=1){let o=e[s]??"";if(o==="--"){i=!0;continue}!i&&o.startsWith("-")||t.sourceIndexes.has(s)||t.pathIndexes.has(s)||n==="findstr"&&H.test(o)||m(e,s,t.pathIndexes,t.pathValues)}}c(Zt,"collectRegexArgumentRoles");function Kt(e,t){if(!e.slice(1).some(i=>/^--from(?:tab)?file(?:=|$)/i.test(i)))return;let r=!1;for(let i=1;i<e.length;i+=1){let s=e[i]??"",o=/^--from(?:tab)?file=(.*)$/i.exec(s)?.[1];if(o!==void 0){t.pathIndexes.add(i),o&&t.pathValues.add(o);continue}if(/^--from(?:tab)?file$/i.test(s)||s==="--"){t.sourceIndexes.add(i),s==="--"&&(r=!0);continue}if(!r&&/^-[^-]/.test(s)){let a=s.slice(1),u=[...a].findIndex(l=>Ie.has(l)||B.has(l));if(t.sourceIndexes.add(i),u>=0&&a.slice(u+1).length===0){let l=B.has(a[u]??"");m(e,i+1,l?t.pathIndexes:t.sourceIndexes,l?t.pathValues:void 0),i+=1}continue}if(!r&&s.startsWith("--")){let a=s.split("=",1)[0]?.toLowerCase()??"";if(t.sourceIndexes.add(i),vt.has(a)&&!s.includes("=")){let u=a==="--output";m(e,i+1,u?t.pathIndexes:t.sourceIndexes,u?t.pathValues:void 0),i+=1}continue}m(e,i,t.pathIndexes,t.pathValues)}}c(Kt,"collectTreeFileListRoles");function q(e){let t=Ft(),n=E(e[0]??"");if(n==="git"){let i=Se(e,t.pathIndexes,t.pathValues),s=i===void 0?void 0:e[i]?.toLowerCase();i!==void 0&&s==="grep"?Ut(e,i,t):i!==void 0&&(s==="diff"||s==="log"||s==="show")?Ht(e,i,t):s==="config"&&j(e,Dt,t.pathIndexes,t.pathValues)}let r=/^python(?:\d+(?:\.\d+)*)?$/.test(n)?he.python:he[n];return r&&Bt(e,r,t),Lt.has(n)&&Zt(e,t),n==="tree"&&Kt(e,t),t}c(q,"collectCommandArgumentRoles");function K(e){let t=[],n=[],r="",i=-1,s,o=c(u=>{i<0||(n.push({value:r,start:i,end:u}),r="",i=-1)},"finishWord"),a=c(()=>{n.length>0&&t.push(n),n=[]},"finishStage");for(let u=0;u<e.length;u+=1){let l=e[u];if(s){l===s?s=void 0:s==='"'&&l==="\\"&&e[u+1]==='"'?(r+=`${l}${e[u+1]}`,u+=1):r+=l;continue}l==='"'||l==="'"?(i<0&&(i=u),s=l):/\s/.test(l)?o(u):l==="|"||l==="&"||l===";"?(o(u),a()):(i<0&&(i=u),r+=l)}return s?[]:(o(e.length),a(),t)}c(K,"tokenizeRawCommandStages");function ye(e){let t=e.split("");for(let n of K(e)){let r=q(n.map(i=>i.value));for(let i of r.sourceIndexes){let s=n[i];if(s)for(let o=s.start;o<s.end;o+=1)t[o]=" "}}return t.join("")}c(ye,"maskRawInlineSources");function Xt(e){let t=[],n;for(let s of[/"([A-Za-z]:\\[^"\r\n]+)"/g,/'([A-Za-z]:\\[^'\r\n]+)'/g])for(;(n=s.exec(e))!==null;)t.push(n[1]);let r=/(?:^|\s)(\.\.?\/[^\s]+|\.\.?\\[^\s]+|~\/[^\s]+|\.[^\s]*[/\\][^\s]*)/g;for(;(n=r.exec(e))!==null;)t.push(n[1]);let i=/(?:^|[\s:=<>])([a-zA-Z]:\\[^\s"'|;&<>]+)/g;for(;(n=i.exec(e))!==null;)t.push(n[1]);return t}c(Xt,"legacyRegexPathScan");function Ce(e){let t=new Set,n=I(e);if(n.unparseable)return[];for(let r of K(e)){let i=r.map(o=>o.value),s=q(i);for(let o of s.pathValues)t.add(o);if(process.platform==="win32")for(let o=0;o<i.length;o+=1){if(s.sourceIndexes.has(o)||s.pathIndexes.has(o))continue;let a=i[o];W(a)&&t.add(a)}}for(let r of n.statements)for(let i of r.stages){let s=q(i.argv);if(process.platform!=="win32")for(let o of s.pathValues)t.add(o);for(let o=0;o<i.argv.length;o+=1){let a=i.argv[o];s.sourceIndexes.has(o)||s.pathIndexes.has(o)||W(a)&&t.add(a)}for(let o of i.redirections)o.descriptorDuplication||W(o.target)&&t.add(o.target)}for(let r of Xt(ye(e)))t.add(r);return Array.from(t)}c(Ce,"extractPathsFromCommand");function Yt(e,t,n=t){let r=Z(e),i=Ce(e);for(let s of i){let o=G(s,n);if(r&&ee(o,n))return!0;if(!(r&&Jt(o))&&Ct(o,t))return!0}return!1}c(Yt,"isCommandOnProtectedPath");function Jt(e){try{let t=v(P())??d.resolve(P()),n=v(e);return n!==void 0&&S(n,t)}catch{return!1}}c(Jt,"isReadableAgentHomeTarget");function Mn(e,t,n=t){return Z(e)&&!Yt(e,t,n)}c(Mn,"isBashReadCommandAutoAllowed");function me(e){let t=d.normalize(e);return process.platform==="win32"?t.toLowerCase():t}c(me,"normalizePathForComparison");function Qt(e,t){return me(e)===me(t)}c(Qt,"pathsEqual");function en(e,t){try{let n=d.resolve(t),r=d.resolve(n,Le(Y(e)));return S(r,n)}catch{return!1}}c(en,"isPathInsideProject");function tn(e){let t=e.match(/[A-Za-z]:[\\/][^\s;|&<>(){}'"]+|\/[^\s;|&<>(){}'"]+/g);return t?t.filter(n=>!/^(?:\/dev\/|\/proc\/)/i.test(n)):[]}c(tn,"collectAbsolutePathCandidates");function X(e){let t=d.resolve(e),n=R.get(t);if(n)return n;if(L.existsSync(t)){let a=L.realpathSync.native(t);return R.set(t,a),a}let r=[],i=t;for(;!L.existsSync(i);){let a=d.dirname(i);if(a===i)return R.set(t,t),t;r.unshift(d.basename(i)),i=a}let s=L.realpathSync.native(i),o=d.join(s,...r);return R.set(t,o),o}c(X,"resolveExistingPathPrefix");function Y(e){return e==="~"?A.homedir():e.startsWith(`~${d.sep}`)||e.startsWith("~/")||e.startsWith("~\\")?d.join(A.homedir(),e.slice(2)):e}c(Y,"expandHomeDirectory");function Le(e){let t=A.tmpdir(),n=[[/^%temp%/i,t],[/^%tmp%/i,t],[/^\$env:temp\b/i,t],[/^\$env:tmp\b/i,t],[/^\$tmpdir\b/i,t],[/^\$temp\b/i,t],[/^\$tmp\b/i,t]];for(let[r,i]of n)if(r.test(e))return e.replace(r,i);return e}c(Le,"expandSystemTempAlias");function nn(e,t,n=t){let r=d.resolve(n??t??process.cwd()),i=Le(Y(e)),s=d.isAbsolute(i)?d.resolve(i):d.resolve(r,i);return X(s)}c(nn,"resolvePermissionPath");function Re(){if($)return $;let e=new Set,t=[A.tmpdir(),process.env.TEMP,process.env.TMP,process.env.TMPDIR].filter(n=>typeof n=="string"&&n.trim().length>0);for(let n of t)try{e.add(X(n))}catch{}return $=Array.from(e),$}c(Re,"getSystemTempDirectories");function $e(e){let t=X(e??process.cwd());return{projectPlanDoc:d.join(t,Ye),systemTempDirs:Re()}}c($e,"getPlanModeAllowedWritablePaths");function we(e,t,n=t){let r=nn(e,t,n),{projectPlanDoc:i,systemTempDirs:s}=$e(t);return Qt(r,i)?!0:s.some(o=>S(r,o))}c(we,"isPlanModeAllowedPath");function rn(e){let{projectPlanDoc:t,systemTempDirs:n}=$e(e),r=n[0]??A.tmpdir();return`${t} or the system temp directory (${r})`}c(rn,"formatPlanModeAllowedLocations");var sn=new Set(["-a","--append","-i","--ignore-interrupts"]);function on(e){let t=[];for(let n=1;n<e.argv.length;n+=1){let r=e.argv[n];sn.has(r)||r.startsWith("-")||t.push(r)}return t}c(on,"collectTeeTargets");function an(e){let t=ue(e.argv),n=[];for(let r of t.operations)"target"in r?n.push(r.target):r.kind==="copy"?n.push(r.destination):n.push(r.source,r.destination);return n}c(an,"collectPowerShellWriteTargets");function We(e){return C(e,0,!0)}c(We,"collectBashWriteTargets");function Nn(e){return C(e,0,!1)}c(Nn,"collectDeterministicBashWriteTargets");var cn=new Set(["rm","rmdir","mkdir","touch","mv","move","ren","del","erase","rd"]),un=new Set(["cp","copy"]),ln={copy:new Set(["/a","/b","/d","/j","/l","/n","/v","/y","/-y","/z"]),del:new Set(["/p","/f","/s","/q","/a"]),erase:new Set(["/p","/f","/s","/q","/a"]),move:new Set(["/y","/-y"]),rd:new Set(["/s","/q"]),rmdir:new Set(["/s","/q"])};function fn(e,t){let n=t.toLowerCase(),r=n.slice(0,n.indexOf(":")>=0?n.indexOf(":"):n.length);return ln[e]?.has(r)===!0}c(fn,"isCmdMutationSwitch");function dn(e,t,n=1){let r=[],i=!1;for(let s=n;s<t.length;s+=1){let o=t[s];if(!i&&["touch","chmod","chown"].includes(e)){if(e==="touch"&&o==="-r"||o==="--reference"){s+=1;continue}if(/^--reference=/.test(o)||e==="touch"&&/^-r.+/.test(o))continue}o==="--"?i=!0:(i||!o.startsWith("-")&&!fn(e,o))&&r.push(o)}return r}c(dn,"collectPositionalArgs");function hn(e){let t=E(e.argv[0]??""),n=dn(t,e.argv);if(cn.has(t))return n;if(un.has(t)){let r=e.argv.findIndex(s=>s==="-t"||s==="--target-directory");if(r>=0){let s=e.argv[r+1];return s?[s]:[]}let i=e.argv.find(s=>s.startsWith("--target-directory="));return i?[i.slice(19)]:n.slice(-1)}if(t==="chmod"||t==="chown")return e.argv.some(i=>i==="--reference"||i.startsWith("--reference="))?n:n.slice(1);if(t==="dd"){let r=e.argv.find(i=>i.startsWith("of="));return r?[r.slice(3)]:[]}return[]}c(hn,"collectDirectCommandWriteTargets");function pn(e){let t=[],n=ye(e),r;for(let i=0;i<n.length;i+=1){let s=n[i];if(r!==void 0){s===r?r=void 0:s==="\\"&&r==='"'&&(i+=1);continue}if(s==='"'||s==="'"){r=s;continue}if(s==="\\"){i+=1;continue}if(s!==">")continue;for(n[i+1]===">"&&(i+=1);/\s/.test(n[i+1]??"");)i+=1;let o=n[i+1],a=i+(o==='"'||o==="'"?2:1),u=a;for(;u<n.length;){let l=n[u];if(o==='"'||o==="'"){if(l===o)break}else if(/\s|[|;&<>]/.test(l))break;u+=1}u>a&&t.push(n.slice(a,u)),i=u}return t}c(pn,"collectRawOutputRedirectionTargets");var ge=new Set(["rm","rmdir","rd","del","erase","remove-item","ri","mv","move","move-item","rename-item","ren","rename"]);function C(e,t,n,r,i,s){let o=new Set,a=I(e),u=r,l=c(p=>{let h=Y(p).replace(/^(?:\$env:KODAX_(?:CONFIG_)?HOME|\$\{KODAX_(?:CONFIG_)?HOME\}|\$KODAX_(?:CONFIG_)?HOME|%KODAX_(?:CONFIG_)?HOME%)(?=$|[\\/])/iu,()=>i??P());process.platform==="win32"&&(h=h.replace(/^(?:%USERPROFILE%|\$env:USERPROFILE)(?=$|[\\/])/iu,()=>process.env.USERPROFILE??A.homedir()));let w=process.platform==="win32"?/^(?:\$HOME|\$\{HOME\})(?=$|[\\/])/iu:/^(?:\$HOME|\$\{HOME\})(?=$|[\\/])/u;return h=h.replace(w,()=>A.homedir()),u===void 0?p:G(h,u)},"resolveTarget"),f=c((p,h=!1)=>{let w=p?.trim();if(w){let O=l(w);o.add(O),h&&s?.add(O)}},"pushTarget");if(n)for(let p of Ce(e))f(p);else if(r===void 0||a.unparseable)for(let p of pn(e))f(p);if(a.unparseable){if(t<3)for(let p of K(e)){let h=U(p.map(w=>w.value));if(h!==void 0)for(let w of C(h,t+1,n,u,i,s))f(w)}return Array.from(o)}for(let p of a.statements)for(let h of p.stages){if(u!==void 0&&["cd","chdir","set-location","sl"].includes(h.argv[0]?.toLowerCase()??"")){let g=h.argv.filter(Me=>!["/d","-path","-literalpath","--"].includes(Me.toLowerCase())).at(-1);g&&h.argv.length>1&&(u=l(g))}for(let g of h.redirections)g.descriptorDuplication||g.input||f(g.target);let w=h.argv[0]?.toLowerCase();if(!w)continue;if(w==="tee")for(let g of on(h))f(g);else if(Ee.has(w))for(let g of an(h))f(g,ge.has(E(w)));if(!n)for(let g of hn(h))f(g,ge.has(E(w)));let O=t<3?U(h.argv):void 0;if(O!==void 0)for(let g of C(O,t+1,n,u,i,s))f(g)}return Array.from(o)}c(C,"collectBashWriteTargetsAtDepth");function Gn(e,t,n){let r=new Set;return C(e,0,!1,t,n,r).some(i=>Q(i,t,n,r.has(i)))?"[Tool Error] Shell mutation of governed Memory is denied; use the Memory Control Plane.":void 0}c(Gn,"getGovernedMemoryShellWriteDenial");function kn(e,t){if(!Oe(e))return{dangerous:!1};let n=new Set([...We(e),...tn(e)]);for(let r of n)if(!en(r,t))return{dangerous:!0,reason:`Command may modify file outside project: ${r}`};return{dangerous:!1}}c(kn,"getBashOutsideProjectWriteRisk");function Dn(e,t,n,r=n,i){let s=rn(n);if(ne(e,i))return null;if(ie.has(e)){let o=typeof t.path=="string"?t.path:"";return o?we(o,n,r)?null:`[Blocked] Plan mode only allows file modifications in ${s}. Requested path: ${o}`:`[Blocked] Tool '${e}' is not allowed in plan mode unless it targets ${s}.`}if(e==="bash"){let o=t.command??"";if(!Oe(o))return null;let a=We(o);if(a.length===0)return`[Blocked] Plan mode only allows bash write operations when every target is either ${s}. Could not determine a safe target from: ${o.slice(0,80)}${o.length>80?"...":""}`;let u=a.find(l=>!we(l,n,r));return u?`[Blocked] Plan mode only allows bash write operations in ${s}. Blocked target: ${u}`:null}return`[Blocked] Tool '${e}' has side effects and is not permitted in plan mode. Switch to accept-edits or auto mode to use it, or work within ${s}.`}c(Dn,"getPlanModeBlockReason");function Vn(e){return e.mode==="ask"?"plan":e.auto||e.confirmTools&&e.confirmTools.size===0?"auto":(e.confirmTools&&!e.confirmTools.has("write")&&!e.confirmTools.has("edit"),"accept-edits")}c(Vn,"inferPermissionMode");export{ie as a,wn as b,se as c,oe as d,xn as e,ue as f,st as g,_e as h,Ae as i,Tt as j,Ln as k,Z as l,Rn as m,Oe as n,Pt as o,$n as p,Wn as q,Ct as r,K as s,Ce as t,Yt as u,Mn as v,en as w,$e as x,we as y,We as z,Nn as A,Gn as B,kn as C,Dn as D,Vn as E};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{a as M,c as K}from"./chunk-
|
|
2
|
+
import{a as M,c as K}from"./chunk-EZF6ZRCO.js";import{ba as J,g as H,ja as B,ma as V,na as W,pa as Y,r as $,s as E,t as D,v as L,w as F}from"./chunk-4FVCMKG2.js";import{C as U,I as b,P as z,Q as R,R as G,b as A,s as O}from"./chunk-V5RCDBKU.js";import{a as n}from"./chunk-V4WSBIXB.js";function u(e){if(typeof e!="string"||!/^[a-zA-Z0-9_.-]+$/.test(e))throw new Error("Invalid cloud route component.");return e}n(u,"segment");function pe(e){let r,t;switch(e.service){case"gemini":r={service:e.service},t="https://generativelanguage.googleapis.com/v1beta";break;case"vertex":{if(!!e.project!=!!e.location)throw new Error("Vertex requires both project and location, or neither for Express API-key mode.");r={service:e.service,...e.project?{project:u(e.project),location:u(e.location)}:{}},t=`https://${!e.location||e.location==="global"?"aiplatform":`${u(e.location)}-aiplatform`}.googleapis.com/v1/${e.project?`projects/${u(e.project)}/locations/${u(e.location)}/`:""}publishers/google`;break}case"bedrock":{let o=u(e.region);r={service:e.service,region:o},t=`https://bedrock-runtime.${o}.amazonaws.com${o.startsWith("cn-")?".cn":""}`;break}case"azure":{let o=new URL(e.endpoint);if(o.protocol!=="https:"||o.username||o.password||o.search||o.hash||!["/","/openai/v1","/openai/v1/"].includes(o.pathname))throw new Error("Azure requires an HTTPS resource endpoint or /openai/v1 endpoint.");r={service:e.service},t=`${o.origin}/openai/v1`;break}}return{name:e.name,model:e.model,cloud:r,protocol:e.service==="azure"?"openai":e.service==="bedrock"?"bedrock":"google",...e.service==="azure"?{api:"responses"}:{},baseUrl:t,apiKeyEnv:"KODAX_CLOUD_BROKER_ONLY",verifyStrategy:"minimal-message"}}n(pe,"createCloudProviderConfig");function Z(e){let r=e.cloud;if(r!==void 0&&(!r||typeof r!="object"||Array.isArray(r)))throw new Error("Invalid cloud connection metadata.");if(!r){if(e.protocol==="google"||e.protocol==="bedrock")throw new Error("Native Google/Bedrock requires cloud connection metadata.");return}let t=r.service==="vertex"?["service","project","location"]:r.service==="bedrock"?["service","region"]:["service"];if(Object.keys(r).some(i=>!t.includes(i)))throw new Error("Cloud connection metadata cannot contain credentials or unknown fields.");if(r.service!=="azure"&&e.verifyStrategy!==void 0&&!["minimal-message","unsupported"].includes(e.verifyStrategy))throw new Error("Native cloud verification supports minimal-message or unsupported.");let o=new URL(e.baseUrl);if(o.protocol!=="https:"||o.username||o.password||o.search||o.hash||e.oauth)throw new Error("Cloud connections require a non-secret HTTPS endpoint and cannot mix OAuth dialects.");let a=r.service==="azure"?"openai":r.service==="bedrock"?"bedrock":"google";if(!["azure","gemini","vertex","bedrock"].includes(r.service)||e.protocol!==a||(r.service==="azure"?!["responses","chat-completions"].includes(e.api??""):e.api!==void 0))throw new Error("Cloud connection and native protocol do not match.");if(r.service==="bedrock"&&u(r.region),r.service==="vertex"&&!!r.project!=!!r.location)throw new Error("Vertex requires project and location together.");r.service==="vertex"&&(r.project!==void 0&&u(r.project),r.location!==void 0&&u(r.location))}n(Z,"validateCloudProviderConfig");import{createHash as te}from"node:crypto";function oe(e){return te("sha256").update(JSON.stringify(e.type==="tool_use"?[e.type,e.id,e.name,e.input]:e.type==="thinking"?[e.type,e.thinking]:e.type==="text"?[e.type,e.text]:[e.type,e.data])).digest("hex")}n(oe,"googleBlockHash");async function Q(e,r){if(!r)return[{text:J}];let t=await B(e);return"placeholder"in t?[{text:t.placeholder}]:[...t.notice?[{text:t.notice}]:[],{inlineData:{mimeType:t.mediaType,data:t.data}}]}n(Q,"imageParts");async function X(e,r,t=!1){let o=[],a=new Map;for(let i of W(e)){let s=[];if(typeof i.content=="string")s.push({text:i.content});else for(let l of i.content){let p="googlePart"in l?l.googlePart:void 0,m=!!p&&V(p.source,r)&&p.contentHash===oe(l),P=m&&p.thoughtSignature?{thoughtSignature:p.thoughtSignature}:{};switch(l.type){case"text":s.push({text:l.text,...P});break;case"thinking":m?s.push({text:l.thinking,thought:!0,...P}):l.thinking&&s.push({text:`<prior_reasoning>
|
|
3
3
|
${l.thinking}
|
|
4
4
|
</prior_reasoning>`});break;case"tool_use":{a.set(l.id,{block:l,native:m}),s.push(m?{functionCall:{...p.callId?{id:p.callId}:{},name:l.name,args:l.input},...P}:{text:`<prior_tool_call name=${JSON.stringify(l.name)}>
|
|
5
5
|
${JSON.stringify(l.input)}
|