alchemylab-opencode 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NODE_COMPAT.md +8 -1
- package/dist/20260127222353_familiar_lady_ursula-YYOFSQD5.js +18 -0
- package/dist/20260211171708_add_project_commands-3GKQTPBZ.js +18 -0
- package/dist/20260213144116_wakeful_the_professor-ROO7OAVL.js +18 -0
- package/dist/20260225215848_workspace-V2OZTNFF.js +18 -0
- package/dist/20260227213759_add_session_workspace_id-GVDWAXKM.js +18 -0
- package/dist/20260228203230_blue_harpoon-Z5QP2II5.js +18 -0
- package/dist/20260303231226_add_workspace_fields-QOVAFN7W.js +18 -0
- package/dist/20260309230000_move_org_to_state-RQURSDZD.js +18 -0
- package/dist/20260312043431_session_message_cursor-VBISKDXL.js +18 -0
- package/dist/20260323234822_events-PILJHLNA.js +18 -0
- package/dist/20260410174513_workspace-name-63YCZ5NS.js +18 -0
- package/dist/20260413175956_chief_energizer-NMAZYGDO.js +18 -0
- package/dist/20260423070820_add_icon_url_override-RAJCVNEP.js +18 -0
- package/dist/20260427172553_slow_nightmare-ULYYZLR4.js +18 -0
- package/dist/20260428004200_add_session_path-U4WO2TGE.js +18 -0
- package/dist/20260501142318_next_venus-6BCYATSC.js +18 -0
- package/dist/20260504145000_add_sync_owner-RGVHV6LN.js +18 -0
- package/dist/20260507164347_add_workspace_time-GE6UHNPM.js +18 -0
- package/dist/{20260510033149_session_usage-UGBVOXZB.js → 20260510033149_session_usage-7XHCFVKY.js} +5 -1
- package/dist/20260511000411_data_migration_state-2EGZKFLB.js +18 -0
- package/dist/20260511173437_session-metadata-K322YY33.js +18 -0
- package/dist/20260601010001_normalize_storage_paths-VZDTY366.js +18 -0
- package/dist/{20260225215848_workspace-ZMSOZSPA.js → 20260601202201_amazing_prowler-YT6PLK3L.js} +5 -1
- package/dist/{20260228203230_blue_harpoon-IW3Z4TQZ.js → 20260602002951_lowly_union_jack-6VLQTBVB.js} +5 -1
- package/dist/20260602182828_add_project_directories-TVSRD25A.js +18 -0
- package/dist/20260603001617_session_message_projection_indexes-PHKTF6HK.js +18 -0
- package/dist/{20260622170816_reset_v2_session_state-5JPHJTZG.js → 20260603040000_session_message_projection_order-7RTV2POG.js} +5 -1
- package/dist/20260603141458_session_input_inbox-RSBWABG7.js +18 -0
- package/dist/20260603160727_jittery_ezekiel_stane-DXBLLRVV.js +18 -0
- package/dist/20260604172448_event_sourced_session_input-H6Z3JEBD.js +18 -0
- package/dist/20260605003541_add_session_context_snapshot-6FDPM2TK.js +18 -0
- package/dist/20260605042240_add_context_epoch_agent-C2OF2UKR.js +18 -0
- package/dist/20260611035744_credential-YNZ47FSH.js +18 -0
- package/dist/20260611192811_lush_chimera-E357VI6P.js +18 -0
- package/dist/20260612174303_project_dir_strategy-VUGGK42O.js +18 -0
- package/dist/20260622142730_simplify_session_context_epoch-UYGXZ5BX.js +18 -0
- package/dist/20260622170816_reset_v2_session_state-EILLPCJQ.js +18 -0
- package/dist/20260622202450_simplify_session_input-Y65GDGBO.js +18 -0
- package/dist/NodeSdk-AGMQWBHH.js +18 -0
- package/dist/anthropic-45OFTLAW.js +18 -0
- package/dist/anthropic-FVULF7C3.js +18 -0
- package/dist/app-runtime-LDQWNGWP.js +18 -0
- package/dist/chunk-2JE3QYG6.js +18 -0
- package/dist/chunk-2MRHL4B2.js +18 -0
- package/dist/chunk-4GJE6OMN.js +190 -0
- package/dist/chunk-4MBUHJHY.js +22 -0
- package/dist/chunk-5BLZCAU6.js +55 -0
- package/dist/chunk-7XX6TY62.js +259 -0
- package/dist/chunk-ANF3QA3Z.js +48 -0
- package/dist/chunk-AZUMH3TO.js +18 -0
- package/dist/chunk-B74WSFN4.js +878 -0
- package/dist/chunk-BQ4IEPN3.js +19 -0
- package/dist/chunk-CYRZU5QM.js +33 -0
- package/dist/chunk-DADVNQTM.js +1490 -0
- package/dist/chunk-DO2UZ6NY.js +18 -0
- package/dist/chunk-DWEYXIQI.js +780 -0
- package/dist/chunk-EK6FQQHY.js +20 -0
- package/dist/chunk-ELPXQ32J.js +90 -0
- package/dist/chunk-FGLPSSRK.js +19 -0
- package/dist/chunk-FOHYZ7MJ.js +55 -0
- package/dist/chunk-FV7U6PVP.js +18 -0
- package/dist/chunk-FYYAOZPU.js +18 -0
- package/dist/chunk-G7PFO5HG.js +920 -0
- package/dist/chunk-GDWO6EXN.js +22 -0
- package/dist/chunk-GW3ZRKAI.js +20 -0
- package/dist/chunk-IYUSBBGY.js +35 -0
- package/dist/chunk-JPOFLMNH.js +18 -0
- package/dist/{chunk-VURLSDCB.js → chunk-K5LKDIVU.js} +4 -0
- package/dist/chunk-KS4WLVK5.js +19 -0
- package/dist/chunk-LIXP4TPL.js +18 -0
- package/dist/chunk-LSC4RT5V.js +36 -0
- package/dist/chunk-M5A6NFHQ.js +28 -0
- package/dist/chunk-M6E6KNLV.js +30 -0
- package/dist/chunk-MLFZXUGQ.js +18 -0
- package/dist/chunk-NDI67DRG.js +31 -0
- package/dist/chunk-NGT6LCW6.js +18 -0
- package/dist/chunk-OCWGUTZJ.js +36 -0
- package/dist/chunk-OGDRUXMJ.js +18 -0
- package/dist/chunk-OGJKLJC7.js +29 -0
- package/dist/chunk-OT2YNR56.js +19 -0
- package/dist/chunk-OUVSKG2H.js +19 -0
- package/dist/chunk-P5RLCJUV.js +18 -0
- package/dist/chunk-Q3WIUQXB.js +18 -0
- package/dist/{20260227213759_add_session_workspace_id-ROENWPKA.js → chunk-QCRIXKIC.js} +5 -1
- package/dist/chunk-QD24DLUD.js +18 -0
- package/dist/chunk-R2GWBJEP.js +18 -0
- package/dist/chunk-RPAXSOGH.js +18 -0
- package/dist/chunk-TK5R7QUN.js +18 -0
- package/dist/chunk-TNQWZFIZ.js +28 -0
- package/dist/chunk-UCLPBO4I.js +18 -0
- package/dist/chunk-UPEPL4I2.js +18 -0
- package/dist/chunk-V6FDDNGV.js +117 -0
- package/dist/chunk-V6HERYFV.js +18 -0
- package/dist/chunk-V7XKKJ7X.js +24 -0
- package/dist/chunk-VHDYUBBS.js +23 -0
- package/dist/chunk-VWLJXTZ5.js +18 -0
- package/dist/chunk-VXAPFOIL.js +22 -0
- package/dist/chunk-WKZYINC7.js +29 -0
- package/dist/chunk-WPMP2ZFE.js +40 -0
- package/dist/chunk-WRTNIOI3.js +18 -0
- package/dist/chunk-X5F46HR5.js +18 -0
- package/dist/chunk-XPS7TQZG.js +22 -0
- package/dist/chunk-YJPP6IQ3.js +23 -0
- package/dist/chunk-ZYQWFC55.js +22 -0
- package/dist/code-mode-YYOGD36U.js +502 -0
- package/dist/copilot-provider-QVMLQZZC.js +18 -0
- package/dist/dist-5NQOHNPL.js +18 -0
- package/dist/dist-7CT3XCNN.js +32 -0
- package/dist/dist-CL46WFZG.js +18 -0
- package/dist/{20260605042240_add_context_epoch_agent-W6IQYZXE.js → dist-CYBRID2F.js} +5 -1
- package/dist/dist-HXJTF22W.js +32 -0
- package/dist/dist-JFXI53ZF.js +22 -0
- package/dist/dist-KBYKWVT5.js +22 -0
- package/dist/dist-KM5HCPZX.js +35 -0
- package/dist/dist-KTNLTEHB.js +18 -0
- package/dist/dist-KZ5R5QM5.js +24 -0
- package/dist/dist-NLXUYBW7.js +32 -0
- package/dist/dist-O4DF72J2.js +22 -0
- package/dist/dist-PH4MEGVR.js +22 -0
- package/dist/{20260511000411_data_migration_state-FB4LBFSE.js → dist-QJPOJCLB.js} +5 -1
- package/dist/dist-QYH62TCJ.js +22 -0
- package/dist/{20260303231226_add_workspace_fields-OUVZMNAG.js → dist-RIC4WKHC.js} +5 -1
- package/dist/dist-T776XKTM.js +22 -0
- package/dist/dist-TCE5MKZQ.js +23 -0
- package/dist/dist-TH2Q44RX.js +50 -0
- package/dist/dist-VV5FV5RT.js +101 -0
- package/dist/dist-XAFENVUS.js +22 -0
- package/dist/dist-XPFB35TX.js +32 -0
- package/dist/dist-YUH4RKR5.js +28 -0
- package/dist/dist-es-43ZM44MP.js +18 -0
- package/dist/dist-es-6PLFRCS4.js +18 -0
- package/dist/dist-es-G5UIJOU7.js +26 -0
- package/dist/{20260428004200_add_session_path-LGW75WYA.js → dist-es-HYIIGUNX.js} +5 -1
- package/dist/dist-es-L2GU465G.js +18 -0
- package/dist/dist-es-LSR2QCFZ.js +18 -0
- package/dist/dist-es-RGEIM2BP.js +18 -0
- package/dist/dist-es-SITTNOGV.js +18 -0
- package/dist/dist-es-W5GYOX6F.js +18 -0
- package/dist/esm-NN5W7YCL.js +18 -0
- package/dist/esm-XWJSHYHG.js +18 -0
- package/dist/getMachineId-bsd-L5I5TZ5I.js +18 -0
- package/dist/getMachineId-darwin-YB7KG37W.js +19 -0
- package/dist/getMachineId-linux-EL47KXX7.js +18 -0
- package/dist/getMachineId-unsupported-QOWPEBPN.js +18 -0
- package/dist/getMachineId-win-HCRYRDFJ.js +18 -0
- package/dist/lib-ZP7Q6A3E.js +199 -0
- package/dist/loadCognitoIdentity-EWT55EI7.js +18 -0
- package/dist/loadSso-AGOUE6RL.js +18 -0
- package/dist/{20260213144116_wakeful_the_professor-ZVDD54AK.js → loadSts-RH5L3PIX.js} +5 -1
- package/dist/mantle-IJXDXT4M.js +25 -0
- package/dist/mime-types-46EO4HOZ.js +18 -0
- package/dist/multipart-parser-KZWMKXA4.js +19 -0
- package/dist/{20260211171708_add_project_commands-GDOHPDPF.js → open-7KXTRM37.js} +5 -1
- package/dist/openai-ZOJI6I5R.js +18 -0
- package/dist/p-map-CYL6ILJW.js +18 -0
- package/dist/photon-W56QZY4L.js +18 -0
- package/dist/{20260423070820_add_icon_url_override-X5SHFGTI.js → pkce-VT4ITJTB.js} +5 -1
- package/dist/{pty.node-Y3N2XKYG.js → pty.node-IWULXXG6.js} +5 -1
- package/dist/run.js +5 -1
- package/dist/serve.js +143 -1
- package/dist/server-LVIHYOCY.js +21 -0
- package/dist/session-6OPJNJMK.js +18 -0
- package/dist/signin-OCIW23YM.js +18 -0
- package/dist/src-3NCXEROI.js +18 -0
- package/dist/src-LXWGIUZH.js +18 -0
- package/dist/src-WDYKISPD.js +20 -0
- package/dist/src-YAAFIGTW.js +18 -0
- package/dist/sso-oidc-OMMKINFE.js +18 -0
- package/dist/sts-MWK22JIX.js +18 -0
- package/dist/token-QPO3OAGS.js +18 -0
- package/dist/token-util-YGPCEEPO.js +18 -0
- package/dist/unified-W3ZKZ4HG.js +18 -0
- package/dist/worktree-32M5MTFE.js +18 -0
- package/package.json +40 -40
- package/postinstall.cjs +4 -2
- package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +0 -14
- package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +0 -14
- package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +0 -14
- package/dist/20260323234822_events-72GIKJ2A.js +0 -14
- package/dist/20260410174513_workspace-name-JXSWFBJN.js +0 -14
- package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +0 -14
- package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +0 -14
- package/dist/20260501142318_next_venus-J3TLVXZ6.js +0 -14
- package/dist/20260504145000_add_sync_owner-3R52GB4C.js +0 -14
- package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +0 -14
- package/dist/20260511173437_session-metadata-T2XHGWHS.js +0 -14
- package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +0 -14
- package/dist/20260601202201_amazing_prowler-PET224YG.js +0 -14
- package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +0 -14
- package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +0 -14
- package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +0 -14
- package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +0 -14
- package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +0 -14
- package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +0 -14
- package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +0 -14
- package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +0 -14
- package/dist/20260611035744_credential-XTMSYTJD.js +0 -14
- package/dist/20260611192811_lush_chimera-XPLIQMJD.js +0 -14
- package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +0 -14
- package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +0 -14
- package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +0 -14
- package/dist/app-runtime-HQBOCDV5.js +0 -14
- package/dist/chunk-4FEBIOI5.js +0 -865
- package/dist/chunk-4K2RXRZL.js +0 -14
- package/dist/chunk-4RFMKEKM.js +0 -1455
- package/dist/chunk-BM2C7NHL.js +0 -41
- package/dist/chunk-MKEMZFJI.js +0 -393
- package/dist/chunk-OMDJ6ZZ2.js +0 -684
- package/dist/chunk-OWMG4NNF.js +0 -186
- package/dist/chunk-QRABYJKL.js +0 -14
- package/dist/chunk-RHIWAYN5.js +0 -14
- package/dist/chunk-Z5TLIUAI.js +0 -28
- package/dist/code-mode-7BQJUARW.js +0 -40
- package/dist/copilot-provider-TX4YFKJZ.js +0 -14
- package/dist/photon-VQS5F5BI.js +0 -14
- package/dist/server-BFUQR7MX.js +0 -17
- package/dist/session-6RNXZNG6.js +0 -14
- package/dist/worktree-QHQHX3SG.js +0 -14
- package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +0 -164
- package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +0 -528
- package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +0 -69
- package/patches/@ai-sdk%2Fgroq@3.0.31.patch +0 -79
- package/patches/@ai-sdk%2Fmistral@3.0.51.patch +0 -714
- package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +0 -39
- package/patches/@ai-sdk%2Fopenai@3.0.88.patch +0 -280
- package/patches/@ai-sdk%2Fxai@3.0.139.patch +0 -296
- package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +0 -647
- package/patches/@npmcli%2Fagent@4.0.2.patch +0 -13
- package/patches/effect@4.0.0-beta.83.patch +0 -57
- package/patches/gcp-metadata@8.1.2.patch +0 -14
- package/patches/pacote@21.5.0.patch +0 -18
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Built by esbuild from opencode-server source
|
|
2
|
+
if (typeof globalThis.Bun === 'undefined') {
|
|
3
|
+
globalThis.Bun = {
|
|
4
|
+
version: '0.0.0-node-compat',
|
|
5
|
+
stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
|
|
6
|
+
which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
|
|
10
|
+
if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
|
|
11
|
+
import { createRequire as __alchemyCreateRequire } from 'node:module';
|
|
12
|
+
const require = __alchemyCreateRequire(import.meta.url);
|
|
13
|
+
import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
|
|
14
|
+
import { dirname as __alchemyDirname } from 'node:path';
|
|
15
|
+
const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
|
|
16
|
+
const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
|
|
17
|
+
|
|
18
|
+
import{L as wt,P as Be,X as ze}from"./chunk-B74WSFN4.js";import{Aa as ht,C as Ne,Da as T,Ma as Ve,_a as $e,jb as J,kb as Me,lb as Oe,mb as qe,s as Ae,v as se,wa as Ge,za as Le}from"./chunk-DWEYXIQI.js";import{c as gt}from"./chunk-R2GWBJEP.js";import{$c as We,Aa as Se,Fa as at,Oa as dt,Pa as D,Ra as lt,Wc as X,_c as m,ad as _e,b as rt,bd as U,c as xe,de as yt,ha as Z,ia as ot,ka as nt,lb as ft,lc as ut,mb as pt,oa as H,pa as it,pc as L,qb as de,rc as mt,uc as be,vb as je,ya as st,za as ct}from"./chunk-7XX6TY62.js";import{Bc as ae,Bf as e,Tc as Q,bb as z,bi as ve,dc as O,lc as we,nb as et,ni as tt,pj as n}from"./chunk-ELPXQ32J.js";import{a as u,e as ie}from"./chunk-2MRHL4B2.js";var Ze={};ie(Ze,{CreateFailedError:()=>Te,CreateInput:()=>$t,Event:()=>Ce,Info:()=>Vt,ListFailedError:()=>Fe,NameGenerationFailedError:()=>Re,NotGitError:()=>me,RemoveFailedError:()=>re,RemoveInput:()=>Mt,ResetFailedError:()=>W,ResetInput:()=>Ot,Service:()=>ye,StartCommandFailedError:()=>Qe,Worktree:()=>Ze,node:()=>Yt});var ue={};ie(ue,{InstanceStore:()=>ue,Service:()=>ce,bootstrapNode:()=>bt,node:()=>Gt,use:()=>At});var le={};ie(le,{InstanceBootstrap:()=>le,Service:()=>Ye});var Ye=class extends z.Service()("@opencode/InstanceBootstrap"){static{u(this,"Service")}};var te={};ie(te,{Event:()=>xt,Info:()=>Tt,NotFoundError:()=>Pe,Project:()=>te,Service:()=>K,UpdateInput:()=>Ft,UpdatePayload:()=>Ut,fromRow:()=>ee,node:()=>Ke,use:()=>_t});var pe={};ie(pe,{Command:()=>pe,Default:()=>ke,Event:()=>Dt,Info:()=>Pt,Service:()=>fe,hints:()=>De,node:()=>Rt});import jt from"path";var He=`Create or update \`AGENTS.md\` for this repository.
|
|
19
|
+
|
|
20
|
+
The goal is a compact instruction file that helps future OpenCode sessions avoid mistakes and ramp up quickly. Every line should answer: "Would an agent likely miss this without help?" If not, leave it out.
|
|
21
|
+
|
|
22
|
+
User-provided focus or constraints (honor these):
|
|
23
|
+
$ARGUMENTS
|
|
24
|
+
|
|
25
|
+
## How to investigate
|
|
26
|
+
|
|
27
|
+
Read the highest-value sources first:
|
|
28
|
+
- \`README*\`, root manifests, workspace config, lockfiles
|
|
29
|
+
- build, test, lint, formatter, typecheck, and codegen config
|
|
30
|
+
- CI workflows and pre-commit / task runner config
|
|
31
|
+
- existing instruction files (\`AGENTS.md\`, \`CLAUDE.md\`, \`.cursor/rules/\`, \`.cursorrules\`, \`.github/copilot-instructions.md\`)
|
|
32
|
+
- repo-local OpenCode config such as \`opencode.json\`
|
|
33
|
+
|
|
34
|
+
If architecture is still unclear after reading config and docs, inspect a small number of representative code files to find the real entrypoints, package boundaries, and execution flow. Prefer reading the files that explain how the system is wired together over random leaf files.
|
|
35
|
+
|
|
36
|
+
Prefer executable sources of truth over prose. If docs conflict with config or scripts, trust the executable source and only keep what you can verify.
|
|
37
|
+
|
|
38
|
+
## What to extract
|
|
39
|
+
|
|
40
|
+
Look for the highest-signal facts for an agent working in this repo:
|
|
41
|
+
- exact developer commands, especially non-obvious ones
|
|
42
|
+
- how to run a single test, a single package, or a focused verification step
|
|
43
|
+
- required command order when it matters, such as \`lint -> typecheck -> test\`
|
|
44
|
+
- monorepo or multi-package boundaries, ownership of major directories, and the real app/library entrypoints
|
|
45
|
+
- framework or toolchain quirks: generated code, migrations, codegen, build artifacts, special env loading, dev servers, infra deploy flow
|
|
46
|
+
- repo-specific style or workflow conventions that differ from defaults
|
|
47
|
+
- testing quirks: fixtures, integration test prerequisites, snapshot workflows, required services, flaky or expensive suites
|
|
48
|
+
- important constraints from existing instruction files worth preserving
|
|
49
|
+
|
|
50
|
+
Good \`AGENTS.md\` content is usually hard-earned context that took reading multiple files to infer.
|
|
51
|
+
|
|
52
|
+
## Questions
|
|
53
|
+
|
|
54
|
+
Only ask the user questions if the repo cannot answer something important. Use the \`question\` tool for one short batch at most.
|
|
55
|
+
|
|
56
|
+
Good questions:
|
|
57
|
+
- undocumented team conventions
|
|
58
|
+
- branch / PR / release expectations
|
|
59
|
+
- missing setup or test prerequisites that are known but not written down
|
|
60
|
+
|
|
61
|
+
Do not ask about anything the repo already makes clear.
|
|
62
|
+
|
|
63
|
+
## Writing rules
|
|
64
|
+
|
|
65
|
+
Include only high-signal, repo-specific guidance such as:
|
|
66
|
+
- exact commands and shortcuts the agent would otherwise guess wrong
|
|
67
|
+
- architecture notes that are not obvious from filenames
|
|
68
|
+
- conventions that differ from language or framework defaults
|
|
69
|
+
- setup requirements, environment quirks, and operational gotchas
|
|
70
|
+
- references to existing instruction sources that matter
|
|
71
|
+
|
|
72
|
+
Exclude:
|
|
73
|
+
- generic software advice
|
|
74
|
+
- long tutorials or exhaustive file trees
|
|
75
|
+
- obvious language conventions
|
|
76
|
+
- speculative claims or anything you could not verify
|
|
77
|
+
- content better stored in another file referenced via \`opencode.json\` \`instructions\`
|
|
78
|
+
|
|
79
|
+
When in doubt, omit.
|
|
80
|
+
|
|
81
|
+
Prefer short sections and bullets. If the repo is simple, keep the file simple. If the repo is large, summarize the few structural facts that actually change how an agent should work.
|
|
82
|
+
|
|
83
|
+
If \`AGENTS.md\` already exists at \`\${path}\`, improve it in place rather than rewriting blindly. Preserve verified useful guidance, delete fluff or stale claims, and reconcile it with the current codebase.
|
|
84
|
+
`;var Xe=`You are a code reviewer. Your job is to review code changes and provide actionable feedback.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
Input: $ARGUMENTS
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Determining What to Review
|
|
93
|
+
|
|
94
|
+
Based on the input provided, determine which type of review to perform:
|
|
95
|
+
|
|
96
|
+
1. **No arguments (default)**: Review all uncommitted changes
|
|
97
|
+
- Run: \`git diff\` for unstaged changes
|
|
98
|
+
- Run: \`git diff --cached\` for staged changes
|
|
99
|
+
- Run: \`git status --short\` to identify untracked (net new) files
|
|
100
|
+
|
|
101
|
+
2. **Commit hash** (40-char SHA or short hash): Review that specific commit
|
|
102
|
+
- Run: \`git show $ARGUMENTS\`
|
|
103
|
+
|
|
104
|
+
3. **Branch name**: Compare current branch to the specified branch
|
|
105
|
+
- Run: \`git diff $ARGUMENTS...HEAD\`
|
|
106
|
+
|
|
107
|
+
4. **PR URL or number** (contains "github.com" or "pull" or looks like a PR number): Review the pull request
|
|
108
|
+
- Run: \`gh pr view $ARGUMENTS\` to get PR context
|
|
109
|
+
- Run: \`gh pr diff $ARGUMENTS\` to get the diff
|
|
110
|
+
|
|
111
|
+
Use best judgement when processing input.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Gathering Context
|
|
116
|
+
|
|
117
|
+
**Diffs alone are not enough.** After getting the diff, read the entire file(s) being modified to understand the full context. Code that looks wrong in isolation may be correct given surrounding logic\u2014and vice versa.
|
|
118
|
+
|
|
119
|
+
- Use the diff to identify which files changed
|
|
120
|
+
- Use \`git status --short\` to identify untracked files, then read their full contents
|
|
121
|
+
- Read the full file to understand existing patterns, control flow, and error handling
|
|
122
|
+
- Check for existing style guide or conventions files (CONVENTIONS.md, AGENTS.md, .editorconfig, etc.)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## What to Look For
|
|
127
|
+
|
|
128
|
+
**Bugs** - Your primary focus.
|
|
129
|
+
- Logic errors, off-by-one mistakes, incorrect conditionals
|
|
130
|
+
- If-else guards: missing guards, incorrect branching, unreachable code paths
|
|
131
|
+
- Edge cases: null/empty/undefined inputs, error conditions, race conditions
|
|
132
|
+
- Security issues: injection, auth bypass, data exposure
|
|
133
|
+
- Broken error handling that swallows failures, throws unexpectedly or returns error types that are not caught.
|
|
134
|
+
|
|
135
|
+
**Structure** - Does the code fit the codebase?
|
|
136
|
+
- Does it follow existing patterns and conventions?
|
|
137
|
+
- Are there established abstractions it should use but doesn't?
|
|
138
|
+
- Excessive nesting that could be flattened with early returns or extraction
|
|
139
|
+
|
|
140
|
+
**Performance** - Only flag if obviously problematic.
|
|
141
|
+
- O(n\xB2) on unbounded data, N+1 queries, blocking I/O on hot paths
|
|
142
|
+
|
|
143
|
+
**Behavior Changes** - If a behavioral change is introduced, raise it (especially if it's possibly unintentional).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Before You Flag Something
|
|
148
|
+
|
|
149
|
+
**Be certain.** If you're going to call something a bug, you need to be confident it actually is one.
|
|
150
|
+
|
|
151
|
+
- Only review the changes - do not review pre-existing code that wasn't modified
|
|
152
|
+
- Don't flag something as a bug if you're unsure - investigate first
|
|
153
|
+
- Don't invent hypothetical problems - if an edge case matters, explain the realistic scenario where it breaks
|
|
154
|
+
- If you need more context to be sure, use the tools below to get it
|
|
155
|
+
|
|
156
|
+
**Don't be a zealot about style.** When checking code against conventions:
|
|
157
|
+
|
|
158
|
+
- Verify the code is *actually* in violation. Don't complain about else statements if early returns are already being used correctly.
|
|
159
|
+
- Some "violations" are acceptable when they're the simplest option. A \`let\` statement is fine if the alternative is convoluted.
|
|
160
|
+
- Excessive nesting is a legitimate concern regardless of other style choices.
|
|
161
|
+
- Don't flag style preferences as issues unless they clearly violate established project conventions.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Tools
|
|
166
|
+
|
|
167
|
+
Use these to inform your review:
|
|
168
|
+
|
|
169
|
+
- **Explore agent** - Find how existing code handles similar problems. Check patterns, conventions, and prior art before claiming something doesn't fit.
|
|
170
|
+
- **Exa Code Context** - Verify correct usage of libraries/APIs before flagging something as wrong.
|
|
171
|
+
- **Web Search** - Research best practices if you're unsure about a pattern.
|
|
172
|
+
|
|
173
|
+
If you're uncertain about something and can't verify it with these tools, say "I'm not sure about X" rather than flagging it as a definite issue.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Output
|
|
178
|
+
|
|
179
|
+
1. If there is a bug, be direct and clear about why it is a bug.
|
|
180
|
+
2. Clearly communicate severity of issues. Do not overstate severity.
|
|
181
|
+
3. Critiques should clearly and explicitly communicate the scenarios, environments, or inputs that are necessary for the bug to arise. The comment should immediately indicate that the issue's severity depends on these factors.
|
|
182
|
+
4. Your tone should be matter-of-fact and not accusatory or overly positive. It should read as a helpful AI assistant suggestion without sounding too much like a human reviewer.
|
|
183
|
+
5. Write so the reader can quickly understand the issue without reading too closely.
|
|
184
|
+
6. AVOID flattery, do not give any comments that are not helpful to the reader. Avoid phrasing like "Great job ...", "Thanks for ...".
|
|
185
|
+
`;var Ie={};ie(Ie,{CommandExecuted:()=>vt,Definitions:()=>St,LegacyEvent:()=>Ie});var vt=st({type:"command.executed",schema:{name:n.String,sessionID:at,arguments:n.String,messageID:yt.MessageID}}),St=ct(vt);var Dt={Executed:Ie.CommandExecuted},Pt=n.Struct({name:n.String,description:n.optional(n.String),agent:n.optional(n.String),model:n.optional(n.String),source:n.optional(n.Literals(["command","mcp","skill"])),template:n.Unknown,subtask:n.optional(n.Boolean),hints:n.Array(n.String)}).annotate({identifier:"Command"});function De(a){let k=[],w=a.match(/\$\d+/g);if(w)for(let x of[...new Set(w)].sort())k.push(x);return a.includes("$ARGUMENTS")&&k.push("$ARGUMENTS"),k}u(De,"hints");var ke={INIT:"init",REVIEW:"review"},fe=class extends z.Service()("@opencode/Command"){static{u(this,"Service")}},Ct=Q.effect(fe,e.gen(function*(){let a=yield*$e.Service,k=yield*ze.Service,w=yield*Be.Service,x=e.fn("Command.state")(function*(C){let v=yield*a.get(),B=yield*wt.make(),_={};_[ke.INIT]={name:ke.INIT,description:"guided AGENTS.md setup",source:"command",get template(){return He.replace("${path}",C.worktree)},hints:De(He)},_[ke.REVIEW]={name:ke.REVIEW,description:"review changes [commit|branch|pr], defaults to uncommitted",source:"command",get template(){return Xe.replace("${path}",C.worktree)},subtask:!0,hints:De(Xe)};for(let[E,b]of Object.entries(v.command??{}))_[E]={name:E,agent:b.agent,model:b.model,description:b.description,source:"command",get template(){return b.template},subtask:b.subtask,hints:De(b.template)};for(let[E,b]of Object.entries(yield*k.prompts()))_[E]={name:E,source:"mcp",description:b.description,get template(){return B.promise(k.getPrompt(b.client,b.name,b.arguments?Object.fromEntries(b.arguments.map(($,A)=>[$.name,`$${A+1}`])):{}).pipe(e.map($=>$?.messages.map(A=>A.content.type==="text"?A.content.text:"").join(`
|
|
186
|
+
`)||"")))},hints:b.arguments?.map(($,A)=>`$${A+1}`)??[]};for(let E of yield*w.all()){if(_[E.name])continue;let b=E.location==="<built-in>"?void 0:jt.dirname(E.location);_[E.name]={name:E.name,description:E.description,source:"skill",get template(){return b?[E.content,"",`Base directory for this skill: ${b}`,"Relative paths in this skill (e.g., scripts/, references/) are relative to this base directory."].join(`
|
|
187
|
+
`):E.content},hints:[]}}return{commands:_}}),V=yield*T.make(C=>x(C)),q=e.fn("Command.get")(function*(C){return(yield*T.get(V)).commands[C]}),S=e.fn("Command.list")(function*(){let C=yield*T.get(V);return Object.values(C.commands)});return fe.of({get:q,list:S})})),Rt=Z.make({service:fe,layer:Ct,deps:[$e.node,ze.node,Be.node]});var Tt=X.Info,xt={Updated:X.Event.Updated};function ee(a){let k=a.icon_url||a.icon_url_override||a.icon_color?{url:a.icon_url??void 0,override:a.icon_url_override??void 0,color:a.icon_color??void 0}:void 0;return{id:a.id,worktree:a.worktree,vcs:a.vcs?n.decodeUnknownSync(X.Vcs)(a.vcs):void 0,name:a.name??void 0,icon:k,time:{created:a.time_created,updated:a.time_updated,initialized:a.time_initialized??void 0},sandboxes:a.sandboxes,commands:a.commands??void 0}}u(ee,"fromRow");var Ft=n.Struct({projectID:U.ID,name:n.optional(n.String),icon:n.optional(X.Icon),commands:n.optional(X.Commands)}),Ut=n.Struct({name:n.optional(n.String),icon:n.optional(X.Icon),commands:n.optional(X.Commands)}).annotate({identifier:"ProjectUpdateInput"}),Pe=class extends n.TaggedErrorClass()("Project.NotFoundError",{projectID:U.ID}){static{u(this,"NotFoundError")}},K=class extends z.Service()("@opencode/Project"){static{u(this,"Service")}},Wt=Q.effect(K,e.gen(function*(){let a=yield*L.Service,k=yield*rt.ChildProcessSpawner,w=yield*U.Service,x=yield*_e.Service,V=yield*Me.Service,q=yield*qe.Service,{db:S}=yield*de.Service,C=e.fnUntraced(function*(i,c){let f=yield*k.spawn(xe.make("git",i,{cwd:c?.cwd,extendEnv:!0,stdin:"ignore"})),[y,j]=yield*e.all([ve.mkString(ve.decodeText(f.stdout)),ve.mkString(ve.decodeText(f.stderr))],{concurrency:2});return{code:yield*f.exitCode,text:y,stderr:j}},e.scoped,e.catch(()=>e.succeed({code:1,text:"",stderr:""}))),v=u(i=>e.sync(()=>J.emit("event",{directory:"global",project:i.id,payload:{type:xt.Updated.type,properties:i}})),"emitUpdated"),B=n.decodeUnknownSync(n.optional(X.Vcs))(ft.OPENCODE_FAKE_VCS),_=yield*ae.Scope,E=e.fn("Project.migrateProjectId")(function*(i,c){i&&i!==U.ID.global&&i!==c&&(yield*S.transaction(f=>e.gen(function*(){let y=yield*f.select().from(m).where(D(m.id,i)).get(),j=yield*f.select().from(m).where(D(m.id,c)).get();y&&!j&&(yield*f.insert(m).values({...y,id:c,time_updated:Date.now()}).run()),yield*f.delete(We).where(D(We.project_id,i)).run(),yield*f.update(se).set({project_id:c,time_updated:dt`${se.time_updated}`}).where(D(se.project_id,i)).run(),yield*f.update(Ae).set({project_id:c}).where(D(Ae.project_id,i)).run(),y&&(yield*f.delete(m).where(D(m.id,i)).run())}),{behavior:"immediate"}).pipe(e.orDie))}),b=e.fn("Project.saveProjectDirectory")(function*(i){if(i.projectID===U.ID.global)return;let c=H.make(L.resolve(i.directory));yield*x.create({directory:c,projectID:i.projectID}).pipe(e.catchCause(f=>e.logWarning("project directory persistence failed",{projectID:i.projectID,cause:f})))}),$=e.fn("Project.fromDirectory")(function*(i){yield*e.logInfo("fromDirectory",{directory:i});let c=yield*w.resolve(H.make(i)),f=c.id===U.ID.make("global")&&!c.vcs?"/":c.directory,y=U.ID.make(c.id);yield*E(c.previous?U.ID.make(c.previous):void 0,y);let j=yield*S.select().from(m).where(D(m.id,y)).get().pipe(e.orDie),r=j?ee(j):{id:y,worktree:f,vcs:c.vcs?.type??B,sandboxes:[],time:{created:Date.now(),updated:Date.now()}};q.experimentalIconDiscovery&&(yield*A(r).pipe(e.ignore,e.forkIn(_)));let t={...r,worktree:y===U.ID.global?f:r.worktree,vcs:c.vcs?.type??B,time:{...r.time,updated:Date.now()}};return y!==U.ID.global&&c.directory!==t.worktree&&!t.sandboxes.includes(c.directory)&&t.sandboxes.push(c.directory),t.sandboxes=yield*e.forEach(t.sandboxes,o=>a.exists(o).pipe(e.orDie,e.map(d=>d?o:void 0)),{concurrency:"unbounded"}).pipe(e.map(o=>o.filter(d=>d!==void 0))),yield*S.insert(m).values({id:t.id,worktree:H.make(t.worktree),vcs:t.vcs??null,name:t.name,icon_url:t.icon?.url,icon_url_override:t.icon?.override,icon_color:t.icon?.color,time_created:t.time.created,time_updated:t.time.updated,time_initialized:t.time.initialized,sandboxes:t.sandboxes.map(o=>H.make(o)),commands:t.commands}).onConflictDoUpdate({target:m.id,set:{worktree:H.make(t.worktree),vcs:t.vcs??null,name:t.name,icon_url:t.icon?.url,icon_url_override:t.icon?.override,icon_color:t.icon?.color,time_updated:t.time.updated,time_initialized:t.time.initialized,sandboxes:t.sandboxes.map(o=>H.make(o)),commands:t.commands}}).run().pipe(e.orDie),y!==U.ID.global&&(yield*S.update(se).set({project_id:y}).where(lt(D(se.project_id,U.ID.global),D(se.directory,c.directory))).run().pipe(e.orDie)),yield*b({projectID:y,directory:c.directory}),yield*v(t),y!==U.ID.global&&c.vcs?.type==="git"&&(yield*w.commit({store:c.vcs.store,id:c.id})),{project:t,sandbox:c.vcs?c.directory:f}}),A=e.fn("Project.discover")(function*(i){if(i.vcs!=="git"||i.icon?.override||i.icon?.url)return;let f=(yield*a.glob("**/favicon.{ico,png,svg,jpg,jpeg,webp}",{cwd:i.worktree,absolute:!0,include:"file"}).pipe(e.orDie)).sort((o,d)=>o.length-d.length)[0];if(!f)return;let y=yield*a.readFile(f).pipe(e.orDie),j=Buffer.from(y).toString("base64"),t=`data:${L.mimeType(f)};base64,${j}`;yield*Y({projectID:i.id,icon:{url:t}}).pipe(e.catchTag("Project.NotFoundError",()=>e.void))}),ge=e.fn("Project.list")(function*(){return(yield*S.select().from(m).all().pipe(e.orDie)).map(ee)}),N=e.fn("Project.get")(function*(i){let c=yield*S.select().from(m).where(D(m.id,i)).get().pipe(e.orDie);return c?ee(c):void 0}),Y=e.fn("Project.update")(function*(i){let c=yield*S.update(m).set({name:i.name,icon_url:i.icon?.url,icon_url_override:i.icon?.override,icon_color:i.icon?.color,commands:i.commands,time_updated:Date.now()}).where(D(m.id,i.projectID)).returning().get().pipe(e.orDie);if(!c)return yield*new Pe({projectID:i.projectID});let f=ee(c);return yield*v(f),f}),s=e.fn("Project.initGit")(function*(i){if(i.project.vcs==="git")return i.project;if(!(yield*e.sync(()=>gt("git"))))throw new Error("Git is not installed");let c=yield*C(["init","--quiet"],{cwd:i.directory});if(c.code!==0)throw new Error(c.stderr.trim()||c.text.trim()||"Failed to initialize git repository");let{project:f}=yield*$(i.directory);return f}),l=e.fn("Project.setInitialized")(function*(i){yield*S.update(m).set({time_initialized:Date.now()}).where(D(m.id,i)).run().pipe(e.orDie)}),g=yield*T.make(e.fn("Project.initState")(function*(i){let c=yield*V.listen(f=>f.type!==pe.Event.Executed.type||f.location?.directory!==i.directory?e.void:f.data.name===pe.Default.INIT?l(i.project.id):e.void);yield*e.addFinalizer(()=>c)})),R=e.fn("Project.init")(function*(){yield*T.get(g)}),M=e.fn("Project.sandboxes")(function*(i){let c=yield*S.select().from(m).where(D(m.id,i)).get().pipe(e.orDie);if(!c)return[];let f=ee(c);return yield*e.forEach(f.sandboxes,y=>a.isDir(y).pipe(e.orDie,e.map(j=>j?y:void 0)),{concurrency:"unbounded"}).pipe(e.map(y=>y.filter(j=>j!==void 0)))}),oe=e.fn("Project.addSandbox")(function*(i,c){let f=yield*S.select().from(m).where(D(m.id,i)).get().pipe(e.orDie);if(!f)throw new Error(`Project not found: ${i}`);let y=H.make(c),j=[...f.sandboxes];j.includes(y)||j.push(y);let r=yield*S.update(m).set({sandboxes:j,time_updated:Date.now()}).where(D(m.id,i)).returning().get().pipe(e.orDie);if(!r)throw new Error(`Project not found: ${i}`);yield*v(ee(r))}),Ue=e.fn("Project.removeSandbox")(function*(i,c){let f=yield*S.select().from(m).where(D(m.id,i)).get().pipe(e.orDie);if(!f)throw new Error(`Project not found: ${i}`);let y=H.make(c),j=f.sandboxes.filter(t=>t!==y),r=yield*S.update(m).set({sandboxes:j,time_updated:Date.now()}).where(D(m.id,i)).returning().get().pipe(e.orDie);if(!r)throw new Error(`Project not found: ${i}`);yield*v(ee(r))});return K.of({init:R,fromDirectory:$,discover:A,list:ge,get:N,update:Y,initGit:s,setInitialized:l,sandboxes:M,addSandbox:oe,removeSandbox:Ue})})),_t=je(K),Ke=Z.make({service:K,layer:Wt,deps:[L.node,be.node,mt.node,U.node,_e.node,Me.node,qe.node,de.node]});var ce=class extends z.Service()("@opencode/InstanceStore"){static{u(this,"Service")}},At=je(ce),Nt=Q.effect(ce,e.gen(function*(){let a=yield*K,k=yield*le.Service,w=yield*ae.Scope,x=new Map,V=u(s=>e.gen(function*(){let l=s.project&&s.worktree?{directory:s.directory,worktree:s.worktree,project:s.project}:yield*a.fromDirectory(s.directory).pipe(e.map(g=>({directory:s.directory,worktree:g.sandbox,project:g.project})));return yield*k.run.pipe(e.provideService(Ge,l)),l}).pipe(e.withSpan("InstanceStore.boot")),"boot"),q=u((s,l)=>e.sync(()=>x.get(s)!==l?!1:(x.delete(s),!0)),"removeEntry"),S=u((s,l,g)=>e.gen(function*(){let R=yield*e.exit(V({...l,directory:s}));we.isFailure(R)&&(yield*q(s,g)),yield*O.done(g.deferred,R).pipe(e.asVoid)}),"completeLoad"),C=u(s=>e.sync(()=>J.emit("event",{directory:s.directory,project:s.project,workspace:ht.workspaceID,payload:{type:"server.instance.disposed",properties:{directory:s.directory}}})),"emitDisposed"),v=e.fn("InstanceStore.disposeContext")(function*(s){yield*e.logInfo("disposing instance",{directory:s.directory}),yield*e.promise(()=>Le(s.directory)),yield*C({directory:s.directory,project:s.project.id})}),B=e.fnUntraced(function*(s,l,g){return x.get(s)!==l||(yield*v(g),x.get(s)!==l)?!1:(x.delete(s),!0)}),_=u(s=>{let l=L.resolve(s.directory);return e.uninterruptibleMask(g=>e.gen(function*(){let R=x.get(l);if(R)return yield*g(O.await(R.deferred));let M={deferred:O.makeUnsafe()};return x.set(l,M),yield*e.gen(function*(){yield*e.logInfo("creating instance",{directory:l}),yield*S(l,s,M)}).pipe(e.forkIn(w,{startImmediately:!0})),yield*g(O.await(M.deferred))})).pipe(e.withSpan("InstanceStore.load"))},"load"),E=u(s=>{let l=L.resolve(s.directory);return e.uninterruptibleMask(g=>e.gen(function*(){let R=x.get(l),M={deferred:O.makeUnsafe()};return x.set(l,M),yield*e.gen(function*(){yield*e.logInfo("reloading instance",{directory:l}),R&&(yield*O.await(R.deferred).pipe(e.ignore),yield*e.promise(()=>Le(l)),yield*C({directory:l,project:s.project?.id})),yield*S(l,s,M)}).pipe(e.forkIn(w,{startImmediately:!0})),yield*g(O.await(M.deferred))})).pipe(e.withSpan("InstanceStore.reload"))},"reload"),b=e.fn("InstanceStore.dispose")(function*(s){let l=x.get(s.directory);if(!l)return yield*v(s);let g=yield*O.await(l.deferred).pipe(e.exit);if(we.isFailure(g))return yield*q(s.directory,l).pipe(e.asVoid);g.value===s&&(yield*B(s.directory,l,s).pipe(e.asVoid))}),$=e.fn("InstanceStore.disposeDirectory")(function*(s){let l=L.resolve(s),g=x.get(l);if(!g)return;let R=yield*O.await(g.deferred).pipe(e.exit);if(we.isFailure(R))return yield*q(l,g).pipe(e.asVoid);yield*B(l,g,R.value).pipe(e.asVoid)}),A=e.fnUntraced(function*(){yield*e.logInfo("disposing all instances"),yield*e.forEach([...x.entries()],s=>e.gen(function*(){let l=yield*O.await(s[1].deferred).pipe(e.exit);if(we.isFailure(l)){yield*e.logWarning("instance dispose failed",{key:s[0],cause:l.cause}),yield*q(s[0],s[1]);return}yield*B(s[0],s[1],l.value)}),{discard:!0})}),ge=yield*e.cachedWithTTL(A(),et.zero),N=e.fn("InstanceStore.disposeAll")(function*(){return yield*ge}),Y=u((s,l)=>_(s).pipe(e.flatMap(g=>l.pipe(e.provideService(Ge,g)))),"provide");return yield*e.addFinalizer(()=>N().pipe(e.ignore)),ce.of({load:_,reload:E,dispose:b,disposeDirectory:$,disposeAll:N,provide:Y})})),bt=Z.unbound(le.Service,nt.tags.values.global),Gt=ot({service:ce,layer:Nt,deps:[Ke,bt]});var Ee={};ie(Ee,{Definitions:()=>Lt,Failed:()=>kt,Ready:()=>It,WorktreeEvent:()=>Ee});var It=Se.define({type:"worktree.ready",schema:{name:n.String,branch:it(n.String)}}),kt=Se.define({type:"worktree.failed",schema:{message:n.String}}),Lt=Se.inventory(It,kt);var Ce=Ee,Vt=n.Struct({name:n.String,branch:n.optional(n.String),directory:n.String}).annotate({identifier:"Worktree"}),$t=n.Struct({name:n.optional(n.String),startCommand:n.optional(n.String.annotate({description:"Additional startup script to run after the project's start command"}))}).annotate({identifier:"WorktreeCreateInput"}),Mt=n.Struct({directory:n.String}).annotate({identifier:"WorktreeRemoveInput"}),Ot=n.Struct({directory:n.String}).annotate({identifier:"WorktreeResetInput"}),me=class extends n.TaggedErrorClass()("WorktreeNotGitError",{message:n.String}){static{u(this,"NotGitError")}},Re=class extends n.TaggedErrorClass()("WorktreeNameGenerationFailedError",{message:n.String}){static{u(this,"NameGenerationFailedError")}},Te=class extends n.TaggedErrorClass()("WorktreeCreateFailedError",{message:n.String}){static{u(this,"CreateFailedError")}},Qe=class extends n.TaggedErrorClass()("WorktreeStartCommandFailedError",{message:n.String}){static{u(this,"StartCommandFailedError")}},re=class extends n.TaggedErrorClass()("WorktreeRemoveFailedError",{message:n.String}){static{u(this,"RemoveFailedError")}},W=class extends n.TaggedErrorClass()("WorktreeResetFailedError",{message:n.String}){static{u(this,"ResetFailedError")}},Fe=class extends n.TaggedErrorClass()("WorktreeListFailedError",{message:n.String}){static{u(this,"ListFailedError")}};function qt(a){return a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}u(qt,"slugify");function Bt(...a){return a.filter(Boolean).flatMap(k=>k.split(`
|
|
188
|
+
`).map(w=>w.trim()).flatMap(w=>{let x=w.match(/^warning:\s+failed to remove\s+(.+):\s+/i);if(!x)return[];let V=x[1]?.trim().replace(/^['"]|['"]$/g,"");return V?[V]:[]}))}u(Bt,"failedRemoves");var ye=class extends z.Service()("@opencode/Worktree"){static{u(this,"Service")}},zt=Q.effect(ye,e.gen(function*(){let a=yield*ae.Scope,k=yield*L.Service,w=yield*tt.Path,x=yield*be.Service,{db:V}=yield*de.Service,q=yield*Oe.Service,S=yield*te.Service,C=yield*ue.Service,v=e.fnUntraced(function*(r,t){let o=yield*x.run(xe.make("git",r,{cwd:t?.cwd,extendEnv:!0,stdin:"ignore"}));return{code:o.exitCode,text:o.stdout.toString("utf8"),stderr:o.stderr.toString("utf8")}},e.catch(r=>e.succeed({code:1,text:"",stderr:r instanceof Error?r.message:String(r)}))),B=26,_=e.fn("Worktree.candidate")(function*(r){let t=yield*T.context;for(let o of Array.from({length:B},(d,p)=>p)){let d=r.name?o===0?r.name:`${r.name}-${Ne.create()}`:Ne.create(),p=r.detached?void 0:`opencode/${d}`,h=w.join(r.root,d);if(!(yield*k.exists(h).pipe(e.orDie))){if(p){let I=`refs/heads/${p}`;if((yield*v(["show-ref","--verify","--quiet",I],{cwd:t.worktree})).code===0)continue}return{name:d,directory:h,...p?{branch:p}:{}}}}return yield*new Re({message:"Failed to generate a unique worktree name"})}),E=e.fn("Worktree.makeWorktreeInfo")(function*(r){let t=yield*T.context;if(t.project.vcs!=="git")return yield*new me({message:"Worktrees are only supported for git projects"});let o=w.join(pt.Path.data,"worktree",t.project.id);return yield*k.makeDirectory(o,{recursive:!0}).pipe(e.orDie),yield*_({root:o,name:r?.name?qt(r.name):"",detached:r?.detached})}),b=e.fnUntraced(function*(r){let t=yield*T.context,o=yield*v(r.branch?["worktree","add","--no-checkout","-b",r.branch,r.directory]:["worktree","add","--no-checkout","--detach",r.directory,"HEAD"],{cwd:t.worktree});if(o.code!==0)return yield*new Te({message:o.stderr||o.text||"Failed to create git worktree"});yield*S.addSandbox(t.project.id,r.directory).pipe(e.catch(()=>e.void))}),$=e.fnUntraced(function*(r,t){let o=yield*T.context,d=yield*T.workspaceID,p=o.project.id,h=t?.trim(),I=yield*v(["reset","--hard"],{cwd:r.directory});if(I.code!==0){let P=I.stderr||I.text||"Failed to populate worktree";yield*e.logError("worktree checkout failed",{directory:r.directory,message:P}),J.emit("event",{directory:r.directory,project:o.project.id,workspace:d,payload:{type:Ce.Failed.type,properties:{message:P}}});return}(yield*C.load({directory:r.directory}).pipe(e.as(!0),e.catch(P=>e.gen(function*(){let ne=Ve(P);return yield*e.logError("worktree bootstrap failed",{directory:r.directory,message:ne}),J.emit("event",{directory:r.directory,project:o.project.id,workspace:d,payload:{type:Ce.Failed.type,properties:{message:ne}}}),!1}))))&&(J.emit("event",{directory:r.directory,project:o.project.id,workspace:d,payload:{type:Ce.Ready.type,properties:{name:r.name,...r.branch?{branch:r.branch}:{}}}}),yield*c(r.directory,{projectID:p,extra:h}))}),A=e.fn("Worktree.createFromInfo")(function*(r,t){yield*b(r),yield*$(r,t).pipe(e.catchCause(o=>e.logError("worktree bootstrap failed",{cause:o})),e.forkIn(a))}),ge=e.fn("Worktree.create")(function*(r){let t=yield*E({name:r?.name});return yield*A(t,r?.startCommand),t}),N=e.fnUntraced(function*(r){let t=w.resolve(r),o=yield*k.realPath(t).pipe(e.catch(()=>e.succeed(t))),d=w.normalize(o);return process.platform==="win32"?d.toLowerCase():d});function Y(r){return r.split(`
|
|
189
|
+
`).map(t=>t.trim()).reduce((t,o)=>{if(!o)return t;if(o.startsWith("worktree "))return t.push({path:o.slice(9).trim()}),t;let d=t[t.length-1];return d&&o.startsWith("branch ")&&(d.branch=o.slice(7).trim()),t},[])}u(Y,"parseWorktreeList");let s=e.fnUntraced(function*(r,t){for(let o of r){if(!o.path)continue;if((yield*N(o.path))===t)return o}}),l=e.fn("Worktree.list")(function*(){let r=yield*T.context;if(r.project.vcs!=="git")return[];let t=yield*v(["worktree","list","--porcelain"],{cwd:r.worktree});if(t.code!==0)return yield*new Fe({message:t.stderr||t.text||"Failed to read git worktrees"});let o=yield*N(r.project.worktree),d=w.basename(o).toLowerCase();return yield*e.forEach(Y(t.text),p=>e.gen(function*(){if(!p.path)return;let h=yield*N(p.path);if(h===o)return;let I=w.basename(h).toLowerCase();return{name:I===d?w.basename(w.dirname(h)):I,directory:h,...p.branch?{branch:p.branch.replace(/^refs\/heads\//,"")}:{}}})).pipe(e.map(p=>p.filter(h=>h!==void 0)))});function g(r){return k.exists(r).pipe(e.orDie,e.flatMap(t=>t?v(["fsmonitor--daemon","stop"],{cwd:r}):e.void))}u(g,"stopFsmonitor");function R(r){return e.tryPromise({try:u(async()=>{let t=await import("fs/promises"),o=process.platform==="win32"?50:5;for(let d of Array.from({length:o},(p,h)=>h))try{await t.rm(r,{recursive:!0,force:!0});return}catch(p){if(d===o-1)throw p;await new Promise(h=>setTimeout(h,100))}},"try"),catch:u(t=>new re({message:Ve(t)||"Failed to remove git worktree directory"}),"catch")})}u(R,"cleanDirectory");let M=e.fn("Worktree.remove")(function*(r){let t=yield*T.context;if(t.project.vcs!=="git")return yield*new me({message:"Worktrees are only supported for git projects"});let o=yield*N(r.directory);o!==(yield*N(t.worktree))&&(yield*C.disposeDirectory(r.directory));let d=yield*v(["worktree","list","--porcelain"],{cwd:t.worktree});if(d.code!==0)return yield*new re({message:d.stderr||d.text||"Failed to read git worktrees"});let p=Y(d.text),h=yield*s(p,o);if(!h?.path)return(yield*k.exists(o).pipe(e.orDie))&&(yield*g(o),yield*R(o)),!0;yield*C.disposeDirectory(h.path),yield*g(h.path);let I=yield*v(["worktree","remove","--force",h.path],{cwd:t.worktree});if(I.code!==0){let P=yield*v(["worktree","list","--porcelain"],{cwd:t.worktree});if(P.code!==0)return yield*new re({message:I.stderr||I.text||P.stderr||P.text||"Failed to remove git worktree"});if((yield*s(Y(P.text),o))?.path)return yield*new re({message:I.stderr||I.text||"Failed to remove git worktree"})}yield*R(h.path);let G=h.branch?.replace(/^refs\/heads\//,"");if(G){let P=yield*v(["branch","-D",G],{cwd:t.worktree});if(P.code!==0)return yield*new re({message:P.stderr||P.text||"Failed to delete worktree branch"})}return!0}),oe=e.fnUntraced(function*(r,t,o){let d=yield*v(r,t);return d.code!==0?yield*o(d):d}),Ue=e.fnUntraced(function*(r,t){let[o,d]=process.platform==="win32"?["cmd",["/c",t]]:["bash",["-lc",t]],p=yield*x.run(xe.make(o,d,{cwd:r,extendEnv:!0,stdin:"ignore"}));return{code:p.exitCode,stderr:p.stderr.toString("utf8")}},e.catch(()=>e.succeed({code:1,stderr:""}))),i=e.fnUntraced(function*(r,t,o){let d=t.trim();if(!d)return!0;let p=yield*Ue(r,d);return p.code===0?!0:(yield*e.logError("worktree start command failed",{kind:o,directory:r,message:p.stderr}),!1)}),c=e.fnUntraced(function*(r,t){let o=yield*V.select().from(m).where(D(m.id,t.projectID)).get().pipe(e.orDie),p=(o?te.fromRow(o):void 0)?.commands?.start?.trim()??"";return(yield*i(r,p,"project"))?(yield*i(r,t.extra??"","worktree"),!0):!1}),f=e.fnUntraced(function*(r,t){let o=yield*N(r);yield*e.forEach(t,d=>e.gen(function*(){let p=yield*N(w.resolve(r,d));p!==o&&p.startsWith(`${o}${w.sep}`)&&(yield*k.remove(p,{recursive:!0}).pipe(e.ignore))}),{concurrency:"unbounded"})}),y=e.fnUntraced(function*(r){let t=yield*v(["clean","-ffdx"],{cwd:r});if(t.code===0)return t;let o=Bt(t.stderr,t.text);return o.length?(yield*f(r,o),yield*v(["clean","-ffdx"],{cwd:r})):t}),j=e.fn("Worktree.reset")(function*(r){let t=yield*T.context;if(t.project.vcs!=="git")return yield*new me({message:"Worktrees are only supported for git projects"});let o=yield*N(r.directory),d=yield*N(t.worktree);if(o===d)return yield*new W({message:"Cannot reset the primary workspace"});let p=yield*v(["worktree","list","--porcelain"],{cwd:t.worktree});if(p.code!==0)return yield*new W({message:p.stderr||p.text||"Failed to read git worktrees"});let h=yield*s(Y(p.text),o);if(!h?.path)return yield*new W({message:"Worktree not found"});let I=h.path,G=yield*q.defaultBranch(t.worktree);if(!G)return yield*new W({message:"Default branch not found"});let P=G.ref.indexOf("/");if(G.ref!==G.name&&P>0){let F=G.ref.slice(0,P),Et=G.ref.slice(P+1);yield*oe(["fetch",F,Et],{cwd:t.worktree},Je=>new W({message:Je.stderr||Je.text||`Failed to fetch ${G.ref}`}))}yield*oe(["reset","--hard",G.ref],{cwd:I},F=>new W({message:F.stderr||F.text||"Failed to reset worktree to target"}));let ne=yield*y(I);if(ne.code!==0)return yield*new W({message:ne.stderr||ne.text||"Failed to clean worktree"});yield*oe(["submodule","update","--init","--recursive","--force"],{cwd:I},F=>new W({message:F.stderr||F.text||"Failed to update submodules"})),yield*oe(["submodule","foreach","--recursive","git","reset","--hard"],{cwd:I},F=>new W({message:F.stderr||F.text||"Failed to reset submodules"})),yield*oe(["submodule","foreach","--recursive","git","clean","-fdx"],{cwd:I},F=>new W({message:F.stderr||F.text||"Failed to clean submodules"}));let he=yield*v(["-c","core.fsmonitor=false","status","--porcelain=v1"],{cwd:I});return he.code!==0?yield*new W({message:he.stderr||he.text||"Failed to read git status"}):he.text.trim()?yield*new W({message:`Worktree reset left local changes:
|
|
190
|
+
${he.text.trim()}`}):(yield*c(I,{projectID:t.project.id}).pipe(e.catchCause(F=>e.logError("worktree start task failed",{cause:F})),e.forkIn(a)),!0)});return ye.of({makeWorktreeInfo:E,createFromInfo:A,create:ge,list:l,remove:M,reset:j})})),Yt=Z.make({service:ye,layer:zt,deps:[L.node,ut,be.node,Oe.node,te.node,ue.node,de.node]});export{Ie as a,pe as b,Ye as c,K as d,Ke as e,te as f,ue as g,Ee as h,Ce as i,Vt as j,$t as k,Mt as l,Ot as m,me as n,Re as o,Te as p,Qe as q,re as r,W as s,Fe as t,ye as u,Yt as v,Ze as w};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Built by esbuild from opencode-server source
|
|
2
|
+
if (typeof globalThis.Bun === 'undefined') {
|
|
3
|
+
globalThis.Bun = {
|
|
4
|
+
version: '0.0.0-node-compat',
|
|
5
|
+
stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
|
|
6
|
+
which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
|
|
10
|
+
if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
|
|
11
|
+
import { createRequire as __alchemyCreateRequire } from 'node:module';
|
|
12
|
+
const require = __alchemyCreateRequire(import.meta.url);
|
|
13
|
+
import { fileURLToPath as __alchemyFileURLToPath } from 'node:url';
|
|
14
|
+
import { dirname as __alchemyDirname } from 'node:path';
|
|
15
|
+
const __alchemy_filename = __alchemyFileURLToPath(import.meta.url);
|
|
16
|
+
const __alchemy_dirname = __alchemyDirname(__alchemy_filename);
|
|
17
|
+
|
|
18
|
+
import{a as O,b as m,c as L,e as S,h as P,j as _,m as w,r as j}from"./chunk-WKZYINC7.js";import{a as f}from"./chunk-Q3WIUQXB.js";import{c as R,e as x}from"./chunk-WPMP2ZFE.js";import{a as o}from"./chunk-2MRHL4B2.js";function Et(...e){return e.reduce((t,r)=>({...t,...r??{}}),{})}o(Et,"combineHeaders");async function kt(e,t){if(e==null)return Promise.resolve();let r=t?.abortSignal;return new Promise((n,a)=>{if(r?.aborted){a(U());return}let i=setTimeout(()=>{s(),n()},e),s=o(()=>{clearTimeout(i),r?.removeEventListener("abort",u)},"cleanup"),u=o(()=>{s(),a(U())},"onAbort");r?.addEventListener("abort",u)})}o(kt,"delay");function U(){return new DOMException("Delay was aborted","AbortError")}o(U,"createAbortError");function E(e){return Object.fromEntries([...e.headers])}o(E,"extractResponseHeaders");var{btoa:ie,atob:St}=globalThis;function se(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return ie(t)}o(se,"convertUint8ArrayToBase64");function Tt(e){return e instanceof Uint8Array?se(e):e}o(Tt,"convertToBase64");async function ue(e){var t;try{await((t=e.body)==null?void 0:t.cancel())}catch{}}o(ue,"cancelResponseBody");var q="AI_DownloadError",V=`vercel.ai.error.${q}`,ce=Symbol.for(V),M,z,B=class extends(z=O,M=ce,z){static{o(this,"DownloadError")}constructor({url:e,statusCode:t,statusText:r,cause:n,message:a=n==null?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${n}`}){super({name:q,message:a,cause:n}),this[M]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return O.hasMarker(e,V)}};var le=globalThis.fetch,$t=fe(le);function fe(e){let t=Function.prototype.toString.call(e);return t.includes("internal/deps/undici")||t.includes("lazy loading of undici")}o(fe,"isNodeDefaultFetch");var de=2*1024*1024*1024;async function pe({response:e,url:t,maxBytes:r=de}){let n=e.headers.get("content-length");if(n!=null){let p=parseInt(n,10);if(!isNaN(p)&&p>r)throw await ue(e),new B({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes (Content-Length: ${p}).`})}let a=e.body;if(a==null)return new Uint8Array(0);let i=a.getReader(),s=[],u=0;try{for(;;){let{done:p,value:k}=await i.read();if(p)break;if(u+=k.length,u>r)throw new B({url:t,message:`Download of ${t} exceeded maximum size of ${r} bytes.`});s.push(k)}}finally{try{await i.cancel()}catch{}finally{i.releaseLock()}}let l=new Uint8Array(u),c=0;for(let p of s)l.set(p,c),c+=p.length;return l}o(pe,"readResponseWithSizeLimit");var me=o(({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:n="-"}={})=>{let a=o(()=>{let i=r.length,s=new Array(t);for(let u=0;u<t;u++)s[u]=r[Math.random()*i|0];return s.join("")},"generator");if(e==null)return a;if(r.includes(n))throw new S({argument:"separator",message:`The separator "${n}" must not be part of the alphabet "${r}".`});return()=>`${e}${n}${a()}`},"createIdGenerator"),Ft=me();function A(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}o(A,"isAbortError");var ye=["fetch failed","failed to fetch"],he=["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE"];function ve(e){if(!(e instanceof Error))return!1;let t=e.code;return!!(typeof t=="string"&&he.includes(t))}o(ve,"isBunNetworkError");function G({error:e,url:t,requestBodyValues:r}){if(A(e))return e;if(e instanceof TypeError&&ye.includes(e.message.toLowerCase())){let n=e.cause;if(n!=null)return new m({message:`Cannot connect to API: ${n.message}`,cause:n,url:t,requestBodyValues:r,isRetryable:!0})}return ve(e)?new m({message:`Cannot connect to API: ${e.message}`,cause:e,url:t,requestBodyValues:r,isRetryable:!0}):e}o(G,"handleFetchError");function K(e=globalThis){var t,r,n;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(n=(r=e.process)==null?void 0:r.versions)!=null&&n.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}o(K,"getRuntimeEnvironmentUserAgent");function ge(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((r,n)=>{t[n.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(let[r,n]of e)n!=null&&(t[r.toLowerCase()]=n)}return t}o(ge,"normalizeHeaders");function X(e,...t){let r=new Headers(ge(e)),n=r.get("user-agent")||"";return r.set("user-agent",[n,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}o(X,"withUserAgentSuffix");var Y="4.0.45",we=o(()=>globalThis.fetch,"getOriginalFetch"),Dt=o(async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:n,abortSignal:a,fetch:i=we()})=>{try{let s=await i(e,{method:"GET",headers:X(t,`ai-sdk/provider-utils/${Y}`,K()),signal:a}),u=E(s);if(!s.ok){let l;try{l=await n({response:s,url:e,requestBodyValues:{}})}catch(c){throw A(c)||m.isInstance(c)?c:new m({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:u,requestBodyValues:{}})}throw l.value}try{return await r({response:s,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(A(l)||m.isInstance(l))?l:new m({message:"Failed to process successful response",cause:l,statusCode:s.status,url:e,responseHeaders:u,requestBodyValues:{}})}}catch(s){throw G({error:s,url:e,requestBodyValues:{}})}},"getFromApi");function Ct({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}o(Ct,"loadOptionalSetting");function Rt({settingValue:e,environmentVariableName:t,settingName:r,description:n}){if(typeof e=="string")return e;if(e!=null)throw new _({message:`${n} setting must be a string.`});if(typeof process>"u")throw new _({message:`${n} setting is missing. Pass it using the '${r}' parameter. Environment variables are not supported in this environment.`});if(e=process.env[t],e==null)throw new _({message:`${n} setting is missing. Pass it using the '${r}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new _({message:`${n} setting must be a string. The value of the ${t} environment variable is not a string.`});return e}o(Rt,"loadSetting");var be=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Pe=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function J(e){let t=JSON.parse(e);return t===null||typeof t!="object"||be.test(e)===!1&&Pe.test(e)===!1?t:_e(t)}o(J,"_parse");function _e(e){let t=[e];for(;t.length;){let r=t;t=[];for(let n of r){if(Object.prototype.hasOwnProperty.call(n,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(n,"constructor")&&n.constructor!==null&&typeof n.constructor=="object"&&Object.prototype.hasOwnProperty.call(n.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(let a in n){let i=n[a];i&&typeof i=="object"&&t.push(i)}}}return e}o(_e,"filter");function Q(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return J(e)}try{return J(e)}finally{Error.stackTraceLimit=t}}o(Q,"secureJsonParse");function Z(e){if(e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")){e.additionalProperties=!1;let{properties:r}=e;if(r!=null)for(let n of Object.keys(r))r[n]=b(r[n])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(b):b(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(b)),e.allOf!=null&&(e.allOf=e.allOf.map(b)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(b));let{definitions:t}=e;if(t!=null)for(let r of Object.keys(t))t[r]=b(t[r]);return e}o(Z,"addAdditionalPropertiesToJsonSchema");function b(e){return typeof e=="boolean"?e:Z(e)}o(b,"visit");var Ae=Symbol("Let zodToJsonSchema decide on which parser to use"),H={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Ee=o(e=>typeof e=="string"?{...H,name:e}:{...H,...e},"getDefaultOptions");function h(){return{}}o(h,"parseAnyDef");function ke(e,t){var r,n,a;let i={type:"array"};return(r=e.type)!=null&&r._def&&((a=(n=e.type)==null?void 0:n._def)==null?void 0:a.typeName)!==f.ZodAny&&(i.items=d(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}o(ke,"parseArrayDef");function Se(e){let t={type:"integer",format:"int64"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}o(Se,"parseBigintDef");function Te(){return{type:"boolean"}}o(Te,"parseBooleanDef");function ee(e,t){return d(e.type._def,t)}o(ee,"parseBrandedDef");var Oe=o((e,t)=>d(e.innerType._def,t),"parseCatchDef");function te(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((a,i)=>te(e,t,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return $e(e)}}o(te,"parseDateDef");var $e=o(e=>{let t={type:"integer",format:"unix-time"};for(let r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t},"integerDateParser");function Ie(e,t){return{...d(e.innerType._def,t),default:e.defaultValue()}}o(Ie,"parseDefaultDef");function Fe(e,t){return t.effectStrategy==="input"?d(e.schema._def,t):h()}o(Fe,"parseEffectsDef");function Ne(e){return{type:"string",enum:Array.from(e.values)}}o(Ne,"parseEnumDef");var Ze=o(e=>"type"in e&&e.type==="string"?!1:"allOf"in e,"isJsonSchema7AllOfType");function De(e,t){let r=[d(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),d(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a),n=[];return r.forEach(a=>{if(Ze(a))n.push(...a.allOf);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:s,...u}=a;i=u}n.push(i)}}),n.length?{allOf:n}:void 0}o(De,"parseIntersectionDef");function Ce(e){let t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}o(Ce,"parseLiteralDef");var $=void 0,v={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:o(()=>($===void 0&&($=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),$),"emoji"),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function re(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value;break;case"email":switch(t.emailStrategy){case"format:email":g(r,"email",n.message,t);break;case"format:idn-email":g(r,"idn-email",n.message,t);break;case"pattern:zod":y(r,v.email,n.message,t);break}break;case"url":g(r,"uri",n.message,t);break;case"uuid":g(r,"uuid",n.message,t);break;case"regex":y(r,n.regex,n.message,t);break;case"cuid":y(r,v.cuid,n.message,t);break;case"cuid2":y(r,v.cuid2,n.message,t);break;case"startsWith":y(r,RegExp(`^${I(n.value,t)}`),n.message,t);break;case"endsWith":y(r,RegExp(`${I(n.value,t)}$`),n.message,t);break;case"datetime":g(r,"date-time",n.message,t);break;case"date":g(r,"date",n.message,t);break;case"time":g(r,"time",n.message,t);break;case"duration":g(r,"duration",n.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value;break;case"includes":{y(r,RegExp(I(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&g(r,"ipv4",n.message,t),n.version!=="v4"&&g(r,"ipv6",n.message,t);break}case"base64url":y(r,v.base64url,n.message,t);break;case"jwt":y(r,v.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&y(r,v.ipv4Cidr,n.message,t),n.version!=="v4"&&y(r,v.ipv6Cidr,n.message,t);break}case"emoji":y(r,v.emoji(),n.message,t);break;case"ulid":{y(r,v.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{g(r,"binary",n.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{y(r,v.base64,n.message,t);break}}break}case"nanoid":y(r,v.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}o(re,"parseStringDef");function I(e,t){return t.patternStrategy==="escape"?Re(e):e}o(I,"escapeLiteralCheckValue");var Le=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Re(e){let t="";for(let r=0;r<e.length;r++)Le.has(e[r])||(t+="\\"),t+=e[r];return t}o(Re,"escapeNonAlphaNumeric");function g(e,t,r,n){var a;e.format||(a=e.anyOf)!=null&&a.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):e.format=t}o(g,"addFormat");function y(e,t,r,n){var a;e.pattern||(a=e.allOf)!=null&&a.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:W(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=W(t,n)}o(y,"addPattern");function W(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=n.i?e.source.toLowerCase():e.source,i="",s=!1,u=!1,l=!1;for(let c=0;c<a.length;c++){if(s){i+=a[c],s=!1;continue}if(n.i){if(u){if(a[c].match(/[a-z]/)){l?(i+=a[c],i+=`${a[c-2]}-${a[c]}`.toUpperCase(),l=!1):a[c+1]==="-"&&((r=a[c+2])!=null&&r.match(/[a-z]/))?(i+=a[c],l=!0):i+=`${a[c]}${a[c].toUpperCase()}`;continue}}else if(a[c].match(/[a-z]/)){i+=`[${a[c]}${a[c].toUpperCase()}]`;continue}}if(n.m){if(a[c]==="^"){i+=`(^|(?<=[\r
|
|
19
|
+
]))`;continue}else if(a[c]==="$"){i+=`($|(?=[\r
|
|
20
|
+
]))`;continue}}if(n.s&&a[c]==="."){i+=u?`${a[c]}\r
|
|
21
|
+
`:`[${a[c]}\r
|
|
22
|
+
]`;continue}i+=a[c],a[c]==="\\"?s=!0:u&&a[c]==="]"?u=!1:!u&&a[c]==="["&&(u=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}o(W,"stringifyRegExpWithFlags");function ne(e,t){var r,n,a,i,s,u;let l={type:"object",additionalProperties:(r=d(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((n=e.keyType)==null?void 0:n._def.typeName)===f.ZodString&&((a=e.keyType._def.checks)!=null&&a.length)){let{type:c,...p}=re(e.keyType._def,t);return{...l,propertyNames:p}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===f.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((s=e.keyType)==null?void 0:s._def.typeName)===f.ZodBranded&&e.keyType._def.type._def.typeName===f.ZodString&&((u=e.keyType._def.type._def.checks)!=null&&u.length)){let{type:c,...p}=ee(e.keyType._def,t);return{...l,propertyNames:p}}}return l}o(ne,"parseRecordDef");function xe(e,t){if(t.mapStrategy==="record")return ne(e,t);let r=d(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||h(),n=d(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||h();return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}o(xe,"parseMapDef");function je(e){let t=e.values,n=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),a=Array.from(new Set(n.map(i=>typeof i)));return{type:a.length===1?a[0]==="string"?"string":"number":["string","number"],enum:n}}o(je,"parseNativeEnumDef");function Ue(){return{not:h()}}o(Ue,"parseNeverDef");function Me(){return{type:"null"}}o(Me,"parseNullDef");var F={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ze(e,t){let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in F&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((a,i)=>{let s=F[i._def.typeName];return s&&!a.includes(s)?[...a,s]:a},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((a,i)=>{let s=typeof i._def.value;switch(s){case"string":case"number":case"boolean":return[...a,s];case"bigint":return[...a,"integer"];case"object":if(i._def.value===null)return[...a,"null"];default:return a}},[]);if(n.length===r.length){let a=n.filter((i,s,u)=>u.indexOf(i)===s);return{type:a.length>1?a:a[0],enum:r.reduce((i,s)=>i.includes(s._def.value)?i:[...i,s._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,a)=>[...n,...a._def.values.filter(i=>!n.includes(i))],[])};return Be(e,t)}o(ze,"parseUnionDef");var Be=o((e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,a)=>d(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0},"asAnyOf");function Je(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[F[e.innerType._def.typeName],"null"]};let r=d(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}o(Je,"parseNullableDef");function He(e){let t={type:"number"};if(!e.checks)return t;for(let r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}o(He,"parseNumberDef");function We(e,t){let r={type:"object",properties:{}},n=[],a=e.shape();for(let s in a){let u=a[s];if(u===void 0||u._def===void 0)continue;let l=Ve(u),c=d(u._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});c!==void 0&&(r.properties[s]=c,l||n.push(s))}n.length&&(r.required=n);let i=qe(e,t);return i!==void 0&&(r.additionalProperties=i),r}o(We,"parseObjectDef");function qe(e,t){if(e.catchall._def.typeName!=="ZodNever")return d(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}o(qe,"decideAdditionalProperties");function Ve(e){try{return e.isOptional()}catch{return!0}}o(Ve,"safeIsOptional");var Ge=o((e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return d(e.innerType._def,t);let n=d(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return n?{anyOf:[{not:h()},n]}:h()},"parseOptionalDef"),Ke=o((e,t)=>{if(t.pipeStrategy==="input")return d(e.in._def,t);if(t.pipeStrategy==="output")return d(e.out._def,t);let r=d(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=d(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(a=>a!==void 0)}},"parsePipelineDef");function Xe(e,t){return d(e.type._def,t)}o(Xe,"parsePromiseDef");function Ye(e,t){let n={type:"array",uniqueItems:!0,items:d(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}o(Ye,"parseSetDef");function Qe(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>d(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:d(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>d(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}o(Qe,"parseTupleDef");function et(){return{not:h()}}o(et,"parseUndefinedDef");function tt(){return h()}o(tt,"parseUnknownDef");var rt=o((e,t)=>d(e.innerType._def,t),"parseReadonlyDef"),nt=o((e,t,r)=>{switch(t){case f.ZodString:return re(e,r);case f.ZodNumber:return He(e);case f.ZodObject:return We(e,r);case f.ZodBigInt:return Se(e);case f.ZodBoolean:return Te();case f.ZodDate:return te(e,r);case f.ZodUndefined:return et();case f.ZodNull:return Me();case f.ZodArray:return ke(e,r);case f.ZodUnion:case f.ZodDiscriminatedUnion:return ze(e,r);case f.ZodIntersection:return De(e,r);case f.ZodTuple:return Qe(e,r);case f.ZodRecord:return ne(e,r);case f.ZodLiteral:return Ce(e);case f.ZodEnum:return Ne(e);case f.ZodNativeEnum:return je(e);case f.ZodNullable:return Je(e,r);case f.ZodOptional:return Ge(e,r);case f.ZodMap:return xe(e,r);case f.ZodSet:return Ye(e,r);case f.ZodLazy:return()=>e.getter()._def;case f.ZodPromise:return Xe(e,r);case f.ZodNaN:case f.ZodNever:return Ue();case f.ZodEffects:return Fe(e,r);case f.ZodAny:return h();case f.ZodUnknown:return tt();case f.ZodDefault:return Ie(e,r);case f.ZodBranded:return ee(e,r);case f.ZodReadonly:return rt(e,r);case f.ZodCatch:return Oe(e,r);case f.ZodPipeline:return Ke(e,r);case f.ZodFunction:case f.ZodVoid:case f.ZodSymbol:return;default:return(n=>{})(t)}},"selectParser"),at=o((e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},"getRelativePath");function d(e,t,r=!1){var n;let a=t.seen.get(e);if(t.override){let l=(n=t.override)==null?void 0:n.call(t,e,t,a,r);if(l!==Ae)return l}if(a&&!r){let l=ot(a,t);if(l!==void 0)return l}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let s=nt(e,e.typeName,t),u=typeof s=="function"?d(s(),t):s;if(u&&it(e,t,u),t.postProcess){let l=t.postProcess(u,e,t);return i.jsonSchema=u,l}return i.jsonSchema=u,u}o(d,"parseDef");var ot=o((e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:at(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),h()):t.$refStrategy==="seen"?h():void 0}},"get$ref"),it=o((e,t,r)=>(e.description&&(r.description=e.description),r),"addMeta"),st=o(e=>{let t=Ee(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}},"getRefs"),ut=o((e,t)=>{var r;let n=st(t),a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[p,k])=>{var C;return{...c,[p]:(C=d(k._def,{...n,currentPath:[...n.basePath,n.definitionPath,p]},!0))!=null?C:h()}},{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,s=(r=d(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1))!=null?r:h(),u=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;u!==void 0&&(s.title=u);let l=i===void 0?a?{...s,[n.definitionPath]:a}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:{...a,[i]:s}};return l.$schema="http://json-schema.org/draft-07/schema#",l},"zod3ToJsonSchema"),N=Symbol.for("vercel.ai.schema");function Jt(e){let t;return()=>(t==null&&(t=e()),t)}o(Jt,"lazySchema");function T(e,{validate:t}={}){return{[N]:!0,_type:void 0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}o(T,"jsonSchema");function ct(e){return typeof e=="object"&&e!==null&&N in e&&e[N]===!0&&"jsonSchema"in e&&"validate"in e}o(ct,"isSchema");function lt(e){return e==null?T({type:"object",properties:{},additionalProperties:!1}):ct(e)?e:"~standard"in e?e["~standard"].vendor==="zod"?ht(e):ft(e):e()}o(lt,"asSchema");function ft(e){return T(()=>{if(!dt(e))throw new Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);return Z(e["~standard"].jsonSchema.input({target:"draft-07"}))},{validate:o(async t=>{let r=await e["~standard"].validate(t);return"value"in r?{success:!0,value:r.value}:{success:!1,error:new w({value:t,cause:r.issues})}},"validate")})}o(ft,"standardSchema");function dt(e){return e["~standard"].jsonSchema!=null}o(dt,"hasStandardJsonSchema");function pt(e,t){var r;let n=(r=t?.useReferences)!=null?r:!1;return T(()=>ut(e,{$refStrategy:n?"root":"none"}),{validate:o(async a=>{let i=await e.safeParseAsync(a);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}o(pt,"zod3Schema");function mt(e,t){var r;let n=(r=t?.useReferences)!=null?r:!1;return T(()=>Z(R(e,{target:"draft-7",io:"input",reused:n?"ref":"inline"})),{validate:o(async a=>{let i=await x(e,a);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}},"validate")})}o(mt,"zod4Schema");function yt(e){return"_zod"in e}o(yt,"isZod4Schema");function ht(e,t){return yt(e)?mt(e,t):pt(e,t)}o(ht,"zodSchema");async function vt({value:e,schema:t,context:r}){let n=await D({value:e,schema:t,context:r});if(!n.success)throw w.wrap({value:e,cause:n.error,context:r});return n.value}o(vt,"validateTypes");async function D({value:e,schema:t,context:r}){let n=lt(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let a=await n.validate(e);return a.success?{success:!0,value:a.value,rawValue:e}:{success:!1,error:w.wrap({value:e,cause:a.error,context:r}),rawValue:e}}catch(a){return{success:!1,error:w.wrap({value:e,cause:a,context:r}),rawValue:e}}}o(D,"safeValidateTypes");async function gt({text:e,schema:t}){try{let r=Q(e);return t==null?r:vt({value:r,schema:t})}catch(r){throw P.isInstance(r)||w.isInstance(r)?r:new P({text:e,cause:r})}}o(gt,"parseJSON");async function ae({text:e,schema:t}){try{let r=Q(e);return t==null?{success:!0,value:r,rawValue:r}:await D({value:r,schema:t})}catch(r){return{success:!1,error:P.isInstance(r)?r:new P({text:e,cause:r}),rawValue:void 0}}}o(ae,"safeParseJSON");function wt({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new j).pipeThrough(new TransformStream({async transform({data:r},n){r!=="[DONE]"&&n.enqueue(await ae({text:r,schema:t}))}}))}o(wt,"parseJsonEventStream");async function qt({provider:e,providerOptions:t,schema:r}){if(t?.[e]==null)return;let n=await D({value:t[e],schema:r});if(!n.success)throw new S({argument:"providerOptions",message:`invalid ${e} provider options`,cause:n.error});return n.value}o(qt,"parseProviderOptions");var bt=o(()=>globalThis.fetch,"getOriginalFetch2"),Gt=o(async({url:e,headers:t,body:r,failedResponseHandler:n,successfulResponseHandler:a,abortSignal:i,fetch:s})=>Pt({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:n,successfulResponseHandler:a,abortSignal:i,fetch:s}),"postJsonToApi");var Pt=o(async({url:e,headers:t={},body:r,successfulResponseHandler:n,failedResponseHandler:a,abortSignal:i,fetch:s=bt()})=>{try{let u=await s(e,{method:"POST",headers:X(t,`ai-sdk/provider-utils/${Y}`,K()),body:r.content,signal:i}),l=E(u);if(!u.ok){let c;try{c=await a({response:u,url:e,requestBodyValues:r.values})}catch(p){throw A(p)||m.isInstance(p)?p:new m({message:"Failed to process error response",cause:p,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw c.value}try{return await n({response:u,url:e,requestBodyValues:r.values})}catch(c){throw c instanceof Error&&(A(c)||m.isInstance(c))?c:new m({message:"Failed to process successful response",cause:c,statusCode:u.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(u){throw G({error:u,url:e,requestBodyValues:r.values})}},"postToApi");function Kt({id:e,inputSchema:t}){return({execute:r,outputSchema:n,needsApproval:a,toModelOutput:i,onInputStart:s,onInputDelta:u,onInputAvailable:l,...c})=>({type:"provider",id:e,args:c,inputSchema:t,outputSchema:n,execute:r,needsApproval:a,toModelOutput:i,onInputStart:s,onInputDelta:u,onInputAvailable:l})}o(Kt,"createProviderToolFactory");function Xt({id:e,inputSchema:t,outputSchema:r,supportsDeferredResults:n}){return({execute:a,needsApproval:i,toModelOutput:s,onInputStart:u,onInputDelta:l,onInputAvailable:c,...p})=>({type:"provider",id:e,args:p,inputSchema:t,outputSchema:r,execute:a,needsApproval:i,toModelOutput:s,onInputStart:u,onInputDelta:l,onInputAvailable:c,supportsDeferredResults:n})}o(Xt,"createProviderToolFactoryWithOutputSchema");async function Yt(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}o(Yt,"resolve");var _t=new TextDecoder;async function oe({response:e,url:t}){return _t.decode(await pe({response:e,url:t}))}o(oe,"readResponseBodyAsText");var er=o(({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:n,url:a,requestBodyValues:i})=>{let s=await oe({response:n,url:a}),u=E(n);if(s.trim()==="")return{responseHeaders:u,value:new m({message:n.statusText,url:a,requestBodyValues:i,statusCode:n.status,responseHeaders:u,responseBody:s,isRetryable:r?.(n)})};try{let l=await gt({text:s,schema:e});return{responseHeaders:u,value:new m({message:t(l),url:a,requestBodyValues:i,statusCode:n.status,responseHeaders:u,responseBody:s,data:l,isRetryable:r?.(n,l)})}}catch{return{responseHeaders:u,value:new m({message:n.statusText,url:a,requestBodyValues:i,statusCode:n.status,responseHeaders:u,responseBody:s,isRetryable:r?.(n)})}}},"createJsonErrorResponseHandler"),tr=o(e=>async({response:t})=>{let r=E(t);if(t.body==null)throw new L({});return{responseHeaders:r,value:wt({stream:t.body,schema:e})}},"createEventSourceResponseHandler"),rr=o(e=>async({response:t,url:r,requestBodyValues:n})=>{let a=await oe({response:t,url:r}),i=await ae({text:a,schema:e}),s=E(t);if(!i.success)throw new m({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:n});return{responseHeaders:s,value:i.value,rawValue:i.rawValue}},"createJsonResponseHandler");function nr(e){return e?.replace(/\/$/,"")}o(nr,"withoutTrailingSlash");export{Et as a,kt as b,se as c,Tt as d,Ft as e,A as f,K as g,ge as h,X as i,Dt as j,Ct as k,Rt as l,Q as m,Jt as n,ht as o,qt as p,Gt as q,Kt as r,Xt as s,Yt as t,er as u,tr as v,rr as w,nr as x};
|