openpond 0.2.68 → 0.2.69
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/dist/app-server.js +1 -1
- package/dist/chunks/account-context-V3KLSNKS.js +12 -0
- package/dist/chunks/{acp-2OIXATRY.js → acp-ER6CUXG2.js} +1 -1
- package/dist/chunks/{acp-agent-PAGX2B47.js → acp-agent-AYJ5RPVF.js} +1 -1
- package/dist/chunks/{actions-command-2VE6YI4W.js → actions-command-BBUS3HDK.js} +1 -1
- package/dist/chunks/{app-layer-YNEUEOEP.js → app-layer-JCEWGUDH.js} +1 -1
- package/dist/chunks/{app-server-connected-apps-TZOAUOYR.js → app-server-connected-apps-ILXBFD3S.js} +1 -1
- package/dist/chunks/{app-server-runtime-GBX65JJ7.js → app-server-runtime-43MCH5SY.js} +1 -1
- package/dist/chunks/{apps-RSFEJOQN.js → apps-VNFGMQFG.js} +1 -1
- package/dist/chunks/{chunk-DWM5G7BU.js → chunk-22RLEU3Q.js} +1 -1
- package/dist/chunks/chunk-7EQLW2KM.js +12 -0
- package/dist/chunks/chunk-BDZDWHBJ.js +6 -0
- package/dist/chunks/{chunk-GEYZVOGD.js → chunk-EWDDDHJN.js} +1 -1
- package/dist/chunks/{chunk-XQAUHXL4.js → chunk-G4FRBT7G.js} +2 -2
- package/dist/chunks/{chunk-FKUWCJ73.js → chunk-LSKMALD6.js} +1 -1
- package/dist/chunks/chunk-M5X7XKXY.js +12 -0
- package/dist/chunks/{chunk-OIH2LPIT.js → chunk-NW6WGGSL.js} +1 -1
- package/dist/chunks/{chunk-JPUSTFZC.js → chunk-NZDLL6JN.js} +1 -1
- package/dist/chunks/{chunk-RBTDSI4L.js → chunk-R6I623SZ.js} +6 -6
- package/dist/chunks/{chunk-MEJLWNRS.js → chunk-RCRZXHAI.js} +1 -1
- package/dist/chunks/{chunk-BHKXPWFB.js → chunk-TB5P3FWM.js} +1 -1
- package/dist/chunks/{chunk-73TW6BKK.js → chunk-Z5CQXPIS.js} +1 -1
- package/dist/chunks/{configuration-command-CNITTZRP.js → configuration-command-C3QBDFND.js} +1 -1
- package/dist/chunks/{connected-app-executor-FGWCLOJO.js → connected-app-executor-LAEAQUJS.js} +1 -1
- package/dist/chunks/{connected-evidence-5VZBYNWN.js → connected-evidence-VKY6O2JW.js} +1 -1
- package/dist/chunks/{connected-starting-assets-KWOFEIE4.js → connected-starting-assets-5LAJ7CZY.js} +1 -1
- package/dist/chunks/{core-commands-BPYXVT7O.js → core-commands-5TNBVR72.js} +1 -1
- package/dist/chunks/{datasets-E5TXSVIY.js → datasets-BIDZJYDC.js} +1 -1
- package/dist/chunks/{desktop-test-FX7DTY4N.js → desktop-test-BY2MS3UL.js} +1 -1
- package/dist/chunks/{evaluation-coordination-KUTZEEPB.js → evaluation-coordination-FXB4DXZA.js} +1 -1
- package/dist/chunks/{experiment-improvements-PQNR5YHN.js → experiment-improvements-JPDLKZXD.js} +1 -1
- package/dist/chunks/{experiments-Z4BJWT3Y.js → experiments-IEN7RXLX.js} +1 -1
- package/dist/chunks/{experiments-signal-3GCLKUWZ.js → experiments-signal-L32D36NH.js} +1 -1
- package/dist/chunks/{help-K6YLZ3KL.js → help-PLQJOP4P.js} +1 -1
- package/dist/chunks/{hosted-app-server-composition-LA3BZ4SE.js → hosted-app-server-composition-GZES7QXJ.js} +1 -1
- package/dist/chunks/{hosted-tasksets-NXVF4AQA.js → hosted-tasksets-V24IBVJX.js} +1 -1
- package/dist/chunks/{human-review-2ZOB7CJZ.js → human-review-6V6EMNVN.js} +1 -1
- package/dist/chunks/{import-YHYKZ6JN.js → import-SI24Z7EF.js} +1 -1
- package/dist/chunks/{opchat-XXI2ZM53.js → opchat-SV67HVMX.js} +1 -1
- package/dist/chunks/{opchat-bounded-chat-3MZGCRLY.js → opchat-bounded-chat-KLMIYSZZ.js} +1 -1
- package/dist/chunks/{organizations-W7HI2JA4.js → organizations-OZZFX7RG.js} +1 -1
- package/dist/chunks/{profile-P2SJPBOJ.js → profile-TD5U3INY.js} +1 -1
- package/dist/chunks/{project-action-payload-LTIQBX77.js → project-action-payload-TK6G4VMC.js} +1 -1
- package/dist/chunks/{project-agent-XRIXMXQK.js → project-agent-FFXPNXCO.js} +1 -1
- package/dist/chunks/sandbox-command-4BCUDAED.js +2 -0
- package/dist/chunks/{sandbox-template-U536EEWY.js → sandbox-template-GOY7QQUY.js} +1 -1
- package/dist/chunks/{saved-work-KSIQPXC2.js → saved-work-M6PUHKCC.js} +1 -1
- package/dist/chunks/{src-SGQYVBNQ.js → src-MT4B43TD.js} +1 -1
- package/dist/chunks/{teams-bot-MPWL2PP4.js → teams-bot-YCUTDDDC.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/sandbox/runtime-handle.d.ts +3 -5
- package/dist/sandbox/sandbox-instance-client.d.ts +11 -5
- package/dist/sandbox/types/billing.d.ts +53 -0
- package/dist/sandbox/types/responses.d.ts +11 -1
- package/dist/sandbox/types/snapshots.d.ts +52 -3
- package/dist/skills/manifest.json +1 -1
- package/docs/command-reference.md +11 -0
- package/package.json +1 -1
- package/dist/chunks/account-context-MWB6HN6I.js +0 -12
- package/dist/chunks/chunk-27JGS3KB.js +0 -12
- package/dist/chunks/chunk-DRTHKWHK.js +0 -6
- package/dist/chunks/chunk-KOC3YJEU.js +0 -12
- package/dist/chunks/sandbox-command-HVA5FJU4.js +0 -2
package/dist/app-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{m as r}from"./chunks/chunk-
|
|
2
|
+
import{m as r}from"./chunks/chunk-G4FRBT7G.js";import"./chunks/chunk-PSY6IRJE.js";import"./chunks/chunk-PKJHN666.js";import"./chunks/chunk-Z33RVGP6.js";import"./chunks/chunk-7PKDJHT6.js";import"./chunks/chunk-65WRWLUD.js";import"./chunks/chunk-LSKMALD6.js";import"./chunks/chunk-B66QCXH2.js";import{b as p}from"./chunks/chunk-PYNW5OFA.js";import"./chunks/chunk-MOXIGLN2.js";import"./chunks/chunk-RHMULF56.js";import"./chunks/chunk-VFH5C6D2.js";import"./chunks/chunk-UOFDKMRU.js";import"./chunks/chunk-AN525SPP.js";import"./chunks/chunk-IZ6DLEVY.js";import"./chunks/chunk-M5X7XKXY.js";import"./chunks/chunk-65FJWWXG.js";import"./chunks/chunk-SYUKES6H.js";import"./chunks/chunk-EYTTZ5H4.js";import"./chunks/chunk-XY7HFXLH.js";import{e}from"./chunks/chunk-6I5AUTVO.js";import"./chunks/chunk-DKOVZ6R2.js";import"./chunks/chunk-N5EAVX4G.js";import"./chunks/chunk-U7X5ZLAL.js";import"./chunks/chunk-7PXZ4X4P.js";import"./chunks/chunk-N73MU2C3.js";import"./chunks/chunk-SO4GMSNP.js";import"./chunks/chunk-NMMHXYDJ.js";import"./chunks/chunk-QLGP2OAQ.js";import"./chunks/chunk-WZ35ICTE.js";import"./chunks/chunk-VS2LOUCT.js";import"./chunks/chunk-DMFUEUAZ.js";import"./chunks/chunk-AFKFN25T.js";import"./chunks/chunk-G4747MOW.js";import"./chunks/chunk-GF55VEMR.js";import"./chunks/chunk-FAKDGLZQ.js";import"./chunks/chunk-KCJVFLBB.js";import"./chunks/chunk-GW766ZSO.js";import"./chunks/chunk-VJYOKU3C.js";import"./chunks/chunk-SSJV3VX7.js";import"./chunks/chunk-7KWD2I6W.js";import"./chunks/chunk-RY46UPBO.js";import"./chunks/chunk-OFJPOTES.js";import"./chunks/chunk-PLROXHG2.js";import"./chunks/chunk-YU3C6U5V.js";import"./chunks/chunk-PHZZBXDO.js";import"./chunks/chunk-KVTBX2UP.js";import"./chunks/chunk-U7D6Q744.js";import"./chunks/chunk-HG2YFMVU.js";import"./chunks/chunk-OQPJ7FJF.js";import"./chunks/chunk-BL3CZWWD.js";import"./chunks/chunk-FYWQWKVS.js";import"./chunks/chunk-GD3RCUDH.js";import"./chunks/chunk-7OKZCJHS.js";import"./chunks/chunk-UTIELP6F.js";import"./chunks/chunk-7NCM6GBN.js";import"./chunks/chunk-4V73I4OL.js";import"./chunks/chunk-LE75SVEL.js";import"./chunks/chunk-6ESBAHWK.js";import"./chunks/chunk-LZPCA6DH.js";import"./chunks/chunk-L3KS6MOV.js";import"./chunks/chunk-7J2NMUTK.js";import"./chunks/chunk-VEBW7NKD.js";import"./chunks/chunk-W45RKGM6.js";import"./chunks/chunk-AUO5DCEU.js";import"./chunks/chunk-Y4I6CFZJ.js";import"./chunks/chunk-4BUM6JEC.js";import"./chunks/chunk-UGFSAG4U.js";import"./chunks/chunk-SSHE6B7Z.js";import"./chunks/chunk-JFXINDOQ.js";import"./chunks/chunk-EDYCSW22.js";import"./chunks/chunk-JT5YQ52I.js";import"./chunks/chunk-XGY4OQLC.js";import"./chunks/chunk-PAYFJHPO.js";import"./chunks/chunk-WD4KAKEX.js";import"./chunks/chunk-2PXKSAG6.js";import"./chunks/chunk-ULTV6INR.js";import"./chunks/chunk-WGQ3FMRF.js";import"./chunks/chunk-JXLDEYRW.js";import"./chunks/chunk-JVMSN7LH.js";import"./chunks/chunk-YI6ME6PU.js";import"./chunks/chunk-DRLP7GIU.js";import"./chunks/chunk-BU6MW65V.js";import"./chunks/chunk-LVXL7T5O.js";import"./chunks/chunk-HIQPGYVH.js";import"./chunks/chunk-DXJC3QW7.js";import"./chunks/chunk-P4QM63L3.js";import"./chunks/chunk-MTP3B2SU.js";import"./chunks/chunk-UN2LKLGV.js";import"./chunks/chunk-2LJCJOJ7.js";import"./chunks/chunk-AMC4Z7G4.js";import"./chunks/chunk-LK77GI6M.js";import"./chunks/chunk-HVM2GUM3.js";import"./chunks/chunk-I6VMRQF4.js";import"./chunks/chunk-D6L6UNUQ.js";import"./chunks/chunk-AJXWJLZA.js";import"./chunks/chunk-OKKNDQJF.js";import"./chunks/chunk-4PUOWSDE.js";import"./chunks/chunk-ZY32SZ2P.js";import"./chunks/chunk-OTDDXEQ6.js";import"./chunks/chunk-ECOH24MC.js";import"./chunks/chunk-4N4EH3RJ.js";import"./chunks/chunk-GY7YSD6J.js";import"./chunks/chunk-KUE46HTH.js";import"./chunks/chunk-JCLTFDVW.js";import"./chunks/chunk-6FA3GG5B.js";import"./chunks/chunk-SV7ZBEK2.js";import"./chunks/chunk-2MEOUS24.js";import"./chunks/chunk-HNQPEOJD.js";import"./chunks/chunk-RCT3O3HQ.js";import"./chunks/chunk-UGOK7VTC.js";import"./chunks/chunk-ZFJWA4JK.js";import"./chunks/chunk-X2J2P5ZT.js";import"./chunks/chunk-FTQLQJQV.js";export{e as AGENT_PROTOCOL_VERSION,r as createOpenPondAppServer,p as runAppServerJsonl};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{a as h,b as y}from"./chunk-KTIBXRWQ.js";import{a as v}from"./chunk-V24VHT76.js";import{b as T,c as L}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{c as $}from"./chunk-3M53YXEI.js";import"./chunk-4N4EH3RJ.js";import"./chunk-GY7YSD6J.js";import"./chunk-KUE46HTH.js";import{a as j,b as l}from"./chunk-GLUWATL5.js";import"./chunk-JCLTFDVW.js";import"./chunk-6FA3GG5B.js";import{v as A}from"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import{f as q}from"./chunk-UGOK7VTC.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import{a as r}from"./chunk-FTQLQJQV.js";function k(o){return{list:r((e={})=>o.listSandboxRuntimes(e),"list"),create:r(e=>o.createSandboxRuntime(e),"create"),handle:r((e,t=null)=>o.sandboxRuntime(e,t),"handle"),get:r(e=>o.getSandboxRuntime(e),"get"),createSandbox:r((e,t={},n={})=>o.createSandboxRuntimeSandbox(e,t,n),"createSandbox"),updateStatus:r((e,t)=>o.updateSandboxRuntimeStatus(e,t),"updateStatus"),events:r(e=>o.listSandboxRuntimeEvents(e),"events"),event:r((e,t)=>o.emitSandboxRuntimeEvent(e,t),"event"),checkpoint:r((e,t={})=>o.checkpointSandboxRuntime(e,t),"checkpoint"),promote:r((e,t,n={})=>o.promoteSandboxRuntime(e,t,n),"promote"),preserveSource:r((e,t={},n={})=>o.preserveSandboxRuntimeSource(e,t,n),"preserveSource")}}r(k,"createSandboxRuntimeNamespace");function E(o){return{list:r((e={})=>o.list(e),"list"),create:r(e=>o.create(e),"create"),get:r(e=>o.get(e),"get"),pricing:r(()=>o.pricing(),"pricing"),costs:r((e={})=>o.costs(e),"costs")}}r(E,"createSandboxNamespace");function F(o){return{list:r(e=>o.listProjects(e),"list"),upsert:r(e=>o.upsertProject(e),"upsert"),upsertGitRemote:r(e=>o.upsertProjectGitRemote(e),"upsertGitRemote"),get:r((e,t)=>o.getProject(e,t),"get"),update:r((e,t)=>o.updateProject(e,t),"update"),sync:r((e,t)=>o.syncProject(e,t),"sync"),ensureGitRemote:r((e,t)=>o.ensureProjectGitRemote(e,t),"ensureGitRemote"),getGitRemote:r((e,t)=>o.ensureProjectGitRemote(e,t),"getGitRemote"),git:r((e,t)=>o.ensureProjectGitRemote(e,t),"git"),uploadSource:r((e,t)=>o.uploadProjectSource(e,t),"uploadSource"),archive:r((e,t)=>o.archiveProject(e,t),"archive")}}r(F,"createSandboxProjectNamespace");function B(o){return{get:r(e=>o.getHostedProfile(e),"get"),status:r(e=>o.getHostedProfile(e),"status"),ensureHosted:r(e=>o.ensureHostedProfile(e),"ensureHosted"),push:r(e=>o.pushHostedProfile(e),"push")}}r(B,"createSandboxProfileNamespace");function M(o){return{list:r(e=>o.listAgents(e),"list"),upsert:r(e=>o.upsertAgent(e),"upsert"),get:r((e,t)=>o.getAgent(e,t),"get"),update:r((e,t)=>o.updateAgent(e,t),"update"),archive:r((e,t)=>o.archiveAgent(e,t),"archive"),run:r((e,t)=>o.runAgent(e,t),"run"),sourceDeployPlan:r((e,t)=>o.getAgentSourceDeployPlan(e,t),"sourceDeployPlan"),manifestSnapshots:r((e,t)=>o.listAgentManifestSnapshots(e,t),"manifestSnapshots"),requestSourceChecks:r((e,t)=>o.requestAgentSourceChecks(e,t),"requestSourceChecks"),configureSourceSetup:r((e,t)=>o.configureAgentSourceSetup(e,t),"configureSourceSetup"),publishSource:r((e,t)=>o.publishAgentSource(e,t),"publishSource")}}r(M,"createSandboxAgentNamespace");function z(o,e,t=null){let n=r(async(a={},d={})=>{let b=await o.getSandboxRuntime(e);return b.sandboxId?o.get(b.sandboxId):o.createSandboxRuntimeSandbox(e,a,d).then(p=>p.sandbox)},"currentSandbox"),s=r(async(a={},d={})=>{let b=await o.getSandboxRuntime(e);if(!b.sandboxId)return o.createSandboxRuntimeSandbox(e,a,d).then(m=>m.sandbox);let p=await o.get(b.sandboxId);return p.state==="stopped"?o.start(p.id,d).then(m=>m.sandbox):p.state==="archived"?o.restore(p.id).then(m=>m.sandbox):p.state==="deleted"||p.state==="error"?o.createSandboxRuntimeSandbox(e,a,d).then(m=>m.sandbox):p},"resume");return{id:e,initial:t,get:r(()=>o.getSandboxRuntime(e),"get"),sandbox:n,resume:s,createSandbox:r((a={},d={})=>o.createSandboxRuntimeSandbox(e,a,d),"createSandbox"),status:r(async a=>{if(typeof a!="string")return o.updateSandboxRuntimeStatus(e,a);let d=await o.getSandboxRuntime(e);return o.updateSandboxRuntimeStatus(e,{status:a,expectedVersion:d.version})},"status"),events:r(()=>o.listSandboxRuntimeEvents(e),"events"),event:r(a=>o.emitSandboxRuntimeEvent(e,a),"event"),recordCommit:r((a,d={})=>o.emitSandboxRuntimeEvent(e,{...d,type:d.type??"git.commit",commitSha:a}),"recordCommit"),checkpointHint:r((a={})=>o.emitSandboxRuntimeEvent(e,{type:"workflow.checkpoint_hint",summary:a.summary??a.reason??"Workflow checkpoint hint",payload:{...a.payload,reason:a.reason??null},artifactRefs:a.artifactRefs,lifecycleHint:{kind:"checkpoint",reason:a.reason??null}}),"checkpointHint"),waitForUser:r(async(a={})=>{await o.emitSandboxRuntimeEvent(e,{type:"workflow.waiting_for_user",summary:a.summary??a.reason??"Waiting for user",payload:{...a.payload,reason:a.reason??null},lifecycleHint:{kind:"waiting_for_user",reason:a.reason??null}});let d=await o.getSandboxRuntime(e);return d.status==="waiting_for_user"?d:o.updateSandboxRuntimeStatus(e,{status:"waiting_for_user",expectedVersion:d.version,summary:a.summary??a.reason,metadata:{workflowWaitForUserReason:a.reason??null}})},"waitForUser"),keepAlive:r((a={})=>{let d=X(a);return o.emitSandboxRuntimeEvent(e,{type:"workflow.keepalive",summary:a.summary??a.reason??"Workflow keepalive",payload:{...a.payload,reason:a.reason??null,keepaliveUntil:d},lifecycleHint:{kind:"keepalive",reason:a.reason??null,keepaliveUntil:d}})},"keepAlive"),checkpoint:r(a=>o.checkpointSandboxRuntime(e,a),"checkpoint"),files:{write:r(async(a,d)=>o.uploadFile((await s()).id,a,d),"write"),read:r(async a=>o.downloadFile((await s()).id,a),"read"),readResponse:r(async a=>o.downloadFileResponse((await s()).id,a),"readResponse"),list:r(async(a={})=>o.listFiles((await s()).id,a),"list"),delete:r(async(a,d={})=>o.deleteFile((await s()).id,a,d),"delete"),search:r(async a=>o.searchFiles((await s()).id,a),"search"),stat:r(async a=>o.statFile((await s()).id,a),"stat"),mkdir:r(async a=>o.mkdir((await s()).id,a),"mkdir"),move:r(async a=>o.moveFile((await s()).id,a),"move")},commands:{run:r(async a=>o.exec((await s()).id,typeof a=="string"?{command:a}:a),"run")},ports:{expose:r(async a=>o.openPort((await s()).id,typeof a=="number"?{port:a}:a),"expose")},promote:r((a,d={})=>o.promoteSandboxRuntime(e,a,d),"promote"),preserveSource:r((a={},d={})=>o.preserveSandboxRuntimeSource(e,a,d),"preserveSource"),archive:r(async a=>{let d=a??(await o.getSandboxRuntime(e)).version;return o.updateSandboxRuntimeStatus(e,{status:"archived",expectedVersion:d})},"archive")}}r(z,"createSandboxRuntimeHandle");function X(o){if(o?.until instanceof Date)return o.until.toISOString();if(typeof o?.until=="string"&&o.until.trim())return new Date(o.until).toISOString();let e=typeof o?.seconds=="number"&&Number.isFinite(o.seconds)?Math.max(1,Math.trunc(o.seconds)):60;return new Date(Date.now()+e*1e3).toISOString()}r(X,"runtimeKeepaliveUntilIso");async function J(o,e={}){let t=`openpond-code-smoke-${Date.now()}`,n=`openpond-code-exec-ok:${t}`,s=`openpond-code-preview-ok:${t}`,i=`openpond-code-file-ok:${t}`,u=4173,S=null,a=null,d=!1,b=!1;try{let p=await D(o,await o.create({repo:e.repo??"https://github.com/octocat/Hello-World",resources:{cpu:e.cpu??1,memoryGb:e.memoryGb??1,diskGb:e.diskGb??8},budget:{maxUsd:e.budgetUsd??"0.05"},quotas:{maxSpendUsd:e.budgetUsd??"0.05",maxDurationSeconds:600,idleTimeoutSeconds:600,maxOpenPorts:2},metadata:{runId:t,source:"openpond-code-sandbox-smoke"}},{async:!0}));S=p.id;let m=e.expectedMppMode;if(m&&p.reservation.mpp?.mode!==m)throw new Error(`expected ${m} reservation, got ${p.reservation.mpp?.mode??"none"}`);if(!m&&!p.reservation.mpp?.mode)throw new Error("expected sandbox reservation MPP metadata");let P=await o.exec(p.id,{command:[`printf '${n}\\n'`,"test -f README && printf 'repo-clone-ok\\n'","cat > server.cjs <<'EOF'","const { createServer } = require('node:http');",`createServer((_request, response) => response.end('${s}')).listen(${u}, '0.0.0.0');`,"EOF","nohup node server.cjs > server.log 2>&1 & sleep 1"].join(`
|
|
3
|
+
`),timeoutSeconds:120});if(P.command.status!=="succeeded")throw new Error(`expected command success, got ${P.command.status}`);if(!P.command.output.includes(n))throw new Error("expected exec marker");if(await o.uploadFile(p.id,"openpond-code-smoke.txt",i),await o.downloadFile(p.id,"openpond-code-smoke.txt")!==i)throw new Error("expected file roundtrip marker");let x=null;if(e.snapshot||e.fork){let R=await o.createSnapshot(p.id,{async:!0,name:`openpond-code-smoke-${t}`,replay:{entrypoints:[{command:"cat openpond-code-smoke.txt",name:"default"}],retention:{class:"pinned"},safety:{cleanup:"delete",idleTimeoutSeconds:600,internetEgress:"block",maxDurationSeconds:600,maxSpendUsd:e.budgetUsd??"0.05",publicPreview:!1},validation:{commands:[{command:"test -f openpond-code-smoke.txt"}]}}}),{snapshot:c}=await te(o,p.id,R.snapshotJob.snapshotId);if(x=c.id,c.state!=="ready")throw new Error(`expected ready snapshot, got ${c.state}`)}if(e.fork){if(!x)throw new Error("expected snapshot id before fork");let R=await D(o,(await o.forkSnapshot(x,{budget:{maxUsd:e.budgetUsd??"0.05"},metadata:{source:"openpond-code-sandbox-smoke-fork",templateSnapshotId:x}},{async:!0})).sandbox);a=R.id;let c=await o.exec(R.id,{command:"cat openpond-code-smoke.txt",timeoutSeconds:120});if(c.command.status!=="succeeded")throw new Error(`expected fork command success, got ${c.command.status}`);if(!c.command.output.includes(i))throw new Error("expected fork snapshot marker");e.keep||(await O(o,R.id),b=!0)}let C=null;if(e.preview!==!1){let R=await o.openPort(p.id,{label:"openpond-code-smoke",port:u}),c=await fetch(R.preview.url);C=c.status;let Q=await c.text();if(c.status!==200)throw new Error(`expected preview HTTP 200, got ${c.status}`);if(!Q.includes(s))throw new Error("expected preview marker")}let{sandbox:V,receipts:Y}=await Z(o,p.id);return e.keep||(await O(o,p.id),d=!0),{deleted:d,execOutput:P.command.output.trim(),fileRoundtrip:!0,forkSandboxId:a,previewStatus:C,receiptRefs:Y.map(R=>R.mpp.receiptRef??null),reservationRef:p.reservation.mpp?.reservationRef??null,runId:t,sandboxId:p.id,snapshotId:x,state:V.state}}finally{a&&!e.keep&&!b&&await N(o,a),S&&!e.keep&&!d&&await N(o,S)}}r(J,"runSandboxSmoke");async function Z(o,e){try{await o.stop(e)}catch{await o.stop(e,{async:!0})}let t=await _(o,e,new Set(["stopped","deleted"]),"stop"),n=await ee(o,e);if(n.length===0)throw new Error("expected receipt readback");return{sandbox:t,receipts:n}}r(Z,"stopSandboxForSmoke");async function O(o,e){try{let t=await o.delete(e);if(t.state==="deleted")return t;await o.delete(e,{async:!0})}catch{await o.delete(e,{async:!0})}return _(o,e,new Set(["deleted"]),"delete")}r(O,"deleteSandboxForSmoke");async function N(o,e){try{await O(o,e)}catch{await o.delete(e,{async:!0}).catch(()=>{})}}r(N,"cleanupSandboxBestEffort");async function _(o,e,t,n){let u=Date.now()+3e5,S=await o.get(e);for(;Date.now()<u;){if(t.has(S.state))return S;if(S.state==="error")throw new Error(`sandbox ${n} failed: ${e}`);await I(3e3),S=await o.get(e)}throw new Error(`sandbox ${n} did not reach ${[...t].join("/")} before timeout: ${e} (${S.state})`)}r(_,"waitForSandboxState");async function ee(o,e){let s=Date.now()+12e4,i=await o.receipts(e);for(;Date.now()<s;){if(i.length>0)return i;await I(3e3),i=await o.receipts(e)}return i}r(ee,"waitForReceipts");async function D(o,e){if(e.state==="running"||e.state==="stopped")return e;if(e.state==="error")throw new Error(`sandbox create failed: ${e.id}
|
|
4
|
+
${e.logs.join(`
|
|
5
|
+
`)}`);let t=12*6e4,n=3e3,s=Date.now()+t,i=e;for(;Date.now()<s;){if(await I(n),i=await o.get(e.id),i.state==="running"||i.state==="stopped")return i;if(i.state==="error")throw new Error(`sandbox create failed: ${i.id}
|
|
6
|
+
${i.logs.join(`
|
|
7
|
+
`)}`)}throw new Error(`sandbox create did not reach running state before timeout: ${i.id} (${i.state})`)}r(D,"waitForCreateReady");async function te(o,e,t){if(!t)throw new Error("snapshot job did not return snapshot id");let n=12*6e4,s=3e3,i=Date.now()+n,u=await o.get(e);for(;Date.now()<i;){let S=u.snapshots?.find(d=>d.id===t);if(S?.state==="ready")return{sandbox:u,snapshot:S};let a=u.snapshotJobs?.find(d=>d.snapshotId===t);if(a?.status==="failed")throw new Error(`snapshot job failed: ${a.error??t}`);await I(s),u=await o.get(e)}throw new Error(`snapshot did not reach ready state before timeout: ${t}`)}r(te,"waitForSnapshotReady");function I(o){return new Promise(e=>setTimeout(e,o))}r(I,"sleep");function g(o={}){return o.async||o.respondAsync?{Prefer:"respond-async"}:void 0}r(g,"asyncRequestHeaders");async function w(o){let e=await h(o.sandboxApiUrl,o.apiKey,o.path,{timeoutMs:0,maxResponseBytes:0});if(!e.body)return;let t=e.body.getReader(),n=new TextDecoder,s="";try{for(;;){let{done:i,value:u}=await t.read();if(i)break;s+=n.decode(u,{stream:!0});let S=s.indexOf(`
|
|
8
|
+
|
|
9
|
+
`);for(;S!==-1;){let a=s.slice(0,S);s=s.slice(S+2);let d=ne(a);d&&process.stdout.write(d),S=s.indexOf(`
|
|
10
|
+
|
|
11
|
+
`)}}}finally{t.releaseLock()}}r(w,"streamSandboxEventOutput");function H(o){return typeof o=="string"?{dataBase64:Buffer.from(o,"utf-8").toString("base64")}:o instanceof Uint8Array?{dataBase64:Buffer.from(o).toString("base64")}:o}r(H,"normalizePtyInput");function ne(o){if(!o.includes("event: output"))return null;let e=o.split(/\r?\n/).filter(t=>t.startsWith("data: ")).map(t=>t.slice(6));if(e.length===0)return null;try{let t=JSON.parse(e.join(`
|
|
12
|
+
`));return typeof t.output=="string"?t.output:null}catch{return null}}r(ne,"parseProcessOutputEvent");function G(o,e={}){let t=o.trim().replace(/\/$/,"");if(!t)throw new Error("sandbox API URL must be non-empty");let n=new URL(t),s=n.pathname.replace(/\/$/,"");if(s.endsWith("/v1/sandboxes")||s.endsWith("/api/sandboxes"))return`${n.origin}${s}`;if(s.endsWith("/v1"))return`${n.origin}${s}/sandboxes`;if(n.origin===j)return`${l}/v1/sandboxes`;let i=e.apiBaseUrl?new URL(e.apiBaseUrl).origin:l;return n.origin===i?`${n.origin}${s}/v1/sandboxes`:`${n.origin}${s}/api/sandboxes`}r(G,"normalizeSandboxApiUrl");function K(o){let e="/sandboxes";if(!o.endsWith(e))throw new Error("sandbox API URL must end with /sandboxes");return o.slice(0,-e.length)}r(K,"apiRootUrlFromSandboxApiUrl");var f=class{static{r(this,"OpenPondSandboxInstanceClient")}apiKey;apiRootUrl;sandboxApiUrl;customEndpoint;constructor(e){this.apiKey=e.apiKey,this.customEndpoint=e.customEndpoint??!1;let t=e.sandboxApiUrl??e.baseUrl??l;this.sandboxApiUrl=G(t,{apiBaseUrl:this.customEndpoint?void 0:t}),this.apiRootUrl=K(this.sandboxApiUrl)}create(e,t={}){return this.request("",{method:"POST",...this.customEndpoint?{timeoutMs:18e4}:{},headers:g(t),body:JSON.stringify(e)}).then(n=>n.sandbox)}get(e){return this.request(`/${encodeURIComponent(e)}`).then(t=>t.sandbox)}exec(e,t){return this.request(`/${encodeURIComponent(e)}/exec`,{method:"POST",body:JSON.stringify(t)})}startProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes`,{method:"POST",body:JSON.stringify(t)})}listProcesses(e){return this.request(`/${encodeURIComponent(e)}/processes`)}getProcess(e,t,n={}){let s=new URLSearchParams;return n.since!==void 0&&s.set("since",String(Math.max(0,n.since))),this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}stopProcess(e,t){return this.request(`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamProcessOutput(e,t,n={}){let s=new URLSearchParams;n.since!==void 0&&s.set("since",String(Math.max(0,n.since))),await w({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}startPty(e,t={}){return this.request(`/${encodeURIComponent(e)}/pty`,{method:"POST",body:JSON.stringify(t)})}listPtys(e){return this.request(`/${encodeURIComponent(e)}/pty`)}getPty(e,t,n={}){let s=new URLSearchParams;return n.since!==void 0&&s.set("since",String(Math.max(0,n.since))),this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}${s.size>0?`?${s.toString()}`:""}`)}writePtyInput(e,t,n){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/input`,{method:"POST",body:JSON.stringify(H(n))})}stopPty(e,t){return this.request(`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}`,{method:"DELETE"})}async streamPtyOutput(e,t,n={}){let s=new URLSearchParams;n.since!==void 0&&s.set("since",String(Math.max(0,n.since))),await w({sandboxApiUrl:this.sandboxApiUrl,apiKey:this.apiKey,path:`/${encodeURIComponent(e)}/pty/${encodeURIComponent(t)}/stream${s.size>0?`?${s.toString()}`:""}`})}uploadFile(e,t,n){return this.uploadFileBase64(e,t,Buffer.from(n,"utf-8").toString("base64"))}uploadFileBase64(e,t,n){return this.request(`/${encodeURIComponent(e)}/files`,{method:"POST",body:JSON.stringify({path:t,contentsBase64:n})})}async downloadFile(e,t){let n=await this.downloadFileResponse(e,t);return Buffer.from(n.file.contentsBase64,"base64").toString("utf-8")}downloadFileResponse(e,t){let n=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:n.path});return n.offsetBytes!==void 0&&s.set("offsetBytes",String(n.offsetBytes)),n.maxBytes!==void 0&&s.set("maxBytes",String(n.maxBytes)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`)}listFiles(e,t={}){let n=new URLSearchParams({list:"1"});return t.path&&n.set("path",t.path),t.recursive!==void 0&&n.set("recursive",String(t.recursive)),t.maxEntries!==void 0&&n.set("maxEntries",String(t.maxEntries)),this.request(`/${encodeURIComponent(e)}/files?${n.toString()}`)}deleteFile(e,t,n={}){let s=new URLSearchParams({path:t});return n.recursive!==void 0&&s.set("recursive",String(n.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"DELETE"})}statFile(e,t){let n=new URLSearchParams({stat:"1",path:t});return this.request(`/${encodeURIComponent(e)}/files?${n.toString()}`)}mkdir(e,t){let n=typeof t=="string"?{path:t}:t,s=new URLSearchParams({path:n.path});return n.recursive!==void 0&&s.set("recursive",String(n.recursive)),this.request(`/${encodeURIComponent(e)}/files?${s.toString()}`,{method:"PUT"})}moveFile(e,t){let n=new URLSearchParams({fromPath:t.fromPath,toPath:t.toPath});return t.overwrite!==void 0&&n.set("overwrite",String(t.overwrite)),this.request(`/${encodeURIComponent(e)}/files?${n.toString()}`,{method:"PATCH"})}searchFiles(e,t){let n=new URLSearchParams({search:"1",query:t.query});return t.path&&n.set("path",t.path),t.maxResults!==void 0&&n.set("maxResults",String(t.maxResults)),this.request(`/${encodeURIComponent(e)}/files?${n.toString()}`)}openPort(e,t){return this.request(`/${encodeURIComponent(e)}/ports`,{method:"POST",body:JSON.stringify(t)})}createSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots`,{method:"POST",body:JSON.stringify(t)})}updateSnapshot(e,t,n){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}validateSnapshot(e,t,n={}){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/validate`,{method:"POST",body:JSON.stringify(n)})}publishSnapshot(e,t){return this.request(`/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}/publish`,{method:"POST"})}fork(e,t={}){return this.request(`/${encodeURIComponent(e)}/fork`,{method:"POST",body:JSON.stringify(t)})}stop(e,t={}){let n=new URLSearchParams;return t.failOnUnpreservedChanges&&n.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}/stop${n.size>0?`?${n.toString()}`:""}`,{method:"POST",headers:g(t)})}start(e,t={}){return this.request(`/${encodeURIComponent(e)}/start`,{method:"POST",headers:g(t),...t.restore?{body:JSON.stringify({restore:t.restore})}:{}})}restore(e,t){return this.request(`/${encodeURIComponent(e)}/restore`,{method:"POST",...t?{body:JSON.stringify(t)}:{}})}delete(e,t={}){let n=new URLSearchParams;return t.failOnUnpreservedChanges&&n.set("failOnUnpreservedChanges","true"),this.request(`/${encodeURIComponent(e)}${n.size>0?`?${n.toString()}`:""}`,{method:"DELETE",headers:g(t)}).then(s=>s.sandbox)}receipts(e){return this.request(`/${encodeURIComponent(e)}/receipts`).then(t=>t.receipts)}logs(e){return this.request(`/${encodeURIComponent(e)}/logs`).then(t=>t.logs)}gitStatus(e){return this.request(`/${encodeURIComponent(e)}/git/status`)}gitDiff(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/diff`,{method:"POST",body:JSON.stringify(t)})}gitExportPatch(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/export-patch`,{method:"POST",body:JSON.stringify(t)})}gitBranch(e,t){return this.request(`/${encodeURIComponent(e)}/git/branch`,{method:"POST",body:JSON.stringify(t)})}gitCommit(e,t){return this.request(`/${encodeURIComponent(e)}/git/commit`,{method:"POST",body:JSON.stringify(t)})}gitPull(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/pull`,{method:"POST",body:JSON.stringify(t)})}gitPush(e,t={}){return this.request(`/${encodeURIComponent(e)}/git/push`,{method:"POST",body:JSON.stringify(t)})}billing(e,t){let n=new URLSearchParams;return t&&(n.set("snapshotRetentionTtlSeconds",String(t.snapshotRetentionTtlSeconds)),n.set("snapshotRetentionClass",t.snapshotRetentionClass)),this.request(`/${encodeURIComponent(e)}/billing${n.size?`?${n}`:""}`)}pricing(){return this.request("/pricing")}costs(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(`/costs${t.size>0?`?${t.toString()}`:""}`)}integrationLeases(e){return this.request(`/${encodeURIComponent(e)}/integrations`)}attachIntegrationConnection(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"POST",body:JSON.stringify(t)})}removeIntegrationLease(e,t){return this.request(`/${encodeURIComponent(e)}/integrations`,{method:"DELETE",body:JSON.stringify({leaseId:t})})}async request(e,t={}){let n=await h(this.sandboxApiUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return y(n,"Sandbox request")}async requestApiRoot(e,t={}){let n=await h(this.apiRootUrl,this.apiKey,e,this.customEndpoint?{...t,explicitBearerAuth:!0,redirect:"error"}:t);return y(n,"OpenPond API request")}};var U=class extends f{static{r(this,"OpenPondSandboxClient")}runtimes=k(this);sandboxes=E(this);profile=B(this);projects=F(this);agents=M(this);list(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.request(t.size>0?`?${t.toString()}`:"").then(n=>n.sandboxes)}listSecrets(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),this.requestApiRoot(`/sandbox-secrets${t.size>0?`?${t.toString()}`:""}`).then(n=>n.secrets)}getSecret(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${n.size>0?`?${n.toString()}`:""}`).then(s=>s.secret)}createSecret(e){return this.requestApiRoot("/sandbox-secrets",{method:"POST",body:JSON.stringify(e)}).then(t=>t.secret)}rotateSecret(e,t){let n=new URLSearchParams;t.teamId&&n.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/rotate${n.size>0?`?${n.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(u=>u.secret)}attachSecret(e,t){let n=new URLSearchParams;t.teamId&&n.set("teamId",t.teamId);let{teamId:s,...i}=t;return this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/attach${n.size>0?`?${n.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(u=>u.secret)}revokeSecret(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}/revoke${n.size>0?`?${n.toString()}`:""}`,{method:"POST"}).then(s=>s.secret)}deleteSecret(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),this.requestApiRoot(`/sandbox-secrets/${encodeURIComponent(e)}${n.size>0?`?${n.toString()}`:""}`,{method:"DELETE"}).then(s=>s.secret)}snapshotCatalog(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.q&&t.set("q",e.q),e.kind&&t.set("kind",e.kind),e.replayState&&t.set("replayState",e.replayState),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/catalog/snapshots${t.size>0?`?${t.toString()}`:""}`)}listSandboxRuntimes(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),this.requestApiRoot(`/runtimes${t.size>0?`?${t.toString()}`:""}`).then(n=>n.runtimes)}listProjects(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`).then(n=>n.projects)}upsertProject(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/projects?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(n=>n.project)}getHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile?${t.toString()}`).then(n=>n.profile)}ensureHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/profile/ensure?${t.toString()}`,{method:"POST"}).then(n=>{if(!n.profile)throw new Error("hosted_profile_missing");return n.profile})}pushHostedProfile(e){let t=new URLSearchParams({teamId:e.teamId}),{teamId:n,...s}=e;return this.requestApiRoot(`/profile/push?${t.toString()}`,{method:"POST",body:JSON.stringify(s)})}async upsertProjectGitRemote(e){let t=await this.upsertProject(e);return this.ensureProjectGitRemote(t.id,{teamId:e.teamId})}getProject(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${n.toString()}`).then(s=>s.project)}syncProject(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/sync?${n.toString()}`,{method:"POST"}).then(s=>s.project)}ensureProjectGitRemote(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/git?${n.toString()}`,{method:"POST"})}uploadProjectSource(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}/source?${n.toString()}`,{method:"POST",body:JSON.stringify(i)}).then(u=>u.project)}updateProject(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${n.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(u=>u.project)}archiveProject(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/projects/${encodeURIComponent(e)}?${n.toString()}`,{method:"DELETE"}).then(s=>s.project)}listAgents(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`).then(n=>n.agents)}upsertAgent(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/agents?${t.toString()}`,{method:"POST",body:JSON.stringify(e)}).then(n=>n.agent)}getAgent(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${n.toString()}`).then(s=>s.agent)}archiveAgent(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${n.toString()}`,{method:"DELETE"}).then(s=>s.agent)}updateAgent(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}?${n.toString()}`,{method:"PATCH",body:JSON.stringify(i)}).then(u=>u.agent)}runAgent(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/run?${n.toString()}`,{method:"POST",headers:{Prefer:"respond-async"},body:JSON.stringify(i)})}getAgentSourceDeployPlan(e,t){let n=new URLSearchParams({teamId:t.teamId});return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/deploy-plan?${n.toString()}`).then(s=>s.deployPlan)}listAgentManifestSnapshots(e,t){let n=new URLSearchParams({teamId:t.teamId});return t.limit!==void 0&&n.set("limit",String(t.limit)),this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/manifest-snapshots?${n.toString()}`).then(s=>s.manifestSnapshots)}requestAgentSourceChecks(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/checks?${n.toString()}`,{method:"POST",body:JSON.stringify(i),timeoutMs:900*1e3})}configureAgentSourceSetup(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/setup?${n.toString()}`,{method:"POST",body:JSON.stringify(i)})}publishAgentSource(e,t){let n=new URLSearchParams({teamId:t.teamId}),{teamId:s,...i}=t;return this.requestApiRoot(`/agents/${encodeURIComponent(e)}/source/publish?${n.toString()}`,{method:"POST",body:JSON.stringify(i)})}getMicrosoftTeamsBotOverview(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/teams/bot/overview?${t.toString()}`)}bindMicrosoftTeamsBotConversation(e){return this.requestApiRoot("/teams/bot/bindings",{method:"POST",body:JSON.stringify(e)})}rebindMicrosoftTeamsBotConversation(e,t){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}unlinkMicrosoftTeamsBotConversation(e){return this.requestApiRoot(`/teams/bot/bindings/${encodeURIComponent(e.bindingId)}`,{method:"DELETE",body:JSON.stringify({teamId:e.teamId})})}sendMicrosoftTeamsBotDiagnostic(e){return this.requestApiRoot("/teams/bot/diagnostics",{method:"POST",body:JSON.stringify(e)})}sendMicrosoftTeamsBotDiagnosticRun(e){return this.requestApiRoot("/teams/bot/diagnostics/run",{method:"POST",body:JSON.stringify(e)})}createSandboxRuntime(e){return this.requestApiRoot("/runtimes",{method:"POST",body:JSON.stringify(e)}).then(t=>t.runtime)}sandboxRuntime(e,t=null){return z(this,e,t)}getSandboxRuntime(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}`).then(t=>t.runtime)}createSandboxRuntimeSandbox(e,t={},n={}){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/sandbox`,{method:"POST",headers:g(n),body:JSON.stringify(t)})}updateSandboxRuntimeStatus(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/status`,{method:"PATCH",body:JSON.stringify(t)}).then(n=>n.runtime)}listSandboxRuntimeEvents(e){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`)}emitSandboxRuntimeEvent(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/events`,{method:"POST",body:JSON.stringify(t)})}checkpointSandboxRuntime(e,t){return this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/checkpoints`,{method:"POST",body:JSON.stringify(t)}).then(n=>n.runtime)}promoteSandboxRuntime(e,t,n={}){let s=new URLSearchParams;return n.teamId&&s.set("teamId",n.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/promote${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}preserveSandboxRuntimeSource(e,t={},n={}){let s=new URLSearchParams;return n.teamId&&s.set("teamId",n.teamId),this.requestApiRoot(`/runtimes/${encodeURIComponent(e)}/preserve-source${s.size>0?`?${s.toString()}`:""}`,{method:"POST",body:JSON.stringify(t)})}forkSnapshot(e,t={},n={}){let s=new URLSearchParams;t.teamId&&s.set("teamId",t.teamId),t.projectId&&s.set("projectId",t.projectId),n.async&&s.set("async","1");let{teamId:i,projectId:u,...S}=t;return this.request(`/catalog/snapshots/${encodeURIComponent(e)}/fork${s.size>0?`?${s.toString()}`:""}`,{method:"POST",headers:n.async?{Prefer:"respond-async"}:void 0,body:JSON.stringify({...S,snapshotId:e})})}templates(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/templates${t.size>0?`?${t.toString()}`:""}`)}publishedSnapshots(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.q&&t.set("q",e.q),e.name&&t.set("name",e.name),e.version&&t.set("version",e.version),e.visibility&&t.set("visibility",e.visibility),e.tag&&t.set("tag",e.tag),e.useCase&&t.set("useCase",e.useCase),e.limit&&t.set("limit",String(e.limit)),this.request(`/published-snapshots${t.size>0?`?${t.toString()}`:""}`).then(n=>{let s=n.publishedSnapshots??n.templates;return{...n,templates:s,publishedSnapshots:s}})}launchTemplate(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:n,projectId:s,...i}=e;return this.request(`/templates/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}runPublishedSnapshot(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:n,projectId:s,...i}=e;return this.request(`/published-snapshots/launch${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)}).then(u=>{let S=u.publishedSnapshot??u.template;return{...u,template:S,publishedSnapshot:S}})}listSchedules(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.sourceSandboxId&&t.set("sourceSandboxId",e.sourceSandboxId),this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`)}createSchedule(e){let t=new URLSearchParams;e.projectId&&t.set("projectId",e.projectId);let{projectId:n,...s}=e;return this.request(`/schedules${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(s)})}getSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`)}updateSchedule(e,t){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}deleteSchedule(e){return this.request(`/schedules/${encodeURIComponent(e)}`,{method:"DELETE"})}listScheduleRuns(e,t={}){let n=new URLSearchParams;return t.limit!==void 0&&n.set("limit",String(t.limit)),this.request(`/schedules/${encodeURIComponent(e)}/runs${n.size>0?`?${n.toString()}`:""}`)}runScheduleNow(e,t={}){return this.request(`/schedules/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t)})}listTemplateBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/sandbox-template-builds?${t.toString()}`).then(n=>n.builds)}createTemplateBuild(e){return this.requestApiRoot("/sandbox-template-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getTemplateBuildLogs(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/logs`)}cancelTemplateBuild(e){return this.requestApiRoot(`/sandbox-template-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listPublishedSnapshotBuilds(e){let t=new URLSearchParams({teamId:e.teamId});return this.requestApiRoot(`/published-snapshot-builds?${t.toString()}`).then(n=>n.builds)}createPublishedSnapshotBuild(e){return this.requestApiRoot("/published-snapshot-builds",{method:"POST",body:JSON.stringify(e)}).then(t=>t.build)}getPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}`).then(t=>t.build)}getPublishedSnapshotBuildLogs(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/logs`)}cancelPublishedSnapshotBuild(e){return this.requestApiRoot(`/published-snapshot-builds/${encodeURIComponent(e)}/cancel`,{method:"POST"}).then(t=>t.build)}listOrganizations(){return this.requestApiRoot("/organizations").then(e=>e.organizations??e.teams??[])}createOrganization(e){return this.requestApiRoot("/organizations",{method:"POST",body:JSON.stringify(e)}).then(t=>t.organization)}getOrganization(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`).then(t=>t.organization)}updateOrganization(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)}).then(n=>n.organization)}listOrganizationMembers(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`).then(t=>t.members)}upsertOrganizationMember(e,t){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/members`,{method:"POST",body:JSON.stringify(t)}).then(n=>n.member)}getOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`).then(t=>t.mcpServer)}generateOrganizationMcpServer(e,t={}){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server`,{method:"POST",body:JSON.stringify(t)}).then(n=>n.mcpServer)}rotateOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/rotate`,{method:"POST"}).then(t=>t.mcpServer)}disableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/disable`,{method:"POST"}).then(t=>t.mcpServer)}enableOrganizationMcpServer(e){return this.requestApiRoot(`/organizations/${encodeURIComponent(e)}/mcp-server/enable`,{method:"POST"}).then(t=>t.mcpServer)}startReplay(e){let t=new URLSearchParams;e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId);let{teamId:n,projectId:s,...i}=e;return this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`,{method:"POST",body:JSON.stringify(i)})}listReplays(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),this.requestApiRoot(`/sandbox-replays${t.size>0?`?${t.toString()}`:""}`)}getReplay(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),t.projectId&&n.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}${n.size>0?`?${n.toString()}`:""}`)}getReplayLogs(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),t.projectId&&n.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/logs${n.size>0?`?${n.toString()}`:""}`)}getReplayArtifacts(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),t.projectId&&n.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/artifacts${n.size>0?`?${n.toString()}`:""}`)}cancelReplay(e,t={}){let n=new URLSearchParams;return t.teamId&&n.set("teamId",t.teamId),t.projectId&&n.set("projectId",t.projectId),this.requestApiRoot(`/sandbox-replays/${encodeURIComponent(e)}/cancel${n.size>0?`?${n.toString()}`:""}`,{method:"POST"})}integrationConnections(e={}){let t=new URLSearchParams;return e.teamId&&t.set("teamId",e.teamId),e.projectId&&t.set("projectId",e.projectId),e.agentId&&t.set("agentId",e.agentId),e.status&&t.set("status",e.status),this.requestApiRoot(`/integrations/connections${t.size>0?`?${t.toString()}`:""}`)}mcpServerConfig(){return{name:"openpond-sandboxes",transport:"streamable-http",url:`${this.sandboxApiUrl}/mcp`,headers:{"openpond-api-key":this.apiKey}}}smoke(e={}){return J(this,e)}};function W(o){return new U(o)}r(W,"createOpenPondSandboxClient");async function oe(o){let e=await v($(o,"account"),T(o));if(!e.account||!e.token)throw new Error("Sign in to the selected OpenPond account before reading its teams.");if(process.env.OPENPOND_API_KEY?.trim()&&process.env.OPENPOND_API_KEY.trim()!==e.token)throw new Error("OPENPOND_API_KEY differs from the selected account. Remove that override before reading account-bound teams.");let t=new URL(L(o)??e.apiBaseUrl);if(t.origin!==new URL(e.apiBaseUrl).origin||t.username||t.password)throw new Error("The API URL must match the selected account\u2019s API origin.");let s=await W({apiKey:e.token,baseUrl:t.origin}).listOrganizations();if(s.length>200)throw new Error("Account team discovery exceeds 200 records; pass an explicit --team-id to the viewer.");let i=s.filter(p=>p.status==="active").map(p=>({teamId:p.teamId,name:(p.displayName||p.name||p.slug).slice(0,191),role:p.role,personalDefault:p.isPersonalDefault===!0||p.kind==="personal_default"||p.workspaceKind==="personal"})),u=new Set;for(let p of i){if(!p.teamId||p.teamId.length>191||u.has(p.teamId))throw new Error("The account returned invalid or duplicate team identities.");u.add(p.teamId)}let a=(await A(q())).document.defaults?.team_id?.trim()||null,d=i.filter(p=>p.personalDefault),b=a?i.find(p=>p.teamId===a):d.length===1?d[0]:i.length===1?i[0]:void 0;return{schemaVersion:1,account:{handle:e.account.handle,baseUrl:e.account.baseUrl??null,apiOrigin:t.origin},defaultTeamId:a,selectedTeamId:b?.teamId??null,selection:b?a?"configuredDefault":d.length===1?"personalDefault":"onlyTeam":a?"unavailableDefault":"chooseTeam",teams:i}}r(oe,"readAccountTeamContext");async function Be(o){console.log(JSON.stringify(await oe(o),null,2))}r(Be,"runAccountContext");export{oe as readAccountTeamContext,Be as runAccountContext};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as t}from"./chunk-XRKFTPHD.js";import"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import{f as n}from"./chunk-UGOK7VTC.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import{a as r}from"./chunk-FTQLQJQV.js";import m from"node:path";async function c(o,i){if(i.length||o.json)throw new Error("openpond acp uses ACP JSON-RPC on stdout; --json and positional arguments are not supported.");let e=typeof o.home=="string"?n({home:o.home}):m.join(n(),"acp-agent");if(process.env.OPENPOND_HOME=e,o.login){await(await import("./core-commands-
|
|
2
|
+
import{a as t}from"./chunk-XRKFTPHD.js";import"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import{f as n}from"./chunk-UGOK7VTC.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import{a as r}from"./chunk-FTQLQJQV.js";import m from"node:path";async function c(o,i){if(i.length||o.json)throw new Error("openpond acp uses ACP JSON-RPC on stdout; --json and positional arguments are not supported.");let e=typeof o.home=="string"?n({home:o.home}):m.join(n(),"acp-agent");if(process.env.OPENPOND_HOME=e,o.login){await(await import("./core-commands-5TNBVR72.js")).runLogin(o);let{AcpAccount:a}=await import("./acp-agent-AYJ5RPVF.js");await new a(e).models();return}await(await import("./acp-agent-AYJ5RPVF.js")).runOpenPondAcpAgent({home:e,version:t(),model:typeof o.model=="string"?o.model:void 0})}r(c,"runAcpCommand");export{c as runAcpCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as xs}from"./chunk-WMBOXX7G.js";import{b as Es,c as Ts}from"./chunk-ZSZXA7WB.js";import"./chunk-4DYWVGVS.js";import"./chunk-4TO743HO.js";import{a as vt,e as bs,g as ys,j as tt,p as Ss}from"./chunk-A77DLBR4.js";import{m as ks}from"./chunk-XQAUHXL4.js";import"./chunk-PSY6IRJE.js";import"./chunk-PKJHN666.js";import"./chunk-Z33RVGP6.js";import"./chunk-7PKDJHT6.js";import"./chunk-65WRWLUD.js";import"./chunk-FKUWCJ73.js";import"./chunk-B66QCXH2.js";import"./chunk-PYNW5OFA.js";import"./chunk-MOXIGLN2.js";import"./chunk-RHMULF56.js";import"./chunk-VFH5C6D2.js";import"./chunk-UOFDKMRU.js";import"./chunk-AN525SPP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-KOC3YJEU.js";import"./chunk-65FJWWXG.js";import"./chunk-SYUKES6H.js";import"./chunk-EYTTZ5H4.js";import"./chunk-XY7HFXLH.js";import"./chunk-6I5AUTVO.js";import"./chunk-DKOVZ6R2.js";import"./chunk-N5EAVX4G.js";import"./chunk-U7X5ZLAL.js";import"./chunk-7PXZ4X4P.js";import"./chunk-N73MU2C3.js";import"./chunk-SO4GMSNP.js";import"./chunk-NMMHXYDJ.js";import"./chunk-QLGP2OAQ.js";import{h as Is}from"./chunk-WZ35ICTE.js";import"./chunk-VS2LOUCT.js";import"./chunk-DMFUEUAZ.js";import"./chunk-AFKFN25T.js";import"./chunk-G4747MOW.js";import"./chunk-GF55VEMR.js";import"./chunk-FAKDGLZQ.js";import"./chunk-KCJVFLBB.js";import"./chunk-GW766ZSO.js";import"./chunk-VJYOKU3C.js";import"./chunk-SSJV3VX7.js";import"./chunk-7KWD2I6W.js";import{a as As,j as At}from"./chunk-RY46UPBO.js";import"./chunk-OFJPOTES.js";import"./chunk-PLROXHG2.js";import"./chunk-YU3C6U5V.js";import"./chunk-PHZZBXDO.js";import"./chunk-KVTBX2UP.js";import"./chunk-U7D6Q744.js";import{I as nt,K as Cs,P as st,a as Rs,c as Ct,g as vs,w as Ce,x as oe}from"./chunk-HG2YFMVU.js";import"./chunk-OQPJ7FJF.js";import"./chunk-BL3CZWWD.js";import"./chunk-FYWQWKVS.js";import"./chunk-GD3RCUDH.js";import"./chunk-7OKZCJHS.js";import"./chunk-UTIELP6F.js";import"./chunk-7NCM6GBN.js";import"./chunk-4V73I4OL.js";import"./chunk-LE75SVEL.js";import"./chunk-6ESBAHWK.js";import"./chunk-LZPCA6DH.js";import"./chunk-L3KS6MOV.js";import"./chunk-7J2NMUTK.js";import"./chunk-VEBW7NKD.js";import"./chunk-W45RKGM6.js";import"./chunk-AUO5DCEU.js";import"./chunk-Y4I6CFZJ.js";import"./chunk-4BUM6JEC.js";import"./chunk-UGFSAG4U.js";import"./chunk-SSHE6B7Z.js";import"./chunk-JFXINDOQ.js";import"./chunk-EDYCSW22.js";import"./chunk-JT5YQ52I.js";import"./chunk-XGY4OQLC.js";import"./chunk-PAYFJHPO.js";import"./chunk-WD4KAKEX.js";import"./chunk-2PXKSAG6.js";import"./chunk-ULTV6INR.js";import"./chunk-WGQ3FMRF.js";import"./chunk-JXLDEYRW.js";import"./chunk-JVMSN7LH.js";import"./chunk-YI6ME6PU.js";import"./chunk-DRLP7GIU.js";import"./chunk-BU6MW65V.js";import"./chunk-LVXL7T5O.js";import"./chunk-HIQPGYVH.js";import"./chunk-DXJC3QW7.js";import"./chunk-P4QM63L3.js";import"./chunk-MTP3B2SU.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-I6VMRQF4.js";import"./chunk-D6L6UNUQ.js";import"./chunk-AJXWJLZA.js";import"./chunk-OKKNDQJF.js";import"./chunk-4PUOWSDE.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-4N4EH3RJ.js";import"./chunk-GY7YSD6J.js";import"./chunk-KUE46HTH.js";import"./chunk-JCLTFDVW.js";import"./chunk-6FA3GG5B.js";import"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import{a as _s,c as ws}from"./chunk-UGOK7VTC.js";import"./chunk-ZFJWA4JK.js";import{A as G,a as fs,e as s,f as et,g as O,h as F,i as q,k as zs,l as d,m as w,n as a,o as me,p as T,r as ee,s as l,u as f,y as ms,z as gs}from"./chunk-X2J2P5ZT.js";import{a as c,c as ho,e as fo}from"./chunk-FTQLQJQV.js";var Mi=ho(Qn=>{"use strict";var Ai=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,Qc=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Ii=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Kc=/\\([\u000b\u0020-\u00ff])/g,Zc=/([\\"])/g,ki=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Qn.format=Xc;Qn.parse=Yc;function Xc(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!ki.test(t))throw new TypeError("invalid type");var i=t;if(e&&typeof e=="object")for(var r,u=Object.keys(e).sort(),h=0;h<u.length;h++){if(r=u[h],!Ii.test(r))throw new TypeError("invalid parameter name");i+="; "+r+"="+td(e[r])}return i}c(Xc,"format");function Yc(n){if(!n)throw new TypeError("argument string is required");var e=typeof n=="object"?ed(n):n;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var t=e.indexOf(";"),i=t!==-1?e.slice(0,t).trim():e.trim();if(!ki.test(i))throw new TypeError("invalid media type");var r=new nd(i.toLowerCase());if(t!==-1){var u,h,p;for(Ai.lastIndex=t;h=Ai.exec(e);){if(h.index!==t)throw new TypeError("invalid parameter format");t+=h[0].length,u=h[1].toLowerCase(),p=h[2],p.charCodeAt(0)===34&&(p=p.slice(1,-1),p.indexOf("\\")!==-1&&(p=p.replace(Kc,"$1"))),r.parameters[u]=p}if(t!==e.length)throw new TypeError("invalid parameter format")}return r}c(Yc,"parse");function ed(n){var e;if(typeof n.getHeader=="function"?e=n.getHeader("content-type"):typeof n.headers=="object"&&(e=n.headers&&n.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}c(ed,"getcontenttype");function td(n){var e=String(n);if(Ii.test(e))return e;if(e.length>0&&!Qc.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(Zc,"\\$1")+'"'}c(td,"qstring");function nd(n){this.parameters=Object.create(null),this.type=n}c(nd,"ContentType")});import{Readable as Ld,Writable as Gd}from"node:stream";var _={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},I={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_message:"mcp/message",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},It={cancel_request:"$/cancel_request"};var Ms=Symbol("skippedItem");function o(n,e){return n.catch(e)}c(o,"defaultOnError");function V(n,e){let t=n.catch(e);return G.unknown().transform((i,r)=>i!==void 0?t.parse(i):(r.addIssue({code:"custom",message:"Required value is missing"}),G.NEVER))}c(V,"requiredDefaultOnError");function Os(n,e){if(n===null||typeof n!="object"||Array.isArray(n))return;let t=n[e];return typeof t=="string"?t:void 0}c(Os,"stringTag");function ge(n,e,t){return n.superRefine((i,r)=>{let u=Os(i,e);u!==void 0&&t.includes(u)&&r.addIssue({code:"custom",path:[e],message:`${e} ${JSON.stringify(u)} is reserved by a known variant, but the value does not match that variant's schema`})})}c(ge,"excludeKnownTags");function _e(n,e,t){return G.unknown().transform((i,r)=>{let u=n.safeParse(i);if(!u.success){for(let z of u.error.issues)r.addIssue({...z,input:i});return G.NEVER}let h=u.data,p=Os(i,e);if(p!==void 0&&!t.includes(p)){let z=i;for(let[m,g]of Object.entries(z))m!=="__proto__"&&(Object.hasOwn(h,m)||(h[m]=g))}return h})}c(_e,"preserveCustomPayload");function C(n){return G.array(n.catch(Ms)).transform(e=>e.filter(t=>t!==Ms))}c(C,"vecSkipError");var te=T([O(),s()]).nullable(),A=s(),Mt=a({sessionId:A,path:s(),content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Ot=a({sessionId:A,path:s(),line:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Nt=s(),js=T([f("read"),f("edit"),f("delete"),f("move"),f("search"),f("execute"),f("think"),f("fetch"),f("switch_mode"),f("other")]),qs=T([f("pending"),f("in_progress"),f("completed"),f("failed")]),mo=T([f("assistant"),f("user")]),Ae=a({audience:o(C(mo).nullish(),()=>{}),lastModified:o(s().nullish(),()=>{}),priority:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),go=a({annotations:o(Ae.nullish(),()=>{}),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),_o=a({annotations:o(Ae.nullish(),()=>{}),data:s(),mimeType:s(),uri:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),wo=a({annotations:o(Ae.nullish(),()=>{}),data:s(),mimeType:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),bo=a({annotations:o(Ae.nullish(),()=>{}),description:o(s().nullish(),()=>{}),mimeType:o(s().nullish(),()=>{}),name:s(),size:o(O().nullish(),()=>{}),title:o(s().nullish(),()=>{}),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),yo=a({mimeType:o(s().nullish(),()=>{}),text:s(),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),So=a({blob:s(),mimeType:o(s().nullish(),()=>{}),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),xo=T([yo,So]),Eo=a({annotations:o(Ae.nullish(),()=>{}),resource:xo,_meta:o(l(s(),d()).nullish(),()=>{})}),re=T([go.and(a({type:f("text")})),_o.and(a({type:f("image")})),wo.and(a({type:f("audio")})),bo.and(a({type:f("resource_link")})),Eo.and(a({type:f("resource")}))]),To=a({content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),Ro=a({path:s(),oldText:o(s().nullish(),()=>{}),newText:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),we=s(),vo=a({terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ps=T([To.and(a({type:f("content")})),Ro.and(a({type:f("diff")})),vo.and(a({type:f("terminal")}))]),Ds=a({path:s(),line:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Hs=a({toolCallId:Nt,kind:o(js.nullish(),()=>{}),status:o(qs.nullish(),()=>{}),title:o(s().nullish(),()=>{}),name:o(s().nullish(),()=>{}),content:o(C(Ps).nullish(),()=>{}),locations:o(C(Ds).nullish(),()=>{}),rawInput:o(d().optional(),()=>{}),rawOutput:o(d().optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Us=s(),Co=T([f("allow_once"),f("allow_always"),f("reject_once"),f("reject_always")]),Ao=a({optionId:Us,name:s(),kind:Co,_meta:o(l(s(),d()).nullish(),()=>{})}),jt=a({sessionId:A,toolCall:Hs,options:w(Ao),_meta:o(l(s(),d()).nullish(),()=>{})}),Ls=a({name:s(),value:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),qt=a({sessionId:A,command:s(),args:o(C(s()).optional(),()=>[]),env:o(C(Ls).optional(),()=>[]),cwd:o(s().nullish(),()=>{}),outputByteLimit:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Pt=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Dt=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ht=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ut=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ie=a({sessionId:A,toolCallId:o(Nt.nullish(),()=>{})}),ke=a({requestId:te}),Io=f("object"),ko=T([f("email"),f("uri"),f("date"),f("date-time")]),Gs=a({const:s(),title:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Lt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minLength:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:s().nullish(),format:ko.nullish(),default:o(s().nullish(),()=>{}),enum:w(s()).nullish(),oneOf:w(Gs).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Gt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:O().nullish(),maximum:O().nullish(),default:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$t=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:O().nullish(),maximum:O().nullish(),default:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ft=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),default:o(q().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Wt=a({enum:w(s()),_meta:o(l(s(),d()).nullish(),()=>{})}),$s=a({anyOf:w(Gs),_meta:o(l(s(),d()).nullish(),()=>{})}),Mo=_e(T([Wt.and(a({type:f("string")})),ge(a({type:s()}),"type",["string"]),$s]),"type",["string"]),Bt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minItems:O().nullish(),maxItems:O().nullish(),items:Mo,default:o(C(s()).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Oo=_e(T([Lt.and(a({type:f("string")})),Gt.and(a({type:f("number")})),$t.and(a({type:f("integer")})),Ft.and(a({type:f("boolean")})),Bt.and(a({type:f("array")})),ge(a({type:s()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),No=a({type:o(Io.optional().default("object"),()=>"object"),title:o(s().nullish(),()=>{}),properties:l(s(),Oo).optional().default({}),required:w(s()).nullish(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Vt=ee(T([Ie,ke]),a({requestedSchema:No})),Fs=s(),Jt=ee(T([Ie,ke]),a({elicitationId:Fs,url:et()})),Qt=_e(ee(T([Vt.and(a({mode:f("form")})),Jt.and(a({mode:f("url")})),ge(ee(T([Ie,ke]),a({mode:s()})),"mode",["form","url"])]),a({message:s(),_meta:o(l(s(),d()).nullish(),()=>{})})),"mode",["form","url"]),Kt=s(),Ws=s(),jo=a({serverId:Kt,requestId:Ws,method:s(),params:l(s(),d()).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Bs=d(),Qd=a({id:te,method:s(),params:T([Mt,Ot,jt,qt,Pt,Dt,Ht,Ut,Qt,jo,Bs]).nullish()}),Vs=F().gte(0).lte(65535),qo=a({image:o(q().optional().default(!1),()=>!1),audio:o(q().optional().default(!1),()=>!1),embeddedContext:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Po=a({http:o(q().optional().default(!1),()=>!1),sse:o(q().optional().default(!1),()=>!1),acp:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Do=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ho=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Uo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Lo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Go=a({_meta:o(l(s(),d()).nullish(),()=>{})}),$o=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Fo=a({list:o(Do.nullish(),()=>{}),delete:o(Ho.nullish(),()=>{}),additionalDirectories:o(Uo.nullish(),()=>{}),fork:o(Lo.nullish(),()=>{}),resume:o(Go.nullish(),()=>{}),close:o($o.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Wo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Bo=a({logout:o(Wo.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Vo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Jo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Qo=T([f("full"),f("incremental")]),Ko=a({syncKind:Qo,_meta:o(l(s(),d()).nullish(),()=>{})}),Zo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Xo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Yo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),er=a({didOpen:o(Jo.nullish(),()=>{}),didChange:o(Ko.nullish(),()=>{}),didClose:o(Zo.nullish(),()=>{}),didSave:o(Xo.nullish(),()=>{}),didFocus:o(Yo.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),tr=a({document:o(er.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),nr=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),sr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ir=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),or=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),rr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ar=a({_meta:o(l(s(),d()).nullish(),()=>{})}),cr=a({recentFiles:o(nr.nullish(),()=>{}),relatedSnippets:o(sr.nullish(),()=>{}),editHistory:o(ir.nullish(),()=>{}),userActions:o(or.nullish(),()=>{}),openFiles:o(rr.nullish(),()=>{}),diagnostics:o(ar.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),dr=a({events:o(tr.nullish(),()=>{}),context:o(cr.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Js=T([f("utf-16"),f("utf-32"),f("utf-8")]),lr=a({loadSession:o(q().optional().default(!1),()=>!1),promptCapabilities:o(qo.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:o(Po.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:o(Fo.optional().default({}),()=>({})),auth:o(Bo.optional().default({}),()=>({})),providers:o(Vo.nullish(),()=>{}),nes:o(dr.nullish(),()=>{}),positionEncoding:o(Js.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Zt=s(),ur=a({id:Zt,name:s(),description:o(s().nullish(),()=>{}),args:o(C(s()).optional(),()=>[]),env:o(l(s(),s()).optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),pr=a({id:Zt,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),hr=T([ur.and(a({type:f("terminal")})),pr]),Qs=a({name:s(),title:o(s().nullish(),()=>{}),version:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),fr=a({protocolVersion:Vs,agentCapabilities:o(lr.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:o(C(hr).optional().default([]),()=>[]),agentInfo:o(Qs.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),zr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Xt=s(),Yt=T([f("anthropic"),f("openai"),f("azure"),f("vertex"),f("bedrock"),s()]),mr=a({apiType:Yt,baseUrl:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),gr=a({providerId:Xt,supported:V(C(Yt),()=>[]),required:q(),current:mr.nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),_r=a({providers:w(gr),_meta:o(l(s(),d()).nullish(),()=>{})}),wr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),br=a({_meta:o(l(s(),d()).nullish(),()=>{})}),yr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),it=s(),Sr=a({id:it,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ot=a({currentModeId:it,availableModes:V(C(Sr),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Ks=s(),xr=T([f("mode"),f("model"),f("model_config"),f("thought_level"),s()]),en=s(),Zs=a({value:en,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Er=s(),Tr=a({group:Er,name:s(),options:V(C(Zs),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Rr=T([w(Zs),w(Tr)]),vr=a({currentValue:en,options:Rr}),Cr=a({currentValue:q()}),be=ee(T([vr.and(a({type:f("select")})),Cr.and(a({type:f("boolean")}))]),a({id:Ks,name:s(),description:o(s().nullish(),()=>{}),category:o(xr.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})})),Ar=a({sessionId:A,modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ir=a({modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),kr=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Mr=a({sessions:V(C(kr),()=>[]),nextCursor:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Or=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Nr=a({sessionId:A,modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),jr=a({modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),qr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Pr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Dr=a({configOptions:V(C(be),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Xs=T([f("end_turn"),f("max_tokens"),f("max_turn_requests"),f("refusal"),f("cancelled")]),Ys=a({totalTokens:O(),inputTokens:O(),outputTokens:O(),thoughtTokens:o(O().nullish(),()=>{}),cachedReadTokens:o(O().nullish(),()=>{}),cachedWriteTokens:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Hr=a({stopReason:Xs,usage:o(Ys.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ur=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),ye=s(),ne=a({line:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:o(l(s(),d()).nullish(),()=>{})}),Se=a({start:ne,end:ne,_meta:o(l(s(),d()).nullish(),()=>{})}),Lr=a({range:Se,newText:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Gr=a({id:ye,uri:s(),edits:w(Lr),cursorPosition:o(ne.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$r=a({id:ye,uri:s(),position:ne,_meta:o(l(s(),d()).nullish(),()=>{})}),Fr=a({id:ye,uri:s(),position:ne,newName:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Wr=a({id:ye,uri:s(),search:s(),replace:s(),isRegex:q().nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Br=T([Gr.and(a({kind:f("edit")})),$r.and(a({kind:f("jump")})),Fr.and(a({kind:f("rename")})),Wr.and(a({kind:f("searchAndReplace")}))]),Vr=a({suggestions:w(Br),_meta:o(l(s(),d()).nullish(),()=>{})}),Jr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ei=d(),Qr=T([f(-32700),f(-32600),f(-32601),f(-32602),f(-32603),f(-32800),f(-32e3),f(-32002),F().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),ti=a({code:Qr,message:s(),data:o(d().optional(),()=>{})}),Kd=T([a({id:te,result:T([fr,zr,_r,wr,br,yr,Ar,Ir,Mr,Or,Nr,jr,qr,Pr,Dr,Hr,Ur,Vr,Jr,ei])}),a({id:te,error:ti})]),tn=s(),kt=a({content:re,messageId:o(tn.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Kr=a({toolCallId:Nt,title:s(),name:o(s().nullish(),()=>{}),kind:o(js.optional(),()=>{}),status:o(qs.optional(),()=>{}),content:o(C(Ps).optional(),()=>[]),locations:o(C(Ds).optional(),()=>[]),rawInput:o(d().optional(),()=>{}),rawOutput:o(d().optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Zr=T([f("high"),f("medium"),f("low")]),Xr=T([f("pending"),f("in_progress"),f("completed")]),ni=a({content:s(),priority:Zr,status:Xr,_meta:o(l(s(),d()).nullish(),()=>{})}),Yr=a({entries:V(C(ni),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),rt=s(),ea=a({planId:rt,entries:V(C(ni),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),ta=a({planId:rt,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),na=a({planId:rt,content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),sa=T([ea.and(a({type:f("items")})),ta.and(a({type:f("file")})),na.and(a({type:f("markdown")}))]),ia=a({plan:sa,_meta:o(l(s(),d()).nullish(),()=>{})}),oa=a({planId:rt,_meta:o(l(s(),d()).nullish(),()=>{})}),ra=a({hint:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),aa=ra,ca=a({name:s(),description:s(),input:o(aa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),da=a({availableCommands:V(C(ca),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),la=a({currentModeId:it,_meta:o(l(s(),d()).nullish(),()=>{})}),ua=a({configOptions:V(C(be),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),pa=a({title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ha=a({amount:O(),currency:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),fa=a({used:O(),size:O(),cost:o(ha.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),za=T([f("info"),f("warning"),f("error"),s()]),ma=a({severity:za,title:s().min(1),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),si=s(),ga=T([f("in_progress"),f("completed"),f("failed"),f("cancelled"),s()]),_a=a({compactionId:si,status:ga,summary:o(C(re).nullish(),()=>{}),error:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),wa=a({compactionId:si,content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),ba=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ya=a({cancel:o(ba.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),nn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),sn=a({stopReason:o(Xs.nullish(),()=>{}),usage:o(Ys.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),on=a({_meta:o(l(s(),d()).nullish(),()=>{})}),rn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Sa=_e(T([nn.and(a({state:f("running")})),sn.and(a({state:f("idle")})),on.and(a({state:f("requires_action")})),rn.and(a({state:f("unknown")})),ge(a({state:s()}),"state",["idle","requires_action","running","unknown"])]),"state",["idle","requires_action","running","unknown"]),xa=a({sessionId:A,title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),capabilities:o(ya.nullish(),()=>{}),state:o(Sa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ea=a({messageId:tn,senderSessionId:o(A.nullish(),()=>{}),recipientSessionId:o(A.nullish(),()=>{}),content:o(C(re).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ta=a({messageId:tn,senderSessionId:o(A.nullish(),()=>{}),recipientSessionId:o(A.nullish(),()=>{}),content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),Ra=T([kt.and(a({sessionUpdate:f("user_message_chunk")})),kt.and(a({sessionUpdate:f("agent_message_chunk")})),kt.and(a({sessionUpdate:f("agent_thought_chunk")})),Kr.and(a({sessionUpdate:f("tool_call")})),Hs.and(a({sessionUpdate:f("tool_call_update")})),Yr.and(a({sessionUpdate:f("plan")})),ia.and(a({sessionUpdate:f("plan_update")})),oa.and(a({sessionUpdate:f("plan_removed")})),da.and(a({sessionUpdate:f("available_commands_update")})),la.and(a({sessionUpdate:f("current_mode_update")})),ua.and(a({sessionUpdate:f("config_option_update")})),pa.and(a({sessionUpdate:f("session_info_update")})),fa.and(a({sessionUpdate:f("usage_update")})),ma.and(a({sessionUpdate:f("notice")})),_a.and(a({sessionUpdate:f("compaction_update")})),wa.and(a({sessionUpdate:f("compaction_summary_chunk")})),xa.and(a({sessionUpdate:f("subagent_update")})),Ea.and(a({sessionUpdate:f("session_message")})),Ta.and(a({sessionUpdate:f("session_message_chunk")}))]),at=a({sessionId:A,update:Ra,_meta:o(l(s(),d()).nullish(),()=>{})}),an=a({elicitationId:Fs,_meta:o(l(s(),d()).nullish(),()=>{})}),ii=d(),Zd=a({method:s(),params:T([at,an,ii]).nullish()}),va=a({readTextFile:o(q().optional().default(!1),()=>!1),writeTextFile:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Ca=l(s(),d()),Aa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ia=a({boolean:o(Aa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ka=l(s(),d()),Ma=a({compaction:o(Ca.nullish(),()=>{}),configOptions:o(Ia.nullish(),()=>{}),notices:o(ka.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Oa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Na=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ja=a({terminal:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),qa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Pa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Da=a({form:o(qa.nullish(),()=>{}),url:o(Pa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ha=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ua=a({_meta:o(l(s(),d()).nullish(),()=>{})}),La=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ga=a({jump:o(Ha.nullish(),()=>{}),rename:o(Ua.nullish(),()=>{}),searchAndReplace:o(La.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$a=a({fs:o(va.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:o(q().optional().default(!1),()=>!1),session:o(Ma.nullish(),()=>{}),subagents:o(Oa.nullish(),()=>{}),plan:o(Na.nullish(),()=>{}),auth:o(ja.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:o(Da.nullish(),()=>{}),nes:o(Ga.nullish(),()=>{}),positionEncodings:o(C(Js).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),cn=a({protocolVersion:Vs,clientCapabilities:o($a.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:o(Qs.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),dn=a({methodId:Zt,_meta:o(l(s(),d()).nullish(),()=>{})}),ln=a({_meta:o(l(s(),d()).nullish(),()=>{})}),un=a({providerId:Xt,apiType:Yt,baseUrl:s(),headers:l(s(),s()).optional(),_meta:o(l(s(),d()).nullish(),()=>{})}),pn=a({providerId:Xt,_meta:o(l(s(),d()).nullish(),()=>{})}),hn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),oi=a({name:s(),value:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Fa=a({name:s(),url:s(),headers:w(oi),_meta:o(l(s(),d()).nullish(),()=>{})}),Wa=a({name:s(),url:s(),headers:w(oi),_meta:o(l(s(),d()).nullish(),()=>{})}),Ba=a({name:s(),serverId:Kt,_meta:o(l(s(),d()).nullish(),()=>{})}),Va=a({name:s(),command:s(),args:w(s()),env:w(Ls),_meta:o(l(s(),d()).nullish(),()=>{})}),ct=T([Fa.and(a({type:f("http")})),Wa.and(a({type:f("sse")})),Ba.and(a({type:f("acp")})),Va]),fn=a({cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:V(C(ct),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),zn=a({mcpServers:V(C(ct),()=>[]),cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),mn=a({cwd:s().nullish(),cursor:s().nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),gn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),_n=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:o(C(ct).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),wn=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:o(C(ct).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),bn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),yn=a({sessionId:A,modeId:it,_meta:o(l(s(),d()).nullish(),()=>{})}),Sn=ee(T([a({value:q(),type:f("boolean")}),a({value:en})]),a({sessionId:A,configId:Ks,_meta:o(l(s(),d()).nullish(),()=>{})})),xn=a({sessionId:A,prompt:w(re),_meta:o(l(s(),d()).nullish(),()=>{})}),Ja=a({uri:s(),name:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Qa=a({name:s(),owner:s(),remoteUrl:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),En=a({workspaceUri:o(s().nullish(),()=>{}),workspaceFolders:w(Ja).nullish(),repository:o(Qa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ka=T([f("automatic"),f("diagnostic"),f("manual")]),Za=a({uri:s(),languageId:s(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Xa=a({startLine:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Ya=a({uri:s(),excerpts:w(Xa),_meta:o(l(s(),d()).nullish(),()=>{})}),ec=a({uri:s(),diff:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),tc=a({action:s(),uri:s(),position:ne,timestampMs:O(),_meta:o(l(s(),d()).nullish(),()=>{})}),nc=a({uri:s(),languageId:s(),visibleRange:o(Se.nullish(),()=>{}),lastFocusedMs:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),sc=T([f("error"),f("warning"),f("information"),f("hint")]),ic=a({uri:s(),range:Se,severity:sc,message:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),oc=a({recentFiles:w(Za).nullish(),relatedSnippets:w(Ya).nullish(),editHistory:w(ec).nullish(),userActions:w(tc).nullish(),openFiles:w(nc).nullish(),diagnostics:w(ic).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Tn=a({sessionId:A,uri:s(),version:O(),position:ne,selection:Se.nullish(),triggerKind:Ka,context:oc.nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Rn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),Xd=a({id:te,method:s(),params:T([cn,dn,ln,un,pn,hn,fn,zn,mn,gn,_n,wn,bn,yn,Sn,xn,En,Tn,Rn,Bs]).nullish()}),rc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ac=a({content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),cc=a({optionId:Us,_meta:o(l(s(),d()).nullish(),()=>{})}),dc=T([a({outcome:f("cancelled")}),cc.and(a({outcome:f("selected")}))]),lc=a({outcome:dc,_meta:o(l(s(),d()).nullish(),()=>{})}),uc=a({terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),pc=a({exitCode:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),hc=a({output:s(),truncated:q(),exitStatus:o(pc.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),fc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),zc=a({exitCode:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),mc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),gc=T([s(),O(),O(),q(),w(s())]),vn=a({content:l(s(),gc).nullish()}),_c=_e(ee(T([vn.and(a({action:f("accept")})),a({action:f("decline")}),a({action:f("cancel")}),ge(a({action:s()}),"action",["accept","cancel","decline"])]),a({_meta:o(l(s(),d()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),wc=me({code:F().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"}),message:s(),data:d().optional()}),bc=T([a({result:d(),_meta:o(l(s(),d()).nullish(),()=>{})}),a({error:wc,_meta:o(l(s(),d()).nullish(),()=>{})})]),Yd=T([a({id:te,result:T([rc,ac,lc,uc,hc,fc,zc,mc,_c,bc,ei])}),a({id:te,error:ti})]),Cn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),An=a({sessionId:A,uri:s(),languageId:s(),version:O(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),yc=a({range:Se.nullish(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),In=a({sessionId:A,uri:s(),version:O(),contentChanges:V(C(yc),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),kn=a({sessionId:A,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Mn=a({sessionId:A,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),On=a({sessionId:A,uri:s(),version:O(),position:ne,visibleRange:Se,_meta:o(l(s(),d()).nullish(),()=>{})}),Nn=a({sessionId:A,id:ye,_meta:o(l(s(),d()).nullish(),()=>{})}),Sc=T([f("rejected"),f("ignored"),f("replaced"),f("cancelled")]),jn=a({sessionId:A,id:ye,reason:o(Sc.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),xc=a({serverId:Kt,requestId:Ws,method:s(),params:l(s(),d()).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),el=a({method:s(),params:T([Cn,An,In,kn,Mn,On,Nn,jn,xc,ii]).nullish()}),tl=a({requestId:te,_meta:o(l(s(),d()).nullish(),()=>{})});var ai="$/cancel_request";function dt(n){return Hn(n)&&"id"in n&&typeof n.method=="string"&&Un(n.id)}c(dt,"isRequestMessage");function di(n){if(!Hn(n)||"method"in n||!("id"in n)||!Un(n.id))return!1;let e=Object.hasOwn(n,"result"),t=Object.hasOwn(n,"error");return e===t?!1:!t||Rc(n.error)}c(di,"isResponseMessage");function xe(n){return Hn(n)&&!("id"in n)&&typeof n.method=="string"}c(xe,"isNotificationMessage");function se(n){return typeof n=="object"&&n!==null}c(se,"isRecord");function Hn(n){return se(n)&&n.jsonrpc==="2.0"}c(Hn,"isJsonRpcEnvelope");function Un(n){return n===null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}c(Un,"isJsonRpcId");function ci(n){return se(n)&&!("method"in n)&&("id"in n||"result"in n||"error"in n)}c(ci,"isResponseShapedMessage");function Ec(n){let e=!1,t=!1,i=!1,r=!1;for(let u of n)e||=dt(u)||xe(u),t||=di(u),se(u)&&(i||="method"in u,r||="result"in u||"error"in u);return e?!1:t?!0:r&&!i}c(Ec,"isResponseBatch");function Tc(n){if(!(!se(n)||!Un(n.requestId)))return n.requestId}c(Tc,"cancelRequestId");function Rc(n){return se(n)&&typeof n.code=="number"&&Number.isInteger(n.code)&&typeof n.message=="string"}c(Rc,"isErrorResponse");var Z={yes(){return{handled:!0}},no(n,e=!1){return{handled:!1,message:n,retry:e}}};function ae(n){let e=Promise.reject(n);return e.catch(()=>{}),e}c(ae,"rejectedPromise");function vc(n){if(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")return n.message}c(vc,"errorDetails");function Cc(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ZodError"&&"issues"in n&&Array.isArray(n.issues)&&"format"in n&&typeof n.format=="function"}c(Cc,"isZodError");function li(n){if(n instanceof S)return n.toResult();if(Cc(n))return S.invalidParams(n.format()).toResult();let e=vc(n);try{return S.internalError(e?JSON.parse(e):{}).toResult()}catch{return S.internalError({details:e}).toResult()}}c(li,"errorToResult");function Ac(n){return n instanceof S&&n.code===-32800?n:S.requestCancelled(n)}c(Ac,"requestCancelledError");function Ic(n,e){let t=kc(n,e);return t?t.toResult():li(n)}c(Ic,"errorToRequestResult");function kc(n,e){if(!(!e.aborted||!Mc(n)))return Ac(e.reason)}c(kc,"abortErrorToRequestCancelled");function Mc(n){if(typeof n!="object"||n===null)return!1;let e=n;return e.name==="AbortError"||e.code==="ABORT_ERR"}c(Mc,"isAbortError");var qn=class{static{c(this,"RequestResponder")}id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,t,i=new AbortController().signal,r){this.id=e,this.sendResult=t,this.signal=i,this.finishRequest=r}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let t=e instanceof S?e.toErrorResponse():e;return this.respondWithResult({error:t})}respondWithResult(e){return this.didRespond?ae(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},Oc=new WeakMap;var Te=class{static{c(this,"HandlerRegistration")}disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},Pn=class{static{c(this,"ConnectionContext")}connection;constructor(e){this.connection=e}sendRequest(e,t,i,r){return this.connection.sendRequest(e,t,i,r)}sendNotification(e,t){return this.connection.sendNotification(e,t)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},Re=class{static{c(this,"Connection")}pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new Pn(this);receiveReader;allowBatches=!0;constructor(e,t,i,r){if(typeof e=="function"){let z=e,m=t,g=i;this.initialize(g,[...r?.handlers??[],this.legacyHandler(z,m)],r);return}let u=e,h=t,p=i;this.initialize(u,[...p?.handlers??[],...h],p)}static builder(){return new Dn}runUntil(e){let t=!1,i=Promise.resolve().then(()=>e(this.context)).finally(()=>{t=!0}),r=this.closed.then(()=>{if(t)return new Promise(()=>{});throw this.closedReason()});return Promise.race([i,r]).finally(()=>{t=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let t of this.retryQueue.splice(0))this.processIncomingMessage(t).catch(i=>this.close(i));return new Te(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,t,i,r={}){if(this.abortController.signal.aborted)return ae(this.closedReason());let u=this.prepareRequest(e,t,i,r);return this.sendWireMessage(u.message).catch(()=>{}),r.cancellationSignal?.aborted&&u.cancel(),u.response}sendBatch(e){if(this.abortController.signal.aborted)return ae(this.closedReason());if(!this.allowBatches)return ae(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return ae(new TypeError("JSON-RPC batch must contain at least one entry"));let t=[],i=[],r=[];for(let z of e){if(z.kind==="notification"){t.push({jsonrpc:"2.0",method:z.method,params:z.params}),r.push(Promise.resolve(void 0));continue}let m=this.prepareRequest(z.method,z.params,z.mapResponse,z.options);t.push(m.message),r.push(m.response),i.push({signal:z.options?.cancellationSignal,cancel:m.cancel})}let u=t,h=this.sendWireMessage(u);for(let z of i)z.signal?.aborted&&z.cancel();let p=Promise.all([h,...r]).then(([,...z])=>z);return p.catch(()=>{}),p}sendCancelRequest(e){return this.sendNotification(ai,{requestId:e})}sendNotification(e,t){return this.abortController.signal.aborted?ae(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:t})}prepareRequest(e,t,i,r={}){let u=this.nextRequestId++,h=c(()=>{},"cancel"),p=new Promise((z,m)=>{let g={resolve:c(x=>{try{z(i?i(x):x)}catch(v){m(v)}},"resolve"),reject:m};h=c(()=>{g.cancellationSent||(g.cancellationSent=!0,g.cleanup?.(),this.sendCancelRequest(u).catch(()=>{}))},"cancel"),r.cancellationSignal?.addEventListener("abort",h,{once:!0}),g.cleanup=()=>{r.cancellationSignal?.removeEventListener("abort",h)},this.pendingResponses.set(u,g)});return p.catch(()=>{}),{message:{jsonrpc:"2.0",id:u,method:e,params:t},response:p,cancel:c(()=>h(),"cancel")}}close(e){if(this.abortController.signal.aborted)return;let t=e??new Error("ACP connection closed");this.abortController.abort(t);for(let i of this.pendingResponses.values())i.cleanup?.(),i.reject(t);this.pendingResponses.clear();for(let i of this.incomingRequests.values())i.abort(t);this.incomingRequests.clear(),this.receiveReader?.cancel(t).catch(()=>{})}initialize(e,t,i){this.stream=e,this.staticHandlers=t,this.allowBatches=i?.allowBatches??!0,this.closedPromise=new Promise(r=>{this.abortController.signal.addEventListener("abort",()=>r())}),this.receive()}legacyHandler(e,t){return{handleMessage:c(async(i,r)=>{if(i.kind==="request"){let u=await e(i.method,i.params,r);await i.responder.respond(u)}else await t(i.method,i.params,r);return Z.yes()},"handleMessage")}}async receive(){let e;try{let t=this.stream.readable.getReader();this.receiveReader=t;try{for(;!this.abortController.signal.aborted;){let{value:i,done:r}=await t.read();if(this.abortController.signal.aborted||r)break;this.receiveWireMessage(i)}}finally{this.receiveReader===t&&(this.receiveReader=void 0),t.releaseLock()}}catch(t){e=t}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!dt(e)&&!xe(e)&&!ci(e)){this.sendWireMessage(Ee(S.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(Ee(S.invalidRequest(e))).catch(()=>{});return}let t=Ec(e),r=t?0:e.reduce((g,x)=>g+(xe(x)?0:1),0),u=e.reduce((g,x)=>g+(xe(x)?1:0),0),h=!1,p=[],z=c(async()=>{h||r!==0||u!==0||p.length===0||(h=!0,await this.sendWireMessage(p))},"sendResponsesIfReady"),m=c(async g=>{p.push(g),r-=1,await z()},"collectResponse");for(let g of e){if(t){ci(g)&&this.receiveMessage(g);continue}if(!dt(g)&&!xe(g)){m(Ee(S.invalidRequest(g))).catch(()=>{});continue}let x=this.receiveMessage(g,dt(g)?m:void 0,e.length);xe(g)&&x.finally(()=>{u-=1,z().catch(v=>this.close(v))})}}receiveMessage(e,t,i){return this.abortController.signal.aborted?Promise.resolve():se(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,t,i)).catch(r=>this.close(r))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let t=e,i=!1;try{for(let r of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let u=await r.handleMessage(t,this.context)??{handled:!0};if(u.handled)return;t=u.message??t,i=i||!!u.retry}i?this.retryQueue.push(t):t.kind==="request"&&await t.responder.respondWithError(S.methodNotFound(t.method))}catch(r){if(this.abortController.signal.aborted)return;if(t.kind==="request"&&!t.responder.responded)await t.responder.respondWithResult(Ic(r,t.responder.signal));else{let u=li(r);"error"in u&&console.error("Error handling notification",e.raw,u.error)}}}toIncomingMessage(e,t,i){if("id"in e){let r=new AbortController;this.incomingRequests.set(e.id,r);let u=c(()=>{this.incomingRequests.get(e.id)===r&&this.incomingRequests.delete(e.id)},"finishRequest"),h=new qn(e.id,p=>{let z={jsonrpc:"2.0",id:e.id,...p};return t?t(z):this.sendWireMessage(z)},r.signal,u);return i!==void 0&&Oc.set(h,i),{kind:"request",method:e.method,params:e.params,raw:e,signal:r.signal,responder:h}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t)if(this.pendingResponses.delete(e.id),t.cleanup?.(),!di(e))t.reject(S.invalidRequest(e));else if("result"in e)t.resolve(e.result);else{let{code:i,message:r,data:u}=e.error;t.reject(new S(i,r,u))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==ai)return;let t=Tc(e.params);if(t===void 0)return;let i=this.incomingRequests.get(t);!i||i.signal.aborted||i.abort(S.requestCancelled({requestId:t}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?ae(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{throw this.close(t),t}),this.writeQueue)}},Dn=class{static{c(this,"ConnectionBuilder")}handlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:c(async(t,i)=>await e(t,i)??Z.no(t),"handleMessage"),describe:c(()=>this.connectionName??"onReceiveMessage","describe")})}onReceiveRequest(e,t,i){return this.withHandler({handleMessage:c(async(r,u)=>{if(r.kind!=="request"||r.method!==e)return Z.no(r);let h=t(r.params);return await i(h,r.responder,u)??Z.yes()},"handleMessage"),describe:c(()=>`${this.connectionName??"request"}:${e}`,"describe")})}onReceiveNotification(e,t,i){return this.withHandler({handleMessage:c(async(r,u)=>{if(r.kind!=="notification"||r.method!==e)return Z.no(r);let h=t(r.params);return await i(h,u)??Z.yes()},"handleMessage"),describe:c(()=>`${this.connectionName??"notification"}:${e}`,"describe")})}connect(e,t){return new Re(e,this.handlers,t)}connectWith(e,t,i){return this.connect(e,i).runUntil(t)}},S=class n extends Error{static{c(this,"RequestError")}code;data;constructor(e,t,i){super(t),this.code=e,this.name="RequestError",this.data=i}static parseError(e,t){return new n(-32700,`Parse error${t?`: ${t}`:""}`,e)}static invalidRequest(e,t){return new n(-32600,`Invalid request${t?`: ${t}`:""}`,e)}static methodNotFound(e){return new n(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,t){return new n(-32602,`Invalid params${t?`: ${t}`:""}`,e)}static internalError(e,t){return new n(-32603,`Internal error${t?`: ${t}`:""}`,e)}static requestCancelled(e,t){return new n(-32800,`Request cancelled${t?`: ${t}`:""}`,e)}static authRequired(e,t){return new n(-32e3,`Authentication required${t?`: ${t}`:""}`,e)}static resourceNotFound(e){return new n(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function Ee(n){return{jsonrpc:"2.0",id:null,error:n.toErrorResponse()}}c(Ee,"protocolErrorResponse");var ve=class extends Error{static{c(this,"MessageTooLargeError")}maxMessageBytes;constructor(e){super(`Incoming ACP data exceeds the configured ${e} byte limit`),this.maxMessageBytes=e,this.name="MessageTooLargeError"}};function Me(n){let e=n??33554432;if(!Number.isSafeInteger(e)||e<=0)throw new RangeError("maxMessageBytes must be a positive safe integer");return e}c(Me,"resolveMaxMessageBytes");var lt=class{static{c(this,"MessageBuffer")}#e=new Uint8Array(0);#t=0;#n;constructor(e){this.#n=Me(e)}get byteLength(){return this.#t}get lastByte(){return this.#e[this.#t-1]}#s(e){if(e>this.#n-this.#t)throw this.clear(),new ve(this.#n)}append(e){this.#s(e.byteLength);let t=this.#t+e.byteLength;if(t>this.#e.byteLength){let i=Math.min(this.#n,Math.max(t,this.#e.byteLength*2,1024)),r=new Uint8Array(i);r.set(this.#e.subarray(0,this.#t)),this.#e=r}this.#e.set(e,this.#t),this.#t=t}take(){let e=this.#e.subarray(0,this.#t);return this.clear(),e}clear(){this.#e=new Uint8Array(0),this.#t=0}};var ui=10,ut=class{static{c(this,"LineBuffer")}#e;#t;constructor(e){this.#t=Me(e),this.#e=new lt(Math.min(Number.MAX_SAFE_INTEGER,this.#t+1))}*push(e){let t=0,i=e.indexOf(ui,t);for(;i!==-1;)yield this.#n(e.subarray(t,i)),t=i+1,i=e.indexOf(ui,t);if(t<e.byteLength){let r=e.subarray(t);this.#s(r),this.#e.append(r)}}flush(){if(this.#e.byteLength!==0)return Ln(this.#e.take())}clear(){this.#e.clear()}#n(e){return this.#s(e),this.#e.byteLength===0?Ln(e):(this.#e.append(e),Ln(this.#e.take()))}#s(e){let t=e.byteLength>0?e[e.byteLength-1]:this.#e.lastByte;if(this.#e.byteLength+e.byteLength-(t===13?1:0)>this.#t)throw this.clear(),new ve(this.#t)}};function Ln(n){return n[n.byteLength-1]===13?n.subarray(0,-1):n}c(Ln,"stripCarriageReturn");function pi(n,e,t={}){let i=Me(t.maxMessageBytes),r=new TextEncoder,u=new TextDecoder,h=!1,p,z=Promise.resolve(),m=c(v=>{let E=JSON.stringify(v)+`
|
|
2
|
+
import{b as xs}from"./chunk-WMBOXX7G.js";import{b as Es,c as Ts}from"./chunk-ZSZXA7WB.js";import"./chunk-4DYWVGVS.js";import"./chunk-4TO743HO.js";import{a as vt,e as bs,g as ys,j as tt,p as Ss}from"./chunk-A77DLBR4.js";import{m as ks}from"./chunk-G4FRBT7G.js";import"./chunk-PSY6IRJE.js";import"./chunk-PKJHN666.js";import"./chunk-Z33RVGP6.js";import"./chunk-7PKDJHT6.js";import"./chunk-65WRWLUD.js";import"./chunk-LSKMALD6.js";import"./chunk-B66QCXH2.js";import"./chunk-PYNW5OFA.js";import"./chunk-MOXIGLN2.js";import"./chunk-RHMULF56.js";import"./chunk-VFH5C6D2.js";import"./chunk-UOFDKMRU.js";import"./chunk-AN525SPP.js";import"./chunk-IZ6DLEVY.js";import"./chunk-M5X7XKXY.js";import"./chunk-65FJWWXG.js";import"./chunk-SYUKES6H.js";import"./chunk-EYTTZ5H4.js";import"./chunk-XY7HFXLH.js";import"./chunk-6I5AUTVO.js";import"./chunk-DKOVZ6R2.js";import"./chunk-N5EAVX4G.js";import"./chunk-U7X5ZLAL.js";import"./chunk-7PXZ4X4P.js";import"./chunk-N73MU2C3.js";import"./chunk-SO4GMSNP.js";import"./chunk-NMMHXYDJ.js";import"./chunk-QLGP2OAQ.js";import{h as Is}from"./chunk-WZ35ICTE.js";import"./chunk-VS2LOUCT.js";import"./chunk-DMFUEUAZ.js";import"./chunk-AFKFN25T.js";import"./chunk-G4747MOW.js";import"./chunk-GF55VEMR.js";import"./chunk-FAKDGLZQ.js";import"./chunk-KCJVFLBB.js";import"./chunk-GW766ZSO.js";import"./chunk-VJYOKU3C.js";import"./chunk-SSJV3VX7.js";import"./chunk-7KWD2I6W.js";import{a as As,j as At}from"./chunk-RY46UPBO.js";import"./chunk-OFJPOTES.js";import"./chunk-PLROXHG2.js";import"./chunk-YU3C6U5V.js";import"./chunk-PHZZBXDO.js";import"./chunk-KVTBX2UP.js";import"./chunk-U7D6Q744.js";import{I as nt,K as Cs,P as st,a as Rs,c as Ct,g as vs,w as Ce,x as oe}from"./chunk-HG2YFMVU.js";import"./chunk-OQPJ7FJF.js";import"./chunk-BL3CZWWD.js";import"./chunk-FYWQWKVS.js";import"./chunk-GD3RCUDH.js";import"./chunk-7OKZCJHS.js";import"./chunk-UTIELP6F.js";import"./chunk-7NCM6GBN.js";import"./chunk-4V73I4OL.js";import"./chunk-LE75SVEL.js";import"./chunk-6ESBAHWK.js";import"./chunk-LZPCA6DH.js";import"./chunk-L3KS6MOV.js";import"./chunk-7J2NMUTK.js";import"./chunk-VEBW7NKD.js";import"./chunk-W45RKGM6.js";import"./chunk-AUO5DCEU.js";import"./chunk-Y4I6CFZJ.js";import"./chunk-4BUM6JEC.js";import"./chunk-UGFSAG4U.js";import"./chunk-SSHE6B7Z.js";import"./chunk-JFXINDOQ.js";import"./chunk-EDYCSW22.js";import"./chunk-JT5YQ52I.js";import"./chunk-XGY4OQLC.js";import"./chunk-PAYFJHPO.js";import"./chunk-WD4KAKEX.js";import"./chunk-2PXKSAG6.js";import"./chunk-ULTV6INR.js";import"./chunk-WGQ3FMRF.js";import"./chunk-JXLDEYRW.js";import"./chunk-JVMSN7LH.js";import"./chunk-YI6ME6PU.js";import"./chunk-DRLP7GIU.js";import"./chunk-BU6MW65V.js";import"./chunk-LVXL7T5O.js";import"./chunk-HIQPGYVH.js";import"./chunk-DXJC3QW7.js";import"./chunk-P4QM63L3.js";import"./chunk-MTP3B2SU.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-I6VMRQF4.js";import"./chunk-D6L6UNUQ.js";import"./chunk-AJXWJLZA.js";import"./chunk-OKKNDQJF.js";import"./chunk-4PUOWSDE.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-4N4EH3RJ.js";import"./chunk-GY7YSD6J.js";import"./chunk-KUE46HTH.js";import"./chunk-JCLTFDVW.js";import"./chunk-6FA3GG5B.js";import"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import{a as _s,c as ws}from"./chunk-UGOK7VTC.js";import"./chunk-ZFJWA4JK.js";import{A as G,a as fs,e as s,f as et,g as O,h as F,i as q,k as zs,l as d,m as w,n as a,o as me,p as T,r as ee,s as l,u as f,y as ms,z as gs}from"./chunk-X2J2P5ZT.js";import{a as c,c as ho,e as fo}from"./chunk-FTQLQJQV.js";var Mi=ho(Qn=>{"use strict";var Ai=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,Qc=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Ii=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Kc=/\\([\u000b\u0020-\u00ff])/g,Zc=/([\\"])/g,ki=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Qn.format=Xc;Qn.parse=Yc;function Xc(n){if(!n||typeof n!="object")throw new TypeError("argument obj is required");var e=n.parameters,t=n.type;if(!t||!ki.test(t))throw new TypeError("invalid type");var i=t;if(e&&typeof e=="object")for(var r,u=Object.keys(e).sort(),h=0;h<u.length;h++){if(r=u[h],!Ii.test(r))throw new TypeError("invalid parameter name");i+="; "+r+"="+td(e[r])}return i}c(Xc,"format");function Yc(n){if(!n)throw new TypeError("argument string is required");var e=typeof n=="object"?ed(n):n;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var t=e.indexOf(";"),i=t!==-1?e.slice(0,t).trim():e.trim();if(!ki.test(i))throw new TypeError("invalid media type");var r=new nd(i.toLowerCase());if(t!==-1){var u,h,p;for(Ai.lastIndex=t;h=Ai.exec(e);){if(h.index!==t)throw new TypeError("invalid parameter format");t+=h[0].length,u=h[1].toLowerCase(),p=h[2],p.charCodeAt(0)===34&&(p=p.slice(1,-1),p.indexOf("\\")!==-1&&(p=p.replace(Kc,"$1"))),r.parameters[u]=p}if(t!==e.length)throw new TypeError("invalid parameter format")}return r}c(Yc,"parse");function ed(n){var e;if(typeof n.getHeader=="function"?e=n.getHeader("content-type"):typeof n.headers=="object"&&(e=n.headers&&n.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}c(ed,"getcontenttype");function td(n){var e=String(n);if(Ii.test(e))return e;if(e.length>0&&!Qc.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(Zc,"\\$1")+'"'}c(td,"qstring");function nd(n){this.parameters=Object.create(null),this.type=n}c(nd,"ContentType")});import{Readable as Ld,Writable as Gd}from"node:stream";var _={initialize:"initialize",authenticate:"authenticate",providers_list:"providers/list",providers_set:"providers/set",providers_disable:"providers/disable",session_new:"session/new",session_load:"session/load",session_set_mode:"session/set_mode",session_set_config_option:"session/set_config_option",session_prompt:"session/prompt",session_cancel:"session/cancel",mcp_message:"mcp/message",session_list:"session/list",session_delete:"session/delete",session_fork:"session/fork",session_resume:"session/resume",session_close:"session/close",logout:"logout",nes_start:"nes/start",nes_suggest:"nes/suggest",nes_accept:"nes/accept",nes_reject:"nes/reject",nes_close:"nes/close",document_did_open:"document/didOpen",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_save:"document/didSave",document_did_focus:"document/didFocus"},I={session_request_permission:"session/request_permission",session_update:"session/update",fs_write_text_file:"fs/write_text_file",fs_read_text_file:"fs/read_text_file",terminal_create:"terminal/create",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit",terminal_kill:"terminal/kill",mcp_message:"mcp/message",elicitation_create:"elicitation/create",elicitation_complete:"elicitation/complete"},It={cancel_request:"$/cancel_request"};var Ms=Symbol("skippedItem");function o(n,e){return n.catch(e)}c(o,"defaultOnError");function V(n,e){let t=n.catch(e);return G.unknown().transform((i,r)=>i!==void 0?t.parse(i):(r.addIssue({code:"custom",message:"Required value is missing"}),G.NEVER))}c(V,"requiredDefaultOnError");function Os(n,e){if(n===null||typeof n!="object"||Array.isArray(n))return;let t=n[e];return typeof t=="string"?t:void 0}c(Os,"stringTag");function ge(n,e,t){return n.superRefine((i,r)=>{let u=Os(i,e);u!==void 0&&t.includes(u)&&r.addIssue({code:"custom",path:[e],message:`${e} ${JSON.stringify(u)} is reserved by a known variant, but the value does not match that variant's schema`})})}c(ge,"excludeKnownTags");function _e(n,e,t){return G.unknown().transform((i,r)=>{let u=n.safeParse(i);if(!u.success){for(let z of u.error.issues)r.addIssue({...z,input:i});return G.NEVER}let h=u.data,p=Os(i,e);if(p!==void 0&&!t.includes(p)){let z=i;for(let[m,g]of Object.entries(z))m!=="__proto__"&&(Object.hasOwn(h,m)||(h[m]=g))}return h})}c(_e,"preserveCustomPayload");function C(n){return G.array(n.catch(Ms)).transform(e=>e.filter(t=>t!==Ms))}c(C,"vecSkipError");var te=T([O(),s()]).nullable(),A=s(),Mt=a({sessionId:A,path:s(),content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Ot=a({sessionId:A,path:s(),line:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),limit:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Nt=s(),js=T([f("read"),f("edit"),f("delete"),f("move"),f("search"),f("execute"),f("think"),f("fetch"),f("switch_mode"),f("other")]),qs=T([f("pending"),f("in_progress"),f("completed"),f("failed")]),mo=T([f("assistant"),f("user")]),Ae=a({audience:o(C(mo).nullish(),()=>{}),lastModified:o(s().nullish(),()=>{}),priority:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),go=a({annotations:o(Ae.nullish(),()=>{}),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),_o=a({annotations:o(Ae.nullish(),()=>{}),data:s(),mimeType:s(),uri:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),wo=a({annotations:o(Ae.nullish(),()=>{}),data:s(),mimeType:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),bo=a({annotations:o(Ae.nullish(),()=>{}),description:o(s().nullish(),()=>{}),mimeType:o(s().nullish(),()=>{}),name:s(),size:o(O().nullish(),()=>{}),title:o(s().nullish(),()=>{}),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),yo=a({mimeType:o(s().nullish(),()=>{}),text:s(),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),So=a({blob:s(),mimeType:o(s().nullish(),()=>{}),uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),xo=T([yo,So]),Eo=a({annotations:o(Ae.nullish(),()=>{}),resource:xo,_meta:o(l(s(),d()).nullish(),()=>{})}),re=T([go.and(a({type:f("text")})),_o.and(a({type:f("image")})),wo.and(a({type:f("audio")})),bo.and(a({type:f("resource_link")})),Eo.and(a({type:f("resource")}))]),To=a({content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),Ro=a({path:s(),oldText:o(s().nullish(),()=>{}),newText:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),we=s(),vo=a({terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ps=T([To.and(a({type:f("content")})),Ro.and(a({type:f("diff")})),vo.and(a({type:f("terminal")}))]),Ds=a({path:s(),line:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Hs=a({toolCallId:Nt,kind:o(js.nullish(),()=>{}),status:o(qs.nullish(),()=>{}),title:o(s().nullish(),()=>{}),name:o(s().nullish(),()=>{}),content:o(C(Ps).nullish(),()=>{}),locations:o(C(Ds).nullish(),()=>{}),rawInput:o(d().optional(),()=>{}),rawOutput:o(d().optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Us=s(),Co=T([f("allow_once"),f("allow_always"),f("reject_once"),f("reject_always")]),Ao=a({optionId:Us,name:s(),kind:Co,_meta:o(l(s(),d()).nullish(),()=>{})}),jt=a({sessionId:A,toolCall:Hs,options:w(Ao),_meta:o(l(s(),d()).nullish(),()=>{})}),Ls=a({name:s(),value:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),qt=a({sessionId:A,command:s(),args:o(C(s()).optional(),()=>[]),env:o(C(Ls).optional(),()=>[]),cwd:o(s().nullish(),()=>{}),outputByteLimit:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Pt=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Dt=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ht=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ut=a({sessionId:A,terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),Ie=a({sessionId:A,toolCallId:o(Nt.nullish(),()=>{})}),ke=a({requestId:te}),Io=f("object"),ko=T([f("email"),f("uri"),f("date"),f("date-time")]),Gs=a({const:s(),title:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Lt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minLength:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),maxLength:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),pattern:s().nullish(),format:ko.nullish(),default:o(s().nullish(),()=>{}),enum:w(s()).nullish(),oneOf:w(Gs).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Gt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:O().nullish(),maximum:O().nullish(),default:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$t=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minimum:O().nullish(),maximum:O().nullish(),default:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ft=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),default:o(q().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Wt=a({enum:w(s()),_meta:o(l(s(),d()).nullish(),()=>{})}),$s=a({anyOf:w(Gs),_meta:o(l(s(),d()).nullish(),()=>{})}),Mo=_e(T([Wt.and(a({type:f("string")})),ge(a({type:s()}),"type",["string"]),$s]),"type",["string"]),Bt=a({title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),minItems:O().nullish(),maxItems:O().nullish(),items:Mo,default:o(C(s()).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Oo=_e(T([Lt.and(a({type:f("string")})),Gt.and(a({type:f("number")})),$t.and(a({type:f("integer")})),Ft.and(a({type:f("boolean")})),Bt.and(a({type:f("array")})),ge(a({type:s()}),"type",["array","boolean","integer","number","string"])]),"type",["array","boolean","integer","number","string"]),No=a({type:o(Io.optional().default("object"),()=>"object"),title:o(s().nullish(),()=>{}),properties:l(s(),Oo).optional().default({}),required:w(s()).nullish(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Vt=ee(T([Ie,ke]),a({requestedSchema:No})),Fs=s(),Jt=ee(T([Ie,ke]),a({elicitationId:Fs,url:et()})),Qt=_e(ee(T([Vt.and(a({mode:f("form")})),Jt.and(a({mode:f("url")})),ge(ee(T([Ie,ke]),a({mode:s()})),"mode",["form","url"])]),a({message:s(),_meta:o(l(s(),d()).nullish(),()=>{})})),"mode",["form","url"]),Kt=s(),Ws=s(),jo=a({serverId:Kt,requestId:Ws,method:s(),params:l(s(),d()).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Bs=d(),Qd=a({id:te,method:s(),params:T([Mt,Ot,jt,qt,Pt,Dt,Ht,Ut,Qt,jo,Bs]).nullish()}),Vs=F().gte(0).lte(65535),qo=a({image:o(q().optional().default(!1),()=>!1),audio:o(q().optional().default(!1),()=>!1),embeddedContext:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Po=a({http:o(q().optional().default(!1),()=>!1),sse:o(q().optional().default(!1),()=>!1),acp:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Do=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ho=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Uo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Lo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Go=a({_meta:o(l(s(),d()).nullish(),()=>{})}),$o=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Fo=a({list:o(Do.nullish(),()=>{}),delete:o(Ho.nullish(),()=>{}),additionalDirectories:o(Uo.nullish(),()=>{}),fork:o(Lo.nullish(),()=>{}),resume:o(Go.nullish(),()=>{}),close:o($o.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Wo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Bo=a({logout:o(Wo.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Vo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Jo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Qo=T([f("full"),f("incremental")]),Ko=a({syncKind:Qo,_meta:o(l(s(),d()).nullish(),()=>{})}),Zo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Xo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Yo=a({_meta:o(l(s(),d()).nullish(),()=>{})}),er=a({didOpen:o(Jo.nullish(),()=>{}),didChange:o(Ko.nullish(),()=>{}),didClose:o(Zo.nullish(),()=>{}),didSave:o(Xo.nullish(),()=>{}),didFocus:o(Yo.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),tr=a({document:o(er.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),nr=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),sr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ir=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),or=a({maxCount:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),rr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ar=a({_meta:o(l(s(),d()).nullish(),()=>{})}),cr=a({recentFiles:o(nr.nullish(),()=>{}),relatedSnippets:o(sr.nullish(),()=>{}),editHistory:o(ir.nullish(),()=>{}),userActions:o(or.nullish(),()=>{}),openFiles:o(rr.nullish(),()=>{}),diagnostics:o(ar.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),dr=a({events:o(tr.nullish(),()=>{}),context:o(cr.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Js=T([f("utf-16"),f("utf-32"),f("utf-8")]),lr=a({loadSession:o(q().optional().default(!1),()=>!1),promptCapabilities:o(qo.optional().default({image:!1,audio:!1,embeddedContext:!1}),()=>({image:!1,audio:!1,embeddedContext:!1})),mcpCapabilities:o(Po.optional().default({http:!1,sse:!1,acp:!1}),()=>({http:!1,sse:!1,acp:!1})),sessionCapabilities:o(Fo.optional().default({}),()=>({})),auth:o(Bo.optional().default({}),()=>({})),providers:o(Vo.nullish(),()=>{}),nes:o(dr.nullish(),()=>{}),positionEncoding:o(Js.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Zt=s(),ur=a({id:Zt,name:s(),description:o(s().nullish(),()=>{}),args:o(C(s()).optional(),()=>[]),env:o(l(s(),s()).optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),pr=a({id:Zt,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),hr=T([ur.and(a({type:f("terminal")})),pr]),Qs=a({name:s(),title:o(s().nullish(),()=>{}),version:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),fr=a({protocolVersion:Vs,agentCapabilities:o(lr.optional().default({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}}),()=>({loadSession:!1,promptCapabilities:{image:!1,audio:!1,embeddedContext:!1},mcpCapabilities:{http:!1,sse:!1,acp:!1},sessionCapabilities:{},auth:{}})),authMethods:o(C(hr).optional().default([]),()=>[]),agentInfo:o(Qs.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),zr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Xt=s(),Yt=T([f("anthropic"),f("openai"),f("azure"),f("vertex"),f("bedrock"),s()]),mr=a({apiType:Yt,baseUrl:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),gr=a({providerId:Xt,supported:V(C(Yt),()=>[]),required:q(),current:mr.nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),_r=a({providers:w(gr),_meta:o(l(s(),d()).nullish(),()=>{})}),wr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),br=a({_meta:o(l(s(),d()).nullish(),()=>{})}),yr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),it=s(),Sr=a({id:it,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ot=a({currentModeId:it,availableModes:V(C(Sr),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Ks=s(),xr=T([f("mode"),f("model"),f("model_config"),f("thought_level"),s()]),en=s(),Zs=a({value:en,name:s(),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Er=s(),Tr=a({group:Er,name:s(),options:V(C(Zs),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Rr=T([w(Zs),w(Tr)]),vr=a({currentValue:en,options:Rr}),Cr=a({currentValue:q()}),be=ee(T([vr.and(a({type:f("select")})),Cr.and(a({type:f("boolean")}))]),a({id:Ks,name:s(),description:o(s().nullish(),()=>{}),category:o(xr.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})})),Ar=a({sessionId:A,modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ir=a({modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),kr=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Mr=a({sessions:V(C(kr),()=>[]),nextCursor:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Or=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Nr=a({sessionId:A,modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),jr=a({modes:o(ot.nullish(),()=>{}),configOptions:o(C(be).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),qr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Pr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Dr=a({configOptions:V(C(be),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),Xs=T([f("end_turn"),f("max_tokens"),f("max_turn_requests"),f("refusal"),f("cancelled")]),Ys=a({totalTokens:O(),inputTokens:O(),outputTokens:O(),thoughtTokens:o(O().nullish(),()=>{}),cachedReadTokens:o(O().nullish(),()=>{}),cachedWriteTokens:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Hr=a({stopReason:Xs,usage:o(Ys.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ur=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),ye=s(),ne=a({line:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),character:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),_meta:o(l(s(),d()).nullish(),()=>{})}),Se=a({start:ne,end:ne,_meta:o(l(s(),d()).nullish(),()=>{})}),Lr=a({range:Se,newText:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Gr=a({id:ye,uri:s(),edits:w(Lr),cursorPosition:o(ne.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$r=a({id:ye,uri:s(),position:ne,_meta:o(l(s(),d()).nullish(),()=>{})}),Fr=a({id:ye,uri:s(),position:ne,newName:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Wr=a({id:ye,uri:s(),search:s(),replace:s(),isRegex:q().nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Br=T([Gr.and(a({kind:f("edit")})),$r.and(a({kind:f("jump")})),Fr.and(a({kind:f("rename")})),Wr.and(a({kind:f("searchAndReplace")}))]),Vr=a({suggestions:w(Br),_meta:o(l(s(),d()).nullish(),()=>{})}),Jr=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ei=d(),Qr=T([f(-32700),f(-32600),f(-32601),f(-32602),f(-32603),f(-32800),f(-32e3),f(-32002),F().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"})]),ti=a({code:Qr,message:s(),data:o(d().optional(),()=>{})}),Kd=T([a({id:te,result:T([fr,zr,_r,wr,br,yr,Ar,Ir,Mr,Or,Nr,jr,qr,Pr,Dr,Hr,Ur,Vr,Jr,ei])}),a({id:te,error:ti})]),tn=s(),kt=a({content:re,messageId:o(tn.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Kr=a({toolCallId:Nt,title:s(),name:o(s().nullish(),()=>{}),kind:o(js.optional(),()=>{}),status:o(qs.optional(),()=>{}),content:o(C(Ps).optional(),()=>[]),locations:o(C(Ds).optional(),()=>[]),rawInput:o(d().optional(),()=>{}),rawOutput:o(d().optional(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Zr=T([f("high"),f("medium"),f("low")]),Xr=T([f("pending"),f("in_progress"),f("completed")]),ni=a({content:s(),priority:Zr,status:Xr,_meta:o(l(s(),d()).nullish(),()=>{})}),Yr=a({entries:V(C(ni),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),rt=s(),ea=a({planId:rt,entries:V(C(ni),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),ta=a({planId:rt,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),na=a({planId:rt,content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),sa=T([ea.and(a({type:f("items")})),ta.and(a({type:f("file")})),na.and(a({type:f("markdown")}))]),ia=a({plan:sa,_meta:o(l(s(),d()).nullish(),()=>{})}),oa=a({planId:rt,_meta:o(l(s(),d()).nullish(),()=>{})}),ra=a({hint:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),aa=ra,ca=a({name:s(),description:s(),input:o(aa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),da=a({availableCommands:V(C(ca),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),la=a({currentModeId:it,_meta:o(l(s(),d()).nullish(),()=>{})}),ua=a({configOptions:V(C(be),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),pa=a({title:o(s().nullish(),()=>{}),updatedAt:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ha=a({amount:O(),currency:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),fa=a({used:O(),size:O(),cost:o(ha.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),za=T([f("info"),f("warning"),f("error"),s()]),ma=a({severity:za,title:s().min(1),description:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),si=s(),ga=T([f("in_progress"),f("completed"),f("failed"),f("cancelled"),s()]),_a=a({compactionId:si,status:ga,summary:o(C(re).nullish(),()=>{}),error:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),wa=a({compactionId:si,content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),ba=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ya=a({cancel:o(ba.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),nn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),sn=a({stopReason:o(Xs.nullish(),()=>{}),usage:o(Ys.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),on=a({_meta:o(l(s(),d()).nullish(),()=>{})}),rn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Sa=_e(T([nn.and(a({state:f("running")})),sn.and(a({state:f("idle")})),on.and(a({state:f("requires_action")})),rn.and(a({state:f("unknown")})),ge(a({state:s()}),"state",["idle","requires_action","running","unknown"])]),"state",["idle","requires_action","running","unknown"]),xa=a({sessionId:A,title:o(s().nullish(),()=>{}),description:o(s().nullish(),()=>{}),capabilities:o(ya.nullish(),()=>{}),state:o(Sa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ea=a({messageId:tn,senderSessionId:o(A.nullish(),()=>{}),recipientSessionId:o(A.nullish(),()=>{}),content:o(C(re).nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ta=a({messageId:tn,senderSessionId:o(A.nullish(),()=>{}),recipientSessionId:o(A.nullish(),()=>{}),content:re,_meta:o(l(s(),d()).nullish(),()=>{})}),Ra=T([kt.and(a({sessionUpdate:f("user_message_chunk")})),kt.and(a({sessionUpdate:f("agent_message_chunk")})),kt.and(a({sessionUpdate:f("agent_thought_chunk")})),Kr.and(a({sessionUpdate:f("tool_call")})),Hs.and(a({sessionUpdate:f("tool_call_update")})),Yr.and(a({sessionUpdate:f("plan")})),ia.and(a({sessionUpdate:f("plan_update")})),oa.and(a({sessionUpdate:f("plan_removed")})),da.and(a({sessionUpdate:f("available_commands_update")})),la.and(a({sessionUpdate:f("current_mode_update")})),ua.and(a({sessionUpdate:f("config_option_update")})),pa.and(a({sessionUpdate:f("session_info_update")})),fa.and(a({sessionUpdate:f("usage_update")})),ma.and(a({sessionUpdate:f("notice")})),_a.and(a({sessionUpdate:f("compaction_update")})),wa.and(a({sessionUpdate:f("compaction_summary_chunk")})),xa.and(a({sessionUpdate:f("subagent_update")})),Ea.and(a({sessionUpdate:f("session_message")})),Ta.and(a({sessionUpdate:f("session_message_chunk")}))]),at=a({sessionId:A,update:Ra,_meta:o(l(s(),d()).nullish(),()=>{})}),an=a({elicitationId:Fs,_meta:o(l(s(),d()).nullish(),()=>{})}),ii=d(),Zd=a({method:s(),params:T([at,an,ii]).nullish()}),va=a({readTextFile:o(q().optional().default(!1),()=>!1),writeTextFile:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),Ca=l(s(),d()),Aa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ia=a({boolean:o(Aa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),ka=l(s(),d()),Ma=a({compaction:o(Ca.nullish(),()=>{}),configOptions:o(Ia.nullish(),()=>{}),notices:o(ka.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Oa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Na=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ja=a({terminal:o(q().optional().default(!1),()=>!1),_meta:o(l(s(),d()).nullish(),()=>{})}),qa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Pa=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Da=a({form:o(qa.nullish(),()=>{}),url:o(Pa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ha=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ua=a({_meta:o(l(s(),d()).nullish(),()=>{})}),La=a({_meta:o(l(s(),d()).nullish(),()=>{})}),Ga=a({jump:o(Ha.nullish(),()=>{}),rename:o(Ua.nullish(),()=>{}),searchAndReplace:o(La.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),$a=a({fs:o(va.optional().default({readTextFile:!1,writeTextFile:!1}),()=>({readTextFile:!1,writeTextFile:!1})),terminal:o(q().optional().default(!1),()=>!1),session:o(Ma.nullish(),()=>{}),subagents:o(Oa.nullish(),()=>{}),plan:o(Na.nullish(),()=>{}),auth:o(ja.optional().default({terminal:!1}),()=>({terminal:!1})),elicitation:o(Da.nullish(),()=>{}),nes:o(Ga.nullish(),()=>{}),positionEncodings:o(C(Js).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),cn=a({protocolVersion:Vs,clientCapabilities:o($a.optional().default({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}),()=>({fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}})),clientInfo:o(Qs.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),dn=a({methodId:Zt,_meta:o(l(s(),d()).nullish(),()=>{})}),ln=a({_meta:o(l(s(),d()).nullish(),()=>{})}),un=a({providerId:Xt,apiType:Yt,baseUrl:s(),headers:l(s(),s()).optional(),_meta:o(l(s(),d()).nullish(),()=>{})}),pn=a({providerId:Xt,_meta:o(l(s(),d()).nullish(),()=>{})}),hn=a({_meta:o(l(s(),d()).nullish(),()=>{})}),oi=a({name:s(),value:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Fa=a({name:s(),url:s(),headers:w(oi),_meta:o(l(s(),d()).nullish(),()=>{})}),Wa=a({name:s(),url:s(),headers:w(oi),_meta:o(l(s(),d()).nullish(),()=>{})}),Ba=a({name:s(),serverId:Kt,_meta:o(l(s(),d()).nullish(),()=>{})}),Va=a({name:s(),command:s(),args:w(s()),env:w(Ls),_meta:o(l(s(),d()).nullish(),()=>{})}),ct=T([Fa.and(a({type:f("http")})),Wa.and(a({type:f("sse")})),Ba.and(a({type:f("acp")})),Va]),fn=a({cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:V(C(ct),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),zn=a({mcpServers:V(C(ct),()=>[]),cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),mn=a({cwd:s().nullish(),cursor:s().nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),gn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),_n=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:o(C(ct).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),wn=a({sessionId:A,cwd:s(),additionalDirectories:o(C(s()).optional(),()=>[]),mcpServers:o(C(ct).optional(),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),bn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),yn=a({sessionId:A,modeId:it,_meta:o(l(s(),d()).nullish(),()=>{})}),Sn=ee(T([a({value:q(),type:f("boolean")}),a({value:en})]),a({sessionId:A,configId:Ks,_meta:o(l(s(),d()).nullish(),()=>{})})),xn=a({sessionId:A,prompt:w(re),_meta:o(l(s(),d()).nullish(),()=>{})}),Ja=a({uri:s(),name:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Qa=a({name:s(),owner:s(),remoteUrl:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),En=a({workspaceUri:o(s().nullish(),()=>{}),workspaceFolders:w(Ja).nullish(),repository:o(Qa.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),Ka=T([f("automatic"),f("diagnostic"),f("manual")]),Za=a({uri:s(),languageId:s(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Xa=a({startLine:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),endLine:F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Ya=a({uri:s(),excerpts:w(Xa),_meta:o(l(s(),d()).nullish(),()=>{})}),ec=a({uri:s(),diff:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),tc=a({action:s(),uri:s(),position:ne,timestampMs:O(),_meta:o(l(s(),d()).nullish(),()=>{})}),nc=a({uri:s(),languageId:s(),visibleRange:o(Se.nullish(),()=>{}),lastFocusedMs:o(O().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),sc=T([f("error"),f("warning"),f("information"),f("hint")]),ic=a({uri:s(),range:Se,severity:sc,message:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),oc=a({recentFiles:w(Za).nullish(),relatedSnippets:w(Ya).nullish(),editHistory:w(ec).nullish(),userActions:w(tc).nullish(),openFiles:w(nc).nullish(),diagnostics:w(ic).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Tn=a({sessionId:A,uri:s(),version:O(),position:ne,selection:Se.nullish(),triggerKind:Ka,context:oc.nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),Rn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),Xd=a({id:te,method:s(),params:T([cn,dn,ln,un,pn,hn,fn,zn,mn,gn,_n,wn,bn,yn,Sn,xn,En,Tn,Rn,Bs]).nullish()}),rc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),ac=a({content:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),cc=a({optionId:Us,_meta:o(l(s(),d()).nullish(),()=>{})}),dc=T([a({outcome:f("cancelled")}),cc.and(a({outcome:f("selected")}))]),lc=a({outcome:dc,_meta:o(l(s(),d()).nullish(),()=>{})}),uc=a({terminalId:we,_meta:o(l(s(),d()).nullish(),()=>{})}),pc=a({exitCode:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),hc=a({output:s(),truncated:q(),exitStatus:o(pc.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),fc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),zc=a({exitCode:o(F().gte(0).max(4294967295,{error:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),()=>{}),signal:o(s().nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),mc=a({_meta:o(l(s(),d()).nullish(),()=>{})}),gc=T([s(),O(),O(),q(),w(s())]),vn=a({content:l(s(),gc).nullish()}),_c=_e(ee(T([vn.and(a({action:f("accept")})),a({action:f("decline")}),a({action:f("cancel")}),ge(a({action:s()}),"action",["accept","cancel","decline"])]),a({_meta:o(l(s(),d()).nullish(),()=>{})})),"action",["accept","cancel","decline"]),wc=me({code:F().min(-2147483648,{error:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{error:"Invalid value: Expected int32 to be <= 2147483647"}),message:s(),data:d().optional()}),bc=T([a({result:d(),_meta:o(l(s(),d()).nullish(),()=>{})}),a({error:wc,_meta:o(l(s(),d()).nullish(),()=>{})})]),Yd=T([a({id:te,result:T([rc,ac,lc,uc,hc,fc,zc,mc,_c,bc,ei])}),a({id:te,error:ti})]),Cn=a({sessionId:A,_meta:o(l(s(),d()).nullish(),()=>{})}),An=a({sessionId:A,uri:s(),languageId:s(),version:O(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),yc=a({range:Se.nullish(),text:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),In=a({sessionId:A,uri:s(),version:O(),contentChanges:V(C(yc),()=>[]),_meta:o(l(s(),d()).nullish(),()=>{})}),kn=a({sessionId:A,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),Mn=a({sessionId:A,uri:s(),_meta:o(l(s(),d()).nullish(),()=>{})}),On=a({sessionId:A,uri:s(),version:O(),position:ne,visibleRange:Se,_meta:o(l(s(),d()).nullish(),()=>{})}),Nn=a({sessionId:A,id:ye,_meta:o(l(s(),d()).nullish(),()=>{})}),Sc=T([f("rejected"),f("ignored"),f("replaced"),f("cancelled")]),jn=a({sessionId:A,id:ye,reason:o(Sc.nullish(),()=>{}),_meta:o(l(s(),d()).nullish(),()=>{})}),xc=a({serverId:Kt,requestId:Ws,method:s(),params:l(s(),d()).nullish(),_meta:o(l(s(),d()).nullish(),()=>{})}),el=a({method:s(),params:T([Cn,An,In,kn,Mn,On,Nn,jn,xc,ii]).nullish()}),tl=a({requestId:te,_meta:o(l(s(),d()).nullish(),()=>{})});var ai="$/cancel_request";function dt(n){return Hn(n)&&"id"in n&&typeof n.method=="string"&&Un(n.id)}c(dt,"isRequestMessage");function di(n){if(!Hn(n)||"method"in n||!("id"in n)||!Un(n.id))return!1;let e=Object.hasOwn(n,"result"),t=Object.hasOwn(n,"error");return e===t?!1:!t||Rc(n.error)}c(di,"isResponseMessage");function xe(n){return Hn(n)&&!("id"in n)&&typeof n.method=="string"}c(xe,"isNotificationMessage");function se(n){return typeof n=="object"&&n!==null}c(se,"isRecord");function Hn(n){return se(n)&&n.jsonrpc==="2.0"}c(Hn,"isJsonRpcEnvelope");function Un(n){return n===null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}c(Un,"isJsonRpcId");function ci(n){return se(n)&&!("method"in n)&&("id"in n||"result"in n||"error"in n)}c(ci,"isResponseShapedMessage");function Ec(n){let e=!1,t=!1,i=!1,r=!1;for(let u of n)e||=dt(u)||xe(u),t||=di(u),se(u)&&(i||="method"in u,r||="result"in u||"error"in u);return e?!1:t?!0:r&&!i}c(Ec,"isResponseBatch");function Tc(n){if(!(!se(n)||!Un(n.requestId)))return n.requestId}c(Tc,"cancelRequestId");function Rc(n){return se(n)&&typeof n.code=="number"&&Number.isInteger(n.code)&&typeof n.message=="string"}c(Rc,"isErrorResponse");var Z={yes(){return{handled:!0}},no(n,e=!1){return{handled:!1,message:n,retry:e}}};function ae(n){let e=Promise.reject(n);return e.catch(()=>{}),e}c(ae,"rejectedPromise");function vc(n){if(n instanceof Error||typeof n=="object"&&n!=null&&"message"in n&&typeof n.message=="string")return n.message}c(vc,"errorDetails");function Cc(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ZodError"&&"issues"in n&&Array.isArray(n.issues)&&"format"in n&&typeof n.format=="function"}c(Cc,"isZodError");function li(n){if(n instanceof S)return n.toResult();if(Cc(n))return S.invalidParams(n.format()).toResult();let e=vc(n);try{return S.internalError(e?JSON.parse(e):{}).toResult()}catch{return S.internalError({details:e}).toResult()}}c(li,"errorToResult");function Ac(n){return n instanceof S&&n.code===-32800?n:S.requestCancelled(n)}c(Ac,"requestCancelledError");function Ic(n,e){let t=kc(n,e);return t?t.toResult():li(n)}c(Ic,"errorToRequestResult");function kc(n,e){if(!(!e.aborted||!Mc(n)))return Ac(e.reason)}c(kc,"abortErrorToRequestCancelled");function Mc(n){if(typeof n!="object"||n===null)return!1;let e=n;return e.name==="AbortError"||e.code==="ABORT_ERR"}c(Mc,"isAbortError");var qn=class{static{c(this,"RequestResponder")}id;sendResult;signal;finishRequest;didRespond=!1;constructor(e,t,i=new AbortController().signal,r){this.id=e,this.sendResult=t,this.signal=i,this.finishRequest=r}get responded(){return this.didRespond}respond(e){return this.respondWithResult({result:e??null})}respondWithError(e){let t=e instanceof S?e.toErrorResponse():e;return this.respondWithResult({error:t})}respondWithResult(e){return this.didRespond?ae(new Error("JSON-RPC request already responded")):(this.didRespond=!0,this.sendResult(e).finally(()=>{this.finishRequest?.()}))}},Oc=new WeakMap;var Te=class{static{c(this,"HandlerRegistration")}disposeHandler;active=!0;constructor(e){this.disposeHandler=e}dispose(){this.active&&(this.active=!1,this.disposeHandler())}[Symbol.dispose](){this.dispose()}runIndefinitely(){return this}},Pn=class{static{c(this,"ConnectionContext")}connection;constructor(e){this.connection=e}sendRequest(e,t,i,r){return this.connection.sendRequest(e,t,i,r)}sendNotification(e,t){return this.connection.sendNotification(e,t)}sendBatch(e){return this.connection.sendBatch(e)}sendCancelRequest(e){return this.connection.sendCancelRequest(e)}addDynamicHandler(e){return this.connection.addDynamicHandler(e)}get signal(){return this.connection.signal}get closed(){return this.connection.closed}},Re=class{static{c(this,"Connection")}pendingResponses=new Map;incomingRequests=new Map;nextRequestId=0;staticHandlers=[];dynamicHandlers=new Set;stream;writeQueue=Promise.resolve();abortController=new AbortController;closedPromise;retryQueue=[];context=new Pn(this);receiveReader;allowBatches=!0;constructor(e,t,i,r){if(typeof e=="function"){let z=e,m=t,g=i;this.initialize(g,[...r?.handlers??[],this.legacyHandler(z,m)],r);return}let u=e,h=t,p=i;this.initialize(u,[...p?.handlers??[],...h],p)}static builder(){return new Dn}runUntil(e){let t=!1,i=Promise.resolve().then(()=>e(this.context)).finally(()=>{t=!0}),r=this.closed.then(()=>{if(t)return new Promise(()=>{});throw this.closedReason()});return Promise.race([i,r]).finally(()=>{t=!0,this.close()})}addDynamicHandler(e){if(this.dynamicHandlers.add(e),this.retryQueue.length>0)for(let t of this.retryQueue.splice(0))this.processIncomingMessage(t).catch(i=>this.close(i));return new Te(()=>{this.dynamicHandlers.delete(e)})}get signal(){return this.abortController.signal}get closed(){return this.closedPromise}getContext(){return this.context}sendRequest(e,t,i,r={}){if(this.abortController.signal.aborted)return ae(this.closedReason());let u=this.prepareRequest(e,t,i,r);return this.sendWireMessage(u.message).catch(()=>{}),r.cancellationSignal?.aborted&&u.cancel(),u.response}sendBatch(e){if(this.abortController.signal.aborted)return ae(this.closedReason());if(!this.allowBatches)return ae(new TypeError("JSON-RPC batches are not supported on this connection"));if(e.length===0)return ae(new TypeError("JSON-RPC batch must contain at least one entry"));let t=[],i=[],r=[];for(let z of e){if(z.kind==="notification"){t.push({jsonrpc:"2.0",method:z.method,params:z.params}),r.push(Promise.resolve(void 0));continue}let m=this.prepareRequest(z.method,z.params,z.mapResponse,z.options);t.push(m.message),r.push(m.response),i.push({signal:z.options?.cancellationSignal,cancel:m.cancel})}let u=t,h=this.sendWireMessage(u);for(let z of i)z.signal?.aborted&&z.cancel();let p=Promise.all([h,...r]).then(([,...z])=>z);return p.catch(()=>{}),p}sendCancelRequest(e){return this.sendNotification(ai,{requestId:e})}sendNotification(e,t){return this.abortController.signal.aborted?ae(this.closedReason()):this.sendWireMessage({jsonrpc:"2.0",method:e,params:t})}prepareRequest(e,t,i,r={}){let u=this.nextRequestId++,h=c(()=>{},"cancel"),p=new Promise((z,m)=>{let g={resolve:c(x=>{try{z(i?i(x):x)}catch(v){m(v)}},"resolve"),reject:m};h=c(()=>{g.cancellationSent||(g.cancellationSent=!0,g.cleanup?.(),this.sendCancelRequest(u).catch(()=>{}))},"cancel"),r.cancellationSignal?.addEventListener("abort",h,{once:!0}),g.cleanup=()=>{r.cancellationSignal?.removeEventListener("abort",h)},this.pendingResponses.set(u,g)});return p.catch(()=>{}),{message:{jsonrpc:"2.0",id:u,method:e,params:t},response:p,cancel:c(()=>h(),"cancel")}}close(e){if(this.abortController.signal.aborted)return;let t=e??new Error("ACP connection closed");this.abortController.abort(t);for(let i of this.pendingResponses.values())i.cleanup?.(),i.reject(t);this.pendingResponses.clear();for(let i of this.incomingRequests.values())i.abort(t);this.incomingRequests.clear(),this.receiveReader?.cancel(t).catch(()=>{})}initialize(e,t,i){this.stream=e,this.staticHandlers=t,this.allowBatches=i?.allowBatches??!0,this.closedPromise=new Promise(r=>{this.abortController.signal.addEventListener("abort",()=>r())}),this.receive()}legacyHandler(e,t){return{handleMessage:c(async(i,r)=>{if(i.kind==="request"){let u=await e(i.method,i.params,r);await i.responder.respond(u)}else await t(i.method,i.params,r);return Z.yes()},"handleMessage")}}async receive(){let e;try{let t=this.stream.readable.getReader();this.receiveReader=t;try{for(;!this.abortController.signal.aborted;){let{value:i,done:r}=await t.read();if(this.abortController.signal.aborted||r)break;this.receiveWireMessage(i)}}finally{this.receiveReader===t&&(this.receiveReader=void 0),t.releaseLock()}}catch(t){e=t}finally{this.close(e)}}receiveWireMessage(e){if(Array.isArray(e)){if(!this.allowBatches){this.close(new TypeError("JSON-RPC batches are not supported on this connection"));return}this.receiveBatch(e);return}if(!dt(e)&&!xe(e)&&!ci(e)){this.sendWireMessage(Ee(S.invalidRequest(e))).catch(()=>{});return}this.receiveMessage(e)}receiveBatch(e){if(e.length===0){this.sendWireMessage(Ee(S.invalidRequest(e))).catch(()=>{});return}let t=Ec(e),r=t?0:e.reduce((g,x)=>g+(xe(x)?0:1),0),u=e.reduce((g,x)=>g+(xe(x)?1:0),0),h=!1,p=[],z=c(async()=>{h||r!==0||u!==0||p.length===0||(h=!0,await this.sendWireMessage(p))},"sendResponsesIfReady"),m=c(async g=>{p.push(g),r-=1,await z()},"collectResponse");for(let g of e){if(t){ci(g)&&this.receiveMessage(g);continue}if(!dt(g)&&!xe(g)){m(Ee(S.invalidRequest(g))).catch(()=>{});continue}let x=this.receiveMessage(g,dt(g)?m:void 0,e.length);xe(g)&&x.finally(()=>{u-=1,z().catch(v=>this.close(v))})}}receiveMessage(e,t,i){return this.abortController.signal.aborted?Promise.resolve():se(e)?"method"in e?("id"in e||this.handleProtocolNotification(e),this.processIncomingMessage(this.toIncomingMessage(e,t,i)).catch(r=>this.close(r))):("id"in e?this.handleResponse(e):console.error("Invalid message",{message:e}),Promise.resolve()):(console.error("Invalid message",{message:e}),Promise.resolve())}async processIncomingMessage(e){if(this.abortController.signal.aborted)return;let t=e,i=!1;try{for(let r of[...this.staticHandlers,...this.dynamicHandlers.values()]){if(this.abortController.signal.aborted)return;let u=await r.handleMessage(t,this.context)??{handled:!0};if(u.handled)return;t=u.message??t,i=i||!!u.retry}i?this.retryQueue.push(t):t.kind==="request"&&await t.responder.respondWithError(S.methodNotFound(t.method))}catch(r){if(this.abortController.signal.aborted)return;if(t.kind==="request"&&!t.responder.responded)await t.responder.respondWithResult(Ic(r,t.responder.signal));else{let u=li(r);"error"in u&&console.error("Error handling notification",e.raw,u.error)}}}toIncomingMessage(e,t,i){if("id"in e){let r=new AbortController;this.incomingRequests.set(e.id,r);let u=c(()=>{this.incomingRequests.get(e.id)===r&&this.incomingRequests.delete(e.id)},"finishRequest"),h=new qn(e.id,p=>{let z={jsonrpc:"2.0",id:e.id,...p};return t?t(z):this.sendWireMessage(z)},r.signal,u);return i!==void 0&&Oc.set(h,i),{kind:"request",method:e.method,params:e.params,raw:e,signal:r.signal,responder:h}}return{kind:"notification",method:e.method,params:e.params,raw:e}}handleResponse(e){let t=this.pendingResponses.get(e.id);if(t)if(this.pendingResponses.delete(e.id),t.cleanup?.(),!di(e))t.reject(S.invalidRequest(e));else if("result"in e)t.resolve(e.result);else{let{code:i,message:r,data:u}=e.error;t.reject(new S(i,r,u))}else console.error("Got response to unknown request",e.id)}handleProtocolNotification(e){if(e.method!==ai)return;let t=Tc(e.params);if(t===void 0)return;let i=this.incomingRequests.get(t);!i||i.signal.aborted||i.abort(S.requestCancelled({requestId:t}))}closedReason(){return this.abortController.signal.reason??new Error("ACP connection closed")}async sendWireMessage(e){return this.abortController.signal.aborted?ae(this.closedReason()):(this.writeQueue=this.writeQueue.then(async()=>{if(this.abortController.signal.aborted)throw this.closedReason();let t=this.stream.writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{throw this.close(t),t}),this.writeQueue)}},Dn=class{static{c(this,"ConnectionBuilder")}handlers=[];connectionName;name(e){return this.connectionName=e,this}withHandler(e){return this.handlers.push(e),this}onReceiveMessage(e){return this.withHandler({handleMessage:c(async(t,i)=>await e(t,i)??Z.no(t),"handleMessage"),describe:c(()=>this.connectionName??"onReceiveMessage","describe")})}onReceiveRequest(e,t,i){return this.withHandler({handleMessage:c(async(r,u)=>{if(r.kind!=="request"||r.method!==e)return Z.no(r);let h=t(r.params);return await i(h,r.responder,u)??Z.yes()},"handleMessage"),describe:c(()=>`${this.connectionName??"request"}:${e}`,"describe")})}onReceiveNotification(e,t,i){return this.withHandler({handleMessage:c(async(r,u)=>{if(r.kind!=="notification"||r.method!==e)return Z.no(r);let h=t(r.params);return await i(h,u)??Z.yes()},"handleMessage"),describe:c(()=>`${this.connectionName??"notification"}:${e}`,"describe")})}connect(e,t){return new Re(e,this.handlers,t)}connectWith(e,t,i){return this.connect(e,i).runUntil(t)}},S=class n extends Error{static{c(this,"RequestError")}code;data;constructor(e,t,i){super(t),this.code=e,this.name="RequestError",this.data=i}static parseError(e,t){return new n(-32700,`Parse error${t?`: ${t}`:""}`,e)}static invalidRequest(e,t){return new n(-32600,`Invalid request${t?`: ${t}`:""}`,e)}static methodNotFound(e){return new n(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,t){return new n(-32602,`Invalid params${t?`: ${t}`:""}`,e)}static internalError(e,t){return new n(-32603,`Internal error${t?`: ${t}`:""}`,e)}static requestCancelled(e,t){return new n(-32800,`Request cancelled${t?`: ${t}`:""}`,e)}static authRequired(e,t){return new n(-32e3,`Authentication required${t?`: ${t}`:""}`,e)}static resourceNotFound(e){return new n(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}};function Ee(n){return{jsonrpc:"2.0",id:null,error:n.toErrorResponse()}}c(Ee,"protocolErrorResponse");var ve=class extends Error{static{c(this,"MessageTooLargeError")}maxMessageBytes;constructor(e){super(`Incoming ACP data exceeds the configured ${e} byte limit`),this.maxMessageBytes=e,this.name="MessageTooLargeError"}};function Me(n){let e=n??33554432;if(!Number.isSafeInteger(e)||e<=0)throw new RangeError("maxMessageBytes must be a positive safe integer");return e}c(Me,"resolveMaxMessageBytes");var lt=class{static{c(this,"MessageBuffer")}#e=new Uint8Array(0);#t=0;#n;constructor(e){this.#n=Me(e)}get byteLength(){return this.#t}get lastByte(){return this.#e[this.#t-1]}#s(e){if(e>this.#n-this.#t)throw this.clear(),new ve(this.#n)}append(e){this.#s(e.byteLength);let t=this.#t+e.byteLength;if(t>this.#e.byteLength){let i=Math.min(this.#n,Math.max(t,this.#e.byteLength*2,1024)),r=new Uint8Array(i);r.set(this.#e.subarray(0,this.#t)),this.#e=r}this.#e.set(e,this.#t),this.#t=t}take(){let e=this.#e.subarray(0,this.#t);return this.clear(),e}clear(){this.#e=new Uint8Array(0),this.#t=0}};var ui=10,ut=class{static{c(this,"LineBuffer")}#e;#t;constructor(e){this.#t=Me(e),this.#e=new lt(Math.min(Number.MAX_SAFE_INTEGER,this.#t+1))}*push(e){let t=0,i=e.indexOf(ui,t);for(;i!==-1;)yield this.#n(e.subarray(t,i)),t=i+1,i=e.indexOf(ui,t);if(t<e.byteLength){let r=e.subarray(t);this.#s(r),this.#e.append(r)}}flush(){if(this.#e.byteLength!==0)return Ln(this.#e.take())}clear(){this.#e.clear()}#n(e){return this.#s(e),this.#e.byteLength===0?Ln(e):(this.#e.append(e),Ln(this.#e.take()))}#s(e){let t=e.byteLength>0?e[e.byteLength-1]:this.#e.lastByte;if(this.#e.byteLength+e.byteLength-(t===13?1:0)>this.#t)throw this.clear(),new ve(this.#t)}};function Ln(n){return n[n.byteLength-1]===13?n.subarray(0,-1):n}c(Ln,"stripCarriageReturn");function pi(n,e,t={}){let i=Me(t.maxMessageBytes),r=new TextEncoder,u=new TextDecoder,h=!1,p,z=Promise.resolve(),m=c(v=>{let E=JSON.stringify(v)+`
|
|
3
3
|
`,j=z.then(async()=>{let R=n.getWriter();try{await R.write(r.encode(E))}finally{R.releaseLock()}});return z=j.catch(()=>{}),j},"writeJson"),g=new ReadableStream({async start(v){let E=new ut(i),j=c(async k=>{let H=u.decode(k).trim();if(!H)return;let $;try{$=JSON.parse(H)}catch{await m(Ee(S.parseError()));return}se($)||Array.isArray($)?v.enqueue($):await m(Ee(S.invalidRequest($)))},"enqueueLine"),R=e.getReader();p=R;try{for(;;){let{value:H,done:$}=await R.read();if(h)return;if($)break;if(H){for(let fe of E.push(H))if(await j(fe),h)return}}if(h)return;let k=E.flush();k&&await j(k)}catch(k){if(h)return;v.error(k),R.cancel(k).catch(()=>{});return}finally{E.clear(),p===R&&(p=void 0),R.releaseLock()}h||v.close()},cancel(v){return h=!0,p?.cancel(v)}}),x=new WritableStream({write(v){return m(v)}});return{readable:g,writable:x}}c(pi,"ndJsonStream");var fl=Vt.and(a({mode:f("form")})).and(a({message:s()})),zl=Jt.and(a({mode:f("url")})).and(a({message:s()})),ml=T([Ie,ke]).and(a({message:s()})),gl=Lt.and(a({type:f("string")})),_l=Gt.and(a({type:f("number")})),wl=$t.and(a({type:f("integer")})),bl=Ft.and(a({type:f("boolean")})),yl=Bt.and(a({type:f("array")})),Sl=Wt.and(a({type:f("string")}));var xl=nn.and(a({state:f("running")})),El=sn.and(a({state:f("idle")})),Tl=on.and(a({state:f("requires_action")})),Rl=rn.and(a({state:f("unknown")})),vl=vn.and(a({action:f("accept")})),Cl=a({action:f("decline")}),Al=a({action:f("cancel")});function mi(n,e,t){return pi(n,e,t)}c(mi,"ndJsonStream");function Q(n){return n??{}}c(Q,"emptyObjectResponse");function gi(n){return typeof n=="object"&&n!==null&&"readable"in n&&"writable"in n}c(gi,"isStream");function _i(){let n=new TransformStream,e=new TransformStream;return[{readable:e.readable,writable:n.writable},{readable:n.readable,writable:e.writable}]}c(_i,"memoryStreamPair");var je={agent:{initialize:_.initialize,authenticate:_.authenticate,logout:_.logout,providers:{list:_.providers_list,set:_.providers_set,disable:_.providers_disable},session:{new:_.session_new,load:_.session_load,list:_.session_list,delete:_.session_delete,fork:_.session_fork,resume:_.session_resume,close:_.session_close,setMode:_.session_set_mode,setConfigOption:_.session_set_config_option,prompt:_.session_prompt,cancel:_.session_cancel},nes:{start:_.nes_start,suggest:_.nes_suggest,accept:_.nes_accept,reject:_.nes_reject,close:_.nes_close},document:{didOpen:_.document_did_open,didChange:_.document_did_change,didClose:_.document_did_close,didSave:_.document_did_save,didFocus:_.document_did_focus}},client:{session:{requestPermission:I.session_request_permission,update:I.session_update},fs:{writeTextFile:I.fs_write_text_file,readTextFile:I.fs_read_text_file},terminal:{create:I.terminal_create,output:I.terminal_output,release:I.terminal_release,waitForExit:I.terminal_wait_for_exit,kill:I.terminal_kill},elicitation:{create:I.elicitation_create,complete:I.elicitation_complete}},protocol:{cancelRequest:It.cancel_request}},wi=Symbol("startActiveSession"),ft=class{static{c(this,"AcpContext")}cx;currentRequestId;constructor(e,t){this.cx=e,this.currentRequestId=t}get requestId(){return this.currentRequestId}get connectionContext(){return this.cx}sendRequest(e,t,i,r){return this.cx.sendRequest(e,t,i,r)}sendNotification(e,t){return this.cx.sendNotification(e,t)}addDynamicHandler(e){return this.cx.addDynamicHandler(e)}},Oe=class n extends ft{static{c(this,"AgentContext")}constructor(e,t){super(e,t)}static create(e,t){return new n(e,t)}request(e,t,i){let r=Ri[e];return this.sendRequest(e,t,r?.mapResponse,i)}notify(e,t){return this.sendNotification(e,t)}},Ne=class n extends ft{static{c(this,"ClientContext")}constructor(e,t){super(e,t)}static create(e,t){return new n(e,t)}[wi](e,t){return this.sendRequest(_.session_new,e,i=>this.attachSession(i),t)}buildSession(e){return typeof e=="string"?mt.create(this,{cwd:e,mcpServers:[]}):mt.create(this,e)}attachSession(e){let t=new Fn,i=this.connectionContext.signal,r=c(()=>{t.fail(i.reason??new Error("ACP connection closed"))},"failUpdatesOnClose");i.aborted?r():i.addEventListener("abort",r);let u=vi(this.connectionContext).attach(e,t),h=new Te(()=>{i.removeEventListener("abort",r)});return Wn.create(this,e,t,[u,h])}request(e,t,i){let r=Ti[e];return this.sendRequest(e,t,r?.mapResponse,i)}notify(e,t){return this.sendNotification(e,t)}},zt=class{static{c(this,"AcpConnectionHandle")}connection;constructor(e){this.connection=e}get signal(){return this.connection.signal}get closed(){return this.connection.closed}close(e){this.connection.close(e)}},Gn=class extends zt{static{c(this,"AgentConnectionHandle")}connectHandlers;client;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.client=Oe.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,bt(this,this.connectHandlers))}},$n=class extends zt{static{c(this,"ClientConnectionHandle")}connectHandlers;agent;didStartConnectHandlers=!1;constructor(e,t=[]){super(e),this.connectHandlers=t,this.agent=Ne.create(e.getContext())}startConnectHandlers(){this.didStartConnectHandlers||(this.didStartConnectHandlers=!0,bt(this,this.connectHandlers))}};function bi(n,e=[]){return new Gn(n,e)}c(bi,"agentConnection");function yi(n,e=[]){return new $n(n,e)}c(yi,"clientConnection");var Fn=class{static{c(this,"AsyncQueue")}values=[];waiters=[];failed=!1;failure;enqueue(e){if(this.failed)return;let t=this.waiters.shift();t?t.resolve(e):this.values.push({kind:"value",value:e})}reject(e){if(!this.failed){if(this.waiters.length>0){for(let t of this.waiters.splice(0))t.reject(e);return}this.values.push({kind:"error",error:e})}}clearErrors(){this.values=this.values.filter(e=>e.kind==="value")}fail(e){if(!this.failed){this.failed=!0,this.failure=e;for(let t of this.waiters.splice(0))t.reject(e)}}next(){if(this.values.length>0){let e=this.values.shift();return e.kind==="error"?Promise.reject(e.error):Promise.resolve(e.value)}return this.failed?Promise.reject(this.failure):new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}};function hi(n){return{...n,additionalDirectories:n.additionalDirectories?[...n.additionalDirectories]:void 0,mcpServers:[...n.mcpServers]}}c(hi,"cloneNewSessionRequest");var mt=class n{static{c(this,"SessionBuilder")}cx;request;constructor(e,t){this.cx=e,this.request=hi(t)}static create(e,t){return new n(e,t)}toRequest(){return hi(this.request)}withAdditionalDirectories(e){return this.request={...this.request,additionalDirectories:[...e]},this}withMcpServer(e){return this.request={...this.request,mcpServers:[...this.request.mcpServers,e]},this}async start(e){return this.cx[wi](this.toRequest(),e)}async withSession(e){let t=await this.start();try{return await e(t)}finally{t.dispose()}}},Wn=class n{static{c(this,"ActiveSession")}cx;sessionResponse;updates;registrations;constructor(e,t,i,r){this.cx=e,this.sessionResponse=t,this.updates=i,this.registrations=r}static create(e,t,i,r){return new n(e,t,i,r)}get sessionId(){return this.sessionResponse.sessionId}get modes(){return this.sessionResponse.modes}get meta(){return this.sessionResponse._meta}get newSessionResponse(){return this.sessionResponse}prompt(e,t){this.updates.clearErrors();let i=this.cx.request(_.session_prompt,{sessionId:this.sessionId,prompt:this.promptBlocks(e)},t);return i.then(r=>{this.updates.enqueue({kind:"stop",response:r,stopReason:r.stopReason})},r=>{this.updates.reject(r)}),i}nextUpdate(){return this.updates.next()}async readText(){let e="";for(;;){let t=await this.nextUpdate();if(t.kind==="stop")return e;let{update:i}=t;i.sessionUpdate==="agent_message_chunk"&&i.content.type==="text"&&(e+=i.content.text)}}dispose(){for(let e of this.registrations.splice(0))e.dispose();this.updates.fail(new Error("Active session disposed"))}[Symbol.dispose](){this.dispose()}promptBlocks(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e:[e]}};function Si(n,e){return n?typeof n=="function"?n(e):n.parse(e):e}c(Si,"parseParams");function P(n,e,t){return{method:n,params:e,mapResponse:t}}c(P,"requestSpec");function K(n,e){return{method:n,params:e}}c(K,"notificationSpec");function xi(n,e,t,i){n.onReceiveRequest(e.method,r=>Si(e.params,r),async(r,u,h)=>{let p=await i(t(r,h,u.signal,u.id));await u.respond(e.mapResponse?e.mapResponse(p):p)})}c(xi,"registerAppRequest");function Ei(n,e,t,i){n.onReceiveNotification(e.method,r=>Si(e.params,r),(r,u)=>i(t(r,u,u.signal)))}c(Ei,"registerAppNotification");function wt(n){let e={};for(let t of Object.values(n))e[t.method]=t;return e}c(wt,"specsByMethod");var Nc={initialize:P(_.initialize,cn),newSession:P(_.session_new,fn),loadSession:P(_.session_load,zn,Q),unstable_forkSession:P(_.session_fork,_n),listSessions:P(_.session_list,mn),deleteSession:P(_.session_delete,gn,Q),resumeSession:P(_.session_resume,wn),closeSession:P(_.session_close,bn,Q),setSessionMode:P(_.session_set_mode,yn,Q),setSessionConfigOption:P(_.session_set_config_option,Sn),authenticate:P(_.authenticate,dn,Q),unstable_listProviders:P(_.providers_list,ln),unstable_setProvider:P(_.providers_set,un,Q),unstable_disableProvider:P(_.providers_disable,pn,Q),logout:P(_.logout,hn,Q),prompt:P(_.session_prompt,xn),unstable_startNes:P(_.nes_start,En),unstable_suggestNes:P(_.nes_suggest,Tn),unstable_closeNes:P(_.nes_close,Rn,Q)},jc={cancel:K(_.session_cancel,Cn),unstable_didOpenDocument:K(_.document_did_open,An),unstable_didChangeDocument:K(_.document_did_change,In),unstable_didCloseDocument:K(_.document_did_close,kn),unstable_didSaveDocument:K(_.document_did_save,Mn),unstable_didFocusDocument:K(_.document_did_focus,On),unstable_acceptNes:K(_.nes_accept,Nn),unstable_rejectNes:K(_.nes_reject,jn)},qc={requestPermission:P(I.session_request_permission,jt),writeTextFile:P(I.fs_write_text_file,Mt,Q),readTextFile:P(I.fs_read_text_file,Ot),createTerminal:P(I.terminal_create,qt),terminalOutput:P(I.terminal_output,Pt),releaseTerminal:P(I.terminal_release,Dt,Q),waitForTerminalExit:P(I.terminal_wait_for_exit,Ht),killTerminal:P(I.terminal_kill,Ut,Q),createElicitation:P(I.elicitation_create,Qt)},Pc={sessionUpdate:K(I.session_update,at),completeElicitation:K(I.elicitation_complete,an)},Ti=wt(Nc),Dc=wt(jc),Ri=wt(qc),Hc=wt(Pc);function Uc(n,e,t,i){return{params:n,requestId:i,signal:t,client:e}}c(Uc,"agentRequestContext");function Lc(n,e,t){return{params:n,signal:t,client:e}}c(Lc,"agentNotificationContext");function Gc(n,e,t,i){return{params:n,requestId:i,signal:t,agent:e}}c(Gc,"clientRequestContext");function $c(n,e,t){return{params:n,signal:t,agent:e}}c($c,"clientNotificationContext");var Bn=class{static{c(this,"SessionUpdateRouter")}activeSessions=new Map;handleMessage(e){if(e.kind!=="notification"||e.method!==I.session_update)return Z.no(e);let t=at.parse(e.params),i={kind:"session_update",notification:t,update:t.update},r=this.activeSessions.get(t.sessionId);if(r&&r.size>0)for(let u of r)u.enqueue(i);return Z.no(e)}attach(e,t){let i=this.activeSessions.get(e.sessionId)??new Set;return i.add(t),this.activeSessions.set(e.sessionId,i),new Te(()=>{i.delete(t),i.size===0&&this.activeSessions.delete(e.sessionId)})}},fi=new WeakMap;function vi(n){let e=fi.get(n);return e||(e=new Bn,fi.set(n,e)),e}c(vi,"sessionUpdateRouter");function bt(n,e){for(let t of e){let i;try{i=t(n)}catch(r){throw n.close(r),r}Promise.resolve(i).catch(r=>{n.close(r)})}}c(bt,"runConnectHandlers");var gt=Symbol("appBuilder"),pt=Symbol("runAgentConnectHandlers"),ht=Symbol("runClientConnectHandlers"),_t={allowBatches:!1};function Ci(n){return new Vn(n)}c(Ci,"agent");var Vn=class{static{c(this,"AgentApp")}builder=Re.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name)}[gt](){return this.builder}[pt](e){bt(e,this.connectHandlers)}connect(e,t={}){return this.connectConnection(e,t).connection}connectWith(e,t){let{rawConnection:i,connection:r}=this.connectConnection(e);return i.runUntil(()=>t(r.client))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,i){if(i)return this.request({method:e,params:t},i);let r=Ti[e];if(!r)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(r,t)}onNotification(e,t,i){if(i)return this.notification({method:e,params:t},i);let r=Dc[e];if(!r)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(r,t)}request(e,t){return xi(this.builder,e,(i,r,u,h)=>Uc(i,Oe.create(r,h),u,h),t),this}notification(e,t){return Ei(this.builder,e,(i,r,u)=>Lc(i,Oe.create(r),u),t),this}connectConnection(e,t={}){if(gi(e)){let z=this.openStreamConnection(e);return t.deferConnectHandlers||this[pt](z.connection),z}let[i,r]=_i(),u=e[gt]().connect(r,_t),h=yi(u),p=this.openStreamConnection(i);p.rawConnection.closed.then(()=>h.close()),u.closed.then(()=>p.connection.close());try{e[ht](h),this[pt](p.connection)}catch(z){throw h.close(z),p.connection.close(z),z}return p}openStreamConnection(e){let t=this.builder.connect(e,_t);return{rawConnection:t,connection:bi(t,this.connectHandlers)}}};var zi=class{static{c(this,"ClientApp")}builder=Re.builder();connectHandlers=[];constructor(e={}){e.name&&this.builder.name(e.name),this.builder.withHandler({handleMessage:c((t,i)=>vi(i).handleMessage(t),"handleMessage"),describe:c(()=>"client-session-update-router","describe")})}[gt](){return this.builder}[ht](e){bt(e,this.connectHandlers)}connect(e){return this.connectConnection(e).connection}connectWith(e,t){let{rawConnection:i,connection:r}=this.connectConnection(e);return i.runUntil(()=>t(r.agent))}onConnect(e){return this.connectHandlers.push(e),this}onRequest(e,t,i){if(i)return this.request({method:e,params:t},i);let r=Ri[e];if(!r)throw new Error(`Unknown ACP request method '${e}'. Pass a params parser for custom methods.`);return this.request(r,t)}onNotification(e,t,i){if(i)return this.notification({method:e,params:t},i);let r=Hc[e];if(!r)throw new Error(`Unknown ACP notification method '${e}'. Pass a params parser for custom methods.`);return this.notification(r,t)}request(e,t){return xi(this.builder,e,(i,r,u,h)=>Gc(i,Ne.create(r,h),u,h),t),this}notification(e,t){return Ei(this.builder,e,(i,r,u)=>$c(i,Ne.create(r),u),t),this}connectConnection(e){if(gi(e)){let p=this.openStreamConnection(e);return this[ht](p.connection),p}let[t,i]=_i(),r=e[gt]().connect(i,_t),u=bi(r),h=this.openStreamConnection(t);h.rawConnection.closed.then(()=>u.close()),r.closed.then(()=>h.connection.close());try{e[pt](u),this[ht](h.connection)}catch(p){throw u.close(p),h.connection.close(p),p}return h}openStreamConnection(e){let t=this.builder.connect(e,_t);return{rawConnection:t,connection:yi(t,this.connectHandlers)}}},Ll=new Set([_.initialize,_.authenticate,_.providers_list,_.providers_set,_.providers_disable,_.session_new,_.session_load,_.session_set_mode,_.session_set_config_option,_.session_prompt,_.session_list,_.session_delete,_.session_fork,_.session_resume,_.session_close,_.logout,_.nes_start,_.nes_suggest,_.nes_close]),Gl=new Set([_.session_cancel,_.nes_accept,_.nes_reject,_.document_did_open,_.document_did_change,_.document_did_close,_.document_did_save,_.document_did_focus]),$l=new Set([I.session_request_permission,I.fs_write_text_file,I.fs_read_text_file,I.terminal_create,I.terminal_output,I.terminal_release,I.terminal_wait_for_exit,I.terminal_kill,I.elicitation_create]),Fl=new Set([I.session_update,I.elicitation_complete]);import{createHash as Wc}from"node:crypto";import{realpath as Bc,stat as Vc}from"node:fs/promises";import Jc from"node:path";function J(n){return Wc("sha256").update(JSON.stringify(n)).digest("hex")}c(J,"fingerprint");async function Jn(n,e){if(!Jc.isAbsolute(n)||e?.length)throw S.invalidParams(void 0,"Supply one absolute workspace directory; additional roots are not supported.");try{let t=await Bc(n);if(!(await Vc(t)).isDirectory())throw new Error;return t}catch{throw S.invalidParams(void 0,"Workspace directory does not exist.")}}c(Jn,"workspaceRoot");var qe=class{constructor(e){this.home=e}home;static{c(this,"AcpAccount")}async context(){let e=await _s(this.home,()=>As(process.env.OPENPOND_ACCOUNT,process.env.OPENPOND_BASE_URL));if(!e.token||!e.account)throw S.authRequired(void 0,"Run openpond acp --login with the same --home/account options, then reconnect.");return e}async scope(){let e=await this.context();return J({home:this.home,account:e.account.handle,api:e.apiBaseUrl,chat:e.chatApiBaseUrl})}stream=async function*(e){let t=await this.context();yield*At({...e,apiBaseUrl:t.chatApiBaseUrl,token:t.token,model:e.model||"openpond-chat"})}.bind(this);async streamForScope(e){let t=await this.context();if(J({home:this.home,account:t.account.handle,api:t.apiBaseUrl,chat:t.chatApiBaseUrl})!==e)throw S.invalidRequest(void 0,"The session account or model route changed. Reconnect with the original account or start a new session.");return async function*(r){yield*At({...r,apiBaseUrl:t.chatApiBaseUrl,token:t.token,model:r.model||"openpond-chat"})}}async models(){let e=await this.context(),t=`${e.chatApiBaseUrl.replace(/\/+$/,"")}/models`,i=await fetch(t,{headers:{Authorization:`Bearer ${e.token}`},signal:AbortSignal.timeout(15e3)});if(!i.ok)throw S.authRequired(void 0,`OpenPond model route is unavailable (HTTP ${i.status}). Check login and account access.`);let r=await i.json(),u=[...new Set((r.data??[]).flatMap(h=>typeof h.id=="string"&&h.id.trim()?[h.id]:[]))];if(!u.length)throw S.invalidRequest(void 0,"OpenPond model route returned no usable models.");return u.map(h=>({id:h,name:h==="openpond-chat"?"OpenPond Chat":h}))}};var Oi=fo(Mi(),1);function Ni(n){if(n)try{return Oi.default.parse(n).type}catch{let e=(n.split(";",1)[0]??"").trim().toLowerCase();return e===""||n.slice(e.length).includes(",")?void 0:e}}c(Ni,"mediaTypeEssence");function yt(n){return n?n instanceof Headers?Object.fromEntries(n.entries()):Array.isArray(n)?Object.fromEntries(n):{...n}:{}}c(yt,"normalizeHeaders");function ji(n=fetch,e){return e?async(t,i)=>{let r={...e,...i,headers:i?.headers?{...yt(e.headers),...yt(i.headers)}:e.headers};return n(t,r)}:n}c(ji,"createFetchWithInit");var sd=5,id=[301,302,303,307,308];function od(n,e){return n.protocol===e.protocol&&n.hostname===e.hostname&&n.port===e.port?!0:n.hostname===e.hostname&&n.protocol==="http:"&&n.port===""&&e.protocol==="https:"&&e.port===""}c(od,"isWithinOrigin");function qi(n,e){let t=id.includes(n.status)?n.headers.get("location"):null;try{return t?new URL(t,e):void 0}catch{return}}c(qi,"redirectTarget");function St(n,e,t,i,r=0){let u=qi(i,e),h=i.status===307||i.status===308||(t?.method??"GET").toUpperCase()==="GET";if(!u||r===sd||!h)return;let p=new URL(e);if(!((u.username||u.password)&&(u.username!==p.username||u.password!==p.password)||!od(p,u)))return Promise.resolve(i.body?.cancel()).then(()=>n(u,{...t,redirect:"manual"})).then(m=>St(n,u,t,m,r+1)??m)}c(St,"followWithinOrigin");var Pi=new WeakSet;function Kn(n){let e=c((t,i)=>(n??fetch)(t,i),"following");return Pi.add(e),e}c(Kn,"fetchLeavingRedirects");function ce(n=fetch){return Pi.has(n)?n:(e,t)=>t?.redirect==="error"||t?.redirect==="manual"?n(e,t):Promise.resolve(n(e,{...t,redirect:"manual"})).then(i=>St(n,e,t,i)??i)}c(ce,"fetchWithinOrigin");function xt(n,e){if(n.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose the redirect target";let t=n.url||e,i=qi(n,t);if(i)return i.username=i.password=i.search=i.hash="",i.protocol==="http:"&&new URL(t).protocol==="https:"?(i.protocol="https:",`Redirect to plain http not followed; try ${i.href} instead`):`Redirect to ${i.href} not followed`}c(xt,"unfollowedRedirect");var Zn;Zn=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(n=>n.webcrypto);async function rd(n){return(await Zn).getRandomValues(new Uint8Array(n))}c(rd,"getRandomValues");async function ad(n){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",t=Math.pow(2,8)-Math.pow(2,8)%e.length,i="";for(;i.length<n;){let r=await rd(n-i.length);for(let u of r)u<t&&(i+=e[u%e.length])}return i}c(ad,"random");async function cd(n){return await ad(n)}c(cd,"generateVerifier");async function dd(n){let e=await(await Zn).subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}c(dd,"generateChallenge");async function Xn(n){if(n||(n=43),n<43||n>128)throw`Expected a length between 43 and 128. Received ${n}.`;let e=await cd(n),t=await dd(e);return{code_verifier:e,code_challenge:t}}c(Xn,"pkceChallenge");var W=et().superRefine((n,e)=>{if(!URL.canParse(n))return e.addIssue({code:ms.custom,message:"URL must be parseable",fatal:!0}),fs}).refine(n=>{let e=new URL(n);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Hi=me({resource:s().url(),authorization_servers:w(W).optional(),jwks_uri:s().url().optional(),scopes_supported:w(s()).optional(),bearer_methods_supported:w(s()).optional(),resource_signing_alg_values_supported:w(s()).optional(),resource_name:s().optional(),resource_documentation:s().optional(),resource_policy_uri:s().url().optional(),resource_tos_uri:s().url().optional(),tls_client_certificate_bound_access_tokens:q().optional(),authorization_details_types_supported:w(s()).optional(),dpop_signing_alg_values_supported:w(s()).optional(),dpop_bound_access_tokens_required:q().optional()}),Yn=me({issuer:s(),authorization_endpoint:W,token_endpoint:W,registration_endpoint:W.optional(),scopes_supported:w(s()).optional(),response_types_supported:w(s()),response_modes_supported:w(s()).optional(),grant_types_supported:w(s()).optional(),token_endpoint_auth_methods_supported:w(s()).optional(),token_endpoint_auth_signing_alg_values_supported:w(s()).optional(),service_documentation:W.optional(),revocation_endpoint:W.optional(),revocation_endpoint_auth_methods_supported:w(s()).optional(),revocation_endpoint_auth_signing_alg_values_supported:w(s()).optional(),introspection_endpoint:s().optional(),introspection_endpoint_auth_methods_supported:w(s()).optional(),introspection_endpoint_auth_signing_alg_values_supported:w(s()).optional(),code_challenge_methods_supported:w(s()).optional(),client_id_metadata_document_supported:q().optional()}),ld=me({issuer:s(),authorization_endpoint:W,token_endpoint:W,userinfo_endpoint:W.optional(),jwks_uri:W,registration_endpoint:W.optional(),scopes_supported:w(s()).optional(),response_types_supported:w(s()),response_modes_supported:w(s()).optional(),grant_types_supported:w(s()).optional(),acr_values_supported:w(s()).optional(),subject_types_supported:w(s()),id_token_signing_alg_values_supported:w(s()),id_token_encryption_alg_values_supported:w(s()).optional(),id_token_encryption_enc_values_supported:w(s()).optional(),userinfo_signing_alg_values_supported:w(s()).optional(),userinfo_encryption_alg_values_supported:w(s()).optional(),userinfo_encryption_enc_values_supported:w(s()).optional(),request_object_signing_alg_values_supported:w(s()).optional(),request_object_encryption_alg_values_supported:w(s()).optional(),request_object_encryption_enc_values_supported:w(s()).optional(),token_endpoint_auth_methods_supported:w(s()).optional(),token_endpoint_auth_signing_alg_values_supported:w(s()).optional(),display_values_supported:w(s()).optional(),claim_types_supported:w(s()).optional(),claims_supported:w(s()).optional(),service_documentation:s().optional(),claims_locales_supported:w(s()).optional(),ui_locales_supported:w(s()).optional(),claims_parameter_supported:q().optional(),request_parameter_supported:q().optional(),request_uri_parameter_supported:q().optional(),require_request_uri_registration:q().optional(),op_policy_uri:W.optional(),op_tos_uri:W.optional(),client_id_metadata_document_supported:q().optional()}),Ui=a({...ld.shape,...Yn.pick({code_challenge_methods_supported:!0}).shape}),Li=a({access_token:s(),id_token:s().optional(),token_type:s(),expires_in:gs.number().optional(),scope:s().optional(),refresh_token:s().optional(),issuer:s().optional().catch(void 0)}).strip(),Gi=a({error:s(),error_description:s().optional(),error_uri:s().optional()}),Di=W.optional().or(f("").transform(()=>{})),ud=a({redirect_uris:w(W),token_endpoint_auth_method:s().optional(),grant_types:w(s()).optional(),response_types:w(s()).optional(),client_name:s().optional(),client_uri:W.optional(),logo_uri:Di,scope:s().optional(),contacts:w(s()).optional(),tos_uri:Di,policy_uri:s().optional(),jwks_uri:W.optional(),jwks:zs().optional(),software_id:s().optional(),software_version:s().optional(),software_statement:s().optional()}).strip(),pd=a({client_id:s(),client_secret:s().optional(),client_id_issued_at:O().optional(),client_secret_expires_at:O().optional(),issuer:s().optional().catch(void 0)}).strip(),$i=ud.merge(pd),pu=a({error:s(),error_description:s().optional()}).strip(),hu=a({token:s(),token_type_hint:s().optional()}).strip();function Fi(n){let e=typeof n=="string"?new URL(n):new URL(n.href);return e.hash="",e}c(Fi,"resourceUrlFromServerUrl");function Wi({requestedResource:n,configuredResource:e}){let t=typeof n=="string"?new URL(n):new URL(n.href),i=typeof e=="string"?new URL(e):new URL(e.href);if(t.origin!==i.origin||t.pathname.length<i.pathname.length)return!1;let r=t.pathname.endsWith("/")?t.pathname:t.pathname+"/",u=i.pathname.endsWith("/")?i.pathname:i.pathname+"/";return r.startsWith(u)}c(Wi,"checkResourceAllowed");var U=class extends Error{static{c(this,"OAuthError")}constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Pe=class extends U{static{c(this,"InvalidRequestError")}};Pe.errorCode="invalid_request";var de=class extends U{static{c(this,"InvalidClientError")}};de.errorCode="invalid_client";var le=class extends U{static{c(this,"InvalidGrantError")}};le.errorCode="invalid_grant";var ue=class extends U{static{c(this,"UnauthorizedClientError")}};ue.errorCode="unauthorized_client";var De=class extends U{static{c(this,"UnsupportedGrantTypeError")}};De.errorCode="unsupported_grant_type";var He=class extends U{static{c(this,"InvalidScopeError")}};He.errorCode="invalid_scope";var Ue=class extends U{static{c(this,"AccessDeniedError")}};Ue.errorCode="access_denied";var X=class extends U{static{c(this,"ServerError")}};X.errorCode="server_error";var Le=class extends U{static{c(this,"TemporarilyUnavailableError")}};Le.errorCode="temporarily_unavailable";var Ge=class extends U{static{c(this,"UnsupportedResponseTypeError")}};Ge.errorCode="unsupported_response_type";var $e=class extends U{static{c(this,"UnsupportedTokenTypeError")}};$e.errorCode="unsupported_token_type";var Fe=class extends U{static{c(this,"InvalidTokenError")}};Fe.errorCode="invalid_token";var We=class extends U{static{c(this,"MethodNotAllowedError")}};We.errorCode="method_not_allowed";var Be=class extends U{static{c(this,"TooManyRequestsError")}};Be.errorCode="too_many_requests";var pe=class extends U{static{c(this,"InvalidClientMetadataError")}};pe.errorCode="invalid_client_metadata";var Ve=class extends U{static{c(this,"InsufficientScopeError")}};Ve.errorCode="insufficient_scope";var Je=class extends U{static{c(this,"InvalidTargetError")}};Je.errorCode="invalid_target";var Bi={[Pe.errorCode]:Pe,[de.errorCode]:de,[le.errorCode]:le,[ue.errorCode]:ue,[De.errorCode]:De,[He.errorCode]:He,[Ue.errorCode]:Ue,[X.errorCode]:X,[Le.errorCode]:Le,[Ge.errorCode]:Ge,[$e.errorCode]:$e,[Fe.errorCode]:Fe,[We.errorCode]:We,[Be.errorCode]:Be,[pe.errorCode]:pe,[Ve.errorCode]:Ve,[Je.errorCode]:Je};var Y=class extends Error{static{c(this,"UnauthorizedError")}constructor(e){super(e??"Unauthorized")}};function hd(n){return["client_secret_basic","client_secret_post","none"].includes(n)}c(hd,"isClientAuthMethod");var es="code",ts="S256";function fd(n,e){let t=n.client_secret!==void 0;return"token_endpoint_auth_method"in n&&n.token_endpoint_auth_method&&hd(n.token_endpoint_auth_method)&&(e.length===0||e.includes(n.token_endpoint_auth_method))?n.token_endpoint_auth_method:e.length===0?t?"client_secret_basic":"none":t&&e.includes("client_secret_basic")?"client_secret_basic":t&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":t?"client_secret_post":"none"}c(fd,"selectClientAuthMethod");function zd(n,e,t,i){let{client_id:r,client_secret:u}=e;switch(n){case"client_secret_basic":md(r,u,t);return;case"client_secret_post":gd(r,u,i);return;case"none":_d(r,i);return;default:throw new Error(`Unsupported client authentication method: ${n}`)}}c(zd,"applyClientAuthentication");function md(n,e,t){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");let i=btoa(`${n}:${e}`);t.set("Authorization",`Basic ${i}`)}c(md,"applyBasicAuth");function gd(n,e,t){t.set("client_id",n),e&&t.set("client_secret",e)}c(gd,"applyPostAuth");function _d(n,e){e.set("client_id",n)}c(_d,"applyPublicAuth");async function Ji(n){let e=n instanceof Response?n.status:void 0,t=n instanceof Response?await n.text():n;try{let i=Gi.parse(JSON.parse(t)),{error:r,error_description:u,error_uri:h}=i,p=Bi[r]||X;return new p(u||"",h)}catch(i){let r=n instanceof Response?xt(n,n.url):void 0,u=`${e?`HTTP ${e}: `:""}${r??`Invalid OAuth error response: ${i}. Raw body: ${t}`}`;return new X(u)}}c(Ji,"parseErrorResponse");function wd(n,e){let[t,i]=[n,e];try{[t,i]=[new URL(n).href,new URL(e).href]}catch{}return t===i||t.endsWith("/")&&t.slice(0,-1)===i||i.endsWith("/")&&i.slice(0,-1)===t}c(wd,"issuersMatch");function is(n,e){if(n)return typeof n.issuer!="string"?n.issuer==null?n:{...n,issuer:void 0}:wd(n.issuer,e)?n:void 0}c(is,"discardIfIssuerMismatch");var bd=Li.omit({issuer:!0}),yd=$i.omit({issuer:!0});function Qi(n,e){return new Error(`OAuth client information is bound to authorization server ${n.issuer} and is not presented to ${e}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}c(Qi,"boundElsewhereError");async function Qe(n,e){try{return await ns(n,e)}catch(t){if(t instanceof de||t instanceof ue)return await n.invalidateCredentials?.("all"),await ns(n,e);if(t instanceof le)return await n.invalidateCredentials?.("tokens"),await ns(n,e);throw t}}c(Qe,"auth");async function ns(n,{serverUrl:e,authorizationCode:t,scope:i,resourceMetadataUrl:r,fetchFn:u}){let h=await n.discoveryState?.(),p,z,m,g=r;if(!g&&h?.resourceMetadataUrl&&(g=new URL(h.resourceMetadataUrl)),h?.authorizationServerUrl){if(z=h.authorizationServerUrl,p=h.resourceMetadata,m=h.authorizationServerMetadata??await Zi(z,{fetchFn:u}),!p)try{p=await Ki(e,{resourceMetadataUrl:g},u)}catch{}(m!==h.authorizationServerMetadata||p!==h.resourceMetadata)&&await n.saveDiscoveryState?.({authorizationServerUrl:String(z),resourceMetadataUrl:g?.toString(),resourceMetadata:p,authorizationServerMetadata:m})}else{let N=await Cd(e,{resourceMetadataUrl:g,fetchFn:u});z=N.authorizationServerUrl,m=N.authorizationServerMetadata,p=N.resourceMetadata,await n.saveDiscoveryState?.({authorizationServerUrl:String(z),resourceMetadataUrl:g?.toString(),resourceMetadata:p,authorizationServerMetadata:m})}let x=String(z),v=await xd(e,n,p),E=v&&p&&!n.validateResourceURL?p.resource:v,j=i||p?.scopes_supported?.join(" ")||n.clientMetadata.scope,R=await Promise.resolve(n.clientInformation()),k=is(R,x),H=n.saveClientInformation!==void 0&&!!n.redirectUrl;if(R&&!k&&!H)throw Qi(R,x);let $=k?.issuer==null?k:void 0,fe=c(async()=>{try{$&&await n.saveClientInformation?.({...$,issuer:x})}catch{}},"bindClientInformation");if(!k){if(t!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let N=m?.client_id_metadata_document_supported===!0,B=n.clientMetadataUrl;if(B&&!Sd(B))throw new pe(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${B}`);if(N&&B)k={client_id:B,issuer:x},await n.saveClientInformation?.(k);else{if(!n.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");k={...await Od(z,{metadata:m,clientMetadata:n.clientMetadata,scope:j,fetchFn:u}),issuer:x},await n.saveClientInformation(k)}}let Rt=!n.redirectUrl;if(t!==void 0||Rt){let N=await Md(n,z,{metadata:m,resource:E,authorizationCode:t,fetchFn:u});return await fe(),await n.saveTokens({...N,issuer:x}),"AUTHORIZED"}let y=is(await n.tokens(),x);if(y?.refresh_token&&y.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),y?.refresh_token)try{let N=await kd(z,{metadata:m,clientInformation:k,refreshToken:y.refresh_token,resource:E,addClientAuthentication:n.addClientAuthentication,fetchFn:u});return await fe(),await n.saveTokens({...N,issuer:x}),"AUTHORIZED"}catch(N){if(!(!(N instanceof U)||N instanceof X))throw N}let b=n.state?await n.state():void 0,{authorizationUrl:M,codeVerifier:L}=await Ad(z,{metadata:m,clientInformation:k,state:b,redirectUrl:n.redirectUrl,scope:j,resource:E});return await n.saveCodeVerifier(L),await n.redirectToAuthorization(M),"REDIRECT"}c(ns,"authInternal");function Sd(n){if(!n)return!1;try{let e=new URL(n);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}c(Sd,"isHttpsUrl");async function xd(n,e,t){let i=Fi(n);if(e.validateResourceURL)return await e.validateResourceURL(i,t?.resource);if(t){if(!Wi({requestedResource:i,configuredResource:t.resource}))throw new Error(`Protected resource ${t.resource} does not match expected ${i} (or origin)`);return new URL(t.resource)}}c(xd,"selectResourceURL");function os(n){let e=n.headers.get("WWW-Authenticate");if(!e)return{};let[t,i]=e.split(" ");if(t.toLowerCase()!=="bearer"||!i)return{};let r=ss(n,"resource_metadata")||void 0,u;if(r)try{u=new URL(r)}catch{}let h=ss(n,"scope")||void 0,p=ss(n,"error")||void 0;return{resourceMetadataUrl:u,scope:h,error:p}}c(os,"extractWWWAuthenticateParams");function ss(n,e){let t=n.headers.get("WWW-Authenticate");if(!t)return null;let i=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),r=t.match(i);return r?r[1]||r[2]:null}c(ss,"extractFieldFromWwwAuth");async function Ki(n,e,t=fetch){let i=await Rd(n,"oauth-protected-resource",t,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!i||i.status===404)throw await i?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!i.ok)throw await i.body?.cancel(),new Error(`HTTP ${i.status} trying to load well-known OAuth protected resource metadata.`);return Hi.parse(await i.json())}c(Ki,"discoverOAuthProtectedResourceMetadata");async function rs(n,e,t=fetch){try{return await ce(t)(n,{headers:e})}catch(i){if(i instanceof TypeError)return e?rs(n,void 0,t):void 0;throw i}}c(rs,"fetchWithCorsRetry");function Ed(n,e="",t={}){return e.endsWith("/")&&(e=e.slice(0,-1)),t.prependPathname?`${e}/.well-known/${n}`:`/.well-known/${n}${e}`}c(Ed,"buildWellKnownPath");async function Vi(n,e,t=fetch){return await rs(n,{"MCP-Protocol-Version":e},t)}c(Vi,"tryMetadataDiscovery");function Td(n,e){return!n||!n.ok&&n.status<500&&e!=="/"}c(Td,"shouldAttemptFallback");async function Rd(n,e,t,i){let r=new URL(n),u=i?.protocolVersion??vt,h;if(i?.metadataUrl)h=new URL(i.metadataUrl);else{let z=Ed(e,r.pathname);h=new URL(z,i?.metadataServerUrl??r),h.search=r.search}let p=await Vi(h,u,t);if(!i?.metadataUrl&&Td(p,r.pathname)){let z=new URL(`/.well-known/${e}`,r);p=await Vi(z,u,t)}return p}c(Rd,"discoverMetadataWithFallback");function vd(n){let e=typeof n=="string"?new URL(n):n,t=e.pathname!=="/",i=[];if(!t)return i.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),i.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),i;let r=e.pathname;return r.endsWith("/")&&(r=r.slice(0,-1)),i.push({url:new URL(`/.well-known/oauth-authorization-server${r}`,e.origin),type:"oauth"}),i.push({url:new URL(`/.well-known/openid-configuration${r}`,e.origin),type:"oidc"}),i.push({url:new URL(`${r}/.well-known/openid-configuration`,e.origin),type:"oidc"}),i}c(vd,"buildDiscoveryUrls");async function Zi(n,{fetchFn:e=fetch,protocolVersion:t=vt}={}){let i={"MCP-Protocol-Version":t,Accept:"application/json"},r=vd(n);for(let{url:u,type:h}of r){let p=await rs(u,i,e);if(p){if(!p.ok){if(await p.body?.cancel(),p.status<500)continue;throw new Error(`HTTP ${p.status} trying to load ${h==="oauth"?"OAuth":"OpenID provider"} metadata from ${u}`)}return h==="oauth"?Yn.parse(await p.json()):Ui.parse(await p.json())}}}c(Zi,"discoverAuthorizationServerMetadata");async function Cd(n,e){let t,i;try{t=await Ki(n,{resourceMetadataUrl:e?.resourceMetadataUrl},e?.fetchFn),t.authorization_servers&&t.authorization_servers.length>0&&(i=t.authorization_servers[0])}catch{}i||(i=String(new URL("/",n)));let r=await Zi(i,{fetchFn:e?.fetchFn});return{authorizationServerUrl:i,authorizationServerMetadata:r,resourceMetadata:t}}c(Cd,"discoverOAuthServerInfo");function Xi(n){return typeof n=="string"?n:n.href}c(Xi,"resourceIndicatorToString");async function Ad(n,{metadata:e,clientInformation:t,redirectUrl:i,scope:r,state:u,resource:h}){let p;if(e){if(p=new URL(e.authorization_endpoint),!e.response_types_supported.includes(es))throw new Error(`Incompatible auth server: does not support response type ${es}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(ts))throw new Error(`Incompatible auth server: does not support code challenge method ${ts}`)}else p=new URL("/authorize",n);let z=await Xn(),m=z.code_verifier,g=z.code_challenge;return p.searchParams.set("response_type",es),p.searchParams.set("client_id",t.client_id),p.searchParams.set("code_challenge",g),p.searchParams.set("code_challenge_method",ts),p.searchParams.set("redirect_uri",String(i)),u&&p.searchParams.set("state",u),r&&p.searchParams.set("scope",r),r?.includes("offline_access")&&p.searchParams.append("prompt","consent"),h&&p.searchParams.set("resource",Xi(h)),{authorizationUrl:p,codeVerifier:m}}c(Ad,"startAuthorization");function Id(n,e,t){return new URLSearchParams({grant_type:"authorization_code",code:n,code_verifier:e,redirect_uri:String(t)})}c(Id,"prepareAuthorizationCodeRequest");async function Yi(n,{metadata:e,tokenRequestParams:t,clientInformation:i,addClientAuthentication:r,resource:u,fetchFn:h}){let p=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",n),z=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(u&&t.set("resource",Xi(u)),r)await r(z,t,p,e);else if(i){let g=e?.token_endpoint_auth_methods_supported??[],x=fd(i,g);zd(x,i,z,t)}let m=await ce(h??fetch)(p,{method:"POST",headers:z,body:t});if(!m.ok)throw await Ji(m);return bd.parse(await m.json())}c(Yi,"executeTokenRequest");async function kd(n,{metadata:e,clientInformation:t,refreshToken:i,resource:r,addClientAuthentication:u,fetchFn:h}){let p=new URLSearchParams({grant_type:"refresh_token",refresh_token:i}),z=await Yi(n,{metadata:e,tokenRequestParams:p,clientInformation:t,addClientAuthentication:u,resource:r,fetchFn:h});return{refresh_token:i,...z}}c(kd,"refreshAuthorization");async function Md(n,e,{metadata:t,resource:i,authorizationCode:r,fetchFn:u}={}){let h=c(async()=>{let g=await n.clientInformation(),x=is(g,String(e));if(g&&!x)throw Qi(g,String(e));return x},"readClientInformation"),p=await h(),z=n.clientMetadata.scope,m;if(n.prepareTokenRequest&&(m=await n.prepareTokenRequest(z)),!m){if(!r)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!n.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let g=await n.codeVerifier();m=Id(r,g,n.redirectUrl)}return p??(p=await h()),Yi(e,{metadata:t,tokenRequestParams:m,clientInformation:p,addClientAuthentication:n.addClientAuthentication,resource:i,fetchFn:u})}c(Md,"fetchToken");async function Od(n,{metadata:e,clientMetadata:t,scope:i,fetchFn:r}){let u;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");u=new URL(e.registration_endpoint)}else u=new URL("/register",n);let h=await ce(r??fetch)(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,...i!==void 0?{scope:i}:{}})});if(!h.ok)throw await Ji(h);return yd.parse(await h.json())}c(Od,"registerClient");var Ke=class extends Error{static{c(this,"ParseError")}constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},eo=10,Nd=13,he=32;function as(n){}c(as,"noop");function so(n){if(typeof n=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=as,onError:t=as,onRetry:i=as,onComment:r,maxBufferSize:u}=n,h=[],p=0,z=!0,m,g="",x=0,v,E=!1;function j(y){if(E)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(z&&(z=!1,y.charCodeAt(0)===239&&y.charCodeAt(1)===187&&y.charCodeAt(2)===191&&(y=y.slice(3))),h.length===0){let L=k(y);L!==""&&(h.push(L),p=L.length),R();return}if(y.indexOf(`
|
|
4
4
|
`)===-1&&y.indexOf("\r")===-1){h.push(y),p+=y.length,R();return}h.push(y);let b=h.join("");h.length=0,p=0;let M=k(b);M!==""&&(h.push(M),p=M.length),R()}c(j,"feed");function R(){u!==void 0&&(p+g.length<=u||(E=!0,h.length=0,p=0,m=void 0,g="",x=0,v=void 0,t(new Ke(`Buffered data exceeded max buffer size of ${u} characters`,{type:"max-buffer-size-exceeded"}))))}c(R,"checkBufferSize");function k(y){let b=0;if(y.indexOf("\r")===-1){let M=y.indexOf(`
|
|
5
5
|
`,b);for(;M!==-1;){if(b===M){x>0&&e({id:m,event:v,data:g}),m=void 0,g="",x=0,v=void 0,b=M+1,M=y.indexOf(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as R,c as p,d as m}from"./chunk-DRMOHADV.js";import{a as v}from"./chunk-RFQD6B44.js";import"./chunk-MTP3B2SU.js";import{w as O}from"./chunk-
|
|
2
|
+
import{b as R,c as p,d as m}from"./chunk-DRMOHADV.js";import{a as v}from"./chunk-RFQD6B44.js";import"./chunk-MTP3B2SU.js";import{w as O}from"./chunk-Z5CQXPIS.js";import"./chunk-7EQLW2KM.js";import{d as P}from"./chunk-RPM4FDRX.js";import"./chunk-KP2MYTP5.js";import"./chunk-PNPV2LDE.js";import"./chunk-4G3GTEVS.js";import"./chunk-KU4TPDPH.js";import"./chunk-55YD4UTW.js";import"./chunk-AFYYIJ6K.js";import"./chunk-J256AEEE.js";import"./chunk-UN2LKLGV.js";import"./chunk-2LJCJOJ7.js";import"./chunk-AMC4Z7G4.js";import"./chunk-LK77GI6M.js";import"./chunk-HVM2GUM3.js";import"./chunk-I6VMRQF4.js";import"./chunk-D6L6UNUQ.js";import"./chunk-AJXWJLZA.js";import"./chunk-OKKNDQJF.js";import"./chunk-4PUOWSDE.js";import"./chunk-ZY32SZ2P.js";import"./chunk-OTDDXEQ6.js";import"./chunk-ECOH24MC.js";import"./chunk-XWPC3AN4.js";import{f as b}from"./chunk-3M53YXEI.js";import"./chunk-GLUWATL5.js";import"./chunk-JCLTFDVW.js";import"./chunk-SV7ZBEK2.js";import"./chunk-2MEOUS24.js";import"./chunk-HNQPEOJD.js";import"./chunk-RCT3O3HQ.js";import"./chunk-UGOK7VTC.js";import"./chunk-TBODQT4W.js";import"./chunk-5HPZGLOL.js";import"./chunk-ZFJWA4JK.js";import"./chunk-X2J2P5ZT.js";import{a as c}from"./chunk-FTQLQJQV.js";import{promises as $,watch as C}from"node:fs";import y from"node:path";import{execFile as J}from"node:child_process";import{promisify as k}from"node:util";var K=k(J);async function G(t,n){let e=n[0]??"check",o=y.resolve(i(t,"cwd")??process.cwd()),l=i(t,"sourceDirectory"),u=i(t,"outputDirectory"),d=b(t.json);if(e==="check"||e==="build"){let r=await p({projectRoot:o,sourceDirectory:l,outputDirectory:u});if(d){console.log(JSON.stringify({status:"passed",actionCount:r.registry.actions.length,registry:r.registry,manifest:r.manifest,outputDirectory:r.outputDirectory},null,2));return}console.log(`${e==="check"?"Validated":"Built"} ${r.registry.actions.length} Project Action${r.registry.actions.length===1?"":"s"}.`),console.log(`Registry: ${r.registryPath}`),console.log(`Bundle: ${r.bundlePath}`);return}if(e==="run"){let r=n[1];if(!r)throw new Error("usage: openpond actions run <action-id> [--input JSON|--input-file PATH]");let a=await m({projectRoot:o,sourceDirectory:l,outputDirectory:u,build:"always"}).run({actionId:r,input:await I(t,o),timeoutMs:A(t,"timeoutMs")});console.log(JSON.stringify(a,null,2));return}if(e==="dev"){let r=n[1]??null;await _({projectRoot:o,sourceDirectory:l,outputDirectory:u,actionId:r,options:t,json:d});return}if(e==="publish"){let r=j(t,"projectId"),s=j(t,"teamId"),a=i(t,"apiKey"),w=process.env.OPENPOND_API_KEY?.trim()||null,g=a||w?null:await P({account:i(t,"account")}),h=a??w??(g?v(g):null);if(!h)throw new Error("OpenPond API key is required. Select a saved OpenPond account, set OPENPOND_API_KEY, or pass --api-key.");let N=await p({projectRoot:o,sourceDirectory:l,outputDirectory:u}),E=i(t,"sourceCommitSha")??await D(o,["rev-parse","HEAD"]),S=i(t,"sourceRef")??await D(o,["rev-parse","--abbrev-ref","HEAD"]),f=await O({apiKey:h,baseUrl:i(t,"baseUrl")??(process.env.OPENPOND_API_URL?.trim()||g?.apiBaseUrl)}).actions.publish({projectId:r,teamId:s,sourceRef:S,sourceCommitSha:E,build:N});console.log(d?JSON.stringify({release:f},null,2):`Published Project Actions release ${f.id} from ${f.sourceCommitSha}.`);return}throw new Error("usage: openpond actions <check|build|run|dev|publish> [action-id]")}c(G,"runProjectActionsCommand");async function _(t){let n=!1,e=!1,o=c(async()=>{if(n){e=!0;return}n=!0;try{let r=m({projectRoot:t.projectRoot,sourceDirectory:t.sourceDirectory,outputDirectory:t.outputDirectory,build:"always"});if(t.actionId){let s=await r.run({actionId:t.actionId,input:await I(t.options,t.projectRoot),timeoutMs:A(t.options,"timeoutMs")});console.log(JSON.stringify(s,null,2))}else{let s=await r.build(),a={status:"ready",actionCount:s.registry.actions.length,bundleHash:s.manifest.bundleHash};console.log(t.json?JSON.stringify(a):`Ready with ${a.actionCount} Project Action${a.actionCount===1?"":"s"}.`)}}catch(r){console.error(r instanceof Error?r.message:String(r))}finally{n=!1,e&&(e=!1,await o())}},"execute");await o();let l=await R(t.projectRoot),u=y.resolve(t.projectRoot,t.sourceDirectory??l.sourceDirectory??"openpond/actions");console.log(`Watching ${u}`);let d=C(u,{recursive:!0},()=>{setTimeout(()=>{o()},50)});await new Promise(r=>{let s=c(()=>{d.close(),r()},"stop");process.once("SIGINT",s),process.once("SIGTERM",s)})}c(_,"runDev");async function I(t,n){let e=i(t,"input"),o=i(t,"inputFile");if(e&&o)throw new Error("Use either --input or --input-file, not both.");return e?JSON.parse(e):o?JSON.parse(await $.readFile(y.resolve(n,o),"utf8")):{}}c(I,"actionInput");function i(t,n){let e=t[n];return typeof e=="string"&&e.trim()?e.trim():void 0}c(i,"stringOption");function j(t,n){let e=i(t,n);if(!e)throw new Error(`--${n.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)} is required.`);return e}c(j,"requiredOption");async function D(t,n){let{stdout:e}=await K("git",n,{cwd:t}),o=e.trim();if(!o)throw new Error(`git ${n.join(" ")} returned no value.`);return o}c(D,"gitValue");function A(t,n){let e=i(t,n);if(e===void 0)return;let o=Number(e);if(!Number.isInteger(o)||o<=0)throw new Error(`--${n} must be a positive integer.`);return o}c(A,"integerOption");export{G as runProjectActionsCommand};
|