junhost 0.1.1 → 0.2.0

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.
Files changed (93) hide show
  1. package/README.md +43 -1
  2. package/dist/browser-mcp-server.js +42 -0
  3. package/dist/index.js +52 -52
  4. package/dist/mcp-server.js +1 -1
  5. package/package.json +2 -2
  6. package/ui-dist/assets/{BrowserPage-CLwJOnA1.js → BrowserPage-Bw1kBIM_.js} +1 -1
  7. package/ui-dist/assets/{DashboardPage-DNlY12tH.js → DashboardPage-BvNlgB4B.js} +1 -1
  8. package/ui-dist/assets/{FilesPage-CfFJjtlo.js → FilesPage-C1IqnxpR.js} +1 -1
  9. package/ui-dist/assets/{McpPage-Ckmbp2T3.js → McpPage-BgXcKazm.js} +1 -1
  10. package/ui-dist/assets/{MemoriesPage-BgBe2rb6.js → MemoriesPage-DYOob4W0.js} +1 -1
  11. package/ui-dist/assets/{RunsPage-9w7iFG8N.js → RunsPage-BpBj82Ux.js} +4 -4
  12. package/ui-dist/assets/{SchedulesPage-B5FVZB0F.js → SchedulesPage-mIWaXymg.js} +1 -1
  13. package/ui-dist/assets/{SettingsPage-lNZmrgQF.js → SettingsPage-C5vG-RLn.js} +1 -1
  14. package/ui-dist/assets/{SkillsPage-BXcSp6ls.js → SkillsPage-DuFQfdSR.js} +1 -1
  15. package/ui-dist/assets/architecture-7EHR7CIX-BMNBOS2i.js +1 -0
  16. package/ui-dist/assets/{architectureDiagram-3BPJPVTR-CZU-I50b.js → architectureDiagram-3BPJPVTR-CQ1UyWn-.js} +1 -1
  17. package/ui-dist/assets/{blockDiagram-GPEHLZMM-CyBud8P5.js → blockDiagram-GPEHLZMM-DO2WH3yT.js} +1 -1
  18. package/ui-dist/assets/{c4Diagram-AAUBKEIU--J4ICgL4.js → c4Diagram-AAUBKEIU-CDcDkAFN.js} +1 -1
  19. package/ui-dist/assets/channel-BMSobhoT.js +1 -0
  20. package/ui-dist/assets/{checkbox-Dl42vHZu.js → checkbox-BO9cBKlP.js} +1 -1
  21. package/ui-dist/assets/{chunk-2J33WTMH-BDb1cFmy.js → chunk-2J33WTMH-CxE9IMxF.js} +1 -1
  22. package/ui-dist/assets/{chunk-3OPIFGDE-BlluxIcQ.js → chunk-3OPIFGDE-CWe0ghtO.js} +1 -1
  23. package/ui-dist/assets/{chunk-5ZQYHXKU-CKTcuPiD.js → chunk-5ZQYHXKU-D9lXR7-a.js} +1 -1
  24. package/ui-dist/assets/{chunk-727SXJPM-MZn2xvWx.js → chunk-727SXJPM-1INZms_u.js} +1 -1
  25. package/ui-dist/assets/{chunk-AQP2D5EJ-BJaTZvWO.js → chunk-AQP2D5EJ-Bo5P94jR.js} +1 -1
  26. package/ui-dist/assets/{chunk-BO2N2NFS-BnH2G-m5.js → chunk-BO2N2NFS-Bb9QKS7r.js} +4 -4
  27. package/ui-dist/assets/{chunk-CSCIHK7Q-CXkHF5UK.js → chunk-CSCIHK7Q-BXW0kTPy.js} +3 -3
  28. package/ui-dist/assets/{chunk-KSCS5N6A-BahjoFv5.js → chunk-KSCS5N6A-su0hRnFY.js} +1 -1
  29. package/ui-dist/assets/{chunk-L5ZTLDWV-Bx4WHt-z.js → chunk-L5ZTLDWV-CLjULdtO.js} +1 -1
  30. package/ui-dist/assets/{chunk-LZXEDZCA-CkFznL5l.js → chunk-LZXEDZCA-DSupe1kd.js} +2 -2
  31. package/ui-dist/assets/{chunk-ND2GUHAM-B8gmrqM9.js → chunk-ND2GUHAM-DVaKW6-I.js} +1 -1
  32. package/ui-dist/assets/{chunk-NZK2D7GU-C18DTyig.js → chunk-NZK2D7GU-DP_luiUT.js} +1 -1
  33. package/ui-dist/assets/{chunk-O5CBEL6O-DhXgjXO_.js → chunk-O5CBEL6O-DJ6oobwT.js} +1 -1
  34. package/ui-dist/assets/{chunk-WU5MYG2G-DakMffny.js → chunk-WU5MYG2G-BJCNi6Df.js} +1 -1
  35. package/ui-dist/assets/classDiagram-4FO5ZUOK-C8buBHXm.js +1 -0
  36. package/ui-dist/assets/classDiagram-v2-Q7XG4LA2-C8buBHXm.js +1 -0
  37. package/ui-dist/assets/{collapsible-BdLJt-lG.js → collapsible-0tqcZUWD.js} +1 -1
  38. package/ui-dist/assets/{dagre-BM42HDAG-CRPnH9-w.js → dagre-BM42HDAG-CRyL8hRI.js} +1 -1
  39. package/ui-dist/assets/{diagram-2AECGRRQ-BHmnvDJu.js → diagram-2AECGRRQ-DyjpW-BD.js} +1 -1
  40. package/ui-dist/assets/{diagram-5GNKFQAL-CnuSOf5i.js → diagram-5GNKFQAL-CBTUCxgf.js} +1 -1
  41. package/ui-dist/assets/{diagram-KO2AKTUF-DkD3Oyzq.js → diagram-KO2AKTUF-C7inOR0g.js} +1 -1
  42. package/ui-dist/assets/{diagram-LMA3HP47-qngr_ayi.js → diagram-LMA3HP47-CfCMRg_H.js} +1 -1
  43. package/ui-dist/assets/{diagram-OG6HWLK6-BUXAAFlB.js → diagram-OG6HWLK6-DLl3GKVl.js} +1 -1
  44. package/ui-dist/assets/{dialog-Bl8-9u35.js → dialog-gLEpdaG1.js} +1 -1
  45. package/ui-dist/assets/{erDiagram-TEJ5UH35-B7fmkd3a.js → erDiagram-TEJ5UH35-D3SsdlGo.js} +1 -1
  46. package/ui-dist/assets/eventmodeling-FCH6USID-Dl7jZkr1.js +1 -0
  47. package/ui-dist/assets/{flowDiagram-I6XJVG4X-D3K28Pdy.js → flowDiagram-I6XJVG4X-BIZoa3Ff.js} +1 -1
  48. package/ui-dist/assets/{ganttDiagram-6RSMTGT7-CXzmskXJ.js → ganttDiagram-6RSMTGT7-DoIzzrgl.js} +1 -1
  49. package/ui-dist/assets/{gitGraph-WXDBUCRP-CROsiysY.js → gitGraph-WXDBUCRP-tT7WczwY.js} +1 -1
  50. package/ui-dist/assets/{gitGraphDiagram-PVQCEYII-BBhICl9b.js → gitGraphDiagram-PVQCEYII-CwoMoyS1.js} +1 -1
  51. package/ui-dist/assets/{highlighted-body-OFNGDK62-woHDdMrg.js → highlighted-body-OFNGDK62-X8dg_vaO.js} +1 -1
  52. package/ui-dist/assets/{index-DmmH6oax.css → index-C_NJsn6Z.css} +1 -1
  53. package/ui-dist/assets/{index-j386AZTn.js → index-DXYsuK0q.js} +2 -2
  54. package/ui-dist/assets/{info-J43DQDTF-DHht6dOt.js → info-J43DQDTF-Da0djCPL.js} +1 -1
  55. package/ui-dist/assets/{infoDiagram-5YYISTIA-Df4LhnuE.js → infoDiagram-5YYISTIA-D-OHDMDH.js} +1 -1
  56. package/ui-dist/assets/{input-D4O22yGt.js → input-BPTmfk5i.js} +1 -1
  57. package/ui-dist/assets/{ishikawaDiagram-YF4QCWOH-B8KMc0In.js → ishikawaDiagram-YF4QCWOH-Bzg0E0Z1.js} +1 -1
  58. package/ui-dist/assets/{journeyDiagram-JHISSGLW-Bpr7eOEv.js → journeyDiagram-JHISSGLW-rmeE-f4I.js} +1 -1
  59. package/ui-dist/assets/{kanban-definition-UN3LZRKU-R8MXwX2D.js → kanban-definition-UN3LZRKU-DSy_xosI.js} +1 -1
  60. package/ui-dist/assets/katex-BNbsei-7.js +1 -0
  61. package/ui-dist/assets/{line-EyXPCaOi.js → line-6Sq5fd7W.js} +1 -1
  62. package/ui-dist/assets/mermaid-GHXKKRXX-eP_ygZe4.js +1 -0
  63. package/ui-dist/assets/{mermaid-parser.core-Bd2TX3li.js → mermaid-parser.core-C6nlL4jI.js} +2 -2
  64. package/ui-dist/assets/{mindmap-definition-RKZ34NQL-CCrZYYSm.js → mindmap-definition-RKZ34NQL-CSJ0pwqG.js} +1 -1
  65. package/ui-dist/assets/{packet-YPE3B663-BsRm1dxS.js → packet-YPE3B663-CJYSZVBB.js} +1 -1
  66. package/ui-dist/assets/{pie-LRSECV5Y-2jRO4jrF.js → pie-LRSECV5Y-B7FDQxHq.js} +1 -1
  67. package/ui-dist/assets/{pieDiagram-4H26LBE5-O21uLYd7.js → pieDiagram-4H26LBE5-BYco3Xpn.js} +1 -1
  68. package/ui-dist/assets/{quadrantDiagram-W4KKPZXB-PFuRo2tu.js → quadrantDiagram-W4KKPZXB-BSzj1BbK.js} +1 -1
  69. package/ui-dist/assets/{radar-GUYGQ44K-DrLd9hhi.js → radar-GUYGQ44K-CIqNKREz.js} +1 -1
  70. package/ui-dist/assets/{requirementDiagram-4Y6WPE33-CsP61d0X.js → requirementDiagram-4Y6WPE33-DTMmHobs.js} +1 -1
  71. package/ui-dist/assets/{sankeyDiagram-5OEKKPKP-OXRKlXwh.js → sankeyDiagram-5OEKKPKP-v48Pd1Sj.js} +1 -1
  72. package/ui-dist/assets/{select-CYgMxtlk.js → select-jBmyVjXL.js} +1 -1
  73. package/ui-dist/assets/{sequenceDiagram-3UESZ5HK-CGKNazDP.js → sequenceDiagram-3UESZ5HK-Cutc-QJ-.js} +1 -1
  74. package/ui-dist/assets/{stateDiagram-AJRCARHV-BBiaMVYA.js → stateDiagram-AJRCARHV-C9wjw5vE.js} +1 -1
  75. package/ui-dist/assets/stateDiagram-v2-BHNVJYJU-0qv-iPvr.js +1 -0
  76. package/ui-dist/assets/{tabs-DS9zR4V0.js → tabs-BUCI-mwA.js} +1 -1
  77. package/ui-dist/assets/{timeline-definition-PNZ67QCA-DCONMP8y.js → timeline-definition-PNZ67QCA-Be0sJR3F.js} +1 -1
  78. package/ui-dist/assets/{treeView-BLDUP644-DLNyeiHu.js → treeView-BLDUP644-BuO1c41a.js} +1 -1
  79. package/ui-dist/assets/{treemap-LRROVOQU-Cdld0366.js → treemap-LRROVOQU-DnqRpBrL.js} +1 -1
  80. package/ui-dist/assets/{useCompositeListItem-BQ4RLkNZ.js → useCompositeListItem-BMeUcGkY.js} +1 -1
  81. package/ui-dist/assets/{vennDiagram-CIIHVFJN-C21GUpuw.js → vennDiagram-CIIHVFJN-BU-tyhcP.js} +1 -1
  82. package/ui-dist/assets/{wardley-L42UT6IY-PuTi7B-8.js → wardley-L42UT6IY-C4lBe1D1.js} +1 -1
  83. package/ui-dist/assets/{wardleyDiagram-YWT4CUSO-BwV-yZO0.js → wardleyDiagram-YWT4CUSO-Ba4GgkxA.js} +1 -1
  84. package/ui-dist/assets/{xychartDiagram-2RQKCTM6-D-bOqUpK.js → xychartDiagram-2RQKCTM6-BZYGoMGR.js} +1 -1
  85. package/ui-dist/index.html +2 -2
  86. package/ui-dist/assets/architecture-7EHR7CIX-D8QwdCM4.js +0 -1
  87. package/ui-dist/assets/channel-CXOCC3Ms.js +0 -1
  88. package/ui-dist/assets/classDiagram-4FO5ZUOK-DMdoabn-.js +0 -1
  89. package/ui-dist/assets/classDiagram-v2-Q7XG4LA2-DMdoabn-.js +0 -1
  90. package/ui-dist/assets/eventmodeling-FCH6USID-DUPVuqbK.js +0 -1
  91. package/ui-dist/assets/katex-U6Climy7.js +0 -1
  92. package/ui-dist/assets/mermaid-GHXKKRXX-CDSYqrX3.js +0 -1
  93. package/ui-dist/assets/stateDiagram-v2-BHNVJYJU-C_bLdSQ9.js +0 -1
@@ -39,4 +39,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
39
39
  `:`[${Y[B]}\r
40
40
  ]`;continue}if($+=Y[B],Y[B]==="\\")J=!0;else if(G&&Y[B]==="]")G=!1;else if(!G&&Y[B]==="[")G=!0}try{new RegExp($)}catch{return console.warn(`Could not convert regex pattern at ${X.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),Q.source}return $}function u9(Q,X){if(X.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(X.target==="openApi3"&&Q.keyType?._def.typeName===M.ZodEnum)return{type:"object",required:Q.keyType._def.values,properties:Q.keyType._def.values.reduce((Y,$)=>({...Y,[$]:g(Q.valueType._def,{...X,currentPath:[...X.currentPath,"properties",$]})??B0(X)}),{}),additionalProperties:X.rejectedAdditionalProperties};let W={type:"object",additionalProperties:g(Q.valueType._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]})??X.allowedAdditionalProperties};if(X.target==="openApi3")return W;if(Q.keyType?._def.typeName===M.ZodString&&Q.keyType._def.checks?.length){let{type:Y,...$}=f9(Q.keyType._def,X);return{...W,propertyNames:$}}else if(Q.keyType?._def.typeName===M.ZodEnum)return{...W,propertyNames:{enum:Q.keyType._def.values}};else if(Q.keyType?._def.typeName===M.ZodBranded&&Q.keyType._def.type._def.typeName===M.ZodString&&Q.keyType._def.type._def.checks?.length){let{type:Y,...$}=h9(Q.keyType._def,X);return{...W,propertyNames:$}}return W}function $J(Q,X){if(X.mapStrategy==="record")return u9(Q,X);let W=g(Q.keyType._def,{...X,currentPath:[...X.currentPath,"items","items","0"]})||B0(X),Y=g(Q.valueType._def,{...X,currentPath:[...X.currentPath,"items","items","1"]})||B0(X);return{type:"array",maxItems:125,items:{type:"array",items:[W,Y],minItems:2,maxItems:2}}}function JJ(Q){let X=Q.values,Y=Object.keys(Q.values).filter((J)=>{return typeof X[X[J]]!=="number"}).map((J)=>X[J]),$=Array.from(new Set(Y.map((J)=>typeof J)));return{type:$.length===1?$[0]==="string"?"string":"number":["string","number"],enum:Y}}function GJ(Q){return Q.target==="openAi"?void 0:{not:B0({...Q,currentPath:[...Q.currentPath,"not"]})}}function HJ(Q){return Q.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var N4={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function zJ(Q,X){if(X.target==="openApi3")return BJ(Q,X);let W=Q.options instanceof Map?Array.from(Q.options.values()):Q.options;if(W.every((Y)=>(Y._def.typeName in N4)&&(!Y._def.checks||!Y._def.checks.length))){let Y=W.reduce(($,J)=>{let G=N4[J._def.typeName];return G&&!$.includes(G)?[...$,G]:$},[]);return{type:Y.length>1?Y:Y[0]}}else if(W.every((Y)=>Y._def.typeName==="ZodLiteral"&&!Y.description)){let Y=W.reduce(($,J)=>{let G=typeof J._def.value;switch(G){case"string":case"number":case"boolean":return[...$,G];case"bigint":return[...$,"integer"];case"object":if(J._def.value===null)return[...$,"null"];case"symbol":case"undefined":case"function":default:return $}},[]);if(Y.length===W.length){let $=Y.filter((J,G,H)=>H.indexOf(J)===G);return{type:$.length>1?$:$[0],enum:W.reduce((J,G)=>{return J.includes(G._def.value)?J:[...J,G._def.value]},[])}}}else if(W.every((Y)=>Y._def.typeName==="ZodEnum"))return{type:"string",enum:W.reduce((Y,$)=>[...Y,...$._def.values.filter((J)=>!Y.includes(J))],[])};return BJ(Q,X)}var BJ=(Q,X)=>{let W=(Q.options instanceof Map?Array.from(Q.options.values()):Q.options).map((Y,$)=>g(Y._def,{...X,currentPath:[...X.currentPath,"anyOf",`${$}`]})).filter((Y)=>!!Y&&(!X.strictUnions||typeof Y==="object"&&Object.keys(Y).length>0));return W.length?{anyOf:W}:void 0};function AJ(Q,X){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(Q.innerType._def.typeName)&&(!Q.innerType._def.checks||!Q.innerType._def.checks.length)){if(X.target==="openApi3")return{type:N4[Q.innerType._def.typeName],nullable:!0};return{type:[N4[Q.innerType._def.typeName],"null"]}}if(X.target==="openApi3"){let Y=g(Q.innerType._def,{...X,currentPath:[...X.currentPath]});if(Y&&"$ref"in Y)return{allOf:[Y],nullable:!0};return Y&&{...Y,nullable:!0}}let W=g(Q.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","0"]});return W&&{anyOf:[W,{type:"null"}]}}function KJ(Q,X){let W={type:"number"};if(!Q.checks)return W;for(let Y of Q.checks)switch(Y.kind){case"int":W.type="integer",WW(W,"type",Y.message,X);break;case"min":if(X.target==="jsonSchema7")if(Y.inclusive)n(W,"minimum",Y.value,Y.message,X);else n(W,"exclusiveMinimum",Y.value,Y.message,X);else{if(!Y.inclusive)W.exclusiveMinimum=!0;n(W,"minimum",Y.value,Y.message,X)}break;case"max":if(X.target==="jsonSchema7")if(Y.inclusive)n(W,"maximum",Y.value,Y.message,X);else n(W,"exclusiveMaximum",Y.value,Y.message,X);else{if(!Y.inclusive)W.exclusiveMaximum=!0;n(W,"maximum",Y.value,Y.message,X)}break;case"multipleOf":n(W,"multipleOf",Y.value,Y.message,X);break}return W}function LJ(Q,X){let W=X.target==="openAi",Y={type:"object",properties:{}},$=[],J=Q.shape();for(let H in J){let B=J[H];if(B===void 0||B._def===void 0)continue;let z=ED(B);if(z&&W){if(B._def.typeName==="ZodOptional")B=B._def.innerType;if(!B.isNullable())B=B.nullable();z=!1}let A=g(B._def,{...X,currentPath:[...X.currentPath,"properties",H],propertyPath:[...X.currentPath,"properties",H]});if(A===void 0)continue;if(Y.properties[H]=A,!z)$.push(H)}if($.length)Y.required=$;let G=jD(Q,X);if(G!==void 0)Y.additionalProperties=G;return Y}function jD(Q,X){if(Q.catchall._def.typeName!=="ZodNever")return g(Q.catchall._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]});switch(Q.unknownKeys){case"passthrough":return X.allowedAdditionalProperties;case"strict":return X.rejectedAdditionalProperties;case"strip":return X.removeAdditionalStrategy==="strict"?X.allowedAdditionalProperties:X.rejectedAdditionalProperties}}function ED(Q){try{return Q.isOptional()}catch{return!0}}var DJ=(Q,X)=>{if(X.currentPath.toString()===X.propertyPath?.toString())return g(Q.innerType._def,X);let W=g(Q.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","1"]});return W?{anyOf:[{not:B0(X)},W]}:B0(X)};var qJ=(Q,X)=>{if(X.pipeStrategy==="input")return g(Q.in._def,X);else if(X.pipeStrategy==="output")return g(Q.out._def,X);let W=g(Q.in._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),Y=g(Q.out._def,{...X,currentPath:[...X.currentPath,"allOf",W?"1":"0"]});return{allOf:[W,Y].filter(($)=>$!==void 0)}};function VJ(Q,X){return g(Q.type._def,X)}function FJ(Q,X){let Y={type:"array",uniqueItems:!0,items:g(Q.valueType._def,{...X,currentPath:[...X.currentPath,"items"]})};if(Q.minSize)n(Y,"minItems",Q.minSize.value,Q.minSize.message,X);if(Q.maxSize)n(Y,"maxItems",Q.maxSize.value,Q.maxSize.message,X);return Y}function UJ(Q,X){if(Q.rest)return{type:"array",minItems:Q.items.length,items:Q.items.map((W,Y)=>g(W._def,{...X,currentPath:[...X.currentPath,"items",`${Y}`]})).reduce((W,Y)=>Y===void 0?W:[...W,Y],[]),additionalItems:g(Q.rest._def,{...X,currentPath:[...X.currentPath,"additionalItems"]})};else return{type:"array",minItems:Q.items.length,maxItems:Q.items.length,items:Q.items.map((W,Y)=>g(W._def,{...X,currentPath:[...X.currentPath,"items",`${Y}`]})).reduce((W,Y)=>Y===void 0?W:[...W,Y],[])}}function OJ(Q){return{not:B0(Q)}}function NJ(Q){return B0(Q)}var wJ=(Q,X)=>{return g(Q.innerType._def,X)};var MJ=(Q,X,W)=>{switch(X){case M.ZodString:return f9(Q,W);case M.ZodNumber:return KJ(Q,W);case M.ZodObject:return LJ(Q,W);case M.ZodBigInt:return r7(Q,W);case M.ZodBoolean:return t7();case M.ZodDate:return YW(Q,W);case M.ZodUndefined:return OJ(W);case M.ZodNull:return HJ(W);case M.ZodArray:return o7(Q,W);case M.ZodUnion:case M.ZodDiscriminatedUnion:return zJ(Q,W);case M.ZodIntersection:return XJ(Q,W);case M.ZodTuple:return UJ(Q,W);case M.ZodRecord:return u9(Q,W);case M.ZodLiteral:return WJ(Q,W);case M.ZodEnum:return QJ(Q);case M.ZodNativeEnum:return JJ(Q);case M.ZodNullable:return AJ(Q,W);case M.ZodOptional:return DJ(Q,W);case M.ZodMap:return $J(Q,W);case M.ZodSet:return FJ(Q,W);case M.ZodLazy:return()=>Q.getter()._def;case M.ZodPromise:return VJ(Q,W);case M.ZodNaN:case M.ZodNever:return GJ(W);case M.ZodEffects:return e7(Q,W);case M.ZodAny:return B0(W);case M.ZodUnknown:return NJ(W);case M.ZodDefault:return s7(Q,W);case M.ZodBranded:return h9(Q,W);case M.ZodReadonly:return wJ(Q,W);case M.ZodCatch:return a7(Q,W);case M.ZodPipeline:return qJ(Q,W);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return((Y)=>{return})(X)}};function g(Q,X,W=!1){let Y=X.seen.get(Q);if(X.override){let H=X.override?.(Q,X,Y,W);if(H!==i7)return H}if(Y&&!W){let H=bD(Y,X);if(H!==void 0)return H}let $={def:Q,path:X.currentPath,jsonSchema:void 0};X.seen.set(Q,$);let J=MJ(Q,Q.typeName,X),G=typeof J==="function"?g(J(),X):J;if(G)SD(Q,X,G);if(X.postProcess){let H=X.postProcess(G,Q,X);return $.jsonSchema=G,H}return $.jsonSchema=G,G}var bD=(Q,X)=>{switch(X.$refStrategy){case"root":return{$ref:Q.path.join("/")};case"relative":return{$ref:y9(X.currentPath,Q.path)};case"none":case"seen":{if(Q.path.length<X.currentPath.length&&Q.path.every((W,Y)=>X.currentPath[Y]===W))return console.warn(`Recursive reference detected at ${X.currentPath.join("/")}! Defaulting to any`),B0(X);return X.$refStrategy==="seen"?B0(X):void 0}}},SD=(Q,X,W)=>{if(Q.description){if(W.description=Q.description,X.markdownDescription)W.markdownDescription=Q.description}return W};var GW=(Q,X)=>{let W=d7(X),Y=typeof X==="object"&&X.definitions?Object.entries(X.definitions).reduce((B,[z,A])=>({...B,[z]:g(A._def,{...W,currentPath:[...W.basePath,W.definitionPath,z]},!0)??B0(W)}),{}):void 0,$=typeof X==="string"?X:X?.nameStrategy==="title"?void 0:X?.name,J=g(Q._def,$===void 0?W:{...W,currentPath:[...W.basePath,W.definitionPath,$]},!1)??B0(W),G=typeof X==="object"&&X.name!==void 0&&X.nameStrategy==="title"?X.name:void 0;if(G!==void 0)J.title=G;if(W.flags.hasReferencedOpenAiAnyType){if(!Y)Y={};if(!Y[W.openAiAnyTypeName])Y[W.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:W.$refStrategy==="relative"?"1":[...W.basePath,W.definitionPath,W.openAiAnyTypeName].join("/")}}}let H=$===void 0?Y?{...J,[W.definitionPath]:Y}:J:{$ref:[...W.$refStrategy==="relative"?[]:W.basePath,W.definitionPath,$].join("/"),[W.definitionPath]:{...Y,[$]:J}};if(W.target==="jsonSchema7")H.$schema="http://json-schema.org/draft-07/schema#";else if(W.target==="jsonSchema2019-09"||W.target==="openAi")H.$schema="https://json-schema.org/draft/2019-09/schema#";if(W.target==="openAi"&&(("anyOf"in H)||("oneOf"in H)||("allOf"in H)||("type"in H)&&Array.isArray(H.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return H};function PD(Q){if(!Q)return"draft-7";if(Q==="jsonSchema7"||Q==="draft-7")return"draft-7";if(Q==="jsonSchema2019-09"||Q==="draft-2020-12")return"draft-2020-12";return"draft-7"}function HW(Q,X){if(f0(Q))return ZX(Q,{target:PD(X?.target),io:X?.pipeStrategy??"input"});return GW(Q,{strictUnions:X?.strictUnions??!0,pipeStrategy:X?.pipeStrategy??"input"})}function BW(Q){let W=I1(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let Y=D9(W);if(typeof Y!=="string")throw Error("Schema method literal must be a string");return Y}function zW(Q,X){let W=R1(Q,X);if(!W.success)throw W.error;return W.data}var RD=60000;class AW{constructor(Q){if(this._options=Q,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(w9,(X)=>{this._oncancel(X)}),this.setNotificationHandler(j9,(X)=>{this._onprogress(X)}),this.setRequestHandler(M9,(X)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(E9,async(X,W)=>{let Y=await this._taskStore.getTask(X.params.taskId,W.sessionId);if(!Y)throw new C(v.InvalidParams,"Failed to retrieve task: Task not found");return{...Y}}),this.setRequestHandler(S9,async(X,W)=>{let Y=async()=>{let $=X.params.taskId;if(this._taskMessageQueue){let G;while(G=await this._taskMessageQueue.dequeue($,W.sessionId)){if(G.type==="response"||G.type==="error"){let H=G.message,B=H.id,z=this._requestResolvers.get(B);if(z)if(this._requestResolvers.delete(B),G.type==="response")z(H);else{let A=H,L=new C(A.error.code,A.error.message,A.error.data);z(L)}else{let A=G.type==="response"?"Response":"Error";this._onerror(Error(`${A} handler missing for request ${B}`))}continue}await this._transport?.send(G.message,{relatedRequestId:W.requestId})}}let J=await this._taskStore.getTask($,W.sessionId);if(!J)throw new C(v.InvalidParams,`Task not found: ${$}`);if(!Z1(J.status))return await this._waitForTaskUpdate($,W.signal),await Y();if(Z1(J.status)){let G=await this._taskStore.getTaskResult($,W.sessionId);return this._clearTaskQueue($),{...G,_meta:{...G._meta,[C1]:{taskId:$}}}}return await Y()};return await Y()}),this.setRequestHandler(P9,async(X,W)=>{try{let{tasks:Y,nextCursor:$}=await this._taskStore.listTasks(X.params?.cursor,W.sessionId);return{tasks:Y,nextCursor:$,_meta:{}}}catch(Y){throw new C(v.InvalidParams,`Failed to list tasks: ${Y instanceof Error?Y.message:String(Y)}`)}}),this.setRequestHandler(I9,async(X,W)=>{try{let Y=await this._taskStore.getTask(X.params.taskId,W.sessionId);if(!Y)throw new C(v.InvalidParams,`Task not found: ${X.params.taskId}`);if(Z1(Y.status))throw new C(v.InvalidParams,`Cannot cancel task in terminal status: ${Y.status}`);await this._taskStore.updateTaskStatus(X.params.taskId,"cancelled","Client cancelled task execution.",W.sessionId),this._clearTaskQueue(X.params.taskId);let $=await this._taskStore.getTask(X.params.taskId,W.sessionId);if(!$)throw new C(v.InvalidParams,`Task not found after cancellation: ${X.params.taskId}`);return{_meta:{},...$}}catch(Y){if(Y instanceof C)throw Y;throw new C(v.InvalidRequest,`Failed to cancel task: ${Y instanceof Error?Y.message:String(Y)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,X,W,Y,$=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(Y,X),startTime:Date.now(),timeout:X,maxTotalTimeout:W,resetTimeoutOnProgress:$,onTimeout:Y})}_resetTimeout(Q){let X=this._timeoutInfo.get(Q);if(!X)return!1;let W=Date.now()-X.startTime;if(X.maxTotalTimeout&&W>=X.maxTotalTimeout)throw this._timeoutInfo.delete(Q),C.fromError(v.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:X.maxTotalTimeout,totalElapsed:W});return clearTimeout(X.timeoutId),X.timeoutId=setTimeout(X.onTimeout,X.timeout),!0}_cleanupTimeout(Q){let X=this._timeoutInfo.get(Q);if(X)clearTimeout(X.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){if(this._transport)throw Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=Q;let X=this.transport?.onclose;this._transport.onclose=()=>{X?.(),this._onclose()};let W=this.transport?.onerror;this._transport.onerror=($)=>{W?.($),this._onerror($)};let Y=this._transport?.onmessage;this._transport.onmessage=($,J)=>{if(Y?.($,J),A4($)||v7($))this._onresponse($);else if(mX($))this._onrequest($,J);else if(T7($))this._onnotification($);else this._onerror(Error(`Unknown message type: ${JSON.stringify($)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let W of this._timeoutInfo.values())clearTimeout(W.timeoutId);this._timeoutInfo.clear();for(let W of this._requestHandlerAbortControllers.values())W.abort();this._requestHandlerAbortControllers.clear();let X=C.fromError(v.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let W of Q.values())W(X)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let X=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X(Q)).catch((W)=>this._onerror(Error(`Uncaught error in notification handler: ${W}`)))}_onrequest(Q,X){let W=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,Y=this._transport,$=Q.params?._meta?.[C1]?.taskId;if(W===void 0){let z={jsonrpc:"2.0",id:Q.id,error:{code:v.MethodNotFound,message:"Method not found"}};if($&&this._taskMessageQueue)this._enqueueTaskMessage($,{type:"error",message:z,timestamp:Date.now()},Y?.sessionId).catch((A)=>this._onerror(Error(`Failed to enqueue error response: ${A}`)));else Y?.send(z).catch((A)=>this._onerror(Error(`Failed to send an error response: ${A}`)));return}let J=new AbortController;this._requestHandlerAbortControllers.set(Q.id,J);let G=I7(Q.params)?Q.params.task:void 0,H=this._taskStore?this.requestTaskStore(Q,Y?.sessionId):void 0,B={signal:J.signal,sessionId:Y?.sessionId,_meta:Q.params?._meta,sendNotification:async(z)=>{if(J.signal.aborted)return;let A={relatedRequestId:Q.id};if($)A.relatedTask={taskId:$};await this.notification(z,A)},sendRequest:async(z,A,L)=>{if(J.signal.aborted)throw new C(v.ConnectionClosed,"Request was cancelled");let D={...L,relatedRequestId:Q.id};if($&&!D.relatedTask)D.relatedTask={taskId:$};let K=D.relatedTask?.taskId??$;if(K&&H)await H.updateTaskStatus(K,"input_required");return await this.request(z,A,D)},authInfo:X?.authInfo,requestId:Q.id,requestInfo:X?.requestInfo,taskId:$,taskStore:H,taskRequestedTtl:G?.ttl,closeSSEStream:X?.closeSSEStream,closeStandaloneSSEStream:X?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(G)this.assertTaskHandlerCapability(Q.method)}).then(()=>W(Q,B)).then(async(z)=>{if(J.signal.aborted)return;let A={result:z,jsonrpc:"2.0",id:Q.id};if($&&this._taskMessageQueue)await this._enqueueTaskMessage($,{type:"response",message:A,timestamp:Date.now()},Y?.sessionId);else await Y?.send(A)},async(z)=>{if(J.signal.aborted)return;let A={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(z.code)?z.code:v.InternalError,message:z.message??"Internal error",...z.data!==void 0&&{data:z.data}}};if($&&this._taskMessageQueue)await this._enqueueTaskMessage($,{type:"error",message:A,timestamp:Date.now()},Y?.sessionId);else await Y?.send(A)}).catch((z)=>this._onerror(Error(`Failed to send response: ${z}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(Q.id)===J)this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:X,...W}=Q.params,Y=Number(X),$=this._progressHandlers.get(Y);if(!$){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let J=this._responseHandlers.get(Y),G=this._timeoutInfo.get(Y);if(G&&J&&G.resetTimeoutOnProgress)try{this._resetTimeout(Y)}catch(H){this._responseHandlers.delete(Y),this._progressHandlers.delete(Y),this._cleanupTimeout(Y),J(H);return}$(W)}_onresponse(Q){let X=Number(Q.id),W=this._requestResolvers.get(X);if(W){if(this._requestResolvers.delete(X),A4(Q))W(Q);else{let J=new C(Q.error.code,Q.error.message,Q.error.data);W(J)}return}let Y=this._responseHandlers.get(X);if(Y===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(X),this._cleanupTimeout(X);let $=!1;if(A4(Q)&&Q.result&&typeof Q.result==="object"){let J=Q.result;if(J.task&&typeof J.task==="object"){let G=J.task;if(typeof G.taskId==="string")$=!0,this._taskProgressTokens.set(G.taskId,X)}}if(!$)this._progressHandlers.delete(X);if(A4(Q))Y(Q);else{let J=C.fromError(Q.error.code,Q.error.message,Q.error.data);Y(J)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,X,W){let{task:Y}=W??{};if(!Y){try{yield{type:"result",result:await this.request(Q,X,W)}}catch(J){yield{type:"error",error:J instanceof C?J:new C(v.InternalError,String(J))}}return}let $;try{let J=await this.request(Q,S6,W);if(J.task)$=J.task.taskId,yield{type:"taskCreated",task:J.task};else throw new C(v.InternalError,"Task creation did not return a task");while(!0){let G=await this.getTask({taskId:$},W);if(yield{type:"taskStatus",task:G},Z1(G.status)){if(G.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:$},X,W)};else if(G.status==="failed")yield{type:"error",error:new C(v.InternalError,`Task ${$} failed`)};else if(G.status==="cancelled")yield{type:"error",error:new C(v.InternalError,`Task ${$} was cancelled`)};return}if(G.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:$},X,W)};return}let H=G.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((B)=>setTimeout(B,H)),W?.signal?.throwIfAborted()}}catch(J){yield{type:"error",error:J instanceof C?J:new C(v.InternalError,String(J))}}}request(Q,X,W){let{relatedRequestId:Y,resumptionToken:$,onresumptiontoken:J,task:G,relatedTask:H}=W??{};return new Promise((B,z)=>{let A=(O)=>{z(O)};if(!this._transport){A(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),G)this.assertTaskCapability(Q.method)}catch(O){A(O);return}W?.signal?.throwIfAborted();let L=this._requestMessageId++,D={...Q,jsonrpc:"2.0",id:L};if(W?.onprogress)this._progressHandlers.set(L,W.onprogress),D.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:L}};if(G)D.params={...D.params,task:G};if(H)D.params={...D.params,_meta:{...D.params?._meta||{},[C1]:H}};let K=(O)=>{this._responseHandlers.delete(L),this._progressHandlers.delete(L),this._cleanupTimeout(L),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:L,reason:String(O)}},{relatedRequestId:Y,resumptionToken:$,onresumptiontoken:J}).catch((b)=>this._onerror(Error(`Failed to send cancellation: ${b}`)));let E=O instanceof C?O:new C(v.RequestTimeout,String(O));z(E)};this._responseHandlers.set(L,(O)=>{if(W?.signal?.aborted)return;if(O instanceof Error)return z(O);try{let E=R1(X,O.result);if(!E.success)z(E.error);else B(E.data)}catch(E){z(E)}}),W?.signal?.addEventListener("abort",()=>{K(W?.signal?.reason)});let q=W?.timeout??RD,V=()=>K(C.fromError(v.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(L,q,W?.maxTotalTimeout,V,W?.resetTimeoutOnProgress??!1);let N=H?.taskId;if(N){let O=(E)=>{let b=this._responseHandlers.get(L);if(b)b(E);else this._onerror(Error(`Response handler missing for side-channeled request ${L}`))};this._requestResolvers.set(L,O),this._enqueueTaskMessage(N,{type:"request",message:D,timestamp:Date.now()}).catch((E)=>{this._cleanupTimeout(L),z(E)})}else this._transport.send(D,{relatedRequestId:Y,resumptionToken:$,onresumptiontoken:J}).catch((O)=>{this._cleanupTimeout(L),z(O)})})}async getTask(Q,X){return this.request({method:"tasks/get",params:Q},b9,X)}async getTaskResult(Q,X,W){return this.request({method:"tasks/result",params:Q},X,W)}async listTasks(Q,X){return this.request({method:"tasks/list",params:Q},R9,X)}async cancelTask(Q,X){return this.request({method:"tasks/cancel",params:Q},x7,X)}async notification(Q,X){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let W=X?.relatedTask?.taskId;if(W){let G={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[C1]:X.relatedTask}}};await this._enqueueTaskMessage(W,{type:"notification",message:G,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!X?.relatedRequestId&&!X?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let G={...Q,jsonrpc:"2.0"};if(X?.relatedTask)G={...G,params:{...G.params,_meta:{...G.params?._meta||{},[C1]:X.relatedTask}}};this._transport?.send(G,X).catch((H)=>this._onerror(H))});return}let J={...Q,jsonrpc:"2.0"};if(X?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[C1]:X.relatedTask}}};await this._transport.send(J,X)}setRequestHandler(Q,X){let W=BW(Q);this.assertRequestHandlerCapability(W),this._requestHandlers.set(W,(Y,$)=>{let J=zW(Q,Y);return Promise.resolve(X(J,$))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,X){let W=BW(Q);this._notificationHandlers.set(W,(Y)=>{let $=zW(Q,Y);return Promise.resolve(X($))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let X=this._taskProgressTokens.get(Q);if(X!==void 0)this._progressHandlers.delete(X),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,X,W){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let Y=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,X,W,Y)}async _clearTaskQueue(Q,X){if(this._taskMessageQueue){let W=await this._taskMessageQueue.dequeueAll(Q,X);for(let Y of W)if(Y.type==="request"&&mX(Y.message)){let $=Y.message.id,J=this._requestResolvers.get($);if(J)J(new C(v.InternalError,"Task cancelled or completed")),this._requestResolvers.delete($);else this._onerror(Error(`Resolver missing for request ${$} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,X){let W=this._options?.defaultTaskPollInterval??1000;try{let Y=await this._taskStore?.getTask(Q);if(Y?.pollInterval)W=Y.pollInterval}catch{}return new Promise((Y,$)=>{if(X.aborted){$(new C(v.InvalidRequest,"Request cancelled"));return}let J=setTimeout(Y,W);X.addEventListener("abort",()=>{clearTimeout(J),$(new C(v.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,X){let W=this._taskStore;if(!W)throw Error("No task store configured");return{createTask:async(Y)=>{if(!Q)throw Error("No request provided");return await W.createTask(Y,Q.id,{method:Q.method,params:Q.params},X)},getTask:async(Y)=>{let $=await W.getTask(Y,X);if(!$)throw new C(v.InvalidParams,"Failed to retrieve task: Task not found");return $},storeTaskResult:async(Y,$,J)=>{await W.storeTaskResult(Y,$,J,X);let G=await W.getTask(Y,X);if(G){let H=V4.parse({method:"notifications/tasks/status",params:G});if(await this.notification(H),Z1(G.status))this._cleanupTaskProgressHandler(Y)}},getTaskResult:(Y)=>{return W.getTaskResult(Y,X)},updateTaskStatus:async(Y,$,J)=>{let G=await W.getTask(Y,X);if(!G)throw new C(v.InvalidParams,`Task "${Y}" not found - it may have been cleaned up`);if(Z1(G.status))throw new C(v.InvalidParams,`Cannot update task "${Y}" from terminal status "${G.status}" to "${$}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await W.updateTaskStatus(Y,$,J,X);let H=await W.getTask(Y,X);if(H){let B=V4.parse({method:"notifications/tasks/status",params:H});if(await this.notification(B),Z1(H.status))this._cleanupTaskProgressHandler(Y)}},listTasks:(Y)=>{return W.listTasks(Y,X)}}}}function jJ(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function EJ(Q,X){let W={...Q};for(let Y in X){let $=Y,J=X[$];if(J===void 0)continue;let G=W[$];if(jJ(G)&&jJ(J))W[$]={...G,...J};else W[$]=J}return W}var JB=RY(JY(),1),GB=RY($B(),1);function rM(){let Q=new JB.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return GB.default(Q),Q}class VY{constructor(Q){this._ajv=Q??rM()}getValidator(Q){let X="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(W)=>{if(X(W))return{valid:!0,data:W,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(X.errors)}}}}class FY{constructor(Q){this._server=Q}requestStream(Q,X,W){return this._server.requestStream(Q,X,W)}createMessageStream(Q,X){let W=this._server.getClientCapabilities();if((Q.tools||Q.toolChoice)&&!W?.sampling?.tools)throw Error("Client does not support sampling tools capability.");if(Q.messages.length>0){let Y=Q.messages[Q.messages.length-1],$=Array.isArray(Y.content)?Y.content:[Y.content],J=$.some((z)=>z.type==="tool_result"),G=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,H=G?Array.isArray(G.content)?G.content:[G.content]:[],B=H.some((z)=>z.type==="tool_use");if(J){if($.some((z)=>z.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!B)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(B){let z=new Set(H.filter((L)=>L.type==="tool_use").map((L)=>L.id)),A=new Set($.filter((L)=>L.type==="tool_result").map((L)=>L.toolUseId));if(z.size!==A.size||![...z].every((L)=>A.has(L)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:Q},O4,X)}elicitInputStream(Q,X){let W=this._server.getClientCapabilities(),Y=Q.mode??"form";switch(Y){case"url":{if(!W?.elicitation?.url)throw Error("Client does not support url elicitation.");break}case"form":{if(!W?.elicitation?.form)throw Error("Client does not support form elicitation.");break}}let $=Y==="form"&&Q.mode===void 0?{...Q,mode:"form"}:Q;return this.requestStream({method:"elicitation/create",params:$},I6,X)}async getTask(Q,X){return this._server.getTask({taskId:Q},X)}async getTaskResult(Q,X,W){return this._server.getTaskResult({taskId:Q},X,W)}async listTasks(Q,X){return this._server.listTasks(Q?{cursor:Q}:void 0,X)}async cancelTask(Q,X){return this._server.cancelTask({taskId:Q},X)}}function HB(Q,X,W){if(!Q)throw Error(`${W} does not support task creation (required for ${X})`);switch(X){case"tools/call":if(!Q.tools?.call)throw Error(`${W} does not support task creation for tools/call (required for ${X})`);break;default:break}}function BB(Q,X,W){if(!Q)throw Error(`${W} does not support task creation (required for ${X})`);switch(X){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${W} does not support task creation for sampling/createMessage (required for ${X})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${W} does not support task creation for elicitation/create (required for ${X})`);break;default:break}}class UY extends AW{constructor(Q,X){super(X);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(U4.options.map((W,Y)=>[W,Y])),this.isMessageIgnored=(W,Y)=>{let $=this._loggingLevels.get(Y);return $?this.LOG_LEVEL_SEVERITY.get(W)<this.LOG_LEVEL_SEVERITY.get($):!1},this._capabilities=X?.capabilities??{},this._instructions=X?.instructions,this._jsonSchemaValidator=X?.jsonSchemaValidator??new VY,this.setRequestHandler(iX,(W)=>this._oninitialize(W)),this.setNotificationHandler(nX,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(eX,async(W,Y)=>{let $=Y.sessionId||Y.requestInfo?.headers["mcp-session-id"]||void 0,{level:J}=W.params,G=U4.safeParse(J);if(G.success)this._loggingLevels.set($,G.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new FY(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=EJ(this._capabilities,Q)}setRequestHandler(Q,X){let Y=I1(Q)?.method;if(!Y)throw Error("Schema is missing a method literal");let $;if(f0(Y)){let G=Y;$=G._zod?.def?.value??G.value}else{let G=Y;$=G._def?.value??G.value}if(typeof $!=="string")throw Error("Schema method literal must be a string");if($==="tools/call"){let G=async(H,B)=>{let z=R1(R6,H);if(!z.success){let K=z.error instanceof Error?z.error.message:String(z.error);throw new C(v.InvalidParams,`Invalid tools/call request: ${K}`)}let{params:A}=z.data,L=await Promise.resolve(X(H,B));if(A.task){let K=R1(S6,L);if(!K.success){let q=K.error instanceof Error?K.error.message:String(K.error);throw new C(v.InvalidParams,`Invalid task creation result: ${q}`)}return K.data}let D=R1(x9,L);if(!D.success){let K=D.error instanceof Error?D.error.message:String(D.error);throw new C(v.InvalidParams,`Invalid tools/call result: ${K}`)}return D.data};return super.setRequestHandler(Q,G)}return super.setRequestHandler(Q,X)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){BB(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;HB(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let X=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:S7.includes(X)?X:uX,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},N9)}async createMessage(Q,X){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let W=Q.messages[Q.messages.length-1],Y=Array.isArray(W.content)?W.content:[W.content],$=Y.some((B)=>B.type==="tool_result"),J=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,G=J?Array.isArray(J.content)?J.content:[J.content]:[],H=G.some((B)=>B.type==="tool_use");if($){if(Y.some((B)=>B.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!H)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(H){let B=new Set(G.filter((A)=>A.type==="tool_use").map((A)=>A.id)),z=new Set(Y.filter((A)=>A.type==="tool_result").map((A)=>A.toolUseId));if(B.size!==z.size||![...B].every((A)=>z.has(A)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},QW,X);return this.request({method:"sampling/createMessage",params:Q},O4,X)}async elicitInput(Q,X){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let Y=Q;return this.request({method:"elicitation/create",params:Y},I6,X)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let Y=Q.mode==="form"?Q:{...Q,mode:"form"},$=await this.request({method:"elicitation/create",params:Y},I6,X);if($.action==="accept"&&$.content&&Y.requestedSchema)try{let G=this._jsonSchemaValidator.getValidator(Y.requestedSchema)($.content);if(!G.valid)throw new C(v.InvalidParams,`Elicitation response content does not match requested schema: ${G.errorMessage}`)}catch(J){if(J instanceof C)throw J;throw new C(v.InternalError,`Error validating elicitation response: ${J instanceof Error?J.message:String(J)}`)}return $}}}createElicitationCompletionNotifier(Q,X){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},X)}async listRoots(Q,X){return this.request({method:"roots/list",params:Q},XW,X)}async sendLoggingMessage(Q,X){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,X))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var AB=Symbol.for("mcp.completable");function OY(Q){return!!Q&&typeof Q==="object"&&AB in Q}function KB(Q){return Q[AB]?.complete}var zB;(function(Q){Q.Completable="McpCompletable"})(zB||(zB={}));var tM=/^[A-Za-z0-9._-]{1,128}$/;function aM(Q){let X=[];if(Q.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(Q.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${Q.length})`]};if(Q.includes(" "))X.push("Tool name contains spaces, which may cause parsing issues");if(Q.includes(","))X.push("Tool name contains commas, which may cause parsing issues");if(Q.startsWith("-")||Q.endsWith("-"))X.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");if(Q.startsWith(".")||Q.endsWith("."))X.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");if(!tM.test(Q)){let W=Q.split("").filter((Y)=>!/[A-Za-z0-9._-]/.test(Y)).filter((Y,$,J)=>J.indexOf(Y)===$);return X.push(`Tool name contains invalid characters: ${W.map((Y)=>`"${Y}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:X}}return{isValid:!0,warnings:X}}function sM(Q,X){if(X.length>0){console.warn(`Tool name validation warning for "${Q}":`);for(let W of X)console.warn(` - ${W}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function NY(Q){let X=aM(Q);return sM(Q,X.warnings),X.isValid}class wY{constructor(Q){this._mcpServer=Q}registerToolTask(Q,X,W){let Y={taskSupport:"required",...X.execution};if(Y.taskSupport==="forbidden")throw Error(`Cannot register task-based tool '${Q}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(Q,X.title,X.description,X.inputSchema,X.outputSchema,X.annotations,Y,X._meta,W)}}class jY{constructor(Q,X){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new UY(Q,X)}get experimental(){if(!this._experimental)this._experimental={tasks:new wY(this)};return this._experimental}async connect(Q){return await this.server.connect(Q)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(h1(_9)),this.server.assertCanSetRequestHandler(h1(R6)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(_9,()=>({tools:Object.entries(this._registeredTools).filter(([,Q])=>Q.enabled).map(([Q,X])=>{let W={name:Q,title:X.title,description:X.description,inputSchema:(()=>{let Y=E6(X.inputSchema);return Y?HW(Y,{strictUnions:!0,pipeStrategy:"input"}):eM})(),annotations:X.annotations,execution:X.execution,_meta:X._meta};if(X.outputSchema){let Y=E6(X.outputSchema);if(Y)W.outputSchema=HW(Y,{strictUnions:!0,pipeStrategy:"output"})}return W})})),this.server.setRequestHandler(R6,async(Q,X)=>{try{let W=this._registeredTools[Q.params.name];if(!W)throw new C(v.InvalidParams,`Tool ${Q.params.name} not found`);if(!W.enabled)throw new C(v.InvalidParams,`Tool ${Q.params.name} disabled`);let Y=!!Q.params.task,$=W.execution?.taskSupport,J="createTask"in W.handler;if(($==="required"||$==="optional")&&!J)throw new C(v.InternalError,`Tool ${Q.params.name} has taskSupport '${$}' but was not registered with registerToolTask`);if($==="required"&&!Y)throw new C(v.MethodNotFound,`Tool ${Q.params.name} requires task augmentation (taskSupport: 'required')`);if($==="optional"&&!Y&&J)return await this.handleAutomaticTaskPolling(W,Q,X);let G=await this.validateToolInput(W,Q.params.arguments,Q.params.name),H=await this.executeToolHandler(W,G,X);if(Y)return H;return await this.validateToolOutput(W,H,Q.params.name),H}catch(W){if(W instanceof C){if(W.code===v.UrlElicitationRequired)throw W}return this.createToolError(W instanceof Error?W.message:String(W))}}),this._toolHandlersInitialized=!0}createToolError(Q){return{content:[{type:"text",text:Q}],isError:!0}}async validateToolInput(Q,X,W){if(!Q.inputSchema)return;let $=E6(Q.inputSchema)??Q.inputSchema,J=await K9($,X);if(!J.success){let G="error"in J?J.error:"Unknown error",H=L9(G);throw new C(v.InvalidParams,`Input validation error: Invalid arguments for tool ${W}: ${H}`)}return J.data}async validateToolOutput(Q,X,W){if(!Q.outputSchema)return;if(!("content"in X))return;if(X.isError)return;if(!X.structuredContent)throw new C(v.InvalidParams,`Output validation error: Tool ${W} has an output schema but no structured content was provided`);let Y=E6(Q.outputSchema),$=await K9(Y,X.structuredContent);if(!$.success){let J="error"in $?$.error:"Unknown error",G=L9(J);throw new C(v.InvalidParams,`Output validation error: Invalid structured content for tool ${W}: ${G}`)}}async executeToolHandler(Q,X,W){let Y=Q.handler;if("createTask"in Y){if(!W.taskStore)throw Error("No task store provided.");let J={...W,taskStore:W.taskStore};if(Q.inputSchema)return await Promise.resolve(Y.createTask(X,J));else return await Promise.resolve(Y.createTask(J))}if(Q.inputSchema)return await Promise.resolve(Y(X,W));else return await Promise.resolve(Y(W))}async handleAutomaticTaskPolling(Q,X,W){if(!W.taskStore)throw Error("No task store provided for task-capable tool.");let Y=await this.validateToolInput(Q,X.params.arguments,X.params.name),$=Q.handler,J={...W,taskStore:W.taskStore},G=Y?await Promise.resolve($.createTask(Y,J)):await Promise.resolve($.createTask(J)),H=G.task.taskId,B=G.task,z=B.pollInterval??5000;while(B.status!=="completed"&&B.status!=="failed"&&B.status!=="cancelled"){await new Promise((L)=>setTimeout(L,z));let A=await W.taskStore.getTask(H);if(!A)throw new C(v.InternalError,`Task ${H} not found during polling`);B=A}return await W.taskStore.getTaskResult(H)}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(h1(g9)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(g9,async(Q)=>{switch(Q.params.ref.type){case"ref/prompt":return l7(Q),this.handlePromptCompletion(Q,Q.params.ref);case"ref/resource":return m7(Q),this.handleResourceCompletion(Q,Q.params.ref);default:throw new C(v.InvalidParams,`Invalid completion reference: ${Q.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion(Q,X){let W=this._registeredPrompts[X.name];if(!W)throw new C(v.InvalidParams,`Prompt ${X.name} not found`);if(!W.enabled)throw new C(v.InvalidParams,`Prompt ${X.name} disabled`);if(!W.argsSchema)return c4;let $=I1(W.argsSchema)?.[Q.params.argument.name];if(!OY($))return c4;let J=KB($);if(!J)return c4;let G=await J(Q.params.argument.value,Q.params.context);return DB(G)}async handleResourceCompletion(Q,X){let W=Object.values(this._registeredResourceTemplates).find((J)=>J.resourceTemplate.uriTemplate.toString()===X.uri);if(!W){if(this._registeredResources[X.uri])return c4;throw new C(v.InvalidParams,`Resource template ${Q.params.ref.uri} not found`)}let Y=W.resourceTemplate.completeCallback(Q.params.argument.name);if(!Y)return c4;let $=await Y(Q.params.argument.value,Q.params.context);return DB($)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(h1(C9)),this.server.assertCanSetRequestHandler(h1(Z9)),this.server.assertCanSetRequestHandler(h1(T9)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(C9,async(Q,X)=>{let W=Object.entries(this._registeredResources).filter(([$,J])=>J.enabled).map(([$,J])=>({uri:$,name:J.name,...J.metadata})),Y=[];for(let $ of Object.values(this._registeredResourceTemplates)){if(!$.resourceTemplate.listCallback)continue;let J=await $.resourceTemplate.listCallback(X);for(let G of J.resources)Y.push({...$.metadata,...G})}return{resources:[...W,...Y]}}),this.server.setRequestHandler(Z9,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([X,W])=>({name:X,uriTemplate:W.resourceTemplate.uriTemplate.toString(),...W.metadata}))}}),this.server.setRequestHandler(T9,async(Q,X)=>{let W=new URL(Q.params.uri),Y=this._registeredResources[W.toString()];if(Y){if(!Y.enabled)throw new C(v.InvalidParams,`Resource ${W} disabled`);return Y.readCallback(W,X)}for(let $ of Object.values(this._registeredResourceTemplates)){let J=$.resourceTemplate.uriTemplate.match(W.toString());if(J)return $.readCallback(W,J,X)}throw new C(v.InvalidParams,`Resource ${W} not found`)}),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(h1(v9)),this.server.assertCanSetRequestHandler(h1(k9)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(v9,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,Q])=>Q.enabled).map(([Q,X])=>{return{name:Q,title:X.title,description:X.description,arguments:X.argsSchema?Qj(X.argsSchema):void 0}})})),this.server.setRequestHandler(k9,async(Q,X)=>{let W=this._registeredPrompts[Q.params.name];if(!W)throw new C(v.InvalidParams,`Prompt ${Q.params.name} not found`);if(!W.enabled)throw new C(v.InvalidParams,`Prompt ${Q.params.name} disabled`);if(W.argsSchema){let Y=E6(W.argsSchema),$=await K9(Y,Q.params.arguments);if(!$.success){let H="error"in $?$.error:"Unknown error",B=L9(H);throw new C(v.InvalidParams,`Invalid arguments for prompt ${Q.params.name}: ${B}`)}let J=$.data,G=W.callback;return await Promise.resolve(G(J,X))}else{let Y=W.callback;return await Promise.resolve(Y(X))}}),this._promptHandlersInitialized=!0}resource(Q,X,...W){let Y;if(typeof W[0]==="object")Y=W.shift();let $=W[0];if(typeof X==="string"){if(this._registeredResources[X])throw Error(`Resource ${X} is already registered`);let J=this._createRegisteredResource(Q,void 0,X,Y,$);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),J}else{if(this._registeredResourceTemplates[Q])throw Error(`Resource template ${Q} is already registered`);let J=this._createRegisteredResourceTemplate(Q,void 0,X,Y,$);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),J}}registerResource(Q,X,W,Y){if(typeof X==="string"){if(this._registeredResources[X])throw Error(`Resource ${X} is already registered`);let $=this._createRegisteredResource(Q,W.title,X,W,Y);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),$}else{if(this._registeredResourceTemplates[Q])throw Error(`Resource template ${Q} is already registered`);let $=this._createRegisteredResourceTemplate(Q,W.title,X,W,Y);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),$}}_createRegisteredResource(Q,X,W,Y,$){let J={name:Q,title:X,metadata:Y,readCallback:$,enabled:!0,disable:()=>J.update({enabled:!1}),enable:()=>J.update({enabled:!0}),remove:()=>J.update({uri:null}),update:(G)=>{if(typeof G.uri<"u"&&G.uri!==W){if(delete this._registeredResources[W],G.uri)this._registeredResources[G.uri]=J}if(typeof G.name<"u")J.name=G.name;if(typeof G.title<"u")J.title=G.title;if(typeof G.metadata<"u")J.metadata=G.metadata;if(typeof G.callback<"u")J.readCallback=G.callback;if(typeof G.enabled<"u")J.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResources[W]=J,J}_createRegisteredResourceTemplate(Q,X,W,Y,$){let J={resourceTemplate:W,title:X,metadata:Y,readCallback:$,enabled:!0,disable:()=>J.update({enabled:!1}),enable:()=>J.update({enabled:!0}),remove:()=>J.update({name:null}),update:(B)=>{if(typeof B.name<"u"&&B.name!==Q){if(delete this._registeredResourceTemplates[Q],B.name)this._registeredResourceTemplates[B.name]=J}if(typeof B.title<"u")J.title=B.title;if(typeof B.template<"u")J.resourceTemplate=B.template;if(typeof B.metadata<"u")J.metadata=B.metadata;if(typeof B.callback<"u")J.readCallback=B.callback;if(typeof B.enabled<"u")J.enabled=B.enabled;this.sendResourceListChanged()}};this._registeredResourceTemplates[Q]=J;let G=W.uriTemplate.variableNames;if(Array.isArray(G)&&G.some((B)=>!!W.completeCallback(B)))this.setCompletionRequestHandler();return J}_createRegisteredPrompt(Q,X,W,Y,$){let J={title:X,description:W,argsSchema:Y===void 0?void 0:t1(Y),callback:$,enabled:!0,disable:()=>J.update({enabled:!1}),enable:()=>J.update({enabled:!0}),remove:()=>J.update({name:null}),update:(G)=>{if(typeof G.name<"u"&&G.name!==Q){if(delete this._registeredPrompts[Q],G.name)this._registeredPrompts[G.name]=J}if(typeof G.title<"u")J.title=G.title;if(typeof G.description<"u")J.description=G.description;if(typeof G.argsSchema<"u")J.argsSchema=t1(G.argsSchema);if(typeof G.callback<"u")J.callback=G.callback;if(typeof G.enabled<"u")J.enabled=G.enabled;this.sendPromptListChanged()}};if(this._registeredPrompts[Q]=J,Y){if(Object.values(Y).some((H)=>{let B=H instanceof _0?H._def?.innerType:H;return OY(B)}))this.setCompletionRequestHandler()}return J}_createRegisteredTool(Q,X,W,Y,$,J,G,H,B){NY(Q);let z={title:X,description:W,inputSchema:LB(Y),outputSchema:LB($),annotations:J,execution:G,_meta:H,handler:B,enabled:!0,disable:()=>z.update({enabled:!1}),enable:()=>z.update({enabled:!0}),remove:()=>z.update({name:null}),update:(A)=>{if(typeof A.name<"u"&&A.name!==Q){if(typeof A.name==="string")NY(A.name);if(delete this._registeredTools[Q],A.name)this._registeredTools[A.name]=z}if(typeof A.title<"u")z.title=A.title;if(typeof A.description<"u")z.description=A.description;if(typeof A.paramsSchema<"u")z.inputSchema=t1(A.paramsSchema);if(typeof A.outputSchema<"u")z.outputSchema=t1(A.outputSchema);if(typeof A.callback<"u")z.handler=A.callback;if(typeof A.annotations<"u")z.annotations=A.annotations;if(typeof A._meta<"u")z._meta=A._meta;if(typeof A.enabled<"u")z.enabled=A.enabled;this.sendToolListChanged()}};return this._registeredTools[Q]=z,this.setToolRequestHandlers(),this.sendToolListChanged(),z}tool(Q,...X){if(this._registeredTools[Q])throw Error(`Tool ${Q} is already registered`);let W,Y,$,J;if(typeof X[0]==="string")W=X.shift();if(X.length>1){let H=X[0];if(MY(H)){if(Y=X.shift(),X.length>1&&typeof X[0]==="object"&&X[0]!==null&&!MY(X[0]))J=X.shift()}else if(typeof H==="object"&&H!==null){if(Object.values(H).some((B)=>typeof B==="object"&&B!==null))throw Error(`Tool ${Q} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);J=X.shift()}}let G=X[0];return this._createRegisteredTool(Q,void 0,W,Y,$,J,{taskSupport:"forbidden"},void 0,G)}registerTool(Q,X,W){if(this._registeredTools[Q])throw Error(`Tool ${Q} is already registered`);let{title:Y,description:$,inputSchema:J,outputSchema:G,annotations:H,_meta:B}=X;return this._createRegisteredTool(Q,Y,$,J,G,H,{taskSupport:"forbidden"},B,W)}prompt(Q,...X){if(this._registeredPrompts[Q])throw Error(`Prompt ${Q} is already registered`);let W;if(typeof X[0]==="string")W=X.shift();let Y;if(X.length>1)Y=X.shift();let $=X[0],J=this._createRegisteredPrompt(Q,void 0,W,Y,$);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),J}registerPrompt(Q,X,W){if(this._registeredPrompts[Q])throw Error(`Prompt ${Q} is already registered`);let{title:Y,description:$,argsSchema:J}=X,G=this._createRegisteredPrompt(Q,Y,$,J,W);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),G}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(Q,X){return this.server.sendLoggingMessage(Q,X)}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var eM={type:"object",properties:{}};function qB(Q){return Q!==null&&typeof Q==="object"&&"parse"in Q&&typeof Q.parse==="function"&&"safeParse"in Q&&typeof Q.safeParse==="function"}function VB(Q){return"_def"in Q||"_zod"in Q||qB(Q)}function MY(Q){if(typeof Q!=="object"||Q===null)return!1;if(VB(Q))return!1;if(Object.keys(Q).length===0)return!0;return Object.values(Q).some(qB)}function LB(Q){if(!Q)return;if(MY(Q))return t1(Q);if(!VB(Q))throw Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return Q}function Qj(Q){let X=I1(Q);if(!X)return[];return Object.entries(X).map(([W,Y])=>{let $=X7(Y),J=W7(Y);return{name:W,description:$,required:!J}})}function h1(Q){let W=I1(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let Y=D9(W);if(typeof Y==="string")return Y;throw Error("Schema method literal must be a string")}function DB(Q){return{completion:{values:Q.slice(0,100),total:Q.length,hasMore:Q.length>100}}}var c4={completion:{values:[],hasMore:!1}};import UB from"process";class EY{append(Q){this._buffer=this._buffer?Buffer.concat([this._buffer,Q]):Q}readMessage(){if(!this._buffer)return null;let Q=this._buffer.indexOf(`
41
41
  `);if(Q===-1)return null;let X=this._buffer.toString("utf8",0,Q).replace(/\r$/,"");return this._buffer=this._buffer.subarray(Q+1),Xj(X)}clear(){this._buffer=void 0}}function Xj(Q){return k7.parse(JSON.parse(Q))}function FB(Q){return JSON.stringify(Q)+`
42
- `}class bY{constructor(Q=UB.stdin,X=UB.stdout){this._stdin=Q,this._stdout=X,this._readBuffer=new EY,this._started=!1,this._ondata=(W)=>{this._readBuffer.append(W),this.processReadBuffer()},this._onerror=(W)=>{this.onerror?.(W)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((X)=>{let W=FB(Q);if(this._stdout.write(W))X();else this._stdout.once("drain",X)})}}var OB={name:"junhost",version:"0.1.1",description:"Jun \u2014 a self-hosted dashboard that runs and supervises Codex as a 24/7 local/VPS agent: chat runs, workspace files, remote browser, skills, MCP, schedules.",type:"module",bin:{jun:"bin/jun.js"},files:["bin","dist","ui-dist","README.md"],engines:{bun:">=1.2.0"},keywords:["codex","agent","ai","dashboard","self-hosted","browser-automation","mcp"],license:"UNLICENSED",scripts:{dev:"bun --hot src/index.ts",start:"bun src/index.ts",build:"bun build src/index.ts src/mcp-server.ts --target=bun --minify --outdir=dist",typecheck:"bunx tsc --noEmit"},dependencies:{"agent-browser":"^0.27.1",cloakbrowser:"^0.3.31"},devDependencies:{"@junhost/shared":"workspace:*","@modelcontextprotocol/sdk":"^1.29.0","@types/bun":"^1.2.0","smol-toml":"^1.6.1",typescript:"^5.6.3",zod:"3"}};var NB=OB.version;var Yj=Number(process.env.JUN_PORT??process.env.AGENTHOST_PORT??8787),$j=`http://127.0.0.1:${Yj}`;async function k0(Q,X,W){let Y=await fetch(`${$j}${X}`,{method:Q,headers:W?{"content-type":"application/json"}:void 0,body:W?JSON.stringify(W):void 0}),$=await Y.text(),J=$;try{J=$?JSON.parse($):null}catch{}if(!Y.ok){let G=(J&&typeof J==="object"&&"error"in J?J.error:void 0)??`${Y.status} ${Y.statusText}`;throw Error(G)}return J}var A1=(Q)=>({content:[{type:"text",text:JSON.stringify(Q,null,2)}]}),K1=(Q)=>({content:[{type:"text",text:`Error: ${Q instanceof Error?Q.message:String(Q)}`}],isError:!0}),Y1=new jY({name:"jun",version:NB});Y1.tool("list_mcp_servers","List the MCP servers configured for this Jun project, with their live status and tools.",{},async()=>{try{return A1(await k0("GET","/api/mcp"))}catch(Q){return K1(Q)}});Y1.tool("add_mcp_server","Add or update a stdio MCP server in this project's config and reload it. Provide a command (e.g. 'npx') with args.",{name:a.string().describe("Server name, e.g. 'context7'"),command:a.string().describe("Executable, e.g. 'npx'"),args:a.array(a.string()).optional().describe("Command arguments"),env:a.record(a.string()).optional().describe("Environment variables")},async({name:Q,command:X,args:W,env:Y})=>{try{return await k0("POST","/api/mcp/servers",{name:Q,command:X,args:W,env:Y}),await k0("POST","/api/mcp/reload"),A1({added:Q,status:await k0("GET","/api/mcp")})}catch($){return K1($)}});Y1.tool("enable_mcp_server","Enable or disable a configured MCP server, then reload.",{name:a.string(),enabled:a.boolean()},async({name:Q,enabled:X})=>{try{return await k0("POST",`/api/mcp/servers/${Q}/enable`,{enabled:X}),await k0("POST","/api/mcp/reload"),A1({name:Q,enabled:X})}catch(W){return K1(W)}});Y1.tool("remove_mcp_server","Remove a configured MCP server, then reload.",{name:a.string()},async({name:Q})=>{try{return await k0("DELETE",`/api/mcp/servers/${Q}`),await k0("POST","/api/mcp/reload"),A1({removed:Q})}catch(X){return K1(X)}});var E8=(Q,X)=>X?`${Q}${Q.includes("?")?"&":"?"}cwd=${encodeURIComponent(X)}`:Q,b8="Pass your current working directory so the skill targets the right workspace (Jun has one workspace per project; omitting this uses the default).";Y1.tool("list_skills","List the skills available in the Jun workspace you are working in.",{cwd:a.string().optional().describe(b8)},async({cwd:Q})=>{try{return A1(await k0("GET",E8("/api/skills",Q)))}catch(X){return K1(X)}});Y1.tool("create_skill","Create a new skill (folder + SKILL.md) in the workspace you are working in. Use a kebab-case name.",{name:a.string().describe("kebab-case skill name"),description:a.string().describe("When Codex should use this skill"),instructions:a.string().optional().describe("Markdown body: how to perform the skill"),cwd:a.string().optional().describe(b8)},async({name:Q,description:X,instructions:W,cwd:Y})=>{try{return A1(await k0("POST",E8("/api/skills",Y),{name:Q,description:X,instructions:W}))}catch($){return K1($)}});Y1.tool("list_schedules","List the schedules (cron or one-off automated runs) in the workspace you are working in.",{cwd:a.string().optional().describe(b8)},async({cwd:Q})=>{try{return A1(await k0("GET",E8("/api/schedules",Q)))}catch(X){return K1(X)}});Y1.tool("create_schedule","Schedule a prompt to run automatically \u2014 repeating on a 5-field cron expression "+"(minute hour day-of-month month day-of-week), or once at a specific time. The run fires in the workspace you are working in and shows up in the Runs page. By default it runs Unattended (a Codex subagent approves actions so it doesn't block). Examples: daily 9am = cron '0 9 * * *'; weekdays 8:30am = '30 8 * * 1-5'.",{name:a.string().describe("Human-readable schedule name, e.g. 'Morning report'"),prompt:a.string().describe("The prompt to run on every fire"),kind:a.enum(["cron","once"]).optional().describe("'cron' (repeating, default) or 'once'"),cron:a.string().optional().describe("5-field cron expression when kind='cron', e.g. '0 9 * * *'"),runAt:a.string().optional().describe("ISO datetime when kind='once', e.g. '2026-06-12T09:00:00Z'"),tz:a.string().optional().describe("IANA timezone for evaluation, e.g. 'America/New_York' (default: daemon local)"),resume:a.boolean().optional().describe("If true, every fire continues ONE conversation (context accumulates) instead of starting fresh"),cwd:a.string().optional().describe(b8)},async({name:Q,prompt:X,kind:W,cron:Y,runAt:$,tz:J,resume:G,cwd:H})=>{try{return A1(await k0("POST",E8("/api/schedules",H),{name:Q,prompt:X,kind:W,cron:Y,runAt:$,tz:J,resume:G}))}catch(B){return K1(B)}});Y1.tool("run_schedule","Fire a schedule immediately (ignores its cadence), creating a run now. Pass the schedule id from list_schedules.",{id:a.string().describe("Schedule id, e.g. 'morning-report-1a2b3c4d'")},async({id:Q})=>{try{return A1(await k0("POST",`/api/schedules/${Q}/run`))}catch(X){return K1(X)}});Y1.tool("delete_schedule","Delete a schedule so it stops firing. Pass the schedule id from list_schedules.",{id:a.string()},async({id:Q})=>{try{return await k0("DELETE",`/api/schedules/${Q}`),A1({removed:Q})}catch(X){return K1(X)}});await Y1.connect(new bY);
42
+ `}class bY{constructor(Q=UB.stdin,X=UB.stdout){this._stdin=Q,this._stdout=X,this._readBuffer=new EY,this._started=!1,this._ondata=(W)=>{this._readBuffer.append(W),this.processReadBuffer()},this._onerror=(W)=>{this.onerror?.(W)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((X)=>{let W=FB(Q);if(this._stdout.write(W))X();else this._stdout.once("drain",X)})}}var OB={name:"junhost",version:"0.2.0",description:"Jun \u2014 a self-hosted dashboard that runs and supervises Codex as a 24/7 local/VPS agent: chat runs, workspace files, remote browser, skills, MCP, schedules.",type:"module",bin:{jun:"bin/jun.js"},files:["bin","dist","ui-dist","README.md"],engines:{bun:">=1.2.0"},keywords:["codex","agent","ai","dashboard","self-hosted","browser-automation","mcp"],license:"UNLICENSED",scripts:{dev:"bun --hot src/index.ts",start:"bun src/index.ts",build:"bun build src/index.ts src/mcp-server.ts src/browser-mcp-server.ts --target=bun --minify --outdir=dist",typecheck:"bunx tsc --noEmit"},dependencies:{"agent-browser":"^0.27.1",cloakbrowser:"^0.3.31"},devDependencies:{"@junhost/shared":"workspace:*","@modelcontextprotocol/sdk":"^1.29.0","@types/bun":"^1.2.0","smol-toml":"^1.6.1",typescript:"^5.6.3",zod:"3"}};var NB=OB.version;var Yj=Number(process.env.JUN_PORT??process.env.AGENTHOST_PORT??8787),$j=`http://127.0.0.1:${Yj}`;async function k0(Q,X,W){let Y=await fetch(`${$j}${X}`,{method:Q,headers:W?{"content-type":"application/json"}:void 0,body:W?JSON.stringify(W):void 0}),$=await Y.text(),J=$;try{J=$?JSON.parse($):null}catch{}if(!Y.ok){let G=(J&&typeof J==="object"&&"error"in J?J.error:void 0)??`${Y.status} ${Y.statusText}`;throw Error(G)}return J}var A1=(Q)=>({content:[{type:"text",text:JSON.stringify(Q,null,2)}]}),K1=(Q)=>({content:[{type:"text",text:`Error: ${Q instanceof Error?Q.message:String(Q)}`}],isError:!0}),Y1=new jY({name:"jun",version:NB});Y1.tool("list_mcp_servers","List the MCP servers configured for this Jun project, with their live status and tools.",{},async()=>{try{return A1(await k0("GET","/api/mcp"))}catch(Q){return K1(Q)}});Y1.tool("add_mcp_server","Add or update a stdio MCP server in this project's config and reload it. Provide a command (e.g. 'npx') with args.",{name:a.string().describe("Server name, e.g. 'context7'"),command:a.string().describe("Executable, e.g. 'npx'"),args:a.array(a.string()).optional().describe("Command arguments"),env:a.record(a.string()).optional().describe("Environment variables")},async({name:Q,command:X,args:W,env:Y})=>{try{return await k0("POST","/api/mcp/servers",{name:Q,command:X,args:W,env:Y}),await k0("POST","/api/mcp/reload"),A1({added:Q,status:await k0("GET","/api/mcp")})}catch($){return K1($)}});Y1.tool("enable_mcp_server","Enable or disable a configured MCP server, then reload.",{name:a.string(),enabled:a.boolean()},async({name:Q,enabled:X})=>{try{return await k0("POST",`/api/mcp/servers/${Q}/enable`,{enabled:X}),await k0("POST","/api/mcp/reload"),A1({name:Q,enabled:X})}catch(W){return K1(W)}});Y1.tool("remove_mcp_server","Remove a configured MCP server, then reload.",{name:a.string()},async({name:Q})=>{try{return await k0("DELETE",`/api/mcp/servers/${Q}`),await k0("POST","/api/mcp/reload"),A1({removed:Q})}catch(X){return K1(X)}});var E8=(Q,X)=>X?`${Q}${Q.includes("?")?"&":"?"}cwd=${encodeURIComponent(X)}`:Q,b8="Pass your current working directory so the skill targets the right workspace (Jun has one workspace per project; omitting this uses the default).";Y1.tool("list_skills","List the skills available in the Jun workspace you are working in.",{cwd:a.string().optional().describe(b8)},async({cwd:Q})=>{try{return A1(await k0("GET",E8("/api/skills",Q)))}catch(X){return K1(X)}});Y1.tool("create_skill","Create a new skill (folder + SKILL.md) in the workspace you are working in. Use a kebab-case name.",{name:a.string().describe("kebab-case skill name"),description:a.string().describe("When Codex should use this skill"),instructions:a.string().optional().describe("Markdown body: how to perform the skill"),cwd:a.string().optional().describe(b8)},async({name:Q,description:X,instructions:W,cwd:Y})=>{try{return A1(await k0("POST",E8("/api/skills",Y),{name:Q,description:X,instructions:W}))}catch($){return K1($)}});Y1.tool("list_schedules","List the schedules (cron or one-off automated runs) in the workspace you are working in.",{cwd:a.string().optional().describe(b8)},async({cwd:Q})=>{try{return A1(await k0("GET",E8("/api/schedules",Q)))}catch(X){return K1(X)}});Y1.tool("create_schedule","Schedule a prompt to run automatically \u2014 repeating on a 5-field cron expression "+"(minute hour day-of-month month day-of-week), or once at a specific time. The run fires in the workspace you are working in and shows up in the Runs page. By default it runs Unattended (a Codex subagent approves actions so it doesn't block). Examples: daily 9am = cron '0 9 * * *'; weekdays 8:30am = '30 8 * * 1-5'.",{name:a.string().describe("Human-readable schedule name, e.g. 'Morning report'"),prompt:a.string().describe("The prompt to run on every fire"),kind:a.enum(["cron","once"]).optional().describe("'cron' (repeating, default) or 'once'"),cron:a.string().optional().describe("5-field cron expression when kind='cron', e.g. '0 9 * * *'"),runAt:a.string().optional().describe("ISO datetime when kind='once', e.g. '2026-06-12T09:00:00Z'"),tz:a.string().optional().describe("IANA timezone for evaluation, e.g. 'America/New_York' (default: daemon local)"),resume:a.boolean().optional().describe("If true, every fire continues ONE conversation (context accumulates) instead of starting fresh"),cwd:a.string().optional().describe(b8)},async({name:Q,prompt:X,kind:W,cron:Y,runAt:$,tz:J,resume:G,cwd:H})=>{try{return A1(await k0("POST",E8("/api/schedules",H),{name:Q,prompt:X,kind:W,cron:Y,runAt:$,tz:J,resume:G}))}catch(B){return K1(B)}});Y1.tool("run_schedule","Fire a schedule immediately (ignores its cadence), creating a run now. Pass the schedule id from list_schedules.",{id:a.string().describe("Schedule id, e.g. 'morning-report-1a2b3c4d'")},async({id:Q})=>{try{return A1(await k0("POST",`/api/schedules/${Q}/run`))}catch(X){return K1(X)}});Y1.tool("delete_schedule","Delete a schedule so it stops firing. Pass the schedule id from list_schedules.",{id:a.string()},async({id:Q})=>{try{return await k0("DELETE",`/api/schedules/${Q}`),A1({removed:Q})}catch(X){return K1(X)}});await Y1.connect(new bY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "junhost",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Jun — a self-hosted dashboard that runs and supervises Codex as a 24/7 local/VPS agent: chat runs, workspace files, remote browser, skills, MCP, schedules.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "scripts": {
29
29
  "dev": "bun --hot src/index.ts",
30
30
  "start": "bun src/index.ts",
31
- "build": "bun build src/index.ts src/mcp-server.ts --target=bun --minify --outdir=dist",
31
+ "build": "bun build src/index.ts src/mcp-server.ts src/browser-mcp-server.ts --target=bun --minify --outdir=dist",
32
32
  "typecheck": "bunx tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
@@ -1 +1 @@
1
- import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{I as r,L as i,V as a,t as o}from"./utils-BX1Diber.js";import{x as s}from"./useBaseUiId-dSIElxm7.js";import{t as c}from"./play-B4R5rXMZ.js";import{t as l}from"./rotate-cw-B1ZRM7VI.js";import{t as u}from"./square-_9cV5Fet.js";import{Yt as d,t as f}from"./index-j386AZTn.js";import{t as p}from"./button-Cg-0y2B2.js";import{t as m}from"./input-D4O22yGt.js";var h=s(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ee=s(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),g=s(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),_=s(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),v=s(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),y=s(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),b=e(t(),1),x=n(),S={width:1280,height:720},C=[{value:`agent`,label:`Agent`,icon:g},{value:`user`,label:`You`,icon:v},{value:`paused`,label:`Paused`,icon:y}];function w(e){return!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}var T=[`left`,`middle`,`right`];function E(){let[e,t]=(0,b.useState)(null),[n,s]=(0,b.useState)([]),[g,y]=(0,b.useState)(``),[E,D]=(0,b.useState)(null),[O,te]=(0,b.useState)(null),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(null),F=(0,b.useRef)(null),I=(0,b.useRef)(null),L=(0,b.useCallback)(()=>{let e=I.current;if(!e)return;let t=S.width/S.height,n=e.clientWidth,r=e.clientHeight;if(n===0||r===0)return;let i=n,a=n/t;a>r&&(a=r,i=r*t);let o={w:Math.floor(i),h:Math.floor(a)};te(e=>e?.w===o.w&&e?.h===o.h?e:o)},[]);(0,b.useEffect)(()=>{L();let e=new ResizeObserver(L);return I.current&&e.observe(I.current),()=>e.disconnect()},[L]);let R=(0,b.useRef)(!1),z=(0,b.useRef)(0),B=e?.streaming??!1,V=e?.running??!1,H=e?.controller??`agent`,U=H===`user`,W=(0,b.useCallback)(async()=>{try{let[{status:e},{actions:n}]=await Promise.all([r(`/api/browser/status`),r(`/api/browser/actions`)]);t(e),s(n),!R.current&&e.url&&e.url!==`about:blank`&&y(e.url),M(null)}catch(e){M(e instanceof Error?e.message:String(e))}},[]);f(W,5e3),(0,b.useEffect)(()=>{U&&F.current?.focus()},[U]),(0,b.useEffect)(()=>{if(!B){D(null);return}let e=!1,t=null,n=0,r=()=>{let i=a(`/api/browser/stream`);N.current=i,i.onmessage=e=>{try{let t=JSON.parse(String(e.data));t.type===`frame`&&t.data&&(n=0,D(`data:image/jpeg;base64,${t.data}`))}catch{}},i.onclose=()=>{if(N.current===i&&(N.current=null),e)return;let a=Math.min(1e3*2**n,1e4);n+=1,t=setTimeout(r,a)}};return r(),()=>{e=!0,t&&clearTimeout(t),N.current?.close(),N.current=null}},[B]);let G=(0,b.useCallback)(async e=>{A(!0),M(null);try{await e(),await W()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[W]),K=()=>G(()=>i(`/api/browser/start`,{url:g.trim()||void 0})),q=()=>G(()=>i(`/api/browser/stop`)),J=()=>{let e=g.trim();if(!e)return;let t=/^[a-z]+:\/\//i.test(e)?e:`https://${e}`;return G(()=>i(`/api/browser/navigate`,{url:t}))},Y=e=>G(()=>i(`/api/browser/${e}`)),ne=()=>G(()=>i(`/api/browser/screenshot`)),X=e=>G(()=>i(`/api/browser/control`,{controller:e})),Z=e=>{let t=N.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},re=e=>{let t=P.current;if(!t)return null;let n=t.getBoundingClientRect();return n.width===0||n.height===0?null:{x:Math.round((e.clientX-n.left)/n.width*S.width),y:Math.round((e.clientY-n.top)/n.height*S.height)}},Q=(e,t,n={})=>{if(!U)return;let r=re(e);r&&(e.preventDefault(),Z({type:`input_mouse`,eventType:t,...r,button:T[e.button]??`left`,clickCount:e.detail||1,modifiers:w(e),...n}))},ie=e=>{let t=performance.now();t-z.current<33||(z.current=t,Q(e,`mouseMoved`))},ae=e=>{let t=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!t)return null;let n=[];return e.ctrlKey&&n.push(`Control`),e.shiftKey&&n.push(`Shift`),e.altKey&&n.push(`Alt`),e.metaKey&&n.push(`Meta`),n.push(e.key===` `?`Space`:e.key),n.join(`+`)},$=(e,t)=>{if(!U)return;e.preventDefault();let n=ae(e);if(n){t===`keyDown`&&i(`/api/browser/key`,{key:n}).catch(()=>{});return}Z({type:`input_keyboard`,eventType:t,key:e.key,code:e.code,text:t===`keyDown`?e.key:void 0,modifiers:w(e)})};return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 p-4`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`back`),children:(0,x.jsx)(h,{})}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`forward`),children:(0,x.jsx)(ee,{})}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`reload`),children:(0,x.jsx)(l,{})})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,x.jsx)(m,{placeholder:`https://example.com`,value:g,onChange:e=>y(e.target.value),onFocus:()=>R.current=!0,onBlur:()=>R.current=!1,onKeyDown:e=>{e.key===`Enter`&&(V?J:K)()}}),(0,x.jsx)(p,{size:`sm`,variant:`outline`,disabled:k||g.trim().length===0,onClick:()=>V?J():K(),children:`Go`})]}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:ne,title:`Screenshot → workspace/screenshots`,children:(0,x.jsx)(_,{})}),(0,x.jsx)(`div`,{className:`flex items-center rounded-md border p-0.5`,children:C.map(({value:e,label:t,icon:n})=>(0,x.jsxs)(p,{size:`sm`,variant:H===e?`secondary`:`ghost`,className:`h-7 gap-1.5 px-2`,disabled:k,onClick:()=>X(e),children:[(0,x.jsx)(n,{className:`size-3.5`}),t]},e))}),V?(0,x.jsxs)(p,{size:`sm`,variant:`outline`,className:`text-destructive hover:text-destructive`,disabled:k,onClick:q,children:[(0,x.jsx)(u,{className:`size-3.5`}),` Stop`]}):(0,x.jsxs)(p,{size:`sm`,disabled:k,onClick:K,children:[(0,x.jsx)(c,{className:`size-3.5`}),` Start`]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:o(`inline-block size-2 rounded-full`,V?`bg-emerald-500`:`bg-neutral-300`)}),V?e?.title||e?.url||`Browser running`:`Browser stopped`,U&&V&&(0,x.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 font-medium text-primary`,children:`You have control — click the page and type`})]}),j&&(0,x.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:j}),(0,x.jsx)(`div`,{ref:I,className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsxs)(`div`,{ref:F,style:O?{width:O.w,height:O.h}:void 0,className:o(`group relative flex items-center justify-center overflow-hidden rounded-lg border bg-neutral-950/95 outline-none`,U&&`ring-2 ring-primary/60`),tabIndex:0,onMouseDown:()=>{U&&F.current?.focus()},onKeyDown:e=>$(e,`keyDown`),onKeyUp:e=>$(e,`keyUp`),children:[E?(0,x.jsx)(`img`,{ref:P,src:E,alt:`Browser viewport`,draggable:!1,className:o(`h-full w-full select-none object-contain`,U?`cursor-crosshair`:`cursor-default`),onMouseDown:e=>Q(e,`mousePressed`),onMouseUp:e=>Q(e,`mouseReleased`),onMouseMove:ie,onContextMenu:e=>U&&e.preventDefault(),onWheel:e=>Q(e,`mouseWheel`,{deltaX:e.deltaX,deltaY:e.deltaY})}):(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-sm text-neutral-400`,children:[(0,x.jsx)(d,{className:`size-8`}),V?`Waiting for viewport frames…`:`Start the browser to see the live viewport.`]}),!U&&E&&(0,x.jsx)(`div`,{className:`absolute inset-0 flex items-end justify-center pb-4 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,x.jsxs)(p,{size:`sm`,className:`shadow-lg`,onClick:()=>X(`user`),children:[(0,x.jsx)(v,{className:`size-3.5`}),` Take control`]})})]})})]}),(0,x.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l`,children:[(0,x.jsx)(`div`,{className:`border-b px-3 py-2 text-sm font-semibold`,children:`Action log`}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-2`,children:[n.map(e=>(0,x.jsxs)(`div`,{className:`rounded-md px-2 py-1.5 text-xs hover:bg-muted/60`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.kind}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()})]}),e.detail&&(0,x.jsx)(`div`,{className:`truncate text-muted-foreground`,title:e.detail,children:e.detail})]},e.id)),n.length===0&&(0,x.jsx)(`p`,{className:`px-2 py-4 text-xs text-muted-foreground`,children:`No actions yet. Start the browser or navigate somewhere.`})]})]})]})}export{E as BrowserPage};
1
+ import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{I as r,L as i,V as a,t as o}from"./utils-BX1Diber.js";import{x as s}from"./useBaseUiId-dSIElxm7.js";import{t as c}from"./play-B4R5rXMZ.js";import{t as l}from"./rotate-cw-B1ZRM7VI.js";import{t as u}from"./square-_9cV5Fet.js";import{Yt as d,t as f}from"./index-DXYsuK0q.js";import{t as p}from"./button-Cg-0y2B2.js";import{t as m}from"./input-BPTmfk5i.js";var h=s(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ee=s(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),g=s(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),_=s(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),v=s(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),y=s(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),b=e(t(),1),x=n(),S={width:1280,height:720},C=[{value:`agent`,label:`Agent`,icon:g},{value:`user`,label:`You`,icon:v},{value:`paused`,label:`Paused`,icon:y}];function w(e){return!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}var T=[`left`,`middle`,`right`];function E(){let[e,t]=(0,b.useState)(null),[n,s]=(0,b.useState)([]),[g,y]=(0,b.useState)(``),[E,D]=(0,b.useState)(null),[O,te]=(0,b.useState)(null),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(null),F=(0,b.useRef)(null),I=(0,b.useRef)(null),L=(0,b.useCallback)(()=>{let e=I.current;if(!e)return;let t=S.width/S.height,n=e.clientWidth,r=e.clientHeight;if(n===0||r===0)return;let i=n,a=n/t;a>r&&(a=r,i=r*t);let o={w:Math.floor(i),h:Math.floor(a)};te(e=>e?.w===o.w&&e?.h===o.h?e:o)},[]);(0,b.useEffect)(()=>{L();let e=new ResizeObserver(L);return I.current&&e.observe(I.current),()=>e.disconnect()},[L]);let R=(0,b.useRef)(!1),z=(0,b.useRef)(0),B=e?.streaming??!1,V=e?.running??!1,H=e?.controller??`agent`,U=H===`user`,W=(0,b.useCallback)(async()=>{try{let[{status:e},{actions:n}]=await Promise.all([r(`/api/browser/status`),r(`/api/browser/actions`)]);t(e),s(n),!R.current&&e.url&&e.url!==`about:blank`&&y(e.url),M(null)}catch(e){M(e instanceof Error?e.message:String(e))}},[]);f(W,5e3),(0,b.useEffect)(()=>{U&&F.current?.focus()},[U]),(0,b.useEffect)(()=>{if(!B){D(null);return}let e=!1,t=null,n=0,r=()=>{let i=a(`/api/browser/stream`);N.current=i,i.onmessage=e=>{try{let t=JSON.parse(String(e.data));t.type===`frame`&&t.data&&(n=0,D(`data:image/jpeg;base64,${t.data}`))}catch{}},i.onclose=()=>{if(N.current===i&&(N.current=null),e)return;let a=Math.min(1e3*2**n,1e4);n+=1,t=setTimeout(r,a)}};return r(),()=>{e=!0,t&&clearTimeout(t),N.current?.close(),N.current=null}},[B]);let G=(0,b.useCallback)(async e=>{A(!0),M(null);try{await e(),await W()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[W]),K=()=>G(()=>i(`/api/browser/start`,{url:g.trim()||void 0})),q=()=>G(()=>i(`/api/browser/stop`)),J=()=>{let e=g.trim();if(!e)return;let t=/^[a-z]+:\/\//i.test(e)?e:`https://${e}`;return G(()=>i(`/api/browser/navigate`,{url:t}))},Y=e=>G(()=>i(`/api/browser/${e}`)),ne=()=>G(()=>i(`/api/browser/screenshot`)),X=e=>G(()=>i(`/api/browser/control`,{controller:e})),Z=e=>{let t=N.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},re=e=>{let t=P.current;if(!t)return null;let n=t.getBoundingClientRect();return n.width===0||n.height===0?null:{x:Math.round((e.clientX-n.left)/n.width*S.width),y:Math.round((e.clientY-n.top)/n.height*S.height)}},Q=(e,t,n={})=>{if(!U)return;let r=re(e);r&&(e.preventDefault(),Z({type:`input_mouse`,eventType:t,...r,button:T[e.button]??`left`,clickCount:e.detail||1,modifiers:w(e),...n}))},ie=e=>{let t=performance.now();t-z.current<33||(z.current=t,Q(e,`mouseMoved`))},ae=e=>{let t=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!t)return null;let n=[];return e.ctrlKey&&n.push(`Control`),e.shiftKey&&n.push(`Shift`),e.altKey&&n.push(`Alt`),e.metaKey&&n.push(`Meta`),n.push(e.key===` `?`Space`:e.key),n.join(`+`)},$=(e,t)=>{if(!U)return;e.preventDefault();let n=ae(e);if(n){t===`keyDown`&&i(`/api/browser/key`,{key:n}).catch(()=>{});return}Z({type:`input_keyboard`,eventType:t,key:e.key,code:e.code,text:t===`keyDown`?e.key:void 0,modifiers:w(e)})};return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3 p-4`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`back`),children:(0,x.jsx)(h,{})}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`forward`),children:(0,x.jsx)(ee,{})}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:()=>Y(`reload`),children:(0,x.jsx)(l,{})})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,x.jsx)(m,{placeholder:`https://example.com`,value:g,onChange:e=>y(e.target.value),onFocus:()=>R.current=!0,onBlur:()=>R.current=!1,onKeyDown:e=>{e.key===`Enter`&&(V?J:K)()}}),(0,x.jsx)(p,{size:`sm`,variant:`outline`,disabled:k||g.trim().length===0,onClick:()=>V?J():K(),children:`Go`})]}),(0,x.jsx)(p,{size:`icon-sm`,variant:`outline`,disabled:!V||k,onClick:ne,title:`Screenshot → workspace/screenshots`,children:(0,x.jsx)(_,{})}),(0,x.jsx)(`div`,{className:`flex items-center rounded-md border p-0.5`,children:C.map(({value:e,label:t,icon:n})=>(0,x.jsxs)(p,{size:`sm`,variant:H===e?`secondary`:`ghost`,className:`h-7 gap-1.5 px-2`,disabled:k,onClick:()=>X(e),children:[(0,x.jsx)(n,{className:`size-3.5`}),t]},e))}),V?(0,x.jsxs)(p,{size:`sm`,variant:`outline`,className:`text-destructive hover:text-destructive`,disabled:k,onClick:q,children:[(0,x.jsx)(u,{className:`size-3.5`}),` Stop`]}):(0,x.jsxs)(p,{size:`sm`,disabled:k,onClick:K,children:[(0,x.jsx)(c,{className:`size-3.5`}),` Start`]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:o(`inline-block size-2 rounded-full`,V?`bg-emerald-500`:`bg-neutral-300`)}),V?e?.title||e?.url||`Browser running`:`Browser stopped`,U&&V&&(0,x.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 font-medium text-primary`,children:`You have control — click the page and type`})]}),j&&(0,x.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:j}),(0,x.jsx)(`div`,{ref:I,className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,x.jsxs)(`div`,{ref:F,style:O?{width:O.w,height:O.h}:void 0,className:o(`group relative flex items-center justify-center overflow-hidden rounded-lg border bg-neutral-950/95 outline-none`,U&&`ring-2 ring-primary/60`),tabIndex:0,onMouseDown:()=>{U&&F.current?.focus()},onKeyDown:e=>$(e,`keyDown`),onKeyUp:e=>$(e,`keyUp`),children:[E?(0,x.jsx)(`img`,{ref:P,src:E,alt:`Browser viewport`,draggable:!1,className:o(`h-full w-full select-none object-contain`,U?`cursor-crosshair`:`cursor-default`),onMouseDown:e=>Q(e,`mousePressed`),onMouseUp:e=>Q(e,`mouseReleased`),onMouseMove:ie,onContextMenu:e=>U&&e.preventDefault(),onWheel:e=>Q(e,`mouseWheel`,{deltaX:e.deltaX,deltaY:e.deltaY})}):(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-sm text-neutral-400`,children:[(0,x.jsx)(d,{className:`size-8`}),V?`Waiting for viewport frames…`:`Start the browser to see the live viewport.`]}),!U&&E&&(0,x.jsx)(`div`,{className:`absolute inset-0 flex items-end justify-center pb-4 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,x.jsxs)(p,{size:`sm`,className:`shadow-lg`,onClick:()=>X(`user`),children:[(0,x.jsx)(v,{className:`size-3.5`}),` Take control`]})})]})})]}),(0,x.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l`,children:[(0,x.jsx)(`div`,{className:`border-b px-3 py-2 text-sm font-semibold`,children:`Action log`}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-2`,children:[n.map(e=>(0,x.jsxs)(`div`,{className:`rounded-md px-2 py-1.5 text-xs hover:bg-muted/60`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.kind}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()})]}),e.detail&&(0,x.jsx)(`div`,{className:`truncate text-muted-foreground`,title:e.detail,children:e.detail})]},e.id)),n.length===0&&(0,x.jsx)(`p`,{className:`px-2 py-4 text-xs text-muted-foreground`,children:`No actions yet. Start the browser or navigate somewhere.`})]})]})]})}export{E as BrowserPage};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{I as r,t as i}from"./utils-BX1Diber.js";import{tn as a}from"./index-j386AZTn.js";import{t as o}from"./button-Cg-0y2B2.js";import{t as s}from"./badge-DjyNiZCE.js";var c=e(t(),1),l=n();function u({className:e,size:t=`default`,...n}){return(0,l.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:i(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function d({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-header`,className:i(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function f({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-title`,className:i(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function p({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-description`,className:i(`text-sm text-muted-foreground`,e),...t})}function m({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-content`,className:i(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}function h(){let[e,t]=(0,c.useState)(null),[n,i]=(0,c.useState)(null);return(0,c.useEffect)(()=>{r(`/api/status`).then(t).catch(()=>{}),r(`/api/runs`).then(({runs:e})=>i(e.filter(e=>[`queued`,`starting`,`running`,`waiting_approval`].includes(e.status)).length)).catch(()=>{})},[]),(0,l.jsxs)(`div`,{className:`page`,children:[(0,l.jsx)(`h1`,{children:`Dashboard`}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsxs)(f,{className:`flex items-center justify-between`,children:[`Daemon`,(0,l.jsx)(s,{variant:e?`default`:`destructive`,children:e?`online`:`offline`})]}),(0,l.jsx)(p,{children:`Local Jun control plane`})]}),(0,l.jsx)(m,{className:`text-sm text-muted-foreground`,children:e?(0,l.jsxs)(`p`,{className:`truncate`,title:e.workspaceRoot,children:[`project `,(0,l.jsx)(`span`,{className:`text-foreground`,children:e.projectId}),` · up `,e.uptimeSeconds,`s`]}):(0,l.jsx)(`p`,{children:`Waiting for daemon…`})})]}),(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsxs)(f,{className:`flex items-center justify-between`,children:[`Codex runs`,n!==null&&(0,l.jsxs)(s,{variant:n>0?`default`:`secondary`,children:[n,` active`]})]}),(0,l.jsx)(p,{children:`Agent activity in this workspace`})]}),(0,l.jsx)(m,{children:(0,l.jsx)(o,{size:`sm`,render:(0,l.jsx)(a,{to:`/runs`}),children:`Open Runs`})})]}),(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsx)(f,{children:`Dynamic widgets`}),(0,l.jsx)(p,{children:`JSON Render widgets arrive in Phase 7 — this grid is their home.`})]}),(0,l.jsx)(m,{children:(0,l.jsx)(o,{variant:`secondary`,size:`sm`,render:(0,l.jsx)(a,{to:`/files`}),children:`Browse workspace`})})]})]})]})}export{h as DashboardPage};
1
+ import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{I as r,t as i}from"./utils-BX1Diber.js";import{tn as a}from"./index-DXYsuK0q.js";import{t as o}from"./button-Cg-0y2B2.js";import{t as s}from"./badge-DjyNiZCE.js";var c=e(t(),1),l=n();function u({className:e,size:t=`default`,...n}){return(0,l.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:i(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function d({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-header`,className:i(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function f({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-title`,className:i(`text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function p({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-description`,className:i(`text-sm text-muted-foreground`,e),...t})}function m({className:e,...t}){return(0,l.jsx)(`div`,{"data-slot":`card-content`,className:i(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}function h(){let[e,t]=(0,c.useState)(null),[n,i]=(0,c.useState)(null);return(0,c.useEffect)(()=>{r(`/api/status`).then(t).catch(()=>{}),r(`/api/runs`).then(({runs:e})=>i(e.filter(e=>[`queued`,`starting`,`running`,`waiting_approval`].includes(e.status)).length)).catch(()=>{})},[]),(0,l.jsxs)(`div`,{className:`page`,children:[(0,l.jsx)(`h1`,{children:`Dashboard`}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:[(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsxs)(f,{className:`flex items-center justify-between`,children:[`Daemon`,(0,l.jsx)(s,{variant:e?`default`:`destructive`,children:e?`online`:`offline`})]}),(0,l.jsx)(p,{children:`Local Jun control plane`})]}),(0,l.jsx)(m,{className:`text-sm text-muted-foreground`,children:e?(0,l.jsxs)(`p`,{className:`truncate`,title:e.workspaceRoot,children:[`project `,(0,l.jsx)(`span`,{className:`text-foreground`,children:e.projectId}),` · up `,e.uptimeSeconds,`s`]}):(0,l.jsx)(`p`,{children:`Waiting for daemon…`})})]}),(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsxs)(f,{className:`flex items-center justify-between`,children:[`Codex runs`,n!==null&&(0,l.jsxs)(s,{variant:n>0?`default`:`secondary`,children:[n,` active`]})]}),(0,l.jsx)(p,{children:`Agent activity in this workspace`})]}),(0,l.jsx)(m,{children:(0,l.jsx)(o,{size:`sm`,render:(0,l.jsx)(a,{to:`/runs`}),children:`Open Runs`})})]}),(0,l.jsxs)(u,{children:[(0,l.jsxs)(d,{children:[(0,l.jsx)(f,{children:`Dynamic widgets`}),(0,l.jsx)(p,{children:`JSON Render widgets arrive in Phase 7 — this grid is their home.`})]}),(0,l.jsx)(m,{children:(0,l.jsx)(o,{variant:`secondary`,size:`sm`,render:(0,l.jsx)(a,{to:`/files`}),children:`Browse workspace`})})]})]})]})}export{h as DashboardPage};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{B as r,H as i,I as a,L as o,V as s,t as c,z as l}from"./utils-BX1Diber.js";import{x as u}from"./useBaseUiId-dSIElxm7.js";import{i as d,n as f,r as p,t as m}from"./collapsible-BdLJt-lG.js";import{Xt as h,en as ee}from"./index-j386AZTn.js";var g=u(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),_=u(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),v=e(t(),1),y=n(),b=(0,v.createContext)({expandedPaths:new Set,togglePath:()=>{}}),x=({expanded:e,defaultExpanded:t=new Set,selectedPath:n,onSelect:r,onExpandedChange:i,className:a,children:o,...s})=>{let[l,u]=(0,v.useState)(t),d=e??l,f=(0,v.useCallback)(e=>{let t=new Set(d);t.has(e)?t.delete(e):t.add(e),u(t),i?.(t)},[d,i]),p=(0,v.useMemo)(()=>({expandedPaths:d,onSelect:r,selectedPath:n,togglePath:f}),[d,r,n,f]);return(0,y.jsx)(b.Provider,{value:p,children:(0,y.jsx)(`div`,{className:c(`rounded-lg border bg-background font-mono text-sm`,a),role:`tree`,...s,children:(0,y.jsx)(`div`,{className:`p-2`,children:o})})})},S=({className:e,children:t,...n})=>(0,y.jsx)(`span`,{className:c(`shrink-0`,e),...n,children:t}),C=({className:e,children:t,...n})=>(0,y.jsx)(`span`,{className:c(`truncate`,e),...n,children:t}),w=(0,v.createContext)({isExpanded:!1,name:``,path:``}),T=({path:e,name:t,className:n,children:r,...i})=>{let{expandedPaths:a,togglePath:o,selectedPath:s,onSelect:l}=(0,v.useContext)(b),u=a.has(e),ee=s===e,g=(0,v.useCallback)(()=>{o(e)},[o,e]),x=(0,v.useCallback)(()=>{l?.(e)},[l,e]),T=(0,v.useMemo)(()=>({isExpanded:u,name:t,path:e}),[u,t,e]);return(0,y.jsx)(w.Provider,{value:T,children:(0,y.jsx)(m,{onOpenChange:g,open:u,children:(0,y.jsxs)(`div`,{className:c(``,n),role:`treeitem`,tabIndex:0,...i,children:[(0,y.jsxs)(`div`,{className:c(`flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors hover:bg-muted/50`,ee&&`bg-muted`),children:[(0,y.jsx)(p,{className:`flex shrink-0 cursor-pointer items-center border-none bg-transparent p-0`,children:(0,y.jsx)(d,{className:c(`size-4 shrink-0 text-muted-foreground transition-transform`,u&&`rotate-90`)})}),(0,y.jsxs)(`button`,{className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-none bg-transparent p-0 text-left`,onClick:x,type:`button`,children:[(0,y.jsx)(S,{children:u?(0,y.jsx)(h,{className:`size-4`}):(0,y.jsx)(_,{className:`size-4`})}),(0,y.jsx)(C,{children:t})]})]}),(0,y.jsx)(f,{children:(0,y.jsx)(`div`,{className:`ml-4 border-l pl-2`,children:r})})]})})})},E=(0,v.createContext)({name:``,path:``}),D=({path:e,name:t,icon:n,className:r,children:i,...a})=>{let{selectedPath:o,onSelect:s}=(0,v.useContext)(b),l=o===e,u=(0,v.useCallback)(()=>{s?.(e)},[s,e]),d=(0,v.useCallback)(t=>{(t.key===`Enter`||t.key===` `)&&s?.(e)},[s,e]),f=(0,v.useMemo)(()=>({name:t,path:e}),[t,e]);return(0,y.jsx)(E.Provider,{value:f,children:(0,y.jsx)(`div`,{className:c(`flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors hover:bg-muted/50`,l&&`bg-muted`,r),onClick:u,onKeyDown:d,role:`treeitem`,tabIndex:0,...a,children:i??(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{className:`size-4 shrink-0`}),(0,y.jsx)(S,{children:n??(0,y.jsx)(g,{className:`size-4 text-muted-foreground`})}),(0,y.jsx)(C,{children:t})]})})})};function te({root:e,selectedPath:t,expanded:n,onSelect:r,onToggle:i}){let a=new Map;return ne(e,a),(0,y.jsx)(x,{className:`ai-file-tree`,expanded:n,selectedPath:t??void 0,onExpandedChange:e=>{let t=re(n,e);t&&i(t)},onSelect:e=>{let t=a.get(e);t&&r(t)},children:(e.children??[]).map(e=>(0,y.jsx)(O,{node:e},e.path))})}function O({node:e}){return e.type===`dir`?(0,y.jsx)(T,{name:e.name,path:e.path,children:(e.children??[]).map(e=>(0,y.jsx)(O,{node:e},e.path))}):(0,y.jsx)(D,{name:e.name,path:e.path})}function ne(e,t){t.set(e.path,e);for(let n of e.children??[])ne(n,t)}function re(e,t){for(let n of t)if(!e.has(n))return n;for(let n of e)if(!t.has(n))return n;return null}function k(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A=k();function ie(e){A=e}var j={exec:()=>null};function M(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function N(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(P.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ae=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),P={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:M(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:M(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:M(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:M(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:M(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:M(e=>RegExp(`^ {0,${e}}>`))},oe=/^(?:[ \t]*(?:\n|$))+/,se=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ce=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=N(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=N(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,I=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ge=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,I).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_e=N(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),L=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,R=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ve=N(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,R).replace(`tag`,L).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye=N(me).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex(),z={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ye).getRegex(),code:se,def:ge,fences:ce,heading:le,hr:F,html:ve,lheading:fe,list:_e,newline:oe,paragraph:ye,table:j,text:he},be=N(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex(),xe={...z,lheading:pe,table:be,paragraph:N(me).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,be).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex()},Se={...z,html:N(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,R).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:j,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(me).replace(`hr`,F).replace(`heading`,` *#{1,6} *[^
1
+ import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{B as r,H as i,I as a,L as o,V as s,t as c,z as l}from"./utils-BX1Diber.js";import{x as u}from"./useBaseUiId-dSIElxm7.js";import{i as d,n as f,r as p,t as m}from"./collapsible-0tqcZUWD.js";import{Xt as h,en as ee}from"./index-DXYsuK0q.js";var g=u(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),_=u(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),v=e(t(),1),y=n(),b=(0,v.createContext)({expandedPaths:new Set,togglePath:()=>{}}),x=({expanded:e,defaultExpanded:t=new Set,selectedPath:n,onSelect:r,onExpandedChange:i,className:a,children:o,...s})=>{let[l,u]=(0,v.useState)(t),d=e??l,f=(0,v.useCallback)(e=>{let t=new Set(d);t.has(e)?t.delete(e):t.add(e),u(t),i?.(t)},[d,i]),p=(0,v.useMemo)(()=>({expandedPaths:d,onSelect:r,selectedPath:n,togglePath:f}),[d,r,n,f]);return(0,y.jsx)(b.Provider,{value:p,children:(0,y.jsx)(`div`,{className:c(`rounded-lg border bg-background font-mono text-sm`,a),role:`tree`,...s,children:(0,y.jsx)(`div`,{className:`p-2`,children:o})})})},S=({className:e,children:t,...n})=>(0,y.jsx)(`span`,{className:c(`shrink-0`,e),...n,children:t}),C=({className:e,children:t,...n})=>(0,y.jsx)(`span`,{className:c(`truncate`,e),...n,children:t}),w=(0,v.createContext)({isExpanded:!1,name:``,path:``}),T=({path:e,name:t,className:n,children:r,...i})=>{let{expandedPaths:a,togglePath:o,selectedPath:s,onSelect:l}=(0,v.useContext)(b),u=a.has(e),ee=s===e,g=(0,v.useCallback)(()=>{o(e)},[o,e]),x=(0,v.useCallback)(()=>{l?.(e)},[l,e]),T=(0,v.useMemo)(()=>({isExpanded:u,name:t,path:e}),[u,t,e]);return(0,y.jsx)(w.Provider,{value:T,children:(0,y.jsx)(m,{onOpenChange:g,open:u,children:(0,y.jsxs)(`div`,{className:c(``,n),role:`treeitem`,tabIndex:0,...i,children:[(0,y.jsxs)(`div`,{className:c(`flex w-full items-center gap-1 rounded px-2 py-1 text-left transition-colors hover:bg-muted/50`,ee&&`bg-muted`),children:[(0,y.jsx)(p,{className:`flex shrink-0 cursor-pointer items-center border-none bg-transparent p-0`,children:(0,y.jsx)(d,{className:c(`size-4 shrink-0 text-muted-foreground transition-transform`,u&&`rotate-90`)})}),(0,y.jsxs)(`button`,{className:`flex min-w-0 flex-1 cursor-pointer items-center gap-1 border-none bg-transparent p-0 text-left`,onClick:x,type:`button`,children:[(0,y.jsx)(S,{children:u?(0,y.jsx)(h,{className:`size-4`}):(0,y.jsx)(_,{className:`size-4`})}),(0,y.jsx)(C,{children:t})]})]}),(0,y.jsx)(f,{children:(0,y.jsx)(`div`,{className:`ml-4 border-l pl-2`,children:r})})]})})})},E=(0,v.createContext)({name:``,path:``}),D=({path:e,name:t,icon:n,className:r,children:i,...a})=>{let{selectedPath:o,onSelect:s}=(0,v.useContext)(b),l=o===e,u=(0,v.useCallback)(()=>{s?.(e)},[s,e]),d=(0,v.useCallback)(t=>{(t.key===`Enter`||t.key===` `)&&s?.(e)},[s,e]),f=(0,v.useMemo)(()=>({name:t,path:e}),[t,e]);return(0,y.jsx)(E.Provider,{value:f,children:(0,y.jsx)(`div`,{className:c(`flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition-colors hover:bg-muted/50`,l&&`bg-muted`,r),onClick:u,onKeyDown:d,role:`treeitem`,tabIndex:0,...a,children:i??(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{className:`size-4 shrink-0`}),(0,y.jsx)(S,{children:n??(0,y.jsx)(g,{className:`size-4 text-muted-foreground`})}),(0,y.jsx)(C,{children:t})]})})})};function te({root:e,selectedPath:t,expanded:n,onSelect:r,onToggle:i}){let a=new Map;return ne(e,a),(0,y.jsx)(x,{className:`ai-file-tree`,expanded:n,selectedPath:t??void 0,onExpandedChange:e=>{let t=re(n,e);t&&i(t)},onSelect:e=>{let t=a.get(e);t&&r(t)},children:(e.children??[]).map(e=>(0,y.jsx)(O,{node:e},e.path))})}function O({node:e}){return e.type===`dir`?(0,y.jsx)(T,{name:e.name,path:e.path,children:(e.children??[]).map(e=>(0,y.jsx)(O,{node:e},e.path))}):(0,y.jsx)(D,{name:e.name,path:e.path})}function ne(e,t){t.set(e.path,e);for(let n of e.children??[])ne(n,t)}function re(e,t){for(let n of t)if(!e.has(n))return n;for(let n of e)if(!t.has(n))return n;return null}function k(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A=k();function ie(e){A=e}var j={exec:()=>null};function M(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function N(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(P.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ae=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),P={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:M(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:M(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:M(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:M(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:M(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:M(e=>RegExp(`^ {0,${e}}>`))},oe=/^(?:[ \t]*(?:\n|$))+/,se=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ce=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=N(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=N(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,I=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ge=N(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,I).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),_e=N(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),L=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,R=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ve=N(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,R).replace(`tag`,L).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye=N(me).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex(),z={blockquote:N(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ye).getRegex(),code:se,def:ge,fences:ce,heading:le,hr:F,html:ve,lheading:fe,list:_e,newline:oe,paragraph:ye,table:j,text:he},be=N(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex(),xe={...z,lheading:pe,table:be,paragraph:N(me).replace(`hr`,F).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,be).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,L).getRegex()},Se={...z,html:N(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,R).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:j,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:N(me).replace(`hr`,F).replace(`heading`,` *#{1,6} *[^
2
2
  ]`).replace(`lheading`,fe).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Ce=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,we=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Te=/^( {2,}|\\)\n(?!\s*$)/,Ee=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,B=/[\p{P}\p{S}]/u,V=/[\s\p{P}\p{S}]/u,De=/[^\s\p{P}\p{S}]/u,Oe=N(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,V).getRegex(),ke=/(?!~)[\p{P}\p{S}]/u,Ae=/(?!~)[\s\p{P}\p{S}]/u,je=/(?:[^\s\p{P}\p{S}]|~)/u,Me=N(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ae?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Ne=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Pe=N(Ne,`u`).replace(/punct/g,B).getRegex(),Fe=N(Ne,`u`).replace(/punct/g,ke).getRegex(),Ie=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Le=N(Ie,`gu`).replace(/notPunctSpace/g,De).replace(/punctSpace/g,V).replace(/punct/g,B).getRegex(),Re=N(Ie,`gu`).replace(/notPunctSpace/g,je).replace(/punctSpace/g,Ae).replace(/punct/g,ke).getRegex(),ze=N(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,De).replace(/punctSpace/g,V).replace(/punct/g,B).getRegex(),Be=N(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,B).getRegex(),Ve=N(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,De).replace(/punctSpace/g,V).replace(/punct/g,B).getRegex(),He=N(/\\(punct)/,`gu`).replace(/punct/g,B).getRegex(),Ue=N(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),We=N(R).replace(`(?:-->|$)`,`-->`).getRegex(),Ge=N(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,We).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),H=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Ke=N(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,H).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qe=N(/^!?\[(label)\]\[(ref)\]/).replace(`label`,H).replace(`ref`,I).getRegex(),Je=N(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,I).getRegex(),Ye=N(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,qe).replace(`nolink`,Je).getRegex(),Xe=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ze={_backpedal:j,anyPunctuation:He,autolink:Ue,blockSkip:Me,br:Te,code:we,del:j,delLDelim:j,delRDelim:j,emStrongLDelim:Pe,emStrongRDelimAst:Le,emStrongRDelimUnd:ze,escape:Ce,link:Ke,nolink:Je,punctuation:Oe,reflink:qe,reflinkSearch:Ye,tag:Ge,text:Ee,url:j},Qe={...Ze,link:N(/^!?\[(label)\]\((.*?)\)/).replace(`label`,H).getRegex(),reflink:N(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,H).getRegex()},$e={...Ze,emStrongRDelimAst:Re,emStrongLDelim:Fe,delLDelim:Be,delRDelim:Ve,url:N(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Xe).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:N(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Xe).getRegex()},et={...$e,br:N(Te).replace(`{2,}`,`*`).getRegex(),text:N($e.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},U={normal:z,gfm:xe,pedantic:Se},W={normal:Ze,gfm:$e,breaks:et,pedantic:Qe},tt={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},nt=e=>tt[e];function G(e,t){if(t){if(P.escapeTest.test(e))return e.replace(P.escapeReplace,nt)}else if(P.escapeTestNoEncode.test(e))return e.replace(P.escapeReplaceNoEncode,nt);return e}function rt(e){try{e=encodeURI(e).replace(P.percentDecode,`%`)}catch{return null}return e}function it(e,t){let n=e.replace(P.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(P.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(P.slashPipe,`|`);return n}function K(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function at(e){let t=e.split(`
3
3
  `),n=t.length-1;for(;n>=0&&P.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
4
4
  `)}function ot(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function st(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function ct(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function lt(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -1 +1 @@
1
- import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{F as r,I as i,L as a,R as o,t as s}from"./utils-BX1Diber.js";import{x as c}from"./useBaseUiId-dSIElxm7.js";import{i as l,n as u,r as d,t as f}from"./collapsible-BdLJt-lG.js";import{t as p}from"./circle-x-BSTd_gmE.js";import{t as m}from"./key-round-D965pLEl.js";import{a as h,i as g,n as _,r as v,t as y}from"./tabs-DS9zR4V0.js";import{E as b}from"./useCompositeListItem-BQ4RLkNZ.js";import{t as x}from"./rotate-cw-B1ZRM7VI.js";import{n as S,t as C}from"./textarea-BkUbRqKD.js";import{a as w,i as T,o as E,r as D,s as O,t as k}from"./dialog-Bl8-9u35.js";import{qt as A}from"./index-j386AZTn.js";import{t as j}from"./button-Cg-0y2B2.js";import{t as M}from"./input-D4O22yGt.js";import{t as N}from"./badge-DjyNiZCE.js";import{t as P}from"./label-CxX4-RmK.js";var F=c(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),I=c(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),L=e(t(),1),R=n();function z({server:e}){if(!e.enabled)return(0,R.jsx)(N,{variant:`outline`,children:`disabled`});switch(e.startupState){case`ready`:return(0,R.jsxs)(N,{variant:`secondary`,className:`gap-1`,children:[(0,R.jsx)(F,{className:`size-3 text-emerald-600`}),` ready`]});case`starting`:return(0,R.jsxs)(N,{variant:`secondary`,className:`gap-1`,children:[(0,R.jsx)(h,{className:`size-3 animate-spin`}),` starting`]});case`failed`:case`cancelled`:return(0,R.jsxs)(N,{variant:`outline`,className:`gap-1 text-destructive`,children:[(0,R.jsx)(p,{className:`size-3`}),` `,e.startupState]});default:return(0,R.jsxs)(N,{variant:`outline`,className:`gap-1`,children:[(0,R.jsx)(I,{className:`size-3`}),` not connected`]})}}function B(){let[e,t]=(0,L.useState)([]),[n,c]=(0,L.useState)(``),[p,h]=(0,L.useState)(!1),[w,T]=(0,L.useState)(null),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(null),[M,P]=(0,L.useState)(!1),F=(0,L.useCallback)(async()=>{try{let[{servers:e},{toml:n}]=await Promise.all([i(`/api/mcp`),i(`/api/mcp/config`)]);t(e),p||c(n),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}},[p]);(0,L.useEffect)(()=>{F()},[F]);let I=(0,L.useCallback)(async e=>{D(!0),T(null);try{await e(),await F()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[F]),B=()=>I(()=>a(`/api/mcp/reload`)),H=()=>I(async()=>{await o(`/api/mcp/config`,{toml:n}),h(!1),await a(`/api/mcp/reload`)}),U=e=>I(async()=>{await a(`/api/mcp/servers/${e.name}/enable`,{enabled:!e.enabled}),await a(`/api/mcp/reload`)}),W=e=>I(async()=>{window.confirm(`Remove MCP server "${e}"?`)&&(await r(`/api/mcp/servers/${e}`),await a(`/api/mcp/reload`))});return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold`,children:`MCP servers`}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsxs)(j,{size:`sm`,variant:`outline`,onClick:B,disabled:E,children:[(0,R.jsx)(x,{className:`size-3.5`}),` Reload`]}),(0,R.jsxs)(j,{size:`sm`,onClick:()=>P(!0),disabled:E,children:[(0,R.jsx)(b,{className:`size-3.5`}),` Add server`]})]})]}),w&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:w}),(0,R.jsxs)(y,{defaultValue:`servers`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(v,{children:[(0,R.jsx)(g,{value:`servers`,children:`Servers`}),(0,R.jsx)(g,{value:`toml`,children:`config.toml`})]}),(0,R.jsx)(_,{value:`servers`,className:`min-h-0 flex-1 overflow-auto pt-2`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.map(e=>(0,R.jsx)(`div`,{className:`rounded-lg border bg-card`,children:(0,R.jsxs)(f,{open:O===e.name,onOpenChange:t=>k(t?e.name:null),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,R.jsx)(A,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsx)(z,{server:e}),e.tools.length>0&&(0,R.jsxs)(N,{variant:`outline`,children:[e.tools.length,` tools`]}),e.authStatus===`notLoggedIn`&&(0,R.jsxs)(N,{variant:`outline`,className:`gap-1`,children:[(0,R.jsx)(m,{className:`size-3`}),` login required`]})]}),(0,R.jsx)(`code`,{className:`block truncate text-xs text-muted-foreground`,children:e.url??[e.command,...e.args??[]].join(` `)}),e.envKeys&&e.envKeys.length>0&&(0,R.jsxs)(`div`,{className:`text-xs text-muted-foreground/70`,children:[`env: `,e.envKeys.map(e=>`${e}=••••`).join(` `)]})]}),(0,R.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>U(e),disabled:E,children:e.enabled?`Disable`:`Enable`}),(0,R.jsx)(j,{size:`icon-sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,onClick:()=>W(e.name),disabled:E,children:(0,R.jsx)(S,{})}),e.tools.length>0&&(0,R.jsx)(d,{className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,R.jsx)(l,{className:s(`size-4 transition-transform`,O===e.name&&`rotate-90`)})})]}),(0,R.jsx)(u,{children:(0,R.jsx)(`div`,{className:`grid gap-1 border-t p-3 sm:grid-cols-2`,children:e.tools.map(e=>(0,R.jsxs)(`div`,{className:`rounded-md bg-muted/40 px-2 py-1.5`,children:[(0,R.jsx)(`code`,{className:`text-xs font-medium`,children:e.name}),e.description&&(0,R.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:e.description,children:e.description})]},e.name))})})]})},e.name)),e.length===0&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-12 text-center text-sm text-muted-foreground`,children:[(0,R.jsx)(A,{className:`size-8`}),`No MCP servers configured. Add one to give Codex extra tools.`]})]})}),(0,R.jsxs)(_,{value:`toml`,className:`flex min-h-0 flex-1 flex-col gap-2 pt-2`,children:[(0,R.jsx)(C,{value:n,spellCheck:!1,className:`min-h-0 flex-1 resize-none font-mono text-sm`,onChange:e=>{c(e.target.value),h(!0)}}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(j,{size:`sm`,onClick:H,disabled:!p||E,children:E?`Saving…`:`Save & reload`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Editing here preserves your comments; structured edits reformat the file.`})]})]})]}),(0,R.jsx)(V,{open:M,onOpenChange:P,onAdded:()=>I(()=>a(`/api/mcp/reload`))})]})}function V({open:e,onOpenChange:t,onAdded:n}){let[r,i]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!1);return(0,R.jsx)(k,{open:e,onOpenChange:t,children:(0,R.jsxs)(D,{children:[(0,R.jsxs)(E,{children:[(0,R.jsx)(O,{children:`Add MCP server`}),(0,R.jsxs)(T,{children:[`A stdio command server (e.g. `,(0,R.jsx)(`code`,{children:`npx -y @scope/pkg`}),`). For URL or advanced transports, use the config.toml tab.`]})]}),f&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:f}),(0,R.jsxs)(`div`,{className:`grid gap-3`,children:[(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-name`,children:`Name`}),(0,R.jsx)(M,{id:`mcp-name`,value:r,placeholder:`context7`,onChange:e=>i(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(M,{id:`mcp-command`,value:o,placeholder:`npx`,onChange:e=>s(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-args`,children:`Args (space-separated)`}),(0,R.jsx)(M,{id:`mcp-args`,value:c,placeholder:`-y @upstash/context7-mcp`,onChange:e=>l(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-env`,children:`Env (KEY=value per line)`}),(0,R.jsx)(C,{id:`mcp-env`,value:u,rows:3,placeholder:`API_KEY=sk-…`,onChange:e=>d(e.target.value)})]})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(j,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(j,{onClick:async()=>{h(!0),p(null);try{let e={};for(let t of u.split(/\r?\n/)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}await a(`/api/mcp/servers`,{name:r.trim(),command:o.trim()||void 0,args:c.trim()?c.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0}),t(!1),i(``),s(``),l(``),d(``),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{h(!1)}},disabled:m||r.trim().length===0||o.trim().length===0,children:m?`Adding…`:`Add & reload`})]})]})})}export{B as McpPage};
1
+ import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{F as r,I as i,L as a,R as o,t as s}from"./utils-BX1Diber.js";import{x as c}from"./useBaseUiId-dSIElxm7.js";import{i as l,n as u,r as d,t as f}from"./collapsible-0tqcZUWD.js";import{t as p}from"./circle-x-BSTd_gmE.js";import{t as m}from"./key-round-D965pLEl.js";import{a as h,i as g,n as _,r as v,t as y}from"./tabs-BUCI-mwA.js";import{E as b}from"./useCompositeListItem-BMeUcGkY.js";import{t as x}from"./rotate-cw-B1ZRM7VI.js";import{n as S,t as C}from"./textarea-BkUbRqKD.js";import{a as w,i as T,o as E,r as D,s as O,t as k}from"./dialog-gLEpdaG1.js";import{qt as A}from"./index-DXYsuK0q.js";import{t as j}from"./button-Cg-0y2B2.js";import{t as M}from"./input-BPTmfk5i.js";import{t as N}from"./badge-DjyNiZCE.js";import{t as P}from"./label-CxX4-RmK.js";var F=c(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),I=c(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),L=e(t(),1),R=n();function z({server:e}){if(!e.enabled)return(0,R.jsx)(N,{variant:`outline`,children:`disabled`});switch(e.startupState){case`ready`:return(0,R.jsxs)(N,{variant:`secondary`,className:`gap-1`,children:[(0,R.jsx)(F,{className:`size-3 text-emerald-600`}),` ready`]});case`starting`:return(0,R.jsxs)(N,{variant:`secondary`,className:`gap-1`,children:[(0,R.jsx)(h,{className:`size-3 animate-spin`}),` starting`]});case`failed`:case`cancelled`:return(0,R.jsxs)(N,{variant:`outline`,className:`gap-1 text-destructive`,children:[(0,R.jsx)(p,{className:`size-3`}),` `,e.startupState]});default:return(0,R.jsxs)(N,{variant:`outline`,className:`gap-1`,children:[(0,R.jsx)(I,{className:`size-3`}),` not connected`]})}}function B(){let[e,t]=(0,L.useState)([]),[n,c]=(0,L.useState)(``),[p,h]=(0,L.useState)(!1),[w,T]=(0,L.useState)(null),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(null),[M,P]=(0,L.useState)(!1),F=(0,L.useCallback)(async()=>{try{let[{servers:e},{toml:n}]=await Promise.all([i(`/api/mcp`),i(`/api/mcp/config`)]);t(e),p||c(n),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}},[p]);(0,L.useEffect)(()=>{F()},[F]);let I=(0,L.useCallback)(async e=>{D(!0),T(null);try{await e(),await F()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[F]),B=()=>I(()=>a(`/api/mcp/reload`)),H=()=>I(async()=>{await o(`/api/mcp/config`,{toml:n}),h(!1),await a(`/api/mcp/reload`)}),U=e=>I(async()=>{await a(`/api/mcp/servers/${e.name}/enable`,{enabled:!e.enabled}),await a(`/api/mcp/reload`)}),W=e=>I(async()=>{window.confirm(`Remove MCP server "${e}"?`)&&(await r(`/api/mcp/servers/${e}`),await a(`/api/mcp/reload`))});return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`h1`,{className:`text-base font-semibold`,children:`MCP servers`}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsxs)(j,{size:`sm`,variant:`outline`,onClick:B,disabled:E,children:[(0,R.jsx)(x,{className:`size-3.5`}),` Reload`]}),(0,R.jsxs)(j,{size:`sm`,onClick:()=>P(!0),disabled:E,children:[(0,R.jsx)(b,{className:`size-3.5`}),` Add server`]})]})]}),w&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:w}),(0,R.jsxs)(y,{defaultValue:`servers`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(v,{children:[(0,R.jsx)(g,{value:`servers`,children:`Servers`}),(0,R.jsx)(g,{value:`toml`,children:`config.toml`})]}),(0,R.jsx)(_,{value:`servers`,className:`min-h-0 flex-1 overflow-auto pt-2`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.map(e=>(0,R.jsx)(`div`,{className:`rounded-lg border bg-card`,children:(0,R.jsxs)(f,{open:O===e.name,onOpenChange:t=>k(t?e.name:null),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 p-3`,children:[(0,R.jsx)(A,{className:`size-4 shrink-0 text-muted-foreground`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,R.jsx)(z,{server:e}),e.tools.length>0&&(0,R.jsxs)(N,{variant:`outline`,children:[e.tools.length,` tools`]}),e.authStatus===`notLoggedIn`&&(0,R.jsxs)(N,{variant:`outline`,className:`gap-1`,children:[(0,R.jsx)(m,{className:`size-3`}),` login required`]})]}),(0,R.jsx)(`code`,{className:`block truncate text-xs text-muted-foreground`,children:e.url??[e.command,...e.args??[]].join(` `)}),e.envKeys&&e.envKeys.length>0&&(0,R.jsxs)(`div`,{className:`text-xs text-muted-foreground/70`,children:[`env: `,e.envKeys.map(e=>`${e}=••••`).join(` `)]})]}),(0,R.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>U(e),disabled:E,children:e.enabled?`Disable`:`Enable`}),(0,R.jsx)(j,{size:`icon-sm`,variant:`ghost`,className:`text-destructive hover:text-destructive`,onClick:()=>W(e.name),disabled:E,children:(0,R.jsx)(S,{})}),e.tools.length>0&&(0,R.jsx)(d,{className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted`,children:(0,R.jsx)(l,{className:s(`size-4 transition-transform`,O===e.name&&`rotate-90`)})})]}),(0,R.jsx)(u,{children:(0,R.jsx)(`div`,{className:`grid gap-1 border-t p-3 sm:grid-cols-2`,children:e.tools.map(e=>(0,R.jsxs)(`div`,{className:`rounded-md bg-muted/40 px-2 py-1.5`,children:[(0,R.jsx)(`code`,{className:`text-xs font-medium`,children:e.name}),e.description&&(0,R.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:e.description,children:e.description})]},e.name))})})]})},e.name)),e.length===0&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-12 text-center text-sm text-muted-foreground`,children:[(0,R.jsx)(A,{className:`size-8`}),`No MCP servers configured. Add one to give Codex extra tools.`]})]})}),(0,R.jsxs)(_,{value:`toml`,className:`flex min-h-0 flex-1 flex-col gap-2 pt-2`,children:[(0,R.jsx)(C,{value:n,spellCheck:!1,className:`min-h-0 flex-1 resize-none font-mono text-sm`,onChange:e=>{c(e.target.value),h(!0)}}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(j,{size:`sm`,onClick:H,disabled:!p||E,children:E?`Saving…`:`Save & reload`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Editing here preserves your comments; structured edits reformat the file.`})]})]})]}),(0,R.jsx)(V,{open:M,onOpenChange:P,onAdded:()=>I(()=>a(`/api/mcp/reload`))})]})}function V({open:e,onOpenChange:t,onAdded:n}){let[r,i]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(!1);return(0,R.jsx)(k,{open:e,onOpenChange:t,children:(0,R.jsxs)(D,{children:[(0,R.jsxs)(E,{children:[(0,R.jsx)(O,{children:`Add MCP server`}),(0,R.jsxs)(T,{children:[`A stdio command server (e.g. `,(0,R.jsx)(`code`,{children:`npx -y @scope/pkg`}),`). For URL or advanced transports, use the config.toml tab.`]})]}),f&&(0,R.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:f}),(0,R.jsxs)(`div`,{className:`grid gap-3`,children:[(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-name`,children:`Name`}),(0,R.jsx)(M,{id:`mcp-name`,value:r,placeholder:`context7`,onChange:e=>i(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-command`,children:`Command`}),(0,R.jsx)(M,{id:`mcp-command`,value:o,placeholder:`npx`,onChange:e=>s(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-args`,children:`Args (space-separated)`}),(0,R.jsx)(M,{id:`mcp-args`,value:c,placeholder:`-y @upstash/context7-mcp`,onChange:e=>l(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,R.jsx)(P,{htmlFor:`mcp-env`,children:`Env (KEY=value per line)`}),(0,R.jsx)(C,{id:`mcp-env`,value:u,rows:3,placeholder:`API_KEY=sk-…`,onChange:e=>d(e.target.value)})]})]}),(0,R.jsxs)(w,{children:[(0,R.jsx)(j,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(j,{onClick:async()=>{h(!0),p(null);try{let e={};for(let t of u.split(/\r?\n/)){let n=t.indexOf(`=`);n>0&&(e[t.slice(0,n).trim()]=t.slice(n+1).trim())}await a(`/api/mcp/servers`,{name:r.trim(),command:o.trim()||void 0,args:c.trim()?c.trim().split(/\s+/):void 0,env:Object.keys(e).length>0?e:void 0}),t(!1),i(``),s(``),l(``),d(``),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{h(!1)}},disabled:m||r.trim().length===0||o.trim().length===0,children:m?`Adding…`:`Add & reload`})]})]})})}export{B as McpPage};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{F as r,I as i,R as a,t as o}from"./utils-BX1Diber.js";import{t as s}from"./checkbox-Dl42vHZu.js";import{t as c}from"./rotate-cw-B1ZRM7VI.js";import{n as l,t as u}from"./textarea-BkUbRqKD.js";import{Qt as d}from"./index-j386AZTn.js";import{t as f}from"./button-Cg-0y2B2.js";import{t as p}from"./input-D4O22yGt.js";import{t as m}from"./badge-DjyNiZCE.js";import{t as h}from"./label-CxX4-RmK.js";var g=e(t(),1),_=n();function v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function y(){let[e,t]=(0,g.useState)(null),[n,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),A=(0,g.useCallback)(async()=>{try{let e=await i(`/api/memories`);t(e),k(e.settings.minRateLimitRemainingPercent===void 0?``:String(e.settings.minRateLimitRemainingPercent)),y(null)}catch(e){y(e instanceof Error?e.message:String(e))}},[]);(0,g.useEffect)(()=>{A()},[A]);let j=(0,g.useCallback)(async e=>{x(!0),y(null);try{await e(),await A()}catch(e){y(e instanceof Error?e.message:String(e))}finally{x(!1)}},[A]),M=()=>j(()=>a(`/api/memories/config`,{enabled:!e?.enabled})),N=e=>j(()=>a(`/api/memories/config`,{settings:e})),P=()=>{let e=Number(O);if(!Number.isFinite(e)||e<0||e>100){y(`Rate-limit threshold must be a number between 0 and 100`);return}N({minRateLimitRemainingPercent:e})},F=e=>j(async()=>{let t=await i(`/api/memories/file?path=${encodeURIComponent(e.path)}`);C(t.path),T(t.content),D(!1)}),I=()=>j(async()=>{S&&(await a(`/api/memories/file`,{path:S,content:w}),D(!1))}),L=e=>j(async()=>{window.confirm(`Delete memory file "${e}"?`)&&(await r(`/api/memories/file?path=${encodeURIComponent(e)}`),S===e&&(C(null),T(``),D(!1)))}),R=e?.enabled??!1,z=e?.settings??{},B=e?.files??[];return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h1`,{className:`text-base font-semibold`,children:`Memories`}),(0,_.jsx)(m,{variant:`outline`,children:`beta`}),e&&e.liveEnabled!==null&&e.liveEnabled!==R&&(0,_.jsx)(m,{variant:`outline`,className:`text-amber-600`,children:`engine state differs — restart pending`}),(0,_.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,_.jsxs)(f,{size:`sm`,variant:`outline`,onClick:()=>A(),disabled:b,children:[(0,_.jsx)(c,{className:`size-3.5`}),` Refresh`]}),(0,_.jsx)(f,{size:`sm`,onClick:M,disabled:b||!e,children:R?`Disable`:`Enable`})]})]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Codex turns useful context from past sessions into local memory files and brings them into new conversations. Memories are global across workspaces (they live in the shared Codex home) and are generated in the background — new files can take a while to appear.`}),n&&(0,_.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:n}),(0,_.jsxs)(`div`,{className:o(`flex flex-col gap-3`,!R&&`opacity-60`),children:[(0,_.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,_.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`Behavior`}),(0,_.jsxs)(`div`,{className:`grid gap-2`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.generateMemories!==!1,disabled:b||!R,onCheckedChange:e=>N({generateMemories:e===!0})}),`Generate memories from new sessions`]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.useMemories!==!1,disabled:b||!R,onCheckedChange:e=>N({useMemories:e===!0})}),`Use existing memories in new sessions`]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.disableOnExternalContext===!0,disabled:b||!R,onCheckedChange:e=>N({disableOnExternalContext:e===!0})}),`Skip sessions that used external context (MCP tools, web search)`]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(h,{htmlFor:`mem-rate`,className:`font-normal`,children:`Pause generation below`}),(0,_.jsx)(p,{id:`mem-rate`,type:`number`,min:0,max:100,placeholder:`25`,className:`h-7 w-20`,value:O,disabled:b||!R,onChange:e=>k(e.target.value),onBlur:()=>{O!==``&&P()},onKeyDown:e=>{e.key===`Enter`&&O!==``&&P()}}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`% rate limit remaining`})]})]}),(0,_.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:`Behavior settings are read by the engine at startup; the on/off toggle applies immediately.`})]}),(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col gap-1 overflow-auto`,children:[(0,_.jsxs)(`div`,{className:`text-sm font-medium`,children:[`Memory files`,B.length>0&&` (${B.length})`]}),B.map(e=>(0,_.jsxs)(`div`,{className:o(`group flex cursor-pointer items-center gap-2 rounded-md border px-2 py-1.5`,S===e.path?`border-foreground/30 bg-muted/60`:`bg-card hover:bg-muted/40`),onClick:()=>F(e),children:[(0,_.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`div`,{className:`truncate text-sm`,title:e.path,children:e.path}),(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[v(e.size),` · `,new Date(e.modifiedAt).toLocaleString()]})]}),(0,_.jsx)(f,{size:`icon-sm`,variant:`ghost`,className:`invisible text-destructive hover:text-destructive group-hover:visible`,disabled:b,onClick:t=>{t.stopPropagation(),L(e.path)},children:(0,_.jsx)(l,{})})]},e.path)),B.length===0&&(0,_.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-sm text-muted-foreground`,children:[(0,_.jsx)(d,{className:`size-8`}),R?`No memories yet. Codex builds them in the background from finished sessions.`:`Enable memories to let Codex remember context across sessions.`]})]}),(0,_.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2`,children:S?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`code`,{className:`truncate text-xs text-muted-foreground`,children:S}),(0,_.jsx)(f,{size:`sm`,className:`ml-auto`,onClick:I,disabled:!E||b,children:b?`Saving…`:`Save`})]}),(0,_.jsx)(u,{value:w,spellCheck:!1,className:`min-h-0 flex-1 resize-none font-mono text-sm`,onChange:e=>{T(e.target.value),D(!0)}})]}):(0,_.jsx)(`div`,{className:`flex flex-1 items-center justify-center rounded-lg border border-dashed text-sm text-muted-foreground`,children:`Select a memory file to inspect or edit it`})})]})]})]})}export{y as MemoriesPage};
1
+ import{a as e}from"./chunk-Cyuzqnbw.js";import{i as t,r as n}from"./bundle-mjs-DssaXR6m.js";import{F as r,I as i,R as a,t as o}from"./utils-BX1Diber.js";import{t as s}from"./checkbox-BO9cBKlP.js";import{t as c}from"./rotate-cw-B1ZRM7VI.js";import{n as l,t as u}from"./textarea-BkUbRqKD.js";import{Qt as d}from"./index-DXYsuK0q.js";import{t as f}from"./button-Cg-0y2B2.js";import{t as p}from"./input-BPTmfk5i.js";import{t as m}from"./badge-DjyNiZCE.js";import{t as h}from"./label-CxX4-RmK.js";var g=e(t(),1),_=n();function v(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function y(){let[e,t]=(0,g.useState)(null),[n,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),A=(0,g.useCallback)(async()=>{try{let e=await i(`/api/memories`);t(e),k(e.settings.minRateLimitRemainingPercent===void 0?``:String(e.settings.minRateLimitRemainingPercent)),y(null)}catch(e){y(e instanceof Error?e.message:String(e))}},[]);(0,g.useEffect)(()=>{A()},[A]);let j=(0,g.useCallback)(async e=>{x(!0),y(null);try{await e(),await A()}catch(e){y(e instanceof Error?e.message:String(e))}finally{x(!1)}},[A]),M=()=>j(()=>a(`/api/memories/config`,{enabled:!e?.enabled})),N=e=>j(()=>a(`/api/memories/config`,{settings:e})),P=()=>{let e=Number(O);if(!Number.isFinite(e)||e<0||e>100){y(`Rate-limit threshold must be a number between 0 and 100`);return}N({minRateLimitRemainingPercent:e})},F=e=>j(async()=>{let t=await i(`/api/memories/file?path=${encodeURIComponent(e.path)}`);C(t.path),T(t.content),D(!1)}),I=()=>j(async()=>{S&&(await a(`/api/memories/file`,{path:S,content:w}),D(!1))}),L=e=>j(async()=>{window.confirm(`Delete memory file "${e}"?`)&&(await r(`/api/memories/file?path=${encodeURIComponent(e)}`),S===e&&(C(null),T(``),D(!1)))}),R=e?.enabled??!1,z=e?.settings??{},B=e?.files??[];return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3 p-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h1`,{className:`text-base font-semibold`,children:`Memories`}),(0,_.jsx)(m,{variant:`outline`,children:`beta`}),e&&e.liveEnabled!==null&&e.liveEnabled!==R&&(0,_.jsx)(m,{variant:`outline`,className:`text-amber-600`,children:`engine state differs — restart pending`}),(0,_.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,_.jsxs)(f,{size:`sm`,variant:`outline`,onClick:()=>A(),disabled:b,children:[(0,_.jsx)(c,{className:`size-3.5`}),` Refresh`]}),(0,_.jsx)(f,{size:`sm`,onClick:M,disabled:b||!e,children:R?`Disable`:`Enable`})]})]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Codex turns useful context from past sessions into local memory files and brings them into new conversations. Memories are global across workspaces (they live in the shared Codex home) and are generated in the background — new files can take a while to appear.`}),n&&(0,_.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:n}),(0,_.jsxs)(`div`,{className:o(`flex flex-col gap-3`,!R&&`opacity-60`),children:[(0,_.jsxs)(`div`,{className:`rounded-lg border bg-card p-3`,children:[(0,_.jsx)(`div`,{className:`mb-2 text-sm font-medium`,children:`Behavior`}),(0,_.jsxs)(`div`,{className:`grid gap-2`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.generateMemories!==!1,disabled:b||!R,onCheckedChange:e=>N({generateMemories:e===!0})}),`Generate memories from new sessions`]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.useMemories!==!1,disabled:b||!R,onCheckedChange:e=>N({useMemories:e===!0})}),`Use existing memories in new sessions`]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(s,{checked:z.disableOnExternalContext===!0,disabled:b||!R,onCheckedChange:e=>N({disableOnExternalContext:e===!0})}),`Skip sessions that used external context (MCP tools, web search)`]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(h,{htmlFor:`mem-rate`,className:`font-normal`,children:`Pause generation below`}),(0,_.jsx)(p,{id:`mem-rate`,type:`number`,min:0,max:100,placeholder:`25`,className:`h-7 w-20`,value:O,disabled:b||!R,onChange:e=>k(e.target.value),onBlur:()=>{O!==``&&P()},onKeyDown:e=>{e.key===`Enter`&&O!==``&&P()}}),(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`% rate limit remaining`})]})]}),(0,_.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:`Behavior settings are read by the engine at startup; the on/off toggle applies immediately.`})]}),(0,_.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col gap-1 overflow-auto`,children:[(0,_.jsxs)(`div`,{className:`text-sm font-medium`,children:[`Memory files`,B.length>0&&` (${B.length})`]}),B.map(e=>(0,_.jsxs)(`div`,{className:o(`group flex cursor-pointer items-center gap-2 rounded-md border px-2 py-1.5`,S===e.path?`border-foreground/30 bg-muted/60`:`bg-card hover:bg-muted/40`),onClick:()=>F(e),children:[(0,_.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsx)(`div`,{className:`truncate text-sm`,title:e.path,children:e.path}),(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[v(e.size),` · `,new Date(e.modifiedAt).toLocaleString()]})]}),(0,_.jsx)(f,{size:`icon-sm`,variant:`ghost`,className:`invisible text-destructive hover:text-destructive group-hover:visible`,disabled:b,onClick:t=>{t.stopPropagation(),L(e.path)},children:(0,_.jsx)(l,{})})]},e.path)),B.length===0&&(0,_.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-center text-sm text-muted-foreground`,children:[(0,_.jsx)(d,{className:`size-8`}),R?`No memories yet. Codex builds them in the background from finished sessions.`:`Enable memories to let Codex remember context across sessions.`]})]}),(0,_.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2`,children:S?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`code`,{className:`truncate text-xs text-muted-foreground`,children:S}),(0,_.jsx)(f,{size:`sm`,className:`ml-auto`,onClick:I,disabled:!E||b,children:b?`Saving…`:`Save`})]}),(0,_.jsx)(u,{value:w,spellCheck:!1,className:`min-h-0 flex-1 resize-none font-mono text-sm`,onChange:e=>{T(e.target.value),D(!0)}})]}):(0,_.jsx)(`div`,{className:`flex flex-1 items-center justify-center rounded-lg border border-dashed text-sm text-muted-foreground`,children:`Select a memory file to inspect or edit it`})})]})]})]})}export{y as MemoriesPage};