@seira-bot/seira 0.1.180 → 0.1.181
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-DpipGqnm.js → ActivityPanel-tZLxRHYi.js} +1 -1
- package/dist/assets/{AnnouncementsPage-GCXia4xK.js → AnnouncementsPage-BrGYAaS0.js} +1 -1
- package/dist/assets/{App-BIllYA_e.js → App-h8WTNY4l.js} +136 -136
- package/dist/assets/{AppEventEditor-DYdUkpiM.js → AppEventEditor-CLpZ2lyb.js} +1 -1
- package/dist/assets/{BotSettingsDialog-DxRMUwAP.js → BotSettingsDialog-COjDhP9V.js} +1 -1
- package/dist/assets/{BrowserPanel-Cu_GqDA1.js → BrowserPanel-D_kPeSZ3.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js} +1 -1
- package/dist/assets/{CloudAddDialog-DUk6i4df.js → CloudAddDialog-vwGwJIYN.js} +1 -1
- package/dist/assets/{ComputerFilesPane-HvpeAXhL.js → ComputerFilesPane-DJu1k1Ap.js} +1 -1
- package/dist/assets/{ComputerPanel-CozzFQeF.js → ComputerPanel-D9bTedHq.js} +2 -2
- package/dist/assets/{DataPanel-DGqcWB1O.js → DataPanel-CsuS_ybT.js} +1 -1
- package/dist/assets/{DesktopViewer-BoBSIDfB.js → DesktopViewer-YvIV04Lf.js} +1 -1
- package/dist/assets/{EnginesSettings-D643-yZk.js → EnginesSettings-C27xDaBN.js} +1 -1
- package/dist/assets/{FilesView-b5DFlMDt.js → FilesView-Dsxj73nW.js} +1 -1
- package/dist/assets/{GrokMoveDialog-gGTLfrGg.js → GrokMoveDialog-DEgRQW9G.js} +1 -1
- package/dist/assets/{ImportDialog-Bu5X6qOF.js → ImportDialog-DLVTgN-h.js} +1 -1
- package/dist/assets/{InspectorPanel-DU7_iwQR.js → InspectorPanel-gvFj5wfe.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-Wxnn1d66.js → KeyboardShortcutsModal-aF0vhD29.js} +1 -1
- package/dist/assets/{LiveDesktop-D9PC-iAT.js → LiveDesktop-Bca91cEb.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-0YxB-I-X.js → LocalVmWorkspace-CVLDY3ws.js} +1 -1
- package/dist/assets/{MacLocalControl-DoEGcs3V.js → MacLocalControl-BeNWQ9oY.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CAlARwd0.js → MarkdownFilePreview-CYw3CQ3T.js} +1 -1
- package/dist/assets/{MenuMotion-DfjnHTCi.js → MenuMotion-CHp-hB40.js} +1 -1
- package/dist/assets/{NewBotDialog-D3i7j_KP.js → NewBotDialog-BxeQktoI.js} +1 -1
- package/dist/assets/{PhoneAppDialog-OeXLO0Wb.js → PhoneAppDialog-CIlw_m5U.js} +1 -1
- package/dist/assets/{PlacesRail-3RaNlpug.js → PlacesRail-Df-jNTHn.js} +1 -1
- package/dist/assets/PluginsPanel-CMqZcDkC.js +8 -0
- package/dist/assets/{ProIntroduction-B3phUWnc.js → ProIntroduction-D8hWm9R5.js} +1 -1
- package/dist/assets/{PublishedAppsPage-BXWDYkhG.js → PublishedAppsPage-BMn3C64O.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-vgrEf5B7.js → RemoteAgentSettingsPanel-B7QJizjx.js} +1 -1
- package/dist/assets/{RoomPanel-BmXypXPv.js → RoomPanel-CyWZ4kkq.js} +1 -1
- package/dist/assets/RoutinesPage-B9kKyfFp.js +2 -0
- package/dist/assets/{ServerPairingCard-c2fKq1gh.js → ServerPairingCard-D21dP5Bc.js} +1 -1
- package/dist/assets/SettingsModal-afRPXeYI.js +2 -0
- package/dist/assets/{ShareDepartmentDialog-CJITsmAd.js → ShareDepartmentDialog-CwErWDth.js} +1 -1
- package/dist/assets/{SignedInSites-B2pCMdic.js → SignedInSites-CFyvOLSc.js} +1 -1
- package/dist/assets/{TeamFilesPage-B10cdbwa.js → TeamFilesPage-BvhXs2O5.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-CRmTfBOI.js → TeamLibraryPanel-Dm8wjNB4.js} +1 -1
- package/dist/assets/{TeamMapPage-BoTNppEy.js → TeamMapPage-jCSzFPvB.js} +1 -1
- package/dist/assets/{ToolPageShell-BPd_nyJ8.js → ToolPageShell-DKZUregg.js} +1 -1
- package/dist/assets/{TriggersPage-DDxtJMT4.js → TriggersPage-wSB6z1cp.js} +1 -1
- package/dist/assets/{VisibilitySection-Cd3TZvS_.js → VisibilitySection-CFr6fOzq.js} +1 -1
- package/dist/assets/{WebhookTrigger-AJduidiC.js → WebhookTrigger-BJN-V-bx.js} +1 -1
- package/dist/assets/{WorksOnGrid-DHo10o0j.js → WorksOnGrid-B3wYro9M.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-DnIZyeSK.js → abnfDiagram-YUKMZFIV-DRhWKTiz.js} +1 -1
- package/dist/assets/{activity-DrX2_Hm9.js → activity-l0oTqbd6.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-DHdulT2e.js → architectureDiagram-47P4ROYG-C_qnTvJF.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BGReDH4k.js → blockDiagram-E7TT5TSB-DzLSloVY.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-BV9zDZsL.js → c4Diagram-CRA5TL53-BzVViHCA.js} +1 -1
- package/dist/assets/{calendar-days-Ddhxf1PV.js → calendar-days-DFd3GKf_.js} +1 -1
- package/dist/assets/channel-B2D6cAE5.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DAj16syq.js → chunk-2Q5K7J3B-hR-bQJHo.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CMyoXW_3.js → chunk-5VM5RSS4-BWmBW1XC.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW--z54G8Jv.js → chunk-7TKQ45FW-DuUk7RXl.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-CPPbUHIj.js → chunk-AW2ZBBNX-Madgl1uv.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-pKEz9wbK.js → chunk-FVRAUYC3-WSgsvIGA.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-DIOqwx2X.js → chunk-HTAEGDNF-CfoPR2yG.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BW474-Li.js → chunk-JWPE2WC7-tLRHdBom.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DjAEB-Df.js → chunk-KQW6MTUR-BqwuNuVY.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CMZz2xNV.js → chunk-XXDRQBXY-BOeb8xE4.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-7GYDWs2n.js → classDiagram-v2-K4WV4PDN-CFeH5trZ.js} +1 -1
- package/dist/assets/{core-Dq4LUz6X.js → core-CnInZb-o.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Dy2zOVu3.js → cose-bilkent-JH36ORCC-BEg68hhI.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-C7I3qmqf.js → cynefin-EF2NZ3EQ-B_Xq3hQ3.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-CsPcUXHD.js → cynefinDiagram-3GCD6N5R-DN1o2ihW.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DxvGlifm.js → dagre-W4DXFKR2-BFf83-nP.js} +1 -1
- package/dist/assets/{de-CrlnmnfQ.js → de-BpsYkrLY.js} +1 -1
- package/dist/assets/{desktop-connection-Df-k5QBM.js → desktop-connection-CU6jsy2e.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-Qz2-e2_u.js → diagram-2UJZ2QOL-_qwbS5JH.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-D1u4ioUX.js → diagram-OVF4WLC6-9sq9EfiF.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-DZiCtcMI.js → diagram-PFPMY2P6-Ow1v5ZhK.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-DmVn9h1H.js → diagram-UMYRVEAY-DDTBFPls.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CJK2ajcB.js → diagram-YEKJPTXX-D1zZ8KqI.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-NoYT_JX9.js → diagram-ZIFT7M5P-C_vZWUw8.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BooF3Pem.js → ebnfDiagram-VR2GEFS7-D_1GvBDx.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-4Ai0igvq.js → elk-IJKZMXRS-CV-PzspH.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-CdhhzqVX.js → erDiagram-O2IAPWRE-CnKVd0av.js} +1 -1
- package/dist/assets/{es-BIPy8tP9.js → es-COLCGADa.js} +1 -1
- package/dist/assets/{file-up-Bs5NWcjw.js → file-up-Bjx5Vcmk.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-SeyZJAiT.js → flowDiagram-OXPTDLAJ-CGJh171P.js} +1 -1
- package/dist/assets/{fr-CCbXz1Dc.js → fr-CJ1x1iRl.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-rmA_SJlC.js → ganttDiagram-R7TSEDQI-CygoACFs.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-Coc2oeHo.js → gitGraphDiagram-XJZIOB7I-ByxErzHV.js} +1 -1
- package/dist/assets/{hi-DmCL9a_Y.js → hi-BC0iO7jD.js} +1 -1
- package/dist/assets/{index-uiyAwyX1.js → index-BRfvYRb5.js} +1 -1
- package/dist/assets/{index-D69O3YiA.js → index-DQZxP2c4.js} +2 -2
- package/dist/assets/{index-C1PEx1tc.js → index-DtDQrExn.js} +3 -3
- package/dist/assets/{infoDiagram-5W2HQ5XZ-DScYPtht.js → infoDiagram-5W2HQ5XZ-BlzjfTwq.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-Cf7mJB_l.js → ishikawaDiagram-K3B6WC7H-2rf_4lR_.js} +1 -1
- package/dist/assets/{it-BWkdcVfm.js → it-BIwsqdpz.js} +2 -2
- package/dist/assets/{ja-BaOL6cSA.js → ja-BJYXkO5E.js} +2 -2
- package/dist/assets/{journeyDiagram-COXZFDF6-Dtmolw3A.js → journeyDiagram-COXZFDF6-mGgPoETt.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-CSL1-s5L.js → kanban-definition-P3RFRI5V-j2hU8Bw4.js} +1 -1
- package/dist/assets/{kit-Cjq8TV0N.js → kit-qjammJR4.js} +1 -1
- package/dist/assets/{ko-ebMBLBXv.js → ko-7QtaPFvf.js} +2 -2
- package/dist/assets/{livekit-KT4NEVZO-B3DA1PsD.js → livekit-KT4NEVZO-DbFoU2r9.js} +1 -1
- package/dist/assets/{mcp-servers-DoMFsds6.js → mcp-servers-Tb2cnkiM.js} +1 -1
- package/dist/assets/{memory-BR-ujoQY.js → memory-BNaMRI5v.js} +1 -1
- package/dist/assets/{mermaid.core-BK1qxlD4.js → mermaid.core-B1mlFiOp.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-Cb7ESZ0y.js → mindmap-definition-LZFPQGKD-C7XLkIzZ.js} +1 -1
- package/dist/assets/{minimize-msM7mbil.js → minimize-Dga3UCb8.js} +1 -1
- package/dist/assets/{monitor-DpsqT1_R.js → monitor-DMPjQDZP.js} +1 -1
- package/dist/assets/{org-library-alRyzCTE.js → org-library-IKFXm7D6.js} +1 -1
- package/dist/assets/{package-format-BFXbXHk8.js → package-format-COujx3jP.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-CqmJQKhe.js → pegDiagram-BGZESJAR-BS2zKH6g.js} +1 -1
- package/dist/assets/{phones-J7mYR-fY.js → phones-CINpTjZv.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-w_QuumOv.js → pieDiagram-CAPJLFHJ-DVAuLXem.js} +1 -1
- package/dist/assets/{pl-CSbinyb5.js → pl-CLa2ta1_.js} +2 -2
- package/dist/assets/{pt-br-BkWykL5e.js → pt-br-8RQzCbpg.js} +3 -3
- package/dist/assets/{quadrantDiagram-GDMTTRAM-248q9C3h.js → quadrantDiagram-GDMTTRAM-H7QRxmHt.js} +1 -1
- package/dist/assets/{rail-DRr_33Fe.js → rail-DNpLzOxa.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-BLzQ_5t7.js → railroadDiagram-SM67HX2B-dq6Rokc9.js} +1 -1
- package/dist/assets/{remote-desktop-panel-BPK6Q0O6.js → remote-desktop-panel-Cxv6Qt3x.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-Bgi1TLdN.js → requirementDiagram-X7JNWC4A-BeWeL_-r.js} +1 -1
- package/dist/assets/{ru-DD01Hb1S.js → ru-CIdzvRVZ.js} +2 -2
- package/dist/assets/{sankeyDiagram-UM26HJRW-CrZgn-Cf.js → sankeyDiagram-UM26HJRW-BmJ-9lt-.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-gAwq1ZfG.js → sequenceDiagram-ZO4K6R2Y-Uuh1hEOh.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BlXmG_DJ.js → sizeCapture-INFHLROL-mKDf6lys.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-CEFB1Iaq.js → stateDiagram-v2-TBUQTH76-BaEihzov.js} +1 -1
- package/dist/assets/{styles-DOJOOIp4.js → styles-3g-ZPS7M.js} +5 -5
- package/dist/assets/styles-CsrDURJH.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-BtJmWAOz.js → swimlanes-N4OXWK64-CpP-NKGz.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-C50Dm6LQ.js +8 -0
- package/dist/assets/{template-add-BcTS64TG.js → template-add-CHwGLPet.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-BZ270zxf.js → timeline-definition-YOQAKGHF-Ca3rjetv.js} +1 -1
- package/dist/assets/{tr-Bw35A32w.js → tr-BhclavHM.js} +1 -1
- package/dist/assets/{uk-DsPsCgp4.js → uk-Or5wmf6s.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-D5yZb3KQ.js → usecaseDiagram-VIAY4XPW-BuuYl689.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-OFx2qTzp.js → vennDiagram-BLWOH2XV-C__pWnnE.js} +1 -1
- package/dist/assets/{vi-DhPdzwW-.js → vi-CYbGVqh-.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-DzSmrVKa.js → wardleyDiagram-YMQ3BMBF-yWcEHD-N.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-UP1H1u5V.js → xychartDiagram-TAQBALBS-CvcdOA7A.js} +1 -1
- package/dist/assets/{zh-CzC3CUQA.js → zh-iptM1e_T.js} +2 -2
- package/dist/assets/{zh-tw-DeXHnAvy.js → zh-tw-BaO1c--E.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/container-mcp.js +18 -17
- package/dist-server/index.js +1136 -1114
- package/dist-server/openmausbot.js +182 -180
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +182 -180
- package/dist-server/server/ai-pool.js +72 -0
- package/dist-server/server/cloud-connected-apps.js +33 -16
- package/dist-server/server/composio-broker-access.js +1 -1
- package/dist-server/server/composio.js +3 -2
- package/dist-server/server/config.js +5 -7
- package/dist-server/server/connector-auth-config-hint.js +5 -0
- package/dist-server/server/drivers/claude.js +14 -11
- package/dist-server/server/flatpak-host.js +5 -2
- package/dist-server/server/host/ai-pool.js +109 -0
- package/dist-server/server/host/app-suggestions.js +2 -1
- package/dist-server/server/host/limit-takeover.js +11 -4
- package/dist-server/server/index.js +33 -26
- package/dist-server/server/limit-failover.js +3 -0
- package/dist-server/server/model-selection-schema.js +9 -0
- package/dist-server/server/routes/ai-pool-patch.js +24 -0
- package/dist-server/server/routes/config.js +8 -1
- package/dist-server/server/routine-dispatch.js +21 -0
- package/dist-server/server/routines.js +4 -18
- package/dist-server/server/tailscale.js +16 -6
- package/dist-server/server/workspace-backup-http.js +2 -2
- package/dist-server/shared/limit-backup.js +1 -1
- package/dist-server/shared/settings-places.js +1 -0
- package/dist-server/shared/toolkit-card.js +1 -0
- package/dist-server/vps-container-mcp.js +18 -17
- package/dist-server/workspace-backup.worker.js +18 -17
- package/package.json +1 -1
- package/dist/assets/PluginsPanel-B5Q70eO8.js +0 -8
- package/dist/assets/RoutinesPage-CLXohizn.js +0 -2
- package/dist/assets/SettingsModal-BlX9XoBu.js +0 -2
- package/dist/assets/channel-DZM5KU--.js +0 -1
- package/dist/assets/styles-9UFSdSaJ.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-pBTtzroP.js +0 -8
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { otherSignInOfSameSubscription } from "../shared/limit-backup.js";
|
|
3
|
+
import { defaultModelSelectionSchema } from "./model-selection-schema.js";
|
|
4
|
+
/** Default levels, as the share of usage left, from which the pool moves a conversation on. */
|
|
5
|
+
export const AI_POOL_LEVELS = [90, 80, 70, 60, 50, 40, 30, 20, 10];
|
|
6
|
+
export const aiPoolSchema = z.object({
|
|
7
|
+
enabled: z.boolean(),
|
|
8
|
+
/** `even` shares usage by levels of usage left. `inOrder` uses the first AI until it cannot run, then the next. */
|
|
9
|
+
mode: z.enum(["even", "inOrder"]).default("even"),
|
|
10
|
+
/** The AIs that share usage, in order. Two to ten, each at most once. */
|
|
11
|
+
members: z.array(defaultModelSelectionSchema).max(10).default([]),
|
|
12
|
+
/** Usage left, in percent, that `even` mode steps down through. */
|
|
13
|
+
levels: z.array(z.number().int().min(1).max(99)).min(1).max(9).optional(),
|
|
14
|
+
/** Usage left, in percent, at which an AI stops taking new work from the pool. */
|
|
15
|
+
floor: z.number().int().min(0).max(98).optional(),
|
|
16
|
+
}).strict().superRefine((pool, ctx) => {
|
|
17
|
+
const issue = (message, path) => ctx.addIssue({ code: "custom", message, path });
|
|
18
|
+
if (pool.enabled && pool.members.length < 2)
|
|
19
|
+
issue("Choose at least two AIs before you turn on the AI pool.", ["members"]);
|
|
20
|
+
if (new Set(pool.members.map((member) => member.instanceId)).size !== pool.members.length)
|
|
21
|
+
issue("Each AI can join the pool once.", ["members"]);
|
|
22
|
+
const levels = pool.levels;
|
|
23
|
+
if (levels?.some((level, index) => index > 0 && level >= levels[index - 1]))
|
|
24
|
+
issue("Each level must be lower than the one before it.", ["levels"]);
|
|
25
|
+
if (pool.floor !== undefined && pool.floor >= (levels ?? AI_POOL_LEVELS).at(-1))
|
|
26
|
+
issue("The floor must be lower than the last level.", ["floor"]);
|
|
27
|
+
});
|
|
28
|
+
export function poolReading(limit, now) {
|
|
29
|
+
if (!limit || limit.usedPercent === null)
|
|
30
|
+
return { remaining: null, resetsAt: limit?.resetsAt ?? null };
|
|
31
|
+
if (limit.resetsAt !== null && limit.resetsAt <= now)
|
|
32
|
+
return { remaining: null, resetsAt: limit.resetsAt };
|
|
33
|
+
return { remaining: Math.min(100, Math.max(0, 100 - limit.usedPercent)), resetsAt: limit.resetsAt };
|
|
34
|
+
}
|
|
35
|
+
export function samePlanPair(members) {
|
|
36
|
+
for (let i = 0; i < members.length; i++) {
|
|
37
|
+
for (let j = i + 1; j < members.length; j++) {
|
|
38
|
+
if (otherSignInOfSameSubscription(members[i], members[j]) && !members[i].billsEachUse && !members[j].billsEachUse)
|
|
39
|
+
return [i, j];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
export function pickPoolMember(input) {
|
|
45
|
+
const { mode, members, currentIndex, threadLevel, floor } = input;
|
|
46
|
+
const noLevel = input.levels[0];
|
|
47
|
+
const current = members[currentIndex];
|
|
48
|
+
const move = (index, level, why) => ({ index, threadLevel: level, reason: index === currentIndex ? "stay" : current?.eligible ? why : "cannotRun" });
|
|
49
|
+
if (mode === "inOrder") {
|
|
50
|
+
const first = members.findIndex((member) => member.eligible && (member.remaining === null || member.remaining > floor));
|
|
51
|
+
const atFloor = current?.eligible && current.remaining !== null && current.remaining <= floor;
|
|
52
|
+
return move(first === -1 ? currentIndex : first, noLevel, atFloor && first > currentIndex ? "low" : "order");
|
|
53
|
+
}
|
|
54
|
+
const known = members.flatMap((member, index) => (member.eligible && member.remaining !== null ? [{ ...member, index, remaining: member.remaining }] : []));
|
|
55
|
+
const level = [...input.levels, floor].filter((candidate) => known.some((member) => member.remaining > candidate)).reduce((best, candidate) => (best === undefined || candidate > best ? candidate : best), undefined);
|
|
56
|
+
const unknown = members.flatMap((member, index) => (member.eligible && member.remaining === null ? [{ index, paid: member.paid }] : []));
|
|
57
|
+
const unknownPick = () => (unknown.find((member) => !member.paid) ?? unknown.find((member) => member.paid))?.index ?? currentIndex;
|
|
58
|
+
const currentUnknown = current?.eligible && current.remaining === null;
|
|
59
|
+
const moveEven = (index, level, why) => move(index, level, current?.paid && !members[index]?.paid ? "payPerUse" : why);
|
|
60
|
+
if (currentUnknown && !current.paid)
|
|
61
|
+
return move(currentIndex, threadLevel ?? level ?? noLevel, "low");
|
|
62
|
+
if (level === undefined) {
|
|
63
|
+
const free = unknown.find((member) => !member.paid)?.index;
|
|
64
|
+
return moveEven(currentUnknown ? free ?? currentIndex : unknownPick(), threadLevel ?? noLevel, "low");
|
|
65
|
+
}
|
|
66
|
+
const held = Math.min(level, threadLevel ?? level);
|
|
67
|
+
if (current?.eligible && current.remaining !== null && current.remaining > held)
|
|
68
|
+
return move(currentIndex, held, "moreLeft");
|
|
69
|
+
const pick = known.filter((member) => member.remaining > level).sort((a, b) => b.remaining - a.remaining
|
|
70
|
+
|| (a.resetsAt ?? Infinity) - (b.resetsAt ?? Infinity) || a.index - b.index)[0];
|
|
71
|
+
return moveEven(pick.index, level, "moreLeft");
|
|
72
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// A
|
|
2
|
-
// it the way the desktop app registers itself
|
|
3
|
-
//
|
|
4
|
-
// project key the owner saves still wins:
|
|
1
|
+
// A server's own installation on Seira's connected-apps service: a Cloud home's, which its plan includes, and a
|
|
2
|
+
// self-hosted release build's. The server registers it the way the desktop app registers itself
|
|
3
|
+
// (electron/managed-composio.mjs), keeps the token in a 0600 file on the data folder that no backup carries, and hands
|
|
4
|
+
// it to the one managed path (composio.setManagedBrokerAccess). A Composio project key the owner saves still wins:
|
|
5
|
+
// composio.connectionMode checks it first.
|
|
5
6
|
import { readFileSync, rmSync } from "node:fs";
|
|
6
7
|
import { join } from "node:path";
|
|
7
8
|
import { z } from "zod";
|
|
8
9
|
import { ensureManagedComposioCredentials, managedComposioAccess, managedComposioBrokerOff, } from "../electron/managed-composio.mjs";
|
|
9
10
|
import { writeFileAtomic } from "./atomic.js";
|
|
10
11
|
import { managedComposioBrokerUrl } from "../electron/managed-composio.mjs";
|
|
11
|
-
/** In the data folder; excluded from backups (workspace-backup-policy.ts), so a restore keeps the
|
|
12
|
+
/** In the data folder; excluded from backups (workspace-backup-policy.ts), so a restore keeps the server's own. */
|
|
12
13
|
export const CLOUD_CONNECTED_APPS_FILE = "connected-apps-installation.json";
|
|
13
14
|
/** Between attempts while the Cloud holds no token, each with up to a fifth of jitter; the last one repeats. */
|
|
14
15
|
export const CLOUD_CONNECTED_APPS_RETRY_MS = [30_000, 60_000, 120_000, 300_000, 600_000, 1_800_000];
|
|
@@ -173,28 +174,44 @@ export function startCloudConnectedApps(options) {
|
|
|
173
174
|
},
|
|
174
175
|
};
|
|
175
176
|
}
|
|
176
|
-
let
|
|
177
|
+
let started = null;
|
|
177
178
|
/** The connected-apps service a Cloud home and a Team Cloud's members register with: only the one that
|
|
178
179
|
* OMB_COMPOSIO_BROKER_URL names. "" for none. */
|
|
179
180
|
export const cloudConnectedAppsBrokerUrl = () => managedComposioBrokerUrl(process.env.OMB_COMPOSIO_BROKER_URL);
|
|
180
|
-
/** A Cloud home
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
/** A Cloud home registers with the service its plan includes. A self-hosted release build registers too, with
|
|
182
|
+
* Seira's service unless OMB_COMPOSIO_BROKER_URL names another. A token in OMB_COMPOSIO_BROKER_TOKEN replaces
|
|
183
|
+
* registration, and a source run, a desktop child and a hosted workspace register nothing. */
|
|
184
|
+
export function startServerConnectedApps(input) {
|
|
185
|
+
if (started)
|
|
183
186
|
return;
|
|
187
|
+
if (!input.cloudHome && !input.selfHosted)
|
|
188
|
+
return;
|
|
189
|
+
if (!input.cloudHome && process.env.OMB_COMPOSIO_BROKER_TOKEN?.trim())
|
|
190
|
+
return;
|
|
191
|
+
const say = (line) => (input.cloudHome ? `cloud home: ${line}` : line);
|
|
184
192
|
if (managedComposioBrokerOff()) {
|
|
185
|
-
console.log("
|
|
193
|
+
console.log(say("the connected-apps service is switched off (OMB_COMPOSIO_BROKER)"));
|
|
186
194
|
return;
|
|
187
195
|
}
|
|
188
196
|
const configured = process.env.OMB_COMPOSIO_BROKER_URL;
|
|
189
|
-
const brokerUrl =
|
|
197
|
+
const brokerUrl = input.cloudHome
|
|
198
|
+
? cloudConnectedAppsBrokerUrl()
|
|
199
|
+
: managedComposioBrokerUrl(configured, { packaged: input.packaged });
|
|
190
200
|
if (!brokerUrl) {
|
|
191
201
|
if (configured?.trim())
|
|
192
|
-
console.warn("
|
|
202
|
+
console.warn(say("connected-apps service URL rejected: HTTPS or a loopback HTTP URL is required"));
|
|
193
203
|
return;
|
|
194
204
|
}
|
|
195
|
-
|
|
205
|
+
started = startCloudConnectedApps({
|
|
206
|
+
dataDir: input.dataDir,
|
|
207
|
+
brokerUrl,
|
|
208
|
+
apply: input.apply,
|
|
209
|
+
ownKey: input.ownKey,
|
|
210
|
+
...(input.cloudHome ? { cloudGrant: input.cloudGrant } : {}),
|
|
211
|
+
log: (line) => console.log(say(line)),
|
|
212
|
+
});
|
|
196
213
|
}
|
|
197
|
-
export function
|
|
198
|
-
|
|
199
|
-
|
|
214
|
+
export function stopServerConnectedApps() {
|
|
215
|
+
started?.stop();
|
|
216
|
+
started = null;
|
|
200
217
|
}
|
|
@@ -54,7 +54,7 @@ const ERASE_CALL_TIMEOUT_MS = 120_000;
|
|
|
54
54
|
const eraseResponseSchema = z.object({ erased: z.boolean().optional(), sharedUserKept: z.boolean().optional(), error: z.string().optional() });
|
|
55
55
|
/**
|
|
56
56
|
* Erases this installation at the managed service and forgets its token here. A failure throws with the token kept, so
|
|
57
|
-
* the call can be repeated. `clearStored` removes a token this process keeps on disk:
|
|
57
|
+
* the call can be repeated. `clearStored` removes a token this process keeps on disk: the server's own
|
|
58
58
|
* CLOUD_CONNECTED_APPS_FILE. `sharedUserKept` says connected apps stayed because another installation uses them.
|
|
59
59
|
*/
|
|
60
60
|
export async function eraseManagedBrokerInstallation(clearStored) {
|
|
@@ -5,7 +5,7 @@ import { SPAWNED_PROXIES } from "./proxy-paths.js";
|
|
|
5
5
|
import { managedConnectorUnavailableReason, managedCustomAuthReason } from "../shared/connector-availability.js";
|
|
6
6
|
import { DEFAULT_BACKEND_ORIGIN, apiBase, canonicalToolkitSlug, deleteConnectedAccount, inputError, keepAuthConfigPick, listConnectedAccounts, MAX_CONNECTED_ACCOUNT_PAGES, noAuthConfigReason, projectHeaders, refusedAuthConfigReason, responseError, } from "./composio-project.js";
|
|
7
7
|
import { MULTI_ACCOUNT_CONFIG, authConfigRefusal, ensureProjectSession, projectApiKey, raiseAccountCap, sessionForToolkit } from "./composio-session.js";
|
|
8
|
-
import { authConfigUseLine, noManagedAuthToolkit, withNoManagedAuthNote } from "./connector-auth-config-hint.js";
|
|
8
|
+
import { authConfigUseLine, needsOwnAuth, noManagedAuthToolkit, withNoManagedAuthNote } from "./connector-auth-config-hint.js";
|
|
9
9
|
import { planAccountLink } from "../shared/connector-account-link.js";
|
|
10
10
|
import { CONNECTOR_TOOL_NAME_PATTERN } from "../shared/wire.js";
|
|
11
11
|
import { CONNECTOR_ALLOWED_TOOLS_ENV, CONNECTOR_ALLOWED_TOOLS_MAX_BYTES, CONNECTOR_SERVICE_SLUGS_ENV, CONNECTOR_SERVICE_SLUGS_MAX_BYTES, serializeConnectorAllowedTools, serializeConnectorServiceSlugs, } from "./connector-advertisement.js";
|
|
@@ -754,7 +754,7 @@ const CURATED = [
|
|
|
754
754
|
{ slug: "sentry", label: "Sentry", blurb: "Errors and alerts", domain: "sentry.io", logo: null, categories: ["Developer tools"] },
|
|
755
755
|
{ slug: "posthog", label: "PostHog", blurb: "Analytics, feature flags, experiments", domain: "posthog.com", logo: null, categories: ["Analytics"] },
|
|
756
756
|
{ slug: "discord", label: "Discord", blurb: "Messages and channels", domain: "discord.com", logo: null, categories: ["Communication"] },
|
|
757
|
-
{ slug: "twitter", label: "X (Twitter)", blurb: "Post and read on X", domain: "x.com", logo: null, categories: ["Social"] },
|
|
757
|
+
{ slug: "twitter", label: "X (Twitter)", blurb: "Post and read on X", domain: "x.com", logo: null, needsOwnAuth: true, categories: ["Social"] },
|
|
758
758
|
{ slug: "reddit", label: "Reddit", blurb: "Browse and post", domain: "reddit.com", logo: null, categories: ["Social"] },
|
|
759
759
|
{ slug: "zapier", label: "Zapier", blurb: "Connect 9,000+ apps", domain: "zapier.com", logo: null, categories: ["Automation"] },
|
|
760
760
|
{ slug: "hubspot", label: "HubSpot", blurb: "CRM search & updates", domain: "hubspot.com", logo: null, categories: ["Sales and CRM"] },
|
|
@@ -852,6 +852,7 @@ export async function listToolkits(cfg) {
|
|
|
852
852
|
blurb: (t.meta?.description ?? t.description ?? "").slice(0, 90),
|
|
853
853
|
logo: t.meta?.logo ?? t.logo ?? null,
|
|
854
854
|
noAuth: t.no_auth === true,
|
|
855
|
+
...(needsOwnAuth(t) ? { needsOwnAuth: true } : {}),
|
|
855
856
|
domain: null,
|
|
856
857
|
...(toolkitCategories(t.meta?.categories) ? { categories: toolkitCategories(t.meta?.categories) } : {}),
|
|
857
858
|
}));
|
|
@@ -16,7 +16,8 @@ import { withoutComputerEngine } from "./computer-engine-removal.js";
|
|
|
16
16
|
import { newBotDefaultsSchema } from "./new-bot-defaults.js";
|
|
17
17
|
import { replaySettings } from "./replay-settings.js";
|
|
18
18
|
import { EFFORT_LEVELS } from "../shared/wire.js";
|
|
19
|
-
import {
|
|
19
|
+
import { defaultModelSelectionSchema } from "./model-selection-schema.js";
|
|
20
|
+
import { aiPoolSchema } from "./ai-pool.js";
|
|
20
21
|
import { API_KEY_FLEET, DEFAULT_FLEET, OPENAI_API_INSTANCE, OPENROUTER_API_INSTANCE, CLAUDE_API_INSTANCE, PRODUCT_FLEET_ADDITIONS } from "./instance-fleets.js";
|
|
21
22
|
export { CLAUDE_API_INSTANCE, OPENAI_API_INSTANCE, OPENROUTER_API_INSTANCE, XAI_API_INSTANCE } from "./instance-fleets.js";
|
|
22
23
|
import { DEFAULT_WINDOW_MINUTES, MAX_WINDOW_MINUTES } from "./cache-keepwarm.js";
|
|
@@ -251,12 +252,6 @@ const instanceConfigSchema = z.object({
|
|
|
251
252
|
config: z.json().optional(),
|
|
252
253
|
});
|
|
253
254
|
const instanceConfigMapSchema = z.record(z.string(), instanceConfigSchema);
|
|
254
|
-
const defaultModelSelectionSchema = z.object({
|
|
255
|
-
instanceId: z.string().trim().min(1).max(200),
|
|
256
|
-
model: z.string().trim().min(1).max(500),
|
|
257
|
-
effort: z.enum(EFFORT_LEVELS).optional(),
|
|
258
|
-
variant: z.string().refine(isModelVariant, "invalid model variant").optional(),
|
|
259
|
-
}).refine((selection) => selection.variant === undefined || selection.effort === undefined, "choose either a model variant or an effort level");
|
|
260
255
|
const automaticRecoverySchema = z.object({
|
|
261
256
|
enabled: z.boolean(),
|
|
262
257
|
backup: defaultModelSelectionSchema.optional(),
|
|
@@ -292,6 +287,7 @@ const appConfigSchema = z.object({
|
|
|
292
287
|
signIn: z.object({ admins: z.array(z.string().max(320)).max(500).optional(), members: z.array(z.string().max(320)).max(5000).optional() }).optional(),
|
|
293
288
|
defaultModelSelection: defaultModelSelectionSchema.optional(),
|
|
294
289
|
automaticRecovery: automaticRecoverySchema.optional(),
|
|
290
|
+
aiPool: aiPoolSchema.optional(),
|
|
295
291
|
cacheKeepWarm: cacheKeepWarmSchema.optional(),
|
|
296
292
|
newBotDefaults: newBotDefaultsSchema.optional(),
|
|
297
293
|
newBots: newBotsConfigSchema.optional(),
|
|
@@ -826,6 +822,8 @@ export function saveConfig(patch, options = {}) {
|
|
|
826
822
|
// Replace the section so clearing a backup cannot revive the old selection.
|
|
827
823
|
if (checkedPatch.automaticRecovery !== undefined)
|
|
828
824
|
disk.automaticRecovery = checkedPatch.automaticRecovery;
|
|
825
|
+
if (checkedPatch.aiPool !== undefined)
|
|
826
|
+
disk.aiPool = checkedPatch.aiPool;
|
|
829
827
|
if (checkedPatch.cacheKeepWarm !== undefined)
|
|
830
828
|
disk.cacheKeepWarm = checkedPatch.cacheKeepWarm;
|
|
831
829
|
if (checkedPatch.usageCaps !== undefined)
|
|
@@ -37,3 +37,8 @@ export async function withNoManagedAuthNote(bytes, contentType, toolkit, ready)
|
|
|
37
37
|
: MANAGED_NOTE(toolkit);
|
|
38
38
|
return withFailedCallHint(bytes, contentType, NO_MANAGED_AUTH, () => note, []);
|
|
39
39
|
}
|
|
40
|
+
/** A Composio session refuses a toolkit whose catalog entry lists no managed auth scheme, unless the project holds its
|
|
41
|
+
* own auth config for it. */
|
|
42
|
+
export function needsOwnAuth(item) {
|
|
43
|
+
return item.no_auth !== true && Array.isArray(item.composio_managed_auth_schemes) && item.composio_managed_auth_schemes.length === 0;
|
|
44
|
+
}
|
|
@@ -328,25 +328,26 @@ const steerGraceScale = () => fakeTimerScale("FAKE_CLAUDE_STEER_GRACE_SCALE");
|
|
|
328
328
|
const steerSilenceScale = () => fakeTimerScale("FAKE_CLAUDE_STEER_SILENCE_SCALE");
|
|
329
329
|
/** In a folder of its own, which the bot box puts back read-only: a bind of the file alone would keep showing the box the
|
|
330
330
|
* copy it was started with after a turn renames a new token over it. */
|
|
331
|
-
export function hookTokenFile(threadId, botId) {
|
|
332
|
-
const digest = createHash("sha256").update(`${botId ?? ""}\0${threadId}`).digest("hex").slice(0, 24);
|
|
331
|
+
export function hookTokenFile(threadId, botId, account) {
|
|
332
|
+
const digest = createHash("sha256").update(`${botId ?? ""}\0${threadId}${account ? `\0${account}` : ""}`).digest("hex").slice(0, 24);
|
|
333
333
|
return join(DATA_DIR, "hook-tokens", digest, "token");
|
|
334
334
|
}
|
|
335
|
-
export function permissionSocketPath(threadId, botId) {
|
|
336
|
-
// Half the tag digests the full bot+thread key: Windows named pipes share one global namespace
|
|
335
|
+
export function permissionSocketPath(threadId, botId, account) {
|
|
336
|
+
// Half the tag digests the full bot+thread+account key: Windows named pipes share one global namespace
|
|
337
337
|
// and are never unlinked, and 8 chars keeps POSIX paths under the 104-byte sun_path limit.
|
|
338
|
-
const
|
|
338
|
+
const baseKey = botId ? `${botId}\0${threadId}` : threadId;
|
|
339
|
+
const key = account ? `${baseKey}\0${account}` : baseKey;
|
|
339
340
|
const prefix = threadId.replace(/[^\w-]/g, "").slice(0, 4);
|
|
340
341
|
const digest = createHash("sha256").update(key).digest("hex").slice(0, 4);
|
|
341
342
|
return brokerSocketPath(DATA_DIR, `${prefix}${digest}`);
|
|
342
343
|
}
|
|
343
344
|
/** Broker bind paths, in order. Windows pipe names are never unlinkable (a hung child can hold one
|
|
344
345
|
* for minutes), and macOS rejects socket paths past `sun_path`, hence the short temp fallback. */
|
|
345
|
-
export function brokerSocketCandidates(threadId, botId) {
|
|
346
|
-
const base = permissionSocketPath(threadId, botId);
|
|
346
|
+
export function brokerSocketCandidates(threadId, botId, account) {
|
|
347
|
+
const base = permissionSocketPath(threadId, botId, account);
|
|
347
348
|
if (process.platform !== "win32") {
|
|
348
349
|
const scope = createHash("sha256")
|
|
349
|
-
.update(`${DATA_DIR}\0${process.pid}\0${botId ?? ""}\0${threadId}`)
|
|
350
|
+
.update(`${DATA_DIR}\0${process.pid}\0${botId ?? ""}\0${threadId}${account ? `\0${account}` : ""}`)
|
|
350
351
|
.digest("hex")
|
|
351
352
|
.slice(0, 16);
|
|
352
353
|
return [base, join(tmpdir(), `omb-perm-${scope}.sock`)];
|
|
@@ -502,6 +503,8 @@ export async function createPermissionBroker(opts) {
|
|
|
502
503
|
drain();
|
|
503
504
|
},
|
|
504
505
|
close() {
|
|
506
|
+
if (closed)
|
|
507
|
+
return;
|
|
505
508
|
closed = true;
|
|
506
509
|
drain();
|
|
507
510
|
try {
|
|
@@ -1029,7 +1032,7 @@ export const ClaudeDriver = {
|
|
|
1029
1032
|
const ownHttp = claudeOwnMcpOverHttp(mcpServers); // Seira's own servers by URL where that setting is on: no proxy process each
|
|
1030
1033
|
// Full access keeps ask_user: native bypass skips permission prompts, not questions.
|
|
1031
1034
|
let broker;
|
|
1032
|
-
const socketPath = permissionSocketPath(threadId, botId);
|
|
1035
|
+
const socketPath = permissionSocketPath(threadId, botId, instanceId);
|
|
1033
1036
|
if (permissionMode !== "bypassPermissions") {
|
|
1034
1037
|
args.push("--permission-prompt-tool", "mcp__ogb__approve");
|
|
1035
1038
|
}
|
|
@@ -1055,7 +1058,7 @@ export const ClaudeDriver = {
|
|
|
1055
1058
|
// The hook helper reads its bearer from a per-thread file refreshed every turn, so a
|
|
1056
1059
|
// long-lived CLI process never presents a stale token.
|
|
1057
1060
|
const hooks = turn.integrations?.hooks;
|
|
1058
|
-
const hookTokenPath = hooks ? hookTokenFile(threadId, botId) : null;
|
|
1061
|
+
const hookTokenPath = hooks ? hookTokenFile(threadId, botId, instanceId) : null;
|
|
1059
1062
|
if (hooks && hookTokenPath) {
|
|
1060
1063
|
mkdirSync(dirname(hookTokenPath), { recursive: true, mode: 0o700 });
|
|
1061
1064
|
writeFileAtomicIfChanged(hookTokenPath, hooks.token, { mode: 0o600, durable: false });
|
|
@@ -1161,7 +1164,7 @@ export const ClaudeDriver = {
|
|
|
1161
1164
|
if (socketPath) {
|
|
1162
1165
|
const askTools = new Map();
|
|
1163
1166
|
broker = await createPermissionBroker({
|
|
1164
|
-
socketPaths: brokerSocketCandidates(threadId, botId),
|
|
1167
|
+
socketPaths: brokerSocketCandidates(threadId, botId, instanceId),
|
|
1165
1168
|
isActive: () => Boolean(sessions.get(threadId)?.turn),
|
|
1166
1169
|
onAsk: (ask) => {
|
|
1167
1170
|
const eventTurnId = sessions.get(threadId)?.turn?.turnId ?? turnId;
|
|
@@ -18,7 +18,8 @@ const CANDIDATE_TTL_MS = 3_000;
|
|
|
18
18
|
const SANDBOX_ENV = /^(?:FLATPAK_.*|ZYPAK_.*|XDG_(?:CONFIG|DATA|CACHE|STATE)_HOME|XDG_(?:DATA|CONFIG)_DIRS|XDG_RUNTIME_DIR|DBUS_SESSION_BUS_ADDRESS|XAUTHORITY|TMPDIR|LD_LIBRARY_PATH|LD_PRELOAD|LD_AUDIT|GI_TYPELIB_PATH|GIO_EXTRA_MODULES|GST_.*|PKG_CONFIG_.*|CHROME_.*|container|PULSE_.*|PIPEWIRE_.*|AT_SPI_BUS_ADDRESS)$/;
|
|
19
19
|
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
20
20
|
// Each hit prints two NUL-ended fields: the file, then where its links lead (empty when that cannot be resolved).
|
|
21
|
-
|
|
21
|
+
// A relative folder is skipped: the launch runs in another folder, where the same name means another file.
|
|
22
|
+
const FIND_ON_PATH = 'set -f; IFS=:; for d in $1; do case "$d" in /*) ;; *) continue ;; esac; p="$d/$2"; if [ -f "$p" ] && [ -x "$p" ]; then printf "%s\\0%s\\0" "$p" "$(readlink -f -- "$p")"; fi; done';
|
|
22
23
|
const FIND_FILE = 'if [ -f "$1" ] && [ -x "$1" ]; then printf "%s\\0%s\\0" "$1" "$(readlink -f -- "$1")"; fi';
|
|
23
24
|
function defaultRunner(argv) {
|
|
24
25
|
const result = spawnSync(FLATPAK_SPAWN, [...argv], { encoding: "utf8", timeout: HOST_PROBE_TIMEOUT_MS, windowsHide: true });
|
|
@@ -131,9 +132,11 @@ export function hostBridge(resolved, context, processEnv = process.env) {
|
|
|
131
132
|
throw Object.assign(new Error(`${resolved.command} is in a folder the bots can write, so the server does not run it outside the bot box.`), { code: "EACCES" });
|
|
132
133
|
}
|
|
133
134
|
const entries = hostEnvEntries({ ...env, PATH: path });
|
|
135
|
+
// The link, not its target, as a shell and the deb's spawn start it: a program such as mise links every tool to itself
|
|
136
|
+
// and picks the tool by the name it runs as. Started by its target, mise gets its own name and refuses the tool's flags.
|
|
134
137
|
return {
|
|
135
138
|
command: FLATPAK_SPAWN,
|
|
136
|
-
args: hostSpawnArgv({ command: program.
|
|
139
|
+
args: hostSpawnArgv({ command: program.path, args: resolved.args, cwd }),
|
|
137
140
|
env: busEnv(processEnv),
|
|
138
141
|
envBlock: entries.map((entry) => `${entry}\0`).join(""),
|
|
139
142
|
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { writeFileAtomic } from "../atomic.js";
|
|
3
|
+
import { AI_POOL_LEVELS, pickPoolMember } from "../ai-pool.js";
|
|
4
|
+
const MAX_TRACKED_THREADS = 2000;
|
|
5
|
+
function loadRecords(file) {
|
|
6
|
+
const records = new Map();
|
|
7
|
+
if (!file)
|
|
8
|
+
return records;
|
|
9
|
+
try {
|
|
10
|
+
const saved = JSON.parse(readFileSync(file, "utf8"));
|
|
11
|
+
for (const [threadId, record] of Object.entries(saved ?? {})) {
|
|
12
|
+
if (typeof record?.instanceId === "string" && typeof record.model === "string" && Number.isFinite(record.level) && (record.until === null || Number.isFinite(record.until))) {
|
|
13
|
+
records.set(threadId, { instanceId: record.instanceId, model: record.model, level: record.level, until: record.until });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return records;
|
|
19
|
+
}
|
|
20
|
+
return records;
|
|
21
|
+
}
|
|
22
|
+
export function poolNote(reason, from, to) {
|
|
23
|
+
switch (reason) {
|
|
24
|
+
case "cannotRun": return `${from} can't take this turn, so this conversation moved to ${to}.`;
|
|
25
|
+
case "low": return `${from} is low on usage, so this conversation moved to ${to}.`;
|
|
26
|
+
case "payPerUse": return `${from} is pay-per-use, so this conversation moved to ${to}.`;
|
|
27
|
+
case "order": return `${to} comes first in the AI pool, so this conversation moved from ${from} to ${to}.`;
|
|
28
|
+
default: return `${to} has more usage left, so this conversation moved from ${from} to ${to}.`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function createAiPool(deps) {
|
|
32
|
+
const now = deps.now ?? Date.now;
|
|
33
|
+
const records = loadRecords(deps.file);
|
|
34
|
+
const save = () => {
|
|
35
|
+
if (!deps.file)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
writeFileAtomic(deps.file, JSON.stringify(Object.fromEntries(records)), { mode: 0o600, durable: false });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error(`ai pool: could not save threads: ${error instanceof Error ? error.message : String(error)}`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const write = (threadId, next) => {
|
|
45
|
+
const before = records.get(threadId);
|
|
46
|
+
const unchanged = next && before && before.instanceId === next.instanceId && before.model === next.model && before.level === next.level && before.until === next.until;
|
|
47
|
+
records.delete(threadId);
|
|
48
|
+
if (next)
|
|
49
|
+
records.set(threadId, next);
|
|
50
|
+
if (unchanged)
|
|
51
|
+
return;
|
|
52
|
+
while (records.size > (deps.maxTrackedThreads ?? MAX_TRACKED_THREADS))
|
|
53
|
+
records.delete(records.keys().next().value);
|
|
54
|
+
save();
|
|
55
|
+
};
|
|
56
|
+
const active = () => {
|
|
57
|
+
const pool = deps.config();
|
|
58
|
+
return pool?.enabled && pool.members.length >= 2 ? pool : undefined;
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
place(botId, threadId) {
|
|
62
|
+
const pool = active(), current = deps.threadModel(botId, threadId);
|
|
63
|
+
if (!pool || !current)
|
|
64
|
+
return false;
|
|
65
|
+
const currentIndex = pool.members.findIndex((member) => member.instanceId === current.instanceId);
|
|
66
|
+
const record = records.get(threadId);
|
|
67
|
+
if (currentIndex === -1 || (record && (record.instanceId !== current.instanceId || record.model !== current.model))) {
|
|
68
|
+
if (record)
|
|
69
|
+
write(threadId, null);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if (!record) {
|
|
73
|
+
const own = deps.botModel(botId);
|
|
74
|
+
if (!own || own.instanceId !== current.instanceId || own.model !== current.model)
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const at = now();
|
|
78
|
+
const readings = pool.members.map((member) => deps.reading(member.instanceId));
|
|
79
|
+
const recordFor = (index, level) => {
|
|
80
|
+
const resetsAt = readings[index].resetsAt;
|
|
81
|
+
return { instanceId: pool.members[index].instanceId, model: index === currentIndex ? current.model : pool.members[index].model, level, until: resetsAt !== null && resetsAt > at ? resetsAt : null };
|
|
82
|
+
};
|
|
83
|
+
const members = pool.members.map((member, index) => ({
|
|
84
|
+
eligible: deps.canRun(botId, threadId, current, index === currentIndex ? current : member),
|
|
85
|
+
paid: deps.paid(member.instanceId),
|
|
86
|
+
...readings[index],
|
|
87
|
+
}));
|
|
88
|
+
const threadLevel = record && record.until !== null && record.until > at ? record.level : undefined;
|
|
89
|
+
const picked = pickPoolMember({ mode: pool.mode, levels: pool.levels ?? AI_POOL_LEVELS, floor: pool.floor ?? 0, members, currentIndex, threadLevel });
|
|
90
|
+
if (picked.index === currentIndex) {
|
|
91
|
+
write(threadId, recordFor(currentIndex, picked.threadLevel));
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const to = pool.members[picked.index];
|
|
95
|
+
if (!deps.moveTo(botId, threadId, current, to))
|
|
96
|
+
return false;
|
|
97
|
+
write(threadId, recordFor(picked.index, picked.threadLevel));
|
|
98
|
+
deps.note(threadId, poolNote(picked.reason, deps.engineName(current.instanceId), deps.engineName(to.instanceId)));
|
|
99
|
+
return true;
|
|
100
|
+
},
|
|
101
|
+
backupsFor(from) {
|
|
102
|
+
const pool = active();
|
|
103
|
+
if (!pool?.members.some((member) => member.instanceId === from.instanceId))
|
|
104
|
+
return [];
|
|
105
|
+
const others = pool.members.filter((member) => member.instanceId !== from.instanceId);
|
|
106
|
+
return [...others.filter((member) => !deps.paid(member.instanceId)), ...others.filter((member) => deps.paid(member.instanceId))];
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -69,7 +69,8 @@ export function createAppSuggestions(deps) {
|
|
|
69
69
|
try {
|
|
70
70
|
const [{ cards }, services] = await Promise.all([deps.catalog(), deps.services()]);
|
|
71
71
|
const connected = Object.entries(services).filter(([, service]) => service.connected).map(([app]) => app).sort();
|
|
72
|
-
|
|
72
|
+
const offered = cards.filter((card) => !card.needsOwnAuth || connected.includes(card.slug));
|
|
73
|
+
return { cards: offered, connected, held: Object.keys(services), key: pickKey(connected, roles()) };
|
|
73
74
|
}
|
|
74
75
|
catch {
|
|
75
76
|
return null;
|
|
@@ -9,7 +9,7 @@ import { recoveryCapabilityError } from "../automatic-recovery.js";
|
|
|
9
9
|
import { readyToRun } from "../default-model-selection.js";
|
|
10
10
|
import { engineFailureKind } from "../drivers/engine-errors.js";
|
|
11
11
|
import { classifyError } from "../drivers/retry.js";
|
|
12
|
-
import { failoverLine, limitBackupAllowed, signedOutLine } from "../limit-failover.js";
|
|
12
|
+
import { billsEachUse, failoverLine, limitBackupAllowed, signedOutLine } from "../limit-failover.js";
|
|
13
13
|
import { LimitNotices, limitNoticeText, signedOutNoticeText } from "../limit-notices.js";
|
|
14
14
|
import { UNNAMED_LIMIT_MS } from "../limit-resets.js";
|
|
15
15
|
/** A model's own limit holds that model at most this long before it is tried again, in case its window ended early. */
|
|
@@ -114,8 +114,9 @@ export function createLimitTakeover(deps) {
|
|
|
114
114
|
if (engine.instanceId !== current.instanceId) {
|
|
115
115
|
if (signedOutHeld(engine.instanceId))
|
|
116
116
|
return false;
|
|
117
|
-
// Another sign-in to the same plan never carries a limit (that rotates accounts); it may stand in for one signed out.
|
|
118
|
-
|
|
117
|
+
// Another sign-in to the same plan never carries a limit (that rotates accounts); it may stand in for one signed out, and a pay-per-use key may hand the conversation back to the plan.
|
|
118
|
+
const keyHandsBack = scope === "pool" && billsEachUse(deps.configs()[current.instanceId]);
|
|
119
|
+
if (scope !== "signed-out" && !keyHandsBack && !limitBackupAllowed(current, engine, deps.configs()[engine.instanceId]))
|
|
119
120
|
return false;
|
|
120
121
|
// The same rule as switching by hand: a level the other AI has no such mode for needs the person first.
|
|
121
122
|
if (approval && modelSwitchNeedsAsk(approval, current.driverKind, engine.driverKind))
|
|
@@ -144,7 +145,7 @@ export function createLimitTakeover(deps) {
|
|
|
144
145
|
};
|
|
145
146
|
if (scope === "model" || scope === "credits")
|
|
146
147
|
add({ instanceId: current.instanceId, model: current.models.default });
|
|
147
|
-
for (const selection of scope === "signed-out" ? deps.signedOutChosen?.(botId) ?? deps.chosen(botId) : deps.chosen(botId))
|
|
148
|
+
for (const selection of scope === "signed-out" ? deps.signedOutChosen?.(botId) ?? deps.chosen(botId, from) : deps.chosen(botId, from))
|
|
148
149
|
add(selection);
|
|
149
150
|
return out;
|
|
150
151
|
}
|
|
@@ -186,6 +187,12 @@ export function createLimitTakeover(deps) {
|
|
|
186
187
|
};
|
|
187
188
|
return {
|
|
188
189
|
backups,
|
|
190
|
+
canCarry(from, to, approval) {
|
|
191
|
+
if (to.instanceId === from.instanceId)
|
|
192
|
+
return deps.blockedUntil(to.instanceId, to.model) === null && modelHeld(to) === null && !signedOutHeld(to.instanceId);
|
|
193
|
+
const engines = deps.engines(), current = engines.find((engine) => engine.instanceId === from.instanceId);
|
|
194
|
+
return Boolean(current) && usable(engines, current, to, "pool", approval);
|
|
195
|
+
},
|
|
189
196
|
/** This model alone, held by its own limit; null when it is not. */
|
|
190
197
|
modelHeld,
|
|
191
198
|
/** This model's own limit refused a turn: it is held until the reset the limit named, an hour when it named none,
|