@wirecat/zoom-cli 0.72.0 → 0.74.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/contracts/wirecat.json +1478 -0
- package/dist/account-removal.d.ts.map +1 -1
- package/dist/account-removal.js +0 -2
- package/dist/account-removal.js.map +1 -1
- package/dist/answers.d.ts +1 -3
- package/dist/answers.d.ts.map +1 -1
- package/dist/answers.js +0 -3
- package/dist/answers.js.map +1 -1
- package/dist/bin/main.js +13 -5
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/zm.js +2 -2
- package/dist/bundle/{all-profiles-XFIPF4GF.js → all-profiles-SDOAABLC.js} +12 -12
- package/dist/bundle/answer-policy-RHS74QYY.js +110 -0
- package/dist/bundle/{anthropic-SSUBR3BC.js → anthropic-HCVY2PIN.js} +7 -7
- package/dist/bundle/{app-server-7DJHHF2F.js → app-server-V64VS6KN.js} +65 -61
- package/dist/bundle/{bun-6HBYWQIX.js → bun-EBQHHLKR.js} +2 -2
- package/dist/bundle/{bun-sqlite-4L3Q55NB.js → bun-sqlite-PVMXO2JB.js} +7 -7
- package/dist/bundle/chunk-2PNG76LV.js +707 -0
- package/dist/bundle/chunk-2PYZTRRC.js +84 -0
- package/dist/bundle/{chunk-63QXCE5Z.js → chunk-3HTJBGNP.js} +10 -10
- package/dist/bundle/{chunk-5X4IY5JH.js → chunk-3ROL6MBJ.js} +1763 -762
- package/dist/bundle/{chunk-N4QNYWWG.js → chunk-3TYNBHBK.js} +2 -2
- package/dist/bundle/{chunk-7SUWPMZG.js → chunk-4ELLWJT4.js} +8 -8
- package/dist/bundle/{chunk-PJWSGXOB.js → chunk-4EZKR6Q4.js} +7 -7
- package/dist/bundle/{chunk-UVZLK3M4.js → chunk-4RJL32PF.js} +25 -10
- package/dist/bundle/{chunk-LTWJM3ED.js → chunk-5KDBLEUF.js} +17 -17
- package/dist/bundle/{chunk-7IFO43Q5.js → chunk-5R6EBM5Z.js} +2 -2
- package/dist/bundle/{chunk-OHCLQJOV.js → chunk-6EMOZGSN.js} +3 -3
- package/dist/bundle/{chunk-D24OQAHM.js → chunk-6GPBDVQ2.js} +4 -4
- package/dist/bundle/chunk-7NE3LB7A.js +25 -0
- package/dist/bundle/{chunk-VIV64MQM.js → chunk-7R4UU65O.js} +26 -17
- package/dist/bundle/{chunk-4XQWF3U2.js → chunk-7W23N2YW.js} +6 -6
- package/dist/bundle/{chunk-RN5SU2RN.js → chunk-AFUHT7F7.js} +6 -6
- package/dist/bundle/{chunk-SXZGCD6E.js → chunk-APLV37JA.js} +3 -3
- package/dist/bundle/{chunk-LLUNHAZ7.js → chunk-BKMC4ETU.js} +4 -4
- package/dist/bundle/{chunk-IACWKZWS.js → chunk-BOGGQOVO.js} +1 -1
- package/dist/bundle/{chunk-U3NJBGLA.js → chunk-DSRG5NRF.js} +185 -34
- package/dist/bundle/{chunk-X2MP634F.js → chunk-DXZN3DU6.js} +4 -4
- package/dist/bundle/{chunk-ELJUBPY4.js → chunk-EA2OB75T.js} +1 -1
- package/dist/bundle/{chunk-ZVFYGTGJ.js → chunk-F6PUM6ZK.js} +17 -17
- package/dist/bundle/{chunk-MCPOZNWG.js → chunk-FIVFP53N.js} +1 -1
- package/dist/bundle/{chunk-WOAYHCM2.js → chunk-FL2TKSZY.js} +1 -1
- package/dist/bundle/{chunk-RZUJMAMK.js → chunk-FT7X74RT.js} +4 -4
- package/dist/bundle/{chunk-ADLS6FVG.js → chunk-FXBHOCJK.js} +1 -1
- package/dist/bundle/{chunk-I7CUMZD6.js → chunk-FY2X6U6O.js} +3 -3
- package/dist/bundle/{chunk-W3YTVEWV.js → chunk-GPGIU3OG.js} +9 -9
- package/dist/bundle/{chunk-6DCLZLGX.js → chunk-HCZYJMBP.js} +1 -1
- package/dist/bundle/{chunk-IU4DUUB3.js → chunk-HGUYJUNO.js} +325 -14
- package/dist/bundle/{chunk-S7SXSHRC.js → chunk-HNWDEDMU.js} +61 -30
- package/dist/bundle/{chunk-NMZQTYKJ.js → chunk-HZUUVNWC.js} +1 -1
- package/dist/bundle/{chunk-7S4D5SM2.js → chunk-I2D4ZZOD.js} +31 -32
- package/dist/bundle/{chunk-XPWZSW6Y.js → chunk-IJCUAKR5.js} +4 -4
- package/dist/bundle/{chunk-QQUY4MZY.js → chunk-IJONJTST.js} +1 -1
- package/dist/bundle/chunk-IS6FUZCP.js +73 -0
- package/dist/bundle/{chunk-ZW5KHKMA.js → chunk-IZUOL4Q6.js} +5 -5
- package/dist/bundle/{chunk-H53WFZBN.js → chunk-KBRIMLVN.js} +12 -12
- package/dist/bundle/{chunk-2MIBRVSV.js → chunk-KCPRTZBZ.js} +2 -2
- package/dist/bundle/chunk-KYL5FYOW.js +13 -0
- package/dist/bundle/{chunk-4SY67IUA.js → chunk-LHPYSVGP.js} +26 -35
- package/dist/bundle/{chunk-JG4MNYG2.js → chunk-LN2LWPN2.js} +1 -1
- package/dist/bundle/{chunk-CW46FWKW.js → chunk-LQR4V5EY.js} +14 -12
- package/dist/bundle/{chunk-B3SILJBU.js → chunk-LUBG5GKK.js} +30 -22
- package/dist/bundle/{chunk-3KRTEX5M.js → chunk-LZ4AVHBS.js} +3 -2
- package/dist/bundle/{chunk-RX5CJ55S.js → chunk-M4OP5ASJ.js} +1 -1
- package/dist/bundle/{chunk-FSCPQQS5.js → chunk-MAE5UGRQ.js} +150 -93
- package/dist/bundle/{chunk-KPIQXFNB.js → chunk-N7KCNMKL.js} +16 -15
- package/dist/bundle/{chunk-RLCVPECY.js → chunk-NKBMLSWK.js} +110 -64
- package/dist/bundle/{chunk-T27IMG6X.js → chunk-NV2REPY6.js} +1 -1
- package/dist/bundle/{chunk-EFF2XBHP.js → chunk-OP6HK2QL.js} +2 -2
- package/dist/bundle/{chunk-WLVG4RBZ.js → chunk-OPUGV7VW.js} +15 -2
- package/dist/bundle/{chunk-5AELTC52.js → chunk-P53CLAXD.js} +103 -102
- package/dist/bundle/{chunk-KWURWGGB.js → chunk-PKM2UKAZ.js} +32 -9
- package/dist/bundle/{chunk-7JYMGXLI.js → chunk-PMHMKZEJ.js} +47 -43
- package/dist/bundle/{chunk-23J2ANZ7.js → chunk-QAGSAOYS.js} +2 -2
- package/dist/bundle/{chunk-JZ4XNNL7.js → chunk-QLKCKTM4.js} +1 -1
- package/dist/bundle/{chunk-OP5PGE2N.js → chunk-QSWR7VDA.js} +4 -4
- package/dist/bundle/{chunk-LA6QUVGQ.js → chunk-R35YGFKQ.js} +163 -16
- package/dist/bundle/{chunk-CANRIRNZ.js → chunk-R4J4DLJV.js} +1792 -1205
- package/dist/bundle/{chunk-QW7YTRV2.js → chunk-RJJ4OYNH.js} +3 -3
- package/dist/bundle/{chunk-DOCVEKP2.js → chunk-RQJ2RXFO.js} +37 -35
- package/dist/bundle/{chunk-TF2WKPNW.js → chunk-RRW54FK6.js} +17 -17
- package/dist/bundle/{chunk-KFZL67JP.js → chunk-SKDQNYKA.js} +129 -48
- package/dist/bundle/{chunk-7GLJSJ7M.js → chunk-SPWKGRTO.js} +1 -1
- package/dist/bundle/{chunk-MSQHSW4C.js → chunk-SY4MIIWF.js} +2 -2
- package/dist/bundle/{chunk-ZHA56THL.js → chunk-TKPIDOW5.js} +927 -904
- package/dist/bundle/{chunk-WXTYYWZI.js → chunk-TLNZUPGU.js} +115 -113
- package/dist/bundle/{chunk-WZGKHTA4.js → chunk-TMCXUWTY.js} +8 -2
- package/dist/bundle/{chunk-7OD3522V.js → chunk-TN2YUZBF.js} +1192 -496
- package/dist/bundle/{chunk-JFPUYQSP.js → chunk-UGLNVUFX.js} +5 -5
- package/dist/bundle/{chunk-IFBIXU6C.js → chunk-UVWNUY3W.js} +2 -2
- package/dist/bundle/{chunk-5MGICK47.js → chunk-UW3BB2XW.js} +26 -26
- package/dist/bundle/{chunk-24OFZNRC.js → chunk-UXSTXFZQ.js} +5168 -4245
- package/dist/bundle/{chunk-U32VL3MA.js → chunk-WRRGO246.js} +3 -2
- package/dist/bundle/{chunk-QA6KIL7Q.js → chunk-WYV5IITK.js} +11 -8
- package/dist/bundle/{chunk-D5EUMWD5.js → chunk-X2FILY5F.js} +3 -3
- package/dist/bundle/{chunk-4YIGXTBP.js → chunk-XCC7R47Z.js} +3 -3
- package/dist/bundle/{chunk-37NF5CBJ.js → chunk-XFT3YIHU.js} +6 -8
- package/dist/bundle/{chunk-IXO4SCKE.js → chunk-XGEPAJBY.js} +1 -1
- package/dist/bundle/chunk-XWBPP2HX.js +2 -0
- package/dist/bundle/{chunk-RJTGENHZ.js → chunk-Y4KWWPIO.js} +4 -7
- package/dist/bundle/{chunk-DEPXZJ2V.js → chunk-YFLTHGB3.js} +17 -13
- package/dist/bundle/{chunk-JRCH4YZP.js → chunk-YM6ZATEK.js} +17 -121
- package/dist/bundle/{chunk-ADKMBXY4.js → chunk-YNI57LTZ.js} +1 -1
- package/dist/bundle/{chunk-ERJYJ36F.js → chunk-ZMHZ6CQS.js} +2 -2
- package/dist/bundle/{chunk-M3DMXDX6.js → chunk-ZYMTS3CI.js} +6 -6
- package/dist/bundle/{cli-IYYI7GAM.js → cli-5ALOQCAC.js} +152 -123
- package/dist/bundle/command-contract-WO5QJVLZ.js +41 -0
- package/dist/bundle/{command-server-entry-FXX4LJWF.js → command-server-entry-ICOMIJIH.js} +33 -33
- package/dist/bundle/config-YQA5TJ7Y.js +97 -0
- package/dist/bundle/{decode-SRGOOGBW.js → decode-7LFOROWF.js} +6 -6
- package/dist/bundle/{dispatch-OUHRPFUL.js → dispatch-EU67WGME.js} +9 -9
- package/dist/bundle/{dist-UZLNLAIO.js → dist-KJOOYNCP.js} +25 -22
- package/dist/bundle/{echarts-7CM2MCMW.js → echarts-EJXBKCJT.js} +2 -2
- package/dist/bundle/{embed-VEE56BOB.js → embed-TOZCKRRO.js} +7 -7
- package/dist/bundle/{embedder-SZFYR543.js → embedder-QKEKUCS5.js} +10 -10
- package/dist/bundle/{failure-MZBNM7M5.js → failure-CTJLEB2R.js} +3 -3
- package/dist/bundle/first-run-S7CQVGK6.js +29 -0
- package/dist/bundle/first-screen-6GW6FD6S.js +39 -0
- package/dist/bundle/folders-MSBTAPAG.js +24 -0
- package/dist/bundle/{instructions-R7OHVAWH.js → instructions-Z7GVGWXS.js} +1 -1
- package/dist/bundle/{main-EFUN2O3K.js → main-RL3GC4OX.js} +39 -26
- package/dist/bundle/{mcp-7KQUJNFN.js → mcp-TDKGDB4V.js} +2 -2
- package/dist/bundle/{meetings-5I2BDNTA.js → meetings-JCMLE5AO.js} +9 -7
- package/dist/bundle/{node-P4E63KXA.js → node-KM3CUABH.js} +9 -9
- package/dist/bundle/{node-3N2JGZ7V.js → node-L2PVEW3N.js} +2 -2
- package/dist/bundle/{node-sqlite-2UVEE2WM.js → node-sqlite-4YW3W4XI.js} +10 -10
- package/dist/bundle/{oauth-AYGD7UU3.js → oauth-NNHWAT6A.js} +8 -8
- package/dist/bundle/{open-3GUVDLGD.js → open-PF2JHJIY.js} +6 -6
- package/dist/bundle/openai-C72ADYMD.js +28 -0
- package/dist/bundle/{output-file-72JFXVHQ.js → output-file-VDOCYH2G.js} +6 -6
- package/dist/bundle/{process-YAHHUFR5.js → process-MNZTQ2DA.js} +1 -1
- package/dist/bundle/{program-OSZROCTK.js → program-FOCBZZZS.js} +146 -151
- package/dist/bundle/{prompt-HMCW4XQJ.js → prompt-RBSUKMV7.js} +6 -6
- package/dist/bundle/{recognize-VF5CA7EM.js → recognize-RM6TQKK3.js} +5 -5
- package/dist/bundle/{remote-5C6VTPR2.js → remote-UKHTU3YR.js} +11 -10
- package/dist/bundle/{rerank-ER7NEDOI.js → rerank-3LBRVESU.js} +8 -8
- package/dist/bundle/run-log-UXINNGKA.js +124 -0
- package/dist/bundle/{serve-QJWXJOM7.js → serve-OOZFTW3W.js} +10 -10
- package/dist/bundle/server-DM5ZPFZB.js +75 -0
- package/dist/bundle/{server-KCIK3Y2P.js → server-YNQPNIJD.js} +52 -50
- package/dist/bundle/{services-LQMYJQG3.js → services-SLEOMN4B.js} +61 -44
- package/dist/bundle/{speech-74GJQNQH.js → speech-FZZ6QVGU.js} +20 -20
- package/dist/bundle/sqlite-runtime-WUR4PWYB.js +20 -0
- package/dist/bundle/{state-4XDGCHDF.js → state-ET36L4TY.js} +7 -7
- package/dist/bundle/{store-5Y5HK2L2.js → store-DI6OUBXA.js} +20 -20
- package/dist/bundle/{store-Y56AHJ2Y.js → store-SQB2DOVJ.js} +34 -28
- package/dist/bundle/store-connection-M6LVRAZ5.js +90 -0
- package/dist/bundle/store-maintenance-command-B66KWG6K.js +65 -0
- package/dist/bundle/{streaming-E5CR6HSR.js → streaming-PQEXKTE5.js} +7 -7
- package/dist/bundle/tokens-SUHRRQ25.js +24 -0
- package/dist/bundle/zm.js +9 -9
- package/dist/bundle/{zoom-app-NVL7HEAX.js → zoom-app-GE4SSHOP.js} +9 -8
- package/dist/folders.d.ts +12 -2
- package/dist/folders.d.ts.map +1 -1
- package/dist/folders.js +81 -3
- package/dist/folders.js.map +1 -1
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +14 -0
- package/dist/identity.js.map +1 -1
- package/dist/recording-schedule-setup.d.ts.map +1 -1
- package/dist/recording-schedule-setup.js +4 -7
- package/dist/recording-schedule-setup.js.map +1 -1
- package/dist/remote-http.d.ts +1 -1
- package/dist/remote-http.d.ts.map +1 -1
- package/dist/remote-http.js +21 -23
- package/dist/remote-http.js.map +1 -1
- package/dist/setup-commands.d.ts.map +1 -1
- package/dist/setup-commands.js +2 -4
- package/dist/setup-commands.js.map +1 -1
- package/dist/tokens.d.ts +17 -2
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +109 -29
- package/dist/tokens.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +15 -14
- package/dist/bundle/answer-policy-AT6CDEE5.js +0 -110
- package/dist/bundle/chunk-EG25AY4L.js +0 -17
- package/dist/bundle/chunk-JAEPK457.js +0 -997
- package/dist/bundle/chunk-K6HR6HCO.js +0 -32
- package/dist/bundle/chunk-OY6N2ABP.js +0 -1239
- package/dist/bundle/chunk-YVVJ6Y5C.js +0 -153
- package/dist/bundle/command-contract-TX7NSUBM.js +0 -42
- package/dist/bundle/config-YKNM33J7.js +0 -96
- package/dist/bundle/first-run-KWC7RKF2.js +0 -29
- package/dist/bundle/first-screen-DWKMNSEI.js +0 -40
- package/dist/bundle/folders-UQXRSDJJ.js +0 -16
- package/dist/bundle/openai-NHCDLWWY.js +0 -28
- package/dist/bundle/run-log-JKTLKXSK.js +0 -124
- package/dist/bundle/server-LLGFDLLJ.js +0 -75
- package/dist/bundle/store-connection-4WI32AYU.js +0 -89
- package/dist/bundle/store-maintenance-command-PCXO5AH4.js +0 -65
- package/dist/bundle/tokens-E2QNVC4F.js +0 -20
- /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-7O7XM37N.js} +0 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
AUDIT_MIN_SCORE,
|
|
5
|
+
LIST_QUERY_GUIDE,
|
|
6
|
+
nativeTerms,
|
|
7
|
+
throughWrapper
|
|
8
|
+
} from "./chunk-3ROL6MBJ.js";
|
|
9
|
+
import {
|
|
10
|
+
environmentOf,
|
|
11
|
+
itemOf,
|
|
12
|
+
listOf,
|
|
13
|
+
nextStep,
|
|
14
|
+
renderAnswer,
|
|
15
|
+
snakeKeys
|
|
16
|
+
} from "./chunk-TN2YUZBF.js";
|
|
17
|
+
import {
|
|
18
|
+
readOnlyLockOf
|
|
19
|
+
} from "./chunk-3TYNBHBK.js";
|
|
20
|
+
import {
|
|
21
|
+
formatReference
|
|
22
|
+
} from "./chunk-7R4UU65O.js";
|
|
23
|
+
import {
|
|
24
|
+
queryError
|
|
25
|
+
} from "./chunk-3HTJBGNP.js";
|
|
26
|
+
import {
|
|
27
|
+
array,
|
|
28
|
+
boolean,
|
|
29
|
+
check,
|
|
30
|
+
pipe,
|
|
31
|
+
record,
|
|
32
|
+
safeParse,
|
|
33
|
+
strictObject,
|
|
34
|
+
string
|
|
35
|
+
} from "./chunk-4RJL32PF.js";
|
|
36
|
+
import {
|
|
37
|
+
CliError
|
|
38
|
+
} from "./chunk-EA2OB75T.js";
|
|
39
|
+
import {
|
|
40
|
+
__name
|
|
41
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
42
|
+
|
|
43
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/messenger/lacks.js
|
|
44
|
+
var COMMAND_NEEDS = {
|
|
45
|
+
"account update": ["updateProfile", "change the profile"],
|
|
46
|
+
"account sessions list": ["sessions", "list the account's sessions"],
|
|
47
|
+
"account sessions end": ["endOtherSessions", "end other sessions"],
|
|
48
|
+
"chats events": ["chatEvents", "read who joined or left"],
|
|
49
|
+
"chats inspect": ["inspect", "read a link"],
|
|
50
|
+
"chats folders list": ["folders", "list its folders"],
|
|
51
|
+
"chats folders show": ["folders", "list its folders"],
|
|
52
|
+
"chats folders create": ["createFolder", "create a folder"],
|
|
53
|
+
"chats folders update": ["updateFolder", "change a folder"],
|
|
54
|
+
"chats folders delete": ["deleteFolder", "delete a folder"],
|
|
55
|
+
"contacts add": ["addContact", "add a contact"],
|
|
56
|
+
"contacts remove": ["removeContact", "remove a contact"],
|
|
57
|
+
"contacts rename": ["renameContact", "rename a contact"],
|
|
58
|
+
"contacts import": ["importContacts", "import contacts"],
|
|
59
|
+
"messages comments": ["comments", "read comments on a channel post"],
|
|
60
|
+
"messages pin": ["pin", "pin a message"],
|
|
61
|
+
"messages unpin": ["unpin", "unpin a message"]
|
|
62
|
+
};
|
|
63
|
+
var STORE_ANSWERS = /* @__PURE__ */ new Set(["chats events"]);
|
|
64
|
+
var lackedNeed = /* @__PURE__ */ __name((messenger, path) => {
|
|
65
|
+
const need = COMMAND_NEEDS[path];
|
|
66
|
+
if (!need)
|
|
67
|
+
return void 0;
|
|
68
|
+
if (path === "messages comments" && (messenger?.readsComments ?? messenger?.channelComments) === false)
|
|
69
|
+
return need;
|
|
70
|
+
if (!messenger?.lacks?.includes(need[0]) && !messenger?.never?.includes(need[0]))
|
|
71
|
+
return void 0;
|
|
72
|
+
return messenger.history === "store" && STORE_ANSWERS.has(path) ? void 0 : need;
|
|
73
|
+
}, "lackedNeed");
|
|
74
|
+
var refuseLacking = /* @__PURE__ */ __name((messenger, path) => {
|
|
75
|
+
const need = lackedNeed(messenger, path.join(" "));
|
|
76
|
+
if (need)
|
|
77
|
+
throw new CliError("validation_error", `this messenger cannot ${need[1]}`);
|
|
78
|
+
}, "refuseLacking");
|
|
79
|
+
var hideNever = /* @__PURE__ */ __name((messenger, group) => {
|
|
80
|
+
const walk = /* @__PURE__ */ __name((command, path) => {
|
|
81
|
+
for (const child of command.commands) {
|
|
82
|
+
const at = [...path, child.name()];
|
|
83
|
+
const need = COMMAND_NEEDS[at.join(" ")];
|
|
84
|
+
if (need && messenger.never?.includes(need[0]))
|
|
85
|
+
child._hidden = true;
|
|
86
|
+
walk(child, at);
|
|
87
|
+
}
|
|
88
|
+
}, "walk");
|
|
89
|
+
walk(group, [group.name()]);
|
|
90
|
+
return group;
|
|
91
|
+
}, "hideNever");
|
|
92
|
+
|
|
93
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/paging.js
|
|
94
|
+
var positiveCount = /* @__PURE__ */ __name((flag) => (value) => {
|
|
95
|
+
if (!/^\d+$/.test(value.trim()) || Number(value) < 1)
|
|
96
|
+
throw new CliError("validation_error", `${flag} takes a whole number from 1 upwards, not "${value}"`);
|
|
97
|
+
return Number(value);
|
|
98
|
+
}, "positiveCount");
|
|
99
|
+
var withPaging = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")).option("--all", "every row, no paging"), "withPaging");
|
|
100
|
+
var window = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { offset: 0 } : { limit, offset: (page - 1) * limit }, "window");
|
|
101
|
+
|
|
102
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/messenger/chat-answers.js
|
|
103
|
+
var defined = /* @__PURE__ */ __name((record2) => Object.fromEntries(Object.entries(record2).filter(([, value]) => value !== void 0)), "defined");
|
|
104
|
+
var chatRef = /* @__PURE__ */ __name((account, chat) => formatReference({ type: "chat", provider: account.provider, account: account.account, chat }), "chatRef");
|
|
105
|
+
var settingsOf = /* @__PURE__ */ __name((settings) => defined({
|
|
106
|
+
all_can_pin: settings.allCanPin,
|
|
107
|
+
only_admins_add: settings.onlyAdminsAdd,
|
|
108
|
+
only_admins_call: settings.onlyAdminsCall,
|
|
109
|
+
only_owner_edits_info: settings.onlyOwnerEditsInfo,
|
|
110
|
+
members_see_link: settings.membersSeeLink,
|
|
111
|
+
join_approval: settings.joinApproval,
|
|
112
|
+
only_admins_send: settings.onlyAdminsSend,
|
|
113
|
+
only_admins_edit_info: settings.onlyAdminsEditInfo,
|
|
114
|
+
disappearing_seconds: settings.disappearingSeconds
|
|
115
|
+
}), "settingsOf");
|
|
116
|
+
var chatAnswer = /* @__PURE__ */ __name((account, chat) => defined({
|
|
117
|
+
ref: chatRef(account, chat.id),
|
|
118
|
+
id: chat.id,
|
|
119
|
+
title: chat.title,
|
|
120
|
+
kind: chat.kind,
|
|
121
|
+
unread_count: chat.unreadCount,
|
|
122
|
+
unread_mentions: chat.unreadMentions,
|
|
123
|
+
last_message_at: chat.lastMessageAt,
|
|
124
|
+
participants_count: chat.participantsCount,
|
|
125
|
+
muted: chat.muted,
|
|
126
|
+
muted_until: chat.mutedUntil ?? void 0,
|
|
127
|
+
archived: chat.archived,
|
|
128
|
+
marked_unread: chat.markedUnread,
|
|
129
|
+
membership_state: chat.membershipState,
|
|
130
|
+
parent_chat_id: chat.parentChatId ?? void 0,
|
|
131
|
+
scope: chat.scope,
|
|
132
|
+
provider_metadata: chat.providerMetadata,
|
|
133
|
+
description: chat.description,
|
|
134
|
+
invite_link: chat.link,
|
|
135
|
+
settings: chat.settings ? settingsOf(chat.settings) : void 0,
|
|
136
|
+
members: chat.members?.map(memberAnswer)
|
|
137
|
+
}), "chatAnswer");
|
|
138
|
+
var memberAnswer = /* @__PURE__ */ __name((member) => {
|
|
139
|
+
const group = member;
|
|
140
|
+
return defined({
|
|
141
|
+
id: member.id,
|
|
142
|
+
name: member.name,
|
|
143
|
+
username: member.username,
|
|
144
|
+
role: group.role,
|
|
145
|
+
last_seen_at: group.lastSeenAt,
|
|
146
|
+
registered_at: group.registeredAt,
|
|
147
|
+
joined_at: group.joinedAt,
|
|
148
|
+
invited_by: group.invitedBy,
|
|
149
|
+
is_bot: group.isBot,
|
|
150
|
+
deleted: group.deleted,
|
|
151
|
+
flagged: group.flagged,
|
|
152
|
+
has_photo: group.hasPhoto,
|
|
153
|
+
score: group.score,
|
|
154
|
+
reasons: group.reasons,
|
|
155
|
+
check: group.check ? snakeKeys(group.check) : void 0
|
|
156
|
+
});
|
|
157
|
+
}, "memberAnswer");
|
|
158
|
+
var contactRef = /* @__PURE__ */ __name((provider, id) => formatReference({ type: "contact", provider, id }), "contactRef");
|
|
159
|
+
var contactAnswer = /* @__PURE__ */ __name((account, contact) => {
|
|
160
|
+
const card = contact;
|
|
161
|
+
return defined({
|
|
162
|
+
ref: contactRef(account.provider, contact.id),
|
|
163
|
+
id: contact.id,
|
|
164
|
+
name: contact.name,
|
|
165
|
+
username: contact.username,
|
|
166
|
+
alias: contact.alias,
|
|
167
|
+
display_name: contact.displayName,
|
|
168
|
+
description: contact.description,
|
|
169
|
+
last_messaged_at: contact.lastMessagedAt,
|
|
170
|
+
chats: card.chats?.map((chat) => ({
|
|
171
|
+
ref: chatRef(account, chat.id),
|
|
172
|
+
id: chat.id,
|
|
173
|
+
title: chat.title,
|
|
174
|
+
kind: chat.kind,
|
|
175
|
+
last_message_at: chat.lastMessageAt
|
|
176
|
+
})),
|
|
177
|
+
notes: card.notes?.map(({ id, text, revision, createdAt, updatedAt }) => ({
|
|
178
|
+
id,
|
|
179
|
+
text,
|
|
180
|
+
revision,
|
|
181
|
+
created_at: createdAt,
|
|
182
|
+
updated_at: updatedAt
|
|
183
|
+
}))
|
|
184
|
+
});
|
|
185
|
+
}, "contactAnswer");
|
|
186
|
+
var contactShown = /* @__PURE__ */ __name((account, card, profile) => {
|
|
187
|
+
const { id: _id, name: _name, bio, chats, ...facts } = profile;
|
|
188
|
+
const listed = new Map(card.chats.map((chat) => [chat.id, chat]));
|
|
189
|
+
const active = new Set(chats.map(({ id }) => id));
|
|
190
|
+
const shared = [
|
|
191
|
+
...chats.map((chat) => ({
|
|
192
|
+
ref: chatRef(account, chat.id),
|
|
193
|
+
id: chat.id,
|
|
194
|
+
title: chat.title,
|
|
195
|
+
kind: chat.kind,
|
|
196
|
+
last_message_at: listed.get(chat.id)?.lastMessageAt ?? chat.lastAt,
|
|
197
|
+
their_messages: chat.theirMessages,
|
|
198
|
+
first_at: chat.firstAt,
|
|
199
|
+
last_at: chat.lastAt,
|
|
200
|
+
complete: chat.complete
|
|
201
|
+
})),
|
|
202
|
+
...card.chats.filter(({ id }) => !active.has(id)).map((chat) => ({
|
|
203
|
+
ref: chatRef(account, chat.id),
|
|
204
|
+
id: chat.id,
|
|
205
|
+
title: chat.title,
|
|
206
|
+
kind: chat.kind,
|
|
207
|
+
last_message_at: chat.lastMessageAt
|
|
208
|
+
}))
|
|
209
|
+
];
|
|
210
|
+
const answer = contactAnswer(account, card);
|
|
211
|
+
return {
|
|
212
|
+
...answer,
|
|
213
|
+
...snakeKeys(facts),
|
|
214
|
+
description: answer.description ?? bio,
|
|
215
|
+
chats: shared
|
|
216
|
+
};
|
|
217
|
+
}, "contactShown");
|
|
218
|
+
var chatEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
|
|
219
|
+
chat_id: chatId,
|
|
220
|
+
time: event.timestamp,
|
|
221
|
+
type: event.event,
|
|
222
|
+
message_id: event.messageId,
|
|
223
|
+
by: event.by,
|
|
224
|
+
people: event.people,
|
|
225
|
+
title: event.title
|
|
226
|
+
}), "chatEventAnswer");
|
|
227
|
+
var HISTORY_TYPES = { joined: "join", left: "leave", changed: "profile" };
|
|
228
|
+
var memberEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
|
|
229
|
+
chat_id: chatId,
|
|
230
|
+
time: event.at,
|
|
231
|
+
type: HISTORY_TYPES[event.event],
|
|
232
|
+
by: event.invitedBy === void 0 ? void 0 : { id: event.invitedBy, name: null },
|
|
233
|
+
people: [{ id: event.id, name: event.name, username: event.username }],
|
|
234
|
+
before: event.before ? { name: event.before.name, username: event.before.username } : void 0
|
|
235
|
+
}), "memberEventAnswer");
|
|
236
|
+
var inviteLinkAnswer = /* @__PURE__ */ __name((link) => defined({
|
|
237
|
+
link: link.link,
|
|
238
|
+
approval: link.approval,
|
|
239
|
+
expires_at: link.expiresAt,
|
|
240
|
+
max_uses: link.maxUses,
|
|
241
|
+
primary: link.primary,
|
|
242
|
+
revoked: link.revoked,
|
|
243
|
+
pending_count: link.pending,
|
|
244
|
+
joined_count: link.joined
|
|
245
|
+
}), "inviteLinkAnswer");
|
|
246
|
+
var joinRequestAnswer = /* @__PURE__ */ __name((request) => defined({
|
|
247
|
+
person_id: request.person.id,
|
|
248
|
+
name: request.person.name,
|
|
249
|
+
username: request.person.username,
|
|
250
|
+
requested_at: request.requestedAt,
|
|
251
|
+
about: request.about
|
|
252
|
+
}), "joinRequestAnswer");
|
|
253
|
+
var pollVoteAnswer = /* @__PURE__ */ __name((vote) => ({
|
|
254
|
+
person_id: vote.person.id,
|
|
255
|
+
name: vote.person.name,
|
|
256
|
+
username: vote.person.username,
|
|
257
|
+
answers: vote.answers,
|
|
258
|
+
voted_at: vote.votedAt
|
|
259
|
+
}), "pollVoteAnswer");
|
|
260
|
+
var reactorAnswer = /* @__PURE__ */ __name((reactor) => ({
|
|
261
|
+
person: { id: reactor.person.id, name: reactor.person.name, username: reactor.person.username },
|
|
262
|
+
reaction: reactor.reaction,
|
|
263
|
+
reacted_at: reactor.reactedAt
|
|
264
|
+
}), "reactorAnswer");
|
|
265
|
+
var topicAnswer = /* @__PURE__ */ __name((topic) => defined({
|
|
266
|
+
id: topic.id,
|
|
267
|
+
title: topic.title,
|
|
268
|
+
closed: topic.closed,
|
|
269
|
+
pinned: topic.pinned,
|
|
270
|
+
hidden: topic.hidden,
|
|
271
|
+
unread_count: topic.unreadCount,
|
|
272
|
+
last_message_at: topic.lastMessageAt,
|
|
273
|
+
created_at: topic.createdAt,
|
|
274
|
+
untrusted: ["title"]
|
|
275
|
+
}), "topicAnswer");
|
|
276
|
+
var folderAnswer = /* @__PURE__ */ __name((folder) => {
|
|
277
|
+
const shown = "chats" in folder ? folder : void 0;
|
|
278
|
+
const listed = shown ? void 0 : folder;
|
|
279
|
+
return defined({
|
|
280
|
+
id: folder.id,
|
|
281
|
+
title: folder.title,
|
|
282
|
+
chat_ids: listed ? listed.chatIds : shown?.chats.map((chat) => chat.id) ?? [],
|
|
283
|
+
emoji: folder.emoji,
|
|
284
|
+
include: folder.include,
|
|
285
|
+
skip: folder.skip,
|
|
286
|
+
excluded_chat_ids: listed?.excludedChatIds ?? shown?.excluded.map((chat) => chat.id),
|
|
287
|
+
pinned_chat_ids: listed?.pinnedChatIds ?? shown?.pinned.map((chat) => chat.id),
|
|
288
|
+
chats: shown?.chats,
|
|
289
|
+
pinned_chats: shown?.pinned,
|
|
290
|
+
excluded_chats: shown?.excluded
|
|
291
|
+
});
|
|
292
|
+
}, "folderAnswer");
|
|
293
|
+
var lines = /* @__PURE__ */ __name((line) => (body) => (body.items ?? (body.item === void 0 ? [] : [body.item])).map((item) => `${line(item).trimEnd()}
|
|
294
|
+
`).join(""), "lines");
|
|
295
|
+
var pageOf = /* @__PURE__ */ __name(({ limit, page, all }, { items, hasMore }) => all ? { limit: Math.max(1, items.length), has_more: false, page: 1 } : { limit, has_more: hasMore, page }, "pageOf");
|
|
296
|
+
var wholeList = /* @__PURE__ */ __name((command, items, extra = {}) => listOf(command, { items, limit: Math.max(1, items.length), has_more: false, ...extra }), "wholeList");
|
|
297
|
+
var chatShown = /* @__PURE__ */ __name((account, card) => {
|
|
298
|
+
const listed = card.members?.length;
|
|
299
|
+
const short = listed !== void 0 && card.participantsCount !== null && listed < card.participantsCount;
|
|
300
|
+
return itemOf(chatAnswer(account, card), short ? {
|
|
301
|
+
missing: [
|
|
302
|
+
{
|
|
303
|
+
field: "members",
|
|
304
|
+
why: `${listed} listed; the chat reports ${card.participantsCount} \u2014 the list may omit your account or be partial`,
|
|
305
|
+
step: "chats.members"
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
next: [nextStep("chats.members", { args: { chat: card.id } })]
|
|
309
|
+
} : {});
|
|
310
|
+
}, "chatShown");
|
|
311
|
+
var scoreFloor = /* @__PURE__ */ __name((ast) => {
|
|
312
|
+
const term = nativeTerms(ast, "chats members check").get("score");
|
|
313
|
+
if (!term)
|
|
314
|
+
return AUDIT_MIN_SCORE;
|
|
315
|
+
const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
|
|
316
|
+
if (term.operator !== "range" || upper !== "*")
|
|
317
|
+
queryError("query.unsupported-operator", term.span, "score takes a lower bound: score>=3", {
|
|
318
|
+
command: "chats members check",
|
|
319
|
+
guide: LIST_QUERY_GUIDE
|
|
320
|
+
});
|
|
321
|
+
const floor = Number(term.value);
|
|
322
|
+
return Math.ceil(term.lower_inclusive === false ? floor + 1 : floor);
|
|
323
|
+
}, "scoreFloor");
|
|
324
|
+
var auditAnswer = /* @__PURE__ */ __name((audit) => wholeList("chats members check", audit.items.map(memberAnswer), {
|
|
325
|
+
...audit.more ? { meta: { truncated: true } } : {},
|
|
326
|
+
...audit.completeness && audit.completeness.state !== "complete" ? {
|
|
327
|
+
missing: [
|
|
328
|
+
{
|
|
329
|
+
field: "reasons",
|
|
330
|
+
why: "never_wrote counts only stored messages, and the store does not hold the chat whole",
|
|
331
|
+
...audit.fetch ? { step: "messages.sync" } : {}
|
|
332
|
+
}
|
|
333
|
+
],
|
|
334
|
+
...audit.fetch ? { next: [nextStep("messages.sync", { args: { chat: audit.chatId } })] } : {}
|
|
335
|
+
} : {}
|
|
336
|
+
}), "auditAnswer");
|
|
337
|
+
var renderItem = /* @__PURE__ */ __name((command, output, value, next = []) => renderAnswer(command, output, itemOf(snakeKeys(value), { next })), "renderItem");
|
|
338
|
+
var withPage = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")), "withPage");
|
|
339
|
+
var documentLinkAnswer = /* @__PURE__ */ __name(({ url, documentId, title, inStore, locator, sentAt, sender }) => ({
|
|
340
|
+
url,
|
|
341
|
+
document_id: documentId,
|
|
342
|
+
title,
|
|
343
|
+
in_store: inStore,
|
|
344
|
+
ref: locator,
|
|
345
|
+
sent_at: sentAt,
|
|
346
|
+
sender
|
|
347
|
+
}), "documentLinkAnswer");
|
|
348
|
+
var accountAnswer = /* @__PURE__ */ __name((provider, { id, name, username, phone }) => ({
|
|
349
|
+
provider,
|
|
350
|
+
id,
|
|
351
|
+
name,
|
|
352
|
+
username,
|
|
353
|
+
...phone === void 0 ? {} : { phone }
|
|
354
|
+
}), "accountAnswer");
|
|
355
|
+
var sessionAnswer = /* @__PURE__ */ __name(({ current, client, device, location, lastActiveAt, createdAt }) => ({
|
|
356
|
+
current,
|
|
357
|
+
client,
|
|
358
|
+
device,
|
|
359
|
+
location,
|
|
360
|
+
last_active_at: lastActiveAt,
|
|
361
|
+
...createdAt === void 0 ? {} : { created_at: createdAt }
|
|
362
|
+
}), "sessionAnswer");
|
|
363
|
+
|
|
364
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/background/relay.js
|
|
365
|
+
import { createHash } from "node:crypto";
|
|
366
|
+
import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
|
|
367
|
+
import { createConnection, createServer } from "node:net";
|
|
368
|
+
import { tmpdir } from "node:os";
|
|
369
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
370
|
+
import { PassThrough, Writable } from "node:stream";
|
|
371
|
+
var RELAY_PROTOCOL = 1;
|
|
372
|
+
var requestSchema = strictObject({
|
|
373
|
+
argv: array(string()),
|
|
374
|
+
env: record(string(), string()),
|
|
375
|
+
cwd: pipe(string(), check((path) => isAbsolute(path))),
|
|
376
|
+
tty: boolean(),
|
|
377
|
+
stdinTty: boolean()
|
|
378
|
+
});
|
|
379
|
+
var MAX_CLIENT_LINE = 1024 * 1024;
|
|
380
|
+
var MAX_SERVE_LINE = 64 * 1024 * 1024;
|
|
381
|
+
var MAX_SOCKET_PATH = 100;
|
|
382
|
+
var relayPath = /* @__PURE__ */ __name((lockPath) => {
|
|
383
|
+
const beside = lockPath.replace(/\.lock$/, ".sock");
|
|
384
|
+
if (beside.length <= MAX_SOCKET_PATH)
|
|
385
|
+
return beside;
|
|
386
|
+
const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
|
|
387
|
+
const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
|
|
388
|
+
const temporary = join(tmpdir(), name);
|
|
389
|
+
if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
|
|
390
|
+
return temporary;
|
|
391
|
+
return join("/tmp", name);
|
|
392
|
+
}, "relayPath");
|
|
393
|
+
var privateDirectory = /* @__PURE__ */ __name((dir) => {
|
|
394
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
395
|
+
const stat = lstatSync(dir);
|
|
396
|
+
const mine = process.getuid === void 0 || stat.uid === process.getuid();
|
|
397
|
+
if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
|
|
398
|
+
throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
|
|
399
|
+
}
|
|
400
|
+
}, "privateDirectory");
|
|
401
|
+
var lines2 = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
|
|
402
|
+
let buffered = "";
|
|
403
|
+
socket.setEncoding("utf8");
|
|
404
|
+
socket.on("data", (chunk) => {
|
|
405
|
+
buffered += chunk;
|
|
406
|
+
for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
|
|
407
|
+
const line = buffered.slice(0, end);
|
|
408
|
+
buffered = buffered.slice(end + 1);
|
|
409
|
+
if (line)
|
|
410
|
+
onLine(line);
|
|
411
|
+
}
|
|
412
|
+
if (buffered.length > max)
|
|
413
|
+
onTooLong();
|
|
414
|
+
});
|
|
415
|
+
}, "lines");
|
|
416
|
+
var frame = /* @__PURE__ */ __name((socket, value) => {
|
|
417
|
+
if (!socket.destroyed)
|
|
418
|
+
socket.write(`${JSON.stringify(value)}
|
|
419
|
+
`);
|
|
420
|
+
}, "frame");
|
|
421
|
+
var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
|
|
422
|
+
privateDirectory(dirname(path));
|
|
423
|
+
rmSync(path, { force: true });
|
|
424
|
+
const open = /* @__PURE__ */ new Set();
|
|
425
|
+
const running = /* @__PURE__ */ new Set();
|
|
426
|
+
const server = createServer((socket) => {
|
|
427
|
+
open.add(socket);
|
|
428
|
+
const stop = new AbortController();
|
|
429
|
+
const stdin = new PassThrough();
|
|
430
|
+
let started = false;
|
|
431
|
+
socket.on("error", () => {
|
|
432
|
+
});
|
|
433
|
+
socket.on("close", () => {
|
|
434
|
+
open.delete(socket);
|
|
435
|
+
stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
|
|
436
|
+
if (!stdin.writableEnded)
|
|
437
|
+
stdin.end();
|
|
438
|
+
});
|
|
439
|
+
lines2(socket, MAX_CLIENT_LINE, (line) => {
|
|
440
|
+
let message;
|
|
441
|
+
try {
|
|
442
|
+
message = JSON.parse(line);
|
|
443
|
+
} catch {
|
|
444
|
+
socket.destroy();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (!started) {
|
|
448
|
+
started = true;
|
|
449
|
+
if (message.v !== RELAY_PROTOCOL) {
|
|
450
|
+
frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
|
|
451
|
+
socket.end();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const parsed = safeParse(requestSchema, message.run);
|
|
455
|
+
if (!parsed.success) {
|
|
456
|
+
socket.destroy();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
stdin.isTTY = parsed.output.stdinTty;
|
|
460
|
+
if (parsed.output.stdinTty)
|
|
461
|
+
stdin.end();
|
|
462
|
+
const job = serve(socket, parsed.output, stdin, stop.signal, run);
|
|
463
|
+
running.add(job);
|
|
464
|
+
void job.then(() => running.delete(job), () => running.delete(job));
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (typeof message.stdin === "string" && !stdin.writableEnded)
|
|
468
|
+
stdin.write(Buffer.from(message.stdin, "base64"));
|
|
469
|
+
if (message.stdinEnd === true && !stdin.writableEnded)
|
|
470
|
+
stdin.end();
|
|
471
|
+
}, () => socket.destroy());
|
|
472
|
+
});
|
|
473
|
+
await new Promise((resolve, reject) => {
|
|
474
|
+
server.once("error", reject);
|
|
475
|
+
server.listen(path, () => {
|
|
476
|
+
server.off("error", reject);
|
|
477
|
+
resolve();
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
chmodSync(path, 384);
|
|
481
|
+
return {
|
|
482
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
483
|
+
for (const socket of open)
|
|
484
|
+
socket.destroy();
|
|
485
|
+
await new Promise((resolve) => server.close(() => resolve()));
|
|
486
|
+
await Promise.allSettled(running);
|
|
487
|
+
rmSync(path, { force: true });
|
|
488
|
+
}, "close")
|
|
489
|
+
};
|
|
490
|
+
}, "listenRelay");
|
|
491
|
+
var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
|
|
492
|
+
const streams = {
|
|
493
|
+
data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
|
|
494
|
+
diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
|
|
495
|
+
progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
|
|
496
|
+
};
|
|
497
|
+
const stdout = new Writable({
|
|
498
|
+
write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
|
|
499
|
+
frame(socket, { raw: Buffer.from(chunk).toString("base64") });
|
|
500
|
+
done();
|
|
501
|
+
}, "write")
|
|
502
|
+
});
|
|
503
|
+
let code = 1;
|
|
504
|
+
try {
|
|
505
|
+
code = await run(request, { streams, stdin, stdout, signal });
|
|
506
|
+
} finally {
|
|
507
|
+
frame(socket, { exit: code });
|
|
508
|
+
socket.end();
|
|
509
|
+
}
|
|
510
|
+
}, "serve");
|
|
511
|
+
var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
|
|
512
|
+
const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
|
|
513
|
+
const socket = createConnection(path);
|
|
514
|
+
let connected = false;
|
|
515
|
+
let settled = false;
|
|
516
|
+
let timer;
|
|
517
|
+
const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
|
|
518
|
+
const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
|
|
519
|
+
const brokenPipe = /* @__PURE__ */ __name((error) => {
|
|
520
|
+
if (error.code === "EPIPE")
|
|
521
|
+
finish({ code: 0 });
|
|
522
|
+
}, "brokenPipe");
|
|
523
|
+
const finish = /* @__PURE__ */ __name((outcome) => {
|
|
524
|
+
if (settled)
|
|
525
|
+
return;
|
|
526
|
+
settled = true;
|
|
527
|
+
if (timer)
|
|
528
|
+
clearTimeout(timer);
|
|
529
|
+
stdout.off("error", brokenPipe);
|
|
530
|
+
signal.removeEventListener("abort", aborted);
|
|
531
|
+
stdin.off("data", forward).off("end", ended);
|
|
532
|
+
stdin.pause();
|
|
533
|
+
socket.destroy();
|
|
534
|
+
if ("code" in outcome)
|
|
535
|
+
resolve(outcome.code);
|
|
536
|
+
else
|
|
537
|
+
reject(outcome.error);
|
|
538
|
+
}, "finish");
|
|
539
|
+
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");
|
|
540
|
+
const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
|
|
541
|
+
if (signal.aborted)
|
|
542
|
+
return aborted();
|
|
543
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
544
|
+
stdout.on("error", brokenPipe);
|
|
545
|
+
if (deadlineMs !== void 0)
|
|
546
|
+
timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
|
|
547
|
+
socket.on("connect", () => {
|
|
548
|
+
connected = true;
|
|
549
|
+
frame(socket, { v: RELAY_PROTOCOL, run: request });
|
|
550
|
+
if (request.stdinTty)
|
|
551
|
+
ended();
|
|
552
|
+
else {
|
|
553
|
+
stdin.on("data", forward).once("end", ended);
|
|
554
|
+
stdin.resume();
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
socket.on("error", (error) => {
|
|
558
|
+
if (connected)
|
|
559
|
+
return finish({ error: stopped() });
|
|
560
|
+
finish({
|
|
561
|
+
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 })
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
socket.on("close", () => finish({ error: stopped() }));
|
|
565
|
+
lines2(socket, MAX_SERVE_LINE, (line) => {
|
|
566
|
+
let message;
|
|
567
|
+
try {
|
|
568
|
+
message = JSON.parse(line);
|
|
569
|
+
} catch {
|
|
570
|
+
return finish({ error: stopped() });
|
|
571
|
+
}
|
|
572
|
+
if (typeof message.data === "string")
|
|
573
|
+
streams.data(message.data);
|
|
574
|
+
if (typeof message.diagnostic === "string")
|
|
575
|
+
streams.diagnostic(message.diagnostic);
|
|
576
|
+
if (typeof message.progress === "string")
|
|
577
|
+
streams.progress?.(message.progress);
|
|
578
|
+
if (typeof message.raw === "string")
|
|
579
|
+
stdout.write(Buffer.from(message.raw, "base64"));
|
|
580
|
+
if (typeof message.exit === "number")
|
|
581
|
+
finish({ code: message.exit });
|
|
582
|
+
}, () => finish({ error: stopped() }));
|
|
583
|
+
}), "relayCommand");
|
|
584
|
+
|
|
585
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.659.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_2476fb045fb1ee08e5e46f4aab8c07fa/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
|
|
586
|
+
var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
|
|
587
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
588
|
+
}, "close"),
|
|
589
|
+
feed: void 0,
|
|
590
|
+
storedChats: void 0,
|
|
591
|
+
listen: void 0,
|
|
592
|
+
listenHistory: void 0,
|
|
593
|
+
...connection.watch && watchers ? {
|
|
594
|
+
// A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
|
|
595
|
+
watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
|
|
596
|
+
let watcher;
|
|
597
|
+
try {
|
|
598
|
+
await new Promise((resolve, reject) => {
|
|
599
|
+
watcher = /* @__PURE__ */ __name((event) => {
|
|
600
|
+
try {
|
|
601
|
+
onEvent(event);
|
|
602
|
+
} catch (error) {
|
|
603
|
+
reject(error);
|
|
604
|
+
}
|
|
605
|
+
}, "watcher");
|
|
606
|
+
watchers.add(watcher);
|
|
607
|
+
signal.addEventListener("abort", () => resolve(), { once: true });
|
|
608
|
+
onReady?.();
|
|
609
|
+
if (signal.aborted)
|
|
610
|
+
resolve();
|
|
611
|
+
});
|
|
612
|
+
} finally {
|
|
613
|
+
if (watcher)
|
|
614
|
+
watchers.delete(watcher);
|
|
615
|
+
}
|
|
616
|
+
}, "watch")
|
|
617
|
+
} : { watch: void 0 }
|
|
618
|
+
}), "lentConnection");
|
|
619
|
+
var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
|
|
620
|
+
let held;
|
|
621
|
+
let relay;
|
|
622
|
+
const watchers = /* @__PURE__ */ new Set();
|
|
623
|
+
const borrowed = /* @__PURE__ */ __name(() => {
|
|
624
|
+
const connection = held;
|
|
625
|
+
if (!connection)
|
|
626
|
+
throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
|
|
627
|
+
return lentConnection(connection, watchers);
|
|
628
|
+
}, "borrowed");
|
|
629
|
+
return {
|
|
630
|
+
messenger: {
|
|
631
|
+
...messenger,
|
|
632
|
+
connect: /* @__PURE__ */ __name(async (...args) => {
|
|
633
|
+
held = await messenger.connect(...args);
|
|
634
|
+
return held;
|
|
635
|
+
}, "connect")
|
|
636
|
+
},
|
|
637
|
+
arrived: /* @__PURE__ */ __name((event) => {
|
|
638
|
+
for (const watcher of watchers)
|
|
639
|
+
watcher(event);
|
|
640
|
+
}, "arrived"),
|
|
641
|
+
/** Listens beside the lock; the address goes into it, which is how a client finds it. */
|
|
642
|
+
open: /* @__PURE__ */ __name(async (lockPath, profile) => {
|
|
643
|
+
const environment = environmentOf(command);
|
|
644
|
+
const runCommand = environment.runCommand;
|
|
645
|
+
if (!runCommand)
|
|
646
|
+
return void 0;
|
|
647
|
+
const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
|
|
648
|
+
const path = relayPath(lockPath);
|
|
649
|
+
relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
|
|
650
|
+
env: {
|
|
651
|
+
...request.env,
|
|
652
|
+
...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
|
|
653
|
+
},
|
|
654
|
+
streams: io.streams,
|
|
655
|
+
stdin: io.stdin,
|
|
656
|
+
stdout: io.stdout,
|
|
657
|
+
tty: request.tty,
|
|
658
|
+
signal: io.signal,
|
|
659
|
+
answer: /* @__PURE__ */ __name(() => null, "answer"),
|
|
660
|
+
relayed: { profile, cwd: request.cwd, connection: borrowed }
|
|
661
|
+
}));
|
|
662
|
+
return { path, protocol: RELAY_PROTOCOL };
|
|
663
|
+
}, "open"),
|
|
664
|
+
close: /* @__PURE__ */ __name(async () => {
|
|
665
|
+
await relay?.close();
|
|
666
|
+
}, "close")
|
|
667
|
+
};
|
|
668
|
+
}, "serveRelay");
|
|
669
|
+
|
|
670
|
+
export {
|
|
671
|
+
COMMAND_NEEDS,
|
|
672
|
+
lackedNeed,
|
|
673
|
+
refuseLacking,
|
|
674
|
+
hideNever,
|
|
675
|
+
RELAY_PROTOCOL,
|
|
676
|
+
relayCommand,
|
|
677
|
+
lentConnection,
|
|
678
|
+
serveRelay,
|
|
679
|
+
positiveCount,
|
|
680
|
+
withPaging,
|
|
681
|
+
window,
|
|
682
|
+
chatRef,
|
|
683
|
+
chatAnswer,
|
|
684
|
+
memberAnswer,
|
|
685
|
+
contactRef,
|
|
686
|
+
contactAnswer,
|
|
687
|
+
contactShown,
|
|
688
|
+
chatEventAnswer,
|
|
689
|
+
memberEventAnswer,
|
|
690
|
+
inviteLinkAnswer,
|
|
691
|
+
joinRequestAnswer,
|
|
692
|
+
pollVoteAnswer,
|
|
693
|
+
reactorAnswer,
|
|
694
|
+
topicAnswer,
|
|
695
|
+
folderAnswer,
|
|
696
|
+
lines,
|
|
697
|
+
pageOf,
|
|
698
|
+
wholeList,
|
|
699
|
+
chatShown,
|
|
700
|
+
scoreFloor,
|
|
701
|
+
auditAnswer,
|
|
702
|
+
renderItem,
|
|
703
|
+
withPage,
|
|
704
|
+
documentLinkAnswer,
|
|
705
|
+
accountAnswer,
|
|
706
|
+
sessionAnswer
|
|
707
|
+
};
|