@intent-hq/web 2.280.0 → 2.280.1
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/package.json +1 -1
- package/web/app/immutable/chunks/{CqWjEg_w.js → -CwTNgWz.js} +1 -1
- package/web/app/immutable/chunks/{gb654U7I.js → 2jlj3Ler.js} +1 -1
- package/web/app/immutable/chunks/{N6QJHIhO.js → 3jOBMSa2.js} +1 -1
- package/web/app/immutable/chunks/{C90yTaYt.js → 4_muao6M.js} +1 -1
- package/web/app/immutable/chunks/{DXBMViP_.js → 68rxuoyq.js} +1 -1
- package/web/app/immutable/chunks/{hkbK0uGm.js → 6WgKbzWn.js} +1 -1
- package/web/app/immutable/chunks/{C7i9B-ha.js → 9hy801AX.js} +1 -1
- package/web/app/immutable/chunks/{DnhUO3WC.js → A03aFnAi.js} +1 -1
- package/web/app/immutable/chunks/{DY3OgpfJ.js → A9wPt9W8.js} +1 -1
- package/web/app/immutable/chunks/{CSWj16FD.js → AxG32tEq.js} +1 -1
- package/web/app/immutable/chunks/{BvY26mms.js → B2K72oo5.js} +1 -1
- package/web/app/immutable/chunks/{ZEBhSR5D.js → B45awpwY.js} +6 -6
- package/web/app/immutable/chunks/{DuEMgIMk.js → B4FELDN8.js} +1 -1
- package/web/app/immutable/chunks/{CcncgTgR.js → B4m64te4.js} +1 -1
- package/web/app/immutable/chunks/{DYYnXH8M.js → B6ZTfeOu.js} +2 -2
- package/web/app/immutable/chunks/{BjT2fyp4.js → B898Thex.js} +1 -1
- package/web/app/immutable/chunks/{B3HWhL7f.js → BAKCy1ct.js} +1 -1
- package/web/app/immutable/chunks/{CEwq2icc.js → BBzV6xv4.js} +1 -1
- package/web/app/immutable/chunks/{T2cz-xly.js → BDjsvDcb.js} +2 -2
- package/web/app/immutable/chunks/{NPEQPSOM.js → BEl--qal.js} +1 -1
- package/web/app/immutable/chunks/{BhWpP6Em.js → BFT1DBam.js} +1 -1
- package/web/app/immutable/chunks/{URngKIcX.js → BHgv1zSY.js} +1 -1
- package/web/app/immutable/chunks/{CTzUuaPY.js → BLSSZOMv.js} +1 -1
- package/web/app/immutable/chunks/{DKzibOTp.js → BP9ZIbzc.js} +1 -1
- package/web/app/immutable/chunks/{8a4VhuXU.js → BPNaYp5g.js} +1 -1
- package/web/app/immutable/chunks/{nBH4tfK0.js → BPQzmBfs.js} +1 -1
- package/web/app/immutable/chunks/{CAwhk8oQ.js → BPSTu_LB.js} +1 -1
- package/web/app/immutable/chunks/{DfgY-kiD.js → BPU_rzFz.js} +1 -1
- package/web/app/immutable/chunks/{B4LsznIm.js → BQ-dHdWP.js} +1 -1
- package/web/app/immutable/chunks/{CJ-1Nicc.js → BQHODbmu.js} +1 -1
- package/web/app/immutable/chunks/BT84ap5K.js +1 -0
- package/web/app/immutable/chunks/{BMMv1dT9.js → BTM_WGL_.js} +1 -1
- package/web/app/immutable/chunks/{DoyPrFXR.js → BU0pqKbR.js} +1 -1
- package/web/app/immutable/chunks/{DfNuJ6oL.js → BVKhCVH9.js} +1 -1
- package/web/app/immutable/chunks/{YHdlsWct.js → BVXynvnn.js} +1 -1
- package/web/app/immutable/chunks/{B_NbPKl3.js → BW-plizF.js} +1 -1
- package/web/app/immutable/chunks/{CtJg7u1A.js → BW8TPfRW.js} +3 -3
- package/web/app/immutable/chunks/{Dm0QgRo-.js → BXciywVo.js} +1 -1
- package/web/app/immutable/chunks/{eQM-IxZX.js → BY0FrRuN.js} +5 -5
- package/web/app/immutable/chunks/{DOrHUF0y.js → BYkwlyOx.js} +1 -1
- package/web/app/immutable/chunks/BZ8IpxwP.js +1 -0
- package/web/app/immutable/chunks/{DAtbkiMc.js → BZLCAaA0.js} +1 -1
- package/web/app/immutable/chunks/{C93vPsHK.js → BZux1no-.js} +1 -1
- package/web/app/immutable/chunks/{3riJ9IqO.js → B_b2DFb_.js} +1 -1
- package/web/app/immutable/chunks/{CDYpj3Wv.js → B_gYec_y.js} +1 -1
- package/web/app/immutable/chunks/{BkBahiMY.js → Baw2yANm.js} +1 -1
- package/web/app/immutable/chunks/{DKp6jlON.js → Bbx7keP6.js} +1 -1
- package/web/app/immutable/chunks/{DZLfTd9v.js → Bc1u6HH9.js} +1 -1
- package/web/app/immutable/chunks/{BwKTpHLe.js → BceFI8C_.js} +1 -1
- package/web/app/immutable/chunks/{Bx952p7Q.js → BfwUFrB0.js} +1 -1
- package/web/app/immutable/chunks/{DLqv0Ikg.js → BgNO_1M2.js} +1 -1
- package/web/app/immutable/chunks/{BPNyirUe.js → BguE5B0x.js} +1 -1
- package/web/app/immutable/chunks/{B_eTXuFT.js → BhDJcXuT.js} +1 -1
- package/web/app/immutable/chunks/{DvaVsSuU.js → BjBETkWC.js} +1 -1
- package/web/app/immutable/chunks/{stotUVND.js → Bl0HJ17r.js} +3 -3
- package/web/app/immutable/chunks/{BLUcjUGa.js → Bm52rc6Y.js} +1 -1
- package/web/app/immutable/chunks/{N7fhICzs.js → Bmb9f-vS.js} +1 -1
- package/web/app/immutable/chunks/{DkJZ6qt_.js → BmdFGxql.js} +1 -1
- package/web/app/immutable/chunks/{B4VMxRrC.js → BmyBU_d0.js} +1 -1
- package/web/app/immutable/chunks/{clVAYYi3.js → BoGQvi6r.js} +1 -1
- package/web/app/immutable/chunks/{DkOgrmDO.js → BoqFUVbe.js} +1 -1
- package/web/app/immutable/chunks/{CQWH6H5Q.js → BrW2Z0Ue.js} +1 -1
- package/web/app/immutable/chunks/{9nkBC1Gf.js → BtNv1rB8.js} +1 -1
- package/web/app/immutable/chunks/{xYBj3dw3.js → Bu2f_xik.js} +1 -1
- package/web/app/immutable/chunks/{BP0nvB-r.js → BvugS_th.js} +1 -1
- package/web/app/immutable/chunks/{y8oZX4sf.js → BxG24Fz6.js} +1 -1
- package/web/app/immutable/chunks/{Dvrl4uc9.js → BzSqqrdV.js} +1 -1
- package/web/app/immutable/chunks/{UQoGZ5qq.js → C-3IOyFr.js} +1 -1
- package/web/app/immutable/chunks/{B__WlfRy.js → C-YIgYgI.js} +3 -3
- package/web/app/immutable/chunks/{N6Oy5HNi.js → C1A6QIyB.js} +1 -1
- package/web/app/immutable/chunks/{BZSrLoH0.js → C1F9VBVR.js} +1 -1
- package/web/app/immutable/chunks/{CQB9d6Yf.js → C3uzPV7c.js} +1 -1
- package/web/app/immutable/chunks/{BlWy-Yyj.js → C7uEROnA.js} +3 -3
- package/web/app/immutable/chunks/C82p3eaN.js +410 -0
- package/web/app/immutable/chunks/{CqMqlLWW.js → C87twKUp.js} +1 -1
- package/web/app/immutable/chunks/{Dz9B-9IH.js → C8BD21JK.js} +1 -1
- package/web/app/immutable/chunks/{CdjxL29Q.js → C8Ri7767.js} +1 -1
- package/web/app/immutable/chunks/{nSxzXlBd.js → CAvR_m9C.js} +1 -1
- package/web/app/immutable/chunks/{BC5uKK7w.js → CBGnfmpX.js} +1 -1
- package/web/app/immutable/chunks/{vpnNwaI3.js → CBQ-NG4P.js} +1 -1
- package/web/app/immutable/chunks/{DXT5rgnn.js → CBWj5Yn9.js} +1 -1
- package/web/app/immutable/chunks/{BVt6P2Dk.js → CE_2ADe7.js} +1 -1
- package/web/app/immutable/chunks/{CMAGQJUI.js → CH6MdBMX.js} +1 -1
- package/web/app/immutable/chunks/{C-WnhoQ3.js → CJ17D0UC.js} +1 -1
- package/web/app/immutable/chunks/{DERVpCl4.js → CLst9ImY.js} +1 -1
- package/web/app/immutable/chunks/CN6Xgdqp.js +1 -0
- package/web/app/immutable/chunks/{eQHw-9b6.js → COGdwXWC.js} +2 -2
- package/web/app/immutable/chunks/{B7f90q4s.js → CPRrGZdb.js} +1 -1
- package/web/app/immutable/chunks/{BndTIIgb.js → CRK47dBR.js} +1 -1
- package/web/app/immutable/chunks/{CJ0FjS97.js → CSZ4_RTQ.js} +2 -2
- package/web/app/immutable/chunks/{CongIN9X.js → CS_zvIHS.js} +1 -1
- package/web/app/immutable/chunks/{Te3M5bc7.js → CVgZfK3-.js} +1 -1
- package/web/app/immutable/chunks/{Cz4cjwfL.js → CX9zash3.js} +1 -1
- package/web/app/immutable/chunks/{uA-GSod5.js → CYmzMH2T.js} +1 -1
- package/web/app/immutable/chunks/{CeNnTXT3.js → C_FFOKOn.js} +1 -1
- package/web/app/immutable/chunks/{D0X3JVqD.js → CcMBhJ58.js} +1 -1
- package/web/app/immutable/chunks/{Bp5ygEp6.js → CdJoXoLx.js} +1 -1
- package/web/app/immutable/chunks/{6mfqT9F0.js → CeCzBIMM.js} +1 -1
- package/web/app/immutable/chunks/{BAw6o6lJ.js → CfBY2vbK.js} +1 -1
- package/web/app/immutable/chunks/{DGsBebnq.js → CfBpHiou.js} +1 -1
- package/web/app/immutable/chunks/{rrF5Hl_J.js → CgGQ3Slz.js} +1 -1
- package/web/app/immutable/chunks/{BUxfGI8Z.js → ChBxJ_T2.js} +1 -1
- package/web/app/immutable/chunks/{Df1cVjK1.js → CiShviCo.js} +4 -4
- package/web/app/immutable/chunks/{BGVlzHwy.js → CkFE8VfK.js} +1 -1
- package/web/app/immutable/chunks/{Q2u3rFY1.js → ClR-TTMN.js} +2 -2
- package/web/app/immutable/chunks/{Yip29sR2.js → Cmf1A7_B.js} +1 -1
- package/web/app/immutable/chunks/{CEIySDvB.js → Cmr6Xpw3.js} +1 -1
- package/web/app/immutable/chunks/{BvP_3Sy4.js → Cmzu4CqY.js} +1 -1
- package/web/app/immutable/chunks/{CS36kkvG.js → Com4THH3.js} +1 -1
- package/web/app/immutable/chunks/{UFzyo4ne.js → CqF12LNt.js} +1 -1
- package/web/app/immutable/chunks/{B6Rs6hHm.js → Cql2yasp.js} +1 -1
- package/web/app/immutable/chunks/{t7BMdiLm.js → Cr_gbuBh.js} +1 -1
- package/web/app/immutable/chunks/{BJfxejEG.js → CrarsPv2.js} +1 -1
- package/web/app/immutable/chunks/{CDSYYpwa.js → CriyUZJv.js} +1 -1
- package/web/app/immutable/chunks/{CwSIKtqo.js → CszhQy-T.js} +1 -1
- package/web/app/immutable/chunks/{mklnjf4_.js → CtfKkjtt.js} +1 -1
- package/web/app/immutable/chunks/{C33zLAon.js → CwW1BUBB.js} +1 -1
- package/web/app/immutable/chunks/{BkVUImC4.js → D5SukII7.js} +1 -1
- package/web/app/immutable/chunks/{w-RLNdGr.js → D5nEFEMU.js} +1 -1
- package/web/app/immutable/chunks/{C1r_dvAi.js → D8KNd2JX.js} +1 -1
- package/web/app/immutable/chunks/{D5DS8MOZ.js → DACKa6C3.js} +1 -1
- package/web/app/immutable/chunks/{oLkbmMHL.js → DB_7wrc7.js} +1 -1
- package/web/app/immutable/chunks/{lF96b5e4.js → DBct6Vvn.js} +1 -1
- package/web/app/immutable/chunks/{CJGDfIog.js → DC6J5sZ-.js} +1 -1
- package/web/app/immutable/chunks/DCU5S8Gd.js +1 -0
- package/web/app/immutable/chunks/{DiXg0x-W.js → DD57Mp8Z.js} +1 -1
- package/web/app/immutable/chunks/{D3jilL3b.js → DDK55OAB.js} +1 -1
- package/web/app/immutable/chunks/{Jw-22-gH.js → DFKo1ZAJ.js} +1 -1
- package/web/app/immutable/chunks/{HoeZnZ3h.js → DFxsImeG.js} +1 -1
- package/web/app/immutable/chunks/{CbO_toqh.js → DFz-Vr9a.js} +1 -1
- package/web/app/immutable/chunks/{EzR2MUkx.js → DGC3jX9C.js} +3 -3
- package/web/app/immutable/chunks/{CB2itZPT.js → DGrFhzHu.js} +2 -2
- package/web/app/immutable/chunks/{Bq0kEo6t.js → DGsKwFeF.js} +1 -1
- package/web/app/immutable/chunks/{DH71XKkM.js → DHM3GVKY.js} +1 -1
- package/web/app/immutable/chunks/{LK9i1Fgb.js → DHMcsnK1.js} +1 -1
- package/web/app/immutable/chunks/{C9fQIDg9.js → DHt5Qx-W.js} +1 -1
- package/web/app/immutable/chunks/{bTkQsu94.js → DIGRq3Np.js} +1 -1
- package/web/app/immutable/chunks/{Cr8O6b9X.js → DJxE8cOI.js} +4 -4
- package/web/app/immutable/chunks/{DTULcguA.js → DM3bYLxj.js} +1 -1
- package/web/app/immutable/chunks/{C19ZZHpm.js → DOqOxnjD.js} +1 -1
- package/web/app/immutable/chunks/{CtxR6yc7.js → DOsLfX1h.js} +3 -3
- package/web/app/immutable/chunks/{DeqDTWfs.js → DPMpx6lS.js} +1 -1
- package/web/app/immutable/chunks/{Cp73wfaC.js → DPsGF2i5.js} +1 -1
- package/web/app/immutable/chunks/{6Ys1q35u.js → DS_3tw6q.js} +1 -1
- package/web/app/immutable/chunks/{DjeJHedD.js → DSvMjM09.js} +1 -1
- package/web/app/immutable/chunks/{B3-959pn.js → DTOf9l3E.js} +1 -1
- package/web/app/immutable/chunks/{Dukd5fsq.js → DTd1YpaC.js} +1 -1
- package/web/app/immutable/chunks/{BVb5pfaA.js → DTpHCyDe.js} +1 -1
- package/web/app/immutable/chunks/{C8n2AuxQ.js → DUOglMHy.js} +1 -1
- package/web/app/immutable/chunks/{BH9ttt95.js → DVh97JfW.js} +1 -1
- package/web/app/immutable/chunks/{DI5BNHva.js → DVqZmj-R.js} +1 -1
- package/web/app/immutable/chunks/{CbKxMrMY.js → D_qXZ-ka.js} +3 -3
- package/web/app/immutable/chunks/{CgDKiC6v.js → Dayd4Wgp.js} +2 -2
- package/web/app/immutable/chunks/{ElkcFG4d.js → De0AF9gl.js} +1 -1
- package/web/app/immutable/chunks/{BXrUMWsR.js → DePQKdPz.js} +1 -1
- package/web/app/immutable/chunks/{DACPyPs7.js → DgFsji4g.js} +1 -1
- package/web/app/immutable/chunks/{D1Ntri6z.js → Di6uZPiF.js} +1 -1
- package/web/app/immutable/chunks/{IJ5h6xZ4.js → DkNxxzmT.js} +1 -1
- package/web/app/immutable/chunks/{Dzimjbdi.js → DkxKadFP.js} +1 -1
- package/web/app/immutable/chunks/{BANaLpH3.js → DnE5aVuv.js} +1 -1
- package/web/app/immutable/chunks/{BuN1aIUI.js → DnEM5LKJ.js} +1 -1
- package/web/app/immutable/chunks/{CiLfhM-B.js → Do7HQr7r.js} +2 -2
- package/web/app/immutable/chunks/{C-uox8N9.js → DpQUJ1uI.js} +1 -1
- package/web/app/immutable/chunks/{Cnhc2tSL.js → Dp_sBH9q.js} +1 -1
- package/web/app/immutable/chunks/{B3vK-R-o.js → DrooRzRX.js} +1 -1
- package/web/app/immutable/chunks/{Dm2prBtG.js → Ds0y9W2N.js} +1 -1
- package/web/app/immutable/chunks/{D6EF8Ce7.js → Ds641dV5.js} +1 -1
- package/web/app/immutable/chunks/{waekWt8I.js → DsB3GaMq.js} +1 -1
- package/web/app/immutable/chunks/{CpA81uUD.js → DuJ8M51r.js} +1 -1
- package/web/app/immutable/chunks/{CMlYEClg.js → Duy6Dp7J.js} +1 -1
- package/web/app/immutable/chunks/{BNa1xVO7.js → Dwp3N9DW.js} +1 -1
- package/web/app/immutable/chunks/{Aq_hvPuk.js → DxrVr4Z-.js} +1 -1
- package/web/app/immutable/chunks/{DtDJkmRR.js → DzBqr5Ds.js} +1 -1
- package/web/app/immutable/chunks/{UEOyoIDp.js → DzTcsuyr.js} +1 -1
- package/web/app/immutable/chunks/{BUkZ_wc0.js → EYJa5XI2.js} +1 -1
- package/web/app/immutable/chunks/{DQ1jf8rv.js → F78VMou9.js} +2 -2
- package/web/app/immutable/chunks/{CGZwKPOh.js → GHkZED_H.js} +1 -1
- package/web/app/immutable/chunks/{FJwDbpvw.js → H0GxNKO6.js} +1 -1
- package/web/app/immutable/chunks/{6PSZ6lUf.js → HnBTNAMz.js} +1 -1
- package/web/app/immutable/chunks/{e95iwXST.js → IsiJ9INb.js} +1 -1
- package/web/app/immutable/chunks/{CBOwO-Mt.js → Jp68-Q2x.js} +1 -1
- package/web/app/immutable/chunks/{s9eau3Xa.js → Jy9V3N_7.js} +1 -1
- package/web/app/immutable/chunks/{DenIsJVL.js → K0azdCX9.js} +1 -1
- package/web/app/immutable/chunks/{BM_-VfIm.js → Kk07D7VE.js} +1 -1
- package/web/app/immutable/chunks/{DMWrQCj4.js → LXk8sd0A.js} +1 -1
- package/web/app/immutable/chunks/{D6xwyO9X.js → Lr6hvseQ.js} +1 -1
- package/web/app/immutable/chunks/{CE4Q63si.js → MQaqCR4A.js} +1 -1
- package/web/app/immutable/chunks/{DYk_WT-b.js → Njxs8gUf.js} +1 -1
- package/web/app/immutable/chunks/{BzC1GMNV.js → OiX-SxC_.js} +1 -1
- package/web/app/immutable/chunks/{A0CZ88DG.js → OwL7thrT.js} +1 -1
- package/web/app/immutable/chunks/{BxMZftIo.js → PWYpp4hZ.js} +1 -1
- package/web/app/immutable/chunks/{fxbWd_e1.js → UJwgGUj4.js} +1 -1
- package/web/app/immutable/chunks/{qMMt4K52.js → UgfAVREY.js} +1 -1
- package/web/app/immutable/chunks/{Cv5hE_ED.js → XUEHMX7O.js} +1 -1
- package/web/app/immutable/chunks/{BLPQXyX_.js → Z6bOeoYv.js} +1 -1
- package/web/app/immutable/chunks/{D51GwsQ1.js → ZOO6Vfpu.js} +1 -1
- package/web/app/immutable/chunks/{BI00pPJ1.js → a8E6fbkW.js} +1 -1
- package/web/app/immutable/chunks/{UOvnclhB.js → aZQ0-tdp.js} +4 -4
- package/web/app/immutable/chunks/{DtIgh-Wb.js → bxUMV0oT.js} +1 -1
- package/web/app/immutable/chunks/{BQM-54by.js → c3Abb5qo.js} +1 -1
- package/web/app/immutable/chunks/{BsLu-N-o.js → cOSCr41c.js} +1 -1
- package/web/app/immutable/chunks/{B05_pVBL.js → caVSTeyS.js} +1 -1
- package/web/app/immutable/chunks/{CKaz-nQX.js → cfpFgXT5.js} +1 -1
- package/web/app/immutable/chunks/{D8hmEpbp.js → e0v3-ZIG.js} +1 -1
- package/web/app/immutable/chunks/{CVma05vh.js → i9DY-0TX.js} +1 -1
- package/web/app/immutable/chunks/{4c21rJgy.js → kSHx_2s_.js} +1 -1
- package/web/app/immutable/chunks/{Dqugp38s.js → qasXuzlR.js} +1 -1
- package/web/app/immutable/chunks/{Dcg7SWi9.js → qj5yCt7h.js} +1 -1
- package/web/app/immutable/chunks/{Ci0AQ6w8.js → qkfs_BCa.js} +1 -1
- package/web/app/immutable/chunks/{C6HFp_sK.js → qqmEa9H6.js} +1 -1
- package/web/app/immutable/chunks/{BrgQitGU.js → sSa7Wn7K.js} +1 -1
- package/web/app/immutable/chunks/{D5DbIKBx.js → sXvRCqUb.js} +1 -1
- package/web/app/immutable/chunks/{BjM2Qc64.js → tdATXSHH.js} +1 -1
- package/web/app/immutable/chunks/{CR9OjoGG.js → tuQscXjh.js} +1 -1
- package/web/app/immutable/chunks/{DWTk7BzJ.js → uYOEUrhQ.js} +1 -1
- package/web/app/immutable/chunks/{DnQbQ1Ee.js → vJt7gt7x.js} +7 -7
- package/web/app/immutable/chunks/{CkoWrmIy.js → y3HzT_To.js} +1 -1
- package/web/app/immutable/chunks/{DrDKCvwv.js → yL59xdGf.js} +1 -1
- package/web/app/immutable/chunks/{CZvE7cU6.js → yvuwpbPL.js} +1 -1
- package/web/app/immutable/chunks/{BAR8yUHQ.js → zd6Cuy6l.js} +1 -1
- package/web/app/immutable/entry/app.DY99f_Ty.js +4 -0
- package/web/app/immutable/entry/start.BcYitP96.js +1 -0
- package/web/app/immutable/nodes/{0.BoxQzHDp.js → 0.C4LmvMoM.js} +1 -1
- package/web/app/immutable/nodes/{1.DU9opyfh.js → 1.BYE5bJSa.js} +1 -1
- package/web/app/immutable/nodes/{10.eExevNYJ.js → 10.BrKhL_G6.js} +1 -1
- package/web/app/immutable/nodes/{12.DyoMTbCQ.js → 12.BGqWnph6.js} +1 -1
- package/web/app/immutable/nodes/{13.C0iYfqVI.js → 13.vfNjr05l.js} +1 -1
- package/web/app/immutable/nodes/{14.KEg9Fqc4.js → 14.U6Ne_Zng.js} +1 -1
- package/web/app/immutable/nodes/{15.F8zDHy08.js → 15.DHcLeO2-.js} +1 -1
- package/web/app/immutable/nodes/{16.dAZs6dYD.js → 16.Brkz5pXG.js} +2 -2
- package/web/app/immutable/nodes/{2.BrvzcNmI.js → 2.BsPWX-pi.js} +4 -4
- package/web/app/immutable/nodes/{3.ByPIR3CM.js → 3.CYtb_dsh.js} +1 -1
- package/web/app/immutable/nodes/{4.JEfjf0UF.js → 4.DWQJjc9i.js} +1 -1
- package/web/app/immutable/nodes/{5.BUymCG_x.js → 5.BrUyXV_u.js} +1 -1
- package/web/app/immutable/nodes/{6.Btna6Yhq.js → 6.CA6jFqpu.js} +1 -1
- package/web/app/immutable/nodes/{7.BHmutzAv.js → 7.BYZ_h1_W.js} +1 -1
- package/web/app/immutable/nodes/{8.Ctc8SBWw.js → 8.ie9sNdo3.js} +4 -4
- package/web/app/immutable/nodes/{9.Cwg6B2vl.js → 9.nBlKsA0T.js} +4 -4
- package/web/app/version.json +1 -1
- package/web/index.html +11 -10
- package/web/app/immutable/chunks/BH6SkDfK.js +0 -1
- package/web/app/immutable/chunks/CmlEVTR3.js +0 -410
- package/web/app/immutable/chunks/DK5QZ1vP.js +0 -1
- package/web/app/immutable/chunks/DW3Zf5Ax.js +0 -1
- package/web/app/immutable/entry/app.b6gE4ET2.js +0 -4
- package/web/app/immutable/entry/start.BoRhInyV.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Vr=Object.defineProperty;var Kt=n=>{throw TypeError(n)};var zr=(n,e,t)=>e in n?Vr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var y=(n,e,t)=>zr(n,typeof e!="symbol"?e+"":e,t),ht=(n,e,t)=>e.has(n)||Kt("Cannot "+t);var T=(n,e,t)=>(ht(n,e,"read from private field"),t?t.call(n):e.get(n)),H=(n,e,t)=>e.has(n)?Kt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ke=(n,e,t,r)=>(ht(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),vt=(n,e,t)=>(ht(n,e,"access private method"),t);import{e as Jn,c as Kr,C as Yr,g as Jr}from"./0I000Ru9.js";import{bo as E}from"./GWL2EpD7.js";import{fr as Zr,ah as ve,p_ as Zn,c as Qr,b as bt,b9 as Qn,zk as Xr,a6 as es,i as ot,kI as ts,l$ as ns,G0 as rs,S as St,a3 as It,ak as ss,t as os,aj as is,d as as,aA as cs,aB as us,aH as ls,au as ds,aD as fs,az as ps,aG as gs,ay as ys,aC as ms,aE as hs,ax as vs,aF as bs,as as Ss,aw as Is,av as ks,mw as Xn,hK as er,ba as je,hB as As,hm as Ts,aP as ws}from"./C2YltVuJ.js";import{br as se,bs as oe,ax as u,aK as Es,aL as Cs,bp as Rs,ay as $t,aA as Ne,bz as _s,$ as Os,_ as Ms,ah as Ps,aN as Ns,aM as Ls}from"./CgDKiC6v.js";import{b as Yt,B as tr}from"./CsjyI82U.js";import{c as ze}from"./ChTqQfQN.js";import{bV as xs,br as Bs,aD as ge,bH as kt}from"./B8o4lNgr.js";import{a as js}from"./BJzHxIyr.js";import{i as ye}from"./CbVPen4y.js";import{I as k,b as Ds}from"./BeYie-c5.js";import{i as Us,C as nr,g as qs}from"./DypB-Dwi.js";import{r as Q,b as Fs,i as $s}from"./DVkfuwKw.js";import{o as Ke,s as Se,n as X,b as Hs,Z as Ws,r as At}from"./CpHIRYx9.js";const Gs=["high","medium","low"],Vs=["pending","in_progress","completed"],zs=256;function K(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ks(n){return K(n)?typeof n.content=="string"&&Gs.includes(n.priority)&&Vs.includes(n.status):!1}function rr(n){return K(n)&&n.type==="plan"&&Array.isArray(n.entries)&&n.entries.length<=zs&&n.entries.every(Ks)}function Jt(n){return n?.type==="plan"?rr(n):typeof n=="object"&&n!==null&&(typeof n.type=="string"&&["text","code","tool_use","tool_result","thinking","image","audio","video","file","nav-link","proposal","plan"].includes(n.type)||n.kind==="nav-link"&&typeof n.target=="string"||Jn(n.kind)&&!!n.preview)}const Ys=/\.(?:mp4|webm|mov|m4v)$/i,Js=/^video\/[a-z0-9][a-z0-9.+-]*$/i,Zs=new Set(["video/mp4","video/webm","video/quicktime","video/x-m4v","video/m4v"]);function xt(n){if(typeof n!="string")return;const e=n.split(";",1)[0].trim().toLowerCase();return Js.test(e)?e:void 0}function Qs(n,e){if(typeof n!="string"||n.length===0||n!==n.trim())return null;let t;try{t=new URL(n)}catch{return null}if(t.protocol!=="https:"||t.username||t.password)return null;const r=xt(e),s=r&&Zs.has(r)?r:void 0;return!s&&!Ys.test(t.pathname)?null:{kind:"remote",url:n,...s?{mimeType:s}:{}}}function Xs(n,e){if(typeof n!="string"||!n.startsWith("intent://local/")||!e||!/^[A-Za-z0-9._-]+$/.test(e)||n.includes("?")||n.includes("#"))return null;const r=n.slice(9).split("/").slice(1);let s,o;if(r[0]==="file")s=e,o=r.slice(1);else if(r.length>=3&&r[1]==="file"){try{s=decodeURIComponent(r[0])}catch{return null}if(s!==e)return null;o=r.slice(2)}else return null;const i=[];for(const l of o){let d;try{d=decodeURIComponent(l)}catch{return null}if(!d||d==="."||d===".."||d.includes("/")||d.includes("\\")||d.includes("\0"))return null;i.push(d)}if(i.length===0||/^[A-Za-z]:/.test(i[0]))return null;const a=i[i.length-1].toLowerCase(),c=a.endsWith(".mp4")?"video/mp4":a.endsWith(".webm")?"video/webm":null;return c?{kind:"workspace",url:`workspace-file://${s}/${i.map(encodeURIComponent).join("/")}`,mimeType:c}:null}function Tt(n,e,t){return Qs(n,e)??Xs(n,t)}function De(n,e,t){return{type:"video",source:e,...typeof n.id=="string"?{id:n.id}:{},...K(n.metadata)?{metadata:n.metadata}:{},...typeof t=="string"&&t.length>0?{fileName:t}:{}}}function eo(n,e){if(!K(n))return null;const t=n.type;if((t==="file"||t==="blob")&&typeof n.data=="string"&&n.data){const r=xt(n.mimeType);if(r)return De(n,{kind:"inline",data:n.data,mimeType:r},n.fileName)}if(t==="resource"&&K(n.resource)){const r=n.resource,s=xt(r.mimeType);if(s&&typeof r.blob=="string"&&r.blob)return De(n,{kind:"inline",data:r.blob,mimeType:s},r.name);const o=Tt(r.uri,r.mimeType,e);return o?De(n,o,r.name):null}if(t==="resource_link"){const r=Tt(n.uri,n.mimeType,e);return r?De(n,r,n.name):null}if(t==="file"){const r=Tt(n.url??n.uri,n.mimeType,e);return r?De(n,r,n.fileName):null}return null}function Zt(n,e){if(!Array.isArray(n))return n;let t=!1;const r=n.map(s=>{const o=sr(s,e);return o!==s&&(t=!0),o});return t?r:n}function sr(n,e){const t=eo(n,e);if(t)return t;if(!K(n)||n.type!=="tool_result")return n;const r=Zt(n.output,e),s=Zt(n.content,e);return r===n.output&&s===n.content?n:{...n,output:r,content:s}}function su(n,e,t){if(e!=="assistant")return n;let r=!1;const s=n.map(o=>{const i=sr(o,t);return i!==o&&(r=!0),i});return r?s:n}function to(n){return n.kind==="inline"?`inline:${n.mimeType}:${n.data}`:`${n.kind}:${n.url}`}function ou(n){const e=new Set;function t(r){let s=!1;const o=[];for(const i of r){if(K(i)&&i.type==="video"&&K(i.source)){const a=i.source,c=to(a);if(e.has(c)){s=!0;continue}e.add(c)}if(K(i)&&i.type==="tool_result"){const a=Array.isArray(i.output)?t(i.output):i.output,c=Array.isArray(i.content)?t(i.content):i.content;if(a!==i.output||c!==i.content){o.push({...i,output:a,content:c}),s=!0;continue}}o.push(i)}return s?o:r}return t(n)}const no=new Set(["text","code","tool_use","tool_result","thinking","image","audio","file","nav-link","proposal","plan"]);function ro(n){return{content:n.content,priority:n.priority,status:n.status}}function so(n){if(!rr(n))throw new Error(`Invalid plan block: required bounded 'entries' snapshot missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);return{type:"plan",...typeof n.id=="string"?{id:n.id}:{},entries:n.entries.map(ro)}}const Qt=/^image\/[a-z0-9][a-z0-9.+-]*$/i;function oo(n){const e=Object.prototype.hasOwnProperty.call(n,"data"),t=typeof n.data=="string",r=n.dataTruncated!==void 0,s=n.dataIsThumbnail!==void 0,o=n.dataBytes!==void 0;if(Object.prototype.hasOwnProperty.call(n,"attachmentId")){if(typeof n.attachmentId!="string"||n.attachmentId.trim().length===0||e||r||s||o||n.mimeType!==void 0&&(typeof n.mimeType!="string"||!Qt.test(n.mimeType)))throw new Error("Invalid image attachment reference (PROTOCOL §5.5)");return}if(typeof n.mimeType!="string"||!Qt.test(n.mimeType))throw new Error(`Invalid image block: required image 'mimeType'. Received: ${JSON.stringify(n)}`);if(e&&!t)throw new Error(`Invalid image block: present 'data' must be a string. Received: ${JSON.stringify(n)}`);if(!r){if(!t||s||o)throw new Error(`Invalid image block: full images require 'data' without slim flags. Received: ${JSON.stringify(n)}`);return}if(n.dataTruncated!==!0||!Number.isSafeInteger(n.dataBytes)||n.dataBytes<0||(t?n.dataIsThumbnail!==!0:s))throw new Error(`Invalid image block: malformed slim projection metadata. Received: ${JSON.stringify(n)}`)}function io(n){if(!n||typeof n!="object")throw new Error("Invalid block: must be an object");const e=Kr(n);if(e)return{type:"proposal",kind:e.kind,payload:e.payload,preview:e.preview,applyToolCallId:e.applyToolCallId,proposal:e,id:n.id,metadata:n.metadata};if(n.kind==="nav-link"&&typeof n.target=="string")return{type:"nav-link",kind:"nav-link",target:n.target,label:n.label,id:n.id,metadata:n.metadata};if((n.type==="proposal"||Jn(n.kind))&&n.preview){const t=n.proposal??{kind:n.kind,payload:n.payload??{},preview:n.preview,applyToolCallId:n.applyToolCallId};return{type:"proposal",kind:t.kind,payload:t.payload,preview:t.preview,applyToolCallId:t.applyToolCallId,proposal:t,id:n.id,metadata:n.metadata}}if(typeof n.type!="string")throw new Error(`Invalid ContentBlock: missing canonical 'type' field (PROTOCOL §7). Received: ${JSON.stringify(n)}`);if(!no.has(n.type))throw new Error(`Invalid ContentBlock: unknown 'type' "${n.type}" (PROTOCOL §7). Received: ${JSON.stringify(n)}`);return ao(n),co(n)}function ao(n){if(n.text===void 0&&typeof n.content=="string")throw new Error(`Invalid ContentBlock: legacy 'content' field is not part of PROTOCOL §7 (use 'text'). Received: ${JSON.stringify(n)}`);if(n.name===void 0&&typeof n.toolName=="string")throw new Error(`Invalid ContentBlock: legacy 'toolName' field is not part of PROTOCOL §7 (use 'name'). Received: ${JSON.stringify(n)}`);if(n.type==="tool_result"&&n.tool_use_id===void 0&&typeof n.toolCallId=="string")throw new Error(`Invalid ContentBlock: tool_result must use 'tool_use_id' (PROTOCOL §7). Received: ${JSON.stringify(n)}`);if(n.is_error===void 0&&n.isError!==void 0)throw new Error(`Invalid ContentBlock: legacy 'isError' field is not part of PROTOCOL §7 (use 'is_error'). Received: ${JSON.stringify(n)}`)}function co(n){switch(n.type){case"text":case"thinking":if(typeof n.text!="string")throw new Error(`Invalid ${n.type} block: required 'text' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"tool_use":if(typeof n.name!="string")throw new Error(`Invalid tool_use block: required 'name' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"tool_result":if(typeof n.tool_use_id!="string")throw new Error(`Invalid tool_result block: required 'tool_use_id' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"image":oo(n);break;case"audio":if(typeof n.data!="string"||typeof n.mimeType!="string")throw new Error(`Invalid ${n.type} block: required 'data'/'mimeType' fields missing. Received: ${JSON.stringify(n)}`);break;case"file":if(typeof n.attachmentId!="string"||n.attachmentId.length===0||typeof n.fileName!="string"||n.fileName.length===0)throw new Error(`Invalid file block: required 'attachmentId'/'fileName' fields missing (PROTOCOL §5.5). Received: ${JSON.stringify(n)}`);break;case"code":case"nav-link":case"proposal":break;case"plan":return so(n)}return{...n}}const uo=["user","assistant","tool","system","error"];function or(n){return typeof n=="number"&&Number.isInteger(n)&&n>0}function ir(n){if(!n||typeof n!="object")return null;const e=n;return or(e.position)?e:null}function lo(n){const{position:e,queueSize:t}=n;return or(t)&&t>=e?E.shared_mergeQueue_positionOfTotal_label({position:e,total:t}):E.shared_mergeQueue_position_label({position:e})}function fo(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)return null;const e=Math.max(1,Math.ceil(n/60));return e<60?E.shared_mergeQueue_etaMinutes_label({minutes:e}):E.shared_mergeQueue_etaHours_label({hours:Math.floor(e/60),minutes:e%60})}function iu(n){const e=ir(n);if(!e)return null;const t=fo(e.estimatedTimeToMerge),r=lo(e);return t?`${r} · ${t}`:r}const au=k.AGENT,cu=k.WORKSPACE,uu=k.FILE,lu=k.SYSTEM,du=k.WINDOW,fu=k.BROWSER_ACCESS,pu=k.QUIT_CONFIRMATION,gu=k.INVITE_CONSENT,yu=k.INVITE_PROGRESS,mu=k.INVITE_NOTICE,hu=k.AUGGIE,vu=k.OPENCODE,bu=k.CLAUDE_CODE,Su=k.CODEX,Iu=k.CORTEX,ku=k.PI,Au=k.DROID,Tu=k.GROK,wu=k.UNSLOTH,Eu=k.ANTIGRAVITY,Cu=k.PROVIDERS,Ru=k.SETTINGS,_u=k.FEATURE_CODES,Ou=k.USER_MCP,Mu=k.DEEP_LINK,Pu=k.PANEL_LAYOUT,po=k.LOG,Nu=k.USER_ACTIVITY,Lu=k.COLLABORATION_AUTH,ar=-32602,Bt="not-found";function xu(n){if(!n||typeof n!="object"||n.rpcCode!==ar)return!1;const e=n.data;return!e||typeof e!="object"?!1:e.code===Bt}function go(n){if(!n||typeof n!="object")return!1;const{message:e,rpcCode:t,code:r,data:s}=n,o=s&&typeof s=="object"?s.code:void 0;return r===Bt||o===Bt?!0:t===ar&&typeof e=="string"&&/not found/i.test(e)}function yo(n){if(n.notificationsMuted===!0||Zr(n)!=="topLevel"||n.lastMessageRole!=="assistant")return!1;const e=Xt(n.lastMessageId);return e===void 0?!1:e!==Xt(n.metadata?.lastSeenMessageId)}function Xt(n){return typeof n=="string"&&n.length>0?n:void 0}const mo=1e3;async function at(n,e,t){const r=e??{},s=await n(Object.keys(r).length>0?r:void 0);if(!s||typeof s!="object")return s;const o=s[t];let i=s.nextToken;if(typeof i!="string"||i.length===0)return s;const a=Array.isArray(o)?[...o]:[];for(let c=1;typeof i=="string"&&i.length>0&&!(c>=mo);c+=1){const l=await n({...r,nextToken:i}),d=l&&typeof l=="object"?l[t]:void 0;Array.isArray(d)&&a.push(...d),i=l&&typeof l=="object"?l.nextToken:void 0}return{...s,[t]:a,nextToken:null}}const ho="application/vnd.intent.secret-request+json";function vo(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.requestId=="string"&&e.requestId.length>0&&typeof e.agentId=="string"&&typeof e.name=="string"&&e.name.length>0&&typeof e.reason=="string"}function bo(n){if(!n||typeof n!="object")return!1;const e=n;if(e.type!=="resource")return!1;const t=e.resource;return typeof t=="object"&&t!==null&&t.mimeType===ho}function Bu(n){if(!bo(n))return null;const e=n.resource.text;if(typeof e!="string")return null;try{const t=JSON.parse(e);return vo(t)?t:null}catch{return null}}function cr(n){return!!n&&typeof n=="object"&&typeof n.name=="string"}function ur(n){return cr(n)&&typeof n.requestId=="string"}function So(n){const e=n?.outcome;return ur(n)&&(e==="provided"||e==="declined")}function Io(n){if(!n||typeof n!="object")return null;const e=n,t=r=>Array.isArray(e[r])?e[r]:[];return{secrets:t("secrets").filter(cr).map(({name:r})=>({name:r})),pendingRequests:t("pendingRequests").filter(ur).map(({requestId:r,name:s})=>({requestId:r,name:s})),answeredRequests:t("answeredRequests").filter(So).map(({requestId:r,name:s,outcome:o})=>({requestId:r,name:s,outcome:o}))}}const ko=ze("DeltaSubscription");function Ao(n,e){if(n!=="subscription.push"||!e||typeof e!="object")return null;const t=e,r=typeof t.subscriptionId=="string"?t.subscriptionId:void 0,s=typeof t.seq=="number"?t.seq:void 0;if(!r||s===void 0)return null;if(t.kind==="snapshot")return{subscriptionId:r,kind:"snapshot",seq:s,snapshot:Array.isArray(t.snapshot)?t.snapshot:[],...typeof t.nextToken=="string"&&t.nextToken.length>0?{nextToken:t.nextToken}:{}};if(t.kind==="delta"){const o=t.delta&&typeof t.delta=="object"?t.delta:{};return{subscriptionId:r,kind:"delta",seq:s,delta:{added:Array.isArray(o.added)?o.added:[],updated:Array.isArray(o.updated)?o.updated:[],removedIds:Array.isArray(o.removedIds)?o.removedIds.map(i=>String(i)):[]}}}return null}class en{constructor(e,t){y(this,"items",new Map);y(this,"removedSinceSnapshot",new Set);y(this,"changedSinceSnapshot",new Set);y(this,"expectedSeq",0);y(this,"seeded",!1);y(this,"epochValue",0);this.getId=e,this.normalize=t}reset(){this.items.clear(),this.removedSinceSnapshot.clear(),this.changedSinceSnapshot.clear(),this.expectedSeq=0,this.seeded=!1,this.epochValue+=1}get epoch(){return this.epochValue}applySnapshot(e,t){this.items.clear(),this.removedSinceSnapshot.clear(),this.changedSinceSnapshot.clear(),this.epochValue+=1;for(const r of t)this.upsert(r);this.expectedSeq=e+1,this.seeded=!0}applyDelta(e,t){if(!this.seeded||e!==this.expectedSeq)return!1;for(const r of[...t.added??[],...t.updated??[]])if(this.upsert(r),r&&typeof r=="object"){const s=this.getId(r);s&&this.changedSinceSnapshot.add(s)}for(const r of t.removedIds??[])this.items.delete(String(r)),this.removedSinceSnapshot.add(String(r));return this.expectedSeq=e+1,!0}fillFromPage(e){for(const t of e){if(!t||typeof t!="object")continue;const r=this.getId(t);!r||this.items.has(r)||this.removedSinceSnapshot.has(r)||this.upsert(t)}}completeRow(e){const t=this.getId(e);return!t||!this.items.has(t)||this.changedSinceSnapshot.has(t)?!1:(this.upsert(e),!0)}values(){return[...this.items.values()]}upsert(e){if(!e||typeof e!="object")return;const t=e,r=this.getId(t);if(!r)return;const s=this.normalize(t);s!==null&&this.items.set(r,s)}}const To=32,wo=1e3,tn=3,Eo=250,Co=1e3,Ro=3e4;function Ue(n){return Math.min(Co*2**n,Ro)}function Ye(n){const{channel:e,getId:t,normalize:r,handler:s}=n,o=e.dynamic,i={...e.params},a=(g,p)=>({subscriptionId:g,...typeof p.workspaceId=="string"?{workspaceId:p.workspaceId}:{}}),c=new en(t,r);let l=!1,d,m=0,I=0,w=0,S;const A=new Map,N=[],ie=g=>{N.push(g),N.length>To&&N.shift()},J=g=>{const p=N.filter(f=>f.subscriptionId===g);for(const f of p)N.splice(N.indexOf(f),1);for(const f of p)ue(f)},ae=()=>{if(!o)return c.values();const g=[];for(const p of A.values())g.push(...p.reconciler.values());return g},U=()=>{l||s(ae())},ce=()=>{if(o){for(const g of A.values())if(g.subscriptionId===void 0)return!0;return!1}return d===void 0},q=()=>{N.length>0&&!ce()&&(N.length=0)},j=()=>{if(o)return;S!==void 0&&(clearTimeout(S),S=void 0),m+=1;const g=m;u(e.subscribeMethod,i).then(p=>{const f=p?.subscriptionId;if(g!==m||l){f&&u(e.unsubscribeMethod,a(f,i)).catch(()=>{});return}if(!f){const h=Ue(I);I+=1,S=setTimeout(()=>{S=void 0,l||j()},h);return}d=f,I=0,J(f),q()}).catch(()=>{if(g!==m||l)return;const p=Ue(I);I+=1,S=setTimeout(()=>{S=void 0,l||j()},p)})},Z=()=>{if(o||(m+=1,S!==void 0&&(clearTimeout(S),S=void 0),!d))return;const g=d;d=void 0,u(e.unsubscribeMethod,a(g,i)).catch(()=>{})},B=(g,p)=>{if(!o)return;p.retryTimer!==void 0&&(clearTimeout(p.retryTimer),p.retryTimer=void 0),p.generation+=1;const f=p.generation;u(e.subscribeMethod,p.params).then(h=>{const v=h?.subscriptionId;if(l||A.get(g)!==p||f!==p.generation){v&&u(e.unsubscribeMethod,a(v,p.params)).catch(()=>{});return}if(!v){const C=Ue(p.retryAttempt);p.retryAttempt+=1,p.retryTimer=setTimeout(()=>{p.retryTimer=void 0,!l&&A.get(g)===p&&B(g,p)},C);return}p.subscriptionId=v,p.retryAttempt=0,J(v),q()}).catch(()=>{if(l||A.get(g)!==p||f!==p.generation)return;const h=Ue(p.retryAttempt);p.retryAttempt+=1,p.retryTimer=setTimeout(()=>{p.retryTimer=void 0,!l&&A.get(g)===p&&B(g,p)},h)})},V=g=>{g.generation+=1,g.retryTimer!==void 0&&(clearTimeout(g.retryTimer),g.retryTimer=void 0);const p=g.subscriptionId;g.subscriptionId=void 0,p&&u(e.unsubscribeMethod,a(p,g.params)).catch(()=>{})},z=(g,p)=>{p.awaitingResnapshot||(p.awaitingResnapshot=!0,p.seeded=!1,p.reconciler.reset(),V(p),B(g,p),U())},yt=g=>{if(l||!o)return;const p=new Set(g);let f=!1;for(const[h,v]of[...A])p.has(h)||(A.delete(h),V(v),f=!0);for(const h of p){if(A.has(h))continue;const v={generation:0,params:{...o.paramsForId(h)},reconciler:new en(t,r),seeded:!1,awaitingResnapshot:!1,retryAttempt:0,continuationFailures:0};A.set(h,v),B(h,v),f=!0}f&&U()},Je=()=>{c.reset(),Z(),j()},xe=(g,p,f,h)=>{const v=e.continuation;if(!v)return;const C=g.epoch,R=()=>l||g.epoch!==C;(async()=>{let de=f;for(let zt=0;de&&zt<wo;zt+=1){let fe;for(let pe=0;pe<tn;pe+=1){if(pe>0&&(await new Promise(Gr=>setTimeout(Gr,Eo*2**(pe-1))),R())||(fe=await u(v.method,{...v.params(p),nextToken:de}).catch(()=>{}),R()))return;if(fe)break}if(!fe){const pe=h.failures();ko.warn(`${v.method} continuation page failed ${tn} times; resubscribing ${e.subscribeMethod} for a fresh snapshot`),h.setFailures(pe+1),setTimeout(()=>{R()||h.resubscribe()},Ue(pe));return}const Ze=fe[v.key];g.fillFromPage(Array.isArray(Ze)?Ze:[]),U(),Ie(g,Array.isArray(Ze)?Ze:[]),de=typeof fe.nextToken=="string"&&fe.nextToken?fe.nextToken:null}h.setFailures(0)})()},Ie=(g,p)=>{const f=n.complete;if(!f)return;const h=g.epoch;for(const v of p){if(!v||typeof v!="object")continue;const C=f(v);C&&C.then(R=>{l||g.epoch!==h||g.completeRow(R)&&U()}).catch(()=>{})}},ue=g=>{if(!l){if(o){for(const[p,f]of A)if(f.subscriptionId===g.subscriptionId){g.kind==="snapshot"?(f.awaitingResnapshot=!1,f.seeded=!0,f.reconciler.applySnapshot(g.seq,g.snapshot??[]),U(),Ie(f.reconciler,g.snapshot??[]),g.nextToken&&xe(f.reconciler,f.params,g.nextToken,{failures:()=>f.continuationFailures,setFailures:h=>{f.continuationFailures=h},resubscribe:()=>{A.get(p)===f&&z(p,f)}})):f.awaitingResnapshot||(f.reconciler.applyDelta(g.seq,g.delta??{})?U():z(p,f));return}ce()&&ie(g);return}if(g.subscriptionId!==d){ce()&&ie(g);return}g.kind==="snapshot"?(c.applySnapshot(g.seq,g.snapshot??[]),U(),Ie(c,g.snapshot??[]),g.nextToken&&xe(c,i,g.nextToken,{failures:()=>w,setFailures:p=>{w=p},resubscribe:Je})):c.applyDelta(g.seq,g.delta??{})?U():Je()}},Be=se(g=>{const p=Ao(g.method,g.params);p&&ue(p)}),mt=oe(()=>{if(!l){m+=1,d=void 0,I=0,S!==void 0&&(clearTimeout(S),S=void 0),c.reset(),N.length=0;for(const[g,p]of A)p.generation+=1,p.subscriptionId=void 0,p.seeded=!1,p.awaitingResnapshot=!1,p.retryAttempt=0,p.retryTimer!==void 0&&(clearTimeout(p.retryTimer),p.retryTimer=void 0),p.reconciler.reset(),B(g,p);o||j()}}),le=o?o.subscribeIds(yt):void 0;return o||j(),()=>{l=!0,S!==void 0&&(clearTimeout(S),S=void 0),Be(),mt(),le?.(),Z();for(const g of A.values())V(g);A.clear()}}const _o=1e3;function Oo(n){if(!n||typeof n!="object")return;const e=n.nextToken;return typeof e=="string"&&e.length>0?e:void 0}async function Re(n,e,t){const r=[],s=new Set;let o;for(let i=0;i<_o;i++){const a=await n(o?{...e,nextToken:o}:e),c=a&&typeof a=="object"?a[t]:void 0;if(Array.isArray(c)&&r.push(...c),o=Oo(a),!o||s.has(o))break;s.add(o)}return r}function Mo(n){const e=new Map,t=[];for(const r of n){const s=r&&typeof r=="object"?r.threadId:void 0;if(typeof s!="string"||!s){t.push(r);continue}e.delete(s),e.set(s,r)}return[...e.values(),...t]}function lr(n,e){if(!n||typeof n!="object")return null;const t=n;return t.commentsTruncated!==!0||typeof t.threadId!="string"?null:e(t.threadId).then(r=>{if(!r||typeof r!="object")return t;const{rootComment:s,replies:o}=r;if(!s||typeof s!="object"||!Array.isArray(o))return t;const{commentsTruncated:i,...a}=t;return{...a,comments:[s,...o]}},()=>t)}async function Po(n,e,t){const r=Mo(await Re(n,e,"threads"));return Promise.all(r.map(s=>lr(s,t)??s))}const No=1e3;function nn(n){if(!n||typeof n!="object")return;const e="note"in n?n.note:n;return e&&typeof e=="object"?e:void 0}function rn(n){const e=n.nextContentOffset;return n.contentTruncated===!0&&typeof e=="number"&&e>0?e:void 0}async function Lo(n,e,t){const r=nn(t);if(!r)return{result:t,retry:!1};let s=rn(r);if(s===void 0)return{result:t,retry:!1};let o=typeof r.content=="string"?r.content:"";for(let w=1;w<No&&s!==void 0;w++){const S=nn(await n({...e,contentOffset:s}));if(S&&S.rev!==r.rev)return{result:t,retry:!0};if(!S||typeof S.content!="string"||S.contentOffset!==s)return{result:t,retry:!1};o+=S.content,s=rn(S)}if(s!==void 0||new TextEncoder().encode(o).length!==r.contentBytes)return{result:t,retry:!1};const{contentTruncated:i,contentBytes:a,contentOffset:c,nextContentOffset:l,...d}=r,m={...d,content:o};return{result:t&&typeof t=="object"&&"note"in t?{...t,note:m}:m,retry:!1}}async function dr(n,e){let t;for(let r=0;r<3;r++){t=await n(e);const{result:s,retry:o}=await Lo(n,e,t);if(!o)return s}return t}function Y(){const n=globalThis.crypto;return typeof n?.randomUUID=="function"?n.randomUUID():`idk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function _(n){const e=n instanceof Error?n.message:String(n);if(e==="Internal error"&&n&&typeof n=="object"){const t=n.data;if(typeof t=="string"&&t.length>0)return`${e}: ${t}`;if(t&&typeof t=="object"){const r=t.detail;if(typeof r=="string"&&r.length>0)return`${e}: ${r}`}}return e}const xo=-32005;function ct(n){if(!n||typeof n!="object"||n.rpcCode!==xo)return;const e=n.data;if(!(!e||typeof e!="object")&&e.code==="conflict")return{current:e.current}}function Bo(n){if(!n||typeof n!="object")return;const e=n.noteRev;return typeof e=="number"&&Number.isFinite(e)?e:void 0}function jo(n){if(!n||typeof n!="object")return;const{newContent:e,rev:t}=n;if(typeof e=="string")return typeof t=="number"&&Number.isFinite(t)?{newContent:e,rev:t}:{newContent:e}}async function b(n,e,t){try{const r=await(t!==void 0?u(n,e,t):u(n,e)),s=jo(r),o=Bo(r)??s?.rev;return{success:!0,...o!==void 0?{noteRev:o}:{},...s!==void 0?{newContent:s.newContent}:{}}}catch(r){const s=ct(r);return s?{success:!1,error:_(r),conflict:s}:Do(r)?{success:!1,error:_(r),contentBaseMismatch:!0}:{success:!1,error:_(r)}}}function Do(n){if(!n||typeof n!="object"||n.rpcCode!==-32602)return!1;const e=n.data;return!!e&&typeof e=="object"&&e.code==="content-base-mismatch"}function Uo(n){if(!n||typeof n!="object")return;const e=n,t=e.id;if(typeof t=="string"&&t.length>0)return t;for(const r of["task","note","entity"]){const s=e[r];if(s&&typeof s=="object"){const o=s.id;if(typeof o=="string"&&o.length>0)return o}}}async function jt(n,e,t){try{const r=await(t!==void 0?u(n,e,t):u(n,e)),s=Uo(r);return s!==void 0?{success:!0,id:s}:{success:!0}}catch(r){const s=ct(r);return s?{success:!1,error:_(r),conflict:s}:{success:!1,error:_(r)}}}const qo=2e3;let _e=null,we=null;function Fo(n,e){console.debug(`[live-support] workspace.list RPC (${n})${e?`: ${e}`:""}`)}function fr(n,e){if(we)return we;Fo(n,e);const t=at(r=>u("workspace.list",r),void 0,"workspaces").then(r=>{const o=(Array.isArray(r?.workspaces)?r.workspaces:[]).map(i=>String(i.id??i.workspaceId??"")).filter(i=>i.length>0);return _e={ids:o,fetchedAt:Date.now()},o});return we=t,t.catch(()=>{}).finally(()=>{we===t&&(we=null)}),t}async function $o(n){return P!==null?[...P]:_e!==null&&Date.now()-_e.fetchedAt<qo?[..._e.ids]:fr(n)}const Ho=["workspace:created","workspace:updated","workspace:deleted"],Wo=250;let P=null,Ee=0;const ut=new Map;let Go=0,wt=null,Et=null,ne=0,Dt=!1,Ce=!1,Oe;function Ht(){const n=P?[...P]:[];for(const e of ut.values())e(n)}function pr(n,e){Dt=!0;const t=ne;we!==null&&(Ce=!0),fr(n,e).then(r=>{ne!==t&&(Ee===0||(Ce=!0,P!==null))||(P=new Set(r),ne+=1,Ht())}).catch(()=>{if(P===null)for(const r of ut.values())r([])}).finally(()=>{Dt=!1,Ce&&(Ce=!1,Oe=setTimeout(()=>{Oe=void 0,Ee>0&&pr("follow-up")},Wo))})}function te(n,e){if(Oe===void 0){if(Dt){Ce=!0;return}pr(n,e)}}function sn(n){if(!P){ne+=1,te("defensive-resync","workspace event before seed settled");return}P.has(n)||(P.add(n),ne+=1,_e=null,Ht())}function on(n){if(!P){ne+=1,te("defensive-resync","workspace event before seed settled");return}P.has(n)&&(P.delete(n),ne+=1,_e=null,Ht())}function Vo(n){if(!n||typeof n!="object")return;const e=n.event;return e&&typeof e=="object"?e.data:n.data}function an(n){if(!n||typeof n!="object")return;const e=n;if(typeof e.workspaceId=="string"&&e.workspaceId.length>0)return e.workspaceId;const t=e.workspace;if(t&&typeof t=="object"){const r=t.id;if(typeof r=="string"&&r.length>0)return r}}function zo(n){if(!n||typeof n!="object")return!1;const e=n.workspace;return!e||typeof e!="object"?!1:e.archived===!0}function Ko(n,e){if(!Zo(n,e,Ho))return;const t=yr(e);if(t===void 0){te("defensive-resync","typeless event payload");return}const r=Vo(e);if(t==="workspace:created"){const s=an(r);if(!s){te("defensive-resync",`${t} without workspace id`);return}if(zo(r))return;sn(s);return}if(t==="workspace:deleted"){const s=an(r);if(!s){te("defensive-resync",`${t} without workspace id`);return}on(s);return}if(t==="workspace:updated"){const s=r&&typeof r=="object"?r:void 0,o=typeof s?.workspaceId=="string"?s.workspaceId:void 0,i=s?.changes;if(!o||!i||typeof i!="object"){te("defensive-resync",`${t} without workspaceId/changes`);return}const a=i.archived;a===!0?on(o):a===!1&&sn(o)}}function Wt(n){let e=!1;Ee+=1;const t=Go++;return ut.set(t,n),Ee===1?(wt=se(r=>Ko(r.method,r.params)),Et=oe(()=>te("reconnect")),te("seed")):P!==null&&n([...P]),()=>{e||(e=!0,ut.delete(t),Ee-=1,!(Ee>0)&&(wt?.(),wt=null,Et?.(),Et=null,Oe!==void 0&&(clearTimeout(Oe),Oe=void 0),Ce=!1,P=null,ne+=1))}}const gr=new Map;function He(n,e){n&&e&&(gr.set(n,e),lt.delete(n))}const Yo=5e3,lt=new Map,Ct=new Map;async function Jo(n){let e;try{e=await $o("resolver")}catch{return null}let t=!0;for(const r of e)try{const s=a=>u("note.list",a);let o;try{o=await Re(s,{workspaceId:r,projection:"slim",limit:ve},"notes")}catch(a){if(!Zn(a))throw a;o=await Re(s,{workspaceId:r,limit:ve},"notes")}let i=!1;for(const a of o){const c=String(a.id??"");c&&He(c,r),c===n&&(i=!0)}if(i)return r}catch{t=!1}return t&&e.length>0&<.set(n,Date.now()),null}async function re(n){const e=gr.get(n);if(e)return e;const t=lt.get(n);if(t!==void 0){if(Date.now()-t<Yo)return null;lt.delete(n)}const r=Ct.get(n);if(r)return r;const s=Jo(n).finally(()=>{Ct.delete(n)});return Ct.set(n,s),s}function yr(n){if(!n||typeof n!="object")return;const e=n.event;if(e&&typeof e=="object"){const r=e.type;if(typeof r=="string")return r}const t=n.type;return typeof t=="string"?t:void 0}function Zo(n,e,t){if(n!=="events.event")return!1;const r=yr(e);return r===void 0?!0:t.includes(r)}const mr=new Map,Qo=41943040,Xo=/^response for agent\.getConversation exceeds maximum outbound frame size: ([1-9][0-9]*) bytes > 41943040 bytes$/;function ei(n){if(!n||typeof n!="object")return!1;const e=n;if(e.name!=="BackendError"||typeof e.message!="string")return!1;const t=Xo.exec(e.message);return t!==null&&Number(t[1])>Qo}function ti(n,e){n&&e&&mr.set(n,e)}function Qe(n){const e=new Date().toISOString(),t=String(n.id??""),r=n.acpSessionId?String(n.acpSessionId):null,s=String(n.workspaceId??"");ti(t,s);const o={...n,id:bt(t),backendSessionId:r?bt(r):null,workspaceId:Qn(s),name:String(n.name??t),status:typeof n.status=="string"?n.status:Qr.Pending,messages:Array.isArray(n.messages)?n.messages:[],createdAt:String(n.createdAt??e),updatedAt:String(n.updatedAt??e)};return typeof n.retiredAt=="string"&&n.retiredAt.length>0&&(o.retiredAt=n.retiredAt),typeof n.parentAgentId=="string"&&n.parentAgentId.length>0&&(o.parentAgentId=bt(n.parentAgentId)),o.usingEarlierProfileSettings=n.usingEarlierProfileSettings===!0?!0:void 0,o.providerReplacementRequired=ni(n.providerReplacementRequired),typeof n.isBackground=="boolean"&&(o.metadata={...o.metadata,isBackground:n.isBackground},o.agentMetadata&&(o.agentMetadata={...o.agentMetadata,isBackground:n.isBackground})),o.hasUnread=yo(o),o}function ni(n){if(!n||typeof n!="object")return;const{providerRef:e,reason:t}=n;if(!(typeof e!="string"||e.length===0)&&!(t!=="profile-missing"&&t!=="provider-disabled"))return{providerRef:e,reason:t}}function ri(n){if(!n||typeof n!="object")return;const{topLevel:e,delegated:t,background:r}=n;if(!(typeof e!="number"||typeof t!="number"||typeof r!="number"))return{topLevel:e,delegated:t,background:r}}function si(n){if(!n||typeof n!="object")return;const{running:e,byParent:t,orphaned:r}=n;if(typeof e!="number"||!t||typeof t!="object"||Array.isArray(t))return;const s={};for(const[i,a]of Object.entries(t)){const c=cn(a);if(!c)return;s[i]=c}if(r===void 0)return{running:e,byParent:s};const o=cn(r);if(o)return{running:e,byParent:s,orphaned:o}}function cn(n){if(!n||typeof n!="object")return;const{total:e,running:t}=n;if(!(typeof e!="number"||typeof t!="number"))return{total:e,running:t}}async function un(n,e){try{return await u(n,e),{ok:!0}}catch(t){const r=t?.data,s=!!r&&typeof r=="object"&&r.code==="secret-request-unknown",o=t instanceof Error?t.message:String(t);return{ok:!1,expired:s,error:o}}}class oi{constructor(){y(this,"retirementCapabilityRequest",null)}supportsRetirement(e=0){if(this.retirementCapabilityRequest?.generation!==e){const t=u("client.hello",{}).then(r=>r?.server?.capabilities?.agentRetire===1).catch(()=>!1).finally(()=>{this.retirementCapabilityRequest?.promise===t&&(this.retirementCapabilityRequest=null)});this.retirementCapabilityRequest={generation:e,promise:t}}return this.retirementCapabilityRequest.promise}async list(e,t){const{agents:r}=await this.listWithMeta(e,t);return r}async listWithMeta(e,t){const r={workspaceId:e};t?.retiredOnly&&(r.retiredOnly=!0),t?.scope&&t.scope!=="all"&&(r.scope=t.scope),t?.parentAgentId&&(r.parentAgentId=t.parentAgentId),t?.orphanedOnly&&(r.orphanedOnly=!0);const s=await at(c=>u("agent.list",c),r,"agents"),o=Array.isArray(s?.agents)?s.agents:[],i=ri(s?.scopeCounts),a=si(s?.delegatedCounts);return{agents:o.map(c=>Qe(c)),retiredCount:typeof s?.retiredCount=="number"?s.retiredCount:0,...i?{scopeCounts:i}:{},...a?{delegatedCounts:a}:{}}}async get(e,t){const r=await u("agent.get",{agentId:e,...t!==void 0?{workspaceId:t}:{}}),s=r&&typeof r=="object"&&"agent"in r?r.agent:r;return!s||typeof s!="object"?null:Qe(s)}async getConversation(e,t=Yr,r,s,o,i){let a=t,c;for(;;){const d={agentId:e,...i!==void 0?{workspaceId:i}:{},limit:a,projection:"slim"};r!==void 0&&(d.nextToken=r),s!==void 0&&(d.aroundMessageId=s),o!==void 0&&(d.aroundIndex=o);try{c=await u("agent.getConversation",d);break}catch(m){if(!ei(m)||!Number.isFinite(a)||a<=1)throw m;a=Math.max(1,Math.floor(a/2))}}return!c||typeof c!="object"?{messages:[],truncated:!1,totalMessages:0,nextToken:null,prevToken:null}:{messages:Array.isArray(c.messages)?c.messages:[],truncated:!!c.truncated,totalMessages:typeof c.totalMessages=="number"?c.totalMessages:0,nextToken:typeof c.nextToken=="string"?c.nextToken:null,prevToken:typeof c.prevToken=="string"?c.prevToken:null}}async getMessageBlock(e,t,r,s){const i=(await u("agent.getMessageBlock",{agentId:e,messageId:t,blockId:r,...s!==void 0?{workspaceId:s}:{}}))?.block;if(!Jt(i))throw new Error(`agent.getMessageBlock returned no block for message ${t} block ${r}`);return i}async getMessageBlockPage(e,t,r,s){const o=await u("agent.getMessageBlock",{agentId:e,messageId:t,blockId:r,...s!==void 0?{workspaceId:s}:{}}),i=o?.block;if(!Jt(i))throw new Error(`agent.getMessageBlock returned no block for message ${t} block ${r}`);const a=c=>typeof c=="number"&&Number.isSafeInteger(c)&&c>=0?c:null;return{block:i,truncated:o.truncated===!0,field:typeof o.field=="string"?o.field:null,encoding:o.encoding==="text"||o.encoding==="json"?o.encoding:null,totalBytes:a(o.totalBytes),nextOffset:a(o.nextOffset)}}async listUserMessages(e,t,r,s){const o={agentId:e,...r!==void 0?{workspaceId:r}:{}};t!==void 0&&(o.previewChars=t),s?.limit!==void 0&&(o.limit=s.limit),s?.nextToken!==void 0&&(o.nextToken=s.nextToken);try{const i=await u("agent.listUserMessages",o),c=(Array.isArray(i?.items)?i.items:[]).filter(m=>!!m&&typeof m=="object").map(m=>{const I={id:String(m.id??""),preview:String(m.preview??""),createdAt:String(m.createdAt??"")};return m.metadata&&typeof m.metadata=="object"&&(I.metadata=m.metadata),I}),l=typeof i?.total=="number"?i.total:c.length,d=i?.nextToken;return typeof d=="string"||d===null?{ok:!0,items:c,total:l,nextToken:d}:{ok:!0,items:c,total:l}}catch(i){return{ok:!1,unsupported:!!i&&typeof i=="object"&&"rpcCode"in i&&i.rpcCode===-32601,error:i instanceof Error?i.message:String(i)}}}async create(e){const t={workspaceId:e.workspaceId,idempotencyKey:Y()};e.placement!==void 0&&(t.placement=e.placement),e.model!==void 0&&(t.model=e.model),e.reasoningEffort!==void 0&&(t.reasoningEffort=e.reasoningEffort),e.rememberSpecialist!==void 0&&(t.rememberSpecialist=e.rememberSpecialist),e.specialist!==void 0&&(e.specialist!==null||e.rememberSpecialist)&&(t.specialistId=e.specialist),e.prompt!==void 0&&(t.behaviorPrompt=e.prompt),e.name!==void 0&&(t.name=e.name),e.nameExplicitlySet!==void 0&&(t.nameExplicitlySet=e.nameExplicitlySet),e.provider!==void 0&&(t.provider=e.provider),e.agentType!==void 0&&(t.agentType=e.agentType),e.metadata!==void 0&&(t.metadata=e.metadata),e.workspacePath!==void 0&&(t.workspacePath=e.workspacePath),e.workspaceContext!==void 0&&(t.workspaceContext=e.workspaceContext);const r=await u("agent.create",t),s=r&&typeof r=="object"&&"agent"in r?r.agent:r;if(!s||typeof s!="object")throw new Error("agent.create returned no agent object");const o=s.id;if(typeof o!="string"||o.length===0)throw new Error("agent.create response missing daemon-assigned agent.id");return Qe(s)}async send(e,t,r){if(r??=await this.resolveAgentWorkspaceId(e)??void 0,!r)return{success:!1,error:`Unknown workspace for agent ${e}`};const s=Y();return b("agent.sendMessage",{agentId:e,content:t,workspaceId:r,messageId:s})}async editAndRegenerate(e){const t={agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId,content:e.content};return e.model!==void 0&&(t.model=e.model),e.imageBlocks!==void 0&&(t.imageBlocks=e.imageBlocks),e.fileBlocks!==void 0&&(t.fileBlocks=e.fileBlocks),b("agent.editAndRegenerate",t)}async queue(e,t,r){try{const s={agentId:e,content:t,...r?.workspaceId!==void 0?{workspaceId:r.workspaceId}:{}};r?.messageId!==void 0&&(s.messageId=r.messageId),r?.imageBlocks!==void 0&&(s.imageBlocks=r.imageBlocks),r?.fileBlocks!==void 0&&(s.fileBlocks=r.fileBlocks),r?.messageMetadata!==void 0&&(s.messageMetadata=r.messageMetadata);const o=await u("agent.queueMessage",s);if(o?.success===!1)return{success:!1,error:o.error};const i=o?.queuedMessage,a=typeof o?.turnId=="string"?o.turnId:typeof i?.turnId=="string"?i.turnId:void 0,c={success:!0};return i&&(c.queuedMessage=i),a!==void 0&&(c.turnId=a),c}catch(s){const o=s&&typeof s=="object"?s.rpcCode:void 0,i=o===-32600||o===-32601||o===-32602||Yt(s);if(r?.messageId!==void 0&&!i)throw s;return{success:!1,error:s instanceof Error?s.message:String(s)}}}async editQueued(e,t,r,s,o){try{const i={agentId:e,messageId:t,content:r,...o!==void 0?{workspaceId:o}:{}};s!==void 0&&(i.editing=s);const c=(await u("agent.editQueuedMessage",i))?.queuedMessage;return c?{success:!0,queuedMessage:c}:{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async sendQueuedNow(e){try{const t=await u("agent.sendQueuedMessageNow",{agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId});return{success:t.success,queued:t.queued,...t.quarantined!==void 0?{quarantined:t.quarantined}:{},...t.queuedMessage?{queuedMessage:t.queuedMessage}:{},...!t.queued&&t.turnId?{turnId:t.turnId}:{}}}catch(t){return{success:!1,error:_(t)}}}async sendQueuedMessagesNow(e){try{const r=(await u("client.hello",{}))?.server?.protocolVersion,s=typeof r=="string"?/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(r):null;if(!s||Number(s[1])<13||Number(s[1])===13&&Number(s[2])<1)return{success:!1,error:E.chat_queuedMessages_sendAllUnsupported_error()};const o=await u("agent.sendQueuedMessagesNow",{agentId:e.agentId,workspaceId:e.workspaceId,messageIds:e.messageIds});return{success:o.success,queued:o.queued,messageIds:o.messageIds,...o.quarantined!==void 0?{quarantined:o.quarantined}:{},...!o.queued&&!o.quarantined&&o.turnId?{turnId:o.turnId}:{}}}catch(t){return{success:!1,error:_(t)}}}async getQueue(e,t){const r=await at(s=>u("agent.getQueue",s),{agentId:e,...t!==void 0?{workspaceId:t}:{}},"queue");return Array.isArray(r?.queue)?r.queue:[]}async removeQueued(e,t,r){return b("agent.removeQueuedMessage",{agentId:e,messageId:t,...r!==void 0?{workspaceId:r}:{}})}async stop(e,t){return b("agent.stop",{agentId:e,...t!==void 0?{workspaceId:t}:{}})}async cancelSubscriptions(e){const t={agentId:e.agentId,workspaceId:e.workspaceId};return e.subscriptionId!==void 0&&(t.subscriptionId=e.subscriptionId),e.groupId!==void 0&&(t.groupId=e.groupId),b("agent.cancelSubscriptions",t)}async dismissQuestions(e){return b("agent.dismissQuestions",{agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId})}async secretList(e){try{return Io(await u("secret.list",{workspaceId:e.workspaceId,agentId:e.agentId}))}catch{return null}}async secretProvide(e){return un("secret.provide",{workspaceId:e.workspaceId,requestId:e.requestId,value:e.value})}async secretDismiss(e){return un("secret.dismiss",{workspaceId:e.workspaceId,requestId:e.requestId})}async resolveProposal(e){const t={workspaceId:e.workspaceId,agentId:e.agentId,proposalId:e.proposalId,outcome:e.outcome};return e.detail!==void 0&&(t.detail=e.detail),b("agent.resolveProposal",t)}async markSeen(e){return b("agent.markSeen",{workspaceId:e.workspaceId,agentId:e.agentId,messageId:e.messageId})}async setReasoningEffort(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{reasoningEffort:e.reasoningEffort}})}async setNotificationsMuted(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{notificationsMuted:e.notificationsMuted}})}async setPinned(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{pinned:e.pinned}})}async setBackground(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{isBackground:e.isBackground}})}async updateSpecialist(e){const t={specialist:e.specialist};e.rememberSpecialist!==void 0&&(t.rememberSpecialist=e.rememberSpecialist),e.model!==void 0&&(t.model=e.model),e.systemPrompt!==void 0&&(t.systemPrompt=e.systemPrompt);const r={agentId:e.agentId,workspaceId:e.workspaceId,changes:t};try{return await u("agent.update",r),{success:!0}}catch(s){if(e.rememberSpecialist!==void 0&&s?.rpcCode===-32602&&_(s).includes("agent.update: unknown field `rememberSpecialist` in `changes`")){const o={...t};return delete o.rememberSpecialist,b("agent.update",{...r,changes:o})}return{success:!1,error:_(s)}}}async rename(e,t,r,s){const o={agentId:e,name:t,...r!==void 0?{workspaceId:r}:{}};return s?.skipIfExplicitlySet===!0&&(o.skipIfExplicitlySet=!0),b("agent.rename",o)}async delete(e,t,r){const s=r?.undoDelayMs;try{const o=await u("agent.delete",{agentId:e,...t!==void 0?{workspaceId:t}:{},...s&&s>0?{undoDelayMs:s}:{}}),i=o?.scheduled===!0,a=typeof o?.deleteAt=="string"?o.deleteAt:void 0;return i&&a?{success:!0,scheduled:!0,deleteAt:a}:{success:!0}}catch(o){return Yt(o)?{success:!1,forbidden:!0,error:_(o)}:{success:!1,error:_(o)}}}async cancelDelete(e,t){try{return{success:!0,cancelled:(await u("agent.cancelDelete",{agentId:e,...t!==void 0?{workspaceId:t}:{}}))?.cancelled===!0}}catch(r){return{success:!1,error:_(r)}}}async retire(e,t){const r={agentId:e};t!==void 0&&(r.workspaceId=t);try{return await u("agent.retire",r)}catch(s){return{success:!1,error:_(s)}}}async restore(e,t){const r={agentId:e,...t!==void 0?{workspaceId:t}:{}};return b("agent.restore",r)}async retry(e,t){try{const r=await u("agent.retry",{agentId:e,workspaceId:t});if(r?.ok!==!0)return{ok:!1,error:"Agent not in error status"};const s=typeof r.redriven=="boolean"?r.redriven:void 0,o=typeof r.turnId=="string"?r.turnId:void 0;return o!==void 0?{ok:!0,redriven:s,turnId:o}:{ok:!0,redriven:s}}catch(r){const s=r instanceof Error?r.message:"Failed to retry agent spawn";return go(r)?{ok:!1,notFound:!0,error:s}:{ok:!1,error:s}}}async respondPermission(e,t,r){try{const s=await u("agent.respondPermission",{requestId:e,outcome:t,...r!==void 0?{workspaceId:r}:{}}),o=typeof s?.resolved=="boolean"?s.resolved:void 0;return o!==void 0?{success:!0,resolved:o}:{success:!0}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async listInterrupted(){try{const e=await u("agent.listInterrupted",{});return(Array.isArray(e?.agents)?e.agents:[]).map(r=>{const s=r;return{agentId:String(s.agentId??""),workspaceId:String(s.workspaceId??""),workspaceName:String(s.workspaceName??""),agentName:String(s.agentName??""),prevStatus:String(s.prevStatus??""),interruptedAt:String(s.interruptedAt??"")}})}catch(e){if(e&&typeof e=="object"&&"rpcCode"in e&&e.rpcCode===-32601)return[];throw e}}async resolveInterrupted(e){try{const t=await u("agent.resolveInterrupted",e);return{resumed:Array.isArray(t?.resumed)?t.resumed:[],abandoned:Array.isArray(t?.abandoned)?t.abandoned:[],failed:Array.isArray(t?.failed)?t.failed.map(r=>{const s=r;return{agentId:String(s.agentId??""),error:String(s.error??"")}}):[]}}catch(t){throw t}}async resolveAgentWorkspaceId(e){const t=mr.get(e);if(t)return t;const r=await this.get(e);if(!r)return null;const s=String(r.workspaceId??"");return s.length>0?s:null}subscribe(e){return Ye({channel:{subscribeMethod:"agent.subscribe",unsubscribeMethod:"events.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t})},continuation:{method:"agent.list",key:"agents",params:t=>({workspaceId:t.workspaceId})}},getId:t=>String(t.id??""),normalize:t=>Qe(t),handler:e})}}function ii(n){return`browser-recent-${n}`}function ai(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.url=="string"&&typeof e.lastVisited=="string"&&(e.title===void 0||typeof e.title=="string")&&(e.favicon===void 0||typeof e.favicon=="string")}function ju(n){const e=n?.target;return G(e)&&typeof e.clientId=="string"&&e.clientId.length>0&&typeof e.via=="string"?{clientId:e.clientId,via:e.via}:void 0}function G(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ln(n){return G(n)&&n.ok===!0}function ci(n){return G(n)&&typeof n.action=="string"&&typeof n.success=="boolean"&&(n.error===void 0||typeof n.error=="string")}function ui(n){return G(n)&&typeof n.clientId=="string"&&G(n.capabilities)&&typeof n.connections=="number"&&Array.isArray(n.transports)&&typeof n.connectedAt=="string"}function Du(n){return G(n)&&typeof n.clientId=="string"&&G(n.capabilities)}function li(n){if(!G(n))return!1;if(n.source==="workspace"){if(typeof n.clientId!="string")return!1}else if(n.source==="default"){if(n.clientId!==void 0)return!1}else return!1;const e=n.resolved;return e===null||G(e)&&typeof e.clientId=="string"}function hr(n){return G(n)&&typeof n.tabId=="string"&&typeof n.workspaceId=="string"&&typeof n.hostClientId=="string"&&typeof n.url=="string"&&(n.visibility==="visible"||n.visibility==="hidden")&&typeof n.createdAt=="string"&&typeof n.updatedAt=="string"}function di(n){return hr(n)&&typeof n.hostConnected=="boolean"}function fi(n){const e=Xr.getJSON(ii(n));return Array.isArray(e)?e.filter(t=>ai(t)).slice(0,es):[]}class pi{async recentUrls(e){return fi(e)}subscribe(e){return e([]),()=>{}}async listTabs(e){const t=await u("browser.listTabs",{workspaceId:e});if(!Array.isArray(t?.tabs)||!t.tabs.every(di))throw new Error("Invalid browser.listTabs response shape");return t.tabs}async upsertTab(e,t){const r=await u("browser.upsertTab",{workspaceId:e,tab:t});if(!hr(r?.tab))throw new Error("Invalid browser.upsertTab response shape");return r.tab}async removeTab(e){const t=await u("browser.removeTab",{tabId:e});if(!ln(t))throw new Error("Invalid browser.removeTab response shape");return t}async syncTabs(e){const t=await u("browser.syncTabs",{tabs:e});if(!Array.isArray(t?.drop)||!t.drop.every(r=>typeof r=="string"))throw new Error("Invalid browser.syncTabs response shape");return{drop:t.drop}}async navigateTab(e,t){const r=await u("browser.navigateTab",{tabId:e,url:t});if(!ci(r))throw new Error("Invalid browser.navigateTab response shape");return r}async closeTab(e,t){const r=await u("browser.closeTab",{tabId:e,...t?.force===void 0?{}:{force:t.force}});if(!ln(r))throw new Error("Invalid browser.closeTab response shape");return r}}var vr=(n=>(n.AGENT="agent",n))(vr||{}),ee,D,Ge,W,ft,pt,gt,Pe,Ve,Ut;class gi{constructor(){H(this,Ve);H(this,ee);H(this,D,xs(Bs([])));H(this,Ge,1e3);H(this,W,[]);H(this,ft,100);H(this,pt,5e3);H(this,gt,null);H(this,Pe,!1);ke(this,ee,new js("Renderer",{enableConsole:!0})),typeof window<"u"&&window.electronAPI&&ke(this,Pe,!0),T(this,Pe)&&ke(this,gt,setInterval(()=>{vt(this,Ve,Ut).call(this)},T(this,pt)))}get logs(){return ge(T(this,D))}addToStore(e){kt(T(this,D),[...ge(T(this,D)),e],!0),ge(T(this,D)).length>T(this,Ge)&&kt(T(this,D),ge(T(this,D)).slice(-T(this,Ge)),!0)}addToPendingLogs(e){T(this,W).push(e),T(this,W).length>=T(this,ft)&&vt(this,Ve,Ut).call(this)}error(e,t,r,s){const o={timestamp:new Date().toISOString(),level:"ERROR",category:e,message:t,context:s,error:r instanceof Error?{name:r.name,message:r.message,stack:r.stack}:void 0};T(this,ee).error(t,r instanceof Error?r:void 0,s),this.addToStore(o),this.addToPendingLogs(o)}warn(e,t,r){const s={timestamp:new Date().toISOString(),level:"WARN",category:e,message:t,context:r};T(this,ee).warn(t,r),this.addToStore(s),this.addToPendingLogs(s)}info(e,t,r){const s={timestamp:new Date().toISOString(),level:"INFO",category:e,message:t,context:r};T(this,ee).info(t,r),this.addToStore(s),this.addToPendingLogs(s)}debug(e,t,r){const s={timestamp:new Date().toISOString(),level:"DEBUG",category:e,message:t,context:r};T(this,ee).debug(t,r),this.addToStore(s),this.addToPendingLogs(s)}verbose(e,t,r){this.debug(e,t,r)}getLogs(){return[...ge(T(this,D))]}getLogsByCategory(e){return ge(T(this,D)).filter(t=>t.category===e)}getLogsByLevel(e){return ge(T(this,D)).filter(t=>t.level===e.toUpperCase())}clearLogs(){kt(T(this,D),[],!0)}}ee=new WeakMap,D=new WeakMap,Ge=new WeakMap,W=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,Pe=new WeakMap,Ve=new WeakSet,Ut=async function(){if(T(this,W).length===0||!T(this,Pe))return;const e=[...T(this,W)];ke(this,W,[]);try{await ye(po.PERSIST_RENDERER_LOGS,e)}catch(t){console.error("[RendererLogger] Failed to persist logs via IPC:",t),ke(this,W,[...e,...T(this,W)])}};const yi=new gi,mi=2048,hi=256;let dn=0,fn=0,pn=0;const vi=192,bi=64;function Si(n){if(n.stage==="render"&&(n.event.includes("not-committed")||n.terminalErrorVisible===!0||n.callbackResult==="ignored"||n.callbackResult==="threw"))return"render";if(n.callbackResult==="threw"||n.storeStreamState==="error"||n.event.includes("failed")||n.event.includes("error")||n.pushKind==="snapshot"&&(n.callbackResult==="ignored"||n.callbackResult==="buffered")&&n.event.startsWith("snapshot-"))return"failure"}function gn(n){if(!n)return;let e=0xcbf29ce484222325n;for(const t of new TextEncoder().encode(n))e^=BigInt(t),e=BigInt.asUintN(64,e*0x100000001b3n);return e.toString(16).padStart(16,"0")}function L(n){const e=mi-hi;if(dn<e)dn+=1;else{const t=Si(n);if(t==="failure"&&fn<vi)fn+=1;else if(t==="render"&&pn<bi)pn+=1;else return}yi.info(vr.AGENT,"stream-lifecycle",n)}const Ii={messages:[],truncated:!1,totalMessages:0},yn=5e3,mn=1e3,ki=3e4,Ai=256,Ti=new Set(uo),wi=new Set(["text","code","tool_use","tool_result","thinking","image","audio","file","nav-link","proposal","plan"]);function $(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function hn(n){if(!$(n))return null;const{target:e,received:t,complete:r}=n;return typeof e!="number"||!Number.isSafeInteger(e)||e<1||e>200||typeof t!="number"||!Number.isSafeInteger(t)||t<0||t>e||typeof r!="boolean"?null:{target:e,received:t,complete:r}}function br(n){if(!$(n))return null;try{return io(n)}catch{return typeof n.type!="string"||n.type.length===0||wi.has(n.type)?null:{...n}}}function Sr(n,e){if(!$(n)||typeof n.id!="string"||n.id.length===0||typeof n.role!="string"||!Ti.has(n.role)||typeof n.timestamp!="string"||n.timestamp.length===0)return null;const t=n.agentId===void 0?e:n.agentId;if(t!==void 0&&(typeof t!="string"||t.length===0)||e!==void 0&&t!==void 0&&t!==e||n.seq!==void 0&&(typeof n.seq!="number"||!Number.isSafeInteger(n.seq)||n.seq<0))return null;const r=Array.isArray(n.contentBlocks)?n.contentBlocks.map(br).filter(s=>s!==null):[];return{...n,...t===void 0?{}:{agentId:t},contentBlocks:r}}function Ir(n,e){if(!$(n))return Ii;const t=n.agentId===void 0?e:n.agentId,r=t===void 0||typeof t=="string"&&t.length>0&&(e===void 0||t===e);return{messages:Array.isArray(n.messages)?r?n.messages.map(o=>Sr(o,t)).filter(o=>o!==null):[]:[],...n.nextToken===null||typeof n.nextToken=="string"?{nextToken:n.nextToken}:{},truncated:!!n.truncated,totalMessages:typeof n.totalMessages=="number"?n.totalMessages:0}}function Ei(n){if(!n||typeof n!="object")return;const e=n.resumed;return typeof e=="boolean"?e:void 0}function Ci(n,e){if(n!=="subscription.push"||!e||typeof e!="object")return null;const t=e,r=typeof t.subscriptionId=="string"?t.subscriptionId:null,s=typeof t.seq=="number"?t.seq:null;if(!r||s===null||!Number.isSafeInteger(s)||s<0)return null;if(t.kind==="snapshot")return{subscriptionId:r,kind:"snapshot",seq:s,snapshot:t.snapshot};if(t.kind==="history")return{subscriptionId:r,kind:"history",seq:s,history:t.history};if(t.kind==="delta"){const o=t.delta&&typeof t.delta=="object"?t.delta:{};return{subscriptionId:r,kind:"delta",seq:s,delta:{added:Array.isArray(o.added)?o.added:[],updated:Array.isArray(o.updated)?o.updated:[],removedIds:Array.isArray(o.removedIds)?o.removedIds.map(i=>String(i)):[]}}}return null}function Ri(n){if(n.kind==="snapshot"){const t=Ir(n.snapshot).messages;for(let r=t.length-1;r>=0;r-=1){const s=t[r];if(s.role==="assistant")return gn(s.id)}return}const e=[...n.delta?.updated??[],...n.delta?.added??[]];for(let t=e.length-1;t>=0;t-=1){const r=kr(e[t],!0);if(r&&(r.role===void 0||r.role==="assistant"))return gn(r.messageId)}}function kr(n,e){if(!$(n))return null;const t=n,r=typeof t.messageId=="string"?t.messageId:null;if(!r||!$(t.block)||typeof t.block.id!="string")return null;const s=e&&(t.block.type==="text"||t.block.type==="thinking")&&typeof t.block.textDelta=="string",o=br(s?{text:t.block.textDelta,...t.block}:t.block);return o?(s&&!("text"in t.block)&&delete o.text,{messageId:r,...typeof t.role=="string"?{role:t.role}:{},block:o,...typeof t.messageSeq=="number"?{messageSeq:t.messageSeq}:{},...typeof t.timestamp=="string"?{timestamp:t.timestamp}:{},...t.streamingComplete===!0?{streamingComplete:!0}:{},...t.metadata&&typeof t.metadata=="object"&&!Array.isArray(t.metadata)?{metadata:t.metadata}:{},...typeof t.appMessageId=="string"&&t.appMessageId.length>0?{appMessageId:t.appMessageId}:{},...t.author===null||t.author&&typeof t.author=="object"&&!Array.isArray(t.author)?{author:t.author}:{}}):null}function _i(n,e){const t=e.name??e.toolName??"";if(e.type!=="tool_use"||n.type!=="tool_use"||!e.toolCallId||e.toolCallId!==n.toolCallId||t.length>0)return e;const r=n.metadata?.toolKind;return{...e,name:n.name??n.toolName??"",input:n.input,metadata:{...e.metadata??{},...r!==void 0?{toolKind:r}:{}}}}function Oi(n,e){return n.type!=="text"||!e?.media?n:{...n,media:{...e.media,...n.media??{}}}}function Mi(n){const e=JSON.stringify(n)??"";let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}class Pi{constructor(e){y(this,"messages",[]);y(this,"truncated",!1);y(this,"nextToken");y(this,"totalMessages",0);y(this,"streaming",!1);y(this,"expectedSeq",0);y(this,"seeded",!1);y(this,"snapshotFingerprint",0);y(this,"incremental",!1);y(this,"initialHistory");y(this,"initialMessageIds",new Set);this.expectedAgentId=e}reset(){this.messages=[],this.truncated=!1,this.nextToken=void 0,this.totalMessages=0,this.streaming=!1,this.expectedSeq=0,this.seeded=!1,this.snapshotFingerprint=0,this.incremental=!1,this.initialHistory=void 0,this.initialMessageIds.clear()}applySnapshot(e,t){const r=$(t)?t:{},s=r.historyDelivery==="progressive"?hn(r.initialHistory):void 0,o=Ir(t,this.expectedAgentId),i=new Set(o.messages.map(l=>l.id));if(s===null||s&&(s.received!==i.size||!s.complete&&o.messages.length>1))return"invalid";const a=Mi(t);if(this.seeded&&a===this.snapshotFingerprint&&(e+1===this.expectedSeq||e===0&&s!==void 0&&e<this.expectedSeq))return!1;this.snapshotFingerprint=a,this.messages=o.messages,this.truncated=o.truncated,this.nextToken=o.nextToken,this.totalMessages=o.totalMessages;const c=t&&typeof t=="object"?t:{};return this.streaming=this.messages.some(l=>l.isStreaming===!0)||c.isResponding===!0||c.turnInFlight===!0,this.incremental=c.deltaEncoding==="incremental",this.initialHistory=s,this.initialMessageIds=i,this.initialHistory?.complete===!1&&(this.nextToken=void 0),this.expectedSeq=e+1,this.seeded=!0,!0}applyDelta(e,t){if(!this.seeded||e>this.expectedSeq)return"gap";if(e<this.expectedSeq)return"stale";let r=!1,s=!1;for(const o of[...t.added,...t.updated]){const i=kr(o,this.incremental);i&&(this.upsertBlock(i),(i.role===void 0||i.role==="assistant")&&(s=!0,i.streamingComplete&&(r=!0)))}if(t.removedIds.length>0){const o=new Set(t.removedIds);this.messages=this.messages.map(i=>{const a=i.contentBlocks;return!a||!a.some(c=>c.id!==void 0&&o.has(c.id))?i:{...i,contentBlocks:a.filter(c=>c.id===void 0||!o.has(c.id))}})}return r?this.streaming=this.messages.some(o=>o.role==="assistant"&&o.isStreaming===!0):s&&(this.streaming=!0),this.expectedSeq=e+1,"applied"}applyHistory(e,t){if(!this.seeded||e>this.expectedSeq)return"gap";if(e<this.expectedSeq)return"stale";if(!this.initialHistory||this.initialHistory.complete||!$(t))return"gap";const r=hn(t);if(!r||r.target!==this.initialHistory.target)return"gap";const{received:s,complete:o}=r,i=t.message===void 0?void 0:Sr(t.message,this.expectedAgentId);if(!o&&!i||o&&t.message!==void 0)return"gap";const a=i&&!this.initialMessageIds.has(i.id);return s!==this.initialHistory.received+(a?1:0)||o&&(t.nextToken!==null&&(typeof t.nextToken!="string"||t.nextToken.length===0)||typeof t.truncated!="boolean"||typeof t.totalMessages!="number"||!Number.isSafeInteger(t.totalMessages)||t.totalMessages<s||s<r.target&&t.nextToken!==null)?"gap":(i&&(this.initialMessageIds.add(i.id),this.messages.some(c=>c.id===i.id)||(this.messages=[i,...this.messages].sort((c,l)=>(c.seq??Number.MAX_SAFE_INTEGER)-(l.seq??Number.MAX_SAFE_INTEGER)))),this.initialHistory=r,o&&(this.nextToken=t.nextToken,this.truncated=t.truncated,this.totalMessages=t.totalMessages),this.expectedSeq=e+1,"applied")}transcript(){return{...this.initialHistory?{initialHistory:this.initialHistory}:{},messages:this.messages,truncated:this.truncated,...this.nextToken!==void 0?{nextToken:this.nextToken}:{},totalMessages:this.totalMessages,isStreaming:this.streaming}}materializeBlock(e,t){const{textDelta:r,...s}=e.block,i=this.incremental&&typeof r=="string"&&(s.type==="text"||s.type==="thinking")?{...s,text:(t?.text??"")+r}:e.block;return Oi(i,t)}upsertBlock(e){const t=e.streamingComplete===!0;let r=this.messages.findIndex(l=>l.id===e.messageId);r<0&&(this.messages=[...this.messages,{id:e.messageId,role:e.role??"assistant",contentBlocks:[],timestamp:e.timestamp??new Date().toISOString(),isStreaming:!t}],r=this.messages.length-1,this.totalMessages+=1);const s=this.messages[r],o=[...s.contentBlocks??[]],i=o.findIndex(l=>l.id===e.block.id),a=this.materializeBlock(e,i>=0?o[i]:void 0);i>=0?o[i]=_i(o[i],a):o.push(a);const c={...s,contentBlocks:o,isStreaming:!t,...t?{streamingComplete:!0}:{}};e.timestamp&&(c.timestamp=e.timestamp),e.messageSeq!==void 0&&(c.seq=e.messageSeq),e.metadata&&(c.metadata=e.metadata),e.appMessageId&&(c.appMessageId=e.appMessageId),"author"in e&&(c.author=e.author),this.messages=[...this.messages.slice(0,r),c,...this.messages.slice(r+1)]}}class Ni{subscribe(e,t,r,s){const o=s?.workspaceId,i=o!==void 0?{workspaceId:o}:{},a=new Pi(e);let c=!1,l,d=s?.sinceMessageId,m=!1,I,w;const S=f=>{c||f===I||(I=f,r?.(f))},A=()=>{w!==void 0&&(clearTimeout(w),w=void 0)};let N,ie=mn,J=!1;const ae=()=>{N!==void 0&&(clearTimeout(N),N=void 0)},U=()=>{ae(),J=!1,ie=mn},ce=()=>{c||(S("delayed"),J=!0,ae(),N=setTimeout(()=>{N=void 0,!c&&(a.reset(),Be(),ue())},ie),ie=Math.min(ie*2,ki))};let q=0,j=0,Z=!1,B=!1,V=!1,z=[];const yt=(f,h=!1)=>{if(!c)try{t({...a.transcript(),...h?{fromHistory:!0}:{}}),L({...f,callbackResult:"delivered"})}catch(v){throw L({...f,callbackResult:"threw"}),v}},Je=(f,h,v=!1)=>{if(c)return;const C=a.transcript();try{t({...C,fromSnapshot:!0,...f===void 0?{}:{resumed:f},...v?{resetCachedTranscript:!0}:{}}),L({...h,callbackResult:"delivered"})}catch(R){throw L({...h,callbackResult:"threw"}),R}},xe=()=>{A(),a.transcript().initialHistory?.complete===!1&&(w=setTimeout(()=>{w=void 0,m=!0,ce()},yn))},Ie=f=>{if(c)return;const h={stage:"subscription",event:"push",turnCorrelation:Ri(f),subscriptionGeneration:q,transportGeneration:j,pushKind:f.kind,pushSeq:f.seq};if(l===void 0){z.push(f),z.length>Ai&&z.shift(),L({...h,callbackResult:"buffered"});return}if(f.subscriptionId!==l){L({...h,callbackResult:"ignored"});return}if(f.kind==="snapshot"){B=!1,A(),U(),S("live");const v=Ei(f.snapshot);d=void 0;const C=a.applySnapshot(f.seq,f.snapshot);if(C==="invalid"){m=Z,le();return}if(C){const R=m&&v===void 0;m=!1;const de=Z?"reset":"applied";Z=!0,Je(v,{...h,reconcilerResult:de},R)}else L({...h,reconcilerResult:"duplicate",callbackResult:"not-invoked"});xe(),V&&a.transcript().initialHistory?.complete!==!1&&(V=!1,le())}else if(B)L({...h,callbackResult:"ignored"});else{const v=f.kind==="history"?a.applyHistory(f.seq,f.history):a.applyDelta(f.seq,f.delta??{added:[],updated:[],removedIds:[]});v==="applied"?(f.kind==="history"&&(U(),S("live"),xe()),yt({...h,reconcilerResult:"applied"},f.kind==="history"),f.kind==="history"&&a.transcript().initialHistory?.complete&&V&&(V=!1,le())):v==="gap"?(L({...h,reconcilerResult:"gap",callbackResult:"not-invoked"}),le()):L({...h,reconcilerResult:"stale",callbackResult:"not-invoked"})}},ue=()=>{ae(),q+=1;const f=q;L({stage:"subscription",event:"registration-start",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),J||S(B?"resyncing":"connecting"),u("chat.subscribe",{agentId:e,...i,deltaEncoding:"incremental",projection:"slim",historyDelivery:"progressive",...d===void 0?{}:{sinceMessageId:d}}).then(h=>{const v=h?.subscriptionId;if(q!==f||c){L({stage:"subscription",event:"registration-stale",subscriptionGeneration:f,transportGeneration:j,callbackResult:"ignored"}),v&&u("chat.unsubscribe",{subscriptionId:v,...i}).catch(()=>{});return}l=v,L({stage:"subscription",event:"registration-ack",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),!B&&!J&&S("awaiting-snapshot"),A(),w=setTimeout(()=>{w=void 0,ce()},yn);const C=z.filter(R=>R.subscriptionId===v);z=[];for(const R of C)Ie(R)}).catch(()=>{q===f&&(L({stage:"subscription",event:"registration-failed",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),ce())})},Be=()=>{if(q+=1,!l)return;const f=l;l=void 0,u("chat.unsubscribe",{subscriptionId:f,...i}).catch(()=>{})},mt=()=>{B=!0,ae(),A(),a.reset(),Be(),ue()},le=()=>{c||B||mt()},g=se(f=>{const h=Ci(f.method,f.params);if(h){Ie(h);return}if(c||f.method!=="events.event"||!$(f.params))return;const v=$(f.params.event)?f.params.event:f.params;if(v.type!=="agent:stream:end"||!$(v.data))return;const C=v.data;if(C.agentId!==e||typeof C.messageId!="string"||C.messageId.length===0||C.stopReason!=="interrupted"&&typeof C.finishReason!="string")return;const R=a.transcript().messages.find(de=>de.id===C.messageId);R&&((R.contentBlocks?.length??0)>0||R.seq!==void 0&&R.isStreaming!==!0&&R.streamingComplete!==!1)||(!Z||B||l===void 0||w!==void 0||J?V=!0:le())}),p=oe(()=>{c||(m||=Z,j+=1,q+=1,L({stage:"subscription",event:"transport-reconnected",subscriptionGeneration:q,transportGeneration:j,callbackResult:"not-invoked"}),l=void 0,B=!1,z=[],A(),U(),a.reset(),ue())});return ue(),()=>{c=!0,A(),ae(),g(),p(),Be()}}}let me=null;class Li{async list(e){const t=await u("client.list",...e?[{workspaceId:e}]:[]);if(!Array.isArray(t?.clients)||!t.clients.every(ui))throw new Error("Invalid client.list response shape");return t.clients}ownClientId(){if(!me){me=u("client.hello",{}).then(t=>{const r=t?.clientId;if(typeof r!="string"||r.length===0)throw new Error("Invalid client.hello response shape: clientId missing");return r});const e=me;e.catch(()=>{me===e&&(me=null)})}return me}}function Uu(){me=null}function Gt(n){if(n.authorType!=="user")return{};const e={};if(typeof n.authorPrincipalId=="string"&&n.authorPrincipalId.trim()&&(e.authorPrincipalId=n.authorPrincipalId),Us(n.authorIdentity)&&n.authorIdentity.externalUserId.trim()){const{provider:t,host:r,externalUserId:s}=n.authorIdentity;e.authorIdentity={provider:t,host:r,externalUserId:s}}return e}function xi(n){const e=n.latestCommentAuthorType==="user"||n.latestCommentAuthorType==="agent"?n.latestCommentAuthorType:void 0,t=Gt({authorType:e,authorPrincipalId:n.latestCommentAuthorPrincipalId,authorIdentity:n.latestCommentAuthorIdentity});return{author:typeof n.latestCommentAuthor=="string"?n.latestCommentAuthor:void 0,authorType:e,authorPrincipalId:t.authorPrincipalId,authorIdentity:t.authorIdentity}}function qu(n){const e=n.author||E.tiptap_comment_unknownAuthor_label(),{authorIdentity:t}=Gt(n);if(!t)return e;const{provider:r,host:s,externalUserId:o}=t,i=`${r}@${s} · ${o}`;return E.presence_person_forge_label({name:e,handle:i})}function Bi(n){if(!(!n||typeof n!="object"))return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Array.isArray(t)?t.map(r=>String(r)):[String(t)]]))}function ji(n){if(!n||typeof n!="object")return;const e=n;return{before:String(e.before??""),after:String(e.after??"")}}function Di(n){const e=n&&typeof n=="object"?n:{};return{original:String(e.original??""),proposed:String(e.proposed??"")}}function qt(n,e,t){const r=new Date().toISOString(),s=String(n.id??""),o=typeof n.parentId=="string"&&n.parentId.length>0,i=n.anchor&&typeof n.anchor=="object"?n.anchor:o?void 0:{type:"point"},a=ji(n.anchorContext),c=Bi(n.reactions),l={...Gt(n),id:s,threadId:String(n.threadId??s),noteId:String(n.noteId??e),...t?{workspaceId:t}:{},content:String(n.content??""),author:String(n.author??""),authorType:n.authorType==="agent"?"agent":"user",status:typeof n.status=="string"?n.status:"open",...i?{anchor:i}:{},createdAt:String(n.createdAt??r),updatedAt:String(n.updatedAt??r),...typeof n.parentId=="string"?{parentId:n.parentId}:{},...n.anchorText!==void 0||n.section!==void 0?{anchorText:String(n.anchorText??n.section??"")}:{},...a?{anchorContext:a}:{},...typeof n.isOrphaned=="boolean"?{isOrphaned:n.isOrphaned}:{},...c?{reactions:c}:{}},d=typeof n.type=="string"?n.type:"comment";switch(d){case"suggestion":return{...l,type:d,suggestionDiff:Di(n.suggestionDiff)};case"session":return{...l,type:d,agentId:String(n.agentId??"")};case"change-request":case"question":return{...l,type:d};case"comment":default:return{...l,type:"comment"}}}async function Ui(n,e){const t=e??await re(n);if(!t)return[];try{const r=await Po(o=>u("comment.list",o),{workspaceId:t,noteId:n,includeComments:!0,limit:ot},o=>u("comment.getThread",{workspaceId:t,noteId:n,threadId:o})),s=[];for(const o of r){if(!o||typeof o!="object")continue;const i=o;if(Array.isArray(i.comments))for(const a of i.comments)s.push(qt(a,n,t));else s.push(qt({...i,...xi(i)},n,t))}return s}catch{return[]}}class qi{async list(e,t){return Ui(e,t)}async add(e,t){return this.runCommentMutation(e,"comment.add",{searchContext:t.searchContext,commentTarget:t.commentTarget,comment:t.comment,...t.type!==void 0?{type:t.type}:{},...t.author!==void 0?{author:t.author}:{},...t.authorType!==void 0?{authorType:t.authorType}:{},...t.commentId!==void 0?{commentId:t.commentId}:{},idempotencyKey:Y()},t.workspaceId)}async respond(e,t){return this.runCommentMutation(e,"comment.respond",{...t.threadId!==void 0?{threadId:t.threadId}:{},...t.commentId!==void 0?{commentId:t.commentId}:{},comment:t.comment,...t.type!==void 0?{type:t.type}:{},...t.authorType!==void 0?{authorType:t.authorType}:{},...t.suggestionOriginal!==void 0?{suggestionOriginal:t.suggestionOriginal}:{},...t.suggestionProposed!==void 0?{suggestionProposed:t.suggestionProposed}:{}},t.workspaceId)}async delete(e,t,r){return this.runCommentMutation(e,"comment.delete",{commentId:t},r)}async runCommentMutation(e,t,r,s){const o=s??await re(e);return o?b(t,{workspaceId:o,noteId:e,...r}):{success:!1,error:`Cannot resolve workspace for note ${e}`}}subscribe(e,t,r){let s=r;const o={subscribeMethod:"comment.subscribe",unsubscribeMethod:"comment.unsubscribe",continuation:{method:"comment.list",key:"threads",params:i=>({workspaceId:i.workspaceId,noteId:e,includeComments:!0,limit:ot})},...r?{params:{workspaceId:r,noteId:e,limit:ot}}:{dynamic:{subscribeIds:i=>{let a=!1;return re(e).then(c=>{a||!c||(s=c,i([c]))}).catch(()=>{}),()=>{a=!0}},paramsForId:i=>({workspaceId:i,noteId:e,limit:ot})}}};return Ye({channel:o,getId:i=>typeof i.threadId=="string"?i.threadId:"",complete:i=>lr(i,a=>u("comment.getThread",{workspaceId:s,noteId:e,threadId:a})),normalize:i=>i.noteId!==e||!Array.isArray(i.comments)?null:i.comments.flatMap(a=>{if(!a||typeof a!="object"||Array.isArray(a))return[];const c=a;return typeof c.id!="string"||!c.id||c.threadId!==i.threadId||c.noteId!==void 0&&c.noteId!==e?[]:[qt(c,e,s)]}),handler:i=>t(i.flat())})}}class Fi{async get(e,t){return await u("drafts.get",{workspaceId:e,agentId:t})??null}async set(e,t,r,s){const o={workspaceId:e,agentId:t,text:r};return s&&s.length>0&&(o.attachments=s),await u("drafts.set",o)}async clear(e,t){return await u("drafts.clear",{workspaceId:e,agentId:t})}}const $i=300;class Hi{async list(e){return[...await this.query(e,{limit:$i})].reverse()}async query(e,t={}){const r=await u("event.query",{workspaceId:e,...t});return Array.isArray(r)?r:[]}async queryPage(e,t={}){return u("event.query",{workspaceId:e,...t,paginate:!0})}subscribe(e,t){return this.list(e).then(r=>t(r)).catch(()=>t([])),()=>{}}}const Wi=new Set([".onnx",".onnx_data",".pt",".pth",".bin",".safetensors",".h5",".hdf5",".pkl",".pickle",".npy",".npz",".model",".weights",".tflite",".mlmodel",".pb",".ckpt",".mat",".parquet",".feather",".arrow",".wasm",".png",".jpg",".jpeg",".gif",".bmp",".ico",".icns",".webp",".tiff",".tif",".svg",".psd",".raw",".heic",".heif",".avif",".mp3",".wav",".ogg",".flac",".aac",".m4a",".wma",".mp4",".mov",".avi",".mkv",".webm",".wmv",".flv",".zip",".tar",".gz",".bz2",".7z",".rar",".xz",".tgz",".exe",".dll",".so",".dylib",".a",".o",".obj",".ttf",".otf",".woff",".woff2",".eot",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".db",".sqlite",".sqlite3",".pyc",".pyo",".class",".jar",".war",".ear",".node"]),Gi=[/package-lock\.json$/,/yarn\.lock$/,/pnpm-lock\.yaml$/,/composer\.lock$/,/Gemfile\.lock$/,/Cargo\.lock$/,/poetry\.lock$/,/\.min\.(js|css)$/,/\.bundle\.(js|css)$/,/[\\/](dist|build|node_modules)[\\/]/];function Vi(n){const e=n.lastIndexOf("."),t=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return e>t&&e!==-1?n.slice(e).toLowerCase():""}function zi(n){const e=Vi(n);return Wi.has(e)}function Ki(n){return Gi.some(e=>e.test(n))}function Fu(n){return zi(n)?{skip:!0,reason:"binary/media file"}:Ki(n)?{skip:!0,reason:"lock/minified/build file"}:{skip:!1}}function Yi(n,e=8192){const t=n.subarray(0,Math.min(e,n.length));if(t.includes(0))return!0;let r=0;for(let s=0;s<t.length;s++){const o=t[s];o!==9&&o!==10&&o!==13&&!(o>=32&&o<=126)&&!(o>=194&&o<=244)&&!(o>=128&&o<=191)&&r++}return r/t.length>.3}const Ar=48e4,Ji=8*1024*1024,vn=40*1024*1024;class Tr extends Error{constructor(e){super(`file.read: ${e}: stream did not contain valid UTF-8`),this.name="InvalidUtf8Error"}}function wr(n){if(typeof n=="string")return{text:n,truncated:!1};if(n&&typeof n=="object"){const{content:e,truncated:t}=n;if(typeof e=="string")return{text:e,truncated:t===!0}}return null}function Zi(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}async function Er(n,e,t=u,r=Ji){const s=[];let o=0,i;for(;;){const l=await t(n,{...e,offset:o,length:r});if(!l||typeof l.content!="string"||!Number.isSafeInteger(l.size)||!Number.isSafeInteger(l.bytesRead))throw new Error(`${n}: invalid chunk response`);if(l.size>vn)throw new Error(`${n}: object is ${l.size} bytes, over the ${vn}-byte limit`);if(i===void 0)i=l.size;else if(l.size!==i)throw new Error(`${n}: object changed while it was read`);const d=Zi(l.content);if(d.length!==l.bytesRead)throw new Error(`${n}: content/bytesRead mismatch (${d.length} vs ${l.bytesRead})`);if(s.push(d),o+=d.length,d.length<r||o>=i)break}const a=new Uint8Array(o);let c=0;for(const l of s)a.set(l,c),c+=l.length;return a}async function Qi(n,e=u){const t=await e("file.read",{...n,maxBytes:Ar}),r=wr(t);if(!r)return null;if(!r.truncated)return r.text;const s=await Er("file.readChunk",n,e);try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(s)}catch{throw new Tr(n.path)}}async function $u(n,e=u){const t=await e("git.showFile",{...n,maxBytes:Ar}),r=wr(t);if(!r)return"";if(!r.truncated)return r.text;const s=await Er("git.showFileChunk",n,e);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(s)}function Xi(n){for(let e=0;e<n.length;e++){const t=n.charCodeAt(e);if(t<=8||t>=14&&t<=26||t>=28&&t<=31||t===127)return!0}return!1}function Rt(n,e){return{path:n,absolutePath:null,...ns(e),lastUpdated:Date.now(),loading:!1,saving:!1,error:null,truncated:!1}}function bn(n){const e=n,t=Array.isArray(e)?e:Array.isArray(e?.entries)?e.entries:Array.isArray(e?.files)?e.files:[],r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=s,i=typeof o.name=="string"?o.name:void 0,c=(typeof o.path=="string"?o.path:void 0)??i;if(!c)continue;const l=o.type==="directory"||o.type==="dir"||o.isDirectory===!0,d={name:i??c.split("/").pop()??c,path:c,type:l?"directory":"file"};typeof o.size=="number"&&(d.size=o.size),typeof o.modified=="string"&&(d.modified=o.modified),typeof o.isGitignored=="boolean"&&(d.isGitignored=o.isGitignored),r.push(d)}return r}function ea(n,e){const t=n.trim();return t==="?"?"??":e?`${t} `:` ${t}`}class ta{async list(e){return[]}async read(e,t,r){try{const s=await Qi({workspaceId:e,path:t,...r?.gitRootId?{gitRootId:r.gitRootId}:{}});if(s===null)return null;const o=Xi(s)||Yi(new TextEncoder().encode(s.slice(0,8192)));return Rt(t,o?{kind:"restorable-snapshot",content:s,isBinary:!0}:ts(s))}catch(s){if(s instanceof Tr)return Rt(t,{kind:"preview-only",isBinary:!0});if(s instanceof tr&&s.rpcCode===-32603){const o=_(s);if(o.endsWith("stream did not contain valid UTF-8"))return Rt(t,{kind:"preview-only",isBinary:!0});if(!r?.gitRootId&&/\(os error [23]\)$/.test(o))return null}throw s}}async explorerTree(e){const t=await u("file.tree",{workspaceId:e,path:"."});if(!Array.isArray(t))throw new Error("Invalid file.tree response: expected an array");return{name:"",path:"",type:"directory",children:bn(t)}}async listDirectory(e,t){try{const r=await u("file.list",{workspaceId:e,path:t});return bn(r)}catch{return[]}}async gitStatusMap(e){try{const t=await u("git.status",{workspaceId:e}),r=Array.isArray(t?.files)?t.files:[],s={};for(const o of r){const i=o,a=String(i.path??"");a&&(s[a]={status:ea(String(i.status??""),!!i.staged)})}return s}catch{return{}}}async write(e,t,r){return b("file.write",{workspaceId:e,path:t,content:r.content,idempotencyKey:Y()})}async delete(e,t){return b("file.delete",{workspaceId:e,path:t})}async mkdir(e,t){return b("file.mkdir",{workspaceId:e,path:t,idempotencyKey:Y()})}async rename(e,t,r){return b("file.rename",{workspaceId:e,oldPath:t,newPath:r,idempotencyKey:Y()})}}const na=15e4;function Cr(n){const t=(Array.isArray(n.files)?n.files:[]).map(r=>{const s=r,o={path:String(s.path??""),status:typeof s.status=="string"?s.status.trim()||St.Modified:St.Modified,staged:!!s.staged};return typeof s.mode=="string"&&(o.mode=s.mode),typeof s.oldSha=="string"&&(o.oldSha=s.oldSha),typeof s.newSha=="string"&&(o.newSha=s.newSha),o});return{branch:String(n.branch??""),ahead:Number(n.ahead??0),behind:Number(n.behind??0),diverged:n.diverged===void 0?Number(n.ahead)>0&&Number(n.behind)>0:!!n.diverged,files:t,hasUncommittedChanges:n.hasUncommittedChanges===void 0?t.length>0:!!n.hasUncommittedChanges,hasUntrackedFiles:n.hasUntrackedFiles===void 0?t.some(r=>r.status===St.Untracked):!!n.hasUntrackedFiles}}function Hu(n){if(!n||typeof n!="object")return null;const e=n;return typeof e.branch!="string"||typeof e.ahead!="number"||typeof e.behind!="number"||!Array.isArray(e.files)||e.files.some(t=>!t||typeof t!="object"||typeof t.path!="string"||typeof t.status!="string"||typeof t.staged!="boolean")?null:Cr(e)}const Xe=new Map;function Sn(n,e){const t=rs.state,r=JSON.stringify([Jr(t),qs(t),t.daemonHealth?.connectionGeneration,n]);if(!e?.forceRefresh){const o=Xe.get(r);if(o)return o}const s=u("git.status",{workspaceId:n,...e?.forceRefresh?{forceRefresh:!0}:{}}).then(o=>!o||typeof o!="object"?null:Cr(o)).catch(()=>null);return Xe.set(r,s),s.then(()=>{Xe.get(r)===s&&Xe.delete(r)}),s}function ra(n){const e=n&&typeof n=="object"?n:{},t=typeof e.type=="string"?e.type:"Context",s={type:t==="Addition"?It.Addition:t==="Deletion"?It.Deletion:It.Context,content:typeof e.content=="string"?e.content:""};return typeof e.oldNumber=="number"&&(s.oldNumber=e.oldNumber),typeof e.newNumber=="number"&&(s.newNumber=e.newNumber),s}function sa(n){const e=Array.isArray(n)?n:[],t=[];for(const r of e){if(!r||typeof r!="object")continue;const s=r,o=typeof s.path=="string"?s.path:"";if(!o)continue;const a=(Array.isArray(s.hunks)?s.hunks:[]).map(c=>{const l=c&&typeof c=="object"?c:{};return{oldStart:Number(l.oldStart??0),oldLines:Number(l.oldLines??0),newStart:Number(l.newStart??0),newLines:Number(l.newLines??0),lines:Array.isArray(l.lines)?l.lines.map(ra):[]}});t.push({file:o,chunks:a})}return t}function oa(n){if(typeof n!="string"||!n)return 0;const e=Date.parse(n);return Number.isFinite(e)?e:0}function ia(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.path=="string"?e.path:"";if(!t)return null;const r={path:t};return typeof e.additions=="number"&&(r.additions=e.additions),typeof e.deletions=="number"&&(r.deletions=e.deletions),typeof e.status=="string"&&(r.status=e.status),r}function aa(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.hash=="string"?e.hash:"";if(!t)return null;const r=!!e.isPushed,s={hash:t,message:typeof e.message=="string"?e.message:"",author:typeof e.author=="string"?e.author:"",timestamp:oa(e.date),stage:r?"pushed":"local",isPushed:r};return Array.isArray(e.files)&&(s.files=e.files.map(ia).filter(o=>o!==null)),typeof e.filesChanged=="number"&&(s.filesChanged=e.filesChanged),typeof e.date=="string"&&(s.date=e.date),typeof e.agentId=="string"&&(s.agentId=e.agentId),typeof e.linkedNoteId=="string"&&(s.linkedNoteId=e.linkedNoteId),s}function ca(n,e){const r=(Array.isArray(n.files)?n.files:[]).map(i=>typeof i=="string"?i:null).filter(i=>i!==null),o=(Array.isArray(n.fileDetails)?n.fileDetails:[]).map(i=>{if(!i||typeof i!="object")return null;const a=i,c=typeof a.path=="string"?a.path:"";return c?{path:c,additions:typeof a.additions=="number"?a.additions:0,deletions:typeof a.deletions=="number"?a.deletions:0}:null}).filter(i=>i!==null);return{commitHash:typeof n.commitHash=="string"?n.commitHash:e,author:typeof n.author=="string"?n.author:"",authorEmail:typeof n.authorEmail=="string"?n.authorEmail:"",date:typeof n.date=="string"?n.date:"",message:typeof n.message=="string"?n.message:"",files:r,fileDetails:o}}const ua=new Set(Object.values(nr)),la=new Set(["added","modified","deleted","renamed"]);function da(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.file=="string"?e.file:"",r=typeof e.relativePath=="string"?e.relativePath:t;if(!t&&!r)return null;const s=typeof e.stage=="string"&&ua.has(e.stage)?e.stage:nr.Unstaged,o=typeof e.status=="string"&&la.has(e.status)?e.status:void 0,i=e.stats&&typeof e.stats=="object"?e.stats:{},a=e.attribution&&typeof e.attribution=="object"?e.attribution:{};return{id:typeof e.id=="string"&&e.id?e.id:r||t,file:t||r,relativePath:r||t,stage:s,stats:{additions:typeof i.additions=="number"?i.additions:0,deletions:typeof i.deletions=="number"?i.deletions:0},...o?{status:o}:{},attribution:{...a.agent&&typeof a.agent=="object"?{agent:a.agent}:{},...typeof a.manual=="boolean"?{manual:a.manual}:{},timestamp:typeof a.timestamp=="number"?a.timestamp:0},...typeof e.commitHash=="string"?{commitHash:e.commitHash}:{}}}function _t(n,e){const t=n.map(r=>r.trim()).filter(Boolean);return t.length===0?{ok:!1,failure:{success:!1,error:`No file paths provided; ${e.toLowerCase()} requires explicit paths.`}}:t.some(r=>r==="."||r==="*"||r.includes("--all"))?{ok:!1,failure:{success:!1,error:`${e} all files is not allowed; specify explicit file paths.`}}:{ok:!0,paths:t}}class fa{async originUrl(e){try{const t=await u("git.getRemoteUrl",{repoPath:e,remoteName:"origin"});return typeof t?.url=="string"?t.url:null}catch{return null}}async status(e,t){return Sn(e,t)}async changes(e){return Sn(e)}async diffs(e,t){const r={workspaceId:e};t?.path&&(r.path=t.path),t?.paths?.length&&(r.paths=t.paths),t?.staged===!0&&(r.staged=!0),t?.commitHash&&(r.commitHash=t.commitHash),t?.gitRootId&&(r.gitRootId=t.gitRootId);try{const s=await u("git.diffs",r);return sa(s)}catch{return[]}}async commitDetails(e,t,r){try{const s=await u("git.commitDetails",{workspaceId:e,commitHash:t,...r?.gitRootId?{gitRootId:r.gitRootId}:{}});return!s||typeof s!="object"?null:ca(s,t)}catch{return null}}async trackedChanges(e){try{const t=await u("file-tracking.getChanges",{workspaceId:e});return(Array.isArray(t?.changes)?t.changes:[]).map(da).filter(s=>s!==null)}catch{return null}}async commits(e,t){try{return(await this.commitsWithBoundary(e,t)).commits}catch{return[]}}async commitsWithBoundary(e,t){const r=await u("file-tracking.loadCommits",{workspaceId:e,...t!==void 0?{includeOlder:t}:{}}),s=Array.isArray(r?.commits)?r.commits:[],o=r?.boundarySha===null||typeof r?.boundarySha=="string"?r.boundarySha:null,i=r?.nextToken===null||typeof r?.nextToken=="string"?r.nextToken:null;return{commits:s.map(aa).filter(a=>a!==null),boundarySha:o,nextToken:i,...typeof r?.historyIdentity=="string"&&r.historyIdentity?{historyIdentity:r.historyIdentity}:{}}}async getBranches(e,t,r){try{const s=await u("git.getBranches",{...r===void 0?{}:{workspaceId:r},repoPath:e,includeRemote:t});if(!s||typeof s!="object")return null;const o=Array.isArray(s.branches)?s.branches.filter(a=>typeof a=="string"):[],i=Array.isArray(s.remoteBranches)?s.remoteBranches.filter(a=>typeof a=="string"):[];return{branches:o,remoteBranches:i,currentBranch:typeof s.currentBranch=="string"?s.currentBranch:"",defaultBranch:typeof s.defaultBranch=="string"?s.defaultBranch:""}}catch{return null}}async branchStatus(e,t,r){try{const s=await u("git.branchStatus",{...r===void 0?{}:{workspaceId:r},repoPath:e,branchName:t});return!s||typeof s!="object"?null:{branch:typeof s.branch=="string"?s.branch:t,currentBranch:typeof s.currentBranch=="string"?s.currentBranch:"",isCurrentBranch:!!s.isCurrentBranch,ahead:typeof s.ahead=="number"?s.ahead:0,behind:typeof s.behind=="number"?s.behind:0,hasUncommittedChanges:!!s.hasUncommittedChanges}}catch{return null}}async prRefresh(e,t){try{const r=await u("pr.refresh",{workspaceId:e,...t});return!r||typeof r!="object"||typeof r.outcome!="string"||!["skipped","unchanged","linked","updated","unlinked"].includes(r.outcome)?null:{outcome:r.outcome,prNumber:typeof r.prNumber=="number"?r.prNumber:void 0,prUrl:typeof r.prUrl=="string"?r.prUrl:void 0,prStatus:typeof r.prStatus=="string"?r.prStatus:void 0,pullRequests:Array.isArray(r.pullRequests)?r.pullRequests:[]}}catch{return null}}async stage(e,t){const r=_t(t,"Staging");return r.ok?b("git.stage",{workspaceId:e,paths:r.paths}):r.failure}async unstage(e,t){const r=_t(t,"Unstaging");return r.ok?b("git.unstage",{workspaceId:e,paths:r.paths}):r.failure}async discard(e,t){const r=_t(t,"Discarding");return r.ok?b("git.discard",{workspaceId:e,paths:r.paths}):r.failure}async commit(e,t){return t.userRequested?b("git.agentCommit",{workspaceId:e,message:t.message,...t.files!==void 0?{files:t.files}:{},userRequested:t.userRequested}):{success:!1,error:"git.agentCommit requires userRequested: true."}}async pull(e,t,r){try{const s=await u("git.pull",{repoPath:e,branchName:t,...r===void 0?{}:{workspaceId:r}},{timeoutMs:na});return s&&typeof s=="object"&&s.ok===!0?{success:!0}:{success:!1,error:s&&typeof s=="object"&&typeof s.error=="string"&&s.error?s.error:"Failed to pull changes"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}}const pa=ze("LiveIntegrationsClient");function ga(n){return n.merged===!0?"merged":n.state==="closed"?"closed":n.draft===!0?"draft":n.isInMergeQueue===!0?"queued":"open"}class ya{captureRepositoryCheckout(e){return Es(e)}async githubUser(e){try{const r=(await u("github.getUser",...e===void 0?[]:[{workspaceId:e}]))?.user;return!r||typeof r.login!="string"||r.login.length===0?null:{login:r.login,name:null,email:null,avatar_url:typeof r.avatarUrl=="string"?r.avatarUrl:""}}catch{return null}}async githubBranches(e,t,r,s){const[o,i]=await Promise.all([u("github.branches.list",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,...r?{prefix:r}:{}}),r?Promise.resolve(void 0):u("github.repos.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t}).then(c=>{const l=c?.repo?.defaultBranch;return typeof l=="string"&&l.length>0?l:void 0},()=>{})]);return{branches:Array.isArray(o?.branches)?o.branches.filter(c=>typeof c=="string"):[],defaultBranch:i}}async githubBranchesCached(e,t,r){try{const s=await u("github.branches.listCached",{owner:e,repo:t,...r===void 0?{}:{workspaceId:r}}),o=Array.isArray(s?.branches)?s.branches.filter(c=>typeof c=="string"):[],i=typeof s?.defaultBranch=="string"&&s.defaultBranch.length>0?s.defaultBranch:void 0,a=s?.source==="cache"||s?.source==="ls-remote"?s.source:void 0;return{cached:s?.cached===!0,branches:o,defaultBranch:i,source:a}}catch{return{cached:!1,branches:[]}}}async githubRepoConfig(e,t,r,s){const o=await u("github.repoConfig.get",{owner:e,repo:t,...r?{ref:r}:{},...s===void 0?{}:{workspaceId:s}}),i=o?.config&&typeof o.config=="object"&&!Array.isArray(o.config)?o.config:null;return i===null&&o?.config!=null&&pa.warn("github.repoConfig.get returned a non-object config; treating as null",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t}),{config:i,exists:o?.exists===!0}}captureRepositoryResource(e){return Cs(e)}async githubPullRequest(e,t,r,s){const i=(await u("github.pulls.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,number:r}))?.pull;if(!i)throw new Error(`Pull request ${e}/${t}#${r} not found`);const a=ga(i),c=a==="queued"?ir(i.mergeQueue):null;return{owner:e,repo:t,number:i.number,title:i.title,state:a,author:i.user.login,createdAt:i.createdAt,updatedAt:i.updatedAt,url:i.htmlUrl,headRef:i.headRef,baseRef:i.baseRef,...c?{mergeQueue:c}:{}}}async githubIssue(e,t,r,s){const i=(await u("github.issues.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,number:r}))?.issue;if(!i)throw new Error(`Issue ${e}/${t}#${r} not found`);return{owner:e,repo:t,number:i.number,title:i.title,state:i.state,author:i.user.login,createdAt:i.createdAt,updatedAt:i.updatedAt,url:i.htmlUrl}}async linearIssues(e){try{return(await u("linear.authStatus",...e===void 0?[]:[{workspaceId:e}]))?.authenticated!==!0?[]:(await u("linear.listIssues",...e===void 0?[]:[{workspaceId:e}])).issues}catch{return[]}}async sentryIssues(e){try{return(await u("sentry.authStatus",...e===void 0?[]:[{workspaceId:e}]))?.authenticated!==!0?[]:(await u("sentry.listIssues",...e===void 0?[]:[{workspaceId:e}])).issues}catch{return[]}}subscribe(e){let t=!1;return this.githubUser().then(r=>{t||e({githubUser:r})}),()=>{t=!0}}}const ma=["cli-missing","prerequisite-missing"];function ha(n){return ma.some(e=>e===n)}function va(n){if(!(typeof n?.warning!="string"||!n.warning))return ha(n.warningKind)?n.warningKind:void 0}function Wu(n){const e={success:!0,data:Rr(n)};typeof n?.warning=="string"&&n.warning&&(e.warning=n.warning),n?.stale===!0&&(e.stale=!0);const t=va(n);return t&&(e.warningKind=t),e}function ba(n){if(typeof n?.id!="string"||!n.id||typeof n?.name!="string"||!n.name)return null;const e={value:n.id,label:n.name};return typeof n.description=="string"&&(e.description=n.description),typeof n.modelGroupPriority=="number"&&(e.modelGroupPriority=n.modelGroupPriority),typeof n.costTier=="number"&&(e.costTier=n.costTier),Array.isArray(n.badges)&&(e.badges=n.badges),Array.isArray(n.effortLevels)&&(e.effortLevels=n.effortLevels),n.isDefault===!0&&(e.isDefault=!0),n.isLegacyModel===!0&&(e.isLegacyModel=!0),typeof n.priority=="number"&&(e.priority=n.priority),e}function Rr(n){return Array.isArray(n?.models)?n.models.flatMap(e=>ba(e)??[]):[]}class Sa{async list(e,t){try{const r=e||t?await u("models.list",{...e?{providerId:e}:{},...t?{workspaceId:t}:{}}):await u("models.list");return e&&r.providerId!==e?[]:Rr(r)}catch{return[]}}subscribe(e){let t=!1;return this.list().then(r=>{t||e(r)}),()=>{t=!0}}}function Ft(n){if(typeof n=="number"&&Number.isFinite(n)&&n>=0)return Math.trunc(n);if(typeof n=="string"&&n.length>0){const e=Number(n);if(Number.isFinite(e)&&e>=0)return Math.trunc(e)}return null}function Ia(n){if(!n||typeof n!="object")return null;const e=n,t=Ft(e.v);if(t===null)return null;const r=e.author&&typeof e.author=="object"?e.author:null,s=r?{id:String(r.id??""),name:String(r.name??""),type:typeof r.type=="string"?r.type:as.System}:void 0;return{versionId:String(t),versionNumber:t,content:String(e.content??""),title:String(e.title??""),...s?{author:s}:{},createdAt:String(e.date??"")}}class ka extends Error{constructor(){super("Truncated note read capability is unknown: no acknowledged hello yet"),this.name="NoteCapabilityUnknownError"}}function Aa(n){return n instanceof Error?n.message===E.agent_placement_unavailable()?!1:n.name!=="UnbridgedMockIpcChannelError":!0}const Ta=30,wa=100;function qe(n,e){const t=new Date().toISOString(),r=String(n.id??"");return{...n,id:is(r),workspaceId:Qn(String(n.workspaceId??e)),title:String(n.title??""),content:String(n.content??""),contentType:typeof n.contentType=="string"?n.contentType:os.Markdown,tags:Array.isArray(n.tags)?n.tags:[],isPinned:!!(n.isPinned??n.is_pinned??!1),isArchived:!!(n.isArchived??n.is_archived??!1),visibility:typeof n.visibility=="string"?n.visibility:ss.Workspace,rev:typeof n.rev=="number"?n.rev:void 0,contentPreview:typeof n.contentPreview=="string"?n.contentPreview:void 0,contentLength:typeof n.contentLength=="number"?n.contentLength:void 0,contentTruncated:n.contentTruncated===!0?!0:void 0,contentBytes:n.contentTruncated===!0&&typeof n.contentBytes=="number"?n.contentBytes:void 0,createdAt:String(n.createdAt??n.created_at??t),updatedAt:String(n.updatedAt??n.updated_at??t)}}class Ea{async list(e,t){const r=o=>u("note.list",o);let s;if(t?.projection==="slim")try{s=await Re(r,{workspaceId:e,projection:"slim",limit:ve},"notes")}catch(o){if(!Zn(o))throw o;s=await Re(r,{workspaceId:e,limit:ve},"notes")}else s=await Re(r,{workspaceId:e,limit:ve},"notes");return s.map(o=>{const i=qe(o,e);return He(String(i.id),e),i})}async supportsTruncatedRead(){for(let e=0;e<Ta;e++){try{const r=(await Rs())?.server?.capabilities;if(r)return r.noteTruncatedRead===1}catch(t){if(!Aa(t))return!1}await new Promise(t=>setTimeout(t,wa))}throw new ka}async get(e,t,r){const s=t??await re(e);if(!s)return null;try{const o=r?.maxContentBytes!==void 0?await u("note.get",{workspaceId:s,noteId:e,maxContentBytes:r.maxContentBytes}):await dr(a=>u("note.get",a),{workspaceId:s,noteId:e}),i=o&&typeof o=="object"&&"note"in o?o.note:o;return!i||typeof i!="object"?null:qe(i,s)}catch{return null}}async create(e){return jt("note.create",{...e,idempotencyKey:Y()})}async setContent(e,t,r,s,o){return this.runNoteMutation(e,"note.setContent",{content:t,...o?.baseContentBytes!==void 0?{baseContentBytes:o.baseContentBytes}:{}},r,s)}async add(e,t,r,s,o){return this.runNoteMutation(e,"note.add",{content:t,...r?.heading!==void 0?{heading:r.heading}:{},...r?.position!==void 0?{position:r.position}:{}},s,o)}async edit(e,t,r,s,o){return this.runNoteMutation(e,"note.edit",{old:t,new:r},s,o)}async editLines(e,t,r,s,o,i){return this.runNoteMutation(e,"note.editLines",{start:t,end:r,content:s},o,i)}async delete(e,t,r){return this.runNoteMutation(e,"note.delete",{},t,r)}async updateMetadata(e,t,r,s){return this.runNoteMutation(e,"note.updateMetadata",{...t.title!==void 0?{title:t.title}:{},...t.tags!==void 0?{tags:t.tags}:{}},r,s)}async listVersions(e,t){const r=await u("note.listVersions",{workspaceId:e,noteId:t});return!Array.isArray(r)||r.length===0?[]:(await Promise.all(r.map(o=>{const i=Ft(o.v);return i===null?Promise.resolve(null):u("note.getVersion",{workspaceId:e,noteId:t,v:i}).then(a=>Ia(a)).catch(()=>null)}))).filter(o=>o!==null)}async restoreVersion(e,t,r){const s=Ft(r);if(s===null)return{success:!1,error:`Invalid version id: ${r}`};try{const o=await u("note.restoreVersion",{workspaceId:e,noteId:t,v:s});return{success:!0,note:o&&typeof o=="object"&&o.note&&typeof o.note=="object"?qe(o.note,e):void 0}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}async runNoteMutation(e,t,r,s,o){const i=o??await re(e);if(!i)return{success:!1,error:`Cannot resolve workspace for note ${e}`};const a=await b(t,{workspaceId:i,noteId:e,...r,...s!==void 0?{expectedVersion:s}:{}}),c=a.conflict?.current;return c&&typeof c=="object"?{...a,conflict:{current:qe(c,i)}}:a}subscribe(e){return Ye({channel:{subscribeMethod:"note.subscribe",unsubscribeMethod:"note.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t,limit:ve})},continuation:{method:"note.list",key:"notes",params:t=>({workspaceId:t.workspaceId,limit:ve})}},getId:t=>String(t.id??""),normalize:t=>{const r=String(t.workspaceId??"");if(!r)return null;const s=qe(t,r);return He(String(s.id),r),s},handler:e})}}class Ca{async catalog(e){const t=cs.parse(e?{workspaceId:e}:{}),r=await u(Ss,t);return us.parse(r)}async listProfiles(e){const t=await u(Is,e?{baseProviderId:e}:{});return ls.parse(t)}async createProfile(e){const t=await u(ds,{baseProviderId:e.baseProviderId,name:e.name,...e.env?{env:e.env}:{},...e.backup!==void 0?{backup:e.backup}:{}});return fs.parse(t)}async updateProfile(e){const t=await u(ps,{profileId:e.profileId,...e.name!==void 0?{name:e.name}:{},...e.env?{env:e.env}:{},...e.backup!==void 0?{backup:e.backup}:{}});return gs.parse(t)}async updateDefault(e){const t=await u(ys,{baseProviderId:e.baseProviderId,...e.name!==void 0?{name:e.name}:{},...e.env?{env:e.env}:{}});return ms.parse(t)}async deleteProfile(e){const t=await u(ks,{profileId:e});return hs.parse(t)}async reorderProfiles(e){const t=await u(vs,{baseProviderId:e.baseProviderId,profileIds:e.profileIds});return bs.parse(t)}}const Ra=200;class _a{async supportsLifecycle(){return(await u("client.hello",{}))?.server?.capabilities?.scriptLifecycle===1}async requireActiveLists(){const e=await u("client.hello",{});if(e.server?.capabilities?.scriptActiveLists!==1)throw new Error(E.scripts_list_unsupported_error());return{fullPages:e.server?.capabilities?.boundedReads===1}}async list(e,t){const{fullPages:r}=await this.requireActiveLists(),s=[],o=new Set;let i;do{const a=await u("script.list",{workspaceId:e,archive:t?.archive??"active",...r?{limit:Ra,...i?{cursor:i}:{}}:{}});if(!Array.isArray(a?.scripts))throw new Error(E.scripts_list_load_error());for(const l of a.scripts)s.push(Oa(l)?await In(e,l.id):l);const c=r?a.nextCursor:void 0;if(typeof c=="string"&&c&&!o.has(c))o.add(c),i=c;else{if(c!=null)throw new Error(E.scripts_list_load_error());i=void 0}}while(i);return s}async listPage(e,t){await this.requireActiveLists();const r=await u("script.list",{workspaceId:e,archive:"active",view:"summary",limit:100,...t});if(r?.view!=="summary"||!Array.isArray(r.scripts))throw new Error(E.scripts_list_unsupported_error());return r}async get(e,t){return await this.requireActiveLists(),In(e,t)}async archive(e,t,r){if(!r?.capabilityVerified&&!await this.supportsLifecycle())throw new Error(E.scripts_list_unsupported_error());return u("script.archive",{workspaceId:e,scriptIds:t})}async restore(e,t,r){if(!r?.capabilityVerified&&!await this.supportsLifecycle())throw new Error(E.scripts_list_unsupported_error());return u("script.restore",{workspaceId:e,scriptIds:t})}async create(e,t){try{if(t.scriptId!==void 0)throw new Error("Use scriptsClient.update to edit an existing script.");const r=await u("script.create",{workspaceId:e,name:t.name,command:t.command,mode:t.mode,...t.purpose!==void 0?{purpose:t.purpose}:{},...t.cwd!==void 0?{cwd:t.cwd}:{},...t.env!==void 0?{env:t.env}:{},...t.category!==void 0?{category:t.category}:{},...t.autoStart!==void 0?{autoStart:t.autoStart}:{},...t.healthUrl!==void 0?{healthUrl:t.healthUrl}:{},...t.readyPattern!==void 0?{readyPattern:t.readyPattern}:{}}),s=typeof r?.id=="string"?r.id:void 0;return{success:!0,...s?{id:s}:{},...r?{script:r}:{}}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async start(e,t){return b("script.start",{workspaceId:e,scriptId:t})}async stop(e,t){return b("script.stop",{workspaceId:e,scriptId:t})}async restart(e,t){return b("script.restart",{workspaceId:e,scriptId:t})}async output(e,t,r){try{const s=await u("script.output",{workspaceId:e,scriptId:t,...r!==void 0?{maxLines:r}:{}});return typeof s=="string"?s:""}catch{return""}}async status(e,t){try{const r=await u("script.status",{workspaceId:e,scriptId:t});return r&&typeof r=="object"?r:null}catch{return null}}async run(e,t,r){try{const s=await u("script.run",{workspaceId:e,scriptId:t,...r?.maxLines!==void 0?{maxLines:r.maxLines}:{},...r?.timeoutSeconds!==void 0?{timeoutSeconds:r.timeoutSeconds}:{}});return s&&typeof s=="object"?s:null}catch{return null}}subscribe(e){return e([]),()=>{}}}function Oa(n){return Object.entries(n).some(([e,t])=>e.endsWith("Omitted")&&t===!0)}const Ma=3,Pa=4096;async function In(n,e){for(let t=0;t<Ma;t++){const r=await u("script.get",{workspaceId:n,scriptId:e});if(r?.commandTruncated!==!0)return r;const s=r.commandBytes;let o=r.command,i=r.nextCommandOffset,a=!1,c=1;for(;typeof i=="number";){if(++c>Pa)throw new Error(E.scripts_list_load_error());const S=await u("script.get",{workspaceId:n,scriptId:e,commandOffset:i});if(S?.commandBytes!==s||S.commandOffset!==i||S.updatedAt!==r.updatedAt){a=!0;break}o+=S.command;const A=S.nextCommandOffset;if(typeof A=="number"&&A<=i)throw new Error(E.scripts_list_load_error());i=A}if(a)continue;if(new TextEncoder().encode(o).length!==s)throw new Error(E.scripts_list_load_error());const{commandTruncated:l,commandBytes:d,commandOffset:m,nextCommandOffset:I,...w}=r;return{...w,command:o}}throw new Error(E.scripts_list_load_error())}const Na=["stdio","http","sse"],La=["oauth","header","none"];function Le(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function kn(n){const e=new WeakSet;try{const t=JSON.stringify(n,(r,s)=>!Le(s)&&!Array.isArray(s)?s:e.has(s)?"[Circular]":(e.add(s),Array.isArray(s)?s:Object.keys(s).sort().reduce((o,i)=>(o[i]=s[i],o),{})));return t===void 0?void 0:t}catch{return}}function _r(n,e,t){if(n==null)return e;if(typeof n=="string")return n||e;if(n instanceof Error)return n.message||e;if(Le(n)){if(t.has(n))return kn(n)??e;t.add(n);for(const r of["message","error","reason","details"])if(r in n)return _r(n[r],e,t)}return kn(n)??String(n||e)}function Gu(n,e){return _r(n,e,new WeakSet)}function Ae(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function xa(n){if(Array.isArray(n)){const e=n.filter(t=>typeof t=="string");return e.length>0?e:void 0}if(typeof n=="string"){const e=n.trim().split(/\s+/).filter(Boolean);return e.length>0?e:void 0}}function An(n){if(!Le(n))return;const e=Object.entries(n).filter(t=>typeof t[1]=="string");return Object.fromEntries(e)}function Ba(n){return La.includes(n)?n:void 0}function Vu(n){switch(n){case"running":return"connected";case"starting":return"configured";case"stopped":return"stopped";case"error":return"error";case"auth_required":return"auth_required";default:return null}}function Ot(n,e){if(!Le(n))return null;const t=Ae(n.name)??Ae(e);if(!t)return null;const r=n.type??n.transport,s=Na.includes(r)?r:Ae(n.command)?"stdio":"http",o={name:t,type:s},i=Ae(n.id);i&&(o.id=i);const a=Ae(n.command),c=Ae(n.url),l=xa(n.args),d=An(n.env),m=An(n.headers),I=Ba(n.authType);return a&&(o.command=a),c&&(o.url=c),l&&(o.args=l),d&&(o.env=d),m&&(o.headers=m),I&&(o.authType=I),typeof n.disabled=="boolean"&&(o.disabled=n.disabled),o}function ja(n){if(Array.isArray(n))return n.flatMap(r=>Ot(r)??[]);if(!Le(n))return[];const e=n.mcpServers??n.servers;if(Array.isArray(e))return e.flatMap(r=>Ot(r)??[]);const t=Le(e)?e:n;return Object.entries(t).flatMap(([r,s])=>Ot(s,r)??[])}function Or(n){const e=new Set,t=new Map;for(const r of n){const s=Xn(r);if(e.has(s))throw new Error(`Duplicate MCP server identity: ${s}`);e.add(s);const o=t.get(r.name);if(o&&(!o.id||!r.id))throw new Error(`Duplicate MCP server name requires distinct IDs: ${r.name}`);t.set(r.name,r)}}function zu(n){const e=ja(n);return Or(e),e}function Ku(n){const e={name:n.name,type:n.type};return n.id!==void 0&&(e.id=n.id),n.command!==void 0&&(e.command=n.command),n.args!==void 0&&(e.args=[...n.args]),n.url!==void 0&&(e.url=n.url),n.authType!==void 0&&(e.authType=n.authType),n.disabled!==void 0&&(e.disabled=n.disabled),n.workspaceDisabled!==void 0&&(e.workspaceDisabled=n.workspaceDisabled),e}const Tn="global",be=new Map,$e=new Map,he=new Map;let Me=0,Mr=0;function Pr(n,e){return JSON.stringify([Mr,e??null,n])}let wn=!1;function Da(n){if(n.method!=="events.event"||!n.params)return;const e=n.params,t=e.event&&typeof e.event=="object"?e.event:e;return typeof t.type=="string"?t.type:void 0}function Nr(){wn||(wn=!0,typeof se=="function"&&se(n=>{Da(n)==="settings:changed"&&We()}),typeof oe=="function"&&oe(()=>{Mr+=1,We()}))}function We(n){if(Me+=1,!n)be.clear();else for(const e of be.keys())n.includes(JSON.parse(e)[2])&&be.delete(e)}function Ua(n){return n?.definition?{...n.definition,value:n.value,...n.origin?{origin:n.origin}:{},...typeof n.revision=="number"?{revision:n.revision}:{}}:null}function Lr(n,e){Nr();const t=Pr(n,e);if(be.has(t))return Promise.resolve(be.get(t)??null);const r=$e.get(t);if(r?.generation===Me)return r.promise;if(r){const i=he.get(t);if(i)return i;const a=r.promise.catch(()=>null).then(()=>he.get(t)!==a?null:(he.delete(t),Lr(n,e))).finally(()=>{he.get(t)===a&&he.delete(t)});return he.set(t,a),a}const s=Me,o=u("settings.get",{path:n,...e?{workspaceId:e}:{}}).then(Ua).then(i=>(s===Me&&be.set(t,i),i)).finally(()=>{$e.get(t)?.promise===o&&$e.delete(t)});return $e.set(t,{generation:s,promise:o}),o}async function qa(n){if(n.length===0)return{applied:[],revision:0};const e=await u("settings.update",{changes:n});return We(n.map(({path:t})=>t)),{applied:Array.isArray(e?.applied)?e.applied:[],revision:typeof e?.revision=="number"?e.revision:0}}function Yu(){We(),$e.clear(),he.clear()}function En(n){const e=[];for(const[t,r]of Object.entries(n))r!==void 0&&e.push({path:t,value:r});return e}class Fa{async list(e){return(await this.listSnapshot(e)).settings}async listSnapshot(e){Nr();const t=Me;try{const r=await u("settings.list",...e?[{workspaceId:e}]:[]),s={settings:Array.isArray(r?.settings)?r.settings:[],revision:typeof r?.revision=="number"?r.revision:0};if(t===Me)for(const o of s.settings)be.set(Pr(o.path,e),o);return s}catch{return{settings:[],revision:0}}}async get(e,t){try{return await Lr(e,t)}catch{return null}}async update(e){return(await this.updateSnapshot(e)).applied}async updateSnapshot(e){return qa(e)}async reset(e){try{const t=await u("settings.reset",{path:e});return typeof t?.path!="string"?null:(We([t.path]),{path:t.path,value:t.value})}catch{return null}}async getUserRule(e,t){try{const r=await u("rules.get",{workspaceId:t??Tn,ruleType:e});return!r||typeof r.content!="string"?null:{enabled:r.enabled===!0,content:r.content,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:0}}catch{return null}}async updateUserRule(e,t,r){return b("rules.update",{workspaceId:Tn,ruleType:e,content:t,...r!==void 0?{enabled:r}:{}})}async getUserPreferences(){return null}async setUserPreferences(e){return{success:!0}}async getProviderSettings(e){const t=await this.list(e),r=Mt(t,"model.defaultProvider"),s=et(t,"providers.enabled");return r===null&&s===null?null:{activeProviderId:r??"",enabledProviders:s??{}}}async setProviderSettings(e){return b("settings.update",{changes:En({"model.defaultProvider":e.activeProviderId,"providers.enabled":e.enabledProviders})})}async getMcpServers(e){return(await Rn(e)).flatMap(r=>xr(r)??[])}async getMcpServerStatuses(e,t){return(await Promise.all(e.map(async s=>{try{const o=await u("mcp.servers.getStatus",{serverId:s,...t?{workspaceId:t}:{}});return Cn(s,o?.status)}catch{return null}}))).filter(s=>s!==null)}async restartMcpServer(e){const t=await u("mcp.servers.restart",{serverId:e}),r=Cn(e,t?.status);if(!r)throw new Error("The daemon returned an invalid MCP server status.");return r}async getWorkspaceDisabledMcpServerKeys(e){try{const t=await u("mcp.servers.list",{workspaceId:e});return Array.isArray(t?.servers)?t.servers.flatMap(r=>r.workspaceDisabled===!0&&typeof r.name=="string"&&r.name?[Xn({id:r.id,name:r.name})]:[]):null}catch{return null}}async toggleWorkspaceMcpServer(e,t,r){try{const s=await u("mcp.servers.toggle",{serverId:t,enabled:r,workspaceId:e});return typeof s?.workspaceDisabled=="boolean"?{success:!0,workspaceDisabled:s.workspaceDisabled}:{success:!0}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async setMcpServers(e){try{Or(e);const t=await Rn(),r=new Map(t.map(i=>[i.id,i])),s=e.map(i=>{if(i.id!==void 0)return{config:i,current:r.get(i.id)};const a=t.filter(c=>c.name===i.name);if(a.length>1)throw new Error(`Ambiguous MCP server name: ${i.name}`);return{config:i,current:a[0]}}),o=new Set;for(const{config:i,current:a}of s){const c=a?.id??i.id;if(c){if(o.has(c))throw new Error(`Duplicate MCP server identity: ${c}`);o.add(c)}}for(const i of t)i.id&&!o.has(i.id)&&await u("mcp.servers.delete",{serverId:i.id});for(const{config:i,current:a}of s){if(!a?.id){await u("mcp.servers.create",{config:_n(i,i.id)});continue}const c={...i,env:i.env??a.env,headers:i.headers??a.headers};$a(a,c)||await u("mcp.servers.update",{serverId:a.id,config:_n(c,a.id)});const l=i.disabled!==!0;a.enabled!==!1!==l&&await u("mcp.servers.toggle",{serverId:a.id,enabled:l})}return{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async getWorkspaceSettings(e){try{const t=await u("workspace.getAutoCommit",{workspaceId:e});return typeof t?.autoCommit?.enabled!="boolean"?null:{autoCommitEnabled:t.autoCommit.enabled}}catch{return null}}async setWorkspaceSettings(e,t){return t.autoCommitEnabled===void 0?{success:!0}:b("workspace.setAutoCommit",{workspaceId:e,enabled:t.autoCommitEnabled})}async getBackgroundAgentSettings(e){const t=await this.list(e),r=Mt(t,"quickActions.defaultReasoningEffort"),s=et(t,"quickActions.typeReasoningEffortOverrides"),o=Mt(t,"quickActions.defaultModel"),i=et(t,"quickActions.typeOverrides"),a=et(t,"quickActions.providerSettings");return o===null&&i===null&&a===null&&r===null&&s===null?null:{defaultReasoningEffort:r??"",typeReasoningEffortOverrides:s??{},defaultModel:o??"",typeOverrides:i??{commit:"",pr:"",review:"",fast:""},providerSettings:a??{}}}async setBackgroundAgentSettings(e){return b("settings.update",{changes:En({"quickActions.defaultReasoningEffort":e.defaultReasoningEffort,"quickActions.typeReasoningEffortOverrides":e.typeReasoningEffortOverrides,"quickActions.defaultModel":e.defaultModel,"quickActions.typeOverrides":e.typeOverrides,"quickActions.providerSettings":e.providerSettings})})}subscribe(e){return e(null),()=>{}}}function Cn(n,e){if(typeof e?.serverId=="string"&&e.serverId&&e.serverId!==n||e?.state!=="stopped"&&e?.state!=="starting"&&e?.state!=="running"&&e?.state!=="error"&&e?.state!=="auth_required")return null;const t={serverId:n,state:e.state};return typeof e.lastError=="string"&&e.lastError&&(t.lastError=e.lastError),t}async function Rn(n){try{const e=await u("mcp.servers.list",...n?[{workspaceId:n}]:[]);return Array.isArray(e?.servers)?e.servers:[]}catch{return[]}}function xr(n){if(typeof n?.name!="string"||!n.name)return null;const e=n.transport==="http"||n.transport==="sse"?n.transport:"stdio",t={name:n.name,type:e};return typeof n.id=="string"&&n.id&&(t.id=n.id),typeof n.command=="string"&&n.command&&(t.command=n.command),Array.isArray(n.args)&&(t.args=n.args),n.env&&typeof n.env=="object"&&(t.env=n.env),typeof n.url=="string"&&n.url&&(t.url=n.url),n.headers&&typeof n.headers=="object"&&(t.headers=n.headers),n.enabled===!1&&(t.disabled=!0),typeof n.workspaceDisabled=="boolean"&&(t.workspaceDisabled=n.workspaceDisabled),t}function _n(n,e){const t={name:n.name,transport:n.type,enabled:n.disabled!==!0};return e&&(t.id=e),n.command&&(t.command=n.command),n.args&&(t.args=n.args),n.env&&(t.env=n.env),n.url&&(t.url=n.url),n.headers&&(t.headers=n.headers),t}function $a(n,e){const t=xr(n);if(!t)return!1;const r=o=>o?Object.entries(o).sort(([i],[a])=>i.localeCompare(a)):null,s=o=>JSON.stringify([o.name,o.type,o.command??null,o.args??null,r(o.env),o.url??null,r(o.headers)]);return s(t)===s(e)}function Br(n,e){for(const t of n)if(t.path===e)return t;return null}function Mt(n,e){const t=Br(n,e);return t&&typeof t.value=="string"?t.value:null}function et(n,e){const t=Br(n,e);return!t||t.value===null||typeof t.value!="object"?null:t.value}function Pt(n){if(!n||typeof n!="object")return null;const e=n.setupScript;return!e||typeof e!="object"?null:e}class Ha{async get(e){try{const t=await u("workspace.getSetupScript",{workspaceId:e});return Pt(t)}catch{return null}}async save(e,t){try{const r=await u("workspace.saveSetupScript",{workspaceId:e,script:t});return Pt(r)}catch{return null}}async detectProjectType(e){try{const t=await u("workspace.detectProjectType",{workspaceId:e});return typeof t?.projectType=="string"?t.projectType:null}catch{return null}}async generate(e){try{const t=await u("workspace.generateSetupScript",{workspaceId:e});return Pt(t)}catch{return null}}}const On=ze("LiveSkillsClient"),Wa=500,Ga=100;function Mn(n){return{name:n.name,description:n.description,location:n.location,...n.resourceDirectory?{resourceDirectory:n.resourceDirectory}:{},scope:n.scope}}class Va{async fetchList(e){const t=[],r=new Set;let s;for(let o=0;o<Ga;o++){const i=await u("skill.list",{workspaceId:e,limit:Wa,...s?{nextToken:s}:{}});if(Array.isArray(i))return i.map(Mn);for(const a of Array.isArray(i?.skills)?i.skills:[])r.has(a.name)||(r.add(a.name),t.push(Mn(a)));if(s=typeof i?.nextToken=="string"?i.nextToken:void 0,!s)return t}return On.warn("skill.list paging stopped at the page limit"),t}async list(e){return this.fetchList(e)}subscribe(e){let t=!1,r,s;e([]);const o=l=>{this.fetchList(l).then(d=>{t||e(d)}).catch(d=>{On.error("Failed to refetch skill list; keeping last known-good view",d)})},i=()=>$t({eventTypes:["skills:changed"]}).then(l=>{r=l?.subscriptionId,t&&r&&Ne(r)}).catch(()=>{});i();const a=se(l=>{if(l.method==="skills:changed"&&!t){const m=l.params?.workspaceId;m&&(s=m,o(m))}}),c=oe(()=>{t||(r=void 0,i(),s&&o(s))});return()=>{t=!0,a(),c(),r&&Ne(r)}}}const Nt=ze("LiveSpecialistsClient"),za=100,Ka=500,Ya=100;class Ja{async listCatalog(e,t,r){const s={...e?{provider:e}:{},...t?{workspaceId:t}:{},...r?.includeProject?{includeProject:!0}:{}},o=[],i=new Set;let a,c;for(let d=0;d<Ya;d++){const m=await u("specialist.list",{...s,limit:Ka,...c?{nextToken:c}:{}});for(const I of Array.isArray(m?.specialists)?m.specialists:[])i.has(I.id)||(i.add(I.id),o.push(I));if(d===0&&(a=m?.importDiagnostics),c=typeof m?.nextToken=="string"?m.nextToken:void 0,!c)break}return c&&Nt.warn("specialist.list paging stopped at the page limit"),{specialists:await Promise.all(o.map(d=>d.behaviorPromptOmitted?this.hydrateOmittedPrompt(d,e,t):d)),importDiagnostics:a}}async hydrateOmittedPrompt(e,t,r){try{const o=(await u("specialist.get",{id:e.id,...t?{provider:t}:{},...r?{workspaceId:r}:{}}))?.specialist;if(o&&o.id===e.id&&o.source===e.source&&!o.behaviorPromptOmitted&&typeof o.behaviorPrompt=="string")return{...e,...o,behaviorPromptOmitted:void 0,behaviorPromptBytes:void 0}}catch(s){Nt.warn(`specialist.get for omitted prompt of ${e.id} failed`,s)}return e}async list(e,t){try{return(await this.listCatalog(e,t)).specialists}catch{return[]}}subscribe(e){return this.subscribeCatalogSnapshot(t=>e(t.specialists),()=>e([]))}subscribeCatalog(e){return this.subscribeCatalogSnapshot(e)}subscribeCatalogSnapshot(e,t){let r=!1,s,o;this.listCatalog().then(d=>{r||e(d)}).catch(()=>{r||t?.()});const i=()=>{this.listCatalog().then(d=>{r||e(d)}).catch(d=>{Nt.error("Failed to refetch specialist list; keeping last known-good view",d)})},a=()=>$t({eventTypes:["specialists:changed","skills:changed"]}).then(d=>{s=d?.subscriptionId,r&&s&&Ne(s)}).catch(()=>{});a();const c=se(d=>{(d.method==="specialists:changed"||d.method==="skills:changed")&&!r&&(o!==void 0&&clearTimeout(o),o=setTimeout(()=>{o=void 0,i()},za))}),l=oe(()=>{r||(s=void 0,a(),o!==void 0&&(clearTimeout(o),o=void 0),i())});return()=>{r=!0,o!==void 0&&(clearTimeout(o),o=void 0),c(),l(),s&&Ne(s)}}async create(e,t,r,s,o){const i={id:e,spec:t};return r&&(i.scope=r),s&&(i.workspacePath=s),r==="project"&&o&&(i.workspaceId=o),(await u("specialist.create",i)).specialist}async edit(e,t,r,s,o){const i={id:e,spec:t,scope:r};return s&&(i.workspacePath=s),r==="project"&&o&&(i.workspaceId=o),(await u("specialist.edit",i)).specialist}async delete(e,t,r,s){const o={id:e,scope:t};return r&&(o.workspacePath=r),t==="project"&&s&&(o.workspaceId=s),await u("specialist.delete",o)}}class Za{async getUsage(e,t,r){const s={period:e,tzOffsetMinutes:r};t!==void 0&&(s.key=t);const o=await u("stats.getUsage",s);for(const i of["byModel","byProvider"])if(!Array.isArray(o[i]))throw new Error(`stats.getUsage result is missing the required \`${i}\` array (PROTOCOL §5.36) — the daemon is likely outdated and predates this field`);return o}}const Qa=12e4;function Xa(n){return typeof n.arrayBuffer=="function"?n.arrayBuffer():new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(r.error??new Error("Blob read failed")),r.readAsArrayBuffer(n)})}async function ec(n){const e=new Uint8Array(await Xa(n)),t=32768;let r="";for(let s=0;s<e.length;s+=t)r+=String.fromCharCode(...e.subarray(s,s+t));return btoa(r)}class tc{async transcribe(e,t,r,s){const o={audio:await ec(e),mimeType:t};return r&&(r.prompt!==void 0||r.keyterms!==void 0)&&(o.context=r),typeof s=="string"&&s.trim().length>0&&(o.workspaceId=s),u("voice.transcribe",o,{timeoutMs:Qa})}async getWorkspaceVocabulary(e){return u("voice.getWorkspaceVocabulary",{workspaceId:e})}}const nc=["stable","beta","alpha","disabled"];function Ju(n){return nc.includes(n)}const O={CHECK_MANUAL:"auto-update:check-manual",DOWNLOAD:"auto-update:download",INSTALL:"auto-update:install",GET_STATE:"auto-update:get-state",SET_CHANNEL:"auto-update:set-channel",SET_SHARE_STATISTICS:"auto-update:set-share-statistics",STATUS_CHANGED:"auto-update:status-changed",PROGRESS:"auto-update:progress",ERROR:"auto-update:error",UP_TO_DATE:"auto-update:up-to-date",SHOW_TOAST:"auto-update:show-toast"},jr={async checkForUpdatesManual(){const n=await ye(O.CHECK_MANUAL);if(!n.success||n.data===void 0)throw new Error(n.error?.message||E.autoUpdate_client_checkFailed_error());return n.data},async downloadUpdate(){const n=await ye(O.DOWNLOAD);if(!n.success)throw new Error(n.error?.message||E.autoUpdate_client_downloadFailed_error())},async installUpdate(){const n=await ye(O.INSTALL);if(!n.success)throw new Error(n.error?.message||E.autoUpdate_client_installFailed_error())},async getState(){const n=await ye(O.GET_STATE);if(!n.success||n.data===void 0)throw new Error(n.error?.message||E.autoUpdate_client_getStateFailed_error());return n.data},async setChannel(n){const e=await ye(O.SET_CHANNEL,{channel:n});if(!e.success)throw new Error(e.error?.message||E.autoUpdate_client_setChannelFailed_error())},async setShareStatistics(n){const e=await ye(O.SET_SHARE_STATISTICS,{enabled:n});if(!e.success)throw new Error(e.error?.message||E.autoUpdate_client_setShareStatisticsFailed_error())},onStatusChanged(n){const e=window.electronAPI.on(O.STATUS_CHANGED,n);return()=>{e&&window.electronAPI.offById(O.STATUS_CHANGED,e)}},onProgress(n){const e=window.electronAPI.on(O.PROGRESS,n);return()=>{e&&window.electronAPI.offById(O.PROGRESS,e)}},onError(n){const e=window.electronAPI.on(O.ERROR,n);return()=>{e&&window.electronAPI.offById(O.ERROR,e)}},onShowToast(n){const e=window.electronAPI.on(O.SHOW_TOAST,n);return()=>{e&&window.electronAPI.offById(O.SHOW_TOAST,e)}},onUpToDate(n){const e=window.electronAPI.on(O.UP_TO_DATE,n);return()=>{e&&window.electronAPI.offById(O.UP_TO_DATE,e)}}},Zu=Object.freeze(Object.defineProperty({__proto__:null,autoUpdateClient:jr},Symbol.toStringTag,{value:"Module"}));class rc{async status(){try{const e=await u("system.status");return!e||typeof e!="object"?{nodeVersionOk:null,nodeVersion:void 0,auggieInstalled:!1,binaryInstallAvailable:!1}:{nodeVersionOk:typeof e.nodeVersionOk=="boolean"?e.nodeVersionOk:null,nodeVersion:typeof e.nodeVersion=="string"?e.nodeVersion:void 0,auggieInstalled:typeof e.auggieInstalled=="boolean"?e.auggieInstalled:!1,binaryInstallAvailable:typeof e.binaryInstallAvailable=="boolean"?e.binaryInstallAvailable:!1}}catch{return{nodeVersionOk:null,nodeVersion:void 0,auggieInstalled:!1,binaryInstallAvailable:!1}}}async capabilities(e){try{const t=await u("system.capabilities",...e?[{workspaceId:e}]:[]);return!t||typeof t!="object"?{}:{cowSupported:typeof t.cowSupported=="boolean"?t.cowSupported:void 0}}catch{return{}}}async releaseNotes(){return null}async autoUpdate(){try{return{...await jr.getState(),toastVisible:!1,downloadedToastDismissedAt:null}}catch{return null}}subscribe(e){return this.status().then(t=>e(t)),()=>{}}}class Dr{constructor(e=!1){this.localMachine=e}async pairingInfo(){const e=await u("server.pairingInfo",void 0,this.localMachine?{localMachine:!0}:void 0);if(typeof e?.token!="string"||typeof e?.certFingerprint!="string"||typeof e?.path!="string"||!Array.isArray(e?.localIps)||typeof e?.hostname!="string")throw new Error("Invalid server.pairingInfo response shape");return{token:e.token,certFingerprint:e.certFingerprint,port:e.port??null,path:e.path,localIps:e.localIps,hostname:e.hostname,...typeof e.tcAddress=="string"&&e.tcAddress.length>0?{tcAddress:e.tcAddress}:{},...Array.isArray(e.availableIps)?{availableIps:e.availableIps}:{}}}async rotateToken(){const e=await u("server.rotateToken",void 0,this.localMachine?{localMachine:!0}:void 0);if(typeof e?.token!="string")throw new Error("Invalid server.rotateToken response shape");return{token:e.token}}}const sc=ze("LiveTasksClient");function Lt(n,e){if(!(!Array.isArray(e)||e.length===0)){if(!e.every(t=>typeof t=="string")){sc.warn(`discarding malformed ${n}: expected string[], got non-string member`,{value:e});return}return e}}function Ur(n){const e=Lt("dependsOn",n.dependsOn),t=Lt("conflictsWith",n.conflictsWith),r=Lt("unmetDependsOn",n.unmetDependsOn);return{...e?{dependsOn:e}:{},...t?{conflictsWith:t}:{},...r?{unmetDependsOn:r}:{}}}function qr(n){return typeof n.specLinked=="boolean"?{specLinked:n.specLinked}:{}}function Vt(n){const t=n.metadata?.task;return t?{id:String(n.id??""),title:String(n.title??""),status:typeof t.status=="string"?t.status:"not_started",updatedAt:typeof n.updatedAt=="string"?n.updatedAt:typeof n.updated_at=="string"?n.updated_at:void 0,...typeof n.rev=="number"?{rev:n.rev}:{},...Ur(t),...qr(t)}:null}function Pn(n){const e=Vt(n);return e||(typeof n.status!="string"?null:{id:String(n.id??""),title:String(n.title??""),status:n.status,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:typeof n.updated_at=="string"?n.updated_at:void 0,...typeof n.rev=="number"?{rev:n.rev}:{},...Ur(n),...qr(n)})}function oc(n){const e=Vt(n);return e||(typeof n.status=="string"?{id:String(n.id??""),title:String(n.title??""),status:n.status,...typeof n.updatedAt=="string"?{updatedAt:n.updatedAt}:{},...typeof n.rev=="number"?{rev:n.rev}:{}}:null)}const ic={total:0,completed:0,inProgress:0};function Nn(n){if(!n||typeof n!="object")return null;const e=n,t=e.noteId,r=e.taskKey,s=e.taskText,o=e.agentId,i=e.createdAt;return typeof t!="string"||typeof r!="string"||typeof s!="string"||typeof o!="string"||typeof i!="number"?null:{noteId:t,taskKey:r,taskText:s,agentId:o,createdAt:i}}function ac(n){if(!n||typeof n!="object")return{...ic};const e=n;return{total:typeof e.total=="number"?e.total:0,completed:typeof e.completed=="number"?e.completed:0,inProgress:typeof e.inProgress=="number"?e.inProgress:0}}class cc{async list(e){const t=await u("task.list",{workspaceId:e}),r=Array.isArray(t?.tasks)?t.tasks:[],s=[];for(const o of r){const i=Pn(o);i&&(i.id&&He(i.id,e),s.push(i))}return{tasks:s,stats:ac(t?.stats)}}async get(e){const t=await re(e);if(!t)return null;try{const r=await dr(o=>u("note.get",o),{workspaceId:t,noteId:e}),s=r&&typeof r=="object"&&"note"in r?r.note:r;return!s||typeof s!="object"?null:Vt(s)}catch{return null}}async updateStatus(e,t,r,s){return this.runTaskMutation(e,"task.updateStatus",{taskText:t,status:r},s)}async update(e,t,r,s){return this.runTaskMutation(e,"task.update",{line:t,...r.text!==void 0?{text:r.text}:{},...r.status!==void 0?{status:r.status}:{},...r.expected!==void 0?{expected:r.expected}:{}},s)}async updateNoteStatus(e,t,r){return this.runTaskMutation(e,"task.updateNoteStatus",{status:t},r)}async markAsTask(e,t,r,s){return this.runTaskMutation(e,"task.markAsTask",{status:t,...r?.acceptanceCriteria!==void 0?{acceptanceCriteria:r.acceptanceCriteria}:{},...r?.effort!==void 0?{effort:r.effort}:{},...r?.dependsOn!==void 0?{dependsOn:r.dependsOn}:{},...r?.conflictsWith!==void 0?{conflictsWith:r.conflictsWith}:{}},s)}async setRelations(e,t){return this.runTaskMutation(e,"task.setRelations",{...t.dependsOn!==void 0?{dependsOn:t.dependsOn}:{},...t.conflictsWith!==void 0?{conflictsWith:t.conflictsWith}:{}})}async assignAgent(e,t,r){return this.runTaskMutation(e,"task.assignAgent",{agentId:t},r)}async createPrerequisite(e,t,r){const s=await re(e);return s?jt("task.createPrerequisite",{workspaceId:s,dependentNoteId:e,title:t,...r?.content!==void 0?{content:r.content}:{},...r?.status!==void 0?{status:r.status}:{},idempotencyKey:Y()}):{success:!1,error:`Cannot resolve workspace for note ${e}`}}async listAgentLinks(e){const r=(await u("task.listAgentLinks",{workspaceId:e}))?.linksByNoteId;if(!r||typeof r!="object")return{};const s={};for(const[o,i]of Object.entries(r)){if(!i||typeof i!="object")continue;const a={};for(const[c,l]of Object.entries(i)){const d=Nn(l);d&&(a[c]=d)}Object.keys(a).length>0&&(s[o]=a)}return s}async linkAgent(e,t,r){const s=await u("task.linkAgent",{workspaceId:e,noteId:t,taskText:r.taskText,agentId:r.agentId,...r.taskKey!==void 0?{taskKey:r.taskKey}:{}}),o=Nn(s?.link);return o||{...r,noteId:t}}async unlinkAgent(e,t,r){return(await u("task.unlinkAgent",{workspaceId:e,noteId:t,taskKey:r}))?.removed===!0}async runTaskMutation(e,t,r,s){const o=await re(e);if(!o)return{success:!1,error:`Cannot resolve workspace for note ${e}`};const i=await jt(t,{workspaceId:o,noteId:e,...r,...s!==void 0?{expectedVersion:s}:{}}),a=i.conflict?.current;if(a&&typeof a=="object"){const c=oc(a);if(c)return{...i,conflict:{current:c}}}return i}subscribe(e){return Ye({channel:{subscribeMethod:"task.subscribe",unsubscribeMethod:"task.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t})}},getId:t=>String(t.id??""),normalize:t=>{const r=Pn(t);return r?.id&&typeof t.workspaceId=="string"&&t.workspaceId&&He(r.id,t.workspaceId),r},handler:e})}}function uc(n){const e=new TextEncoder().encode(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Ln(n){if(typeof n!="string"||n.length===0)return"";try{const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return new TextDecoder().decode(t)}catch{return""}}function lc(n,e){if(!n||typeof n!="object")return null;const t=n,r=String(t.terminalId??t.id??"");if(!r)return null;const s=typeof t.workspaceId=="string"?t.workspaceId:e;return{id:r,name:typeof t.name=="string"?t.name:"",workspaceId:s,createdAt:typeof t.createdAt=="string"?t.createdAt:void 0,isConnected:!0,...typeof t.isExecutingCommand=="boolean"?{isExecuting:t.isExecutingCommand}:{}}}function dc(n){if(!n||typeof n!="object")return null;const e=n;return e.event&&typeof e.event=="object"?e.event:typeof e.type=="string"?e:null}function fc(n){if(!n||typeof n!="object")return;const e=n.subscriptionId;return typeof e=="string"?e:void 0}class pc{async list(e){const t=await u("terminal.list",{workspaceId:e}),r=Array.isArray(t),s=r?t:Array.isArray(t?.terminals)?t.terminals:[],o=!r&&typeof t?.daemonBootId=="string"?t.daemonBootId:void 0,i=[];for(const a of s){const c=lc(a,e);c&&i.push(c)}return{terminals:i,...o!==void 0?{daemonBootId:o}:{}}}async create(e){try{const t=await u("terminal.create",{workspaceId:e.workspaceId,cols:e.cols,rows:e.rows,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.command!==void 0?{command:e.command}:{},...e.env!==void 0?{env:e.env}:{}}),r=typeof t?.terminalId=="string"?t.terminalId:void 0;return r?{success:!0,id:r}:{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async write(e,t,r){return b("terminal.write",{terminalId:e,data:uc(t),...r!==void 0?{workspaceId:r}:{}})}async resize(e,t,r,s){return b("terminal.resize",{terminalId:e,cols:t,rows:r,...s!==void 0?{workspaceId:s}:{}})}async kill(e,t){return b("terminal.kill",{terminalId:e,...t!==void 0?{workspaceId:t}:{}})}async getBuffer(e,t,r){try{const s=await u("terminal.getBuffer",{terminalId:e,...r!==void 0?{workspaceId:r}:{},...t!==void 0?{maxBytes:t}:{}});return Ln(s?.data)}catch{return""}}async output(e,t){try{const r=await u("terminal.readOutput",{workspaceId:e,terminalId:t});if(typeof r=="string")return r;const s=r?.output;return typeof s=="string"?s:""}catch{return""}}subscribeEvents(e,t,r){let s=!1,o=0,i;const a=se(d=>{if(d.method!=="events.event")return;const m=fc(d.params);if(i===void 0||m!==i)return;const I=dc(d.params);if(!I||typeof I.type!="string"||!I.type.startsWith("terminal:"))return;const w=I.data??{};if(w.terminalId===e)switch(I.type){case"terminal:data":t.onData?.({terminalId:e,chunk:Ln(w.chunk)});break;case"terminal:exit":t.onExit?.({terminalId:e,exitCode:typeof w.exitCode=="number"?w.exitCode:0});break;case"terminal:cwd":typeof w.cwd=="string"&&t.onCwd?.({terminalId:e,cwd:w.cwd});break;case"terminal:title":typeof w.title=="string"&&t.onTitle?.({terminalId:e,title:w.title});break}}),c=()=>{const d=++o;return $t({eventTypes:["terminal:data","terminal:exit","terminal:cwd","terminal:title"],...r!==void 0?{workspaceId:r}:{}}).then(m=>{const I=m?.subscriptionId;if(s||d!==o){I&&Ne(I,r);return}i=I}).catch(()=>{})};c();const l=oe(()=>{i=void 0,c()});return()=>{s=!0,a(),l(),i&&Ne(i,r)}}subscribe(e){return e([]),()=>{}}}function gc(n=_s){return{async begin(e,t,r){const s=Os.parse(e),o=Ms.parse(t);if(Q(s.root)!==Q(o.review.root))throw new Error("NATIVE_REVIEW_UNAVAILABLE");const i=await n(o);if(Q(i.preview.root)!==Q(s.root))throw await i.release(),new Error("NATIVE_REVIEW_UNAVAILABLE");let a;try{a=i.onRetired(r)}catch(d){throw await i.release(),d}let c=!1,l;return{...o.review.companion&&i.prepareCompanion?{prepareCompanion(){return l||(l=Promise.resolve().then(async()=>{if(c)throw new Error("NATIVE_REVIEW_UNAVAILABLE");const d=await i.prepareCompanion();if(c||Q(d.preview.root)!==Q(s.root))throw await d.release(),new Error("NATIVE_REVIEW_UNAVAILABLE");return d}),l)}}:{},preview:i.preview,onRetired:i.onRetired,confirm:i.confirm,reconcile:i.reconcile,async release(){c||(c=!0,a(),l?.then(d=>d.release(),()=>{}),await i.release())}}}}}const yc=Ke({root:Ps,editId:Se().min(1),admission:Se().nullable()}).strict();function mc(n=Ns){return{async begin(e,t){const r=yc.parse(e),s=await n(r.root);if(Q(s.preview.root)!==Q(r.root))throw await s.release(),new Error("REPOSITORY_SELECTION_UNAVAILABLE");const o=s.onRetired(t);let i=!1;return{preview:s.preview,onRetired:s.onRetired,confirm:s.confirm,reconcile:s.reconcile,async release(){i||(i=!0,o(),await s.release())}}}}}function hc(n=Ls){return{async observe(e,t){const r=Object.freeze({...e});let s=!0,o,i;const a=()=>{s&&(s=!1,i?.(),o?.release())},c=()=>{if(s)try{t({type:"unavailable",request:r})}finally{a()}};return(async()=>{if(o=await n(r.gitRootId===void 0?{workspaceId:r.workspaceId,kind:"primary"}:{workspaceId:r.workspaceId,kind:"registered",gitRootId:r.gitRootId}),!s){await o.release();return}if(i=o.onRetired(()=>{if(s)try{t({type:"retired",request:r})}finally{a()}}),!s){i();return}const l=await o.request("workspace.repositoryContext",{workspaceId:r.workspaceId,...r.gitRootId===void 0?{}:{gitRootId:r.gitRootId}});if(!s)return;if(!l.current){try{t({type:"retired",request:r})}finally{a()}return}if(l.settlement.status!=="fulfilled"){c();return}const d=Fs.parse(l.settlement.value);if(!$s(d,r)){c();return}t({type:"received",response:{request:r,context:d}})})().catch(c),a}}}const vc=Ke({amount:X().finite(),currency:Se().min(1)}).passthrough(),it=Ke({inputTokens:X().int().nonnegative(),outputTokens:X().int().nonnegative(),cacheReadTokens:X().int().nonnegative(),cacheCreationTokens:X().int().nonnegative(),thoughtTokens:X().int().nonnegative().optional(),cost:vc.optional()}).passthrough(),bc=Ke({agentId:Se().min(1),model:Se().min(1),totals:it,humanMessages:X().int().nonnegative(),agentMessages:X().int().nonnegative()}).passthrough(),xn=new TextEncoder;function Bn(n,e){const t=xn.encode(n),r=xn.encode(e);for(let s=0;s<Math.min(t.length,r.length);s++)if(t[s]!==r[s])return t[s]-r[s];return t.length-r.length}const Sc=Hs(bc).superRefine((n,e)=>{for(const[t,r]of n.entries()){const s=n[t-1];s!==void 0&&(Bn(r.agentId,s.agentId)||Bn(r.model,s.model))<=0&&e.addIssue({code:Ws.custom,message:"byAgentModel rows must be unique and sorted by agentId, then model",path:[t]})}}),Fr=Ke({byAgentId:At(it),totals:it,byModel:At(it),byAgentModel:Sc.optional(),agentNames:At(Se()).optional(),lastScanAt:Se().datetime({offset:!0}).nullable()}).passthrough();function Ic(n){return Fr.parse(n)}function Qu(n){const e=Fr.safeParse(n);return e.success?e.data:null}const kc=12e4,Ac=12e4;function Tc(n){switch(String(n).toLowerCase()){case"inactive":return je.Inactive;case"archived":return je.Archived;case"retired":return je.Retired;case"deleted":return je.Deleted;default:return je.Active}}function Te(n){const e=new Date().toISOString(),t=String(n.id??n.workspaceId??""),{defaultAgentPlacement:r,...s}=n;return{...s,...r===void 0?{}:{defaultAgentPlacement:Ds.parse(r)},id:er(t),title:String(n.title??n.name??t),branch:String(n.branch??""),status:Tc(n.status),changesets:Array.isArray(n.changesets)?n.changesets:[],timeline:Array.isArray(n.timeline)?n.timeline:[],conversationInfo:Array.isArray(n.conversationInfo)?n.conversationInfo:[],createdAt:String(n.createdAt??e),updatedAt:String(n.updatedAt??e)}}function jn(n){if(!n||typeof n!="object")return;const e=n.data;if(!e||typeof e!="object")return;const t=e.code;return typeof t=="string"&&t.length>0?t:void 0}function wc(n){if(!n||typeof n!="object")return;const e=n.data;if(!e||typeof e!="object")return;const t=e;if(t.code!=="launch-failed"||typeof t.workspaceId!="string"||t.workspaceId.length===0)return;const r=t.launch?.agentId,s=t.cause?.message;return{workspaceId:t.workspaceId,...typeof r=="string"&&r.length>0?{agentId:r}:{},...typeof s=="string"&&s.length>0?{cause:s}:{}}}function Dn(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.id=="string"&&e.id.length>0&&typeof e.type=="string"&&e.type.length>0}function Un(n,e){if(!li(n))throw new Error(`Invalid ${e} response shape`);return n}function Ec(n){if(n===null||typeof n!="object")return!1;const e=n;return typeof e.id=="string"&&e.id.length>0&&typeof e.title=="string"&&typeof e.archived=="boolean"&&typeof e.linkedAt=="string"}const Cc=["applied","dismissed","notResolved"];function Rc(n){if(!n||typeof n!="object")return;const{proposalId:e,outcome:t}=n;if(!(typeof e!="string"||typeof t!="string")&&Cc.includes(t))return{proposalId:e,outcome:t}}class _c{constructor(){y(this,"listRequests",new Map);y(this,"getRequests",new Map)}beginNativeReview(e,t,r){return gc().begin(e,t,r)}beginRepositorySelectionEdit(e,t){return mc().begin(e,t)}observeRepositoryContext(e,t){return hc().observe(e,t)}list(e){const t=e?.includeArchived===!0,r=e?.includeRetired===!0,s=`${t}:${r}`,o=r?void 0:this.listRequests.get(s);if(o)return o;const i={...t?{includeArchived:!0}:{},...r?{includeRetired:!0}:{}},a=at(l=>u("workspace.list",l),i,"workspaces").then(l=>(Array.isArray(l?.workspaces)?l.workspaces:[]).map(m=>Te(m)));if(r)return a;this.listRequests.set(s,a);const c=()=>{this.listRequests.get(s)===a&&this.listRequests.delete(s)};return a.then(c,c),a}get(e){const t=this.getRequests.get(e);if(t)return t;const r=u("workspace.get",{workspaceId:e}).then(o=>{const i=o&&typeof o=="object"&&"workspace"in o?o.workspace:o;return!i||typeof i!="object"?null:Te(i)});this.getRequests.set(e,r);const s=()=>{this.getRequests.get(e)===r&&this.getRequests.delete(e)};return r.then(s,s),r}async open(e){return this.get(e)}async create(e){try{const t=await u("workspace.create",{...e,idempotencyKey:e.idempotencyKey??Y()},{timeoutMs:Ac}),r=t?.workspace,s=t?.initialAgent,o=Rc(t?.proposalOrigin);let i;if(s!=null){if(typeof s!="object"||typeof s.id!="string"||s.id.length===0)return{success:!1,error:"workspace.create returned an initialAgent without a valid daemon-assigned id"};i=s}return r&&typeof r=="object"?{success:!0,workspace:Te(r),...i?{initialAgent:i}:{},...o?{proposalOrigin:o}:{}}:{success:!0}}catch(t){const r=t instanceof Error?t.message:String(t),s=ct(t);if(s)return{success:!1,error:r,conflict:s};const o=jn(t),i=wc(t);return o?{success:!1,error:r,errorCode:o,...i?{launchFailure:i}:{}}:{success:!1,error:r}}}async update(e){const{id:t,...r}=e;try{const o=(await u("workspace.update",{workspaceId:t,...r}))?.workspace;return o&&typeof o=="object"?{success:!0,workspace:Te(o)}:{success:!0}}catch(s){const o=s instanceof Error?s.message:String(s),i=ct(s);return i?{success:!1,error:o,conflict:i}:{success:!1,error:o}}}async delete(e,t){const r=t?.undoDelayMs;try{const s=await u("workspace.delete",r&&r>0?{workspaceId:e,undoDelayMs:r}:{workspaceId:e},{timeoutMs:kc}),o=s?.scheduled===!0,i=typeof s?.deleteAt=="string"?s.deleteAt:void 0;return o&&i?{success:!0,scheduled:!0,deleteAt:i}:{success:!0}}catch(s){return{success:!1,error:_(s)}}}async findByPullRequest(e){const r=(await u("workspace.findByPullRequest",{url:e}))?.workspaces;if(!Array.isArray(r)||!r.every(Ec))throw new Error("Invalid workspace.findByPullRequest response shape");return r}async cancelDelete(e){try{return{success:!0,cancelled:(await u("workspace.cancelDelete",{workspaceId:e}))?.cancelled===!0}}catch(t){return{success:!1,error:_(t)}}}async archive(e){return b("workspace.archive",{workspaceId:e})}async unarchive(e){return b("workspace.unarchive",{workspaceId:e})}async retire(e){try{const r=(await u("workspace.retire",{workspaceId:e}))?.workspace;return{success:!0,...r&&typeof r=="object"?{workspace:Te(r)}:{}}}catch(t){const r=jn(t);return{success:!1,error:_(t),...r?{errorCode:r}:{}}}}async markSeen(e){return b("workspace.markSeen",{workspaceId:e})}async setActive(e){return b("workspace.setActive",{workspaceId:e})}async recentViews(){return{}}async getTokenUsage(e){const r=(await u("workspace.getTokenUsage",{workspaceId:e}))?.tokenUsage;return r&&typeof r=="object"?Ic(r):null}async diskUsage(e){try{const t=await u("workspace.diskUsage",{workspaceId:e}),r=t?.diskUsage,s={refreshing:t?.refreshing===!0};return r&&typeof r=="object"&&(s.diskUsage=r),s}catch(t){if(t instanceof tr&&(t.rpcCode===-32601||t.code==="METHOD_NOT_FOUND"))return null;throw t}}async getContext(e){const t=await u("workspace.getContext",{workspaceId:e});return(Array.isArray(t?.items)?t.items:[]).filter(Dn)}async updateContext(e,t){const r=await u("workspace.updateContext",{workspaceId:e,items:t});return(Array.isArray(r?.items)?r.items:[]).filter(Dn)}async getBrowserClient(e){const t=await u("workspace.getBrowserClient",{workspaceId:e});return Un(t?.browserClient,"workspace.getBrowserClient")}async setBrowserClient(e,t){const r=await u("workspace.setBrowserClient",{workspaceId:e,clientId:t});return Un(r?.browserClient,"workspace.setBrowserClient")}subscribe(e){return Ye({channel:{subscribeMethod:"workspace.subscribe",unsubscribeMethod:"workspace.unsubscribe",continuation:{method:"workspace.list",key:"workspaces",params:t=>({includeArchived:!0,...t.includeRetired===!0?{includeRetired:!0}:{}})}},getId:t=>String(t.id??t.workspaceId??""),normalize:t=>Te(t),handler:e})}}class $r{constructor(){y(this,"workspaces",new _c);y(this,"agents",new oi);y(this,"notes",new Ea);y(this,"tasks",new cc);y(this,"comments",new qi);y(this,"git",new fa);y(this,"files",new ta);y(this,"terminals",new pc);y(this,"settings",new Fa);y(this,"specialists",new Ja);y(this,"integrations",new ya);y(this,"scripts",new _a);y(this,"setupScripts",new Ha);y(this,"events",new Hi);y(this,"models",new Sa);y(this,"providers",new Ca);y(this,"stats",new Za);y(this,"voice",new tc);y(this,"chat",new Ni);y(this,"skills",new Va);y(this,"browser",new pi);y(this,"system",new rc);y(this,"server",new Dr);y(this,"drafts",new Fi);y(this,"clients",new Li)}}const tt={FileChanged:"file:changed",AgentIdle:"agent:idle",NoteUpdated:"note:updated",TaskStatusChanged:"task:status-changed"},dt="2026-01-01T00:00:00.000Z",M=er("ws-mock-1"),Oc=As("00000000-0000-4000-8000-000000000010"),Hr=`terminal-${M}-default`,Wr=`terminal-${M}-2`,qn=[{id:Hr,name:"Terminal",type:"terminal",workspaceId:String(M),createdAt:dt},{id:Wr,name:"Terminal 2",type:"terminal",workspaceId:String(M),createdAt:dt}],Fn={[Hr]:`$ pnpm run dev\r
|
|
1
|
+
var Vr=Object.defineProperty;var Kt=n=>{throw TypeError(n)};var zr=(n,e,t)=>e in n?Vr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var y=(n,e,t)=>zr(n,typeof e!="symbol"?e+"":e,t),ht=(n,e,t)=>e.has(n)||Kt("Cannot "+t);var T=(n,e,t)=>(ht(n,e,"read from private field"),t?t.call(n):e.get(n)),H=(n,e,t)=>e.has(n)?Kt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ke=(n,e,t,r)=>(ht(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),vt=(n,e,t)=>(ht(n,e,"access private method"),t);import{e as Jn,c as Kr,C as Yr,g as Jr}from"./0I000Ru9.js";import{bo as E}from"./GWL2EpD7.js";import{fr as Zr,ah as ve,p_ as Zn,c as Qr,b as bt,b9 as Qn,zk as Xr,a6 as es,i as ot,kI as ts,l$ as ns,G0 as rs,S as St,a3 as It,ak as ss,t as os,aj as is,d as as,aA as cs,aB as us,aH as ls,au as ds,aD as fs,az as ps,aG as gs,ay as ys,aC as ms,aE as hs,ax as vs,aF as bs,as as Ss,aw as Is,av as ks,mw as Xn,hK as er,ba as je,hB as As,hm as Ts,aP as ws}from"./C2YltVuJ.js";import{br as se,bs as oe,ax as u,aK as Es,aL as Cs,bp as Rs,ay as $t,aA as Ne,bz as _s,$ as Os,_ as Ms,ah as Ps,aN as Ns,aM as Ls}from"./Dayd4Wgp.js";import{b as Yt,B as tr}from"./CsjyI82U.js";import{c as ze}from"./ChTqQfQN.js";import{bV as xs,br as Bs,aD as ge,bH as kt}from"./B8o4lNgr.js";import{a as js}from"./BJzHxIyr.js";import{i as ye}from"./CbVPen4y.js";import{I as k,b as Ds}from"./BeYie-c5.js";import{i as Us,C as nr,g as qs}from"./DypB-Dwi.js";import{r as Q,b as Fs,i as $s}from"./DVkfuwKw.js";import{o as Ke,s as Se,n as X,b as Hs,Z as Ws,r as At}from"./CpHIRYx9.js";const Gs=["high","medium","low"],Vs=["pending","in_progress","completed"],zs=256;function K(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ks(n){return K(n)?typeof n.content=="string"&&Gs.includes(n.priority)&&Vs.includes(n.status):!1}function rr(n){return K(n)&&n.type==="plan"&&Array.isArray(n.entries)&&n.entries.length<=zs&&n.entries.every(Ks)}function Jt(n){return n?.type==="plan"?rr(n):typeof n=="object"&&n!==null&&(typeof n.type=="string"&&["text","code","tool_use","tool_result","thinking","image","audio","video","file","nav-link","proposal","plan"].includes(n.type)||n.kind==="nav-link"&&typeof n.target=="string"||Jn(n.kind)&&!!n.preview)}const Ys=/\.(?:mp4|webm|mov|m4v)$/i,Js=/^video\/[a-z0-9][a-z0-9.+-]*$/i,Zs=new Set(["video/mp4","video/webm","video/quicktime","video/x-m4v","video/m4v"]);function xt(n){if(typeof n!="string")return;const e=n.split(";",1)[0].trim().toLowerCase();return Js.test(e)?e:void 0}function Qs(n,e){if(typeof n!="string"||n.length===0||n!==n.trim())return null;let t;try{t=new URL(n)}catch{return null}if(t.protocol!=="https:"||t.username||t.password)return null;const r=xt(e),s=r&&Zs.has(r)?r:void 0;return!s&&!Ys.test(t.pathname)?null:{kind:"remote",url:n,...s?{mimeType:s}:{}}}function Xs(n,e){if(typeof n!="string"||!n.startsWith("intent://local/")||!e||!/^[A-Za-z0-9._-]+$/.test(e)||n.includes("?")||n.includes("#"))return null;const r=n.slice(9).split("/").slice(1);let s,o;if(r[0]==="file")s=e,o=r.slice(1);else if(r.length>=3&&r[1]==="file"){try{s=decodeURIComponent(r[0])}catch{return null}if(s!==e)return null;o=r.slice(2)}else return null;const i=[];for(const l of o){let d;try{d=decodeURIComponent(l)}catch{return null}if(!d||d==="."||d===".."||d.includes("/")||d.includes("\\")||d.includes("\0"))return null;i.push(d)}if(i.length===0||/^[A-Za-z]:/.test(i[0]))return null;const a=i[i.length-1].toLowerCase(),c=a.endsWith(".mp4")?"video/mp4":a.endsWith(".webm")?"video/webm":null;return c?{kind:"workspace",url:`workspace-file://${s}/${i.map(encodeURIComponent).join("/")}`,mimeType:c}:null}function Tt(n,e,t){return Qs(n,e)??Xs(n,t)}function De(n,e,t){return{type:"video",source:e,...typeof n.id=="string"?{id:n.id}:{},...K(n.metadata)?{metadata:n.metadata}:{},...typeof t=="string"&&t.length>0?{fileName:t}:{}}}function eo(n,e){if(!K(n))return null;const t=n.type;if((t==="file"||t==="blob")&&typeof n.data=="string"&&n.data){const r=xt(n.mimeType);if(r)return De(n,{kind:"inline",data:n.data,mimeType:r},n.fileName)}if(t==="resource"&&K(n.resource)){const r=n.resource,s=xt(r.mimeType);if(s&&typeof r.blob=="string"&&r.blob)return De(n,{kind:"inline",data:r.blob,mimeType:s},r.name);const o=Tt(r.uri,r.mimeType,e);return o?De(n,o,r.name):null}if(t==="resource_link"){const r=Tt(n.uri,n.mimeType,e);return r?De(n,r,n.name):null}if(t==="file"){const r=Tt(n.url??n.uri,n.mimeType,e);return r?De(n,r,n.fileName):null}return null}function Zt(n,e){if(!Array.isArray(n))return n;let t=!1;const r=n.map(s=>{const o=sr(s,e);return o!==s&&(t=!0),o});return t?r:n}function sr(n,e){const t=eo(n,e);if(t)return t;if(!K(n)||n.type!=="tool_result")return n;const r=Zt(n.output,e),s=Zt(n.content,e);return r===n.output&&s===n.content?n:{...n,output:r,content:s}}function su(n,e,t){if(e!=="assistant")return n;let r=!1;const s=n.map(o=>{const i=sr(o,t);return i!==o&&(r=!0),i});return r?s:n}function to(n){return n.kind==="inline"?`inline:${n.mimeType}:${n.data}`:`${n.kind}:${n.url}`}function ou(n){const e=new Set;function t(r){let s=!1;const o=[];for(const i of r){if(K(i)&&i.type==="video"&&K(i.source)){const a=i.source,c=to(a);if(e.has(c)){s=!0;continue}e.add(c)}if(K(i)&&i.type==="tool_result"){const a=Array.isArray(i.output)?t(i.output):i.output,c=Array.isArray(i.content)?t(i.content):i.content;if(a!==i.output||c!==i.content){o.push({...i,output:a,content:c}),s=!0;continue}}o.push(i)}return s?o:r}return t(n)}const no=new Set(["text","code","tool_use","tool_result","thinking","image","audio","file","nav-link","proposal","plan"]);function ro(n){return{content:n.content,priority:n.priority,status:n.status}}function so(n){if(!rr(n))throw new Error(`Invalid plan block: required bounded 'entries' snapshot missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);return{type:"plan",...typeof n.id=="string"?{id:n.id}:{},entries:n.entries.map(ro)}}const Qt=/^image\/[a-z0-9][a-z0-9.+-]*$/i;function oo(n){const e=Object.prototype.hasOwnProperty.call(n,"data"),t=typeof n.data=="string",r=n.dataTruncated!==void 0,s=n.dataIsThumbnail!==void 0,o=n.dataBytes!==void 0;if(Object.prototype.hasOwnProperty.call(n,"attachmentId")){if(typeof n.attachmentId!="string"||n.attachmentId.trim().length===0||e||r||s||o||n.mimeType!==void 0&&(typeof n.mimeType!="string"||!Qt.test(n.mimeType)))throw new Error("Invalid image attachment reference (PROTOCOL §5.5)");return}if(typeof n.mimeType!="string"||!Qt.test(n.mimeType))throw new Error(`Invalid image block: required image 'mimeType'. Received: ${JSON.stringify(n)}`);if(e&&!t)throw new Error(`Invalid image block: present 'data' must be a string. Received: ${JSON.stringify(n)}`);if(!r){if(!t||s||o)throw new Error(`Invalid image block: full images require 'data' without slim flags. Received: ${JSON.stringify(n)}`);return}if(n.dataTruncated!==!0||!Number.isSafeInteger(n.dataBytes)||n.dataBytes<0||(t?n.dataIsThumbnail!==!0:s))throw new Error(`Invalid image block: malformed slim projection metadata. Received: ${JSON.stringify(n)}`)}function io(n){if(!n||typeof n!="object")throw new Error("Invalid block: must be an object");const e=Kr(n);if(e)return{type:"proposal",kind:e.kind,payload:e.payload,preview:e.preview,applyToolCallId:e.applyToolCallId,proposal:e,id:n.id,metadata:n.metadata};if(n.kind==="nav-link"&&typeof n.target=="string")return{type:"nav-link",kind:"nav-link",target:n.target,label:n.label,id:n.id,metadata:n.metadata};if((n.type==="proposal"||Jn(n.kind))&&n.preview){const t=n.proposal??{kind:n.kind,payload:n.payload??{},preview:n.preview,applyToolCallId:n.applyToolCallId};return{type:"proposal",kind:t.kind,payload:t.payload,preview:t.preview,applyToolCallId:t.applyToolCallId,proposal:t,id:n.id,metadata:n.metadata}}if(typeof n.type!="string")throw new Error(`Invalid ContentBlock: missing canonical 'type' field (PROTOCOL §7). Received: ${JSON.stringify(n)}`);if(!no.has(n.type))throw new Error(`Invalid ContentBlock: unknown 'type' "${n.type}" (PROTOCOL §7). Received: ${JSON.stringify(n)}`);return ao(n),co(n)}function ao(n){if(n.text===void 0&&typeof n.content=="string")throw new Error(`Invalid ContentBlock: legacy 'content' field is not part of PROTOCOL §7 (use 'text'). Received: ${JSON.stringify(n)}`);if(n.name===void 0&&typeof n.toolName=="string")throw new Error(`Invalid ContentBlock: legacy 'toolName' field is not part of PROTOCOL §7 (use 'name'). Received: ${JSON.stringify(n)}`);if(n.type==="tool_result"&&n.tool_use_id===void 0&&typeof n.toolCallId=="string")throw new Error(`Invalid ContentBlock: tool_result must use 'tool_use_id' (PROTOCOL §7). Received: ${JSON.stringify(n)}`);if(n.is_error===void 0&&n.isError!==void 0)throw new Error(`Invalid ContentBlock: legacy 'isError' field is not part of PROTOCOL §7 (use 'is_error'). Received: ${JSON.stringify(n)}`)}function co(n){switch(n.type){case"text":case"thinking":if(typeof n.text!="string")throw new Error(`Invalid ${n.type} block: required 'text' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"tool_use":if(typeof n.name!="string")throw new Error(`Invalid tool_use block: required 'name' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"tool_result":if(typeof n.tool_use_id!="string")throw new Error(`Invalid tool_result block: required 'tool_use_id' field missing (PROTOCOL §7). Received: ${JSON.stringify(n)}`);break;case"image":oo(n);break;case"audio":if(typeof n.data!="string"||typeof n.mimeType!="string")throw new Error(`Invalid ${n.type} block: required 'data'/'mimeType' fields missing. Received: ${JSON.stringify(n)}`);break;case"file":if(typeof n.attachmentId!="string"||n.attachmentId.length===0||typeof n.fileName!="string"||n.fileName.length===0)throw new Error(`Invalid file block: required 'attachmentId'/'fileName' fields missing (PROTOCOL §5.5). Received: ${JSON.stringify(n)}`);break;case"code":case"nav-link":case"proposal":break;case"plan":return so(n)}return{...n}}const uo=["user","assistant","tool","system","error"];function or(n){return typeof n=="number"&&Number.isInteger(n)&&n>0}function ir(n){if(!n||typeof n!="object")return null;const e=n;return or(e.position)?e:null}function lo(n){const{position:e,queueSize:t}=n;return or(t)&&t>=e?E.shared_mergeQueue_positionOfTotal_label({position:e,total:t}):E.shared_mergeQueue_position_label({position:e})}function fo(n){if(typeof n!="number"||!Number.isFinite(n)||n<0)return null;const e=Math.max(1,Math.ceil(n/60));return e<60?E.shared_mergeQueue_etaMinutes_label({minutes:e}):E.shared_mergeQueue_etaHours_label({hours:Math.floor(e/60),minutes:e%60})}function iu(n){const e=ir(n);if(!e)return null;const t=fo(e.estimatedTimeToMerge),r=lo(e);return t?`${r} · ${t}`:r}const au=k.AGENT,cu=k.WORKSPACE,uu=k.FILE,lu=k.SYSTEM,du=k.WINDOW,fu=k.BROWSER_ACCESS,pu=k.QUIT_CONFIRMATION,gu=k.INVITE_CONSENT,yu=k.INVITE_PROGRESS,mu=k.INVITE_NOTICE,hu=k.AUGGIE,vu=k.OPENCODE,bu=k.CLAUDE_CODE,Su=k.CODEX,Iu=k.CORTEX,ku=k.PI,Au=k.DROID,Tu=k.GROK,wu=k.UNSLOTH,Eu=k.ANTIGRAVITY,Cu=k.PROVIDERS,Ru=k.SETTINGS,_u=k.FEATURE_CODES,Ou=k.USER_MCP,Mu=k.DEEP_LINK,Pu=k.PANEL_LAYOUT,po=k.LOG,Nu=k.USER_ACTIVITY,Lu=k.COLLABORATION_AUTH,ar=-32602,Bt="not-found";function xu(n){if(!n||typeof n!="object"||n.rpcCode!==ar)return!1;const e=n.data;return!e||typeof e!="object"?!1:e.code===Bt}function go(n){if(!n||typeof n!="object")return!1;const{message:e,rpcCode:t,code:r,data:s}=n,o=s&&typeof s=="object"?s.code:void 0;return r===Bt||o===Bt?!0:t===ar&&typeof e=="string"&&/not found/i.test(e)}function yo(n){if(n.notificationsMuted===!0||Zr(n)!=="topLevel"||n.lastMessageRole!=="assistant")return!1;const e=Xt(n.lastMessageId);return e===void 0?!1:e!==Xt(n.metadata?.lastSeenMessageId)}function Xt(n){return typeof n=="string"&&n.length>0?n:void 0}const mo=1e3;async function at(n,e,t){const r=e??{},s=await n(Object.keys(r).length>0?r:void 0);if(!s||typeof s!="object")return s;const o=s[t];let i=s.nextToken;if(typeof i!="string"||i.length===0)return s;const a=Array.isArray(o)?[...o]:[];for(let c=1;typeof i=="string"&&i.length>0&&!(c>=mo);c+=1){const l=await n({...r,nextToken:i}),d=l&&typeof l=="object"?l[t]:void 0;Array.isArray(d)&&a.push(...d),i=l&&typeof l=="object"?l.nextToken:void 0}return{...s,[t]:a,nextToken:null}}const ho="application/vnd.intent.secret-request+json";function vo(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.requestId=="string"&&e.requestId.length>0&&typeof e.agentId=="string"&&typeof e.name=="string"&&e.name.length>0&&typeof e.reason=="string"}function bo(n){if(!n||typeof n!="object")return!1;const e=n;if(e.type!=="resource")return!1;const t=e.resource;return typeof t=="object"&&t!==null&&t.mimeType===ho}function Bu(n){if(!bo(n))return null;const e=n.resource.text;if(typeof e!="string")return null;try{const t=JSON.parse(e);return vo(t)?t:null}catch{return null}}function cr(n){return!!n&&typeof n=="object"&&typeof n.name=="string"}function ur(n){return cr(n)&&typeof n.requestId=="string"}function So(n){const e=n?.outcome;return ur(n)&&(e==="provided"||e==="declined")}function Io(n){if(!n||typeof n!="object")return null;const e=n,t=r=>Array.isArray(e[r])?e[r]:[];return{secrets:t("secrets").filter(cr).map(({name:r})=>({name:r})),pendingRequests:t("pendingRequests").filter(ur).map(({requestId:r,name:s})=>({requestId:r,name:s})),answeredRequests:t("answeredRequests").filter(So).map(({requestId:r,name:s,outcome:o})=>({requestId:r,name:s,outcome:o}))}}const ko=ze("DeltaSubscription");function Ao(n,e){if(n!=="subscription.push"||!e||typeof e!="object")return null;const t=e,r=typeof t.subscriptionId=="string"?t.subscriptionId:void 0,s=typeof t.seq=="number"?t.seq:void 0;if(!r||s===void 0)return null;if(t.kind==="snapshot")return{subscriptionId:r,kind:"snapshot",seq:s,snapshot:Array.isArray(t.snapshot)?t.snapshot:[],...typeof t.nextToken=="string"&&t.nextToken.length>0?{nextToken:t.nextToken}:{}};if(t.kind==="delta"){const o=t.delta&&typeof t.delta=="object"?t.delta:{};return{subscriptionId:r,kind:"delta",seq:s,delta:{added:Array.isArray(o.added)?o.added:[],updated:Array.isArray(o.updated)?o.updated:[],removedIds:Array.isArray(o.removedIds)?o.removedIds.map(i=>String(i)):[]}}}return null}class en{constructor(e,t){y(this,"items",new Map);y(this,"removedSinceSnapshot",new Set);y(this,"changedSinceSnapshot",new Set);y(this,"expectedSeq",0);y(this,"seeded",!1);y(this,"epochValue",0);this.getId=e,this.normalize=t}reset(){this.items.clear(),this.removedSinceSnapshot.clear(),this.changedSinceSnapshot.clear(),this.expectedSeq=0,this.seeded=!1,this.epochValue+=1}get epoch(){return this.epochValue}applySnapshot(e,t){this.items.clear(),this.removedSinceSnapshot.clear(),this.changedSinceSnapshot.clear(),this.epochValue+=1;for(const r of t)this.upsert(r);this.expectedSeq=e+1,this.seeded=!0}applyDelta(e,t){if(!this.seeded||e!==this.expectedSeq)return!1;for(const r of[...t.added??[],...t.updated??[]])if(this.upsert(r),r&&typeof r=="object"){const s=this.getId(r);s&&this.changedSinceSnapshot.add(s)}for(const r of t.removedIds??[])this.items.delete(String(r)),this.removedSinceSnapshot.add(String(r));return this.expectedSeq=e+1,!0}fillFromPage(e){for(const t of e){if(!t||typeof t!="object")continue;const r=this.getId(t);!r||this.items.has(r)||this.removedSinceSnapshot.has(r)||this.upsert(t)}}completeRow(e){const t=this.getId(e);return!t||!this.items.has(t)||this.changedSinceSnapshot.has(t)?!1:(this.upsert(e),!0)}values(){return[...this.items.values()]}upsert(e){if(!e||typeof e!="object")return;const t=e,r=this.getId(t);if(!r)return;const s=this.normalize(t);s!==null&&this.items.set(r,s)}}const To=32,wo=1e3,tn=3,Eo=250,Co=1e3,Ro=3e4;function Ue(n){return Math.min(Co*2**n,Ro)}function Ye(n){const{channel:e,getId:t,normalize:r,handler:s}=n,o=e.dynamic,i={...e.params},a=(g,p)=>({subscriptionId:g,...typeof p.workspaceId=="string"?{workspaceId:p.workspaceId}:{}}),c=new en(t,r);let l=!1,d,m=0,I=0,w=0,S;const A=new Map,N=[],ie=g=>{N.push(g),N.length>To&&N.shift()},J=g=>{const p=N.filter(f=>f.subscriptionId===g);for(const f of p)N.splice(N.indexOf(f),1);for(const f of p)ue(f)},ae=()=>{if(!o)return c.values();const g=[];for(const p of A.values())g.push(...p.reconciler.values());return g},U=()=>{l||s(ae())},ce=()=>{if(o){for(const g of A.values())if(g.subscriptionId===void 0)return!0;return!1}return d===void 0},q=()=>{N.length>0&&!ce()&&(N.length=0)},j=()=>{if(o)return;S!==void 0&&(clearTimeout(S),S=void 0),m+=1;const g=m;u(e.subscribeMethod,i).then(p=>{const f=p?.subscriptionId;if(g!==m||l){f&&u(e.unsubscribeMethod,a(f,i)).catch(()=>{});return}if(!f){const h=Ue(I);I+=1,S=setTimeout(()=>{S=void 0,l||j()},h);return}d=f,I=0,J(f),q()}).catch(()=>{if(g!==m||l)return;const p=Ue(I);I+=1,S=setTimeout(()=>{S=void 0,l||j()},p)})},Z=()=>{if(o||(m+=1,S!==void 0&&(clearTimeout(S),S=void 0),!d))return;const g=d;d=void 0,u(e.unsubscribeMethod,a(g,i)).catch(()=>{})},B=(g,p)=>{if(!o)return;p.retryTimer!==void 0&&(clearTimeout(p.retryTimer),p.retryTimer=void 0),p.generation+=1;const f=p.generation;u(e.subscribeMethod,p.params).then(h=>{const v=h?.subscriptionId;if(l||A.get(g)!==p||f!==p.generation){v&&u(e.unsubscribeMethod,a(v,p.params)).catch(()=>{});return}if(!v){const C=Ue(p.retryAttempt);p.retryAttempt+=1,p.retryTimer=setTimeout(()=>{p.retryTimer=void 0,!l&&A.get(g)===p&&B(g,p)},C);return}p.subscriptionId=v,p.retryAttempt=0,J(v),q()}).catch(()=>{if(l||A.get(g)!==p||f!==p.generation)return;const h=Ue(p.retryAttempt);p.retryAttempt+=1,p.retryTimer=setTimeout(()=>{p.retryTimer=void 0,!l&&A.get(g)===p&&B(g,p)},h)})},V=g=>{g.generation+=1,g.retryTimer!==void 0&&(clearTimeout(g.retryTimer),g.retryTimer=void 0);const p=g.subscriptionId;g.subscriptionId=void 0,p&&u(e.unsubscribeMethod,a(p,g.params)).catch(()=>{})},z=(g,p)=>{p.awaitingResnapshot||(p.awaitingResnapshot=!0,p.seeded=!1,p.reconciler.reset(),V(p),B(g,p),U())},yt=g=>{if(l||!o)return;const p=new Set(g);let f=!1;for(const[h,v]of[...A])p.has(h)||(A.delete(h),V(v),f=!0);for(const h of p){if(A.has(h))continue;const v={generation:0,params:{...o.paramsForId(h)},reconciler:new en(t,r),seeded:!1,awaitingResnapshot:!1,retryAttempt:0,continuationFailures:0};A.set(h,v),B(h,v),f=!0}f&&U()},Je=()=>{c.reset(),Z(),j()},xe=(g,p,f,h)=>{const v=e.continuation;if(!v)return;const C=g.epoch,R=()=>l||g.epoch!==C;(async()=>{let de=f;for(let zt=0;de&&zt<wo;zt+=1){let fe;for(let pe=0;pe<tn;pe+=1){if(pe>0&&(await new Promise(Gr=>setTimeout(Gr,Eo*2**(pe-1))),R())||(fe=await u(v.method,{...v.params(p),nextToken:de}).catch(()=>{}),R()))return;if(fe)break}if(!fe){const pe=h.failures();ko.warn(`${v.method} continuation page failed ${tn} times; resubscribing ${e.subscribeMethod} for a fresh snapshot`),h.setFailures(pe+1),setTimeout(()=>{R()||h.resubscribe()},Ue(pe));return}const Ze=fe[v.key];g.fillFromPage(Array.isArray(Ze)?Ze:[]),U(),Ie(g,Array.isArray(Ze)?Ze:[]),de=typeof fe.nextToken=="string"&&fe.nextToken?fe.nextToken:null}h.setFailures(0)})()},Ie=(g,p)=>{const f=n.complete;if(!f)return;const h=g.epoch;for(const v of p){if(!v||typeof v!="object")continue;const C=f(v);C&&C.then(R=>{l||g.epoch!==h||g.completeRow(R)&&U()}).catch(()=>{})}},ue=g=>{if(!l){if(o){for(const[p,f]of A)if(f.subscriptionId===g.subscriptionId){g.kind==="snapshot"?(f.awaitingResnapshot=!1,f.seeded=!0,f.reconciler.applySnapshot(g.seq,g.snapshot??[]),U(),Ie(f.reconciler,g.snapshot??[]),g.nextToken&&xe(f.reconciler,f.params,g.nextToken,{failures:()=>f.continuationFailures,setFailures:h=>{f.continuationFailures=h},resubscribe:()=>{A.get(p)===f&&z(p,f)}})):f.awaitingResnapshot||(f.reconciler.applyDelta(g.seq,g.delta??{})?U():z(p,f));return}ce()&&ie(g);return}if(g.subscriptionId!==d){ce()&&ie(g);return}g.kind==="snapshot"?(c.applySnapshot(g.seq,g.snapshot??[]),U(),Ie(c,g.snapshot??[]),g.nextToken&&xe(c,i,g.nextToken,{failures:()=>w,setFailures:p=>{w=p},resubscribe:Je})):c.applyDelta(g.seq,g.delta??{})?U():Je()}},Be=se(g=>{const p=Ao(g.method,g.params);p&&ue(p)}),mt=oe(()=>{if(!l){m+=1,d=void 0,I=0,S!==void 0&&(clearTimeout(S),S=void 0),c.reset(),N.length=0;for(const[g,p]of A)p.generation+=1,p.subscriptionId=void 0,p.seeded=!1,p.awaitingResnapshot=!1,p.retryAttempt=0,p.retryTimer!==void 0&&(clearTimeout(p.retryTimer),p.retryTimer=void 0),p.reconciler.reset(),B(g,p);o||j()}}),le=o?o.subscribeIds(yt):void 0;return o||j(),()=>{l=!0,S!==void 0&&(clearTimeout(S),S=void 0),Be(),mt(),le?.(),Z();for(const g of A.values())V(g);A.clear()}}const _o=1e3;function Oo(n){if(!n||typeof n!="object")return;const e=n.nextToken;return typeof e=="string"&&e.length>0?e:void 0}async function Re(n,e,t){const r=[],s=new Set;let o;for(let i=0;i<_o;i++){const a=await n(o?{...e,nextToken:o}:e),c=a&&typeof a=="object"?a[t]:void 0;if(Array.isArray(c)&&r.push(...c),o=Oo(a),!o||s.has(o))break;s.add(o)}return r}function Mo(n){const e=new Map,t=[];for(const r of n){const s=r&&typeof r=="object"?r.threadId:void 0;if(typeof s!="string"||!s){t.push(r);continue}e.delete(s),e.set(s,r)}return[...e.values(),...t]}function lr(n,e){if(!n||typeof n!="object")return null;const t=n;return t.commentsTruncated!==!0||typeof t.threadId!="string"?null:e(t.threadId).then(r=>{if(!r||typeof r!="object")return t;const{rootComment:s,replies:o}=r;if(!s||typeof s!="object"||!Array.isArray(o))return t;const{commentsTruncated:i,...a}=t;return{...a,comments:[s,...o]}},()=>t)}async function Po(n,e,t){const r=Mo(await Re(n,e,"threads"));return Promise.all(r.map(s=>lr(s,t)??s))}const No=1e3;function nn(n){if(!n||typeof n!="object")return;const e="note"in n?n.note:n;return e&&typeof e=="object"?e:void 0}function rn(n){const e=n.nextContentOffset;return n.contentTruncated===!0&&typeof e=="number"&&e>0?e:void 0}async function Lo(n,e,t){const r=nn(t);if(!r)return{result:t,retry:!1};let s=rn(r);if(s===void 0)return{result:t,retry:!1};let o=typeof r.content=="string"?r.content:"";for(let w=1;w<No&&s!==void 0;w++){const S=nn(await n({...e,contentOffset:s}));if(S&&S.rev!==r.rev)return{result:t,retry:!0};if(!S||typeof S.content!="string"||S.contentOffset!==s)return{result:t,retry:!1};o+=S.content,s=rn(S)}if(s!==void 0||new TextEncoder().encode(o).length!==r.contentBytes)return{result:t,retry:!1};const{contentTruncated:i,contentBytes:a,contentOffset:c,nextContentOffset:l,...d}=r,m={...d,content:o};return{result:t&&typeof t=="object"&&"note"in t?{...t,note:m}:m,retry:!1}}async function dr(n,e){let t;for(let r=0;r<3;r++){t=await n(e);const{result:s,retry:o}=await Lo(n,e,t);if(!o)return s}return t}function Y(){const n=globalThis.crypto;return typeof n?.randomUUID=="function"?n.randomUUID():`idk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function _(n){const e=n instanceof Error?n.message:String(n);if(e==="Internal error"&&n&&typeof n=="object"){const t=n.data;if(typeof t=="string"&&t.length>0)return`${e}: ${t}`;if(t&&typeof t=="object"){const r=t.detail;if(typeof r=="string"&&r.length>0)return`${e}: ${r}`}}return e}const xo=-32005;function ct(n){if(!n||typeof n!="object"||n.rpcCode!==xo)return;const e=n.data;if(!(!e||typeof e!="object")&&e.code==="conflict")return{current:e.current}}function Bo(n){if(!n||typeof n!="object")return;const e=n.noteRev;return typeof e=="number"&&Number.isFinite(e)?e:void 0}function jo(n){if(!n||typeof n!="object")return;const{newContent:e,rev:t}=n;if(typeof e=="string")return typeof t=="number"&&Number.isFinite(t)?{newContent:e,rev:t}:{newContent:e}}async function b(n,e,t){try{const r=await(t!==void 0?u(n,e,t):u(n,e)),s=jo(r),o=Bo(r)??s?.rev;return{success:!0,...o!==void 0?{noteRev:o}:{},...s!==void 0?{newContent:s.newContent}:{}}}catch(r){const s=ct(r);return s?{success:!1,error:_(r),conflict:s}:Do(r)?{success:!1,error:_(r),contentBaseMismatch:!0}:{success:!1,error:_(r)}}}function Do(n){if(!n||typeof n!="object"||n.rpcCode!==-32602)return!1;const e=n.data;return!!e&&typeof e=="object"&&e.code==="content-base-mismatch"}function Uo(n){if(!n||typeof n!="object")return;const e=n,t=e.id;if(typeof t=="string"&&t.length>0)return t;for(const r of["task","note","entity"]){const s=e[r];if(s&&typeof s=="object"){const o=s.id;if(typeof o=="string"&&o.length>0)return o}}}async function jt(n,e,t){try{const r=await(t!==void 0?u(n,e,t):u(n,e)),s=Uo(r);return s!==void 0?{success:!0,id:s}:{success:!0}}catch(r){const s=ct(r);return s?{success:!1,error:_(r),conflict:s}:{success:!1,error:_(r)}}}const qo=2e3;let _e=null,we=null;function Fo(n,e){console.debug(`[live-support] workspace.list RPC (${n})${e?`: ${e}`:""}`)}function fr(n,e){if(we)return we;Fo(n,e);const t=at(r=>u("workspace.list",r),void 0,"workspaces").then(r=>{const o=(Array.isArray(r?.workspaces)?r.workspaces:[]).map(i=>String(i.id??i.workspaceId??"")).filter(i=>i.length>0);return _e={ids:o,fetchedAt:Date.now()},o});return we=t,t.catch(()=>{}).finally(()=>{we===t&&(we=null)}),t}async function $o(n){return P!==null?[...P]:_e!==null&&Date.now()-_e.fetchedAt<qo?[..._e.ids]:fr(n)}const Ho=["workspace:created","workspace:updated","workspace:deleted"],Wo=250;let P=null,Ee=0;const ut=new Map;let Go=0,wt=null,Et=null,ne=0,Dt=!1,Ce=!1,Oe;function Ht(){const n=P?[...P]:[];for(const e of ut.values())e(n)}function pr(n,e){Dt=!0;const t=ne;we!==null&&(Ce=!0),fr(n,e).then(r=>{ne!==t&&(Ee===0||(Ce=!0,P!==null))||(P=new Set(r),ne+=1,Ht())}).catch(()=>{if(P===null)for(const r of ut.values())r([])}).finally(()=>{Dt=!1,Ce&&(Ce=!1,Oe=setTimeout(()=>{Oe=void 0,Ee>0&&pr("follow-up")},Wo))})}function te(n,e){if(Oe===void 0){if(Dt){Ce=!0;return}pr(n,e)}}function sn(n){if(!P){ne+=1,te("defensive-resync","workspace event before seed settled");return}P.has(n)||(P.add(n),ne+=1,_e=null,Ht())}function on(n){if(!P){ne+=1,te("defensive-resync","workspace event before seed settled");return}P.has(n)&&(P.delete(n),ne+=1,_e=null,Ht())}function Vo(n){if(!n||typeof n!="object")return;const e=n.event;return e&&typeof e=="object"?e.data:n.data}function an(n){if(!n||typeof n!="object")return;const e=n;if(typeof e.workspaceId=="string"&&e.workspaceId.length>0)return e.workspaceId;const t=e.workspace;if(t&&typeof t=="object"){const r=t.id;if(typeof r=="string"&&r.length>0)return r}}function zo(n){if(!n||typeof n!="object")return!1;const e=n.workspace;return!e||typeof e!="object"?!1:e.archived===!0}function Ko(n,e){if(!Zo(n,e,Ho))return;const t=yr(e);if(t===void 0){te("defensive-resync","typeless event payload");return}const r=Vo(e);if(t==="workspace:created"){const s=an(r);if(!s){te("defensive-resync",`${t} without workspace id`);return}if(zo(r))return;sn(s);return}if(t==="workspace:deleted"){const s=an(r);if(!s){te("defensive-resync",`${t} without workspace id`);return}on(s);return}if(t==="workspace:updated"){const s=r&&typeof r=="object"?r:void 0,o=typeof s?.workspaceId=="string"?s.workspaceId:void 0,i=s?.changes;if(!o||!i||typeof i!="object"){te("defensive-resync",`${t} without workspaceId/changes`);return}const a=i.archived;a===!0?on(o):a===!1&&sn(o)}}function Wt(n){let e=!1;Ee+=1;const t=Go++;return ut.set(t,n),Ee===1?(wt=se(r=>Ko(r.method,r.params)),Et=oe(()=>te("reconnect")),te("seed")):P!==null&&n([...P]),()=>{e||(e=!0,ut.delete(t),Ee-=1,!(Ee>0)&&(wt?.(),wt=null,Et?.(),Et=null,Oe!==void 0&&(clearTimeout(Oe),Oe=void 0),Ce=!1,P=null,ne+=1))}}const gr=new Map;function He(n,e){n&&e&&(gr.set(n,e),lt.delete(n))}const Yo=5e3,lt=new Map,Ct=new Map;async function Jo(n){let e;try{e=await $o("resolver")}catch{return null}let t=!0;for(const r of e)try{const s=a=>u("note.list",a);let o;try{o=await Re(s,{workspaceId:r,projection:"slim",limit:ve},"notes")}catch(a){if(!Zn(a))throw a;o=await Re(s,{workspaceId:r,limit:ve},"notes")}let i=!1;for(const a of o){const c=String(a.id??"");c&&He(c,r),c===n&&(i=!0)}if(i)return r}catch{t=!1}return t&&e.length>0&<.set(n,Date.now()),null}async function re(n){const e=gr.get(n);if(e)return e;const t=lt.get(n);if(t!==void 0){if(Date.now()-t<Yo)return null;lt.delete(n)}const r=Ct.get(n);if(r)return r;const s=Jo(n).finally(()=>{Ct.delete(n)});return Ct.set(n,s),s}function yr(n){if(!n||typeof n!="object")return;const e=n.event;if(e&&typeof e=="object"){const r=e.type;if(typeof r=="string")return r}const t=n.type;return typeof t=="string"?t:void 0}function Zo(n,e,t){if(n!=="events.event")return!1;const r=yr(e);return r===void 0?!0:t.includes(r)}const mr=new Map,Qo=41943040,Xo=/^response for agent\.getConversation exceeds maximum outbound frame size: ([1-9][0-9]*) bytes > 41943040 bytes$/;function ei(n){if(!n||typeof n!="object")return!1;const e=n;if(e.name!=="BackendError"||typeof e.message!="string")return!1;const t=Xo.exec(e.message);return t!==null&&Number(t[1])>Qo}function ti(n,e){n&&e&&mr.set(n,e)}function Qe(n){const e=new Date().toISOString(),t=String(n.id??""),r=n.acpSessionId?String(n.acpSessionId):null,s=String(n.workspaceId??"");ti(t,s);const o={...n,id:bt(t),backendSessionId:r?bt(r):null,workspaceId:Qn(s),name:String(n.name??t),status:typeof n.status=="string"?n.status:Qr.Pending,messages:Array.isArray(n.messages)?n.messages:[],createdAt:String(n.createdAt??e),updatedAt:String(n.updatedAt??e)};return typeof n.retiredAt=="string"&&n.retiredAt.length>0&&(o.retiredAt=n.retiredAt),typeof n.parentAgentId=="string"&&n.parentAgentId.length>0&&(o.parentAgentId=bt(n.parentAgentId)),o.usingEarlierProfileSettings=n.usingEarlierProfileSettings===!0?!0:void 0,o.providerReplacementRequired=ni(n.providerReplacementRequired),typeof n.isBackground=="boolean"&&(o.metadata={...o.metadata,isBackground:n.isBackground},o.agentMetadata&&(o.agentMetadata={...o.agentMetadata,isBackground:n.isBackground})),o.hasUnread=yo(o),o}function ni(n){if(!n||typeof n!="object")return;const{providerRef:e,reason:t}=n;if(!(typeof e!="string"||e.length===0)&&!(t!=="profile-missing"&&t!=="provider-disabled"))return{providerRef:e,reason:t}}function ri(n){if(!n||typeof n!="object")return;const{topLevel:e,delegated:t,background:r}=n;if(!(typeof e!="number"||typeof t!="number"||typeof r!="number"))return{topLevel:e,delegated:t,background:r}}function si(n){if(!n||typeof n!="object")return;const{running:e,byParent:t,orphaned:r}=n;if(typeof e!="number"||!t||typeof t!="object"||Array.isArray(t))return;const s={};for(const[i,a]of Object.entries(t)){const c=cn(a);if(!c)return;s[i]=c}if(r===void 0)return{running:e,byParent:s};const o=cn(r);if(o)return{running:e,byParent:s,orphaned:o}}function cn(n){if(!n||typeof n!="object")return;const{total:e,running:t}=n;if(!(typeof e!="number"||typeof t!="number"))return{total:e,running:t}}async function un(n,e){try{return await u(n,e),{ok:!0}}catch(t){const r=t?.data,s=!!r&&typeof r=="object"&&r.code==="secret-request-unknown",o=t instanceof Error?t.message:String(t);return{ok:!1,expired:s,error:o}}}class oi{constructor(){y(this,"retirementCapabilityRequest",null)}supportsRetirement(e=0){if(this.retirementCapabilityRequest?.generation!==e){const t=u("client.hello",{}).then(r=>r?.server?.capabilities?.agentRetire===1).catch(()=>!1).finally(()=>{this.retirementCapabilityRequest?.promise===t&&(this.retirementCapabilityRequest=null)});this.retirementCapabilityRequest={generation:e,promise:t}}return this.retirementCapabilityRequest.promise}async list(e,t){const{agents:r}=await this.listWithMeta(e,t);return r}async listWithMeta(e,t){const r={workspaceId:e};t?.retiredOnly&&(r.retiredOnly=!0),t?.scope&&t.scope!=="all"&&(r.scope=t.scope),t?.parentAgentId&&(r.parentAgentId=t.parentAgentId),t?.orphanedOnly&&(r.orphanedOnly=!0);const s=await at(c=>u("agent.list",c),r,"agents"),o=Array.isArray(s?.agents)?s.agents:[],i=ri(s?.scopeCounts),a=si(s?.delegatedCounts);return{agents:o.map(c=>Qe(c)),retiredCount:typeof s?.retiredCount=="number"?s.retiredCount:0,...i?{scopeCounts:i}:{},...a?{delegatedCounts:a}:{}}}async get(e,t){const r=await u("agent.get",{agentId:e,...t!==void 0?{workspaceId:t}:{}}),s=r&&typeof r=="object"&&"agent"in r?r.agent:r;return!s||typeof s!="object"?null:Qe(s)}async getConversation(e,t=Yr,r,s,o,i){let a=t,c;for(;;){const d={agentId:e,...i!==void 0?{workspaceId:i}:{},limit:a,projection:"slim"};r!==void 0&&(d.nextToken=r),s!==void 0&&(d.aroundMessageId=s),o!==void 0&&(d.aroundIndex=o);try{c=await u("agent.getConversation",d);break}catch(m){if(!ei(m)||!Number.isFinite(a)||a<=1)throw m;a=Math.max(1,Math.floor(a/2))}}return!c||typeof c!="object"?{messages:[],truncated:!1,totalMessages:0,nextToken:null,prevToken:null}:{messages:Array.isArray(c.messages)?c.messages:[],truncated:!!c.truncated,totalMessages:typeof c.totalMessages=="number"?c.totalMessages:0,nextToken:typeof c.nextToken=="string"?c.nextToken:null,prevToken:typeof c.prevToken=="string"?c.prevToken:null}}async getMessageBlock(e,t,r,s){const i=(await u("agent.getMessageBlock",{agentId:e,messageId:t,blockId:r,...s!==void 0?{workspaceId:s}:{}}))?.block;if(!Jt(i))throw new Error(`agent.getMessageBlock returned no block for message ${t} block ${r}`);return i}async getMessageBlockPage(e,t,r,s){const o=await u("agent.getMessageBlock",{agentId:e,messageId:t,blockId:r,...s!==void 0?{workspaceId:s}:{}}),i=o?.block;if(!Jt(i))throw new Error(`agent.getMessageBlock returned no block for message ${t} block ${r}`);const a=c=>typeof c=="number"&&Number.isSafeInteger(c)&&c>=0?c:null;return{block:i,truncated:o.truncated===!0,field:typeof o.field=="string"?o.field:null,encoding:o.encoding==="text"||o.encoding==="json"?o.encoding:null,totalBytes:a(o.totalBytes),nextOffset:a(o.nextOffset)}}async listUserMessages(e,t,r,s){const o={agentId:e,...r!==void 0?{workspaceId:r}:{}};t!==void 0&&(o.previewChars=t),s?.limit!==void 0&&(o.limit=s.limit),s?.nextToken!==void 0&&(o.nextToken=s.nextToken);try{const i=await u("agent.listUserMessages",o),c=(Array.isArray(i?.items)?i.items:[]).filter(m=>!!m&&typeof m=="object").map(m=>{const I={id:String(m.id??""),preview:String(m.preview??""),createdAt:String(m.createdAt??"")};return m.metadata&&typeof m.metadata=="object"&&(I.metadata=m.metadata),I}),l=typeof i?.total=="number"?i.total:c.length,d=i?.nextToken;return typeof d=="string"||d===null?{ok:!0,items:c,total:l,nextToken:d}:{ok:!0,items:c,total:l}}catch(i){return{ok:!1,unsupported:!!i&&typeof i=="object"&&"rpcCode"in i&&i.rpcCode===-32601,error:i instanceof Error?i.message:String(i)}}}async create(e){const t={workspaceId:e.workspaceId,idempotencyKey:Y()};e.placement!==void 0&&(t.placement=e.placement),e.model!==void 0&&(t.model=e.model),e.reasoningEffort!==void 0&&(t.reasoningEffort=e.reasoningEffort),e.rememberSpecialist!==void 0&&(t.rememberSpecialist=e.rememberSpecialist),e.specialist!==void 0&&(e.specialist!==null||e.rememberSpecialist)&&(t.specialistId=e.specialist),e.prompt!==void 0&&(t.behaviorPrompt=e.prompt),e.name!==void 0&&(t.name=e.name),e.nameExplicitlySet!==void 0&&(t.nameExplicitlySet=e.nameExplicitlySet),e.provider!==void 0&&(t.provider=e.provider),e.agentType!==void 0&&(t.agentType=e.agentType),e.metadata!==void 0&&(t.metadata=e.metadata),e.workspacePath!==void 0&&(t.workspacePath=e.workspacePath),e.workspaceContext!==void 0&&(t.workspaceContext=e.workspaceContext);const r=await u("agent.create",t),s=r&&typeof r=="object"&&"agent"in r?r.agent:r;if(!s||typeof s!="object")throw new Error("agent.create returned no agent object");const o=s.id;if(typeof o!="string"||o.length===0)throw new Error("agent.create response missing daemon-assigned agent.id");return Qe(s)}async send(e,t,r){if(r??=await this.resolveAgentWorkspaceId(e)??void 0,!r)return{success:!1,error:`Unknown workspace for agent ${e}`};const s=Y();return b("agent.sendMessage",{agentId:e,content:t,workspaceId:r,messageId:s})}async editAndRegenerate(e){const t={agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId,content:e.content};return e.model!==void 0&&(t.model=e.model),e.imageBlocks!==void 0&&(t.imageBlocks=e.imageBlocks),e.fileBlocks!==void 0&&(t.fileBlocks=e.fileBlocks),b("agent.editAndRegenerate",t)}async queue(e,t,r){try{const s={agentId:e,content:t,...r?.workspaceId!==void 0?{workspaceId:r.workspaceId}:{}};r?.messageId!==void 0&&(s.messageId=r.messageId),r?.imageBlocks!==void 0&&(s.imageBlocks=r.imageBlocks),r?.fileBlocks!==void 0&&(s.fileBlocks=r.fileBlocks),r?.messageMetadata!==void 0&&(s.messageMetadata=r.messageMetadata);const o=await u("agent.queueMessage",s);if(o?.success===!1)return{success:!1,error:o.error};const i=o?.queuedMessage,a=typeof o?.turnId=="string"?o.turnId:typeof i?.turnId=="string"?i.turnId:void 0,c={success:!0};return i&&(c.queuedMessage=i),a!==void 0&&(c.turnId=a),c}catch(s){const o=s&&typeof s=="object"?s.rpcCode:void 0,i=o===-32600||o===-32601||o===-32602||Yt(s);if(r?.messageId!==void 0&&!i)throw s;return{success:!1,error:s instanceof Error?s.message:String(s)}}}async editQueued(e,t,r,s,o){try{const i={agentId:e,messageId:t,content:r,...o!==void 0?{workspaceId:o}:{}};s!==void 0&&(i.editing=s);const c=(await u("agent.editQueuedMessage",i))?.queuedMessage;return c?{success:!0,queuedMessage:c}:{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async sendQueuedNow(e){try{const t=await u("agent.sendQueuedMessageNow",{agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId});return{success:t.success,queued:t.queued,...t.quarantined!==void 0?{quarantined:t.quarantined}:{},...t.queuedMessage?{queuedMessage:t.queuedMessage}:{},...!t.queued&&t.turnId?{turnId:t.turnId}:{}}}catch(t){return{success:!1,error:_(t)}}}async sendQueuedMessagesNow(e){try{const r=(await u("client.hello",{}))?.server?.protocolVersion,s=typeof r=="string"?/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(r):null;if(!s||Number(s[1])<13||Number(s[1])===13&&Number(s[2])<1)return{success:!1,error:E.chat_queuedMessages_sendAllUnsupported_error()};const o=await u("agent.sendQueuedMessagesNow",{agentId:e.agentId,workspaceId:e.workspaceId,messageIds:e.messageIds});return{success:o.success,queued:o.queued,messageIds:o.messageIds,...o.quarantined!==void 0?{quarantined:o.quarantined}:{},...!o.queued&&!o.quarantined&&o.turnId?{turnId:o.turnId}:{}}}catch(t){return{success:!1,error:_(t)}}}async getQueue(e,t){const r=await at(s=>u("agent.getQueue",s),{agentId:e,...t!==void 0?{workspaceId:t}:{}},"queue");return Array.isArray(r?.queue)?r.queue:[]}async removeQueued(e,t,r){return b("agent.removeQueuedMessage",{agentId:e,messageId:t,...r!==void 0?{workspaceId:r}:{}})}async stop(e,t){return b("agent.stop",{agentId:e,...t!==void 0?{workspaceId:t}:{}})}async cancelSubscriptions(e){const t={agentId:e.agentId,workspaceId:e.workspaceId};return e.subscriptionId!==void 0&&(t.subscriptionId=e.subscriptionId),e.groupId!==void 0&&(t.groupId=e.groupId),b("agent.cancelSubscriptions",t)}async dismissQuestions(e){return b("agent.dismissQuestions",{agentId:e.agentId,workspaceId:e.workspaceId,messageId:e.messageId})}async secretList(e){try{return Io(await u("secret.list",{workspaceId:e.workspaceId,agentId:e.agentId}))}catch{return null}}async secretProvide(e){return un("secret.provide",{workspaceId:e.workspaceId,requestId:e.requestId,value:e.value})}async secretDismiss(e){return un("secret.dismiss",{workspaceId:e.workspaceId,requestId:e.requestId})}async resolveProposal(e){const t={workspaceId:e.workspaceId,agentId:e.agentId,proposalId:e.proposalId,outcome:e.outcome};return e.detail!==void 0&&(t.detail=e.detail),b("agent.resolveProposal",t)}async markSeen(e){return b("agent.markSeen",{workspaceId:e.workspaceId,agentId:e.agentId,messageId:e.messageId})}async setReasoningEffort(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{reasoningEffort:e.reasoningEffort}})}async setNotificationsMuted(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{notificationsMuted:e.notificationsMuted}})}async setPinned(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{pinned:e.pinned}})}async setBackground(e){return b("agent.update",{agentId:e.agentId,workspaceId:e.workspaceId,changes:{isBackground:e.isBackground}})}async updateSpecialist(e){const t={specialist:e.specialist};e.rememberSpecialist!==void 0&&(t.rememberSpecialist=e.rememberSpecialist),e.model!==void 0&&(t.model=e.model),e.systemPrompt!==void 0&&(t.systemPrompt=e.systemPrompt);const r={agentId:e.agentId,workspaceId:e.workspaceId,changes:t};try{return await u("agent.update",r),{success:!0}}catch(s){if(e.rememberSpecialist!==void 0&&s?.rpcCode===-32602&&_(s).includes("agent.update: unknown field `rememberSpecialist` in `changes`")){const o={...t};return delete o.rememberSpecialist,b("agent.update",{...r,changes:o})}return{success:!1,error:_(s)}}}async rename(e,t,r,s){const o={agentId:e,name:t,...r!==void 0?{workspaceId:r}:{}};return s?.skipIfExplicitlySet===!0&&(o.skipIfExplicitlySet=!0),b("agent.rename",o)}async delete(e,t,r){const s=r?.undoDelayMs;try{const o=await u("agent.delete",{agentId:e,...t!==void 0?{workspaceId:t}:{},...s&&s>0?{undoDelayMs:s}:{}}),i=o?.scheduled===!0,a=typeof o?.deleteAt=="string"?o.deleteAt:void 0;return i&&a?{success:!0,scheduled:!0,deleteAt:a}:{success:!0}}catch(o){return Yt(o)?{success:!1,forbidden:!0,error:_(o)}:{success:!1,error:_(o)}}}async cancelDelete(e,t){try{return{success:!0,cancelled:(await u("agent.cancelDelete",{agentId:e,...t!==void 0?{workspaceId:t}:{}}))?.cancelled===!0}}catch(r){return{success:!1,error:_(r)}}}async retire(e,t){const r={agentId:e};t!==void 0&&(r.workspaceId=t);try{return await u("agent.retire",r)}catch(s){return{success:!1,error:_(s)}}}async restore(e,t){const r={agentId:e,...t!==void 0?{workspaceId:t}:{}};return b("agent.restore",r)}async retry(e,t){try{const r=await u("agent.retry",{agentId:e,workspaceId:t});if(r?.ok!==!0)return{ok:!1,error:"Agent not in error status"};const s=typeof r.redriven=="boolean"?r.redriven:void 0,o=typeof r.turnId=="string"?r.turnId:void 0;return o!==void 0?{ok:!0,redriven:s,turnId:o}:{ok:!0,redriven:s}}catch(r){const s=r instanceof Error?r.message:"Failed to retry agent spawn";return go(r)?{ok:!1,notFound:!0,error:s}:{ok:!1,error:s}}}async respondPermission(e,t,r){try{const s=await u("agent.respondPermission",{requestId:e,outcome:t,...r!==void 0?{workspaceId:r}:{}}),o=typeof s?.resolved=="boolean"?s.resolved:void 0;return o!==void 0?{success:!0,resolved:o}:{success:!0}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async listInterrupted(){try{const e=await u("agent.listInterrupted",{});return(Array.isArray(e?.agents)?e.agents:[]).map(r=>{const s=r;return{agentId:String(s.agentId??""),workspaceId:String(s.workspaceId??""),workspaceName:String(s.workspaceName??""),agentName:String(s.agentName??""),prevStatus:String(s.prevStatus??""),interruptedAt:String(s.interruptedAt??"")}})}catch(e){if(e&&typeof e=="object"&&"rpcCode"in e&&e.rpcCode===-32601)return[];throw e}}async resolveInterrupted(e){try{const t=await u("agent.resolveInterrupted",e);return{resumed:Array.isArray(t?.resumed)?t.resumed:[],abandoned:Array.isArray(t?.abandoned)?t.abandoned:[],failed:Array.isArray(t?.failed)?t.failed.map(r=>{const s=r;return{agentId:String(s.agentId??""),error:String(s.error??"")}}):[]}}catch(t){throw t}}async resolveAgentWorkspaceId(e){const t=mr.get(e);if(t)return t;const r=await this.get(e);if(!r)return null;const s=String(r.workspaceId??"");return s.length>0?s:null}subscribe(e){return Ye({channel:{subscribeMethod:"agent.subscribe",unsubscribeMethod:"events.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t})},continuation:{method:"agent.list",key:"agents",params:t=>({workspaceId:t.workspaceId})}},getId:t=>String(t.id??""),normalize:t=>Qe(t),handler:e})}}function ii(n){return`browser-recent-${n}`}function ai(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.url=="string"&&typeof e.lastVisited=="string"&&(e.title===void 0||typeof e.title=="string")&&(e.favicon===void 0||typeof e.favicon=="string")}function ju(n){const e=n?.target;return G(e)&&typeof e.clientId=="string"&&e.clientId.length>0&&typeof e.via=="string"?{clientId:e.clientId,via:e.via}:void 0}function G(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ln(n){return G(n)&&n.ok===!0}function ci(n){return G(n)&&typeof n.action=="string"&&typeof n.success=="boolean"&&(n.error===void 0||typeof n.error=="string")}function ui(n){return G(n)&&typeof n.clientId=="string"&&G(n.capabilities)&&typeof n.connections=="number"&&Array.isArray(n.transports)&&typeof n.connectedAt=="string"}function Du(n){return G(n)&&typeof n.clientId=="string"&&G(n.capabilities)}function li(n){if(!G(n))return!1;if(n.source==="workspace"){if(typeof n.clientId!="string")return!1}else if(n.source==="default"){if(n.clientId!==void 0)return!1}else return!1;const e=n.resolved;return e===null||G(e)&&typeof e.clientId=="string"}function hr(n){return G(n)&&typeof n.tabId=="string"&&typeof n.workspaceId=="string"&&typeof n.hostClientId=="string"&&typeof n.url=="string"&&(n.visibility==="visible"||n.visibility==="hidden")&&typeof n.createdAt=="string"&&typeof n.updatedAt=="string"}function di(n){return hr(n)&&typeof n.hostConnected=="boolean"}function fi(n){const e=Xr.getJSON(ii(n));return Array.isArray(e)?e.filter(t=>ai(t)).slice(0,es):[]}class pi{async recentUrls(e){return fi(e)}subscribe(e){return e([]),()=>{}}async listTabs(e){const t=await u("browser.listTabs",{workspaceId:e});if(!Array.isArray(t?.tabs)||!t.tabs.every(di))throw new Error("Invalid browser.listTabs response shape");return t.tabs}async upsertTab(e,t){const r=await u("browser.upsertTab",{workspaceId:e,tab:t});if(!hr(r?.tab))throw new Error("Invalid browser.upsertTab response shape");return r.tab}async removeTab(e){const t=await u("browser.removeTab",{tabId:e});if(!ln(t))throw new Error("Invalid browser.removeTab response shape");return t}async syncTabs(e){const t=await u("browser.syncTabs",{tabs:e});if(!Array.isArray(t?.drop)||!t.drop.every(r=>typeof r=="string"))throw new Error("Invalid browser.syncTabs response shape");return{drop:t.drop}}async navigateTab(e,t){const r=await u("browser.navigateTab",{tabId:e,url:t});if(!ci(r))throw new Error("Invalid browser.navigateTab response shape");return r}async closeTab(e,t){const r=await u("browser.closeTab",{tabId:e,...t?.force===void 0?{}:{force:t.force}});if(!ln(r))throw new Error("Invalid browser.closeTab response shape");return r}}var vr=(n=>(n.AGENT="agent",n))(vr||{}),ee,D,Ge,W,ft,pt,gt,Pe,Ve,Ut;class gi{constructor(){H(this,Ve);H(this,ee);H(this,D,xs(Bs([])));H(this,Ge,1e3);H(this,W,[]);H(this,ft,100);H(this,pt,5e3);H(this,gt,null);H(this,Pe,!1);ke(this,ee,new js("Renderer",{enableConsole:!0})),typeof window<"u"&&window.electronAPI&&ke(this,Pe,!0),T(this,Pe)&&ke(this,gt,setInterval(()=>{vt(this,Ve,Ut).call(this)},T(this,pt)))}get logs(){return ge(T(this,D))}addToStore(e){kt(T(this,D),[...ge(T(this,D)),e],!0),ge(T(this,D)).length>T(this,Ge)&&kt(T(this,D),ge(T(this,D)).slice(-T(this,Ge)),!0)}addToPendingLogs(e){T(this,W).push(e),T(this,W).length>=T(this,ft)&&vt(this,Ve,Ut).call(this)}error(e,t,r,s){const o={timestamp:new Date().toISOString(),level:"ERROR",category:e,message:t,context:s,error:r instanceof Error?{name:r.name,message:r.message,stack:r.stack}:void 0};T(this,ee).error(t,r instanceof Error?r:void 0,s),this.addToStore(o),this.addToPendingLogs(o)}warn(e,t,r){const s={timestamp:new Date().toISOString(),level:"WARN",category:e,message:t,context:r};T(this,ee).warn(t,r),this.addToStore(s),this.addToPendingLogs(s)}info(e,t,r){const s={timestamp:new Date().toISOString(),level:"INFO",category:e,message:t,context:r};T(this,ee).info(t,r),this.addToStore(s),this.addToPendingLogs(s)}debug(e,t,r){const s={timestamp:new Date().toISOString(),level:"DEBUG",category:e,message:t,context:r};T(this,ee).debug(t,r),this.addToStore(s),this.addToPendingLogs(s)}verbose(e,t,r){this.debug(e,t,r)}getLogs(){return[...ge(T(this,D))]}getLogsByCategory(e){return ge(T(this,D)).filter(t=>t.category===e)}getLogsByLevel(e){return ge(T(this,D)).filter(t=>t.level===e.toUpperCase())}clearLogs(){kt(T(this,D),[],!0)}}ee=new WeakMap,D=new WeakMap,Ge=new WeakMap,W=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,Pe=new WeakMap,Ve=new WeakSet,Ut=async function(){if(T(this,W).length===0||!T(this,Pe))return;const e=[...T(this,W)];ke(this,W,[]);try{await ye(po.PERSIST_RENDERER_LOGS,e)}catch(t){console.error("[RendererLogger] Failed to persist logs via IPC:",t),ke(this,W,[...e,...T(this,W)])}};const yi=new gi,mi=2048,hi=256;let dn=0,fn=0,pn=0;const vi=192,bi=64;function Si(n){if(n.stage==="render"&&(n.event.includes("not-committed")||n.terminalErrorVisible===!0||n.callbackResult==="ignored"||n.callbackResult==="threw"))return"render";if(n.callbackResult==="threw"||n.storeStreamState==="error"||n.event.includes("failed")||n.event.includes("error")||n.pushKind==="snapshot"&&(n.callbackResult==="ignored"||n.callbackResult==="buffered")&&n.event.startsWith("snapshot-"))return"failure"}function gn(n){if(!n)return;let e=0xcbf29ce484222325n;for(const t of new TextEncoder().encode(n))e^=BigInt(t),e=BigInt.asUintN(64,e*0x100000001b3n);return e.toString(16).padStart(16,"0")}function L(n){const e=mi-hi;if(dn<e)dn+=1;else{const t=Si(n);if(t==="failure"&&fn<vi)fn+=1;else if(t==="render"&&pn<bi)pn+=1;else return}yi.info(vr.AGENT,"stream-lifecycle",n)}const Ii={messages:[],truncated:!1,totalMessages:0},yn=5e3,mn=1e3,ki=3e4,Ai=256,Ti=new Set(uo),wi=new Set(["text","code","tool_use","tool_result","thinking","image","audio","file","nav-link","proposal","plan"]);function $(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function hn(n){if(!$(n))return null;const{target:e,received:t,complete:r}=n;return typeof e!="number"||!Number.isSafeInteger(e)||e<1||e>200||typeof t!="number"||!Number.isSafeInteger(t)||t<0||t>e||typeof r!="boolean"?null:{target:e,received:t,complete:r}}function br(n){if(!$(n))return null;try{return io(n)}catch{return typeof n.type!="string"||n.type.length===0||wi.has(n.type)?null:{...n}}}function Sr(n,e){if(!$(n)||typeof n.id!="string"||n.id.length===0||typeof n.role!="string"||!Ti.has(n.role)||typeof n.timestamp!="string"||n.timestamp.length===0)return null;const t=n.agentId===void 0?e:n.agentId;if(t!==void 0&&(typeof t!="string"||t.length===0)||e!==void 0&&t!==void 0&&t!==e||n.seq!==void 0&&(typeof n.seq!="number"||!Number.isSafeInteger(n.seq)||n.seq<0))return null;const r=Array.isArray(n.contentBlocks)?n.contentBlocks.map(br).filter(s=>s!==null):[];return{...n,...t===void 0?{}:{agentId:t},contentBlocks:r}}function Ir(n,e){if(!$(n))return Ii;const t=n.agentId===void 0?e:n.agentId,r=t===void 0||typeof t=="string"&&t.length>0&&(e===void 0||t===e);return{messages:Array.isArray(n.messages)?r?n.messages.map(o=>Sr(o,t)).filter(o=>o!==null):[]:[],...n.nextToken===null||typeof n.nextToken=="string"?{nextToken:n.nextToken}:{},truncated:!!n.truncated,totalMessages:typeof n.totalMessages=="number"?n.totalMessages:0}}function Ei(n){if(!n||typeof n!="object")return;const e=n.resumed;return typeof e=="boolean"?e:void 0}function Ci(n,e){if(n!=="subscription.push"||!e||typeof e!="object")return null;const t=e,r=typeof t.subscriptionId=="string"?t.subscriptionId:null,s=typeof t.seq=="number"?t.seq:null;if(!r||s===null||!Number.isSafeInteger(s)||s<0)return null;if(t.kind==="snapshot")return{subscriptionId:r,kind:"snapshot",seq:s,snapshot:t.snapshot};if(t.kind==="history")return{subscriptionId:r,kind:"history",seq:s,history:t.history};if(t.kind==="delta"){const o=t.delta&&typeof t.delta=="object"?t.delta:{};return{subscriptionId:r,kind:"delta",seq:s,delta:{added:Array.isArray(o.added)?o.added:[],updated:Array.isArray(o.updated)?o.updated:[],removedIds:Array.isArray(o.removedIds)?o.removedIds.map(i=>String(i)):[]}}}return null}function Ri(n){if(n.kind==="snapshot"){const t=Ir(n.snapshot).messages;for(let r=t.length-1;r>=0;r-=1){const s=t[r];if(s.role==="assistant")return gn(s.id)}return}const e=[...n.delta?.updated??[],...n.delta?.added??[]];for(let t=e.length-1;t>=0;t-=1){const r=kr(e[t],!0);if(r&&(r.role===void 0||r.role==="assistant"))return gn(r.messageId)}}function kr(n,e){if(!$(n))return null;const t=n,r=typeof t.messageId=="string"?t.messageId:null;if(!r||!$(t.block)||typeof t.block.id!="string")return null;const s=e&&(t.block.type==="text"||t.block.type==="thinking")&&typeof t.block.textDelta=="string",o=br(s?{text:t.block.textDelta,...t.block}:t.block);return o?(s&&!("text"in t.block)&&delete o.text,{messageId:r,...typeof t.role=="string"?{role:t.role}:{},block:o,...typeof t.messageSeq=="number"?{messageSeq:t.messageSeq}:{},...typeof t.timestamp=="string"?{timestamp:t.timestamp}:{},...t.streamingComplete===!0?{streamingComplete:!0}:{},...t.metadata&&typeof t.metadata=="object"&&!Array.isArray(t.metadata)?{metadata:t.metadata}:{},...typeof t.appMessageId=="string"&&t.appMessageId.length>0?{appMessageId:t.appMessageId}:{},...t.author===null||t.author&&typeof t.author=="object"&&!Array.isArray(t.author)?{author:t.author}:{}}):null}function _i(n,e){const t=e.name??e.toolName??"";if(e.type!=="tool_use"||n.type!=="tool_use"||!e.toolCallId||e.toolCallId!==n.toolCallId||t.length>0)return e;const r=n.metadata?.toolKind;return{...e,name:n.name??n.toolName??"",input:n.input,metadata:{...e.metadata??{},...r!==void 0?{toolKind:r}:{}}}}function Oi(n,e){return n.type!=="text"||!e?.media?n:{...n,media:{...e.media,...n.media??{}}}}function Mi(n){const e=JSON.stringify(n)??"";let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}class Pi{constructor(e){y(this,"messages",[]);y(this,"truncated",!1);y(this,"nextToken");y(this,"totalMessages",0);y(this,"streaming",!1);y(this,"expectedSeq",0);y(this,"seeded",!1);y(this,"snapshotFingerprint",0);y(this,"incremental",!1);y(this,"initialHistory");y(this,"initialMessageIds",new Set);this.expectedAgentId=e}reset(){this.messages=[],this.truncated=!1,this.nextToken=void 0,this.totalMessages=0,this.streaming=!1,this.expectedSeq=0,this.seeded=!1,this.snapshotFingerprint=0,this.incremental=!1,this.initialHistory=void 0,this.initialMessageIds.clear()}applySnapshot(e,t){const r=$(t)?t:{},s=r.historyDelivery==="progressive"?hn(r.initialHistory):void 0,o=Ir(t,this.expectedAgentId),i=new Set(o.messages.map(l=>l.id));if(s===null||s&&(s.received!==i.size||!s.complete&&o.messages.length>1))return"invalid";const a=Mi(t);if(this.seeded&&a===this.snapshotFingerprint&&(e+1===this.expectedSeq||e===0&&s!==void 0&&e<this.expectedSeq))return!1;this.snapshotFingerprint=a,this.messages=o.messages,this.truncated=o.truncated,this.nextToken=o.nextToken,this.totalMessages=o.totalMessages;const c=t&&typeof t=="object"?t:{};return this.streaming=this.messages.some(l=>l.isStreaming===!0)||c.isResponding===!0||c.turnInFlight===!0,this.incremental=c.deltaEncoding==="incremental",this.initialHistory=s,this.initialMessageIds=i,this.initialHistory?.complete===!1&&(this.nextToken=void 0),this.expectedSeq=e+1,this.seeded=!0,!0}applyDelta(e,t){if(!this.seeded||e>this.expectedSeq)return"gap";if(e<this.expectedSeq)return"stale";let r=!1,s=!1;for(const o of[...t.added,...t.updated]){const i=kr(o,this.incremental);i&&(this.upsertBlock(i),(i.role===void 0||i.role==="assistant")&&(s=!0,i.streamingComplete&&(r=!0)))}if(t.removedIds.length>0){const o=new Set(t.removedIds);this.messages=this.messages.map(i=>{const a=i.contentBlocks;return!a||!a.some(c=>c.id!==void 0&&o.has(c.id))?i:{...i,contentBlocks:a.filter(c=>c.id===void 0||!o.has(c.id))}})}return r?this.streaming=this.messages.some(o=>o.role==="assistant"&&o.isStreaming===!0):s&&(this.streaming=!0),this.expectedSeq=e+1,"applied"}applyHistory(e,t){if(!this.seeded||e>this.expectedSeq)return"gap";if(e<this.expectedSeq)return"stale";if(!this.initialHistory||this.initialHistory.complete||!$(t))return"gap";const r=hn(t);if(!r||r.target!==this.initialHistory.target)return"gap";const{received:s,complete:o}=r,i=t.message===void 0?void 0:Sr(t.message,this.expectedAgentId);if(!o&&!i||o&&t.message!==void 0)return"gap";const a=i&&!this.initialMessageIds.has(i.id);return s!==this.initialHistory.received+(a?1:0)||o&&(t.nextToken!==null&&(typeof t.nextToken!="string"||t.nextToken.length===0)||typeof t.truncated!="boolean"||typeof t.totalMessages!="number"||!Number.isSafeInteger(t.totalMessages)||t.totalMessages<s||s<r.target&&t.nextToken!==null)?"gap":(i&&(this.initialMessageIds.add(i.id),this.messages.some(c=>c.id===i.id)||(this.messages=[i,...this.messages].sort((c,l)=>(c.seq??Number.MAX_SAFE_INTEGER)-(l.seq??Number.MAX_SAFE_INTEGER)))),this.initialHistory=r,o&&(this.nextToken=t.nextToken,this.truncated=t.truncated,this.totalMessages=t.totalMessages),this.expectedSeq=e+1,"applied")}transcript(){return{...this.initialHistory?{initialHistory:this.initialHistory}:{},messages:this.messages,truncated:this.truncated,...this.nextToken!==void 0?{nextToken:this.nextToken}:{},totalMessages:this.totalMessages,isStreaming:this.streaming}}materializeBlock(e,t){const{textDelta:r,...s}=e.block,i=this.incremental&&typeof r=="string"&&(s.type==="text"||s.type==="thinking")?{...s,text:(t?.text??"")+r}:e.block;return Oi(i,t)}upsertBlock(e){const t=e.streamingComplete===!0;let r=this.messages.findIndex(l=>l.id===e.messageId);r<0&&(this.messages=[...this.messages,{id:e.messageId,role:e.role??"assistant",contentBlocks:[],timestamp:e.timestamp??new Date().toISOString(),isStreaming:!t}],r=this.messages.length-1,this.totalMessages+=1);const s=this.messages[r],o=[...s.contentBlocks??[]],i=o.findIndex(l=>l.id===e.block.id),a=this.materializeBlock(e,i>=0?o[i]:void 0);i>=0?o[i]=_i(o[i],a):o.push(a);const c={...s,contentBlocks:o,isStreaming:!t,...t?{streamingComplete:!0}:{}};e.timestamp&&(c.timestamp=e.timestamp),e.messageSeq!==void 0&&(c.seq=e.messageSeq),e.metadata&&(c.metadata=e.metadata),e.appMessageId&&(c.appMessageId=e.appMessageId),"author"in e&&(c.author=e.author),this.messages=[...this.messages.slice(0,r),c,...this.messages.slice(r+1)]}}class Ni{subscribe(e,t,r,s){const o=s?.workspaceId,i=o!==void 0?{workspaceId:o}:{},a=new Pi(e);let c=!1,l,d=s?.sinceMessageId,m=!1,I,w;const S=f=>{c||f===I||(I=f,r?.(f))},A=()=>{w!==void 0&&(clearTimeout(w),w=void 0)};let N,ie=mn,J=!1;const ae=()=>{N!==void 0&&(clearTimeout(N),N=void 0)},U=()=>{ae(),J=!1,ie=mn},ce=()=>{c||(S("delayed"),J=!0,ae(),N=setTimeout(()=>{N=void 0,!c&&(a.reset(),Be(),ue())},ie),ie=Math.min(ie*2,ki))};let q=0,j=0,Z=!1,B=!1,V=!1,z=[];const yt=(f,h=!1)=>{if(!c)try{t({...a.transcript(),...h?{fromHistory:!0}:{}}),L({...f,callbackResult:"delivered"})}catch(v){throw L({...f,callbackResult:"threw"}),v}},Je=(f,h,v=!1)=>{if(c)return;const C=a.transcript();try{t({...C,fromSnapshot:!0,...f===void 0?{}:{resumed:f},...v?{resetCachedTranscript:!0}:{}}),L({...h,callbackResult:"delivered"})}catch(R){throw L({...h,callbackResult:"threw"}),R}},xe=()=>{A(),a.transcript().initialHistory?.complete===!1&&(w=setTimeout(()=>{w=void 0,m=!0,ce()},yn))},Ie=f=>{if(c)return;const h={stage:"subscription",event:"push",turnCorrelation:Ri(f),subscriptionGeneration:q,transportGeneration:j,pushKind:f.kind,pushSeq:f.seq};if(l===void 0){z.push(f),z.length>Ai&&z.shift(),L({...h,callbackResult:"buffered"});return}if(f.subscriptionId!==l){L({...h,callbackResult:"ignored"});return}if(f.kind==="snapshot"){B=!1,A(),U(),S("live");const v=Ei(f.snapshot);d=void 0;const C=a.applySnapshot(f.seq,f.snapshot);if(C==="invalid"){m=Z,le();return}if(C){const R=m&&v===void 0;m=!1;const de=Z?"reset":"applied";Z=!0,Je(v,{...h,reconcilerResult:de},R)}else L({...h,reconcilerResult:"duplicate",callbackResult:"not-invoked"});xe(),V&&a.transcript().initialHistory?.complete!==!1&&(V=!1,le())}else if(B)L({...h,callbackResult:"ignored"});else{const v=f.kind==="history"?a.applyHistory(f.seq,f.history):a.applyDelta(f.seq,f.delta??{added:[],updated:[],removedIds:[]});v==="applied"?(f.kind==="history"&&(U(),S("live"),xe()),yt({...h,reconcilerResult:"applied"},f.kind==="history"),f.kind==="history"&&a.transcript().initialHistory?.complete&&V&&(V=!1,le())):v==="gap"?(L({...h,reconcilerResult:"gap",callbackResult:"not-invoked"}),le()):L({...h,reconcilerResult:"stale",callbackResult:"not-invoked"})}},ue=()=>{ae(),q+=1;const f=q;L({stage:"subscription",event:"registration-start",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),J||S(B?"resyncing":"connecting"),u("chat.subscribe",{agentId:e,...i,deltaEncoding:"incremental",projection:"slim",historyDelivery:"progressive",...d===void 0?{}:{sinceMessageId:d}}).then(h=>{const v=h?.subscriptionId;if(q!==f||c){L({stage:"subscription",event:"registration-stale",subscriptionGeneration:f,transportGeneration:j,callbackResult:"ignored"}),v&&u("chat.unsubscribe",{subscriptionId:v,...i}).catch(()=>{});return}l=v,L({stage:"subscription",event:"registration-ack",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),!B&&!J&&S("awaiting-snapshot"),A(),w=setTimeout(()=>{w=void 0,ce()},yn);const C=z.filter(R=>R.subscriptionId===v);z=[];for(const R of C)Ie(R)}).catch(()=>{q===f&&(L({stage:"subscription",event:"registration-failed",subscriptionGeneration:f,transportGeneration:j,callbackResult:"not-invoked"}),ce())})},Be=()=>{if(q+=1,!l)return;const f=l;l=void 0,u("chat.unsubscribe",{subscriptionId:f,...i}).catch(()=>{})},mt=()=>{B=!0,ae(),A(),a.reset(),Be(),ue()},le=()=>{c||B||mt()},g=se(f=>{const h=Ci(f.method,f.params);if(h){Ie(h);return}if(c||f.method!=="events.event"||!$(f.params))return;const v=$(f.params.event)?f.params.event:f.params;if(v.type!=="agent:stream:end"||!$(v.data))return;const C=v.data;if(C.agentId!==e||typeof C.messageId!="string"||C.messageId.length===0||C.stopReason!=="interrupted"&&typeof C.finishReason!="string")return;const R=a.transcript().messages.find(de=>de.id===C.messageId);R&&((R.contentBlocks?.length??0)>0||R.seq!==void 0&&R.isStreaming!==!0&&R.streamingComplete!==!1)||(!Z||B||l===void 0||w!==void 0||J?V=!0:le())}),p=oe(()=>{c||(m||=Z,j+=1,q+=1,L({stage:"subscription",event:"transport-reconnected",subscriptionGeneration:q,transportGeneration:j,callbackResult:"not-invoked"}),l=void 0,B=!1,z=[],A(),U(),a.reset(),ue())});return ue(),()=>{c=!0,A(),ae(),g(),p(),Be()}}}let me=null;class Li{async list(e){const t=await u("client.list",...e?[{workspaceId:e}]:[]);if(!Array.isArray(t?.clients)||!t.clients.every(ui))throw new Error("Invalid client.list response shape");return t.clients}ownClientId(){if(!me){me=u("client.hello",{}).then(t=>{const r=t?.clientId;if(typeof r!="string"||r.length===0)throw new Error("Invalid client.hello response shape: clientId missing");return r});const e=me;e.catch(()=>{me===e&&(me=null)})}return me}}function Uu(){me=null}function Gt(n){if(n.authorType!=="user")return{};const e={};if(typeof n.authorPrincipalId=="string"&&n.authorPrincipalId.trim()&&(e.authorPrincipalId=n.authorPrincipalId),Us(n.authorIdentity)&&n.authorIdentity.externalUserId.trim()){const{provider:t,host:r,externalUserId:s}=n.authorIdentity;e.authorIdentity={provider:t,host:r,externalUserId:s}}return e}function xi(n){const e=n.latestCommentAuthorType==="user"||n.latestCommentAuthorType==="agent"?n.latestCommentAuthorType:void 0,t=Gt({authorType:e,authorPrincipalId:n.latestCommentAuthorPrincipalId,authorIdentity:n.latestCommentAuthorIdentity});return{author:typeof n.latestCommentAuthor=="string"?n.latestCommentAuthor:void 0,authorType:e,authorPrincipalId:t.authorPrincipalId,authorIdentity:t.authorIdentity}}function qu(n){const e=n.author||E.tiptap_comment_unknownAuthor_label(),{authorIdentity:t}=Gt(n);if(!t)return e;const{provider:r,host:s,externalUserId:o}=t,i=`${r}@${s} · ${o}`;return E.presence_person_forge_label({name:e,handle:i})}function Bi(n){if(!(!n||typeof n!="object"))return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,Array.isArray(t)?t.map(r=>String(r)):[String(t)]]))}function ji(n){if(!n||typeof n!="object")return;const e=n;return{before:String(e.before??""),after:String(e.after??"")}}function Di(n){const e=n&&typeof n=="object"?n:{};return{original:String(e.original??""),proposed:String(e.proposed??"")}}function qt(n,e,t){const r=new Date().toISOString(),s=String(n.id??""),o=typeof n.parentId=="string"&&n.parentId.length>0,i=n.anchor&&typeof n.anchor=="object"?n.anchor:o?void 0:{type:"point"},a=ji(n.anchorContext),c=Bi(n.reactions),l={...Gt(n),id:s,threadId:String(n.threadId??s),noteId:String(n.noteId??e),...t?{workspaceId:t}:{},content:String(n.content??""),author:String(n.author??""),authorType:n.authorType==="agent"?"agent":"user",status:typeof n.status=="string"?n.status:"open",...i?{anchor:i}:{},createdAt:String(n.createdAt??r),updatedAt:String(n.updatedAt??r),...typeof n.parentId=="string"?{parentId:n.parentId}:{},...n.anchorText!==void 0||n.section!==void 0?{anchorText:String(n.anchorText??n.section??"")}:{},...a?{anchorContext:a}:{},...typeof n.isOrphaned=="boolean"?{isOrphaned:n.isOrphaned}:{},...c?{reactions:c}:{}},d=typeof n.type=="string"?n.type:"comment";switch(d){case"suggestion":return{...l,type:d,suggestionDiff:Di(n.suggestionDiff)};case"session":return{...l,type:d,agentId:String(n.agentId??"")};case"change-request":case"question":return{...l,type:d};case"comment":default:return{...l,type:"comment"}}}async function Ui(n,e){const t=e??await re(n);if(!t)return[];try{const r=await Po(o=>u("comment.list",o),{workspaceId:t,noteId:n,includeComments:!0,limit:ot},o=>u("comment.getThread",{workspaceId:t,noteId:n,threadId:o})),s=[];for(const o of r){if(!o||typeof o!="object")continue;const i=o;if(Array.isArray(i.comments))for(const a of i.comments)s.push(qt(a,n,t));else s.push(qt({...i,...xi(i)},n,t))}return s}catch{return[]}}class qi{async list(e,t){return Ui(e,t)}async add(e,t){return this.runCommentMutation(e,"comment.add",{searchContext:t.searchContext,commentTarget:t.commentTarget,comment:t.comment,...t.type!==void 0?{type:t.type}:{},...t.author!==void 0?{author:t.author}:{},...t.authorType!==void 0?{authorType:t.authorType}:{},...t.commentId!==void 0?{commentId:t.commentId}:{},idempotencyKey:Y()},t.workspaceId)}async respond(e,t){return this.runCommentMutation(e,"comment.respond",{...t.threadId!==void 0?{threadId:t.threadId}:{},...t.commentId!==void 0?{commentId:t.commentId}:{},comment:t.comment,...t.type!==void 0?{type:t.type}:{},...t.authorType!==void 0?{authorType:t.authorType}:{},...t.suggestionOriginal!==void 0?{suggestionOriginal:t.suggestionOriginal}:{},...t.suggestionProposed!==void 0?{suggestionProposed:t.suggestionProposed}:{}},t.workspaceId)}async delete(e,t,r){return this.runCommentMutation(e,"comment.delete",{commentId:t},r)}async runCommentMutation(e,t,r,s){const o=s??await re(e);return o?b(t,{workspaceId:o,noteId:e,...r}):{success:!1,error:`Cannot resolve workspace for note ${e}`}}subscribe(e,t,r){let s=r;const o={subscribeMethod:"comment.subscribe",unsubscribeMethod:"comment.unsubscribe",continuation:{method:"comment.list",key:"threads",params:i=>({workspaceId:i.workspaceId,noteId:e,includeComments:!0,limit:ot})},...r?{params:{workspaceId:r,noteId:e,limit:ot}}:{dynamic:{subscribeIds:i=>{let a=!1;return re(e).then(c=>{a||!c||(s=c,i([c]))}).catch(()=>{}),()=>{a=!0}},paramsForId:i=>({workspaceId:i,noteId:e,limit:ot})}}};return Ye({channel:o,getId:i=>typeof i.threadId=="string"?i.threadId:"",complete:i=>lr(i,a=>u("comment.getThread",{workspaceId:s,noteId:e,threadId:a})),normalize:i=>i.noteId!==e||!Array.isArray(i.comments)?null:i.comments.flatMap(a=>{if(!a||typeof a!="object"||Array.isArray(a))return[];const c=a;return typeof c.id!="string"||!c.id||c.threadId!==i.threadId||c.noteId!==void 0&&c.noteId!==e?[]:[qt(c,e,s)]}),handler:i=>t(i.flat())})}}class Fi{async get(e,t){return await u("drafts.get",{workspaceId:e,agentId:t})??null}async set(e,t,r,s){const o={workspaceId:e,agentId:t,text:r};return s&&s.length>0&&(o.attachments=s),await u("drafts.set",o)}async clear(e,t){return await u("drafts.clear",{workspaceId:e,agentId:t})}}const $i=300;class Hi{async list(e){return[...await this.query(e,{limit:$i})].reverse()}async query(e,t={}){const r=await u("event.query",{workspaceId:e,...t});return Array.isArray(r)?r:[]}async queryPage(e,t={}){return u("event.query",{workspaceId:e,...t,paginate:!0})}subscribe(e,t){return this.list(e).then(r=>t(r)).catch(()=>t([])),()=>{}}}const Wi=new Set([".onnx",".onnx_data",".pt",".pth",".bin",".safetensors",".h5",".hdf5",".pkl",".pickle",".npy",".npz",".model",".weights",".tflite",".mlmodel",".pb",".ckpt",".mat",".parquet",".feather",".arrow",".wasm",".png",".jpg",".jpeg",".gif",".bmp",".ico",".icns",".webp",".tiff",".tif",".svg",".psd",".raw",".heic",".heif",".avif",".mp3",".wav",".ogg",".flac",".aac",".m4a",".wma",".mp4",".mov",".avi",".mkv",".webm",".wmv",".flv",".zip",".tar",".gz",".bz2",".7z",".rar",".xz",".tgz",".exe",".dll",".so",".dylib",".a",".o",".obj",".ttf",".otf",".woff",".woff2",".eot",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".db",".sqlite",".sqlite3",".pyc",".pyo",".class",".jar",".war",".ear",".node"]),Gi=[/package-lock\.json$/,/yarn\.lock$/,/pnpm-lock\.yaml$/,/composer\.lock$/,/Gemfile\.lock$/,/Cargo\.lock$/,/poetry\.lock$/,/\.min\.(js|css)$/,/\.bundle\.(js|css)$/,/[\\/](dist|build|node_modules)[\\/]/];function Vi(n){const e=n.lastIndexOf("."),t=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return e>t&&e!==-1?n.slice(e).toLowerCase():""}function zi(n){const e=Vi(n);return Wi.has(e)}function Ki(n){return Gi.some(e=>e.test(n))}function Fu(n){return zi(n)?{skip:!0,reason:"binary/media file"}:Ki(n)?{skip:!0,reason:"lock/minified/build file"}:{skip:!1}}function Yi(n,e=8192){const t=n.subarray(0,Math.min(e,n.length));if(t.includes(0))return!0;let r=0;for(let s=0;s<t.length;s++){const o=t[s];o!==9&&o!==10&&o!==13&&!(o>=32&&o<=126)&&!(o>=194&&o<=244)&&!(o>=128&&o<=191)&&r++}return r/t.length>.3}const Ar=48e4,Ji=8*1024*1024,vn=40*1024*1024;class Tr extends Error{constructor(e){super(`file.read: ${e}: stream did not contain valid UTF-8`),this.name="InvalidUtf8Error"}}function wr(n){if(typeof n=="string")return{text:n,truncated:!1};if(n&&typeof n=="object"){const{content:e,truncated:t}=n;if(typeof e=="string")return{text:e,truncated:t===!0}}return null}function Zi(n){const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}async function Er(n,e,t=u,r=Ji){const s=[];let o=0,i;for(;;){const l=await t(n,{...e,offset:o,length:r});if(!l||typeof l.content!="string"||!Number.isSafeInteger(l.size)||!Number.isSafeInteger(l.bytesRead))throw new Error(`${n}: invalid chunk response`);if(l.size>vn)throw new Error(`${n}: object is ${l.size} bytes, over the ${vn}-byte limit`);if(i===void 0)i=l.size;else if(l.size!==i)throw new Error(`${n}: object changed while it was read`);const d=Zi(l.content);if(d.length!==l.bytesRead)throw new Error(`${n}: content/bytesRead mismatch (${d.length} vs ${l.bytesRead})`);if(s.push(d),o+=d.length,d.length<r||o>=i)break}const a=new Uint8Array(o);let c=0;for(const l of s)a.set(l,c),c+=l.length;return a}async function Qi(n,e=u){const t=await e("file.read",{...n,maxBytes:Ar}),r=wr(t);if(!r)return null;if(!r.truncated)return r.text;const s=await Er("file.readChunk",n,e);try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(s)}catch{throw new Tr(n.path)}}async function $u(n,e=u){const t=await e("git.showFile",{...n,maxBytes:Ar}),r=wr(t);if(!r)return"";if(!r.truncated)return r.text;const s=await Er("git.showFileChunk",n,e);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(s)}function Xi(n){for(let e=0;e<n.length;e++){const t=n.charCodeAt(e);if(t<=8||t>=14&&t<=26||t>=28&&t<=31||t===127)return!0}return!1}function Rt(n,e){return{path:n,absolutePath:null,...ns(e),lastUpdated:Date.now(),loading:!1,saving:!1,error:null,truncated:!1}}function bn(n){const e=n,t=Array.isArray(e)?e:Array.isArray(e?.entries)?e.entries:Array.isArray(e?.files)?e.files:[],r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=s,i=typeof o.name=="string"?o.name:void 0,c=(typeof o.path=="string"?o.path:void 0)??i;if(!c)continue;const l=o.type==="directory"||o.type==="dir"||o.isDirectory===!0,d={name:i??c.split("/").pop()??c,path:c,type:l?"directory":"file"};typeof o.size=="number"&&(d.size=o.size),typeof o.modified=="string"&&(d.modified=o.modified),typeof o.isGitignored=="boolean"&&(d.isGitignored=o.isGitignored),r.push(d)}return r}function ea(n,e){const t=n.trim();return t==="?"?"??":e?`${t} `:` ${t}`}class ta{async list(e){return[]}async read(e,t,r){try{const s=await Qi({workspaceId:e,path:t,...r?.gitRootId?{gitRootId:r.gitRootId}:{}});if(s===null)return null;const o=Xi(s)||Yi(new TextEncoder().encode(s.slice(0,8192)));return Rt(t,o?{kind:"restorable-snapshot",content:s,isBinary:!0}:ts(s))}catch(s){if(s instanceof Tr)return Rt(t,{kind:"preview-only",isBinary:!0});if(s instanceof tr&&s.rpcCode===-32603){const o=_(s);if(o.endsWith("stream did not contain valid UTF-8"))return Rt(t,{kind:"preview-only",isBinary:!0});if(!r?.gitRootId&&/\(os error [23]\)$/.test(o))return null}throw s}}async explorerTree(e){const t=await u("file.tree",{workspaceId:e,path:"."});if(!Array.isArray(t))throw new Error("Invalid file.tree response: expected an array");return{name:"",path:"",type:"directory",children:bn(t)}}async listDirectory(e,t){try{const r=await u("file.list",{workspaceId:e,path:t});return bn(r)}catch{return[]}}async gitStatusMap(e){try{const t=await u("git.status",{workspaceId:e}),r=Array.isArray(t?.files)?t.files:[],s={};for(const o of r){const i=o,a=String(i.path??"");a&&(s[a]={status:ea(String(i.status??""),!!i.staged)})}return s}catch{return{}}}async write(e,t,r){return b("file.write",{workspaceId:e,path:t,content:r.content,idempotencyKey:Y()})}async delete(e,t){return b("file.delete",{workspaceId:e,path:t})}async mkdir(e,t){return b("file.mkdir",{workspaceId:e,path:t,idempotencyKey:Y()})}async rename(e,t,r){return b("file.rename",{workspaceId:e,oldPath:t,newPath:r,idempotencyKey:Y()})}}const na=15e4;function Cr(n){const t=(Array.isArray(n.files)?n.files:[]).map(r=>{const s=r,o={path:String(s.path??""),status:typeof s.status=="string"?s.status.trim()||St.Modified:St.Modified,staged:!!s.staged};return typeof s.mode=="string"&&(o.mode=s.mode),typeof s.oldSha=="string"&&(o.oldSha=s.oldSha),typeof s.newSha=="string"&&(o.newSha=s.newSha),o});return{branch:String(n.branch??""),ahead:Number(n.ahead??0),behind:Number(n.behind??0),diverged:n.diverged===void 0?Number(n.ahead)>0&&Number(n.behind)>0:!!n.diverged,files:t,hasUncommittedChanges:n.hasUncommittedChanges===void 0?t.length>0:!!n.hasUncommittedChanges,hasUntrackedFiles:n.hasUntrackedFiles===void 0?t.some(r=>r.status===St.Untracked):!!n.hasUntrackedFiles}}function Hu(n){if(!n||typeof n!="object")return null;const e=n;return typeof e.branch!="string"||typeof e.ahead!="number"||typeof e.behind!="number"||!Array.isArray(e.files)||e.files.some(t=>!t||typeof t!="object"||typeof t.path!="string"||typeof t.status!="string"||typeof t.staged!="boolean")?null:Cr(e)}const Xe=new Map;function Sn(n,e){const t=rs.state,r=JSON.stringify([Jr(t),qs(t),t.daemonHealth?.connectionGeneration,n]);if(!e?.forceRefresh){const o=Xe.get(r);if(o)return o}const s=u("git.status",{workspaceId:n,...e?.forceRefresh?{forceRefresh:!0}:{}}).then(o=>!o||typeof o!="object"?null:Cr(o)).catch(()=>null);return Xe.set(r,s),s.then(()=>{Xe.get(r)===s&&Xe.delete(r)}),s}function ra(n){const e=n&&typeof n=="object"?n:{},t=typeof e.type=="string"?e.type:"Context",s={type:t==="Addition"?It.Addition:t==="Deletion"?It.Deletion:It.Context,content:typeof e.content=="string"?e.content:""};return typeof e.oldNumber=="number"&&(s.oldNumber=e.oldNumber),typeof e.newNumber=="number"&&(s.newNumber=e.newNumber),s}function sa(n){const e=Array.isArray(n)?n:[],t=[];for(const r of e){if(!r||typeof r!="object")continue;const s=r,o=typeof s.path=="string"?s.path:"";if(!o)continue;const a=(Array.isArray(s.hunks)?s.hunks:[]).map(c=>{const l=c&&typeof c=="object"?c:{};return{oldStart:Number(l.oldStart??0),oldLines:Number(l.oldLines??0),newStart:Number(l.newStart??0),newLines:Number(l.newLines??0),lines:Array.isArray(l.lines)?l.lines.map(ra):[]}});t.push({file:o,chunks:a})}return t}function oa(n){if(typeof n!="string"||!n)return 0;const e=Date.parse(n);return Number.isFinite(e)?e:0}function ia(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.path=="string"?e.path:"";if(!t)return null;const r={path:t};return typeof e.additions=="number"&&(r.additions=e.additions),typeof e.deletions=="number"&&(r.deletions=e.deletions),typeof e.status=="string"&&(r.status=e.status),r}function aa(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.hash=="string"?e.hash:"";if(!t)return null;const r=!!e.isPushed,s={hash:t,message:typeof e.message=="string"?e.message:"",author:typeof e.author=="string"?e.author:"",timestamp:oa(e.date),stage:r?"pushed":"local",isPushed:r};return Array.isArray(e.files)&&(s.files=e.files.map(ia).filter(o=>o!==null)),typeof e.filesChanged=="number"&&(s.filesChanged=e.filesChanged),typeof e.date=="string"&&(s.date=e.date),typeof e.agentId=="string"&&(s.agentId=e.agentId),typeof e.linkedNoteId=="string"&&(s.linkedNoteId=e.linkedNoteId),s}function ca(n,e){const r=(Array.isArray(n.files)?n.files:[]).map(i=>typeof i=="string"?i:null).filter(i=>i!==null),o=(Array.isArray(n.fileDetails)?n.fileDetails:[]).map(i=>{if(!i||typeof i!="object")return null;const a=i,c=typeof a.path=="string"?a.path:"";return c?{path:c,additions:typeof a.additions=="number"?a.additions:0,deletions:typeof a.deletions=="number"?a.deletions:0}:null}).filter(i=>i!==null);return{commitHash:typeof n.commitHash=="string"?n.commitHash:e,author:typeof n.author=="string"?n.author:"",authorEmail:typeof n.authorEmail=="string"?n.authorEmail:"",date:typeof n.date=="string"?n.date:"",message:typeof n.message=="string"?n.message:"",files:r,fileDetails:o}}const ua=new Set(Object.values(nr)),la=new Set(["added","modified","deleted","renamed"]);function da(n){if(!n||typeof n!="object")return null;const e=n,t=typeof e.file=="string"?e.file:"",r=typeof e.relativePath=="string"?e.relativePath:t;if(!t&&!r)return null;const s=typeof e.stage=="string"&&ua.has(e.stage)?e.stage:nr.Unstaged,o=typeof e.status=="string"&&la.has(e.status)?e.status:void 0,i=e.stats&&typeof e.stats=="object"?e.stats:{},a=e.attribution&&typeof e.attribution=="object"?e.attribution:{};return{id:typeof e.id=="string"&&e.id?e.id:r||t,file:t||r,relativePath:r||t,stage:s,stats:{additions:typeof i.additions=="number"?i.additions:0,deletions:typeof i.deletions=="number"?i.deletions:0},...o?{status:o}:{},attribution:{...a.agent&&typeof a.agent=="object"?{agent:a.agent}:{},...typeof a.manual=="boolean"?{manual:a.manual}:{},timestamp:typeof a.timestamp=="number"?a.timestamp:0},...typeof e.commitHash=="string"?{commitHash:e.commitHash}:{}}}function _t(n,e){const t=n.map(r=>r.trim()).filter(Boolean);return t.length===0?{ok:!1,failure:{success:!1,error:`No file paths provided; ${e.toLowerCase()} requires explicit paths.`}}:t.some(r=>r==="."||r==="*"||r.includes("--all"))?{ok:!1,failure:{success:!1,error:`${e} all files is not allowed; specify explicit file paths.`}}:{ok:!0,paths:t}}class fa{async originUrl(e){try{const t=await u("git.getRemoteUrl",{repoPath:e,remoteName:"origin"});return typeof t?.url=="string"?t.url:null}catch{return null}}async status(e,t){return Sn(e,t)}async changes(e){return Sn(e)}async diffs(e,t){const r={workspaceId:e};t?.path&&(r.path=t.path),t?.paths?.length&&(r.paths=t.paths),t?.staged===!0&&(r.staged=!0),t?.commitHash&&(r.commitHash=t.commitHash),t?.gitRootId&&(r.gitRootId=t.gitRootId);try{const s=await u("git.diffs",r);return sa(s)}catch{return[]}}async commitDetails(e,t,r){try{const s=await u("git.commitDetails",{workspaceId:e,commitHash:t,...r?.gitRootId?{gitRootId:r.gitRootId}:{}});return!s||typeof s!="object"?null:ca(s,t)}catch{return null}}async trackedChanges(e){try{const t=await u("file-tracking.getChanges",{workspaceId:e});return(Array.isArray(t?.changes)?t.changes:[]).map(da).filter(s=>s!==null)}catch{return null}}async commits(e,t){try{return(await this.commitsWithBoundary(e,t)).commits}catch{return[]}}async commitsWithBoundary(e,t){const r=await u("file-tracking.loadCommits",{workspaceId:e,...t!==void 0?{includeOlder:t}:{}}),s=Array.isArray(r?.commits)?r.commits:[],o=r?.boundarySha===null||typeof r?.boundarySha=="string"?r.boundarySha:null,i=r?.nextToken===null||typeof r?.nextToken=="string"?r.nextToken:null;return{commits:s.map(aa).filter(a=>a!==null),boundarySha:o,nextToken:i,...typeof r?.historyIdentity=="string"&&r.historyIdentity?{historyIdentity:r.historyIdentity}:{}}}async getBranches(e,t,r){try{const s=await u("git.getBranches",{...r===void 0?{}:{workspaceId:r},repoPath:e,includeRemote:t});if(!s||typeof s!="object")return null;const o=Array.isArray(s.branches)?s.branches.filter(a=>typeof a=="string"):[],i=Array.isArray(s.remoteBranches)?s.remoteBranches.filter(a=>typeof a=="string"):[];return{branches:o,remoteBranches:i,currentBranch:typeof s.currentBranch=="string"?s.currentBranch:"",defaultBranch:typeof s.defaultBranch=="string"?s.defaultBranch:""}}catch{return null}}async branchStatus(e,t,r){try{const s=await u("git.branchStatus",{...r===void 0?{}:{workspaceId:r},repoPath:e,branchName:t});return!s||typeof s!="object"?null:{branch:typeof s.branch=="string"?s.branch:t,currentBranch:typeof s.currentBranch=="string"?s.currentBranch:"",isCurrentBranch:!!s.isCurrentBranch,ahead:typeof s.ahead=="number"?s.ahead:0,behind:typeof s.behind=="number"?s.behind:0,hasUncommittedChanges:!!s.hasUncommittedChanges}}catch{return null}}async prRefresh(e,t){try{const r=await u("pr.refresh",{workspaceId:e,...t});return!r||typeof r!="object"||typeof r.outcome!="string"||!["skipped","unchanged","linked","updated","unlinked"].includes(r.outcome)?null:{outcome:r.outcome,prNumber:typeof r.prNumber=="number"?r.prNumber:void 0,prUrl:typeof r.prUrl=="string"?r.prUrl:void 0,prStatus:typeof r.prStatus=="string"?r.prStatus:void 0,pullRequests:Array.isArray(r.pullRequests)?r.pullRequests:[]}}catch{return null}}async stage(e,t){const r=_t(t,"Staging");return r.ok?b("git.stage",{workspaceId:e,paths:r.paths}):r.failure}async unstage(e,t){const r=_t(t,"Unstaging");return r.ok?b("git.unstage",{workspaceId:e,paths:r.paths}):r.failure}async discard(e,t){const r=_t(t,"Discarding");return r.ok?b("git.discard",{workspaceId:e,paths:r.paths}):r.failure}async commit(e,t){return t.userRequested?b("git.agentCommit",{workspaceId:e,message:t.message,...t.files!==void 0?{files:t.files}:{},userRequested:t.userRequested}):{success:!1,error:"git.agentCommit requires userRequested: true."}}async pull(e,t,r){try{const s=await u("git.pull",{repoPath:e,branchName:t,...r===void 0?{}:{workspaceId:r}},{timeoutMs:na});return s&&typeof s=="object"&&s.ok===!0?{success:!0}:{success:!1,error:s&&typeof s=="object"&&typeof s.error=="string"&&s.error?s.error:"Failed to pull changes"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}}const pa=ze("LiveIntegrationsClient");function ga(n){return n.merged===!0?"merged":n.state==="closed"?"closed":n.draft===!0?"draft":n.isInMergeQueue===!0?"queued":"open"}class ya{captureRepositoryCheckout(e){return Es(e)}async githubUser(e){try{const r=(await u("github.getUser",...e===void 0?[]:[{workspaceId:e}]))?.user;return!r||typeof r.login!="string"||r.login.length===0?null:{login:r.login,name:null,email:null,avatar_url:typeof r.avatarUrl=="string"?r.avatarUrl:""}}catch{return null}}async githubBranches(e,t,r,s){const[o,i]=await Promise.all([u("github.branches.list",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,...r?{prefix:r}:{}}),r?Promise.resolve(void 0):u("github.repos.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t}).then(c=>{const l=c?.repo?.defaultBranch;return typeof l=="string"&&l.length>0?l:void 0},()=>{})]);return{branches:Array.isArray(o?.branches)?o.branches.filter(c=>typeof c=="string"):[],defaultBranch:i}}async githubBranchesCached(e,t,r){try{const s=await u("github.branches.listCached",{owner:e,repo:t,...r===void 0?{}:{workspaceId:r}}),o=Array.isArray(s?.branches)?s.branches.filter(c=>typeof c=="string"):[],i=typeof s?.defaultBranch=="string"&&s.defaultBranch.length>0?s.defaultBranch:void 0,a=s?.source==="cache"||s?.source==="ls-remote"?s.source:void 0;return{cached:s?.cached===!0,branches:o,defaultBranch:i,source:a}}catch{return{cached:!1,branches:[]}}}async githubRepoConfig(e,t,r,s){const o=await u("github.repoConfig.get",{owner:e,repo:t,...r?{ref:r}:{},...s===void 0?{}:{workspaceId:s}}),i=o?.config&&typeof o.config=="object"&&!Array.isArray(o.config)?o.config:null;return i===null&&o?.config!=null&&pa.warn("github.repoConfig.get returned a non-object config; treating as null",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t}),{config:i,exists:o?.exists===!0}}captureRepositoryResource(e){return Cs(e)}async githubPullRequest(e,t,r,s){const i=(await u("github.pulls.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,number:r}))?.pull;if(!i)throw new Error(`Pull request ${e}/${t}#${r} not found`);const a=ga(i),c=a==="queued"?ir(i.mergeQueue):null;return{owner:e,repo:t,number:i.number,title:i.title,state:a,author:i.user.login,createdAt:i.createdAt,updatedAt:i.updatedAt,url:i.htmlUrl,headRef:i.headRef,baseRef:i.baseRef,...c?{mergeQueue:c}:{}}}async githubIssue(e,t,r,s){const i=(await u("github.issues.get",{...s===void 0?{}:{workspaceId:s},owner:e,repo:t,number:r}))?.issue;if(!i)throw new Error(`Issue ${e}/${t}#${r} not found`);return{owner:e,repo:t,number:i.number,title:i.title,state:i.state,author:i.user.login,createdAt:i.createdAt,updatedAt:i.updatedAt,url:i.htmlUrl}}async linearIssues(e){try{return(await u("linear.authStatus",...e===void 0?[]:[{workspaceId:e}]))?.authenticated!==!0?[]:(await u("linear.listIssues",...e===void 0?[]:[{workspaceId:e}])).issues}catch{return[]}}async sentryIssues(e){try{return(await u("sentry.authStatus",...e===void 0?[]:[{workspaceId:e}]))?.authenticated!==!0?[]:(await u("sentry.listIssues",...e===void 0?[]:[{workspaceId:e}])).issues}catch{return[]}}subscribe(e){let t=!1;return this.githubUser().then(r=>{t||e({githubUser:r})}),()=>{t=!0}}}const ma=["cli-missing","prerequisite-missing"];function ha(n){return ma.some(e=>e===n)}function va(n){if(!(typeof n?.warning!="string"||!n.warning))return ha(n.warningKind)?n.warningKind:void 0}function Wu(n){const e={success:!0,data:Rr(n)};typeof n?.warning=="string"&&n.warning&&(e.warning=n.warning),n?.stale===!0&&(e.stale=!0);const t=va(n);return t&&(e.warningKind=t),e}function ba(n){if(typeof n?.id!="string"||!n.id||typeof n?.name!="string"||!n.name)return null;const e={value:n.id,label:n.name};return typeof n.description=="string"&&(e.description=n.description),typeof n.modelGroupPriority=="number"&&(e.modelGroupPriority=n.modelGroupPriority),typeof n.costTier=="number"&&(e.costTier=n.costTier),Array.isArray(n.badges)&&(e.badges=n.badges),Array.isArray(n.effortLevels)&&(e.effortLevels=n.effortLevels),n.isDefault===!0&&(e.isDefault=!0),n.isLegacyModel===!0&&(e.isLegacyModel=!0),typeof n.priority=="number"&&(e.priority=n.priority),e}function Rr(n){return Array.isArray(n?.models)?n.models.flatMap(e=>ba(e)??[]):[]}class Sa{async list(e,t){try{const r=e||t?await u("models.list",{...e?{providerId:e}:{},...t?{workspaceId:t}:{}}):await u("models.list");return e&&r.providerId!==e?[]:Rr(r)}catch{return[]}}subscribe(e){let t=!1;return this.list().then(r=>{t||e(r)}),()=>{t=!0}}}function Ft(n){if(typeof n=="number"&&Number.isFinite(n)&&n>=0)return Math.trunc(n);if(typeof n=="string"&&n.length>0){const e=Number(n);if(Number.isFinite(e)&&e>=0)return Math.trunc(e)}return null}function Ia(n){if(!n||typeof n!="object")return null;const e=n,t=Ft(e.v);if(t===null)return null;const r=e.author&&typeof e.author=="object"?e.author:null,s=r?{id:String(r.id??""),name:String(r.name??""),type:typeof r.type=="string"?r.type:as.System}:void 0;return{versionId:String(t),versionNumber:t,content:String(e.content??""),title:String(e.title??""),...s?{author:s}:{},createdAt:String(e.date??"")}}class ka extends Error{constructor(){super("Truncated note read capability is unknown: no acknowledged hello yet"),this.name="NoteCapabilityUnknownError"}}function Aa(n){return n instanceof Error?n.message===E.agent_placement_unavailable()?!1:n.name!=="UnbridgedMockIpcChannelError":!0}const Ta=30,wa=100;function qe(n,e){const t=new Date().toISOString(),r=String(n.id??"");return{...n,id:is(r),workspaceId:Qn(String(n.workspaceId??e)),title:String(n.title??""),content:String(n.content??""),contentType:typeof n.contentType=="string"?n.contentType:os.Markdown,tags:Array.isArray(n.tags)?n.tags:[],isPinned:!!(n.isPinned??n.is_pinned??!1),isArchived:!!(n.isArchived??n.is_archived??!1),visibility:typeof n.visibility=="string"?n.visibility:ss.Workspace,rev:typeof n.rev=="number"?n.rev:void 0,contentPreview:typeof n.contentPreview=="string"?n.contentPreview:void 0,contentLength:typeof n.contentLength=="number"?n.contentLength:void 0,contentTruncated:n.contentTruncated===!0?!0:void 0,contentBytes:n.contentTruncated===!0&&typeof n.contentBytes=="number"?n.contentBytes:void 0,createdAt:String(n.createdAt??n.created_at??t),updatedAt:String(n.updatedAt??n.updated_at??t)}}class Ea{async list(e,t){const r=o=>u("note.list",o);let s;if(t?.projection==="slim")try{s=await Re(r,{workspaceId:e,projection:"slim",limit:ve},"notes")}catch(o){if(!Zn(o))throw o;s=await Re(r,{workspaceId:e,limit:ve},"notes")}else s=await Re(r,{workspaceId:e,limit:ve},"notes");return s.map(o=>{const i=qe(o,e);return He(String(i.id),e),i})}async supportsTruncatedRead(){for(let e=0;e<Ta;e++){try{const r=(await Rs())?.server?.capabilities;if(r)return r.noteTruncatedRead===1}catch(t){if(!Aa(t))return!1}await new Promise(t=>setTimeout(t,wa))}throw new ka}async get(e,t,r){const s=t??await re(e);if(!s)return null;try{const o=r?.maxContentBytes!==void 0?await u("note.get",{workspaceId:s,noteId:e,maxContentBytes:r.maxContentBytes}):await dr(a=>u("note.get",a),{workspaceId:s,noteId:e}),i=o&&typeof o=="object"&&"note"in o?o.note:o;return!i||typeof i!="object"?null:qe(i,s)}catch{return null}}async create(e){return jt("note.create",{...e,idempotencyKey:Y()})}async setContent(e,t,r,s,o){return this.runNoteMutation(e,"note.setContent",{content:t,...o?.baseContentBytes!==void 0?{baseContentBytes:o.baseContentBytes}:{}},r,s)}async add(e,t,r,s,o){return this.runNoteMutation(e,"note.add",{content:t,...r?.heading!==void 0?{heading:r.heading}:{},...r?.position!==void 0?{position:r.position}:{}},s,o)}async edit(e,t,r,s,o){return this.runNoteMutation(e,"note.edit",{old:t,new:r},s,o)}async editLines(e,t,r,s,o,i){return this.runNoteMutation(e,"note.editLines",{start:t,end:r,content:s},o,i)}async delete(e,t,r){return this.runNoteMutation(e,"note.delete",{},t,r)}async updateMetadata(e,t,r,s){return this.runNoteMutation(e,"note.updateMetadata",{...t.title!==void 0?{title:t.title}:{},...t.tags!==void 0?{tags:t.tags}:{}},r,s)}async listVersions(e,t){const r=await u("note.listVersions",{workspaceId:e,noteId:t});return!Array.isArray(r)||r.length===0?[]:(await Promise.all(r.map(o=>{const i=Ft(o.v);return i===null?Promise.resolve(null):u("note.getVersion",{workspaceId:e,noteId:t,v:i}).then(a=>Ia(a)).catch(()=>null)}))).filter(o=>o!==null)}async restoreVersion(e,t,r){const s=Ft(r);if(s===null)return{success:!1,error:`Invalid version id: ${r}`};try{const o=await u("note.restoreVersion",{workspaceId:e,noteId:t,v:s});return{success:!0,note:o&&typeof o=="object"&&o.note&&typeof o.note=="object"?qe(o.note,e):void 0}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}async runNoteMutation(e,t,r,s,o){const i=o??await re(e);if(!i)return{success:!1,error:`Cannot resolve workspace for note ${e}`};const a=await b(t,{workspaceId:i,noteId:e,...r,...s!==void 0?{expectedVersion:s}:{}}),c=a.conflict?.current;return c&&typeof c=="object"?{...a,conflict:{current:qe(c,i)}}:a}subscribe(e){return Ye({channel:{subscribeMethod:"note.subscribe",unsubscribeMethod:"note.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t,limit:ve})},continuation:{method:"note.list",key:"notes",params:t=>({workspaceId:t.workspaceId,limit:ve})}},getId:t=>String(t.id??""),normalize:t=>{const r=String(t.workspaceId??"");if(!r)return null;const s=qe(t,r);return He(String(s.id),r),s},handler:e})}}class Ca{async catalog(e){const t=cs.parse(e?{workspaceId:e}:{}),r=await u(Ss,t);return us.parse(r)}async listProfiles(e){const t=await u(Is,e?{baseProviderId:e}:{});return ls.parse(t)}async createProfile(e){const t=await u(ds,{baseProviderId:e.baseProviderId,name:e.name,...e.env?{env:e.env}:{},...e.backup!==void 0?{backup:e.backup}:{}});return fs.parse(t)}async updateProfile(e){const t=await u(ps,{profileId:e.profileId,...e.name!==void 0?{name:e.name}:{},...e.env?{env:e.env}:{},...e.backup!==void 0?{backup:e.backup}:{}});return gs.parse(t)}async updateDefault(e){const t=await u(ys,{baseProviderId:e.baseProviderId,...e.name!==void 0?{name:e.name}:{},...e.env?{env:e.env}:{}});return ms.parse(t)}async deleteProfile(e){const t=await u(ks,{profileId:e});return hs.parse(t)}async reorderProfiles(e){const t=await u(vs,{baseProviderId:e.baseProviderId,profileIds:e.profileIds});return bs.parse(t)}}const Ra=200;class _a{async supportsLifecycle(){return(await u("client.hello",{}))?.server?.capabilities?.scriptLifecycle===1}async requireActiveLists(){const e=await u("client.hello",{});if(e.server?.capabilities?.scriptActiveLists!==1)throw new Error(E.scripts_list_unsupported_error());return{fullPages:e.server?.capabilities?.boundedReads===1}}async list(e,t){const{fullPages:r}=await this.requireActiveLists(),s=[],o=new Set;let i;do{const a=await u("script.list",{workspaceId:e,archive:t?.archive??"active",...r?{limit:Ra,...i?{cursor:i}:{}}:{}});if(!Array.isArray(a?.scripts))throw new Error(E.scripts_list_load_error());for(const l of a.scripts)s.push(Oa(l)?await In(e,l.id):l);const c=r?a.nextCursor:void 0;if(typeof c=="string"&&c&&!o.has(c))o.add(c),i=c;else{if(c!=null)throw new Error(E.scripts_list_load_error());i=void 0}}while(i);return s}async listPage(e,t){await this.requireActiveLists();const r=await u("script.list",{workspaceId:e,archive:"active",view:"summary",limit:100,...t});if(r?.view!=="summary"||!Array.isArray(r.scripts))throw new Error(E.scripts_list_unsupported_error());return r}async get(e,t){return await this.requireActiveLists(),In(e,t)}async archive(e,t,r){if(!r?.capabilityVerified&&!await this.supportsLifecycle())throw new Error(E.scripts_list_unsupported_error());return u("script.archive",{workspaceId:e,scriptIds:t})}async restore(e,t,r){if(!r?.capabilityVerified&&!await this.supportsLifecycle())throw new Error(E.scripts_list_unsupported_error());return u("script.restore",{workspaceId:e,scriptIds:t})}async create(e,t){try{if(t.scriptId!==void 0)throw new Error("Use scriptsClient.update to edit an existing script.");const r=await u("script.create",{workspaceId:e,name:t.name,command:t.command,mode:t.mode,...t.purpose!==void 0?{purpose:t.purpose}:{},...t.cwd!==void 0?{cwd:t.cwd}:{},...t.env!==void 0?{env:t.env}:{},...t.category!==void 0?{category:t.category}:{},...t.autoStart!==void 0?{autoStart:t.autoStart}:{},...t.healthUrl!==void 0?{healthUrl:t.healthUrl}:{},...t.readyPattern!==void 0?{readyPattern:t.readyPattern}:{}}),s=typeof r?.id=="string"?r.id:void 0;return{success:!0,...s?{id:s}:{},...r?{script:r}:{}}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async start(e,t){return b("script.start",{workspaceId:e,scriptId:t})}async stop(e,t){return b("script.stop",{workspaceId:e,scriptId:t})}async restart(e,t){return b("script.restart",{workspaceId:e,scriptId:t})}async output(e,t,r){try{const s=await u("script.output",{workspaceId:e,scriptId:t,...r!==void 0?{maxLines:r}:{}});return typeof s=="string"?s:""}catch{return""}}async status(e,t){try{const r=await u("script.status",{workspaceId:e,scriptId:t});return r&&typeof r=="object"?r:null}catch{return null}}async run(e,t,r){try{const s=await u("script.run",{workspaceId:e,scriptId:t,...r?.maxLines!==void 0?{maxLines:r.maxLines}:{},...r?.timeoutSeconds!==void 0?{timeoutSeconds:r.timeoutSeconds}:{}});return s&&typeof s=="object"?s:null}catch{return null}}subscribe(e){return e([]),()=>{}}}function Oa(n){return Object.entries(n).some(([e,t])=>e.endsWith("Omitted")&&t===!0)}const Ma=3,Pa=4096;async function In(n,e){for(let t=0;t<Ma;t++){const r=await u("script.get",{workspaceId:n,scriptId:e});if(r?.commandTruncated!==!0)return r;const s=r.commandBytes;let o=r.command,i=r.nextCommandOffset,a=!1,c=1;for(;typeof i=="number";){if(++c>Pa)throw new Error(E.scripts_list_load_error());const S=await u("script.get",{workspaceId:n,scriptId:e,commandOffset:i});if(S?.commandBytes!==s||S.commandOffset!==i||S.updatedAt!==r.updatedAt){a=!0;break}o+=S.command;const A=S.nextCommandOffset;if(typeof A=="number"&&A<=i)throw new Error(E.scripts_list_load_error());i=A}if(a)continue;if(new TextEncoder().encode(o).length!==s)throw new Error(E.scripts_list_load_error());const{commandTruncated:l,commandBytes:d,commandOffset:m,nextCommandOffset:I,...w}=r;return{...w,command:o}}throw new Error(E.scripts_list_load_error())}const Na=["stdio","http","sse"],La=["oauth","header","none"];function Le(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function kn(n){const e=new WeakSet;try{const t=JSON.stringify(n,(r,s)=>!Le(s)&&!Array.isArray(s)?s:e.has(s)?"[Circular]":(e.add(s),Array.isArray(s)?s:Object.keys(s).sort().reduce((o,i)=>(o[i]=s[i],o),{})));return t===void 0?void 0:t}catch{return}}function _r(n,e,t){if(n==null)return e;if(typeof n=="string")return n||e;if(n instanceof Error)return n.message||e;if(Le(n)){if(t.has(n))return kn(n)??e;t.add(n);for(const r of["message","error","reason","details"])if(r in n)return _r(n[r],e,t)}return kn(n)??String(n||e)}function Gu(n,e){return _r(n,e,new WeakSet)}function Ae(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function xa(n){if(Array.isArray(n)){const e=n.filter(t=>typeof t=="string");return e.length>0?e:void 0}if(typeof n=="string"){const e=n.trim().split(/\s+/).filter(Boolean);return e.length>0?e:void 0}}function An(n){if(!Le(n))return;const e=Object.entries(n).filter(t=>typeof t[1]=="string");return Object.fromEntries(e)}function Ba(n){return La.includes(n)?n:void 0}function Vu(n){switch(n){case"running":return"connected";case"starting":return"configured";case"stopped":return"stopped";case"error":return"error";case"auth_required":return"auth_required";default:return null}}function Ot(n,e){if(!Le(n))return null;const t=Ae(n.name)??Ae(e);if(!t)return null;const r=n.type??n.transport,s=Na.includes(r)?r:Ae(n.command)?"stdio":"http",o={name:t,type:s},i=Ae(n.id);i&&(o.id=i);const a=Ae(n.command),c=Ae(n.url),l=xa(n.args),d=An(n.env),m=An(n.headers),I=Ba(n.authType);return a&&(o.command=a),c&&(o.url=c),l&&(o.args=l),d&&(o.env=d),m&&(o.headers=m),I&&(o.authType=I),typeof n.disabled=="boolean"&&(o.disabled=n.disabled),o}function ja(n){if(Array.isArray(n))return n.flatMap(r=>Ot(r)??[]);if(!Le(n))return[];const e=n.mcpServers??n.servers;if(Array.isArray(e))return e.flatMap(r=>Ot(r)??[]);const t=Le(e)?e:n;return Object.entries(t).flatMap(([r,s])=>Ot(s,r)??[])}function Or(n){const e=new Set,t=new Map;for(const r of n){const s=Xn(r);if(e.has(s))throw new Error(`Duplicate MCP server identity: ${s}`);e.add(s);const o=t.get(r.name);if(o&&(!o.id||!r.id))throw new Error(`Duplicate MCP server name requires distinct IDs: ${r.name}`);t.set(r.name,r)}}function zu(n){const e=ja(n);return Or(e),e}function Ku(n){const e={name:n.name,type:n.type};return n.id!==void 0&&(e.id=n.id),n.command!==void 0&&(e.command=n.command),n.args!==void 0&&(e.args=[...n.args]),n.url!==void 0&&(e.url=n.url),n.authType!==void 0&&(e.authType=n.authType),n.disabled!==void 0&&(e.disabled=n.disabled),n.workspaceDisabled!==void 0&&(e.workspaceDisabled=n.workspaceDisabled),e}const Tn="global",be=new Map,$e=new Map,he=new Map;let Me=0,Mr=0;function Pr(n,e){return JSON.stringify([Mr,e??null,n])}let wn=!1;function Da(n){if(n.method!=="events.event"||!n.params)return;const e=n.params,t=e.event&&typeof e.event=="object"?e.event:e;return typeof t.type=="string"?t.type:void 0}function Nr(){wn||(wn=!0,typeof se=="function"&&se(n=>{Da(n)==="settings:changed"&&We()}),typeof oe=="function"&&oe(()=>{Mr+=1,We()}))}function We(n){if(Me+=1,!n)be.clear();else for(const e of be.keys())n.includes(JSON.parse(e)[2])&&be.delete(e)}function Ua(n){return n?.definition?{...n.definition,value:n.value,...n.origin?{origin:n.origin}:{},...typeof n.revision=="number"?{revision:n.revision}:{}}:null}function Lr(n,e){Nr();const t=Pr(n,e);if(be.has(t))return Promise.resolve(be.get(t)??null);const r=$e.get(t);if(r?.generation===Me)return r.promise;if(r){const i=he.get(t);if(i)return i;const a=r.promise.catch(()=>null).then(()=>he.get(t)!==a?null:(he.delete(t),Lr(n,e))).finally(()=>{he.get(t)===a&&he.delete(t)});return he.set(t,a),a}const s=Me,o=u("settings.get",{path:n,...e?{workspaceId:e}:{}}).then(Ua).then(i=>(s===Me&&be.set(t,i),i)).finally(()=>{$e.get(t)?.promise===o&&$e.delete(t)});return $e.set(t,{generation:s,promise:o}),o}async function qa(n){if(n.length===0)return{applied:[],revision:0};const e=await u("settings.update",{changes:n});return We(n.map(({path:t})=>t)),{applied:Array.isArray(e?.applied)?e.applied:[],revision:typeof e?.revision=="number"?e.revision:0}}function Yu(){We(),$e.clear(),he.clear()}function En(n){const e=[];for(const[t,r]of Object.entries(n))r!==void 0&&e.push({path:t,value:r});return e}class Fa{async list(e){return(await this.listSnapshot(e)).settings}async listSnapshot(e){Nr();const t=Me;try{const r=await u("settings.list",...e?[{workspaceId:e}]:[]),s={settings:Array.isArray(r?.settings)?r.settings:[],revision:typeof r?.revision=="number"?r.revision:0};if(t===Me)for(const o of s.settings)be.set(Pr(o.path,e),o);return s}catch{return{settings:[],revision:0}}}async get(e,t){try{return await Lr(e,t)}catch{return null}}async update(e){return(await this.updateSnapshot(e)).applied}async updateSnapshot(e){return qa(e)}async reset(e){try{const t=await u("settings.reset",{path:e});return typeof t?.path!="string"?null:(We([t.path]),{path:t.path,value:t.value})}catch{return null}}async getUserRule(e,t){try{const r=await u("rules.get",{workspaceId:t??Tn,ruleType:e});return!r||typeof r.content!="string"?null:{enabled:r.enabled===!0,content:r.content,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:0}}catch{return null}}async updateUserRule(e,t,r){return b("rules.update",{workspaceId:Tn,ruleType:e,content:t,...r!==void 0?{enabled:r}:{}})}async getUserPreferences(){return null}async setUserPreferences(e){return{success:!0}}async getProviderSettings(e){const t=await this.list(e),r=Mt(t,"model.defaultProvider"),s=et(t,"providers.enabled");return r===null&&s===null?null:{activeProviderId:r??"",enabledProviders:s??{}}}async setProviderSettings(e){return b("settings.update",{changes:En({"model.defaultProvider":e.activeProviderId,"providers.enabled":e.enabledProviders})})}async getMcpServers(e){return(await Rn(e)).flatMap(r=>xr(r)??[])}async getMcpServerStatuses(e,t){return(await Promise.all(e.map(async s=>{try{const o=await u("mcp.servers.getStatus",{serverId:s,...t?{workspaceId:t}:{}});return Cn(s,o?.status)}catch{return null}}))).filter(s=>s!==null)}async restartMcpServer(e){const t=await u("mcp.servers.restart",{serverId:e}),r=Cn(e,t?.status);if(!r)throw new Error("The daemon returned an invalid MCP server status.");return r}async getWorkspaceDisabledMcpServerKeys(e){try{const t=await u("mcp.servers.list",{workspaceId:e});return Array.isArray(t?.servers)?t.servers.flatMap(r=>r.workspaceDisabled===!0&&typeof r.name=="string"&&r.name?[Xn({id:r.id,name:r.name})]:[]):null}catch{return null}}async toggleWorkspaceMcpServer(e,t,r){try{const s=await u("mcp.servers.toggle",{serverId:t,enabled:r,workspaceId:e});return typeof s?.workspaceDisabled=="boolean"?{success:!0,workspaceDisabled:s.workspaceDisabled}:{success:!0}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}async setMcpServers(e){try{Or(e);const t=await Rn(),r=new Map(t.map(i=>[i.id,i])),s=e.map(i=>{if(i.id!==void 0)return{config:i,current:r.get(i.id)};const a=t.filter(c=>c.name===i.name);if(a.length>1)throw new Error(`Ambiguous MCP server name: ${i.name}`);return{config:i,current:a[0]}}),o=new Set;for(const{config:i,current:a}of s){const c=a?.id??i.id;if(c){if(o.has(c))throw new Error(`Duplicate MCP server identity: ${c}`);o.add(c)}}for(const i of t)i.id&&!o.has(i.id)&&await u("mcp.servers.delete",{serverId:i.id});for(const{config:i,current:a}of s){if(!a?.id){await u("mcp.servers.create",{config:_n(i,i.id)});continue}const c={...i,env:i.env??a.env,headers:i.headers??a.headers};$a(a,c)||await u("mcp.servers.update",{serverId:a.id,config:_n(c,a.id)});const l=i.disabled!==!0;a.enabled!==!1!==l&&await u("mcp.servers.toggle",{serverId:a.id,enabled:l})}return{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async getWorkspaceSettings(e){try{const t=await u("workspace.getAutoCommit",{workspaceId:e});return typeof t?.autoCommit?.enabled!="boolean"?null:{autoCommitEnabled:t.autoCommit.enabled}}catch{return null}}async setWorkspaceSettings(e,t){return t.autoCommitEnabled===void 0?{success:!0}:b("workspace.setAutoCommit",{workspaceId:e,enabled:t.autoCommitEnabled})}async getBackgroundAgentSettings(e){const t=await this.list(e),r=Mt(t,"quickActions.defaultReasoningEffort"),s=et(t,"quickActions.typeReasoningEffortOverrides"),o=Mt(t,"quickActions.defaultModel"),i=et(t,"quickActions.typeOverrides"),a=et(t,"quickActions.providerSettings");return o===null&&i===null&&a===null&&r===null&&s===null?null:{defaultReasoningEffort:r??"",typeReasoningEffortOverrides:s??{},defaultModel:o??"",typeOverrides:i??{commit:"",pr:"",review:"",fast:""},providerSettings:a??{}}}async setBackgroundAgentSettings(e){return b("settings.update",{changes:En({"quickActions.defaultReasoningEffort":e.defaultReasoningEffort,"quickActions.typeReasoningEffortOverrides":e.typeReasoningEffortOverrides,"quickActions.defaultModel":e.defaultModel,"quickActions.typeOverrides":e.typeOverrides,"quickActions.providerSettings":e.providerSettings})})}subscribe(e){return e(null),()=>{}}}function Cn(n,e){if(typeof e?.serverId=="string"&&e.serverId&&e.serverId!==n||e?.state!=="stopped"&&e?.state!=="starting"&&e?.state!=="running"&&e?.state!=="error"&&e?.state!=="auth_required")return null;const t={serverId:n,state:e.state};return typeof e.lastError=="string"&&e.lastError&&(t.lastError=e.lastError),t}async function Rn(n){try{const e=await u("mcp.servers.list",...n?[{workspaceId:n}]:[]);return Array.isArray(e?.servers)?e.servers:[]}catch{return[]}}function xr(n){if(typeof n?.name!="string"||!n.name)return null;const e=n.transport==="http"||n.transport==="sse"?n.transport:"stdio",t={name:n.name,type:e};return typeof n.id=="string"&&n.id&&(t.id=n.id),typeof n.command=="string"&&n.command&&(t.command=n.command),Array.isArray(n.args)&&(t.args=n.args),n.env&&typeof n.env=="object"&&(t.env=n.env),typeof n.url=="string"&&n.url&&(t.url=n.url),n.headers&&typeof n.headers=="object"&&(t.headers=n.headers),n.enabled===!1&&(t.disabled=!0),typeof n.workspaceDisabled=="boolean"&&(t.workspaceDisabled=n.workspaceDisabled),t}function _n(n,e){const t={name:n.name,transport:n.type,enabled:n.disabled!==!0};return e&&(t.id=e),n.command&&(t.command=n.command),n.args&&(t.args=n.args),n.env&&(t.env=n.env),n.url&&(t.url=n.url),n.headers&&(t.headers=n.headers),t}function $a(n,e){const t=xr(n);if(!t)return!1;const r=o=>o?Object.entries(o).sort(([i],[a])=>i.localeCompare(a)):null,s=o=>JSON.stringify([o.name,o.type,o.command??null,o.args??null,r(o.env),o.url??null,r(o.headers)]);return s(t)===s(e)}function Br(n,e){for(const t of n)if(t.path===e)return t;return null}function Mt(n,e){const t=Br(n,e);return t&&typeof t.value=="string"?t.value:null}function et(n,e){const t=Br(n,e);return!t||t.value===null||typeof t.value!="object"?null:t.value}function Pt(n){if(!n||typeof n!="object")return null;const e=n.setupScript;return!e||typeof e!="object"?null:e}class Ha{async get(e){try{const t=await u("workspace.getSetupScript",{workspaceId:e});return Pt(t)}catch{return null}}async save(e,t){try{const r=await u("workspace.saveSetupScript",{workspaceId:e,script:t});return Pt(r)}catch{return null}}async detectProjectType(e){try{const t=await u("workspace.detectProjectType",{workspaceId:e});return typeof t?.projectType=="string"?t.projectType:null}catch{return null}}async generate(e){try{const t=await u("workspace.generateSetupScript",{workspaceId:e});return Pt(t)}catch{return null}}}const On=ze("LiveSkillsClient"),Wa=500,Ga=100;function Mn(n){return{name:n.name,description:n.description,location:n.location,...n.resourceDirectory?{resourceDirectory:n.resourceDirectory}:{},scope:n.scope}}class Va{async fetchList(e){const t=[],r=new Set;let s;for(let o=0;o<Ga;o++){const i=await u("skill.list",{workspaceId:e,limit:Wa,...s?{nextToken:s}:{}});if(Array.isArray(i))return i.map(Mn);for(const a of Array.isArray(i?.skills)?i.skills:[])r.has(a.name)||(r.add(a.name),t.push(Mn(a)));if(s=typeof i?.nextToken=="string"?i.nextToken:void 0,!s)return t}return On.warn("skill.list paging stopped at the page limit"),t}async list(e){return this.fetchList(e)}subscribe(e){let t=!1,r,s;e([]);const o=l=>{this.fetchList(l).then(d=>{t||e(d)}).catch(d=>{On.error("Failed to refetch skill list; keeping last known-good view",d)})},i=()=>$t({eventTypes:["skills:changed"]}).then(l=>{r=l?.subscriptionId,t&&r&&Ne(r)}).catch(()=>{});i();const a=se(l=>{if(l.method==="skills:changed"&&!t){const m=l.params?.workspaceId;m&&(s=m,o(m))}}),c=oe(()=>{t||(r=void 0,i(),s&&o(s))});return()=>{t=!0,a(),c(),r&&Ne(r)}}}const Nt=ze("LiveSpecialistsClient"),za=100,Ka=500,Ya=100;class Ja{async listCatalog(e,t,r){const s={...e?{provider:e}:{},...t?{workspaceId:t}:{},...r?.includeProject?{includeProject:!0}:{}},o=[],i=new Set;let a,c;for(let d=0;d<Ya;d++){const m=await u("specialist.list",{...s,limit:Ka,...c?{nextToken:c}:{}});for(const I of Array.isArray(m?.specialists)?m.specialists:[])i.has(I.id)||(i.add(I.id),o.push(I));if(d===0&&(a=m?.importDiagnostics),c=typeof m?.nextToken=="string"?m.nextToken:void 0,!c)break}return c&&Nt.warn("specialist.list paging stopped at the page limit"),{specialists:await Promise.all(o.map(d=>d.behaviorPromptOmitted?this.hydrateOmittedPrompt(d,e,t):d)),importDiagnostics:a}}async hydrateOmittedPrompt(e,t,r){try{const o=(await u("specialist.get",{id:e.id,...t?{provider:t}:{},...r?{workspaceId:r}:{}}))?.specialist;if(o&&o.id===e.id&&o.source===e.source&&!o.behaviorPromptOmitted&&typeof o.behaviorPrompt=="string")return{...e,...o,behaviorPromptOmitted:void 0,behaviorPromptBytes:void 0}}catch(s){Nt.warn(`specialist.get for omitted prompt of ${e.id} failed`,s)}return e}async list(e,t){try{return(await this.listCatalog(e,t)).specialists}catch{return[]}}subscribe(e){return this.subscribeCatalogSnapshot(t=>e(t.specialists),()=>e([]))}subscribeCatalog(e){return this.subscribeCatalogSnapshot(e)}subscribeCatalogSnapshot(e,t){let r=!1,s,o;this.listCatalog().then(d=>{r||e(d)}).catch(()=>{r||t?.()});const i=()=>{this.listCatalog().then(d=>{r||e(d)}).catch(d=>{Nt.error("Failed to refetch specialist list; keeping last known-good view",d)})},a=()=>$t({eventTypes:["specialists:changed","skills:changed"]}).then(d=>{s=d?.subscriptionId,r&&s&&Ne(s)}).catch(()=>{});a();const c=se(d=>{(d.method==="specialists:changed"||d.method==="skills:changed")&&!r&&(o!==void 0&&clearTimeout(o),o=setTimeout(()=>{o=void 0,i()},za))}),l=oe(()=>{r||(s=void 0,a(),o!==void 0&&(clearTimeout(o),o=void 0),i())});return()=>{r=!0,o!==void 0&&(clearTimeout(o),o=void 0),c(),l(),s&&Ne(s)}}async create(e,t,r,s,o){const i={id:e,spec:t};return r&&(i.scope=r),s&&(i.workspacePath=s),r==="project"&&o&&(i.workspaceId=o),(await u("specialist.create",i)).specialist}async edit(e,t,r,s,o){const i={id:e,spec:t,scope:r};return s&&(i.workspacePath=s),r==="project"&&o&&(i.workspaceId=o),(await u("specialist.edit",i)).specialist}async delete(e,t,r,s){const o={id:e,scope:t};return r&&(o.workspacePath=r),t==="project"&&s&&(o.workspaceId=s),await u("specialist.delete",o)}}class Za{async getUsage(e,t,r){const s={period:e,tzOffsetMinutes:r};t!==void 0&&(s.key=t);const o=await u("stats.getUsage",s);for(const i of["byModel","byProvider"])if(!Array.isArray(o[i]))throw new Error(`stats.getUsage result is missing the required \`${i}\` array (PROTOCOL §5.36) — the daemon is likely outdated and predates this field`);return o}}const Qa=12e4;function Xa(n){return typeof n.arrayBuffer=="function"?n.arrayBuffer():new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(r.error??new Error("Blob read failed")),r.readAsArrayBuffer(n)})}async function ec(n){const e=new Uint8Array(await Xa(n)),t=32768;let r="";for(let s=0;s<e.length;s+=t)r+=String.fromCharCode(...e.subarray(s,s+t));return btoa(r)}class tc{async transcribe(e,t,r,s){const o={audio:await ec(e),mimeType:t};return r&&(r.prompt!==void 0||r.keyterms!==void 0)&&(o.context=r),typeof s=="string"&&s.trim().length>0&&(o.workspaceId=s),u("voice.transcribe",o,{timeoutMs:Qa})}async getWorkspaceVocabulary(e){return u("voice.getWorkspaceVocabulary",{workspaceId:e})}}const nc=["stable","beta","alpha","disabled"];function Ju(n){return nc.includes(n)}const O={CHECK_MANUAL:"auto-update:check-manual",DOWNLOAD:"auto-update:download",INSTALL:"auto-update:install",GET_STATE:"auto-update:get-state",SET_CHANNEL:"auto-update:set-channel",SET_SHARE_STATISTICS:"auto-update:set-share-statistics",STATUS_CHANGED:"auto-update:status-changed",PROGRESS:"auto-update:progress",ERROR:"auto-update:error",UP_TO_DATE:"auto-update:up-to-date",SHOW_TOAST:"auto-update:show-toast"},jr={async checkForUpdatesManual(){const n=await ye(O.CHECK_MANUAL);if(!n.success||n.data===void 0)throw new Error(n.error?.message||E.autoUpdate_client_checkFailed_error());return n.data},async downloadUpdate(){const n=await ye(O.DOWNLOAD);if(!n.success)throw new Error(n.error?.message||E.autoUpdate_client_downloadFailed_error())},async installUpdate(){const n=await ye(O.INSTALL);if(!n.success)throw new Error(n.error?.message||E.autoUpdate_client_installFailed_error())},async getState(){const n=await ye(O.GET_STATE);if(!n.success||n.data===void 0)throw new Error(n.error?.message||E.autoUpdate_client_getStateFailed_error());return n.data},async setChannel(n){const e=await ye(O.SET_CHANNEL,{channel:n});if(!e.success)throw new Error(e.error?.message||E.autoUpdate_client_setChannelFailed_error())},async setShareStatistics(n){const e=await ye(O.SET_SHARE_STATISTICS,{enabled:n});if(!e.success)throw new Error(e.error?.message||E.autoUpdate_client_setShareStatisticsFailed_error())},onStatusChanged(n){const e=window.electronAPI.on(O.STATUS_CHANGED,n);return()=>{e&&window.electronAPI.offById(O.STATUS_CHANGED,e)}},onProgress(n){const e=window.electronAPI.on(O.PROGRESS,n);return()=>{e&&window.electronAPI.offById(O.PROGRESS,e)}},onError(n){const e=window.electronAPI.on(O.ERROR,n);return()=>{e&&window.electronAPI.offById(O.ERROR,e)}},onShowToast(n){const e=window.electronAPI.on(O.SHOW_TOAST,n);return()=>{e&&window.electronAPI.offById(O.SHOW_TOAST,e)}},onUpToDate(n){const e=window.electronAPI.on(O.UP_TO_DATE,n);return()=>{e&&window.electronAPI.offById(O.UP_TO_DATE,e)}}},Zu=Object.freeze(Object.defineProperty({__proto__:null,autoUpdateClient:jr},Symbol.toStringTag,{value:"Module"}));class rc{async status(){try{const e=await u("system.status");return!e||typeof e!="object"?{nodeVersionOk:null,nodeVersion:void 0,auggieInstalled:!1,binaryInstallAvailable:!1}:{nodeVersionOk:typeof e.nodeVersionOk=="boolean"?e.nodeVersionOk:null,nodeVersion:typeof e.nodeVersion=="string"?e.nodeVersion:void 0,auggieInstalled:typeof e.auggieInstalled=="boolean"?e.auggieInstalled:!1,binaryInstallAvailable:typeof e.binaryInstallAvailable=="boolean"?e.binaryInstallAvailable:!1}}catch{return{nodeVersionOk:null,nodeVersion:void 0,auggieInstalled:!1,binaryInstallAvailable:!1}}}async capabilities(e){try{const t=await u("system.capabilities",...e?[{workspaceId:e}]:[]);return!t||typeof t!="object"?{}:{cowSupported:typeof t.cowSupported=="boolean"?t.cowSupported:void 0}}catch{return{}}}async releaseNotes(){return null}async autoUpdate(){try{return{...await jr.getState(),toastVisible:!1,downloadedToastDismissedAt:null}}catch{return null}}subscribe(e){return this.status().then(t=>e(t)),()=>{}}}class Dr{constructor(e=!1){this.localMachine=e}async pairingInfo(){const e=await u("server.pairingInfo",void 0,this.localMachine?{localMachine:!0}:void 0);if(typeof e?.token!="string"||typeof e?.certFingerprint!="string"||typeof e?.path!="string"||!Array.isArray(e?.localIps)||typeof e?.hostname!="string")throw new Error("Invalid server.pairingInfo response shape");return{token:e.token,certFingerprint:e.certFingerprint,port:e.port??null,path:e.path,localIps:e.localIps,hostname:e.hostname,...typeof e.tcAddress=="string"&&e.tcAddress.length>0?{tcAddress:e.tcAddress}:{},...Array.isArray(e.availableIps)?{availableIps:e.availableIps}:{}}}async rotateToken(){const e=await u("server.rotateToken",void 0,this.localMachine?{localMachine:!0}:void 0);if(typeof e?.token!="string")throw new Error("Invalid server.rotateToken response shape");return{token:e.token}}}const sc=ze("LiveTasksClient");function Lt(n,e){if(!(!Array.isArray(e)||e.length===0)){if(!e.every(t=>typeof t=="string")){sc.warn(`discarding malformed ${n}: expected string[], got non-string member`,{value:e});return}return e}}function Ur(n){const e=Lt("dependsOn",n.dependsOn),t=Lt("conflictsWith",n.conflictsWith),r=Lt("unmetDependsOn",n.unmetDependsOn);return{...e?{dependsOn:e}:{},...t?{conflictsWith:t}:{},...r?{unmetDependsOn:r}:{}}}function qr(n){return typeof n.specLinked=="boolean"?{specLinked:n.specLinked}:{}}function Vt(n){const t=n.metadata?.task;return t?{id:String(n.id??""),title:String(n.title??""),status:typeof t.status=="string"?t.status:"not_started",updatedAt:typeof n.updatedAt=="string"?n.updatedAt:typeof n.updated_at=="string"?n.updated_at:void 0,...typeof n.rev=="number"?{rev:n.rev}:{},...Ur(t),...qr(t)}:null}function Pn(n){const e=Vt(n);return e||(typeof n.status!="string"?null:{id:String(n.id??""),title:String(n.title??""),status:n.status,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:typeof n.updated_at=="string"?n.updated_at:void 0,...typeof n.rev=="number"?{rev:n.rev}:{},...Ur(n),...qr(n)})}function oc(n){const e=Vt(n);return e||(typeof n.status=="string"?{id:String(n.id??""),title:String(n.title??""),status:n.status,...typeof n.updatedAt=="string"?{updatedAt:n.updatedAt}:{},...typeof n.rev=="number"?{rev:n.rev}:{}}:null)}const ic={total:0,completed:0,inProgress:0};function Nn(n){if(!n||typeof n!="object")return null;const e=n,t=e.noteId,r=e.taskKey,s=e.taskText,o=e.agentId,i=e.createdAt;return typeof t!="string"||typeof r!="string"||typeof s!="string"||typeof o!="string"||typeof i!="number"?null:{noteId:t,taskKey:r,taskText:s,agentId:o,createdAt:i}}function ac(n){if(!n||typeof n!="object")return{...ic};const e=n;return{total:typeof e.total=="number"?e.total:0,completed:typeof e.completed=="number"?e.completed:0,inProgress:typeof e.inProgress=="number"?e.inProgress:0}}class cc{async list(e){const t=await u("task.list",{workspaceId:e}),r=Array.isArray(t?.tasks)?t.tasks:[],s=[];for(const o of r){const i=Pn(o);i&&(i.id&&He(i.id,e),s.push(i))}return{tasks:s,stats:ac(t?.stats)}}async get(e){const t=await re(e);if(!t)return null;try{const r=await dr(o=>u("note.get",o),{workspaceId:t,noteId:e}),s=r&&typeof r=="object"&&"note"in r?r.note:r;return!s||typeof s!="object"?null:Vt(s)}catch{return null}}async updateStatus(e,t,r,s){return this.runTaskMutation(e,"task.updateStatus",{taskText:t,status:r},s)}async update(e,t,r,s){return this.runTaskMutation(e,"task.update",{line:t,...r.text!==void 0?{text:r.text}:{},...r.status!==void 0?{status:r.status}:{},...r.expected!==void 0?{expected:r.expected}:{}},s)}async updateNoteStatus(e,t,r){return this.runTaskMutation(e,"task.updateNoteStatus",{status:t},r)}async markAsTask(e,t,r,s){return this.runTaskMutation(e,"task.markAsTask",{status:t,...r?.acceptanceCriteria!==void 0?{acceptanceCriteria:r.acceptanceCriteria}:{},...r?.effort!==void 0?{effort:r.effort}:{},...r?.dependsOn!==void 0?{dependsOn:r.dependsOn}:{},...r?.conflictsWith!==void 0?{conflictsWith:r.conflictsWith}:{}},s)}async setRelations(e,t){return this.runTaskMutation(e,"task.setRelations",{...t.dependsOn!==void 0?{dependsOn:t.dependsOn}:{},...t.conflictsWith!==void 0?{conflictsWith:t.conflictsWith}:{}})}async assignAgent(e,t,r){return this.runTaskMutation(e,"task.assignAgent",{agentId:t},r)}async createPrerequisite(e,t,r){const s=await re(e);return s?jt("task.createPrerequisite",{workspaceId:s,dependentNoteId:e,title:t,...r?.content!==void 0?{content:r.content}:{},...r?.status!==void 0?{status:r.status}:{},idempotencyKey:Y()}):{success:!1,error:`Cannot resolve workspace for note ${e}`}}async listAgentLinks(e){const r=(await u("task.listAgentLinks",{workspaceId:e}))?.linksByNoteId;if(!r||typeof r!="object")return{};const s={};for(const[o,i]of Object.entries(r)){if(!i||typeof i!="object")continue;const a={};for(const[c,l]of Object.entries(i)){const d=Nn(l);d&&(a[c]=d)}Object.keys(a).length>0&&(s[o]=a)}return s}async linkAgent(e,t,r){const s=await u("task.linkAgent",{workspaceId:e,noteId:t,taskText:r.taskText,agentId:r.agentId,...r.taskKey!==void 0?{taskKey:r.taskKey}:{}}),o=Nn(s?.link);return o||{...r,noteId:t}}async unlinkAgent(e,t,r){return(await u("task.unlinkAgent",{workspaceId:e,noteId:t,taskKey:r}))?.removed===!0}async runTaskMutation(e,t,r,s){const o=await re(e);if(!o)return{success:!1,error:`Cannot resolve workspace for note ${e}`};const i=await jt(t,{workspaceId:o,noteId:e,...r,...s!==void 0?{expectedVersion:s}:{}}),a=i.conflict?.current;if(a&&typeof a=="object"){const c=oc(a);if(c)return{...i,conflict:{current:c}}}return i}subscribe(e){return Ye({channel:{subscribeMethod:"task.subscribe",unsubscribeMethod:"task.unsubscribe",dynamic:{subscribeIds:Wt,paramsForId:t=>({workspaceId:t})}},getId:t=>String(t.id??""),normalize:t=>{const r=Pn(t);return r?.id&&typeof t.workspaceId=="string"&&t.workspaceId&&He(r.id,t.workspaceId),r},handler:e})}}function uc(n){const e=new TextEncoder().encode(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Ln(n){if(typeof n!="string"||n.length===0)return"";try{const e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return new TextDecoder().decode(t)}catch{return""}}function lc(n,e){if(!n||typeof n!="object")return null;const t=n,r=String(t.terminalId??t.id??"");if(!r)return null;const s=typeof t.workspaceId=="string"?t.workspaceId:e;return{id:r,name:typeof t.name=="string"?t.name:"",workspaceId:s,createdAt:typeof t.createdAt=="string"?t.createdAt:void 0,isConnected:!0,...typeof t.isExecutingCommand=="boolean"?{isExecuting:t.isExecutingCommand}:{}}}function dc(n){if(!n||typeof n!="object")return null;const e=n;return e.event&&typeof e.event=="object"?e.event:typeof e.type=="string"?e:null}function fc(n){if(!n||typeof n!="object")return;const e=n.subscriptionId;return typeof e=="string"?e:void 0}class pc{async list(e){const t=await u("terminal.list",{workspaceId:e}),r=Array.isArray(t),s=r?t:Array.isArray(t?.terminals)?t.terminals:[],o=!r&&typeof t?.daemonBootId=="string"?t.daemonBootId:void 0,i=[];for(const a of s){const c=lc(a,e);c&&i.push(c)}return{terminals:i,...o!==void 0?{daemonBootId:o}:{}}}async create(e){try{const t=await u("terminal.create",{workspaceId:e.workspaceId,cols:e.cols,rows:e.rows,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.command!==void 0?{command:e.command}:{},...e.env!==void 0?{env:e.env}:{}}),r=typeof t?.terminalId=="string"?t.terminalId:void 0;return r?{success:!0,id:r}:{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async write(e,t,r){return b("terminal.write",{terminalId:e,data:uc(t),...r!==void 0?{workspaceId:r}:{}})}async resize(e,t,r,s){return b("terminal.resize",{terminalId:e,cols:t,rows:r,...s!==void 0?{workspaceId:s}:{}})}async kill(e,t){return b("terminal.kill",{terminalId:e,...t!==void 0?{workspaceId:t}:{}})}async getBuffer(e,t,r){try{const s=await u("terminal.getBuffer",{terminalId:e,...r!==void 0?{workspaceId:r}:{},...t!==void 0?{maxBytes:t}:{}});return Ln(s?.data)}catch{return""}}async output(e,t){try{const r=await u("terminal.readOutput",{workspaceId:e,terminalId:t});if(typeof r=="string")return r;const s=r?.output;return typeof s=="string"?s:""}catch{return""}}subscribeEvents(e,t,r){let s=!1,o=0,i;const a=se(d=>{if(d.method!=="events.event")return;const m=fc(d.params);if(i===void 0||m!==i)return;const I=dc(d.params);if(!I||typeof I.type!="string"||!I.type.startsWith("terminal:"))return;const w=I.data??{};if(w.terminalId===e)switch(I.type){case"terminal:data":t.onData?.({terminalId:e,chunk:Ln(w.chunk)});break;case"terminal:exit":t.onExit?.({terminalId:e,exitCode:typeof w.exitCode=="number"?w.exitCode:0});break;case"terminal:cwd":typeof w.cwd=="string"&&t.onCwd?.({terminalId:e,cwd:w.cwd});break;case"terminal:title":typeof w.title=="string"&&t.onTitle?.({terminalId:e,title:w.title});break}}),c=()=>{const d=++o;return $t({eventTypes:["terminal:data","terminal:exit","terminal:cwd","terminal:title"],...r!==void 0?{workspaceId:r}:{}}).then(m=>{const I=m?.subscriptionId;if(s||d!==o){I&&Ne(I,r);return}i=I}).catch(()=>{})};c();const l=oe(()=>{i=void 0,c()});return()=>{s=!0,a(),l(),i&&Ne(i,r)}}subscribe(e){return e([]),()=>{}}}function gc(n=_s){return{async begin(e,t,r){const s=Os.parse(e),o=Ms.parse(t);if(Q(s.root)!==Q(o.review.root))throw new Error("NATIVE_REVIEW_UNAVAILABLE");const i=await n(o);if(Q(i.preview.root)!==Q(s.root))throw await i.release(),new Error("NATIVE_REVIEW_UNAVAILABLE");let a;try{a=i.onRetired(r)}catch(d){throw await i.release(),d}let c=!1,l;return{...o.review.companion&&i.prepareCompanion?{prepareCompanion(){return l||(l=Promise.resolve().then(async()=>{if(c)throw new Error("NATIVE_REVIEW_UNAVAILABLE");const d=await i.prepareCompanion();if(c||Q(d.preview.root)!==Q(s.root))throw await d.release(),new Error("NATIVE_REVIEW_UNAVAILABLE");return d}),l)}}:{},preview:i.preview,onRetired:i.onRetired,confirm:i.confirm,reconcile:i.reconcile,async release(){c||(c=!0,a(),l?.then(d=>d.release(),()=>{}),await i.release())}}}}}const yc=Ke({root:Ps,editId:Se().min(1),admission:Se().nullable()}).strict();function mc(n=Ns){return{async begin(e,t){const r=yc.parse(e),s=await n(r.root);if(Q(s.preview.root)!==Q(r.root))throw await s.release(),new Error("REPOSITORY_SELECTION_UNAVAILABLE");const o=s.onRetired(t);let i=!1;return{preview:s.preview,onRetired:s.onRetired,confirm:s.confirm,reconcile:s.reconcile,async release(){i||(i=!0,o(),await s.release())}}}}}function hc(n=Ls){return{async observe(e,t){const r=Object.freeze({...e});let s=!0,o,i;const a=()=>{s&&(s=!1,i?.(),o?.release())},c=()=>{if(s)try{t({type:"unavailable",request:r})}finally{a()}};return(async()=>{if(o=await n(r.gitRootId===void 0?{workspaceId:r.workspaceId,kind:"primary"}:{workspaceId:r.workspaceId,kind:"registered",gitRootId:r.gitRootId}),!s){await o.release();return}if(i=o.onRetired(()=>{if(s)try{t({type:"retired",request:r})}finally{a()}}),!s){i();return}const l=await o.request("workspace.repositoryContext",{workspaceId:r.workspaceId,...r.gitRootId===void 0?{}:{gitRootId:r.gitRootId}});if(!s)return;if(!l.current){try{t({type:"retired",request:r})}finally{a()}return}if(l.settlement.status!=="fulfilled"){c();return}const d=Fs.parse(l.settlement.value);if(!$s(d,r)){c();return}t({type:"received",response:{request:r,context:d}})})().catch(c),a}}}const vc=Ke({amount:X().finite(),currency:Se().min(1)}).passthrough(),it=Ke({inputTokens:X().int().nonnegative(),outputTokens:X().int().nonnegative(),cacheReadTokens:X().int().nonnegative(),cacheCreationTokens:X().int().nonnegative(),thoughtTokens:X().int().nonnegative().optional(),cost:vc.optional()}).passthrough(),bc=Ke({agentId:Se().min(1),model:Se().min(1),totals:it,humanMessages:X().int().nonnegative(),agentMessages:X().int().nonnegative()}).passthrough(),xn=new TextEncoder;function Bn(n,e){const t=xn.encode(n),r=xn.encode(e);for(let s=0;s<Math.min(t.length,r.length);s++)if(t[s]!==r[s])return t[s]-r[s];return t.length-r.length}const Sc=Hs(bc).superRefine((n,e)=>{for(const[t,r]of n.entries()){const s=n[t-1];s!==void 0&&(Bn(r.agentId,s.agentId)||Bn(r.model,s.model))<=0&&e.addIssue({code:Ws.custom,message:"byAgentModel rows must be unique and sorted by agentId, then model",path:[t]})}}),Fr=Ke({byAgentId:At(it),totals:it,byModel:At(it),byAgentModel:Sc.optional(),agentNames:At(Se()).optional(),lastScanAt:Se().datetime({offset:!0}).nullable()}).passthrough();function Ic(n){return Fr.parse(n)}function Qu(n){const e=Fr.safeParse(n);return e.success?e.data:null}const kc=12e4,Ac=12e4;function Tc(n){switch(String(n).toLowerCase()){case"inactive":return je.Inactive;case"archived":return je.Archived;case"retired":return je.Retired;case"deleted":return je.Deleted;default:return je.Active}}function Te(n){const e=new Date().toISOString(),t=String(n.id??n.workspaceId??""),{defaultAgentPlacement:r,...s}=n;return{...s,...r===void 0?{}:{defaultAgentPlacement:Ds.parse(r)},id:er(t),title:String(n.title??n.name??t),branch:String(n.branch??""),status:Tc(n.status),changesets:Array.isArray(n.changesets)?n.changesets:[],timeline:Array.isArray(n.timeline)?n.timeline:[],conversationInfo:Array.isArray(n.conversationInfo)?n.conversationInfo:[],createdAt:String(n.createdAt??e),updatedAt:String(n.updatedAt??e)}}function jn(n){if(!n||typeof n!="object")return;const e=n.data;if(!e||typeof e!="object")return;const t=e.code;return typeof t=="string"&&t.length>0?t:void 0}function wc(n){if(!n||typeof n!="object")return;const e=n.data;if(!e||typeof e!="object")return;const t=e;if(t.code!=="launch-failed"||typeof t.workspaceId!="string"||t.workspaceId.length===0)return;const r=t.launch?.agentId,s=t.cause?.message;return{workspaceId:t.workspaceId,...typeof r=="string"&&r.length>0?{agentId:r}:{},...typeof s=="string"&&s.length>0?{cause:s}:{}}}function Dn(n){if(!n||typeof n!="object")return!1;const e=n;return typeof e.id=="string"&&e.id.length>0&&typeof e.type=="string"&&e.type.length>0}function Un(n,e){if(!li(n))throw new Error(`Invalid ${e} response shape`);return n}function Ec(n){if(n===null||typeof n!="object")return!1;const e=n;return typeof e.id=="string"&&e.id.length>0&&typeof e.title=="string"&&typeof e.archived=="boolean"&&typeof e.linkedAt=="string"}const Cc=["applied","dismissed","notResolved"];function Rc(n){if(!n||typeof n!="object")return;const{proposalId:e,outcome:t}=n;if(!(typeof e!="string"||typeof t!="string")&&Cc.includes(t))return{proposalId:e,outcome:t}}class _c{constructor(){y(this,"listRequests",new Map);y(this,"getRequests",new Map)}beginNativeReview(e,t,r){return gc().begin(e,t,r)}beginRepositorySelectionEdit(e,t){return mc().begin(e,t)}observeRepositoryContext(e,t){return hc().observe(e,t)}list(e){const t=e?.includeArchived===!0,r=e?.includeRetired===!0,s=`${t}:${r}`,o=r?void 0:this.listRequests.get(s);if(o)return o;const i={...t?{includeArchived:!0}:{},...r?{includeRetired:!0}:{}},a=at(l=>u("workspace.list",l),i,"workspaces").then(l=>(Array.isArray(l?.workspaces)?l.workspaces:[]).map(m=>Te(m)));if(r)return a;this.listRequests.set(s,a);const c=()=>{this.listRequests.get(s)===a&&this.listRequests.delete(s)};return a.then(c,c),a}get(e){const t=this.getRequests.get(e);if(t)return t;const r=u("workspace.get",{workspaceId:e}).then(o=>{const i=o&&typeof o=="object"&&"workspace"in o?o.workspace:o;return!i||typeof i!="object"?null:Te(i)});this.getRequests.set(e,r);const s=()=>{this.getRequests.get(e)===r&&this.getRequests.delete(e)};return r.then(s,s),r}async open(e){return this.get(e)}async create(e){try{const t=await u("workspace.create",{...e,idempotencyKey:e.idempotencyKey??Y()},{timeoutMs:Ac}),r=t?.workspace,s=t?.initialAgent,o=Rc(t?.proposalOrigin);let i;if(s!=null){if(typeof s!="object"||typeof s.id!="string"||s.id.length===0)return{success:!1,error:"workspace.create returned an initialAgent without a valid daemon-assigned id"};i=s}return r&&typeof r=="object"?{success:!0,workspace:Te(r),...i?{initialAgent:i}:{},...o?{proposalOrigin:o}:{}}:{success:!0}}catch(t){const r=t instanceof Error?t.message:String(t),s=ct(t);if(s)return{success:!1,error:r,conflict:s};const o=jn(t),i=wc(t);return o?{success:!1,error:r,errorCode:o,...i?{launchFailure:i}:{}}:{success:!1,error:r}}}async update(e){const{id:t,...r}=e;try{const o=(await u("workspace.update",{workspaceId:t,...r}))?.workspace;return o&&typeof o=="object"?{success:!0,workspace:Te(o)}:{success:!0}}catch(s){const o=s instanceof Error?s.message:String(s),i=ct(s);return i?{success:!1,error:o,conflict:i}:{success:!1,error:o}}}async delete(e,t){const r=t?.undoDelayMs;try{const s=await u("workspace.delete",r&&r>0?{workspaceId:e,undoDelayMs:r}:{workspaceId:e},{timeoutMs:kc}),o=s?.scheduled===!0,i=typeof s?.deleteAt=="string"?s.deleteAt:void 0;return o&&i?{success:!0,scheduled:!0,deleteAt:i}:{success:!0}}catch(s){return{success:!1,error:_(s)}}}async findByPullRequest(e){const r=(await u("workspace.findByPullRequest",{url:e}))?.workspaces;if(!Array.isArray(r)||!r.every(Ec))throw new Error("Invalid workspace.findByPullRequest response shape");return r}async cancelDelete(e){try{return{success:!0,cancelled:(await u("workspace.cancelDelete",{workspaceId:e}))?.cancelled===!0}}catch(t){return{success:!1,error:_(t)}}}async archive(e){return b("workspace.archive",{workspaceId:e})}async unarchive(e){return b("workspace.unarchive",{workspaceId:e})}async retire(e){try{const r=(await u("workspace.retire",{workspaceId:e}))?.workspace;return{success:!0,...r&&typeof r=="object"?{workspace:Te(r)}:{}}}catch(t){const r=jn(t);return{success:!1,error:_(t),...r?{errorCode:r}:{}}}}async markSeen(e){return b("workspace.markSeen",{workspaceId:e})}async setActive(e){return b("workspace.setActive",{workspaceId:e})}async recentViews(){return{}}async getTokenUsage(e){const r=(await u("workspace.getTokenUsage",{workspaceId:e}))?.tokenUsage;return r&&typeof r=="object"?Ic(r):null}async diskUsage(e){try{const t=await u("workspace.diskUsage",{workspaceId:e}),r=t?.diskUsage,s={refreshing:t?.refreshing===!0};return r&&typeof r=="object"&&(s.diskUsage=r),s}catch(t){if(t instanceof tr&&(t.rpcCode===-32601||t.code==="METHOD_NOT_FOUND"))return null;throw t}}async getContext(e){const t=await u("workspace.getContext",{workspaceId:e});return(Array.isArray(t?.items)?t.items:[]).filter(Dn)}async updateContext(e,t){const r=await u("workspace.updateContext",{workspaceId:e,items:t});return(Array.isArray(r?.items)?r.items:[]).filter(Dn)}async getBrowserClient(e){const t=await u("workspace.getBrowserClient",{workspaceId:e});return Un(t?.browserClient,"workspace.getBrowserClient")}async setBrowserClient(e,t){const r=await u("workspace.setBrowserClient",{workspaceId:e,clientId:t});return Un(r?.browserClient,"workspace.setBrowserClient")}subscribe(e){return Ye({channel:{subscribeMethod:"workspace.subscribe",unsubscribeMethod:"workspace.unsubscribe",continuation:{method:"workspace.list",key:"workspaces",params:t=>({includeArchived:!0,...t.includeRetired===!0?{includeRetired:!0}:{}})}},getId:t=>String(t.id??t.workspaceId??""),normalize:t=>Te(t),handler:e})}}class $r{constructor(){y(this,"workspaces",new _c);y(this,"agents",new oi);y(this,"notes",new Ea);y(this,"tasks",new cc);y(this,"comments",new qi);y(this,"git",new fa);y(this,"files",new ta);y(this,"terminals",new pc);y(this,"settings",new Fa);y(this,"specialists",new Ja);y(this,"integrations",new ya);y(this,"scripts",new _a);y(this,"setupScripts",new Ha);y(this,"events",new Hi);y(this,"models",new Sa);y(this,"providers",new Ca);y(this,"stats",new Za);y(this,"voice",new tc);y(this,"chat",new Ni);y(this,"skills",new Va);y(this,"browser",new pi);y(this,"system",new rc);y(this,"server",new Dr);y(this,"drafts",new Fi);y(this,"clients",new Li)}}const tt={FileChanged:"file:changed",AgentIdle:"agent:idle",NoteUpdated:"note:updated",TaskStatusChanged:"task:status-changed"},dt="2026-01-01T00:00:00.000Z",M=er("ws-mock-1"),Oc=As("00000000-0000-4000-8000-000000000010"),Hr=`terminal-${M}-default`,Wr=`terminal-${M}-2`,qn=[{id:Hr,name:"Terminal",type:"terminal",workspaceId:String(M),createdAt:dt},{id:Wr,name:"Terminal 2",type:"terminal",workspaceId:String(M),createdAt:dt}],Fn={[Hr]:`$ pnpm run dev\r
|
|
2
2
|
\x1B[32m➜\x1B[0m Local: http://localhost:5173/\r
|
|
3
3
|
$ `,[Wr]:`$ git status\r
|
|
4
4
|
On branch feat/dark-mode-toggle\r
|