@wirecat/notion-cli 0.4.0 → 0.6.0
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/CHANGELOG.md +58 -0
- package/README.md +5 -0
- package/contracts/wirecat.json +55 -2
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/agent-ILG6AH7S.js +42 -0
- package/dist/bundle/{all-profiles-4IONYZB6.js → all-profiles-AELHUTFU.js} +64 -21
- package/dist/bundle/{anthropic-OXF74J4P.js → anthropic-3CCYAGO3.js} +6 -6
- package/dist/bundle/{app-server-M2VF6ABM.js → app-server-DJ6P4NY4.js} +86 -65
- package/dist/bundle/{bun-DLA6QRLL.js → bun-2FLR4IV4.js} +2 -2
- package/dist/bundle/{bun-sqlite-F4BYLW3F.js → bun-sqlite-QB6CU6TH.js} +7 -7
- package/dist/bundle/chunk-2CMLY2X3.js +72 -0
- package/dist/bundle/{chunk-TZ2QJ53V.js → chunk-2XUV7HNE.js} +2 -2
- package/dist/bundle/{chunk-6JBLIQQN.js → chunk-2Z7UOXFC.js} +1 -1
- package/dist/bundle/{chunk-6GN7KU7X.js → chunk-3LMW7U7F.js} +22 -10
- package/dist/bundle/chunk-3MYN2RMG.js +398 -0
- package/dist/bundle/{chunk-YFWLHTNO.js → chunk-3UX4VJWD.js} +1 -1
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/{chunk-4KUJTSHG.js → chunk-4RFR4J2O.js} +2 -2
- package/dist/bundle/{chunk-OCDJ4FFA.js → chunk-4VXXOJ2F.js} +4 -4
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-P3P6DA6K.js → chunk-5OJLUUOJ.js} +6 -6
- package/dist/bundle/{chunk-T5UNSFES.js → chunk-5XPHFV7H.js} +35 -12
- package/dist/bundle/{chunk-KL3P5TQK.js → chunk-6EJCI47L.js} +4 -4
- package/dist/bundle/chunk-6VPC5Z56.js +2145 -0
- package/dist/bundle/{chunk-IJMFG7HB.js → chunk-6YOMPW7Y.js} +10 -8
- package/dist/bundle/{chunk-7NF3V5L2.js → chunk-7JVKQ6NM.js} +4 -4
- package/dist/bundle/chunk-7L2XOKDZ.js +353 -0
- package/dist/bundle/{chunk-TXONV3HW.js → chunk-A42T4YX7.js} +3 -3
- package/dist/bundle/chunk-AE4VW4NB.js +50 -0
- package/dist/bundle/chunk-AV2ZJ4WX.js +7 -0
- package/dist/bundle/{chunk-L6H7PY4X.js → chunk-AZLDR36U.js} +3 -3
- package/dist/bundle/{chunk-TFNRCCGR.js → chunk-BAXNAOOL.js} +4 -4
- package/dist/bundle/{chunk-QX3TPFEX.js → chunk-BEV5LO4D.js} +110 -862
- package/dist/bundle/{chunk-UROEWCOG.js → chunk-BQBC2WIG.js} +1 -65
- package/dist/bundle/{chunk-NO2LIHWA.js → chunk-CFQQTDSA.js} +1 -1
- package/dist/bundle/chunk-CHPWBQUK.js +39 -0
- package/dist/bundle/chunk-CL3YNUCC.js +388 -0
- package/dist/bundle/{chunk-WHJWURZB.js → chunk-DGMTSDKB.js} +6 -6
- package/dist/bundle/{chunk-HTKSCSJU.js → chunk-DHVVXQEL.js} +4 -4
- package/dist/bundle/chunk-DIU2QJJF.js +785 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/{chunk-Z53LYX4M.js → chunk-EHW45LLT.js} +3 -3
- package/dist/bundle/{chunk-XCTOCVMW.js → chunk-ERN53B3Z.js} +32 -24
- package/dist/bundle/{chunk-CDGZZNGY.js → chunk-ESZHGC4Q.js} +38 -8
- package/dist/bundle/{chunk-RMJMID5D.js → chunk-EZMG5QXB.js} +8 -8
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-Y5LAJWR5.js → chunk-F5ZAN7OC.js} +1 -1
- package/dist/bundle/{chunk-2MHMKNWD.js → chunk-FMMYBVCH.js} +1 -1
- package/dist/bundle/{chunk-WZEEEQGC.js → chunk-FRB2L7OE.js} +3 -3
- package/dist/bundle/chunk-FV4WTZCU.js +561 -0
- package/dist/bundle/{chunk-BEPFGITI.js → chunk-G4ZU73SD.js} +101 -80
- package/dist/bundle/{chunk-5XP4KQ2F.js → chunk-GCAJW4SR.js} +1 -1
- package/dist/bundle/{chunk-FEMHUSGO.js → chunk-GPRJXJC7.js} +15 -1
- package/dist/bundle/chunk-GUIQJUJV.js +340 -0
- package/dist/bundle/{chunk-M2EEIYBU.js → chunk-HHEWTLAT.js} +2 -2
- package/dist/bundle/{chunk-LIQMUDIZ.js → chunk-HM6AMYHR.js} +2 -2
- package/dist/bundle/{chunk-TJCPTRYD.js → chunk-HOVHE3A3.js} +7 -7
- package/dist/bundle/{chunk-YAPDU3SV.js → chunk-HVXOA4FO.js} +1 -1
- package/dist/bundle/{chunk-D6RCRBDH.js → chunk-IJVTN5L3.js} +2 -2
- package/dist/bundle/{chunk-CIVXTBJY.js → chunk-IURYZSG3.js} +39 -52
- package/dist/bundle/chunk-JFSVAOA7.js +108 -0
- package/dist/bundle/{chunk-FSJHASRQ.js → chunk-JVESLS7B.js} +611 -572
- package/dist/bundle/chunk-K5IC4FZN.js +36 -0
- package/dist/bundle/chunk-KB35BVTG.js +30 -0
- package/dist/bundle/chunk-KGAUINBO.js +594 -0
- package/dist/bundle/{chunk-AYU5TFDU.js → chunk-KNCPBX5P.js} +85 -76
- package/dist/bundle/{chunk-GSNE7OB4.js → chunk-KZJQPJK5.js} +4 -4
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-M6DGZ2O6.js → chunk-LC6WE6JS.js} +9 -9
- package/dist/bundle/{chunk-YGCI3DHS.js → chunk-LECMHK2F.js} +1 -1
- package/dist/bundle/chunk-LQVDFD65.js +72 -0
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-K5I64ZVI.js → chunk-NSR43UEW.js} +7 -64
- package/dist/bundle/{chunk-GK4GLPG2.js → chunk-OEQNP56V.js} +2 -100
- package/dist/bundle/{chunk-MGUEZYFA.js → chunk-OLAGFJDM.js} +13 -2143
- package/dist/bundle/{chunk-MRA62W5K.js → chunk-P27NDZQR.js} +255 -563
- package/dist/bundle/{chunk-GBFEEHQC.js → chunk-PHKED7AG.js} +8 -225
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-JODE2XED.js → chunk-Q7EIL6VU.js} +43 -33
- package/dist/bundle/{chunk-4TQVZXOV.js → chunk-QEJFBORC.js} +3 -3
- package/dist/bundle/{chunk-ZC6ZQQ55.js → chunk-QGGRFRMP.js} +65 -49
- package/dist/bundle/{chunk-JIRRF6BM.js → chunk-RD7BKTWV.js} +4 -4
- package/dist/bundle/chunk-RXU5T5NM.js +714 -0
- package/dist/bundle/{chunk-MVA5HVKL.js → chunk-S4UUN6LD.js} +18 -0
- package/dist/bundle/{chunk-7NGFGFE5.js → chunk-SAPP2LEH.js} +10 -10
- package/dist/bundle/{chunk-COH7OEER.js → chunk-SEAGUFBX.js} +12 -12
- package/dist/bundle/{chunk-5LBJNTEJ.js → chunk-STTO2MSY.js} +43 -64
- package/dist/bundle/{chunk-5UA2TYMI.js → chunk-T37TAXVL.js} +2 -2
- package/dist/bundle/{chunk-R6SDRSZK.js → chunk-T6XIBULH.js} +139 -571
- package/dist/bundle/chunk-TFT4FVRU.js +67 -0
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/{chunk-KFVDL2QS.js → chunk-UC7JLE6J.js} +1 -89
- package/dist/bundle/{chunk-SGBS5QCU.js → chunk-UOC52GCB.js} +4 -4
- package/dist/bundle/chunk-UPL474OW.js +94 -0
- package/dist/bundle/chunk-VH7526NL.js +80 -0
- package/dist/bundle/chunk-VNWF4I7E.js +34 -0
- package/dist/bundle/chunk-W2VQDIU5.js +221 -0
- package/dist/bundle/{chunk-EQPAZ33O.js → chunk-WAGADES3.js} +19 -19
- package/dist/bundle/{chunk-WU3XHGOB.js → chunk-WAU5LSHP.js} +81 -438
- package/dist/bundle/{chunk-FIHXADRF.js → chunk-WB2KSQIP.js} +4 -4
- package/dist/bundle/{chunk-OI5DWZJG.js → chunk-WGZH2M64.js} +3 -3
- package/dist/bundle/chunk-WVN2KTNS.js +52 -0
- package/dist/bundle/{chunk-UKE3CGHK.js → chunk-XYQVVW4R.js} +1 -1
- package/dist/bundle/{chunk-7NVPM55S.js → chunk-YDDI4QIT.js} +2203 -1808
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/{chunk-7YZPBAQX.js → chunk-YUDVRFXN.js} +1 -1
- package/dist/bundle/{chunk-EY6S7FV3.js → chunk-YXYZAWWW.js} +6 -6
- package/dist/bundle/{chunk-GCCPFKSU.js → chunk-YYQ5GKAI.js} +9532 -10735
- package/dist/bundle/chunk-ZDYEOE7L.js +2366 -0
- package/dist/bundle/command-contract-L2FASWD6.js +41 -0
- package/dist/bundle/{command-server-entry-2SORMVRM.js → command-server-entry-VUR6WL77.js} +30 -27
- package/dist/bundle/{decode-5O7IEFPN.js → decode-I64PF2RM.js} +6 -6
- package/dist/bundle/{definitions-M3U4UYHN.js → definitions-MB65223J.js} +72 -18
- package/dist/bundle/{dispatch-YHQX6FEJ.js → dispatch-JQBAZWCL.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-ARLMVQC7.js → echarts-YRRVLEX3.js} +2 -2
- package/dist/bundle/{embed-FUDUKQ3K.js → embed-BLXLKMK2.js} +7 -7
- package/dist/bundle/{embedder-HDRV7GX3.js → embedder-JYGF6R7I.js} +10 -10
- package/dist/bundle/{failure-JHXICWIL.js → failure-I6AAF5R5.js} +3 -3
- package/dist/bundle/first-run-YLDOZGY6.js +29 -0
- package/dist/bundle/first-screen-GZH3LMLZ.js +41 -0
- package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
- package/dist/bundle/hast-util-to-html-IIFHILP5.js +998 -0
- package/dist/bundle/hast-util-to-mdast-3CSMIWK2.js +2272 -0
- package/dist/bundle/{instructions-MEFIKCDI.js → instructions-AG7SRWTR.js} +1 -1
- package/dist/bundle/{mcp-VMS6PBCU.js → mcp-YGOAUNC3.js} +2 -2
- package/dist/bundle/{mdast-util-from-markdown-R66F4HZA.js → mdast-util-from-markdown-XCR5KW5S.js} +138 -195
- package/dist/bundle/{mdast-util-gfm-LN2ELINH.js → mdast-util-gfm-JO7PHUIB.js} +28 -357
- package/dist/bundle/mdast-util-to-hast-AYJV7KAE.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-DOXGHRI7.js +1854 -0
- package/dist/bundle/meeting-combined-OFQSGKBG.js +25 -0
- package/dist/bundle/meeting-model-K6NSX3O5.js +27 -0
- package/dist/bundle/{meeting-semantic-R4CSLVRG.js → meeting-semantic-3DZPHM7L.js} +7 -7
- package/dist/bundle/{micromark-extension-gfm-5X7YT43T.js → micromark-extension-gfm-PQ7DWZM7.js} +12 -78
- package/dist/bundle/{node-MAQALPLA.js → node-GJQYN4FT.js} +2 -2
- package/dist/bundle/{node-sqlite-J7IJYNBO.js → node-sqlite-7VXIRQPH.js} +8 -8
- package/dist/bundle/notes-search-ACDOPTNH.js +64 -0
- package/dist/bundle/notion.js +14 -14
- package/dist/bundle/oauth-N67CH2TK.js +20 -0
- package/dist/bundle/{open-AB27MTGR.js → open-JGXVHIKO.js} +6 -6
- package/dist/bundle/{openai-D77MU5XV.js → openai-PFQJTF4H.js} +21 -18
- package/dist/bundle/{process-SIOWTRJ6.js → process-MEKCZMX3.js} +1 -1
- package/dist/bundle/{program-7K34KI27.js → program-DUJYLJH5.js} +6947 -6532
- package/dist/bundle/{prompt-W77YDHA6.js → prompt-FW44QDHD.js} +6 -6
- package/dist/bundle/{recognize-3JAXQQ36.js → recognize-62TDQ6A7.js} +5 -5
- package/dist/bundle/{remote-PSOJXCXO.js → remote-7ONFD7GG.js} +12 -11
- package/dist/bundle/{rerank-EE44ZTGL.js → rerank-YOHQQJS4.js} +8 -8
- package/dist/bundle/{schemas-LBYUMBC6.js → schemas-IIGJ7DOP.js} +39 -60
- package/dist/bundle/{serve-XJMGAMFW.js → serve-ZCXGT5RB.js} +11 -11
- package/dist/bundle/{server-ASU6CP5R.js → server-RQ74M637.js} +78 -56
- package/dist/bundle/server-XMZF57WM.js +90 -0
- package/dist/bundle/{services-PT4PA4J6.js → services-FWBRZ57M.js} +105 -90
- package/dist/bundle/{sqlite-runtime-YHXRTVXE.js → sqlite-runtime-ZZBNGV5L.js} +7 -7
- package/dist/bundle/{state-T6ZKFWGD.js → state-GDDFO62Y.js} +7 -7
- package/dist/bundle/{store-E5EE25FY.js → store-D2LRIWEI.js} +24 -20
- package/dist/bundle/{store-3MUCZEI3.js → store-KQCLR57N.js} +32 -18
- package/dist/bundle/store-maintenance-command-CK2MU5M6.js +77 -0
- package/dist/bundle/surface-K4TPIQW7.js +76 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +22 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/api.d.ts +7 -2
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +19 -119
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/library.d.ts.map +1 -1
- package/dist/commands/library.js +16 -5
- package/dist/commands/library.js.map +1 -1
- package/dist/config.d.ts +11 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +63 -54
- package/dist/config.js.map +1 -1
- package/dist/generated/definitions.d.ts.map +1 -1
- package/dist/generated/definitions.js +72 -18
- package/dist/generated/definitions.js.map +1 -1
- package/dist/generated/manifest.d.ts +4 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +69 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/schemas.js +32 -32
- package/dist/generated/schemas.js.map +1 -1
- package/dist/generated/types.d.ts +125 -25
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/knowledge.d.ts +1 -0
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +68 -2
- package/dist/knowledge.js.map +1 -1
- package/dist/library.d.ts +12 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +35 -1
- package/dist/library.js.map +1 -1
- package/dist/notion/port.d.ts.map +1 -1
- package/dist/notion/port.js +1 -0
- package/dist/notion/port.js.map +1 -1
- package/dist/notion/reads.d.ts +13 -1
- package/dist/notion/reads.d.ts.map +1 -1
- package/dist/notion/reads.js +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +19 -2
- package/dist/program.js.map +1 -1
- package/dist/sync/files.d.ts +19 -0
- package/dist/sync/files.d.ts.map +1 -1
- package/dist/sync/files.js.map +1 -1
- package/dist/sync/source.d.ts +1 -1
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +60 -55
- package/dist/sync/source.js.map +1 -1
- package/dist/sync/users.d.ts +22 -0
- package/dist/sync/users.d.ts.map +1 -0
- package/dist/sync/users.js +111 -0
- package/dist/sync/users.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunk-L62XTC7N.js +0 -726
- package/dist/bundle/chunk-SHTHNBHG.js +0 -2
- package/dist/bundle/command-contract-UBXS6NHI.js +0 -38
- package/dist/bundle/first-run-BGEFTXOE.js +0 -29
- package/dist/bundle/first-screen-F5F3VS6Y.js +0 -38
- package/dist/bundle/meeting-combined-HNSS3FQY.js +0 -24
- package/dist/bundle/meeting-model-REZVYGQW.js +0 -26
- package/dist/bundle/oauth-AMV4YGJD.js +0 -20
- package/dist/bundle/server-WSPQ5EOA.js +0 -72
- package/dist/bundle/store-maintenance-command-ZZ55BBBG.js +0 -63
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
environmentOf
|
|
5
|
+
} from "./chunk-P27NDZQR.js";
|
|
6
|
+
import {
|
|
7
|
+
throughWrapper
|
|
8
|
+
} from "./chunk-KB35BVTG.js";
|
|
9
|
+
import {
|
|
10
|
+
readOnlyLockOf
|
|
11
|
+
} from "./chunk-3MYN2RMG.js";
|
|
12
|
+
import {
|
|
13
|
+
array,
|
|
14
|
+
boolean,
|
|
15
|
+
check,
|
|
16
|
+
pipe,
|
|
17
|
+
record,
|
|
18
|
+
safeParse,
|
|
19
|
+
strictObject,
|
|
20
|
+
string
|
|
21
|
+
} from "./chunk-S4UUN6LD.js";
|
|
22
|
+
import {
|
|
23
|
+
CliError
|
|
24
|
+
} from "./chunk-HM6AMYHR.js";
|
|
25
|
+
import {
|
|
26
|
+
__name
|
|
27
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
28
|
+
|
|
29
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/background/relay.js
|
|
30
|
+
import { createHash } from "node:crypto";
|
|
31
|
+
import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
|
|
32
|
+
import { createConnection, createServer } from "node:net";
|
|
33
|
+
import { tmpdir } from "node:os";
|
|
34
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
35
|
+
import { PassThrough, Writable } from "node:stream";
|
|
36
|
+
var RELAY_PROTOCOL = 1;
|
|
37
|
+
var requestSchema = strictObject({
|
|
38
|
+
argv: array(string()),
|
|
39
|
+
env: record(string(), string()),
|
|
40
|
+
cwd: pipe(string(), check((path) => isAbsolute(path))),
|
|
41
|
+
tty: boolean(),
|
|
42
|
+
stdinTty: boolean()
|
|
43
|
+
});
|
|
44
|
+
var MAX_CLIENT_LINE = 1024 * 1024;
|
|
45
|
+
var MAX_SERVE_LINE = 64 * 1024 * 1024;
|
|
46
|
+
var MAX_SOCKET_PATH = 100;
|
|
47
|
+
var relayPath = /* @__PURE__ */ __name((lockPath) => {
|
|
48
|
+
const beside = lockPath.replace(/\.lock$/, ".sock");
|
|
49
|
+
if (beside.length <= MAX_SOCKET_PATH)
|
|
50
|
+
return beside;
|
|
51
|
+
const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
|
|
52
|
+
const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
|
|
53
|
+
const temporary = join(tmpdir(), name);
|
|
54
|
+
if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
|
|
55
|
+
return temporary;
|
|
56
|
+
return join("/tmp", name);
|
|
57
|
+
}, "relayPath");
|
|
58
|
+
var privateDirectory = /* @__PURE__ */ __name((dir) => {
|
|
59
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
60
|
+
const stat = lstatSync(dir);
|
|
61
|
+
const mine = process.getuid === void 0 || stat.uid === process.getuid();
|
|
62
|
+
if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
|
|
63
|
+
throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
|
|
64
|
+
}
|
|
65
|
+
}, "privateDirectory");
|
|
66
|
+
var lines = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
|
|
67
|
+
let buffered = "";
|
|
68
|
+
socket.setEncoding("utf8");
|
|
69
|
+
socket.on("data", (chunk) => {
|
|
70
|
+
buffered += chunk;
|
|
71
|
+
for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
|
|
72
|
+
const line = buffered.slice(0, end);
|
|
73
|
+
buffered = buffered.slice(end + 1);
|
|
74
|
+
if (line)
|
|
75
|
+
onLine(line);
|
|
76
|
+
}
|
|
77
|
+
if (buffered.length > max)
|
|
78
|
+
onTooLong();
|
|
79
|
+
});
|
|
80
|
+
}, "lines");
|
|
81
|
+
var frame = /* @__PURE__ */ __name((socket, value) => {
|
|
82
|
+
if (!socket.destroyed)
|
|
83
|
+
socket.write(`${JSON.stringify(value)}
|
|
84
|
+
`);
|
|
85
|
+
}, "frame");
|
|
86
|
+
var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
|
|
87
|
+
privateDirectory(dirname(path));
|
|
88
|
+
rmSync(path, { force: true });
|
|
89
|
+
const open = /* @__PURE__ */ new Set();
|
|
90
|
+
const running = /* @__PURE__ */ new Set();
|
|
91
|
+
const server = createServer((socket) => {
|
|
92
|
+
open.add(socket);
|
|
93
|
+
const stop = new AbortController();
|
|
94
|
+
const stdin = new PassThrough();
|
|
95
|
+
let started = false;
|
|
96
|
+
socket.on("error", () => {
|
|
97
|
+
});
|
|
98
|
+
socket.on("close", () => {
|
|
99
|
+
open.delete(socket);
|
|
100
|
+
stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
|
|
101
|
+
if (!stdin.writableEnded)
|
|
102
|
+
stdin.end();
|
|
103
|
+
});
|
|
104
|
+
lines(socket, MAX_CLIENT_LINE, (line) => {
|
|
105
|
+
let message;
|
|
106
|
+
try {
|
|
107
|
+
message = JSON.parse(line);
|
|
108
|
+
} catch {
|
|
109
|
+
socket.destroy();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!started) {
|
|
113
|
+
started = true;
|
|
114
|
+
if (message.v !== RELAY_PROTOCOL) {
|
|
115
|
+
frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
|
|
116
|
+
socket.end();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const parsed = safeParse(requestSchema, message.run);
|
|
120
|
+
if (!parsed.success) {
|
|
121
|
+
socket.destroy();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
stdin.isTTY = parsed.output.stdinTty;
|
|
125
|
+
if (parsed.output.stdinTty)
|
|
126
|
+
stdin.end();
|
|
127
|
+
const job = serve(socket, parsed.output, stdin, stop.signal, run);
|
|
128
|
+
running.add(job);
|
|
129
|
+
void job.then(() => running.delete(job), () => running.delete(job));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (typeof message.stdin === "string" && !stdin.writableEnded)
|
|
133
|
+
stdin.write(Buffer.from(message.stdin, "base64"));
|
|
134
|
+
if (message.stdinEnd === true && !stdin.writableEnded)
|
|
135
|
+
stdin.end();
|
|
136
|
+
}, () => socket.destroy());
|
|
137
|
+
});
|
|
138
|
+
await new Promise((resolve, reject) => {
|
|
139
|
+
server.once("error", reject);
|
|
140
|
+
server.listen(path, () => {
|
|
141
|
+
server.off("error", reject);
|
|
142
|
+
resolve();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
chmodSync(path, 384);
|
|
146
|
+
return {
|
|
147
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
148
|
+
for (const socket of open)
|
|
149
|
+
socket.destroy();
|
|
150
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
151
|
+
await Promise.allSettled(running);
|
|
152
|
+
rmSync(path, { force: true });
|
|
153
|
+
}, "close")
|
|
154
|
+
};
|
|
155
|
+
}, "listenRelay");
|
|
156
|
+
var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
|
|
157
|
+
const streams = {
|
|
158
|
+
data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
|
|
159
|
+
diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
|
|
160
|
+
progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
|
|
161
|
+
};
|
|
162
|
+
const stdout = new Writable({
|
|
163
|
+
write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
|
|
164
|
+
frame(socket, { raw: Buffer.from(chunk).toString("base64") });
|
|
165
|
+
done();
|
|
166
|
+
}, "write")
|
|
167
|
+
});
|
|
168
|
+
let code = 1;
|
|
169
|
+
try {
|
|
170
|
+
code = await run(request, { streams, stdin, stdout, signal });
|
|
171
|
+
} finally {
|
|
172
|
+
frame(socket, { exit: code });
|
|
173
|
+
socket.end();
|
|
174
|
+
}
|
|
175
|
+
}, "serve");
|
|
176
|
+
var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
|
|
177
|
+
const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
|
|
178
|
+
const socket = createConnection(path);
|
|
179
|
+
let connected = false;
|
|
180
|
+
let settled = false;
|
|
181
|
+
let timer;
|
|
182
|
+
const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
|
|
183
|
+
const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
|
|
184
|
+
const brokenPipe = /* @__PURE__ */ __name((error) => {
|
|
185
|
+
if (error.code === "EPIPE")
|
|
186
|
+
finish({ code: 0 });
|
|
187
|
+
}, "brokenPipe");
|
|
188
|
+
const finish = /* @__PURE__ */ __name((outcome) => {
|
|
189
|
+
if (settled)
|
|
190
|
+
return;
|
|
191
|
+
settled = true;
|
|
192
|
+
if (timer)
|
|
193
|
+
clearTimeout(timer);
|
|
194
|
+
stdout.off("error", brokenPipe);
|
|
195
|
+
signal.removeEventListener("abort", aborted);
|
|
196
|
+
stdin.off("data", forward).off("end", ended);
|
|
197
|
+
stdin.pause();
|
|
198
|
+
socket.destroy();
|
|
199
|
+
if ("code" in outcome)
|
|
200
|
+
resolve(outcome.code);
|
|
201
|
+
else
|
|
202
|
+
reject(outcome.error);
|
|
203
|
+
}, "finish");
|
|
204
|
+
const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
|
|
205
|
+
const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
|
|
206
|
+
if (signal.aborted)
|
|
207
|
+
return aborted();
|
|
208
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
209
|
+
stdout.on("error", brokenPipe);
|
|
210
|
+
if (deadlineMs !== void 0)
|
|
211
|
+
timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
|
|
212
|
+
socket.on("connect", () => {
|
|
213
|
+
connected = true;
|
|
214
|
+
frame(socket, { v: RELAY_PROTOCOL, run: request });
|
|
215
|
+
if (request.stdinTty)
|
|
216
|
+
ended();
|
|
217
|
+
else {
|
|
218
|
+
stdin.on("data", forward).once("end", ended);
|
|
219
|
+
stdin.resume();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
socket.on("error", (error) => {
|
|
223
|
+
if (connected)
|
|
224
|
+
return finish({ error: stopped() });
|
|
225
|
+
finish({
|
|
226
|
+
error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
socket.on("close", () => finish({ error: stopped() }));
|
|
230
|
+
lines(socket, MAX_SERVE_LINE, (line) => {
|
|
231
|
+
let message;
|
|
232
|
+
try {
|
|
233
|
+
message = JSON.parse(line);
|
|
234
|
+
} catch {
|
|
235
|
+
return finish({ error: stopped() });
|
|
236
|
+
}
|
|
237
|
+
if (typeof message.data === "string")
|
|
238
|
+
streams.data(message.data);
|
|
239
|
+
if (typeof message.diagnostic === "string")
|
|
240
|
+
streams.diagnostic(message.diagnostic);
|
|
241
|
+
if (typeof message.progress === "string")
|
|
242
|
+
streams.progress?.(message.progress);
|
|
243
|
+
if (typeof message.raw === "string")
|
|
244
|
+
stdout.write(Buffer.from(message.raw, "base64"));
|
|
245
|
+
if (typeof message.exit === "number")
|
|
246
|
+
finish({ code: message.exit });
|
|
247
|
+
}, () => finish({ error: stopped() }));
|
|
248
|
+
}), "relayCommand");
|
|
249
|
+
|
|
250
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
|
|
251
|
+
var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
|
|
252
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
253
|
+
}, "close"),
|
|
254
|
+
feed: void 0,
|
|
255
|
+
storedChats: void 0,
|
|
256
|
+
listen: void 0,
|
|
257
|
+
listenHistory: void 0,
|
|
258
|
+
...connection.watch && watchers ? {
|
|
259
|
+
// A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
|
|
260
|
+
watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
|
|
261
|
+
let watcher;
|
|
262
|
+
try {
|
|
263
|
+
await new Promise((resolve, reject) => {
|
|
264
|
+
watcher = /* @__PURE__ */ __name((event) => {
|
|
265
|
+
try {
|
|
266
|
+
onEvent(event);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
reject(error);
|
|
269
|
+
}
|
|
270
|
+
}, "watcher");
|
|
271
|
+
watchers.add(watcher);
|
|
272
|
+
signal.addEventListener("abort", () => resolve(), { once: true });
|
|
273
|
+
onReady?.();
|
|
274
|
+
if (signal.aborted)
|
|
275
|
+
resolve();
|
|
276
|
+
});
|
|
277
|
+
} finally {
|
|
278
|
+
if (watcher)
|
|
279
|
+
watchers.delete(watcher);
|
|
280
|
+
}
|
|
281
|
+
}, "watch")
|
|
282
|
+
} : { watch: void 0 }
|
|
283
|
+
}), "lentConnection");
|
|
284
|
+
var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
|
|
285
|
+
let held;
|
|
286
|
+
let relay;
|
|
287
|
+
const watchers = /* @__PURE__ */ new Set();
|
|
288
|
+
const borrowed = /* @__PURE__ */ __name(() => {
|
|
289
|
+
const connection = held;
|
|
290
|
+
if (!connection)
|
|
291
|
+
throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
|
|
292
|
+
return lentConnection(connection, watchers);
|
|
293
|
+
}, "borrowed");
|
|
294
|
+
return {
|
|
295
|
+
messenger: {
|
|
296
|
+
...messenger,
|
|
297
|
+
connect: /* @__PURE__ */ __name(async (...args) => {
|
|
298
|
+
held = await messenger.connect(...args);
|
|
299
|
+
return held;
|
|
300
|
+
}, "connect")
|
|
301
|
+
},
|
|
302
|
+
arrived: /* @__PURE__ */ __name((event) => {
|
|
303
|
+
for (const watcher of watchers)
|
|
304
|
+
watcher(event);
|
|
305
|
+
}, "arrived"),
|
|
306
|
+
/** Listens beside the lock; the address goes into it, which is how a client finds it. */
|
|
307
|
+
open: /* @__PURE__ */ __name(async (lockPath, profile) => {
|
|
308
|
+
const environment = environmentOf(command);
|
|
309
|
+
const runCommand = environment.runCommand;
|
|
310
|
+
if (!runCommand)
|
|
311
|
+
return void 0;
|
|
312
|
+
const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
|
|
313
|
+
const path = relayPath(lockPath);
|
|
314
|
+
relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
|
|
315
|
+
env: {
|
|
316
|
+
...request.env,
|
|
317
|
+
...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
|
|
318
|
+
},
|
|
319
|
+
streams: io.streams,
|
|
320
|
+
stdin: io.stdin,
|
|
321
|
+
stdout: io.stdout,
|
|
322
|
+
tty: request.tty,
|
|
323
|
+
signal: io.signal,
|
|
324
|
+
answer: /* @__PURE__ */ __name(() => null, "answer"),
|
|
325
|
+
relayed: { profile, cwd: request.cwd, connection: borrowed }
|
|
326
|
+
}));
|
|
327
|
+
return { path, protocol: RELAY_PROTOCOL };
|
|
328
|
+
}, "open"),
|
|
329
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
330
|
+
await relay?.close();
|
|
331
|
+
}, "close")
|
|
332
|
+
};
|
|
333
|
+
}, "serveRelay");
|
|
334
|
+
|
|
335
|
+
export {
|
|
336
|
+
RELAY_PROTOCOL,
|
|
337
|
+
relayCommand,
|
|
338
|
+
lentConnection,
|
|
339
|
+
serveRelay
|
|
340
|
+
};
|
|
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
resolvePaths
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KNCPBX5P.js";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-ZVVMGPBJ.js";
|
|
9
9
|
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/store/path.js
|
|
11
11
|
import { realpathSync } from "node:fs";
|
|
12
12
|
import { userInfo } from "node:os";
|
|
13
13
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__name
|
|
5
5
|
} from "./chunk-ZVVMGPBJ.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/errors.js
|
|
8
8
|
var errorCodes = [
|
|
9
9
|
"validation_error",
|
|
10
10
|
"configuration_error",
|
|
@@ -39,7 +39,7 @@ var CliError = class extends Error {
|
|
|
39
39
|
};
|
|
40
40
|
var isCliError = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && value[BRAND] === true, "isCliError");
|
|
41
41
|
|
|
42
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
42
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/sanitize.js
|
|
43
43
|
var CONTROL = (
|
|
44
44
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the whole point
|
|
45
45
|
/[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B\u200E\u200F\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu
|
|
@@ -2,24 +2,24 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
storePath
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HHEWTLAT.js";
|
|
6
6
|
import {
|
|
7
7
|
resolvePaths,
|
|
8
8
|
writeSecurely
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KNCPBX5P.js";
|
|
10
10
|
import {
|
|
11
11
|
CliError,
|
|
12
12
|
singleLine
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HM6AMYHR.js";
|
|
14
14
|
import {
|
|
15
15
|
__name
|
|
16
16
|
} from "./chunk-ZVVMGPBJ.js";
|
|
17
17
|
|
|
18
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
18
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/store/shared-config.js
|
|
19
19
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
20
20
|
import { dirname, join, resolve } from "node:path";
|
|
21
21
|
|
|
22
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
22
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/domain/config-repair.js
|
|
23
23
|
var REPAIR_WORDS = {
|
|
24
24
|
byte_order_mark: "an invisible byte-order mark at the start",
|
|
25
25
|
comment: "a comment, which JSON does not allow",
|
|
@@ -303,7 +303,7 @@ var explainBrokenJson = /* @__PURE__ */ __name((text, result) => {
|
|
|
303
303
|
return `line ${line}, column ${column}: ${why}${around(line)}; likely fix: ${fix ?? "correct that part by hand"}`;
|
|
304
304
|
}, "explainBrokenJson");
|
|
305
305
|
|
|
306
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
306
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/domain/task-categories.js
|
|
307
307
|
var DEFAULT_TASK_CATEGORIES = [
|
|
308
308
|
{
|
|
309
309
|
name: "taxes",
|
|
@@ -1058,7 +1058,7 @@ var storedTaskCategories = /* @__PURE__ */ __name((json) => {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
}, "storedTaskCategories");
|
|
1060
1060
|
|
|
1061
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1061
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/store/shared-config.js
|
|
1062
1062
|
var SECTION = "task_categories";
|
|
1063
1063
|
var sharedConfigPath = /* @__PURE__ */ __name((store, env = process.env) => {
|
|
1064
1064
|
const paths = resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env });
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__name
|
|
5
5
|
} from "./chunk-ZVVMGPBJ.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/installer.js
|
|
8
8
|
var installerOf = /* @__PURE__ */ __name((scriptPath) => {
|
|
9
9
|
const path = scriptPath.replaceAll("\\", "/");
|
|
10
10
|
if (path.includes("/_npx/"))
|
|
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
CliError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HM6AMYHR.js";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-ZVVMGPBJ.js";
|
|
9
9
|
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/cli/input-policy.js
|
|
11
11
|
var MAX_BUFFERED_INPUT = 16 * 1024 * 1024;
|
|
12
12
|
var MAX_SECRET_INPUT = 64 * 1024;
|
|
13
13
|
var policies = /* @__PURE__ */ new WeakMap();
|
|
@@ -2,12 +2,12 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
CliError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HM6AMYHR.js";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-ZVVMGPBJ.js";
|
|
9
9
|
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/atomic-write.js
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
12
|
import { constants } from "node:fs";
|
|
13
13
|
import { link, open, realpath, rename, unlink } from "node:fs/promises";
|
|
@@ -45,7 +45,7 @@ var writeFileAtomic = /* @__PURE__ */ __name(async (path, content, { mode = 384,
|
|
|
45
45
|
}
|
|
46
46
|
}, "writeFileAtomic");
|
|
47
47
|
|
|
48
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
48
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/ordinary-file.js
|
|
49
49
|
import { constants as constants2 } from "node:fs";
|
|
50
50
|
import { lstat, open as open2 } from "node:fs/promises";
|
|
51
51
|
var deviceOf = /* @__PURE__ */ __name((dev) => process.platform === "win32" ? BigInt.asUintN(32, dev) : dev, "deviceOf");
|
|
@@ -111,50 +111,21 @@ var syncDirectory = /* @__PURE__ */ __name(async (path) => {
|
|
|
111
111
|
}
|
|
112
112
|
}, "syncDirectory");
|
|
113
113
|
|
|
114
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
115
|
-
var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
|
|
116
|
-
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 16 * 1024 * 1024)
|
|
117
|
-
throw new CliError("validation_error", "file maxBytes takes 1\u201316777216 bytes");
|
|
118
|
-
const file = await openOrdinaryFile(path);
|
|
119
|
-
try {
|
|
120
|
-
if ((await file.stat()).size > maxBytes)
|
|
121
|
-
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
122
|
-
const chunks = [], buffer = Buffer.alloc(Math.min(65536, maxBytes + 1));
|
|
123
|
-
let bytes = 0;
|
|
124
|
-
for (; ; ) {
|
|
125
|
-
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, maxBytes - bytes + 1), null);
|
|
126
|
-
if (bytesRead === 0)
|
|
127
|
-
break;
|
|
128
|
-
bytes += bytesRead;
|
|
129
|
-
if (bytes > maxBytes)
|
|
130
|
-
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
131
|
-
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes));
|
|
135
|
-
} catch {
|
|
136
|
-
throw new CliError("validation_error", "input file must contain valid UTF-8");
|
|
137
|
-
}
|
|
138
|
-
} finally {
|
|
139
|
-
await file.close();
|
|
140
|
-
}
|
|
141
|
-
}, "readBoundedUtf8File");
|
|
142
|
-
|
|
143
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.680.0_@wirecat+cli-base@0.106.0_commander@15.0.0_esbuild@0.28.2_typ_620ac9b386657c249f5c9038159a7caa/node_modules/@wirecat/cli-core/dist/files/lock.js
|
|
114
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/lock.js
|
|
144
115
|
import { mkdir as mkdir2 } from "node:fs/promises";
|
|
145
116
|
import { basename as basename2, dirname as dirname2 } from "node:path";
|
|
146
117
|
|
|
147
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
118
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
|
|
148
119
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
149
120
|
import { lstat as lstat3, mkdir, open as open3, realpath as realpath3, rmdir as rmdir2, unlink as unlink4 } from "node:fs/promises";
|
|
150
121
|
import { hostname as hostname2 } from "node:os";
|
|
151
122
|
import { join as join3 } from "node:path";
|
|
152
123
|
|
|
153
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
124
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
|
|
154
125
|
import { lstat as lstat2, readdir, realpath as realpath2, unlink as unlink2 } from "node:fs/promises";
|
|
155
126
|
import { join as join2 } from "node:path";
|
|
156
127
|
|
|
157
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
128
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-lease-owner.js
|
|
158
129
|
import { hostname } from "node:os";
|
|
159
130
|
var missingLeaseFile = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missingLeaseFile");
|
|
160
131
|
var readLeaseOwner = /* @__PURE__ */ __name(async (path, name, signal) => {
|
|
@@ -199,7 +170,7 @@ var leaseOwnerStatus = /* @__PURE__ */ __name((owner) => {
|
|
|
199
170
|
}
|
|
200
171
|
}, "leaseOwnerStatus");
|
|
201
172
|
|
|
202
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
173
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-lease-inspection.js
|
|
203
174
|
var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
|
|
204
175
|
const inspect = /* @__PURE__ */ __name(async (destination, options = {}) => {
|
|
205
176
|
options.signal?.throwIfAborted();
|
|
@@ -258,7 +229,7 @@ var leaseInspection = /* @__PURE__ */ __name((markerDirectory) => {
|
|
|
258
229
|
return { inspect, recover };
|
|
259
230
|
}, "leaseInspection");
|
|
260
231
|
|
|
261
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
232
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-lease-release.js
|
|
262
233
|
import { rmdir, unlink as unlink3 } from "node:fs/promises";
|
|
263
234
|
var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identity) => {
|
|
264
235
|
let releasing;
|
|
@@ -283,7 +254,7 @@ var ownedNativeLease = /* @__PURE__ */ __name((path, name, owner, folder, identi
|
|
|
283
254
|
};
|
|
284
255
|
}, "ownedNativeLease");
|
|
285
256
|
|
|
286
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
257
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/native-writer-lease.js
|
|
287
258
|
var validName = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0 && value !== "." && value !== ".." && !/[\\/\0:]/.test(value), "validName");
|
|
288
259
|
var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
|
|
289
260
|
const { markerDirectory, legacyMarker } = layout;
|
|
@@ -354,7 +325,7 @@ var nativeWriterLeaseStore = /* @__PURE__ */ __name((layout) => {
|
|
|
354
325
|
};
|
|
355
326
|
}, "nativeWriterLeaseStore");
|
|
356
327
|
|
|
357
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
328
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/lock.js
|
|
358
329
|
var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
|
|
359
330
|
const folder = dirname2(path);
|
|
360
331
|
await mkdir2(folder, { recursive: true, mode: 448 });
|
|
@@ -369,17 +340,34 @@ var acquireLock = /* @__PURE__ */ __name(async (path, { signal } = {}) => {
|
|
|
369
340
|
});
|
|
370
341
|
}, "acquireLock");
|
|
371
342
|
|
|
372
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (
|
|
379
|
-
|
|
343
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/files/bounded-utf8.js
|
|
344
|
+
var readBoundedUtf8File = /* @__PURE__ */ __name(async (path, { maxBytes }) => {
|
|
345
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 16 * 1024 * 1024)
|
|
346
|
+
throw new CliError("validation_error", "file maxBytes takes 1\u201316777216 bytes");
|
|
347
|
+
const file = await openOrdinaryFile(path);
|
|
348
|
+
try {
|
|
349
|
+
if ((await file.stat()).size > maxBytes)
|
|
350
|
+
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
351
|
+
const chunks = [], buffer = Buffer.alloc(Math.min(65536, maxBytes + 1));
|
|
352
|
+
let bytes = 0;
|
|
353
|
+
for (; ; ) {
|
|
354
|
+
const { bytesRead } = await file.read(buffer, 0, Math.min(buffer.length, maxBytes - bytes + 1), null);
|
|
355
|
+
if (bytesRead === 0)
|
|
356
|
+
break;
|
|
357
|
+
bytes += bytesRead;
|
|
358
|
+
if (bytes > maxBytes)
|
|
359
|
+
throw new CliError("validation_error", "input file exceeds its byte budget");
|
|
360
|
+
chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
|
|
361
|
+
}
|
|
362
|
+
try {
|
|
363
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes));
|
|
364
|
+
} catch {
|
|
365
|
+
throw new CliError("validation_error", "input file must contain valid UTF-8");
|
|
366
|
+
}
|
|
367
|
+
} finally {
|
|
368
|
+
await file.close();
|
|
380
369
|
}
|
|
381
|
-
|
|
382
|
-
}, "safeName");
|
|
370
|
+
}, "readBoundedUtf8File");
|
|
383
371
|
|
|
384
372
|
export {
|
|
385
373
|
writeFileAtomic,
|
|
@@ -387,6 +375,5 @@ export {
|
|
|
387
375
|
sameOrdinaryFile,
|
|
388
376
|
syncDirectory,
|
|
389
377
|
readBoundedUtf8File,
|
|
390
|
-
acquireLock
|
|
391
|
-
safeName
|
|
378
|
+
acquireLock
|
|
392
379
|
};
|