@chibitek/chibi 0.1.182 → 0.1.184
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/{abnfDiagram-O67JEVCF-B8rB4VYk.js → abnfDiagram-O67JEVCF-D63grDEy.js} +1 -1
- package/dist/assets/{arc-COTt5eKp.js → arc-bQvylCdS.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CPejbWZ8.js → architectureDiagram-NJMV4G6O-BOAFaaj7.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DoioDp90.js → blockDiagram-BEXU5L5S-ewLAgFlb.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-8PWWVdYW.js → c4Diagram-YGBWAQC7-Dn_C6A7b.js} +1 -1
- package/dist/assets/channel-DaRjZag9.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DxtJtts-.js → chunk-2Q5K7J3B-DpB_wNSI.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-D3YkXW5d.js → chunk-3FUC2YCW-DIelvlCV.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CsKzmOcP.js → chunk-5VM5RSS4-O-aALIul.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-gZEIPwuj.js → chunk-GTNCS2PH-Dqe5r4Ji.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-Bjt2-00s.js → chunk-GWA4HPMP-FzFr6U_I.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BvUQuiRB.js → chunk-JWPE2WC7-BuJO0Fyh.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-Dq0TzVqk.js → chunk-NETBCI7D-DMgFuMgZ.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-DYCSZnMz.js → chunk-WEXAMYUT-BYXYAyMu.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-B_OfX3TH.js → chunk-XXDRQBXY-s_OT2iv7.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-CyGFfePO.js → classDiagram-v2-NBCMYWYE-Cdbr4CZV.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-v7FbM5j-.js → cose-bilkent-JH36ORCC-CXjx4058.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-CqvJgX3t.js → cynefin-OW5HDTMX-Cc2YqzW6.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-CA2yN6Xd.js → cynefinDiagram-VND7K2PF-Cze_i1Vk.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-Zr9etAoq.js → dagre-6A5THRUB-oPouQ7XU.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DtUG2c4U.js → diagram-22UHCM2B-DNRc977u.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-D9Y-Wrhr.js → diagram-3UASUU5V-B8vBo05Y.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DkeBHA-m.js → diagram-ATOU4E4O-dCch9eKa.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CdGlcHWC.js → diagram-CDSNMT55-CYJSen9G.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BeHhIQjn.js → diagram-MLGK6HIB-RxYVGgc6.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-AgCxokZc.js → diagram-MPIPVDR6-B-UyrObe.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-CqYoX9yZ.js → ebnfDiagram-ZINNZB2B-CxGXwVT7.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-Br_wamlb.js → elk-276RUBZZ-CHGRRKuJ.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-YuGMoUl0.js → erDiagram-OPXOYQCR-BMJusoDl.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-VflMWlTN.js → flowDiagram-KWPJA3E3-DtiBETZe.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-q1LvQaev.js → ganttDiagram-FUAMR5RP-DAXqRUQM.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-CHRdJIvn.js → gitGraphDiagram-X574FWY7-Cx_M7do1.js} +1 -1
- package/dist/assets/{index-B_gcNCKf.js → index-COCy7XsD.js} +167 -167
- package/dist/assets/{index-C2q5K4Lk.js → index-DKt9qb9g.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-DRwVvitP.js → infoDiagram-VRGFBTTK-CNgfLxed.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BXZw4L0c.js → ishikawaDiagram-OU5B5YK6-BvdGqyOz.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-B7AeEVRV.js → journeyDiagram-ZHPQQLJL-atzjOsJ2.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-CQLN4aVl.js → kanban-definition-PNTS6WVX-miq8ywtS.js} +1 -1
- package/dist/assets/{linear-CbYhE1pa.js → linear-3skQIwEd.js} +1 -1
- package/dist/assets/{mermaid.core-D1syQdvp.js → mermaid.core-CcefVt63.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-B2IFEIiB.js → mindmap-definition-NLK3R4M7-CyJLiFXW.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-DHZYilhs.js → pegDiagram-GJSIUBJH-DdBX63bl.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DO_aJLMk.js → pieDiagram-5QR66LMP-DNO9-2f5.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-gUPrtKHH.js → quadrantDiagram-O4NWA36T-BciZP71K.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-BBF0wp-6.js → railroadDiagram-XR7U4H2S-4IdVOKPa.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-xcAp1hln.js → requirementDiagram-PLB6GJNP-DFdsFYy-.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-Dm5c9FwQ.js → sankeyDiagram-IPEJSGJF-HH2WFlmw.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-vRzb3zIA.js → sequenceDiagram-PO4LG4MO-CP91Sy-s.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Czu8kIt2.js → sizeCapture-INFHLROL-DhZiuL4S.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-BOfJjcD1.js → stateDiagram-v2-GCMORJYK-DIa0uzhR.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-D0ipJonR.js → swimlanes-2SLR337P-CXr7kql9.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CtuksGU4.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-TpaYbjnd.js → timeline-definition-EJHVYXUP-BidOWl1X.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-B-jKTFl6.js → usecaseDiagram-POWQR4AR-Dt0DqsBc.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Dy6k1yAu.js → vennDiagram-UO4OBE2U-DMfDgcZH.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DYRJUBY6.js → wardleyDiagram-VNRHLVJA-jgsJZ4n4.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-CETDzaRA.js → xychartDiagram-PMCCYNJV-AllqBdcw.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -5
- package/dist/index.html +1 -1
- package/dist-server/drivers/agents-proxy.js +4 -4
- package/dist-server/index.js +185 -128
- package/dist-server/openmausbot.js +30 -9
- package/dist-server/pair-cli.js +30 -9
- package/dist-server/server/drivers/acp/hermes.js +4 -9
- package/dist-server/server/workspace-backup-copy.js +34 -1
- package/dist-server/server/workspace-backup-http.js +8 -5
- package/dist-server/server/workspace-backup-secrets.js +2 -2
- package/dist-server/server/workspace-backup.js +40 -54
- package/dist-server/shared/provider-accounts.js +13 -0
- package/dist-server/shared/subscription-bots.js +4 -4
- package/dist-server/shared/workspace-backup.js +23 -1
- package/package.json +1 -1
- package/dist/assets/channel-CDw9Li4I.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BJpOJd6C.js +0 -8
package/dist-server/index.js
CHANGED
|
@@ -32204,7 +32204,7 @@ async function receiveGoalCommand(runtime, store2, botId, threadId, command, tex
|
|
|
32204
32204
|
// server/index.ts
|
|
32205
32205
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
32206
32206
|
import { createHash as createHash54, randomBytes as randomBytes15, randomUUID as randomUUID49, timingSafeEqual as timingSafeEqual9 } from "node:crypto";
|
|
32207
|
-
import { existsSync as existsSync84, readFileSync as
|
|
32207
|
+
import { existsSync as existsSync84, readFileSync as readFileSync108, realpathSync as realpathSync15, rmSync as rmSync24, mkdirSync as mkdirSync72, statSync as statSync30 } from "node:fs";
|
|
32208
32208
|
import { rm as removeDirectory } from "node:fs/promises";
|
|
32209
32209
|
import { createServer as createServer4 } from "node:http";
|
|
32210
32210
|
|
|
@@ -33736,6 +33736,18 @@ var ACCOUNT_PROVIDERS = [
|
|
|
33736
33736
|
keyUrl: "https://platform.minimax.io/console/plan",
|
|
33737
33737
|
signupUrl: "https://www.minimax.io/m-plan"
|
|
33738
33738
|
},
|
|
33739
|
+
{
|
|
33740
|
+
// Coding Plan quota uses its own endpoint, separate from the general Z.ai API.
|
|
33741
|
+
id: "zai",
|
|
33742
|
+
kind: "apiKey",
|
|
33743
|
+
label: "Z.ai GLM Coding Plan",
|
|
33744
|
+
billing: "subscription",
|
|
33745
|
+
driver: "openai-compat",
|
|
33746
|
+
envVar: "ZAI_API_KEY",
|
|
33747
|
+
config: { url: "https://api.z.ai/api/coding/paas/v4", apiKeyEnv: "ZAI_API_KEY", model: "glm-5.3", provider: "" },
|
|
33748
|
+
keyUrl: "https://z.ai/manage-apikey/apikey-list",
|
|
33749
|
+
signupUrl: "https://z.ai/subscribe"
|
|
33750
|
+
},
|
|
33739
33751
|
{
|
|
33740
33752
|
id: "xai",
|
|
33741
33753
|
kind: "apiKey",
|
|
@@ -33774,6 +33786,20 @@ var ACCOUNT_PROVIDERS = [
|
|
|
33774
33786
|
keyUrl: "https://ollama.com/settings/keys",
|
|
33775
33787
|
signupUrl: "https://ollama.com/pricing"
|
|
33776
33788
|
},
|
|
33789
|
+
{
|
|
33790
|
+
// Nous Portal's OpenAI-compatible API, signed in with a portal key. No
|
|
33791
|
+
// Hermes needed (Erick, 2026-11-08).
|
|
33792
|
+
id: "nous",
|
|
33793
|
+
kind: "apiKey",
|
|
33794
|
+
label: "Nous Research",
|
|
33795
|
+
billing: "subscription",
|
|
33796
|
+
driver: "openai-compat",
|
|
33797
|
+
envVar: "NOUS_API_KEY",
|
|
33798
|
+
config: { url: "https://inference-api.nousresearch.com/v1", apiKeyEnv: "NOUS_API_KEY", model: "Hermes-4-405B", provider: "" },
|
|
33799
|
+
keyTest: { provider: "openaiCompat", url: "https://inference-api.nousresearch.com/v1" },
|
|
33800
|
+
keyUrl: "https://portal.nousresearch.com/",
|
|
33801
|
+
signupUrl: "https://portal.nousresearch.com/"
|
|
33802
|
+
},
|
|
33777
33803
|
{
|
|
33778
33804
|
// OpenCode Go is a flat monthly plan used through an OpenCode key.
|
|
33779
33805
|
id: "opencodeGo",
|
|
@@ -42285,10 +42311,10 @@ var SUBSCRIPTION_PROVIDERS = Object.freeze([
|
|
|
42285
42311
|
planOnly: true,
|
|
42286
42312
|
signInUrl: "https://platform.minimax.io/console/plan"
|
|
42287
42313
|
},
|
|
42288
|
-
//
|
|
42289
|
-
//
|
|
42290
|
-
//
|
|
42291
|
-
// Nous Portal and the plan together makes the Nous Research bot only.
|
|
42314
|
+
// A Hermes the person set up themselves with a Z.ai key on the GLM Coding
|
|
42315
|
+
// Plan endpoint (server/drivers/acp/hermes.ts hermesZaiCodingPlan). Atomic
|
|
42316
|
+
// setup never installs Hermes: the Z.ai card takes the plan key directly.
|
|
42317
|
+
// A Hermes on Nous Portal and the plan together makes the Nous Research bot only.
|
|
42292
42318
|
{
|
|
42293
42319
|
id: "zai",
|
|
42294
42320
|
name: "Z.ai GLM",
|
|
@@ -72571,15 +72597,10 @@ var support10 = {
|
|
|
72571
72597
|
// from its log, by the core's stderr check).
|
|
72572
72598
|
promptIdleMs: 3e5,
|
|
72573
72599
|
loginNote: "Hermes CLI is not installed",
|
|
72574
|
-
install:
|
|
72575
|
-
|
|
72576
|
-
|
|
72577
|
-
|
|
72578
|
-
win32: "iex (irm https://hermes-agent.nousresearch.com/install.ps1)"
|
|
72579
|
-
},
|
|
72580
|
-
docsUrl: "https://hermes-agent.nousresearch.com/docs/getting-started/quickstart",
|
|
72581
|
-
signInCommand: "hermes setup"
|
|
72582
|
-
},
|
|
72600
|
+
// No install command: setup never installs Hermes (Erick, 2026-11-08).
|
|
72601
|
+
// Nous Research signs in with a Nous Portal API key instead
|
|
72602
|
+
// (shared/provider-accounts.ts `nous`); Hermes runs only where the person
|
|
72603
|
+
// installed it themselves.
|
|
72583
72604
|
spawnArgs: () => ["acp"],
|
|
72584
72605
|
transformEnv: (env) => {
|
|
72585
72606
|
for (const key5 of ["OPENAI_API_KEY", "OPENROUTER_API_KEY"]) delete env[key5];
|
|
@@ -101036,7 +101057,7 @@ import {
|
|
|
101036
101057
|
lstatSync as lstatSync13,
|
|
101037
101058
|
mkdirSync as mkdirSync55,
|
|
101038
101059
|
openSync as openSync17,
|
|
101039
|
-
readFileSync as
|
|
101060
|
+
readFileSync as readFileSync87,
|
|
101040
101061
|
readdirSync as readdirSync23,
|
|
101041
101062
|
readlinkSync as readlinkSync2,
|
|
101042
101063
|
readSync as readSync12,
|
|
@@ -101051,7 +101072,7 @@ import { backup, DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
|
101051
101072
|
|
|
101052
101073
|
// server/workspace-backup-copy.ts
|
|
101053
101074
|
import { createHash as createHash43 } from "node:crypto";
|
|
101054
|
-
import { closeSync as closeSync16, constants as constants10, fstatSync as fstatSync9, fsyncSync as fsyncSync4, lstatSync as lstatSync11, openSync as openSync16, readSync as readSync11, writeSync as writeSync3 } from "node:fs";
|
|
101075
|
+
import { closeSync as closeSync16, constants as constants10, fstatSync as fstatSync9, fsyncSync as fsyncSync4, lstatSync as lstatSync11, openSync as openSync16, readFileSync as readFileSync83, readSync as readSync11, writeSync as writeSync3 } from "node:fs";
|
|
101055
101076
|
|
|
101056
101077
|
// server/workspace-backup-archive.ts
|
|
101057
101078
|
import { createCipheriv, createDecipheriv, createHash as createHash42, randomBytes as randomBytes7, scrypt } from "node:crypto";
|
|
@@ -101221,6 +101242,31 @@ function copyRegular(source3, destination, onLiveChange) {
|
|
|
101221
101242
|
}
|
|
101222
101243
|
return captured ?? null;
|
|
101223
101244
|
}
|
|
101245
|
+
var MAX_METADATA_BYTES = 64 * 1024 ** 2;
|
|
101246
|
+
function entryExists(path2) {
|
|
101247
|
+
try {
|
|
101248
|
+
lstatSync11(path2);
|
|
101249
|
+
return true;
|
|
101250
|
+
} catch (error51) {
|
|
101251
|
+
if (error51.code === "ENOENT") return false;
|
|
101252
|
+
throw error51;
|
|
101253
|
+
}
|
|
101254
|
+
}
|
|
101255
|
+
function privateJson(path2) {
|
|
101256
|
+
const fd = openSync16(path2, constants10.O_RDONLY | constants10.O_NOFOLLOW);
|
|
101257
|
+
try {
|
|
101258
|
+
const stat8 = fstatSync9(fd);
|
|
101259
|
+
if (!stat8.isFile() || stat8.size > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata is too large or is not a regular file.");
|
|
101260
|
+
return JSON.parse(readFileSync83(fd, "utf8"));
|
|
101261
|
+
} finally {
|
|
101262
|
+
closeSync16(fd);
|
|
101263
|
+
}
|
|
101264
|
+
}
|
|
101265
|
+
function writeJson(path2, value) {
|
|
101266
|
+
const text18 = JSON.stringify(value);
|
|
101267
|
+
if (Buffer.byteLength(text18) > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata exceeds the size limit.");
|
|
101268
|
+
writeFileAtomic(path2, text18, { mode: 384 });
|
|
101269
|
+
}
|
|
101224
101270
|
|
|
101225
101271
|
// server/workspace-backup-policy.ts
|
|
101226
101272
|
var PORTABLE_CONFIG_KEYS = [
|
|
@@ -101252,8 +101298,33 @@ function ephemeralWorkspaceTokenPath(path2) {
|
|
|
101252
101298
|
return /^hook-tokens(?:\/|$)/.test(path2);
|
|
101253
101299
|
}
|
|
101254
101300
|
|
|
101301
|
+
// shared/workspace-backup.ts
|
|
101302
|
+
var WORKSPACE_RESTORE_PARTS = ["conversations", "settings", "routines", "credentials", "desktops"];
|
|
101303
|
+
var PART_BY_NAME = {
|
|
101304
|
+
"config.json": "settings",
|
|
101305
|
+
"webhooks.json": "settings",
|
|
101306
|
+
"routines.json": "routines",
|
|
101307
|
+
"calendar-calls.json": "routines",
|
|
101308
|
+
"providers": "credentials",
|
|
101309
|
+
"workspace-credentials.json": "credentials",
|
|
101310
|
+
"instance-keys.json": "credentials",
|
|
101311
|
+
"external-runtimes.json": "credentials",
|
|
101312
|
+
"vm-home": "desktops",
|
|
101313
|
+
"vm-homes": "desktops"
|
|
101314
|
+
};
|
|
101315
|
+
function workspaceRestorePart(name2) {
|
|
101316
|
+
const key5 = name2.toLowerCase();
|
|
101317
|
+
return Object.hasOwn(PART_BY_NAME, key5) ? PART_BY_NAME[key5] : "conversations";
|
|
101318
|
+
}
|
|
101319
|
+
function validWorkspaceRestoreKeep(value) {
|
|
101320
|
+
if (value === void 0) return [];
|
|
101321
|
+
if (!Array.isArray(value) || !value.every((part) => WORKSPACE_RESTORE_PARTS.includes(part)) || new Set(value).size !== value.length) throw new Error("Invalid restore choices.");
|
|
101322
|
+
if (value.includes("settings") && !value.includes("credentials")) throw new Error("Restore app settings with saved credentials, or keep both on this computer.");
|
|
101323
|
+
return value;
|
|
101324
|
+
}
|
|
101325
|
+
|
|
101255
101326
|
// server/workspace-backup-private.ts
|
|
101256
|
-
import { existsSync as existsSync58, readFileSync as
|
|
101327
|
+
import { existsSync as existsSync58, readFileSync as readFileSync84 } from "node:fs";
|
|
101257
101328
|
import { join as join107 } from "node:path";
|
|
101258
101329
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
101259
101330
|
function record9(value) {
|
|
@@ -101266,7 +101337,7 @@ function privateBotIds(dataDir2) {
|
|
|
101266
101337
|
if (!existsSync58(path2)) return { botIds, threadIds };
|
|
101267
101338
|
let value;
|
|
101268
101339
|
try {
|
|
101269
|
-
value = JSON.parse(
|
|
101340
|
+
value = JSON.parse(readFileSync84(path2, "utf8"));
|
|
101270
101341
|
} catch {
|
|
101271
101342
|
return { botIds, threadIds };
|
|
101272
101343
|
}
|
|
@@ -101318,7 +101389,7 @@ function scrubPrivateMessages(dbPath, botIds, threadIds) {
|
|
|
101318
101389
|
|
|
101319
101390
|
// server/workspace-backup-secrets.ts
|
|
101320
101391
|
import { randomUUID as randomUUID34 } from "node:crypto";
|
|
101321
|
-
import { existsSync as existsSync59, readFileSync as
|
|
101392
|
+
import { existsSync as existsSync59, readFileSync as readFileSync85 } from "node:fs";
|
|
101322
101393
|
import { join as join108 } from "node:path";
|
|
101323
101394
|
|
|
101324
101395
|
// electron/workspace-credentials.mjs
|
|
@@ -101360,7 +101431,7 @@ function desktopWorkspaceSecrets() {
|
|
|
101360
101431
|
}
|
|
101361
101432
|
function installWorkspaceSecrets(port, dataDir2, restore2) {
|
|
101362
101433
|
if (!port) {
|
|
101363
|
-
if (restore2.restored && restore2.id && restore2.summary?.secrets) markRestoreSecrets(dataDir2, restore2, "failed");
|
|
101434
|
+
if (restore2.restored && restore2.id && restore2.summary?.secrets && !restore2.keep?.includes("credentials")) markRestoreSecrets(dataDir2, restore2, "failed");
|
|
101364
101435
|
return;
|
|
101365
101436
|
}
|
|
101366
101437
|
const waiting = /* @__PURE__ */ new Map();
|
|
@@ -101396,7 +101467,7 @@ function installWorkspaceSecrets(port, dataDir2, restore2) {
|
|
|
101396
101467
|
return (await request4({ action: "apply", id })).applied === true;
|
|
101397
101468
|
}
|
|
101398
101469
|
};
|
|
101399
|
-
if (restore2.restored && restore2.id && restore2.summary?.secrets) {
|
|
101470
|
+
if (restore2.restored && restore2.id && restore2.summary?.secrets && !restore2.keep?.includes("credentials")) {
|
|
101400
101471
|
void desktop.apply(restore2.id).then(
|
|
101401
101472
|
(applied) => markRestoreSecrets(dataDir2, restore2, applied ? "applied" : "failed"),
|
|
101402
101473
|
(error51) => {
|
|
@@ -101410,14 +101481,14 @@ function markRestoreSecrets(dataDir2, restore2, outcome) {
|
|
|
101410
101481
|
restore2.secrets = outcome;
|
|
101411
101482
|
const path2 = join108(dataDir2, ".backups", "last-restore.json");
|
|
101412
101483
|
if (!existsSync59(path2)) return;
|
|
101413
|
-
const receipt = JSON.parse(
|
|
101484
|
+
const receipt = JSON.parse(readFileSync85(path2, "utf8"));
|
|
101414
101485
|
if (!receipt || typeof receipt !== "object" || receipt.id !== restore2.id) return;
|
|
101415
101486
|
writeFileAtomic(path2, JSON.stringify({ ...receipt, secrets: outcome }), { mode: 384 });
|
|
101416
101487
|
}
|
|
101417
101488
|
|
|
101418
101489
|
// server/workspace-restore-paths.ts
|
|
101419
101490
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
101420
|
-
import { existsSync as existsSync60, lstatSync as lstatSync12, readFileSync as
|
|
101491
|
+
import { existsSync as existsSync60, lstatSync as lstatSync12, readFileSync as readFileSync86, readdirSync as readdirSync22, renameSync as renameSync15, symlinkSync as symlinkSync2, writeFileSync as writeFileSync31 } from "node:fs";
|
|
101421
101492
|
import { dirname as dirname30, isAbsolute as isAbsolute19, join as join109, posix as posix3, relative as relative9, resolve as resolve26, win32 as win324 } from "node:path";
|
|
101422
101493
|
function validRelative(path2) {
|
|
101423
101494
|
return !!path2 && path2.length <= 4096 && !isAbsolute19(path2) && !/[\\\0:]/.test(path2) && path2.split("/").every((part) => !!part && part !== "." && part !== ".." && !/[. ]$/.test(part) && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part));
|
|
@@ -101474,7 +101545,7 @@ function rebaseTree(root, pairs2) {
|
|
|
101474
101545
|
if (name2 === "projects" && relative9(root, path2).startsWith("providers")) renameProjectDirs(path2, pairs2);
|
|
101475
101546
|
if (depth < 12) visit3(path2, depth + 1);
|
|
101476
101547
|
} else if (stat8.isFile() && TEXT_FILE.test(name2) && stat8.size <= MAX_REWRITE_BYTES) {
|
|
101477
|
-
const text18 =
|
|
101548
|
+
const text18 = readFileSync86(path2, "utf8");
|
|
101478
101549
|
const next = rebaseText(text18, pairs2);
|
|
101479
101550
|
if (next !== text18) writeFileSync31(path2, next, { mode: stat8.mode & 511 });
|
|
101480
101551
|
}
|
|
@@ -101531,16 +101602,16 @@ function checkoutRemote(directory) {
|
|
|
101531
101602
|
try {
|
|
101532
101603
|
readdirSync22(gitDir);
|
|
101533
101604
|
} catch {
|
|
101534
|
-
const pointer = /^gitdir:\s*(.+)$/m.exec(
|
|
101605
|
+
const pointer = /^gitdir:\s*(.+)$/m.exec(readFileSync86(gitDir, "utf8"))?.[1]?.trim();
|
|
101535
101606
|
if (!pointer) return null;
|
|
101536
101607
|
gitDir = isAbsolute19(pointer) ? pointer : join109(directory, pointer);
|
|
101537
101608
|
const common = join109(gitDir, "commondir");
|
|
101538
101609
|
if (existsSync60(common)) {
|
|
101539
|
-
const shared =
|
|
101610
|
+
const shared = readFileSync86(common, "utf8").trim();
|
|
101540
101611
|
gitDir = isAbsolute19(shared) ? shared : join109(gitDir, shared);
|
|
101541
101612
|
}
|
|
101542
101613
|
}
|
|
101543
|
-
const config2 =
|
|
101614
|
+
const config2 = readFileSync86(join109(gitDir, "config"), "utf8");
|
|
101544
101615
|
return /\[remote "origin"\][^[]*?\burl\s*=\s*(\S+)/.exec(config2)?.[1] ?? null;
|
|
101545
101616
|
} catch {
|
|
101546
101617
|
return null;
|
|
@@ -101549,7 +101620,6 @@ function checkoutRemote(directory) {
|
|
|
101549
101620
|
|
|
101550
101621
|
// server/workspace-backup.ts
|
|
101551
101622
|
var MAX_WORKSPACE_BACKUP_FILES = 1e5;
|
|
101552
|
-
var MAX_METADATA_BYTES = 16 * 1024 ** 2;
|
|
101553
101623
|
var MAX_REPORTED_PATHS = 200;
|
|
101554
101624
|
var ID2 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
101555
101625
|
var EXCLUDED = /* @__PURE__ */ new Set([
|
|
@@ -101571,6 +101641,7 @@ var EXCLUDED = /* @__PURE__ */ new Set([
|
|
|
101571
101641
|
"messages.db-wal",
|
|
101572
101642
|
"messages.db-shm"
|
|
101573
101643
|
]);
|
|
101644
|
+
var ANTIGRAVITY_TOOL_CATALOG = /^providers\/antigravity\/[^/]+\/antigravity-acp\/brain\/[^/]+\/mcp$/;
|
|
101574
101645
|
var REINSTALLABLE_DIRS = /* @__PURE__ */ new Set(["node_modules", ".pnpm-store", ".venv", "venv", "__pycache__", ".next", ".turbo", "DerivedData", ".build"]);
|
|
101575
101646
|
var BROWSER_LOCK_LINKS = /* @__PURE__ */ new Set(["lock", ".parentlock", "SingletonLock", "SingletonSocket", "SingletonCookie"]);
|
|
101576
101647
|
var SECRETS_NOTE = "Saved credentials, provider and MCP connections, managed provider login homes and browser login profiles are not transferred. Destination connections are preserved; reconnect on a new device.";
|
|
@@ -101578,7 +101649,7 @@ var EXCLUSION_NOTES = [
|
|
|
101578
101649
|
"Device pairing, server identity, live leases and runtime files (existing destination identities are preserved).",
|
|
101579
101650
|
SECRETS_NOTE,
|
|
101580
101651
|
"Downloaded tools and caches; these can be installed again.",
|
|
101581
|
-
"Project dependency and build folders (node_modules, .venv, __pycache__, .next, .turbo, .build, DerivedData); reinstall
|
|
101652
|
+
"Project dependency and build folders (node_modules, .venv, __pycache__, .next, .turbo, .build, DerivedData, and in task workspaces .git, *-derived, *.xcarchive, dist and release); reinstall or rebuild them after restoring.",
|
|
101582
101653
|
"External project folders, CLI login homes, browser session homes, OS keychains, companion devices and other servers.",
|
|
101583
101654
|
"VM/container disk layers and remote cloud data; durable files inside this workspace are included."
|
|
101584
101655
|
];
|
|
@@ -101630,30 +101701,6 @@ function newJob(dataDir2) {
|
|
|
101630
101701
|
function record10(value) {
|
|
101631
101702
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
101632
101703
|
}
|
|
101633
|
-
function entryExists(path2) {
|
|
101634
|
-
try {
|
|
101635
|
-
lstatSync13(path2);
|
|
101636
|
-
return true;
|
|
101637
|
-
} catch (error51) {
|
|
101638
|
-
if (error51.code === "ENOENT") return false;
|
|
101639
|
-
throw error51;
|
|
101640
|
-
}
|
|
101641
|
-
}
|
|
101642
|
-
function privateJson(path2) {
|
|
101643
|
-
const fd = openSync17(path2, constants11.O_RDONLY | constants11.O_NOFOLLOW);
|
|
101644
|
-
try {
|
|
101645
|
-
const stat8 = fstatSync10(fd);
|
|
101646
|
-
if (!stat8.isFile() || stat8.size > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata is too large or is not a regular file.");
|
|
101647
|
-
return JSON.parse(readFileSync86(fd, "utf8"));
|
|
101648
|
-
} finally {
|
|
101649
|
-
closeSync17(fd);
|
|
101650
|
-
}
|
|
101651
|
-
}
|
|
101652
|
-
function writeJson(path2, value) {
|
|
101653
|
-
const text18 = JSON.stringify(value);
|
|
101654
|
-
if (Buffer.byteLength(text18) > MAX_METADATA_BYTES) throw new Error("Workspace backup metadata exceeds the size limit.");
|
|
101655
|
-
writeFileAtomic(path2, text18, { mode: 384 });
|
|
101656
|
-
}
|
|
101657
101704
|
function privateMetadata(manifest) {
|
|
101658
101705
|
return { summary: manifest.summary, clientState: manifest.clientState };
|
|
101659
101706
|
}
|
|
@@ -101797,7 +101844,8 @@ async function createWorkspaceBackup(dataDir2, options) {
|
|
|
101797
101844
|
removedFiles++;
|
|
101798
101845
|
continue;
|
|
101799
101846
|
}
|
|
101800
|
-
if (prefix && REINSTALLABLE_DIRS.has(name2) && (stat8.isDirectory() || stat8.isSymbolicLink())) continue;
|
|
101847
|
+
if (prefix && REINSTALLABLE_DIRS.has(name2) && (stat8.isDirectory() || stat8.isSymbolicLink()) || path3.startsWith("task-workspaces/") && (name2 === ".git" || stat8.isDirectory() && /^(?:.+-derived|.+\.xcarchive|dist.*|release)$/.test(name2))) continue;
|
|
101848
|
+
if (stat8.isDirectory() && ANTIGRAVITY_TOOL_CATALOG.test(path3)) continue;
|
|
101801
101849
|
if (stat8.isSymbolicLink() && BROWSER_LOCK_LINKS.has(name2)) continue;
|
|
101802
101850
|
if (stat8.isSymbolicLink()) {
|
|
101803
101851
|
if (/^workspaces\/[^/]+\/\.(?:claude|agents|grok)\/skills\/[^/]+$/.test(path3)) {
|
|
@@ -101825,7 +101873,7 @@ async function createWorkspaceBackup(dataDir2, options) {
|
|
|
101825
101873
|
writeJson(destination, Array.isArray(value) ? value.filter((bot) => !(record10(bot) && bot.personal === true)) : value);
|
|
101826
101874
|
copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
|
|
101827
101875
|
} else if (hiddenIds.size && name2.endsWith(".jsonl")) {
|
|
101828
|
-
const kept =
|
|
101876
|
+
const kept = readFileSync87(source3, "utf8").split("\n").filter((line3) => ![...hiddenIds].some((id) => line3.includes(id)));
|
|
101829
101877
|
writeFileSync32(destination, kept.join("\n"), { mode: 384, flag: "wx" });
|
|
101830
101878
|
copied = { size: lstatSync13(destination).size, mode: 384, sha256: hashFile(destination) };
|
|
101831
101879
|
} else if ((path3 === "config.json" || path3 === "webhooks.json") && !secrets) {
|
|
@@ -102062,14 +102110,17 @@ function readStagedWorkspaceBackup(dataDir2, id) {
|
|
|
102062
102110
|
const manifest = validateManifest(privateJson(join110(directory, "staged", "manifest.json")));
|
|
102063
102111
|
return { id, ...privateMetadata(manifest) };
|
|
102064
102112
|
}
|
|
102065
|
-
function commitPendingWorkspaceRestore(dataDir2, id) {
|
|
102113
|
+
function commitPendingWorkspaceRestore(dataDir2, id, keep = []) {
|
|
102114
|
+
keep = validWorkspaceRestoreKeep(keep);
|
|
102066
102115
|
const root = backupRoot(dataDir2);
|
|
102067
102116
|
if (existsSync61(join110(root, "pending-restore.json"))) throw new Error("A workspace restore is already waiting for restart.");
|
|
102068
102117
|
if (existsSync61(join110(root, `safety-${id}`))) throw new Error("This restore was already attempted. Preview the backup again to create a fresh restore attempt.");
|
|
102069
102118
|
const metadata = readStagedWorkspaceBackup(dataDir2, id);
|
|
102070
102119
|
const manifest = validateStaged(join110(jobPath(dataDir2, id), "staged"));
|
|
102071
|
-
|
|
102072
|
-
|
|
102120
|
+
const incoming = new Set(manifest.entries.map((entry) => workspaceRestorePart(entry.path.split("/")[0])));
|
|
102121
|
+
if (keep.length && ![...incoming].some((part) => !keep.includes(part))) throw new Error("Choose at least one part of this backup to restore.");
|
|
102122
|
+
prepareRestore(dataDir2, id, manifest, keep);
|
|
102123
|
+
writeJson(join110(root, "pending-restore.json"), { id, keep });
|
|
102073
102124
|
return { id, restartRequired: true, summary: metadata.summary };
|
|
102074
102125
|
}
|
|
102075
102126
|
function readPendingWorkspaceRestoreMetadata(dataDir2) {
|
|
@@ -102139,15 +102190,16 @@ function rebaseMessage(message4, pairs2) {
|
|
|
102139
102190
|
function pathPairs(dataDir2, manifest) {
|
|
102140
102191
|
return restorePathPairs({ dataDir: manifest.sourceDataDir, home: manifest.sourceHome }, { dataDir: resolve27(dataDir2), home: homedir42() });
|
|
102141
102192
|
}
|
|
102142
|
-
function prepareRestore(dataDir2, id, manifest) {
|
|
102193
|
+
function prepareRestore(dataDir2, id, manifest, keep) {
|
|
102143
102194
|
assertLocalAuthOutsideSnapshot(dataDir2);
|
|
102144
102195
|
const pairs2 = pathPairs(dataDir2, manifest);
|
|
102145
|
-
const secrets = manifest.summary.secrets === true;
|
|
102196
|
+
const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
|
|
102146
102197
|
const job = jobPath(dataDir2, id);
|
|
102147
102198
|
const prepared = join110(job, "apply", "data");
|
|
102148
102199
|
if (existsSync61(join110(job, "apply"))) rmSync18(join110(job, "apply"), { recursive: true, force: true });
|
|
102149
102200
|
folder2(prepared);
|
|
102150
|
-
const
|
|
102201
|
+
const kept = (path2) => keep.includes(workspaceRestorePart(path2.split("/")[0]));
|
|
102202
|
+
const installed2 = manifest.entries.filter((entry) => !ephemeralWorkspaceTokenPath(entry.path) && !kept(entry.path));
|
|
102151
102203
|
for (const entry of installed2.filter((entry2) => entry2.type === "directory")) folder2(join110(prepared, entry.path));
|
|
102152
102204
|
for (const entry of installed2) {
|
|
102153
102205
|
const destination = join110(prepared, entry.path);
|
|
@@ -102155,9 +102207,9 @@ function prepareRestore(dataDir2, id, manifest) {
|
|
|
102155
102207
|
}
|
|
102156
102208
|
const unresolved = { paths: /* @__PURE__ */ new Set(), exists: (path2) => {
|
|
102157
102209
|
const inside2 = relative10(resolve27(dataDir2), path2);
|
|
102158
|
-
return inside2 && !inside2.startsWith("..") && !isAbsolute20(inside2) ? entryExists(join110(prepared, inside2)) : existsSync61(path2);
|
|
102210
|
+
return inside2 && !inside2.startsWith("..") && !isAbsolute20(inside2) && !kept(inside2) ? entryExists(join110(prepared, inside2)) : existsSync61(path2);
|
|
102159
102211
|
} };
|
|
102160
|
-
const skippedLinks = restoreLinks(prepared, dataDir2, manifest.links ?? [], pairs2, unresolved.paths);
|
|
102212
|
+
const skippedLinks = restoreLinks(prepared, dataDir2, (manifest.links ?? []).filter((link2) => !kept(link2.path)), pairs2, unresolved.paths);
|
|
102161
102213
|
if (pairs2.length) rebaseTree(prepared, pairs2);
|
|
102162
102214
|
const changeJson = (name2, change) => {
|
|
102163
102215
|
const path2 = join110(prepared, name2);
|
|
@@ -102175,7 +102227,7 @@ function prepareRestore(dataDir2, id, manifest) {
|
|
|
102175
102227
|
});
|
|
102176
102228
|
const oldConfig = join110(dataDir2, "config.json");
|
|
102177
102229
|
const newConfig = join110(prepared, "config.json");
|
|
102178
|
-
if (!secrets && (existsSync61(oldConfig) || existsSync61(newConfig))) {
|
|
102230
|
+
if (!kept("config.json") && !secrets && (existsSync61(oldConfig) || existsSync61(newConfig))) {
|
|
102179
102231
|
writeJson(newConfig, restoredWorkspaceConfig(existsSync61(newConfig) ? privateJson(newConfig) : {}, existsSync61(oldConfig) ? privateJson(oldConfig) : {}));
|
|
102180
102232
|
}
|
|
102181
102233
|
changeJson("config.json", (value) => rebaseFields(value, pairs2, unresolved));
|
|
@@ -102184,9 +102236,9 @@ function prepareRestore(dataDir2, id, manifest) {
|
|
|
102184
102236
|
folder2(join110(prepared, "providers", "native-vault"));
|
|
102185
102237
|
copyFileSync3(vaultKey, join110(prepared, "providers", "native-vault", "key.bin"));
|
|
102186
102238
|
}
|
|
102187
|
-
const browserHomes = ["vm-home"];
|
|
102239
|
+
const browserHomes = kept("vm-home") ? [] : ["vm-home"];
|
|
102188
102240
|
const vmHomes = join110(dataDir2, "vm-homes");
|
|
102189
|
-
if (entryExists(vmHomes)) {
|
|
102241
|
+
if (!kept("vm-homes") && entryExists(vmHomes)) {
|
|
102190
102242
|
if (!lstatSync13(vmHomes).isDirectory()) throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
|
|
102191
102243
|
for (const name2 of readdirSync23(vmHomes)) if (validRelative(name2)) browserHomes.push(`vm-homes/${name2}`);
|
|
102192
102244
|
}
|
|
@@ -102280,7 +102332,7 @@ function readLastWorkspaceRestore(dataDir2) {
|
|
|
102280
102332
|
if (!record10(raw) || raw.restored !== true || typeof raw.id !== "string" || !ID2.test(raw.id)) throw new Error("Invalid workspace restore receipt.");
|
|
102281
102333
|
return raw;
|
|
102282
102334
|
}
|
|
102283
|
-
function finishRestore(dataDir2, id, consumePending = true) {
|
|
102335
|
+
function finishRestore(dataDir2, id, consumePending = true, keep = []) {
|
|
102284
102336
|
const root = backupRoot(dataDir2);
|
|
102285
102337
|
const { summary, clientState } = readStagedWorkspaceBackup(dataDir2, id);
|
|
102286
102338
|
const draftAttachments = clientState["omb-draft-attachments"];
|
|
@@ -102296,7 +102348,7 @@ function finishRestore(dataDir2, id, consumePending = true) {
|
|
|
102296
102348
|
const unresolvedFile = join110(jobPath(dataDir2, id), "unresolved.json");
|
|
102297
102349
|
const listed = existsSync61(unresolvedFile) ? privateJson(unresolvedFile) : [];
|
|
102298
102350
|
const unresolvedPaths = Array.isArray(listed) ? listed.filter((path2) => typeof path2 === "string") : [];
|
|
102299
|
-
const result = { restored: true, id, safetyCopyPath: join110(root, `safety-${id}`), summary, clientState, unresolvedPaths };
|
|
102351
|
+
const result = { restored: true, id, safetyCopyPath: join110(root, `safety-${id}`), summary, clientState, unresolvedPaths, keep };
|
|
102300
102352
|
writeJson(join110(root, "last-restore.json"), result);
|
|
102301
102353
|
if (consumePending) rmSync18(join110(root, "pending-restore.json"), { force: true });
|
|
102302
102354
|
return result;
|
|
@@ -102316,25 +102368,28 @@ function applyPendingWorkspaceRestore(dataDir2) {
|
|
|
102316
102368
|
if (previous2.phase === "committed" && existsSync61(pendingFile)) {
|
|
102317
102369
|
const pending3 = privateJson(pendingFile);
|
|
102318
102370
|
if (record10(pending3) && pending3.id === previous2.id) {
|
|
102319
|
-
return finishRestore(dataDir2, previous2.id);
|
|
102371
|
+
return finishRestore(dataDir2, previous2.id, true, validWorkspaceRestoreKeep(previous2.keep));
|
|
102320
102372
|
}
|
|
102321
102373
|
}
|
|
102322
102374
|
}
|
|
102323
102375
|
const pending2 = readPendingWorkspaceRestoreMetadata(dataDir2);
|
|
102324
102376
|
if (!pending2) return { restored: false };
|
|
102377
|
+
const keep = validWorkspaceRestoreKeep(privateJson(pendingFile).keep);
|
|
102378
|
+
const kept = (name2) => keep.includes(workspaceRestorePart(name2));
|
|
102325
102379
|
const staged = join110(jobPath(dataDir2, pending2.id), "staged");
|
|
102326
102380
|
const manifest = validateStaged(staged);
|
|
102327
|
-
const prepared = prepareRestore(dataDir2, pending2.id, manifest);
|
|
102381
|
+
const prepared = prepareRestore(dataDir2, pending2.id, manifest, keep);
|
|
102328
102382
|
const safetyCopyPath = join110(root, `safety-${pending2.id}`);
|
|
102329
102383
|
if (existsSync61(safetyCopyPath)) throw new Error("A safety copy already exists for this restore. Original files have not been changed.");
|
|
102330
102384
|
folder2(join110(safetyCopyPath, "data"));
|
|
102331
|
-
const secrets = manifest.summary.secrets === true;
|
|
102385
|
+
const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
|
|
102332
102386
|
const journal = {
|
|
102333
102387
|
id: pending2.id,
|
|
102334
102388
|
phase: "applying",
|
|
102335
|
-
existing: readdirSync23(dataDir2).filter((name2) => !preserved(name2, secrets)).sort(),
|
|
102336
|
-
incoming: readdirSync23(prepared).sort(),
|
|
102337
|
-
secrets
|
|
102389
|
+
existing: readdirSync23(dataDir2).filter((name2) => !preserved(name2, secrets) && !kept(name2)).sort(),
|
|
102390
|
+
incoming: readdirSync23(prepared).filter((name2) => !kept(name2)).sort(),
|
|
102391
|
+
secrets,
|
|
102392
|
+
keep
|
|
102338
102393
|
};
|
|
102339
102394
|
for (const name2 of [...journal.existing, ...journal.incoming]) {
|
|
102340
102395
|
if (!validRelative(name2) || name2.includes("/") || preserved(name2, secrets)) throw new Error("Unsafe workspace restore target.");
|
|
@@ -102345,7 +102400,7 @@ function applyPendingWorkspaceRestore(dataDir2) {
|
|
|
102345
102400
|
try {
|
|
102346
102401
|
for (const name2 of journal.existing) renameSync16(join110(dataDir2, name2), join110(safetyCopyPath, "data", name2));
|
|
102347
102402
|
for (const name2 of journal.incoming) if (entryExists(join110(prepared, name2))) renameSync16(join110(prepared, name2), join110(dataDir2, name2));
|
|
102348
|
-
finishRestore(dataDir2, pending2.id, false);
|
|
102403
|
+
finishRestore(dataDir2, pending2.id, false, keep);
|
|
102349
102404
|
writeJson(journalFile2, { ...journal, phase: "committed" });
|
|
102350
102405
|
} catch (error51) {
|
|
102351
102406
|
rollback(dataDir2, journal);
|
|
@@ -102353,7 +102408,7 @@ function applyPendingWorkspaceRestore(dataDir2) {
|
|
|
102353
102408
|
rmSync18(pendingFile, { force: true });
|
|
102354
102409
|
throw new Error("The workspace restore failed and the previous workspace was recovered.", { cause: error51 });
|
|
102355
102410
|
}
|
|
102356
|
-
return finishRestore(dataDir2, pending2.id);
|
|
102411
|
+
return finishRestore(dataDir2, pending2.id, true, keep);
|
|
102357
102412
|
}
|
|
102358
102413
|
function removeWorkspaceBackupJob(dataDir2, id) {
|
|
102359
102414
|
const path2 = jobPath(dataDir2, id);
|
|
@@ -102493,7 +102548,8 @@ function createWorkspaceBackupRoutes(options) {
|
|
|
102493
102548
|
safetyCopyPath: restored.safetyCopyPath ?? null,
|
|
102494
102549
|
// What Settings shows after a restore: what to sign in to or clone again.
|
|
102495
102550
|
lastRestore: restored.restored ? {
|
|
102496
|
-
secretsIncluded: restored.summary?.secrets === true,
|
|
102551
|
+
secretsIncluded: restored.summary?.secrets === true && !restored.keep?.includes("credentials"),
|
|
102552
|
+
keep: restored.keep ?? [],
|
|
102497
102553
|
secrets: restored.secrets ?? null,
|
|
102498
102554
|
unresolvedPaths: restored.unresolvedPaths ?? [],
|
|
102499
102555
|
checkouts: restored.summary?.checkouts ?? [],
|
|
@@ -102506,7 +102562,7 @@ function createWorkspaceBackupRoutes(options) {
|
|
|
102506
102562
|
const body = external_exports.object({ restoreId: external_exports.string().uuid() }).parse(await options.readBody(req));
|
|
102507
102563
|
check2(req, auth);
|
|
102508
102564
|
if (!options.restored.restored || body.restoreId !== options.restored.id) throw failure3("This restore has not completed. Restart Atomic first.", 409);
|
|
102509
|
-
json5(res, 200, { clientState: options.restored.clientState ?? {} });
|
|
102565
|
+
json5(res, 200, { clientState: options.restored.clientState ?? {}, keep: options.restored.keep ?? [] });
|
|
102510
102566
|
return true;
|
|
102511
102567
|
}
|
|
102512
102568
|
if (method === "POST" && path2 === `${PREFIX}/export`) {
|
|
@@ -102652,14 +102708,15 @@ function createWorkspaceBackupRoutes(options) {
|
|
|
102652
102708
|
return true;
|
|
102653
102709
|
}
|
|
102654
102710
|
if (method === "POST" && path2 === `${PREFIX}/restore`) {
|
|
102655
|
-
const body = external_exports.object({ id: external_exports.string().uuid(), confirmation: external_exports.literal("REPLACE") }).parse(await options.readBody(req));
|
|
102711
|
+
const body = external_exports.object({ id: external_exports.string().uuid(), confirmation: external_exports.literal("REPLACE"), keep: external_exports.array(external_exports.enum(WORKSPACE_RESTORE_PARTS)).max(WORKSPACE_RESTORE_PARTS.length).optional() }).parse(await options.readBody(req));
|
|
102712
|
+
if (body.keep?.includes("settings") && !body.keep.includes("credentials")) throw failure3("Restore app settings with saved credentials, or keep both on this computer.", 400);
|
|
102656
102713
|
get(body.id, auth, "staged");
|
|
102657
102714
|
const result = await operate(() => options.exclusive(async () => {
|
|
102658
102715
|
check2(req, auth);
|
|
102659
102716
|
const secrets = stagedSecrets.get(body.id);
|
|
102660
102717
|
const desktop2 = desktopWorkspaceSecrets();
|
|
102661
|
-
if (secrets && desktop2) await desktop2.stage(body.id, secrets);
|
|
102662
|
-
return commitPendingWorkspaceRestore(options.dataDir, body.id);
|
|
102718
|
+
if (secrets && desktop2 && !body.keep?.includes("credentials")) await desktop2.stage(body.id, secrets);
|
|
102719
|
+
return commitPendingWorkspaceRestore(options.dataDir, body.id, body.keep);
|
|
102663
102720
|
}, true));
|
|
102664
102721
|
artifacts.delete(body.id);
|
|
102665
102722
|
stagedSecrets.delete(body.id);
|
|
@@ -103396,7 +103453,7 @@ import { isIP as isIP2 } from "node:net";
|
|
|
103396
103453
|
|
|
103397
103454
|
// server/connected-assistants.ts
|
|
103398
103455
|
import { createHash as createHash45, randomBytes as randomBytes10, randomUUID as randomUUID37, timingSafeEqual as timingSafeEqual4 } from "node:crypto";
|
|
103399
|
-
import { existsSync as existsSync63, mkdirSync as mkdirSync57, readdirSync as readdirSync25, readFileSync as
|
|
103456
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync57, readdirSync as readdirSync25, readFileSync as readFileSync88, rmSync as rmSync19 } from "node:fs";
|
|
103400
103457
|
import { appendFile as appendFile5, mkdir as mkdir8 } from "node:fs/promises";
|
|
103401
103458
|
import { dirname as dirname31, join as join112 } from "node:path";
|
|
103402
103459
|
var ASSISTANT_TOKEN_PREFIX = "omb_asst_";
|
|
@@ -103421,7 +103478,7 @@ var ConnectedAssistants = class {
|
|
|
103421
103478
|
this.now = options.now ?? Date.now;
|
|
103422
103479
|
if (!existsSync63(this.file)) return;
|
|
103423
103480
|
try {
|
|
103424
|
-
const parsed = fileSchema3.safeParse(JSON.parse(
|
|
103481
|
+
const parsed = fileSchema3.safeParse(JSON.parse(readFileSync88(this.file, "utf8")));
|
|
103425
103482
|
if (parsed.success) this.assistants = parsed.data.assistants;
|
|
103426
103483
|
} catch {
|
|
103427
103484
|
}
|
|
@@ -103534,7 +103591,7 @@ function recentAssistantAudit(dataDir2, limit = 20, assistantId) {
|
|
|
103534
103591
|
const files = readdirSync25(dir).filter((name2) => MONTH_FILE2.test(name2)).sort().slice(-2).reverse();
|
|
103535
103592
|
const rows = [];
|
|
103536
103593
|
for (const name2 of files) {
|
|
103537
|
-
const lines =
|
|
103594
|
+
const lines = readFileSync88(join112(dir, name2), "utf8").split("\n").filter(Boolean).reverse();
|
|
103538
103595
|
for (const line3 of lines) {
|
|
103539
103596
|
try {
|
|
103540
103597
|
const row = JSON.parse(line3);
|
|
@@ -104111,7 +104168,7 @@ function resolveRequestAuth(req, options) {
|
|
|
104111
104168
|
|
|
104112
104169
|
// server/sessions.ts
|
|
104113
104170
|
import { createHash as createHash46, randomBytes as randomBytes11, randomUUID as randomUUID38, timingSafeEqual as timingSafeEqual6 } from "node:crypto";
|
|
104114
|
-
import { closeSync as closeSync18, existsSync as existsSync64, fsyncSync as fsyncSync5, mkdirSync as mkdirSync58, openSync as openSync18, readFileSync as
|
|
104171
|
+
import { closeSync as closeSync18, existsSync as existsSync64, fsyncSync as fsyncSync5, mkdirSync as mkdirSync58, openSync as openSync18, readFileSync as readFileSync89, unlinkSync as unlinkSync15 } from "node:fs";
|
|
104115
104172
|
import { dirname as dirname32 } from "node:path";
|
|
104116
104173
|
var SCOPES = ["admin", "client"];
|
|
104117
104174
|
var PAIRING_CODE_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
@@ -104225,7 +104282,7 @@ var SessionRegistry = class {
|
|
|
104225
104282
|
if (!existsSync64(this.options.file)) return;
|
|
104226
104283
|
let raw;
|
|
104227
104284
|
try {
|
|
104228
|
-
raw = JSON.parse(
|
|
104285
|
+
raw = JSON.parse(readFileSync89(this.options.file, "utf8"));
|
|
104229
104286
|
} catch {
|
|
104230
104287
|
return;
|
|
104231
104288
|
}
|
|
@@ -104540,13 +104597,13 @@ var SessionRegistry = class {
|
|
|
104540
104597
|
};
|
|
104541
104598
|
|
|
104542
104599
|
// server/editor-connect.ts
|
|
104543
|
-
import { copyFileSync as copyFileSync6, existsSync as existsSync66, mkdirSync as mkdirSync59, readFileSync as
|
|
104600
|
+
import { copyFileSync as copyFileSync6, existsSync as existsSync66, mkdirSync as mkdirSync59, readFileSync as readFileSync91, statSync as statSync25 } from "node:fs";
|
|
104544
104601
|
import { homedir as homedir44 } from "node:os";
|
|
104545
104602
|
import { dirname as dirname33, join as join114 } from "node:path";
|
|
104546
104603
|
|
|
104547
104604
|
// server/claude-code-connect.ts
|
|
104548
104605
|
import { execFile as execFile10 } from "node:child_process";
|
|
104549
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync65, readFileSync as
|
|
104606
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync65, readFileSync as readFileSync90, statSync as statSync24 } from "node:fs";
|
|
104550
104607
|
import { homedir as homedir43 } from "node:os";
|
|
104551
104608
|
import { join as join113 } from "node:path";
|
|
104552
104609
|
import { promisify as promisify6 } from "node:util";
|
|
@@ -104609,7 +104666,7 @@ async function unregisterFromClaudeCode(options = {}) {
|
|
|
104609
104666
|
}
|
|
104610
104667
|
function claudeCodeHasEntry(options = {}) {
|
|
104611
104668
|
try {
|
|
104612
|
-
const config2 = JSON.parse(
|
|
104669
|
+
const config2 = JSON.parse(readFileSync90(claudeCodeConfigPath(options.env, options.home), "utf8"));
|
|
104613
104670
|
return Boolean(config2?.mcpServers?.[CLAUDE_CODE_SERVER_NAME]);
|
|
104614
104671
|
} catch {
|
|
104615
104672
|
return false;
|
|
@@ -104619,7 +104676,7 @@ function editConfig(configPath, change) {
|
|
|
104619
104676
|
let config2 = {};
|
|
104620
104677
|
let mode = 384;
|
|
104621
104678
|
if (existsSync65(configPath)) {
|
|
104622
|
-
const raw =
|
|
104679
|
+
const raw = readFileSync90(configPath, "utf8");
|
|
104623
104680
|
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
104624
104681
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${configPath} is not a JSON object; add the entry with \`claude mcp add-json\` instead`);
|
|
104625
104682
|
config2 = parsed;
|
|
@@ -104661,7 +104718,7 @@ function editorEntry(format, entry) {
|
|
|
104661
104718
|
var serversKey = (format) => format === "vscode" ? "servers" : format === "opencode" ? "mcp" : "mcpServers";
|
|
104662
104719
|
function readConfig(path2) {
|
|
104663
104720
|
if (!existsSync66(path2)) return {};
|
|
104664
|
-
const raw =
|
|
104721
|
+
const raw = readFileSync91(path2, "utf8");
|
|
104665
104722
|
const parsed = raw.trim() ? JSON.parse(raw) : {};
|
|
104666
104723
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${path2} is not a JSON object`);
|
|
104667
104724
|
return parsed;
|
|
@@ -104702,7 +104759,7 @@ function editorHasEntry(target) {
|
|
|
104702
104759
|
}
|
|
104703
104760
|
|
|
104704
104761
|
// server/thread-starters.ts
|
|
104705
|
-
import { readFileSync as
|
|
104762
|
+
import { readFileSync as readFileSync92 } from "node:fs";
|
|
104706
104763
|
var KEY = /^p_[\w-]{22}$/;
|
|
104707
104764
|
var THREAD = /^[\w-]{1,128}$/;
|
|
104708
104765
|
var MAX_ENTRIES3 = 5e4;
|
|
@@ -104713,7 +104770,7 @@ var ThreadStarters = class {
|
|
|
104713
104770
|
this.file = file2;
|
|
104714
104771
|
let raw;
|
|
104715
104772
|
try {
|
|
104716
|
-
raw = JSON.parse(
|
|
104773
|
+
raw = JSON.parse(readFileSync92(file2, "utf8"));
|
|
104717
104774
|
} catch {
|
|
104718
104775
|
return;
|
|
104719
104776
|
}
|
|
@@ -104739,7 +104796,7 @@ var ThreadStarters = class {
|
|
|
104739
104796
|
};
|
|
104740
104797
|
|
|
104741
104798
|
// server/admin-activity.ts
|
|
104742
|
-
import { readdirSync as readdirSync26, readFileSync as
|
|
104799
|
+
import { readdirSync as readdirSync26, readFileSync as readFileSync93 } from "node:fs";
|
|
104743
104800
|
import { appendFile as appendFile6, mkdir as mkdir9 } from "node:fs/promises";
|
|
104744
104801
|
import { basename as basename18, join as join115 } from "node:path";
|
|
104745
104802
|
var ADMIN_ACTIVITY_CATEGORIES = ["config", "people", "session", "webhook", "mcp", "engine", "bot", "budget", "visibility"];
|
|
@@ -104959,7 +105016,7 @@ var isRow2 = (value) => isPlainObject2(value) && typeof value.at === "string" &&
|
|
|
104959
105016
|
function readRows2(path2) {
|
|
104960
105017
|
let text18;
|
|
104961
105018
|
try {
|
|
104962
|
-
text18 =
|
|
105019
|
+
text18 = readFileSync93(path2, "utf8");
|
|
104963
105020
|
} catch {
|
|
104964
105021
|
return [];
|
|
104965
105022
|
}
|
|
@@ -105071,7 +105128,7 @@ function activityCsv(entries2) {
|
|
|
105071
105128
|
}
|
|
105072
105129
|
|
|
105073
105130
|
// server/brand.ts
|
|
105074
|
-
import { existsSync as existsSync67, readFileSync as
|
|
105131
|
+
import { existsSync as existsSync67, readFileSync as readFileSync94 } from "node:fs";
|
|
105075
105132
|
import { join as join116 } from "node:path";
|
|
105076
105133
|
var HEX_COLOUR = /^#[0-9a-fA-F]{6}$/;
|
|
105077
105134
|
var MAX_LOGO_CHARS = 3e5;
|
|
@@ -105120,7 +105177,7 @@ function loadBrand(options = {}) {
|
|
|
105120
105177
|
if (!existsSync67(file2)) return fallback();
|
|
105121
105178
|
let raw;
|
|
105122
105179
|
try {
|
|
105123
|
-
raw = JSON.parse(
|
|
105180
|
+
raw = JSON.parse(readFileSync94(file2, "utf8"));
|
|
105124
105181
|
} catch (error51) {
|
|
105125
105182
|
return fallback(`${file2} is not valid JSON (${error51 instanceof Error ? error51.message : String(error51)}); using the default brand`);
|
|
105126
105183
|
}
|
|
@@ -107643,7 +107700,7 @@ var PhoneSecretBridge = class {
|
|
|
107643
107700
|
|
|
107644
107701
|
// server/bot-work-modes.ts
|
|
107645
107702
|
import { randomUUID as randomUUID39 } from "node:crypto";
|
|
107646
|
-
import { existsSync as existsSync68, readFileSync as
|
|
107703
|
+
import { existsSync as existsSync68, readFileSync as readFileSync95 } from "node:fs";
|
|
107647
107704
|
var WORK_MODES = ["plan", "ask", "edits", "full"];
|
|
107648
107705
|
var valid2 = (value) => WORK_MODES.includes(value);
|
|
107649
107706
|
var BotWorkModes = class {
|
|
@@ -107655,7 +107712,7 @@ var BotWorkModes = class {
|
|
|
107655
107712
|
this.file = file2;
|
|
107656
107713
|
if (!existsSync68(file2)) return;
|
|
107657
107714
|
try {
|
|
107658
|
-
const data = JSON.parse(
|
|
107715
|
+
const data = JSON.parse(readFileSync95(file2, "utf8"));
|
|
107659
107716
|
if (Array.isArray(data.allowed)) this.allowed = ["ask", ...data.allowed.filter((mode) => valid2(mode) && mode !== "ask")];
|
|
107660
107717
|
for (const [id, entry] of Object.entries(data.selections ?? {})) {
|
|
107661
107718
|
const item = entry;
|
|
@@ -111452,7 +111509,7 @@ function mergeHistoryEnvVars(result, history) {
|
|
|
111452
111509
|
}
|
|
111453
111510
|
|
|
111454
111511
|
// server/model-levels/overrides.ts
|
|
111455
|
-
import { existsSync as existsSync71, mkdirSync as mkdirSync60, readFileSync as
|
|
111512
|
+
import { existsSync as existsSync71, mkdirSync as mkdirSync60, readFileSync as readFileSync96 } from "node:fs";
|
|
111456
111513
|
import { dirname as dirname36 } from "node:path";
|
|
111457
111514
|
var OVERRIDES_FILE = "model-levels-overrides.json";
|
|
111458
111515
|
var LEGACY_CAPABILITY_ORDER = ["*", "agent", "coding", "writing", "search", "tools"];
|
|
@@ -111509,7 +111566,7 @@ function parseOverrides(raw) {
|
|
|
111509
111566
|
function readOverrides(path2) {
|
|
111510
111567
|
if (!existsSync71(path2)) return parseOverrides(void 0);
|
|
111511
111568
|
try {
|
|
111512
|
-
return parseOverrides(JSON.parse(
|
|
111569
|
+
return parseOverrides(JSON.parse(readFileSync96(path2, "utf8")));
|
|
111513
111570
|
} catch (error51) {
|
|
111514
111571
|
return { overrides: { aliases: {}, classes: {} }, problems: [`${path2}: ${error51 instanceof Error ? error51.message : String(error51)}`] };
|
|
111515
111572
|
}
|
|
@@ -113122,7 +113179,7 @@ import { createServer as createServer3 } from "node:http";
|
|
|
113122
113179
|
|
|
113123
113180
|
// server/oauth-account-vault.ts
|
|
113124
113181
|
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes12, randomUUID as randomUUID43 } from "node:crypto";
|
|
113125
|
-
import { mkdirSync as mkdirSync63, readFileSync as
|
|
113182
|
+
import { mkdirSync as mkdirSync63, readFileSync as readFileSync97 } from "node:fs";
|
|
113126
113183
|
import { join as join125 } from "node:path";
|
|
113127
113184
|
var MAX_OAUTH_ACCOUNTS = 40;
|
|
113128
113185
|
var OAUTH_ACCOUNTS_ENV = "OMB_OAUTH_ACCOUNTS";
|
|
@@ -113224,7 +113281,7 @@ var FileAccountVault = class {
|
|
|
113224
113281
|
key() {
|
|
113225
113282
|
const file2 = join125(this.directory, "key");
|
|
113226
113283
|
try {
|
|
113227
|
-
const existing =
|
|
113284
|
+
const existing = readFileSync97(file2, "utf8").trim();
|
|
113228
113285
|
if (/^[0-9a-f]{64}$/u.test(existing)) return Buffer.from(existing, "hex");
|
|
113229
113286
|
} catch {
|
|
113230
113287
|
}
|
|
@@ -113237,7 +113294,7 @@ var FileAccountVault = class {
|
|
|
113237
113294
|
load() {
|
|
113238
113295
|
let raw;
|
|
113239
113296
|
try {
|
|
113240
|
-
raw =
|
|
113297
|
+
raw = readFileSync97(join125(this.directory, "accounts.enc"), "utf8");
|
|
113241
113298
|
} catch {
|
|
113242
113299
|
return {};
|
|
113243
113300
|
}
|
|
@@ -113955,7 +114012,7 @@ import { timingSafeEqual as timingSafeEqual8 } from "node:crypto";
|
|
|
113955
114012
|
|
|
113956
114013
|
// server/vault/store.ts
|
|
113957
114014
|
import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes14, randomUUID as randomUUID45 } from "node:crypto";
|
|
113958
|
-
import { lstatSync as lstatSync15, mkdirSync as mkdirSync64, readFileSync as
|
|
114015
|
+
import { lstatSync as lstatSync15, mkdirSync as mkdirSync64, readFileSync as readFileSync98, rmdirSync } from "node:fs";
|
|
113959
114016
|
import { join as join126 } from "node:path";
|
|
113960
114017
|
|
|
113961
114018
|
// shared/vault.ts
|
|
@@ -114071,7 +114128,7 @@ var VaultStore = class {
|
|
|
114071
114128
|
throw error51;
|
|
114072
114129
|
}
|
|
114073
114130
|
if (!stat8.isFile() || stat8.isSymbolicLink() || stat8.size > MAX_BYTES2) throw new Error();
|
|
114074
|
-
const envelope = envelopeSchema.parse(JSON.parse(
|
|
114131
|
+
const envelope = envelopeSchema.parse(JSON.parse(readFileSync98(this.#file, "utf8")));
|
|
114075
114132
|
const decipher = createDecipheriv3("aes-256-gcm", this.#key, Buffer.from(envelope.iv, "hex"));
|
|
114076
114133
|
decipher.setAAD(AAD);
|
|
114077
114134
|
decipher.setAuthTag(Buffer.from(envelope.tag, "hex"));
|
|
@@ -116160,7 +116217,7 @@ function localTag(model2) {
|
|
|
116160
116217
|
}
|
|
116161
116218
|
|
|
116162
116219
|
// server/model-levels/artificial-analysis.ts
|
|
116163
|
-
import { existsSync as existsSync75, readFileSync as
|
|
116220
|
+
import { existsSync as existsSync75, readFileSync as readFileSync99 } from "node:fs";
|
|
116164
116221
|
import { homedir as homedir50 } from "node:os";
|
|
116165
116222
|
import { join as join128 } from "node:path";
|
|
116166
116223
|
var AA_MODELS_URL = "https://artificialanalysis.ai/api/v2/data/llms/models";
|
|
@@ -116172,7 +116229,7 @@ function artificialAnalysisKey(env = process.env, envFile = join128(homedir50(),
|
|
|
116172
116229
|
let text18;
|
|
116173
116230
|
try {
|
|
116174
116231
|
if (!existsSync75(envFile)) return void 0;
|
|
116175
|
-
text18 =
|
|
116232
|
+
text18 = readFileSync99(envFile, "utf8");
|
|
116176
116233
|
} catch {
|
|
116177
116234
|
return void 0;
|
|
116178
116235
|
}
|
|
@@ -117502,7 +117559,7 @@ var BASELINE = {
|
|
|
117502
117559
|
};
|
|
117503
117560
|
|
|
117504
117561
|
// server/model-levels/cache.ts
|
|
117505
|
-
import { existsSync as existsSync76, mkdirSync as mkdirSync65, readFileSync as
|
|
117562
|
+
import { existsSync as existsSync76, mkdirSync as mkdirSync65, readFileSync as readFileSync100 } from "node:fs";
|
|
117506
117563
|
import { dirname as dirname37 } from "node:path";
|
|
117507
117564
|
var CACHE_FILE = "model-levels.json";
|
|
117508
117565
|
var AA_CACHE_FILE = "model-classes-aa.json";
|
|
@@ -117531,7 +117588,7 @@ function validSnapshots(value, knownSources) {
|
|
|
117531
117588
|
function readCache2(path2, knownSources) {
|
|
117532
117589
|
if (!existsSync76(path2)) return [];
|
|
117533
117590
|
try {
|
|
117534
|
-
const parsed = JSON.parse(
|
|
117591
|
+
const parsed = JSON.parse(readFileSync100(path2, "utf8"));
|
|
117535
117592
|
if (parsed.version !== VERSION && parsed.version !== 1) return [];
|
|
117536
117593
|
return validSnapshots(parsed.snapshots, knownSources);
|
|
117537
117594
|
} catch {
|
|
@@ -117555,7 +117612,7 @@ function validAaRow(row) {
|
|
|
117555
117612
|
function readAaCache(path2) {
|
|
117556
117613
|
if (!existsSync76(path2)) return null;
|
|
117557
117614
|
try {
|
|
117558
|
-
const parsed = JSON.parse(
|
|
117615
|
+
const parsed = JSON.parse(readFileSync100(path2, "utf8"));
|
|
117559
117616
|
if (parsed.version !== AA_VERSION || typeof parsed.snapshot?.fetchedAt !== "string" || !Array.isArray(parsed.snapshot.rows)) return null;
|
|
117560
117617
|
const rows = parsed.snapshot.rows.filter(validAaRow);
|
|
117561
117618
|
return rows.length ? { fetchedAt: parsed.snapshot.fetchedAt, rows } : null;
|
|
@@ -117570,7 +117627,7 @@ function writeAaCache(path2, snapshot2, now) {
|
|
|
117570
117627
|
}
|
|
117571
117628
|
|
|
117572
117629
|
// server/model-levels/chibitek-rankings.ts
|
|
117573
|
-
import { existsSync as existsSync77, mkdirSync as mkdirSync66, readFileSync as
|
|
117630
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync66, readFileSync as readFileSync101 } from "node:fs";
|
|
117574
117631
|
import { dirname as dirname38 } from "node:path";
|
|
117575
117632
|
var CHIBITEK_RANKINGS_CACHE = "model-rankings-chibitek.json";
|
|
117576
117633
|
var CACHE_VERSION = 1;
|
|
@@ -117608,7 +117665,7 @@ function parseRankings(raw, catalog2, fetchedAt) {
|
|
|
117608
117665
|
function readRankingsCache(path2, catalog2) {
|
|
117609
117666
|
if (!existsSync77(path2)) return null;
|
|
117610
117667
|
try {
|
|
117611
|
-
const parsed = JSON.parse(
|
|
117668
|
+
const parsed = JSON.parse(readFileSync101(path2, "utf8"));
|
|
117612
117669
|
if (parsed.version !== CACHE_VERSION || typeof parsed.fetchedAt !== "string") return null;
|
|
117613
117670
|
return parseRankings(parsed.document, catalog2, parsed.fetchedAt)?.rankings ?? null;
|
|
117614
117671
|
} catch {
|
|
@@ -118816,7 +118873,7 @@ function isChange(value) {
|
|
|
118816
118873
|
}
|
|
118817
118874
|
|
|
118818
118875
|
// server/primary-bot.ts
|
|
118819
|
-
import { existsSync as existsSync78, mkdirSync as mkdirSync67, readFileSync as
|
|
118876
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync67, readFileSync as readFileSync102 } from "node:fs";
|
|
118820
118877
|
import { dirname as dirname39, join as join130 } from "node:path";
|
|
118821
118878
|
var PRIMARY_BOT_FILE = "primary-bot.json";
|
|
118822
118879
|
var PRIMARY_BOT_THREAD_TITLE = "Primary Bot sweeps";
|
|
@@ -119191,7 +119248,7 @@ var PrimaryBotStore = class {
|
|
|
119191
119248
|
const empty = () => ({ version: 1, settings: normalizeSettings(void 0), history: [], attempted: {}, checkedIn: {}, threadAttempts: {}, failures: [] });
|
|
119192
119249
|
if (!existsSync78(this.path)) return empty();
|
|
119193
119250
|
try {
|
|
119194
|
-
const raw = JSON.parse(
|
|
119251
|
+
const raw = JSON.parse(readFileSync102(this.path, "utf8"));
|
|
119195
119252
|
const file2 = empty();
|
|
119196
119253
|
file2.settings = normalizeSettings(raw.settings);
|
|
119197
119254
|
file2.history = (Array.isArray(raw.history) ? raw.history : []).filter((record12) => record12 && typeof record12.id === "string" && finite4(record12.at)).slice(0, HISTORY_LIMIT2);
|
|
@@ -119463,7 +119520,7 @@ function moveIntoChibi(botId, deps) {
|
|
|
119463
119520
|
}
|
|
119464
119521
|
|
|
119465
119522
|
// server/engine-rest.ts
|
|
119466
|
-
import { existsSync as existsSync79, mkdirSync as mkdirSync68, readFileSync as
|
|
119523
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync68, readFileSync as readFileSync103 } from "node:fs";
|
|
119467
119524
|
import { dirname as dirname40, join as join131 } from "node:path";
|
|
119468
119525
|
var ENGINE_REST_FILE = "engine-rest.json";
|
|
119469
119526
|
var MINUTE_MS2 = 6e4;
|
|
@@ -119708,7 +119765,7 @@ var EngineRestStore = class {
|
|
|
119708
119765
|
load() {
|
|
119709
119766
|
if (!existsSync79(this.path)) return;
|
|
119710
119767
|
try {
|
|
119711
|
-
const raw = JSON.parse(
|
|
119768
|
+
const raw = JSON.parse(readFileSync103(this.path, "utf8"));
|
|
119712
119769
|
for (const entry of Array.isArray(raw.entries) ? raw.entries : []) {
|
|
119713
119770
|
if (!validEntry(entry)) continue;
|
|
119714
119771
|
this.entries.set(keyOf(entry.instanceId, entry.account, entry.scope), entry);
|
|
@@ -119748,7 +119805,7 @@ function validRecord(value) {
|
|
|
119748
119805
|
}
|
|
119749
119806
|
|
|
119750
119807
|
// server/pay-per-use.ts
|
|
119751
|
-
import { existsSync as existsSync80, mkdirSync as mkdirSync69, readFileSync as
|
|
119808
|
+
import { existsSync as existsSync80, mkdirSync as mkdirSync69, readFileSync as readFileSync104 } from "node:fs";
|
|
119752
119809
|
import { dirname as dirname41, join as join132 } from "node:path";
|
|
119753
119810
|
var PAY_PER_USE_FILE = "pay-per-use.json";
|
|
119754
119811
|
var PERSONAL_PAY_PER_USE_FILE = "pay-per-use-personal.json";
|
|
@@ -119879,7 +119936,7 @@ var PayPerUseEpisodes = class {
|
|
|
119879
119936
|
load() {
|
|
119880
119937
|
if (!existsSync80(this.path)) return;
|
|
119881
119938
|
try {
|
|
119882
|
-
const raw = JSON.parse(
|
|
119939
|
+
const raw = JSON.parse(readFileSync104(this.path, "utf8"));
|
|
119883
119940
|
this.episodes = (Array.isArray(raw.episodes) ? raw.episodes : []).filter(validEpisode).slice(0, HISTORY_LIMIT4);
|
|
119884
119941
|
} catch (error51) {
|
|
119885
119942
|
console.error(`pay-per-use: ignoring unreadable ${this.path}: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -120891,7 +120948,7 @@ function createTeamRoomsRoutes(deps) {
|
|
|
120891
120948
|
|
|
120892
120949
|
// server/team-rooms/host.ts
|
|
120893
120950
|
import { randomUUID as randomUUID47 } from "node:crypto";
|
|
120894
|
-
import { existsSync as existsSync82, mkdirSync as mkdirSync71, readFileSync as
|
|
120951
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync71, readFileSync as readFileSync106, writeFileSync as writeFileSync36 } from "node:fs";
|
|
120895
120952
|
import { join as join134 } from "node:path";
|
|
120896
120953
|
|
|
120897
120954
|
// server/stiki-session.ts
|
|
@@ -120923,7 +120980,7 @@ function onStikiSessionChange(listener) {
|
|
|
120923
120980
|
|
|
120924
120981
|
// server/team-rooms/service.ts
|
|
120925
120982
|
import { randomUUID as randomUUID46 } from "node:crypto";
|
|
120926
|
-
import { existsSync as existsSync81, mkdirSync as mkdirSync70, readdirSync as readdirSync27, readFileSync as
|
|
120983
|
+
import { existsSync as existsSync81, mkdirSync as mkdirSync70, readdirSync as readdirSync27, readFileSync as readFileSync105, rmSync as rmSync23, writeFileSync as writeFileSync35 } from "node:fs";
|
|
120927
120984
|
import { join as join133 } from "node:path";
|
|
120928
120985
|
|
|
120929
120986
|
// server/team-rooms/realtime.ts
|
|
@@ -121763,7 +121820,7 @@ var TeamRoomsService = class {
|
|
|
121763
121820
|
try {
|
|
121764
121821
|
for (const name2 of readdirSync27(dir)) {
|
|
121765
121822
|
if (!name2.endsWith(".json")) continue;
|
|
121766
|
-
const raw = JSON.parse(
|
|
121823
|
+
const raw = JSON.parse(readFileSync105(join133(dir, name2), "utf8"));
|
|
121767
121824
|
if (raw?.room?.id && !this.rooms.has(raw.room.id)) this.rooms.set(raw.room.id, { ...raw, turns: /* @__PURE__ */ new Map(), approvals: /* @__PURE__ */ new Map() });
|
|
121768
121825
|
}
|
|
121769
121826
|
} catch {
|
|
@@ -121927,7 +121984,7 @@ var TeamRoomsHost = class {
|
|
|
121927
121984
|
}
|
|
121928
121985
|
readThreads() {
|
|
121929
121986
|
try {
|
|
121930
|
-
return JSON.parse(
|
|
121987
|
+
return JSON.parse(readFileSync106(join134(this.deps.dataDir, "team-rooms", "threads.json"), "utf8"));
|
|
121931
121988
|
} catch {
|
|
121932
121989
|
return {};
|
|
121933
121990
|
}
|
|
@@ -121953,7 +122010,7 @@ function loadInstallId(dataDir2) {
|
|
|
121953
122010
|
const dir = join134(dataDir2, "team-rooms");
|
|
121954
122011
|
const file2 = join134(dir, "install-id");
|
|
121955
122012
|
if (existsSync82(file2)) {
|
|
121956
|
-
const id2 =
|
|
122013
|
+
const id2 = readFileSync106(file2, "utf8").trim();
|
|
121957
122014
|
if (/^[\w.:-]{8,200}$/.test(id2)) return id2;
|
|
121958
122015
|
}
|
|
121959
122016
|
mkdirSync71(dir, { recursive: true, mode: 448 });
|
|
@@ -122859,7 +122916,7 @@ async function runAnswerCheck(input, deps) {
|
|
|
122859
122916
|
}
|
|
122860
122917
|
|
|
122861
122918
|
// server/jev/key.ts
|
|
122862
|
-
import { existsSync as existsSync83, readFileSync as
|
|
122919
|
+
import { existsSync as existsSync83, readFileSync as readFileSync107 } from "node:fs";
|
|
122863
122920
|
import { homedir as homedir51 } from "node:os";
|
|
122864
122921
|
import { join as join135 } from "node:path";
|
|
122865
122922
|
var TYPESAFE_KEY_VARIABLE = "TYPESAFE_API_KEY";
|
|
@@ -122873,7 +122930,7 @@ function readEnvKey(name2, env = process.env, envFile = defaultEnvFile()) {
|
|
|
122873
122930
|
let text18;
|
|
122874
122931
|
try {
|
|
122875
122932
|
if (!existsSync83(envFile)) return void 0;
|
|
122876
|
-
text18 =
|
|
122933
|
+
text18 = readFileSync107(envFile, "utf8");
|
|
122877
122934
|
} catch {
|
|
122878
122935
|
return void 0;
|
|
122879
122936
|
}
|
|
@@ -136496,13 +136553,13 @@ function serveStatic(res, path2) {
|
|
|
136496
136553
|
const safe3 = path2 === "/" ? "/index.html" : path2.replace(/\.\./g, "");
|
|
136497
136554
|
const file2 = join136(STATIC_DIR, safe3);
|
|
136498
136555
|
try {
|
|
136499
|
-
const data =
|
|
136556
|
+
const data = readFileSync108(file2);
|
|
136500
136557
|
res.writeHead(200, { "content-type": MIME3[extname7(file2)] ?? "application/octet-stream" });
|
|
136501
136558
|
res.end(data);
|
|
136502
136559
|
return true;
|
|
136503
136560
|
} catch {
|
|
136504
136561
|
try {
|
|
136505
|
-
const data =
|
|
136562
|
+
const data = readFileSync108(join136(STATIC_DIR, "index.html"));
|
|
136506
136563
|
res.writeHead(200, { "content-type": "text/html" });
|
|
136507
136564
|
res.end(data);
|
|
136508
136565
|
return true;
|