limixbot 0.3.50 → 0.3.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-BwDOVD9j.js → ActivityPanel-DoWrjUz7.js} +1 -1
- package/dist/assets/App-DmJM-bVw.js +243 -0
- package/dist/assets/{AppEventEditor-zUBmRtgm.js → AppEventEditor-emHq_cA0.js} +1 -1
- package/dist/assets/BotSettingsDialog-BshbTnT_.js +16 -0
- package/dist/assets/{BrowserPanel-B5vUqP5d.js → BrowserPanel-PLHN7znJ.js} +2 -2
- package/dist/assets/{BrowserProfilesManager-DF3iHV1l.js → BrowserProfilesManager-ChG7MrYQ.js} +1 -1
- package/dist/assets/CloudAddDialog-CyKmG4VN.js +1 -0
- package/dist/assets/ComputerFilesPane-BPu6_l8N.js +1 -0
- package/dist/assets/{ComputerPanel-o_9TTtVS.js → ComputerPanel-Df-QaAS2.js} +2 -2
- package/dist/assets/{DataPanel-D6Yq58K8.js → DataPanel-QSdW8P4h.js} +1 -1
- package/dist/assets/{DesktopViewer-DFhYwHIq.js → DesktopViewer-Du64Zar0.js} +1 -1
- package/dist/assets/{FilesView-DIY7IawO.js → FilesView-0Ijtj6CN.js} +1 -1
- package/dist/assets/{GrokMoveDialog-yVqkaGh0.js → GrokMoveDialog-BVG5-cPU.js} +1 -1
- package/dist/assets/{InspectorPanel-DZmieMQG.js → InspectorPanel-CtBr7aZo.js} +2 -2
- package/dist/assets/{KeyboardShortcutsModal-S5e-EG9u.js → KeyboardShortcutsModal-Co3LHjUp.js} +1 -1
- package/dist/assets/{LimixChannelReview-CrGNdtS-.js → LimixChannelReview-LNSDJ-cn.js} +1 -1
- package/dist/assets/{LiveDesktop-H2irpbo4.js → LiveDesktop-DPs1lypu.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-5beJanrU.js → LocalVmWorkspace-Bf2EXh1s.js} +1 -1
- package/dist/assets/{MacLocalControl-D5PKKnuP.js → MacLocalControl-BGeq2FOD.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CKcwA3Cw.js → MarkdownFilePreview-BDNgFKxV.js} +1 -1
- package/dist/assets/{MenuMotion-CtV49YrJ.js → MenuMotion-DFWzLAOE.js} +1 -1
- package/dist/assets/{NewBotDialog-Cna8-DSW.js → NewBotDialog-itNxT2iU.js} +1 -1
- package/dist/assets/{PhoneAppDialog-Dtkpl1Hc.js → PhoneAppDialog-CMtCT9Xu.js} +1 -1
- package/dist/assets/PlacesRail-i-4ph-KR.js +1 -0
- package/dist/assets/{PluginsPanel-LvPKdxpW.js → PluginsPanel-49ZWw79q.js} +2 -2
- package/dist/assets/ProIntroduction-CyKL7OF8.js +1 -0
- package/dist/assets/{RemoteAgentSettingsPanel-BIqx787N.js → RemoteAgentSettingsPanel-Bbp1t8mD.js} +1 -1
- package/dist/assets/{RoomPanel-CJTHUkDN.js → RoomPanel-Gw0rFOk7.js} +1 -1
- package/dist/assets/{RoutinesPage-C8QjVdJH.js → RoutinesPage-Bo4NVg7D.js} +2 -2
- package/dist/assets/SettingsModal-D4XZMVXS.js +19 -0
- package/dist/assets/{ShareTeamDialog-DLKGTkzv.js → ShareTeamDialog-CeT0rE7W.js} +1 -1
- package/dist/assets/{SignedInSites-Ccr7Us46.js → SignedInSites-BGpe1m04.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-DWkmvSW0.js → TeamLibraryPanel-SJebr72G.js} +1 -1
- package/dist/assets/{TeamMapPage-BjPonu5A.js → TeamMapPage-DIiHaEPP.js} +1 -1
- package/dist/assets/{TriggersPage-BE8reM-u.js → TriggersPage-Dz_RBgRC.js} +1 -1
- package/dist/assets/VisibilitySection-BLgOrAop.js +22 -0
- package/dist/assets/{WebhookTrigger-BOsrYQH6.js → WebhookTrigger-Cw7eIur5.js} +1 -1
- package/dist/assets/{WorksOnGrid-D204I3p5.js → WorksOnGrid-DJiQ_gRM.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-DmWI1Mtg.js → abnfDiagram-YUKMZFIV-CAhmS2rs.js} +1 -1
- package/dist/assets/{activity-WfPBvs3Z.js → activity-Bi0tXcsw.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-rzc3-Q0w.js → architectureDiagram-47P4ROYG-B6w0Yu0g.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-VPDyKlQ7.js → blockDiagram-E7TT5TSB-BYtaJu6s.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-C9OGckku.js → c4Diagram-CRA5TL53-B_FsOyDV.js} +1 -1
- package/dist/assets/{calendar-days-W4JHp6-m.js → calendar-days-B8SfZLZO.js} +1 -1
- package/dist/assets/channel-DVwNbGUM.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-EpYkwMC8.js → chunk-2Q5K7J3B-BdKiuWEd.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-DyJEI8X6.js → chunk-5VM5RSS4-CgItQr02.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-CJvVxQ2I.js → chunk-7TKQ45FW-BFsWqiRT.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-s78zNrhy.js → chunk-AW2ZBBNX-Cnj5ddTo.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-CUPjaz9e.js → chunk-FVRAUYC3-BCqqreNP.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-BhuM2dxl.js → chunk-HTAEGDNF-BOE8LQps.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-DAj1UgJ8.js → chunk-JWPE2WC7-DhA4nyzx.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-BgfdtkJI.js → chunk-KQW6MTUR-DzXl5ZXS.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Vak43p0S.js → chunk-XXDRQBXY-C6tPSut7.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-Cjvbs86l.js → classDiagram-v2-K4WV4PDN-DQW9NJQl.js} +1 -1
- package/dist/assets/{core-D5ZIkAZ3.js → core-B3WlSEbe.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BEekB3gO.js → cose-bilkent-JH36ORCC-6jNO5GSL.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-D3g3_jPk.js → cynefin-EF2NZ3EQ-mnQt4_3K.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-13xmjXZj.js → cynefinDiagram-3GCD6N5R-DoEMDFuf.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-CHAV8s2t.js → dagre-W4DXFKR2-DoKMCbtK.js} +1 -1
- package/dist/assets/de-C8GllVmL.js +8 -0
- package/dist/assets/{diagram-2UJZ2QOL-DgwdzZN7.js → diagram-2UJZ2QOL-dVwBPQ-y.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-DobmWwa_.js → diagram-OVF4WLC6-xIwVUznT.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-CWjTVc0N.js → diagram-PFPMY2P6-DAkRkPXu.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-CAruZkhk.js → diagram-UMYRVEAY-YE49n-np.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-Bcs89mQN.js → diagram-YEKJPTXX-DQkmy5qU.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-Dz-O18tl.js → diagram-ZIFT7M5P-u9Uj06_B.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-CJX4rMIs.js → ebnfDiagram-VR2GEFS7-DoxIDWDW.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-Byop6FtW.js → elk-IJKZMXRS-DPDeQQIg.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-ChpLnNCF.js → erDiagram-O2IAPWRE-BHdTvU5H.js} +1 -1
- package/dist/assets/{file-up-G3qWGpEB.js → file-up-BkYyRMzo.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-CWWhkNOE.js → flowDiagram-OXPTDLAJ-ChNmwKMG.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-DMXicWgq.js → ganttDiagram-R7TSEDQI-3Sx3AKf_.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-CpiCnPUQ.js → gitGraphDiagram-XJZIOB7I-C67fsohV.js} +1 -1
- package/dist/assets/{import-name-Cjp7lk7e.js → import-name-zOg5ckYf.js} +1 -1
- package/dist/assets/index-DhTEAf1-.js +3 -0
- package/dist/assets/{index-CZvRt7dv.js → index-Uvk6r9xX.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-BU9zbv9f.js → infoDiagram-5W2HQ5XZ-CBtxWn_a.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-KEjUVvmG.js → ishikawaDiagram-K3B6WC7H-B0368JQ8.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-DGU1V_40.js → journeyDiagram-COXZFDF6-BlyoIOJv.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-weJ2OFB2.js → kanban-definition-P3RFRI5V-Cn5CUDI2.js} +1 -1
- package/dist/assets/{mcp-servers-_vV_C1no.js → mcp-servers-BffOs9kX.js} +1 -1
- package/dist/assets/{mermaid.core-DhSRukyE.js → mermaid.core-BitzuZjJ.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-DKKO0DWj.js → mindmap-definition-LZFPQGKD-Jg9lbPrn.js} +1 -1
- package/dist/assets/{minimize-C16JX5N8.js → minimize-CIbeUlkc.js} +1 -1
- package/dist/assets/{monitor-Bben4nuu.js → monitor-CQgH3Q9j.js} +1 -1
- package/dist/assets/{new-bot-DwK47ypo.js → new-bot-D75cIR6C.js} +2 -2
- package/dist/assets/org-library-pEzmTM3q.js +1 -0
- package/dist/assets/{package-format-CmRh54Ve.js → package-format-C8RU0HIi.js} +2 -2
- package/dist/assets/{pegDiagram-BGZESJAR-CNNprTkt.js → pegDiagram-BGZESJAR-CnAlnJHt.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-pS8U8zdK.js → pieDiagram-CAPJLFHJ-DaL17-zU.js} +1 -1
- package/dist/assets/pt-br-DiNqB940.js +13 -0
- package/dist/assets/{quadrantDiagram-GDMTTRAM-CLk_fr2j.js → quadrantDiagram-GDMTTRAM-BJHzyXHs.js} +1 -1
- package/dist/assets/rail-BDfsZpav.js +1 -0
- package/dist/assets/{railroadDiagram-SM67HX2B-DH8VPMJG.js → railroadDiagram-SM67HX2B-Cw9re6eo.js} +1 -1
- package/dist/assets/{remote-desktop-panel-C_EqBmng.js → remote-desktop-panel-BI4lP7pc.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-CoHRI7dx.js → requirementDiagram-X7JNWC4A-Cd7X7PJA.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-2zcVfvWw.js → sankeyDiagram-UM26HJRW-nufeOHip.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B0d21eid.js → sequenceDiagram-ZO4K6R2Y-CMZoHw7j.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CcYkvoh7.js → sizeCapture-INFHLROL-DPZOqMVW.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-B5EilR72.js → stateDiagram-v2-TBUQTH76-BpWOIyFw.js} +1 -1
- package/dist/assets/styles-BvB4UlHn.js +79 -0
- package/dist/assets/styles-Ce5Qc_2r.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-xM7mNll9.js → swimlanes-N4OXWK64-BNx8ZaTX.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-BO73RuC_.js +8 -0
- package/dist/assets/{team-share-Bp69YR8I.js → team-share-CNY994iy.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-DM6SmhCQ.js → timeline-definition-YOQAKGHF-L78B2xWx.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-DiUdGN3G.js → usecaseDiagram-VIAY4XPW-gU5zWpPp.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-DrtmNBp4.js → vennDiagram-BLWOH2XV-pdiz8880.js} +1 -1
- package/dist/assets/vi-Cbg_srO_.js +15 -0
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-D7jihWm5.js → wardleyDiagram-YMQ3BMBF-F-D92MhK.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-BCk-D9Uj.js → xychartDiagram-TAQBALBS-DKMdsWWR.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/bot-box/box-check.js +10 -10
- package/dist-server/cloud-home-start.js +5 -5
- package/dist-server/container-mcp.js +2 -2
- package/dist-server/drivers/agents-proxy.js +128 -126
- package/dist-server/index.js +8256 -7937
- package/dist-server/mcp-gate.js +18 -17
- package/dist-server/openmausbot.js +1190 -1156
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +1065 -1034
- package/dist-server/server/activity.js +1 -0
- package/dist-server/server/agents-turn.js +2 -1
- package/dist-server/server/app-settings/host.js +187 -0
- package/dist-server/server/app-settings/picture-file.js +62 -0
- package/dist-server/server/app-settings/registry-bots.js +147 -0
- package/dist-server/server/app-settings/registry-config.js +190 -0
- package/dist-server/server/app-settings/registry-pictures.js +59 -0
- package/dist-server/server/app-settings/registry-window.js +35 -0
- package/dist-server/server/app-settings/registry.js +287 -0
- package/dist-server/server/attachments.js +16 -12
- package/dist-server/server/automation-reports.js +11 -1
- package/dist-server/server/bot-attachment.js +34 -10
- package/dist-server/server/bot-box/env.js +2 -2
- package/dist-server/server/bot-box/plan.js +1 -1
- package/dist-server/server/cloud-home-start.js +2 -0
- package/dist-server/server/config.js +1 -0
- package/dist-server/server/drivers/acp/client-path.js +39 -0
- package/dist-server/server/drivers/acp/core.js +9 -37
- package/dist-server/server/drivers/agents-app-settings-tool.js +22 -0
- package/dist-server/server/drivers/agents-call.js +8 -3
- package/dist-server/server/drivers/agents-catalog-profile.js +2 -1
- package/dist-server/server/drivers/agents-catalog.js +19 -2
- package/dist-server/server/drivers/agents-claude-defer.js +38 -0
- package/dist-server/server/drivers/agents-mcp-env.js +2 -2
- package/dist-server/server/drivers/agents-mcp.js +2 -1
- package/dist-server/server/drivers/agents-proxy.js +0 -1
- package/dist-server/server/drivers/agents-tool-groups.js +45 -0
- package/dist-server/server/drivers/antigravity-acp.js +6 -2
- package/dist-server/server/drivers/antigravity-skills.js +107 -0
- package/dist-server/server/drivers/antigravity.js +9 -1
- package/dist-server/server/drivers/claude-bot-settings.js +22 -1
- package/dist-server/server/drivers/claude-tool-search.js +20 -2
- package/dist-server/server/drivers/claude.js +12 -12
- package/dist-server/server/drivers/codex.js +4 -1
- package/dist-server/server/drivers/ollama-context.js +5 -2
- package/dist-server/server/drivers/openai-chat.js +10 -10
- package/dist-server/server/drivers/retry.js +3 -2
- package/dist-server/server/email/host.js +6 -2
- package/dist-server/server/engine-handshake.js +1 -0
- package/dist-server/server/generated-image.js +1 -1
- package/dist-server/server/host/bot-holds.js +76 -0
- package/dist-server/server/host/fill-login-turn.js +2 -2
- package/dist-server/server/host/handoff-limits.js +30 -0
- package/dist-server/server/host/limit-takeover.js +11 -0
- package/dist-server/server/host/peer-limit-resend.js +147 -0
- package/dist-server/server/host/skills-library.js +15 -1
- package/dist-server/server/host/trust-answers.js +42 -0
- package/dist-server/server/imported-skills.js +15 -4
- package/dist-server/server/index.js +109 -125
- package/dist-server/server/limit-poll.js +32 -0
- package/dist-server/server/limit-reset-owed.js +15 -0
- package/dist-server/server/limit-resets.js +33 -8
- package/dist-server/server/login-fill.js +37 -9
- package/dist-server/server/mcp-gate-config.js +28 -0
- package/dist-server/server/mcp-gate.js +8 -2
- package/dist-server/server/message-file.js +10 -1
- package/dist-server/server/quota-switch.js +7 -5
- package/dist-server/server/replies.js +1 -1
- package/dist-server/server/request-auth.js +7 -4
- package/dist-server/server/routes/app-settings.js +46 -0
- package/dist-server/server/routes/bot-holds.js +24 -0
- package/dist-server/server/routes/bot-patch.js +7 -0
- package/dist-server/server/routes/call-route.js +16 -0
- package/dist-server/server/routes/channels.js +45 -38
- package/dist-server/server/routes/custom-domain.js +36 -0
- package/dist-server/server/routes/sidebar-sections.js +1 -0
- package/dist-server/server/routes/threads.js +1 -1
- package/dist-server/server/routine-lines.js +25 -0
- package/dist-server/server/routines.js +9 -5
- package/dist-server/server/runtime/envelope.js +3 -0
- package/dist-server/server/runtime/store.js +1 -0
- package/dist-server/server/send-idempotency.js +43 -0
- package/dist-server/server/shared-computers.js +35 -6
- package/dist-server/server/themes/history.js +54 -0
- package/dist-server/server/themes/routes.js +136 -0
- package/dist-server/server/themes/store.js +266 -0
- package/dist-server/server/themes/tool.js +151 -0
- package/dist-server/server/tool-groups.js +12 -0
- package/dist-server/server/turn-continuation.js +6 -6
- package/dist-server/shared/app-settings.js +60 -0
- package/dist-server/shared/bot-limit.js +2 -0
- package/dist-server/shared/plain-preview.js +3 -2
- package/dist-server/shared/theme.js +240 -0
- package/dist-server/shared/tool-groups.js +27 -0
- package/dist-server/src/lib/composer-attachments.js +22 -6
- package/dist-server/vps-container-mcp.js +12 -12
- package/dist-server/workspace-backup.worker.js +2 -2
- package/package.json +1 -1
- package/dist/assets/App-CGZnP4z7.js +0 -243
- package/dist/assets/BotSettingsDialog-DTFwZfbQ.js +0 -16
- package/dist/assets/CloudAddDialog-Bi9x2OVN.js +0 -1
- package/dist/assets/ComputerFilesPane-DXb-rVT_.js +0 -1
- package/dist/assets/PlacesRail-COZEZH0n.js +0 -57
- package/dist/assets/ProIntroduction-Cjw1BiAB.js +0 -1
- package/dist/assets/SettingsModal-D3I1whQj.js +0 -19
- package/dist/assets/VisibilitySection-diCNRN7h.js +0 -22
- package/dist/assets/channel-DAFePtOr.js +0 -1
- package/dist/assets/de-CJcRve_J.js +0 -8
- package/dist/assets/index-CSGTkyGn.js +0 -2
- package/dist/assets/org-library-BXuxCBsG.js +0 -1
- package/dist/assets/pt-br-Dr9a700a.js +0 -13
- package/dist/assets/rail-CpM5o3ti.js +0 -1
- package/dist/assets/styles-Cbtcp5Re.js +0 -23
- package/dist/assets/styles-rYmbSF4Y.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-CnVwW_RC.js +0 -8
- package/dist/assets/vi-vTat5qyz.js +0 -15
- package/dist-server/server/limix-managed-grant.js +0 -110
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { credentialIsConfigured, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS } from "../../shared/credential-request.js";
|
|
3
|
+
import { WINDOW_PREFS } from "../../shared/app-settings.js";
|
|
4
|
+
import { defaultBotThreads, MAX_CONCURRENT_BOT_THREADS } from "../bot-thread-limits.js";
|
|
5
|
+
import { isClaudeBedrock } from "../claude-bedrock.js";
|
|
6
|
+
import { isClaudeEndpoint } from "../claude-endpoints.js";
|
|
7
|
+
import { isCodexEndpoint } from "../codex-endpoints.js";
|
|
8
|
+
import { MAX_MCP_CALL_TIMEOUT_MINUTES, MAX_ROOM_TURN_TIMEOUT_MINUTES, mcpCallTimeoutMinutes, MIN_MCP_CALL_TIMEOUT_MINUTES, MIN_ROOM_TURN_TIMEOUT_MINUTES, persistableInstanceConfigs, roomTurnTimeoutMinutes } from "../config.js";
|
|
9
|
+
import { BUILT_IN_DRIVERS } from "../drivers/builtIn.js";
|
|
10
|
+
import { endpointDisplayUrl, isAddedEndpoint } from "../openai-compat-endpoints.js";
|
|
11
|
+
import { callRoute } from "../routes/call-route.js";
|
|
12
|
+
import { botEntries } from "./registry-bots.js";
|
|
13
|
+
import { configEntries } from "./registry-config.js";
|
|
14
|
+
import { pictureEntries } from "./registry-pictures.js";
|
|
15
|
+
import { windowEntries } from "./registry-window.js";
|
|
16
|
+
/** A setting's value for a person or bot; empty when unset, so each edge can say "not set" in its own words. */
|
|
17
|
+
export const display = (value) => (value === undefined || value === null || value === "" ? "" : typeof value === "string" ? value : JSON.stringify(value));
|
|
18
|
+
const url = z.string().trim().max(2048).refine((text) => text === "" || /^https?:\/\/\S+$/.test(text), "an http(s) address, or empty to clear");
|
|
19
|
+
const KEY_WHERE = {
|
|
20
|
+
ttsKey: "Settings → General", geminiTtsKey: "Settings → General", fishAudioKey: "Settings → General",
|
|
21
|
+
onePasswordToken: "Settings → Vault", boxToken: "Settings → Desktops & browser", composioApiKey: "Settings → AI",
|
|
22
|
+
};
|
|
23
|
+
/** One plain line for a change only the person makes, in Settings. */
|
|
24
|
+
export const personOnly = (what, where) => `${what} is changed only by the person, in ${where}. Tell them where in one line; do not try another way.`;
|
|
25
|
+
/** Security: a key never passes through the bot. A value naming a key, token, secret or password field is refused at
|
|
26
|
+
* the boundary; `except` lets through a field that only names a saved key. */
|
|
27
|
+
export const withoutKeys = (schema, except = []) => z.record(z.string(), z.unknown())
|
|
28
|
+
.refine((fields) => !Object.keys(fields).some((field) => !except.includes(field) && /key|token|secret|password/i.test(field)), "Never put a key or token in the value. Save it first with set on keys.<id> (a secure card asks the user), then name that id in keyFrom.")
|
|
29
|
+
// The record check above already holds an object; the schema decides its shape.
|
|
30
|
+
.pipe(schema);
|
|
31
|
+
const PROVIDER_KEY_SECTION = {
|
|
32
|
+
openaiApiKey: "openai", anthropicApiKey: "anthropic", openrouterApiKey: "openrouter", mistralApiKey: "mistral", cerebrasApiKey: "cerebras",
|
|
33
|
+
groqApiKey: "groq", greenferenceApiKey: "greenference", modelgoApiKey: "modelgo", metaApiKey: "meta", deepseekApiKey: "deepseek",
|
|
34
|
+
};
|
|
35
|
+
/** A local server takes no key; Settings sends the same stand-in for one. */
|
|
36
|
+
const LOCAL_SERVER = { ollama: { name: "Ollama", key: "ollama" }, lmstudio: { name: "LM Studio", key: "lm-studio" } };
|
|
37
|
+
const engineName = z.string().trim().min(1).max(80);
|
|
38
|
+
const engineUrl = z.string().trim().min(1).max(512);
|
|
39
|
+
/** Security: a key never passes through the bot. An engine that needs one names a key the person saved through the
|
|
40
|
+
* secure card (`keyFrom`), and the server reads it at the moment the owner taps Change. */
|
|
41
|
+
const engineChange = withoutKeys(z.discriminatedUnion("kind", [
|
|
42
|
+
z.object({ kind: z.enum(["ollama", "lmstudio"]), name: engineName.optional(), url: engineUrl }).strict(),
|
|
43
|
+
z.object({ kind: z.literal("openai-compat"), name: engineName, url: engineUrl, keyFrom: z.enum(PROVIDER_CREDENTIAL_TARGETS), models: z.array(z.string().trim().min(1).max(200)).max(64).optional() }).strict(),
|
|
44
|
+
z.object({ kind: z.literal("bedrock"), name: engineName, awsProfile: z.string().trim().min(1).max(128), awsRegion: z.string().trim().min(1).max(40), model: z.string().trim().min(1).max(160) }).strict(),
|
|
45
|
+
z.object({ kind: z.literal("remove"), instanceId: z.string().regex(/^[\w.-]{1,120}$/) }).strict(),
|
|
46
|
+
]), ["keyFrom"]);
|
|
47
|
+
/** The engines a bot may remove: added without a sign-in. Accounts and the built-in engines stay with the owner. */
|
|
48
|
+
const removableKind = (instanceId, entry) => isAddedEndpoint(instanceId, entry) ? "OpenAI-compatible server"
|
|
49
|
+
: isClaudeBedrock(entry) ? "Claude on Amazon Bedrock" : isClaudeEndpoint(entry) ? "Claude endpoint" : isCodexEndpoint(entry) ? "Codex endpoint" : null;
|
|
50
|
+
export function createSettingsRegistry(deps) {
|
|
51
|
+
const cfg = deps.cfg;
|
|
52
|
+
const names = (ids) => ids.map((id) => deps.bots().find((bot) => bot.id === id)?.name ?? id).join(", ");
|
|
53
|
+
const writable = (spec) => ({
|
|
54
|
+
...spec, tier: "safe", read: spec.read ?? (() => display(spec.current())), current: spec.current,
|
|
55
|
+
write: spec.write, ...(spec.describe ? { describe: spec.describe } : {}),
|
|
56
|
+
});
|
|
57
|
+
const config = (patch) => (value) => deps.saveConfig(patch(value));
|
|
58
|
+
const windowPref = (id, label, help, where, synonyms, allowed, line) => writable({
|
|
59
|
+
id, label, help, where, synonyms, value: WINDOW_PREFS[id], allowed,
|
|
60
|
+
current: () => deps.window.read(id), write: async (value) => deps.window.write(id, value),
|
|
61
|
+
...(line ? { describe: (value) => { const refusal = line.refusal?.(value); return refusal ? { refusal } : { change: line.says(value) }; } } : {}),
|
|
62
|
+
});
|
|
63
|
+
const enumOf = (values) => values.join(", ");
|
|
64
|
+
const pinned = () => deps.bots().filter((bot) => bot.pinned).map((bot) => bot.id);
|
|
65
|
+
const groups = () => Object.fromEntries(deps.sections().map((section) => [section, deps.bots().filter((bot) => bot.section === section).map((bot) => bot.id)]));
|
|
66
|
+
const safe = [
|
|
67
|
+
windowPref("appearance.skin", "Skin", "The window's built-in look; \"system\" follows the computer's light or dark mode. A custom look (any colours, fonts, CSS, pictures) is a theme: use action theme.", "Settings → Appearance", ["theme", "dark mode", "light mode", "colors", "look"], enumOf(WINDOW_PREFS["appearance.skin"].options)),
|
|
68
|
+
windowPref("appearance.advanced", "Advanced mode", "Advanced shows every setting and tool; Simple keeps the everyday ones.", "Settings → Appearance", ["simple mode", "advanced mode", "interface mode"], "true or false"),
|
|
69
|
+
windowPref("appearance.font", "Font", "The app's typeface.", "Settings → Appearance", ["typeface", "typography"], enumOf(WINDOW_PREFS["appearance.font"].options)),
|
|
70
|
+
windowPref("appearance.chatWidth", "Chat width", "How wide the chat column is.", "Settings → Appearance", ["layout", "column", "wide"], enumOf(WINDOW_PREFS["appearance.chatWidth"].options)),
|
|
71
|
+
windowPref("general.sendKey", "Send key", "Which key sends a message in the composer.", "Settings → General", ["enter", "typing", "keyboard", "shortcut"], enumOf(WINDOW_PREFS["general.sendKey"].options)),
|
|
72
|
+
windowPref("general.notificationSounds", "Notification sounds", "Play a sound when a bot needs you or finishes.", "Settings → General", ["sound", "sounds", "mute", "alerts", "notifications"], "true or false"),
|
|
73
|
+
writable({
|
|
74
|
+
id: "general.language", label: "Language", help: "The app's language, as a tag such as en, de or pt-br; empty follows the computer.", where: "Settings → General",
|
|
75
|
+
synonyms: ["locale", "translation"], value: z.string().trim().max(16).regex(/^[a-z]{2,3}(-[a-z0-9]{2,8})*$|^$/i, "a language tag such as en or pt-br"), allowed: "a language tag such as en, de, ja, pt-br, zh-tw; empty to follow the computer",
|
|
76
|
+
current: () => cfg().language ?? "", write: config((language) => ({ language })),
|
|
77
|
+
}),
|
|
78
|
+
writable({
|
|
79
|
+
id: "bots.order", label: "Bot order", help: "The order bots are listed in the sidebar and on phones. Send bot ids from list_bots; bots you leave out keep their places.", where: "the sidebar",
|
|
80
|
+
synonyms: ["reorder", "sidebar order", "sort bots", "move bot", "arrange"], value: z.array(z.string().regex(/^[\w-]+$/)).min(1).max(100), allowed: "an array of bot ids in the wanted order",
|
|
81
|
+
current: () => deps.bots().map((bot) => bot.id), read: () => names(deps.bots().map((bot) => bot.id)), write: (botIds) => deps.reorderBots(botIds),
|
|
82
|
+
}),
|
|
83
|
+
writable({
|
|
84
|
+
id: "bots.pinned", label: "Pinned bots", help: "Which bots are pinned to the top of the sidebar. Send every bot id that should be pinned, including ones already pinned; the rest are unpinned.", where: "the sidebar",
|
|
85
|
+
synonyms: ["pin", "pinned", "unpin", "favorite", "favourite", "top", "star"], value: z.array(z.string().regex(/^[\w-]+$/)).max(100), allowed: "an array of the bot ids to pin; an empty array unpins every bot",
|
|
86
|
+
current: pinned, read: () => names(pinned()),
|
|
87
|
+
write: async (botIds) => {
|
|
88
|
+
const unknown = botIds.find((id) => !deps.bots().some((bot) => bot.id === id));
|
|
89
|
+
if (unknown)
|
|
90
|
+
return `No bot has the id ${unknown}. Use list_bots for the ids.`;
|
|
91
|
+
for (const bot of deps.bots()) {
|
|
92
|
+
if (Boolean(bot.pinned) === botIds.includes(bot.id))
|
|
93
|
+
continue;
|
|
94
|
+
const refusal = await deps.pinBot(bot.id, botIds.includes(bot.id));
|
|
95
|
+
if (refusal)
|
|
96
|
+
return refusal;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
writable({
|
|
102
|
+
id: "bots.groups", label: "Sidebar groups", help: "Which bots sit in which sidebar group (department). Send an object of group name to bot ids; a bot in no listed group is ungrouped.", where: "the sidebar",
|
|
103
|
+
synonyms: ["group", "groups", "department", "departments", "section", "sections", "team", "folder"],
|
|
104
|
+
value: z.record(z.string().trim().min(1).max(60), z.array(z.string().regex(/^[\w-]+$/)).max(100)), allowed: "an object: group name → array of bot ids",
|
|
105
|
+
current: groups,
|
|
106
|
+
read: () => {
|
|
107
|
+
const grouped = Object.entries(groups()).map(([section, ids]) => `${section}: ${names(ids) || "(empty)"}`);
|
|
108
|
+
const loose = deps.bots().filter((bot) => !bot.section).map((bot) => bot.id);
|
|
109
|
+
return [...grouped, ...(loose.length ? [`ungrouped: ${names(loose)}`] : [])].join("; ");
|
|
110
|
+
},
|
|
111
|
+
write: async (wanted) => {
|
|
112
|
+
const listed = new Set(Object.values(wanted).flat());
|
|
113
|
+
const loosen = deps.bots().filter((bot) => bot.section && !listed.has(bot.id)).map((bot) => bot.id);
|
|
114
|
+
for (const [name, botIds] of Object.entries(wanted)) {
|
|
115
|
+
const refusal = await deps.groupBots(name, botIds);
|
|
116
|
+
if (refusal)
|
|
117
|
+
return refusal;
|
|
118
|
+
}
|
|
119
|
+
return loosen.length ? deps.groupBots("", loosen) : null;
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
writable({
|
|
123
|
+
id: "threads.maxConcurrentPerBot", label: "Threads per bot", help: "How many conversations one bot may work on at once.", where: "Settings → You and your bots",
|
|
124
|
+
synonyms: ["concurrent", "parallel", "limit", "limits", "thread limit"], value: z.number().int().min(1).max(MAX_CONCURRENT_BOT_THREADS), allowed: `1 to ${MAX_CONCURRENT_BOT_THREADS}`,
|
|
125
|
+
current: () => cfg().threads?.maxConcurrentPerBot ?? defaultBotThreads(), write: config((maxConcurrentPerBot) => ({ threads: { maxConcurrentPerBot } })),
|
|
126
|
+
}),
|
|
127
|
+
writable({
|
|
128
|
+
id: "threads.eventLogRetentionDays", label: "Thread log retention", help: "Days a closed conversation's event logs are kept; null keeps them forever.", where: "Settings → Data",
|
|
129
|
+
synonyms: ["cleanup", "clean up", "retention", "logs", "delete old", "storage"], value: z.number().int().min(1).max(3650).nullable(), allowed: "1 to 3650 days, or null to keep forever",
|
|
130
|
+
current: () => cfg().threads?.eventLogRetentionDays ?? null, read: () => display(cfg().threads?.eventLogRetentionDays ?? "forever"),
|
|
131
|
+
write: config((eventLogRetentionDays) => ({ threads: { eventLogRetentionDays } })),
|
|
132
|
+
}),
|
|
133
|
+
writable({
|
|
134
|
+
id: "rooms.turnTimeoutMinutes", label: "Room turn timeout", help: "Minutes a bot's turn in a room may run before it is stopped.", where: "Settings → You and your bots",
|
|
135
|
+
synonyms: ["room", "channel", "timeout", "turn limit"], value: z.number().int().min(MIN_ROOM_TURN_TIMEOUT_MINUTES).max(MAX_ROOM_TURN_TIMEOUT_MINUTES), allowed: `${MIN_ROOM_TURN_TIMEOUT_MINUTES} to ${MAX_ROOM_TURN_TIMEOUT_MINUTES} minutes`,
|
|
136
|
+
current: () => roomTurnTimeoutMinutes(cfg()), write: config((turnTimeoutMinutes) => ({ rooms: { turnTimeoutMinutes } })),
|
|
137
|
+
}),
|
|
138
|
+
writable({
|
|
139
|
+
id: "mcp.callTimeoutMinutes", label: "MCP call timeout", help: "Minutes one MCP tool call may run.", where: "Settings → AI",
|
|
140
|
+
synonyms: ["mcp", "tool timeout", "call timeout"], value: z.number().int().min(MIN_MCP_CALL_TIMEOUT_MINUTES).max(MAX_MCP_CALL_TIMEOUT_MINUTES), allowed: `${MIN_MCP_CALL_TIMEOUT_MINUTES} to ${MAX_MCP_CALL_TIMEOUT_MINUTES} minutes`,
|
|
141
|
+
current: () => mcpCallTimeoutMinutes(cfg()), write: config((callTimeoutMinutes) => ({ mcp: { callTimeoutMinutes } })),
|
|
142
|
+
}),
|
|
143
|
+
writable({
|
|
144
|
+
id: "bots.defaultModel", label: "Default model for new bots", help: "The engine and model a newly created bot starts on; existing bots keep theirs. Ids come from list_models.", where: "Settings → You and your bots",
|
|
145
|
+
synonyms: ["default model", "new bots", "model", "engine"], value: z.object({ instanceId: z.string().min(1).max(80), model: z.string().min(1).max(200) }), allowed: "{ instanceId, model } from list_models",
|
|
146
|
+
current: () => cfg().defaultModelSelection, read: () => { const selection = cfg().defaultModelSelection; return selection ? `${selection.instanceId} / ${selection.model}` : ""; },
|
|
147
|
+
write: config((defaultModelSelection) => ({ defaultModelSelection })),
|
|
148
|
+
}),
|
|
149
|
+
];
|
|
150
|
+
const provider = (id, label, synonyms, current, patch) => writable({
|
|
151
|
+
id, label, help: `${label}: the address MausBot sends requests to. Empty uses the provider's own.`, where: "Settings → AI", synonyms: [...synonyms, "url", "base url", "endpoint", "address", "proxy"],
|
|
152
|
+
value: url, allowed: "an http(s) address, or empty to clear", current: () => current() ?? "", write: config(patch),
|
|
153
|
+
});
|
|
154
|
+
const providers = [
|
|
155
|
+
provider("providers.anthropic.url", "Anthropic address", ["anthropic", "claude"], () => cfg().anthropic?.url, (text) => ({ anthropic: { ...cfg().anthropic, url: text } })),
|
|
156
|
+
provider("providers.xai.url", "xAI address", ["xai", "grok"], () => cfg().xai?.url, (text) => ({ xai: { ...cfg().xai, url: text } })),
|
|
157
|
+
provider("providers.groq.url", "Groq address", ["groq"], () => cfg().groq?.url, (text) => ({ groq: { ...cfg().groq, url: text } })),
|
|
158
|
+
provider("providers.meta.url", "Meta address", ["meta", "llama"], () => cfg().meta?.url, (text) => ({ meta: { ...cfg().meta, url: text } })),
|
|
159
|
+
provider("providers.openaiCompat.url", "OpenAI-compatible address", ["openai compatible", "custom provider", "ollama", "lm studio", "openrouter"], () => cfg().openaiCompat?.url, (text) => ({ openaiCompat: { ...cfg().openaiCompat, url: text } })),
|
|
160
|
+
writable({
|
|
161
|
+
id: "providers.openaiCompat.model", label: "OpenAI-compatible model", help: "The model name sent to the OpenAI-compatible provider.", where: "Settings → AI",
|
|
162
|
+
synonyms: ["openai compatible", "custom provider", "model name"], value: z.string().trim().max(200), allowed: "a model name, or empty to clear",
|
|
163
|
+
current: () => cfg().openaiCompat?.model ?? "", write: config((model) => ({ openaiCompat: { ...cfg().openaiCompat, model } })),
|
|
164
|
+
}),
|
|
165
|
+
provider("voice.baseUrl", "Voice server address", ["tts", "voice", "speech", "chatterbox"], () => cfg().tts?.baseUrl, (text) => ({ tts: { ...cfg().tts, baseUrl: text } })),
|
|
166
|
+
];
|
|
167
|
+
const secret = Object.keys(CREDENTIAL_TARGETS).map((credentialId) => {
|
|
168
|
+
const target = CREDENTIAL_TARGETS[credentialId];
|
|
169
|
+
return {
|
|
170
|
+
id: `keys.${credentialId}`, label: target.label, help: target.description, synonyms: ["key", "api key", "token", "credential", target.label.split(" ")[0].toLowerCase()],
|
|
171
|
+
where: KEY_WHERE[credentialId] ?? (PROVIDER_CREDENTIAL_TARGETS.includes(credentialId) ? "Settings → AI → API keys" : "Settings → AI"),
|
|
172
|
+
tier: "secret", credentialId, read: () => (credentialIsConfigured(deps.credentials(), credentialId) ? "set" : ""),
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
const instances = () => persistableInstanceConfigs(cfg());
|
|
176
|
+
const savedKey = (id) => deps.credentials()[PROVIDER_KEY_SECTION[id]]?.key;
|
|
177
|
+
const keyMissing = (id) => `Your ${CREDENTIAL_TARGETS[id].label} is not saved yet. Call set on keys.${id} with no value first (a secure card asks the user for it), then add the engine.`;
|
|
178
|
+
const listEngines = () => deps.engines().map(({ instanceId, name, working }) => {
|
|
179
|
+
const entry = instances()[instanceId];
|
|
180
|
+
const url = isAddedEndpoint(instanceId, entry) ? endpointDisplayUrl(entry.config) : undefined;
|
|
181
|
+
return `${instanceId}: ${name}${url ? ` at ${url}` : ""}${working ? "" : " (not working)"}${removableKind(instanceId, entry) ? "" : " (removed only in Settings)"}`;
|
|
182
|
+
}).join("; ");
|
|
183
|
+
const engines = writable({
|
|
184
|
+
id: "engines", label: "AI engines", help: "The AI engines bots run on. get lists each one's id; set adds one, with Undo. Removing one deletes its setup and key, so only the person does that, in Settings.", where: "Settings → AI",
|
|
185
|
+
synonyms: ["engine", "engines", "ai engine", "add engine", "remove engine", "provider", "providers", "ollama", "lm studio", "lmstudio", "bedrock", "endpoint", "local model"],
|
|
186
|
+
value: engineChange,
|
|
187
|
+
allowed: '{"kind":"ollama" or "lmstudio","url"} for a local server; {"kind":"openai-compat","name","url","keyFrom":"<a keys.* id, e.g. openrouterApiKey>","models"?:[...]}; '
|
|
188
|
+
+ '{"kind":"bedrock","name","awsProfile","awsRegion","model"}. Sign-in accounts (Claude, ChatGPT, Antigravity) are added and signed in by the user in Settings → AI',
|
|
189
|
+
current: () => ({ kind: "keep", instanceIds: deps.engines().map((engine) => engine.instanceId) }), read: listEngines,
|
|
190
|
+
describe: (change) => {
|
|
191
|
+
if (change.kind === "remove")
|
|
192
|
+
return { refusal: personOnly("Removing an AI engine", "Settings → AI") };
|
|
193
|
+
if (change.kind === "openai-compat") {
|
|
194
|
+
if (!savedKey(change.keyFrom))
|
|
195
|
+
return { refusal: keyMissing(change.keyFrom) };
|
|
196
|
+
return { change: `Add the engine "${change.name}" (OpenAI-compatible) at ${change.url}, sending it your saved ${CREDENTIAL_TARGETS[change.keyFrom].label}` };
|
|
197
|
+
}
|
|
198
|
+
if (change.kind === "bedrock")
|
|
199
|
+
return { change: `Add the engine "${change.name}" (Claude on Amazon Bedrock), AWS profile ${change.awsProfile} in ${change.awsRegion}, model ${change.model}` };
|
|
200
|
+
return { change: `Add the engine "${change.name ?? LOCAL_SERVER[change.kind].name}" (${LOCAL_SERVER[change.kind].name} on ${change.url})` };
|
|
201
|
+
},
|
|
202
|
+
write: async (change) => {
|
|
203
|
+
if (change.kind === "keep") {
|
|
204
|
+
for (const { instanceId } of deps.engines()) {
|
|
205
|
+
if (change.instanceIds.includes(instanceId) || !removableKind(instanceId, instances()[instanceId]))
|
|
206
|
+
continue;
|
|
207
|
+
const refusal = await deps.removeEngine(instanceId);
|
|
208
|
+
if (refusal)
|
|
209
|
+
return refusal;
|
|
210
|
+
}
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
if (change.kind === "remove")
|
|
214
|
+
return personOnly("Removing an AI engine", "Settings → AI");
|
|
215
|
+
if (change.kind === "bedrock")
|
|
216
|
+
return deps.addEngine("claude-bedrock", { displayName: change.name, awsProfile: change.awsProfile, awsRegion: change.awsRegion, model: change.model });
|
|
217
|
+
if (change.kind === "openai-compat") {
|
|
218
|
+
const key = savedKey(change.keyFrom);
|
|
219
|
+
return key ? deps.addEngine("openai-compat", { displayName: change.name, url: change.url, key, ...(change.models ? { models: change.models } : {}) }) : keyMissing(change.keyFrom);
|
|
220
|
+
}
|
|
221
|
+
const local = LOCAL_SERVER[change.kind];
|
|
222
|
+
return deps.addEngine("openai-compat", { displayName: change.name ?? local.name, url: change.url, key: local.key, catalog: change.kind });
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
const ownerOnly = (id, label, help, where, synonyms, read) => ({ id, label, help, where, synonyms, tier: "owner-only", read });
|
|
226
|
+
const owner = [
|
|
227
|
+
ownerOnly("cloud.account", "MausBot Cloud account", "The account this app is signed in with, and its plan.", "Settings → Your account", ["account", "sign in", "sign out", "plan", "billing", "subscription"], () => "managed in Settings"),
|
|
228
|
+
ownerOnly("vault.logins", "Vault and logins", "Saved website logins and secrets bots may use.", "Settings → Vault", ["vault", "password", "passwords", "login", "logins", "1password"], () => "managed in Settings"),
|
|
229
|
+
ownerOnly("data.backups", "Backups", "Making a backup (it takes a password), restoring or deleting one, and the daily company backup (it takes a typed confirmation).", "Settings → Data", ["backup", "backups", "restore", "export", "import", "schedule"], () => "managed in Settings"),
|
|
230
|
+
ownerOnly("phone.pairing", "Paired devices", "Pairing a phone or computer with a code, removing one, and what each paired device may do.", "Settings → Phone & devices", ["pair", "pairing", "qr", "code", "paired", "revoke", "remove device", "device access"], () => "managed in Settings"),
|
|
231
|
+
ownerOnly("computer.lending", "Lending this computer", "Which folders and apps this computer lends to a Cloud or server; each grant is picked and confirmed in the desktop app's own dialogs.", "Settings → Desktops & browser", ["lend", "lending", "share computer", "share folders", "pause sharing"], () => "managed in Settings"),
|
|
232
|
+
ownerOnly("data.keepHere", "Keep bots on this computer", "Whether this computer's bots stay here or move to My Cloud; the desktop app takes it only from the person's own click.", "Settings → Data", ["keep here", "move to cloud", "move back", "bring back"], () => "managed in Settings"),
|
|
233
|
+
ownerOnly("appearance.sidebarPicture", "Sidebar picture", "The picture at the top of the sidebar; it is a file the person picks or removes.", "Settings → Overview", ["wallpaper", "background", "banner", "sidebar image", "picture"], () => "managed in Settings"),
|
|
234
|
+
ownerOnly("account.organization", "Organization", "Joining or leaving a company's managed MausBot; it signs in through the company's portal.", "Settings → Your account", ["organization", "organisation", "company", "managed"], () => "managed in Settings"),
|
|
235
|
+
ownerOnly("people.signIn", "Who may sign in", "On a self-hosted server, the emails or @domains that may sign in, as admins or members. A change could lock someone out, or hand every setting to someone new.", "Settings → Your account", ["people", "members", "invite", "roles", "admins", "sign in access"], () => "managed in Settings"),
|
|
236
|
+
ownerOnly("remote.domain", "Custom domain", "The web address this self-hosted server answers on. Changing it can cut off the address the person is using right now.", "Settings → Overview", ["domain", "custom domain", "dns", "public url"], () => cfg().customDomain ?? ""),
|
|
237
|
+
ownerOnly("remote.httpsAddress", "HTTPS address", "This computer's public HTTPS address for paired devices; turning it off can cut off the device the person is using now.", "Settings → Phone & devices", ["https", "public address"], () => "managed in Settings"),
|
|
238
|
+
];
|
|
239
|
+
return [...safe, ...providers, engines, ...botEntries(deps, writable), ...pictureEntries(deps, writable), ...configEntries(deps, writable), ...windowEntries(windowPref), ...secret, ...owner];
|
|
240
|
+
}
|
|
241
|
+
export function findSettings(entries, query, limit = 8) {
|
|
242
|
+
const words = query.toLowerCase().split(/[^a-z0-9.-]+/).filter((word) => word.length > 1);
|
|
243
|
+
if (!words.length)
|
|
244
|
+
return [];
|
|
245
|
+
const phrase = words.join(" ");
|
|
246
|
+
const scored = entries.map((entry) => {
|
|
247
|
+
const label = entry.label.toLowerCase(), id = entry.id.toLowerCase();
|
|
248
|
+
const synonyms = entry.synonyms.map((synonym) => synonym.toLowerCase());
|
|
249
|
+
const loose = [entry.help, ...synonyms].join(" ").toLowerCase();
|
|
250
|
+
const whole = id === phrase || label === phrase || synonyms.includes(phrase) ? 10 : 0;
|
|
251
|
+
const score = words.reduce((sum, word) => sum + (id === word || label === word ? 6 : label.includes(word) || id.includes(word) ? 3 : loose.includes(word) ? 1 : 0), whole);
|
|
252
|
+
return { entry, score };
|
|
253
|
+
}).filter((hit) => hit.score > 0).sort((a, b) => b.score - a.score);
|
|
254
|
+
return scored.slice(0, limit).map((hit) => hit.entry);
|
|
255
|
+
}
|
|
256
|
+
/** The registry over the Settings window's own routes, called as the window calls them. */
|
|
257
|
+
export function routeBackedRegistry(deps) {
|
|
258
|
+
const auth = { kind: "loopback", scopes: ["admin", "client"] };
|
|
259
|
+
const refusal = async (reply) => {
|
|
260
|
+
try {
|
|
261
|
+
const { status, body } = await reply;
|
|
262
|
+
return status < 300 ? null : String(body.error ?? `HTTP ${status}`);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return error instanceof Error ? error.message : String(error);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
return createSettingsRegistry({
|
|
269
|
+
cfg: deps.cfg, bots: () => deps.store.bots, sections: () => deps.store.sections, credentials: deps.credentials, window: deps.window, paused: deps.paused,
|
|
270
|
+
saveConfig: (patch) => refusal(callRoute(deps.routes.config, { method: "PUT", path: "/api/config", body: patch, auth })),
|
|
271
|
+
reorderBots: (botIds) => refusal(callRoute(deps.routes.botOrder, { method: "PUT", path: "/api/bots/order", body: { botIds }, auth })),
|
|
272
|
+
pinBot: (botId, pinned) => refusal(callRoute(deps.routes.botPatch, { method: "PATCH", path: `/api/bots/${encodeURIComponent(botId)}`, body: { pinned }, auth })),
|
|
273
|
+
patchBot: (botId, body) => refusal(callRoute(deps.routes.botPatch, { method: "PATCH", path: `/api/bots/${encodeURIComponent(botId)}`, body, auth })),
|
|
274
|
+
call: (route, method, path, body) => refusal(callRoute(deps.routes[route], { method, path, ...(body ? { body } : {}), auth })),
|
|
275
|
+
read: async (route, path) => {
|
|
276
|
+
const reply = await callRoute(deps.routes[route], { method: "GET", path, auth }).catch(() => null);
|
|
277
|
+
return reply && reply.status < 300 ? reply.body : null;
|
|
278
|
+
},
|
|
279
|
+
groupBots: (name, botIds) => refusal(callRoute(deps.routes.sections, { method: "POST", path: "/api/sidebar-sections", body: { name, botIds }, auth })),
|
|
280
|
+
engines: () => deps.providers.instances().filter((instance) => instance.enabled).map((instance) => ({
|
|
281
|
+
instanceId: instance.instanceId, working: deps.providers.lastSnapshot(instance.instanceId)?.state === "available",
|
|
282
|
+
name: instance.displayName ?? BUILT_IN_DRIVERS.find((driver) => driver.driverKind === instance.driverKind)?.metadata.displayName ?? instance.instanceId,
|
|
283
|
+
})),
|
|
284
|
+
addEngine: (path, body) => refusal(callRoute(deps.routes.instances, { method: "POST", path: `/api/instances/${path}`, body, auth })),
|
|
285
|
+
removeEngine: (instanceId) => refusal(callRoute(deps.routes.instances, { method: "DELETE", path: `/api/instances/${encodeURIComponent(instanceId)}`, auth })),
|
|
286
|
+
});
|
|
287
|
+
}
|
|
@@ -48,7 +48,7 @@ const IMAGE_MIMES = {
|
|
|
48
48
|
"image/gif": ".gif",
|
|
49
49
|
"image/webp": ".webp",
|
|
50
50
|
};
|
|
51
|
-
/**
|
|
51
|
+
/** Types kept under their own extension; archives are kept as sent, never unpacked. The claimed mime picks the stored extension; an attacker's filename never does. */
|
|
52
52
|
const FILE_MIMES = {
|
|
53
53
|
"video/mp4": ".mp4",
|
|
54
54
|
"video/webm": ".webm",
|
|
@@ -83,14 +83,20 @@ const FILE_MIMES = {
|
|
|
83
83
|
"application/vnd.oasis.opendocument.spreadsheet": ".ods",
|
|
84
84
|
"application/vnd.oasis.opendocument.presentation": ".odp",
|
|
85
85
|
"application/zip": ".zip",
|
|
86
|
+
"application/x-zip-compressed": ".zip",
|
|
86
87
|
"application/vnd.rar": ".rar",
|
|
88
|
+
"application/x-rar-compressed": ".rar",
|
|
87
89
|
"application/x-7z-compressed": ".7z",
|
|
88
90
|
"application/x-tar": ".tar",
|
|
89
91
|
"application/gzip": ".gz",
|
|
92
|
+
"application/x-gzip": ".gz",
|
|
90
93
|
"application/x-compressed-tar": ".tgz",
|
|
91
94
|
"application/x-bzip2": ".bz2",
|
|
92
95
|
"application/x-xz": ".xz",
|
|
93
96
|
};
|
|
97
|
+
/** Every other type (binaries, HTML, SVG, scripts) is stored as an inert `.bin` download, never rendered. */
|
|
98
|
+
const GENERIC_FILE_MIME = "application/octet-stream";
|
|
99
|
+
const GENERIC_FILE_EXTENSION = ".bin";
|
|
94
100
|
export function extensionForMime(mime) {
|
|
95
101
|
if (!mime)
|
|
96
102
|
return null;
|
|
@@ -335,7 +341,7 @@ async function withUploadLock(uploadId, operation) {
|
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
/** saveFile/saveImage only ever write `${uuid}${extension}` with one of these extensions. */
|
|
338
|
-
const KNOWN_ATTACHMENT_EXTENSIONS = Array.from(new Set([...Object.values(IMAGE_MIMES), ...Object.values(FILE_MIMES)]));
|
|
344
|
+
const KNOWN_ATTACHMENT_EXTENSIONS = Array.from(new Set([...Object.values(IMAGE_MIMES), ...Object.values(FILE_MIMES), GENERIC_FILE_EXTENSION]));
|
|
339
345
|
function statSizeIfFile(path) {
|
|
340
346
|
try {
|
|
341
347
|
const stat = statSync(path);
|
|
@@ -376,11 +382,9 @@ export function extensionForFileMime(mime) {
|
|
|
376
382
|
const value = normalizedMime(mime);
|
|
377
383
|
return value ? FILE_MIMES[value] ?? null : null;
|
|
378
384
|
}
|
|
379
|
-
/** Separators and encoded separators are rejected, not massaged, so traversal attempts stay visible as bad requests.
|
|
385
|
+
/** Separators and encoded separators are rejected, not massaged, so traversal attempts stay visible as bad requests.
|
|
386
|
+
* A known type takes its extension from the mime; any other keeps its own short one, in the display name only. */
|
|
380
387
|
export function sanitizeSharedFileName(name, mime) {
|
|
381
|
-
const extension = extensionForFileMime(mime);
|
|
382
|
-
if (!extension)
|
|
383
|
-
throw statusError(400, "content-type must be a supported document or audio type");
|
|
384
388
|
const normalized = name.normalize("NFKC").trim();
|
|
385
389
|
if (!normalized)
|
|
386
390
|
throw statusError(400, "name is required");
|
|
@@ -390,7 +394,9 @@ export function sanitizeSharedFileName(name, mime) {
|
|
|
390
394
|
throw statusError(400, "name must be a filename, not a path");
|
|
391
395
|
}
|
|
392
396
|
const dot = normalized.lastIndexOf(".");
|
|
393
|
-
const
|
|
397
|
+
const own = dot > 0 ? normalized.slice(dot).toLowerCase() : "";
|
|
398
|
+
const extension = extensionForFileMime(mime) ?? (/^\.[a-z0-9]{1,10}$/.test(own) ? own : "");
|
|
399
|
+
const withoutExtension = dot > 0 && extension ? normalized.slice(0, dot) : normalized;
|
|
394
400
|
const safeCharacters = Array.from(withoutExtension, (character) => {
|
|
395
401
|
const code = character.charCodeAt(0);
|
|
396
402
|
return code <= 31 || code === 127 || "<>:\"|?*".includes(character) ? "_" : character;
|
|
@@ -407,12 +413,10 @@ export function sanitizeSharedFileName(name, mime) {
|
|
|
407
413
|
}
|
|
408
414
|
/** Never buffers the request; a failed, empty or oversized upload leaves no partial file. */
|
|
409
415
|
export async function saveFile(chunks, originalName, mime, options = {}) {
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
416
|
+
const known = extensionForFileMime(mime);
|
|
417
|
+
const normalized = known ? normalizedMime(mime) : GENERIC_FILE_MIME;
|
|
418
|
+
const extension = known ?? GENERIC_FILE_EXTENSION;
|
|
414
419
|
const name = sanitizeSharedFileName(originalName, normalized);
|
|
415
|
-
const extension = extensionForFileMime(normalized);
|
|
416
420
|
const uploadId = validateAttachmentUploadId(options.uploadId);
|
|
417
421
|
const expectedBytes = options.expectedBytes;
|
|
418
422
|
if (expectedBytes !== undefined && (!Number.isSafeInteger(expectedBytes) || expectedBytes < 0)) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// next flush, which the server runs whenever it releases what was queued behind a turn, ahead of that queue. A routine
|
|
6
6
|
// that delivers to the brief posts no line: its answer goes to the brief, which reads it as a small JSON result.
|
|
7
7
|
import { liveCardKind } from "../shared/live-approval.js";
|
|
8
|
+
import { ROUTINE_HANDOFF_WAIT } from "../shared/routines.js";
|
|
8
9
|
import { signInWaits } from "../shared/sign-in-request.js";
|
|
9
10
|
import { intlLocale } from "./language.js";
|
|
10
11
|
import { needsInputQuestion } from "./runtime-coordinator.js";
|
|
@@ -24,6 +25,14 @@ export function readRunReply(text, attached = false) {
|
|
|
24
25
|
const at = lines.findLastIndex((line) => NEEDS_INPUT.test(line));
|
|
25
26
|
return { quiet: false, text: [...lines.slice(0, at), lines[at].replace(NEEDS_INPUT, ""), ...lines.slice(at + 1)].join("\n").trim(), question };
|
|
26
27
|
}
|
|
28
|
+
/** A run puts its chat under To review only when the person is needed: it failed or was missed, waits on them (not on teammates), or ended on a question. */
|
|
29
|
+
export function routineRunNeedsReview(run, reply) {
|
|
30
|
+
if (run.status === "failed" || run.status === "missed")
|
|
31
|
+
return true;
|
|
32
|
+
if (run.status === "waiting")
|
|
33
|
+
return run.attention !== ROUTINE_HANDOFF_WAIT;
|
|
34
|
+
return run.status === "completed" && needsInputQuestion(reply ?? run.output ?? "") !== undefined;
|
|
35
|
+
}
|
|
27
36
|
function inHostZone(at, locale, options) {
|
|
28
37
|
const format = (timeZone) => new Intl.DateTimeFormat(locale, { ...options, timeZone }).format(at);
|
|
29
38
|
try {
|
|
@@ -173,7 +182,8 @@ export function createAutomationReports(deps) {
|
|
|
173
182
|
});
|
|
174
183
|
deps.routines()?.noteReport(run.id, { state: "posted", threadId: target.threadId, messageId: posted.id });
|
|
175
184
|
deps.wrote(target.bot, target.threadId);
|
|
176
|
-
|
|
185
|
+
if (line.kind === "failure" || reply.question !== undefined || routineRunNeedsReview(run))
|
|
186
|
+
store.patchTask(target.bot.id, target.threadId, { unread: true });
|
|
177
187
|
if (line.kind === "reply" && !recovered)
|
|
178
188
|
deps.notify(reply.question ? "question" : "done", target.bot, target.threadId, `${run.routineName}: ${reply.question ?? reply.text}`);
|
|
179
189
|
return true;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// copied into the private store, so the chat never reaches into a bot's workspace or VM home afterwards.
|
|
3
3
|
import { basename, join, posix } from "node:path";
|
|
4
4
|
import { extensionForFileMime, extensionForMime, FILE_MAX_BYTES, IMAGE_MAX_BYTES, saveFile, saveImage, } from "./attachments.js";
|
|
5
|
-
import { mimeFor, openFileSavedSince, openMessageFile } from "./message-file.js";
|
|
5
|
+
import { mimeFor, openFileSavedSince, openMessageFile, referencedPathIdentity } from "./message-file.js";
|
|
6
6
|
export const ATTACH_SUPPORTED_TYPES = "images (png, jpg, gif, webp), video (mp4, webm, mov), audio (mp3, m4a, aac, wav, ogg, opus, flac), " +
|
|
7
|
-
"pdf, Word/Excel/PowerPoint and OpenDocument files,
|
|
7
|
+
"pdf, Word/Excel/PowerPoint and OpenDocument files, csv, tsv, txt, md, json, rtf, " +
|
|
8
|
+
"and archives (zip, rar, 7z, tar, gz, tgz, bz2, xz)";
|
|
8
9
|
function statusError(status, message) {
|
|
9
10
|
return Object.assign(new Error(message), { status });
|
|
10
11
|
}
|
|
@@ -78,23 +79,46 @@ export async function saveBotAttachment(input) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
/** The chat's link rule: search from the reply back to the last non-bot message; only the reply's author counts, and a
|
|
81
|
-
*
|
|
82
|
-
|
|
82
|
+
* delivery matched twice is refused. A link to the source the bot saved resolves the delivered copy by its source path
|
|
83
|
+
* first, so a renamed attachment still opens; the display name is the fallback for records without a source. */
|
|
84
|
+
export function deliveredCopy(messages, reply, name, href) {
|
|
83
85
|
const byId = new Map(messages.map((message) => [message.id, message]));
|
|
84
86
|
const author = reply.from?.botId;
|
|
85
|
-
let
|
|
87
|
+
let wanted;
|
|
88
|
+
if (href) {
|
|
89
|
+
try {
|
|
90
|
+
wanted = referencedPathIdentity(href);
|
|
91
|
+
}
|
|
92
|
+
catch { }
|
|
93
|
+
}
|
|
94
|
+
const inScope = [];
|
|
86
95
|
for (let message = reply; message?.role === "bot"; message = message.parentId ? byId.get(message.parentId) : undefined) {
|
|
87
96
|
if (message.from?.botId !== author)
|
|
88
97
|
continue;
|
|
89
98
|
for (const attachment of message.attachments ?? []) {
|
|
90
|
-
if (attachment.kind === "audio"
|
|
99
|
+
if (attachment.kind === "audio")
|
|
91
100
|
continue;
|
|
92
|
-
|
|
93
|
-
return null;
|
|
94
|
-
found = attachment;
|
|
101
|
+
inScope.push(attachment);
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
if (wanted !== undefined) {
|
|
105
|
+
const bySource = inScope.filter((attachment) => {
|
|
106
|
+
if (!attachment.source)
|
|
107
|
+
return false;
|
|
108
|
+
try {
|
|
109
|
+
return referencedPathIdentity(attachment.source) === wanted;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (bySource.length > 1)
|
|
116
|
+
return null;
|
|
117
|
+
if (bySource.length === 1)
|
|
118
|
+
return bySource[0];
|
|
119
|
+
}
|
|
120
|
+
const byName = inScope.filter((attachment) => attachment.name === name);
|
|
121
|
+
return byName.length === 1 ? byName[0] : null;
|
|
98
122
|
}
|
|
99
123
|
/** The slot is reserved before the await, so parallel calls cannot all pass the per-turn count; `stillLive` is asked again
|
|
100
124
|
* just before `publish`, so nothing is published for a turn that ended meanwhile. */
|
|
@@ -15,10 +15,10 @@ export const BOX_ENV_NAMES = new Set([
|
|
|
15
15
|
* proxies it starts. Security: no other `OMB_` name passes, whatever the operator set on the server (an SMTP URL, a
|
|
16
16
|
* token); env.test.ts lists every `OMB_` name the server knows, so a new one needs a decision. */
|
|
17
17
|
export const BOX_ENV_OMB_NAMES = new Set([
|
|
18
|
-
"OMB_HARNESS_URL", "OMB_BOT_ID", "OMB_THREAD_ID", "OMB_COMMS_TOKEN", "
|
|
18
|
+
"OMB_HARNESS_URL", "OMB_BOT_ID", "OMB_THREAD_ID", "OMB_COMMS_TOKEN", "OMB_EXTERNAL_RUNTIME",
|
|
19
19
|
"OMB_CHIEF_OF_STAFF", "OMB_MAUSBOT", "OMB_SKILL_AUTHORING_ENABLED", "OMB_MEMORY_ENABLED", "OMB_SHARED_COMPUTERS_ENABLED",
|
|
20
20
|
"OMB_VOICE_NOTES", "OMB_X_RESEARCH", "OMB_RESEARCH", "OMB_TEAM_PEOPLE", "OMB_COMPUTER_SELECTION", "OMB_ROOM",
|
|
21
|
-
"OMB_IMAGE_GENERATION", "OMB_MEETINGS", "OMB_AGENTS_TOOL_BRIDGE", "OMB_TOOL_LIMIT", "OMB_TOOL_SCHEMA_PROFILE",
|
|
21
|
+
"OMB_IMAGE_GENERATION", "OMB_MEETINGS", "OMB_TOOLS_OFF", "OMB_AGENTS_TOOL_BRIDGE", "OMB_AGENTS_DEFER_TOOLS", "OMB_TOOL_LIMIT", "OMB_TOOL_SCHEMA_PROFILE",
|
|
22
22
|
"OMB_MCP_CONFIG", "OMB_MCP_RESTART", "OMB_MCP_RESULT_BUDGET",
|
|
23
23
|
"OMB_HOOK_URL", "OMB_HOOK_TOKEN_FILE", "OMB_HOOK_TIMEOUT_MS", "OMB_PERMISSION_TOOL_SCOPE",
|
|
24
24
|
"OMB_CONNECTOR_UPSTREAM_URL", "OMB_CONNECTOR_UPSTREAM_HEADERS", "OMB_CONNECTOR_TOKEN", "OMB_CONNECTOR_ALLOWED_TOOLS",
|
|
@@ -185,7 +185,7 @@ export function planBox(setup, request) {
|
|
|
185
185
|
if (!named.has(full) && (under(full, dataDir) || under(dataDir, full)) && !covered(full) && !inBotFolder(full))
|
|
186
186
|
continue;
|
|
187
187
|
// Code and the system are already there; a file under HOME or /tmp the command line names is put back read-only.
|
|
188
|
-
if (covered(full) || readOnly.has(full))
|
|
188
|
+
if ((!named.has(full) && covered(full)) || readOnly.has(full))
|
|
189
189
|
continue;
|
|
190
190
|
if (["/usr", "/etc", "/opt", "/var/lib", ...setup.codeRoots, ...setup.engineRoots].some((base) => under(full, resolve(base))))
|
|
191
191
|
continue;
|
|
@@ -39,6 +39,8 @@ const SERVER_ENV_NAMES = new Set([
|
|
|
39
39
|
"OMB_BOT_BOX",
|
|
40
40
|
// An ended Cloud started only for its owner's export: the server runs frozen (server/move-freeze.ts).
|
|
41
41
|
"OMB_CLOUD_EXPORT_ONLY",
|
|
42
|
+
// Limix Bot: the server runs the Telegram / Zalo / Discord connector beside it (server/limix-gateway-sidecar.ts).
|
|
43
|
+
"LIMIX_GATEWAY_SIDECAR",
|
|
42
44
|
]);
|
|
43
45
|
export function serverEnvironmentAllowed(name) {
|
|
44
46
|
return SERVER_ENV_NAMES.has(name) || name.startsWith("LC_");
|
|
@@ -407,6 +407,7 @@ const storedAppConfigSchema = appConfigSchema.extend(helperStoredShape).extend({
|
|
|
407
407
|
});
|
|
408
408
|
const appConfigPatchSchema = appConfigSchema.omit({ instances: true, mcpServers: true, cliStartup: true, customDomain: true })
|
|
409
409
|
.extend({ threads: threadsPatchSchema.optional(), newBots: newBotsPatchSchema.optional(), imageGen: imageGenPatchSchema.optional() });
|
|
410
|
+
export const CONFIG_PATCH_FIELDS = appConfigPatchSchema.shape;
|
|
410
411
|
const jsonObjectSchema = z.record(z.string(), z.json());
|
|
411
412
|
/** Electron storage must use this, never the profile id. */
|
|
412
413
|
export function browserProfilePartitionId(profile) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { lstat, realpath } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
3
|
+
const inside = (root, path) => {
|
|
4
|
+
const rel = relative(root, path);
|
|
5
|
+
return rel !== ".." && !rel.startsWith(".." + sep) && !isAbsolute(rel);
|
|
6
|
+
};
|
|
7
|
+
export async function resolveAcpClientPath(requestPath, cwd, readRoots = []) {
|
|
8
|
+
if (typeof requestPath !== "string" || !isAbsolute(requestPath))
|
|
9
|
+
throw new Error("ACP file paths must be absolute.");
|
|
10
|
+
const requested = resolve(requestPath);
|
|
11
|
+
const stagedRoot = readRoots.find((allowed) => inside(resolve(allowed), requested));
|
|
12
|
+
if (stagedRoot) {
|
|
13
|
+
const expected = resolve(stagedRoot);
|
|
14
|
+
const info = await lstat(expected);
|
|
15
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath(expected) !== expected) {
|
|
16
|
+
throw new Error("ACP staged read root must be a real directory at its expected location.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const root = [cwd, ...readRoots].find((allowed) => inside(resolve(allowed), requested));
|
|
20
|
+
if (!root)
|
|
21
|
+
throw new Error("ACP file path is outside the session workspace.");
|
|
22
|
+
const workspace = await realpath(root).catch(() => resolve(root));
|
|
23
|
+
const suffix = [basename(requested)];
|
|
24
|
+
let ancestor = dirname(requested);
|
|
25
|
+
while (!(await lstat(ancestor).catch(() => null))) {
|
|
26
|
+
const parent = dirname(ancestor);
|
|
27
|
+
if (parent === ancestor)
|
|
28
|
+
throw new Error("ACP file path has no accessible parent.");
|
|
29
|
+
suffix.unshift(basename(ancestor));
|
|
30
|
+
ancestor = parent;
|
|
31
|
+
}
|
|
32
|
+
const candidate = resolve(await realpath(ancestor), ...suffix);
|
|
33
|
+
if (!inside(workspace, candidate))
|
|
34
|
+
throw new Error("ACP file path is outside the session workspace.");
|
|
35
|
+
const existing = await lstat(candidate).catch(() => null);
|
|
36
|
+
if (existing?.isSymbolicLink())
|
|
37
|
+
throw new Error("ACP file path cannot be a symbolic link.");
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|