@wirecat/notion-cli 0.5.0 → 0.7.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 +47 -0
- package/README.md +5 -0
- package/contracts/wirecat.json +55 -2
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/agent-AILW4JPO.js +42 -0
- package/dist/bundle/{all-profiles-V37KCXH3.js → all-profiles-CKOACXTW.js} +64 -21
- package/dist/bundle/{anthropic-Q4S3BYXD.js → anthropic-DWBBVTU3.js} +6 -6
- package/dist/bundle/{app-server-43SR3ACI.js → app-server-BHFYNCDE.js} +86 -65
- package/dist/bundle/{bun-M3J2QTR3.js → bun-ICK2XT7J.js} +2 -2
- package/dist/bundle/{bun-sqlite-EJ3W2PSV.js → bun-sqlite-LU5V5Y4A.js} +7 -7
- package/dist/bundle/{chunk-KHWOLBHQ.js → chunk-2OZVCNU5.js} +2 -2
- package/dist/bundle/{chunk-O5YB7FQD.js → chunk-2RNJ2JP3.js} +4 -4
- package/dist/bundle/{chunk-TP7GDWVF.js → chunk-364ET7LV.js} +1 -1
- package/dist/bundle/{chunk-TDNURSU6.js → chunk-3AKMIKND.js} +19 -19
- package/dist/bundle/{chunk-O3DYRCIT.js → chunk-3DGHBXH2.js} +1 -1
- package/dist/bundle/chunk-3KOJNZH3.js +80 -0
- package/dist/bundle/{chunk-DSP36YHQ.js → chunk-3T3OAYL4.js} +2 -2
- package/dist/bundle/{chunk-W7HM2VGO.js → chunk-3YXYA6HB.js} +1 -1
- package/dist/bundle/chunk-3ZSUVFR7.js +398 -0
- package/dist/bundle/{chunk-GCZ6MAEN.js → chunk-46JBCXLI.js} +43 -64
- package/dist/bundle/{chunk-DB2XKHI4.js → chunk-4FHKSSXQ.js} +2 -2
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-BNEE35WD.js → chunk-5NFIUY2P.js} +4 -4
- package/dist/bundle/{chunk-E5WLE7BM.js → chunk-63SW4UXG.js} +3 -4
- package/dist/bundle/{chunk-NHHJHXMQ.js → chunk-64IK7JFO.js} +2 -2
- package/dist/bundle/{chunk-HZRQLAHO.js → chunk-6MQSBWWF.js} +1 -1
- package/dist/bundle/{chunk-2FJNMADN.js → chunk-6UZ5D2WP.js} +10 -10
- package/dist/bundle/chunk-6VPC5Z56.js +2145 -0
- package/dist/bundle/chunk-7COTHS6G.js +388 -0
- package/dist/bundle/{chunk-TOSCB4SO.js → chunk-A3RJ6FD5.js} +29 -10
- package/dist/bundle/chunk-ADCAWRRX.js +2366 -0
- package/dist/bundle/{chunk-PPHBRESD.js → chunk-ALAPDLCP.js} +2 -2
- package/dist/bundle/{chunk-ONZVPE24.js → chunk-B6DJQBZI.js} +6 -6
- package/dist/bundle/{chunk-N2XADGL4.js → chunk-BFCRGLOF.js} +4 -4
- package/dist/bundle/{chunk-5P5TXU2K.js → chunk-BFHPT67P.js} +9581 -10764
- package/dist/bundle/{chunk-NA6QLHBZ.js → chunk-BQ6CXCLP.js} +10 -8
- package/dist/bundle/{chunk-JCKWQGCD.js → chunk-BXXHUO7Y.js} +110 -862
- package/dist/bundle/chunk-DCSPCOPB.js +221 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/chunk-EMIJVLOA.js +30 -0
- package/dist/bundle/{chunk-DFCHHR5M.js → chunk-EUF5JNPG.js} +1 -1
- package/dist/bundle/{chunk-RIGE67FR.js → chunk-EWXMIKZN.js} +43 -33
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-QYXWRKNA.js → chunk-FHYV4VWY.js} +16 -9
- package/dist/bundle/{chunk-WE4UFASG.js → chunk-FNESLLZS.js} +29 -1
- package/dist/bundle/chunk-FO3XY2Y2.js +108 -0
- package/dist/bundle/chunk-HJDQTM3T.js +353 -0
- package/dist/bundle/chunk-HOO53OYK.js +561 -0
- package/dist/bundle/{chunk-KHZ2RGXI.js → chunk-HSVKU4OJ.js} +153 -572
- package/dist/bundle/{chunk-CDK5E45T.js → chunk-IEY7KS6Q.js} +2 -100
- package/dist/bundle/{chunk-RJMQGG3P.js → chunk-ITW26OBI.js} +65 -49
- package/dist/bundle/{chunk-FBZI4Z3Z.js → chunk-ITWINZ6R.js} +13 -26
- package/dist/bundle/{chunk-J3NKZ6MO.js → chunk-IYZWHCZJ.js} +155 -435
- package/dist/bundle/{chunk-W53EJOFQ.js → chunk-J3DZVB67.js} +1 -1
- package/dist/bundle/{chunk-FKA7DOCK.js → chunk-JEZJFQQW.js} +1 -1
- package/dist/bundle/chunk-JPGN473W.js +50 -0
- package/dist/bundle/{chunk-NTG657MI.js → chunk-JVRBW5LH.js} +7 -64
- package/dist/bundle/chunk-KBY42GKW.js +785 -0
- package/dist/bundle/{chunk-DO7BLXO3.js → chunk-KWBLDSRV.js} +16 -3
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-PWRRDDMZ.js → chunk-LBRTLZHI.js} +249 -555
- package/dist/bundle/{chunk-B3FSLAIU.js → chunk-LEPPRULN.js} +20 -6
- package/dist/bundle/{chunk-WPP76PSX.js → chunk-LVAFTQ45.js} +32 -24
- package/dist/bundle/{chunk-PAW6RRCW.js → chunk-MB4HXDBT.js} +8 -210
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/{chunk-UZSBGECU.js → chunk-N3NJPHZB.js} +1 -65
- package/dist/bundle/{chunk-BWLBSQSU.js → chunk-NCCRLAAI.js} +4 -4
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-H3E2PZ5Y.js → chunk-NV7NNL5T.js} +7 -7
- package/dist/bundle/chunk-OALFRUMI.js +67 -0
- package/dist/bundle/{chunk-CWXOXIWS.js → chunk-OCGNOJYD.js} +1 -1
- package/dist/bundle/chunk-OFMCU3BH.js +72 -0
- package/dist/bundle/{chunk-MGUEZYFA.js → chunk-OLAGFJDM.js} +13 -2143
- package/dist/bundle/{chunk-E2AFUJDR.js → chunk-OP2BH55P.js} +3 -3
- package/dist/bundle/{chunk-P5BHKKBI.js → chunk-OS4WPXPZ.js} +4 -4
- package/dist/bundle/{chunk-XUPN2EHR.js → chunk-OW5HW3TD.js} +23 -7
- package/dist/bundle/{chunk-ECC2UX7X.js → chunk-PDVXG3T3.js} +6 -6
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-G2MJYXZG.js → chunk-PSMRUOII.js} +4 -4
- package/dist/bundle/{chunk-DBEQI5YM.js → chunk-QK52ARAU.js} +3 -3
- package/dist/bundle/{chunk-QWYMXFKM.js → chunk-QMNEDK7Z.js} +3 -3
- package/dist/bundle/chunk-R4JV3VLU.js +714 -0
- package/dist/bundle/{chunk-C32AKHTY.js → chunk-REOBWSGV.js} +35 -12
- package/dist/bundle/{chunk-X2M6NIQG.js → chunk-RNVYNPXT.js} +1 -1
- package/dist/bundle/{chunk-HHVFIXDO.js → chunk-RXGX2CZX.js} +399 -399
- package/dist/bundle/{chunk-W5JZMXGW.js → chunk-S35UJBFZ.js} +75 -75
- package/dist/bundle/{chunk-MVA5HVKL.js → chunk-S4UUN6LD.js} +18 -0
- package/dist/bundle/chunk-S5P7THM5.js +72 -0
- package/dist/bundle/{chunk-NE43YXKL.js → chunk-SRVTGI3M.js} +3 -3
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/chunk-TWY543BS.js +39 -0
- package/dist/bundle/{chunk-KFVDL2QS.js → chunk-UC7JLE6J.js} +1 -89
- package/dist/bundle/{chunk-3RL2MIUF.js → chunk-UO4O6WQ4.js} +8 -8
- package/dist/bundle/chunk-UPL474OW.js +94 -0
- package/dist/bundle/chunk-UQVUXG7H.js +594 -0
- package/dist/bundle/chunk-UYEDQGMI.js +340 -0
- package/dist/bundle/chunk-VNWF4I7E.js +34 -0
- package/dist/bundle/{chunk-FPUGMDJV.js → chunk-VRBEYOJL.js} +1 -1
- package/dist/bundle/{chunk-BBSFQ3PU.js → chunk-VXKD533R.js} +1646 -1337
- package/dist/bundle/{chunk-ECEZOLOD.js → chunk-VYZ2J7DT.js} +4 -4
- package/dist/bundle/{chunk-TD2JZ25O.js → chunk-WJFQMOVM.js} +113 -80
- package/dist/bundle/{chunk-MNRMKWCN.js → chunk-WUNEJRLJ.js} +6 -6
- package/dist/bundle/chunk-WVN2KTNS.js +52 -0
- package/dist/bundle/{chunk-GTY6N5KZ.js → chunk-X5LUHN62.js} +2 -2
- package/dist/bundle/{chunk-LBYGJKXW.js → chunk-X737FHZP.js} +4 -4
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/chunk-YSF5JBRA.js +36 -0
- package/dist/bundle/{chunk-QIG55MZH.js → chunk-ZGUUP2T3.js} +12 -12
- package/dist/bundle/{chunk-AT5I34AN.js → chunk-ZMKAI3F3.js} +3 -3
- package/dist/bundle/command-contract-C2CF4QAH.js +41 -0
- package/dist/bundle/{command-server-entry-LJ627ZUA.js → command-server-entry-F3B2KSPO.js} +30 -27
- package/dist/bundle/{decode-PX2LZ5Y2.js → decode-FDHFF7GC.js} +6 -6
- package/dist/bundle/{definitions-M3U4UYHN.js → definitions-MB65223J.js} +72 -18
- package/dist/bundle/{dispatch-KOISQ5QJ.js → dispatch-IXKG5Z5Y.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-FVTUDXDU.js → echarts-PGJPVPA4.js} +2 -2
- package/dist/bundle/{embed-CCSDK43I.js → embed-U6X7CNNK.js} +7 -7
- package/dist/bundle/{embedder-VHI4DHB7.js → embedder-3ROL6ROQ.js} +10 -10
- package/dist/bundle/{failure-FZ6VYKEQ.js → failure-IYMRXM2X.js} +3 -3
- package/dist/bundle/first-run-PNVNHGR7.js +29 -0
- package/dist/bundle/first-screen-DEDD64YH.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-HET7BCYK.js → instructions-MJQWRI2D.js} +1 -1
- package/dist/bundle/{mcp-RGNRW77S.js → mcp-JNHOSK4L.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-HEC25QPY.js +25 -0
- package/dist/bundle/meeting-model-R7QPDNZZ.js +27 -0
- package/dist/bundle/{meeting-semantic-UD26T37N.js → meeting-semantic-7WPLMBNT.js} +7 -7
- package/dist/bundle/{micromark-extension-gfm-5X7YT43T.js → micromark-extension-gfm-PQ7DWZM7.js} +12 -78
- package/dist/bundle/{node-CXZIFHZC.js → node-3UXNV3CD.js} +2 -2
- package/dist/bundle/{node-sqlite-ME7KMORI.js → node-sqlite-ULWDWM3I.js} +8 -8
- package/dist/bundle/notes-search-7PE3E3C7.js +64 -0
- package/dist/bundle/notion.js +14 -14
- package/dist/bundle/oauth-LNUZMA72.js +20 -0
- package/dist/bundle/{open-HA6D3SXR.js → open-HGHC35M4.js} +6 -6
- package/dist/bundle/{openai-H5AJPZBX.js → openai-ISSP57MV.js} +21 -18
- package/dist/bundle/{process-5RUXWGYS.js → process-PB2WCOR2.js} +1 -1
- package/dist/bundle/{program-F3NBTZ7J.js → program-GASBJRMG.js} +7574 -7047
- package/dist/bundle/{prompt-6XSUOLHK.js → prompt-3VGQVX2B.js} +6 -6
- package/dist/bundle/{recognize-2Y7AUVGG.js → recognize-7Q2P3NME.js} +5 -5
- package/dist/bundle/{remote-KCABPXQ3.js → remote-BBAWKVIT.js} +12 -11
- package/dist/bundle/{rerank-BTN7LUVA.js → rerank-H4PUS4HV.js} +8 -8
- package/dist/bundle/{schemas-VVLTLMXS.js → schemas-TTVUADHT.js} +39 -60
- package/dist/bundle/{serve-CYEMVRFC.js → serve-FZNSKY7R.js} +11 -11
- package/dist/bundle/{server-WFIICGMI.js → server-BRRNDW6L.js} +78 -56
- package/dist/bundle/server-CQJ4LKAZ.js +90 -0
- package/dist/bundle/{services-L4W6ZWDG.js → services-PEU557KZ.js} +103 -88
- package/dist/bundle/{sqlite-runtime-IKMYLRQC.js → sqlite-runtime-4IZJ4YUM.js} +7 -7
- package/dist/bundle/{state-LMUP636P.js → state-MX3JVT5Q.js} +7 -7
- package/dist/bundle/{store-W2JC2JP4.js → store-JUT34REM.js} +24 -20
- package/dist/bundle/{store-A2QZFBOX.js → store-PP4BPADZ.js} +30 -18
- package/dist/bundle/store-maintenance-command-GRFTJBSB.js +77 -0
- package/dist/bundle/surface-FPWES3NY.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 -141
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/library.d.ts.map +1 -1
- package/dist/commands/library.js +14 -6
- 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/context.d.ts +11 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +20 -7
- package/dist/context.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.map +1 -1
- package/dist/generated/manifest.js +49 -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/generated/wirecat-config.d.ts +13 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +82 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/library.d.ts +3 -0
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +11 -1
- package/dist/library.js.map +1 -1
- package/dist/notion/client.d.ts +2 -6
- package/dist/notion/client.d.ts.map +1 -1
- package/dist/notion/client.js +7 -8
- package/dist/notion/client.js.map +1 -1
- package/dist/notion/errors.d.ts +5 -0
- package/dist/notion/errors.d.ts.map +1 -1
- package/dist/notion/errors.js +21 -1
- package/dist/notion/errors.js.map +1 -1
- package/dist/notion/port.d.ts +10 -0
- package/dist/notion/port.d.ts.map +1 -1
- package/dist/notion/port.js +19 -0
- package/dist/notion/port.js.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/sync/files.d.ts +12 -0
- package/dist/sync/files.d.ts.map +1 -1
- package/dist/sync/files.js.map +1 -1
- package/dist/sync/from-config.d.ts +13 -0
- package/dist/sync/from-config.d.ts.map +1 -0
- package/dist/sync/from-config.js +32 -0
- package/dist/sync/from-config.js.map +1 -0
- package/dist/sync/source.d.ts +2 -1
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +48 -48
- package/dist/sync/source.js.map +1 -1
- package/dist/sync/users.d.ts +4 -1
- package/dist/sync/users.d.ts.map +1 -1
- package/dist/sync/users.js +3 -1
- package/dist/sync/users.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -8
- package/dist/bundle/chunk-6EOZTUHT.js +0 -726
- package/dist/bundle/command-contract-TVRFW2IX.js +0 -38
- package/dist/bundle/first-run-7JKE5AHN.js +0 -29
- package/dist/bundle/first-screen-ZROHOEYJ.js +0 -38
- package/dist/bundle/meeting-combined-SSTOJUIJ.js +0 -24
- package/dist/bundle/meeting-model-K7TPS4S5.js +0 -26
- package/dist/bundle/oauth-XBTROXHB.js +0 -20
- package/dist/bundle/server-UC2FNNXX.js +0 -72
- package/dist/bundle/store-maintenance-command-LRGQJPSZ.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-LBRTLZHI.js";
|
|
6
|
+
import {
|
|
7
|
+
throughWrapper
|
|
8
|
+
} from "./chunk-EMIJVLOA.js";
|
|
9
|
+
import {
|
|
10
|
+
readOnlyLockOf
|
|
11
|
+
} from "./chunk-3ZSUVFR7.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-4FHKSSXQ.js";
|
|
25
|
+
import {
|
|
26
|
+
__name
|
|
27
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
28
|
+
|
|
29
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/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.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/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
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/longest-streak@3.1.0/node_modules/longest-streak/index.js
|
|
8
|
+
function longestStreak(value, substring) {
|
|
9
|
+
const source = String(value);
|
|
10
|
+
let index = source.indexOf(substring);
|
|
11
|
+
let expected = index;
|
|
12
|
+
let count = 0;
|
|
13
|
+
let max = 0;
|
|
14
|
+
if (typeof substring !== "string") {
|
|
15
|
+
throw new TypeError("Expected substring");
|
|
16
|
+
}
|
|
17
|
+
while (index !== -1) {
|
|
18
|
+
if (index === expected) {
|
|
19
|
+
if (++count > max) {
|
|
20
|
+
max = count;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
count = 1;
|
|
24
|
+
}
|
|
25
|
+
expected = index + substring.length;
|
|
26
|
+
index = source.indexOf(substring, expected);
|
|
27
|
+
}
|
|
28
|
+
return max;
|
|
29
|
+
}
|
|
30
|
+
__name(longestStreak, "longestStreak");
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
longestStreak
|
|
34
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
4
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/monthly.js
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
var CI_PAGE = join(dirname(fileURLToPath(new URL("standards/monthly.js", import.meta.resolve("@wirecat/cli-base")).href)), "../../docs/standards/ci.md");
|