sliccy 3.5.4 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/node-server/_cloud_core/src/errors.d.ts +14 -0
- package/dist/node-server/_cloud_core/src/errors.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/errors.js +13 -0
- package/dist/node-server/_cloud_core/src/index.d.ts +19 -0
- package/dist/node-server/_cloud_core/src/index.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/index.js +14 -0
- package/dist/node-server/_cloud_core/src/operations/kill.d.ts +18 -0
- package/dist/node-server/_cloud_core/src/operations/kill.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/operations/kill.js +32 -0
- package/dist/node-server/_cloud_core/src/operations/list.d.ts +25 -0
- package/dist/node-server/_cloud_core/src/operations/list.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/operations/list.js +145 -0
- package/dist/node-server/_cloud_core/src/operations/pause.d.ts +15 -0
- package/dist/node-server/_cloud_core/src/operations/pause.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/operations/pause.js +27 -0
- package/dist/node-server/_cloud_core/src/operations/resume.d.ts +22 -0
- package/dist/node-server/_cloud_core/src/operations/resume.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/operations/resume.js +86 -0
- package/dist/node-server/_cloud_core/src/operations/start.d.ts +67 -0
- package/dist/node-server/_cloud_core/src/operations/start.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/operations/start.js +228 -0
- package/dist/node-server/_cloud_core/src/polling.d.ts +18 -0
- package/dist/node-server/_cloud_core/src/polling.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/polling.js +79 -0
- package/dist/node-server/_cloud_core/src/registry.d.ts +27 -0
- package/dist/node-server/_cloud_core/src/registry.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/registry.js +1 -0
- package/dist/node-server/_cloud_core/src/secrets-filter.d.ts +2 -0
- package/dist/node-server/_cloud_core/src/secrets-filter.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/secrets-filter.js +17 -0
- package/dist/node-server/_cloud_core/src/substrate-factory.d.ts +3 -0
- package/dist/node-server/_cloud_core/src/substrate-factory.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/substrate-factory.js +6 -0
- package/dist/node-server/_cloud_core/src/substrate.d.ts +53 -0
- package/dist/node-server/_cloud_core/src/substrate.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/substrate.js +1 -0
- package/dist/node-server/_cloud_core/src/substrates/e2b.d.ts +3 -0
- package/dist/node-server/_cloud_core/src/substrates/e2b.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/substrates/e2b.js +98 -0
- package/dist/node-server/_cloud_core/src/types.d.ts +94 -0
- package/dist/node-server/_cloud_core/src/types.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/src/types.js +3 -0
- package/dist/node-server/_cloud_core/tests/fixtures/fake-substrate.d.ts +39 -0
- package/dist/node-server/_cloud_core/tests/fixtures/fake-substrate.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/fixtures/fake-substrate.js +75 -0
- package/dist/node-server/_cloud_core/tests/fixtures/index.d.ts +4 -0
- package/dist/node-server/_cloud_core/tests/fixtures/index.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/fixtures/index.js +2 -0
- package/dist/node-server/_cloud_core/tests/fixtures/mem-registry.d.ts +10 -0
- package/dist/node-server/_cloud_core/tests/fixtures/mem-registry.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/fixtures/mem-registry.js +25 -0
- package/dist/node-server/_cloud_core/tests/kill.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/kill.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/kill.test.js +164 -0
- package/dist/node-server/_cloud_core/tests/list.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/list.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/list.test.js +300 -0
- package/dist/node-server/_cloud_core/tests/pause.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/pause.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/pause.test.js +167 -0
- package/dist/node-server/_cloud_core/tests/resume.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/resume.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/resume.test.js +203 -0
- package/dist/node-server/_cloud_core/tests/secrets-filter.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/secrets-filter.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/secrets-filter.test.js +30 -0
- package/dist/node-server/_cloud_core/tests/start.test.d.ts +2 -0
- package/dist/node-server/_cloud_core/tests/start.test.d.ts.map +1 -0
- package/dist/node-server/_cloud_core/tests/start.test.js +513 -0
- package/dist/node-server/chrome-launch.d.ts +1 -0
- package/dist/node-server/chrome-launch.js +3 -0
- package/dist/node-server/cloud/dispatch.d.ts +34 -0
- package/dist/node-server/cloud/dispatch.js +79 -0
- package/dist/node-server/cloud/kill.d.ts +12 -0
- package/dist/node-server/cloud/kill.js +11 -0
- package/dist/node-server/cloud/list.d.ts +6 -0
- package/dist/node-server/cloud/list.js +6 -0
- package/dist/node-server/cloud/pause.d.ts +7 -0
- package/dist/node-server/cloud/pause.js +6 -0
- package/dist/node-server/cloud/registry-file.d.ts +13 -0
- package/dist/node-server/cloud/registry-file.js +85 -0
- package/dist/node-server/cloud/resume.d.ts +11 -0
- package/dist/node-server/cloud/resume.js +17 -0
- package/dist/node-server/cloud/start.d.ts +16 -0
- package/dist/node-server/cloud/start.js +49 -0
- package/dist/node-server/cloud-status.d.ts +11 -0
- package/dist/node-server/cloud-status.js +49 -0
- package/dist/node-server/hosted-bootstrap.d.ts +21 -0
- package/dist/node-server/hosted-bootstrap.js +14 -0
- package/dist/node-server/index.js +146 -3
- package/dist/node-server/leader-restart.d.ts +29 -0
- package/dist/node-server/leader-restart.js +146 -0
- package/dist/node-server/runtime-flags.d.ts +1 -0
- package/dist/node-server/runtime-flags.js +6 -0
- package/dist/ui/assets/adobe-BLY_1hN7.js +1 -0
- package/dist/ui/assets/adobe-BZS2Kmci.js +2 -0
- package/dist/ui/assets/agent-bridge-BFRFxJAl.js +1 -0
- package/dist/ui/assets/{agent-message-to-chat-H07zq-Kv.js → agent-message-to-chat-Cd-DQATg.js} +1 -1
- package/dist/ui/assets/anthropic-BbwUhO9H.js +39 -0
- package/dist/ui/assets/{anthropic-BK3Od7MT.js → anthropic-Dg9_3G1u.js} +3 -3
- package/dist/ui/assets/{apps-mZJxOz_q.js → apps-BQuoIsxV.js} +1 -1
- package/dist/ui/assets/azure-openai-CilK3M_Q.js +1 -0
- package/dist/ui/assets/{azure-openai-Dch5aR9j.js → azure-openai-CleJGzBE.js} +1 -1
- package/dist/ui/assets/azure-openai-responses-DMLD0Ano.js +1 -0
- package/dist/ui/assets/azure-openai-responses-_joBD1ru.js +1 -0
- package/dist/ui/assets/{bsh-watchdog-i5GXbvla.js → bsh-watchdog-CpJwB685.js} +1 -1
- package/dist/ui/assets/{cdp-Cv6W51Ld.js → cdp-BXSNdZRM.js} +3 -3
- package/dist/ui/assets/cloud-CCHD45tb.js +1 -0
- package/dist/ui/assets/cloud-DyAca2cv.css +1 -0
- package/dist/ui/assets/cost-command-Bv5UQVUC.js +1 -0
- package/dist/ui/assets/{dist-cK1g1pHF.js → dist-ChvbMSOY.js} +1 -1
- package/dist/ui/assets/{dist-BTGs16AV.js → dist-CltZJzbd.js} +1 -1
- package/dist/ui/assets/{dist-BcBxL8nL.js → dist-cZSF0917.js} +1 -1
- package/dist/ui/assets/{dist-Bgcuvc8h.js → dist-ljtB3O-J.js} +1 -1
- package/dist/ui/assets/{dist-EkY3RL7q.js → dist-tLLu0PBg.js} +1 -1
- package/dist/ui/assets/{es-Crcyr8Z7.js → es-C2wm9v2H.js} +1 -1
- package/dist/ui/assets/follower-sprinkle-bridge-Bg1mCcnG.js +1 -0
- package/dist/ui/assets/{github-DKcpc18I.js → github-BDzC2pCD.js} +1 -1
- package/dist/ui/assets/github-BzwlgA3s.js +2 -0
- package/dist/ui/assets/{google-IZXg3PJn.js → google-BVxsfaV3.js} +1 -1
- package/dist/ui/assets/google-C0Zd1qsl.js +1 -0
- package/dist/ui/assets/google-shared-DcZhZ_Z7.js +11 -0
- package/dist/ui/assets/{google-shared-BaIigNCs.js → google-shared-KyLYJrXa.js} +1 -1
- package/dist/ui/assets/google-vertex-BGpbWEWq.js +1 -0
- package/dist/ui/assets/{google-vertex-DDwmtWoJ.js → google-vertex-BSOalca9.js} +1 -1
- package/dist/ui/assets/{intercepted-oauth-CEgKdcyY.js → intercepted-oauth-D6eAxYca.js} +1 -1
- package/dist/ui/assets/{kernel-worker-dg2bRx7X.js → kernel-worker-D1_EtuZW.js} +1016 -980
- package/dist/ui/assets/{lick-ws-bridge-DgWfdUlv.js → lick-ws-bridge-DXFDOui-.js} +1 -1
- package/dist/ui/assets/{local-llm-DuUGv7wX.js → local-llm-B3qsU55x.js} +1 -1
- package/dist/ui/assets/magick-wasm-CasStH-w.js +1 -0
- package/dist/ui/assets/main-BSfjQXCf.js +1612 -0
- package/dist/ui/assets/{mistral-czd8-m0c.js → mistral-BkhZQqeV.js} +1 -1
- package/dist/ui/assets/{mistral-BS_Gm2MH.js → mistral-D130SR-b.js} +1 -1
- package/dist/ui/assets/modulepreload-polyfill-wMinxHhO.js +1 -0
- package/dist/ui/assets/nuke-command-D_sxu_AA.js +1 -0
- package/dist/ui/assets/{oauth-CJxNn7hC.js → oauth-BocTO4G9.js} +1 -1
- package/dist/ui/assets/oauth-bootstrap-DZdd7KZS.js +2 -0
- package/dist/ui/assets/{oauth-service-BAnfipgD.js → oauth-service-DAWR1CpY.js} +1 -1
- package/dist/ui/assets/oauth-service-y04jhWb_.js +1 -0
- package/dist/ui/assets/offscreen-client-HCLuFFlN.js +1 -0
- package/dist/ui/assets/onboarding-orchestrator-qbEVluIu.js +1 -0
- package/dist/ui/assets/openai-codex-responses-Bmd17Jq9.js +7 -0
- package/dist/ui/assets/openai-codex-responses-CMOclqki.js +7 -0
- package/dist/ui/assets/openai-completions-DmwgEsb4.js +5 -0
- package/dist/ui/assets/openai-responses-BYdEOxUq.js +1 -0
- package/dist/ui/assets/openai-responses-C3bs8sd1.js +1 -0
- package/dist/ui/assets/{openai-responses-shared-DDootAUL.js → openai-responses-shared-AM04ghTC.js} +1 -1
- package/dist/ui/assets/{openai-responses-shared-07lPyxEg.js → openai-responses-shared-Be22tDzQ.js} +1 -1
- package/dist/ui/assets/openrouter-BIFqVYxG.js +1 -0
- package/dist/ui/assets/openrouter-Dc1D0QOS.js +1 -0
- package/dist/ui/assets/panel-rpc-handlers-DDaHHzWR.js +1 -0
- package/dist/ui/assets/{provider-rBD-3FHW.js → provider-CU5ao6kF.js} +2 -2
- package/dist/ui/assets/{provider-BhabAJGA.js → provider-ChUiWhH0.js} +1 -1
- package/dist/ui/assets/provider-store-access-Bliwcbgg.js +1 -0
- package/dist/ui/assets/provider-store-access-iTh_6mMO.js +1 -0
- package/dist/ui/assets/proxied-fetch-8v3TaZYg.js +1 -0
- package/dist/ui/assets/{pyodide-BC4PaR54.js → pyodide-B7x60zRI.js} +2 -2
- package/dist/ui/assets/{remote-terminal-view-CXbFLcuS.js → remote-terminal-view-BREvd00U.js} +1 -1
- package/dist/ui/assets/secret-env-Js2g2sNO.js +1 -0
- package/dist/ui/assets/slicc-editor-Bu07BjW4.js +12 -0
- package/dist/ui/assets/{spawn-qtlw6x6p.js → spawn-CQ5XACZ1.js} +1 -1
- package/dist/ui/assets/{sql-wasm-DeVtn0z8.js → sql-wasm-C-pXJvOw.js} +1 -1
- package/dist/ui/assets/{store-DLeVoNF3.js → store-DQUahHdW.js} +1 -1
- package/dist/ui/assets/tray-leave-runtime-BEBMIYY_.js +1 -0
- package/dist/ui/assets/{upgrade-detection-CKrzeeRx.js → upgrade-detection-T74KTnyb.js} +1 -1
- package/dist/ui/assets/{xai-grok-CNyu04Tg.js → xai-grok-CkPPMxfZ.js} +1 -1
- package/dist/ui/assets/{xai-grok-sanitize-BeI8rdV5.js → xai-grok-sanitize-C7TgWvwD.js} +1 -1
- package/dist/ui/assets/{xai-grok-sanitize-h_8XMTD9.js → xai-grok-sanitize-L5nUbDcW.js} +1 -1
- package/dist/ui/assets/xai-grok-u9MyUN8m.js +1 -0
- package/dist/ui/electron-overlay-entry.js +9 -9
- package/dist/ui/index.html +3 -2
- package/dist/ui/packages/webapp/cloud/index.html +38 -0
- package/dist/ui/packages/webapp/index.html +3 -2
- package/package.json +10 -8
- package/dist/ui/assets/adobe-DpCIcyEb.js +0 -2
- package/dist/ui/assets/adobe-NMBK1vG2.js +0 -1
- package/dist/ui/assets/agent-bridge-D2k69QZ-.js +0 -1
- package/dist/ui/assets/anthropic-ZtfIcLyL.js +0 -39
- package/dist/ui/assets/azure-openai-CN9QA_pv.js +0 -1
- package/dist/ui/assets/azure-openai-responses-Bhr0mNdj.js +0 -1
- package/dist/ui/assets/azure-openai-responses-D400BxTc.js +0 -1
- package/dist/ui/assets/cost-command-BGqK_hbH.js +0 -1
- package/dist/ui/assets/follower-sprinkle-bridge-BayCf20v.js +0 -1
- package/dist/ui/assets/github-DpDjTcq9.js +0 -2
- package/dist/ui/assets/google-B97zVBac.js +0 -1
- package/dist/ui/assets/google-shared-DwzANLbz.js +0 -11
- package/dist/ui/assets/google-vertex-ICKJGS1M.js +0 -1
- package/dist/ui/assets/index-CCGqFzR9.js +0 -1575
- package/dist/ui/assets/magick-wasm-Bu7zx3Ux.js +0 -1
- package/dist/ui/assets/nuke-command-BSkSFZ4H.js +0 -1
- package/dist/ui/assets/oauth-bootstrap-BeZQrd7y.js +0 -2
- package/dist/ui/assets/oauth-service-BX55wTV9.js +0 -1
- package/dist/ui/assets/offscreen-client-DSEhUCxj.js +0 -1
- package/dist/ui/assets/onboarding-orchestrator-DjNti83y.js +0 -1
- package/dist/ui/assets/openai-codex-responses-DJKJH9AX.js +0 -7
- package/dist/ui/assets/openai-codex-responses-jB5RkWeq.js +0 -7
- package/dist/ui/assets/openai-completions-BWWM3S2J.js +0 -5
- package/dist/ui/assets/openai-responses-C_3YpAmj.js +0 -1
- package/dist/ui/assets/openai-responses-tJegTQYT.js +0 -1
- package/dist/ui/assets/panel-rpc-handlers-B4jZTNHO.js +0 -1
- package/dist/ui/assets/provider-store-access-H9Lu5HRL.js +0 -1
- package/dist/ui/assets/provider-store-access-biaB--zG.js +0 -1
- package/dist/ui/assets/proxied-fetch-C6dm2Ugc.js +0 -1
- package/dist/ui/assets/secret-env-s_8cP7Wf.js +0 -1
- package/dist/ui/assets/slicc-editor-pZcWEwTm.js +0 -12
- package/dist/ui/assets/tray-leave-runtime-DqA9PbxV.js +0 -1
- package/dist/ui/assets/xai-grok-CN1nP4TF.js +0 -1
- /package/dist/ui/assets/{active-transport-CfU1UxY6.js → active-transport-Clj9slj7.js} +0 -0
- /package/dist/ui/assets/{active-transport-Dm6CWYVE.js → active-transport-DHcaBd4j.js} +0 -0
- /package/dist/ui/assets/{addon-fit-BDUxDgg1.js → addon-fit-CBG3Hsec.js} +0 -0
- /package/dist/ui/assets/{addon-fit-Dkm5m5XK.js → addon-fit-CUt9lrQO.js} +0 -0
- /package/dist/ui/assets/{azure-ai-foundry-BHLfY_0t.js → azure-ai-foundry-B4QrVklT.js} +0 -0
- /package/dist/ui/assets/{azure-ai-foundry-1pnZpxAJ.js → azure-ai-foundry-CGkSI_4f.js} +0 -0
- /package/dist/ui/assets/{chat-fixture-DOzffHLr.js → chat-fixture-ChGRNFda.js} +0 -0
- /package/dist/ui/assets/{dist-BYoCEWmq.js → dist-9RlRmGag.js} +0 -0
- /package/dist/ui/assets/{dist-BNe7ZIzA.js → dist-CZcDRTma.js} +0 -0
- /package/dist/ui/assets/{dist-BrjVVq8c.js → dist-D0kTaNET.js} +0 -0
- /package/dist/ui/assets/{git-config-CGMfR0WK.js → git-config-DcQbkikl.js} +0 -0
- /package/dist/ui/assets/{github-copilot-headers-CTUP_cqn.js → github-copilot-headers-C5CocKfn.js} +0 -0
- /package/dist/ui/assets/{global-db-B97_fwjD.js → global-db-DL3jdM9H.js} +0 -0
- /package/dist/ui/assets/{hash-B9Dtr1VK.js → hash-iitWbNjK.js} +0 -0
- /package/dist/ui/assets/{headers-AeYLn7L4.js → headers-qDMOQQGF.js} +0 -0
- /package/dist/ui/assets/{lick-manager-proxy-BnnMFbgv.js → lick-manager-proxy-1L0EGIWD.js} +0 -0
- /package/dist/ui/assets/{index-CvlDeETm.css → main-CvlDeETm.css} +0 -0
- /package/dist/ui/assets/{openai-Bf1npfRy.js → openai-BR_xAflc.js} +0 -0
- /package/dist/ui/assets/{page-storage-sync-CqMAh8jG.js → page-storage-sync-sv2ogNKh.js} +0 -0
- /package/dist/ui/assets/{pdfjs-DDDkZHZ4.js → pdfjs-CW51NNE6.js} +0 -0
- /package/dist/ui/assets/{rum-DCU8sePD.js → rum-z5wz4Dnj.js} +0 -0
- /package/dist/ui/assets/{sanitize-unicode-h0KEBmEw.js → sanitize-unicode-B1z_Y4Dq.js} +0 -0
- /package/dist/ui/assets/{sprinkle-bridge-channel-DojIojh7.js → sprinkle-bridge-channel-Bw5UaanD.js} +0 -0
- /package/dist/ui/assets/{sprinkle-bridge-channel-DJC5SGWr.js → sprinkle-bridge-channel-ChD0T07C.js} +0 -0
- /package/dist/ui/assets/{sprinkle-proxy-rF3NSOGq.js → sprinkle-proxy-D6wqmewK.js} +0 -0
- /package/dist/ui/assets/{src-BQRb5emh.js → src-DRmQ1wr-.js} +0 -0
- /package/dist/ui/assets/{xai-grok-errors-Bzn3oNvW.js → xai-grok-errors-BdY43UIn.js} +0 -0
- /package/dist/ui/assets/{xai-grok-errors-WbFsMZum.js → xai-grok-errors-C6VnD_MH.js} +0 -0
- /package/dist/ui/assets/{xai-grok-models-cvcIXmNM.js → xai-grok-models-BndZgIFZ.js} +0 -0
- /package/dist/ui/assets/{xai-grok-models-DMYWtapT.js → xai-grok-models-C9MIa-Aj.js} +0 -0
- /package/dist/ui/assets/{xterm-D8ldLLKi.js → xterm-DLCsxsB1.js} +0 -0
- /package/dist/ui/assets/{xterm-DhusGoAm.js → xterm-VndicwFp.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as e,G as t,O as n,V as r,b as i,v as a,y as o,z as s}from"./
|
|
1
|
+
import{D as e,G as t,O as n,V as r,b as i,v as a,y as o,z as s}from"./main-BSfjQXCf.js";import{t as c}from"./headers-qDMOQQGF.js";import{t as l}from"./sanitize-unicode-B1z_Y4Dq.js";import{i as u,n as ee,t as d}from"./github-copilot-headers-C5CocKfn.js";function f(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function p(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var te=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return te=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function m(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var h=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},g=class extends Error{},_=class e extends g{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new ne({message:r,cause:h(n)});let a=n,o=a?.error?.type;return t===400?new ie(t,a,r,i,o):t===401?new ae(t,a,r,i,o):t===403?new oe(t,a,r,i,o):t===404?new se(t,a,r,i,o):t===409?new ce(t,a,r,i,o):t===422?new le(t,a,r,i,o):t===429?new ue(t,a,r,i,o):t>=500?new de(t,a,r,i,o):new e(t,a,r,i,o)}},v=class extends _{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},ne=class extends _{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},re=class extends ne{constructor({message:e}={}){super({message:e??`Request timed out.`})}},ie=class extends _{},ae=class extends _{},oe=class extends _{},se=class extends _{},ce=class extends _{},le=class extends _{},ue=class extends _{},de=class extends _{},fe=/^[a-z][a-z0-9+.-]*:/i,pe=e=>fe.test(e),me=e=>(me=Array.isArray,me(e)),he=me;function ge(e){return typeof e==`object`?e??{}:{}}function _e(e){if(!e)return!0;for(let t in e)return!1;return!0}function ve(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var ye=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new g(`${e} must be an integer`);if(t<0)throw new g(`${e} must be a positive integer`);return t},be=e=>{try{return JSON.parse(e)}catch{return}},xe=e=>new Promise(t=>setTimeout(t,e)),y=`0.91.1`,Se=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`;function Ce(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var we=()=>{let e=Ce();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":De(Deno.build.os),"X-Stainless-Arch":Ee(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":De(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Ee(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=Te();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":y,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function Te(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Ee=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,De=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),Oe,ke=()=>Oe??=we();function Ae(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function je(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function Me(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return je({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function Ne(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function Pe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Fe=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)});function Ie(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new g(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}function Le(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Re;function ze(e){let t;return(Re??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Be;function Ve(e){let t;return(Be??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var b,x,He=class{constructor(){b.set(this,void 0),x.set(this,void 0),f(this,b,new Uint8Array,`f`),f(this,x,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?ze(e):e;f(this,b,Le([p(this,b,`f`),t]),`f`);let n=[],r;for(;(r=Ue(p(this,b,`f`),p(this,x,`f`)))!=null;){if(r.carriage&&p(this,x,`f`)==null){f(this,x,r.index,`f`);continue}if(p(this,x,`f`)!=null&&(r.index!==p(this,x,`f`)+1||r.carriage)){n.push(Ve(p(this,b,`f`).subarray(0,p(this,x,`f`)-1))),f(this,b,p(this,b,`f`).subarray(p(this,x,`f`)),`f`),f(this,x,null,`f`);continue}let e=p(this,x,`f`)===null?r.preceding:r.preceding-1,t=Ve(p(this,b,`f`).subarray(0,e));n.push(t),f(this,b,p(this,b,`f`).subarray(r.index),`f`),f(this,x,null,`f`)}return n}flush(){return p(this,b,`f`).length?this.decode(`
|
|
2
2
|
`):[]}};b=new WeakMap,x=new WeakMap,He.NEWLINE_CHARS=new Set([`
|
|
3
3
|
`,`\r`]),He.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ue(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function We(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var Ge={off:0,error:200,warn:300,info:400,debug:500},Ke=(e,t,n)=>{if(e){if(ve(Ge,e))return e;S(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ge))}`)}};function qe(){}function Je(e,t,n){return!t||Ge[e]>Ge[n]?qe:t[e].bind(t)}var Ye={error:qe,warn:qe,info:qe,debug:qe},Xe=new WeakMap;function S(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Ye;let r=Xe.get(t);if(r&&r[0]===n)return r[1];let i={error:Je(`error`,t,n),warn:Je(`warn`,t,n),info:Je(`info`,t,n),debug:Je(`debug`,t,n)};return Xe.set(t,[n,i]),i}var C=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Ze,Qe=class e{constructor(e,t,n){this.iterator=e,Ze.set(this,void 0),this.controller=t,f(this,Ze,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?S(r):console;async function*o(){if(i)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of $e(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`||e.event===`message`||e.event===`user.message`||e.event===`user.interrupt`||e.event===`user.tool_confirmation`||e.event===`user.custom_tool_result`||e.event===`agent.message`||e.event===`agent.thinking`||e.event===`agent.tool_use`||e.event===`agent.tool_result`||e.event===`agent.mcp_tool_use`||e.event===`agent.mcp_tool_result`||e.event===`agent.custom_tool_use`||e.event===`agent.thread_context_compacted`||e.event===`session.status_running`||e.event===`session.status_idle`||e.event===`session.status_rescheduled`||e.event===`session.status_terminated`||e.event===`session.error`||e.event===`session.deleted`||e.event===`span.model_request_start`||e.event===`span.model_request_end`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=be(e.data)??e.data,r=n?.error?.type;throw new _(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(m(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new He,n=Ne(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new g("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(m(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ze=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,p(this,Ze,`f`)),new e(()=>i(n),this.controller,p(this,Ze,`f`))]}toReadableStream(){let e=this,t;return je({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=ze(JSON.stringify(n)+`
|
|
4
4
|
`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}};async function*$e(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new g(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new g(`Attempted to iterate over a response with no body`);let n=new tt,r=new He,i=Ne(e.body);for await(let e of et(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*et(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?ze(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=We(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}var tt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
|
|
@@ -33,7 +33,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
33
33
|
|
|
34
34
|
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
35
35
|
`);this.baseURL=i.baseURL,this.timeout=i.timeout??br.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=Ke(i.logLevel,`ClientOptions.logLevel`,this)??Ke(vr(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??Ae(),f(this,xr,Fe,`f`),this._options=i,this.apiKey=typeof t==`string`?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get(`x-api-key`)||e.get(`authorization`))&&!(this.apiKey&&e.get(`x-api-key`))&&!t.has(`x-api-key`)&&!(this.authToken&&e.get(`authorization`))&&!t.has(`authorization`))throw Error(`Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted`)}async authHeaders(e){return O([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return O([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return O([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Ie(e)}getUserAgent(){return`${this.constructor.name}/JS ${y}`}defaultIdempotencyKey(){return`stainless-node-retry-${te()}`}makeStatusError(e,t,n,r){return _.generate(e,t,n,r)}buildURL(e,t,n){let r=!p(this,yr,`m`,Sr).call(this)&&n||this.baseURL,i=pe(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!_e(a)||!_e(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new g(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details`);return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new ot(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(S(this).debug(`[${c}] sending request`,C({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new v;let ee=new AbortController,d=await this.fetchWithTimeout(o,a,s,ee).catch(h),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new v;let i=m(d)||/timed? ?out/i.test(String(d)+(`cause`in d?String(d.cause):``));if(t)return S(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),S(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,C({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??c);throw S(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),S(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,C({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),i?new re:new ne({cause:d})}let p=`[${c}${l}${[...d.headers.entries()].filter(([e])=>e===`request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${d.ok?`succeeded`:`failed`} with status ${d.status} in ${f-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await Pe(d.body),S(this).info(`${p} - ${e}`),S(this).debug(`[${c}] response error (${e})`,C({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),this.retryRequest(r,t,n??c,d.headers)}let i=e?`error; no more retries left`:`error; not retryable`;S(this).info(`${p} - ${i}`);let a=await d.text().catch(e=>h(e).message),o=be(a),s=o?void 0:a;throw S(this).debug(`[${c}] response error (${i})`,C({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(d.status,o,s,d.headers)}return S(this).info(p),S(this).debug(`[${c}] response start`,C({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),{response:d,options:r,controller:ee,requestLogID:c,retryOfRequestLogID:n,startTime:u}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new lt(this,n,e)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await xe(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}calculateNonstreamingTimeout(e,t){let n=600*1e3;if(36e5*e/128e3>n||t!=null&&e>t)throw new g(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details`);return n}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&ye(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n});return{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=O([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...ke(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":`true`}:void 0,"anthropic-version":`2023-06-01`},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=O([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:Me(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:p(this,xr,`f`).call(this,{body:e,headers:n})}};br=Q,xr=new WeakMap,yr=new WeakSet,Sr=function(){return this.baseURL!==`https://api.anthropic.com`},Q.Anthropic=br,Q.HUMAN_PROMPT=Cr,Q.AI_PROMPT=wr,Q.DEFAULT_TIMEOUT=6e5,Q.AnthropicError=g,Q.APIError=_,Q.APIConnectionError=ne,Q.APIConnectionTimeoutError=re,Q.APIUserAbortError=v,Q.NotFoundError=se,Q.ConflictError=ce,Q.RateLimitError=ue,Q.BadRequestError=ie,Q.AuthenticationError=ae,Q.InternalServerError=de,Q.PermissionDeniedError=oe,Q.UnprocessableEntityError=le,Q.toFile=St;var $=class extends Q{constructor(){super(...arguments),this.completions=new Bn(this),this.messages=new mr(this),this.models=new _r(this),this.beta=new K(this)}};$.Completions=Bn,$.Messages=mr,$.Models=_r,$.Beta=K;function Tr(e){return e||(typeof process<`u`&&{}.PI_CACHE_RETENTION===`long`?`long`:`short`)}function Er(e,t){let n=Tr(t);if(n===`none`)return{retention:n};let r=n===`long`&&Pr(e).supportsLongCacheRetention?`1h`:void 0;return{retention:n,cacheControl:{type:`ephemeral`,...r&&{ttl:r}}}}var Dr=`2.1.75`,Or=new Map([`Read`,`Write`,`Edit`,`Bash`,`Grep`,`Glob`,`AskUserQuestion`,`EnterPlanMode`,`ExitPlanMode`,`KillShell`,`NotebookEdit`,`Skill`,`Task`,`TaskOutput`,`TodoWrite`,`WebFetch`,`WebSearch`].map(e=>[e.toLowerCase(),e])),kr=e=>Or.get(e.toLowerCase())??e,Ar=(e,t)=>{if(t&&t.length>0){let n=e.toLowerCase(),r=t.find(e=>e.name.toLowerCase()===n);if(r)return r.name}return e};function jr(e){if(!e.some(e=>e.type===`image`))return l(e.map(e=>e.text).join(`
|
|
36
|
-
`));let t=e.map(e=>e.type===`text`?{type:`text`,text:l(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}});return t.some(e=>e.type===`text`)||t.unshift({type:`text`,text:`(see attached image)`}),t}var Mr=`fine-grained-tool-streaming-2025-05-14`,Nr=`interleaved-thinking-2025-05-14`;function Pr(e){return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!
|
|
36
|
+
`));let t=e.map(e=>e.type===`text`?{type:`text`,text:l(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}});return t.some(e=>e.type===`text`)||t.unshift({type:`text`,text:`(see attached image)`}),t}var Mr=`fine-grained-tool-streaming-2025-05-14`,Nr=`interleaved-thinking-2025-05-14`;function Pr(e){let t=e.provider===`fireworks`,n=e.provider===`cloudflare-ai-gateway`&&e.baseUrl.includes(`anthropic`);return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!t,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!t,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??!!(t||n),supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!t}}function Fr(...e){let t={};for(let n of e)n&&Object.assign(t,n);return t}var Ir=new Set([`message_start`,`message_delta`,`message_stop`,`content_block_start`,`content_block_delta`,`content_block_stop`]);function Lr(e){if(!e.event&&e.data.length===0)return null;let t={event:e.event,data:e.data.join(`
|
|
37
37
|
`),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],t}function Rr(e,t){if(e===``)return Lr(t);if(t.raw.push(e),e.startsWith(`:`))return null;let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i.startsWith(` `)&&(i=i.slice(1)),r===`event`?t.event=i:r===`data`&&t.data.push(i),null}function zr(e){let t=e.indexOf(`\r`),n=e.indexOf(`
|
|
38
38
|
`);return t===-1?n:n===-1?t:Math.min(t,n)}function Br(e){let t=zr(e);if(t===-1)return null;let n=t+1;return e[t]===`\r`&&e[n]===`
|
|
39
|
-
`&&(n+=1),{line:e.slice(0,t),rest:e.slice(n)}}async function*Vr(e,t){let n=e.getReader(),r=new TextDecoder,i={event:null,data:[],raw:[]},a=``;try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{value:e,done:o}=await n.read();if(o)break;a+=r.decode(e,{stream:!0});let s=Br(a);for(;s;){a=s.rest;let e=Rr(s.line,i);e&&(yield e),s=Br(a)}}a+=r.decode();let e=Br(a);for(;e;){a=e.rest;let t=Rr(e.line,i);t&&(yield t),e=Br(a)}if(a.length>0){let e=Rr(a,i);e&&(yield e)}let o=Lr(i);o&&(yield o)}finally{n.releaseLock()}}async function*Hr(t,n){if(!t.body)throw Error(`Attempted to iterate over an Anthropic response with no body`);let r=!1,i=!1;for await(let a of Vr(t.body,n)){if(a.event===`error`)throw Error(a.data);if(Ir.has(a.event??``))try{let t=e(a.data);t.type===`message_start`?r=!0:t.type===`message_stop`&&(i=!0),yield t}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Could not parse Anthropic SSE event ${a.event}: ${t}; data=${a.data}; raw=${a.raw.join(`\\n`)}`)}}if(r&&!i)throw Error(`Anthropic stream ended before message_stop`)}var Ur=(e,i,a)=>{let o=new s;return(async()=>{let s={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l,u;if(a?.client)l=a.client,u=!1;else{let n=a?.apiKey??t(e.provider)??``,r;if(e.provider===`github-copilot`){let e=ee(i.messages);r=d({messages:i.messages,hasImages:e})}let o=Jr(e,n,a?.interleavedThinking??!0,Qr(e,i),a?.headers,r);l=o.client,u=o.isOAuthToken}let f=Yr(e,i,u,a),p=await a?.onPayload?.(f,e);p!==void 0&&(f=p);let te={...a?.signal?{signal:a.signal}:{},...a?.timeoutMs===void 0?{}:{timeout:a.timeoutMs},...a?.maxRetries===void 0?{}:{maxRetries:a.maxRetries}},m=await l.messages.create({...f,stream:!0},te).asResponse();await a?.onResponse?.({status:m.status,headers:c(m.headers)},e),o.push({type:`start`,partial:s});let h=s.content;for await(let t of Hr(m,a?.signal))if(t.type===`message_start`)s.responseId=t.message.id,s.usage.input=t.message.usage.input_tokens||0,s.usage.output=t.message.usage.output_tokens||0,s.usage.cacheRead=t.message.usage.cache_read_input_tokens||0,s.usage.cacheWrite=t.message.usage.cache_creation_input_tokens||0,s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite,r(e,s.usage);else if(t.type===`content_block_start`){if(t.content_block.type===`text`){let e={type:`text`,text:``,index:t.index};s.content.push(e),o.push({type:`text_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`thinking`){let e={type:`thinking`,thinking:``,thinkingSignature:``,index:t.index};s.content.push(e),o.push({type:`thinking_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`redacted_thinking`){let e={type:`thinking`,thinking:`[Reasoning redacted]`,thinkingSignature:t.content_block.data,redacted:!0,index:t.index};s.content.push(e),o.push({type:`thinking_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`tool_use`){let e={type:`toolCall`,id:t.content_block.id,name:u?Ar(t.content_block.name,i.tools):t.content_block.name,arguments:t.content_block.input??{},partialJson:``,index:t.index};s.content.push(e),o.push({type:`toolcall_start`,contentIndex:s.content.length-1,partial:s})}}else if(t.type===`content_block_delta`){if(t.delta.type===`text_delta`){let e=h.findIndex(e=>e.index===t.index),n=h[e];n&&n.type===`text`&&(n.text+=t.delta.text,o.push({type:`text_delta`,contentIndex:e,delta:t.delta.text,partial:s}))}else if(t.delta.type===`thinking_delta`){let e=h.findIndex(e=>e.index===t.index),n=h[e];n&&n.type===`thinking`&&(n.thinking+=t.delta.thinking,o.push({type:`thinking_delta`,contentIndex:e,delta:t.delta.thinking,partial:s}))}else if(t.delta.type===`input_json_delta`){let e=h.findIndex(e=>e.index===t.index),r=h[e];r&&r.type===`toolCall`&&(r.partialJson+=t.delta.partial_json,r.arguments=n(r.partialJson),o.push({type:`toolcall_delta`,contentIndex:e,delta:t.delta.partial_json,partial:s}))}else if(t.delta.type===`signature_delta`){let e=h[h.findIndex(e=>e.index===t.index)];e&&e.type===`thinking`&&(e.thinkingSignature=e.thinkingSignature||``,e.thinkingSignature+=t.delta.signature)}}else if(t.type===`content_block_stop`){let e=h.findIndex(e=>e.index===t.index),r=h[e];r&&(delete r.index,r.type===`text`?o.push({type:`text_end`,contentIndex:e,content:r.text,partial:s}):r.type===`thinking`?o.push({type:`thinking_end`,contentIndex:e,content:r.thinking,partial:s}):r.type===`toolCall`&&(r.arguments=n(r.partialJson),delete r.partialJson,o.push({type:`toolcall_end`,contentIndex:e,toolCall:r,partial:s})))}else t.type===`message_delta`&&(t.delta.stop_reason&&(s.stopReason=ei(t.delta.stop_reason)),t.usage.input_tokens!=null&&(s.usage.input=t.usage.input_tokens),t.usage.output_tokens!=null&&(s.usage.output=t.usage.output_tokens),t.usage.cache_read_input_tokens!=null&&(s.usage.cacheRead=t.usage.cache_read_input_tokens),t.usage.cache_creation_input_tokens!=null&&(s.usage.cacheWrite=t.usage.cache_creation_input_tokens),s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite,r(e,s.usage));if(a?.signal?.aborted)throw Error(`Request was aborted`);if(s.stopReason===`aborted`||s.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:s.stopReason,message:s}),o.end()}catch(e){for(let e of s.content)delete e.index,delete e.partialJson;s.stopReason=a?.signal?.aborted?`aborted`:`error`,s.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:s.stopReason,error:s}),o.end()}})(),o};function Wr(e){return e.includes(`opus-4-6`)||e.includes(`opus-4.6`)||e.includes(`opus-4-7`)||e.includes(`opus-4.7`)||e.includes(`sonnet-4-6`)||e.includes(`sonnet-4.6`)}function Gr(e,t){let n=t?e.thinkingLevelMap?.[t]:void 0;if(typeof n==`string`)return n;switch(t){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;default:return`high`}}var Kr=(e,n,r)=>{let i=r?.apiKey||t(e.provider);if(!i)throw Error(`No API key for provider: ${e.provider}`);let s=o(e,r,i);if(!r?.reasoning)return Ur(e,n,{...s,thinkingEnabled:!1});if(Wr(e.id)){let t=Gr(e,r.reasoning);return Ur(e,n,{...s,thinkingEnabled:!0,effort:t})}let c=a(s.maxTokens||0,e.maxTokens,r.reasoning,r.thinkingBudgets);return Ur(e,n,{...s,maxTokens:c.maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:c.thinkingBudget})};function qr(e){return e.includes(`sk-ant-oat`)}function Jr(e,t,n,r,i,a){let o=n&&!Wr(e.id),s=[];return r&&s.push(Mr),o&&s.push(Nr),e.provider===`cloudflare-ai-gateway`?{client:new $({apiKey:null,authToken:null,baseURL:u(e),dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"cf-aig-authorization":`Bearer ${t}`,"x-api-key":null,Authorization:null,...s.length>0?{"anthropic-beta":s.join(`,`)}:{}},e.headers,i)}),isOAuthToken:!1}:e.provider===`github-copilot`?{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...s.length>0?{"anthropic-beta":s.join(`,`)}:{}},e.headers,a,i)}),isOAuthToken:!1}:qr(t)?{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":[`claude-code-20250219`,`oauth-2025-04-20`,...s].join(`,`),"user-agent":`claude-cli/${Dr}`,"x-app":`cli`},e.headers,i)}),isOAuthToken:!0}:{client:new $({apiKey:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...s.length>0?{"anthropic-beta":s.join(`,`)}:{}},e.headers,i)}),isOAuthToken:!1}}function Yr(e,t,n,r){let{cacheControl:i}=Er(e,r?.cacheRetention),a={model:e.id,messages:Zr(t.messages,e,n,i),max_tokens:r?.maxTokens||e.maxTokens/3|0,stream:!0};if(n?(a.system=[{type:`text`,text:`You are Claude Code, Anthropic's official CLI for Claude.`,...i?{cache_control:i}:{}}],t.systemPrompt&&a.system.push({type:`text`,text:l(t.systemPrompt),...i?{cache_control:i}:{}})):t.systemPrompt&&(a.system=[{type:`text`,text:l(t.systemPrompt),...i?{cache_control:i}:{}}]),r?.temperature!==void 0&&!r?.thinkingEnabled&&(a.temperature=r.temperature),t.tools&&t.tools.length>0&&(a.tools=$r(t.tools,n,Pr(e).supportsEagerToolInputStreaming,i)),e.reasoning)if(r?.thinkingEnabled){let t=r.thinkingDisplay??`summarized`;Wr(e.id)?(a.thinking={type:`adaptive`,display:t},r.effort&&(a.output_config=(r.effort,{effort:r.effort}))):a.thinking={type:`enabled`,budget_tokens:r.thinkingBudgetTokens||1024,display:t}}else r?.thinkingEnabled===!1&&(a.thinking={type:`disabled`});if(r?.metadata){let e=r.metadata.user_id;typeof e==`string`&&(a.metadata={user_id:e})}return r?.toolChoice&&(typeof r.toolChoice==`string`?a.tool_choice={type:r.toolChoice}:a.tool_choice=r.toolChoice),a}function Xr(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Zr(e,t,n,r){let a=[],o=i(e,t,Xr);for(let e=0;e<o.length;e++){let t=o[e];if(t.role===`user`)if(typeof t.content==`string`)t.content.trim().length>0&&a.push({role:`user`,content:l(t.content)});else{let e=t.content.map(e=>e.type===`text`?{type:`text`,text:l(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}}).filter(e=>e.type===`text`?e.text.trim().length>0:!0);if(e.length===0)continue;a.push({role:`user`,content:e})}else if(t.role===`assistant`){let e=[];for(let r of t.content)if(r.type===`text`){if(r.text.trim().length===0)continue;e.push({type:`text`,text:l(r.text)})}else if(r.type===`thinking`){if(r.redacted){e.push({type:`redacted_thinking`,data:r.thinkingSignature});continue}if(r.thinking.trim().length===0)continue;!r.thinkingSignature||r.thinkingSignature.trim().length===0?e.push({type:`text`,text:l(r.thinking)}):e.push({type:`thinking`,thinking:l(r.thinking),signature:r.thinkingSignature})}else r.type===`toolCall`&&e.push({type:`tool_use`,id:r.id,name:n?kr(r.name):r.name,input:r.arguments??{}});if(e.length===0)continue;a.push({role:`assistant`,content:e})}else if(t.role===`toolResult`){let n=[];n.push({type:`tool_result`,tool_use_id:t.toolCallId,content:jr(t.content),is_error:t.isError});let r=e+1;for(;r<o.length&&o[r].role===`toolResult`;){let e=o[r];n.push({type:`tool_result`,tool_use_id:e.toolCallId,content:jr(e.content),is_error:e.isError}),r++}e=r-1,a.push({role:`user`,content:n})}}if(r&&a.length>0){let e=a[a.length-1];if(e.role===`user`)if(Array.isArray(e.content)){let t=e.content[e.content.length-1];t&&(t.type===`text`||t.type===`image`||t.type===`tool_result`)&&(t.cache_control=r)}else typeof e.content==`string`&&(e.content=[{type:`text`,text:e.content,cache_control:r}])}return a}function Qr(e,t){return!!t.tools?.length&&!Pr(e).supportsEagerToolInputStreaming}function $r(e,t,n,r){return e?e.map((i,a)=>{let o=i.parameters;return{name:t?kr(i.name):i.name,description:i.description,...n?{eager_input_streaming:!0}:{},input_schema:{type:`object`,properties:o.properties??{},required:o.required??[]},...r&&a===e.length-1?{cache_control:r}:{}}}):[]}function ei(e){switch(e){case`end_turn`:return`stop`;case`max_tokens`:return`length`;case`tool_use`:return`toolUse`;case`refusal`:return`error`;case`pause_turn`:return`stop`;case`stop_sequence`:return`stop`;case`sensitive`:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{Ur as streamAnthropic,Kr as streamSimpleAnthropic};
|
|
39
|
+
`&&(n+=1),{line:e.slice(0,t),rest:e.slice(n)}}async function*Vr(e,t){let n=e.getReader(),r=new TextDecoder,i={event:null,data:[],raw:[]},a=``;try{for(;;){if(t?.aborted)throw Error(`Request was aborted`);let{value:e,done:o}=await n.read();if(o)break;a+=r.decode(e,{stream:!0});let s=Br(a);for(;s;){a=s.rest;let e=Rr(s.line,i);e&&(yield e),s=Br(a)}}a+=r.decode();let e=Br(a);for(;e;){a=e.rest;let t=Rr(e.line,i);t&&(yield t),e=Br(a)}if(a.length>0){let e=Rr(a,i);e&&(yield e)}let o=Lr(i);o&&(yield o)}finally{n.releaseLock()}}async function*Hr(t,n){if(!t.body)throw Error(`Attempted to iterate over an Anthropic response with no body`);let r=!1,i=!1;for await(let a of Vr(t.body,n)){if(a.event===`error`)throw Error(a.data);if(Ir.has(a.event??``))try{let t=e(a.data);t.type===`message_start`?r=!0:t.type===`message_stop`&&(i=!0),yield t}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Could not parse Anthropic SSE event ${a.event}: ${t}; data=${a.data}; raw=${a.raw.join(`\\n`)}`)}}if(r&&!i)throw Error(`Anthropic stream ended before message_stop`)}var Ur=(e,i,a)=>{let o=new s;return(async()=>{let s={role:`assistant`,content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l,u;if(a?.client)l=a.client,u=!1;else{let n=a?.apiKey??t(e.provider)??``,r;if(e.provider===`github-copilot`){let e=ee(i.messages);r=d({messages:i.messages,hasImages:e})}let o=(a?.cacheRetention??Tr())===`none`?void 0:a?.sessionId,s=Jr(e,n,a?.interleavedThinking??!0,Qr(e,i),a?.headers,r,o);l=s.client,u=s.isOAuthToken}let f=Yr(e,i,u,a),p=await a?.onPayload?.(f,e);p!==void 0&&(f=p);let te={...a?.signal?{signal:a.signal}:{},...a?.timeoutMs===void 0?{}:{timeout:a.timeoutMs},...a?.maxRetries===void 0?{}:{maxRetries:a.maxRetries}},m=await l.messages.create({...f,stream:!0},te).asResponse();await a?.onResponse?.({status:m.status,headers:c(m.headers)},e),o.push({type:`start`,partial:s});let h=s.content;for await(let t of Hr(m,a?.signal))if(t.type===`message_start`)s.responseId=t.message.id,s.usage.input=t.message.usage.input_tokens||0,s.usage.output=t.message.usage.output_tokens||0,s.usage.cacheRead=t.message.usage.cache_read_input_tokens||0,s.usage.cacheWrite=t.message.usage.cache_creation_input_tokens||0,s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite,r(e,s.usage);else if(t.type===`content_block_start`){if(t.content_block.type===`text`){let e={type:`text`,text:``,index:t.index};s.content.push(e),o.push({type:`text_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`thinking`){let e={type:`thinking`,thinking:``,thinkingSignature:``,index:t.index};s.content.push(e),o.push({type:`thinking_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`redacted_thinking`){let e={type:`thinking`,thinking:`[Reasoning redacted]`,thinkingSignature:t.content_block.data,redacted:!0,index:t.index};s.content.push(e),o.push({type:`thinking_start`,contentIndex:s.content.length-1,partial:s})}else if(t.content_block.type===`tool_use`){let e={type:`toolCall`,id:t.content_block.id,name:u?Ar(t.content_block.name,i.tools):t.content_block.name,arguments:t.content_block.input??{},partialJson:``,index:t.index};s.content.push(e),o.push({type:`toolcall_start`,contentIndex:s.content.length-1,partial:s})}}else if(t.type===`content_block_delta`){if(t.delta.type===`text_delta`){let e=h.findIndex(e=>e.index===t.index),n=h[e];n&&n.type===`text`&&(n.text+=t.delta.text,o.push({type:`text_delta`,contentIndex:e,delta:t.delta.text,partial:s}))}else if(t.delta.type===`thinking_delta`){let e=h.findIndex(e=>e.index===t.index),n=h[e];n&&n.type===`thinking`&&(n.thinking+=t.delta.thinking,o.push({type:`thinking_delta`,contentIndex:e,delta:t.delta.thinking,partial:s}))}else if(t.delta.type===`input_json_delta`){let e=h.findIndex(e=>e.index===t.index),r=h[e];r&&r.type===`toolCall`&&(r.partialJson+=t.delta.partial_json,r.arguments=n(r.partialJson),o.push({type:`toolcall_delta`,contentIndex:e,delta:t.delta.partial_json,partial:s}))}else if(t.delta.type===`signature_delta`){let e=h[h.findIndex(e=>e.index===t.index)];e&&e.type===`thinking`&&(e.thinkingSignature=e.thinkingSignature||``,e.thinkingSignature+=t.delta.signature)}}else if(t.type===`content_block_stop`){let e=h.findIndex(e=>e.index===t.index),r=h[e];r&&(delete r.index,r.type===`text`?o.push({type:`text_end`,contentIndex:e,content:r.text,partial:s}):r.type===`thinking`?o.push({type:`thinking_end`,contentIndex:e,content:r.thinking,partial:s}):r.type===`toolCall`&&(r.arguments=n(r.partialJson),delete r.partialJson,o.push({type:`toolcall_end`,contentIndex:e,toolCall:r,partial:s})))}else t.type===`message_delta`&&(t.delta.stop_reason&&(s.stopReason=ei(t.delta.stop_reason)),t.usage.input_tokens!=null&&(s.usage.input=t.usage.input_tokens),t.usage.output_tokens!=null&&(s.usage.output=t.usage.output_tokens),t.usage.cache_read_input_tokens!=null&&(s.usage.cacheRead=t.usage.cache_read_input_tokens),t.usage.cache_creation_input_tokens!=null&&(s.usage.cacheWrite=t.usage.cache_creation_input_tokens),s.usage.totalTokens=s.usage.input+s.usage.output+s.usage.cacheRead+s.usage.cacheWrite,r(e,s.usage));if(a?.signal?.aborted)throw Error(`Request was aborted`);if(s.stopReason===`aborted`||s.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:s.stopReason,message:s}),o.end()}catch(e){for(let e of s.content)delete e.index,delete e.partialJson;s.stopReason=a?.signal?.aborted?`aborted`:`error`,s.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:s.stopReason,error:s}),o.end()}})(),o};function Wr(e){return e.includes(`opus-4-6`)||e.includes(`opus-4.6`)||e.includes(`opus-4-7`)||e.includes(`opus-4.7`)||e.includes(`sonnet-4-6`)||e.includes(`sonnet-4.6`)}function Gr(e,t){let n=t?e.thinkingLevelMap?.[t]:void 0;if(typeof n==`string`)return n;switch(t){case`minimal`:case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;default:return`high`}}var Kr=(e,n,r)=>{let i=r?.apiKey||t(e.provider);if(!i)throw Error(`No API key for provider: ${e.provider}`);let s=o(e,r,i);if(!r?.reasoning)return Ur(e,n,{...s,thinkingEnabled:!1});if(Wr(e.id)){let t=Gr(e,r.reasoning);return Ur(e,n,{...s,thinkingEnabled:!0,effort:t})}let c=a(s.maxTokens||0,e.maxTokens,r.reasoning,r.thinkingBudgets);return Ur(e,n,{...s,maxTokens:c.maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:c.thinkingBudget})};function qr(e){return e.includes(`sk-ant-oat`)}function Jr(e,t,n,r,i,a,o){let s=n&&!Wr(e.id),c=[];if(r&&c.push(Mr),s&&c.push(Nr),e.provider===`cloudflare-ai-gateway`)return{client:new $({apiKey:null,authToken:null,baseURL:u(e),dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"cf-aig-authorization":`Bearer ${t}`,"x-api-key":null,Authorization:null,...c.length>0?{"anthropic-beta":c.join(`,`)}:{}},e.headers,i)}),isOAuthToken:!1};if(e.provider===`github-copilot`)return{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...c.length>0?{"anthropic-beta":c.join(`,`)}:{}},e.headers,a,i)}),isOAuthToken:!1};if(qr(t))return{client:new $({apiKey:null,authToken:t,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,"anthropic-beta":[`claude-code-20250219`,`oauth-2025-04-20`,...c].join(`,`),"user-agent":`claude-cli/${Dr}`,"x-app":`cli`},e.headers,i)}),isOAuthToken:!0};let l=o&&Pr(e).sendSessionAffinityHeaders?{"x-session-affinity":o}:{};return{client:new $({apiKey:t,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:Fr({accept:`application/json`,"anthropic-dangerous-direct-browser-access":`true`,...c.length>0?{"anthropic-beta":c.join(`,`)}:{}},l,e.headers,i)}),isOAuthToken:!1}}function Yr(e,t,n,r){let{cacheControl:i}=Er(e,r?.cacheRetention),a={model:e.id,messages:Zr(t.messages,e,n,i),max_tokens:r?.maxTokens||e.maxTokens/3|0,stream:!0};if(n?(a.system=[{type:`text`,text:`You are Claude Code, Anthropic's official CLI for Claude.`,...i?{cache_control:i}:{}}],t.systemPrompt&&a.system.push({type:`text`,text:l(t.systemPrompt),...i?{cache_control:i}:{}})):t.systemPrompt&&(a.system=[{type:`text`,text:l(t.systemPrompt),...i?{cache_control:i}:{}}]),r?.temperature!==void 0&&!r?.thinkingEnabled&&(a.temperature=r.temperature),t.tools&&t.tools.length>0){let r=Pr(e);a.tools=$r(t.tools,n,r.supportsEagerToolInputStreaming,r.supportsCacheControlOnTools?i:void 0)}if(e.reasoning)if(r?.thinkingEnabled){let t=r.thinkingDisplay??`summarized`;Wr(e.id)?(a.thinking={type:`adaptive`,display:t},r.effort&&(a.output_config=(r.effort,{effort:r.effort}))):a.thinking={type:`enabled`,budget_tokens:r.thinkingBudgetTokens||1024,display:t}}else r?.thinkingEnabled===!1&&(a.thinking={type:`disabled`});if(r?.metadata){let e=r.metadata.user_id;typeof e==`string`&&(a.metadata={user_id:e})}return r?.toolChoice&&(typeof r.toolChoice==`string`?a.tool_choice={type:r.toolChoice}:a.tool_choice=r.toolChoice),a}function Xr(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function Zr(e,t,n,r){let a=[],o=i(e,t,Xr);for(let e=0;e<o.length;e++){let t=o[e];if(t.role===`user`)if(typeof t.content==`string`)t.content.trim().length>0&&a.push({role:`user`,content:l(t.content)});else{let e=t.content.map(e=>e.type===`text`?{type:`text`,text:l(e.text)}:{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}}).filter(e=>e.type===`text`?e.text.trim().length>0:!0);if(e.length===0)continue;a.push({role:`user`,content:e})}else if(t.role===`assistant`){let e=[];for(let r of t.content)if(r.type===`text`){if(r.text.trim().length===0)continue;e.push({type:`text`,text:l(r.text)})}else if(r.type===`thinking`){if(r.redacted){e.push({type:`redacted_thinking`,data:r.thinkingSignature});continue}if(r.thinking.trim().length===0)continue;!r.thinkingSignature||r.thinkingSignature.trim().length===0?e.push({type:`text`,text:l(r.thinking)}):e.push({type:`thinking`,thinking:l(r.thinking),signature:r.thinkingSignature})}else r.type===`toolCall`&&e.push({type:`tool_use`,id:r.id,name:n?kr(r.name):r.name,input:r.arguments??{}});if(e.length===0)continue;a.push({role:`assistant`,content:e})}else if(t.role===`toolResult`){let n=[];n.push({type:`tool_result`,tool_use_id:t.toolCallId,content:jr(t.content),is_error:t.isError});let r=e+1;for(;r<o.length&&o[r].role===`toolResult`;){let e=o[r];n.push({type:`tool_result`,tool_use_id:e.toolCallId,content:jr(e.content),is_error:e.isError}),r++}e=r-1,a.push({role:`user`,content:n})}}if(r&&a.length>0){let e=a[a.length-1];if(e.role===`user`)if(Array.isArray(e.content)){let t=e.content[e.content.length-1];t&&(t.type===`text`||t.type===`image`||t.type===`tool_result`)&&(t.cache_control=r)}else typeof e.content==`string`&&(e.content=[{type:`text`,text:e.content,cache_control:r}])}return a}function Qr(e,t){return!!t.tools?.length&&!Pr(e).supportsEagerToolInputStreaming}function $r(e,t,n,r){return e?e.map((i,a)=>{let o=i.parameters;return{name:t?kr(i.name):i.name,description:i.description,...n?{eager_input_streaming:!0}:{},input_schema:{type:`object`,properties:o.properties??{},required:o.required??[]},...r&&a===e.length-1?{cache_control:r}:{}}}):[]}function ei(e){switch(e){case`end_turn`:return`stop`;case`max_tokens`:return`length`;case`tool_use`:return`toolUse`;case`refusal`:return`error`;case`pause_turn`:return`stop`;case`stop_sequence`:return`stop`;case`sensitive`:return`error`;default:throw Error(`Unhandled stop reason: ${e}`)}}export{Ur as streamAnthropic,Kr as streamSimpleAnthropic};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Y as e,nt as t,q as n}from"./kernel-worker-
|
|
1
|
+
import{Y as e,nt as t,q as n}from"./kernel-worker-D1_EtuZW.js";const r=t(`mcp-apps`),i=`/workspace/.mcp/sprinkles`;async function a(e){if(e)return e;let{VirtualFS:t}=await import(`./kernel-worker-D1_EtuZW.js`);return await t.create({dbName:n})}function o(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`app`}function s(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function c(e,t){let n=s(t.title??t.name),r=t.description?s(t.description):``,i=s(t.templateUri??`about:blank`),a=JSON.stringify(e),o=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
|
|
2
2
|
<header class="mcp-app__header" style="padding:8px 12px;border-bottom:1px solid var(--s2-border-subtle,#3a3a3a);">
|
|
3
3
|
<h2 style="font-size:14px;font-weight:600;margin:0;">${n}</h2>${r?`\n <p style="font-size:12px;margin:4px 0 0;color:var(--s2-content-secondary,#a0a0a0);">${r}</p>`:``}
|
|
4
4
|
</header>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,K as t,V as n,b as r,d as i,p as a,y as o}from"./main-BSfjQXCf.js";import{t as s}from"./openai-BR_xAflc.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=a(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=r(e.messages,t,d),i=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)i.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});i.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),r=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));r.length?i.push({role:`assistant`,content:n||null,tool_calls:r}):i.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;i.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return i}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(t,r,a={})=>{let o=e();return(async()=>{let e={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=a.apiKey;if(!u)throw Error(`Azure API key is required`);let d=t.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=t.id,_={};t.headers&&Object.assign(_,t.headers),a.headers&&Object.assign(_,a.headers);let v=i(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...r.systemPrompt?[{role:`system`,content:r.systemPrompt}]:[],...f(r,t)],x=p(r.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...a.maxTokens?{max_completion_tokens:a.maxTokens}:{},...a.temperature===void 0?{}:{temperature:a.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:e});for await(let r of S){r.usage&&(e.usage.input=r.usage.prompt_tokens??0,e.usage.output=r.usage.completion_tokens??0,e.usage.totalTokens=r.usage.total_tokens??0,n(t,e.usage));for(let t of r.choices??[]){let n=t.delta;if(n){if(n.content){let{block:t,index:r}=m(e);t.text===``&&o.push({type:`text_start`,contentIndex:r,partial:e}),t.text+=n.content,o.push({type:`text_delta`,contentIndex:r,delta:n.content,partial:e})}if(n.tool_calls)for(let t of n.tool_calls){let n=t.id?h(e,t.id):void 0;if(!n&&t.id&&(n={type:`toolCall`,id:t.id,name:t.function?.name??``,arguments:{},_partialJson:``},e.content.push(n),o.push({type:`toolcall_start`,contentIndex:e.content.length-1,partial:e})),n&&t.function?.arguments){n._partialJson+=t.function.arguments;try{n.arguments=JSON.parse(n._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:e.content.indexOf(n),delta:t.function.arguments,partial:e})}}t.finish_reason&&(e.stopReason=t.finish_reason===`tool_calls`?`toolUse`:t.finish_reason===`length`?`length`:`stop`)}}}for(let t of e.content){let n=e.content.indexOf(t);if(t.type===`toolCall`){let r=t;try{r.arguments=JSON.parse(r._partialJson||`{}`)}catch{}delete r._partialJson,o.push({type:`toolcall_end`,contentIndex:n,toolCall:t,partial:e})}else t.type===`text`&&o.push({type:`text_end`,contentIndex:n,content:t.text,partial:e})}o.push({type:`done`,reason:e.stopReason,message:e}),o.end()}catch(t){e.stopReason=a.signal?.aborted?`aborted`:`error`,e.errorMessage=t instanceof Error?t.message:JSON.stringify(t),o.push({type:`error`,reason:e.stopReason,error:e}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...o(e,n,r)})};function v(){t({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as e,R as t,b as n,c as r,g as i,m as a,x as o,z as s}from"./kernel-worker-
|
|
1
|
+
import{G as e,R as t,b as n,c as r,g as i,m as a,x as o,z as s}from"./kernel-worker-D1_EtuZW.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=i(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:t.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(e,n,i={})=>{let o=t();return(async()=>{let t={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),i.headers&&Object.assign(_,i.headers);let v=a(c)||l,y=new r({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:t});for await(let n of S){n.usage&&(t.usage.input=n.usage.prompt_tokens??0,t.usage.output=n.usage.completion_tokens??0,t.usage.totalTokens=n.usage.total_tokens??0,s(e,t.usage));for(let e of n.choices??[]){let n=e.delta;if(n){if(n.content){let{block:e,index:r}=m(t);e.text===``&&o.push({type:`text_start`,contentIndex:r,partial:t}),e.text+=n.content,o.push({type:`text_delta`,contentIndex:r,delta:n.content,partial:t})}if(n.tool_calls)for(let e of n.tool_calls){let n=e.id?h(t,e.id):void 0;if(!n&&e.id&&(n={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},t.content.push(n),o.push({type:`toolcall_start`,contentIndex:t.content.length-1,partial:t})),n&&e.function?.arguments){n._partialJson+=e.function.arguments;try{n.arguments=JSON.parse(n._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:t.content.indexOf(n),delta:e.function.arguments,partial:t})}}e.finish_reason&&(t.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of t.content){let n=t.content.indexOf(e);if(e.type===`toolCall`){let r=e;try{r.arguments=JSON.parse(r._partialJson||`{}`)}catch{}delete r._partialJson,o.push({type:`toolcall_end`,contentIndex:n,toolCall:e,partial:t})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:n,content:e.text,partial:t})}o.push({type:`done`,reason:t.stopReason,message:t}),o.end()}catch(e){t.stopReason=i.signal?.aborted?`aborted`:`error`,t.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:t.stopReason,error:t}),o.end()}})(),o},_=(e,t,r)=>{let i=r?.apiKey;if(!i)throw Error(`Azure API key is required`);return g(e,t,{...n(e,r,i)})};function v(){e({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as e,L as t,U as n,b as r,c as i,s as a}from"./kernel-worker-D1_EtuZW.js";import{n as o,r as s,t as c}from"./openai-responses-shared-Be22tDzQ.js";const l=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function u(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function d(e,t){return t?.azureDeploymentName?t.azureDeploymentName:u({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}function f(e){if(e instanceof Error){let t=e.status,n=typeof t==`number`?t:void 0;return n===void 0?e.message:`Azure OpenAI API error (${n}): ${e.message}`}try{return JSON.stringify(e)}catch{return String(e)}}const p=(e,r,i)=>{let o=new t;return(async()=>{let t=d(e,i),c={role:`assistant`,content:[],api:`azure-openai-responses`,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l=v(e,i?.apiKey||n(e.provider)||``,i),u=y(e,r,i,t),d=await i?.onPayload?.(u,e);d!==void 0&&(u=d);let f={...i?.signal?{signal:i.signal}:{},...i?.timeoutMs===void 0?{}:{timeout:i.timeoutMs},...i?.maxRetries===void 0?{}:{maxRetries:i.maxRetries}},{data:p,response:m}=await l.responses.create(u,f).withResponse();if(await i?.onResponse?.({status:m.status,headers:a(m.headers)},e),o.push({type:`start`,partial:c}),await s(p,c,o,e),i?.signal?.aborted)throw Error(`Request was aborted`);if(c.stopReason===`aborted`||c.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:c.stopReason,message:c}),o.end()}catch(e){for(let e of c.content)delete e.index,delete e.partialJson;c.stopReason=i?.signal?.aborted?`aborted`:`error`,c.errorMessage=f(e),o.push({type:`error`,reason:c.stopReason,error:c}),o.end()}})(),o},m=(t,i,a)=>{let o=a?.apiKey||n(t.provider);if(!o)throw Error(`No API key for provider: ${t.provider}`);let s=r(t,a,o),c=a?.reasoning?e(t,a.reasoning):void 0,l=c===`off`?void 0:c;return p(t,i,{...s,reasoningEffort:l})};function h(e){let t=e.trim().replace(/\/+$/,``),n;try{n=new URL(t)}catch{throw Error(`Invalid Azure OpenAI base URL: ${e}`)}let r=n.hostname.endsWith(`.openai.azure.com`)||n.hostname.endsWith(`.cognitiveservices.azure.com`),i=n.pathname.replace(/\/+$/,``);return r&&(i===``||i===`/`||i===`/openai`)&&(n.pathname=`/openai/v1`,n.search=``),n.toString().replace(/\/+$/,``)}function g(e){return`https://${e}.openai.azure.com/openai/v1`}function _(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||`v1`,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=g(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:h(a),apiVersion:n}}function v(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:a,apiVersion:o}=_(e,n);return new i({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:a})}function y(e,t,n,r){let i={model:r,input:c(e,t,l),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&t.tools.length>0&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort?e.thinkingLevelMap?.[n.reasoningEffort]??n.reasoningEffort:`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):e.thinkingLevelMap?.off!==null&&(i.reasoning={effort:e.thinkingLevelMap?.off??`none`})),i}export{p as streamAzureOpenAIResponses,m as streamSimpleAzureOpenAIResponses};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as e,H as t,y as n,z as r}from"./main-BSfjQXCf.js";import{t as i}from"./headers-qDMOQQGF.js";import{t as a}from"./openai-BR_xAflc.js";import{n as o,r as s,t as c}from"./openai-responses-shared-AM04ghTC.js";var l=`v1`,u=new Set([`openai`,`openai-codex`,`opencode`,`azure-openai-responses`]);function d(e){let t=new Map;if(!e)return t;for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let[r,i]=e.split(`=`,2);!r||!i||t.set(r.trim(),i.trim())}return t}function f(e,t){return t?.azureDeploymentName?t.azureDeploymentName:d({}.AZURE_OPENAI_DEPLOYMENT_NAME_MAP).get(e.id)||e.id}function p(e){if(e instanceof Error){let t=e.status,n=typeof t==`number`?t:void 0;return n===void 0?e.message:`Azure OpenAI API error (${n}): ${e.message}`}try{return JSON.stringify(e)}catch{return String(e)}}var m=(t,n,a)=>{let o=new r;return(async()=>{let r=f(t,a),c={role:`assistant`,content:[],api:`azure-openai-responses`,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let l=y(t,a?.apiKey||e(t.provider)||``,a),u=b(t,n,a,r),d=await a?.onPayload?.(u,t);d!==void 0&&(u=d);let f={...a?.signal?{signal:a.signal}:{},...a?.timeoutMs===void 0?{}:{timeout:a.timeoutMs},...a?.maxRetries===void 0?{}:{maxRetries:a.maxRetries}},{data:p,response:m}=await l.responses.create(u,f).withResponse();if(await a?.onResponse?.({status:m.status,headers:i(m.headers)},t),o.push({type:`start`,partial:c}),await s(p,c,o,t),a?.signal?.aborted)throw Error(`Request was aborted`);if(c.stopReason===`aborted`||c.stopReason===`error`)throw Error(`An unknown error occurred`);o.push({type:`done`,reason:c.stopReason,message:c}),o.end()}catch(e){for(let e of c.content)delete e.index,delete e.partialJson;c.stopReason=a?.signal?.aborted?`aborted`:`error`,c.errorMessage=p(e),o.push({type:`error`,reason:c.stopReason,error:c}),o.end()}})(),o},h=(r,i,a)=>{let o=a?.apiKey||e(r.provider);if(!o)throw Error(`No API key for provider: ${r.provider}`);let s=n(r,a,o),c=a?.reasoning?t(r,a.reasoning):void 0,l=c===`off`?void 0:c;return m(r,i,{...s,reasoningEffort:l})};function g(e){let t=e.trim().replace(/\/+$/,``),n;try{n=new URL(t)}catch{throw Error(`Invalid Azure OpenAI base URL: ${e}`)}let r=n.hostname.endsWith(`.openai.azure.com`)||n.hostname.endsWith(`.cognitiveservices.azure.com`),i=n.pathname.replace(/\/+$/,``);return r&&(i===``||i===`/`||i===`/openai`)&&(n.pathname=`/openai/v1`,n.search=``),n.toString().replace(/\/+$/,``)}function _(e){return`https://${e}.openai.azure.com/openai/v1`}function v(e,t){let n=t?.azureApiVersion||{}.AZURE_OPENAI_API_VERSION||l,r=t?.azureBaseUrl?.trim()||{}.AZURE_OPENAI_BASE_URL?.trim()||void 0,i=t?.azureResourceName||{}.AZURE_OPENAI_RESOURCE_NAME,a=r;if(!a&&i&&(a=_(i)),!a&&e.baseUrl&&(a=e.baseUrl),!a)throw Error(`Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.`);return{baseUrl:g(a),apiVersion:n}}function y(e,t,n){if(!t){if(!{}.AZURE_OPENAI_API_KEY)throw Error(`Azure OpenAI API key is required. Set AZURE_OPENAI_API_KEY environment variable or pass it as an argument.`);t={}.AZURE_OPENAI_API_KEY}let r={...e.headers};n?.headers&&Object.assign(r,n.headers);let{baseUrl:i,apiVersion:o}=v(e,n);return new a({apiKey:t,apiVersion:o,dangerouslyAllowBrowser:!0,defaultHeaders:r,baseURL:i})}function b(e,t,n,r){let i={model:r,input:c(e,t,u),stream:!0,prompt_cache_key:n?.sessionId};return n?.maxTokens&&(i.max_output_tokens=n?.maxTokens),n?.temperature!==void 0&&(i.temperature=n?.temperature),t.tools&&t.tools.length>0&&(i.tools=o(t.tools)),e.reasoning&&(n?.reasoningEffort||n?.reasoningSummary?(i.reasoning={effort:n?.reasoningEffort?e.thinkingLevelMap?.[n.reasoningEffort]??n.reasoningEffort:`medium`,summary:n?.reasoningSummary||`auto`},i.include=[`reasoning.encrypted_content`]):e.thinkingLevelMap?.off!==null&&(i.reasoning={effort:e.thinkingLevelMap?.off??`none`})),i}export{m as streamAzureOpenAIResponses,h as streamSimpleAzureOpenAIResponses};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{nt as e}from"./kernel-worker-
|
|
1
|
+
import{nt as e}from"./kernel-worker-D1_EtuZW.js";const t=e(`bsh-watchdog`);var n=class{transport;browserAPI;fs;scriptCatalog;running=!1;executing=new Set;constructor(e){if(!e.transport&&!e.browserAPI)throw Error(`BshWatchdog requires either transport or browserAPI`);if(!e.scriptCatalog)throw Error(`BshWatchdog requires a ScriptCatalog`);this.browserAPI=e.browserAPI,this.transport=e.transport??e.browserAPI.getTransport(),this.fs=e.fs,this.scriptCatalog=e.scriptCatalog}async start(){if(this.running)return;this.running=!0,this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback((e,t)=>{t!==this.transport&&this.setTransport(t)});let e;try{e=(await this.scriptCatalog.getBshEntries()).length}catch(e){t.warn(`BSH watchdog startup discovery failed`,{error:e instanceof Error?e.message:String(e)})}t.info(`BSH watchdog started`,e===void 0?void 0:{scriptCount:e})}stop(){this.running&&(this.running=!1,this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.browserAPI&&this.browserAPI.setSessionChangeCallback(void 0),this.executing.clear(),t.info(`BSH watchdog stopped`))}setTransport(e){e!==this.transport&&(this.transport.off(`Page.frameNavigated`,this.onFrameNavigated),this.transport=e,this.running&&this.transport.on(`Page.frameNavigated`,this.onFrameNavigated),t.info(`BSH watchdog transport swapped`))}async discover(){this.scriptCatalog.invalidateBsh(),await this.scriptCatalog.getBshEntries()}async getEntries(){return this.scriptCatalog.getBshEntries()}onFrameNavigated=e=>{let n=e.frame;if(n?.parentId||!n?.url)return;let r=n.url,i=e.sessionId;if(!(!r.startsWith(`http://`)&&!r.startsWith(`https://`))){if(!i){t.warn(`BSH watchdog: no sessionId in Page.frameNavigated params, skipping`,{url:r});return}this.scriptCatalog.findMatchingBshScripts(r).then(e=>{if(e.length!==0)for(let n of e){let e=`${n.path}::${r}`;this.executing.has(e)||(this.executing.add(e),t.info(`BSH watchdog executing script`,{script:n.path,url:r}),this.executeInTargetPage(n.path,r,i).then(()=>{t.info(`BSH script completed`,{script:n.path,url:r})}).catch(e=>{t.error(`BSH script execution error`,{script:n.path,url:r,error:e instanceof Error?e.message:String(e)})}).finally(()=>{this.executing.delete(e)}))}}).catch(e=>{t.error(`BSH discovery failed`,{url:r,error:e instanceof Error?e.message:String(e)})})}};async executeInTargetPage(e,n,r){let i=await this.fs.readFile(e),a=typeof i==`string`?i:new TextDecoder().decode(i),o=`(async () => {
|
|
2
2
|
const __requireSpecifiers = (function() {
|
|
3
3
|
const re = /require\\s*\\(\\s*['"]([^'"]+)['"]\\s*\\)/g;
|
|
4
4
|
const code = ${JSON.stringify(a)};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-
|
|
2
|
-
import{X as e,Y as t}from"./
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-CasStH-w.js","assets/main-BSfjQXCf.js","assets/modulepreload-polyfill-wMinxHhO.js","assets/main-CvlDeETm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{X as e,Y as t}from"./main-BSfjQXCf.js";var n=e(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function i(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var a=`(function() {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
// ===== DOM Utilities =====
|
|
@@ -869,7 +869,7 @@ import{X as e,Y as t}from"./index-CCGqFzR9.js";var n=e(`cdp`),r=class{ws=null;ne
|
|
|
869
869
|
} catch(e) {
|
|
870
870
|
return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
|
|
871
871
|
}
|
|
872
|
-
})()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-
|
|
872
|
+
})()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-CasStH-w.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),r=Math.max(t.width,t.height);if(t.width>n||r>s){let e=Math.min(n/t.width,s/r);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(a,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
|
|
873
873
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
874
874
|
const r = this.getBoundingClientRect();
|
|
875
875
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./modulepreload-polyfill-wMinxHhO.js";var e=`cloud-ims-token`,t=`cloud-ims-token-exp`,n=null;async function r(){if(n)return n;let e=await fetch(`/api/cloud/config`);if(!e.ok)throw Error(`config fetch failed: `+e.status);return n=await e.json(),n}function i(){let n=localStorage.getItem(e),r=parseInt(localStorage.getItem(t)||`0`,10);return!n||r<Date.now()?null:n}function a(n,r){localStorage.setItem(e,n),localStorage.setItem(t,String(Date.now()+(parseInt(r,10)||0)*1e3))}function o(){localStorage.removeItem(e),localStorage.removeItem(t)}function s(e){let t=document.getElementById(`toast`);t.textContent=e,t.classList.remove(`hidden`),setTimeout(()=>t.classList.add(`hidden`),4e3)}function c(){document.getElementById(`signed-out`).classList.add(`hidden`),document.getElementById(`signed-in`).classList.remove(`hidden`),document.getElementById(`user-box`).classList.remove(`hidden`),document.getElementById(`user-label`).textContent=`signed in`}function l(){document.getElementById(`signed-out`).classList.remove(`hidden`),document.getElementById(`signed-in`).classList.add(`hidden`),document.getElementById(`user-box`).classList.add(`hidden`)}async function u(){let e=await r(),t=new URL(e.imsRelayUrl).host===window.location.host,n=/^(localhost|127\.0\.0\.1)$/.test(window.location.hostname),i=crypto.randomUUID(),o,s;if(t)o=window.location.origin+e.imsReceivePath,s=i;else if(n){o=e.imsRelayUrl;let t=Number(window.location.port)||(window.location.protocol===`https:`?443:80);s=btoa(JSON.stringify({source:`local`,port:t,path:e.imsReceivePath,nonce:i}))}else o=e.imsRelayUrl,s=btoa(JSON.stringify({source:`remote`,origin:window.location.origin,path:e.imsReceivePath,nonce:i}));return new Promise((t,n)=>{let r=new URLSearchParams({client_id:e.imsClientId,scope:e.imsScope,response_type:`token`,redirect_uri:o,state:s});if(!window.open(`${e.imsAuthorizeUrl}?${r}`,`sliccy-cloud-ims`,`width=480,height=640`))return n(Error(`popup blocked`));function i(e){e.origin===window.location.origin&&(e.data?.type===`sliccy.cloud.imsToken`?(window.removeEventListener(`message`,i),a(e.data.token,e.data.expiresIn),t()):e.data?.type===`sliccy.cloud.imsError`&&(window.removeEventListener(`message`,i),n(Error(e.data.error))))}window.addEventListener(`message`,i)})}async function d(e,t={}){let n=i();if(!n)throw Error(`not authenticated`);let r=await fetch(e,{...t,headers:{...t.headers||{},Authorization:`Bearer ${n}`,...t.body?{"content-type":`application/json`}:{}}});if(r.status===401)throw o(),l(),s(`Session expired — please sign in again.`),Error(`unauthorized`);if(!r.ok){let e=await r.json().catch(()=>({error:`unknown`,message:r.statusText}));throw Object.assign(Error(e.message||`error`),{code:e.error})}return r.json()}function f(e){if(!e)return`just now`;let t=new Date(e),n=Math.max(0,(Date.now()-t.getTime())/1e3);return n<60?`${Math.floor(n)}s ago`:n<3600?`${Math.floor(n/60)} min ago`:`${Math.floor(n/3600)} hr ago`}function p(e){let t=document.getElementById(`cone-list`);t.replaceChildren();for(let n of e){let e=document.createElement(`li`);e.className=`cone ${n.state}`;let r=document.createElement(`div`),i=document.createElement(`span`);i.className=`state-dot`,r.appendChild(i);let a=document.createElement(`strong`);a.textContent=n.name||n.sandboxId,r.appendChild(a),r.appendChild(document.createTextNode(` `));let o=document.createElement(`span`);o.className=`status`,o.textContent=`${n.state} · ${f(n.lastSeen)}`,r.appendChild(o),e.appendChild(r);let s=document.createElement(`div`);if(s.className=`cone-actions`,n.state===`running`&&n.joinUrl){let e=document.createElement(`a`);e.href=n.joinUrl,e.target=`_blank`,e.rel=`noopener noreferrer`,e.title=`This link grants follower access — only share with people you trust to see this cone.`,e.textContent=`Open ↗`,s.appendChild(e)}if(n.state===`running`){let t=document.createElement(`button`);t.textContent=`Pause`,t.addEventListener(`click`,()=>v(e,n.sandboxId,`pause`)),s.appendChild(t)}if(n.state===`paused`){let t=document.createElement(`button`);t.textContent=`Resume`,t.addEventListener(`click`,()=>v(e,n.sandboxId,`resume`)),s.appendChild(t)}let c=document.createElement(`button`);c.textContent=`Kill`,c.addEventListener(`click`,()=>v(e,n.sandboxId,`kill`)),s.appendChild(c),e.appendChild(s),h.has(n.sandboxId)&&_(e,h.get(n.sandboxId)),t.appendChild(e)}let r=e.filter(e=>e.state===`running`||e.state===`reserved`).length,i=e.filter(e=>e.state===`paused`).length,a=n.capRunning??1,o=n.capPaused??5;document.getElementById(`cap-info`).textContent=`${r} running · ${i} paused (cap: ${a}/${o})`;let s=document.getElementById(`create-btn`),c=r>=a,l=i>=o;s.disabled=c||l,c?s.title=`Cap reached (${r}/${a} running). Pause or kill another first.`:l?s.title=`Paused cap reached (${i}/${o}). Resume or kill a paused cone first.`:s.title=``}async function m(){try{p((await d(`/api/cloud/list`)).cones||[])}catch(e){e.message!==`unauthorized`&&s(`List failed: `+e.message)}}var h=new Map,g={pause:{label:`Pausing…`,path:`/api/cloud/pause`,confirm:null},resume:{label:`Resuming…`,path:`/api/cloud/resume`,confirm:null},kill:{label:`Killing…`,path:`/api/cloud/kill`,confirm:`Kill this cone? This cannot be undone.`}};function _(e,t){e.classList.add(`cone--busy`);for(let t of e.querySelectorAll(`button`))t.disabled=!0;let n=e.querySelector(`.cone-busy-badge`);if(!n){n=document.createElement(`span`),n.className=`cone-busy-badge`;let t=e.querySelector(`.status`);t&&t.appendChild(n)}n.textContent=` · `+t}async function v(e,t,n){let r=g[n];if(r&&!(r.confirm&&!confirm(r.confirm))){h.set(t,r.label),_(e,r.label);try{await d(r.path,{method:`POST`,body:JSON.stringify({sandboxId:t})})}catch(e){s(n.charAt(0).toUpperCase()+n.slice(1)+` failed: `+e.message)}finally{h.delete(t),await m()}}}document.getElementById(`sign-in-btn`).addEventListener(`click`,async()=>{try{await u(),c(),await m()}catch(e){s(`Sign-in failed: `+e.message)}}),document.getElementById(`sign-out-btn`).addEventListener(`click`,async()=>{let e=i();if(e)try{await fetch(`/api/cloud/sign-out`,{method:`POST`,headers:{Authorization:`Bearer ${e}`}})}catch{}o(),l()});var y=document.getElementById(`create-btn`);y.addEventListener(`click`,async()=>{if(y.disabled)return;let e=document.getElementById(`cone-name`),t=document.getElementById(`create-status`),n=e.value.trim()||void 0,r=y.textContent;y.disabled=!0,y.textContent=`Starting…`,t.textContent=`creating cone (this can take 30s)…`;try{let r=await d(`/api/cloud/start`,{method:`POST`,body:JSON.stringify({name:n})});t.textContent=`ready`,e.value=``,await m(),r.joinUrl&&window.open(r.joinUrl,`_blank`,`noopener,noreferrer`)}catch(e){s(`Create failed: `+e.message),t.textContent=``}finally{y.disabled=!1,y.textContent=r,setTimeout(()=>t.textContent=``,3e3)}}),window.addEventListener(`focus`,()=>{i()&&m()});var b=document.getElementById(`sign-in-btn`);b.disabled=!0,b.textContent=`Loading…`,r().then(()=>{b.disabled=!1,b.textContent=`Sign in with Adobe`,i()?(c(),m()):l()}).catch(e=>{b.textContent=`Config error`,s(`Could not load IMS config: `+e.message),l()});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--bg:#fbfaf7;--surface:#fff;--border:#ece8df;--text:#1f1d1a;--muted:#6e655d;--accent:#e8516b;--accent-deep:#c4344f;--accent-soft:#fce4e8;--running:#2ec27e;--paused:#c5b8a6;--dead:#d96363;--shadow:0 2px 8px #281e190f;--radius:14px}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);min-height:100vh;margin:0;padding:32px 24px;font:14.5px/1.55 -apple-system,BlinkMacSystemFont,SF Pro Text,system-ui,sans-serif}main,header{max-width:720px;margin:0 auto}header{border-radius:var(--radius);box-shadow:var(--shadow);background:linear-gradient(135deg,#ffe8d6 0%,#ffc9c9 100%);justify-content:space-between;align-items:center;margin-bottom:24px;padding:20px 24px;display:flex}header h1{letter-spacing:-.01em;color:#4a2a1f;margin:0;font-size:22px;font-weight:600}header h1:before{content:"🍦 "}#user-label{color:var(--muted);margin-right:12px;font-size:13px}.hidden{display:none!important}button{font:inherit;border:1px solid var(--border);background:var(--surface);color:var(--text);cursor:pointer;border-radius:8px;padding:8px 14px;transition:all .15s}button:hover:not(:disabled){border-color:var(--accent);color:var(--accent-deep)}button:active:not(:disabled){transform:translateY(1px)}button:disabled{opacity:.5;cursor:not-allowed}.cone--busy{opacity:.7}.cone-busy-badge{color:var(--accent-deep);font-weight:500}.cone--busy .cone-busy-badge:before{content:"";border:2px solid var(--accent);vertical-align:-1px;border-top-color:#0000;border-radius:50%;width:10px;height:10px;margin-right:6px;animation:.8s linear infinite cone-spin;display:inline-block}@keyframes cone-spin{to{transform:rotate(360deg)}}button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}#sign-in-btn,#create-btn{background:var(--accent);color:#fff;border-color:var(--accent);padding:10px 18px;font-weight:500}#sign-in-btn:hover:not(:disabled),#create-btn:hover:not(:disabled){background:var(--accent-deep);border-color:var(--accent-deep);color:#fff}#signed-out{text-align:center;padding:48px 24px}.create-row{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);align-items:center;gap:10px;margin:20px 0 24px;padding:16px;display:flex}#cone-name{font:inherit;border:1px solid var(--border);background:var(--bg);color:var(--text);border-radius:8px;flex:1;padding:10px 14px}#cone-name:focus{border-color:var(--accent);background:var(--surface);outline:none}#cone-list{margin:0;padding:0;list-style:none}.cone{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);justify-content:space-between;align-items:center;margin-bottom:12px;padding:16px 18px;transition:transform .15s;display:flex}.cone:hover{transform:translateY(-1px)}.state-dot{border-radius:50%;width:10px;height:10px;margin-right:10px;display:inline-block;box-shadow:0 0 0 3px #ffffffb3}.cone.running .state-dot{background:var(--running)}.cone.paused .state-dot{background:var(--paused)}.cone.dead .state-dot{background:var(--dead)}.cone.reserved .state-dot{background:var(--accent)}.cone strong{font-weight:600}.cone-actions{gap:8px;display:flex}.cone-actions a{background:var(--accent-soft);color:var(--accent-deep);border:1px solid #0000;border-radius:8px;align-items:center;padding:8px 12px;font-weight:500;text-decoration:none;display:inline-flex}.cone-actions a:hover{border-color:var(--accent)}.status{color:var(--muted);font-size:12px}.cap-info{color:var(--muted);text-align:right;margin-top:12px;padding-right:6px;font-size:12px}.toast{color:#fff;background:#2b2723;border-radius:10px;max-width:320px;padding:14px 18px;font-size:13.5px;animation:.3s toast-in;position:fixed;top:24px;right:24px;box-shadow:0 6px 20px #0003}@keyframes toast-in{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./main-BSfjQXCf.js";function e(e){}export{e as registerSessionCostsProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,g as t,h as n,nt as r,o as i,r as a,tt as o,u as s}from"./dist-
|
|
1
|
+
import{b as e,g as t,h as n,nt as r,o as i,r as a,tt as o,u as s}from"./dist-CZcDRTma.js";import{r as c}from"./dist-CltZJzbd.js";var l=o({String:r.string,Number:r.number,"True False":r.bool,PropertyName:r.propertyName,Null:r.null,", :":r.separator,"[ ]":r.squareBracket,"{ }":r.brace}),u=c.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[l],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),d=a.define({name:`json`,parser:u.configure({props:[e.add({Object:s({except:/^\s*\}/}),Array:s({except:/^\s*\]/})}),t.add({"Object Array":n})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function f(){return new i(d)}export{f as json};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{at as e,it as t,lt as n,ot as r,rt as i,st as a,ut as o}from"./dist-BNe7ZIzA.js";var s=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new c(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from,c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(r==0&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&e.buffer[r-4]==0&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t){e.buffer[r-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(;n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new l(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new c(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},c=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},l=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},u=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function d(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var f=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},p=new f,m=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=p,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=p,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},h=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;v(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};h.prototype.contextual=h.prototype.fallback=h.prototype.extend=!1;var g=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?d(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(v(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};g.prototype.contextual=h.prototype.fallback=h.prototype.extend=!1;var _=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function v(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||b(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function y(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function b(e,t,n,r){let i=y(n,r,t);return i<0||y(n,r,e)<i}var x=typeof process<`u`&&/\bparse\b/.test({}.LOG),S=null;function C(e,n,r){let i=e.cursor(t.IncludeAnonymous);for(i.moveTo(n);;)if(!(r<0?i.childBefore(n):i.childAfter(n)))for(;;){if((r<0?i.to<n:i.from>n)&&!i.type.isError)return r<0?Math.max(0,Math.min(i.to-1,n-25)):Math.min(e.length,Math.max(i.from+1,n+25));if(r<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return r<0?0:e.length}}var w=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?C(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?C(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let a=r.children[i],s=this.start[n]+r.positions[i];if(s>t)return this.nextStart=s,null;if(a instanceof o){if(s==t){if(s<this.safeFrom)return null;let t=s+a.length;if(t<=this.safeTo){let n=a.prop(e.lookAhead);if(!n||t+n<this.fragment.to)return a}}this.index[n]++,s+a.length>=Math.max(this.safeFrom,t)&&(this.trees.push(a),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+a.length}}},T=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new f)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new f,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new f,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=M(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(M(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(M(o,s+1),t,n,r))}return r}},E=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new m(t,r),this.tokens=new T(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[s.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new w(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&N(r);if(e)return x&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw x&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return x&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(t,n,r){let i=t.pos,{parser:a}=this,s=x?this.stackID(t)+` -> `:``;if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let n=t.curContext&&t.curContext.tracker.strict,r=n?t.curContext.hash:0;for(let c=this.fragments.nodeAt(i);c;){let i=this.parser.nodeSet.types[c.type.id]==c.type?a.getGoto(t.state,c.type.id):-1;if(i>-1&&c.length&&(!n||(c.prop(e.contextHash)||0)==r))return t.useNode(c,i),x&&console.log(s+this.stackID(t)+` (via reuse of ${a.getName(c.type.id)})`),!0;if(!(c instanceof o)||c.children.length==0||c.positions[0]>0)break;let l=c.children[0];if(l instanceof o&&c.positions[0]==0)c=l;else break}}let c=a.stateSlot(t.state,4);if(c>0)return t.reduce(c),x&&console.log(s+this.stackID(t)+` (via always-reduce ${a.getName(c&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let e=0;e<l.length;){let o=l[e++],c=l[e++],u=l[e++],d=e==l.length||!r,f=d?t:t.split(),p=this.tokens.mainToken;if(f.apply(o,c,p?p.start:f.pos,u),x&&console.log(s+this.stackID(f)+` (via ${o&65536?`reduce of ${a.getName(o&65535)}`:`shift`} for ${a.getName(c)} @ ${i}${f==t?``:`, split`})`),d)return!0;f.pos>i?n.push(f):r.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return D(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=x?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),x&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(x&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)x&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))x&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),x&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),D(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),o.build({buffer:u.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(S||=new WeakMap).get(e);return t||S.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function D(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var O=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},k=e=>e,A=class{constructor(e){this.start=e.start,this.shift=e.shift||k,this.reduce=e.reduce||k,this.reuse=e.reuse||k,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},j=class t extends n{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(` `);this.minRepeatTerm=n.length;for(let e=0;e<t.repeatNodeCount;e++)n.push(``);let o=Object.keys(t.topRules).map(e=>t.topRules[e][1]),s=[];for(let e=0;e<n.length;e++)s.push([]);function c(e,t,n){s[e].push([t,t.deserialize(String(n))])}if(t.nodeProps)for(let n of t.nodeProps){let t=n[0];typeof t==`string`&&(t=e[t]);for(let e=1;e<n.length;){let r=n[e++];if(r>=0)c(r,t,n[e++]);else{let i=n[e+-r];for(let a=-r;a>0;a--)c(n[e++],t,i);e++}}}this.nodeSet=new r(n.map((e,n)=>a.define({name:n>=this.minRepeatTerm?void 0:e,id:n,props:s[n],top:o.indexOf(n)>-1,error:n==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(n)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=i;let l=d(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(P),this.states=d(t.states,Uint32Array),this.data=d(t.stateData),this.goto=d(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(e=>typeof e==`number`?new h(l,e):e),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new E(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=M(n,i+2)];else if(n[i+1]==2)return M(n,i+2);else break;if(a==t||a==0)return M(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=M(this.data,n+2);else break;r=t(M(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=M(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let n=Object.assign(Object.create(t.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let t=this.topRules[e.top];if(!t)throw RangeError(`Invalid top rule name ${e.top}`);n.top=t}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((t,r)=>{let i=e.specializers.find(e=>e.from==t.external);if(!i)return t;let a=Object.assign(Object.assign({},t),{external:i.to});return n.specializers[r]=P(a),a})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new O(e,n,r)}static deserialize(e){return new t(e)}};function M(e,t){return e[t]|e[t+1]<<16}function N(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function P(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}export{g as i,_ as n,j as r,A as t};
|
|
1
|
+
import{at as e,it as t,lt as n,ot as r,rt as i,st as a,ut as o}from"./dist-CZcDRTma.js";var s=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new c(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from,c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(r==0&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&e.buffer[r-4]==0&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t){e.buffer[r-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(;n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new l(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new c(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},c=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},l=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},u=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function d(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var f=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},p=new f,m=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=p,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=p,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},h=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;v(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};h.prototype.contextual=h.prototype.fallback=h.prototype.extend=!1;var g=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?d(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(v(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};g.prototype.contextual=h.prototype.fallback=h.prototype.extend=!1;var _=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function v(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||b(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function y(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function b(e,t,n,r){let i=y(n,r,t);return i<0||y(n,r,e)<i}var x=typeof process<`u`&&/\bparse\b/.test({}.LOG),S=null;function C(e,n,r){let i=e.cursor(t.IncludeAnonymous);for(i.moveTo(n);;)if(!(r<0?i.childBefore(n):i.childAfter(n)))for(;;){if((r<0?i.to<n:i.from>n)&&!i.type.isError)return r<0?Math.max(0,Math.min(i.to-1,n-25)):Math.min(e.length,Math.max(i.from+1,n+25));if(r<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return r<0?0:e.length}}var w=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?C(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?C(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let a=r.children[i],s=this.start[n]+r.positions[i];if(s>t)return this.nextStart=s,null;if(a instanceof o){if(s==t){if(s<this.safeFrom)return null;let t=s+a.length;if(t<=this.safeTo){let n=a.prop(e.lookAhead);if(!n||t+n<this.fragment.to)return a}}this.index[n]++,s+a.length>=Math.max(this.safeFrom,t)&&(this.trees.push(a),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+a.length}}},T=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new f)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new f,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new f,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=M(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(M(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(M(o,s+1),t,n,r))}return r}},E=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new m(t,r),this.tokens=new T(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[s.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new w(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&N(r);if(e)return x&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw x&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return x&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(t,n,r){let i=t.pos,{parser:a}=this,s=x?this.stackID(t)+` -> `:``;if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let n=t.curContext&&t.curContext.tracker.strict,r=n?t.curContext.hash:0;for(let c=this.fragments.nodeAt(i);c;){let i=this.parser.nodeSet.types[c.type.id]==c.type?a.getGoto(t.state,c.type.id):-1;if(i>-1&&c.length&&(!n||(c.prop(e.contextHash)||0)==r))return t.useNode(c,i),x&&console.log(s+this.stackID(t)+` (via reuse of ${a.getName(c.type.id)})`),!0;if(!(c instanceof o)||c.children.length==0||c.positions[0]>0)break;let l=c.children[0];if(l instanceof o&&c.positions[0]==0)c=l;else break}}let c=a.stateSlot(t.state,4);if(c>0)return t.reduce(c),x&&console.log(s+this.stackID(t)+` (via always-reduce ${a.getName(c&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let e=0;e<l.length;){let o=l[e++],c=l[e++],u=l[e++],d=e==l.length||!r,f=d?t:t.split(),p=this.tokens.mainToken;if(f.apply(o,c,p?p.start:f.pos,u),x&&console.log(s+this.stackID(f)+` (via ${o&65536?`reduce of ${a.getName(o&65535)}`:`shift`} for ${a.getName(c)} @ ${i}${f==t?``:`, split`})`),d)return!0;f.pos>i?n.push(f):r.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return D(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=x?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),x&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(x&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)x&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))x&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),x&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),D(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),o.build({buffer:u.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(S||=new WeakMap).get(e);return t||S.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function D(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var O=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},k=e=>e,A=class{constructor(e){this.start=e.start,this.shift=e.shift||k,this.reduce=e.reduce||k,this.reuse=e.reuse||k,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},j=class t extends n{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(` `);this.minRepeatTerm=n.length;for(let e=0;e<t.repeatNodeCount;e++)n.push(``);let o=Object.keys(t.topRules).map(e=>t.topRules[e][1]),s=[];for(let e=0;e<n.length;e++)s.push([]);function c(e,t,n){s[e].push([t,t.deserialize(String(n))])}if(t.nodeProps)for(let n of t.nodeProps){let t=n[0];typeof t==`string`&&(t=e[t]);for(let e=1;e<n.length;){let r=n[e++];if(r>=0)c(r,t,n[e++]);else{let i=n[e+-r];for(let a=-r;a>0;a--)c(n[e++],t,i);e++}}}this.nodeSet=new r(n.map((e,n)=>a.define({name:n>=this.minRepeatTerm?void 0:e,id:n,props:s[n],top:o.indexOf(n)>-1,error:n==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(n)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=i;let l=d(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(P),this.states=d(t.states,Uint32Array),this.data=d(t.stateData),this.goto=d(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(e=>typeof e==`number`?new h(l,e):e),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new E(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=M(n,i+2)];else if(n[i+1]==2)return M(n,i+2);else break;if(a==t||a==0)return M(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=M(this.data,n+2);else break;r=t(M(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=M(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let n=Object.assign(Object.create(t.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let t=this.topRules[e.top];if(!t)throw RangeError(`Invalid top rule name ${e.top}`);n.top=t}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((t,r)=>{let i=e.specializers.find(e=>e.from==t.external);if(!i)return t;let a=Object.assign(Object.assign({},t),{external:i.to});return n.specializers[r]=P(a),a})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new O(e,n,r)}static deserialize(e){return new t(e)}};function M(e,t){return e[t]|e[t+1]<<16}function N(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function P(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}export{g as i,_ as n,j as r,A as t};
|