zidane 7.2.5 → 8.0.4
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/LICENSE +21 -0
- package/README.md +34 -6
- package/dist/{acp-D-tVyUjw.js → acp-DQDhi2dj.js} +230 -77
- package/dist/acp-DQDhi2dj.js.map +1 -0
- package/dist/acp-cli.d.ts +1 -1
- package/dist/acp-cli.js +9 -66
- package/dist/acp-cli.js.map +1 -1
- package/dist/acp.d.ts +10 -590
- package/dist/acp.d.ts.map +1 -1
- package/dist/acp.js +3 -3
- package/dist/{agent-D0zZnGbt.js → agent-DSLNmBp0.js} +14401 -13214
- package/dist/agent-DSLNmBp0.js.map +1 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -2
- package/dist/aliasing-lVFbm81n.js +217 -0
- package/dist/aliasing-lVFbm81n.js.map +1 -0
- package/dist/{anthropic-C2aole0G.js → anthropic-CD00LhUP.js} +1442 -1264
- package/dist/anthropic-CD00LhUP.js.map +1 -0
- package/dist/artifacts-CV2hUKnL.js.map +1 -1
- package/dist/{atomic-write-B7zr1ddF.js → atomic-write-Ijgf2Mhc.js} +13 -3
- package/dist/atomic-write-Ijgf2Mhc.js.map +1 -0
- package/dist/call-tool-dHlbGOIY.js +70 -0
- package/dist/call-tool-dHlbGOIY.js.map +1 -0
- package/dist/chat/pure.d.ts +372 -6
- package/dist/chat/pure.d.ts.map +1 -1
- package/dist/chat/pure.js +35 -244
- package/dist/chat/pure.js.map +1 -1
- package/dist/{approvals-DKaJZYlm.js → chat-JPJJ8uu5.js} +15879 -14631
- package/dist/chat-JPJJ8uu5.js.map +1 -0
- package/dist/chat.d.ts +4 -6
- package/dist/chat.js +23 -12
- package/dist/cli-shared-C-YCaglL.js +159 -0
- package/dist/cli-shared-C-YCaglL.js.map +1 -0
- package/dist/client-core-BQSyDALT.d.ts +2115 -0
- package/dist/client-core-BQSyDALT.d.ts.map +1 -0
- package/dist/codemode-worker.d.ts +1 -0
- package/dist/codemode-worker.js +155 -0
- package/dist/codemode-worker.js.map +1 -0
- package/dist/codemode.d.ts +352 -0
- package/dist/codemode.d.ts.map +1 -0
- package/dist/codemode.js +5 -0
- package/dist/connection-Dr-Js4yZ.d.ts +28 -0
- package/dist/connection-Dr-Js4yZ.d.ts.map +1 -0
- package/dist/connection-loop-gdh22LTI.js +112 -0
- package/dist/connection-loop-gdh22LTI.js.map +1 -0
- package/dist/context-segments-BHKlagL6.js +1016 -0
- package/dist/context-segments-BHKlagL6.js.map +1 -0
- package/dist/{context-transport-T_6AYIvy.js → context-transport-DSMTUsK1.js} +3 -3
- package/dist/{context-transport-T_6AYIvy.js.map → context-transport-DSMTUsK1.js.map} +1 -1
- package/dist/contexts/daytona.d.ts +19 -8
- package/dist/contexts/daytona.d.ts.map +1 -1
- package/dist/contexts/daytona.js +1 -440
- package/dist/contexts/docker.d.ts +36 -7
- package/dist/contexts/docker.d.ts.map +1 -1
- package/dist/contexts/docker.js +1 -456
- package/dist/contexts/e2b.d.ts +68 -13
- package/dist/contexts/e2b.d.ts.map +1 -1
- package/dist/contexts/e2b.js +1 -382
- package/dist/contexts/sandbox.d.ts +1 -1
- package/dist/contexts/sandbox.js +5 -0
- package/dist/contexts/sandbox.js.map +1 -1
- package/dist/{contexts-CRE9pw07.js → contexts-d7UolYot.js} +1059 -524
- package/dist/contexts-d7UolYot.js.map +1 -0
- package/dist/contexts.d.ts +3 -3
- package/dist/contexts.js +1 -1
- package/dist/cred-keys-GpBg71cP.js +105 -0
- package/dist/cred-keys-GpBg71cP.js.map +1 -0
- package/dist/{auth-BG2rVKSt.js → credentials-JttEuRON.js} +55 -206
- package/dist/credentials-JttEuRON.js.map +1 -0
- package/dist/{cursor-iojRXHF9.js → cursor-CdjaQTBW.js} +3 -3
- package/dist/{cursor-iojRXHF9.js.map → cursor-CdjaQTBW.js.map} +1 -1
- package/dist/daemon-cli.d.ts +1 -1
- package/dist/daemon-cli.js +3 -2
- package/dist/daemon-cli.js.map +1 -1
- package/dist/daytona-DG3omipZ.js +513 -0
- package/dist/daytona-DG3omipZ.js.map +1 -0
- package/dist/defaults-Cx3zvDOV.js +23 -0
- package/dist/defaults-Cx3zvDOV.js.map +1 -0
- package/dist/dispatcher-BMlu2BmZ.js +4941 -0
- package/dist/dispatcher-BMlu2BmZ.js.map +1 -0
- package/dist/docker-BZhMMJUp.js +727 -0
- package/dist/docker-BZhMMJUp.js.map +1 -0
- package/dist/e2b-CEVOdRib.js +480 -0
- package/dist/e2b-CEVOdRib.js.map +1 -0
- package/dist/edit-utils-EGosADZq.js +234 -0
- package/dist/edit-utils-EGosADZq.js.map +1 -0
- package/dist/environment-8wsKE2Ln.js +214 -0
- package/dist/environment-8wsKE2Ln.js.map +1 -0
- package/dist/eval-BNcvle_J.js +1595 -0
- package/dist/eval-BNcvle_J.js.map +1 -0
- package/dist/eval.d.ts +2 -2
- package/dist/eval.js +1 -1489
- package/dist/executor-Cx5-8yqi.js +621 -0
- package/dist/executor-Cx5-8yqi.js.map +1 -0
- package/dist/extension-authoring-DyGGmq9V.js +385 -0
- package/dist/extension-authoring-DyGGmq9V.js.map +1 -0
- package/dist/extensions.d.ts +2 -2
- package/dist/extensions.js +3 -3
- package/dist/{fetch-url-DX75gpL0.js → fetch-url-Ct2TjDWt.js} +4 -4
- package/dist/{fetch-url-DX75gpL0.js.map → fetch-url-Ct2TjDWt.js.map} +1 -1
- package/dist/{format-BF745pLL.js → format-C2NQEVUH.js} +39 -2
- package/dist/format-C2NQEVUH.js.map +1 -0
- package/dist/format-bytes-C7tfc3Zm.js +55 -0
- package/dist/format-bytes-C7tfc3Zm.js.map +1 -0
- package/dist/headless-C_rNUuYC.js +960 -0
- package/dist/headless-C_rNUuYC.js.map +1 -0
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -413
- package/dist/{history-search-C4bk1Wz_.js → history-search-CcYzF8-0.js} +7 -3
- package/dist/history-search-CcYzF8-0.js.map +1 -0
- package/dist/history-search-worker.d.ts +1 -1
- package/dist/history-search-worker.js +1 -1
- package/dist/host-D7NrI03V.js +378 -0
- package/dist/host-D7NrI03V.js.map +1 -0
- package/dist/host-signals-BcP5QKUD.js +118 -0
- package/dist/host-signals-BcP5QKUD.js.map +1 -0
- package/dist/identity-CwfO8K-t.js +26 -0
- package/dist/identity-CwfO8K-t.js.map +1 -0
- package/dist/{index-BgN1T3lk.d.ts → index-BGe1fQT7.d.ts} +10987 -9320
- package/dist/index-BGe1fQT7.d.ts.map +1 -0
- package/dist/index-BVQsIKGn.d.ts +448 -0
- package/dist/index-BVQsIKGn.d.ts.map +1 -0
- package/dist/{index-C6NEd5y_.d.ts → index-CHABJd-L.d.ts} +3386 -502
- package/dist/index-CHABJd-L.d.ts.map +1 -0
- package/dist/{index-C37_ppWv.d.ts → index-D6a7qXpg.d.ts} +2 -3
- package/dist/index-D6a7qXpg.d.ts.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +27 -23
- package/dist/{completion-core-BRo86R_L.js → inline-ghost-BVRQeGoL.js} +50 -2
- package/dist/inline-ghost-BVRQeGoL.js.map +1 -0
- package/dist/ipc/remote.d.ts +313 -0
- package/dist/ipc/remote.d.ts.map +1 -0
- package/dist/ipc/remote.js +4 -0
- package/dist/ipc.d.ts +6 -964
- package/dist/ipc.js +403 -4
- package/dist/ipc.js.map +1 -0
- package/dist/{isolation-Kfoof0MM.d.ts → isolation-D9L650W5.d.ts} +100 -15
- package/dist/isolation-D9L650W5.d.ts.map +1 -0
- package/dist/json-rpc--HXQti1E.js +350 -0
- package/dist/json-rpc--HXQti1E.js.map +1 -0
- package/dist/links-j8rED1sR.js +603 -0
- package/dist/links-j8rED1sR.js.map +1 -0
- package/dist/local-terminal-D8QThwo_.js +252 -0
- package/dist/local-terminal-D8QThwo_.js.map +1 -0
- package/dist/{logger--C1VQjwJ.js → logger-Gtqlayx8.js} +199 -173
- package/dist/logger-Gtqlayx8.js.map +1 -0
- package/dist/logs-view-CWG8aUAG.js.map +1 -1
- package/dist/{mcp-CgNd-f3F.js → mcp-_wecH9Qe.js} +608 -562
- package/dist/mcp-_wecH9Qe.js.map +1 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/media-sniff-UKijEaiQ.js.map +1 -1
- package/dist/{messages-2jcOA_5R.js → messages-BqiwcD2Q.js} +1017 -1014
- package/dist/messages-BqiwcD2Q.js.map +1 -0
- package/dist/{oauth-DxHO17JE.js → oauth-Px_pBB9W.js} +5 -5
- package/dist/{oauth-DxHO17JE.js.map → oauth-Px_pBB9W.js.map} +1 -1
- package/dist/{openai-compat-Dy56weK8.js → openai-compat-CFrpH7uq.js} +432 -589
- package/dist/openai-compat-CFrpH7uq.js.map +1 -0
- package/dist/orchestration-BCGmB8Ps.js +511 -0
- package/dist/orchestration-BCGmB8Ps.js.map +1 -0
- package/dist/output/stream-json.d.ts +1 -2
- package/dist/output/stream-json.d.ts.map +1 -1
- package/dist/output/stream-json.js +1 -1
- package/dist/output/terminal.d.ts +1 -2
- package/dist/output/terminal.d.ts.map +1 -1
- package/dist/output/terminal.js +13 -7
- package/dist/output/terminal.js.map +1 -1
- package/dist/{plugins-gbI7SBA6.js → plugins-DS7mahzZ.js} +20 -101
- package/dist/plugins-DS7mahzZ.js.map +1 -0
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -2
- package/dist/prelude-Cxo4t74B.js +517 -0
- package/dist/prelude-Cxo4t74B.js.map +1 -0
- package/dist/presets.d.ts +1 -1
- package/dist/presets.js +1 -2
- package/dist/project-root-B8zADr4o.js +167 -0
- package/dist/project-root-B8zADr4o.js.map +1 -0
- package/dist/project-user-paths-BSgtrRxl.js +58 -0
- package/dist/project-user-paths-BSgtrRxl.js.map +1 -0
- package/dist/{prompts-Pqc3JdW_.d.ts → prompts-DYcvqShf.d.ts} +14 -11
- package/dist/prompts-DYcvqShf.d.ts.map +1 -0
- package/dist/protocol-DnhqqSmE.js +13 -0
- package/dist/protocol-DnhqqSmE.js.map +1 -0
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +1 -2
- package/dist/providers/arcee.d.ts +1 -1
- package/dist/providers/arcee.js +1 -1
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +1 -1
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +3 -2
- package/dist/providers/cerebras.js.map +1 -1
- package/dist/providers/local.d.ts +1 -1
- package/dist/providers/local.js +1 -1
- package/dist/providers/openai-compat.d.ts +1 -1
- package/dist/providers/openai-compat.js +1 -2
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +15 -12
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +3 -2
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +3 -3
- package/dist/{providers-BVhnFyiY.js → providers-XUR7F4Hi.js} +4 -4
- package/dist/{providers-BVhnFyiY.js.map → providers-XUR7F4Hi.js.map} +1 -1
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +4 -4
- package/dist/registry-D6ShBWJU.js +5234 -0
- package/dist/registry-D6ShBWJU.js.map +1 -0
- package/dist/remote-hosts-BtA_9ZGp.js +97 -0
- package/dist/remote-hosts-BtA_9ZGp.js.map +1 -0
- package/dist/restate.d.ts +2 -3
- package/dist/restate.d.ts.map +1 -1
- package/dist/restate.js +631 -572
- package/dist/restate.js.map +1 -1
- package/dist/run-summary-CklLiZ4y.js +288 -0
- package/dist/run-summary-CklLiZ4y.js.map +1 -0
- package/dist/{sandbox-BH0WQkXn.d.ts → sandbox-C5dR5DwQ.d.ts} +6 -3
- package/dist/sandbox-C5dR5DwQ.d.ts.map +1 -0
- package/dist/session/sqlite.d.ts +1 -2
- package/dist/session/sqlite.d.ts.map +1 -1
- package/dist/session/sqlite.js +1 -616
- package/dist/session-factory-BUGY5P40.js +1576 -0
- package/dist/session-factory-BUGY5P40.js.map +1 -0
- package/dist/{session-BqRP1hS7.js → session-xh9JXu6i.js} +94 -52
- package/dist/session-xh9JXu6i.js.map +1 -0
- package/dist/session.d.ts +1 -1
- package/dist/session.js +2 -2
- package/dist/settings-keys-Ckf29NeM.js +677 -0
- package/dist/settings-keys-Ckf29NeM.js.map +1 -0
- package/dist/shell-path-Dqaoow2J.js +412 -0
- package/dist/shell-path-Dqaoow2J.js.map +1 -0
- package/dist/{skills-BC3dodWp.js → skills-DKqZJm4X.js} +430 -470
- package/dist/skills-DKqZJm4X.js.map +1 -0
- package/dist/skills.d.ts +2 -2
- package/dist/skills.js +1 -2
- package/dist/source-mPExaUm8.js +381 -0
- package/dist/source-mPExaUm8.js.map +1 -0
- package/dist/sqlite-DV1DQzN2.js +698 -0
- package/dist/sqlite-DV1DQzN2.js.map +1 -0
- package/dist/{src-CkNQKFKr.js → src-BRMYRJib.js} +903 -1121
- package/dist/src-BRMYRJib.js.map +1 -0
- package/dist/{stdio-DPpBDPx5.js → stdio-C6YyoW3I.js} +4 -4
- package/dist/{stdio-DPpBDPx5.js.map → stdio-C6YyoW3I.js.map} +1 -1
- package/dist/{stdio-loader-Bbx19dMZ.js → stdio-loader-C830Vg-Z.js} +4 -4
- package/dist/{stdio-loader-Bbx19dMZ.js.map → stdio-loader-C830Vg-Z.js.map} +1 -1
- package/dist/system-prompt-MNVHatSD.d.ts.map +1 -1
- package/dist/timeout-DEaqslLO.d.ts.map +1 -1
- package/dist/todo-edits-Dn251YUP.js +1790 -0
- package/dist/todo-edits-Dn251YUP.js.map +1 -0
- package/dist/{turn-operations-DrbJlpq9.js → tool-formatters-IQFDrdrs.js} +1456 -2120
- package/dist/tool-formatters-IQFDrdrs.js.map +1 -0
- package/dist/tool-state-Dku6YqAB.js +989 -0
- package/dist/tool-state-Dku6YqAB.js.map +1 -0
- package/dist/tools/fetch-url.d.ts +1 -2
- package/dist/tools/fetch-url.d.ts.map +1 -1
- package/dist/tools/fetch-url.js +1 -2
- package/dist/tools/prompts.d.ts +1 -1
- package/dist/tools/prompts.js +7 -7
- package/dist/tools/prompts.js.map +1 -1
- package/dist/tools/web-search.d.ts +1 -2
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +2 -2
- package/dist/tools/web-search.js.map +1 -1
- package/dist/tools-_DnT3AGM.js +578 -0
- package/dist/tools-_DnT3AGM.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +4 -2
- package/dist/tui.d.ts +534 -517
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +34933 -27243
- package/dist/tui.js.map +1 -1
- package/dist/turn-operations-B8sokwi5.js +333 -0
- package/dist/turn-operations-B8sokwi5.js.map +1 -0
- package/dist/turn-operations-DQX5ZZni.d.ts +3089 -0
- package/dist/turn-operations-DQX5ZZni.d.ts.map +1 -0
- package/dist/types-C7ZFOztE.d.ts +132 -0
- package/dist/types-C7ZFOztE.d.ts.map +1 -0
- package/dist/types-CH5XpIHw.js +114 -0
- package/dist/types-CH5XpIHw.js.map +1 -0
- package/dist/{types-CWgENVLY.js → types-Cu0ZGDu9.js} +10 -6
- package/dist/types-Cu0ZGDu9.js.map +1 -0
- package/dist/types-IqegbJEE.d.ts +624 -0
- package/dist/types-IqegbJEE.d.ts.map +1 -0
- package/dist/types.d.ts +4 -4
- package/dist/types.js +1 -1
- package/dist/url-D8HCl65b.js +1259 -0
- package/dist/url-D8HCl65b.js.map +1 -0
- package/dist/wasm-BVT-j5cl.js +33 -0
- package/dist/wasm-BVT-j5cl.js.map +1 -0
- package/dist/workspace-exec-stream-SV2R9d5S.js +355 -0
- package/dist/workspace-exec-stream-SV2R9d5S.js.map +1 -0
- package/dist/ws-CIHMvlSh.js +952 -0
- package/dist/ws-CIHMvlSh.js.map +1 -0
- package/dist/ws-client-N7NxzvQp.js +230 -0
- package/dist/ws-client-N7NxzvQp.js.map +1 -0
- package/dist/{xai-CazjStOK.js → xai-CvJTeLrI.js} +165 -5
- package/dist/xai-CvJTeLrI.js.map +1 -0
- package/dist/xdg-zweed0-t.js +117 -0
- package/dist/xdg-zweed0-t.js.map +1 -0
- package/docs/ACP.md +52 -0
- package/docs/ARCHITECTURE.md +103 -6
- package/docs/ARTIFACTS.md +8 -4
- package/docs/CHAT.md +165 -14
- package/docs/EXECUTION_CONTEXT.md +8 -0
- package/docs/EXTENSIONS.md +123 -2
- package/docs/HEADLESS.md +2 -0
- package/docs/IPC.md +775 -64
- package/docs/MACHINES.md +456 -0
- package/docs/PANELS.md +3 -0
- package/docs/README.md +4 -0
- package/docs/RESTATE.md +3 -2
- package/docs/RUN_IN_BACKGROUND.md +10 -2
- package/docs/SERVER.md +1085 -0
- package/docs/SKILL.md +6 -1
- package/docs/TERMINAL.md +75 -0
- package/docs/TUI.md +65 -14
- package/package.json +58 -26
- package/scripts/eval.ts +4 -0
- package/dist/acp-D-tVyUjw.js.map +0 -1
- package/dist/agent-D0zZnGbt.js.map +0 -1
- package/dist/anthropic-C2aole0G.js.map +0 -1
- package/dist/approvals-DKaJZYlm.js.map +0 -1
- package/dist/atomic-write-B7zr1ddF.js.map +0 -1
- package/dist/auth-BG2rVKSt.js.map +0 -1
- package/dist/completion-core-BRo86R_L.js.map +0 -1
- package/dist/contexts/daytona.js.map +0 -1
- package/dist/contexts/docker.js.map +0 -1
- package/dist/contexts/e2b.js.map +0 -1
- package/dist/contexts-CRE9pw07.js.map +0 -1
- package/dist/eval.js.map +0 -1
- package/dist/format-BF745pLL.js.map +0 -1
- package/dist/glob-DluQFSw1.js +0 -270
- package/dist/glob-DluQFSw1.js.map +0 -1
- package/dist/headless.js.map +0 -1
- package/dist/history-search-C4bk1Wz_.js.map +0 -1
- package/dist/index-BgN1T3lk.d.ts.map +0 -1
- package/dist/index-C37_ppWv.d.ts.map +0 -1
- package/dist/index-C6NEd5y_.d.ts.map +0 -1
- package/dist/ipc-BKVIIOqH.js +0 -331
- package/dist/ipc-BKVIIOqH.js.map +0 -1
- package/dist/ipc.d.ts.map +0 -1
- package/dist/isolation-Kfoof0MM.d.ts.map +0 -1
- package/dist/json-rpc-rSWMUh9b.js +0 -192
- package/dist/json-rpc-rSWMUh9b.js.map +0 -1
- package/dist/logger--C1VQjwJ.js.map +0 -1
- package/dist/mcp-CgNd-f3F.js.map +0 -1
- package/dist/messages-2jcOA_5R.js.map +0 -1
- package/dist/openai-compat-Dy56weK8.js.map +0 -1
- package/dist/output-cap-C9zukcCj.js +0 -100
- package/dist/output-cap-C9zukcCj.js.map +0 -1
- package/dist/panels-B6gRk4bf.js +0 -789
- package/dist/panels-B6gRk4bf.js.map +0 -1
- package/dist/plugins-gbI7SBA6.js.map +0 -1
- package/dist/prompts-Pqc3JdW_.d.ts.map +0 -1
- package/dist/run-summary-BU_NgwUT.js +0 -269
- package/dist/run-summary-BU_NgwUT.js.map +0 -1
- package/dist/sandbox-BH0WQkXn.d.ts.map +0 -1
- package/dist/session/sqlite.js.map +0 -1
- package/dist/session-BqRP1hS7.js.map +0 -1
- package/dist/shell-path-DfdXrGg9.js +0 -1549
- package/dist/shell-path-DfdXrGg9.js.map +0 -1
- package/dist/skills-BC3dodWp.js.map +0 -1
- package/dist/src-CkNQKFKr.js.map +0 -1
- package/dist/todo-edits-UOwgxGKu.js +0 -528
- package/dist/todo-edits-UOwgxGKu.js.map +0 -1
- package/dist/tool-formatters-DoRLnfuD.d.ts +0 -759
- package/dist/tool-formatters-DoRLnfuD.d.ts.map +0 -1
- package/dist/transcript-anchors-BeudMbXx.d.ts +0 -1762
- package/dist/transcript-anchors-BeudMbXx.d.ts.map +0 -1
- package/dist/turn-operations-C8bMBDl_.d.ts +0 -1258
- package/dist/turn-operations-C8bMBDl_.d.ts.map +0 -1
- package/dist/turn-operations-DrbJlpq9.js.map +0 -1
- package/dist/types-CWgENVLY.js.map +0 -1
- package/dist/xai-CazjStOK.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-core-BQSyDALT.d.ts","names":["OrchestrationCreateWorkerParams","Orchest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URCE } from "./prelude-Cxo4t74B.js";
|
|
3
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
4
|
+
import { JSException, MAX_STACK_SIZE, QuickJS } from "quickjs-wasi";
|
|
5
|
+
//#region src/codemode/runtime/worker.ts
|
|
6
|
+
function post(message) {
|
|
7
|
+
parentPort?.postMessage(message);
|
|
8
|
+
}
|
|
9
|
+
function crash(error) {
|
|
10
|
+
post({
|
|
11
|
+
type: "crash",
|
|
12
|
+
message: error instanceof Error ? `${error.name}: ${error.message}` : String(error)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** WASI `errno` for success. */
|
|
16
|
+
const ESUCCESS = 0;
|
|
17
|
+
/**
|
|
18
|
+
* WASI overrides. QuickJS writes engine diagnostics to fd 1 and 2, which the
|
|
19
|
+
* default shim forwards to the host's stdout and stderr. That output belongs to
|
|
20
|
+
* the host application (for example the TUI), so it is discarded; reporting
|
|
21
|
+
* every byte as written keeps libc from retrying. With `determinism`, the clock
|
|
22
|
+
* and random source are pinned as well.
|
|
23
|
+
*/
|
|
24
|
+
function wasiOverrides(determinism) {
|
|
25
|
+
return (memory) => {
|
|
26
|
+
const overrides = { fd_write(_fd, iovsPtr, iovsLen, nwrittenPtr) {
|
|
27
|
+
const view = new DataView(memory.buffer);
|
|
28
|
+
let written = 0;
|
|
29
|
+
for (let i = 0; i < iovsLen; i++) written += view.getUint32(iovsPtr + i * 8 + 4, true);
|
|
30
|
+
view.setUint32(nwrittenPtr, written, true);
|
|
31
|
+
return ESUCCESS;
|
|
32
|
+
} };
|
|
33
|
+
if (!determinism) return overrides;
|
|
34
|
+
const nowNs = BigInt(Math.trunc(determinism.nowMs)) * 1000000n;
|
|
35
|
+
let state = determinism.seed >>> 0 || 2654435769;
|
|
36
|
+
overrides.clock_time_get = (_clockId, _precision, resultPtr) => {
|
|
37
|
+
new DataView(memory.buffer).setBigUint64(resultPtr, nowNs, true);
|
|
38
|
+
return ESUCCESS;
|
|
39
|
+
};
|
|
40
|
+
overrides.random_get = (bufPtr, bufLen) => {
|
|
41
|
+
const bytes = new Uint8Array(memory.buffer, bufPtr, bufLen);
|
|
42
|
+
for (let i = 0; i < bufLen; i++) {
|
|
43
|
+
state ^= state << 13;
|
|
44
|
+
state ^= state >>> 17;
|
|
45
|
+
state ^= state << 5;
|
|
46
|
+
state >>>= 0;
|
|
47
|
+
bytes[i] = state & 255;
|
|
48
|
+
}
|
|
49
|
+
return ESUCCESS;
|
|
50
|
+
};
|
|
51
|
+
return overrides;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function describeException(error) {
|
|
55
|
+
const head = error.message ? `${error.name}: ${error.message}` : error.name;
|
|
56
|
+
const stack = error.stack?.trimEnd();
|
|
57
|
+
return JSON.stringify({
|
|
58
|
+
name: error.name,
|
|
59
|
+
message: error.message,
|
|
60
|
+
stack: stack ? `${head}\n${stack}` : head
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function main(data) {
|
|
64
|
+
const interrupt = new Int32Array(data.interrupt);
|
|
65
|
+
const vm = await QuickJS.create({
|
|
66
|
+
wasm: data.wasm,
|
|
67
|
+
memoryLimit: data.memoryLimitBytes,
|
|
68
|
+
maxStackSize: MAX_STACK_SIZE,
|
|
69
|
+
interruptHandler: () => Atomics.load(interrupt, 0) !== 0,
|
|
70
|
+
wasi: wasiOverrides(data.determinism)
|
|
71
|
+
});
|
|
72
|
+
const bridge = vm.newFunction("bridge", (kind, a, b, c) => {
|
|
73
|
+
switch (kind.toString()) {
|
|
74
|
+
case "call":
|
|
75
|
+
case "global":
|
|
76
|
+
post({
|
|
77
|
+
type: "call",
|
|
78
|
+
id: a.toNumber(),
|
|
79
|
+
target: kind.toString() === "call" ? "tool" : "global",
|
|
80
|
+
name: b.toString(),
|
|
81
|
+
args: c === void 0 || c.isUndefined ? void 0 : c.toString()
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
case "output":
|
|
85
|
+
post({
|
|
86
|
+
type: "output",
|
|
87
|
+
item: a.toString() === "image" ? {
|
|
88
|
+
type: "image",
|
|
89
|
+
data: b.toString(),
|
|
90
|
+
mimeType: c.toString()
|
|
91
|
+
} : a.toString() === "console" ? {
|
|
92
|
+
type: "text",
|
|
93
|
+
text: b.toString(),
|
|
94
|
+
console: true
|
|
95
|
+
} : {
|
|
96
|
+
type: "text",
|
|
97
|
+
text: b.toString()
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
break;
|
|
101
|
+
case "done": if (a.toBoolean()) post({
|
|
102
|
+
type: "done",
|
|
103
|
+
ok: true,
|
|
104
|
+
value: b === void 0 || b.isUndefined ? void 0 : b.toString(),
|
|
105
|
+
writes: c.toString()
|
|
106
|
+
});
|
|
107
|
+
else post({
|
|
108
|
+
type: "done",
|
|
109
|
+
ok: false,
|
|
110
|
+
error: b.toString()
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return vm.undefined;
|
|
114
|
+
});
|
|
115
|
+
const api = vm.withScope((scope) => scope.escape(vm.callFunction(vm.evalCode(PRELUDE_SOURCE, "codemode-prelude.js"), vm.undefined, bridge, vm.newString(JSON.stringify(data.tools)), vm.newString(JSON.stringify(data.globals)), vm.newString(JSON.stringify(data.store)))));
|
|
116
|
+
const settle = api.getProp("settle");
|
|
117
|
+
const run = api.getProp("run");
|
|
118
|
+
const stalled = api.getProp("stalled");
|
|
119
|
+
/** Run queued jobs, then fail a script that waits on nothing that can ever resume it. */
|
|
120
|
+
const drain = () => {
|
|
121
|
+
vm.executePendingJobs();
|
|
122
|
+
vm.callFunction(stalled, api).dispose();
|
|
123
|
+
};
|
|
124
|
+
parentPort?.on("message", (message) => {
|
|
125
|
+
if (!isHostToWorkerMessage(message)) return;
|
|
126
|
+
try {
|
|
127
|
+
vm.withScope(() => {
|
|
128
|
+
vm.callFunction(settle, api, vm.newNumber(message.id), message.ok ? vm.true : vm.false, message.payload === void 0 ? vm.undefined : vm.newString(message.payload));
|
|
129
|
+
});
|
|
130
|
+
drain();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
crash(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
let fn;
|
|
136
|
+
try {
|
|
137
|
+
fn = vm.evalCode(`(async (tools, console) => {${data.code}\n})`, "codemode.js");
|
|
138
|
+
} catch (error) {
|
|
139
|
+
if (!(error instanceof JSException)) throw error;
|
|
140
|
+
post({
|
|
141
|
+
type: "done",
|
|
142
|
+
ok: false,
|
|
143
|
+
error: describeException(error)
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
vm.callFunction(run, api, fn).dispose();
|
|
148
|
+
fn.dispose();
|
|
149
|
+
drain();
|
|
150
|
+
}
|
|
151
|
+
if (parentPort) main(workerData).catch(crash);
|
|
152
|
+
//#endregion
|
|
153
|
+
export {};
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=codemode-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemode-worker.js","names":[],"sources":["../src/codemode/runtime/worker.ts"],"sourcesContent":["/**\n * Worker thread entry. One worker runs one script inside a fresh QuickJS VM\n * (a separate wasm instance), relays tool calls and output to the host, and\n * reports the result. The host terminates the worker when the script settles,\n * times out, or is aborted; the worker exists so that a spinning script never\n * blocks the host thread.\n *\n * Importing this module starts the worker. Bundled hosts (a Bun compiled\n * executable, a re-bundled zidane) add this file as a separate entrypoint and\n * pass its URL or embedded-module specifier as `workerUrl`.\n */\nimport type { JSValueHandle } from 'quickjs-wasi'\nimport type { CodemodeDeterminism } from '../types'\nimport type { WorkerData, WorkerToHostMessage } from './protocol'\nimport { parentPort, workerData } from 'node:worker_threads'\nimport { JSException, MAX_STACK_SIZE, QuickJS } from 'quickjs-wasi'\nimport { PRELUDE_SOURCE } from './prelude'\nimport { isHostToWorkerMessage } from './protocol'\n\nfunction post(message: WorkerToHostMessage): void {\n parentPort?.postMessage(message)\n}\n\nfunction crash(error: unknown): void {\n post({ type: 'crash', message: error instanceof Error ? `${error.name}: ${error.message}` : String(error) })\n}\n\n/** WASI `errno` for success. */\nconst ESUCCESS = 0\n\n/**\n * WASI overrides. QuickJS writes engine diagnostics to fd 1 and 2, which the\n * default shim forwards to the host's stdout and stderr. That output belongs to\n * the host application (for example the TUI), so it is discarded; reporting\n * every byte as written keeps libc from retrying. With `determinism`, the clock\n * and random source are pinned as well.\n */\nfunction wasiOverrides(determinism: CodemodeDeterminism | undefined) {\n return (memory: { readonly buffer: ArrayBufferLike }) => {\n const overrides: Record<string, (...args: never[]) => number> = {\n fd_write(_fd: number, iovsPtr: number, iovsLen: number, nwrittenPtr: number): number {\n const view = new DataView(memory.buffer)\n let written = 0\n for (let i = 0; i < iovsLen; i++)\n written += view.getUint32(iovsPtr + i * 8 + 4, true)\n view.setUint32(nwrittenPtr, written, true)\n return ESUCCESS\n },\n }\n if (!determinism)\n return overrides\n const nowNs = BigInt(Math.trunc(determinism.nowMs)) * 1_000_000n\n // xorshift32; a zero state would stay zero.\n let state = (determinism.seed >>> 0) || 0x9E3779B9\n overrides.clock_time_get = (_clockId: number, _precision: bigint, resultPtr: number): number => {\n new DataView(memory.buffer).setBigUint64(resultPtr, nowNs, true)\n return ESUCCESS\n }\n overrides.random_get = (bufPtr: number, bufLen: number): number => {\n const bytes = new Uint8Array(memory.buffer, bufPtr, bufLen)\n for (let i = 0; i < bufLen; i++) {\n state ^= state << 13\n state ^= state >>> 17\n state ^= state << 5\n state >>>= 0\n bytes[i] = state & 0xFF\n }\n return ESUCCESS\n }\n return overrides\n }\n}\n\nfunction describeException(error: JSException): string {\n const head = error.message ? `${error.name}: ${error.message}` : error.name\n const stack = error.stack?.trimEnd()\n return JSON.stringify({ name: error.name, message: error.message, stack: stack ? `${head}\\n${stack}` : head })\n}\n\nasync function main(data: WorkerData): Promise<void> {\n const interrupt = new Int32Array(data.interrupt)\n const vm = await QuickJS.create({\n wasm: data.wasm as WebAssembly.Module,\n memoryLimit: data.memoryLimitBytes,\n // Without a guard, deep recursion overflows the wasm stack and traps instead of throwing a\n // catchable RangeError.\n maxStackSize: MAX_STACK_SIZE,\n interruptHandler: () => Atomics.load(interrupt, 0) !== 0,\n wasi: wasiOverrides(data.determinism),\n })\n\n // Called from the prelude with primitives only.\n const bridge = vm.newFunction('bridge', (kind, a, b, c) => {\n switch (kind.toString()) {\n case 'call':\n case 'global':\n post({\n type: 'call',\n id: a.toNumber(),\n target: kind.toString() === 'call' ? 'tool' : 'global',\n name: b.toString(),\n args: c === undefined || c.isUndefined ? undefined : c.toString(),\n })\n break\n case 'output':\n post({\n type: 'output',\n item:\n a.toString() === 'image'\n ? { type: 'image', data: b.toString(), mimeType: c.toString() }\n : a.toString() === 'console'\n ? { type: 'text', text: b.toString(), console: true }\n : { type: 'text', text: b.toString() },\n })\n break\n case 'done':\n if (a.toBoolean()) {\n post({\n type: 'done',\n ok: true,\n value: b === undefined || b.isUndefined ? undefined : b.toString(),\n writes: c.toString(),\n })\n }\n else {\n post({ type: 'done', ok: false, error: b.toString() })\n }\n break\n }\n return vm.undefined\n })\n\n // The VM lives until the host terminates the worker, so these handles are never disposed.\n const api = vm.withScope(scope =>\n scope.escape(\n vm.callFunction(\n vm.evalCode(PRELUDE_SOURCE, 'codemode-prelude.js'),\n vm.undefined,\n bridge,\n vm.newString(JSON.stringify(data.tools)),\n vm.newString(JSON.stringify(data.globals)),\n vm.newString(JSON.stringify(data.store)),\n ),\n ),\n )\n const settle = api.getProp('settle')\n const run = api.getProp('run')\n const stalled = api.getProp('stalled')\n /** Run queued jobs, then fail a script that waits on nothing that can ever resume it. */\n const drain = () => {\n vm.executePendingJobs()\n vm.callFunction(stalled, api).dispose()\n }\n\n parentPort?.on('message', (message: unknown) => {\n if (!isHostToWorkerMessage(message))\n return\n try {\n vm.withScope(() => {\n vm.callFunction(\n settle,\n api,\n vm.newNumber(message.id),\n message.ok ? vm.true : vm.false,\n message.payload === undefined ? vm.undefined : vm.newString(message.payload),\n )\n })\n drain()\n }\n catch (error) {\n crash(error)\n }\n })\n\n // The prefix shares the first line with the script so reported line numbers\n // match the script as written.\n let fn: JSValueHandle\n try {\n fn = vm.evalCode(`(async (tools, console) => {${data.code}\\n})`, 'codemode.js')\n }\n catch (error) {\n if (!(error instanceof JSException))\n throw error\n post({ type: 'done', ok: false, error: describeException(error) })\n return\n }\n vm.callFunction(run, api, fn).dispose()\n fn.dispose()\n drain()\n}\n\nif (parentPort)\n main(workerData as WorkerData).catch(crash)\n"],"mappings":";;;;;AAmBA,SAAS,KAAK,SAAoC;CAChD,YAAY,YAAY,OAAO;AACjC;AAEA,SAAS,MAAM,OAAsB;CACnC,KAAK;EAAE,MAAM;EAAS,SAAS,iBAAiB,QAAQ,GAAG,MAAM,KAAK,IAAI,MAAM,YAAY,OAAO,KAAK;CAAE,CAAC;AAC7G;;AAGA,MAAM,WAAW;;;;;;;;AASjB,SAAS,cAAc,aAA8C;CACnE,QAAQ,WAAiD;EACvD,MAAM,YAA0D,EAC9D,SAAS,KAAa,SAAiB,SAAiB,aAA6B;GACnF,MAAM,OAAO,IAAI,SAAS,OAAO,MAAM;GACvC,IAAI,UAAU;GACd,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,KAC3B,WAAW,KAAK,UAAU,UAAU,IAAI,IAAI,GAAG,IAAI;GACrD,KAAK,UAAU,aAAa,SAAS,IAAI;GACzC,OAAO;EACT,EACF;EACA,IAAI,CAAC,aACH,OAAO;EACT,MAAM,QAAQ,OAAO,KAAK,MAAM,YAAY,KAAK,CAAC,IAAI;EAEtD,IAAI,QAAS,YAAY,SAAS,KAAM;EACxC,UAAU,kBAAkB,UAAkB,YAAoB,cAA8B;GAC9F,IAAI,SAAS,OAAO,MAAM,CAAC,CAAC,aAAa,WAAW,OAAO,IAAI;GAC/D,OAAO;EACT;EACA,UAAU,cAAc,QAAgB,WAA2B;GACjE,MAAM,QAAQ,IAAI,WAAW,OAAO,QAAQ,QAAQ,MAAM;GAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;IAC/B,SAAS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AAQ,IAAI;GAAO,OAAO,kBAAkB,KAAK;EAAE,CAAC;EACjE;CACF;CACA,GAAG,aAAa,KAAK,KAAK,EAAE,CAAC,CAAC,QAAQ;CACtC,GAAG,QAAQ;CACX,MAAM;AACR;AAEA,IAAI,YACF,KAAK,UAAwB,CAAC,CAAC,MAAM,KAAK"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
//#region src/codemode/wasm.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A compiled `WebAssembly.Module` of `quickjs-wasi/quickjs.wasm`. Typed opaquely so callers don't
|
|
4
|
+
* need the DOM lib for the WebAssembly globals.
|
|
5
|
+
*/
|
|
6
|
+
type CodemodeWasmModule = object;
|
|
7
|
+
/**
|
|
8
|
+
* Read and compile the QuickJS wasm once per path. `path` defaults to the file in the installed
|
|
9
|
+
* `quickjs-wasi` package (an optional peer dependency); pass it when the file lives elsewhere, for
|
|
10
|
+
* example embedded in a Bun compiled executable. A failed load is retried on the next call.
|
|
11
|
+
*/
|
|
12
|
+
declare function loadQuickJSWasm(path?: string): Promise<CodemodeWasmModule>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/codemode/types.d.ts
|
|
15
|
+
interface CodemodeToolContext {
|
|
16
|
+
/**
|
|
17
|
+
* Aborted when the script finishes (including unawaited calls), the
|
|
18
|
+
* execution times out, the caller aborts, or the sandbox is closed.
|
|
19
|
+
*/
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
/**
|
|
22
|
+
* 1-based position of this call in the order the script issued it, shared
|
|
23
|
+
* by tools and globals. The VM is single-threaded and has no timers, so for
|
|
24
|
+
* a given script and given results the order is the same on every run:
|
|
25
|
+
* durable adapters can key journal entries on it.
|
|
26
|
+
*/
|
|
27
|
+
seq: number;
|
|
28
|
+
}
|
|
29
|
+
/** A JSON Schema document. Only used to render declarations; values are not validated against it. */
|
|
30
|
+
type CodemodeJsonSchema = {
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
} | boolean;
|
|
33
|
+
interface CodemodeTool {
|
|
34
|
+
/**
|
|
35
|
+
* The script calls tools as `tools.<id>(args)`, where `<id>` is the name with characters that
|
|
36
|
+
* are not valid in identifiers replaced by `_` (see `toCodemodeIdentifier`), and also as
|
|
37
|
+
* `tools["<name>"](args)`. Globals are called as `<name>(args)` and must be identifiers, or
|
|
38
|
+
* `<namespace>.<member>`, which groups them into a frozen namespace object.
|
|
39
|
+
*/
|
|
40
|
+
name: string;
|
|
41
|
+
/** Shown as a doc comment in `renderDeclarations`, and listed in `ALL_TOOLS` for tools. */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** Schema of the single argument. Rendered as the parameter type; `unknown` when omitted. */
|
|
44
|
+
inputSchema?: CodemodeJsonSchema;
|
|
45
|
+
/** Schema of the resolved value. Rendered as the promise type; `unknown` when omitted. */
|
|
46
|
+
outputSchema?: CodemodeJsonSchema;
|
|
47
|
+
/** Globals only: `execute` receives all call arguments as an array instead of the first one. */
|
|
48
|
+
spread?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Globals only: TypeScript parameter list and return type for `renderDeclarations`, for
|
|
51
|
+
* example `(type: string, id?: string): Promise<Model[]>`. Replaces the rendering from the schemas.
|
|
52
|
+
*/
|
|
53
|
+
signature?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `args` is whatever the script passed, after a JSON round trip. The return
|
|
56
|
+
* value must be JSON-serializable; a thrown error surfaces in the script as
|
|
57
|
+
* an `Error` with the same message.
|
|
58
|
+
*/
|
|
59
|
+
execute: (args: unknown, context: CodemodeToolContext) => Promise<unknown> | unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One item of the script's output, in the order the script produced it: `text()` and `console.*`
|
|
63
|
+
* produce text items, with `console: true` for `console.*`, and `image()` image items. `data` is base64.
|
|
64
|
+
*/
|
|
65
|
+
type CodemodeOutputItem = {
|
|
66
|
+
type: 'text';
|
|
67
|
+
text: string;
|
|
68
|
+
console?: true;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'image';
|
|
71
|
+
data: string;
|
|
72
|
+
mimeType: string;
|
|
73
|
+
};
|
|
74
|
+
type CodemodeCallStatus = 'ok' | 'error' | 'cancelled';
|
|
75
|
+
interface CodemodeCall {
|
|
76
|
+
name: string;
|
|
77
|
+
/** Same as {@link CodemodeToolContext.seq} for this call. */
|
|
78
|
+
seq: number;
|
|
79
|
+
status: CodemodeCallStatus;
|
|
80
|
+
durationMs: number;
|
|
81
|
+
}
|
|
82
|
+
type CodemodeErrorKind = 'script' |
|
|
83
|
+
/** The overall deadline expired. The worker was terminated. */
|
|
84
|
+
'timeout' |
|
|
85
|
+
/** The caller's signal fired or the sandbox was closed. The worker was terminated. */
|
|
86
|
+
'aborted' |
|
|
87
|
+
/** The worker or VM failed outside the script's control (for example a wasm trap or a missing worker file). */
|
|
88
|
+
'sandbox';
|
|
89
|
+
interface CodemodeError {
|
|
90
|
+
kind: CodemodeErrorKind;
|
|
91
|
+
name?: string;
|
|
92
|
+
message: string;
|
|
93
|
+
stack?: string;
|
|
94
|
+
}
|
|
95
|
+
/** Keys the script changed with `store()`. Only successful executions report writes. */
|
|
96
|
+
interface CodemodeStoreWrites {
|
|
97
|
+
set: Record<string, unknown>;
|
|
98
|
+
/** Keys stored as `undefined`. */
|
|
99
|
+
delete: string[];
|
|
100
|
+
}
|
|
101
|
+
/** `output` is kept for failed executions too, up to the failure. `exit()` completes with `value: undefined`. */
|
|
102
|
+
type CodemodeResult = {
|
|
103
|
+
ok: true;
|
|
104
|
+
value: unknown;
|
|
105
|
+
output: CodemodeOutputItem[];
|
|
106
|
+
calls: CodemodeCall[];
|
|
107
|
+
storeWrites: CodemodeStoreWrites;
|
|
108
|
+
} | {
|
|
109
|
+
ok: false;
|
|
110
|
+
error: CodemodeError;
|
|
111
|
+
output: CodemodeOutputItem[];
|
|
112
|
+
calls: CodemodeCall[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Pins the VM's only nondeterministic inputs, the WASI clock and random
|
|
116
|
+
* source. `Date.now()` returns `nowMs` for the whole run and `Math.random()`
|
|
117
|
+
* (seeded from the clock by QuickJS) plus WASI `random_get` derive from
|
|
118
|
+
* `seed`. With these set, a script that sees the same tool results takes the
|
|
119
|
+
* same path, which is what durable replay needs.
|
|
120
|
+
*/
|
|
121
|
+
interface CodemodeDeterminism {
|
|
122
|
+
nowMs: number;
|
|
123
|
+
seed: number;
|
|
124
|
+
}
|
|
125
|
+
interface CodemodeSandboxOptions {
|
|
126
|
+
tools?: CodemodeTool[];
|
|
127
|
+
/**
|
|
128
|
+
* Functions exposed as top-level identifiers instead of on `tools`, for host helpers such as
|
|
129
|
+
* attaching an image to the result. They behave like tools (JSON round trip, promise result)
|
|
130
|
+
* but are not recorded in `result.calls`. Names must be identifiers and may not shadow the
|
|
131
|
+
* built-in globals (`tools`, `ALL_TOOLS`, `console`, `text`, `image`, `exit`, `store`, `load`).
|
|
132
|
+
*/
|
|
133
|
+
globals?: CodemodeTool[];
|
|
134
|
+
/**
|
|
135
|
+
* Overall deadline per execution, including time spent in tools. `Infinity` disables the
|
|
136
|
+
* deadline; the execution then only ends when the script settles or is aborted.
|
|
137
|
+
* Default: 300000.
|
|
138
|
+
*/
|
|
139
|
+
timeoutMs?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Maximum memory the QuickJS VM may allocate. Allocations beyond it fail inside the script as
|
|
142
|
+
* `InternalError: out of memory`. Default: no limit beyond wasm32's 4 GiB address space.
|
|
143
|
+
*/
|
|
144
|
+
memoryLimitBytes?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Compiled `quickjs-wasi/quickjs.wasm`, usually from `loadQuickJSWasm`. Default: the file in
|
|
147
|
+
* the installed `quickjs-wasi` package. Pass it when that file is not on disk, for example in a
|
|
148
|
+
* Bun compiled executable.
|
|
149
|
+
*/
|
|
150
|
+
wasm?: CodemodeWasmModule | Promise<CodemodeWasmModule>;
|
|
151
|
+
/**
|
|
152
|
+
* Worker entry (`src/codemode/runtime/worker.ts`, `dist/codemode-worker.js`). Default: the
|
|
153
|
+
* sibling of this module. Pass it when zidane is re-bundled. Bun compiled executables need
|
|
154
|
+
* the relative string specifier of an embedded build entrypoint; other hosts usually use a URL.
|
|
155
|
+
*/
|
|
156
|
+
workerUrl?: string | URL;
|
|
157
|
+
}
|
|
158
|
+
interface CodemodeExecuteOptions {
|
|
159
|
+
signal?: AbortSignal;
|
|
160
|
+
/** Overrides the sandbox default for this execution. */
|
|
161
|
+
timeoutMs?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Values the script reads with `load(key)`. Must be JSON-serializable. The script's own
|
|
164
|
+
* `store()` calls come back as `result.storeWrites`; persisting them is up to the caller.
|
|
165
|
+
*/
|
|
166
|
+
store?: Readonly<Record<string, unknown>>;
|
|
167
|
+
/** Pin the clock and random source for this execution. See {@link CodemodeDeterminism}. */
|
|
168
|
+
determinism?: CodemodeDeterminism;
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/codemode/identifier.d.ts
|
|
172
|
+
/**
|
|
173
|
+
* The identifier a script uses for a tool: characters that are not valid in a JavaScript
|
|
174
|
+
* identifier become `_`. `mcp__docs__search` stays as is, `my-tool` becomes `my_tool`.
|
|
175
|
+
*/
|
|
176
|
+
declare function toCodemodeIdentifier(name: string): string;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/codemode/declarations.d.ts
|
|
179
|
+
/** Largest rendered input type, in characters, before it becomes `unknown`. */
|
|
180
|
+
declare const DEFAULT_INPUT_SCHEMA_MAX_CHARS = 16000;
|
|
181
|
+
/**
|
|
182
|
+
* TypeScript types for MCP results, from the MCP `CallToolResult` schema, so `CallToolResult<T>`
|
|
183
|
+
* declarations can refer to them.
|
|
184
|
+
*/
|
|
185
|
+
declare const MCP_TYPESCRIPT_PREAMBLE = "type Role = \"user\" | \"assistant\";\ntype MetaObject = Record<string, unknown>;\ntype Annotations = {\n audience?: Role[];\n priority?: number;\n lastModified?: string;\n};\ntype Icon = {\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n};\ntype TextResourceContents = {\n uri: string;\n mimeType?: string;\n _meta?: MetaObject;\n text: string;\n};\ntype BlobResourceContents = {\n uri: string;\n mimeType?: string;\n _meta?: MetaObject;\n blob: string;\n};\ntype TextContent = {\n type: \"text\";\n text: string;\n annotations?: Annotations;\n _meta?: MetaObject;\n};\ntype ImageContent = {\n type: \"image\";\n data: string;\n mimeType: string;\n annotations?: Annotations;\n _meta?: MetaObject;\n};\ntype AudioContent = {\n type: \"audio\";\n data: string;\n mimeType: string;\n annotations?: Annotations;\n _meta?: MetaObject;\n};\ntype ResourceLink = {\n icons?: Icon[];\n name: string;\n title?: string;\n uri: string;\n description?: string;\n mimeType?: string;\n annotations?: Annotations;\n size?: number;\n _meta?: MetaObject;\n type: \"resource_link\";\n};\ntype EmbeddedResource = {\n type: \"resource\";\n resource: TextResourceContents | BlobResourceContents;\n annotations?: Annotations;\n _meta?: MetaObject;\n};\ntype ContentBlock =\n | TextContent\n | ImageContent\n | AudioContent\n | ResourceLink\n | EmbeddedResource;\ntype CallToolResult<TStructured = { [key: string]: unknown }> = {\n _meta?: MetaObject;\n content: ContentBlock[];\n isError?: boolean;\n structuredContent?: TStructured;\n [key: string]: unknown;\n};";
|
|
186
|
+
interface RenderDeclarationsOptions {
|
|
187
|
+
tools?: readonly CodemodeTool[];
|
|
188
|
+
globals?: readonly CodemodeTool[];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Render TypeScript declarations for the script-visible API. Tools become members of
|
|
192
|
+
* `declare const tools`, globals become `declare function` statements, and `ns.member` globals
|
|
193
|
+
* members of `declare const ns`. Descriptions become doc comments; schemas become types.
|
|
194
|
+
*/
|
|
195
|
+
declare function renderDeclarations(options: RenderDeclarationsOptions): string;
|
|
196
|
+
/**
|
|
197
|
+
* One tool as a member of the `tools` object: `name(args: T): Promise<R>;` with the
|
|
198
|
+
* name as the identifier scripts use. Input types longer than `inputMaxChars` render as `unknown`.
|
|
199
|
+
* Tools whose output schema is an MCP `CallToolResult` render as `Promise<CallToolResult<T>>`,
|
|
200
|
+
* which needs {@link MCP_TYPESCRIPT_PREAMBLE}.
|
|
201
|
+
*/
|
|
202
|
+
declare function renderToolSignature(tool: Pick<CodemodeTool, 'name' | 'inputSchema' | 'outputSchema'>, options?: {
|
|
203
|
+
inputMaxChars?: number;
|
|
204
|
+
}): string;
|
|
205
|
+
/**
|
|
206
|
+
* A tool's sample: the description followed by the tool's declaration. Used for tool
|
|
207
|
+
* listings and `ALL_TOOLS` entries.
|
|
208
|
+
*/
|
|
209
|
+
declare function renderToolSample(tool: Pick<CodemodeTool, 'name' | 'description' | 'inputSchema' | 'outputSchema'>, options?: {
|
|
210
|
+
inputMaxChars?: number;
|
|
211
|
+
}): string;
|
|
212
|
+
/**
|
|
213
|
+
* The `structuredContent` schema of an MCP `CallToolResult` output schema (detected by a
|
|
214
|
+
* `content` array of objects, boolean `isError`, and object `_meta`), `true` when it declares none, or
|
|
215
|
+
* `undefined` when the schema is not a `CallToolResult`.
|
|
216
|
+
*/
|
|
217
|
+
declare function mcpStructuredContentSchema(schema: CodemodeJsonSchema | undefined): CodemodeJsonSchema | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* The type a tool call resolves to: `CallToolResult<T>` for MCP output schemas (needs
|
|
220
|
+
* {@link MCP_TYPESCRIPT_PREAMBLE}), the schema's type otherwise, and `unknown` without a schema.
|
|
221
|
+
*/
|
|
222
|
+
declare function renderToolOutputType(schema: CodemodeJsonSchema | undefined): string;
|
|
223
|
+
/**
|
|
224
|
+
* Convert a JSON Schema to a TypeScript type expression: objects on one line (`{ a: string; b?: number; }`) with properties sorted by name,
|
|
225
|
+
* or one property per line with `//` comments when a property has a description; `Array<T>` for
|
|
226
|
+
* arrays. Local references (`#/$defs/...`, `#/definitions/...`) resolve against `schema`;
|
|
227
|
+
* recursive and remote references render as `unknown`. A result longer than `maxChars` renders as
|
|
228
|
+
* `unknown`.
|
|
229
|
+
*/
|
|
230
|
+
declare function schemaToType(schema: CodemodeJsonSchema, options?: {
|
|
231
|
+
maxChars?: number;
|
|
232
|
+
}): string;
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/codemode/runtime/host.d.ts
|
|
235
|
+
/**
|
|
236
|
+
* Runs JavaScript in a QuickJS VM (a separate wasm instance) inside a worker
|
|
237
|
+
* thread. The script sees `tools.<name>(args)` for every registered tool, `ALL_TOOLS`,
|
|
238
|
+
* the output helpers `text`, `image`, `exit`, and `console.*`, `store`/`load`, and the
|
|
239
|
+
* configured globals; nothing else (no timers, `fetch`, `process`, `require`, modules).
|
|
240
|
+
*
|
|
241
|
+
* Each `execute()` gets its own worker and VM; the sandbox only holds the tool
|
|
242
|
+
* table and defaults. `close()` aborts in-flight executions.
|
|
243
|
+
*/
|
|
244
|
+
declare class CodemodeSandbox {
|
|
245
|
+
private readonly toolsByName;
|
|
246
|
+
private readonly globalsByName;
|
|
247
|
+
private readonly timeoutMs;
|
|
248
|
+
private readonly memoryLimitBytes;
|
|
249
|
+
private readonly wasm;
|
|
250
|
+
private readonly workerUrl;
|
|
251
|
+
private readonly running;
|
|
252
|
+
private closed;
|
|
253
|
+
constructor(options?: CodemodeSandboxOptions);
|
|
254
|
+
/** Throws if a tool with the same name is already registered. */
|
|
255
|
+
registerTool(tool: CodemodeTool): void;
|
|
256
|
+
unregisterTool(name: string): boolean;
|
|
257
|
+
get tools(): CodemodeTool[];
|
|
258
|
+
get globals(): CodemodeTool[];
|
|
259
|
+
/**
|
|
260
|
+
* `code` is an async function body: `return` and top-level `await` work.
|
|
261
|
+
* Never rejects for script failures; those come back as `{ ok: false }`.
|
|
262
|
+
* The script can use `store(key, value)` and `load(key)` on `options.store`.
|
|
263
|
+
*/
|
|
264
|
+
execute(code: string, options?: CodemodeExecuteOptions): Promise<CodemodeResult>;
|
|
265
|
+
/** Aborts in-flight executions (they resolve with `kind: "aborted"`) and rejects new ones. */
|
|
266
|
+
close(): Promise<void>;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/codemode/runtime/prelude.d.ts
|
|
270
|
+
/**
|
|
271
|
+
* JavaScript evaluated inside the QuickJS VM before the script runs.
|
|
272
|
+
*
|
|
273
|
+
* The VM is its own wasm instance, so nothing here guards a realm boundary.
|
|
274
|
+
* The prelude keeps the host bridge in a closure so the script cannot call it
|
|
275
|
+
* directly, and builds `tools`, `ALL_TOOLS`, the output helpers (`text`, `image`,
|
|
276
|
+
* `exit`, `console`), and globals on top of it. Tool arguments and results cross
|
|
277
|
+
* as JSON strings and are parsed on this side.
|
|
278
|
+
*
|
|
279
|
+
* Output helpers: `text(value)` appends a text item (non-strings are
|
|
280
|
+
* JSON-stringified), `image(urlOrItem)` appends an image from a base64 `data:` URL, an
|
|
281
|
+
* `{ image_url }` object, or an MCP `ImageContent` block, and `exit()` ends the script
|
|
282
|
+
* successfully. `console.*` appends text items marked as console output.
|
|
283
|
+
*
|
|
284
|
+
* `store(key, value)` and `load(key)` are synchronous: they work on a snapshot of
|
|
285
|
+
* JSON text passed in as `storeJson`, and the keys the script wrote are reported
|
|
286
|
+
* with a successful "done".
|
|
287
|
+
*
|
|
288
|
+
* Evaluates to a function `(bridge, toolsJson, globalsJson, storeJson) => { settle, run, stalled }`.
|
|
289
|
+
* `toolsJson` lists `{ name, jsName, description }`: `tools[jsName]` and `tools[name]` call the
|
|
290
|
+
* tool, and `ALL_TOOLS` lists `{ name: jsName, description }`.
|
|
291
|
+
* `stalled()` reports a script that has not finished while no host call is pending: with no timers
|
|
292
|
+
* or I/O in the VM, nothing can ever resume it.
|
|
293
|
+
* `globalsJson` lists `{ name, spread }`; `a.b` names are grouped into a frozen `a` object.
|
|
294
|
+
* `bridge(kind, a, b, c)` with kind "call" or "global" (id, name, argsJson),
|
|
295
|
+
* "output" ("text" or "console", text) or ("image", data, mimeType), or "done" (ok, valueJsonOrErrorJson, writesJson).
|
|
296
|
+
*
|
|
297
|
+
* Calls get ids from one counter shared by tools and globals, in issue order: the host exposes
|
|
298
|
+
* them as `CodemodeToolContext.seq`.
|
|
299
|
+
*
|
|
300
|
+
* Before anything else the prelude freezes the built-ins and makes the built-in globals read-only.
|
|
301
|
+
* The prelude shares them with the script, so a script that patched one (for example
|
|
302
|
+
* `Array.prototype.toJSON`) could otherwise corrupt what the prelude reports to the host.
|
|
303
|
+
*/
|
|
304
|
+
declare const MAX_STORE_VALUE_CHARS: number;
|
|
305
|
+
declare const MAX_STORE_TOTAL_CHARS: number;
|
|
306
|
+
/**
|
|
307
|
+
* Output one script may produce with `text()`, `image()`, and `console.*`: characters of text and
|
|
308
|
+
* base64 image data, and items. The host keeps all output until the script ends, so without a
|
|
309
|
+
* limit a script that prints in a loop grows the host's memory until it crashes. The item limit
|
|
310
|
+
* covers loops that print empty strings.
|
|
311
|
+
*/
|
|
312
|
+
declare const MAX_OUTPUT_CHARS: number;
|
|
313
|
+
declare const MAX_OUTPUT_ITEMS = 100000;
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/codemode/source.d.ts
|
|
316
|
+
/**
|
|
317
|
+
* Codemode source format: JavaScript, optionally preceded by one options line.
|
|
318
|
+
*
|
|
319
|
+
* ```js
|
|
320
|
+
* // @options: {"max_output_tokens": 2000, "timeout_ms": 30000}
|
|
321
|
+
* const text = await tools.read_file({ path: "package.json" });
|
|
322
|
+
* text(JSON.parse(text).name);
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
declare const CODEMODE_OPTIONS_PREFIX = "// @options:";
|
|
326
|
+
/**
|
|
327
|
+
* Lark grammar for providers with grammar-constrained tool input. It only fixes the shape of the
|
|
328
|
+
* options line; the options JSON and the code are checked by {@link parseCodemodeSource}.
|
|
329
|
+
*/
|
|
330
|
+
declare const CODEMODE_SOURCE_GRAMMAR: string;
|
|
331
|
+
interface CodemodeSourceOptions {
|
|
332
|
+
/** Token budget for the script's output. */
|
|
333
|
+
maxOutputTokens?: number;
|
|
334
|
+
/** Hard deadline for the whole script in milliseconds, including tool calls. */
|
|
335
|
+
timeoutMs?: number;
|
|
336
|
+
}
|
|
337
|
+
interface ParsedCodemodeSource {
|
|
338
|
+
/** The script with the options line replaced by an empty line, so line numbers are unchanged. */
|
|
339
|
+
code: string;
|
|
340
|
+
options: CodemodeSourceOptions;
|
|
341
|
+
}
|
|
342
|
+
declare class CodemodeSourceError extends Error {
|
|
343
|
+
constructor(message: string);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Split an optional first-line `// @options: {...}` from the script. Throws
|
|
347
|
+
* {@link CodemodeSourceError} for empty input and invalid options.
|
|
348
|
+
*/
|
|
349
|
+
declare function parseCodemodeSource(input: string): ParsedCodemodeSource;
|
|
350
|
+
//#endregion
|
|
351
|
+
export { CODEMODE_OPTIONS_PREFIX, CODEMODE_SOURCE_GRAMMAR, type CodemodeCall, type CodemodeCallStatus, type CodemodeDeterminism, type CodemodeError, type CodemodeErrorKind, type CodemodeExecuteOptions, type CodemodeJsonSchema, type CodemodeOutputItem, type CodemodeResult, CodemodeSandbox, type CodemodeSandboxOptions, CodemodeSourceError, type CodemodeSourceOptions, type CodemodeStoreWrites, type CodemodeTool, type CodemodeToolContext, type CodemodeWasmModule, DEFAULT_INPUT_SCHEMA_MAX_CHARS, MAX_OUTPUT_CHARS, MAX_OUTPUT_ITEMS, MAX_STORE_TOTAL_CHARS, MAX_STORE_VALUE_CHARS, MCP_TYPESCRIPT_PREAMBLE, type ParsedCodemodeSource, type RenderDeclarationsOptions, loadQuickJSWasm, mcpStructuredContentSchema, parseCodemodeSource, renderDeclarations, renderToolOutputType, renderToolSample, renderToolSignature, schemaToType, toCodemodeIdentifier };
|
|
352
|
+
//# sourceMappingURL=codemode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemode.d.ts","names":[],"sources":["../src/codemode/wasm.ts","../src/codemode/types.ts","../src/codemode/identifier.ts","../src/codemode/declarations.ts","../src/codemode/runtime/host.ts","../src/codemode/runtime/prelude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SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC/YJ;cACA;;;;;;;cAOA;cACA;;;;;;;;;;;;cCnCA;;;;;cAWA;UAUI;;EAEf;;EAEA;;UAGe;;EAEf;EACA,SAAS;;cAGE,4BAA4B;EAC3B,YAAA;;;;;;iBAgDE,oBAAoB,gBAAgB"}
|
package/dist/codemode.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as DEFAULT_INPUT_SCHEMA_MAX_CHARS, c as renderDeclarations, d as renderToolSignature, f as schemaToType, i as parseCodemodeSource, l as renderToolOutputType, n as CODEMODE_SOURCE_GRAMMAR, o as MCP_TYPESCRIPT_PREAMBLE, p as toCodemodeIdentifier, r as CodemodeSourceError, s as mcpStructuredContentSchema, t as CODEMODE_OPTIONS_PREFIX, u as renderToolSample } from "./source-mPExaUm8.js";
|
|
2
|
+
import { t as loadQuickJSWasm } from "./wasm-BVT-j5cl.js";
|
|
3
|
+
import { t as CodemodeSandbox } from "./host-D7NrI03V.js";
|
|
4
|
+
import { i as MAX_STORE_VALUE_CHARS, n as MAX_OUTPUT_ITEMS, r as MAX_STORE_TOTAL_CHARS, t as MAX_OUTPUT_CHARS } from "./prelude-Cxo4t74B.js";
|
|
5
|
+
export { CODEMODE_OPTIONS_PREFIX, CODEMODE_SOURCE_GRAMMAR, CodemodeSandbox, CodemodeSourceError, DEFAULT_INPUT_SCHEMA_MAX_CHARS, MAX_OUTPUT_CHARS, MAX_OUTPUT_ITEMS, MAX_STORE_TOTAL_CHARS, MAX_STORE_VALUE_CHARS, MCP_TYPESCRIPT_PREAMBLE, loadQuickJSWasm, mcpStructuredContentSchema, parseCodemodeSource, renderDeclarations, renderToolOutputType, renderToolSample, renderToolSignature, schemaToType, toCodemodeIdentifier };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/chat/hosts/connection.d.ts
|
|
2
|
+
/** This computer's key in every host directory (the in-process host, the embedded one, or the daemon). */
|
|
3
|
+
declare const LOCAL_HOST_KEY = "local";
|
|
4
|
+
/** This computer's label in lists and pickers. */
|
|
5
|
+
declare const LOCAL_HOST_NAME = "This computer";
|
|
6
|
+
/**
|
|
7
|
+
* `auth-refused`: the server turned the token down (401/403); `identity`: a
|
|
8
|
+
* different server answers at a saved host's URL. Neither retries until
|
|
9
|
+
* something changes.
|
|
10
|
+
*/
|
|
11
|
+
type HostConnectionStatus = 'connecting' | 'connected' | 'reconnecting' | 'offline' | 'auth-refused' | 'identity';
|
|
12
|
+
/**
|
|
13
|
+
* A saved host's URL answered with another host id (reinstalled, or the
|
|
14
|
+
* name now points elsewhere). The connection is closed before anything is
|
|
15
|
+
* read from it, and nothing is recorded under the saved id.
|
|
16
|
+
*/
|
|
17
|
+
declare class HostIdentityError extends Error {
|
|
18
|
+
readonly url: string;
|
|
19
|
+
readonly answeredBy?: string | undefined;
|
|
20
|
+
constructor(url: string, answeredBy?: string | undefined);
|
|
21
|
+
}
|
|
22
|
+
/** JSON-RPC "method not found": the host predates an additive method. */
|
|
23
|
+
declare const METHOD_NOT_FOUND: number;
|
|
24
|
+
/** The host predates the method (`models.list`, `catalog.*`, …): callers degrade, never fail. */
|
|
25
|
+
declare function isMethodNotFound(err: unknown): boolean;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { METHOD_NOT_FOUND as a, LOCAL_HOST_NAME as i, HostIdentityError as n, isMethodNotFound as o, LOCAL_HOST_KEY as r, HostConnectionStatus as t };
|
|
28
|
+
//# sourceMappingURL=connection-Dr-Js4yZ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-Dr-Js4yZ.d.ts","names":[],"sources":["../src/chat/hosts/connection.ts"],"mappings":";;cAQa;;cAGA;;;;;;KAOD;;;;;;cAOC,0BAA0B;WAChB;WAAsB;EAAtB,YAAA,aAAsB;;;cAOhC;;iBAGG,iBAAiB"}
|