limixbot 0.3.51 → 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-C74ksK5_.js → ActivityPanel-DoWrjUz7.js} +1 -1
- package/dist/assets/App-DmJM-bVw.js +243 -0
- package/dist/assets/{AppEventEditor-Derw3FHd.js → AppEventEditor-emHq_cA0.js} +1 -1
- package/dist/assets/BotSettingsDialog-BshbTnT_.js +16 -0
- package/dist/assets/{BrowserPanel-BUwH6i3q.js → BrowserPanel-PLHN7znJ.js} +2 -2
- package/dist/assets/{BrowserProfilesManager-LPWaNOTL.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-BKSAp5BV.js → ComputerPanel-Df-QaAS2.js} +2 -2
- package/dist/assets/{DataPanel-C8JFQXPW.js → DataPanel-QSdW8P4h.js} +1 -1
- package/dist/assets/{DesktopViewer-DFhYwHIq.js → DesktopViewer-Du64Zar0.js} +1 -1
- package/dist/assets/{FilesView-uvhFDVLX.js → FilesView-0Ijtj6CN.js} +1 -1
- package/dist/assets/{GrokMoveDialog-DqtBggcO.js → GrokMoveDialog-BVG5-cPU.js} +1 -1
- package/dist/assets/{InspectorPanel-B9946G8k.js → InspectorPanel-CtBr7aZo.js} +2 -2
- package/dist/assets/{KeyboardShortcutsModal-3p8-Y0gj.js → KeyboardShortcutsModal-Co3LHjUp.js} +1 -1
- package/dist/assets/{LimixChannelReview-BDF1Ho_G.js → LimixChannelReview-LNSDJ-cn.js} +1 -1
- package/dist/assets/{LiveDesktop-csn9EgQr.js → LiveDesktop-DPs1lypu.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-CY-cK25P.js → LocalVmWorkspace-Bf2EXh1s.js} +1 -1
- package/dist/assets/{MacLocalControl-tjDKmfaz.js → MacLocalControl-BGeq2FOD.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-C9270gON.js → MarkdownFilePreview-BDNgFKxV.js} +1 -1
- package/dist/assets/{MenuMotion-CtV49YrJ.js → MenuMotion-DFWzLAOE.js} +1 -1
- package/dist/assets/{NewBotDialog-QR0H-5OX.js → NewBotDialog-itNxT2iU.js} +1 -1
- package/dist/assets/{PhoneAppDialog-4jvBw2u6.js → PhoneAppDialog-CMtCT9Xu.js} +1 -1
- package/dist/assets/PlacesRail-i-4ph-KR.js +1 -0
- package/dist/assets/{PluginsPanel-DHUbnE7N.js → PluginsPanel-49ZWw79q.js} +2 -2
- package/dist/assets/ProIntroduction-CyKL7OF8.js +1 -0
- package/dist/assets/{RemoteAgentSettingsPanel-Dllevm4e.js → RemoteAgentSettingsPanel-Bbp1t8mD.js} +1 -1
- package/dist/assets/{RoomPanel-Bd_Xtwqu.js → RoomPanel-Gw0rFOk7.js} +1 -1
- package/dist/assets/{RoutinesPage-QcfeQgTy.js → RoutinesPage-Bo4NVg7D.js} +2 -2
- package/dist/assets/SettingsModal-D4XZMVXS.js +19 -0
- package/dist/assets/{ShareTeamDialog-DMqi3pEn.js → ShareTeamDialog-CeT0rE7W.js} +1 -1
- package/dist/assets/{SignedInSites-DayALoO-.js → SignedInSites-BGpe1m04.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-DMAGl5Yz.js → TeamLibraryPanel-SJebr72G.js} +1 -1
- package/dist/assets/{TeamMapPage-MEkKU-EN.js → TeamMapPage-DIiHaEPP.js} +1 -1
- package/dist/assets/{TriggersPage-D3KTWX3z.js → TriggersPage-Dz_RBgRC.js} +1 -1
- package/dist/assets/VisibilitySection-BLgOrAop.js +22 -0
- package/dist/assets/{WebhookTrigger-DJlTvzBb.js → WebhookTrigger-Cw7eIur5.js} +1 -1
- package/dist/assets/{WorksOnGrid-CW82h_3C.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-x2kyD7fr.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-Dob2tT-n.js → import-name-zOg5ckYf.js} +1 -1
- package/dist/assets/index-DhTEAf1-.js +3 -0
- package/dist/assets/{index-B7zM90O2.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-Cki_Gh83.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-Cdx_YpVT.js → new-bot-D75cIR6C.js} +2 -2
- package/dist/assets/org-library-pEzmTM3q.js +1 -0
- package/dist/assets/{package-format-C4A5Q4UD.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-XKcfTfrc.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 +8241 -7922
- package/dist-server/mcp-gate.js +18 -17
- package/dist-server/openmausbot.js +1153 -1119
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +1028 -997
- 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/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-BjHYb_ps.js +0 -243
- package/dist/assets/BotSettingsDialog-D8LUP9Jn.js +0 -16
- package/dist/assets/CloudAddDialog-BbmxUPbT.js +0 -1
- package/dist/assets/ComputerFilesPane-Df6Y0sr2.js +0 -1
- package/dist/assets/PlacesRail-COZEZH0n.js +0 -57
- package/dist/assets/ProIntroduction-Cc_7SVv1.js +0 -1
- package/dist/assets/SettingsModal-MzznkaJe.js +0 -19
- package/dist/assets/VisibilitySection-ajWCQrhN.js +0 -22
- package/dist/assets/channel-DAFePtOr.js +0 -1
- package/dist/assets/de-CJcRve_J.js +0 -8
- package/dist/assets/index-C2Sr_aMA.js +0 -2
- package/dist/assets/org-library-tRxkixxQ.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,36 @@
|
|
|
1
|
+
import { PASS } from "./table.js";
|
|
2
|
+
export const CUSTOM_DOMAIN_PATH = "/api/settings/custom-domain";
|
|
3
|
+
/** Admin-only by request-auth's default deny; only future pairing links change. */
|
|
4
|
+
export function createCustomDomainRoutes(deps) {
|
|
5
|
+
let revision = 0;
|
|
6
|
+
const save = (origin) => { deps.save(origin); revision++; };
|
|
7
|
+
return async ({ req, res, path, method, auth, json, readBody }) => {
|
|
8
|
+
if (path !== CUSTOM_DOMAIN_PATH)
|
|
9
|
+
return PASS;
|
|
10
|
+
res.setHeader?.("cache-control", "no-store");
|
|
11
|
+
if (method === "GET")
|
|
12
|
+
return json(res, 200, deps.status());
|
|
13
|
+
if (method !== "POST" && method !== "DELETE")
|
|
14
|
+
return PASS;
|
|
15
|
+
if (deps.desktopManaged)
|
|
16
|
+
return json(res, 409, { error: "Custom domains are configured on a self-hosted Limix Bot server, not the desktop companion." });
|
|
17
|
+
if (!/^application\/json\b/i.test(String(req.headers["content-type"] ?? ""))) {
|
|
18
|
+
return json(res, 415, { error: "content-type must be application/json" });
|
|
19
|
+
}
|
|
20
|
+
if (method === "DELETE") {
|
|
21
|
+
save("");
|
|
22
|
+
return json(res, 200, deps.status());
|
|
23
|
+
}
|
|
24
|
+
const body = await readBody(req, 4096);
|
|
25
|
+
if (typeof body?.domain !== "string")
|
|
26
|
+
return json(res, 400, { error: "Enter your domain name." });
|
|
27
|
+
const started = revision;
|
|
28
|
+
const verified = await deps.verify(body.domain);
|
|
29
|
+
if (deps.sessionEnded(auth))
|
|
30
|
+
return json(res, 401, { error: "Your session ended. Sign in again before connecting a domain." });
|
|
31
|
+
if (started !== revision)
|
|
32
|
+
return json(res, 409, { error: "Domain settings changed during verification. Try again." });
|
|
33
|
+
save(verified.origin);
|
|
34
|
+
return json(res, 200, deps.status());
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -34,6 +34,7 @@ export function createSidebarSectionRoutes(deps) {
|
|
|
34
34
|
const error = nextName === null ? store.deleteSection(section) : store.renameSection(section, nextName, teamComputers);
|
|
35
35
|
if (error)
|
|
36
36
|
return json(res, error === "No such department" ? 404 : 409, storeRefusal(error));
|
|
37
|
+
deps.renamed?.(section, nextName);
|
|
37
38
|
return json(res, 200, { sections: store.sections });
|
|
38
39
|
}
|
|
39
40
|
if (method === "PUT" && path === "/api/sidebar-sections") {
|
|
@@ -186,7 +186,7 @@ export function createThreadRoutes(deps) {
|
|
|
186
186
|
const name = message.role === "bot" && !botAttachment && !folderEntry && (code === "outside_workspace" || status === 404)
|
|
187
187
|
? referencedFileName(href)
|
|
188
188
|
: null;
|
|
189
|
-
const copy = name ? deliveredCopy(store.messagesFor(threadId), message, name) : null;
|
|
189
|
+
const copy = name ? deliveredCopy(store.messagesFor(threadId), message, name, href) : null;
|
|
190
190
|
if (copy) {
|
|
191
191
|
file = await openMessageFile(copy.path, [ATTACHMENTS_DIR], maxBytes);
|
|
192
192
|
downloadName = copy.name;
|
|
@@ -60,3 +60,28 @@ export function applyCheckResult(routine, result, now) {
|
|
|
60
60
|
delete routine[field];
|
|
61
61
|
Object.assign(routine, result.wakeAt === undefined ? {} : { wakeAt: result.wakeAt }, result.trouble ? { checkTrouble: result.trouble.slice(0, 300), ...(result.troubleCode ? { checkTroubleCode: result.troubleCode } : {}) } : {}, result.trouble || result.run ? {} : { checkedAt: now });
|
|
62
62
|
}
|
|
63
|
+
const CLOSING_QUESTION = /^\s*needs input:/i;
|
|
64
|
+
/** A run's reply cut to max characters for its stored output. A reply that ends on a NEEDS INPUT question (with at most
|
|
65
|
+
* a default: line after it) keeps that question at the end, whole when it fits and else cut on its own line, so a long
|
|
66
|
+
* reply still reads as waiting on the person. */
|
|
67
|
+
export function clipRunOutput(text, max) {
|
|
68
|
+
if (text.length <= max)
|
|
69
|
+
return text;
|
|
70
|
+
const lines = text.split(/\r?\n/);
|
|
71
|
+
const at = lines.findLastIndex((line) => CLOSING_QUESTION.test(line));
|
|
72
|
+
const after = at < 0 ? [] : lines.slice(at + 1).filter((line) => line.trim());
|
|
73
|
+
const closing = at >= 0 && (after.length === 0 || (after.length === 1 && /^default:/i.test(after[0].trim())));
|
|
74
|
+
if (!closing)
|
|
75
|
+
return text.slice(0, max);
|
|
76
|
+
const tail = lines.slice(at).join("\n").trim();
|
|
77
|
+
if (tail.length > max) {
|
|
78
|
+
const question = lines[at].trim();
|
|
79
|
+
// A bare NEEDS INPUT: line asks through its default: line, so that line is kept (cut) with it.
|
|
80
|
+
// Blank lines between them and the default: line's own indent say nothing, so they go first; otherwise they could push it out.
|
|
81
|
+
if (!question.replace(CLOSING_QUESTION, "").trim())
|
|
82
|
+
return `${[question, ...after.map((line) => line.trim())].join("\n").slice(0, max - 1)}…`;
|
|
83
|
+
return question.length <= max ? question : `${question.slice(0, max - 1)}…`;
|
|
84
|
+
}
|
|
85
|
+
const room = max - tail.length - 3;
|
|
86
|
+
return room > 0 ? `${text.slice(0, room).trimEnd()}\n…\n${tail}` : tail;
|
|
87
|
+
}
|
|
@@ -11,6 +11,7 @@ import { startDueTimer } from "./due-timer.js";
|
|
|
11
11
|
import { intervalAllowsOccurrence, intervalHasRestrictions, isSameLocalDay, latestIntervalOccurrence } from "./routine-intervals.js";
|
|
12
12
|
import { cloneSchedule, limitResetOccurrence, mergeScheduleUpdate, nextOccurrence, RoutineScheduleError } from "./routine-schedules.js";
|
|
13
13
|
import { runsOnce } from "../shared/limit-reset.js";
|
|
14
|
+
import { limitResetRunOwed } from "./limit-reset-owed.js";
|
|
14
15
|
import { ROUTINE_HANDOFF_WAIT, isRoutineProblemRun, } from "../shared/routines.js";
|
|
15
16
|
import { composeExecutionPrompt, continuityCarry, ROUTINE_DEFERRAL_NOTICE_MS, ROUTINE_SKIPPED_WHILE_WAITING, ROUTINE_SUPERSEDED, routineFailure, routineHostWarning, skipNeedsNotice, supersededBy, } from "./routine-execution.js";
|
|
16
17
|
import { dispatchRefusal, engineFacts, loadOwnerNotices, nextScheduledRun, recoverRun, requeueOnce, weekRuns, } from "./routine-recovery.js";
|
|
@@ -21,7 +22,7 @@ import { attachmentPathsOf, attachmentsMalformed, cloneAttachments } from "./rou
|
|
|
21
22
|
import { loadInstalledPackage, loadRequestReceipts, loadRoutine, loadRun } from "./routine-load.js";
|
|
22
23
|
import { applyHolds, holdCauses } from "./routine-holds.js";
|
|
23
24
|
import { sanitizeInput } from "./routine-input.js";
|
|
24
|
-
import { applyCheckResult, routineLine, runLineFields } from "./routine-lines.js";
|
|
25
|
+
import { applyCheckResult, clipRunOutput, routineLine, runLineFields } from "./routine-lines.js";
|
|
25
26
|
import { checkHold, CHECK_BOOT_HOLD_MS } from "./routine-check-pacing.js";
|
|
26
27
|
import { resolveRoutineResultsThread, routineRunDefinition } from "./routine-run-definition.js";
|
|
27
28
|
export { intervalHasRestrictions } from "./routine-intervals.js";
|
|
@@ -668,10 +669,10 @@ export class RoutineManager {
|
|
|
668
669
|
this.emitRoutine(routine);
|
|
669
670
|
return moved.length;
|
|
670
671
|
}
|
|
671
|
-
/** The engines' reset times changed: each limit-reset routine that is on takes its engine's new time. */
|
|
672
|
+
/** The engines' reset times changed: each limit-reset routine that is on takes its engine's new time, once the run it owes a passed reset was made (limit-reset-owed.ts). */
|
|
672
673
|
retimeLimitResets() {
|
|
673
674
|
const moved = this.routines.filter((routine) => {
|
|
674
|
-
if (!routine.enabled || routine.schedule.type !== "limit_reset")
|
|
675
|
+
if (!routine.enabled || routine.schedule.type !== "limit_reset" || limitResetRunOwed(routine, this.runs, this.now()))
|
|
675
676
|
return false;
|
|
676
677
|
const schedule = this.timedSchedule(routine.schedule, routine.id);
|
|
677
678
|
if (schedule.type !== "limit_reset" || (schedule.at === routine.schedule.at && schedule.at === routine.nextRunAt))
|
|
@@ -931,7 +932,10 @@ export class RoutineManager {
|
|
|
931
932
|
}
|
|
932
933
|
const paused = run.target === "room-goal" ? null : this.options.pausedText?.(run.botId);
|
|
933
934
|
if (paused) {
|
|
934
|
-
this.
|
|
935
|
+
if (triggerSource !== "manual" && this.options.held?.(run.botId))
|
|
936
|
+
void this.cancelRun(run.id, paused);
|
|
937
|
+
else
|
|
938
|
+
this.failRun(run, paused);
|
|
935
939
|
continue;
|
|
936
940
|
}
|
|
937
941
|
const startedAt = this.now();
|
|
@@ -1081,7 +1085,7 @@ export class RoutineManager {
|
|
|
1081
1085
|
run.attention = undefined;
|
|
1082
1086
|
}
|
|
1083
1087
|
else if (event.type === "item.completed" && event.itemType === "assistant_text") {
|
|
1084
|
-
run.output = redactSecretsInText(event.text).trim()
|
|
1088
|
+
run.output = clipRunOutput(redactSecretsInText(event.text).trim(), 2_000);
|
|
1085
1089
|
}
|
|
1086
1090
|
else if (event.type === "runtime.error") {
|
|
1087
1091
|
Object.assign(run, runLineFields("error", event.message, event.text));
|
|
@@ -159,6 +159,9 @@ function evidenceLine(evidence) {
|
|
|
159
159
|
if (shown.length)
|
|
160
160
|
parts.push(`outward actions done (${shown.join(", ")}${more})`);
|
|
161
161
|
}
|
|
162
|
+
const served = quote(evidence.servedBy, NAME_MAX);
|
|
163
|
+
if (served)
|
|
164
|
+
parts.push(`done by ${served}, not the assignee's own AI`);
|
|
162
165
|
const summary = quote(evidence.summary, QUOTE_MAX);
|
|
163
166
|
if (!parts.length && !summary)
|
|
164
167
|
return "The harness observed nothing of this turn.";
|
|
@@ -13,6 +13,7 @@ const evidenceSchema = z.object({
|
|
|
13
13
|
okToolCalls: z.number().int().nonnegative().optional(),
|
|
14
14
|
errors: z.array(z.string()).optional(),
|
|
15
15
|
outward: z.array(z.string()).optional(),
|
|
16
|
+
servedBy: z.string().optional(),
|
|
16
17
|
});
|
|
17
18
|
const assignmentSchema = z.object({
|
|
18
19
|
id: z.string().min(1),
|
|
@@ -47,3 +47,46 @@ export class SendSequencer {
|
|
|
47
47
|
export function sendFingerprint(text, replyToId, channelMode) {
|
|
48
48
|
return JSON.stringify([text, replyToId ?? null, channelMode ?? null]);
|
|
49
49
|
}
|
|
50
|
+
/** A Stop's `stopId`: the same client-generated form as a `sendId`. Null when one is sent but malformed. */
|
|
51
|
+
export function parseStopId(value) {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
const parsed = sendIdSchema.safeParse(value);
|
|
55
|
+
return parsed.success && parsed.data !== undefined ? parsed.data : null;
|
|
56
|
+
}
|
|
57
|
+
/** One answer per Stop. A phone resends a POST when its pooled connection dies, so a Stop it resends must not stop the
|
|
58
|
+
* turn that started after the first one did: every resend of a key within `keepMs` gets the first one's answer. An
|
|
59
|
+
* attempt that throws keeps no answer, so its resend runs again. */
|
|
60
|
+
export class StopReceipts {
|
|
61
|
+
receipts = new Map();
|
|
62
|
+
keepMs;
|
|
63
|
+
max;
|
|
64
|
+
now;
|
|
65
|
+
constructor(options = {}) {
|
|
66
|
+
this.keepMs = options.keepMs ?? 10 * 60_000;
|
|
67
|
+
this.max = options.max ?? 1_000;
|
|
68
|
+
this.now = options.now ?? Date.now;
|
|
69
|
+
}
|
|
70
|
+
run(key, stop) {
|
|
71
|
+
if (!key)
|
|
72
|
+
return stop();
|
|
73
|
+
const now = this.now();
|
|
74
|
+
for (const [old, receipt] of this.receipts) {
|
|
75
|
+
if (now - receipt.at < this.keepMs)
|
|
76
|
+
break;
|
|
77
|
+
this.receipts.delete(old);
|
|
78
|
+
}
|
|
79
|
+
const kept = this.receipts.get(key);
|
|
80
|
+
if (kept)
|
|
81
|
+
return kept.answer;
|
|
82
|
+
const entry = { at: now, answer: stop() };
|
|
83
|
+
this.receipts.set(key, entry);
|
|
84
|
+
if (this.receipts.size > this.max)
|
|
85
|
+
this.receipts.delete(this.receipts.keys().next().value);
|
|
86
|
+
entry.answer.catch(() => {
|
|
87
|
+
if (this.receipts.get(key) === entry)
|
|
88
|
+
this.receipts.delete(key);
|
|
89
|
+
});
|
|
90
|
+
return entry.answer;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -203,6 +203,26 @@ export class SharedComputers {
|
|
|
203
203
|
return this.lent?.list(principal).some(record => record.id === id && record.stoppedAt === null) ?? false;
|
|
204
204
|
}
|
|
205
205
|
online(entry) { return this.sessionLive(entry.owner.session) && Date.now() - entry.seen < 40_000; }
|
|
206
|
+
/** One computer can be registered twice after the desktop pairs again: the old session stays signed in, so its entry
|
|
207
|
+
* remains, and it is the one inserted first. A request or the known list has to use the entry that is polling. */
|
|
208
|
+
prefer(current, candidate) {
|
|
209
|
+
if (!current)
|
|
210
|
+
return candidate;
|
|
211
|
+
const currentOnline = this.online(current);
|
|
212
|
+
const candidateOnline = this.online(candidate);
|
|
213
|
+
if (candidateOnline !== currentOnline)
|
|
214
|
+
return candidateOnline ? candidate : current;
|
|
215
|
+
return candidate.seen >= current.seen ? candidate : current;
|
|
216
|
+
}
|
|
217
|
+
chosen(principal, id) {
|
|
218
|
+
let best;
|
|
219
|
+
for (const candidate of this.computers.values()) {
|
|
220
|
+
if (candidate.registration.id !== id || candidate.owner.person !== principal)
|
|
221
|
+
continue;
|
|
222
|
+
best = this.prefer(best, candidate);
|
|
223
|
+
}
|
|
224
|
+
return best;
|
|
225
|
+
}
|
|
206
226
|
/** The desktop takes a 401 or 403 for a lost sign-in and signs in again, so a stopping server answers 503. */
|
|
207
227
|
authorize(id, session, secret) {
|
|
208
228
|
if (this.closed)
|
|
@@ -252,9 +272,8 @@ export class SharedComputers {
|
|
|
252
272
|
known(principal) {
|
|
253
273
|
if (!principal)
|
|
254
274
|
return [];
|
|
255
|
-
const live = [...this.computers.values()].filter(entry => entry.owner.person === principal);
|
|
256
275
|
return (this.lent?.list(principal) ?? []).map(record => {
|
|
257
|
-
const entry =
|
|
276
|
+
const entry = this.chosen(principal, record.id);
|
|
258
277
|
return { id: record.id, name: record.name, platform: record.platform, online: entry ? this.online(entry) : false, busy: (entry?.jobs.size ?? 0) > 0,
|
|
259
278
|
lent: record.stoppedAt === null, lastSeenAt: entry ? Math.max(entry.seen, record.lastSeenAt) : record.lastSeenAt, lastUsedAt: record.lastUsedAt,
|
|
260
279
|
scopes: { folders: record.folders, terminal: record.terminal, screen: record.screen, internet: record.internet === true, chrome: record.chrome === true } };
|
|
@@ -305,7 +324,13 @@ export class SharedComputers {
|
|
|
305
324
|
if (!principal)
|
|
306
325
|
return [];
|
|
307
326
|
this.reap();
|
|
308
|
-
|
|
327
|
+
const shown = new Map();
|
|
328
|
+
for (const entry of this.computers.values()) {
|
|
329
|
+
if (entry.owner.person !== principal)
|
|
330
|
+
continue;
|
|
331
|
+
shown.set(entry.registration.id, this.prefer(shown.get(entry.registration.id), entry));
|
|
332
|
+
}
|
|
333
|
+
return [...shown.values()].map(entry => ({
|
|
309
334
|
id: entry.registration.id, name: entry.registration.name, online: this.online(entry), busy: entry.jobs.size > 0, lastSeenAt: entry.seen,
|
|
310
335
|
scopes: {
|
|
311
336
|
folders: entry.registration.folders.map(({ id, name, write }) => ({ id, name, write })),
|
|
@@ -346,8 +371,12 @@ export class SharedComputers {
|
|
|
346
371
|
entry.wake = wake;
|
|
347
372
|
});
|
|
348
373
|
this.authorize(id, session, secret);
|
|
349
|
-
|
|
350
|
-
|
|
374
|
+
// A poll whose client already left, or that a newer poll replaced, must not mark this registration
|
|
375
|
+
// just seen. After a re-pair that would make the old session look like the live one.
|
|
376
|
+
if (entry.polls === mine && !gone?.aborted) {
|
|
377
|
+
entry.seen = Date.now();
|
|
378
|
+
this.lent?.seen(entry.owner.person, id);
|
|
379
|
+
}
|
|
351
380
|
return next();
|
|
352
381
|
}
|
|
353
382
|
send(entry, job) {
|
|
@@ -399,7 +428,7 @@ export class SharedComputers {
|
|
|
399
428
|
async request(operation, principal, active) {
|
|
400
429
|
if (!principal)
|
|
401
430
|
throw failure("This conversation cannot use a shared computer: only a conversation started by the person who shared it can.", 403);
|
|
402
|
-
const lent = () =>
|
|
431
|
+
const lent = () => this.chosen(principal, operation.computer_id);
|
|
403
432
|
for (const deadline = Date.now() + RECONNECT_WAIT_MS;;) {
|
|
404
433
|
const known = lent();
|
|
405
434
|
if (known && this.online(known))
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// A person's last look changes in history.json beside their themes, oldest first: what they wore before and after, and
|
|
2
|
+
// each theme file a change rewrote as it was before it, so any kept change can be gone back to.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { SKIN_IDS } from "../../shared/app-settings.js";
|
|
7
|
+
import { LOOK_CHANGE_KINDS, LOOK_HISTORY_LIMIT, THEME_ASSET_NAME, THEME_ID, themeFileSchema } from "../../shared/theme.js";
|
|
8
|
+
import { writeFileAtomic } from "../atomic.js";
|
|
9
|
+
const skinSchema = z.enum([...SKIN_IDS, "system"]);
|
|
10
|
+
/** What a person wears: their saved theme, or none; and the built-in skin underneath when one is known. */
|
|
11
|
+
const lookSchema = z.object({ id: z.string().regex(THEME_ID).nullable(), skin: skinSchema.optional() }).strict();
|
|
12
|
+
/** A theme file as it was; null when the theme did not exist yet. Its pictures and fonts stay in the theme's folder, so
|
|
13
|
+
* only their names are kept. */
|
|
14
|
+
const snapshotSchema = z.object({ file: themeFileSchema.nullable(), assets: z.array(z.string().regex(THEME_ASSET_NAME)) }).strict();
|
|
15
|
+
const entrySchema = z.object({
|
|
16
|
+
seq: z.number().int().positive(),
|
|
17
|
+
at: z.string(),
|
|
18
|
+
change: z.object({ kind: z.enum(LOOK_CHANGE_KINDS), name: z.string().max(60).optional(), count: z.number().int().positive().optional() }).strict(),
|
|
19
|
+
before: lookSchema,
|
|
20
|
+
after: lookSchema,
|
|
21
|
+
themes: z.record(z.string().regex(THEME_ID), snapshotSchema).optional(),
|
|
22
|
+
}).strict();
|
|
23
|
+
const historySchema = z.object({ entries: z.array(entrySchema) }).strict();
|
|
24
|
+
const FILE = "history.json";
|
|
25
|
+
export function readHistory(folder) {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = historySchema.safeParse(JSON.parse(readFileSync(join(folder, FILE), "utf8")));
|
|
28
|
+
return parsed.success ? parsed.data.entries : [];
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function appendHistory(folder, entry, now = new Date()) {
|
|
35
|
+
const entries = readHistory(folder);
|
|
36
|
+
const seq = (entries.at(-1)?.seq ?? 0) + 1;
|
|
37
|
+
const kept = [...entries, { ...entry, seq, at: now.toISOString() }].slice(-LOOK_HISTORY_LIMIT);
|
|
38
|
+
writeFileAtomic(join(folder, FILE), `${JSON.stringify({ entries: kept })}\n`);
|
|
39
|
+
}
|
|
40
|
+
/** How things looked right after change `seq`: what was worn, and every theme file changed since as it was then. Null
|
|
41
|
+
* when that change is no longer kept; `undone` empty when it is the latest. */
|
|
42
|
+
export function lookAfter(entries, seq) {
|
|
43
|
+
const first = entries[0];
|
|
44
|
+
if (!first || seq < first.seq - 1 || seq > entries.at(-1).seq)
|
|
45
|
+
return null;
|
|
46
|
+
const undone = entries.filter((entry) => entry.seq > seq);
|
|
47
|
+
const themes = {};
|
|
48
|
+
for (const entry of undone) {
|
|
49
|
+
for (const [id, snapshot] of Object.entries(entry.themes ?? {}))
|
|
50
|
+
themes[id] ??= snapshot;
|
|
51
|
+
}
|
|
52
|
+
const look = undone[0]?.before ?? entries.at(-1).after;
|
|
53
|
+
return { look, themes, undone };
|
|
54
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createReadStream } from "node:fs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SKIN_IDS } from "../../shared/app-settings.js";
|
|
4
|
+
import { THEME_ID, THEME_LIMITS, themeExportSchema, themeFileSchema } from "../../shared/theme.js";
|
|
5
|
+
import { PASS } from "../routes/table.js";
|
|
6
|
+
import { isRefusal } from "./store.js";
|
|
7
|
+
const THEME_PATH = /^\/api\/themes\/([a-z0-9][a-z0-9-]{0,47})(\/duplicate|\/export)?$/;
|
|
8
|
+
const ASSET_PATH = /^\/api\/theme-assets\/([a-z0-9][a-z0-9-]{0,47})\/([a-z0-9][a-z0-9._-]{0,99})$/;
|
|
9
|
+
const IMPORT_LIMIT = Math.ceil(THEME_LIMITS.themeBytes * 1.4) + THEME_LIMITS.cssChars * 4 + 100_000;
|
|
10
|
+
const activeBody = z.object({ id: z.string().regex(THEME_ID).nullable(), skin: z.enum([...SKIN_IDS, "system"]).optional() }).strict();
|
|
11
|
+
const saveBody = z.object({ theme: themeFileSchema }).strict();
|
|
12
|
+
const nameBody = z.object({ name: z.string().trim().min(1).max(60) }).strict();
|
|
13
|
+
const historyBody = z.object({ index: z.number().int().positive() }).strict();
|
|
14
|
+
export function createThemeRoutes(deps) {
|
|
15
|
+
const { store } = deps;
|
|
16
|
+
return async ({ req, res, path, method, auth, json, readBody }) => {
|
|
17
|
+
const asset = method === "GET" || method === "HEAD" ? ASSET_PATH.exec(path) : null;
|
|
18
|
+
if (!asset && path !== "/api/themes" && !path.startsWith("/api/themes/"))
|
|
19
|
+
return PASS;
|
|
20
|
+
const person = deps.person(auth);
|
|
21
|
+
if (!person)
|
|
22
|
+
return json(res, 403, { error: "Themes belong to a signed-in person." });
|
|
23
|
+
if (asset) {
|
|
24
|
+
const file = store.asset(person, asset[1], asset[2]);
|
|
25
|
+
if (!file)
|
|
26
|
+
return json(res, 404, { error: "No such theme file." });
|
|
27
|
+
const etag = `"${file.bytes.toString(36)}-${Math.floor(file.mtimeMs).toString(36)}"`;
|
|
28
|
+
// Security: an SVG opened on its own would run as a page of this origin; sandboxed with nothing allowed, it cannot.
|
|
29
|
+
const headers = {
|
|
30
|
+
"Content-Type": file.type, "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-cache", ETag: etag,
|
|
31
|
+
"Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:; sandbox", "Cross-Origin-Resource-Policy": "same-origin",
|
|
32
|
+
};
|
|
33
|
+
if (req.headers["if-none-match"] === etag) {
|
|
34
|
+
res.writeHead(304, headers);
|
|
35
|
+
res.end();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
res.writeHead(200, { ...headers, "Content-Length": String(file.bytes) });
|
|
39
|
+
if (method === "HEAD")
|
|
40
|
+
return void res.end();
|
|
41
|
+
createReadStream(file.path).pipe(res);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (path === "/api/themes" && method === "GET")
|
|
45
|
+
return json(res, 200, store.list(person));
|
|
46
|
+
if (path === "/api/themes/active") {
|
|
47
|
+
if (method === "GET") {
|
|
48
|
+
const id = store.active(person);
|
|
49
|
+
return json(res, 200, { id, theme: id ? store.read(person, id) : null });
|
|
50
|
+
}
|
|
51
|
+
if (method !== "PUT")
|
|
52
|
+
return json(res, 405, { error: "GET or PUT" });
|
|
53
|
+
const parsed = activeBody.safeParse(await readBody(req));
|
|
54
|
+
if (!parsed.success)
|
|
55
|
+
return json(res, 400, { error: "id must be a saved theme's id or null" });
|
|
56
|
+
const done = store.change(person, { wear: parsed.data.id, ...(parsed.data.skin ? { skin: parsed.data.skin } : {}) });
|
|
57
|
+
if (isRefusal(done))
|
|
58
|
+
return json(res, 404, { error: done.refusal });
|
|
59
|
+
deps.changed(person, done.skin);
|
|
60
|
+
return json(res, 200, { ok: true });
|
|
61
|
+
}
|
|
62
|
+
if (path === "/api/themes/history") {
|
|
63
|
+
const items = store.history(person);
|
|
64
|
+
if (method === "GET")
|
|
65
|
+
return json(res, 200, { items: items.map(({ index, at, kind, name, count }) => ({ index, at, kind, name, count })) });
|
|
66
|
+
if (method !== "POST")
|
|
67
|
+
return json(res, 405, { error: "GET or POST" });
|
|
68
|
+
const parsed = historyBody.safeParse(await readBody(req));
|
|
69
|
+
const target = parsed.success ? items.find((item) => item.index === parsed.data.index) : undefined;
|
|
70
|
+
if (!target)
|
|
71
|
+
return json(res, 400, { error: "index must be one of the changes listed." });
|
|
72
|
+
const done = store.restore(person, target.seq);
|
|
73
|
+
if (isRefusal(done))
|
|
74
|
+
return json(res, 409, { error: done.refusal });
|
|
75
|
+
deps.changed(person, done.skin);
|
|
76
|
+
return json(res, 200, { ok: true });
|
|
77
|
+
}
|
|
78
|
+
if (path === "/api/themes/import" && method === "POST") {
|
|
79
|
+
const parsed = themeExportSchema.safeParse(await readBody(req, IMPORT_LIMIT));
|
|
80
|
+
if (!parsed.success)
|
|
81
|
+
return json(res, 400, { error: "This is not a MausBot theme file." });
|
|
82
|
+
const imported = store.importTheme(person, parsed.data);
|
|
83
|
+
return isRefusal(imported) ? json(res, 400, { error: imported.refusal }) : json(res, 200, imported);
|
|
84
|
+
}
|
|
85
|
+
const match = THEME_PATH.exec(path);
|
|
86
|
+
if (!match)
|
|
87
|
+
return json(res, 404, { error: "No such theme route." });
|
|
88
|
+
const id = match[1];
|
|
89
|
+
if (match[2] === "/export" && method === "GET") {
|
|
90
|
+
const data = store.exportTheme(person, id);
|
|
91
|
+
return data ? json(res, 200, data) : json(res, 404, { error: "No such theme." });
|
|
92
|
+
}
|
|
93
|
+
if (match[2] === "/duplicate" && method === "POST") {
|
|
94
|
+
const parsed = nameBody.safeParse(await readBody(req));
|
|
95
|
+
if (!parsed.success)
|
|
96
|
+
return json(res, 400, { error: "name is required" });
|
|
97
|
+
const copy = store.duplicate(person, id, parsed.data.name);
|
|
98
|
+
return isRefusal(copy) ? json(res, 400, { error: copy.refusal }) : json(res, 200, copy);
|
|
99
|
+
}
|
|
100
|
+
if (match[2])
|
|
101
|
+
return json(res, 405, { error: "Method not allowed." });
|
|
102
|
+
if (method === "GET") {
|
|
103
|
+
const theme = store.read(person, id);
|
|
104
|
+
return theme ? json(res, 200, { id, theme }) : json(res, 404, { error: "No such theme." });
|
|
105
|
+
}
|
|
106
|
+
if (method === "PUT") {
|
|
107
|
+
const parsed = saveBody.safeParse(await readBody(req, THEME_LIMITS.cssChars * 4 + 50_000));
|
|
108
|
+
if (!parsed.success)
|
|
109
|
+
return json(res, 400, { error: parsed.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ") });
|
|
110
|
+
const done = store.change(person, { saves: [{ id, file: parsed.data.theme }] });
|
|
111
|
+
if (isRefusal(done))
|
|
112
|
+
return json(res, 400, { error: done.refusal });
|
|
113
|
+
if (store.active(person) === id)
|
|
114
|
+
deps.changed(person);
|
|
115
|
+
return json(res, 200, { ok: true });
|
|
116
|
+
}
|
|
117
|
+
if (method === "PATCH") {
|
|
118
|
+
const parsed = nameBody.safeParse(await readBody(req));
|
|
119
|
+
const theme = store.read(person, id);
|
|
120
|
+
if (!parsed.success || !theme)
|
|
121
|
+
return json(res, parsed.success ? 404 : 400, { error: parsed.success ? "No such theme." : "name is required" });
|
|
122
|
+
const refusal = store.save(person, id, { ...theme, name: parsed.data.name });
|
|
123
|
+
if (refusal)
|
|
124
|
+
return json(res, 400, { error: refusal.refusal });
|
|
125
|
+
return json(res, 200, { ok: true });
|
|
126
|
+
}
|
|
127
|
+
if (method === "DELETE") {
|
|
128
|
+
const wasActive = store.active(person) === id;
|
|
129
|
+
store.remove(person, id);
|
|
130
|
+
if (wasActive)
|
|
131
|
+
deps.changed(person);
|
|
132
|
+
return json(res, 200, { ok: true });
|
|
133
|
+
}
|
|
134
|
+
return json(res, 405, { error: "Method not allowed." });
|
|
135
|
+
};
|
|
136
|
+
}
|