@bigduu/lotus-next 2026.11.9 → 2026.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asset-manifest.json +33 -33
- package/dist/assets/{AgentService-CsJ7WhuL.js → AgentService-SbVTfVIA.js} +1 -1
- package/dist/assets/{ConversationClearDialogContent-CsrHs1Ze.js → ConversationClearDialogContent-CVrJK3Fo.js} +1 -1
- package/dist/assets/{JianduProjectMemories-DRs5HQZd.js → JianduProjectMemories-DlYsa8ZZ.js} +1 -1
- package/dist/assets/{Root-BI46na22.js → Root-B7yT7Otc.js} +4 -4
- package/dist/assets/{RunDiagnosticsDialogContent-D0z0OJGE.js → RunDiagnosticsDialogContent-yjlcMb_h.js} +1 -1
- package/dist/assets/{Settings-BfIYlkg-.js → Settings-gM0mfiFQ.js} +3 -3
- package/dist/assets/{SidebarProjectDrag-voL3KpvK.js → SidebarProjectDrag-BHSAbtHE.js} +1 -1
- package/dist/assets/{SupervisorManagedSessions-OHqd8Wiu.js → SupervisorManagedSessions-5puJv65c.js} +1 -1
- package/dist/assets/{appStore-DtSQC8LZ.js → appStore-CtVfGWhw.js} +3 -3
- package/dist/assets/{command-DGPzCE7j.js → command-BR9ELivv.js} +2 -2
- package/dist/assets/{index-D7_pjoEW.js → index-BoAMGaCY.js} +3 -3
- package/dist/assets/{managedSessions-BGFiZPYJ.js → managedSessions-KUza_IRG.js} +1 -1
- package/dist/assets/{managedSessions-D4u69IPf.js → managedSessions-iFtGE6is.js} +1 -1
- package/dist/bundle-ownership.json +16 -16
- package/dist/index.html +1 -1
- package/dist/lotus-next-manifest.json +38 -38
- package/package.json +1 -1
package/dist/asset-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_AgentService-
|
|
3
|
-
"file": "assets/AgentService-
|
|
2
|
+
"_AgentService-SbVTfVIA.js": {
|
|
3
|
+
"file": "assets/AgentService-SbVTfVIA.js",
|
|
4
4
|
"name": "AgentService",
|
|
5
5
|
"imports": [
|
|
6
6
|
"_runtimeConfig-DNyol2mX.js",
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"_runtimeConfig-DNyol2mX.js"
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
|
-
"_appStore-
|
|
104
|
-
"file": "assets/appStore-
|
|
103
|
+
"_appStore-CtVfGWhw.js": {
|
|
104
|
+
"file": "assets/appStore-CtVfGWhw.js",
|
|
105
105
|
"name": "appStore",
|
|
106
106
|
"imports": [
|
|
107
107
|
"_rolldown-runtime-QTnfLwEv.js",
|
|
@@ -110,11 +110,11 @@
|
|
|
110
110
|
"_clipboard-CyQ_pZV9.js",
|
|
111
111
|
"_react-BqtYw2Yd.js",
|
|
112
112
|
"_api-CPcpMjoM.js",
|
|
113
|
-
"_AgentService-
|
|
113
|
+
"_AgentService-SbVTfVIA.js",
|
|
114
114
|
"_project-Bes6r3Er.js"
|
|
115
115
|
],
|
|
116
116
|
"dynamicImports": [
|
|
117
|
-
"_managedSessions-
|
|
117
|
+
"_managedSessions-KUza_IRG.js"
|
|
118
118
|
]
|
|
119
119
|
},
|
|
120
120
|
"_arrow-left-wQDuPz_E.js": {
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"file": "assets/clipboard-CyQ_pZV9.js",
|
|
152
152
|
"name": "clipboard"
|
|
153
153
|
},
|
|
154
|
-
"_command-
|
|
155
|
-
"file": "assets/command-
|
|
154
|
+
"_command-BR9ELivv.js": {
|
|
155
|
+
"file": "assets/command-BR9ELivv.js",
|
|
156
156
|
"name": "command",
|
|
157
157
|
"imports": [
|
|
158
158
|
"_rolldown-runtime-QTnfLwEv.js",
|
|
@@ -355,13 +355,13 @@
|
|
|
355
355
|
"_createLucideIcon-5m7IB1Aa.js"
|
|
356
356
|
]
|
|
357
357
|
},
|
|
358
|
-
"_managedSessions-
|
|
359
|
-
"file": "assets/managedSessions-
|
|
358
|
+
"_managedSessions-KUza_IRG.js": {
|
|
359
|
+
"file": "assets/managedSessions-KUza_IRG.js",
|
|
360
360
|
"name": "managedSessions",
|
|
361
361
|
"imports": [
|
|
362
362
|
"_preload-helper-DYl5dUZ5.js",
|
|
363
363
|
"_api-CPcpMjoM.js",
|
|
364
|
-
"_AgentService-
|
|
364
|
+
"_AgentService-SbVTfVIA.js",
|
|
365
365
|
"_client-Cxjm7aQO.js"
|
|
366
366
|
],
|
|
367
367
|
"dynamicImports": [
|
|
@@ -694,7 +694,7 @@
|
|
|
694
694
|
]
|
|
695
695
|
},
|
|
696
696
|
"index.html": {
|
|
697
|
-
"file": "assets/index-
|
|
697
|
+
"file": "assets/index-BoAMGaCY.js",
|
|
698
698
|
"name": "index",
|
|
699
699
|
"src": "index.html",
|
|
700
700
|
"isEntry": true,
|
|
@@ -6690,7 +6690,7 @@
|
|
|
6690
6690
|
]
|
|
6691
6691
|
},
|
|
6692
6692
|
"src/Root.tsx": {
|
|
6693
|
-
"file": "assets/Root-
|
|
6693
|
+
"file": "assets/Root-B7yT7Otc.js",
|
|
6694
6694
|
"name": "Root",
|
|
6695
6695
|
"src": "src/Root.tsx",
|
|
6696
6696
|
"isDynamicEntry": true,
|
|
@@ -6700,7 +6700,7 @@
|
|
|
6700
6700
|
"_runtimeConfig-DNyol2mX.js",
|
|
6701
6701
|
"_preload-helper-DYl5dUZ5.js",
|
|
6702
6702
|
"_ui-C2RfJtHm.js",
|
|
6703
|
-
"_command-
|
|
6703
|
+
"_command-BR9ELivv.js",
|
|
6704
6704
|
"_createLucideIcon-5m7IB1Aa.js",
|
|
6705
6705
|
"_popover-Cu0Q3dYz.js",
|
|
6706
6706
|
"_loader-circle-B9fKDSy8.js",
|
|
@@ -6722,9 +6722,9 @@
|
|
|
6722
6722
|
"_x-CH9nNoJJ.js",
|
|
6723
6723
|
"_clipboard-CyQ_pZV9.js",
|
|
6724
6724
|
"_react-BqtYw2Yd.js",
|
|
6725
|
-
"_appStore-
|
|
6725
|
+
"_appStore-CtVfGWhw.js",
|
|
6726
6726
|
"_api-CPcpMjoM.js",
|
|
6727
|
-
"_AgentService-
|
|
6727
|
+
"_AgentService-SbVTfVIA.js",
|
|
6728
6728
|
"_project-Bes6r3Er.js",
|
|
6729
6729
|
"_button-Cfb4l-V4.js",
|
|
6730
6730
|
"_utils-DqNhCx4L.js",
|
|
@@ -6746,7 +6746,7 @@
|
|
|
6746
6746
|
],
|
|
6747
6747
|
"dynamicImports": [
|
|
6748
6748
|
"src/components/chat/SupervisorManagedSessions.tsx",
|
|
6749
|
-
"_managedSessions-
|
|
6749
|
+
"_managedSessions-KUza_IRG.js",
|
|
6750
6750
|
"src/components/chat/CommandPalette.tsx",
|
|
6751
6751
|
"src/components/chat/Settings.tsx",
|
|
6752
6752
|
"_runDiagnostic-DBibDMFH.js",
|
|
@@ -6859,7 +6859,7 @@
|
|
|
6859
6859
|
]
|
|
6860
6860
|
},
|
|
6861
6861
|
"src/components/app/SidebarProjectDrag.tsx": {
|
|
6862
|
-
"file": "assets/SidebarProjectDrag-
|
|
6862
|
+
"file": "assets/SidebarProjectDrag-BHSAbtHE.js",
|
|
6863
6863
|
"name": "SidebarProjectDrag",
|
|
6864
6864
|
"src": "src/components/app/SidebarProjectDrag.tsx",
|
|
6865
6865
|
"isDynamicEntry": true,
|
|
@@ -6868,7 +6868,7 @@
|
|
|
6868
6868
|
"_vendor-react-CCIEwYL0.js",
|
|
6869
6869
|
"_ui-C2RfJtHm.js",
|
|
6870
6870
|
"_workbenchSensors-t4FKs4U1.js",
|
|
6871
|
-
"_appStore-
|
|
6871
|
+
"_appStore-CtVfGWhw.js",
|
|
6872
6872
|
"_projectSidebarPreferences-CMJ99W-X.js"
|
|
6873
6873
|
]
|
|
6874
6874
|
},
|
|
@@ -6920,7 +6920,7 @@
|
|
|
6920
6920
|
]
|
|
6921
6921
|
},
|
|
6922
6922
|
"src/components/chat/ConversationClearDialogContent.tsx": {
|
|
6923
|
-
"file": "assets/ConversationClearDialogContent-
|
|
6923
|
+
"file": "assets/ConversationClearDialogContent-CVrJK3Fo.js",
|
|
6924
6924
|
"name": "ConversationClearDialogContent",
|
|
6925
6925
|
"src": "src/components/chat/ConversationClearDialogContent.tsx",
|
|
6926
6926
|
"isDynamicEntry": true,
|
|
@@ -6928,7 +6928,7 @@
|
|
|
6928
6928
|
"_rolldown-runtime-QTnfLwEv.js",
|
|
6929
6929
|
"_vendor-react-CCIEwYL0.js",
|
|
6930
6930
|
"_ui-C2RfJtHm.js",
|
|
6931
|
-
"_appStore-
|
|
6931
|
+
"_appStore-CtVfGWhw.js",
|
|
6932
6932
|
"_button-Cfb4l-V4.js",
|
|
6933
6933
|
"_responsive-dialog-fYAouKrw.js"
|
|
6934
6934
|
]
|
|
@@ -6961,7 +6961,7 @@
|
|
|
6961
6961
|
]
|
|
6962
6962
|
},
|
|
6963
6963
|
"src/components/chat/RunDiagnosticsDialogContent.tsx": {
|
|
6964
|
-
"file": "assets/RunDiagnosticsDialogContent-
|
|
6964
|
+
"file": "assets/RunDiagnosticsDialogContent-yjlcMb_h.js",
|
|
6965
6965
|
"name": "RunDiagnosticsDialogContent",
|
|
6966
6966
|
"src": "src/components/chat/RunDiagnosticsDialogContent.tsx",
|
|
6967
6967
|
"isDynamicEntry": true,
|
|
@@ -6970,7 +6970,7 @@
|
|
|
6970
6970
|
"_vendor-react-CCIEwYL0.js",
|
|
6971
6971
|
"_runtimeConfig-DNyol2mX.js",
|
|
6972
6972
|
"_ui-C2RfJtHm.js",
|
|
6973
|
-
"_AgentService-
|
|
6973
|
+
"_AgentService-SbVTfVIA.js",
|
|
6974
6974
|
"_button-Cfb4l-V4.js",
|
|
6975
6975
|
"_responsive-dialog-fYAouKrw.js",
|
|
6976
6976
|
"_runDiagnosticId-Chp3mq_m.js",
|
|
@@ -6978,7 +6978,7 @@
|
|
|
6978
6978
|
]
|
|
6979
6979
|
},
|
|
6980
6980
|
"src/components/chat/Settings.tsx": {
|
|
6981
|
-
"file": "assets/Settings-
|
|
6981
|
+
"file": "assets/Settings-gM0mfiFQ.js",
|
|
6982
6982
|
"name": "Settings",
|
|
6983
6983
|
"src": "src/components/chat/Settings.tsx",
|
|
6984
6984
|
"isDynamicEntry": true,
|
|
@@ -6988,7 +6988,7 @@
|
|
|
6988
6988
|
"_runtimeConfig-DNyol2mX.js",
|
|
6989
6989
|
"_preload-helper-DYl5dUZ5.js",
|
|
6990
6990
|
"_ui-C2RfJtHm.js",
|
|
6991
|
-
"_command-
|
|
6991
|
+
"_command-BR9ELivv.js",
|
|
6992
6992
|
"_createLucideIcon-5m7IB1Aa.js",
|
|
6993
6993
|
"_popover-Cu0Q3dYz.js",
|
|
6994
6994
|
"_loader-circle-B9fKDSy8.js",
|
|
@@ -7004,9 +7004,9 @@
|
|
|
7004
7004
|
"_x-CH9nNoJJ.js",
|
|
7005
7005
|
"_clipboard-CyQ_pZV9.js",
|
|
7006
7006
|
"_react-BqtYw2Yd.js",
|
|
7007
|
-
"_appStore-
|
|
7007
|
+
"_appStore-CtVfGWhw.js",
|
|
7008
7008
|
"_api-CPcpMjoM.js",
|
|
7009
|
-
"_AgentService-
|
|
7009
|
+
"_AgentService-SbVTfVIA.js",
|
|
7010
7010
|
"_dist-F2p7j0vG.js",
|
|
7011
7011
|
"_button-Cfb4l-V4.js",
|
|
7012
7012
|
"_utils-DqNhCx4L.js",
|
|
@@ -7059,7 +7059,7 @@
|
|
|
7059
7059
|
]
|
|
7060
7060
|
},
|
|
7061
7061
|
"src/components/chat/SupervisorManagedSessions.tsx": {
|
|
7062
|
-
"file": "assets/SupervisorManagedSessions-
|
|
7062
|
+
"file": "assets/SupervisorManagedSessions-5puJv65c.js",
|
|
7063
7063
|
"name": "SupervisorManagedSessions",
|
|
7064
7064
|
"src": "src/components/chat/SupervisorManagedSessions.tsx",
|
|
7065
7065
|
"isDynamicEntry": true,
|
|
@@ -7073,7 +7073,7 @@
|
|
|
7073
7073
|
"_dialog-CfOua_Le.js",
|
|
7074
7074
|
"_client-Cxjm7aQO.js",
|
|
7075
7075
|
"_SupervisorProjectScopeDialog-DdIuDGl8.js",
|
|
7076
|
-
"_managedSessions-
|
|
7076
|
+
"_managedSessions-KUza_IRG.js"
|
|
7077
7077
|
]
|
|
7078
7078
|
},
|
|
7079
7079
|
"src/components/chat/TicketWorkPanel.tsx": {
|
|
@@ -7105,7 +7105,7 @@
|
|
|
7105
7105
|
]
|
|
7106
7106
|
},
|
|
7107
7107
|
"src/components/chat/settings/JianduProjectMemories.tsx": {
|
|
7108
|
-
"file": "assets/JianduProjectMemories-
|
|
7108
|
+
"file": "assets/JianduProjectMemories-DlYsa8ZZ.js",
|
|
7109
7109
|
"name": "JianduProjectMemories",
|
|
7110
7110
|
"src": "src/components/chat/settings/JianduProjectMemories.tsx",
|
|
7111
7111
|
"isDynamicEntry": true,
|
|
@@ -7115,7 +7115,7 @@
|
|
|
7115
7115
|
"_ui-C2RfJtHm.js",
|
|
7116
7116
|
"_input-DWysC80E.js",
|
|
7117
7117
|
"_select-CBtmzEvB.js",
|
|
7118
|
-
"_appStore-
|
|
7118
|
+
"_appStore-CtVfGWhw.js",
|
|
7119
7119
|
"_button-Cfb4l-V4.js",
|
|
7120
7120
|
"_responsive-dialog-fYAouKrw.js",
|
|
7121
7121
|
"_textarea-BKzYyWL5.js",
|
|
@@ -7156,12 +7156,12 @@
|
|
|
7156
7156
|
]
|
|
7157
7157
|
},
|
|
7158
7158
|
"src/services/supervisorScope/managedSessions.ts": {
|
|
7159
|
-
"file": "assets/managedSessions-
|
|
7159
|
+
"file": "assets/managedSessions-iFtGE6is.js",
|
|
7160
7160
|
"name": "managedSessions",
|
|
7161
7161
|
"src": "src/services/supervisorScope/managedSessions.ts",
|
|
7162
7162
|
"isDynamicEntry": true,
|
|
7163
7163
|
"imports": [
|
|
7164
|
-
"_managedSessions-
|
|
7164
|
+
"_managedSessions-KUza_IRG.js"
|
|
7165
7165
|
]
|
|
7166
7166
|
},
|
|
7167
7167
|
"src/services/supervisorScope/sessionLabels.ts": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./runDiagnostic-DJ_i4o1q.js","./runDiagnostic-DBibDMFH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./runtimeConfig-DNyol2mX.js";import{t}from"./preload-helper-DYl5dUZ5.js";import{r as n}from"./ui-C2RfJtHm.js";import{c as r,t as i}from"./api-CPcpMjoM.js";async function a(){let e;try{e=await i.get(`execute/defaults`,{cache:`no-store`})}catch(e){return r(e)&&e.status===404?`unsupported`:`unknown`}if(!e||typeof e!=`object`||Array.isArray(e))return`unknown`;if(!(`upstream_retry`in e)){let t=e;return typeof t.system_prompt==`string`&&typeof t.base_system_prompt==`string`&&(t.default_session_permission_mode===void 0||[`default`,`auto`,`bypass`].includes(t.default_session_permission_mode))&&(t.model===null||typeof t.model==`string`)?`unsupported`:`unknown`}let t=e.upstream_retry;return!t||typeof t!=`object`||Array.isArray(t)||!(`supported_modes`in t)||!Array.isArray(t.supported_modes)||!t.supported_modes.every(e=>typeof e==`string`)?`unknown`:t.supported_modes.includes(`until_cancelled`)?`supported`:`unsupported`}async function o(){return await a()===`supported`}var s=e=>typeof e==`string`&&/^[!-~]{1,128}$/.test(e),c=null,l=new Set,ee=e=>{c=new Set(e??[]);for(let e of l)e()},te=e=>c?.has(e)??!1,ne=()=>!1,re=e=>{if(!ne())return!1;try{return localStorage.getItem(e)===`1`}catch{return!1}},u=(e,t,...n)=>{ne()&&re(`bodhi_debug_verbose`)&&console.log(`${e} ${t}`,...n)},ie=`bodhi_api_v2_msgpack`,ae=()=>{try{return localStorage.getItem(ie)===`1`}catch{return!1}};function oe(e){let t=e.length,n=0,r=0;for(;r<t;){let i=e.charCodeAt(r++);if(!(i&4294967168)){n++;continue}else if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&r<t){let t=e.charCodeAt(r);(t&64512)==56320&&(++r,i=((i&1023)<<10)+(t&1023)+65536)}i&4294901760?n+=4:n+=3}}return n}function se(e,t,n){let r=e.length,i=n,a=0;for(;a<r;){let n=e.charCodeAt(a++);if(!(n&4294967168)){t[i++]=n;continue}else if(!(n&4294965248))t[i++]=n>>6&31|192;else{if(n>=55296&&n<=56319&&a<r){let t=e.charCodeAt(a);(t&64512)==56320&&(++a,n=((n&1023)<<10)+(t&1023)+65536)}n&4294901760?(t[i++]=n>>18&7|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128):(t[i++]=n>>12&15|224,t[i++]=n>>6&63|128)}t[i++]=n&63|128}}var ce=new TextEncoder,le=50;function ue(e,t,n){ce.encodeInto(e,t.subarray(n))}function de(e,t,n){e.length>le?ue(e,t,n):se(e,t,n)}var fe=4096;function pe(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=fe&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var me=new TextDecoder,he=200;function ge(e,t,n){let r=e.subarray(t,t+n);return me.decode(r)}function _e(e,t,n){return n>he?ge(e,t,n):pe(e,t,n)}var d=class{type;data;constructor(e,t){this.type=e,this.data=t}},f=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};function ve(e,t,n){let r=n/4294967296,i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function ye(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function be(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function xe(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var Se=4294967295,Ce=17179869183;function we({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=Ce)if(t===0&&e<=Se){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),ye(r,4,e),n}}function Te(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function Ee(e){return e instanceof Date?we(Te(e)):null}function De(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:be(t,4),nsec:t.getUint32(0)};default:throw new f(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Oe(e){let t=De(e);return new Date(t.sec*1e3+t.nsec/1e6)}var ke={type:-1,encode:Ee,decode:Oe},Ae=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ke)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new d(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new d(n,i)}}return e instanceof d?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new d(t,e)}};function je(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function Me(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):je(e)?new Uint8Array(e):Uint8Array.from(e)}var Ne=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ae.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??100,this.initialBufferSize=e?.initialBufferSize??2048,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e==`boolean`?this.encodeBoolean(e):typeof e==`number`?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e==`string`?this.encodeString(e):this.useBigInt64&&typeof e==`bigint`?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let t=oe(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),de(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e==`object`)this.encodeMap(e,t);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw Error(`Too large binary: ${t}`);let n=Me(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw Error(`Too large array: ${n}`);for(let n of e)this.doEncode(n,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw Error(`Too large map object: ${r}`);for(let r of n){let n=e[r];this.ignoreUndefined&&n===void 0||(this.encodeString(r),this.doEncode(n,t+1))}}encodeExtension(e){if(typeof e.data==`function`){let t=e.data(this.pos+6),n=t.length;if(n>=4294967296)throw Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(t);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),ve(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ye(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Pe(e,t){return new Ne(t).encodeSharedRef(e)}function Fe(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var Ie=16,Le=16,Re=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ie,t=Le){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let i=pe(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},p=`array`,m=`map_key`,ze=`map_value`,Be=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new f(`The type of key must be string or number but `+typeof e)},Ve=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=p,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=m,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===p){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===m||e.type===ze){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},h=-1,g=new DataView(new ArrayBuffer(0)),He=new Uint8Array(g.buffer);try{g.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}var Ue=RangeError(`Insufficient data`),We=new Re,Ge=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=g;bytes=He;headByte=h;stack=new Ve;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ae.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder===void 0?We:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??Be}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=h,this.stack.reset()}setBuffer(e){let t=Me(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===h&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=Me(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${Fe(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new f(`Unrecognized type byte: ${Fe(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===p)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===m){if(t===`__proto__`)throw new f(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=ze;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=m;continue DECODE}}return t}}readHeadByte(){return this.headByte===h&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=h}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new f(`Unrecognized array type byte: ${Fe(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new f(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new f(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new f(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ue;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):_e(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===m:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new f(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ue;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new f(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=xe(this.view,this.pos);return this.pos+=8,e}readI64(){let e=be(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Ke(e,t){return new Ge(t).decode(e)}var qe=new TextEncoder,_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),v=(e,t)=>Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t)),y=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,b=e=>typeof e==`string`&&e.length>0&&e.trim()===e&&qe.encode(e).length<=256&&!e.includes(`..`)&&!/[\\/]/.test(e)&&![...e].some(e=>{let t=e.codePointAt(0);return t<32||t>=127&&t<=159||t>=55296&&t<=57343||t>=8234&&t<=8238||t>=8294&&t<=8297}),Je=e=>{if(typeof e!=`string`)return!1;if(e.length===32)return/^[0-9a-f]{32}$/i.test(e);let t=e.length===38&&e.startsWith(`{`)&&e.endsWith(`}`)?e.slice(1,-1):e.length===45&&e.startsWith(`urn:uuid:`)?e.slice(9):e;return t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)};function Ye(e,t){if(!b(t)||!_(e)||e.ch!==`actor.${t}`||!y(e.seq))return null;if(v(e,[`ch`,`seq`,`control`])&&_(e.control)){let t=e.control;if(v(t,[`type`,`epoch`,`cursor`,`resumed_from`])&&t.type===`actor_replay_complete`&&typeof t.epoch==`string`&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t.epoch)&&t.cursor===e.seq&&(t.resumed_from===null||y(t.resumed_from)&&t.resumed_from<=e.seq))return{type:`replay_complete`,seq:e.seq,control:t};if(v(t,[`type`,`reason`,`cursor`])&&t.type===`actor_snapshot_required`&&(t.reason===`initial`||t.reason===`gap`)&&t.cursor===e.seq)return{type:`control`,seq:e.seq,control:t}}if(v(e,[`ch`,`seq`,`event`])&&_(e.event)){let n=e.event;if(v(n,[`type`,`actor_id`,`root_actor_id`,`parent_actor_id`,`activation_id`,`attempt`,`event_id`,`class`])&&n.type===`actor_changed`&&n.actor_id===t&&b(n.root_actor_id)&&(n.parent_actor_id===null||b(n.parent_actor_id))&&Je(n.activation_id)&&y(n.attempt)&&typeof n.event_id==`string`&&/^ae1-[0-9a-f]{64}$/.test(n.event_id)&&(n.class===`lifecycle`||n.class===`semantic`||n.class===`snapshot`||n.class===`ephemeral`))return{type:`event`,seq:e.seq,event:n}}return null}var Xe=15e3,Ze=500,Qe=15e3,$e=4e4,et=1e3,tt=5e3,nt=5e3,rt=`bamboo.v2.msgpack`,x=e=>typeof e==`object`&&!!e&&!Array.isArray(e),S=(e,t)=>{let n=Object.keys(e).sort(),r=[...t].sort();return n.length===r.length&&n.every((e,t)=>e===r[t])},C=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,w=e=>{if(typeof e!=`string`)return null;let t=/^at1-([0-9a-f]{64})-([1-9][0-9]*)$/.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isSafeInteger(n)&&n>0?{scope:t[1],revision:n}:null},T=(e,t)=>{let n=w(e),r=w(t);return n!==null&&r!==null&&n.scope===r.scope&&n.revision>=r.revision},it=e=>e===`complete`||e===`cancelled`||e===`error`,at=e=>!x(e)||!S(e,[`id`,`content`,`created_at`])||typeof e.id!=`string`||typeof e.content!=`string`||typeof e.created_at!=`string`?null:e,ot=e=>{if(e.control!==void 0||!E(e.seq)||!x(e.event)||!S(e,[`ch`,`seq`,`event`]))return null;let t=e.event;if(t.type===`snapshot`){if(!S(t,t.terminal===void 0?[`type`,`version`,`messages`,`history_committed`]:[`type`,`version`,`messages`,`history_committed`,`terminal`])||!C(t.version)||!Array.isArray(t.messages)||typeof t.history_committed!=`boolean`||t.terminal!==void 0&&!it(t.terminal))return null;let e=t.messages.map(at);return e.some(e=>e===null)?null:{...t,messages:e}}return t.type===`started`?!S(t,[`type`,`version`,`message_id`,`created_at`])||!C(t.version)||typeof t.message_id!=`string`||typeof t.created_at!=`string`?null:t:t.type===`delta`?!S(t,[`type`,`version`,`message_id`,`offset`,`content`,`created_at`])||!C(t.version)||!C(t.offset)||typeof t.message_id!=`string`||typeof t.content!=`string`||typeof t.created_at!=`string`?null:t:t.type===`discarded`?!S(t,[`type`,`version`,`message_id`])||!C(t.version)||typeof t.message_id!=`string`?null:t:null},st=e=>{if(e.event!==void 0||!E(e.seq)||!x(e.control)||!S(e,[`ch`,`seq`,`control`]))return null;let t=e.control;return t.type===`gap`&&S(t,[`type`,`skipped`])&&C(t.skipped)||t.type===`terminal`&&S(t,[`type`,`reason`])&&it(t.reason)||t.type===`history_committed`&&S(t,[`type`,`version`])&&C(t.version)?t:null},E=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,ct=e=>{if(!E(e.seq)||e.control!==void 0||!x(e.event))return null;let t=e.event;return!E(t.seq)||t.seq!==e.seq||typeof t.ts!=`string`||t.session_id!==void 0&&typeof t.session_id!=`string`||!x(t.event)||typeof t.event.type!=`string`?null:t},lt=e=>e.seq!==0||e.event!==void 0||!x(e.control)||e.control.type!==`feed_reset`||!E(e.control.from_seq)?null:e.control.from_seq,D=null,O=!1,k=0,A=null,j=!1,M=!1,N=null,P=new Set,ut=e=>(P.add(e),()=>P.delete(e)),F=(e=D)=>{let t=N;return e!==null&&D===e&&e.readyState===WebSocket.OPEN&&t!==null&&t.socket===e&&t.phase===`ready`},I=null,dt=()=>F()&&I!==null&&!I.deliveryFailed&&I.subscribedSince!==null,L=new Map,R=new Map,z=new Map,B=new Map,ft=e=>`agent.${e}`,pt=e=>`message.${e}`,mt=e=>`actor.${e}`,ht=e=>`tree.${e}`,V=()=>I!==null&&!I.deliveryFailed||L.size>0||R.size>0||z.size>0||B.size>0,gt=(e,t)=>{if(!x(e)||!S(e,[`ch`,`seq`,`control`])||e.ch!==ht(t)||!x(e.control)||!S(e.control,[`type`,`reason`,`cursor`])||e.control.type!==`actor_snapshot_required`)return null;let n=e.control.reason;if(n!==`initial`&&n!==`gap`&&n!==`changed`&&n!==`unavailable`)return null;let r=e.control.cursor;if(r===null){if(e.seq!==0||n===`changed`)return null}else{let t=w(r);if(!t||e.seq!==t.revision||n===`unavailable`)return null}return{type:`actor_snapshot_required`,reason:n,cursor:r}},_t=e=>e.protocol===rt,H=(e,t)=>{if(D===e&&e.readyState===WebSocket.OPEN)try{return e.send(_t(e)?Pe(t):JSON.stringify(t)),!0}catch(e){u(`[v2Stream]`,`send.error`,{payload:t,error:e})}return!1},U=e=>D!==null&&H(D,e),vt=e=>!e||!F()?!1:U({type:`stop`,session_id:e}),yt=(e,t)=>{let n=e.since;return e.subscribedSince=null,e.acceptedInSubscription=!1,e.resetHandledInSubscription=!1,H(t,{type:`subscribe`,ch:`feed`,since:n})?(e.subscribedSince=n,!0):!1},bt=(e,t,n)=>{if(console.warn(`Failed to ${t} v2 feed:`,n),!(I!==e||e.deliveryFailed)){e.deliveryFailed=!0,e.subscribedSince=null,F()&&U({type:`unsubscribe`,ch:`feed`});try{e.handlers.onError?.()}catch(e){console.warn(`Failed to report v2 feed handler error:`,e)}J()}},W=e=>{e.resume?.timer!==null&&e.resume?.timer!==void 0&&clearTimeout(e.resume.timer),e.resume=null},G=e=>{if(e.resume&&(e.resume.failed=!0),e.epoch=null,!e.gapNotified){e.gapNotified=!0;for(let t of[...e.subscribers])try{t.onGap()}catch(e){u(`[v2Stream]`,`actor.gap_listener_error`,{error:e})}}},xt=(e,t,n)=>{W(e);let r={socket:n,anchorEpoch:e.epoch,anchorCursor:e.cursor,awaitingReset:!0,resetCursor:null,failed:!1,timer:null};return e.resume=r,r.anchorEpoch!==null&&r.anchorCursor!==null&&(r.timer=setTimeout(()=>{D!==n||z.get(t)!==e||e.resume!==r||(W(e),G(e))},nt)),H(n,{type:`subscribe`,ch:t,...e.cursor===null?{}:{since:e.cursor},actor_resume:{epoch:e.epoch}})},St=e=>{if(I&&!I.deliveryFailed&&!yt(I,e))return!1;for(let t of L.keys())if(!H(e,{type:`subscribe`,ch:t}))return!1;for(let t of R.keys())if(!H(e,{type:`subscribe`,ch:t}))return!1;for(let[t,n]of z)if(!xt(n,t,e))return!1;for(let[t,n]of B)if(!H(e,n.cursor===null?{type:`subscribe_tree`,ch:t}:{type:`subscribe_tree`,ch:t,cursor:n.cursor}))return!1;return!0},Ct=()=>{A&&=(clearTimeout(A),null)},wt=()=>{if(!V()||j||A)return;let e=Math.min(Ze*2**k,Xe);k+=1,u(`[v2Stream]`,`reconnect.schedule`,{attempt:k,delay:e}),A=setTimeout(()=>{A=null,Y()},e)},K=e=>{let t=N;if(!(!t||e&&t.socket!==e)){t.welcomeTimer!==null&&(clearTimeout(t.welcomeTimer),t.welcomeTimer=null),t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null),t.watchdogTimer!==null&&(clearInterval(t.watchdogTimer),t.watchdogTimer=null),t.visibilityListener&&typeof document<`u`&&(document.removeEventListener(`visibilitychange`,t.visibilityListener),t.visibilityListener=null);for(let e of[...z.values()]){let n=e.resume;n?.socket===t.socket&&(n.anchorEpoch!==null&&e.cursor!==n.anchorCursor&&G(e),W(e))}N===t&&(N=null)}},Tt=e=>{let t=D;if(!t||e&&t!==e)return!1;K(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}return D===t&&(D=null),!0},Et=()=>{try{I?.handlers.onError?.()}catch(e){u(`[v2Stream]`,`unavailable.listener_error`,{error:e})}},q=(e,t)=>{N!==e||D!==e.socket||e.recoveryStarted||(e.recoveryStarted=!0,I&&(I.subscribedSince=null,I.acceptedInSubscription=!1,I.resetHandledInSubscription=!1),M=!0,u(`[v2Stream]`,`epoch.unavailable`,{reason:t}),Et(),Tt(e.socket),O=!1,wt())},Dt=e=>{N!==e||D!==e.socket||e.recoveryStarted||(u(`[v2Stream]`,`watchdog.stale_socket`,{silentForMs:Date.now()-e.lastFrameAt}),q(e,`heartbeat-stale`))},Ot=e=>{N!==e||D!==e.socket||e.socket.readyState!==WebSocket.OPEN||e.phase!==`ready`||!e.heartbeatAckSeen||Date.now()-e.lastFrameAt>=$e&&Dt(e)},kt=e=>{K();let t={socket:e,phase:`awaiting-welcome`,lastFrameAt:Date.now(),pingSent:!1,heartbeatAckSeen:!1,recoveryStarted:!1,welcomeTimer:null,heartbeatTimer:null,watchdogTimer:null,visibilityListener:null};return N=t,t.welcomeTimer=setTimeout(()=>{N!==t||D!==e||t.phase!==`awaiting-welcome`||q(t,`welcome-timeout`)},tt),t},At=e=>{let t=e.socket;e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.lastFrameAt=Date.now(),e.heartbeatTimer=setInterval(()=>{N!==e||D!==t||t.readyState!==WebSocket.OPEN||e.phase!==`ready`||H(t,{type:`ping`})&&(e.pingSent=!0)},Qe),e.watchdogTimer=setInterval(()=>Ot(e),et),typeof document<`u`&&(e.visibilityListener=()=>{document.visibilityState===`visible`&&Ot(e)},document.addEventListener(`visibilitychange`,e.visibilityListener))},jt=e=>{let t=N;return!t||t.socket!==e||D!==e||t.phase!==`ready`?null:(t.lastFrameAt=Date.now(),t)},Mt=e=>{!e||!e.pingSent||e.heartbeatAckSeen||(e.heartbeatAckSeen=!0,u(`[v2Stream]`,`heartbeat.acknowledged`,{}))},J=()=>{V()||(j=!0,Ct(),Tt(),K(),O=!1,k=0,M=!1)},Nt=e=>{try{if(typeof e==`string`)return JSON.parse(e);if(e instanceof ArrayBuffer)return Ke(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return Ke(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}u(`[v2Stream]`,`frame.unknown_data_type`,{});return}catch(t){console.warn(`Failed to parse v2 stream frame:`,e,t);return}},Pt=e=>x(e)&&Object.keys(e).length===1&&Object.prototype.hasOwnProperty.call(e,`type`)&&e.type===`welcome`,Ft=e=>x(e)&&e.type===`welcome`,It=e=>{let t=e.socket;if(N!==e||D!==t||t.readyState!==WebSocket.OPEN||e.phase!==`awaiting-welcome`)return;if(e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.phase=`subscribing`,!V()){J();return}if(!St(t)){q(e,`subscribe-send-failed`);return}if(N!==e||D!==t||!V()){J();return}e.phase=`ready`,k=0;let n=M;if(M=!1,At(e),u(`[v2Stream]`,`ready`,{afterDrop:n}),n){for(let e of[...z.values()])e.resume?.anchorEpoch&&e.resume.anchorCursor!==null||(e.cursor=null,e.lastControl=null,G(e));for(let e of[...B.values()]){e.lastControl=null,e.gapNotified=!0;for(let t of[...e.subscribers])try{t.onGap()}catch(e){u(`[v2Stream]`,`tree.gap_listener_error`,{error:e})}}}if(I&&!I.deliveryFailed&&I.subscribedSince!==null)try{I.handlers.onOpen?.()}catch(e){u(`[v2Stream]`,`feed.open_listener_error`,{error:e})}if(!(N!==e||D!==t||e.phase!==`ready`||!V())&&n)for(let e of[...P])try{e()}catch(e){u(`[v2Stream]`,`reconnected.listener_error`,{error:e})}},Lt=(e,t)=>{if(e?.type===`pong`&&e.ch===void 0){Mt(t);return}if(!e||typeof e.ch!=`string`){u(`[v2Stream]`,`frame.unknown`,{});return}let{ch:n,control:r,event:i}=e;if(n!==`sys`){if(n===`feed`){let t=I;if(!t||t.deliveryFailed||t.subscribedSince===null)return;if(r){let n=lt(e);if(n!==null&&n===t.subscribedSince&&!t.acceptedInSubscription&&!t.resetHandledInSubscription){u(`[v2Stream]`,`feed.reset`,{});let e=t.handlers.onReset;if(!e){bt(t,`apply reset`,Error(`feed_reset requires an application reset handler`));return}let r=t.since;t.since=0;try{e()}catch(e){t.since=r,bt(t,`apply reset`,e);return}I===t&&!t.deliveryFailed&&(t.resetHandledInSubscription=!0,t.postResetFloor=n)}else u(`[v2Stream]`,`feed.control.invalid`,{});return}let n=ct(e);if(!n){u(`[v2Stream]`,`feed.frame.invalid_event`,{});return}let i=Math.max(t.since,t.postResetFloor??0);if(n.seq<=i){u(`[v2Stream]`,`feed.frame.stale`,{seq:n.seq,since:i});return}try{t.handlers.onChange(n)}catch(e){bt(t,`apply event`,e);return}I===t&&(t.since=n.seq,t.acceptedInSubscription=!0,t.postResetFloor=null);return}if(n.startsWith(`message.`)){let t=R.get(n);if(!t||t.size===0)return;if(r!==void 0){let r=st(e);if(!r){u(`[v2Stream]`,`message.frame.invalid_control`,{ch:n});return}for(let e of[...t])e.handlers.onControl(r);return}let i=ot(e);if(!i){u(`[v2Stream]`,`message.frame.invalid_event`,{ch:n});return}for(let e of[...t])e.handlers.onEvent(i);return}if(n.startsWith(`tree.`)){let t=B.get(n);if(!t)return;let r=gt(e,t.rootId);if(!r){if(!t.gapNotified){t.gapNotified=!0;for(let e of[...t.subscribers])e.onGap()}return}if(r.cursor!==null&&T(t.cursor,r.cursor)||t.lastControl?.reason===r.reason&&t.lastControl.cursor===r.cursor)return;t.lastControl=r,t.gapNotified=!1;for(let e of[...t.subscribers])e.onControl(r);return}if(n.startsWith(`actor.`)){let t=z.get(n);if(!t)return;let r=Ye(e,t.actorId);if(!r){G(t);return}let i=t.resume;if(r.type===`replay_complete`){if(!i||i.socket!==D)return;let e=r.control,n=!i.failed&&i.anchorEpoch!==null&&e.epoch===i.anchorEpoch&&e.resumed_from===i.anchorCursor&&i.resetCursor===null&&e.cursor===t.cursor,a=e.resumed_from===null&&i.resetCursor!==null&&e.cursor===i.resetCursor&&e.cursor===t.cursor;W(t),n||a?t.epoch=e.epoch:G(t);return}if(r.type===`control`){if(t.cursor!==null&&r.seq<=t.cursor&&!i?.awaitingReset)return;let e=i?.anchorEpoch!==null&&i?.anchorEpoch!==void 0;i&&(i.awaitingReset=!1,i.resetCursor=r.seq),e&&G(t),t.cursor=r.seq,e||(t.gapNotified=!1),t.lastControl=r.control;for(let e of[...t.subscribers])e.onControl(r.control);return}if(i&&(i.awaitingReset=!1),t.cursor===null||r.seq>t.cursor+1)G(t);else if(r.seq<=t.cursor)return;t.cursor=r.seq;for(let e of[...t.subscribers])e.onEvent(r.event,r.seq);return}if(n.startsWith(`agent.`)){let e=L.get(n);if(!e||e.size===0)return;if(r){if(r.type===`terminal`){u(`[v2Stream]`,`agent.terminal`,{ch:n,subscribers:e.size});for(let t of[...e])t.resolve()}return}if(i===void 0){u(`[v2Stream]`,`agent.frame.no_event`,{});return}for(let t of[...e])try{t.dispatch(i,t.handlers)}catch(e){console.warn(`Failed to dispatch v2 agent event:`,i,e)}return}u(`[v2Stream]`,`frame.unknown_channel`,{ch:n})}},Y=()=>{if(!V()||D&&(D.readyState===WebSocket.OPEN||D.readyState===WebSocket.CONNECTING)||O)return;if(typeof WebSocket>`u`){u(`[v2Stream]`,`connect.no_websocket`,{});return}O=!0,j=!1;let t=e().endpoints.v2Stream;u(`[v2Stream]`,`connect`,{url:t});let n=ae(),r;try{r=n?new WebSocket(t,[rt]):new WebSocket(t),n&&(r.binaryType=`arraybuffer`)}catch(e){O=!1,u(`[v2Stream]`,`connect.error`,{error:e}),I?.handlers.onError?.(),wt();return}D=r,r.onopen=()=>{if(D!==r)return;O=!1;let e=kt(r);u(`[v2Stream]`,`open.awaiting_welcome`,{}),H(r,{type:`hello`})||q(e,`hello-send-failed`)},r.onmessage=e=>{if(D!==r)return;let t=Nt(e.data),n=N;if(!(!n||n.socket!==r)){if(n.phase===`awaiting-welcome`){Pt(t)?It(n):u(`[v2Stream]`,`frame.before_welcome`,{});return}n.phase!==`subscribing`&&(Ft(t)||Lt(t,jt(r)))}},r.onerror=()=>{D===r&&(u(`[v2Stream]`,`error`,{}),Et())},r.onclose=()=>{D===r&&(O=!1,K(r),u(`[v2Stream]`,`close`,{intentional:j}),D=null,!j&&(M=!0,I&&(I.subscribedSince=null),Et(),wt()))}},Rt=(e,t)=>{I={handlers:e,since:E(t)?t:0,deliveryFailed:!1,subscribedSince:null,acceptedInSubscription:!1,resetHandledInSubscription:!1,postResetFloor:null};let n=I;if(D&&F(D)){if(!yt(n,D)){let e=N;e&&q(e,`feed-subscribe-send-failed`)}}else Y();let r=!1;return{close(){r||(r=!0,I===n&&(I=null,F()&&U({type:`unsubscribe`,ch:`feed`}),J()))}}},zt=(e,t,n)=>{let r=ft(e),i=!1,a=()=>{},o={sessionId:e,handlers:t,dispatch:n,resolve:()=>a()},s=new Promise(e=>{a=()=>{if(i)return;i=!0;let t=L.get(r);t?.delete(o),(!t||t.size===0)&&(L.delete(r),F()&&U({type:`unsubscribe`,ch:r}),J()),e()}}),c=L.get(r),l=!c||c.size===0;if(c?c.add(o):L.set(r,new Set([o])),D&&F(D)){if(l&&!H(D,{type:`subscribe`,ch:r})){let e=N;e&&q(e,`agent-subscribe-send-failed`)}}else Y();return{promise:s,close:()=>a()}},Bt=(e,t)=>{let n=pt(e),r={handlers:t},i=R.get(n),a=!i||i.size===0;if(i?i.add(r):R.set(n,new Set([r])),D&&F(D)){if(a&&!H(D,{type:`subscribe`,ch:n})){let e=N;e&&q(e,`message-subscribe-send-failed`)}}else Y();let o=!1;return{close(){if(o)return;o=!0;let e=R.get(n);e?.delete(r),(!e||e.size===0)&&(R.delete(n),F()&&U({type:`unsubscribe`,ch:n}),J())}}},Vt=(e,t)=>{if(!b(e))throw Error(`Invalid ActorId`);let n=mt(e),r=z.get(n),i=!r;r||(r={actorId:e,subscribers:new Set,cursor:null,gapNotified:!1,lastControl:null,epoch:null,resume:null},z.set(n,r));let a=r;if(a.subscribers.add(t),D&&F(D)){if(i&&!xt(a,n,D)){let e=N;e&&q(e,`actor-subscribe-send-failed`)}}else Y();a.gapNotified?t.onGap():a.lastControl&&t.onControl(a.lastControl);let o=!1;return{close(){o||(o=!0,a.subscribers.delete(t),a.subscribers.size===0&&z.get(n)===a&&(W(a),z.delete(n),F()&&U({type:`unsubscribe`,ch:n}),J()))}}},Ht=(e,t,n)=>{if(!b(e)||t!==null&&!w(t))throw Error(`Invalid Actor tree subscription`);let r=ht(e),i=B.get(r),a=!i,o=!1,s;i?i.cursor!==t&&(t!==null&&(i.cursor===null||T(t,i.cursor))?(i.cursor=t,i.lastControl=null,i.gapNotified=!1,s=t,a=!0):t!==null&&T(i.cursor,t)?o=!0:(i.cursor=null,i.lastControl=null,i.gapNotified=!0,a=!0)):(i={rootId:e,subscribers:new Set,cursor:t,gapNotified:!1,lastControl:null},B.set(r,i));let c=i;if(c.subscribers.add(n),s!==void 0)for(let e of[...c.subscribers])e!==n&&e.onControl({type:`actor_snapshot_required`,reason:`changed`,cursor:s});if(D&&F(D)){if(a&&!H(D,c.cursor===null?{type:`subscribe_tree`,ch:r}:{type:`subscribe_tree`,ch:r,cursor:c.cursor})){let e=N;e&&q(e,`tree-subscribe-send-failed`)}}else Y();c.gapNotified||o?n.onGap():c.lastControl&&n.onControl(c.lastControl);let l=!1;return{close(){l||(l=!0,c.subscribers.delete(n),c.subscribers.size===0&&B.get(r)===c&&(B.delete(r),F()&&U({type:`unsubscribe`,ch:r}),J()))}}},Ut=e=>e===`standard`||e===`ultra`,Wt=e=>e==="default"||e===`bypass`||e===`auto`?e:null,Gt=e=>{if(typeof e!=`string`||!/^"\d{1,20}"$/.test(e))return null;let t=BigInt(e.slice(1,-1));return t<=18446744073709551615n?t:null},Kt=class extends Error{constructor(){super(`The backend did not confirm a supported, revisioned session permission mode.`),this.name=`SessionPermissionContractError`}},qt=async(e,t)=>{let n=await t.json(),r=n&&typeof n==`object`&&`session`in n?n.session:null,i=r&&typeof r==`object`&&`permission_mode`in r?Wt(r.permission_mode):null,a=t.headers.get(`ETag`);if(!r||typeof r!=`object`||!(`id`in r)||r.id!==e||!i||!a||Gt(a)===null)throw new Kt;return{sessionId:e,mode:i,etag:a}},Jt=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0,Yt=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.summary!=`string`||typeof t.messages_summarized!=`number`||!Number.isSafeInteger(t.messages_summarized)||t.messages_summarized<0||typeof t.tokens_saved!=`number`||!Number.isSafeInteger(t.tokens_saved)||t.tokens_saved<0?null:{summary:t.summary,messages_summarized:t.messages_summarized,tokens_saved:t.tokens_saved}},X=class extends Error{constructor(){super(n(`the_current_request_could_not_be_confirmed_refresh_and__015fae5f`)),this.name=`PendingInteractionContractError`}},Z=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null,Q=e=>typeof e==`string`&&e.trim().length>0,$=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function Xt(e,t){let n=Z(t);if(!n)throw new X;if(n.has_pending_question===!1&&n.interaction_kind==null&&n.permission_request==null)return{has_pending_question:!1};if(n.has_pending_question!==!0||typeof n.question!=`string`||!Array.isArray(n.options)||!n.options.every(e=>typeof e==`string`)||typeof n.allow_custom!=`boolean`||!Q(n.tool_call_id))throw new X;if(n.interaction_kind===`clarification`&&n.permission_request==null)return n;let r=Z(n.permission_request);if(n.interaction_kind!==`permission`||!r||r.session_id!==e||r.request_id!==n.tool_call_id||!Q(r.request_generation)||!$(r.policy_revision)||![`tool_name`,`permission_type`,`resource`,`operation_summary`].every(e=>typeof r[e]==`string`)||!Array.isArray(r.allowed_decisions)||!r.allowed_decisions.every(e=>typeof e==`string`))throw new X;return n}var Zt=class extends Error{constructor(){super(`The backend returned an invalid message-only history response.`),this.name=`MessageHistoryContractError`}},Qt=(e,t)=>{let n=Object.keys(e).sort(),r=[...t].sort();return n.length===r.length&&n.every((e,t)=>e===r[t])},$t=(e,t)=>{let n=Z(t);if(!n||!Qt(n,[`session_id`,`projection`,`messages`,`is_delta`,`truncated`,`total_message_count`])||n.session_id!==e||n.projection!==`messages`||!Array.isArray(n.messages)||typeof n.is_delta!=`boolean`||typeof n.truncated!=`boolean`||!$(n.total_message_count))throw new Zt;for(let e of n.messages){let t=Z(e);if(!t||Object.keys(t).some(e=>![`id`,`role`,`content`,`created_at`,`thread_id`,`in_reply_to`,`correlation_id`].includes(e))||[`thread_id`,`in_reply_to`,`correlation_id`].some(e=>t[e]!==void 0&&(typeof t[e]!=`string`||t[e].length>128))||typeof t.id!=`string`||t.role!==`user`&&t.role!==`assistant`||typeof t.content!=`string`||typeof t.created_at!=`string`)throw new Zt}return n},en=e=>e?{client_message_count:e.client_message_count,client_last_message_id:e.client_last_message_id??null,client_has_pending_question:e.client_has_pending_question,client_pending_question_tool_call_id:e.client_pending_question_tool_call_id??null}:null,tn=e=>e?{need_sync:e.need_sync,reason:e.reason??null,server_message_count:e.server_message_count,server_last_message_id:e.server_last_message_id??null,has_pending_question:e.has_pending_question,pending_question_tool_call_id:e.pending_question_tool_call_id??null,has_pending_user_message:e.has_pending_user_message}:null,nn=e=>{let t=e.messages[e.messages.length-1];return{session_id:e.session_id,messageCount:e.messages.length,lastMessageId:t?.id??null,lastRole:t?.role??null,compressionEvents:e.compression_events?.length??0}},rn=e=>({count:e.length,runningCount:e.filter(e=>e.is_running).length,sessions:e.slice(0,10).map(e=>({id:e.id,is_running:e.is_running,last_run_status:e.last_run_status??null,message_count:e.message_count,has_pending_question:e.has_pending_question??!1,running_child_count:e.running_child_count??0,updated_at:e.updated_at}))}),an=e=>({count:e.sessions.length,sessions:e.sessions.map(e=>({session_id:e.session_id,run_id:e.run_id,round_count:e.round_count,last_event_at:e.last_event_at??null,last_tool_name:e.last_tool_name??null,last_tool_phase:e.last_tool_phase??null,criticalEventCount:e.last_critical_events.length,runningChildCount:e.running_child_session_ids.length}))}),on=e=>({type:e.type,session_id:e.session_id??null,run_id:e.run_id??null,round_count:e.round_count??null,message:e.message??null,error:e.error??null,tool_call_id:e.tool_call_id??null}),sn=(e,t)=>{if(e.session_id!==void 0||e.project_id!==void 0||!e.workspace_path?.trim()||!r(t)||t.status!==409||!t.body)return null;try{let e=JSON.parse(t.body);if(typeof e!=`object`||!e)return null;let n=e,r=n.error;if(typeof r!=`object`||!r||r.code!==`project_workspace_conflict`||n.session_project_id!==`unassigned`)return null;let i=n.owner_project_id;return typeof i!=`string`||!i.trim()?null:i.trim()}catch{return null}},cn=class e{static instance;static getInstance(){return e.instance||=new e,e.instance}async sendMessage(e){u(`[AgentClient]`,`chat.request`,{sessionId:e.session_id??null,model:e.model,modelRef:e.model_ref??null,provider:e.provider??null,messageLength:e.message.length,hasImages:(e.images?.length??0)>0,imageCount:e.images?.length??0,selectedSkillCount:e.selected_skill_ids?.length??0,workspacePath:e.workspace_path??null,projectId:e.project_id??null});let t;try{t=await i.post(`chat`,e)}catch(n){let r=sn(e,n);if(!r)throw n;t=await i.post(`chat`,{...e,project_id:r})}return u(`[AgentClient]`,`chat.response`,{requestedSessionId:e.session_id??null,sessionId:t.session_id,status:t.status}),t}async execute(e,t,n,r,a,o,s){let c={};o&&(c.upstream_retry=o),s===!0&&(c.live_bootstrap_resume=!0),t&&(c.model=t),n&&(c.reasoning_effort=n),r&&(c.client_sync=r),a&&(c.model_ref=a,c.provider=a.provider),u(`[AgentClient]`,`execute.request`,{sessionId:e,model:c.model??null,reasoningEffort:c.reasoning_effort??null,modelRef:c.model_ref??null,provider:c.provider??null,clientSync:en(c.client_sync)});let l=await i.post(`execute/${e}`,c);return u(`[AgentClient]`,`execute.response`,{sessionId:e,status:l.status,runId:l.run_id??null,eventsUrl:l.events_url,sync:tn(l.sync)}),l}async listSessions(e={}){let t=new URLSearchParams;e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),e.kind!==void 0&&t.set(`kind`,e.kind),e.root_session_id!==void 0&&t.set(`root_session_id`,e.root_session_id);let n=t.size>0?`?${t.toString()}`:``;u(`[AgentClient]`,`sessions.list.request`,e);let r=await i.get(`sessions${n}`);return ee(r.features),u(`[AgentClient]`,`sessions.list.response`,rn(r.sessions)),r}async getSession(e){return i.get(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`})}async ensureDefaultSupervisor(){let e=await i.post(`supervisor/default`,{});if(e?.session_id!==`bamboo-default-supervisor`||typeof e.incarnation_id!=`string`||!e.incarnation_id)throw Error(`The backend did not confirm the default Supervisor identity.`)}async selectRootMode(e,t){return i.post(`sessions/${encodeURIComponent(e)}/root-mode-operations/${encodeURIComponent(t.operationId)}`,{birth_token:t.birthToken,expected_epoch:t.expectedEpoch,enabled:t.enabled,thinking_mode:t.enabled?`ultra`:`standard`})}async recoverRootMode(e,t){return i.post(`sessions/${encodeURIComponent(e)}/root-mode-operations/${encodeURIComponent(t.operationId)}/recover`,{birth_token:t.birthToken,expected_epoch:t.expectedEpoch,enabled:t.enabled,thinking_mode:t.enabled?`ultra`:`standard`})}async getTaskList(e){let t=encodeURIComponent(e),n=await i.get(`task/${t}`);if(!(typeof n.title==`string`||n.items.length>0))return null;let r=new Date().toISOString();return{session_id:n.session_id,title:n.title??`Task List`,items:n.items,created_at:n.created_at??r,updated_at:n.updated_at??r,...n.version===void 0?{}:{version:n.version}}}async getPendingQuestion(e){let t=encodeURIComponent(e);return Xt(e,await i.get(`respond/${t}/pending`,{cache:`no-store`}))}async submitPermissionDecision(e,t){if(!Q(t.request_id)||!Q(t.request_generation)||!$(t.expected_policy_revision)||t.decision!==`allow_once`&&t.decision!==`deny_once`)throw new X;let n=Z(await i.post(`sessions/${encodeURIComponent(e)}/permission-decisions`,t)),r=Z(n?.receipt),a=Z(r?.decision);if(n?.success!==!0||typeof n.replayed!=`boolean`||r?.session_id!==e||a?.request_id!==t.request_id||a?.request_generation!==t.request_generation||a?.decision!==t.decision||a?.matcher_id!=null||a?.expected_policy_revision!=null&&!$(a.expected_policy_revision)||a?.confirm_global!=null&&a.confirm_global!==!1)throw new X;let o=Z(n.resume),s=o?.auto_resume_status,c=n.replayed&&n.resume==null&&n.auto_resume_status==null||o?.success===!0&&typeof s==`string`&&[`started`,`already_running`,`completed`].includes(s)&&n.auto_resume_status===s;return{replayed:n.replayed,autoResumeStatus:typeof s==`string`?s:void 0,continuationConfirmed:c}}async createSession(e){return i.post(`sessions`,e)}async patchSession(e,t){let n=encodeURIComponent(e);await i.patch(`sessions/${n}`,t)}async getSessionPermissionMode(e){return qt(e,await i.fetchRaw(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`}))}async patchSessionPermissionMode(e,t,n){if(!Wt(t)||Gt(n)===null)throw new Kt;let r={permission_mode:t};return qt(e,await i.fetchRaw(`sessions/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"If-Match":n},body:JSON.stringify(r),cache:`no-store`}))}async regenerateSessionTitle(e){let t=encodeURIComponent(e);await i.post(`sessions/${t}/regenerate-title`)}async getSessionSystemPrompt(e){let t=encodeURIComponent(e);return i.get(`sessions/${t}/system-prompt`)}async clearSession(e){let t=encodeURIComponent(e),n=await i.post(`sessions/${t}/clear`);if(n?.success!==!0||n.session_id!==e)throw Error(`Invalid conversation clear receipt`)}async compactSessionContext(e){let t=encodeURIComponent(e),n=await i.postOnce(`sessions/${t}/compact`,void 0,{logicalTimeoutMs:31e4});if(n?.session_id===e){if(n.status===`unchanged`)return n;if(n.status===`compacted`&&Jt(n.usage_before_percent)&&Jt(n.usage_after_percent)){let e=n.token_usage;if(e&&[e.total_tokens,e.system_tokens,e.summary_tokens,e.window_tokens,e.budget_limit,e.segments_removed].every(Jt)&&typeof e.truncation_occurred==`boolean`)return n}}throw Error(`Invalid context compaction receipt`)}async runProjectDream(e){let t=encodeURIComponent(e);return i.post(`sessions/${t}/project-dream/run`)}async truncateSessionMessages(e,t){let n=encodeURIComponent(e);return i.post(`sessions/${n}/messages/truncate`,t)}async restoreSessionState(e,t){let n=encodeURIComponent(e);return i.post(`sessions/${n}/restore`,t)}async patchSessionMessage(e,t,n){let r=encodeURIComponent(e),a=encodeURIComponent(t);await i.patch(`sessions/${r}/messages/${a}`,n)}async deleteSessionMessage(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);await i.delete(`sessions/${n}/messages/${r}`)}async cleanupSessions(e,t){await i.post(`sessions/cleanup`,{mode:e,keep_pinned:t})}async respondToChildApproval(e,t,n){return i.post(`child-approval/${encodeURIComponent(e)}`,{request_id:t,approved:n})}async devResetSessions(){await i.post(`dev/reset`)}async getRunningSessions(){u(`[AgentClient]`,`runs.active.request`,{});let e=await i.get(`runs/active`);return u(`[AgentClient]`,`runs.active.response`,an(e)),e}async listSchedules(){return i.get(`schedules`)}async createSchedule(e){return i.post(`schedules`,e)}async patchSchedule(e,t){let n=encodeURIComponent(e);return i.patch(`schedules/${n}`,t)}async deleteSchedule(e){let t=encodeURIComponent(e);await i.delete(`schedules/${t}`)}async runScheduleNow(e){let t=encodeURIComponent(e);await i.post(`schedules/${t}/run`)}async listScheduleSessions(e){let t=encodeURIComponent(e);return i.get(`schedules/${t}/sessions`)}async listScheduleRuns(e){let t=encodeURIComponent(e);return i.get(`schedules/${t}/runs`)}async subscribeToEvents(e,n,r){let i=r?.signal;if(u(`[AgentClient]`,`events.subscribe.request`,{sessionId:e}),i?.aborted){u(`[AgentClient]`,`events.subscribe.ws.aborted_before_connect`,{sessionId:e});return}let a=await t(()=>import(`./runDiagnostic-DJ_i4o1q.js`).then(e=>e.decodeRunDiagnostic),__vite__mapDeps([0,1]),import.meta.url).catch(()=>void 0);if(i?.aborted)return;let{promise:o,close:s}=zt(e,n,(t,n)=>this.handleEvent(t,n,e,a)),c=()=>{u(`[AgentClient]`,`events.subscribe.ws.abort`,{sessionId:e}),s()};i?.addEventListener(`abort`,c,{once:!0});try{await o}finally{i?.removeEventListener(`abort`,c)}}subscribeToAccountStream(e,t){return Rt(e,t?.since??0)}handleEvent(e,t,n,r){switch(e.type){case`token`:t.onToken?.(e.content||``);break;case`reasoning_token`:t.onReasoningToken?.(e.content||``);break;case`tool_token`:t.onToolToken?.(e.tool_call_id||``,e.content||``);break;case`tool_start`:t.onToolStart?.(e.tool_call_id||``,e.tool_name||``,e.arguments||{});break;case`tool_complete`:e.result&&t.onToolComplete?.(e.tool_call_id||``,e.result);break;case`bash_completed`:t.onBashCompleted?.(e.bash_id??``,e.command??``,e.exit_code??null,typeof e.status==`string`?e.status:`completed`);break;case`tool_error`:t.onToolError?.(e.tool_call_id||``,e.error||``);break;case`task_list_updated`:e.task_list&&t.onTaskListUpdated?.(e.version===void 0?e.task_list:{...e.task_list,version:e.version});break;case`task_list_item_progress`:if(e.session_id&&e.item_id&&e.status&&e.tool_calls_count!==void 0&&e.version!==void 0){let n=e.status;if(!(n===`pending`||n===`in_progress`||n===`completed`||n===`blocked`))break;t.onTaskListItemProgress?.({session_id:e.session_id,item_id:e.item_id,status:n,tool_calls_count:e.tool_calls_count,version:e.version})}break;case`task_list_completed`:e.session_id&&e.total_rounds!==void 0&&e.total_tool_calls!==void 0&&t.onTaskListCompleted?.(e.session_id,e.total_rounds,e.total_tool_calls,e.completed_at);break;case`task_evaluation_started`:e.session_id&&e.items_count!==void 0&&t.onTaskEvaluationStarted?.(e.session_id,e.items_count);break;case`task_evaluation_completed`:e.session_id&&e.updates_count!==void 0&&e.reasoning&&t.onTaskEvaluationCompleted?.(e.session_id,e.updates_count,e.reasoning);break;case`token_budget_updated`:e.usage&&`system_tokens`in e.usage&&t.onTokenBudgetUpdated?.(e.usage);break;case`context_compression_status`:typeof e.phase==`string`&&typeof e.status==`string`&&t.onContextCompressionStatus?.(e.phase,e.status);break;case`tool_lifecycle`:t.onToolLifecycle?.(e.tool_call_id||``,e.tool_name||``,e.phase||``,e.elapsed_ms,e.is_mutating,e.auto_approved,e.summary,e.error);break;case`context_summarized`:{let n=Yt(e.summary_info===void 0?e:e.summary_info);n&&t.onContextSummarized?.(n);break}case`context_pressure_notification`:typeof e.percent==`number`&&typeof e.level==`string`&&t.onContextPressureNotification?.(e.percent,e.level,e.message||``);break;case`sub_agent_started`:e.parent_session_id&&e.child_session_id&&t.onSubAgentStarted?.(e.parent_session_id,e.child_session_id,e.title);break;case`sub_agent_event`:e.parent_session_id&&e.child_session_id&&e.event&&t.onSubAgentEvent?.(e.parent_session_id,e.child_session_id,e.event);break;case`sub_agent_heartbeat`:e.parent_session_id&&e.child_session_id&&e.timestamp&&t.onSubAgentHeartbeat?.(e.parent_session_id,e.child_session_id,e.timestamp);break;case`sub_agent_completed`:e.parent_session_id&&e.child_session_id&&t.onSubAgentCompleted?.(e.parent_session_id,e.child_session_id,typeof e.status==`string`?e.status:`completed`,e.error);break;case`child_approval_requested`:e.child_session_id&&e.request_id&&t.onChildApprovalRequested?.(e.child_session_id,e.request_id,{toolName:e.tool_name,permission:e.permission,resource:e.resource});break;case`execution_started`:t.onExecutionStarted?.(e.run_id||``,e.started_at);break;case`runner_progress`:e.session_id&&typeof e.round_count==`number`&&t.onRunnerProgress?.(e.session_id,e.round_count);break;case`need_clarification`:t.onNeedClarification?.(e);break;case`notification`:t.onNotification?.(e);break;case`session_title_updated`:e.session_id&&typeof e.title==`string`&&typeof e.title_version==`number`&&(e.source===`auto`||e.source===`manual`||e.source===`fallback`)&&typeof e.updated_at==`string`&&t.onSessionTitleUpdated?.({type:`session_title_updated`,session_id:e.session_id,title:e.title,title_version:e.title_version,source:e.source,updated_at:e.updated_at});break;case`session_pinned_updated`:e.session_id&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.onSessionPinnedUpdated?.({type:`session_pinned_updated`,session_id:e.session_id,pinned:e.pinned,updated_at:e.updated_at});break;case`plan_mode_entered`:t.onPlanModeEntered?.(e);break;case`plan_mode_exited`:t.onPlanModeExited?.(e);break;case`plan_file_updated`:t.onPlanFileUpdated?.(e);break;case`goal_status_changed`:t.onGoalStatusChanged?.(e);break;case`message_appended`:e.session_id&&t.onMessageAppended?.(e.session_id,e.message_id);break;case`session_history_committed`:e.session_id&&t.onSessionHistoryCommitted?.(e.session_id);break;case`complete`:u(`[AgentClient]`,`events.dispatch.complete`,on(e)),t.onComplete?.(e.usage);break;case`cancelled`:u(`[AgentClient]`,`events.dispatch.cancelled`,on(e)),t.onCancelled?.(e.message);break;case`error`:if(u(`[AgentClient]`,`events.dispatch.error`,on(e)),e.session_id&&e.session_id!==n)break;{let i=e.message||e.error||`Unknown error`,a=r?.(e.diagnostic,n,i);a?t.onError?.(i,a):t.onError?.(i)}break;default:console.warn(`Unknown event type:`,e)}}async stopGeneration(e,t){if(t!==void 0){if(!s(t))throw Error(`Invalid execution identity`);await i.post(`stop/${encodeURIComponent(e)}`,void 0,{headers:{"Bamboo-Run-Id":t}});return}vt(e)||await i.post(`stop/${encodeURIComponent(e)}`)}async deleteSession(e){let t=encodeURIComponent(e);await i.delete(`sessions/${t}`)}async getHistory(e,t){u(`[AgentClient]`,`history.request`,{sessionId:e,sinceMessageId:t});let n=t?`history/${encodeURIComponent(e)}?since_message_id=${encodeURIComponent(t)}`:`history/${encodeURIComponent(e)}`,r=await i.get(n,{cache:`no-store`});return u(`[AgentClient]`,`history.response`,nn(r)),r}async getMessageHistory(e,t){let n=new URLSearchParams({projection:`messages`});t&&n.set(`since_message_id`,t);let r=`sessions/${encodeURIComponent(e)}/history?${n.toString()}`;return $t(e,await i.get(r,{cache:`no-store`}))}async healthCheck(){try{return await i.get(`health`),!0}catch{return!1}}},ln=cn.getInstance();export{o as _,Wt as a,ut as c,Bt as d,u as f,a as g,s as h,Ut as i,Vt as l,te as m,Kt as n,Gt as o,ne as p,ln as r,dt as s,cn as t,Ht as u};
|
|
2
|
+
import{i as e}from"./runtimeConfig-DNyol2mX.js";import{t}from"./preload-helper-DYl5dUZ5.js";import{r as n}from"./ui-C2RfJtHm.js";import{c as r,t as i}from"./api-CPcpMjoM.js";async function a(){let e;try{e=await i.get(`execute/defaults`,{cache:`no-store`})}catch(e){return r(e)&&e.status===404?`unsupported`:`unknown`}if(!e||typeof e!=`object`||Array.isArray(e))return`unknown`;if(!(`upstream_retry`in e)){let t=e;return typeof t.system_prompt==`string`&&typeof t.base_system_prompt==`string`&&(t.default_session_permission_mode===void 0||[`default`,`auto`,`bypass`].includes(t.default_session_permission_mode))&&(t.model===null||typeof t.model==`string`)?`unsupported`:`unknown`}let t=e.upstream_retry;return!t||typeof t!=`object`||Array.isArray(t)||!(`supported_modes`in t)||!Array.isArray(t.supported_modes)||!t.supported_modes.every(e=>typeof e==`string`)?`unknown`:t.supported_modes.includes(`until_cancelled`)?`supported`:`unsupported`}async function o(){return await a()===`supported`}var s=e=>typeof e==`string`&&/^[!-~]{1,128}$/.test(e),c=null,l=new Set,ee=e=>{c=new Set(e??[]);for(let e of l)e()},te=e=>c?.has(e)??!1,ne=()=>!1,re=e=>{if(!ne())return!1;try{return localStorage.getItem(e)===`1`}catch{return!1}},u=(e,t,...n)=>{ne()&&re(`bodhi_debug_verbose`)&&console.log(`${e} ${t}`,...n)},ie=`bodhi_api_v2_msgpack`,ae=()=>{try{return localStorage.getItem(ie)===`1`}catch{return!1}};function oe(e){let t=e.length,n=0,r=0;for(;r<t;){let i=e.charCodeAt(r++);if(!(i&4294967168)){n++;continue}else if(!(i&4294965248))n+=2;else{if(i>=55296&&i<=56319&&r<t){let t=e.charCodeAt(r);(t&64512)==56320&&(++r,i=((i&1023)<<10)+(t&1023)+65536)}i&4294901760?n+=4:n+=3}}return n}function se(e,t,n){let r=e.length,i=n,a=0;for(;a<r;){let n=e.charCodeAt(a++);if(!(n&4294967168)){t[i++]=n;continue}else if(!(n&4294965248))t[i++]=n>>6&31|192;else{if(n>=55296&&n<=56319&&a<r){let t=e.charCodeAt(a);(t&64512)==56320&&(++a,n=((n&1023)<<10)+(t&1023)+65536)}n&4294901760?(t[i++]=n>>18&7|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128):(t[i++]=n>>12&15|224,t[i++]=n>>6&63|128)}t[i++]=n&63|128}}var ce=new TextEncoder,le=50;function ue(e,t,n){ce.encodeInto(e,t.subarray(n))}function de(e,t,n){e.length>le?ue(e,t,n):se(e,t,n)}var fe=4096;function pe(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=fe&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}var me=new TextDecoder,he=200;function ge(e,t,n){let r=e.subarray(t,t+n);return me.decode(r)}function _e(e,t,n){return n>he?ge(e,t,n):pe(e,t,n)}var d=class{type;data;constructor(e,t){this.type=e,this.data=t}},f=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};function ve(e,t,n){let r=n/4294967296,i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function ye(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function be(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function xe(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}var Se=4294967295,Ce=17179869183;function we({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=Ce)if(t===0&&e<=Se){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),ye(r,4,e),n}}function Te(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function Ee(e){return e instanceof Date?we(Te(e)):null}function De(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:be(t,4),nsec:t.getUint32(0)};default:throw new f(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function Oe(e){let t=De(e);return new Date(t.sec*1e3+t.nsec/1e6)}var ke={type:-1,encode:Ee,decode:Oe},Ae=class e{static defaultCodec=new e;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ke)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new d(-1-n,i)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let i=r(e,t);if(i!=null)return new d(n,i)}}return e instanceof d?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new d(t,e)}};function je(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function Me(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):je(e)?new Uint8Array(e):Uint8Array.from(e)}var Ne=class e{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ae.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??100,this.initialBufferSize=e?.initialBufferSize??2048,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e==`boolean`?this.encodeBoolean(e):typeof e==`number`?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e==`string`?this.encodeString(e):this.useBigInt64&&typeof e==`bigint`?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let t=oe(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),de(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e==`object`)this.encodeMap(e,t);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw Error(`Too large binary: ${t}`);let n=Me(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw Error(`Too large array: ${n}`);for(let n of e)this.doEncode(n,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw Error(`Too large map object: ${r}`);for(let r of n){let n=e[r];this.ignoreUndefined&&n===void 0||(this.encodeString(r),this.doEncode(n,t+1))}}encodeExtension(e){if(typeof e.data==`function`){let t=e.data(this.pos+6),n=t.length;if(n>=4294967296)throw Error(`Too large extension object: ${n}`);this.writeU8(201),this.writeU32(n),this.writeI8(e.type),this.writeU8a(t);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),ve(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ye(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function Pe(e,t){return new Ne(t).encodeSharedRef(e)}function Fe(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var Ie=16,Le=16,Re=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Ie,t=Le){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let i=pe(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}},p=`array`,m=`map_key`,ze=`map_value`,Be=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new f(`The type of key must be string or number but `+typeof e)},Ve=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=p,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=m,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===p){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===m||e.type===ze){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},h=-1,g=new DataView(new ArrayBuffer(0)),He=new Uint8Array(g.buffer);try{g.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}var Ue=RangeError(`Insufficient data`),We=new Re,Ge=class e{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=g;bytes=He;headByte=h;stack=new Ve;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??Ae.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder===void 0?We:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??Be}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=h,this.stack.reset()}setBuffer(e){let t=Me(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===h&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=Me(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${Fe(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new f(`Unrecognized type byte: ${Fe(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===p)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===m){if(t===`__proto__`)throw new f(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=ze;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=m;continue DECODE}}return t}}readHeadByte(){return this.headByte===h&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=h}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new f(`Unrecognized array type byte: ${Fe(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new f(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new f(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new f(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ue;let n=this.pos+t,r;return r=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):_e(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===m:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new f(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ue;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new f(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=xe(this.view,this.pos);return this.pos+=8,e}readI64(){let e=be(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Ke(e,t){return new Ge(t).decode(e)}var qe=new TextEncoder,_=e=>typeof e==`object`&&!!e&&!Array.isArray(e),v=(e,t)=>Object.keys(e).length===t.length&&t.every(t=>Object.hasOwn(e,t)),y=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,b=e=>typeof e==`string`&&e.length>0&&e.trim()===e&&qe.encode(e).length<=256&&!e.includes(`..`)&&!/[\\/]/.test(e)&&![...e].some(e=>{let t=e.codePointAt(0);return t<32||t>=127&&t<=159||t>=55296&&t<=57343||t>=8234&&t<=8238||t>=8294&&t<=8297}),Je=e=>{if(typeof e!=`string`)return!1;if(e.length===32)return/^[0-9a-f]{32}$/i.test(e);let t=e.length===38&&e.startsWith(`{`)&&e.endsWith(`}`)?e.slice(1,-1):e.length===45&&e.startsWith(`urn:uuid:`)?e.slice(9):e;return t.length===36&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)};function Ye(e,t){if(!b(t)||!_(e)||e.ch!==`actor.${t}`||!y(e.seq))return null;if(v(e,[`ch`,`seq`,`control`])&&_(e.control)){let t=e.control;if(v(t,[`type`,`epoch`,`cursor`,`resumed_from`])&&t.type===`actor_replay_complete`&&typeof t.epoch==`string`&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t.epoch)&&t.cursor===e.seq&&(t.resumed_from===null||y(t.resumed_from)&&t.resumed_from<=e.seq))return{type:`replay_complete`,seq:e.seq,control:t};if(v(t,[`type`,`reason`,`cursor`])&&t.type===`actor_snapshot_required`&&(t.reason===`initial`||t.reason===`gap`)&&t.cursor===e.seq)return{type:`control`,seq:e.seq,control:t}}if(v(e,[`ch`,`seq`,`event`])&&_(e.event)){let n=e.event;if(v(n,[`type`,`actor_id`,`root_actor_id`,`parent_actor_id`,`activation_id`,`attempt`,`event_id`,`class`])&&n.type===`actor_changed`&&n.actor_id===t&&b(n.root_actor_id)&&(n.parent_actor_id===null||b(n.parent_actor_id))&&Je(n.activation_id)&&y(n.attempt)&&typeof n.event_id==`string`&&/^ae1-[0-9a-f]{64}$/.test(n.event_id)&&(n.class===`lifecycle`||n.class===`semantic`||n.class===`snapshot`||n.class===`ephemeral`))return{type:`event`,seq:e.seq,event:n}}return null}var Xe=15e3,Ze=500,Qe=15e3,$e=4e4,et=1e3,tt=5e3,nt=5e3,rt=`bamboo.v2.msgpack`,x=e=>typeof e==`object`&&!!e&&!Array.isArray(e),S=(e,t)=>{let n=Object.keys(e).sort(),r=[...t].sort();return n.length===r.length&&n.every((e,t)=>e===r[t])},C=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,w=e=>{if(typeof e!=`string`)return null;let t=/^at1-([0-9a-f]{64})-([1-9][0-9]*)$/.exec(e);if(!t)return null;let n=Number(t[2]);return Number.isSafeInteger(n)&&n>0?{scope:t[1],revision:n}:null},T=(e,t)=>{let n=w(e),r=w(t);return n!==null&&r!==null&&n.scope===r.scope&&n.revision>=r.revision},it=e=>e===`complete`||e===`cancelled`||e===`error`,at=e=>!x(e)||!S(e,[`id`,`content`,`created_at`])||typeof e.id!=`string`||typeof e.content!=`string`||typeof e.created_at!=`string`?null:e,ot=e=>{if(e.control!==void 0||!E(e.seq)||!x(e.event)||!S(e,[`ch`,`seq`,`event`]))return null;let t=e.event;if(t.type===`snapshot`){if(!S(t,t.terminal===void 0?[`type`,`version`,`messages`,`history_committed`]:[`type`,`version`,`messages`,`history_committed`,`terminal`])||!C(t.version)||!Array.isArray(t.messages)||typeof t.history_committed!=`boolean`||t.terminal!==void 0&&!it(t.terminal))return null;let e=t.messages.map(at);return e.some(e=>e===null)?null:{...t,messages:e}}return t.type===`started`?!S(t,[`type`,`version`,`message_id`,`created_at`])||!C(t.version)||typeof t.message_id!=`string`||typeof t.created_at!=`string`?null:t:t.type===`delta`?!S(t,[`type`,`version`,`message_id`,`offset`,`content`,`created_at`])||!C(t.version)||!C(t.offset)||typeof t.message_id!=`string`||typeof t.content!=`string`||typeof t.created_at!=`string`?null:t:t.type===`discarded`?!S(t,[`type`,`version`,`message_id`])||!C(t.version)||typeof t.message_id!=`string`?null:t:null},st=e=>{if(e.event!==void 0||!E(e.seq)||!x(e.control)||!S(e,[`ch`,`seq`,`control`]))return null;let t=e.control;return t.type===`gap`&&S(t,[`type`,`skipped`])&&C(t.skipped)||t.type===`terminal`&&S(t,[`type`,`reason`])&&it(t.reason)||t.type===`history_committed`&&S(t,[`type`,`version`])&&C(t.version)?t:null},E=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>0,ct=e=>{if(!E(e.seq)||e.control!==void 0||!x(e.event))return null;let t=e.event;return!E(t.seq)||t.seq!==e.seq||typeof t.ts!=`string`||t.session_id!==void 0&&typeof t.session_id!=`string`||!x(t.event)||typeof t.event.type!=`string`?null:t},lt=e=>e.seq!==0||e.event!==void 0||!x(e.control)||e.control.type!==`feed_reset`||!E(e.control.from_seq)?null:e.control.from_seq,D=null,O=!1,k=0,A=null,j=!1,M=!1,N=null,P=new Set,ut=e=>(P.add(e),()=>P.delete(e)),F=(e=D)=>{let t=N;return e!==null&&D===e&&e.readyState===WebSocket.OPEN&&t!==null&&t.socket===e&&t.phase===`ready`},I=null,dt=()=>F()&&I!==null&&!I.deliveryFailed&&I.subscribedSince!==null,L=new Map,R=new Map,z=new Map,B=new Map,ft=e=>`agent.${e}`,pt=e=>`message.${e}`,mt=e=>`actor.${e}`,ht=e=>`tree.${e}`,V=()=>I!==null&&!I.deliveryFailed||L.size>0||R.size>0||z.size>0||B.size>0,gt=(e,t)=>{if(!x(e)||!S(e,[`ch`,`seq`,`control`])||e.ch!==ht(t)||!x(e.control)||!S(e.control,[`type`,`reason`,`cursor`])||e.control.type!==`actor_snapshot_required`)return null;let n=e.control.reason;if(n!==`initial`&&n!==`gap`&&n!==`changed`&&n!==`unavailable`)return null;let r=e.control.cursor;if(r===null){if(e.seq!==0||n===`changed`)return null}else{let t=w(r);if(!t||e.seq!==t.revision||n===`unavailable`)return null}return{type:`actor_snapshot_required`,reason:n,cursor:r}},_t=e=>e.protocol===rt,H=(e,t)=>{if(D===e&&e.readyState===WebSocket.OPEN)try{return e.send(_t(e)?Pe(t):JSON.stringify(t)),!0}catch(e){u(`[v2Stream]`,`send.error`,{payload:t,error:e})}return!1},U=e=>D!==null&&H(D,e),vt=e=>!e||!F()?!1:U({type:`stop`,session_id:e}),yt=(e,t)=>{let n=e.since;return e.subscribedSince=null,e.acceptedInSubscription=!1,e.resetHandledInSubscription=!1,H(t,{type:`subscribe`,ch:`feed`,since:n})?(e.subscribedSince=n,!0):!1},bt=(e,t,n)=>{if(console.warn(`Failed to ${t} v2 feed:`,n),!(I!==e||e.deliveryFailed)){e.deliveryFailed=!0,e.subscribedSince=null,F()&&U({type:`unsubscribe`,ch:`feed`});try{e.handlers.onError?.()}catch(e){console.warn(`Failed to report v2 feed handler error:`,e)}J()}},W=e=>{e.resume?.timer!==null&&e.resume?.timer!==void 0&&clearTimeout(e.resume.timer),e.resume=null},G=e=>{if(e.resume&&(e.resume.failed=!0),e.epoch=null,!e.gapNotified){e.gapNotified=!0;for(let t of[...e.subscribers])try{t.onGap()}catch(e){u(`[v2Stream]`,`actor.gap_listener_error`,{error:e})}}},xt=(e,t,n)=>{W(e);let r={socket:n,anchorEpoch:e.epoch,anchorCursor:e.cursor,awaitingReset:!0,resetCursor:null,failed:!1,timer:null};return e.resume=r,r.anchorEpoch!==null&&r.anchorCursor!==null&&(r.timer=setTimeout(()=>{D!==n||z.get(t)!==e||e.resume!==r||(W(e),G(e))},nt)),H(n,{type:`subscribe`,ch:t,...e.cursor===null?{}:{since:e.cursor},actor_resume:{epoch:e.epoch}})},St=e=>{if(I&&!I.deliveryFailed&&!yt(I,e))return!1;for(let t of L.keys())if(!H(e,{type:`subscribe`,ch:t}))return!1;for(let t of R.keys())if(!H(e,{type:`subscribe`,ch:t}))return!1;for(let[t,n]of z)if(!xt(n,t,e))return!1;for(let[t,n]of B)if(!H(e,n.cursor===null?{type:`subscribe_tree`,ch:t}:{type:`subscribe_tree`,ch:t,cursor:n.cursor}))return!1;return!0},Ct=()=>{A&&=(clearTimeout(A),null)},wt=()=>{if(!V()||j||A)return;let e=Math.min(Ze*2**k,Xe);k+=1,u(`[v2Stream]`,`reconnect.schedule`,{attempt:k,delay:e}),A=setTimeout(()=>{A=null,Y()},e)},K=e=>{let t=N;if(!(!t||e&&t.socket!==e)){t.welcomeTimer!==null&&(clearTimeout(t.welcomeTimer),t.welcomeTimer=null),t.heartbeatTimer!==null&&(clearInterval(t.heartbeatTimer),t.heartbeatTimer=null),t.watchdogTimer!==null&&(clearInterval(t.watchdogTimer),t.watchdogTimer=null),t.visibilityListener&&typeof document<`u`&&(document.removeEventListener(`visibilitychange`,t.visibilityListener),t.visibilityListener=null);for(let e of[...z.values()]){let n=e.resume;n?.socket===t.socket&&(n.anchorEpoch!==null&&e.cursor!==n.anchorCursor&&G(e),W(e))}N===t&&(N=null)}},Tt=e=>{let t=D;if(!t||e&&t!==e)return!1;K(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}return D===t&&(D=null),!0},Et=()=>{try{I?.handlers.onError?.()}catch(e){u(`[v2Stream]`,`unavailable.listener_error`,{error:e})}},q=(e,t)=>{N!==e||D!==e.socket||e.recoveryStarted||(e.recoveryStarted=!0,I&&(I.subscribedSince=null,I.acceptedInSubscription=!1,I.resetHandledInSubscription=!1),M=!0,u(`[v2Stream]`,`epoch.unavailable`,{reason:t}),Et(),Tt(e.socket),O=!1,wt())},Dt=e=>{N!==e||D!==e.socket||e.recoveryStarted||(u(`[v2Stream]`,`watchdog.stale_socket`,{silentForMs:Date.now()-e.lastFrameAt}),q(e,`heartbeat-stale`))},Ot=e=>{N!==e||D!==e.socket||e.socket.readyState!==WebSocket.OPEN||e.phase!==`ready`||!e.heartbeatAckSeen||Date.now()-e.lastFrameAt>=$e&&Dt(e)},kt=e=>{K();let t={socket:e,phase:`awaiting-welcome`,lastFrameAt:Date.now(),pingSent:!1,heartbeatAckSeen:!1,recoveryStarted:!1,welcomeTimer:null,heartbeatTimer:null,watchdogTimer:null,visibilityListener:null};return N=t,t.welcomeTimer=setTimeout(()=>{N!==t||D!==e||t.phase!==`awaiting-welcome`||q(t,`welcome-timeout`)},tt),t},At=e=>{let t=e.socket;e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.lastFrameAt=Date.now(),e.heartbeatTimer=setInterval(()=>{N!==e||D!==t||t.readyState!==WebSocket.OPEN||e.phase!==`ready`||H(t,{type:`ping`})&&(e.pingSent=!0)},Qe),e.watchdogTimer=setInterval(()=>Ot(e),et),typeof document<`u`&&(e.visibilityListener=()=>{document.visibilityState===`visible`&&Ot(e)},document.addEventListener(`visibilitychange`,e.visibilityListener))},jt=e=>{let t=N;return!t||t.socket!==e||D!==e||t.phase!==`ready`?null:(t.lastFrameAt=Date.now(),t)},Mt=e=>{!e||!e.pingSent||e.heartbeatAckSeen||(e.heartbeatAckSeen=!0,u(`[v2Stream]`,`heartbeat.acknowledged`,{}))},J=()=>{V()||(j=!0,Ct(),Tt(),K(),O=!1,k=0,M=!1)},Nt=e=>{try{if(typeof e==`string`)return JSON.parse(e);if(e instanceof ArrayBuffer)return Ke(new Uint8Array(e));if(ArrayBuffer.isView(e)){let t=e;return Ke(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}u(`[v2Stream]`,`frame.unknown_data_type`,{});return}catch(t){console.warn(`Failed to parse v2 stream frame:`,e,t);return}},Pt=e=>x(e)&&Object.keys(e).length===1&&Object.prototype.hasOwnProperty.call(e,`type`)&&e.type===`welcome`,Ft=e=>x(e)&&e.type===`welcome`,It=e=>{let t=e.socket;if(N!==e||D!==t||t.readyState!==WebSocket.OPEN||e.phase!==`awaiting-welcome`)return;if(e.welcomeTimer!==null&&(clearTimeout(e.welcomeTimer),e.welcomeTimer=null),e.phase=`subscribing`,!V()){J();return}if(!St(t)){q(e,`subscribe-send-failed`);return}if(N!==e||D!==t||!V()){J();return}e.phase=`ready`,k=0;let n=M;if(M=!1,At(e),u(`[v2Stream]`,`ready`,{afterDrop:n}),n){for(let e of[...z.values()])e.resume?.anchorEpoch&&e.resume.anchorCursor!==null||(e.cursor=null,e.lastControl=null,G(e));for(let e of[...B.values()]){e.lastControl=null,e.gapNotified=!0;for(let t of[...e.subscribers])try{t.onGap()}catch(e){u(`[v2Stream]`,`tree.gap_listener_error`,{error:e})}}}if(I&&!I.deliveryFailed&&I.subscribedSince!==null)try{I.handlers.onOpen?.()}catch(e){u(`[v2Stream]`,`feed.open_listener_error`,{error:e})}if(!(N!==e||D!==t||e.phase!==`ready`||!V())&&n)for(let e of[...P])try{e()}catch(e){u(`[v2Stream]`,`reconnected.listener_error`,{error:e})}},Lt=(e,t)=>{if(e?.type===`pong`&&e.ch===void 0){Mt(t);return}if(!e||typeof e.ch!=`string`){u(`[v2Stream]`,`frame.unknown`,{});return}let{ch:n,control:r,event:i}=e;if(n!==`sys`){if(n===`feed`){let t=I;if(!t||t.deliveryFailed||t.subscribedSince===null)return;if(r){let n=lt(e);if(n!==null&&n===t.subscribedSince&&!t.acceptedInSubscription&&!t.resetHandledInSubscription){u(`[v2Stream]`,`feed.reset`,{});let e=t.handlers.onReset;if(!e){bt(t,`apply reset`,Error(`feed_reset requires an application reset handler`));return}let r=t.since;t.since=0;try{e()}catch(e){t.since=r,bt(t,`apply reset`,e);return}I===t&&!t.deliveryFailed&&(t.resetHandledInSubscription=!0,t.postResetFloor=n)}else u(`[v2Stream]`,`feed.control.invalid`,{});return}let n=ct(e);if(!n){u(`[v2Stream]`,`feed.frame.invalid_event`,{});return}let i=Math.max(t.since,t.postResetFloor??0);if(n.seq<=i){u(`[v2Stream]`,`feed.frame.stale`,{seq:n.seq,since:i});return}try{t.handlers.onChange(n)}catch(e){bt(t,`apply event`,e);return}I===t&&(t.since=n.seq,t.acceptedInSubscription=!0,t.postResetFloor=null);return}if(n.startsWith(`message.`)){let t=R.get(n);if(!t||t.size===0)return;if(r!==void 0){let r=st(e);if(!r){u(`[v2Stream]`,`message.frame.invalid_control`,{ch:n});return}for(let e of[...t])e.handlers.onControl(r);return}let i=ot(e);if(!i){u(`[v2Stream]`,`message.frame.invalid_event`,{ch:n});return}for(let e of[...t])e.handlers.onEvent(i);return}if(n.startsWith(`tree.`)){let t=B.get(n);if(!t)return;let r=gt(e,t.rootId);if(!r){if(!t.gapNotified){t.gapNotified=!0;for(let e of[...t.subscribers])e.onGap()}return}if(r.cursor!==null&&T(t.cursor,r.cursor)||t.lastControl?.reason===r.reason&&t.lastControl.cursor===r.cursor)return;t.lastControl=r,t.gapNotified=!1;for(let e of[...t.subscribers])e.onControl(r);return}if(n.startsWith(`actor.`)){let t=z.get(n);if(!t)return;let r=Ye(e,t.actorId);if(!r){G(t);return}let i=t.resume;if(r.type===`replay_complete`){if(!i||i.socket!==D)return;let e=r.control,n=!i.failed&&i.anchorEpoch!==null&&e.epoch===i.anchorEpoch&&e.resumed_from===i.anchorCursor&&i.resetCursor===null&&e.cursor===t.cursor,a=e.resumed_from===null&&i.resetCursor!==null&&e.cursor===i.resetCursor&&e.cursor===t.cursor;W(t),n||a?t.epoch=e.epoch:G(t);return}if(r.type===`control`){if(t.cursor!==null&&r.seq<=t.cursor&&!i?.awaitingReset)return;let e=i?.anchorEpoch!==null&&i?.anchorEpoch!==void 0;i&&(i.awaitingReset=!1,i.resetCursor=r.seq),e&&G(t),t.cursor=r.seq,e||(t.gapNotified=!1),t.lastControl=r.control;for(let e of[...t.subscribers])e.onControl(r.control);return}if(i&&(i.awaitingReset=!1),t.cursor===null||r.seq>t.cursor+1)G(t);else if(r.seq<=t.cursor)return;t.cursor=r.seq;for(let e of[...t.subscribers])e.onEvent(r.event,r.seq);return}if(n.startsWith(`agent.`)){let e=L.get(n);if(!e||e.size===0)return;if(r){if(r.type===`terminal`){u(`[v2Stream]`,`agent.terminal`,{ch:n,subscribers:e.size});for(let t of[...e])t.resolve()}return}if(i===void 0){u(`[v2Stream]`,`agent.frame.no_event`,{});return}for(let t of[...e])try{t.dispatch(i,t.handlers)}catch(e){console.warn(`Failed to dispatch v2 agent event:`,i,e)}return}u(`[v2Stream]`,`frame.unknown_channel`,{ch:n})}},Y=()=>{if(!V()||D&&(D.readyState===WebSocket.OPEN||D.readyState===WebSocket.CONNECTING)||O)return;if(typeof WebSocket>`u`){u(`[v2Stream]`,`connect.no_websocket`,{});return}O=!0,j=!1;let t=e().endpoints.v2Stream;u(`[v2Stream]`,`connect`,{url:t});let n=ae(),r;try{r=n?new WebSocket(t,[rt]):new WebSocket(t),n&&(r.binaryType=`arraybuffer`)}catch(e){O=!1,u(`[v2Stream]`,`connect.error`,{error:e}),I?.handlers.onError?.(),wt();return}D=r,r.onopen=()=>{if(D!==r)return;O=!1;let e=kt(r);u(`[v2Stream]`,`open.awaiting_welcome`,{}),H(r,{type:`hello`})||q(e,`hello-send-failed`)},r.onmessage=e=>{if(D!==r)return;let t=Nt(e.data),n=N;if(!(!n||n.socket!==r)){if(n.phase===`awaiting-welcome`){Pt(t)?It(n):u(`[v2Stream]`,`frame.before_welcome`,{});return}n.phase!==`subscribing`&&(Ft(t)||Lt(t,jt(r)))}},r.onerror=()=>{D===r&&(u(`[v2Stream]`,`error`,{}),Et())},r.onclose=()=>{D===r&&(O=!1,K(r),u(`[v2Stream]`,`close`,{intentional:j}),D=null,!j&&(M=!0,I&&(I.subscribedSince=null),Et(),wt()))}},Rt=(e,t)=>{I={handlers:e,since:E(t)?t:0,deliveryFailed:!1,subscribedSince:null,acceptedInSubscription:!1,resetHandledInSubscription:!1,postResetFloor:null};let n=I;if(D&&F(D)){if(!yt(n,D)){let e=N;e&&q(e,`feed-subscribe-send-failed`)}}else Y();let r=!1;return{close(){r||(r=!0,I===n&&(I=null,F()&&U({type:`unsubscribe`,ch:`feed`}),J()))}}},zt=(e,t,n)=>{let r=ft(e),i=!1,a=()=>{},o={sessionId:e,handlers:t,dispatch:n,resolve:()=>a()},s=new Promise(e=>{a=()=>{if(i)return;i=!0;let t=L.get(r);t?.delete(o),(!t||t.size===0)&&(L.delete(r),F()&&U({type:`unsubscribe`,ch:r}),J()),e()}}),c=L.get(r),l=!c||c.size===0;if(c?c.add(o):L.set(r,new Set([o])),D&&F(D)){if(l&&!H(D,{type:`subscribe`,ch:r})){let e=N;e&&q(e,`agent-subscribe-send-failed`)}}else Y();return{promise:s,close:()=>a()}},Bt=(e,t)=>{let n=pt(e),r={handlers:t},i=R.get(n),a=!i||i.size===0;if(i?i.add(r):R.set(n,new Set([r])),D&&F(D)){if(a&&!H(D,{type:`subscribe`,ch:n})){let e=N;e&&q(e,`message-subscribe-send-failed`)}}else Y();let o=!1;return{close(){if(o)return;o=!0;let e=R.get(n);e?.delete(r),(!e||e.size===0)&&(R.delete(n),F()&&U({type:`unsubscribe`,ch:n}),J())}}},Vt=(e,t)=>{if(!b(e))throw Error(`Invalid ActorId`);let n=mt(e),r=z.get(n),i=!r;r||(r={actorId:e,subscribers:new Set,cursor:null,gapNotified:!1,lastControl:null,epoch:null,resume:null},z.set(n,r));let a=r;if(a.subscribers.add(t),D&&F(D)){if(i&&!xt(a,n,D)){let e=N;e&&q(e,`actor-subscribe-send-failed`)}}else Y();a.gapNotified?t.onGap():a.lastControl&&t.onControl(a.lastControl);let o=!1;return{close(){o||(o=!0,a.subscribers.delete(t),a.subscribers.size===0&&z.get(n)===a&&(W(a),z.delete(n),F()&&U({type:`unsubscribe`,ch:n}),J()))}}},Ht=(e,t,n)=>{if(!b(e)||t!==null&&!w(t))throw Error(`Invalid Actor tree subscription`);let r=ht(e),i=B.get(r),a=!i,o=!1,s;i?i.cursor!==t&&(t!==null&&(i.cursor===null||T(t,i.cursor))?(i.cursor=t,i.lastControl=null,i.gapNotified=!1,s=t,a=!0):t!==null&&T(i.cursor,t)?o=!0:(i.cursor=null,i.lastControl=null,i.gapNotified=!0,a=!0)):(i={rootId:e,subscribers:new Set,cursor:t,gapNotified:!1,lastControl:null},B.set(r,i));let c=i;if(c.subscribers.add(n),s!==void 0)for(let e of[...c.subscribers])e!==n&&e.onControl({type:`actor_snapshot_required`,reason:`changed`,cursor:s});if(D&&F(D)){if(a&&!H(D,c.cursor===null?{type:`subscribe_tree`,ch:r}:{type:`subscribe_tree`,ch:r,cursor:c.cursor})){let e=N;e&&q(e,`tree-subscribe-send-failed`)}}else Y();c.gapNotified||o?n.onGap():c.lastControl&&n.onControl(c.lastControl);let l=!1;return{close(){l||(l=!0,c.subscribers.delete(n),c.subscribers.size===0&&B.get(r)===c&&(B.delete(r),F()&&U({type:`unsubscribe`,ch:r}),J()))}}},Ut=e=>e===`standard`||e===`ultra`,Wt=e=>e==="default"||e===`bypass`||e===`auto`?e:null,Gt=e=>{if(typeof e!=`string`||!/^"\d{1,20}"$/.test(e))return null;let t=BigInt(e.slice(1,-1));return t<=18446744073709551615n?t:null},Kt=class extends Error{constructor(){super(`The backend did not confirm a supported, revisioned session permission mode.`),this.name=`SessionPermissionContractError`}},qt=async(e,t)=>{let n=await t.json(),r=n&&typeof n==`object`&&`session`in n?n.session:null,i=r&&typeof r==`object`&&`permission_mode`in r?Wt(r.permission_mode):null,a=t.headers.get(`ETag`);if(!r||typeof r!=`object`||!(`id`in r)||r.id!==e||!i||!a||Gt(a)===null)throw new Kt;return{sessionId:e,mode:i,etag:a}},Jt=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0,Yt=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.summary!=`string`||typeof t.messages_summarized!=`number`||!Number.isSafeInteger(t.messages_summarized)||t.messages_summarized<0||typeof t.tokens_saved!=`number`||!Number.isSafeInteger(t.tokens_saved)||t.tokens_saved<0?null:{summary:t.summary,messages_summarized:t.messages_summarized,tokens_saved:t.tokens_saved}},X=class extends Error{constructor(){super(n(`the_current_request_could_not_be_confirmed_refresh_and__015fae5f`)),this.name=`PendingInteractionContractError`}},Z=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:null,Q=e=>typeof e==`string`&&e.trim().length>0,$=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function Xt(e,t){let n=Z(t);if(!n)throw new X;if(n.has_pending_question===!1&&n.interaction_kind==null&&n.permission_request==null)return{has_pending_question:!1};if(n.has_pending_question!==!0||typeof n.question!=`string`||!Array.isArray(n.options)||!n.options.every(e=>typeof e==`string`)||typeof n.allow_custom!=`boolean`||!Q(n.tool_call_id))throw new X;if(n.interaction_kind===`clarification`&&n.permission_request==null)return n;let r=Z(n.permission_request);if(n.interaction_kind!==`permission`||!r||r.session_id!==e||r.request_id!==n.tool_call_id||!Q(r.request_generation)||!$(r.policy_revision)||![`tool_name`,`permission_type`,`resource`,`operation_summary`].every(e=>typeof r[e]==`string`)||!Array.isArray(r.allowed_decisions)||!r.allowed_decisions.every(e=>typeof e==`string`))throw new X;return n}var Zt=class extends Error{constructor(){super(`The backend returned an invalid message-only history response.`),this.name=`MessageHistoryContractError`}},Qt=(e,t)=>{let n=Object.keys(e).sort(),r=[...t].sort();return n.length===r.length&&n.every((e,t)=>e===r[t])},$t=(e,t)=>{let n=Z(t);if(!n||!Qt(n,[`session_id`,`projection`,`messages`,`is_delta`,`truncated`,`total_message_count`])||n.session_id!==e||n.projection!==`messages`||!Array.isArray(n.messages)||typeof n.is_delta!=`boolean`||typeof n.truncated!=`boolean`||!$(n.total_message_count))throw new Zt;for(let e of n.messages){let t=Z(e);if(!t||Object.keys(t).some(e=>![`id`,`role`,`content`,`created_at`,`thread_id`,`in_reply_to`,`correlation_id`].includes(e))||[`thread_id`,`in_reply_to`,`correlation_id`].some(e=>t[e]!==void 0&&(typeof t[e]!=`string`||t[e].length>128))||typeof t.id!=`string`||t.role!==`user`&&t.role!==`assistant`||typeof t.content!=`string`||typeof t.created_at!=`string`)throw new Zt}return n},en=e=>e?{client_message_count:e.client_message_count,client_last_message_id:e.client_last_message_id??null,client_has_pending_question:e.client_has_pending_question,client_pending_question_tool_call_id:e.client_pending_question_tool_call_id??null}:null,tn=e=>e?{need_sync:e.need_sync,reason:e.reason??null,server_message_count:e.server_message_count,server_last_message_id:e.server_last_message_id??null,has_pending_question:e.has_pending_question,pending_question_tool_call_id:e.pending_question_tool_call_id??null,has_pending_user_message:e.has_pending_user_message}:null,nn=e=>{let t=e.messages[e.messages.length-1];return{session_id:e.session_id,messageCount:e.messages.length,lastMessageId:t?.id??null,lastRole:t?.role??null,compressionEvents:e.compression_events?.length??0}},rn=e=>({count:e.length,runningCount:e.filter(e=>e.is_running).length,sessions:e.slice(0,10).map(e=>({id:e.id,is_running:e.is_running,last_run_status:e.last_run_status??null,message_count:e.message_count,has_pending_question:e.has_pending_question??!1,running_child_count:e.running_child_count??0,updated_at:e.updated_at}))}),an=e=>({count:e.sessions.length,sessions:e.sessions.map(e=>({session_id:e.session_id,run_id:e.run_id,round_count:e.round_count,last_event_at:e.last_event_at??null,last_tool_name:e.last_tool_name??null,last_tool_phase:e.last_tool_phase??null,criticalEventCount:e.last_critical_events.length,runningChildCount:e.running_child_session_ids.length}))}),on=e=>({type:e.type,session_id:e.session_id??null,run_id:e.run_id??null,round_count:e.round_count??null,message:e.message??null,error:e.error??null,tool_call_id:e.tool_call_id??null}),sn=(e,t)=>{if(e.session_id!==void 0||e.project_id!==void 0||!e.workspace_path?.trim()||!r(t)||t.status!==409||!t.body)return null;try{let e=JSON.parse(t.body);if(typeof e!=`object`||!e)return null;let n=e,r=n.error;if(typeof r!=`object`||!r||r.code!==`project_workspace_conflict`||n.session_project_id!==`unassigned`)return null;let i=n.owner_project_id;return typeof i!=`string`||!i.trim()?null:i.trim()}catch{return null}},cn=class e{static instance;static getInstance(){return e.instance||=new e,e.instance}async sendMessage(e){u(`[AgentClient]`,`chat.request`,{sessionId:e.session_id??null,model:e.model,modelRef:e.model_ref??null,provider:e.provider??null,messageLength:e.message.length,hasImages:(e.images?.length??0)>0,imageCount:e.images?.length??0,selectedSkillCount:e.selected_skill_ids?.length??0,workspacePath:e.workspace_path??null,projectId:e.project_id??null});let t;try{t=await i.post(`chat`,e)}catch(n){let r=sn(e,n);if(!r)throw n;t=await i.post(`chat`,{...e,project_id:r})}return u(`[AgentClient]`,`chat.response`,{requestedSessionId:e.session_id??null,sessionId:t.session_id,status:t.status}),t}async execute(e,t,n,r,a,o,s){let c={};o&&(c.upstream_retry=o),s===!0&&(c.live_bootstrap_resume=!0),t&&(c.model=t),n&&(c.reasoning_effort=n),r&&(c.client_sync=r),a&&(c.model_ref=a,c.provider=a.provider),u(`[AgentClient]`,`execute.request`,{sessionId:e,model:c.model??null,reasoningEffort:c.reasoning_effort??null,modelRef:c.model_ref??null,provider:c.provider??null,clientSync:en(c.client_sync)});let l=await i.post(`execute/${e}`,c);return u(`[AgentClient]`,`execute.response`,{sessionId:e,status:l.status,runId:l.run_id??null,eventsUrl:l.events_url,sync:tn(l.sync)}),l}async listSessions(e={}){let t=new URLSearchParams;e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),e.kind!==void 0&&t.set(`kind`,e.kind),e.root_session_id!==void 0&&t.set(`root_session_id`,e.root_session_id);let n=t.size>0?`?${t.toString()}`:``;u(`[AgentClient]`,`sessions.list.request`,e);let r=await i.get(`sessions${n}`);return ee(r.features),u(`[AgentClient]`,`sessions.list.response`,rn(r.sessions)),r}async getSession(e){return i.get(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`})}async ensureDefaultSupervisor(){let e=await i.post(`supervisor/default`,{});if(e?.session_id!==`bamboo-default-supervisor`||typeof e.incarnation_id!=`string`||!e.incarnation_id)throw Error(`The backend did not confirm the default Supervisor identity.`)}async selectRootMode(e,t){return i.post(`sessions/${encodeURIComponent(e)}/root-mode-operations/${encodeURIComponent(t.operationId)}`,{birth_token:t.birthToken,expected_epoch:t.expectedEpoch,enabled:t.enabled,thinking_mode:t.enabled?`ultra`:`standard`})}async recoverRootMode(e,t){return i.post(`sessions/${encodeURIComponent(e)}/root-mode-operations/${encodeURIComponent(t.operationId)}/recover`,{birth_token:t.birthToken,expected_epoch:t.expectedEpoch,enabled:t.enabled,thinking_mode:t.enabled?`ultra`:`standard`})}async getTaskList(e){let t=encodeURIComponent(e),n=await i.get(`task/${t}`,{cache:`no-store`});if(!(typeof n.title==`string`||n.items.length>0))return null;let r=new Date().toISOString();return{session_id:n.session_id,title:n.title??`Task List`,items:n.items,created_at:n.created_at??r,updated_at:n.updated_at??r,...n.version===void 0?{}:{version:n.version}}}async getPendingQuestion(e){let t=encodeURIComponent(e);return Xt(e,await i.get(`respond/${t}/pending`,{cache:`no-store`}))}async submitPermissionDecision(e,t){if(!Q(t.request_id)||!Q(t.request_generation)||!$(t.expected_policy_revision)||t.decision!==`allow_once`&&t.decision!==`deny_once`)throw new X;let n=Z(await i.post(`sessions/${encodeURIComponent(e)}/permission-decisions`,t)),r=Z(n?.receipt),a=Z(r?.decision);if(n?.success!==!0||typeof n.replayed!=`boolean`||r?.session_id!==e||a?.request_id!==t.request_id||a?.request_generation!==t.request_generation||a?.decision!==t.decision||a?.matcher_id!=null||a?.expected_policy_revision!=null&&!$(a.expected_policy_revision)||a?.confirm_global!=null&&a.confirm_global!==!1)throw new X;let o=Z(n.resume),s=o?.auto_resume_status,c=n.replayed&&n.resume==null&&n.auto_resume_status==null||o?.success===!0&&typeof s==`string`&&[`started`,`already_running`,`completed`].includes(s)&&n.auto_resume_status===s;return{replayed:n.replayed,autoResumeStatus:typeof s==`string`?s:void 0,continuationConfirmed:c}}async createSession(e){return i.post(`sessions`,e)}async patchSession(e,t){let n=encodeURIComponent(e);await i.patch(`sessions/${n}`,t)}async getSessionPermissionMode(e){return qt(e,await i.fetchRaw(`sessions/${encodeURIComponent(e)}`,{cache:`no-store`}))}async patchSessionPermissionMode(e,t,n){if(!Wt(t)||Gt(n)===null)throw new Kt;let r={permission_mode:t};return qt(e,await i.fetchRaw(`sessions/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"If-Match":n},body:JSON.stringify(r),cache:`no-store`}))}async regenerateSessionTitle(e){let t=encodeURIComponent(e);await i.post(`sessions/${t}/regenerate-title`)}async getSessionSystemPrompt(e){let t=encodeURIComponent(e);return i.get(`sessions/${t}/system-prompt`)}async clearSession(e){let t=encodeURIComponent(e),n=await i.post(`sessions/${t}/clear`);if(n?.success!==!0||n.session_id!==e)throw Error(`Invalid conversation clear receipt`)}async compactSessionContext(e){let t=encodeURIComponent(e),n=await i.postOnce(`sessions/${t}/compact`,void 0,{logicalTimeoutMs:31e4});if(n?.session_id===e){if(n.status===`unchanged`)return n;if(n.status===`compacted`&&Jt(n.usage_before_percent)&&Jt(n.usage_after_percent)){let e=n.token_usage;if(e&&[e.total_tokens,e.system_tokens,e.summary_tokens,e.window_tokens,e.budget_limit,e.segments_removed].every(Jt)&&typeof e.truncation_occurred==`boolean`)return n}}throw Error(`Invalid context compaction receipt`)}async runProjectDream(e){let t=encodeURIComponent(e);return i.post(`sessions/${t}/project-dream/run`)}async truncateSessionMessages(e,t){let n=encodeURIComponent(e);return i.post(`sessions/${n}/messages/truncate`,t)}async restoreSessionState(e,t){let n=encodeURIComponent(e);return i.post(`sessions/${n}/restore`,t)}async patchSessionMessage(e,t,n){let r=encodeURIComponent(e),a=encodeURIComponent(t);await i.patch(`sessions/${r}/messages/${a}`,n)}async deleteSessionMessage(e,t){let n=encodeURIComponent(e),r=encodeURIComponent(t);await i.delete(`sessions/${n}/messages/${r}`)}async cleanupSessions(e,t){await i.post(`sessions/cleanup`,{mode:e,keep_pinned:t})}async respondToChildApproval(e,t,n){return i.post(`child-approval/${encodeURIComponent(e)}`,{request_id:t,approved:n})}async devResetSessions(){await i.post(`dev/reset`)}async getRunningSessions(){u(`[AgentClient]`,`runs.active.request`,{});let e=await i.get(`runs/active`);return u(`[AgentClient]`,`runs.active.response`,an(e)),e}async listSchedules(){return i.get(`schedules`)}async createSchedule(e){return i.post(`schedules`,e)}async patchSchedule(e,t){let n=encodeURIComponent(e);return i.patch(`schedules/${n}`,t)}async deleteSchedule(e){let t=encodeURIComponent(e);await i.delete(`schedules/${t}`)}async runScheduleNow(e){let t=encodeURIComponent(e);await i.post(`schedules/${t}/run`)}async listScheduleSessions(e){let t=encodeURIComponent(e);return i.get(`schedules/${t}/sessions`)}async listScheduleRuns(e){let t=encodeURIComponent(e);return i.get(`schedules/${t}/runs`)}async subscribeToEvents(e,n,r){let i=r?.signal;if(u(`[AgentClient]`,`events.subscribe.request`,{sessionId:e}),i?.aborted){u(`[AgentClient]`,`events.subscribe.ws.aborted_before_connect`,{sessionId:e});return}let a=await t(()=>import(`./runDiagnostic-DJ_i4o1q.js`).then(e=>e.decodeRunDiagnostic),__vite__mapDeps([0,1]),import.meta.url).catch(()=>void 0);if(i?.aborted)return;let{promise:o,close:s}=zt(e,n,(t,n)=>this.handleEvent(t,n,e,a)),c=()=>{u(`[AgentClient]`,`events.subscribe.ws.abort`,{sessionId:e}),s()};i?.addEventListener(`abort`,c,{once:!0});try{await o}finally{i?.removeEventListener(`abort`,c)}}subscribeToAccountStream(e,t){return Rt(e,t?.since??0)}handleEvent(e,t,n,r){switch(e.type){case`token`:t.onToken?.(e.content||``);break;case`reasoning_token`:t.onReasoningToken?.(e.content||``);break;case`tool_token`:t.onToolToken?.(e.tool_call_id||``,e.content||``);break;case`tool_start`:t.onToolStart?.(e.tool_call_id||``,e.tool_name||``,e.arguments||{});break;case`tool_complete`:e.result&&t.onToolComplete?.(e.tool_call_id||``,e.result);break;case`bash_completed`:t.onBashCompleted?.(e.bash_id??``,e.command??``,e.exit_code??null,typeof e.status==`string`?e.status:`completed`);break;case`tool_error`:t.onToolError?.(e.tool_call_id||``,e.error||``);break;case`task_list_updated`:e.task_list&&t.onTaskListUpdated?.(e.version===void 0?e.task_list:{...e.task_list,version:e.version});break;case`task_list_item_progress`:if(e.session_id&&e.item_id&&e.status&&e.tool_calls_count!==void 0&&e.version!==void 0){let n=e.status;if(!(n===`pending`||n===`in_progress`||n===`completed`||n===`blocked`))break;t.onTaskListItemProgress?.({session_id:e.session_id,item_id:e.item_id,status:n,tool_calls_count:e.tool_calls_count,version:e.version})}break;case`task_list_completed`:e.session_id&&e.total_rounds!==void 0&&e.total_tool_calls!==void 0&&t.onTaskListCompleted?.(e.session_id,e.total_rounds,e.total_tool_calls,e.completed_at);break;case`task_evaluation_started`:e.session_id&&e.items_count!==void 0&&t.onTaskEvaluationStarted?.(e.session_id,e.items_count);break;case`task_evaluation_completed`:e.session_id&&e.updates_count!==void 0&&e.reasoning&&t.onTaskEvaluationCompleted?.(e.session_id,e.updates_count,e.reasoning);break;case`token_budget_updated`:e.usage&&`system_tokens`in e.usage&&t.onTokenBudgetUpdated?.(e.usage);break;case`context_compression_status`:typeof e.phase==`string`&&typeof e.status==`string`&&t.onContextCompressionStatus?.(e.phase,e.status);break;case`tool_lifecycle`:t.onToolLifecycle?.(e.tool_call_id||``,e.tool_name||``,e.phase||``,e.elapsed_ms,e.is_mutating,e.auto_approved,e.summary,e.error);break;case`context_summarized`:{let n=Yt(e.summary_info===void 0?e:e.summary_info);n&&t.onContextSummarized?.(n);break}case`context_pressure_notification`:typeof e.percent==`number`&&typeof e.level==`string`&&t.onContextPressureNotification?.(e.percent,e.level,e.message||``);break;case`sub_agent_started`:e.parent_session_id&&e.child_session_id&&t.onSubAgentStarted?.(e.parent_session_id,e.child_session_id,e.title);break;case`sub_agent_event`:e.parent_session_id&&e.child_session_id&&e.event&&t.onSubAgentEvent?.(e.parent_session_id,e.child_session_id,e.event);break;case`sub_agent_heartbeat`:e.parent_session_id&&e.child_session_id&&e.timestamp&&t.onSubAgentHeartbeat?.(e.parent_session_id,e.child_session_id,e.timestamp);break;case`sub_agent_completed`:e.parent_session_id&&e.child_session_id&&t.onSubAgentCompleted?.(e.parent_session_id,e.child_session_id,typeof e.status==`string`?e.status:`completed`,e.error);break;case`child_approval_requested`:e.child_session_id&&e.request_id&&t.onChildApprovalRequested?.(e.child_session_id,e.request_id,{toolName:e.tool_name,permission:e.permission,resource:e.resource});break;case`execution_started`:t.onExecutionStarted?.(e.run_id||``,e.started_at);break;case`runner_progress`:e.session_id&&typeof e.round_count==`number`&&t.onRunnerProgress?.(e.session_id,e.round_count);break;case`need_clarification`:t.onNeedClarification?.(e);break;case`notification`:t.onNotification?.(e);break;case`session_title_updated`:e.session_id&&typeof e.title==`string`&&typeof e.title_version==`number`&&(e.source===`auto`||e.source===`manual`||e.source===`fallback`)&&typeof e.updated_at==`string`&&t.onSessionTitleUpdated?.({type:`session_title_updated`,session_id:e.session_id,title:e.title,title_version:e.title_version,source:e.source,updated_at:e.updated_at});break;case`session_pinned_updated`:e.session_id&&typeof e.pinned==`boolean`&&typeof e.updated_at==`string`&&t.onSessionPinnedUpdated?.({type:`session_pinned_updated`,session_id:e.session_id,pinned:e.pinned,updated_at:e.updated_at});break;case`plan_mode_entered`:t.onPlanModeEntered?.(e);break;case`plan_mode_exited`:t.onPlanModeExited?.(e);break;case`plan_file_updated`:t.onPlanFileUpdated?.(e);break;case`goal_status_changed`:t.onGoalStatusChanged?.(e);break;case`message_appended`:e.session_id&&t.onMessageAppended?.(e.session_id,e.message_id);break;case`session_history_committed`:e.session_id&&t.onSessionHistoryCommitted?.(e.session_id);break;case`complete`:u(`[AgentClient]`,`events.dispatch.complete`,on(e)),t.onComplete?.(e.usage);break;case`cancelled`:u(`[AgentClient]`,`events.dispatch.cancelled`,on(e)),t.onCancelled?.(e.message);break;case`error`:if(u(`[AgentClient]`,`events.dispatch.error`,on(e)),e.session_id&&e.session_id!==n)break;{let i=e.message||e.error||`Unknown error`,a=r?.(e.diagnostic,n,i);a?t.onError?.(i,a):t.onError?.(i)}break;default:console.warn(`Unknown event type:`,e)}}async stopGeneration(e,t){if(t!==void 0){if(!s(t))throw Error(`Invalid execution identity`);await i.post(`stop/${encodeURIComponent(e)}`,void 0,{headers:{"Bamboo-Run-Id":t}});return}vt(e)||await i.post(`stop/${encodeURIComponent(e)}`)}async deleteSession(e){let t=encodeURIComponent(e);await i.delete(`sessions/${t}`)}async getHistory(e,t){u(`[AgentClient]`,`history.request`,{sessionId:e,sinceMessageId:t});let n=t?`history/${encodeURIComponent(e)}?since_message_id=${encodeURIComponent(t)}`:`history/${encodeURIComponent(e)}`,r=await i.get(n,{cache:`no-store`});return u(`[AgentClient]`,`history.response`,nn(r)),r}async getMessageHistory(e,t){let n=new URLSearchParams({projection:`messages`});t&&n.set(`since_message_id`,t);let r=`sessions/${encodeURIComponent(e)}/history?${n.toString()}`;return $t(e,await i.get(r,{cache:`no-store`}))}async healthCheck(){try{return await i.get(`health`),!0}catch{return!1}}},ln=cn.getInstance();export{o as _,Wt as a,ut as c,Bt as d,u as f,a as g,s as h,Ut as i,Vt as l,te as m,Kt as n,Gt as o,ne as p,ln as r,dt as s,cn as t,Ht as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-C2RfJtHm.js";import{i}from"./appStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-C2RfJtHm.js";import{i}from"./appStore-CtVfGWhw.js";import{t as a}from"./button-Cfb4l-V4.js";import{i as o,n as s,r as c,t as l}from"./responsive-dialog-fYAouKrw.js";var u=e(t(),1),d=n(),f={active_run:`conversation_clear_active_run`,pending_approval:`conversation_clear_pending_approval`,state_unavailable:`conversation_clear_state_unavailable`,authority_conflict:`conversation_clear_authority_conflict`,incompatible:`conversation_clear_incompatible`,unsupported:`conversation_clear_unsupported`,unknown:`conversation_clear_unknown`,readback_failed:`conversation_clear_readback_failed`};function p({sessionId:e,title:t,onClose:n}){let p=r(),m=i(t=>t.conversationClears[e]),h=(0,u.useRef)(!1),g=m?.error===`unknown`||m?.error===`readback_failed`,_=()=>{i.getState().conversationClears[e]?.busy||(i.getState().dismissConversationClear(e),n())},v=async t=>{if(!h.current){h.current=!0;try{let n=i.getState();await(t?g?n.verifyConversationClear(e):n.refreshConversationClear(e):n.clearConversation(e))}catch{}finally{h.current=!1}}};return(0,d.jsx)(l,{open:!0,onOpenChange:e=>{e||_()},children:(0,d.jsxs)(s,{showCloseButton:!m?.busy,dismissable:!m?.busy,className:`gap-3 overflow-y-auto p-4 sm:pb-4 sm:max-w-lg`,children:[(0,d.jsx)(o,{children:p(`conversation_clear_title`)}),(0,d.jsx)(c,{asChild:!0,children:(0,d.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,d.jsxs)(`p`,{className:`break-all font-medium text-foreground`,children:[t,` · `,e]}),(0,d.jsx)(`p`,{children:p(`conversation_clear_impact`)}),(0,d.jsx)(`p`,{children:p(`conversation_clear_limits`)})]})}),m?.confirmed?(0,d.jsx)(`p`,{role:`status`,className:`text-sm`,children:p(`conversation_clear_confirmed`)}):null,m?.error?(0,d.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p(f[m.error])}):null,m?.readbackConfirmed?(0,d.jsx)(`p`,{role:`status`,className:`text-sm`,children:p(`conversation_clear_readback_only`)}):null,m?.refreshFailed?(0,d.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p(`conversation_clear_refresh_failed`)}):null,(0,d.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,d.jsx)(a,{variant:`secondary`,size:`sm`,disabled:m?.busy,onClick:_,children:m?.confirmed||g?p(`close_3fd47edc`):p(`cancel_2cd0f3be`)}),m?.error?(0,d.jsx)(a,{variant:`outline`,size:`sm`,disabled:m?.busy,onClick:()=>void v(!0),children:m?.busy?p(`processing_d3d21191`):p(`conversation_clear_refresh`)}):null,!g&&!m?.confirmed?(0,d.jsx)(a,{variant:`destructive`,size:`sm`,disabled:m?.busy,onClick:()=>void v(!1),children:m?.busy?p(`processing_d3d21191`):p(`conversation_clear_action`)}):null]})]})})}export{p as ConversationClearDialogContent};
|