@wirecat/mail-cli 0.23.0 → 0.24.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 +29 -0
- package/dist/bin/mail.js +2 -2
- package/dist/bundle/{all-profiles-CI32WFEV.js → all-profiles-VS7P6DJY.js} +11 -11
- package/dist/bundle/{anthropic-ICSOMJIN.js → anthropic-C5JXKGBS.js} +16 -7
- package/dist/bundle/{app-server-3F4ZB7DH.js → app-server-HU3LVU42.js} +51 -50
- package/dist/bundle/{bun-7AHNFZMZ.js → bun-QLFX47WZ.js} +2 -2
- package/dist/bundle/{bun-sqlite-UIWRS4HI.js → bun-sqlite-W4PGAKVY.js} +5 -5
- package/dist/bundle/{chunk-ETIUB2DF.js → chunk-3FD3IATT.js} +6 -6
- package/dist/bundle/{chunk-6FSLEARF.js → chunk-3KSK5BBB.js} +2 -2
- package/dist/bundle/{chunk-I3YNNSGB.js → chunk-4QNHAM3J.js} +2 -2
- package/dist/bundle/{chunk-7SWWVDEZ.js → chunk-4W4EVVL4.js} +61 -21
- package/dist/bundle/{chunk-JDKC7EXM.js → chunk-5NLHDK7P.js} +50 -46
- package/dist/bundle/{chunk-AHRHP2H2.js → chunk-5X3GU5LI.js} +6 -6
- package/dist/bundle/{chunk-KNRONMVG.js → chunk-64ZG5ERD.js} +2 -2
- package/dist/bundle/{chunk-RIAZTS6C.js → chunk-6PWCQKMD.js} +12 -12
- package/dist/bundle/{chunk-4PNIZUEC.js → chunk-6VV7J2TN.js} +36 -57
- package/dist/bundle/{chunk-5AS5N7V5.js → chunk-A6J4MPTI.js} +3 -1
- package/dist/bundle/{chunk-ZYHBMDNU.js → chunk-AUTX2MLF.js} +11 -9
- package/dist/bundle/{chunk-5Y2WRUYP.js → chunk-B72343TK.js} +2 -2
- package/dist/bundle/{chunk-7SIWMF77.js → chunk-BFQQV22T.js} +1 -1
- package/dist/bundle/chunk-C3NYJW6B.js +1542 -0
- package/dist/bundle/{chunk-7ZDH2XEY.js → chunk-C5BMCLCQ.js} +4 -4
- package/dist/bundle/{chunk-JO4BJYVE.js → chunk-DW3F6DUW.js} +1 -1
- package/dist/bundle/chunk-EKGRNFYQ.js +18 -0
- package/dist/bundle/{chunk-4YTX5YAU.js → chunk-FKWUUCX2.js} +1361 -1539
- package/dist/bundle/{chunk-LLYVBO3R.js → chunk-FNLUKODV.js} +19 -19
- package/dist/bundle/{chunk-HGV7DSSA.js → chunk-H5FJTHVA.js} +2 -2
- package/dist/bundle/{chunk-3QVGB2CI.js → chunk-HBZAJINU.js} +4 -4
- package/dist/bundle/{chunk-BT7UUI6E.js → chunk-IRUN4XOV.js} +2 -2
- package/dist/bundle/{chunk-4TKQIXND.js → chunk-JMLIKXFO.js} +2 -2
- package/dist/bundle/{chunk-XV3M3NAN.js → chunk-JOQGJUFT.js} +1 -1
- package/dist/bundle/{chunk-NEDYKKJJ.js → chunk-JWMLMAHP.js} +4 -4
- package/dist/bundle/{chunk-5QQOUYNA.js → chunk-KGOVFEWZ.js} +3 -3
- package/dist/bundle/{chunk-NKDYHAHP.js → chunk-KV4VTKF3.js} +3 -3
- package/dist/bundle/chunk-LVGX7VTD.js +138 -0
- package/dist/bundle/{chunk-3DQYO7FB.js → chunk-MCPOZNWG.js} +1 -1
- package/dist/bundle/{chunk-SCH3NC5X.js → chunk-MTO6YVMN.js} +3 -3
- package/dist/bundle/{chunk-R4RAWEMV.js → chunk-NCRSE647.js} +286 -48
- package/dist/bundle/{chunk-UTLJQG6Q.js → chunk-NSIN5IM4.js} +8 -8
- package/dist/bundle/{chunk-IMIY7HQB.js → chunk-NWKKPDZV.js} +2 -2
- package/dist/bundle/chunk-O373QEAJ.js +1243 -0
- package/dist/bundle/{chunk-OMW37FXK.js → chunk-OQW6GHUA.js} +1 -1
- package/dist/bundle/{chunk-D6WTKSRA.js → chunk-PRQ2U7HF.js} +2 -2
- package/dist/bundle/{chunk-HRIYU2HJ.js → chunk-PT6MF2VU.js} +469 -120
- package/dist/bundle/{chunk-B6GITVDX.js → chunk-Q4OKEN3B.js} +7 -7
- package/dist/bundle/{chunk-ELGEHZK2.js → chunk-Q6K2XUGU.js} +1 -1
- package/dist/bundle/{chunk-CNYQ3TTZ.js → chunk-QI3PXUOJ.js} +43 -595
- package/dist/bundle/{chunk-SGMENSI6.js → chunk-QVMOEB3I.js} +391 -16
- package/dist/bundle/{chunk-S2U5BXWS.js → chunk-RLQZFZLK.js} +80 -5
- package/dist/bundle/{chunk-SETCGPFG.js → chunk-RN7OI5KL.js} +9 -8
- package/dist/bundle/{chunk-5J4WNTTM.js → chunk-RNZKQMFY.js} +14 -14
- package/dist/bundle/{chunk-WQRX4RQS.js → chunk-RUASZW3M.js} +5 -5
- package/dist/bundle/{chunk-UHC5I3JV.js → chunk-RX5CJ55S.js} +1 -1
- package/dist/bundle/{chunk-FHCOGR7S.js → chunk-SWKQ6IAR.js} +3 -3
- package/dist/bundle/{chunk-KJQZXCNK.js → chunk-TI7ZIPA2.js} +4 -4
- package/dist/bundle/{chunk-7DFWXIY5.js → chunk-TLEBSMC7.js} +1997 -768
- package/dist/bundle/{chunk-5Z7LZAVP.js → chunk-U6MMQNNK.js} +6 -6
- package/dist/bundle/{chunk-HN6PB7F5.js → chunk-VNKWSCN7.js} +99 -42
- package/dist/bundle/{chunk-DALBYUPC.js → chunk-VUBZFMGP.js} +2 -2
- package/dist/bundle/{chunk-XP5FBDIG.js → chunk-VVL4MKYH.js} +1 -1
- package/dist/bundle/{chunk-TEL2OMS5.js → chunk-WOX7FZJP.js} +686 -220
- package/dist/bundle/{chunk-2BAO4T4Z.js → chunk-X47BL4M5.js} +13 -13
- package/dist/bundle/{chunk-GOMJNH56.js → chunk-X7J3TTDO.js} +8 -8
- package/dist/bundle/{chunk-FVKZ55I2.js → chunk-XBEO472U.js} +29976 -16640
- package/dist/bundle/{chunk-UA4BOLIY.js → chunk-YA45XV6G.js} +4 -4
- package/dist/bundle/{chunk-FIZWQTUC.js → chunk-YBQ5AYLZ.js} +3 -3
- package/dist/bundle/{chunk-AFPETMXZ.js → chunk-YI544LHI.js} +13 -136
- package/dist/bundle/chunk-ZO4MQWIK.js +188 -0
- package/dist/bundle/{chunk-7OVVX4F4.js → chunk-ZR2BDNGG.js} +1 -1
- package/dist/bundle/command-contract-ERYYPAD2.js +35 -0
- package/dist/bundle/command-server-entry-5E3PPDE5.js +164 -0
- package/dist/bundle/{decode-BJXABRAN.js → decode-AVWV7SVZ.js} +5 -5
- package/dist/bundle/{dispatch-G4CYFWQ2.js → dispatch-BXPHSNK5.js} +10 -10
- package/dist/bundle/{dist-LLEA6R4V.js → dist-PIOOKBWT.js} +78 -44
- package/dist/bundle/{echarts-YPTKBOZV.js → echarts-7K6YQV52.js} +2 -2
- package/dist/bundle/{embed-DMROTI5M.js → embed-4NT76GJK.js} +6 -6
- package/dist/bundle/{embedder-DWMHXCHJ.js → embedder-ITQFF7EN.js} +9 -9
- package/dist/bundle/{failure-FFPK2WYB.js → failure-3Q65JOPD.js} +2 -2
- package/dist/bundle/{first-run-FQOEF2IO.js → first-run-PM74YU4X.js} +11 -11
- package/dist/bundle/first-screen-WBVGVSMY.js +33 -0
- package/dist/bundle/{instructions-OGKMROLD.js → instructions-JDSITYHV.js} +1 -1
- package/dist/bundle/mail.js +37 -13
- package/dist/bundle/{mcp-CFVG2OUS.js → mcp-7KQUJNFN.js} +2 -2
- package/dist/bundle/{node-HIKYE546.js → node-D6YIJOJI.js} +2 -2
- package/dist/bundle/{node-sqlite-3GJAG7VO.js → node-sqlite-PJOHHB4X.js} +6 -6
- package/dist/bundle/{oauth-H3DB6IHI.js → oauth-BOWJ3IBT.js} +7 -7
- package/dist/bundle/{open-DJ2PRG74.js → open-FIAKKZMW.js} +5 -5
- package/dist/bundle/{openai-MDBRYB55.js → openai-QL54VVLC.js} +16 -37
- package/dist/bundle/{process-4LBD72JH.js → process-AYHK7WRC.js} +1 -1
- package/dist/bundle/{program-F6WK6RX4.js → program-6FKWOTBK.js} +3206 -1603
- package/dist/bundle/{prompt-UNPUG6SO.js → prompt-XJZCBELC.js} +5 -5
- package/dist/bundle/{recognize-DMIO4PDB.js → recognize-OQKWAHBY.js} +4 -4
- package/dist/bundle/{remote-24HJA72D.js → remote-NLVUZ5WK.js} +7 -7
- package/dist/bundle/{rerank-PTNCHHIU.js → rerank-NRPZDTJ7.js} +7 -7
- package/dist/bundle/{serve-T6JHM2YD.js → serve-O4YUI7F6.js} +9 -9
- package/dist/bundle/server-6OT5ZEWL.js +66 -0
- package/dist/bundle/{server-BWEYRUR3.js → server-WAL3M4OO.js} +40 -40
- package/dist/bundle/{sqlite-runtime-ZJ4EH5ZM.js → sqlite-runtime-5YHGI4D4.js} +6 -6
- package/dist/bundle/{state-KSN4OFYW.js → state-WYYOJ7KK.js} +6 -6
- package/dist/bundle/{store-OIEZJEA7.js → store-6BJO3F2J.js} +22 -16
- package/dist/bundle/{store-GVBW2ZFK.js → store-X72GOJHD.js} +50 -22
- package/dist/bundle/store-maintenance-command-ASS7RBYC.js +54 -0
- package/dist/commands/rules.d.ts.map +1 -1
- package/dist/commands/rules.js +29 -7
- package/dist/commands/rules.js.map +1 -1
- package/dist/commands/sync.d.ts +0 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +8 -2
- package/dist/commands/sync.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunk-5AQ4S4TZ.js +0 -12172
- package/dist/bundle/chunk-B4MWHI2V.js +0 -380
- package/dist/bundle/command-contract-UIRWJVEY.js +0 -35
- package/dist/bundle/first-screen-B6LF5464.js +0 -33
- package/dist/bundle/server-VUQNR5ZD.js +0 -65
- package/dist/bundle/store-maintenance-command-KJ54HLUQ.js +0 -54
- /package/dist/bundle/{chunk-QZLK2ISN.js → chunk-YVNHQFLC.js} +0 -0
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
readLock,
|
|
6
6
|
releaseLock,
|
|
7
7
|
takeLock
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YBQ5AYLZ.js";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-ZVVMGPBJ.js";
|
|
12
12
|
|
|
13
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
|
|
14
14
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
15
15
|
|
|
16
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
16
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/mcp/http/activity.js
|
|
17
17
|
import { randomBytes } from "node:crypto";
|
|
18
18
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
19
19
|
import { dirname } from "node:path";
|
|
@@ -86,7 +86,7 @@ var activityRecorder = /* @__PURE__ */ __name((path, now = Date.now) => {
|
|
|
86
86
|
};
|
|
87
87
|
}, "activityRecorder");
|
|
88
88
|
|
|
89
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
89
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
|
|
90
90
|
var ACCESS_SECONDS = 60 * 60;
|
|
91
91
|
var REFRESH_SECONDS = 30 * 24 * 60 * 60;
|
|
92
92
|
var readStored = /* @__PURE__ */ __name((path) => existsSync2(path) ? JSON.parse(readFileSync2(path, "utf8")) : { clients: [], tokens: [] }, "readStored");
|
|
@@ -2,16 +2,16 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
alive
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DW3F6DUW.js";
|
|
6
6
|
import {
|
|
7
7
|
resolvePaths,
|
|
8
8
|
writeSecurely
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FNLUKODV.js";
|
|
10
10
|
import {
|
|
11
11
|
__name
|
|
12
12
|
} from "./chunk-ZVVMGPBJ.js";
|
|
13
13
|
|
|
14
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
14
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/background/lock.js
|
|
15
15
|
import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { dirname, join } from "node:path";
|
|
17
17
|
var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
|
|
@@ -2,19 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
LEVELS
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Q4OKEN3B.js";
|
|
6
6
|
import {
|
|
7
7
|
WORD_BODY,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
providerLabel,
|
|
11
|
-
providerNamed,
|
|
12
|
-
typedPhone
|
|
13
|
-
} from "./chunk-5AQ4S4TZ.js";
|
|
8
|
+
e164Of
|
|
9
|
+
} from "./chunk-C3NYJW6B.js";
|
|
14
10
|
import {
|
|
15
11
|
resolvePaths,
|
|
16
12
|
writeSecurely
|
|
17
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FNLUKODV.js";
|
|
18
14
|
import {
|
|
19
15
|
array,
|
|
20
16
|
getDotPath,
|
|
@@ -33,122 +29,16 @@ import {
|
|
|
33
29
|
string,
|
|
34
30
|
transform,
|
|
35
31
|
unknown
|
|
36
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-X7J3TTDO.js";
|
|
37
33
|
import {
|
|
38
34
|
CliError,
|
|
39
|
-
singleLine,
|
|
40
35
|
visibleControls
|
|
41
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-VUBZFMGP.js";
|
|
42
37
|
import {
|
|
43
38
|
__name
|
|
44
39
|
} from "./chunk-ZVVMGPBJ.js";
|
|
45
40
|
|
|
46
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47
|
-
var TAKES = {
|
|
48
|
-
chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
|
|
49
|
-
message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
|
|
50
|
-
};
|
|
51
|
-
var article = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
|
|
52
|
-
var wrongKind = /* @__PURE__ */ __name((text, kind, takes) => new CliError("validation_error", `${text} names ${article(kind)} ${kind}; this takes ${TAKES[takes]}`, {
|
|
53
|
-
reason: "ref.wrong-kind"
|
|
54
|
-
}), "wrongKind");
|
|
55
|
-
var wrongProvider = /* @__PURE__ */ __name((text, provider, kind) => {
|
|
56
|
-
const entry = providerNamed(provider);
|
|
57
|
-
const command = entry?.command;
|
|
58
|
-
const opens = kind === "entity" ? void 0 : entry?.opens?.[kind];
|
|
59
|
-
const how = command && opens ? `open it with ${command} <profile> ${opens} ${text}` : "open it with its own CLI";
|
|
60
|
-
const label = providerLabel(provider);
|
|
61
|
-
return new CliError("validation_error", `${text} is ${article(label.toLowerCase())} ${label} ${kind}; ${how}`, {
|
|
62
|
-
reason: "ref.wrong-provider"
|
|
63
|
-
});
|
|
64
|
-
}, "wrongProvider");
|
|
65
|
-
var chatReferenceOf = /* @__PURE__ */ __name((text, provider, takes = "chat") => {
|
|
66
|
-
const trimmed = text.trim();
|
|
67
|
-
if (!looksLikeReference(trimmed))
|
|
68
|
-
return void 0;
|
|
69
|
-
const reference = parseReference(trimmed);
|
|
70
|
-
if (reference.type !== "chat" && reference.type !== "message")
|
|
71
|
-
throw wrongKind(trimmed, reference.type, takes);
|
|
72
|
-
if (reference.provider !== provider)
|
|
73
|
-
throw wrongProvider(trimmed, reference.provider, reference.type);
|
|
74
|
-
const found = {
|
|
75
|
-
text: trimmed,
|
|
76
|
-
provider: reference.provider,
|
|
77
|
-
account: reference.account,
|
|
78
|
-
chat: reference.chat,
|
|
79
|
-
...reference.type === "message" ? { message: reference.message } : {}
|
|
80
|
-
};
|
|
81
|
-
return found;
|
|
82
|
-
}, "chatReferenceOf");
|
|
83
|
-
var contactReferenceOf = /* @__PURE__ */ __name((text, provider) => {
|
|
84
|
-
const trimmed = text.trim();
|
|
85
|
-
if (!trimmed.startsWith("contact:"))
|
|
86
|
-
return void 0;
|
|
87
|
-
const reference = parseReference(trimmed);
|
|
88
|
-
if (reference.type !== "contact")
|
|
89
|
-
return void 0;
|
|
90
|
-
if (provider !== void 0 && reference.provider !== provider)
|
|
91
|
-
throw wrongProvider(trimmed, reference.provider, reference.type);
|
|
92
|
-
return reference.id;
|
|
93
|
-
}, "contactReferenceOf");
|
|
94
|
-
var wrongAccount = /* @__PURE__ */ __name((reference, scope, profiles) => {
|
|
95
|
-
const here = scope.account === void 0 ? "the account of this profile is not known yet" : `${scope.profile === void 0 ? "this profile" : `profile ${scope.profile}`} is account ${scope.account}`;
|
|
96
|
-
const others = profiles === void 0 ? "" : `. Profiles signed in to ${reference.account}: ${profiles.length > 0 ? profiles.join(", ") : "none here"}`;
|
|
97
|
-
return new CliError("validation_error", `${reference.text} belongs to account ${reference.account}; ${here}${others}`, { reason: "ref.wrong-account" });
|
|
98
|
-
}, "wrongAccount");
|
|
99
|
-
var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn) => {
|
|
100
|
-
if (scope.account !== void 0 && scope.account === reference.account)
|
|
101
|
-
return;
|
|
102
|
-
const profiles = await profilesOn?.(reference.account).catch(() => void 0);
|
|
103
|
-
throw wrongAccount(reference, scope, profiles);
|
|
104
|
-
}, "ensureAccount");
|
|
105
|
-
|
|
106
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/resolve.js
|
|
107
|
-
var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
|
|
108
|
-
var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
|
|
109
|
-
var pickChat = /* @__PURE__ */ __name((reference, chats) => {
|
|
110
|
-
const wanted = foldName(reference.trim());
|
|
111
|
-
const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
|
|
112
|
-
if (matches.length === 1 && matches[0])
|
|
113
|
-
return matches[0];
|
|
114
|
-
if (matches.length === 0)
|
|
115
|
-
throw new CliError("not_found", `no chat matches "${reference}"`);
|
|
116
|
-
throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
|
|
117
|
-
}, "pickChat");
|
|
118
|
-
var pickPerson = /* @__PURE__ */ __name((reference, people) => {
|
|
119
|
-
const trimmed = reference.trim();
|
|
120
|
-
const contact = contactReferenceOf(trimmed, people.provider);
|
|
121
|
-
if (contact !== void 0) {
|
|
122
|
-
const named = people.get(contact);
|
|
123
|
-
if (named)
|
|
124
|
-
return named;
|
|
125
|
-
throw new CliError("not_found", `no person ${contact} in what this account has seen`);
|
|
126
|
-
}
|
|
127
|
-
const known = people.get(trimmed);
|
|
128
|
-
if (known)
|
|
129
|
-
return known;
|
|
130
|
-
if (isId(trimmed))
|
|
131
|
-
throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
|
|
132
|
-
const wanted = foldName(trimmed.replace(/^@/, ""));
|
|
133
|
-
const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
134
|
-
const fields = /* @__PURE__ */ __name((person) => [person.alias, person.name, person.username].filter(isPresent).map(foldName), "fields");
|
|
135
|
-
const exact = everyone.filter((person) => fields(person).includes(wanted));
|
|
136
|
-
const matches = exact.length > 0 ? exact : everyone.filter((person) => fields(person).some((one) => one.includes(wanted)));
|
|
137
|
-
if (matches.length === 1 && matches[0])
|
|
138
|
-
return matches[0];
|
|
139
|
-
if (matches.length === 0)
|
|
140
|
-
throw new CliError("not_found", `nobody matches "${reference}"`);
|
|
141
|
-
throw ambiguous(reference, "people", matches.map(({ id, name, username }) => ({ id, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
|
|
142
|
-
}, "pickPerson");
|
|
143
|
-
var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label) => {
|
|
144
|
-
const width = Math.max(...candidates.map(({ id }) => id.length));
|
|
145
|
-
const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label(candidate)}`).join("\n");
|
|
146
|
-
return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
|
|
147
|
-
${lines}`, { candidates });
|
|
148
|
-
}, "ambiguous");
|
|
149
|
-
var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
|
|
150
|
-
|
|
151
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_af5f2db22f61976c09fb28de9c7dc33e/node_modules/@wirecat/cli-core/dist/domain/vcard.js
|
|
41
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/vcard.js
|
|
152
42
|
import { createHash } from "node:crypto";
|
|
153
43
|
var MAX_ID = 512;
|
|
154
44
|
var AS_WORD = new RegExp(`^${WORD_BODY}$`);
|
|
@@ -244,14 +134,7 @@ var components = /* @__PURE__ */ __name((value) => {
|
|
|
244
134
|
return parts.map((part) => part.trim());
|
|
245
135
|
}, "components");
|
|
246
136
|
var textOf = /* @__PURE__ */ __name((property, report) => components(decoded(property, report)).join(";").trim(), "textOf");
|
|
247
|
-
var e164 = /* @__PURE__ */ __name((typed, region) =>
|
|
248
|
-
const text = typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim();
|
|
249
|
-
const international = /^(\+|00)/.test(text);
|
|
250
|
-
if (!international && region === void 0)
|
|
251
|
-
return void 0;
|
|
252
|
-
const value = typedPhone(text, region === void 0 ? {} : { phoneCountries: [region] })?.value;
|
|
253
|
-
return value?.startsWith("+") ? value : void 0;
|
|
254
|
-
}, "e164");
|
|
137
|
+
var e164 = /* @__PURE__ */ __name((typed, region) => e164Of(typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim(), region) ?? void 0, "e164");
|
|
255
138
|
var foldedName = /* @__PURE__ */ __name((name) => name.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim(), "foldedName");
|
|
256
139
|
var hashed = /* @__PURE__ */ __name((prefix, parts) => `${prefix}${createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 32)}`, "hashed");
|
|
257
140
|
var organizationId = /* @__PURE__ */ __name((name) => {
|
|
@@ -302,7 +185,8 @@ var cardsOf = /* @__PURE__ */ __name((text) => {
|
|
|
302
185
|
}
|
|
303
186
|
return { cards, issues };
|
|
304
187
|
}, "cardsOf");
|
|
305
|
-
var envelopeOfVcard = /* @__PURE__ */ __name((text, { provider, account, batchId, region }) => {
|
|
188
|
+
var envelopeOfVcard = /* @__PURE__ */ __name((text, { provider, account, batchId, region: given }) => {
|
|
189
|
+
const region = given?.toLowerCase();
|
|
306
190
|
const { cards, issues } = cardsOf(text);
|
|
307
191
|
const people = [];
|
|
308
192
|
const organizations = /* @__PURE__ */ new Map();
|
|
@@ -385,7 +269,7 @@ var envelopeOfVcard = /* @__PURE__ */ __name((text, { provider, account, batchId
|
|
|
385
269
|
};
|
|
386
270
|
}, "envelopeOfVcard");
|
|
387
271
|
|
|
388
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
272
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/domain/formatting.js
|
|
389
273
|
var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "the messenger formatter returned invalid text spans"), "invalid");
|
|
390
274
|
var validateFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
391
275
|
const { text, spans } = formatted;
|
|
@@ -445,7 +329,7 @@ var visibleFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
|
445
329
|
};
|
|
446
330
|
}, "visibleFormattedText");
|
|
447
331
|
|
|
448
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
332
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/moderation/check.js
|
|
449
333
|
var INVITE = /max\.ru\/join\/|(t|telegram)\.me\/(\+|joinchat\/)|tg:\/\/join/i;
|
|
450
334
|
var LINK = /https?:\/\/\S+/i;
|
|
451
335
|
var STRENGTH = { report: 0, delete: 1, remove: 2 };
|
|
@@ -633,7 +517,7 @@ var nextPoint = /* @__PURE__ */ __name((rows, found) => {
|
|
|
633
517
|
}, "nextPoint");
|
|
634
518
|
var someUndone = /* @__PURE__ */ __name((rows) => rows.some(undone), "someUndone");
|
|
635
519
|
|
|
636
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
520
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/moderation/rules.js
|
|
637
521
|
import { existsSync, readFileSync } from "node:fs";
|
|
638
522
|
import { join } from "node:path";
|
|
639
523
|
var RULE_ACTIONS = ["report", "delete", "remove"];
|
|
@@ -777,13 +661,6 @@ var assign = /* @__PURE__ */ __name((rules, key, value) => {
|
|
|
777
661
|
}, "assign");
|
|
778
662
|
|
|
779
663
|
export {
|
|
780
|
-
chatReferenceOf,
|
|
781
|
-
wrongAccount,
|
|
782
|
-
ensureAccount,
|
|
783
|
-
isId,
|
|
784
|
-
foldName,
|
|
785
|
-
pickChat,
|
|
786
|
-
pickPerson,
|
|
787
664
|
isVcard,
|
|
788
665
|
envelopeOfVcard,
|
|
789
666
|
validateFormattedText,
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
stdinFieldOf
|
|
5
|
+
} from "./chunk-EKGRNFYQ.js";
|
|
6
|
+
import {
|
|
7
|
+
commandPathOf
|
|
8
|
+
} from "./chunk-RUASZW3M.js";
|
|
9
|
+
import {
|
|
10
|
+
commandServerRequest,
|
|
11
|
+
metaOf
|
|
12
|
+
} from "./chunk-FKWUUCX2.js";
|
|
13
|
+
import {
|
|
14
|
+
errorObjectOf,
|
|
15
|
+
renderError
|
|
16
|
+
} from "./chunk-X7J3TTDO.js";
|
|
17
|
+
import {
|
|
18
|
+
CliError
|
|
19
|
+
} from "./chunk-VUBZFMGP.js";
|
|
20
|
+
import {
|
|
21
|
+
__name
|
|
22
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
23
|
+
|
|
24
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/command-server.js
|
|
25
|
+
import { createInterface } from "node:readline";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/command-server-argv.js
|
|
28
|
+
var COMMAND_SERVER_ARGV = ["commands", "--serve"];
|
|
29
|
+
var isCommandServer = /* @__PURE__ */ __name((args) => args.length === COMMAND_SERVER_ARGV.length && COMMAND_SERVER_ARGV.every((word, at) => args[at] === word), "isCommandServer");
|
|
30
|
+
|
|
31
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/command-server.js
|
|
32
|
+
var COMMAND_SERVER_PROTOCOL = 1;
|
|
33
|
+
var COMMAND_SERVER_IDLE_MS = 10 * 6e4;
|
|
34
|
+
var COMMAND_SERVER_CONCURRENT = 8;
|
|
35
|
+
var runsAlone = /* @__PURE__ */ __name((command) => commandPathOf(command)[0] === "store", "runsAlone");
|
|
36
|
+
var enterCommandServer = /* @__PURE__ */ __name(async (command, cli) => {
|
|
37
|
+
const request = commandServerRequest();
|
|
38
|
+
if (!request)
|
|
39
|
+
return;
|
|
40
|
+
refuseInCommandServer(command, cli);
|
|
41
|
+
if (runsAlone(command))
|
|
42
|
+
await request.alone();
|
|
43
|
+
}, "enterCommandServer");
|
|
44
|
+
var refuseInCommandServer = /* @__PURE__ */ __name((command, cli) => {
|
|
45
|
+
if (!commandServerRequest())
|
|
46
|
+
return;
|
|
47
|
+
const typed = [cli, ...commandPathOf(command)].join(" ");
|
|
48
|
+
const { lifetime } = metaOf(command);
|
|
49
|
+
if (lifetime)
|
|
50
|
+
throw new CliError("validation_error", `\`${typed}\` ${lifetime === "persistent" ? "runs until it is stopped" : "waits on a person"}; the command server runs only commands that return \u2014 start it as a process of its own`);
|
|
51
|
+
if (stdinFieldOf(command))
|
|
52
|
+
throw new CliError("validation_error", `\`${typed}\` reads its input on stdin, which the command server does not pass on \u2014 start it as a process of its own`);
|
|
53
|
+
}, "refuseInCommandServer");
|
|
54
|
+
var refusal = /* @__PURE__ */ __name((cli, message) => `${renderError(errorObjectOf(new CliError("validation_error", message)), { cli, interactive: false })}
|
|
55
|
+
`, "refusal");
|
|
56
|
+
var requestOf = /* @__PURE__ */ __name((line, cli) => {
|
|
57
|
+
let parsed;
|
|
58
|
+
try {
|
|
59
|
+
parsed = JSON.parse(line);
|
|
60
|
+
} catch {
|
|
61
|
+
return { id: null, error: "a request is one JSON object per line" };
|
|
62
|
+
}
|
|
63
|
+
const { id, argv } = parsed ?? {};
|
|
64
|
+
const known = typeof id === "number" && Number.isFinite(id) ? id : null;
|
|
65
|
+
if (known === null)
|
|
66
|
+
return { id: null, error: 'a request needs a numeric "id"' };
|
|
67
|
+
if (!Array.isArray(argv) || !argv.every((word) => typeof word === "string"))
|
|
68
|
+
return { id: known, error: '"argv" is a list of strings' };
|
|
69
|
+
if (isCommandServer(argv))
|
|
70
|
+
return { id: known, error: `\`${cli} commands --serve\` cannot run inside itself` };
|
|
71
|
+
return { id: known, argv };
|
|
72
|
+
}, "requestOf");
|
|
73
|
+
var serveCommands = /* @__PURE__ */ __name(async ({ input, write, run, cli, version, idleMs = COMMAND_SERVER_IDLE_MS, concurrent = COMMAND_SERVER_CONCURRENT, signal }) => {
|
|
74
|
+
const send = /* @__PURE__ */ __name((value) => write(`${JSON.stringify(value)}
|
|
75
|
+
`), "send");
|
|
76
|
+
await send({ ready: true, protocol: COMMAND_SERVER_PROTOCOL, version, concurrent });
|
|
77
|
+
const lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY });
|
|
78
|
+
return new Promise((resolve) => {
|
|
79
|
+
const waiting = [];
|
|
80
|
+
let active = 0;
|
|
81
|
+
let running = 0;
|
|
82
|
+
let gated = false;
|
|
83
|
+
let drained;
|
|
84
|
+
let turns = Promise.resolve();
|
|
85
|
+
let timer;
|
|
86
|
+
let ending = false;
|
|
87
|
+
let done = false;
|
|
88
|
+
const finish = /* @__PURE__ */ __name(() => {
|
|
89
|
+
if (done)
|
|
90
|
+
return;
|
|
91
|
+
done = true;
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
lines.close();
|
|
94
|
+
resolve(0);
|
|
95
|
+
}, "finish");
|
|
96
|
+
const settle = /* @__PURE__ */ __name(() => {
|
|
97
|
+
if (running === 0 && drained) {
|
|
98
|
+
const go = drained;
|
|
99
|
+
drained = void 0;
|
|
100
|
+
go();
|
|
101
|
+
}
|
|
102
|
+
pump();
|
|
103
|
+
if (active > 0 || waiting.length > 0 || done)
|
|
104
|
+
return;
|
|
105
|
+
if (ending)
|
|
106
|
+
finish();
|
|
107
|
+
else {
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
timer = setTimeout(finish, idleMs);
|
|
110
|
+
}
|
|
111
|
+
}, "settle");
|
|
112
|
+
const start = /* @__PURE__ */ __name((line) => {
|
|
113
|
+
active += 1;
|
|
114
|
+
running += 1;
|
|
115
|
+
let holdsPlace = true;
|
|
116
|
+
let ended = false;
|
|
117
|
+
let turn;
|
|
118
|
+
let release;
|
|
119
|
+
const alone = /* @__PURE__ */ __name(() => {
|
|
120
|
+
if (turn)
|
|
121
|
+
return turn;
|
|
122
|
+
holdsPlace = false;
|
|
123
|
+
running -= 1;
|
|
124
|
+
turn = turns.then(() => new Promise((go) => {
|
|
125
|
+
if (ended)
|
|
126
|
+
return go();
|
|
127
|
+
gated = true;
|
|
128
|
+
drained = /* @__PURE__ */ __name(() => {
|
|
129
|
+
if (ended)
|
|
130
|
+
gated = false;
|
|
131
|
+
else {
|
|
132
|
+
holdsPlace = true;
|
|
133
|
+
running += 1;
|
|
134
|
+
}
|
|
135
|
+
go();
|
|
136
|
+
}, "drained");
|
|
137
|
+
settle();
|
|
138
|
+
}));
|
|
139
|
+
turns = turn.then(() => ended && !holdsPlace ? void 0 : new Promise((free) => release = free));
|
|
140
|
+
return turn;
|
|
141
|
+
}, "alone");
|
|
142
|
+
const answer = /* @__PURE__ */ __name(async () => {
|
|
143
|
+
const request = requestOf(line, cli);
|
|
144
|
+
if ("error" in request)
|
|
145
|
+
return send({ id: request.id, code: 2, stdout: "", stderr: refusal(cli, request.error) });
|
|
146
|
+
const answered = await run(request.argv, alone);
|
|
147
|
+
return send({ id: request.id, ...answered });
|
|
148
|
+
}, "answer");
|
|
149
|
+
answer().catch(finish).finally(() => {
|
|
150
|
+
ended = true;
|
|
151
|
+
active -= 1;
|
|
152
|
+
if (holdsPlace)
|
|
153
|
+
running -= 1;
|
|
154
|
+
if (release) {
|
|
155
|
+
gated = false;
|
|
156
|
+
release();
|
|
157
|
+
}
|
|
158
|
+
settle();
|
|
159
|
+
});
|
|
160
|
+
}, "start");
|
|
161
|
+
const pump = /* @__PURE__ */ __name(() => {
|
|
162
|
+
while (!done && !gated && running < concurrent && waiting.length > 0)
|
|
163
|
+
start(waiting.shift());
|
|
164
|
+
}, "pump");
|
|
165
|
+
lines.on("line", (line) => {
|
|
166
|
+
if (done || ending || line.trim() === "")
|
|
167
|
+
return;
|
|
168
|
+
clearTimeout(timer);
|
|
169
|
+
waiting.push(line);
|
|
170
|
+
pump();
|
|
171
|
+
});
|
|
172
|
+
const end = /* @__PURE__ */ __name(() => {
|
|
173
|
+
ending = true;
|
|
174
|
+
settle();
|
|
175
|
+
}, "end");
|
|
176
|
+
lines.on("close", end);
|
|
177
|
+
if (signal?.aborted)
|
|
178
|
+
end();
|
|
179
|
+
signal?.addEventListener("abort", end, { once: true });
|
|
180
|
+
settle();
|
|
181
|
+
});
|
|
182
|
+
}, "serveCommands");
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
COMMAND_SERVER_CONCURRENT,
|
|
186
|
+
enterCommandServer,
|
|
187
|
+
serveCommands
|
|
188
|
+
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__name
|
|
5
5
|
} from "./chunk-ZVVMGPBJ.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
|
|
8
8
|
var botInstructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => [
|
|
9
9
|
`The owner's ${name} bot "${profile}", through the official Bot API \u2014 not the owner's personal account. What it writes, people see as the bot.`,
|
|
10
10
|
"Use these tools to read the chats this bot is in, find a message or a person, and \u2014 when the profile allows \u2014 write as the bot.",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SCHEMA_DIALECT,
|
|
5
|
+
commandContract,
|
|
6
|
+
commandPathOf,
|
|
7
|
+
findCommand,
|
|
8
|
+
outputOf
|
|
9
|
+
} from "./chunk-RUASZW3M.js";
|
|
10
|
+
import "./chunk-FKWUUCX2.js";
|
|
11
|
+
import "./chunk-Q4OKEN3B.js";
|
|
12
|
+
import "./chunk-AUTX2MLF.js";
|
|
13
|
+
import "./chunk-DW3F6DUW.js";
|
|
14
|
+
import "./chunk-SWKQ6IAR.js";
|
|
15
|
+
import "./chunk-MTO6YVMN.js";
|
|
16
|
+
import "./chunk-O373QEAJ.js";
|
|
17
|
+
import "./chunk-WOX7FZJP.js";
|
|
18
|
+
import "./chunk-3KSK5BBB.js";
|
|
19
|
+
import "./chunk-Q6K2XUGU.js";
|
|
20
|
+
import "./chunk-3FD3IATT.js";
|
|
21
|
+
import "./chunk-TI7ZIPA2.js";
|
|
22
|
+
import "./chunk-B72343TK.js";
|
|
23
|
+
import "./chunk-YVNHQFLC.js";
|
|
24
|
+
import "./chunk-FNLUKODV.js";
|
|
25
|
+
import "./chunk-X7J3TTDO.js";
|
|
26
|
+
import "./chunk-Y5E2WNWB.js";
|
|
27
|
+
import "./chunk-VUBZFMGP.js";
|
|
28
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
29
|
+
export {
|
|
30
|
+
SCHEMA_DIALECT,
|
|
31
|
+
commandContract,
|
|
32
|
+
commandPathOf,
|
|
33
|
+
findCommand,
|
|
34
|
+
outputOf
|
|
35
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
COMMAND_SERVER_CONCURRENT,
|
|
5
|
+
enterCommandServer,
|
|
6
|
+
serveCommands
|
|
7
|
+
} from "./chunk-ZO4MQWIK.js";
|
|
8
|
+
import "./chunk-EKGRNFYQ.js";
|
|
9
|
+
import {
|
|
10
|
+
ensureSqlite
|
|
11
|
+
} from "./chunk-IRUN4XOV.js";
|
|
12
|
+
import "./chunk-RUASZW3M.js";
|
|
13
|
+
import {
|
|
14
|
+
commandServerRequest,
|
|
15
|
+
exitCodeSet,
|
|
16
|
+
inCommandServerRequest
|
|
17
|
+
} from "./chunk-FKWUUCX2.js";
|
|
18
|
+
import "./chunk-Q4OKEN3B.js";
|
|
19
|
+
import "./chunk-AUTX2MLF.js";
|
|
20
|
+
import "./chunk-DW3F6DUW.js";
|
|
21
|
+
import "./chunk-SWKQ6IAR.js";
|
|
22
|
+
import "./chunk-MTO6YVMN.js";
|
|
23
|
+
import {
|
|
24
|
+
asOwnProcess
|
|
25
|
+
} from "./chunk-O373QEAJ.js";
|
|
26
|
+
import "./chunk-WOX7FZJP.js";
|
|
27
|
+
import "./chunk-3KSK5BBB.js";
|
|
28
|
+
import "./chunk-Q6K2XUGU.js";
|
|
29
|
+
import "./chunk-3FD3IATT.js";
|
|
30
|
+
import "./chunk-TI7ZIPA2.js";
|
|
31
|
+
import "./chunk-B72343TK.js";
|
|
32
|
+
import "./chunk-YVNHQFLC.js";
|
|
33
|
+
import "./chunk-U6MMQNNK.js";
|
|
34
|
+
import "./chunk-A6J4MPTI.js";
|
|
35
|
+
import "./chunk-FNLUKODV.js";
|
|
36
|
+
import {
|
|
37
|
+
catchCrashes
|
|
38
|
+
} from "./chunk-X7J3TTDO.js";
|
|
39
|
+
import "./chunk-Y5E2WNWB.js";
|
|
40
|
+
import {
|
|
41
|
+
CliError
|
|
42
|
+
} from "./chunk-VUBZFMGP.js";
|
|
43
|
+
import {
|
|
44
|
+
__name
|
|
45
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
46
|
+
|
|
47
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.630.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_4dc2b7e09a64a37f199c7e635efe1b87/node_modules/@wirecat/cli-core/dist/cli/command-server-entry.js
|
|
48
|
+
import { PassThrough } from "node:stream";
|
|
49
|
+
var route = /* @__PURE__ */ __name((stream, sink) => {
|
|
50
|
+
const original = stream.write;
|
|
51
|
+
stream.write = ((chunk, encoding, callback) => {
|
|
52
|
+
sink()(typeof chunk === "string" ? Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8") : Buffer.from(chunk));
|
|
53
|
+
const done = typeof encoding === "function" ? encoding : callback;
|
|
54
|
+
if (done)
|
|
55
|
+
process.nextTick(done);
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
return () => {
|
|
59
|
+
stream.write = original;
|
|
60
|
+
};
|
|
61
|
+
}, "route");
|
|
62
|
+
var closedStdin = /* @__PURE__ */ __name(() => {
|
|
63
|
+
const stdin = new PassThrough();
|
|
64
|
+
stdin.end();
|
|
65
|
+
return stdin;
|
|
66
|
+
}, "closedStdin");
|
|
67
|
+
var useStdin = /* @__PURE__ */ __name((outside) => Object.defineProperty(process, "stdin", {
|
|
68
|
+
get: /* @__PURE__ */ __name(() => commandServerRequest()?.stdin ?? outside, "get"),
|
|
69
|
+
configurable: true,
|
|
70
|
+
enumerable: true
|
|
71
|
+
}), "useStdin");
|
|
72
|
+
var roomFor = /* @__PURE__ */ __name((runs) => {
|
|
73
|
+
const emitters = [process, process.stdout, process.stderr];
|
|
74
|
+
const before = emitters.map((emitter) => emitter.getMaxListeners());
|
|
75
|
+
for (const emitter of emitters)
|
|
76
|
+
emitter.setMaxListeners(emitter.getMaxListeners() + 2 * runs);
|
|
77
|
+
return () => {
|
|
78
|
+
for (const [at, emitter] of emitters.entries())
|
|
79
|
+
emitter.setMaxListeners(before[at]);
|
|
80
|
+
};
|
|
81
|
+
}, "roomFor");
|
|
82
|
+
var serveEntry = /* @__PURE__ */ __name(async (entry, io, { firstRunAt, commanderExit }) => {
|
|
83
|
+
const release = catchCrashes({
|
|
84
|
+
cli: entry.app.command,
|
|
85
|
+
interactive: false,
|
|
86
|
+
...entry.reasons ? { reasons: entry.reasons } : {},
|
|
87
|
+
target: io.signals
|
|
88
|
+
});
|
|
89
|
+
const stopper = new AbortController();
|
|
90
|
+
const stop = /* @__PURE__ */ __name(() => stopper.abort(new CliError("cancelled", "the command server was stopped", { retryable: false })), "stop");
|
|
91
|
+
const protocol = io.stdout.write.bind(io.stdout);
|
|
92
|
+
const ownStderr = io.stderr.write.bind(io.stderr);
|
|
93
|
+
const toStderr = /* @__PURE__ */ __name((chunk) => {
|
|
94
|
+
ownStderr(chunk);
|
|
95
|
+
}, "toStderr");
|
|
96
|
+
const sink = /* @__PURE__ */ __name((pick) => () => {
|
|
97
|
+
const request = commandServerRequest();
|
|
98
|
+
return request ? (chunk) => pick(request).push(chunk) : toStderr;
|
|
99
|
+
}, "sink");
|
|
100
|
+
const unrouteOut = route(process.stdout, sink((request) => request.stdout));
|
|
101
|
+
const unrouteErr = route(process.stderr, sink((request) => request.stderr));
|
|
102
|
+
const stdin = Object.getOwnPropertyDescriptor(process, "stdin");
|
|
103
|
+
const requests = io.stdin;
|
|
104
|
+
useStdin(closedStdin());
|
|
105
|
+
const unroom = roomFor(COMMAND_SERVER_CONCURRENT);
|
|
106
|
+
io.signals.on("SIGINT", stop).on("SIGTERM", stop);
|
|
107
|
+
io.stdout.on("error", stop);
|
|
108
|
+
const run = /* @__PURE__ */ __name(async (argv, alone) => {
|
|
109
|
+
const request = { stdout: [], stderr: [], stdin: closedStdin(), alone };
|
|
110
|
+
const requestIo = { ...io, argv: [...io.argv.slice(0, 2), ...argv], stdin: request.stdin };
|
|
111
|
+
const context = {
|
|
112
|
+
args: argv,
|
|
113
|
+
env: io.env,
|
|
114
|
+
tty: false,
|
|
115
|
+
signal: stopper.signal,
|
|
116
|
+
atStart: /* @__PURE__ */ __name(async (command) => {
|
|
117
|
+
await enterCommandServer(command, entry.app.command);
|
|
118
|
+
await firstRunAt(entry, requestIo, () => true)(command);
|
|
119
|
+
}, "atStart"),
|
|
120
|
+
ask: /* @__PURE__ */ __name(async () => false, "ask"),
|
|
121
|
+
openBrowser: /* @__PURE__ */ __name(async () => void 0, "openBrowser"),
|
|
122
|
+
outputClosed: /* @__PURE__ */ __name(() => false, "outputClosed"),
|
|
123
|
+
setExitCode: /* @__PURE__ */ __name((code2) => {
|
|
124
|
+
request.exitCode = code2;
|
|
125
|
+
}, "setExitCode")
|
|
126
|
+
};
|
|
127
|
+
const code = await inCommandServerRequest(request, () => asOwnProcess(async () => {
|
|
128
|
+
try {
|
|
129
|
+
const returned = await entry.run(context);
|
|
130
|
+
return typeof returned === "number" ? returned : exitCodeSet() ?? 0;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return commanderExit(error) ?? entry.fail(error, context);
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
const text = /* @__PURE__ */ __name((chunks) => Buffer.concat(chunks).toString("utf8"), "text");
|
|
136
|
+
return { code, stdout: text(request.stdout), stderr: text(request.stderr) };
|
|
137
|
+
}, "run");
|
|
138
|
+
try {
|
|
139
|
+
if (entry.sqlite)
|
|
140
|
+
await ensureSqlite();
|
|
141
|
+
await serveCommands({
|
|
142
|
+
input: requests,
|
|
143
|
+
write: /* @__PURE__ */ __name((line) => new Promise((resolve) => protocol(line) ? resolve() : io.stdout.once("drain", resolve)), "write"),
|
|
144
|
+
run,
|
|
145
|
+
cli: entry.app.command,
|
|
146
|
+
concurrent: COMMAND_SERVER_CONCURRENT,
|
|
147
|
+
version: entry.app.version,
|
|
148
|
+
signal: stopper.signal
|
|
149
|
+
});
|
|
150
|
+
io.setExitCode(0);
|
|
151
|
+
} finally {
|
|
152
|
+
io.signals.off("SIGINT", stop).off("SIGTERM", stop);
|
|
153
|
+
unroom();
|
|
154
|
+
unrouteOut();
|
|
155
|
+
unrouteErr();
|
|
156
|
+
if (stdin)
|
|
157
|
+
Object.defineProperty(process, "stdin", stdin);
|
|
158
|
+
requests.destroy?.();
|
|
159
|
+
release();
|
|
160
|
+
}
|
|
161
|
+
}, "serveEntry");
|
|
162
|
+
export {
|
|
163
|
+
serveEntry
|
|
164
|
+
};
|