sliccy 5.31.1 → 5.31.3
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/node-server/_cloud_core/src/operations/resume.d.ts.map +1 -1
- package/dist/node-server/_cloud_core/src/operations/resume.js +10 -9
- package/dist/node-server/_shared/electron-overlay-route.d.ts +31 -0
- package/dist/node-server/_shared/electron-overlay-route.d.ts.map +1 -0
- package/dist/node-server/_shared/electron-overlay-route.js +29 -0
- package/dist/node-server/_shared/electron-overlay-route.js.map +1 -0
- package/dist/node-server/_shared/index.d.ts +1 -0
- package/dist/node-server/_shared/index.d.ts.map +1 -1
- package/dist/node-server/_shared/index.js +1 -0
- package/dist/node-server/_shared/index.js.map +1 -1
- package/dist/node-server/electron-controller.d.ts +2 -10
- package/dist/node-server/electron-controller.js +5 -10
- package/dist/node-server/electron-runtime.d.ts +0 -1
- package/dist/node-server/electron-runtime.js +0 -1
- package/dist/ui/assets/__vite-browser-external-CDnYSdyJ.js +1 -0
- package/dist/ui/assets/account-store-BSEcudvg.js +99 -0
- package/dist/ui/assets/{account-store-CufoCtRK.js → account-store-SL9GSzVk.js} +3 -3
- package/dist/ui/assets/{adobe-CzkIC8mZ.js → adobe-DbSSf4Ld.js} +1 -1
- package/dist/ui/assets/{adobe-BHiE6HjD.js → adobe-SNd1IfRO.js} +2 -2
- package/dist/ui/assets/adobe-oauth-state-Ge2y0PGt.js +1 -0
- package/dist/ui/assets/{adobe-oauth-state-hIbA-bCY.js → adobe-oauth-state-X5E5a44s.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-CsrQq0sg.js → agent-message-to-chat-C1C-ZYPB.js} +1 -1
- package/dist/ui/assets/{apps-B5vEInFZ.js → apps-BQ_qFSmZ.js} +1 -1
- package/dist/ui/assets/{azure-openai-DS8Knhiz.js → azure-openai-C4FPpKAs.js} +1 -1
- package/dist/ui/assets/{azure-openai-BPeYDsFl.js → azure-openai-g-MISqMy.js} +1 -1
- package/dist/ui/assets/{cerebras-CDQN4Obw.js → cerebras-D2PjlO7P.js} +1 -1
- package/dist/ui/assets/{cerebras-B8Jo2XB1.js → cerebras-zumaaXYF.js} +1 -1
- package/dist/ui/assets/{composer-speech-D7pXrLX8.js → composer-speech-C8TRsqUk.js} +1 -1
- package/dist/ui/assets/{connect-surface-D8xQOaor.js → connect-surface-C37aNu3W.js} +1 -1
- package/dist/ui/assets/dip-CZO83CmG.js +1 -0
- package/dist/ui/assets/{dist-BG1IxpLe.js → dist-Crm-xEtc.js} +1 -1
- package/dist/ui/assets/{dist-EE4Al_F3.js → dist-Z_lsorao.js} +1 -1
- package/dist/ui/assets/{ensure-speech-assets-d5VIFIIS.js → ensure-speech-assets-C16fjyEc.js} +1 -1
- package/dist/ui/assets/esp8266-f57A77mF.js +1 -0
- package/dist/ui/assets/{esptool-operations-BJlZgV2w.js → esptool-operations-DS77K1xA.js} +2 -2
- package/dist/ui/assets/{fs-DGFq_Mxy.js → fs-4jha6tKU.js} +2 -2
- package/dist/ui/assets/{fs-CryNXen8.js → fs-CJe7ORQQ.js} +1 -1
- package/dist/ui/assets/{github-CTWZAIB1.js → github-B7MJQ6o8.js} +1 -1
- package/dist/ui/assets/{github-DRVxfI4e.js → github-bHdfOCia.js} +2 -2
- package/dist/ui/assets/{github-copilot-DVPbv0Ot.js → github-copilot-B3U5ZsUu.js} +1 -1
- package/dist/ui/assets/{github-copilot-CR-2580l.js → github-copilot-Brb8tPWW.js} +1 -1
- package/dist/ui/assets/{hear-pJ6dxizz.js → hear-DEv4kmVy.js} +1 -1
- package/dist/ui/assets/{hear-C2Oy26rV.js → hear-DVfG4tMB.js} +1 -1
- package/dist/ui/assets/{kernel-worker-BOQlsxzN.js → kernel-worker-DU_V0U3r.js} +344 -345
- package/dist/ui/assets/{kokoro-engine-CtJdZC7U.js → kokoro-engine-BCF6RB67.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-DH009Ya6.js → lick-ws-bridge-Bw7A25PO.js} +1 -1
- package/dist/ui/assets/{lick-ws-bridge-B7WV8f-q.js → lick-ws-bridge-CWz8ua2f.js} +1 -1
- package/dist/ui/assets/{local-llm-CTPBIO5P.js → local-llm-CUYHWkoy.js} +1 -1
- package/dist/ui/assets/{main-Yr2sAIA-.js → main-LqqRM1F-.js} +4 -4
- package/dist/ui/assets/mount-COvarpEy.js +2 -0
- package/dist/ui/assets/mount-DhKiCtt7.js +1 -0
- package/dist/ui/assets/mount-bridge-client-DHpxu7lQ.js +1 -0
- package/dist/ui/assets/new-session-COz75sHo.js +2 -0
- package/dist/ui/assets/oauth-bootstrap-BRe2dg9j.js +2 -0
- package/dist/ui/assets/{oauth-service-DY8Ud2Yu.js → oauth-service-BSqTYvb6.js} +1 -1
- package/dist/ui/assets/{openai-codex-DlwnaPEj.js → openai-codex-BYbsJPYQ.js} +1 -1
- package/dist/ui/assets/{openai-codex-D7QSo0uM.js → openai-codex-Bg862N5_.js} +1 -1
- package/dist/ui/assets/{page-follower-tray-wpVcQCFL.js → page-follower-tray-CKjmGVTI.js} +1 -1
- package/dist/ui/assets/panel-rpc-handlers-DV_SVK7O.js +2 -0
- package/dist/ui/assets/port-bridge-client-BJ5rcoKH.js +2 -0
- package/dist/ui/assets/port-bridge-client-vT8ubtB-.js +1 -0
- package/dist/ui/assets/{provider-B2-NQQon.js → provider-C1MeNgf6.js} +2 -2
- package/dist/ui/assets/{provider-BGNOqrtL.js → provider-CH9Vg0CP.js} +1 -1
- package/dist/ui/assets/provider-store-access-DEnkpFQB.js +1 -0
- package/dist/ui/assets/provider-store-access-hYm5ykP5.js +1 -0
- package/dist/ui/assets/providers-BYABmiE-.js +2 -0
- package/dist/ui/assets/{providers-B4TZx5PO.js → providers-DTc9cavg.js} +1 -1
- package/dist/ui/assets/proxied-fetch-iGqLvoxh.js +2 -0
- package/dist/ui/assets/{py-realm-worker-DJfA3V8e.js → py-realm-worker-BP0PXobe.js} +1 -1
- package/dist/ui/assets/{pyodide-dCNxT3QU.js → pyodide-C3-pUJSm.js} +2 -2
- package/dist/ui/assets/{pyodide-CHuPF4e3.js → pyodide-CxYFR9UT.js} +1 -1
- package/dist/ui/assets/{quick-llm-CvPLRDgB.js → quick-llm-CpQ7FC1y.js} +1 -1
- package/dist/ui/assets/{secret-env-C-5TIS7_.js → secret-env-kbusPsVw.js} +1 -1
- package/dist/ui/assets/{secret-topology-D6iS4SOH.js → secret-topology-DnYeyyJY.js} +1 -1
- package/dist/ui/assets/secrets-bridge-client-x_puVSDN.js +1 -0
- package/dist/ui/assets/session-freezer-ClZHZ4rq.js +1 -0
- package/dist/ui/assets/{speak-BvHvt4mX.js → speak-DnUM0f7v.js} +1 -1
- package/dist/ui/assets/{speak-qia_ii-y.js → speak-qQJqxyY_.js} +1 -1
- package/dist/ui/assets/{sprinkle-manager-ChmTv6wJ.js → sprinkle-manager-DqB-1sMP.js} +1 -1
- package/dist/ui/assets/src-BdPw21ST.js +1 -0
- package/dist/ui/assets/{store-Yx-6Id5z.js → store-CQZC3J0e.js} +1 -1
- package/dist/ui/assets/{sudo-oNdO0hJk.js → sudo-DDua5CDS.js} +1 -1
- package/dist/ui/assets/{transformers-env-DPleNPK9.js → transformers-env-Bd5uUAET.js} +1 -1
- package/dist/ui/assets/{transformers-env-tAIm37Yk.js → transformers-env-CjH48rcA.js} +1 -1
- package/dist/ui/assets/{tray-leader-D2BTQKPA.js → tray-leader-tUG5SYx1.js} +1 -1
- package/dist/ui/assets/{tray-leave-runtime-Bk7lAsZD.js → tray-leave-runtime-DFSM2v0u.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-BGZECbZS.js → upgrade-detection-SjHrqVRd.js} +1 -1
- package/dist/ui/assets/{voice-reply-CkkHHNmV.js → voice-reply-Cfv2GJPY.js} +1 -1
- package/dist/ui/assets/wc-attach-BLShAwZU.js +13 -0
- package/dist/ui/assets/wc-extension-9BJC8pnc.js +2 -0
- package/dist/ui/assets/{wc-float-label-bfJhTEza.js → wc-float-label-Dh8xz8qh.js} +1 -1
- package/dist/ui/assets/wc-follower-DcPEJsCg.js +4 -0
- package/dist/ui/assets/{wc-live-Bahzf7iY.js → wc-live-CpCIXFgr.js} +5 -5
- package/dist/ui/assets/wc-nav-BipzeLE6.js +2 -0
- package/dist/ui/assets/{wc-onboarding-BJpuvWul.js → wc-onboarding-CcG_XrLd.js} +2 -2
- package/dist/ui/assets/wc-placeholder-BYxtEGbt.js +4 -0
- package/dist/ui/assets/{wc-settings-Daanx0yL.js → wc-settings-CdRw8sxH.js} +2 -2
- package/dist/ui/assets/{wc-shell-amvvddsN.js → wc-shell-CrTQtlJQ.js} +3 -3
- package/dist/ui/assets/wc-sprinkles-CiD8jtkB.js +2 -0
- package/dist/ui/assets/wc-tray-CSrI5SrA.js +2 -0
- package/dist/ui/assets/{whisper-engine-SAFByApN.js → whisper-engine-6ZaZ9EaS.js} +1 -1
- package/dist/ui/assets/{whisper-session-CouZGLHz.js → whisper-session-Duou3zwG.js} +2 -2
- package/dist/ui/assets/{xai-grok-C650vv2T.js → xai-grok-BClQ5lXS.js} +1 -1
- package/dist/ui/assets/{xai-grok-BGULFVRv.js → xai-grok-Bjh8Mg84.js} +1 -1
- package/dist/ui/index.html +8 -7
- package/dist/ui/llm-proxy-sw.js +1 -1
- package/dist/ui/packages/webapp/index.html +8 -7
- package/package.json +4 -4
- package/dist/ui/assets/__vite-browser-external-Dyo3iKee.js +0 -1
- package/dist/ui/assets/account-store-CbtT2UK_.js +0 -99
- package/dist/ui/assets/adobe-oauth-state---RmeoFk.js +0 -1
- package/dist/ui/assets/dip-B3HkOg2P.js +0 -1
- package/dist/ui/assets/esp8266-BYVSt9HZ.js +0 -1
- package/dist/ui/assets/mount-9aR2Hmq9.js +0 -2
- package/dist/ui/assets/mount-bridge-client-CB9Fm9Jh.js +0 -2
- package/dist/ui/assets/mount-tjfv2hMK.js +0 -1
- package/dist/ui/assets/new-session-BDOY4e6B.js +0 -2
- package/dist/ui/assets/oauth-bootstrap-DiW8f4Vr.js +0 -2
- package/dist/ui/assets/panel-rpc-handlers-DVCVQxHC.js +0 -2
- package/dist/ui/assets/provider-store-access-C8sjN5g9.js +0 -1
- package/dist/ui/assets/provider-store-access-CRPq-cmP.js +0 -1
- package/dist/ui/assets/providers-kdSIfEzm.js +0 -2
- package/dist/ui/assets/proxied-fetch-Bht31_rT.js +0 -2
- package/dist/ui/assets/secrets-bridge-client-DwfYAgDv.js +0 -2
- package/dist/ui/assets/session-freezer-BT7imza9.js +0 -1
- package/dist/ui/assets/src-x0cJ68Fe.js +0 -1
- package/dist/ui/assets/wc-attach-BUw0fK9O.js +0 -13
- package/dist/ui/assets/wc-extension-BZl1EyiB.js +0 -2
- package/dist/ui/assets/wc-follower-BNlgVmv5.js +0 -4
- package/dist/ui/assets/wc-nav-CndHO66K.js +0 -2
- package/dist/ui/assets/wc-placeholder-BWDIrC_G.js +0 -4
- package/dist/ui/assets/wc-sprinkles-BblVeyPm.js +0 -2
- package/dist/ui/assets/wc-tray-CWYcJaRj.js +0 -2
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{t as n}from"./logger-LESFN7Hj.js";import{h as r,m as i,o as a,r as o,t as s}from"./proxied-fetch-BVw2cmL4.js";import{i as c,r as l}from"./tool-ui-t6ocn6AG.js";import{n as u,r as d}from"./panel-rpc-CjFVE0nK.js";import{n as f,o as p,t as m}from"./providers-B4TZx5PO.js";import{c as h,d as g,r as _,t as v,u as y}from"./bedrock-camp-DlP7CPgV.js";import{d as b,l as x,u as S}from"./transform-messages-BjP6vDPY.js";function C(){return typeof chrome<`u`&&chrome?.runtime?.id?`extension-direct`:o()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function ee(){return C()===`node-rest`}async function te(e,t,n,r,i,a){let o=[...e],s={...t,messages:[...t.messages,...e]};await r({type:`agent_start`}),await r({type:`turn_start`});for(let t of e)await r({type:`message_start`,message:t}),await r({type:`message_end`,message:t});return await re(s,o,n,i,r,a),o}async function ne(e,t,n,r,i){if(e.messages.length===0)throw Error(`Cannot continue: no messages in context`);if(e.messages[e.messages.length-1].role===`assistant`)throw Error(`Cannot continue from message role: assistant`);let a=[],o={...e};return await n({type:`agent_start`}),await n({type:`turn_start`}),await re(o,a,t,r,n,i),a}async function re(e,t,n,r,i,a){let o=e,s=n,c=!0,l=await s.getSteeringMessages?.()||[];for(;;){let e=!0;for(;e||l.length>0;){if(c?c=!1:await i({type:`turn_start`}),l.length>0){for(let e of l)await i({type:`message_start`,message:e}),await i({type:`message_end`,message:e}),o.messages.push(e),t.push(e);l=[]}let n=await ie(o,s,r,i,a);if(t.push(n),n.stopReason===`error`||n.stopReason===`aborted`){await i({type:`turn_end`,message:n,toolResults:[]}),await i({type:`agent_end`,messages:t});return}let u=n.content.filter(e=>e.type===`toolCall`),d=[];if(e=!1,u.length>0){let a=await ae(o,n,s,r,i);d.push(...a.messages),e=!a.terminate;for(let e of d)o.messages.push(e),t.push(e)}await i({type:`turn_end`,message:n,toolResults:d});let f={message:n,toolResults:d,context:o,newMessages:t},p=await s.prepareNextTurn?.(f);if(p&&(o=p.context??o,s={...s,model:p.model??s.model,reasoning:p.thinkingLevel===void 0?s.reasoning:p.thinkingLevel===`off`?void 0:p.thinkingLevel}),await s.shouldStopAfterTurn?.({message:n,toolResults:d,context:o,newMessages:t})){await i({type:`agent_end`,messages:t});return}l=await s.getSteeringMessages?.()||[]}let n=await s.getFollowUpMessages?.()||[];if(n.length>0){l=n;continue}break}await i({type:`agent_end`,messages:t})}async function ie(e,t,n,r,i){let a=e.messages;t.transformContext&&(a=await t.transformContext(a,n));let o=await t.convertToLlm(a),s={systemPrompt:e.systemPrompt,messages:o,tools:e.tools},c=i||g,l=(t.getApiKey?await t.getApiKey(t.model.provider):void 0)||t.apiKey,u=await c(t.model,s,{...t,apiKey:l,signal:n}),d=null,f=!1;for await(let t of u)switch(t.type){case`start`:d=t.partial,e.messages.push(d),f=!0,await r({type:`message_start`,message:{...d}});break;case`text_start`:case`text_delta`:case`text_end`:case`thinking_start`:case`thinking_delta`:case`thinking_end`:case`toolcall_start`:case`toolcall_delta`:case`toolcall_end`:d&&(d=t.partial,e.messages[e.messages.length-1]=d,await r({type:`message_update`,assistantMessageEvent:t,message:{...d}}));break;case`done`:case`error`:{let t=await u.result();return f?e.messages[e.messages.length-1]=t:e.messages.push(t),f||await r({type:`message_start`,message:{...t}}),await r({type:`message_end`,message:t}),t}}let p=await u.result();return f?e.messages[e.messages.length-1]=p:(e.messages.push(p),await r({type:`message_start`,message:{...p}})),await r({type:`message_end`,message:p}),p}async function ae(e,t,n,r,i){let a=t.content.filter(e=>e.type===`toolCall`),o=a.some(t=>e.tools?.find(e=>e.name===t.name)?.executionMode===`sequential`);return n.toolExecution===`sequential`||o?w(e,t,a,n,r,i):oe(e,t,a,n,r,i)}async function w(e,t,n,r,i,a){let o=[],s=[];for(let c of n){await a({type:`tool_execution_start`,toolCallId:c.id,toolName:c.name,args:c.arguments});let n=await le(e,t,c,r,i),l;l=n.kind===`immediate`?{toolCall:c,result:n.result,isError:n.isError}:await de(e,t,n,await ue(n,i,a),r,i),await fe(l,a);let u=pe(l);if(await me(u,a),o.push(l),s.push(u),i?.aborted)break}return{messages:s,terminate:se(o)}}async function oe(e,t,n,r,i,a){let o=[];for(let s of n){await a({type:`tool_execution_start`,toolCallId:s.id,toolName:s.name,args:s.arguments});let n=await le(e,t,s,r,i);if(n.kind===`immediate`){let e={toolCall:s,result:n.result,isError:n.isError};if(await fe(e,a),o.push(e),i?.aborted)break;continue}if(o.push(async()=>{let o=await de(e,t,n,await ue(n,i,a),r,i);return await fe(o,a),o}),i?.aborted)break}let s=await Promise.all(o.map(e=>typeof e==`function`?e():Promise.resolve(e))),c=[];for(let e of s){let t=pe(e);await me(t,a),c.push(t)}return{messages:c,terminate:se(s)}}function se(e){return e.length>0&&e.every(e=>e.result.terminate===!0)}function ce(e,t){if(!e.prepareArguments)return t;let n=e.prepareArguments(t.arguments);return n===t.arguments?t:{...t,arguments:n}}async function le(e,t,n,r,i){let a=e.tools?.find(e=>e.name===n.name);if(!a)return{kind:`immediate`,result:T(`Tool ${n.name} not found`),isError:!0};try{let o=h(a,ce(a,n));if(r.beforeToolCall){let a=await r.beforeToolCall({assistantMessage:t,toolCall:n,args:o,context:e},i);if(i?.aborted)return{kind:`immediate`,result:T(`Operation aborted`),isError:!0};if(a?.block)return{kind:`immediate`,result:T(a.reason||`Tool execution was blocked`),isError:!0}}return i?.aborted?{kind:`immediate`,result:T(`Operation aborted`),isError:!0}:{kind:`prepared`,toolCall:n,tool:a,args:o}}catch(e){return{kind:`immediate`,result:T(e instanceof Error?e.message:String(e)),isError:!0}}}async function ue(e,t,n){let r=[];try{let i=await e.tool.execute(e.toolCall.id,e.args,t,t=>{r.push(Promise.resolve(n({type:`tool_execution_update`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,args:e.toolCall.arguments,partialResult:t})))});return await Promise.all(r),{result:i,isError:!1}}catch(e){return await Promise.all(r),{result:T(e instanceof Error?e.message:String(e)),isError:!0}}}async function de(e,t,n,r,i,a){let o=r.result,s=r.isError;if(i.afterToolCall)try{let r=await i.afterToolCall({assistantMessage:t,toolCall:n.toolCall,args:n.args,result:o,isError:s,context:e},a);r&&(o={content:r.content??o.content,details:r.details??o.details,terminate:r.terminate??o.terminate},s=r.isError??s)}catch(e){o=T(e instanceof Error?e.message:String(e)),s=!0}return{toolCall:n.toolCall,result:o,isError:s}}function T(e){return{content:[{type:`text`,text:e}],details:{}}}async function fe(e,t){await t({type:`tool_execution_end`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,result:e.result,isError:e.isError})}function pe(e){return{role:`toolResult`,toolCallId:e.toolCall.id,toolName:e.toolCall.name,content:e.result.content,details:e.result.details,isError:e.isError,timestamp:Date.now()}}async function me(e,t){await t({type:`message_start`,message:e}),await t({type:`message_end`,message:e})}function he(e){return e.filter(e=>e.role===`user`||e.role===`assistant`||e.role===`toolResult`)}const ge={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},_e={id:`unknown`,name:`unknown`,api:`unknown`,provider:`unknown`,baseUrl:``,reasoning:!1,input:[],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:0,maxTokens:0};function ve(e){let t=e?.tools?.slice()??[],n=e?.messages?.slice()??[];return{systemPrompt:e?.systemPrompt??``,model:e?.model??_e,thinkingLevel:e?.thinkingLevel??`off`,get tools(){return t},set tools(e){t=e.slice()},get messages(){return n},set messages(e){n=e.slice()},isStreaming:!1,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:void 0}}var ye=class{messages=[];mode;constructor(e){this.mode=e}enqueue(e){this.messages.push(e)}hasItems(){return this.messages.length>0}drain(){if(this.mode===`all`){let e=this.messages.slice();return this.messages=[],e}let e=this.messages[0];return e?(this.messages=this.messages.slice(1),[e]):[]}clear(){this.messages=[]}},be=class{_state;listeners=new Set;steeringQueue;followUpQueue;convertToLlm;transformContext;streamFn;getApiKey;onPayload;onResponse;beforeToolCall;afterToolCall;prepareNextTurn;activeRun;sessionId;thinkingBudgets;transport;maxRetryDelayMs;toolExecution;constructor(e={}){this._state=ve(e.initialState),this.convertToLlm=e.convertToLlm??he,this.transformContext=e.transformContext,this.streamFn=e.streamFn??g,this.getApiKey=e.getApiKey,this.onPayload=e.onPayload,this.onResponse=e.onResponse,this.beforeToolCall=e.beforeToolCall,this.afterToolCall=e.afterToolCall,this.prepareNextTurn=e.prepareNextTurn,this.steeringQueue=new ye(e.steeringMode??`one-at-a-time`),this.followUpQueue=new ye(e.followUpMode??`one-at-a-time`),this.sessionId=e.sessionId,this.thinkingBudgets=e.thinkingBudgets,this.transport=e.transport??`auto`,this.maxRetryDelayMs=e.maxRetryDelayMs,this.toolExecution=e.toolExecution??`parallel`}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}get state(){return this._state}set steeringMode(e){this.steeringQueue.mode=e}get steeringMode(){return this.steeringQueue.mode}set followUpMode(e){this.followUpQueue.mode=e}get followUpMode(){return this.followUpQueue.mode}steer(e){this.steeringQueue.enqueue(e)}followUp(e){this.followUpQueue.enqueue(e)}clearSteeringQueue(){this.steeringQueue.clear()}clearFollowUpQueue(){this.followUpQueue.clear()}clearAllQueues(){this.clearSteeringQueue(),this.clearFollowUpQueue()}hasQueuedMessages(){return this.steeringQueue.hasItems()||this.followUpQueue.hasItems()}get signal(){return this.activeRun?.abortController.signal}abort(){this.activeRun?.abortController.abort()}waitForIdle(){return this.activeRun?.promise??Promise.resolve()}reset(){this._state.messages=[],this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this._state.errorMessage=void 0,this.clearFollowUpQueue(),this.clearSteeringQueue()}async prompt(e,t){if(this.activeRun)throw Error(`Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.`);let n=this.normalizePromptInput(e,t);await this.runPromptMessages(n)}async continue(){if(this.activeRun)throw Error(`Agent is already processing. Wait for completion before continuing.`);let e=this._state.messages[this._state.messages.length-1];if(!e)throw Error(`No messages to continue from`);if(e.role===`assistant`){let e=this.steeringQueue.drain();if(e.length>0){await this.runPromptMessages(e,{skipInitialSteeringPoll:!0});return}let t=this.followUpQueue.drain();if(t.length>0){await this.runPromptMessages(t);return}throw Error(`Cannot continue from message role: assistant`)}await this.runContinuation()}normalizePromptInput(e,t){if(Array.isArray(e))return e;if(typeof e!=`string`)return[e];let n=[{type:`text`,text:e}];return t&&t.length>0&&n.push(...t),[{role:`user`,content:n,timestamp:Date.now()}]}async runPromptMessages(e,t={}){await this.runWithLifecycle(async n=>{await te(e,this.createContextSnapshot(),this.createLoopConfig(t),e=>this.processEvents(e),n,this.streamFn)})}async runContinuation(){await this.runWithLifecycle(async e=>{await ne(this.createContextSnapshot(),this.createLoopConfig(),e=>this.processEvents(e),e,this.streamFn)})}createContextSnapshot(){return{systemPrompt:this._state.systemPrompt,messages:this._state.messages.slice(),tools:this._state.tools.slice()}}createLoopConfig(e={}){let t=e.skipInitialSteeringPoll===!0;return{model:this._state.model,reasoning:this._state.thinkingLevel===`off`?void 0:this._state.thinkingLevel,sessionId:this.sessionId,onPayload:this.onPayload,onResponse:this.onResponse,transport:this.transport,thinkingBudgets:this.thinkingBudgets,maxRetryDelayMs:this.maxRetryDelayMs,toolExecution:this.toolExecution,beforeToolCall:this.beforeToolCall,afterToolCall:this.afterToolCall,prepareNextTurn:this.prepareNextTurn?async()=>await this.prepareNextTurn?.(this.signal):void 0,convertToLlm:this.convertToLlm,transformContext:this.transformContext,getApiKey:this.getApiKey,getSteeringMessages:async()=>t?(t=!1,[]):this.steeringQueue.drain(),getFollowUpMessages:async()=>this.followUpQueue.drain()}}async runWithLifecycle(e){if(this.activeRun)throw Error(`Agent is already processing.`);let t=new AbortController,n=()=>{},r=new Promise(e=>{n=e});this.activeRun={promise:r,resolve:n,abortController:t},this._state.isStreaming=!0,this._state.streamingMessage=void 0,this._state.errorMessage=void 0;try{await e(t.signal)}catch(e){await this.handleRunFailure(e,t.signal.aborted)}finally{this.finishRun()}}async handleRunFailure(e,t){let n={role:`assistant`,content:[{type:`text`,text:``}],api:this._state.model.api,provider:this._state.model.provider,model:this._state.model.id,usage:ge,stopReason:t?`aborted`:`error`,errorMessage:e instanceof Error?e.message:String(e),timestamp:Date.now()};await this.processEvents({type:`message_start`,message:n}),await this.processEvents({type:`message_end`,message:n}),await this.processEvents({type:`turn_end`,message:n,toolResults:[]}),await this.processEvents({type:`agent_end`,messages:[n]})}finishRun(){this._state.isStreaming=!1,this._state.streamingMessage=void 0,this._state.pendingToolCalls=new Set,this.activeRun?.resolve(),this.activeRun=void 0}async processEvents(e){switch(e.type){case`message_start`:this._state.streamingMessage=e.message;break;case`message_update`:this._state.streamingMessage=e.message;break;case`message_end`:this._state.streamingMessage=void 0,this._state.messages.push(e.message);break;case`tool_execution_start`:{let t=new Set(this._state.pendingToolCalls);t.add(e.toolCallId),this._state.pendingToolCalls=t;break}case`tool_execution_end`:{let t=new Set(this._state.pendingToolCalls);t.delete(e.toolCallId),this._state.pendingToolCalls=t;break}case`turn_end`:e.message.role===`assistant`&&e.message.errorMessage&&(this._state.errorMessage=e.message.errorMessage);break;case`agent_end`:this._state.streamingMessage=void 0;break}let t=this.activeRun?.abortController.signal;if(!t)throw Error(`Agent listener invoked outside active run`);for(let n of this.listeners)await n(e,t)}};const xe=Symbol.for(`yaml.alias`),Se=Symbol.for(`yaml.document`),E=Symbol.for(`yaml.map`),Ce=Symbol.for(`yaml.pair`),we=Symbol.for(`yaml.scalar`),Te=Symbol.for(`yaml.seq`),D=Symbol.for(`yaml.node.type`),O=e=>!!e&&typeof e==`object`&&e[D]===xe,Ee=e=>!!e&&typeof e==`object`&&e[D]===Se,De=e=>!!e&&typeof e==`object`&&e[D]===E,k=e=>!!e&&typeof e==`object`&&e[D]===Ce,A=e=>!!e&&typeof e==`object`&&e[D]===we,Oe=e=>!!e&&typeof e==`object`&&e[D]===Te;function j(e){if(e&&typeof e==`object`)switch(e[D]){case E:case Te:return!0}return!1}function M(e){if(e&&typeof e==`object`)switch(e[D]){case xe:case E:case we:case Te:return!0}return!1}const ke=e=>(A(e)||j(e))&&!!e.anchor,N=Symbol(`break visit`),Ae=Symbol(`skip children`),P=Symbol(`remove node`);function je(e,t){let n=Ne(t);Ee(e)?F(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):F(null,e,n,Object.freeze([]))}je.BREAK=N,je.SKIP=Ae,je.REMOVE=P;function F(e,t,n,r){let i=Pe(e,t,n,r);if(M(i)||k(i))return Fe(e,r,i),F(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=F(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=F(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=F(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}async function Me(e,t){let n=Ne(t);Ee(e)?await I(null,e.contents,n,Object.freeze([e]))===P&&(e.contents=null):await I(null,e,n,Object.freeze([]))}Me.BREAK=N,Me.SKIP=Ae,Me.REMOVE=P;async function I(e,t,n,r){let i=await Pe(e,t,n,r);if(M(i)||k(i))return Fe(e,r,i),I(e,i,n,r);if(typeof i!=`symbol`){if(j(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await I(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===N)return N;else i===P&&(t.items.splice(e,1),--e)}}else if(k(t)){r=Object.freeze(r.concat(t));let e=await I(`key`,t.key,n,r);if(e===N)return N;e===P&&(t.key=null);let i=await I(`value`,t.value,n,r);if(i===N)return N;i===P&&(t.value=null)}}return i}function Ne(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Pe(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(De(t))return n.Map?.(e,t,r);if(Oe(t))return n.Seq?.(e,t,r);if(k(t))return n.Pair?.(e,t,r);if(A(t))return n.Scalar?.(e,t,r);if(O(t))return n.Alias?.(e,t,r)}function Fe(e,t,n){let r=t[t.length-1];if(j(r))r.items[e]=n;else if(k(r))e===`key`?r.key=n:r.value=n;else if(Ee(r))r.contents=n;else{let e=O(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}const Ie={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Le=e=>e.replace(/[!,[\]{}]/g,e=>Ie[e]);var Re=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Le(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&M(e.contents)){let t={};je(e.contents,(e,n)=>{M(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
2
|
-
`)}};Re.defaultYaml={explicit:!1,version:`1.2`},Re.defaultTags={"!!":`tag:yaml.org,2002:`};function ze(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Be(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Be(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Be(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Be(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Be(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function L(e,t,n){if(Array.isArray(e))return e.map((e,t)=>L(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!ke(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Ve=class{constructor(e){Object.defineProperty(this,D,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ee(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=L(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Be(i,{"":o},``,o):o}},He=class extends Ve{constructor(e){super(xe),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],je(e,{Node:(e,t)=>{(O(t)||ke(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(L(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Ue(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(ze(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Ue(e,t,n){if(O(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(j(t)){let r=0;for(let i of t.items){let t=Ue(e,i,n);t>r&&(r=t)}return r}else if(k(t)){let r=Ue(e,t.key,n),i=Ue(e,t.value,n);return Math.max(r,i)}return 1}const We=e=>!e||typeof e!=`function`&&typeof e!=`object`;var R=class extends Ve{constructor(e){super(we),this.value=e}toJSON(e,t){return t?.keep?this.value:L(this.value,e,t)}toString(){return String(this.value)}};R.BLOCK_FOLDED=`BLOCK_FOLDED`,R.BLOCK_LITERAL=`BLOCK_LITERAL`,R.PLAIN=`PLAIN`,R.QUOTE_DOUBLE=`QUOTE_DOUBLE`,R.QUOTE_SINGLE=`QUOTE_SINGLE`;function Ge(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Ke(e,t,n){if(Ee(e)&&(e=e.contents),M(e))return e;if(k(e)){let t=n.schema[E].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??=i(e),new He(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=`tag:yaml.org,2002:`+t.slice(2));let l=Ge(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new R(e);return c&&(c.node=t),t}l=e instanceof Map?o[E]:Symbol.iterator in Object(e)?o[Te]:o[E]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new R(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function qe(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Ke(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}const Je=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;var Ye=class extends Ve{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>M(t)||k(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Je(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(j(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,qe(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(j(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&A(i)?i.value:i:j(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!k(t))return!1;let n=t.value;return n==null||e&&A(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return j(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(j(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,qe(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}};const Xe=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Ze(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const z=(e,t,n)=>e.endsWith(`
|
|
3
|
-
`)?Ze(n,t):n.includes(`
|
|
4
|
-
`)?`
|
|
5
|
-
`+Ze(n,t):(e.endsWith(` `)?``:` `)+n,Qe=`flow`;function $e(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=et(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
6
|
-
`)n===`block`&&(h=et(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
7
|
-
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
8
|
-
`&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function et(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
9
|
-
`);r=t,i=t+1,a=e[i]}return r}const tt=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),nt=e=>/^(%|---|\.\.\.)/m.test(e);function rt(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
10
|
-
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function it(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(nt(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
11
|
-
|
|
12
|
-
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
13
|
-
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:$e(o,a,`quoted`,tt(t,!1))}function at(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
14
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return it(e,t);let n=t.indent||(nt(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:$e(r,n,Qe,tt(t,!1))}function B(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=it;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?at:i&&!t?it:n?at:it}return r(e,t)}let ot;try{ot=RegExp(`(^|(?<!
|
|
15
|
-
))
|
|
16
|
-
+(?!
|
|
17
|
-
|$)`,`g`)}catch{ot=/\n+(?!\n|$)/g}function st({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return B(n,r);let l=r.indent||(r.forceBlockIndent||nt(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===R.BLOCK_FOLDED?!1:t===R.BLOCK_LITERAL?!0:!rt(n,c,l.length);if(!n)return u?`|
|
|
18
|
-
`:`>
|
|
19
|
-
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
20
|
-
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
21
|
-
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
22
|
-
`&&(p=p.slice(0,-1)),p.replace(ot,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
23
|
-
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
24
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=tt(r,!0);o!==`folded`&&t!==R.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=$e(`${v}${e}${p}`,l,`block`,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function ct(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
25
|
-
`)||u&&/[[\]{},]/.test(a))return B(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
26
|
-
`)?B(a,t):st(e,t,n,r);if(!s&&!u&&i!==R.PLAIN&&a.includes(`
|
|
27
|
-
`))return st(e,t,n,r);if(nt(a)){if(c===``)return t.forceBlockIndent=!0,st(e,t,n,r);if(s&&c===l)return B(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return B(a,t)}return s?d:$e(d,c,Qe,tt(t,!1))}function lt(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==R.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=R.QUOTE_DOUBLE);let c=e=>{switch(e){case R.BLOCK_FOLDED:case R.BLOCK_LITERAL:return i||a?B(o.value,t):st(o,t,n,r);case R.QUOTE_DOUBLE:return it(o.value,t);case R.QUOTE_SINGLE:return at(o.value,t);case R.PLAIN:return ct(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function ut(e,t){let n=Object.assign({blockQuote:!0,commentString:Xe,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function dt(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(A(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function ft(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(A(e)||j(e))&&e.anchor;a&&ze(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function pt(e,t,n,r){if(k(e))return e.toString(t,n,r);if(O(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=M(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=dt(t.doc.schema.tags,a);let o=ft(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):A(a)?lt(a,t,n,r):a.toString(t,n,r);return o?A(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function mt({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=M(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(j(e)||!M(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||j(e)||(A(e)?e.type===R.BLOCK_FOLDED||e.type===R.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=pt(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=z(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=z(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=z(g,n.indent,l(f))));let _,v,y;M(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&A(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Oe(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=pt(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
|
|
28
|
-
`:``,v){let e=l(v);S+=`\n${Ze(e,n.indent)}`}x===``&&!n.inFlow?S===`
|
|
29
|
-
`&&y&&(S=`
|
|
30
|
-
|
|
31
|
-
`):S+=`\n${n.indent}`}else if(!p&&j(t)){let e=x[0],r=x.indexOf(`
|
|
32
|
-
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
|
|
33
|
-
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=z(g,n.indent,l(y)):h&&i&&i(),g}function ht(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}const gt={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new R(Symbol(`<<`)),{addToJSMap:vt}),stringify:()=>`<<`},_t=(e,t)=>(gt.identify(t)||A(t)&&(!t.type||t.type===R.PLAIN)&>.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===gt.tag&&e.default);function vt(e,t,n){let r=bt(e,n);if(Oe(r))for(let n of r.items)yt(e,t,n);else if(Array.isArray(r))for(let n of r)yt(e,t,n);else yt(e,t,r)}function yt(e,t,n){let r=bt(e,n);if(!De(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function bt(e,t){return e&&O(t)?t.resolve(e.doc,e):t}function xt(e,t,{key:n,value:r}){if(M(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(_t(e,n))vt(e,t,r);else{let i=L(n,``,e);if(t instanceof Map)t.set(i,L(r,i,e));else if(t instanceof Set)t.add(i);else{let a=St(n,i,e),o=L(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function St(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(M(e)&&n?.doc){let t=ut(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),ht(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Ct(e,t,n){return new V(Ke(e,void 0,n),Ke(t,void 0,n))}var V=class e{constructor(e,t=null){Object.defineProperty(this,D,{value:Ce}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return M(n)&&(n=n.clone(t)),M(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return xt(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?mt(this,e,t,n):JSON.stringify(this)}};function wt(e,t,n){return(t.inFlow??e.flow?Et:Tt)(e,t,n)}function Tt({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(M(i))!d&&i.spaceBefore&&f.push(``),Dt(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(k(i)){let e=M(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),Dt(n,f,e.commentBefore,d))}d=!1;let s=pt(i,u,()=>o=null,()=>d=!0);o&&(s+=z(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
34
|
-
`}}return e?(p+=`
|
|
35
|
-
`+Ze(l(e),c),s&&s()):d&&o&&o(),p}function Et({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(M(i))i.spaceBefore&&d.push(``),Dt(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(k(i)){let e=M(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Dt(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=M(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=pt(i,c,()=>a=null);l||=d.length>u||o.includes(`
|
|
36
|
-
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=z(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
37
|
-
`;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function Dt({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Ze(t(r),e);n.push(i.trimStart())}}function H(e,t){let n=A(t)?t.value:t;for(let r of e)if(k(r)&&(r.key===t||r.key===n||A(r.key)&&r.key.value===n))return r}var U=class extends Ye{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(E,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ct(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=k(e)?e:!e||typeof e!=`object`||!(`key`in e)?new V(e,e?.value):new V(e.key,e.value);let r=H(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);A(r.value)&&We(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=H(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=H(this.items,e)?.value;return(!t&&A(n)?n.value:n)??void 0}has(e){return!!H(this.items,e)}set(e,t){this.add(new V(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)xt(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!k(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),wt(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Ot={collection:`map`,default:!0,nodeClass:U,tag:`tag:yaml.org,2002:map`,resolve(e,t){return De(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>U.from(e,t,n)};var kt=class extends Ye{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Te,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=At(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=At(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&A(r)?r.value:r}has(e){let t=At(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=At(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];A(r)&&We(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(L(e,String(r++),t));return n}toString(e,t,n){return e?wt(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Ke(a,void 0,n))}}return i}};function At(e){let t=A(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const jt={collection:`seq`,default:!0,nodeClass:kt,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Oe(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>kt.from(e,t,n)};function Mt(e){return typeof e==`bigint`||Number.isInteger(e)}const Nt=({value:e})=>JSON.stringify(e),Pt=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Nt},{identify:e=>e==null,createNode:()=>new R(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Nt},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Nt},{identify:Mt,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Mt(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Nt}];[Ot,jt].concat(Pt,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function Ft(e,t,n){let{replacer:r}=n,i=new kt(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ct(o,s,n))}return i}var It=class e extends kt{constructor(){super(),this.add=U.prototype.add.bind(this),this.delete=U.prototype.delete.bind(this),this.get=U.prototype.get.bind(this),this.has=U.prototype.has.bind(this),this.set=U.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(k(e)?(r=L(e.key,``,t),i=L(e.value,r,t)):r=L(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Ft(e,t,n),i=new this;return i.items=r.items,i}};It.tag=`tag:yaml.org,2002:omap`;var Lt=class e extends U{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=k(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new V(e.key,null):new V(e,null),H(this.items,t.key)||this.items.push(t)}get(e,t){let n=H(this.items,e);return!t&&k(n)?A(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=H(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new V(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ct(e,null,n));return i}};Lt.tag=`tag:yaml.org,2002:set`;const Rt=Symbol(`break visit`),zt=Symbol(`skip children`),Bt=Symbol(`remove item`);function W(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),Vt(Object.freeze([]),e,t)}W.BREAK=Rt,W.SKIP=zt,W.REMOVE=Bt,W.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},W.parentCollection=(e,t)=>{let n=W.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function Vt(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=Vt(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===Rt)return Rt;else r===Bt&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}t(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,ee=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,te=e=>e.split(s).filter(Boolean);var ne=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let re=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new ne(e,t,i,n,r,s)};var ie=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),ee(e.pattern)){let t=re(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?te(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let ae=(e,t)=>{throw new t(e)},w=(e,t,n)=>C(e)?e?w.isNotRelative(e)?n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):!0:n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),oe=e=>c.test(e);w.isNotRelative=oe,w.convert=e=>e;var se=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new ie(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&w.convert(e);return w(i,e,this._strictPathCheck?ae:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let ce=e=>new se(e),le=e=>w(e&&w.convert(e),e,m),ue=()=>{w.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;w.isNotRelative=t=>e.test(t)||oe(t)};typeof process<`u`&&process.platform===`win32`&&ue(),t.exports=ce,ce.default=ce,t.exports.isPathValid=le,f(t.exports,Symbol.for(`setupWindows`),ue)}))(),globalThis.Buffer;function Ht(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n>=10||r===0?Math.round(n):Math.round(n*10)/10} ${t[r]}`}function Ut(e){let t=e.mimeType||`application/octet-stream`;return`${e.name} (${t}, ${Ht(e.size)})`}function Wt(e){let t=Ut(e);return e.kind===`image`&&e.data?e.path?`[Attached image: ${t} — full-resolution copy saved to ${e.path}]`:`[Attached image: ${t}]`:e.kind===`text`&&e.text!==void 0?[`----- BEGIN ATTACHMENT ${t} -----`,e.text,`----- END ATTACHMENT ${e.name} -----`].join(`
|
|
38
|
-
`):e.path?`[Attached ${e.kind===`image`?`image`:e.kind===`text`?`text file`:`file`} saved to ${e.path} — ${t}. Read it from the virtual filesystem when you need its contents.]`:e.error?`[Attachment not included: ${t}. ${e.error}]`:`[Attachment not included: ${t}. Unsupported binary attachment.]`}function Gt(e,t){if(!t?.length)return e;let n=t.map(Wt),r=e.trim();return r?`${r}\n\n${n.join(`
|
|
39
|
-
|
|
40
|
-
`)}`:n.join(`
|
|
41
|
-
|
|
42
|
-
`)}function Kt(e){return e?.length?e.filter(e=>e.kind===`image`&&e.data).map(e=>({type:`image`,data:e.data,mimeType:e.mimeType})):[]}const qt={enabled:!0,reserveTokens:16384,keepRecentTokens:2e4};function Jt(e,t,n){return n.enabled?e>t-n.reserveTokens:!1}function Yt(e){if(typeof e==`string`)return e.length;let t=0;for(let n of e)n.type===`text`&&n.text?t+=n.text.length:n.type===`image`&&(t+=4800);return t}function Xt(e){let t=0;switch(e.role){case`user`:return t=Yt(e.content),Math.ceil(t/4);case`assistant`:{let n=e;for(let e of n.content)e.type===`text`?t+=e.text.length:e.type===`thinking`?t+=e.thinking.length:e.type===`toolCall`&&(t+=e.name.length+JSON.stringify(e.arguments).length);return Math.ceil(t/4)}case`custom`:case`toolResult`:return t=Yt(e.content),Math.ceil(t/4);case`bashExecution`:return t=e.command.length+e.output.length,Math.ceil(t/4);case`branchSummary`:case`compactionSummary`:return t=e.summary.length,Math.ceil(t/4)}return 0}const G=n(`context-compaction`);function Zt(e,t){return e.role===t}function Qt(e){let t=0;for(;t<e.length&&Zt(e[t],`toolResult`);){let n=e[t];G.warn(`Dropping orphaned toolResult (no preceding assistant message)`,{toolCallId:n.toolCallId}),t++}return t>0?e.slice(t):e}function $t(e){let t=[];for(let n of e){let e=n;switch(e.role){case`user`:t.push(`<user>\n${en(e.content)}\n</user>`);break;case`assistant`:t.push(`<assistant>\n${en(e.content)}\n</assistant>`);break;case`toolResult`:{let n=e.toolName??`tool`;t.push(`<tool-result name="${n}">\n${en(e.content)}\n</tool-result>`);break}case`bashExecution`:t.push(`<bash>\n$ ${e.command??``}\n${e.output??``}\n</bash>`);break;case`branchSummary`:case`compactionSummary`:t.push(`<prior-summary>\n${e.summary??``}\n</prior-summary>`);break;default:t.push(`<${e.role}>\n${en(e.content)}\n</${e.role}>`)}}return t.join(`
|
|
43
|
-
|
|
44
|
-
`)}function en(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){let e=n;e.type===`text`&&e.text?t.push(e.text):e.type===`thinking`&&e.thinking?t.push(`[thinking] ${e.thinking}`):e.type===`toolCall`?t.push(`[tool-call ${e.name??`?`}] ${JSON.stringify(e.arguments??{})}`):e.type===`image`&&t.push(`[image]`)}return t.join(`
|
|
45
|
-
`)}function tn(e){return`You are a context compaction assistant. You are shown the prefix of a conversation between a user and an AI coding assistant, and asked to produce either a structured summary, durable memory bullets, or a short title — depending on the user's instruction.
|
|
46
|
-
|
|
47
|
-
Do NOT continue the conversation. Do NOT answer questions inside the conversation. Output ONLY what the user asks for in the format specified.
|
|
48
|
-
|
|
49
|
-
<conversation>
|
|
50
|
-
${e}
|
|
51
|
-
</conversation>`}async function nn(e,t,n,r,i,a,o){let s=await y(e,{systemPrompt:n,messages:[{role:`user`,content:[{type:`text`,text:r}],timestamp:Date.now()}]},{maxTokens:i,apiKey:t,headers:a,signal:o});if(s.stopReason===`error`)throw Error(`Compaction call failed: ${s.errorMessage||`Unknown error`}`);return s.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
52
|
-
`).trim()}function rn(e){if(typeof e==`string`)return e.length;if(!Array.isArray(e))return 0;let t=0;for(let n of e){let e=n;if(e.type===`text`&&e.text)t+=e.text.length;else if(e.type===`thinking`&&e.thinking)t+=e.thinking.length;else if(e.type===`toolCall`&&e.arguments!==void 0)try{t+=JSON.stringify(e.arguments).length}catch{}else e.type===`image`&&e.source?.data&&(t+=e.source.data.length)}return t}function an(e,t){let n=Math.max(1,Math.round(e/1024));return`[${t===`assistant`?`Assistant message elided`:`Tool result elided`}: ${n} KB, exceeds half the context window. Re-run with smaller arguments — e.g. open --view --size low.]`}function on(e,t,n){let r=(t-n)/2,i=0,a=0;return{messages:e.map(e=>{if(Xt(e)<=r)return e;let t=e.role;if(t!==`toolResult`&&t!==`assistant`)return e;let n=e,o=rn(n.content);if(t===`toolResult`)return i++,a+=o,{...e,content:[{type:`text`,text:an(o,`toolResult`)}]};let s=(Array.isArray(n.content)?n.content:[]).filter(e=>e.type===`toolCall`);if(s.length===0)return e;let c=s.map(e=>{let t=0;if(e.arguments!==void 0)try{t=JSON.stringify(e.arguments).length}catch{}return{type:e.type,id:e.id,name:e.name,arguments:{elided:!0,originalBytes:t}}});return i++,a+=o,{...e,content:[{type:`text`,text:an(o,`assistant`)},...c]}}),elidedCount:i,elidedBytes:a}}function sn(e){let t=e.contextWindow??2e5,n=e.reserveTokens??qt.reserveTokens,r=e.keepRecentTokens??qt.keepRecentTokens,i=e.hopelessMultiplier??4,a={enabled:!0,reserveTokens:n,keepRecentTokens:r};return async(o,s)=>{if(o.length===0)return o;let c=0;for(let e of o)c+=Xt(e);if(!Jt(c,t,a))return o;let l=o,u=!1;if(c>t*i){u=!0;let e=on(o,t,n);l=e.messages,G.warn(`Compaction hopeless branch`,{totalTokens:c,contextWindow:t,multiplier:i,elidedCount:e.elidedCount,elidedBytes:e.elidedBytes});let r=0;for(let e of l)r+=Xt(e);if(!Jt(r,t,a))return l}G.info(`Context compaction triggered`,{totalTokens:c,contextWindow:t,threshold:t-n,messageCount:l.length});let d=0,f=l.length;for(let e=l.length-1;e>=0;e--){let t=Xt(l[e]);if(d+t>r&&f<l.length)break;d+=t,f=e}for(;f>0&&Zt(l[f],`toolResult`);)f--;if(f<=0||f>=l.length)return G.warn(`Cannot find valid cut point for compaction`),l;let p=l.slice(0,f),m=Qt(l.slice(f));G.info(`Compaction cut point`,{summarizing:p.length,keeping:m.length});let h=t=>{try{e.onCompactionStateChange?.(t)}catch(e){G.warn(`onCompactionStateChange listener threw`,{error:e instanceof Error?e.message:String(e)})}},g=u?void 0:e.getApiKey();if(g)try{let t=tn($t(p)),r=Math.floor(.8*n);h(`summarizing`);let i=await nn(e.model,g,t,`Produce a structured context checkpoint summary of the conversation above that another LLM can use to continue the work.
|
|
53
|
-
|
|
54
|
-
Use this EXACT format:
|
|
55
|
-
|
|
56
|
-
## Goal
|
|
57
|
-
[What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
|
|
58
|
-
|
|
59
|
-
## Constraints & Preferences
|
|
60
|
-
- [Any constraints, preferences, or requirements mentioned by user]
|
|
61
|
-
- [Or "(none)" if none were mentioned]
|
|
62
|
-
|
|
63
|
-
## Progress
|
|
64
|
-
### Done
|
|
65
|
-
- [x] [Completed tasks/changes]
|
|
66
|
-
|
|
67
|
-
### In Progress
|
|
68
|
-
- [ ] [Current work]
|
|
69
|
-
|
|
70
|
-
### Blocked
|
|
71
|
-
- [Issues preventing progress, if any]
|
|
72
|
-
|
|
73
|
-
## Key Decisions
|
|
74
|
-
- **[Decision]**: [Brief rationale]
|
|
75
|
-
|
|
76
|
-
## Next Steps
|
|
77
|
-
1. [Ordered list of what should happen next]
|
|
78
|
-
|
|
79
|
-
## Critical Context
|
|
80
|
-
- [Any data, examples, or references needed to continue]
|
|
81
|
-
- [Or "(none)" if not applicable]
|
|
82
|
-
|
|
83
|
-
Keep each section concise. Preserve exact file paths, function names, and error messages. Output ONLY the summary, with no preamble or follow-up.`,r,e.headers,s),a={role:`user`,content:[{type:`text`,text:`<context-summary>\n${i}\n</context-summary>`}],timestamp:Date.now()};if(G.info(`LLM summarization successful`,{originalMessages:o.length,compactedMessages:1+m.length,summaryLength:i.length}),e.onMemoryUpdates)try{h(`extracting-memory`);let n=await nn(e.model,g,t,`From the conversation above, extract durable memories worth persisting to a global memory file shared across future sessions.
|
|
84
|
-
|
|
85
|
-
Focus on:
|
|
86
|
-
- User preferences, working style, opinions stated explicitly.
|
|
87
|
-
- Stable project facts (architecture decisions, conventions, constraints).
|
|
88
|
-
- Validated approaches the user accepted ("yes, exactly", "perfect"), not just corrections.
|
|
89
|
-
- External resources/links the user named.
|
|
90
|
-
|
|
91
|
-
DO NOT include:
|
|
92
|
-
- Ephemeral state (current task, in-progress work).
|
|
93
|
-
- Information already obvious from the codebase (file paths, function names, framework conventions).
|
|
94
|
-
- Generic restatements of what the conversation was about.
|
|
95
|
-
|
|
96
|
-
If nothing in the conversation is worth persisting, return exactly the single line:
|
|
97
|
-
NONE
|
|
98
|
-
|
|
99
|
-
Otherwise, output ONLY a markdown bullet list (one bullet per memory), no headers, no preamble, no follow-up. Each bullet is one line. Be specific. Prefer one fact per bullet over multi-clause sentences.`,2048,e.headers,s);if(n?.trim()&&n.trim()!==`NONE`)try{await e.onMemoryUpdates(n.trim()),G.info(`Memory extraction applied`,{bulletsLength:n.length})}catch(e){G.warn(`onMemoryUpdates callback threw`,{error:e instanceof Error?e.message:String(e)})}else G.info(`Memory extraction returned no durable memories`)}catch(e){G.warn(`Memory extraction call failed (compaction still applied)`,{error:e instanceof Error?e.message:String(e)})}return h(`idle`),[a,...m]}catch(e){G.warn(`LLM summarization failed, falling back to naive drop`,{error:e instanceof Error?e.message:String(e)})}else u||G.warn(`No API key available for LLM summarization, falling back to naive drop`);h(`idle`);let _={role:`user`,content:[{type:`text`,text:`[Earlier conversation messages were compacted to save context space]`}],timestamp:Date.now()};return G.info(`Naive compaction applied`,{originalMessages:o.length,compactedMessages:1+m.length}),[_,...m]}}const cn=n(`secrets-bridge`),ln=1e4;let un=null,dn=1;const K=new Map;function fn(e){let t=e;if(typeof t?.id!=`number`)return;let n=K.get(t.id);n&&(K.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function pn(){un=null;for(let[,e]of K)clearTimeout(e.timer),e.reject(Error(`secrets.crud port disconnected`));K.clear(),cn.debug(`secrets.crud port disconnected; pending cleared, will reconnect`)}function mn(){if(un)return un;let e=o();if(!e)return cn.warn(`cannot open secrets.crud port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return cn.warn(`cannot open secrets.crud port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`secrets.crud`});return n.onMessage.addListener(fn),n.onDisconnect.addListener(pn),un=n,n}function hn(e,t){return typeof chrome>`u`&&o()?_n(e,t):gn(e,t)}function gn(e,t){return new Promise((n,r)=>{let i=mn();if(!i){n(void 0);return}let a=dn++,o=setTimeout(()=>{K.delete(a)&&(cn.warn(`secrets.crud call timed out`,{type:e}),n(void 0))},ln);K.set(a,{resolve:n,reject:r,timer:o});try{i.postMessage({id:a,type:e,...t})}catch(e){K.delete(a),clearTimeout(o),un=null,r(e instanceof Error?e:Error(String(e)))}})}async function _n(e,t){let{getPanelRpcClient:n}=await import(`./panel-rpc-CjFVE0nK.js`).then(e=>e.i),r=n();if(!r){cn.warn(`cannot bridge secrets call: panel-RPC client unavailable in worker realm`,{type:e});return}let{response:i}=await r.call(`secrets-bridge`,{type:e,payload:t},{timeoutMs:ln});return i}const vn=n(`secret-scrub`),yn=async e=>e;function bn(){let e=C();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(vn.debug(`SW scrub-tool-result returned error`,{error:t.error}),e):typeof t.text==`string`?t.text:e}catch(t){return vn.debug(`SW scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await hn(`secrets.scrub-tool-result`,{text:e});return t?.error?(vn.debug(`Bridge scrub-tool-result returned error`,{error:t.error}),e):typeof t?.text==`string`?t.text:e}catch(t){return vn.debug(`Bridge scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}:e===`connect`?yn:async e=>{if(!e)return e;try{let t=await fetch(a(`/api/secrets/scrub`),{method:`POST`,headers:s({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return vn.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return vn.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const q=`sessions`;function xn(){return new Promise((e,t)=>{let n=indexedDB.open(`agent-sessions`,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(q)||e.createObjectStore(q,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var Sn=class{dbPromise=null;getDB(){return this.dbPromise||=xn().then(e=>(e.onversionchange=()=>{e.close(),this.dbPromise=null},e.onclose=()=>{this.dbPromise=null},e)),this.dbPromise}async save(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(q,`readwrite`).objectStore(q).put(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async load(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(q,`readonly`).objectStore(q).get(e);i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async delete(e){let t=await this.getDB();return new Promise((n,r)=>{let i=t.transaction(q,`readwrite`).objectStore(q).delete(e);i.onsuccess=()=>n(),i.onerror=()=>r(i.error)})}async list(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(q,`readonly`).objectStore(q).getAll();r.onsuccess=()=>{t((r.result??[]).map(e=>({id:e.id,updatedAt:e.updatedAt})))},r.onerror=()=>n(r.error)})}async clearAll(){let e=await this.getDB();return new Promise((t,n)=>{let r=e.transaction(q,`readwrite`).objectStore(q).clear();r.onsuccess=()=>t(),r.onerror=()=>n(r.error)})}static newId(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}static createSession(e,t){let n=Date.now();return{id:e,messages:[],config:t,createdAt:n,updatedAt:n}}static updateMessages(e,t){return{...e,messages:t,updatedAt:Date.now()}}};const J=n(`image-processor`),Cn=3932160,wn=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function Tn(e){return wn.has(e)}function En(e,t){try{if(t===`image/png`){if(e.length<32)return null;let t=atob(e.slice(0,32)),n=t.charCodeAt(16)<<24|t.charCodeAt(17)<<16|t.charCodeAt(18)<<8|t.charCodeAt(19),r=t.charCodeAt(20)<<24|t.charCodeAt(21)<<16|t.charCodeAt(22)<<8|t.charCodeAt(23);return n>0&&r>0?{width:n,height:r}:null}if(t===`image/gif`){if(e.length<16)return null;let t=atob(e.slice(0,16)),n=t.charCodeAt(6)|t.charCodeAt(7)<<8,r=t.charCodeAt(8)|t.charCodeAt(9)<<8;return n>0&&r>0?{width:n,height:r}:null}if(t===`image/jpeg`){let t=Math.min(21846*4,e.length),n=atob(e.slice(0,t));for(let e=0;e<n.length-8;e++)if(n.charCodeAt(e)===255){let t=n.charCodeAt(e+1);if(t===192||t===194){let t=n.charCodeAt(e+5)<<8|n.charCodeAt(e+6),r=n.charCodeAt(e+7)<<8|n.charCodeAt(e+8);return r>0&&t>0?{width:r,height:t}:null}}}}catch{}return null}async function Dn(e){if(!Tn(e.mimeType))return J.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,n=En(e.data,e.mimeType);if(!(t>5242880||n!==null&&(n.width>8e3||n.height>8e3)||n!==null&&Math.max(n.width,n.height)>1568))return e;J.info(`Image needs processing`,{base64Size:t,dimensions:n?`${n.width}x${n.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let r,i;try{let e=await import(`./kernel-worker-BOQlsxzN.js`).then(e=>e.l);r=e.getMagick,i=e.MIME_TO_MAGICK_FORMAT}catch(e){return J.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let a;try{a=await r()}catch(e){return J.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let n=atob(e.data),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);let o={data:null,mime:e.mimeType};if(await a.ImageMagick.read(r,async t=>{let n=t.width,r=t.height,a=Math.max(n,r);if(a>1568){let e=1568/a,i=Math.round(n*e),o=Math.round(r*e);t.resize(i,o),J.info(`Resized image`,{from:`${n}x${r}`,to:`${i}x${o}`})}let s=i[e.mimeType]||`JPEG`;t.write(s,e=>{o.data=new Uint8Array(e)}),o.data&&o.data.length>Cn&&s!==`JPEG`?(J.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}),o.mime=`image/jpeg`):o.data&&o.data.length>Cn&&(J.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{o.data=new Uint8Array(e)}))}),!o.data)return J.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(o.data.length>Cn)return J.warn(`Image still over 5MB after resize+compress`,{size:o.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(o.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let s=``;for(let e=0;e<o.data.length;e++)s+=String.fromCharCode(o.data[e]);let c=btoa(s);return J.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:o.mime}),{type:`image`,data:c,mimeType:o.mime}}catch(n){return J.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const On=n(`tool-adapter`),kn=/<img:(data:(image\/[^;]+);base64,([^>]+))>/g;function An(e){let t=[],n=0;for(let r of e.matchAll(kn)){let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r[2],data:r[3]}),n=r.index+r[0].length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function jn(e){let t=An(e),n=[];for(let e of t)e.type===`image`?n.push(await Dn(e)):n.push(e);return n}function Mn(e,t,n){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,async execute(r,i,a,o){let s;o&&(s=c({onUpdate:o,toolName:e.name,toolCallId:r}));let u=t?t.processManager.spawn({kind:`tool`,argv:[e.name,...Pn(i)],owner:t.owner,ppid:t.getParentPid?.()}):null,d=null;u&&t&&a&&(a.aborted?t.processManager.signal(u.pid,`SIGINT`):a.addEventListener(`abort`,()=>t.processManager.signal(u.pid,`SIGINT`),{once:!0})),u&&t&&(d=t.processManager.onSignal((e,n)=>{e.pid!==u.pid||n!==`SIGKILL`||t.processManager.exit(u.pid,null)}));let f=u?u.abort.signal:a;try{let r=await e.execute(i??{},f),a=r.content;if(n&&typeof a==`string`&&a.length>0)try{a=await n.scrubToolResult(a)}catch(t){On.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),a=r.content}let o;try{o=await jn(a)}catch(t){On.warn(`Image processing failed, falling back to raw content`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),o=An(a)}return u&&t&&t.processManager.exit(u.pid,+!!r.isError),{content:o,details:{isError:r.isError}}}catch(e){throw u&&t&&t.processManager.exit(u.pid,u.abort.signal.aborted?null:1),e}finally{s&&l(s),d?.()}}}}function Nn(e,t,n){return e.map(e=>Mn(e,t,n))}function Pn(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}var Fn=e({ACCOUNTS_KEY:()=>Y,addAccount:()=>nr,getAccounts:()=>$,getAllExtraOAuthDomains:()=>$n,getApiKey:()=>_r,getApiKeyForProvider:()=>ur,getApiVersionForProvider:()=>pr,getAvailableProviders:()=>Gn,getBaseUrlForProvider:()=>dr,getDeploymentForProvider:()=>fr,getExtraOAuthDomains:()=>Xn,getOAuthAccountInfo:()=>Yn,getProviderConfig:()=>X,getProviderModels:()=>Z,getRawApiKeyForProvider:()=>lr,getSelectedModelId:()=>mr,getSelectedProvider:()=>gr,logoutOAuthAccount:()=>ar,maskOAuthTokenWithRetry:()=>or,migrateLegacyAuthOnlySelection:()=>Wn,persistOAuthMaskViaServiceWorker:()=>sr,providerOffersLlmModels:()=>Kn,removeAccount:()=>ir,resolveCurrentModel:()=>Sr,resolveModelById:()=>xr,resolveModelByShorthand:()=>Cr,saveOAuthAccount:()=>cr,setExtraOAuthDomains:()=>Zn,setExtraOAuthDomainsAsync:()=>Qn});const In=x,Ln=S,Y=`slicc_accounts`,Rn=`selected-model`,zn=[`slicc_provider`,`slicc_api_key`,`slicc_base_url`,`anthropic_api_key`,`api_provider`,`azure_resource`,`bedrock_region`],Bn=new Set([`github`]);function Vn(e){let t;try{t=b()}catch{return!1}return t.includes(e)&&!p(e)}let Hn=!1;function Un(){if(!Hn){Hn=!0;for(let e of zn)try{localStorage.removeItem(e)}catch{}Wn()}}function Wn(){try{let e=localStorage.getItem(Rn);if(e){let t=e.indexOf(`:`);if(t>0){let n=e.slice(0,t);(Bn.has(n)||Vn(n))&&localStorage.removeItem(Rn)}}}catch{}try{let e=localStorage.getItem(Y);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let n=t.filter(e=>!(typeof e==`object`&&e&&typeof e.providerId==`string`&&Vn(e.providerId)));n.length!==t.length&&localStorage.setItem(Y,JSON.stringify(n))}catch{}}function Gn(){let e=b().filter(p),t=f();return[...new Set([...e,...t])].filter(e=>!m(e)?.hidden)}function Kn(e){try{if(Z(e).length>0)return!0}catch{}try{if(S(e).length>0)return!0}catch{}let t=m(e);return!!(t?.modelOverrides&&Object.keys(t.modelOverrides).length>0)}function qn(e,t){try{if(Z(e).some(e=>e.id===t))return!0}catch{}try{if(S(e).some(e=>e.id===t))return!0}catch{}let n=m(e);return!!(n?.modelOverrides&&Object.hasOwn(n.modelOverrides,t))}function X(e){return m(e)||{id:e,name:e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),description:`${e} provider`,requiresApiKey:!0,requiresBaseUrl:!1}}function Jn(e,t){t.context_window!==void 0&&(e.contextWindow=t.context_window),t.max_tokens!==void 0&&(e.maxTokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),t.compat!==void 0&&(e.compat={...e.compat??{},...t.compat}),t.thinkingLevelMap!==void 0&&(e.thinkingLevelMap={...e.thinkingLevelMap??{},...t.thinkingLevelMap})}function Z(e){try{if(e===`bedrock-camp`){let e=v(dr(`bedrock-camp`));return Ln(`amazon-bedrock`).filter(t=>_(t,e)).map(e=>({...e,api:`bedrock-camp-converse`,provider:`bedrock-camp`}))}let t=X(e);if(t.getModelIds){let n;try{n=t.getModelIds()}catch(t){return Q.error(`Provider getModelIds callback failed`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}let r=new Map;for(let e of b())try{for(let t of Ln(e))r.set(t.id,t)}catch{}return n.map(n=>{let i=`${e}-${n.api===`openai`?`openai`:`anthropic`}`,a=r.get(n.id),o;a?o={...a,api:i,provider:e}:(o=yr(e,n.id,``,i),n.name&&(o.name=n.name));let s=t.modelOverrides?.[n.id];return s&&Jn(o,s),Jn(o,n),o})}if(t.isOAuth){let n=Ln(`anthropic`),r=`${e}-anthropic`;return n.map(n=>{let i={...n,api:r,provider:e},a=t.modelOverrides?.[n.id];return a&&Jn(i,a),i})}return Ln(e===`azure-ai-foundry`?`anthropic`:e)}catch(t){return Q.error(`Failed to load models`,{providerId:e,error:t instanceof Error?t.message:String(t)}),[]}}function Yn(e){let t=$().find(t=>t.providerId===e);if(!t?.accessToken)return null;let n=!!t.tokenExpiresAt&&Date.now()>t.tokenExpiresAt-6e4;return{token:t.accessToken,maskedValue:t.maskedValue,expiresAt:t.tokenExpiresAt,userName:t.userName,userAvatar:t.userAvatar,expired:n}}Object.assign({})[`/packages/webapp/providers.json`];const Q=n(`provider-settings`);function $(){Un();let e=localStorage.getItem(Y);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&typeof e.providerId==`string`&&typeof e.apiKey==`string`):[]}catch{return[]}}function Xn(e){return i(localStorage)[e]??[]}function Zn(e,t){let n=i(localStorage),a=t.map(e=>e.trim()).filter(e=>e.length>0);a.length===0?delete n[e]:n[e]=a,r(localStorage,n)}async function Qn(e,t){if(d()){Zn(e,t);return}let n=u();if(!n)throw Error(`setExtraOAuthDomainsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let{storeAfter:i}=await n.call(`oauth-extras-set`,{providerId:e,domains:t});try{r(localStorage,i)}catch(t){Q.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{providerId:e,error:t instanceof Error?t.message:String(t)})}}function $n(){return i(localStorage)}function er(e){localStorage.setItem(Y,JSON.stringify(e))}async function tr(e){if(d()){er(e);return}let t=u();if(!t)throw Error(`saveAccountsAsync: no DOM and no panel-rpc client — cannot persist to page localStorage`);let n=JSON.stringify(e),{storedJson:r}=await t.call(`save-oauth-accounts`,{accountsJson:n});try{localStorage.setItem(Y,r)}catch(e){Q.warn(`worker-shim mirror failed after successful page write — reload to refresh`,{error:e instanceof Error?e.message:String(e)})}}function nr(e,t,n,r,i){let a=$().filter(t=>t.providerId!==e),o={providerId:e,apiKey:t};n&&(o.baseUrl=n),r&&(o.deployment=r),i&&(o.apiVersion=i),a.push(o),er(a)}async function rr(e){let t=C();try{if(t===`extension-direct`){let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.delete`,name:`oauth.${e}.token`},n=>{chrome.runtime.lastError&&Q.error(`SW secrets.delete transport failed`,{providerId:e,error:chrome.runtime.lastError.message}),t(n??{})})});t.error&&Q.error(`SW secrets.delete returned error`,{providerId:e,error:t.error})}else if(t===`extension-delegate`){let t=await hn(`secrets.delete`,{name:`oauth.${e}.token`});t?.error&&Q.error(`Bridge secrets.delete returned error`,{providerId:e,error:t.error})}else if(t!==`connect`){let t=await fetch(a(`/api/secrets/oauth/${e}`),{method:`DELETE`,headers:s()});!t.ok&&t.status!==404&&Q.warn(`OAuth replica DELETE non-ok`,{providerId:e,status:t.status})}}catch(n){Q.error(`OAuth replica removal failed`,{providerId:e,topology:t,error:n instanceof Error?n.message:String(n)})}}async function ir(e){let t=$().find(t=>t.providerId===e),n=X(e);t&&n?.isOAuth&&await ar(e),await rr(e),await tr($().filter(t=>t.providerId!==e));let r=localStorage.getItem(Rn)??``,i=r.indexOf(`:`);i>0&&r.slice(0,i)===e&&localStorage.removeItem(Rn)}async function ar(e){let t=$().find(t=>t.providerId===e);if(!t)return;let n=X(e);if(n?.isOAuth){if(n.onOAuthLogout)try{await n.onOAuthLogout()}catch(t){Q.warn(`onOAuthLogout failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})}if(n.getOAuthLogoutUrl){let r=n.getOAuthLogoutUrl(t);if(r){let{openIdpLogoutUrl:t}=await import(`./oauth-service-CPJvHYuO.js`);await t(r).catch(t=>{Q.warn(`IdP logout popup failed`,{providerId:e,error:t instanceof Error?t.message:String(t)})})}}await tr($().map(t=>t.providerId===e?{providerId:t.providerId,apiKey:``,baseUrl:t.baseUrl,userName:t.userName,userAvatar:t.userAvatar,loggedOut:!0}:t)),await rr(e)}}async function or(e,t={}){let n=Math.max(1,t.attempts??3),r=t.delayMs??150,i=t.sleep??(e=>new Promise(t=>setTimeout(t,e))),a;for(let t=0;t<n;t++){let o=await e();if(o.maskedValue)return{maskedValue:o.maskedValue};o.error&&(a=o.error),t<n-1&&await i(r)}return{lastError:a}}async function sr(e,t,n){let r={providerId:e.providerId,accessToken:e.accessToken,domains:e.domains.join(`,`)},{maskedValue:i,lastError:a}=await or(()=>t.sendMaskRequest(r),n);if(!i){Q.error(`OAuth mask give-up: no masked value after retries`,{providerId:e.providerId,reason:a??`no error reported (cold SW or empty reply)`});return}let o=t.getAccounts(),s=o.find(t=>t.providerId===e.providerId);s&&(s.maskedValue=i,await t.saveAccounts(o))}async function cr(e){let t=$().find(t=>t.providerId===e.providerId),n=$().filter(t=>t.providerId!==e.providerId);n.push({providerId:e.providerId,apiKey:``,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar,baseUrl:e.baseUrl??t?.baseUrl}),await tr(n);let r=X(e.providerId)?.oauthTokenDomains??[],i=Xn(e.providerId),o=new Set,c=[];for(let e of[...r,...i]){let t=e.toLowerCase();o.has(t)||(o.add(t),c.push(e))}if(c.length===0)return;let l=C();try{if(l===`extension-direct`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:c},{sendMaskRequest:t=>new Promise(n=>{chrome.runtime.sendMessage({type:`secrets.mask-oauth-token`,...t},t=>{chrome.runtime.lastError&&Q.error(`SW mask-oauth-token transport failed`,{providerId:e.providerId,error:chrome.runtime.lastError.message}),t?.error&&Q.warn(`SW mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),n(t??{})})}),getAccounts:$,saveAccounts:tr});else if(l===`extension-delegate`)await sr({providerId:e.providerId,accessToken:e.accessToken,domains:c},{sendMaskRequest:t=>hn(`secrets.mask-oauth-token`,t).then(t=>(t?.error&&Q.warn(`Bridge mask-oauth-token returned error`,{providerId:e.providerId,error:t.error}),t??{})).catch(t=>(Q.error(`Bridge mask-oauth-token transport failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)}),{})),getAccounts:$,saveAccounts:tr});else if(l!==`connect`){let t=await fetch(a(`/api/secrets/oauth-update`),{method:`POST`,headers:s({"Content-Type":`application/json`}),body:JSON.stringify({providerId:e.providerId,accessToken:e.accessToken,domains:c})});if(t.ok){let n=await t.json();if(typeof n.maskedValue==`string`){let t=$(),r=t.find(t=>t.providerId===e.providerId);r&&(r.maskedValue=n.maskedValue,await tr(t))}else Q.warn(`OAuth replica POST ok but missing maskedValue`,{providerId:e.providerId})}else Q.warn(`OAuth replica POST non-ok`,{providerId:e.providerId,status:t.status})}}catch(t){Q.error(`OAuth replica sync failed`,{providerId:e.providerId,topology:l,error:t instanceof Error?t.message:String(t)})}}function lr(e){let t=$().find(t=>t.providerId===e);return t&&(t.accessToken||t.apiKey)||null}function ur(e){let t=$().find(t=>t.providerId===e);return t?t.accessToken||t.apiKey||(X(e).optionalApiKey?`local`:null):null}function dr(e){return $().find(t=>t.providerId===e)?.baseUrl??null}function fr(e){return $().find(t=>t.providerId===e)?.deployment??null}function pr(e){return $().find(t=>t.providerId===e)?.apiVersion??null}function mr(){let e=localStorage.getItem(Rn)||``,t=e.indexOf(`:`);return t>=0?e.slice(t+1):e}function hr(){return localStorage.getItem(Rn)||``}function gr(){let e=hr(),t=e.indexOf(`:`);if(t>0)return e.slice(0,t);let n=$(),r=mr();if(r){let e=n.find(e=>Kn(e.providerId)&&qn(e.providerId,r));if(e)return e.providerId}let i=n.find(e=>Kn(e.providerId));return i?i.providerId:n.length>0?n[0].providerId:`anthropic`}function _r(){return ur(gr())}function vr(e){return/^(?:gpt[-.]?|o[0-9]|chatgpt)/i.test(e)?`openai`:`anthropic`}function yr(e,t,n,r){return{id:t,name:t,provider:e,api:r??`${e}-${vr(t)}`,baseUrl:n??``,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},reasoning:!0}}function br(e,t){return t.isOAuth||e===`azure-ai-foundry`?`anthropic`:e===`bedrock-camp`?`amazon-bedrock`:e}function xr(e){if(!e)return Sr();let t=gr(),n=dr(t),r=X(t);try{let i=In(br(t,r),e);if(!i?.id)throw Error(`Model ${e} not found`);let a=i;return r.isOAuth?a=Z(t).find(t=>t.id===e)||{...a,api:`${t}-anthropic`,provider:t}:t===`bedrock-camp`&&(a={...a,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(a={...a,baseUrl:n}),a}catch(i){if(Q.debug(`resolveModelById: pi-ai lookup miss, using provider fallback`,{providerId:t,modelId:e,error:i instanceof Error?i.message:String(i)}),r.isOAuth){let r=Z(t).find(t=>t.id===e);return r?n?{...r,baseUrl:n}:r:yr(t,e,n)}return Sr()}}function Sr(){let e=gr(),t=mr(),n=dr(e),r=Z(e),i=X(e),a=i.defaultModelId?r.find(e=>e.id.toLowerCase().includes(i.defaultModelId.toLowerCase()))?.id:void 0,o=t||a||r[0]?.id||`claude-sonnet-4-6`;try{let t=br(e,i),a=In(t,o);if(!a?.id)throw Error(`Model ${o} not found in ${t} registry`);let s=a;return i.isOAuth?s=r.find(e=>e.id===o)||{...s,api:`${e}-anthropic`,provider:e}:e===`bedrock-camp`&&(s={...s,api:`bedrock-camp-converse`,provider:`bedrock-camp`}),n&&(s={...s,baseUrl:n}),s}catch(t){Q.debug(`resolveCurrentModel: pi-ai lookup miss, using provider fallback`,{providerId:e,effectiveModelId:o,error:t instanceof Error?t.message:String(t)});let a=r.find(e=>e.id===o);return a?n?{...a,baseUrl:n}:a:i.isOAuth?yr(e,o,n):In(`anthropic`,`claude-sonnet-4-0`)}}function Cr(e){let t=e.toLowerCase();if(!t)return null;let n=null,r=-1;for(let e of $())for(let i of Z(e.providerId)){let e=i.id.toLowerCase(),a=(i.name??``).toLowerCase();if(!e.includes(t)&&!a.includes(t))continue;let o=i.contextWindow??0;(o>r||o===r&&wr(i.id,n??``)>0)&&(r=o,n=i.id)}return n}function wr(e,t){let n=e.match(/\d+/g)?.map(Number)??[],r=t.match(/\d+/g)?.map(Number)??[],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}export{Qn as A,ee as B,Kn as C,Cr as D,xr as E,sn as F,Qt as I,Gt as L,Sn as M,bn as N,cr as O,hn as P,Kt as R,sr as S,Sr as T,C as V,mr as _,$n as a,or as b,pr as c,fr as d,Xn as f,lr as g,Z as h,$ as i,Nn as j,Zn as k,Gn as l,X as m,Fn as n,_r as o,Yn as p,nr as r,ur as s,Y as t,dr as u,gr as v,ir as w,Wn as x,ar as y,be as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){try{let t=new URL(e);if(t.searchParams.has(`bridge`))return!0;let n=t.hostname;return n!==`localhost`&&n!==`127.0.0.1`}catch{return!1}}function t(t,n){let r=e(t.pageHref),i=n();if(r){if(t.configuredRedirectUri){let e=``;try{e=new URL(t.configuredRedirectUri).origin}catch{e=``}if(e&&t.pageOrigin===e){let e=btoa(JSON.stringify({source:`opener`,path:`/auth/callback`,nonce:i}));return{redirectUri:t.configuredRedirectUri,oauthState:e,expectedNonce:i,source:`opener`}}let n=null;try{n=new URL(t.pageHref)}catch{n=null}if(n!==null&&n.protocol===`http:`&&(n.hostname===`localhost`||n.hostname===`127.0.0.1`)&&n.port!==``&&n){let e=parseInt(n.port,10),r=btoa(JSON.stringify({source:`local`,port:e,path:`/auth/callback`,nonce:i}));return{redirectUri:t.configuredRedirectUri,oauthState:r,expectedNonce:i,source:`local`}}}return{redirectUri:`${t.pageOrigin}/auth/callback`,oauthState:btoa(JSON.stringify({source:`opener`,path:`/auth/callback`,nonce:i})),expectedNonce:i,source:`opener`}}let a=t.configuredRedirectUri??`${t.pageOrigin}/auth/callback`,o=parseInt(new URL(t.pageHref).port||`5710`,10);return{redirectUri:a,oauthState:btoa(JSON.stringify({port:o,path:`/auth/callback`,nonce:i})),expectedNonce:i,source:`local`}}export{e as n,t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as e}from"./wc-live-Bahzf7iY.js";export{e as setDipExecHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./esptool-operations-BJlZgV2w.js";export{e as ESP8266ROM};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/account-store-CufoCtRK.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-D69OmKNn.js","assets/preload-helper-CZgWQFsJ.js","assets/__vite-browser-external-SwrSgYTf.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-C7d6hyOc.js","assets/context-compaction-DvlXtgVG.js","assets/logger-DDBAeTLF.js","assets/src-x0cJ68Fe.js","assets/proxied-fetch-Bht31_rT.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-D6iS4SOH.js","assets/secrets-bridge-client-DwfYAgDv.js","assets/tool-ui-DfXu6quJ.js","assets/providers-kdSIfEzm.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DjKgax8m.js","assets/transform-messages-DiIjWKhh.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{t}from"./mime-types-ugOWOUZ9.js";import{i as n,r}from"./src-x0cJ68Fe.js";import{a as i,n as a,t as o}from"./proxied-fetch-Bht31_rT.js";import{t as s}from"./types-idfTVsM8.js";import"./backend-local-BgTSBOxM.js";import"./mount-table-store-CfQUN_2R.js";import{t as c}from"./mount-bridge-client-CB9Fm9Jh.js";function l(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function u(e){return e.split(`/`).pop()||`data`}function d(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var f=5*1024*1024,p=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=d(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??f,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,n){if(this.assertOpen(e),n.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=this.toMountRelative(e),i=await this.cache.getBody(r),a=l(u(e),t(e),n),o={"content-type":a.contentType,"content-length":String(a.body.byteLength)};i?.etag?o[`if-match`]=i.etag.startsWith(`W/`)?i.etag.slice(2):i.etag:i||(o[`if-none-match`]=`*`);let c=()=>this.transport({method:`POST`,path:this.toSourcePath(r),headers:o,body:a.body}),d,f=1;try{d=await c()}catch{f=2,d=await c()}if(d.status===412){if(f===2){let t=await this.transport({method:`HEAD`,path:this.toSourcePath(r)});if(t.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${t.status}`,e);let i=t.headers.get(`etag`)??``;await this.cache.putBody(r,n,i);let a=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(r);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(d.status===401||d.status===403)throw new s(`EACCES`,`da write denied`,e);if(d.status>=400)throw new s(`EIO`,`da writeFile failed: ${d.status}`,e);let p=d.headers.get(`etag`)??``;await this.cache.putBody(r,n,p);let m=r.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new s(`ENOENT`,`no such file or directory`,e)}throw new s(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function m(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var h=25*1024*1024,g=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??h,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new s(`ENOENT`,`no such file or directory`,e)}throw new s(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new s(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},_=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function v(){let{getAccounts:t}=await e(async()=>{let{getAccounts:e}=await import(`./account-store-CufoCtRK.js`).then(e=>e.r);return{getAccounts:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),n=t().find(e=>e.providerId===`adobe`);if(!n?.accessToken)throw new _(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>n.accessToken}}var y=`slicc-mount-cache`,b=`listings`,x=`bodies`,S=class{mountId;ttlMs;dbName;dbPromise=null;constructor(e){this.mountId=e.mountId,this.ttlMs=e.ttlMs,this.dbName=e.dbName??y}isStale(e,t){return Date.now()-e>=(t??this.ttlMs)}async openDb(){return this.dbPromise||=new Promise((e,t)=>{let n=indexedDB.open(this.dbName,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(b)||e.createObjectStore(b),e.objectStoreNames.contains(x)||e.createObjectStore(x)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.dbPromise=null},t.onclose=()=>{this.dbPromise=null},e(t)},n.onerror=()=>t(n.error)}),this.dbPromise}key(e){return`${this.mountId}::${e}`}async getListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readonly`).objectStore(b).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putListing(e,t){let n=await this.openDb();return new Promise((r,i)=>{let a=n.transaction(b,`readwrite`),o={entries:t,cachedAt:Date.now()};a.objectStore(b).put(o,this.key(e)),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async invalidateListing(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(b,`readwrite`);i.objectStore(b).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async getBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readonly`).objectStore(x).get(this.key(e));i.onsuccess=()=>n(i.result??null),i.onerror=()=>r(i.error)})}async putBody(e,t,n){let r=await this.openDb(),i={body:t,etag:n,size:t.byteLength,cachedAt:Date.now()};try{await this.txPut(r,x,this.key(e),i)}catch(t){if(t instanceof DOMException&&t.name===`QuotaExceededError`){await this.evictLru(.25);try{await this.txPut(r,x,this.key(e),i)}catch{}return}throw t}}async invalidateBody(e){let t=await this.openDb();return new Promise((n,r)=>{let i=t.transaction(x,`readwrite`);i.objectStore(x).delete(this.key(e)),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}async clearMount(){let e=await this.openDb(),t=`${this.mountId}::`,n=n=>new Promise((r,i)=>{let a=e.transaction(n,`readwrite`),o=a.objectStore(n),s=o.getAllKeys();s.onsuccess=()=>{for(let e of s.result)typeof e==`string`&&e.startsWith(t)&&o.delete(e)},a.oncomplete=()=>r(),a.onerror=()=>i(a.error)});await Promise.all([n(b),n(x)])}txPut(e,t,n,r){return new Promise((i,a)=>{let o=e.transaction(t,`readwrite`);o.objectStore(t).put(r,n),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async evictLru(e){let t=await this.openDb(),n=`${this.mountId}::`,r=await new Promise((e,r)=>{let i=t.transaction(x,`readonly`).objectStore(x),a=[],o=i.openCursor();o.onsuccess=()=>{let t=o.result;if(!t){e(a);return}if(typeof t.key==`string`&&t.key.startsWith(n)){let e=t.value;a.push({key:t.key,cachedAt:e.cachedAt})}t.continue()},o.onerror=()=>r(o.error)});r.sort((e,t)=>e.cachedAt-t.cachedAt);let i=Math.max(1,Math.ceil(r.length*e)),a=r.slice(0,i);await new Promise((e,n)=>{let r=t.transaction(x,`readwrite`),i=r.objectStore(x);for(let{key:e}of a)i.delete(e);r.oncomplete=()=>e(),r.onerror=()=>n(r.error)})}};function C(){return typeof chrome<`u`&&!!chrome?.runtime?.id}var w=r,T=n,E=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),D=new Set([101,103,204,205,304]);function O(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||E.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=w(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=D.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function k(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function A(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function j(e,t,n){return C()?A(e,n):a()?c(e,n):k(t,n)}function M(e){return async t=>O(await j(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?T(t.body):void 0}))}function N(e){let t=e?.getImsToken??(async()=>(await v()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return O(await j(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?T(e.body):void 0}))}}export{p as DaMountBackend,S as RemoteMountCache,g as S3MountBackend,N as makeSignedFetchDa,M as makeSignedFetchS3};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/panel-rpc-DmJSNs0I.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-CZgWQFsJ.js";import{t as n}from"./logger-DDBAeTLF.js";import{n as r}from"./proxied-fetch-Bht31_rT.js";import{t as i}from"./types-idfTVsM8.js";var a=e({callMountBridge:()=>m}),o=n(`mount-bridge`),s=12e4,c=null,l=1,u=new Map;function d(e){let t=e;if(typeof t?.id!=`number`)return;let n=u.get(t.id);n&&(u.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function f(){c=null;for(let[,e]of u)clearTimeout(e.timer),e.reject(new i(`EIO`,`mount.sign-and-forward port disconnected`));u.clear(),o.debug(`mount.sign-and-forward port disconnected; pending cleared, will reconnect`)}function p(){if(c)return c;let e=r();if(!e)return o.warn(`cannot open mount.sign-and-forward port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return o.warn(`cannot open mount.sign-and-forward port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`mount.sign-and-forward`});return n.onMessage.addListener(d),n.onDisconnect.addListener(f),c=n,n}function m(e,t){return typeof chrome>`u`&&r()?g(e,t):h(e,t)}function h(e,t){return new Promise((n,r)=>{let a=p();if(!a){r(new i(`EIO`,`mount transport failed: extension delegate unavailable (${e})`));return}let o=l++,d=setTimeout(()=>{u.delete(o)&&r(new i(`EIO`,`mount transport: ${e} timed out`))},s);u.set(o,{resolve:n,reject:r,timer:d});try{a.postMessage({id:o,type:e,envelope:t})}catch(e){u.delete(o),clearTimeout(d),c=null,r(new i(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)}`))}})}async function g(e,n){let{getPanelRpcClient:r}=await t(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DmJSNs0I.js`).then(e=>e.i);return{getPanelRpcClient:e}},__vite__mapDeps([0,1])),a=r();if(!a)throw new i(`EIO`,`mount transport failed: panel-RPC client unavailable in worker realm (${e})`);let{reply:o}=await a.call(`mount-sign-and-forward`,{type:e,envelope:n},{timeoutMs:s});return o}export{a as n,m as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./logger-LESFN7Hj.js";import{_ as n,g as r,o as i,r as a,t as o}from"./proxied-fetch-BVw2cmL4.js";import"./backend-local-mrUgrni5.js";import{t as s}from"./types-idfTVsM8.js";import{t as c}from"./mime-types-BqLkKWa7.js";import{t as l}from"./remote-cache-D59F5FOx.js";function u(e,t,n){let r=`----DaMount${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`,i=new TextEncoder,a=i.encode(`--${r}\r\nContent-Disposition: form-data; name="data"; filename="${e}"\r\nContent-Type: ${t}\r\n\r\n`),o=i.encode(`\r\n--${r}--\r\n`),s=new Uint8Array(a.byteLength+n.byteLength+o.byteLength);return s.set(a,0),s.set(n,a.byteLength),s.set(o,a.byteLength+n.byteLength),{contentType:`multipart/form-data; boundary=${r}`,body:s}}function d(e){return e.split(`/`).pop()||`data`}function f(e){let t=e.match(/^da:\/\/([^/]+)\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid DA source '${e}' — expected da://org/repo[/path]`);return{org:t[1],repo:t[2],path:(t[3]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var p=class{kind=`da`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=f(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??5242880,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toSourcePath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/source/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}toListPath(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``),n=[this.parsed.path,t].filter(e=>e.length>0).join(`/`);return`/list/${this.parsed.org}/${this.parsed.repo}${n?`/${n}`:``}`}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,path:this.toSourcePath(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`da access denied`,e);if(i.status>=400)throw new s(`EIO`,`da readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``,u=l.startsWith(`W/`)?l.slice(2):l;return await this.cache.putBody(t,c,u),c}async writeFile(e,t){if(this.assertOpen(e),t.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let n=this.toMountRelative(e),r=await this.cache.getBody(n),i=u(d(e),c(e),t),a={"content-type":i.contentType,"content-length":String(i.body.byteLength)};r?.etag?a[`if-match`]=r.etag.startsWith(`W/`)?r.etag.slice(2):r.etag:r||(a[`if-none-match`]=`*`);let o=()=>this.transport({method:`POST`,path:this.toSourcePath(n),headers:a,body:i.body}),l,f=1;try{l=await o()}catch{f=2,l=await o()}if(l.status===412){if(f===2){let r=await this.transport({method:`HEAD`,path:this.toSourcePath(n)});if(r.status>=400)throw new s(`EIO`,`da reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(l.status===401||l.status===403)throw new s(`EACCES`,`da write denied`,e);if(l.status>=400)throw new s(`EIO`,`da writeFile failed: ${l.status}`,e);let p=l.headers.get(`etag`)??``;await this.cache.putBody(n,t,p);let m=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(m)}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.transport({method:`GET`,path:this.toListPath(t)});if(r.status===404)throw new s(`ENOENT`,`no such directory`,e);if(r.status>=400)throw new s(`EIO`,`da list failed: ${r.status}`,e);let i=(await r.json()).map(e=>e.ext?{name:`${e.name}.${e.ext}`,kind:`file`,etag:e.etag,lastModified:e.lastModified}:{name:e.name,kind:`directory`,lastModified:e.lastModified});return await this.cache.putListing(t,i),i}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.size,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,path:this.toSourcePath(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`),r=n?Date.parse(n):0;if(o){let n=o.entries.map(n=>n.name===i&&n.kind===`file`?{...n,size:e,etag:t,lastModified:r}:n);await this.cache.putListing(a,n)}return{kind:`file`,size:e,mtime:r,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new s(`ENOENT`,`no such file or directory`,e)}throw new s(`EIO`,`da stat failed: ${c.status}`,e)}async mkdir(e){}async remove(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.transport({method:`DELETE`,path:this.toSourcePath(t)});if(n.status===404)throw new s(`ENOENT`,`no such file`,e);if(n.status===401||n.status===403)throw new s(`EACCES`,`da delete denied`,e);if(n.status>=400)throw new s(`EIO`,`da delete failed: ${n.status}`,e);await this.cache.invalidateBody(t);let r=t.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(r)}async refresh(e){this.assertOpen(`/`);let t={added:[],removed:[],changed:[],unchanged:0,errors:[]},n=[``];for(;n.length>0;){let e=n.pop();try{await this.refreshDir(e,t,n)}catch(n){t.errors.push({path:e,message:n instanceof Error?n.message:String(n)})}}return e?.bodies&&await this.refreshBodies(t),t}async classifyFile(e,t,n){let r=await this.cache.getBody(e);r?t&&r.etag!==t?(await this.cache.invalidateBody(e),n.changed.push(e)):n.unchanged++:n.added.push(e)}async refreshDir(e,t,n){let r=await this.transport({method:`GET`,path:this.toListPath(e)});if(r.status>=400){t.errors.push({path:e,message:`list failed: ${r.status}`});return}let i=await r.json(),a=[];for(let r of i)if(r.ext){let n=e?`${e}/${r.name}.${r.ext}`:`${r.name}.${r.ext}`;a.push({name:`${r.name}.${r.ext}`,kind:`file`,etag:r.etag,lastModified:r.lastModified}),await this.classifyFile(n,r.etag,t)}else a.push({name:r.name,kind:`directory`}),n.push(e?`${e}/${r.name}`:r.name);await this.cache.putListing(e,a)}async refreshBodies(e){for(let t of e.changed)try{await this.readFile(t)}catch(n){e.errors.push({path:t,message:n instanceof Error?n.message:String(n)})}}describe(){return{displayName:`${this.parsed.org}/${this.parsed.repo}${this.parsed.path?`/${this.parsed.path}`:``}`,source:this.source,profile:this.profile}}async close(){this.closed||=!0}};function m(e){let t=e.match(/^s3:\/\/([^/]+)(?:\/(.*))?$/);if(!t)throw Error(`invalid S3 source '${e}' — expected s3://bucket[/prefix]`);return{bucket:t[1],prefix:(t[2]??``).replace(/^\/+/,``).replace(/\/+$/,``)}}var h=class{kind=`s3`;source;profile;mountId;parsed;cache;maxBodyBytes;transport;closed=!1;constructor(e){this.source=e.source,this.profile=e.profile,this.mountId=e.mountId??crypto.randomUUID(),this.parsed=m(e.source),this.cache=e.cache,this.maxBodyBytes=e.maxBodyBytes??26214400,this.transport=e.signedFetch}assertOpen(e){if(this.closed)throw new s(`EBADF`,`mount closed`,e)}toMountRelative(e){return e.replace(/^\/+/,``)}toS3Key(e){let t=e.replace(/^\/+/,``).replace(/\/+$/,``);return[this.parsed.prefix,t].filter(e=>e.length>0).join(`/`)}toMountRelativeKey(e){return this.parsed.prefix?e.slice(this.parsed.prefix.length+1):e}async readFile(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n&&!this.cache.isStale(n.cachedAt))return n.body;let r={};n&&(r[`if-none-match`]=n.etag);let i=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:this.toS3Key(t),headers:r});if(i.status===304&&n)return await this.cache.putBody(t,n.body,n.etag),n.body;if(i.status===404)throw await this.cache.invalidateBody(t),new s(`ENOENT`,`no such file`,e);if(i.status===401||i.status===403)throw new s(`EACCES`,`s3 access denied`,e);if(i.status>=400)throw new s(`EIO`,`s3 readFile failed: ${i.status}`,e);let a=i.headers.get(`content-length`),o=a?Number(a):void 0;if(o!==void 0&&o>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes (${o} > ${this.maxBodyBytes})`,e);let c=new Uint8Array(await i.arrayBuffer());if(c.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let l=i.headers.get(`etag`)??``;return await this.cache.putBody(t,c,l),c}async writeFile(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t.byteLength>this.maxBodyBytes)throw new s(`EFBIG`,`body exceeds maxBodyBytes`,e);let r=await this.cache.getBody(n),i={"content-type":`application/octet-stream`,"content-length":String(t.byteLength)};r?i[`if-match`]=r.etag:i[`if-none-match`]=`*`;let a=()=>this.transport({method:`PUT`,bucket:this.parsed.bucket,key:this.toS3Key(n),headers:i,body:t}),o,c=1;try{o=await a()}catch{c=2,o=await a()}if(o.status===412){if(c===2){let r=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status>=400)throw new s(`EIO`,`s3 reconcile HEAD failed: ${r.status}`,e);let i=r.headers.get(`etag`)??``;await this.cache.putBody(n,t,i);let a=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(a);return}await this.cache.invalidateBody(n);try{await this.readFile(e)}catch{}throw new s(`EBUSY`,`remote modified since last read — re-read and retry`,e)}if(o.status===401||o.status===403)throw new s(`EACCES`,`s3 write denied`,e);if(o.status>=400)throw new s(`EIO`,`s3 writeFile failed: ${o.status}`,e);let l=o.headers.get(`etag`)??``;await this.cache.putBody(n,t,l);let u=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(u)}async listObjectsV2(){let e=[],t;do{let n={"list-type":`2`};this.parsed.prefix&&(n.prefix=`${this.parsed.prefix}/`),t&&(n[`continuation-token`]=t);let r=await this.transport({method:`GET`,bucket:this.parsed.bucket,key:``,query:n});if(r.status>=400)throw new s(`EIO`,`s3 list failed: ${r.status}`,`/`);let i=await r.text(),a=this.parseListingXml(i);e.push(...a.contents),t=a.nextContinuationToken}while(t);return e}parseListingXml(e){let t=[];for(let n of e.matchAll(/<Contents>([\s\S]*?)<\/Contents>/g)){let e=n[1],r=e.match(/<Key>([^<]+)<\/Key>/)?.[1]??``,i=e.match(/<ETag>([^<]+)<\/ETag>/)?.[1]??``,a=e.match(/<Size>([^<]+)<\/Size>/)?.[1]??`0`,o=e.match(/<LastModified>([^<]+)<\/LastModified>/)?.[1]??``;t.push({key:r,etag:i,size:Number(a),lastModified:o?Date.parse(o):0})}return{contents:t,nextContinuationToken:e.match(/<IsTruncated>([^<]+)<\/IsTruncated>/)?.[1]===`true`?e.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/)?.[1]:void 0}}async readDir(e){this.assertOpen(e);let t=this.toMountRelative(e).replace(/\/+$/,``),n=await this.cache.getListing(t);if(n&&!this.cache.isStale(n.cachedAt))return n.entries;let r=await this.listObjectsV2(),i=this.groupByDir(r);for(let[e,t]of i)await this.cache.putListing(e,t);return i.get(t)??[]}groupByDir(e){let t=new Map,n=e=>(t.has(e)||t.set(e,[]),t.get(e));n(``);for(let t of e){let e=this.toMountRelativeKey(t.key).split(`/`),r=e.pop();n(e.join(`/`)).push({name:r,kind:`file`,size:t.size,etag:t.etag,lastModified:t.lastModified});let i=``;for(let t of e){let e=i;i=i?`${i}/${t}`:t;let r=n(e);r.find(e=>e.name===t&&e.kind===`directory`)||r.push({name:t,kind:`directory`}),n(i)}}return t}async stat(e){this.assertOpen(e);let t=this.toMountRelative(e),n=await this.cache.getBody(t);if(n)return{kind:`file`,size:n.body.byteLength,mtime:n.cachedAt,etag:n.etag};let r=t.split(`/`),i=r.pop()??``,a=r.join(`/`),o=await this.cache.getListing(a);if(o&&!this.cache.isStale(o.cachedAt)){let t=o.entries.find(e=>e.name===i);if(t?.kind===`file`&&t.size!==void 0)return{kind:`file`,size:t.size,mtime:t.lastModified??o.cachedAt,etag:t.etag??``};if(t?.kind===`directory`)return{kind:`directory`,size:0,mtime:t.lastModified??o.cachedAt};if(!t)throw new s(`ENOENT`,`no such file or directory`,e)}let c=await this.transport({method:`HEAD`,bucket:this.parsed.bucket,key:this.toS3Key(t)});if(c.status===200){let e=Number(c.headers.get(`content-length`)??`0`),t=c.headers.get(`etag`)??``,n=c.headers.get(`last-modified`);return{kind:`file`,size:e,mtime:n?Date.parse(n):0,etag:t}}if(c.status===404){let n=await this.cache.getListing(t);if(n)return{kind:`directory`,size:0,mtime:n.cachedAt};throw new s(`ENOENT`,`no such file or directory`,e)}throw new s(`EIO`,`s3 stat failed: ${c.status}`,e)}async refresh(e){this.assertOpen(`/`);let t=await this.listObjectsV2(),n=new Set(t.map(e=>this.toMountRelativeKey(e.key))),r=new Map(t.map(e=>[this.toMountRelativeKey(e.key),e.etag])),i={added:[],removed:[],changed:[],unchanged:0,errors:[]};for(let e of n){let t=await this.cache.getBody(e),n=r.get(e);t?t.etag===n?i.unchanged++:(await this.cache.invalidateBody(e),i.changed.push(e)):i.added.push(e)}let a=this.groupByDir(t);for(let[e,t]of a)await this.cache.putListing(e,t);if(e?.bodies)for(let e of i.changed)try{await this.readFile(e)}catch(t){i.errors.push({path:e,message:t instanceof Error?t.message:String(t)})}return i}async mkdir(e){}async remove(e,t){this.assertOpen(e);let n=this.toMountRelative(e);if(t?.recursive)throw new s(`EINVAL`,`recursive remove not yet supported on S3`,e);let r=await this.transport({method:`DELETE`,bucket:this.parsed.bucket,key:this.toS3Key(n)});if(r.status===404)throw new s(`ENOENT`,`no such file`,e);if(r.status===401||r.status===403)throw new s(`EACCES`,`s3 delete denied`,e);if(r.status>=400)throw new s(`EIO`,`s3 delete failed: ${r.status}`,e);await this.cache.invalidateBody(n);let i=n.split(`/`).slice(0,-1).join(`/`);await this.cache.invalidateListing(i)}describe(){return{displayName:this.parsed.prefix?`${this.parsed.bucket}/${this.parsed.prefix}`:this.parsed.bucket,source:this.source,profile:this.profile}}async close(){this.closed||=!0}},g=class extends Error{constructor(e){super(e),this.name=`ProfileNotConfiguredError`}};async function _(){let{getAccounts:e}=await import(`./account-store-CbtT2UK_.js`).then(e=>e.n),t=e().find(e=>e.providerId===`adobe`);if(!t?.accessToken)throw new g(`No Adobe IMS account found. Log in via Settings → Providers → Adobe first.`);return{identity:`adobe-ims`,getBearerToken:async()=>t.accessToken}}const v=t(`mount-bridge`),y=12e4;let b=null,x=1;const S=new Map;function C(e){let t=e;if(typeof t?.id!=`number`)return;let n=S.get(t.id);n&&(S.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function w(){b=null;for(let[,e]of S)clearTimeout(e.timer),e.reject(new s(`EIO`,`mount.sign-and-forward port disconnected`));S.clear(),v.debug(`mount.sign-and-forward port disconnected; pending cleared, will reconnect`)}function T(){if(b)return b;let e=a();if(!e)return v.warn(`cannot open mount.sign-and-forward port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return v.warn(`cannot open mount.sign-and-forward port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`mount.sign-and-forward`});return n.onMessage.addListener(C),n.onDisconnect.addListener(w),b=n,n}function E(e,t){return typeof chrome>`u`&&a()?O(e,t):D(e,t)}function D(e,t){return new Promise((n,r)=>{let i=T();if(!i){r(new s(`EIO`,`mount transport failed: extension delegate unavailable (${e})`));return}let a=x++,o=setTimeout(()=>{S.delete(a)&&r(new s(`EIO`,`mount transport: ${e} timed out`))},y);S.set(a,{resolve:n,reject:r,timer:o});try{i.postMessage({id:a,type:e,envelope:t})}catch(e){S.delete(a),clearTimeout(o),b=null,r(new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)}`))}})}async function O(e,t){let{getPanelRpcClient:n}=await import(`./panel-rpc-CjFVE0nK.js`).then(e=>e.i),r=n();if(!r)throw new s(`EIO`,`mount transport failed: panel-RPC client unavailable in worker realm (${e})`);let{reply:i}=await r.call(`mount-sign-and-forward`,{type:e,envelope:t},{timeoutMs:y});return i}function k(){return typeof chrome<`u`&&!!chrome?.runtime?.id}const A=r,j=n,M=new Set([`invalid_profile`,`invalid_request`,`profile_not_configured`,`fetch_failed`,`internal`]),N=new Set([101,103,204,205,304]);function P(e){if(!e.ok)throw e.errorCode===`profile_not_configured`||e.errorCode===`invalid_profile`?new s(`EACCES`,e.error):e.errorCode===`invalid_request`?new s(`EINVAL`,e.error):e.errorCode===`fetch_failed`||e.errorCode===`internal`||M.has(String(e.errorCode))?new s(`EIO`,e.error):new s(`EINVAL`,`mount transport returned unrecognized errorCode '${e.errorCode}': ${e.error}`);let t;try{t=A(e.bodyBase64)}catch(e){throw new s(`EIO`,`mount transport: response body decode failed: ${e instanceof Error?e.message:String(e)}`)}let n=N.has(e.status)?null:t;return new Response(n,{status:e.status,headers:new Headers(e.headers)})}async function F(e,t){let n;try{n=await fetch(i(e),{method:`POST`,headers:o({"content-type":`application/json`}),body:JSON.stringify(t)})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (SLICC backend at localhost may not be running)`)}try{return await n.json()}catch(e){throw new s(`EIO`,`mount transport: response is not a JSON envelope (status ${n.status}): ${e instanceof Error?e.message:String(e)}`)}}async function I(e,t){try{return await chrome.runtime.sendMessage({type:e,envelope:t})}catch(e){throw new s(`EIO`,`mount transport failed: ${e instanceof Error?e.message:String(e)} (extension service worker not responding)`)}}async function L(e,t,n){return k()?I(e,n):a()?E(e,n):F(t,n)}function R(e){return async t=>P(await L(`mount.s3-sign-and-forward`,`/api/s3-sign-and-forward`,{profile:e,method:t.method,bucket:t.bucket,key:t.key,query:t.query,headers:t.headers,bodyBase64:t.body?j(t.body):void 0}))}function z(e){let t=e?.getImsToken??(async()=>(await _()).getBearerToken());return async e=>{let n;try{n=await t()}catch(e){throw new s(`EACCES`,`DA mount: ${e instanceof Error?e.message:String(e)}`)}return P(await L(`mount.da-sign-and-forward`,`/api/da-sign-and-forward`,{imsToken:n,method:e.method,path:e.path,query:e.query,headers:e.headers,bodyBase64:e.body?j(e.body):void 0}))}}var B=e({DaMountBackend:()=>p,RemoteMountCache:()=>l,S3MountBackend:()=>h,makeSignedFetchDa:()=>z,makeSignedFetchS3:()=>R});export{p as a,h as i,z as n,R as r,B as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/quick-llm-CvPLRDgB.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-D69OmKNn.js","assets/preload-helper-CZgWQFsJ.js","assets/__vite-browser-external-SwrSgYTf.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-C7d6hyOc.js","assets/account-store-CufoCtRK.js","assets/context-compaction-DvlXtgVG.js","assets/logger-DDBAeTLF.js","assets/src-x0cJ68Fe.js","assets/proxied-fetch-Bht31_rT.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-D6iS4SOH.js","assets/secrets-bridge-client-DwfYAgDv.js","assets/tool-ui-DfXu6quJ.js","assets/providers-kdSIfEzm.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DjKgax8m.js","assets/transform-messages-DiIjWKhh.js","assets/llm-session-id-bZQs6gBN.js","assets/icons-C5g936Qd.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{F as t,m as n}from"./account-store-CufoCtRK.js";import{t as r}from"./logger-DDBAeTLF.js";import"./main-Yr2sAIA-.js";import{t as i}from"./llm-session-id-bZQs6gBN.js";import{SessionStore as a}from"./session-store-DAM8GRJ0.js";import{a as o,i as s}from"./wc-live-Bahzf7iY.js";var c=r(`new-session`),l=`ui-new-session`,u=2e4,d=250;async function f(r){let d=r.enrichmentRaceMs??u,f=n()??void 0,m;try{m=t()}catch(e){c.info(`No active model — freezing without LLM enrichment`,{error:e instanceof Error?e.message:String(e)})}let h=m?.provider===`adobe`?{"X-Session-Id":i(l)}:void 0,g=new a;try{await g.init()}catch(e){return c.warn(`SessionStore init failed — cannot freeze`,{error:e instanceof Error?e.message:String(e)}),null}let _=await o({sessionStore:g,vfs:r.vfs,mode:`quick`});if(!_)return null;if(!f||!m)return c.info(`Frozen without enrichment (no LLM credentials) — left pending`,{filename:_.filename}),_;let v=m,y=s(r.vfs,_,{model:v,apiKey:f,headers:h,pickIcon:t=>e(async()=>{let{pickLucideIcon:e}=await import(`./quick-llm-CvPLRDgB.js`).then(e=>e.n);return{pickLucideIcon:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({pickLucideIcon:e})=>e(t))}).catch(e=>(c.warn(`Single-click enrichment threw (entry stays pending)`,{filename:_.filename,error:e instanceof Error?e.message:String(e)}),null)),b=await p(y,d,r.onProgress);return b.kind===`llm`?b.updated?{...b.updated,archive:_.archive}:_:(y.then(e=>{c.info(`Background enrichment resolved after race window`,{filename:_.filename,enriched:e?.filename??null}),r.onBackgroundEnriched?.(e)}),_)}async function p(e,t,n){let r=Date.now(),i,a;n?.(0),n&&(i=setInterval(()=>{n(Math.min(1,(Date.now()-r)/t))},d));let o=new Promise(e=>{a=setTimeout(()=>e({kind:`timer`}),t)}),s=e.then(e=>({kind:`llm`,updated:e}));try{return await Promise.race([s,o])}finally{i&&clearInterval(i),a&&clearTimeout(a),n?.(null)}}async function m(e){let t=new a;try{await t.init()}catch(e){return c.warn(`SessionStore init failed — cannot quick-freeze`,{error:e instanceof Error?e.message:String(e)}),null}return o({sessionStore:t,vfs:e.vfs,mode:`quick`})}export{f as runNewSessionFreeze,m as runNewSessionFreezeQuick};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/provider-B2-NQQon.js","assets/preload-helper-CZgWQFsJ.js","assets/account-store-CufoCtRK.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-D69OmKNn.js","assets/__vite-browser-external-SwrSgYTf.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-C7d6hyOc.js","assets/context-compaction-DvlXtgVG.js","assets/logger-DDBAeTLF.js","assets/src-x0cJ68Fe.js","assets/proxied-fetch-Bht31_rT.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-D6iS4SOH.js","assets/secrets-bridge-client-DwfYAgDv.js","assets/tool-ui-DfXu6quJ.js","assets/providers-kdSIfEzm.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DjKgax8m.js","assets/transform-messages-DiIjWKhh.js","assets/global-db-CbuLl-zx.js","assets/types-idfTVsM8.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{R as t,d as n}from"./account-store-CufoCtRK.js";import{t as r}from"./logger-DDBAeTLF.js";import{t as i}from"./providers-kdSIfEzm.js";import"./main-Yr2sAIA-.js";var a=r(`oauth-bootstrap`),o=6e4;async function s(){try{let{ensureAllMcpProvidersRegistered:t}=await e(async()=>{let{ensureAllMcpProvidersRegistered:e}=await import(`./provider-B2-NQQon.js`);return{ensureAllMcpProvidersRegistered:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])),n=await t();n.length>0&&a.debug(`Pre-registered MCP providers for OAuth bootstrap`,{count:n.length})}catch(e){a.warn(`Failed to pre-register MCP providers for OAuth bootstrap`,{error:e instanceof Error?e.message:String(e)})}let r=n();a.info(`Bootstrap OAuth replicas`,{count:r.length});for(let e of r){if(!e.accessToken){a.debug(`Skipping account without token`,{providerId:e.providerId});continue}if((e.tokenExpiresAt??1/0)-Date.now()<=o){let t=i(e.providerId);if(t?.onSilentRenew)try{if(await t.onSilentRenew()){a.info(`Silently renewed OAuth token`,{providerId:e.providerId});continue}a.warn(`Silent renewal yielded no token; user must re-authenticate`,{providerId:e.providerId});continue}catch(t){a.warn(`Silent renewal failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)});continue}a.debug(`Skipping expired account (no silent-renew hook)`,{providerId:e.providerId});continue}try{await t({providerId:e.providerId,accessToken:e.accessToken,refreshToken:e.refreshToken,tokenExpiresAt:e.tokenExpiresAt,userName:e.userName,userAvatar:e.userAvatar}),a.debug(`Bootstrapped OAuth replica`,{providerId:e.providerId})}catch(t){a.error(`OAuth bootstrap failed`,{providerId:e.providerId,error:t instanceof Error?t.message:String(t)})}}}export{s as bootstrapOAuthReplicas};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/secrets-bridge-client-DwfYAgDv.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-CZgWQFsJ.js","assets/logger-DDBAeTLF.js","assets/proxied-fetch-Bht31_rT.js","assets/src-x0cJ68Fe.js","assets/fetch-body-D2PwksUW.js","assets/mount-bridge-client-CB9Fm9Jh.js","assets/types-idfTVsM8.js","assets/panel-responder-BKgfV-nl.js","assets/speak-BvHvt4mX.js","assets/speech-assets-bridge-CFYafE89.js","assets/transformers-env-tAIm37Yk.js","assets/shared-BtKwD6I9.js","assets/mime-types-ugOWOUZ9.js","assets/hear-pJ6dxizz.js","assets/wc-permissions-registry-Blyunq37.js","assets/whisper-session-CouZGLHz.js","assets/providers-kdSIfEzm.js","assets/esptool-operations-KWVZgO7d.js","assets/rom-eeWiO07Z.js","assets/mount-picker-popup-Cw_D7c_n.js","assets/picker-popup-CpulHQsi.js","assets/theme-engine-DqVfCCym.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./preload-helper-CZgWQFsJ.js";import{V as t,p as n}from"./account-store-CufoCtRK.js";import{a as r,t as i}from"./proxied-fetch-Bht31_rT.js";import"./main-Yr2sAIA-.js";import{n as a,r as o}from"./hid-device-registry-6w-g8ZpF.js";import{a as s,i as c}from"./serial-port-registry-DsPZvGpT.js";import{A as l,C as u,D as d,E as ee,O as te,S as ne,T as re,_ as ie,a as ae,b as oe,c as se,d as ce,f as le,g as ue,h as f,i as p,j as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"./usb-operations-D-YdmmuG.js";import{i as k,r as A}from"./usb-device-registry-k6vTKonT.js";function j(e={}){let t=new Map;return{...de(),...I(e),...L(),...R(e),...z(),...B(e,t),...V(),...H(e),...fe(e),...pe(e),...F(),...P(),...M(),...N(),...xe()}}function M(){return{"secrets-bridge":async({type:t,payload:n})=>{let{callSecretsBridge:r}=await e(async()=>{let{callSecretsBridge:e}=await import(`./secrets-bridge-client-DwfYAgDv.js`).then(e=>e.n);return{callSecretsBridge:e}},__vite__mapDeps([0,1,2,3,4,5,6]));return{response:await r(t,n)}}}}function N(){return{"mount-sign-and-forward":async({type:t,envelope:n})=>{let{callMountBridge:r}=await e(async()=>{let{callMountBridge:e}=await import(`./mount-bridge-client-CB9Fm9Jh.js`).then(e=>e.n);return{callMountBridge:e}},__vite__mapDeps([7,1,2,3,4,5,6,8]));return{reply:await r(t,n)}}}}function P(){return{"sudo-request":async({request:t})=>{let{resolveSudoRequest:n}=await e(async()=>{let{resolveSudoRequest:e}=await import(`./panel-responder-BKgfV-nl.js`);return{resolveSudoRequest:e}},__vite__mapDeps([9,3]));return{decision:n(t)}}}}function F(){return{"proxied-fetch":async({url:t,method:n,headers:r,body:i})=>{let{collectViaExtensionDelegate:a}=await e(async()=>{let{collectViaExtensionDelegate:e}=await import(`./proxied-fetch-Bht31_rT.js`).then(e=>e.i);return{collectViaExtensionDelegate:e}},__vite__mapDeps([4,1,2,5,6])),{head:o,body:s}=await a(t,{method:n,headers:r,body:i});return{head:o,body:s}}}}function de(){return{"page-info":()=>({origin:window.location.origin,href:window.location.href,title:document.title||``}),screencapture:async({mimeType:e,quality:t})=>{let n=await ve(e,t),r=await n.arrayBuffer(),i=await ye(n);return{bytes:r,width:i.width,height:i.height,mimeType:e}},"speak-text":async({text:t,lang:n,voice:r,rate:i,pitch:a,volume:o})=>{let{speak:s}=await e(async()=>{let{speak:e}=await import(`./speak-BvHvt4mX.js`);return{speak:e}},__vite__mapDeps([10,2,3,11,12,4,1,5,6,13,14]));return await s({text:t,lang:n,voice:r,rate:i,pitch:a,volume:o}),{done:!0}},"list-voices":async()=>{let{kokoroVoicesIfReady:t}=await e(async()=>{let{kokoroVoicesIfReady:e}=await import(`./speak-BvHvt4mX.js`);return{kokoroVoicesIfReady:e}},__vite__mapDeps([10,2,3,11,12,4,1,5,6,13,14])),n=t().map(e=>({name:e.id,lang:e.lang,default:!1,onDevice:e.onDevice}));if(typeof speechSynthesis>`u`){if(n.length>0)return{voices:n};throw Error(`speechSynthesis is unavailable in this page`)}let r=speechSynthesis.getVoices();if(r.length>0)return{voices:[...n,...r.map(Q)]};let i=await new Promise(e=>{let t=()=>{speechSynthesis.removeEventListener(`voiceschanged`,t),e(speechSynthesis.getVoices())};speechSynthesis.addEventListener(`voiceschanged`,t),setTimeout(()=>{speechSynthesis.removeEventListener(`voiceschanged`,t),e(speechSynthesis.getVoices())},1e3)});return{voices:[...n,...i.map(Q)]}},"speak-status":async()=>{let{kokoroStatus:t}=await e(async()=>{let{kokoroStatus:e}=await import(`./speak-BvHvt4mX.js`);return{kokoroStatus:e}},__vite__mapDeps([10,2,3,11,12,4,1,5,6,13,14]));return t()},"speak-warmup":async()=>{let{kokoroWarmup:t}=await e(async()=>{let{kokoroWarmup:e}=await import(`./speak-BvHvt4mX.js`);return{kokoroWarmup:e}},__vite__mapDeps([10,2,3,11,12,4,1,5,6,13,14]));return t()},"synthesize-to-wav":async({text:t,lang:n,voice:r,rate:i})=>{let{synthesizeToWav:a}=await e(async()=>{let{synthesizeToWav:e}=await import(`./speak-BvHvt4mX.js`);return{synthesizeToWav:e}},__vite__mapDeps([10,2,3,11,12,4,1,5,6,13,14])),o=await a({text:t,...n===void 0?{}:{lang:n},...r===void 0?{}:{voice:r},...i===void 0?{}:{rate:i}});return{bytes:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}},"play-audio":async({bytes:e,volume:t})=>{if(typeof AudioContext>`u`)throw Error(`Web Audio API is unavailable in this page`);let n=new AudioContext;try{let r=await n.decodeAudioData(e.slice(0)),i=n.createBufferSource();if(i.buffer=r,t!==void 0){let e=n.createGain();e.gain.value=Math.max(0,Math.min(1,t)),i.connect(e),e.connect(n.destination)}else i.connect(n.destination);await new Promise(e=>{i.onended=()=>e(),i.start()})}finally{try{await n.close()}catch{}}return{done:!0}},"play-chime":async({tone:e})=>{let t={success:[880,1320],error:[440,220],notify:[660,660]},[n,r]=t[e??`notify`]??t.notify;if(typeof AudioContext>`u`)throw Error(`Web Audio API is unavailable in this page`);let i=new AudioContext;try{let e=i.currentTime;for(let[t,a]of[n,r].entries()){let n=i.createOscillator();n.type=`sine`,n.frequency.value=a;let r=i.createGain();r.gain.setValueAtTime(1e-4,e+t*.18),r.gain.exponentialRampToValueAtTime(.2,e+t*.18+.02),r.gain.exponentialRampToValueAtTime(1e-4,e+t*.18+.18),n.connect(r),r.connect(i.destination),n.start(e+t*.18),n.stop(e+t*.18+.2)}await new Promise(e=>setTimeout(e,450))}finally{try{await i.close()}catch{}}return{done:!0}}}}function I(e={}){return{"clipboard-read-text":async()=>{if(!navigator.clipboard?.readText)throw Error(`clipboard API unavailable`);return{text:await navigator.clipboard.readText()}},"clipboard-write-text":async({text:e})=>{if(!navigator.clipboard?.writeText)throw Error(`clipboard API unavailable`);return await $(),await navigator.clipboard.writeText(e),{done:!0}},"clipboard-write-image":async({bytes:e,mimeType:t})=>{if(!navigator.clipboard?.write||typeof ClipboardItem>`u`)throw Error(`clipboard image API unavailable`);let n,r=new Blob([e],{type:t});return n=t===`image/png`?r:await be(r),await $(),await navigator.clipboard.write([new ClipboardItem({"image/png":n})]),{done:!0}},"window-open":async({url:e,target:t,features:n})=>({opened:window.open(e,t??`_blank`,n??`noopener,noreferrer`)!==null}),"oauth-popup":async({url:t})=>({redirectUrl:await X(t,e.getPermissionsSurface)}),"capture-camera":async e=>await he(e),"enumerate-media-devices":async()=>{if(!navigator.mediaDevices?.enumerateDevices)throw Error(`enumerateDevices is not supported in this browser`);let e=await navigator.mediaDevices.enumerateDevices(),t=e=>({deviceId:e.deviceId,label:e.label||``,...e.groupId?{groupId:e.groupId}:{}});return{videoinputs:e.filter(e=>e.kind===`videoinput`).map(t),audioinputs:e.filter(e=>e.kind===`audioinput`).map(t)}}}}function L(){return{"hear-capture":async t=>{let{hearCapture:n}=await e(async()=>{let{hearCapture:e}=await import(`./hear-pJ6dxizz.js`);return{hearCapture:e}},__vite__mapDeps([15,3,16,1,17,2,12,4,5,6,13,14]));return await n(t??{})},"hear-transcribe":async({bytes:t,lang:n})=>{let{hearTranscribe:r}=await e(async()=>{let{hearTranscribe:e}=await import(`./hear-pJ6dxizz.js`);return{hearTranscribe:e}},__vite__mapDeps([15,3,16,1,17,2,12,4,5,6,13,14]));return await r(t,n)},"hear-status":async()=>{let{hearStatus:t}=await e(async()=>{let{hearStatus:e}=await import(`./hear-pJ6dxizz.js`);return{hearStatus:e}},__vite__mapDeps([15,3,16,1,17,2,12,4,5,6,13,14]));return t()},"hear-warmup":async()=>{let{hearWarmup:t}=await e(async()=>{let{hearWarmup:e}=await import(`./hear-pJ6dxizz.js`);return{hearWarmup:e}},__vite__mapDeps([15,3,16,1,17,2,12,4,5,6,13,14]));return t()}}}function R(r){return{"tray-reset":async()=>{if(!r.resetTray)throw Error(`host reset: no active tray session to reset`);return await r.resetTray()},"tray-open-preview":async e=>{if(!r.mintPreview)throw Error(`serve: no active leader tray; cannot mint preview`);return await r.mintPreview(e)},"tray-revoke-preview":async e=>{if(!r.revokePreview)throw Error(`serve: no active leader tray; cannot revoke preview`);return await r.revokePreview(e)},"tray-list-previews":async()=>{if(!r.listPreviews)throw Error(`serve: no active leader tray; cannot list previews`);return await r.listPreviews()},"tray-leave":async({workerBaseUrl:e,requestId:t})=>{if(!r.leaveTray)throw Error(`host leave: tray leave is not available in this environment`);return await r.leaveTray({workerBaseUrl:e,requestId:t})},"tray-join":async({joinUrl:e,requestId:t})=>{if(!r.joinTray)throw Error(`host join: tray join is not available in this environment`);return await r.joinTray({joinUrl:e,requestId:t})},"cherry-emit":async({runtimeId:e,name:t,detail:n})=>{if(!r.emitCherrySliccEvent)throw Error(`cherry-emit: not available in this environment`);return{delivered:r.emitCherrySliccEvent(e,t,n)}},"oauth-extras-set":({providerId:e,domains:r})=>(t(e,r),{storeAfter:n()}),"silent-renew":async({providerId:t})=>{let{getRegisteredProviderConfig:n}=await e(async()=>{let{getRegisteredProviderConfig:e}=await import(`./providers-kdSIfEzm.js`).then(e=>e.r);return{getRegisteredProviderConfig:e}},__vite__mapDeps([18,1,2])),r=n(t);return r?.onSilentRenew?{accessToken:await r.onSilentRenew()}:{accessToken:null}},"save-oauth-accounts":({accountsJson:e})=>(localStorage.setItem(`slicc_accounts`,e),{storedJson:localStorage.getItem(`slicc_accounts`)??e})}}function z(){return{"usb-list":async()=>({devices:await y(U(),W())}),"usb-request":async({filters:e})=>({device:await g(U(),W(),e)}),"usb-device-info":({handle:e})=>({device:ae(U(),e)}),"usb-open":async({handle:e})=>(await S(U(),e),{done:!0}),"usb-close":async({handle:e})=>(await v(U(),e),{done:!0}),"usb-select-configuration":async({handle:e,configurationValue:t})=>(await ce(U(),e,t),{done:!0}),"usb-claim-interface":async({handle:e,interfaceNumber:t})=>(await C(U(),e,t),{done:!0}),"usb-release-interface":async({handle:e,interfaceNumber:t})=>(await se(U(),e,t),{done:!0}),"usb-control-transfer-in":async({handle:e,setup:t,length:n})=>x(U(),e,t,n),"usb-control-transfer-out":async({handle:e,setup:t,bytes:n})=>p(U(),e,t,n),"usb-transfer-in":async({handle:e,endpointNumber:t,length:n})=>le(U(),e,t,n),"usb-transfer-out":async({handle:e,endpointNumber:t,bytes:n})=>b(U(),e,t,n),"usb-reset":async({handle:e})=>(await w(U(),e),{done:!0})}}function B(e,t){return{"hid-list":async()=>({devices:await ue(G(),K())}),"hid-request":async({filters:e})=>({devices:await O(G(),K(),e)}),"hid-device-info":({handle:e})=>({device:f(G(),e)}),"hid-open":async({handle:e})=>(await ie(G(),e),{done:!0}),"hid-close":async({handle:e})=>(await _(G(),e),{done:!0}),"hid-send-report":async({handle:e,reportId:t,bytes:n})=>(await D(G(),e,t,n),{done:!0}),"hid-send-feature-report":async({handle:e,reportId:t,bytes:n})=>(await oe(G(),e,t,n),{done:!0}),"hid-receive-feature-report":async({handle:e,reportId:t})=>T(G(),e,t),"hid-subscribe-input-reports":async({handle:n})=>{t.get(n)?.();let r=await ne(G(),n,t=>{e.emitEvent?.(`hid-input-report`,{handle:n,reportId:t.reportId,bytes:t.bytes})});return t.set(n,r),{done:!0}},"hid-unsubscribe-input-reports":({handle:e})=>(t.get(e)?.(),t.delete(e),{done:!0})}}function V(){return{"serial-list":async()=>({devices:await ee(q(),J())}),"serial-request":async({filters:e})=>({device:await h(q(),J(),e)}),"serial-device-info":({handle:e})=>({device:E(q(),e)}),"serial-open":async({handle:e,options:t})=>(await d(q(),e,t),{done:!0}),"serial-close":async({handle:e})=>(await u(q(),e),{done:!0}),"serial-read":async({handle:e,maxBytes:t,until:n,timeoutMs:r})=>{let i=await te(q(),e,{maxBytes:t,until:n?new Uint8Array(n):void 0,timeoutMs:r});return{bytes:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}},"serial-write":async({handle:e,bytes:t})=>({bytesWritten:await m(q(),e,new Uint8Array(t))}),"serial-get-signals":async({handle:e})=>({signals:await re(q(),e)}),"serial-set-signals":async({handle:e,signals:t})=>(await l(q(),e,t),{done:!0})}}function H(t){return{"esptool-chip-info":async({handle:n,baudRate:r})=>(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolChipInfo(q(),n,r,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),"esptool-read-mac":async({handle:n,baudRate:r})=>(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolReadMac(q(),n,r,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),"esptool-erase-flash":async({handle:n,baudRate:r})=>(await(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolEraseFlash(q(),n,r,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),{done:!0}),"esptool-flash":async({handle:n,baudRate:r,eraseAll:i,segments:a})=>(await(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolFlash(q(),n,r,i,a.map(e=>({address:e.address,data:new Uint8Array(e.bytes)})),e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),{done:!0}),"esptool-read-flash":async({handle:n,baudRate:r,address:i,size:a})=>{let o=await(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolReadFlash(q(),n,r,i,a,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e}));return{bytes:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}},"esptool-read-reg":async({handle:n,baudRate:r,address:i})=>(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolReadReg(q(),n,r,i,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),"esptool-flash-id":async({handle:n,baudRate:r})=>(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolFlashId(q(),n,r,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),"esptool-erase-region":async({handle:n,baudRate:r,address:i,size:a})=>(await(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolEraseRegion(q(),n,r,i,a,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),{done:!0}),"esptool-run":async({handle:n,baudRate:r})=>(await(await e(()=>import(`./esptool-operations-KWVZgO7d.js`),__vite__mapDeps([19,1,2,20]))).esptoolRun(q(),n,r,e=>t.emitEvent?.(`esptool-progress`,{handle:n,line:e})),{done:!0})}}function fe(e){return{"list-remote-targets":async()=>e.listRemoteTargets?{targets:(await e.listRemoteTargets()).filter(e=>e.targetId.includes(`:`)).map(e=>({targetId:e.targetId,title:e.title,url:e.url}))}:{targets:[]},"remote-cdp-send":async({runtimeId:t,localTargetId:n,method:r,params:i,sessionId:a,timeout:o})=>{if(!e.remoteCdp)throw Error(`remote-cdp bridge not available`);return e.remoteCdp.send({runtimeId:t,localTargetId:n,method:r,params:i,sessionId:a,timeout:o})},"remote-cdp-subscribe":async({runtimeId:t,localTargetId:n,event:r})=>{if(!e.remoteCdp)throw Error(`remote-cdp bridge not available`);return e.remoteCdp.subscribe({runtimeId:t,localTargetId:n,event:r})},"remote-cdp-unsubscribe":async({runtimeId:t,localTargetId:n,event:r})=>{if(!e.remoteCdp)throw Error(`remote-cdp bridge not available`);return e.remoteCdp.unsubscribe({runtimeId:t,localTargetId:n,event:r})},"remote-cdp-detach":async({runtimeId:t,localTargetId:n})=>{if(!e.remoteCdp)throw Error(`remote-cdp bridge not available`);return e.remoteCdp.detach({runtimeId:t,localTargetId:n})},"remote-open-tab":async({runtimeId:t,url:n})=>{if(!e.remoteCdp)throw Error(`remote-cdp bridge not available`);return e.remoteCdp.openTab({runtimeId:t,url:n})}}}function pe(t){return{"permission-request":async n=>{let r=t.getPermissionsSurface?.()??null;if(!r)throw Error(`permission-request: permission surface unavailable`);let i=await r.prompt({kinds:n.kinds,description:n.description,heading:n.heading,grantLabel:n.grantLabel,cancelLabel:n.cancelLabel});if(i.status!==`granted`){let e=i.message?`: ${i.message}`:``;throw Error(`permission-request: ${i.reason??i.status}${e}`)}let a=[];for(let t of i.grants)switch(t.kind){case`usb`:{let e=U().register(t.device);a.push({kind:`usb`,handle:e});break}case`hid`:{let e=G().register(t.device);a.push({kind:`hid`,handle:e});break}case`serial`:{let e=q().register(t.port);a.push({kind:`serial`,handle:e});break}case`filesystem`:{let{storePendingHandle:n}=await e(async()=>{let{storePendingHandle:e}=await import(`./mount-picker-popup-Cw_D7c_n.js`).then(e=>e.n);return{storePendingHandle:e}},__vite__mapDeps([21,1,3,22])),r=`pendingMount:rpc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`;await n(r,t.handle),a.push({kind:`filesystem`,idbKey:r,dirName:t.handle.name});break}case`camera`:case`microphone`:case`screenshare`:for(let e of t.stream.getTracks())e.stop();a.push({kind:t.kind,ok:!0});break}return{grants:a}}}}function U(){return k()}function W(){let e=A();if(!e)throw Error(`WebUSB is unavailable in this browser`);return e}function G(){return o()}function K(){let e=a();if(!e)throw Error(`WebHID is unavailable in this browser`);return e}function q(){return s()}function J(){let e=c();if(!e)throw Error(`Web Serial is unavailable in this browser`);return e}var me=1500;async function he(e){if(!navigator.mediaDevices?.getUserMedia)throw Error(`getUserMedia is not supported in this browser`);let t=e.mode===`photo`||e.captureVideo!==!1,n=!!e.captureAudio&&e.mode===`video`;if(!t&&!n)throw Error(`camera capture: at least one of video or audio must be requested`);let r=await ge({wantVideo:t,videoDeviceId:t?await Y(e.deviceId,`videoinput`):void 0,audioDeviceId:n?await Y(e.audioDeviceId,`audioinput`):void 0,wantAudio:n,width:e.width,height:e.height,frameRate:e.frameRate,exact:!!e.exactSize});try{let n=null,i=0,a=0;if(t){n=document.createElement(`video`),n.srcObject=r,n.muted=!0,n.playsInline=!0;let e=n;await new Promise((t,n)=>{e.onloadedmetadata=()=>e.play().then(()=>t()).catch(n),e.onerror=()=>n(Error(`Failed to load camera stream`))}),await new Promise(e=>requestAnimationFrame(()=>e())),await new Promise(e=>requestAnimationFrame(()=>e())),i=e.videoWidth,a=e.videoHeight}if(e.mode===`photo`){if(!n)throw Error(`photo capture requires a video track`);let t=e.warmupMs??me;t>0&&await new Promise(e=>setTimeout(e,t));let r=document.createElement(`canvas`);r.width=i,r.height=a;let o=r.getContext(`2d`);if(!o)throw Error(`Failed to get canvas context`);o.drawImage(n,0,0,i,a);let s=await new Promise((t,n)=>{r.toBlob(e=>e?t(e):n(Error(`Failed to encode photo`)),e.mimeType,e.quality)});return{bytes:await s.arrayBuffer(),mimeType:s.type||e.mimeType,width:i,height:a}}let o=Math.max(100,Math.min(e.durationMs??5e3,6e4)),s=typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e.mimeType)?e.mimeType:`video/webm`,c=new MediaRecorder(r,{mimeType:s}),l=[];c.ondataavailable=e=>{e.data&&e.data.size>0&&l.push(e.data)};let u=new Promise(e=>{c.onstop=()=>e()});c.start(),await new Promise(e=>setTimeout(e,o)),c.stop(),await u;let d=new Blob(l,{type:s});return{bytes:await d.arrayBuffer(),mimeType:d.type||s,width:i,height:a,durationMs:o}}finally{r.getTracks().forEach(e=>{e.stop()})}}async function Y(e,t){if(e===void 0||e===``)return;if(!/^\d+$/.test(e))return e;if(!navigator.mediaDevices?.enumerateDevices)return;let n=parseInt(e,10);return(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===t)[n]?.deviceId}async function ge(e){let t=t=>{if(!e.wantVideo)return!1;let n={};return e.videoDeviceId&&(n.deviceId={exact:e.videoDeviceId}),e.width&&(n.width=t===`exact`?{exact:e.width}:{ideal:e.width}),e.height&&(n.height=t===`exact`?{exact:e.height}:{ideal:e.height}),e.frameRate&&(n.frameRate=t===`exact`?{exact:e.frameRate}:{ideal:e.frameRate}),Object.keys(n).length>0?n:!0},n=()=>e.wantAudio?e.audioDeviceId?{deviceId:{exact:e.audioDeviceId}}:!0:!1;try{return await navigator.mediaDevices.getUserMedia({video:t(e.exact?`exact`:`ideal`),audio:n()})}catch(r){let i=r?.name;if(!e.exact||i!==`OverconstrainedError`&&i!==`NotReadableError`)throw r;return console.warn(`panel-rpc:capture-camera: exact ${e.width??`?`}x${e.height??`?`}@${e.frameRate??`?`} unmet, falling back to ideal`),await navigator.mediaDevices.getUserMedia({video:t(`ideal`),audio:n()})}}async function X(e,t){if((typeof navigator<`u`?navigator.userActivation:void 0)?.isActive===!0)return Z(window.open(e,`_blank`,`width=500,height=700,popup=yes`));let n=t?.()??null;if(n){let t=await _e(n,e);return t===void 0?null:Z(t)}return Z(window.open(e,`_blank`,`width=500,height=700,popup=yes`))}function Z(e){return new Promise(t=>{let n=!1,a=null,o=()=>{n||(n=!0,window.removeEventListener(`message`,s),clearTimeout(c),a&&clearInterval(a))},s=n=>{if(n.data?.type!==`oauth-callback`||n.origin!==window.location.origin||e&&n.source!==e)return;if(o(),n.data.error){console.error(`[panel-rpc:oauth-popup] OAuth error:`,n.data.error),t(null);return}let r=n.data.redirectUrl;typeof r!=`string`&&r!=null||t(r??null)};window.addEventListener(`message`,s),a=setInterval(async()=>{if(!n)try{let e=await fetch(r(`/api/oauth-result`),{headers:i()});if(e.status===204||!e.ok)return;let a=await e.json();if(n)return;if(o(),a.error){console.error(`[panel-rpc:oauth-popup] Server relay OAuth error:`,a.error),t(null);return}t(a.redirectUrl??null)}catch(e){console.warn(`[panel-rpc:oauth-popup] Poll failed:`,e instanceof Error?e.message:String(e))}},1e3);let c=setTimeout(()=>{o();try{e?.close()}catch{}t(null)},12e4)})}async function _e(e,t){let n=await e.prompt({kinds:[`popup`],description:`Continue to sign in. A new window will open to the provider.`,grantLabel:`Continue`,requestOptions:{popup:{url:t}}});if(n.status!==`granted`)return;let r=n.grants.find(e=>e.kind===`popup`);return r&&r.kind===`popup`?r.window:null}function Q(e){return{name:e.name,lang:e.lang,default:e.default,onDevice:!1}}async function ve(e,t){if(!navigator.mediaDevices?.getDisplayMedia)throw Error(`screen capture is not supported in this browser`);let n=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1});try{let r=document.createElement(`video`);r.srcObject=n,r.muted=!0,r.playsInline=!0,await new Promise((e,t)=>{r.onloadedmetadata=()=>r.play().then(()=>e()).catch(t),r.onerror=()=>t(Error(`Failed to load video stream`))}),await new Promise(e=>setTimeout(e,100));let i=r.videoWidth,a=r.videoHeight,o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`);if(!s)throw Error(`Failed to get canvas context`);return s.drawImage(r,0,0,i,a),await new Promise((n,r)=>{o.toBlob(e=>e?n(e):r(Error(`Failed to create image blob`)),e,t)})}finally{n.getTracks().forEach(e=>{e.stop()})}}async function ye(e){let t=URL.createObjectURL(e);try{let e=new Image;return await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(`Failed to decode capture`)),e.src=t}),{width:e.naturalWidth,height:e.naturalHeight}}finally{URL.revokeObjectURL(t)}}async function be(e){let t=URL.createObjectURL(e);try{let e=new Image;await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(`Failed to load image for clipboard conversion`)),e.src=t});let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);if(!r)throw Error(`Failed to get canvas context`);return r.drawImage(e,0,0),await new Promise((e,t)=>{n.toBlob(n=>n?e(n):t(Error(`PNG re-encode failed`)),`image/png`)})}finally{URL.revokeObjectURL(t)}}async function $(e=5*6e4){typeof document>`u`||typeof document.hasFocus==`function`&&(document.hasFocus()||await new Promise((t,n)=>{let r=()=>{window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,a),clearTimeout(o)},i=()=>{document.hasFocus()&&(r(),t())},a=()=>{document.visibilityState===`visible`&&document.hasFocus()&&(r(),t())},o=setTimeout(()=>{r(),n(Error(`timed out waiting for window focus`))},e);window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,a)}))}function xe(){return{"theme-apply":async({themeJson:t,action:n})=>{let{importTheme:r,saveCustomTheme:i,setActiveTheme:a,clearActiveTheme:o,applyThemeOverrides:s}=await e(async()=>{let{importTheme:e,saveCustomTheme:t,setActiveTheme:n,clearActiveTheme:r,applyThemeOverrides:i}=await import(`./theme-engine-DqVfCCym.js`).then(e=>e.f);return{importTheme:e,saveCustomTheme:t,setActiveTheme:n,clearActiveTheme:r,applyThemeOverrides:i}},__vite__mapDeps([23,1,3]));if(n===`reset`)return o(),s(),{applied:null};if(t){let e=r(t);return i(e),a(e.id),s(),{applied:e.id}}return{applied:null}}}}export{j as createStandalonePanelRpcHandlers};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./store-Yx-6Id5z.js";import"./provider-BGNOqrtL.js";export{e as readMcpAuthEntries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./provider-B2-NQQon.js";export{e as readMcpAuthEntries};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/azure-openai-DS8Knhiz.js","assets/dist-D69OmKNn.js","assets/preload-helper-CZgWQFsJ.js","assets/__vite-browser-external-SwrSgYTf.js","assets/rolldown-runtime-aKtaBQYM.js","assets/event-stream-BJI_nGaK.js","assets/json-parse-C7d6hyOc.js","assets/account-store-CufoCtRK.js","assets/context-compaction-DvlXtgVG.js","assets/logger-DDBAeTLF.js","assets/src-x0cJ68Fe.js","assets/proxied-fetch-Bht31_rT.js","assets/fetch-body-D2PwksUW.js","assets/secret-topology-D6iS4SOH.js","assets/secrets-bridge-client-DwfYAgDv.js","assets/tool-ui-DfXu6quJ.js","assets/panel-rpc-DmJSNs0I.js","assets/bedrock-camp-DjKgax8m.js","assets/transform-messages-DiIjWKhh.js","assets/openai-BeH6aC_-.js","assets/local-llm-CTPBIO5P.js","assets/openai-completions-B2n4Op2S.js","assets/headers-DO1UzNKu.js","assets/sanitize-unicode-DmIE6hZJ.js","assets/github-copilot-headers-DZtWWv8W.js","assets/openai-prompt-cache-DXo9f3w5.js","assets/adobe-BHiE6HjD.js","assets/main-Yr2sAIA-.js","assets/modulepreload-polyfill-Dezn_h7o.js","assets/messages-BD4p8GuF.js","assets/clipboard-DuHpK59o.js","assets/adobe-oauth-state-hIbA-bCY.js","assets/oauth-service-DY8Ud2Yu.js","assets/wc-permissions-registry-Blyunq37.js","assets/llm-session-id-bZQs6gBN.js","assets/cerebras-B8Jo2XB1.js","assets/github-copilot-CR-2580l.js","assets/github-DRVxfI4e.js","assets/global-db-CbuLl-zx.js","assets/openai-codex-DlwnaPEj.js","assets/xai-grok-sanitize-CR2JoOJd.js","assets/xai-grok-models-CeEBaUMC.js","assets/xai-grok-C650vv2T.js","assets/xai-grok-errors-bnlIBeu-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-CZgWQFsJ.js";var n={include:[`*`],exclude:[`amazon-bedrock`]},r=e({getRegisteredProviderConfig:()=>d,getRegisteredProviderIds:()=>f,registerProviderConfig:()=>p,registerProviders:()=>u,shouldIncludeProvider:()=>a}),i=Object.assign({"/packages/dev-tools/providers.build.json":n})[`/packages/dev-tools/providers.build.json`]??{include:[`*`],exclude:[]};function a(e){let{include:t,exclude:n}=i;return n.includes(`*`)||n.includes(e)?!1:!!(t.includes(`*`)||t.includes(e))}var o=Object.assign({"./built-in/azure-ai-foundry.ts":()=>t(()=>import(`./azure-ai-foundry-Bo0FAJyX.js`),[]),"./built-in/azure-openai.ts":()=>t(()=>import(`./azure-openai-DS8Knhiz.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),"./built-in/bedrock-camp.ts":()=>t(()=>import(`./bedrock-camp-DjKgax8m.js`).then(e=>e.n),__vite__mapDeps([17,4,1,2,3,5,6,18])),"./built-in/local-llm.ts":()=>t(()=>import(`./local-llm-CTPBIO5P.js`),__vite__mapDeps([20,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,21,22,23,24,19,25]))}),s=Object.assign({"/packages/webapp/providers/adobe.ts":()=>t(()=>import(`./adobe-BHiE6HjD.js`),__vite__mapDeps([26,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,27,28,29,30,31,32,33,34])),"/packages/webapp/providers/cerebras.ts":()=>t(()=>import(`./cerebras-B8Jo2XB1.js`),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,21,22,23,24,19,25])),"/packages/webapp/providers/github-copilot.ts":()=>t(()=>import(`./github-copilot-CR-2580l.js`),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,27,28,29,30])),"/packages/webapp/providers/github.ts":()=>t(()=>import(`./github-DRVxfI4e.js`),__vite__mapDeps([37,2,7,4,1,3,5,6,8,9,10,11,12,13,14,15,16,17,18,27,28,29,30,31,32,33,38])),"/packages/webapp/providers/openai-codex.ts":()=>t(()=>import(`./openai-codex-DlwnaPEj.js`),__vite__mapDeps([39,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,27,28,29,30])),"/packages/webapp/providers/xai-grok-errors.ts":()=>t(()=>import(`./xai-grok-errors-bnlIBeu-.js`),[]),"/packages/webapp/providers/xai-grok-models.ts":()=>t(()=>import(`./xai-grok-models-CeEBaUMC.js`),[]),"/packages/webapp/providers/xai-grok-sanitize.ts":()=>t(()=>import(`./xai-grok-sanitize-CR2JoOJd.js`),__vite__mapDeps([40,41])),"/packages/webapp/providers/xai-grok.ts":()=>t(()=>import(`./xai-grok-C650vv2T.js`),__vite__mapDeps([42,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,27,28,29,30,43,41,40]))}),c=new Map,l=null;function u(){return l||(l=(async()=>{for(let[e,t]of Object.entries(o)){let e=await t();e.config&&a(e.config.id)&&(c.set(e.config.id,e.config),e.register?.())}for(let[e,t]of Object.entries(s)){let e=await t();e.config&&(c.set(e.config.id,e.config),e.register?.())}})(),l)}function d(e){return c.get(e)}function f(){return[...c.keys()]}function p(e){c.set(e.id,e)}export{u as a,p as i,f as n,a as o,r,d as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/panel-rpc-DmJSNs0I.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-CZgWQFsJ.js";import{i as n,r}from"./src-x0cJ68Fe.js";import{t as i}from"./fetch-body-D2PwksUW.js";function a(e){return e.headers.get(`x-proxy-error`)===`1`}async function o(e){let t=`Proxy error ${e.status}`,n;try{n=await e.text()}catch{return t}return s(n,t)}function s(e,t){let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!=`object`)return t;let r=n.error;if(typeof r==`string`&&r.length>0)return r;if(r&&typeof r==`object`){let e=r.message;if(typeof e==`string`&&e.length>0)return e;try{return JSON.stringify(r)}catch{return t}}return t}var c=new Map,l=new Map;function u(e){let t=e.length;return t===0?`0`:`${t}:${e.charCodeAt(0)}:${t>1?e.charCodeAt(1):0}:${t>2?e.charCodeAt(2):0}:${t>3?e.charCodeAt(3):0}:${t>4?e.charCodeAt(Math.floor(t/4)):0}:${t>4?e.charCodeAt(Math.floor(t/2)):0}:${t>4?e.charCodeAt(Math.floor(3*t/4)):0}:${e.charCodeAt(t-1)}`}function d(e,t){let n=u(e);c.set(n,t),setTimeout(()=>c.delete(n),1e4)}function f(e,t){l.set(e,t),setTimeout(()=>l.delete(e),1e4)}function p(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=n.toLowerCase();e===`cookie`?t[`X-Proxy-Cookie`]=r:e===`origin`?t[`X-Proxy-Origin`]=r:e===`referer`?t[`X-Proxy-Referer`]=r:e.startsWith(`proxy-`)?t[`X-Proxy-${n}`]=r:t[n]=r}return t}function m(e){let t={};for(let[n,r]of Object.entries(e))n.toLowerCase()===`x-proxy-set-cookie`?t[`set-cookie`]=r:t[n]=r;return t}function h(e){if(e){if(e instanceof Headers){let t={};return e.forEach((e,n)=>{t[n]=e}),t}return e}}var g=e({apiHeaders:()=>O,collectViaExtensionDelegate:()=>H,createProxiedFetch:()=>U,decodeForbiddenResponseHeaders:()=>F,encodeForbiddenRequestHeaders:()=>P,getExtensionDelegateId:()=>E,getLocalApiBaseUrl:()=>S,headersToRecord:()=>M,isTextContentType:()=>A,prepareRequestBody:()=>N,readResponseBody:()=>j,resolveApiUrl:()=>D,setBridgeToken:()=>C,setExtensionDelegateId:()=>T,setLocalApiBaseUrl:()=>x}),_=32*1024*1024,v=new Set([101,103,204,205,304]),y=null,b=null;function x(e){if(e===null||e===``){y=null;return}y=e.replace(/\/+$/,``)}function S(){return y}function C(e){b=e===null||e===``?null:e}var w=null;function T(e){w=e===null||e===``?null:e}function E(){return w}function D(e){return y?`${y}${e}`:e}function O(e){let t={};if(b&&y&&(t[`X-Bridge-Token`]=b),e)for(let n of Object.keys(e))t[n]=e[n];return t}function k(){return D(`/api/fetch-proxy`)}function A(e){if(!e)return!0;let t=e.toLowerCase();return t.startsWith(`text/`)||t.includes(`json`)||t.includes(`xml`)||t.includes(`javascript`)||t.includes(`ecmascript`)||t.includes(`html`)||t.includes(`css`)||t.includes(`svg`)}async function j(e,t){let n=e.headers.get(`content-type`)??``,r=await e.arrayBuffer(),i=new Uint8Array(r);if(!A(n)){let e=``;for(let t=0;t<i.length;t+=32768)e+=String.fromCharCode(...i.subarray(t,t+32768));d(e,i),t&&f(t,i)}return i}var M=h;function N(e,t){if(e){if(!A(t?.[`Content-Type`]??t?.[`content-type`]??``)){let t=i(e);return new Blob([t])}return e}}var P=p,F=m,I=r;function L(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function R(e,t,n){let r=new Headers;for(let[t,n]of Object.entries(e.headers))r.set(t,String(n));let i=v.has(e.status)?null:t,a=await j(new Response(i,{status:e.status,statusText:e.statusText,headers:r}),n);return{status:e.status,statusText:e.statusText,headers:F(e.headers),body:a,url:n}}async function z(e){let t=M(e?.headers),r=e?.method??`GET`,i=e?.body?N(e.body,t):void 0,a=P(t),o,s=!1;if(i!==void 0){let e=i instanceof Uint8Array?i:new Uint8Array(await new Response(i).arrayBuffer());e.byteLength>_?s=!0:o=n(e)}return{method:r,transportHeaders:a,bodyBase64:o,requestBodyTooLarge:s}}async function B(e,t,n){let{method:r,transportHeaders:i,bodyBase64:a,requestBodyTooLarge:o}=await z(n),s=e();return new Promise((e,n)=>{let c=null,l=!1,u=[];s.onMessage.addListener(t=>{let r=t;if(r.type===`response-head`)c={status:r.status,statusText:r.statusText,headers:r.headers};else if(r.type===`response-chunk`)u.push(I(r.dataBase64));else if(r.type===`response-end`){if(l=!0,!c){n(Error(`fetch-proxy: response-end before response-head`));return}e({head:c,body:L(u).buffer}),s.disconnect()}else r.type===`response-error`&&(l=!0,n(Error(r.error)),s.disconnect())}),s.onDisconnect.addListener(()=>{l||n(Error(c?`fetch-proxy port disconnected mid-stream`:`fetch-proxy port disconnected before response`))}),s.postMessage({type:`request`,url:t,method:r,headers:i,bodyBase64:a,requestBodyTooLarge:o})})}async function V(e,t){let{head:n,body:r}=await B(()=>chrome.runtime.connect({name:`fetch-proxy.fetch`}),e,t);return R(n,new Uint8Array(r),e)}async function H(e,t){let n=w;if(!n)throw Error(`proxied-fetch: no extension delegate id configured`);let r=chrome.runtime.connect;return B(()=>r(n,{name:`fetch-proxy.fetch`}),e,t)}function U(){return typeof chrome<`u`&&chrome?.runtime?.id?V:typeof chrome<`u`&&typeof chrome?.runtime?.connect==`function`&&w?async(e,t)=>{let{head:n,body:r}=await H(e,t);return R(n,new Uint8Array(r),e)}:typeof chrome>`u`&&w?async(e,n)=>{let{getPanelRpcClient:r}=await t(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DmJSNs0I.js`).then(e=>e.i);return{getPanelRpcClient:e}},__vite__mapDeps([0,1])),i=r();if(!i)throw Error(`proxied-fetch: panel-RPC client unavailable in worker realm`);let a=n?.method??`GET`,o=M(n?.headers)??{},{head:s,body:c}=await i.call(`proxied-fetch`,{url:e,method:a,headers:o,body:n?.body},{timeoutMs:12e4});return R(s,new Uint8Array(c),e)}:async(e,t)=>{let n=t?.method??`GET`,r=O({...P(M(t?.headers)),"X-Target-URL":e}),i={method:n,headers:r,cache:`no-store`};t?.body&&![`GET`,`HEAD`].includes(n)&&(i.body=N(t.body,r));let s=await fetch(k(),i);if(a(s))throw Error(await o(s));let c=await j(s,e),l={};s.headers.forEach((e,t)=>{l[t]=e});let u=F(l);return{status:s.status,statusText:s.statusText,headers:u,body:c,url:e}}}export{D as a,x as c,g as i,a as l,E as n,C as o,S as r,T as s,O as t,o as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/panel-rpc-DmJSNs0I.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-CZgWQFsJ.js";import{t as n}from"./logger-DDBAeTLF.js";import{n as r}from"./proxied-fetch-Bht31_rT.js";var i=e({callSecretsBridge:()=>p}),a=n(`secrets-bridge`),o=1e4,s=null,c=1,l=new Map;function u(e){let t=e;if(typeof t?.id!=`number`)return;let n=l.get(t.id);n&&(l.delete(t.id),clearTimeout(n.timer),n.resolve(t.response))}function d(){s=null;for(let[,e]of l)clearTimeout(e.timer),e.reject(Error(`secrets.crud port disconnected`));l.clear(),a.debug(`secrets.crud port disconnected; pending cleared, will reconnect`)}function f(){if(s)return s;let e=r();if(!e)return a.warn(`cannot open secrets.crud port: no extension delegate id`),null;if(typeof chrome>`u`||typeof chrome?.runtime?.connect!=`function`)return a.warn(`cannot open secrets.crud port: chrome.runtime.connect unavailable`),null;let t=chrome.runtime.connect,n=t(e,{name:`secrets.crud`});return n.onMessage.addListener(u),n.onDisconnect.addListener(d),s=n,n}function p(e,t){return typeof chrome>`u`&&r()?h(e,t):m(e,t)}function m(e,t){return new Promise((n,r)=>{let i=f();if(!i){n(void 0);return}let u=c++,d=setTimeout(()=>{l.delete(u)&&(a.warn(`secrets.crud call timed out`,{type:e}),n(void 0))},o);l.set(u,{resolve:n,reject:r,timer:d});try{i.postMessage({id:u,type:e,...t})}catch(e){l.delete(u),clearTimeout(d),s=null,r(e instanceof Error?e:Error(String(e)))}})}async function h(e,n){let{getPanelRpcClient:r}=await t(async()=>{let{getPanelRpcClient:e}=await import(`./panel-rpc-DmJSNs0I.js`).then(e=>e.i);return{getPanelRpcClient:e}},__vite__mapDeps([0,1])),i=r();if(!i){a.warn(`cannot bridge secrets call: panel-RPC client unavailable in worker realm`,{type:e});return}let{response:s}=await i.call(`secrets-bridge`,{type:e,payload:n},{timeoutMs:o});return s}export{i as n,p as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./wc-live-Bahzf7iY.js";export{e as readSessionsIndex};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=32768;function t(){return globalThis.Buffer}var n=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})?$/;function r(e){let r=t();if(r){if(!n.test(e))throw Error(`Invalid base64 string`);return new Uint8Array(r.from(e,`base64`))}let i=atob(e),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return a}function i(n){let r=t();if(r)return r.from(n).toString(`base64`);let i=``;for(let t=0;t<n.byteLength;t+=e){let r=n.subarray(t,Math.min(t+e,n.byteLength));i+=String.fromCharCode.apply(null,r)}return btoa(i)}var a=`slicc_oauth_extra_domains`;function o(e){try{let t=e.getItem(a);if(!t)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n)){if(typeof e!=`string`||!Array.isArray(t))continue;let n=t.filter(e=>typeof e==`string`&&e.length>0);n.length>0&&(r[e]=n)}return r}catch{return{}}}function s(e,t){try{e.setItem(a,JSON.stringify(t))}catch(e){throw Error(`Failed to persist OAuth extras (localStorage quota exceeded?): ${e instanceof Error?e.message:String(e)}`)}}[`ghp_`,`gho_`,`ghu_`,`ghs_`,`ghr_`,`github_pat_`,`sk-`,`pk-`,`xoxb-`,`xoxp-`,`xoxa-`,`xoxs-`,`AKIA`,`ABIA`,`ACCA`,`ASIA`,`sk-ant-`,`Bearer `].sort((e,t)=>t.length-e.length);export{i,s as n,r,o as t};
|