@wirecat/cli-memo 0.131.67 → 0.131.68
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/bin/memo.js +2 -2
- package/dist/bundle/{all-profiles-W3GRNNLJ.js → all-profiles-6JKSPBBO.js} +5 -5
- package/dist/bundle/{anthropic-GWMYHBO4.js → anthropic-YA2N6EJ4.js} +2 -2
- package/dist/bundle/{app-server-RQ26EXNI.js → app-server-PGZD3JUW.js} +35 -35
- package/dist/bundle/auto-OVLXIZRU.js +85 -0
- package/dist/bundle/{bun-KKLPQTG5.js → bun-OUFOAYV4.js} +2 -2
- package/dist/bundle/{bun-sqlite-WKIZJNTG.js → bun-sqlite-5RZTFU2Q.js} +2 -2
- package/dist/bundle/{chunk-R4H5HSQZ.js → chunk-22CDLXSR.js} +4 -4
- package/dist/bundle/{chunk-XI5UABKO.js → chunk-267N22E4.js} +1 -1
- package/dist/bundle/{chunk-7IKET6ES.js → chunk-276KPJI5.js} +2 -2
- package/dist/bundle/{chunk-32ROGX5N.js → chunk-2C7Z7CKD.js} +1 -1
- package/dist/bundle/{chunk-NNUJWCEJ.js → chunk-2DQYP2K3.js} +1 -1
- package/dist/bundle/{chunk-TQXXOUOX.js → chunk-2F35N6BI.js} +1 -1
- package/dist/bundle/{chunk-7OMKWYFN.js → chunk-37H7TTWN.js} +16 -9
- package/dist/bundle/{chunk-ECMYCWG2.js → chunk-3LGLKLBA.js} +2 -2
- package/dist/bundle/{chunk-TWTAWPC7.js → chunk-4AH6FONF.js} +12 -12
- package/dist/bundle/{chunk-MLF5FLAP.js → chunk-4HSWIXYE.js} +4 -4
- package/dist/bundle/{chunk-GU3MRYK2.js → chunk-53EAI4VZ.js} +1 -1
- package/dist/bundle/{chunk-7DANHJF6.js → chunk-5EB34LNI.js} +31 -31
- package/dist/bundle/{chunk-TPYXULNG.js → chunk-5EZOMIPL.js} +5 -5
- package/dist/bundle/{chunk-VVTC2YAX.js → chunk-5JPVRS7W.js} +4 -4
- package/dist/bundle/{chunk-ZVXXJYNW.js → chunk-5OMM4CDT.js} +2 -2
- package/dist/bundle/{chunk-FBSHWCIZ.js → chunk-5RYMHX2O.js} +9 -9
- package/dist/bundle/{chunk-AGNWFOAJ.js → chunk-67VEVKMJ.js} +1 -1
- package/dist/bundle/{chunk-TNHFKR6P.js → chunk-6A6HR2CS.js} +21 -21
- package/dist/bundle/{chunk-JG7EDH7K.js → chunk-7JFLHRQL.js} +1 -1
- package/dist/bundle/{chunk-CQNYBTWP.js → chunk-7L4PBN5S.js} +2 -2
- package/dist/bundle/{chunk-ZNBLWLCD.js → chunk-A3WUEOEV.js} +151 -151
- package/dist/bundle/{chunk-PBOVHHYG.js → chunk-AJMAR5DC.js} +8 -8
- package/dist/bundle/{chunk-WJ2OYD2D.js → chunk-BGWPKEKK.js} +4 -4
- package/dist/bundle/{chunk-GHN2KYMO.js → chunk-BQYAMBKB.js} +21 -21
- package/dist/bundle/{chunk-VUCD4DAQ.js → chunk-ECHN36DC.js} +4 -4
- package/dist/bundle/{chunk-TXWVZVDK.js → chunk-EDPA54WQ.js} +3 -3
- package/dist/bundle/{chunk-JEKIBI7P.js → chunk-EEBQN7TK.js} +4 -4
- package/dist/bundle/{chunk-ZOIW2YEU.js → chunk-EO4JMJFZ.js} +7 -7
- package/dist/bundle/{chunk-TFAUB6JO.js → chunk-EOJPZ3LX.js} +374 -306
- package/dist/bundle/{chunk-ZU6HZLZP.js → chunk-FOF7KGG3.js} +429 -90
- package/dist/bundle/{chunk-XYL7GDCX.js → chunk-FSDAEZFS.js} +5 -5
- package/dist/bundle/{chunk-IKZBO7NV.js → chunk-FYWGFRR2.js} +623 -509
- package/dist/bundle/{chunk-DNDELSVT.js → chunk-FZHYGJQ2.js} +5 -5
- package/dist/bundle/{chunk-4JTCNMW6.js → chunk-IHHXGTMX.js} +1 -1
- package/dist/bundle/{chunk-BOOEDDVY.js → chunk-JQREFZWM.js} +78 -63
- package/dist/bundle/{chunk-4C6RU7DG.js → chunk-KX7CVSAY.js} +4 -4
- package/dist/bundle/{chunk-YAFSD345.js → chunk-MK6SQ32Q.js} +12 -12
- package/dist/bundle/{chunk-XVPMSMSP.js → chunk-MWQI6FSU.js} +3 -3
- package/dist/bundle/{chunk-W7FYMZOW.js → chunk-N73YBQ42.js} +6 -6
- package/dist/bundle/{chunk-OUSLPKWY.js → chunk-OBQ7TSUB.js} +1 -1
- package/dist/bundle/{chunk-QCWA3JUT.js → chunk-PHSYMVYX.js} +2 -2
- package/dist/bundle/{chunk-HUPZ6XYH.js → chunk-PSYQPO6D.js} +2 -2
- package/dist/bundle/{chunk-XK4VVGMH.js → chunk-PUACXS7G.js} +2 -2
- package/dist/bundle/{chunk-ORKWFXWV.js → chunk-QHUPSOQT.js} +10 -10
- package/dist/bundle/{chunk-GUWRR7F2.js → chunk-QZU5IM5E.js} +2 -2
- package/dist/bundle/{chunk-SKBDI7LU.js → chunk-RG4GW7EY.js} +28 -28
- package/dist/bundle/{chunk-SUCG5HBF.js → chunk-RHW3DDWI.js} +1 -1
- package/dist/bundle/{chunk-OU4PN7PF.js → chunk-TV75OHKJ.js} +7 -7
- package/dist/bundle/{chunk-7KYVUVDS.js → chunk-TXOXPQN2.js} +2 -2
- package/dist/bundle/{chunk-QFSMJTEA.js → chunk-V2YS63Z5.js} +1 -1
- package/dist/bundle/{chunk-Q4JYHQ47.js → chunk-V6QYWGO4.js} +342 -323
- package/dist/bundle/{chunk-6SFTVGNL.js → chunk-VPKJZKXV.js} +1 -1
- package/dist/bundle/{chunk-QMTCYKAA.js → chunk-WLD5XU3T.js} +6 -6
- package/dist/bundle/{chunk-DNS2QWK3.js → chunk-WNA2WNDK.js} +3 -3
- package/dist/bundle/{chunk-GJ3P7RJF.js → chunk-YTJWIJIG.js} +5 -5
- package/dist/bundle/{chunk-MCA265JM.js → chunk-YVVRV3PQ.js} +19 -1
- package/dist/bundle/{command-contract-46BU5YKL.js → command-contract-RX6RWHCT.js} +11 -11
- package/dist/bundle/{decode-KRVQZPSB.js → decode-IJMDTGTW.js} +2 -2
- package/dist/bundle/{echarts-O6QQRVZE.js → echarts-EHYUXOKP.js} +2 -2
- package/dist/bundle/{embed-DA4H2F4F.js → embed-RUY3UIVC.js} +3 -3
- package/dist/bundle/{embedder-HWAFLIYM.js → embedder-P6WBMEGP.js} +6 -6
- package/dist/bundle/{entry-DE7GJOIZ.js → entry-XHWG43NW.js} +4 -4
- package/dist/bundle/failure-Z7WOYPMA.js +65 -0
- package/dist/bundle/{first-run-GOBPIKQF.js → first-run-FQ2BAEYK.js} +5 -5
- package/dist/bundle/{first-screen-3V3HWSQM.js → first-screen-GP2QGKUA.js} +12 -12
- package/dist/bundle/{instructions-GYYMBSZW.js → instructions-ZMG4FLGO.js} +1 -1
- package/dist/bundle/{mcp-6RDHWRXG.js → mcp-USR3ZFQU.js} +35 -35
- package/dist/bundle/memo.js +6 -6
- package/dist/bundle/{node-R3OFASC5.js → node-QYL4B7JS.js} +2 -2
- package/dist/bundle/{node-sqlite-DYHDZJ5A.js → node-sqlite-ESTT2OCF.js} +3 -3
- package/dist/bundle/{oauth-SMCDSCXQ.js → oauth-CFQFSIRQ.js} +4 -4
- package/dist/bundle/{open-GX7RPGQW.js → open-3XO2HMIT.js} +2 -2
- package/dist/bundle/{openai-WM4TRXCC.js → openai-STUNDBD6.js} +7 -7
- package/dist/bundle/{process-NT5OZH2V.js → process-P4UAJCZX.js} +1 -1
- package/dist/bundle/{program-YQ3UT2LI.js → program-FVSSLRBJ.js} +2028 -1862
- package/dist/bundle/{prompt-5XJNSXCW.js → prompt-ZCYMFMIG.js} +2 -2
- package/dist/bundle/{recognize-DQNGZLRX.js → recognize-V3BY33FK.js} +1 -1
- package/dist/bundle/{remote-RMRYJZSZ.js → remote-IP4QR7SP.js} +4 -4
- package/dist/bundle/{rerank-5J6JM43S.js → rerank-VKUSF3DM.js} +4 -4
- package/dist/bundle/{serve-4RVWOQVC.js → serve-VBIUARHJ.js} +6 -6
- package/dist/bundle/{server-NKCRFK26.js → server-3FW2MQRQ.js} +49 -49
- package/dist/bundle/server-SWSWXNDP.js +48 -0
- package/dist/bundle/server-YRZDZ2PZ.js +61 -0
- package/dist/bundle/{state-MGVPOLPZ.js → state-UBAIZ2WP.js} +3 -3
- package/dist/bundle/{store-IEK4PPOE.js → store-PIQ4TF4O.js} +9 -9
- package/dist/bundle/store-maintenance-command-EWEXJ253.js +47 -0
- package/dist/bundle/update-6QYRXRVJ.js +68 -0
- package/dist/digest/backfill.d.ts +9 -0
- package/dist/digest/backfill.d.ts.map +1 -0
- package/dist/digest/backfill.js +142 -0
- package/dist/digest/backfill.js.map +1 -0
- package/dist/digest/command.d.ts +2 -0
- package/dist/digest/command.d.ts.map +1 -1
- package/dist/digest/command.js +18 -1
- package/dist/digest/command.js.map +1 -1
- package/dist/digest/digest.d.ts +6 -1
- package/dist/digest/digest.d.ts.map +1 -1
- package/dist/digest/digest.js +26 -15
- package/dist/digest/digest.js.map +1 -1
- package/dist/digest/sync-health.d.ts +1 -2
- package/dist/digest/sync-health.d.ts.map +1 -1
- package/dist/digest/tasks.d.ts +14 -1
- package/dist/digest/tasks.d.ts.map +1 -1
- package/dist/digest/tasks.js +31 -4
- package/dist/digest/tasks.js.map +1 -1
- package/dist/discovery/command.d.ts.map +1 -1
- package/dist/discovery/command.js +1 -0
- package/dist/discovery/command.js.map +1 -1
- package/dist/examples.d.ts.map +1 -1
- package/dist/examples.js +4 -0
- package/dist/examples.js.map +1 -1
- package/dist/knowledge/relationships.d.ts +2 -0
- package/dist/knowledge/relationships.d.ts.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +2 -0
- package/dist/program.js.map +1 -1
- package/dist/read-only.d.ts +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +18 -0
- package/dist/reasons.js.map +1 -1
- package/dist/schedule/command.d.ts +2 -1
- package/dist/schedule/command.d.ts.map +1 -1
- package/dist/schedule/command.js +6 -2
- package/dist/schedule/command.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/mail-triage/SKILL.md +25 -19
- package/skills/morning-digest/SKILL.md +15 -1
- package/dist/bundle/auto-FR6LX5KO.js +0 -85
- package/dist/bundle/failure-U3VNIQNX.js +0 -65
- package/dist/bundle/server-HH2X6G7V.js +0 -61
- package/dist/bundle/server-MS3JKMGF.js +0 -48
- package/dist/bundle/store-maintenance-command-GSS2AY4J.js +0 -47
- package/dist/bundle/update-S5XRRWTH.js +0 -68
- /package/dist/bundle/{chunk-DS7NXKAN.js → chunk-AWVQHWIS.js} +0 -0
|
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
answerOf,
|
|
5
5
|
messengerContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6A6HR2CS.js";
|
|
7
7
|
import {
|
|
8
8
|
FETCHING,
|
|
9
9
|
QUICK_HEALTH_CHECKS,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
typedQuery,
|
|
33
33
|
withQuery,
|
|
34
34
|
withTimeLimit
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-V6QYWGO4.js";
|
|
36
36
|
import {
|
|
37
37
|
stringWidth,
|
|
38
38
|
wrapAnsi
|
|
@@ -63,17 +63,17 @@ import {
|
|
|
63
63
|
snakeKeys,
|
|
64
64
|
storeTable,
|
|
65
65
|
withoutProviderRefs
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-A3WUEOEV.js";
|
|
67
67
|
import {
|
|
68
68
|
holdLock,
|
|
69
69
|
lockPath,
|
|
70
70
|
releaseLock,
|
|
71
71
|
servingProfiles,
|
|
72
72
|
takeLock
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-7L4PBN5S.js";
|
|
74
74
|
import {
|
|
75
75
|
holdersOf
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-IHHXGTMX.js";
|
|
77
77
|
import {
|
|
78
78
|
CORPORA,
|
|
79
79
|
MIGRATIONS,
|
|
@@ -88,6 +88,7 @@ import {
|
|
|
88
88
|
fillVectorIndexes,
|
|
89
89
|
formatLocator,
|
|
90
90
|
involvementStoreOver,
|
|
91
|
+
isDerivedTable,
|
|
91
92
|
migrate,
|
|
92
93
|
noteIndexState,
|
|
93
94
|
openSqlite,
|
|
@@ -109,26 +110,26 @@ import {
|
|
|
109
110
|
storeClients,
|
|
110
111
|
storeContents,
|
|
111
112
|
vectorIndexCounts
|
|
112
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-FYWGFRR2.js";
|
|
113
114
|
import {
|
|
114
115
|
queryFieldsOf,
|
|
115
116
|
readDamageMark,
|
|
116
117
|
readHealthMark,
|
|
117
118
|
recordDeepCheck
|
|
118
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-JQREFZWM.js";
|
|
119
120
|
import {
|
|
120
121
|
failureKey,
|
|
121
122
|
isStoreDamage
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-3LGLKLBA.js";
|
|
123
124
|
import {
|
|
124
125
|
readSecret
|
|
125
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-PHSYMVYX.js";
|
|
126
127
|
import {
|
|
127
128
|
storePath
|
|
128
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-V2YS63Z5.js";
|
|
129
130
|
import {
|
|
130
131
|
openCache
|
|
131
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-YTJWIJIG.js";
|
|
132
133
|
import {
|
|
133
134
|
resolvePaths,
|
|
134
135
|
writeSecurely
|
|
@@ -1812,7 +1813,7 @@ var require_liquid_node = __commonJS({
|
|
|
1812
1813
|
return readFileAsync(filepath, "utf8");
|
|
1813
1814
|
}
|
|
1814
1815
|
__name(readFile, "readFile");
|
|
1815
|
-
function
|
|
1816
|
+
function existsSync11(filepath) {
|
|
1816
1817
|
try {
|
|
1817
1818
|
fs$1.statSync(filepath);
|
|
1818
1819
|
return true;
|
|
@@ -1820,11 +1821,11 @@ var require_liquid_node = __commonJS({
|
|
|
1820
1821
|
return false;
|
|
1821
1822
|
}
|
|
1822
1823
|
}
|
|
1823
|
-
__name(
|
|
1824
|
-
function
|
|
1824
|
+
__name(existsSync11, "existsSync");
|
|
1825
|
+
function readFileSync6(filepath) {
|
|
1825
1826
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1826
1827
|
}
|
|
1827
|
-
__name(
|
|
1828
|
+
__name(readFileSync6, "readFileSync");
|
|
1828
1829
|
function resolve2(root, file2, ext) {
|
|
1829
1830
|
if (!path.extname(file2))
|
|
1830
1831
|
file2 += ext;
|
|
@@ -1838,10 +1839,10 @@ var require_liquid_node = __commonJS({
|
|
|
1838
1839
|
}
|
|
1839
1840
|
}
|
|
1840
1841
|
__name(fallback, "fallback");
|
|
1841
|
-
function
|
|
1842
|
+
function dirname4(filepath) {
|
|
1842
1843
|
return path.dirname(filepath);
|
|
1843
1844
|
}
|
|
1844
|
-
__name(
|
|
1845
|
+
__name(dirname4, "dirname");
|
|
1845
1846
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1846
1847
|
async function contains(root, file2) {
|
|
1847
1848
|
try {
|
|
@@ -1869,11 +1870,11 @@ var require_liquid_node = __commonJS({
|
|
|
1869
1870
|
__proto__: null,
|
|
1870
1871
|
exists,
|
|
1871
1872
|
readFile,
|
|
1872
|
-
existsSync:
|
|
1873
|
-
readFileSync:
|
|
1873
|
+
existsSync: existsSync11,
|
|
1874
|
+
readFileSync: readFileSync6,
|
|
1874
1875
|
resolve: resolve2,
|
|
1875
1876
|
fallback,
|
|
1876
|
-
dirname:
|
|
1877
|
+
dirname: dirname4,
|
|
1877
1878
|
contains,
|
|
1878
1879
|
containsSync,
|
|
1879
1880
|
sep: path.sep
|
|
@@ -3598,7 +3599,7 @@ var require_liquid_node = __commonJS({
|
|
|
3598
3599
|
uri_escape,
|
|
3599
3600
|
slugify
|
|
3600
3601
|
});
|
|
3601
|
-
var
|
|
3602
|
+
var join6 = argumentsToValue(function(v, arg) {
|
|
3602
3603
|
const array2 = toArray(v);
|
|
3603
3604
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3604
3605
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3874,7 +3875,7 @@ var require_liquid_node = __commonJS({
|
|
|
3874
3875
|
__name(sample, "sample");
|
|
3875
3876
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3876
3877
|
__proto__: null,
|
|
3877
|
-
join:
|
|
3878
|
+
join: join6,
|
|
3878
3879
|
last,
|
|
3879
3880
|
first,
|
|
3880
3881
|
reverse,
|
|
@@ -5498,11 +5499,11 @@ var require_liquid_node = __commonJS({
|
|
|
5498
5499
|
}
|
|
5499
5500
|
});
|
|
5500
5501
|
|
|
5501
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5502
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5503
|
-
import { dirname as
|
|
5502
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5503
|
+
import { chmodSync, constants, copyFileSync, existsSync as existsSync10, mkdirSync, realpathSync as realpathSync3, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5504
|
+
import { dirname as dirname3, resolve } from "node:path";
|
|
5504
5505
|
|
|
5505
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5506
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5506
5507
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5507
5508
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5508
5509
|
import { Transform } from "node:stream";
|
|
@@ -5609,7 +5610,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5609
5610
|
renameSync(pending, to);
|
|
5610
5611
|
}, "unsealFile");
|
|
5611
5612
|
|
|
5612
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5613
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5613
5614
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5614
5615
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5615
5616
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5633,7 +5634,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5633
5634
|
};
|
|
5634
5635
|
}, "compatibilityOf");
|
|
5635
5636
|
|
|
5636
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5637
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5637
5638
|
import { createHash as createHash2 } from "node:crypto";
|
|
5638
5639
|
var COPY_MARK = "__repair_";
|
|
5639
5640
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5887,17 +5888,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5887
5888
|
return found;
|
|
5888
5889
|
}, "deleteCopy");
|
|
5889
5890
|
|
|
5890
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5891
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5891
5892
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5892
5893
|
|
|
5893
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5894
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5894
5895
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5895
5896
|
|
|
5896
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5897
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5897
5898
|
import { execFileSync, spawn } from "node:child_process";
|
|
5898
5899
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5899
5900
|
import { basename, dirname, join } from "node:path";
|
|
5900
5901
|
import { Transform as Transform2 } from "node:stream";
|
|
5902
|
+
|
|
5903
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5904
|
+
var REFILL_MARGIN_MS = 864e5;
|
|
5905
|
+
var TIME_KEYS = 1e12;
|
|
5906
|
+
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
5907
|
+
var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
|
|
5908
|
+
database.exec("BEGIN");
|
|
5909
|
+
try {
|
|
5910
|
+
const refetch = forget(database, cutoff, now);
|
|
5911
|
+
database.exec("COMMIT");
|
|
5912
|
+
return refetch;
|
|
5913
|
+
} catch (error) {
|
|
5914
|
+
database.exec("ROLLBACK");
|
|
5915
|
+
throw error;
|
|
5916
|
+
}
|
|
5917
|
+
}, "forgetCoverageSince");
|
|
5918
|
+
var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5919
|
+
const chats = /* @__PURE__ */ new Map();
|
|
5920
|
+
const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
|
|
5921
|
+
max(r.to_key) AS top FROM sync_ranges r JOIN chats c ON c.id = r.chat_id JOIN accounts a ON a.id = c.account_id
|
|
5922
|
+
GROUP BY c.id`).all();
|
|
5923
|
+
for (const row of held) {
|
|
5924
|
+
const chat = Number(row.id);
|
|
5925
|
+
const top = Number(row.top);
|
|
5926
|
+
const keepTo = cutoff === null ? null : top >= TIME_KEYS ? cutoff : database.prepare(`SELECT max(CAST(external_id AS INTEGER)) AS k FROM messages WHERE chat_id = ? AND sent_at < ? AND ${integerId}`).get(chat, cutoff)?.k;
|
|
5927
|
+
if (keepTo !== null && top <= keepTo)
|
|
5928
|
+
continue;
|
|
5929
|
+
if (keepTo === null)
|
|
5930
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
|
|
5931
|
+
else {
|
|
5932
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
|
|
5933
|
+
database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
|
|
5934
|
+
}
|
|
5935
|
+
const account = Number(row.account_id);
|
|
5936
|
+
const external = String(row.chat);
|
|
5937
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
|
|
5938
|
+
database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
|
|
5939
|
+
(SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
|
|
5940
|
+
const key = `${row.provider}\0${row.account}`;
|
|
5941
|
+
const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
|
|
5942
|
+
one.chats += 1;
|
|
5943
|
+
chats.set(key, one);
|
|
5944
|
+
}
|
|
5945
|
+
return {
|
|
5946
|
+
since: cutoff === null ? null : new Date(cutoff).toISOString(),
|
|
5947
|
+
chats: [...chats.values()],
|
|
5948
|
+
mail: forgetMail(database, cutoff, now)
|
|
5949
|
+
};
|
|
5950
|
+
}, "forget");
|
|
5951
|
+
var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5952
|
+
const folders = /* @__PURE__ */ new Map();
|
|
5953
|
+
const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
|
|
5954
|
+
JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
|
|
5955
|
+
for (const row of points) {
|
|
5956
|
+
let point;
|
|
5957
|
+
try {
|
|
5958
|
+
point = JSON.parse(String(row.value));
|
|
5959
|
+
} catch {
|
|
5960
|
+
continue;
|
|
5961
|
+
}
|
|
5962
|
+
const account = String(row.account);
|
|
5963
|
+
if (!Array.isArray(point.done)) {
|
|
5964
|
+
if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
|
|
5965
|
+
continue;
|
|
5966
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
|
|
5967
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5968
|
+
continue;
|
|
5969
|
+
}
|
|
5970
|
+
const folder = String(row.key).slice("mail_resume:".length);
|
|
5971
|
+
const last = cutoff === null ? null : database.prepare(`SELECT max(l.uid) AS uid FROM email_locations l JOIN emails e ON e.id = l.email_id
|
|
5972
|
+
WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
|
|
5973
|
+
AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
|
|
5974
|
+
const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
|
|
5975
|
+
if (JSON.stringify(done) === JSON.stringify(point.done))
|
|
5976
|
+
continue;
|
|
5977
|
+
database.prepare("UPDATE sync_cursors SET value = ?, updated_at = ? WHERE account_id = ? AND key = ?").run(JSON.stringify({ ...point, done }), now, Number(row.account_id), String(row.key));
|
|
5978
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5979
|
+
}
|
|
5980
|
+
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
5981
|
+
}, "forgetMail");
|
|
5982
|
+
|
|
5983
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5901
5984
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5902
5985
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5903
5986
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -5992,9 +6075,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
|
5992
6075
|
return { pid, name };
|
|
5993
6076
|
});
|
|
5994
6077
|
}, "storeHolders");
|
|
5995
|
-
var
|
|
6078
|
+
var dataTables = /* @__PURE__ */ __name((database) => {
|
|
5996
6079
|
const indexes = fts5Tables(database).map((index) => index.name);
|
|
5997
|
-
|
|
6080
|
+
return database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'vector_index_%' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !indexes.some((index) => name.startsWith(`${index}_`)));
|
|
6081
|
+
}, "dataTables");
|
|
6082
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6083
|
+
const tables = dataTables(database);
|
|
5998
6084
|
return Object.fromEntries(tables.map((table) => {
|
|
5999
6085
|
try {
|
|
6000
6086
|
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
@@ -6003,6 +6089,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
|
|
|
6003
6089
|
}
|
|
6004
6090
|
}));
|
|
6005
6091
|
}, "tableRows");
|
|
6092
|
+
var sourceTables = /* @__PURE__ */ __name((database) => {
|
|
6093
|
+
const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
|
|
6094
|
+
return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
|
|
6095
|
+
}, "sourceTables");
|
|
6096
|
+
var indexedButGone = /* @__PURE__ */ __name((database) => {
|
|
6097
|
+
const found = {};
|
|
6098
|
+
for (const table of sourceTables(database)) {
|
|
6099
|
+
const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
|
|
6100
|
+
for (const index of indexes) {
|
|
6101
|
+
const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
|
|
6102
|
+
if (columns.some((column) => Number(column.cid) < 0))
|
|
6103
|
+
continue;
|
|
6104
|
+
const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
|
|
6105
|
+
const grouped = `${keys}, row_id`;
|
|
6106
|
+
let rows;
|
|
6107
|
+
try {
|
|
6108
|
+
rows = Number(database.prepare(`SELECT count(*) AS n FROM (SELECT 1 FROM (SELECT ${keys}, rowid AS row_id, 1 AS side FROM "${table}" INDEXED BY "${index}" UNION ALL SELECT ${keys}, rowid, 2 FROM "${table}" NOT INDEXED) GROUP BY ${grouped} HAVING max(side) = 1)`).get()?.n);
|
|
6109
|
+
} catch {
|
|
6110
|
+
continue;
|
|
6111
|
+
}
|
|
6112
|
+
if (rows > (found[table]?.rows ?? 0))
|
|
6113
|
+
found[table] = { rows, index };
|
|
6114
|
+
}
|
|
6115
|
+
}
|
|
6116
|
+
return found;
|
|
6117
|
+
}, "indexedButGone");
|
|
6118
|
+
var storedAs = /* @__PURE__ */ __name((declared) => {
|
|
6119
|
+
const type = declared.toUpperCase();
|
|
6120
|
+
if (type.includes("INT"))
|
|
6121
|
+
return ["integer"];
|
|
6122
|
+
if (/CHAR|CLOB|TEXT/.test(type))
|
|
6123
|
+
return ["text"];
|
|
6124
|
+
if (type === "" || type.includes("BLOB"))
|
|
6125
|
+
return null;
|
|
6126
|
+
if (/REAL|FLOA|DOUB/.test(type))
|
|
6127
|
+
return ["real", "integer"];
|
|
6128
|
+
return null;
|
|
6129
|
+
}, "storedAs");
|
|
6130
|
+
var columnsOf = /* @__PURE__ */ __name((database, table) => {
|
|
6131
|
+
const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
|
|
6132
|
+
const keys = all.filter((column) => Number(column.pk) > 0);
|
|
6133
|
+
return all.map((column) => ({
|
|
6134
|
+
name: String(column.name),
|
|
6135
|
+
type: String(column.type),
|
|
6136
|
+
required: Number(column.required) === 1,
|
|
6137
|
+
hasDefault: column.dflt_value !== null,
|
|
6138
|
+
rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
|
|
6139
|
+
}));
|
|
6140
|
+
}, "columnsOf");
|
|
6141
|
+
var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
|
|
6142
|
+
if (at >= fields)
|
|
6143
|
+
return !column.required || column.hasDefault;
|
|
6144
|
+
const type = types[at];
|
|
6145
|
+
if (column.rowid)
|
|
6146
|
+
return type === "null" || type === "integer";
|
|
6147
|
+
if (type === "null")
|
|
6148
|
+
return !column.required;
|
|
6149
|
+
const allowed = storedAs(column.type);
|
|
6150
|
+
return allowed === null || allowed.includes(type);
|
|
6151
|
+
}), "fits");
|
|
6152
|
+
var placeLostRows = /* @__PURE__ */ __name((database) => {
|
|
6153
|
+
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
|
|
6154
|
+
return {};
|
|
6155
|
+
const fields = database.prepare("SELECT name FROM pragma_table_info(?) WHERE name GLOB 'c[0-9]*'").all(LOST_AND_FOUND).map((row) => String(row.name));
|
|
6156
|
+
const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
|
|
6157
|
+
const rows = database.prepare(`SELECT rowid AS at, nfield, ${fields.map((field) => `typeof(${field}) AS "${field}"`).join(", ")} FROM ${LOST_AND_FOUND} WHERE id IS NOT NULL`).all();
|
|
6158
|
+
const placed = {};
|
|
6159
|
+
const triggers = [];
|
|
6160
|
+
const quiet = /* @__PURE__ */ __name((table) => {
|
|
6161
|
+
if (table in placed)
|
|
6162
|
+
return;
|
|
6163
|
+
placed[table] = 0;
|
|
6164
|
+
for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
|
|
6165
|
+
triggers.push(String(row.sql));
|
|
6166
|
+
database.exec(`DROP TRIGGER "${String(row.name)}"`);
|
|
6167
|
+
}
|
|
6168
|
+
}, "quiet");
|
|
6169
|
+
database.exec("PRAGMA foreign_keys = OFF");
|
|
6170
|
+
database.exec("BEGIN");
|
|
6171
|
+
try {
|
|
6172
|
+
for (const row of rows) {
|
|
6173
|
+
const count3 = Number(row.nfield);
|
|
6174
|
+
const types = fields.slice(0, count3).map((field) => String(row[field]));
|
|
6175
|
+
const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
|
|
6176
|
+
if (fitting.length !== 1)
|
|
6177
|
+
continue;
|
|
6178
|
+
const { table, columns } = fitting[0];
|
|
6179
|
+
quiet(table);
|
|
6180
|
+
const given = columns.slice(0, count3);
|
|
6181
|
+
const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
|
|
6182
|
+
const values = [
|
|
6183
|
+
...given.some((column) => column.rowid) ? [] : ["id"],
|
|
6184
|
+
...given.map((column, at) => column.rowid ? "id" : `c${at}`)
|
|
6185
|
+
];
|
|
6186
|
+
const inserted = database.prepare(`INSERT OR IGNORE INTO "${table}" (${names.map((name) => `"${name}"`).join(", ")}) SELECT ${values.join(", ")} FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6187
|
+
if (Number(inserted.changes) === 0)
|
|
6188
|
+
continue;
|
|
6189
|
+
placed[table] = (placed[table] ?? 0) + 1;
|
|
6190
|
+
database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6191
|
+
}
|
|
6192
|
+
for (const sql of triggers)
|
|
6193
|
+
database.exec(sql);
|
|
6194
|
+
database.exec("COMMIT");
|
|
6195
|
+
} catch (error) {
|
|
6196
|
+
database.exec("ROLLBACK");
|
|
6197
|
+
throw error;
|
|
6198
|
+
} finally {
|
|
6199
|
+
database.exec("PRAGMA foreign_keys = ON");
|
|
6200
|
+
}
|
|
6201
|
+
return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
|
|
6202
|
+
}, "placeLostRows");
|
|
6006
6203
|
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6007
6204
|
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6008
6205
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -6199,6 +6396,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6199
6396
|
throw error;
|
|
6200
6397
|
throw new CliError("configuration_error", "the store file's header or schema is damaged, so its tables cannot be listed and it cannot be recovered; the file was left as it was", { reason: "store.unreadable" });
|
|
6201
6398
|
}
|
|
6399
|
+
note("looking for rows the indexes list and the tables no longer hold");
|
|
6400
|
+
const gone = indexedButGone(watch);
|
|
6401
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6202
6402
|
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6203
6403
|
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6204
6404
|
const target = `${path}.recovering-${stamp}`;
|
|
@@ -6227,7 +6427,10 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6227
6427
|
let json;
|
|
6228
6428
|
let fetch;
|
|
6229
6429
|
let schema;
|
|
6430
|
+
let placed;
|
|
6431
|
+
let refetch;
|
|
6230
6432
|
try {
|
|
6433
|
+
placed = placeLostRows(opened.database);
|
|
6231
6434
|
kept = tableRows(opened.database);
|
|
6232
6435
|
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6233
6436
|
note("clearing values that are not valid JSON");
|
|
@@ -6236,6 +6439,8 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6236
6439
|
note("looking for rows that point at rows that were lost");
|
|
6237
6440
|
dangling = danglingRows(opened.database);
|
|
6238
6441
|
fetch = mailToFetch(opened.database);
|
|
6442
|
+
const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
|
|
6443
|
+
refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
|
|
6239
6444
|
schema = fileSchemaOf(opened.database).version;
|
|
6240
6445
|
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6241
6446
|
} catch (error) {
|
|
@@ -6265,16 +6470,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6265
6470
|
if (existsSync2(`${target}${suffix}`))
|
|
6266
6471
|
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6267
6472
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
|
|
6268
|
-
const lost = Object.entries(rowsBefore).map(([table, before2]) =>
|
|
6473
|
+
const lost = Object.entries(rowsBefore).map(([table, before2]) => {
|
|
6474
|
+
const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
|
|
6475
|
+
return {
|
|
6476
|
+
table,
|
|
6477
|
+
before: before2,
|
|
6478
|
+
read: read[table] ?? 0,
|
|
6479
|
+
kept: kept[table] ?? 0,
|
|
6480
|
+
goneAtLeast,
|
|
6481
|
+
seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
|
|
6482
|
+
};
|
|
6483
|
+
}).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
|
|
6269
6484
|
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6270
6485
|
return {
|
|
6271
6486
|
path,
|
|
6272
6487
|
keptAt,
|
|
6273
6488
|
sqlite3: program.version,
|
|
6274
6489
|
lost,
|
|
6490
|
+
placed,
|
|
6491
|
+
lastKnownGood,
|
|
6275
6492
|
dangling,
|
|
6276
6493
|
invalidJson: json,
|
|
6277
6494
|
mailToFetch: fetch,
|
|
6495
|
+
refetch,
|
|
6278
6496
|
rebuilt,
|
|
6279
6497
|
copyErrors,
|
|
6280
6498
|
health,
|
|
@@ -6290,7 +6508,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6290
6508
|
}
|
|
6291
6509
|
}, "recoverLocked");
|
|
6292
6510
|
|
|
6293
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6511
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6294
6512
|
var COUNTED = [
|
|
6295
6513
|
"accounts",
|
|
6296
6514
|
"chats",
|
|
@@ -6377,12 +6595,28 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
|
|
|
6377
6595
|
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6378
6596
|
};
|
|
6379
6597
|
}, "storeRecoveryRun");
|
|
6598
|
+
var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
|
|
6599
|
+
const from = since === null ? "from the start" : `from ${since} on`;
|
|
6600
|
+
const marked = [
|
|
6601
|
+
...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
|
|
6602
|
+
...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
|
|
6603
|
+
];
|
|
6604
|
+
return [
|
|
6605
|
+
marked.length > 0 ? `marked as not fetched ${from}, so the next sync or serve fetches it again: ${marked.join(", ")}` : `nothing held ${from} was marked as fetched, so there is nothing to fetch again`,
|
|
6606
|
+
...chats.filter(({ provider }) => provider === "whatsapp").map(({ account }) => `whatsapp ${account}: WhatsApp cannot be asked for its chats, so only what the phone pushes while serve runs comes back`),
|
|
6607
|
+
"notes, memories, tags and whatever else only this store held cannot be fetched again"
|
|
6608
|
+
];
|
|
6609
|
+
}, "refetchNotes");
|
|
6380
6610
|
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6381
6611
|
if ("keptAt" in answer) {
|
|
6382
|
-
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6612
|
+
const lost = answer.lost.map(({ table, before, read, kept, goneAtLeast, seenIn }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}` + (goneAtLeast > 0 ? `; at least ${goneAtLeast} rows are gone (the index ${seenIn} lists them)` : ""));
|
|
6613
|
+
const since = answer.lastKnownGood ? `since the last deep check that passed (${answer.lastKnownGood})` : "since the store was made (no deep check that passed is on record)";
|
|
6383
6614
|
return [
|
|
6384
6615
|
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6385
|
-
...lost
|
|
6616
|
+
...lost,
|
|
6617
|
+
...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
|
|
6618
|
+
...refetchNotes(answer.refetch),
|
|
6619
|
+
`${lost.some((line) => line.includes("are gone")) ? "more rows may be gone" : "how many rows were lost is unknown"}: damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`,
|
|
6386
6620
|
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6387
6621
|
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6388
6622
|
...answer.next.map((line) => `next: ${line}`)
|
|
@@ -6423,7 +6657,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6423
6657
|
return recover;
|
|
6424
6658
|
}, "storeRecoverCommand");
|
|
6425
6659
|
|
|
6426
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6660
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6427
6661
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6428
6662
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6429
6663
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6469,7 +6703,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
6469
6703
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
6470
6704
|
}), "storeInfoCommand");
|
|
6471
6705
|
|
|
6472
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6706
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6473
6707
|
var ENCRYPT_OPTION = [
|
|
6474
6708
|
"--encrypt",
|
|
6475
6709
|
"compress and encrypt with a password, typed at a hidden prompt or piped on stdin; it is never kept \u2014 lose it and the file cannot be opened"
|
|
@@ -6488,7 +6722,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6488
6722
|
return password;
|
|
6489
6723
|
}, "passwordOf");
|
|
6490
6724
|
|
|
6491
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6725
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6492
6726
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6493
6727
|
import { join as join2 } from "node:path";
|
|
6494
6728
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6659,7 +6893,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6659
6893
|
}, "problem");
|
|
6660
6894
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6661
6895
|
|
|
6662
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6896
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6663
6897
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6664
6898
|
import { join as join3 } from "node:path";
|
|
6665
6899
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6712,7 +6946,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6712
6946
|
}, "recordReply");
|
|
6713
6947
|
var broken2 = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply state ${path} cannot be read (${why}) \u2014 fix or move the file`), "broken");
|
|
6714
6948
|
|
|
6715
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6949
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6716
6950
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6717
6951
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6718
6952
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6818,10 +7052,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6818
7052
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6819
7053
|
}, "filled");
|
|
6820
7054
|
|
|
6821
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7055
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6822
7056
|
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
6823
7057
|
|
|
6824
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7058
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
6825
7059
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
6826
7060
|
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
6827
7061
|
const engine = new import_liquidjs.Liquid({
|
|
@@ -6848,7 +7082,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
|
6848
7082
|
return engine;
|
|
6849
7083
|
}, "safeLiquid");
|
|
6850
7084
|
|
|
6851
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7085
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6852
7086
|
var TEMPLATE_LIMITS = {
|
|
6853
7087
|
parse: 32768,
|
|
6854
7088
|
renders: 2e3,
|
|
@@ -6987,7 +7221,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6987
7221
|
}
|
|
6988
7222
|
}, "renderReplyTemplate");
|
|
6989
7223
|
|
|
6990
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7224
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
6991
7225
|
var DRY_RUN_DAYS = 7;
|
|
6992
7226
|
var PAGE = 500;
|
|
6993
7227
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7101,7 +7335,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7101
7335
|
}
|
|
7102
7336
|
}, "storedSince");
|
|
7103
7337
|
|
|
7104
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7338
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7105
7339
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7106
7340
|
import { join as join4 } from "node:path";
|
|
7107
7341
|
var shape = strictObject({
|
|
@@ -7126,7 +7360,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7126
7360
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7127
7361
|
}, "mayModelReply");
|
|
7128
7362
|
|
|
7129
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7363
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7130
7364
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7131
7365
|
ai: true
|
|
7132
7366
|
}) => async (rule2, message, chat, now) => {
|
|
@@ -7173,7 +7407,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7173
7407
|
return result2;
|
|
7174
7408
|
}, "replyRenderer");
|
|
7175
7409
|
|
|
7176
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7410
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7177
7411
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7178
7412
|
var NO_RULES = "no rules";
|
|
7179
7413
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7266,7 +7500,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7266
7500
|
return { skip: why };
|
|
7267
7501
|
}, "replyTo");
|
|
7268
7502
|
|
|
7269
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7503
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7270
7504
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7271
7505
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7272
7506
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -7343,7 +7577,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
|
|
|
7343
7577
|
};
|
|
7344
7578
|
}, "startSync");
|
|
7345
7579
|
|
|
7346
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7580
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7347
7581
|
var FIRST_FETCH_MS = 6e4;
|
|
7348
7582
|
var DAY_MS = 864e5;
|
|
7349
7583
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -7397,7 +7631,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
|
|
|
7397
7631
|
};
|
|
7398
7632
|
}, "memberFetches");
|
|
7399
7633
|
|
|
7400
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7634
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7401
7635
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7402
7636
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7403
7637
|
if (context.format === "pretty") {
|
|
@@ -7430,7 +7664,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7430
7664
|
return context;
|
|
7431
7665
|
}, "recordDiagnostics");
|
|
7432
7666
|
|
|
7433
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7667
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7668
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7669
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7670
|
+
var OUTDATED_CHECK_MS = 6e4;
|
|
7671
|
+
var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
|
|
7672
|
+
let dir;
|
|
7673
|
+
try {
|
|
7674
|
+
dir = dirname2(realpathSync2(script ?? ""));
|
|
7675
|
+
} catch {
|
|
7676
|
+
return void 0;
|
|
7677
|
+
}
|
|
7678
|
+
for (let up = 0; up < 8; up++) {
|
|
7679
|
+
const manifest = join5(dir, "package.json");
|
|
7680
|
+
if (existsSync8(manifest))
|
|
7681
|
+
return installedVersion(dir) === running ? dir : void 0;
|
|
7682
|
+
const parent = dirname2(dir);
|
|
7683
|
+
if (parent === dir)
|
|
7684
|
+
return void 0;
|
|
7685
|
+
dir = parent;
|
|
7686
|
+
}
|
|
7687
|
+
return void 0;
|
|
7688
|
+
}, "ownPackageRoot");
|
|
7689
|
+
var installedVersion = /* @__PURE__ */ __name((root) => {
|
|
7690
|
+
try {
|
|
7691
|
+
const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
|
|
7692
|
+
return typeof version === "string" ? version : void 0;
|
|
7693
|
+
} catch {
|
|
7694
|
+
return void 0;
|
|
7695
|
+
}
|
|
7696
|
+
}, "installedVersion");
|
|
7697
|
+
var newer = /* @__PURE__ */ __name((one, other) => {
|
|
7698
|
+
const parts2 = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
|
|
7699
|
+
const [a, b] = [parts2(one), parts2(other)];
|
|
7700
|
+
for (let i = 0; i < 3; i++)
|
|
7701
|
+
if ((a[i] ?? 0) !== (b[i] ?? 0))
|
|
7702
|
+
return (a[i] ?? 0) > (b[i] ?? 0);
|
|
7703
|
+
return false;
|
|
7704
|
+
}, "newer");
|
|
7705
|
+
var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
|
|
7706
|
+
const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
|
|
7707
|
+
if (installed !== void 0 && newer(installed, running))
|
|
7708
|
+
return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
|
|
7709
|
+
if (!existsSync8(storePath2))
|
|
7710
|
+
return void 0;
|
|
7711
|
+
let schema;
|
|
7712
|
+
try {
|
|
7713
|
+
const { database } = await openSqlite(storePath2, { readOnly: true });
|
|
7714
|
+
try {
|
|
7715
|
+
schema = fileSchemaOf(database);
|
|
7716
|
+
} finally {
|
|
7717
|
+
database.close();
|
|
7718
|
+
}
|
|
7719
|
+
} catch {
|
|
7720
|
+
return void 0;
|
|
7721
|
+
}
|
|
7722
|
+
if (writableBy(schema, speaks))
|
|
7723
|
+
return void 0;
|
|
7724
|
+
return `the store is at format ${schema.version} and needs at least ${schema.minCompatible}; this serve (${command} ${running}) speaks ${speaks} and can no longer write it: stopping \u2014 \`${command} upgrade\` if it does not start again on a newer version`;
|
|
7725
|
+
}, "outdatedReason");
|
|
7726
|
+
var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
|
|
7727
|
+
let busy = false;
|
|
7728
|
+
let done = false;
|
|
7729
|
+
const timer = setInterval(() => {
|
|
7730
|
+
if (busy || done)
|
|
7731
|
+
return;
|
|
7732
|
+
busy = true;
|
|
7733
|
+
check2().then((reason) => {
|
|
7734
|
+
if (reason === void 0 || done)
|
|
7735
|
+
return;
|
|
7736
|
+
done = true;
|
|
7737
|
+
clearInterval(timer);
|
|
7738
|
+
onOutdated(reason);
|
|
7739
|
+
}).catch(() => {
|
|
7740
|
+
}).finally(() => {
|
|
7741
|
+
busy = false;
|
|
7742
|
+
});
|
|
7743
|
+
}, everyMs);
|
|
7744
|
+
timer.unref();
|
|
7745
|
+
return {
|
|
7746
|
+
stop: /* @__PURE__ */ __name(() => {
|
|
7747
|
+
done = true;
|
|
7748
|
+
clearInterval(timer);
|
|
7749
|
+
}, "stop")
|
|
7750
|
+
};
|
|
7751
|
+
}, "watchOutdated");
|
|
7752
|
+
|
|
7753
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7434
7754
|
var STEMS_EVERY_MS = 3e4;
|
|
7435
7755
|
var STEMS_SLICE_MS = 2e3;
|
|
7436
7756
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7470,7 +7790,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7470
7790
|
};
|
|
7471
7791
|
}, "stemFills");
|
|
7472
7792
|
|
|
7473
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7793
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
7474
7794
|
import { styleText } from "node:util";
|
|
7475
7795
|
var TIME_WIDTH = 8;
|
|
7476
7796
|
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
@@ -7646,7 +7966,7 @@ var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
|
7646
7966
|
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
7647
7967
|
}, "editedAt");
|
|
7648
7968
|
|
|
7649
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7969
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7650
7970
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7651
7971
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7652
7972
|
kind: attachment.kind,
|
|
@@ -7741,7 +8061,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7741
8061
|
locale: messenger.app.locale
|
|
7742
8062
|
}), "viewOf");
|
|
7743
8063
|
|
|
7744
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8064
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7745
8065
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7746
8066
|
value: value.value,
|
|
7747
8067
|
observed_at: value.observedAt,
|
|
@@ -7808,7 +8128,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7808
8128
|
}
|
|
7809
8129
|
}, "watchEventItem");
|
|
7810
8130
|
|
|
7811
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8131
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7812
8132
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7813
8133
|
output: { entity: "watch_item" },
|
|
7814
8134
|
effects: REMOTE_READ,
|
|
@@ -7963,7 +8283,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
7963
8283
|
}
|
|
7964
8284
|
}, "describe");
|
|
7965
8285
|
|
|
7966
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8286
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
7967
8287
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
7968
8288
|
const command = annotate(new Command("serve"), {
|
|
7969
8289
|
output: { entity: "serve_summary" },
|
|
@@ -7987,8 +8307,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7987
8307
|
}
|
|
7988
8308
|
let relaying;
|
|
7989
8309
|
const onReady = /* @__PURE__ */ __name(() => {
|
|
7990
|
-
const
|
|
7991
|
-
holdLock(path,
|
|
8310
|
+
const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
8311
|
+
holdLock(path, listening2);
|
|
7992
8312
|
note({
|
|
7993
8313
|
code: "listening",
|
|
7994
8314
|
text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
|
|
@@ -7997,7 +8317,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7997
8317
|
return;
|
|
7998
8318
|
relaying = relay.open(path, context.profile).then((address) => {
|
|
7999
8319
|
if (address)
|
|
8000
|
-
holdLock(path, { ...
|
|
8320
|
+
holdLock(path, { ...listening2, relay: address });
|
|
8001
8321
|
}).catch((error) => {
|
|
8002
8322
|
const errorCode = failureKey(error);
|
|
8003
8323
|
warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
|
|
@@ -8006,7 +8326,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8006
8326
|
const counts = {};
|
|
8007
8327
|
const rules = replying(context, messenger, Date.parse(startedAt));
|
|
8008
8328
|
const tasks = tasking(context, warn);
|
|
8009
|
-
const { handled, startSyncDelayMs } = environmentOf(this);
|
|
8329
|
+
const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
|
|
8010
8330
|
const count3 = /* @__PURE__ */ __name((event) => {
|
|
8011
8331
|
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
8012
8332
|
if (event.event === "message") {
|
|
@@ -8078,9 +8398,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8078
8398
|
withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
|
|
8079
8399
|
warn
|
|
8080
8400
|
});
|
|
8401
|
+
const listening = new AbortController();
|
|
8402
|
+
let outdated;
|
|
8403
|
+
const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
|
|
8404
|
+
const watch = watchOutdated({
|
|
8405
|
+
check: /* @__PURE__ */ __name(() => outdatedReason({
|
|
8406
|
+
command: messenger.app.command,
|
|
8407
|
+
running: version,
|
|
8408
|
+
storePath: storePath(context.env),
|
|
8409
|
+
packageRoot
|
|
8410
|
+
}), "check"),
|
|
8411
|
+
onOutdated: /* @__PURE__ */ __name((reason) => {
|
|
8412
|
+
outdated = reason;
|
|
8413
|
+
listening.abort();
|
|
8414
|
+
}, "onOutdated"),
|
|
8415
|
+
...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
|
|
8416
|
+
});
|
|
8081
8417
|
try {
|
|
8082
8418
|
await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
|
|
8083
|
-
stop:
|
|
8419
|
+
stop: listening,
|
|
8084
8420
|
catchUp: true,
|
|
8085
8421
|
onReady,
|
|
8086
8422
|
connected: /* @__PURE__ */ __name((open) => {
|
|
@@ -8093,6 +8429,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8093
8429
|
}, "connected")
|
|
8094
8430
|
});
|
|
8095
8431
|
} finally {
|
|
8432
|
+
watch.stop();
|
|
8096
8433
|
await relaying;
|
|
8097
8434
|
await relay?.close();
|
|
8098
8435
|
rules.stop();
|
|
@@ -8103,6 +8440,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8103
8440
|
await tasks.settled();
|
|
8104
8441
|
releaseLock(path);
|
|
8105
8442
|
}
|
|
8443
|
+
if (outdated !== void 0)
|
|
8444
|
+
throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
|
|
8106
8445
|
renderAnswer(this, context, itemOf({
|
|
8107
8446
|
profile: context.profile,
|
|
8108
8447
|
started_at: startedAt,
|
|
@@ -8227,8 +8566,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8227
8566
|
};
|
|
8228
8567
|
}, "tasking");
|
|
8229
8568
|
|
|
8230
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8231
|
-
import { existsSync as
|
|
8569
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8570
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
8232
8571
|
var PATH = "store tables list";
|
|
8233
8572
|
var STORE_TABLES_QUERY = {
|
|
8234
8573
|
entity: "store_table",
|
|
@@ -8257,7 +8596,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8257
8596
|
const filter = filterOf(words);
|
|
8258
8597
|
const { full } = this.optsWithGlobals();
|
|
8259
8598
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8260
|
-
if (!
|
|
8599
|
+
if (!existsSync9(path))
|
|
8261
8600
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8262
8601
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
8263
8602
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -8270,7 +8609,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8270
8609
|
return tables;
|
|
8271
8610
|
}, "storeTablesCommand");
|
|
8272
8611
|
|
|
8273
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8612
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.618.0_@wirecat+cli-base@0.91.0_commander@15.0.0_esbuild@0.28.2_type_a1c6dd927639f1a41fe5f9c53e24865e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8274
8613
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8275
8614
|
var WORD_INDEX = "message_words";
|
|
8276
8615
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8279,7 +8618,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
8279
8618
|
}, "schemaOf");
|
|
8280
8619
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
8281
8620
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
8282
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8621
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
|
|
8283
8622
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
8284
8623
|
const database = await openCache(path);
|
|
8285
8624
|
try {
|
|
@@ -8306,7 +8645,7 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
|
|
|
8306
8645
|
}, "fileSchema");
|
|
8307
8646
|
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
|
|
8308
8647
|
const path = storePath(env);
|
|
8309
|
-
if (!
|
|
8648
|
+
if (!existsSync10(path))
|
|
8310
8649
|
return { path, exists: false };
|
|
8311
8650
|
const checked = await storeHealth(path, { deep });
|
|
8312
8651
|
const recorded = deep ? recordDeepCheck(path, checked, {
|
|
@@ -8376,7 +8715,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
8376
8715
|
const { renderer, format } = outputFor(this);
|
|
8377
8716
|
const { dryRun: dryRun2 } = this.opts();
|
|
8378
8717
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8379
|
-
if (!
|
|
8718
|
+
if (!existsSync10(path)) {
|
|
8380
8719
|
result(this, { path, exists: false });
|
|
8381
8720
|
return;
|
|
8382
8721
|
}
|
|
@@ -8416,7 +8755,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
8416
8755
|
}, "notesOf");
|
|
8417
8756
|
var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").description("the tables `store repair` kept as copies").addCommand(annotate(new Command("delete"), { output: { entity: "store_copy_removal" }, effects: LOCAL_WRITE }).description("delete one copy `store repair` kept, named exactly; refuses any other table").argument("<name>", "the copy's name, as `store repair` printed it").action(async function(name) {
|
|
8418
8757
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8419
|
-
if (!
|
|
8758
|
+
if (!existsSync10(path))
|
|
8420
8759
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8421
8760
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8422
8761
|
result(this, { path, deleted });
|
|
@@ -8424,7 +8763,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
8424
8763
|
var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary("check the local archive for problems").description("whether the store is healthy \u2014 integrity, search indexes, disk, and which chats are behind").action(async function() {
|
|
8425
8764
|
const { renderer } = outputFor(this);
|
|
8426
8765
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8427
|
-
if (!
|
|
8766
|
+
if (!existsSync10(path)) {
|
|
8428
8767
|
result(this, { path, exists: false, ok: true });
|
|
8429
8768
|
return;
|
|
8430
8769
|
}
|
|
@@ -8487,7 +8826,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
8487
8826
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
8488
8827
|
]);
|
|
8489
8828
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
8490
|
-
const { bavail, bsize } = statfsSync2(
|
|
8829
|
+
const { bavail, bsize } = statfsSync2(dirname3(path));
|
|
8491
8830
|
const free = Number(bavail) * Number(bsize);
|
|
8492
8831
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
8493
8832
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -8575,7 +8914,7 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8575
8914
|
var migrateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary("migrate an older local archive").description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
|
|
8576
8915
|
const { renderer } = outputFor(this);
|
|
8577
8916
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8578
|
-
if (!
|
|
8917
|
+
if (!existsSync10(path)) {
|
|
8579
8918
|
result(this, { path, exists: false });
|
|
8580
8919
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
8581
8920
|
return;
|
|
@@ -8639,7 +8978,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8639
8978
|
var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary("rebuild the local archive's search indexes").description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
|
|
8640
8979
|
const { renderer } = outputFor(this);
|
|
8641
8980
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8642
|
-
if (!
|
|
8981
|
+
if (!existsSync10(path)) {
|
|
8643
8982
|
result(this, { path, exists: false });
|
|
8644
8983
|
return;
|
|
8645
8984
|
}
|
|
@@ -8681,9 +9020,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8681
9020
|
const { encrypt } = this.opts();
|
|
8682
9021
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8683
9022
|
const target = resolve(file2);
|
|
8684
|
-
if (!
|
|
9023
|
+
if (!existsSync10(path))
|
|
8685
9024
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8686
|
-
if (
|
|
9025
|
+
if (existsSync10(target))
|
|
8687
9026
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8688
9027
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8689
9028
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8716,11 +9055,11 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8716
9055
|
const { output } = this.opts();
|
|
8717
9056
|
const from = resolve(file2);
|
|
8718
9057
|
const to = resolve(output);
|
|
8719
|
-
if (!
|
|
9058
|
+
if (!existsSync10(from))
|
|
8720
9059
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8721
9060
|
if (!isSealed(from))
|
|
8722
9061
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8723
|
-
if (
|
|
9062
|
+
if (existsSync10(to))
|
|
8724
9063
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8725
9064
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8726
9065
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
@@ -8728,13 +9067,13 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8728
9067
|
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
|
|
8729
9068
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8730
9069
|
const given = resolve(file2);
|
|
8731
|
-
if (!
|
|
9070
|
+
if (!existsSync10(given))
|
|
8732
9071
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8733
9072
|
refuseWhileServing(this, messenger);
|
|
8734
9073
|
if (!isSealed(given))
|
|
8735
9074
|
return restoreFrom(this, messenger, given, given);
|
|
8736
9075
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8737
|
-
mkdirSync(
|
|
9076
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8738
9077
|
try {
|
|
8739
9078
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8740
9079
|
await restoreFrom(this, messenger, opened, given);
|
|
@@ -8745,26 +9084,26 @@ var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command(
|
|
|
8745
9084
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8746
9085
|
const { renderer } = outputFor(command);
|
|
8747
9086
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8748
|
-
if (
|
|
9087
|
+
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
8749
9088
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8750
9089
|
}
|
|
8751
9090
|
if (await isRollbackCopy(backup))
|
|
8752
9091
|
return rollBackFrom(command, messenger, backup);
|
|
8753
9092
|
const schema = await backupSchema(backup);
|
|
8754
9093
|
const stamp = stampNow();
|
|
8755
|
-
const kept =
|
|
9094
|
+
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8756
9095
|
if (kept) {
|
|
8757
9096
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8758
9097
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8759
9098
|
} else
|
|
8760
|
-
mkdirSync(
|
|
9099
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8761
9100
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8762
9101
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8763
9102
|
chmodSync(incoming, 384);
|
|
8764
9103
|
if (kept) {
|
|
8765
9104
|
renameSync3(path, kept);
|
|
8766
9105
|
for (const suffix of ["-wal", "-shm"])
|
|
8767
|
-
if (
|
|
9106
|
+
if (existsSync10(`${path}${suffix}`))
|
|
8768
9107
|
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8769
9108
|
}
|
|
8770
9109
|
renameSync3(incoming, path);
|
|
@@ -8786,7 +9125,7 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
8786
9125
|
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8787
9126
|
const { renderer } = outputFor(command);
|
|
8788
9127
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8789
|
-
if (!
|
|
9128
|
+
if (!existsSync10(path))
|
|
8790
9129
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8791
9130
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8792
9131
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
@@ -8836,7 +9175,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8836
9175
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8837
9176
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8838
9177
|
const { command } = messenger.app;
|
|
8839
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
9178
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
8840
9179
|
const holders = holdersOf(files);
|
|
8841
9180
|
if (holders === void 0) {
|
|
8842
9181
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -8862,7 +9201,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8862
9201
|
const { command } = messenger.app;
|
|
8863
9202
|
const env = environmentOf(this).env ?? process.env;
|
|
8864
9203
|
const path = storePath(env);
|
|
8865
|
-
if (!
|
|
9204
|
+
if (!existsSync10(path)) {
|
|
8866
9205
|
result(this, { path, exists: false, reset: false });
|
|
8867
9206
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
8868
9207
|
return;
|
|
@@ -8907,8 +9246,8 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8907
9246
|
}), "resetCommand");
|
|
8908
9247
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
8909
9248
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
8910
|
-
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) =>
|
|
8911
|
-
const holders = holdersOf(files.map((file2) =>
|
|
9249
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9250
|
+
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
8912
9251
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
8913
9252
|
const read = await readingOnly(path, (database) => ({
|
|
8914
9253
|
schema: schemaOf(database).version,
|