@wirecat/tg-cli 0.115.0 → 0.117.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/dist/bin/tg.js +2 -2
- package/dist/bot/transport.d.ts +11 -9
- package/dist/bot/transport.d.ts.map +1 -1
- package/dist/bot/transport.js +58 -32
- package/dist/bot/transport.js.map +1 -1
- package/dist/bundle/{adapter-ODK7R4LY.js → adapter-VNQ72MBK.js} +98 -63
- package/dist/bundle/{all-profiles-AQYM65BS.js → all-profiles-3W2UQTCK.js} +10 -9
- package/dist/bundle/{anthropic-VBDSVNIM.js → anthropic-DFUW2KTG.js} +6 -6
- package/dist/bundle/{app-server-YOIHLBNS.js → app-server-5XJIMLHB.js} +49 -45
- package/dist/bundle/{bot-api-TRYLGQKK.js → bot-api-HRRBF3W6.js} +50 -49
- package/dist/bundle/{bot-history-7DTJLBBJ.js → bot-history-GBH5XE4N.js} +18 -17
- package/dist/bundle/{bun-XIMM6EHD.js → bun-ZMOYGG6F.js} +2 -2
- package/dist/bundle/{bun-sqlite-6B3BL5IV.js → bun-sqlite-6FZFMA7K.js} +5 -5
- package/dist/bundle/{chunk-DIABP7ZP.js → chunk-2452HCIV.js} +3 -3
- package/dist/bundle/{chunk-WMG4IGEB.js → chunk-2XLKZL6K.js} +77 -38
- package/dist/bundle/chunk-3GRX7WP6.js +35 -0
- package/dist/bundle/{chunk-WINKEV4F.js → chunk-3MQOLYAN.js} +4 -4
- package/dist/bundle/{chunk-KDOBY524.js → chunk-3RJYLN5V.js} +133 -27
- package/dist/bundle/{chunk-Y3AQHPAJ.js → chunk-4JDGN6OD.js} +1 -1
- package/dist/bundle/{chunk-JZXQZW2D.js → chunk-56Q5JV3Z.js} +2 -2
- package/dist/bundle/{chunk-XIYRHIBK.js → chunk-66FZBLRJ.js} +13 -13
- package/dist/bundle/{chunk-OUX3QMYI.js → chunk-6GFUL4OU.js} +228 -84
- package/dist/bundle/{chunk-O7CBGHI7.js → chunk-6HRN7BW6.js} +1 -1
- package/dist/bundle/{chunk-TQYMLXDS.js → chunk-7NBUT62O.js} +3 -3
- package/dist/bundle/{chunk-A4BQGSKI.js → chunk-7Y3RUEVY.js} +6 -6
- package/dist/bundle/chunk-AG6HWPQP.js +64 -0
- package/dist/bundle/{chunk-GCFU6WBE.js → chunk-AUBRELCM.js} +3 -3
- package/dist/bundle/{chunk-PEKTB3FQ.js → chunk-B2YPB5AE.js} +56 -27
- package/dist/bundle/{chunk-CCHHEMPM.js → chunk-BXTDAGM4.js} +3 -2
- package/dist/bundle/{chunk-QK6VLKG5.js → chunk-C6TUVV7E.js} +674 -316
- package/dist/bundle/{chunk-XY7IGVVS.js → chunk-EA2PGDER.js} +2 -2
- package/dist/bundle/{chunk-KIZT2MI6.js → chunk-EL6I4WTB.js} +1 -1
- package/dist/bundle/{chunk-77M3IAVU.js → chunk-EPCFXKTX.js} +27 -8
- package/dist/bundle/{chunk-L4CMCC3V.js → chunk-EZTYJ43A.js} +4 -2
- package/dist/bundle/{chunk-PEJHI7QO.js → chunk-F6KBVIJP.js} +4 -4
- package/dist/bundle/{chunk-UY7GJRGY.js → chunk-FAHHERJ7.js} +4 -4
- package/dist/bundle/{chunk-WOQGUIXE.js → chunk-FEKXHILZ.js} +1 -1
- package/dist/bundle/chunk-G7B5UIE7.js +182 -0
- package/dist/bundle/{chunk-RFRI2HFT.js → chunk-GFHNQBD2.js} +1 -1
- package/dist/bundle/{chunk-TMATSEP5.js → chunk-HORGORHK.js} +12 -12
- package/dist/bundle/{chunk-2TC76TLJ.js → chunk-HWYSRB64.js} +2 -2
- package/dist/bundle/{chunk-GX4DMI4H.js → chunk-HZZGOLGP.js} +15 -12
- package/dist/bundle/{chunk-MUZ4KYGY.js → chunk-JWIUK3SK.js} +2 -2
- package/dist/bundle/{chunk-WDNNN3J4.js → chunk-KVTLT4V7.js} +6 -6
- package/dist/bundle/{chunk-UBQ3LOF6.js → chunk-L5WNE4WS.js} +2 -2
- package/dist/bundle/{chunk-OMP6ALBT.js → chunk-M7V5XRM6.js} +3 -3
- package/dist/bundle/{chunk-LUIPXRKN.js → chunk-MLHKQDUN.js} +647 -129
- package/dist/bundle/{chunk-VQCWVZWG.js → chunk-MP7M6FFU.js} +6 -6
- package/dist/bundle/{chunk-5ROWSRK7.js → chunk-NUCDEOFC.js} +2 -2
- package/dist/bundle/{chunk-ILHTNOIV.js → chunk-P3ASN72F.js} +1 -1
- package/dist/bundle/{chunk-VVKEWWSO.js → chunk-PTIB7NEE.js} +1 -1
- package/dist/bundle/{chunk-D4E345BC.js → chunk-Q7O4CQDO.js} +4 -2
- package/dist/bundle/{chunk-EW3XTUPB.js → chunk-QOGYHU3Q.js} +4 -4
- package/dist/bundle/{chunk-BEQPZA3S.js → chunk-RDH2QBUE.js} +3 -3
- package/dist/bundle/{chunk-AVWPMJ6E.js → chunk-RDSLSV4M.js} +2 -2
- package/dist/bundle/{chunk-YCUQKFGD.js → chunk-SQXB5ZUZ.js} +3 -3
- package/dist/bundle/{chunk-RHUNMU4Q.js → chunk-TFBHDIGY.js} +4 -4
- package/dist/bundle/{chunk-OSP335AJ.js → chunk-TG6ZYL4B.js} +8 -8
- package/dist/bundle/{chunk-IUDIRZVU.js → chunk-UGPZCNYC.js} +991 -536
- package/dist/bundle/{chunk-AICS3TSF.js → chunk-UYK5AXSW.js} +4 -4
- package/dist/bundle/{chunk-PZAEI4NM.js → chunk-V2T7NYNU.js} +55 -46
- package/dist/bundle/{chunk-HZKWB6WS.js → chunk-V47NPSSV.js} +28 -28
- package/dist/bundle/{chunk-U67TSAAO.js → chunk-VMCQGZIA.js} +1893 -840
- package/dist/bundle/{chunk-CNO3R4O4.js → chunk-VRDVXXXD.js} +8 -8
- package/dist/bundle/{chunk-PQLBPYJR.js → chunk-VW6BF6M7.js} +1 -1
- package/dist/bundle/{chunk-M7B5IMH3.js → chunk-X3CD475M.js} +1336 -366
- package/dist/bundle/chunk-XW5C4TI7.js +91 -0
- package/dist/bundle/{chunk-NTW5ZE47.js → chunk-YHZFGUAP.js} +39 -33
- package/dist/bundle/{chunk-BIEBJLYO.js → chunk-YIXXH74F.js} +2 -2
- package/dist/bundle/{chunk-BPPRR7TV.js → chunk-Z4QKLHJW.js} +15587 -1637
- package/dist/bundle/{chunk-POKTQZOM.js → chunk-ZPILMEFY.js} +12 -89
- package/dist/bundle/command-contract-KMMHARMR.js +33 -0
- package/dist/bundle/{decode-2GATBZGH.js → decode-YMSOY2AY.js} +5 -5
- package/dist/bundle/{dispatch-MJMW7WDH.js → dispatch-OP27MWX5.js} +8 -8
- package/dist/bundle/{echarts-GKEZEAL7.js → echarts-7XS55TQY.js} +2 -2
- package/dist/bundle/{embed-TBQPLA4Y.js → embed-QTOE7NN3.js} +6 -6
- package/dist/bundle/{embedder-B5DTNCRO.js → embedder-KBBRYSNH.js} +9 -9
- package/dist/bundle/{entry-A6DEW2TD.js → entry-HGEUYYMX.js} +7 -7
- package/dist/bundle/{failure-TLF3SISS.js → failure-4JUQFXJT.js} +2 -2
- package/dist/bundle/{first-run-3N5AABEY.js → first-run-CSGMEJXY.js} +11 -11
- package/dist/bundle/first-screen-K2PBNJNE.js +31 -0
- package/dist/bundle/{instructions-P5E34PQR.js → instructions-S6ZXCTFH.js} +1 -1
- package/dist/bundle/{mcp-MNI62HHE.js → mcp-M4QN2E7R.js} +2 -2
- package/dist/bundle/{node-GKPRXS5Y.js → node-LCIUWXXG.js} +2 -2
- package/dist/bundle/{node-sqlite-GIDPALK3.js → node-sqlite-HL4WY4N2.js} +6 -6
- package/dist/bundle/{oauth-C57W4IMD.js → oauth-U4KIMDKG.js} +7 -7
- package/dist/bundle/{open-E6Q4WRPU.js → open-EH7OS7M7.js} +5 -5
- package/dist/bundle/{openai-5WMXY2KP.js → openai-W5TB3NA5.js} +14 -14
- package/dist/bundle/{process-U2P5Z6UF.js → process-3CVLTCTA.js} +1 -1
- package/dist/bundle/{program-FEUDU6GF.js → program-LOIZTK2P.js} +58 -50
- package/dist/bundle/{prompt-4NGAZGHE.js → prompt-IDNH7N3W.js} +5 -5
- package/dist/bundle/{proxy-transport-MGCJ7JAW.js → proxy-transport-4DPZB2W2.js} +5 -5
- package/dist/bundle/{recognize-EUHRBA7V.js → recognize-G5EWYXIF.js} +4 -4
- package/dist/bundle/{remote-3JHLB2FV.js → remote-4XTBZVZD.js} +7 -7
- package/dist/bundle/{rerank-ZZ45SZPC.js → rerank-OWSTDLZN.js} +7 -7
- package/dist/bundle/{serve-XOGX5FC5.js → serve-YCPSEWP3.js} +9 -9
- package/dist/bundle/server-KELKX6S3.js +60 -0
- package/dist/bundle/{server-I6O72XP5.js → server-ODG4A2KK.js} +35 -34
- package/dist/bundle/{state-BIUYTGH6.js → state-OL2235G5.js} +6 -6
- package/dist/bundle/{store-FOJFYOMR.js → store-5AACYNDM.js} +17 -12
- package/dist/bundle/store-maintenance-command-3J7WZYVN.js +50 -0
- package/dist/bundle/tg.js +13 -13
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +7 -0
- package/dist/commands/session.js.map +1 -1
- package/dist/telegram/account.d.ts.map +1 -1
- package/dist/telegram/account.js +4 -1
- package/dist/telegram/account.js.map +1 -1
- package/dist/telegram/errors.d.ts.map +1 -1
- package/dist/telegram/errors.js +2 -1
- package/dist/telegram/errors.js.map +1 -1
- package/dist/telegram/feature.d.ts +4 -1
- package/dist/telegram/feature.d.ts.map +1 -1
- package/dist/telegram/feature.js +5 -2
- package/dist/telegram/feature.js.map +1 -1
- package/dist/telegram/login.d.ts +2 -0
- package/dist/telegram/login.d.ts.map +1 -1
- package/dist/telegram/login.js +31 -2
- package/dist/telegram/login.js.map +1 -1
- package/dist/telegram/sending.d.ts.map +1 -1
- package/dist/telegram/sending.js +24 -10
- package/dist/telegram/sending.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/bundle/chunk-63YKD7YA.js +0 -18
- package/dist/bundle/chunk-GWDMKEDY.js +0 -48
- package/dist/bundle/chunk-WMRFAK5B.js +0 -132
- package/dist/bundle/command-contract-YF4KGFXC.js +0 -32
- package/dist/bundle/first-screen-HANARM67.js +0 -30
- package/dist/bundle/server-DRE5MJ76.js +0 -59
- package/dist/bundle/store-maintenance-command-YKV2C34N.js +0 -49
- /package/dist/bundle/{chunk-NUN6OGOV.js → chunk-VOXIGICJ.js} +0 -0
package/dist/bin/tg.js
CHANGED
|
@@ -9,7 +9,7 @@ if (
|
|
|
9
9
|
(words[0] === "--version" || words[0] === "-V") &&
|
|
10
10
|
!Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
|
|
11
11
|
) {
|
|
12
|
-
process.stdout.write("0.
|
|
12
|
+
process.stdout.write("0.117.0\n")
|
|
13
13
|
} else {
|
|
14
14
|
// Before the bundle compiles: the bundle's own call comes after its chunks.
|
|
15
15
|
module.enableCompileCache()
|
|
@@ -28,7 +28,7 @@ if (
|
|
|
28
28
|
: next(specifier, context),
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
|
-
const chunks = ["../bundle/adapter-
|
|
31
|
+
const chunks = ["../bundle/adapter-VNQ72MBK.js","../bundle/all-profiles-3W2UQTCK.js","../bundle/anthropic-DFUW2KTG.js","../bundle/app-server-5XJIMLHB.js","../bundle/bot-api-HRRBF3W6.js","../bundle/bot-history-GBH5XE4N.js","../bundle/bun-ZMOYGG6F.js","../bundle/bun-sqlite-6FZFMA7K.js","../bundle/command-contract-KMMHARMR.js","../bundle/decode-YMSOY2AY.js","../bundle/dispatch-OP27MWX5.js","../bundle/dist-I7OZPHAZ.js","../bundle/echarts-7XS55TQY.js","../bundle/embed-QTOE7NN3.js","../bundle/embedder-KBBRYSNH.js","../bundle/entry-HGEUYYMX.js","../bundle/failure-4JUQFXJT.js","../bundle/first-run-CSGMEJXY.js","../bundle/first-screen-K2PBNJNE.js","../bundle/instructions-S6ZXCTFH.js","../bundle/mcp-M4QN2E7R.js","../bundle/node-LCIUWXXG.js","../bundle/node-P4E63KXA.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-HL4WY4N2.js","../bundle/oauth-U4KIMDKG.js","../bundle/open-EH7OS7M7.js","../bundle/openai-W5TB3NA5.js","../bundle/process-3CVLTCTA.js","../bundle/program-LOIZTK2P.js","../bundle/prompt-IDNH7N3W.js","../bundle/proxy-transport-4DPZB2W2.js","../bundle/recognize-G5EWYXIF.js","../bundle/remote-4XTBZVZD.js","../bundle/rerank-OWSTDLZN.js","../bundle/serve-YCPSEWP3.js","../bundle/server-KELKX6S3.js","../bundle/server-ODG4A2KK.js","../bundle/state-OL2235G5.js","../bundle/store-5AACYNDM.js","../bundle/store-maintenance-command-3J7WZYVN.js"]
|
|
32
32
|
if (((words) => words
|
|
33
33
|
.filter((word) => !word.startsWith("-"))
|
|
34
34
|
.slice(0, 2)
|
package/dist/bot/transport.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface BotTransportOptions {
|
|
|
14
14
|
*
|
|
15
15
|
* ⚠ **The token is part of every address** — `/bot<token>/<method>` — so the address never leaves
|
|
16
16
|
* this class: not in an error, not in a trace line, and never by passing on a failed request's own
|
|
17
|
-
* error, whose text may hold it. A failure keeps the method
|
|
17
|
+
* error, whose text may hold it. A failure keeps the method and Telegram's code, never Telegram's words.
|
|
18
18
|
*/
|
|
19
19
|
export declare class TelegramBotTransport {
|
|
20
20
|
#private;
|
|
@@ -24,14 +24,15 @@ export declare class TelegramBotTransport {
|
|
|
24
24
|
* anyone. `file` goes up in the same request, as multipart: Telegram has no upload step of its own.
|
|
25
25
|
* `timeoutMs` replaces the transport's for one call — a long poll waits longer than any other request.
|
|
26
26
|
*/
|
|
27
|
-
call(method: string, params?: Record<string, unknown>,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
call(method: string, params?: Record<string, unknown>, options?: CallOptions): Promise<unknown>;
|
|
28
|
+
}
|
|
29
|
+
interface CallOptions {
|
|
30
|
+
reads?: boolean;
|
|
31
|
+
file?: OutgoingFile;
|
|
32
|
+
files?: readonly OutgoingFile[];
|
|
33
|
+
body?: string;
|
|
34
|
+
secrets?: readonly string[];
|
|
35
|
+
timeoutMs?: number;
|
|
35
36
|
}
|
|
36
37
|
/** A file sent with a method — `photo` for sendPhoto, `document`, `voice`. */
|
|
37
38
|
export interface OutgoingFile {
|
|
@@ -39,4 +40,5 @@ export interface OutgoingFile {
|
|
|
39
40
|
name: string;
|
|
40
41
|
blob: Blob;
|
|
41
42
|
}
|
|
43
|
+
export {};
|
|
42
44
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAMtD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE7E,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0GAA0G;IAC1G,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAWD;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAQ/B,YAAY,OAAO,EAAE,mBAAmB,EAOvC;IAED;;;;OAIG;IACG,IAAI,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAMtD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE7E,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0GAA0G;IAC1G,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAWD;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAQ/B,YAAY,OAAO,EAAE,mBAAmB,EAOvC;IAED;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAY5G;CA+GF;AAED,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;CACX"}
|
package/dist/bot/transport.js
CHANGED
|
@@ -7,7 +7,7 @@ const DEFAULT_TIMEOUT_MS = 30_000;
|
|
|
7
7
|
*
|
|
8
8
|
* ⚠ **The token is part of every address** — `/bot<token>/<method>` — so the address never leaves
|
|
9
9
|
* this class: not in an error, not in a trace line, and never by passing on a failed request's own
|
|
10
|
-
* error, whose text may hold it. A failure keeps the method
|
|
10
|
+
* error, whose text may hold it. A failure keeps the method and Telegram's code, never Telegram's words.
|
|
11
11
|
*/
|
|
12
12
|
export class TelegramBotTransport {
|
|
13
13
|
#token;
|
|
@@ -29,7 +29,21 @@ export class TelegramBotTransport {
|
|
|
29
29
|
* anyone. `file` goes up in the same request, as multipart: Telegram has no upload step of its own.
|
|
30
30
|
* `timeoutMs` replaces the transport's for one call — a long poll waits longer than any other request.
|
|
31
31
|
*/
|
|
32
|
-
async call(method, params = {},
|
|
32
|
+
async call(method, params = {}, options = {}) {
|
|
33
|
+
const timeoutMs = options.timeoutMs ?? this.#timeoutMs;
|
|
34
|
+
// Not AbortSignal.timeout: its timer lives until the deadline and holds the run's whole async context, so every
|
|
35
|
+
// finished command stayed in memory for 30 s; bot-api.test.ts ran out of heap on macOS (2026-11-05).
|
|
36
|
+
const deadline = new AbortController();
|
|
37
|
+
const timer = setTimeout(() => deadline.abort(new DOMException(`${method} timed out`, "TimeoutError")), timeoutMs);
|
|
38
|
+
timer.unref();
|
|
39
|
+
try {
|
|
40
|
+
return await this.#send(method, params, { ...options, timeoutMs }, deadline.signal);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async #send(method, params, { reads = true, file, files = [], body, secrets = [], timeoutMs = this.#timeoutMs }, deadline) {
|
|
33
47
|
// The token is the first segment of the real path; `:token` is how cli-core writes it in a run.
|
|
34
48
|
const end = providerRequest(method, this.#events ?? (() => { }), {
|
|
35
49
|
method: "POST",
|
|
@@ -38,7 +52,7 @@ export class TelegramBotTransport {
|
|
|
38
52
|
// A rate-limit retry is made above the transport (cli-core's `patiently`), which names the attempt itself.
|
|
39
53
|
...(currentAttempt() ? {} : { attempt: 1 }),
|
|
40
54
|
});
|
|
41
|
-
const signals = [
|
|
55
|
+
const signals = [deadline, ...(this.#signal ? [this.#signal] : [])];
|
|
42
56
|
let response;
|
|
43
57
|
try {
|
|
44
58
|
response = await this.#fetch(`${this.#baseUrl}/bot${this.#token}/${method}`, {
|
|
@@ -75,11 +89,15 @@ export class TelegramBotTransport {
|
|
|
75
89
|
answer = apiPlainJson(parseApiJson(text));
|
|
76
90
|
}
|
|
77
91
|
catch {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
92
|
+
// A gateway's 502 or 504 is an HTML page, and a write behind it may have gone through.
|
|
93
|
+
const failure = response.status >= 500
|
|
94
|
+
? this.#refused(method, refusalOf(method, {}, response.status), reads)
|
|
95
|
+
: new CliError("invalid_response", `Telegram answered ${method} with something that is not JSON`, {
|
|
96
|
+
operation: method,
|
|
97
|
+
status: response.status,
|
|
98
|
+
});
|
|
99
|
+
end({ ...answered, errorCode: failure.code });
|
|
100
|
+
throw failure;
|
|
83
101
|
}
|
|
84
102
|
if (answer.ok === true) {
|
|
85
103
|
end(answered);
|
|
@@ -92,21 +110,28 @@ export class TelegramBotTransport {
|
|
|
92
110
|
answer.description = answer.description.split(secret).join("[redacted]");
|
|
93
111
|
answer.description = answer.description.replace(/\b\d+:[A-Za-z0-9_-]{20,}\b/g, "[redacted]");
|
|
94
112
|
}
|
|
95
|
-
const refusal = refusalOf(method, answer, response.status);
|
|
113
|
+
const refusal = this.#refused(method, refusalOf(method, answer, response.status), reads);
|
|
96
114
|
end({ ...answered, errorCode: refusal.code });
|
|
97
115
|
throw refusal;
|
|
98
116
|
}
|
|
117
|
+
/** A server failure may come after a write was made; only a refusal says it was not (WC-LIFE-9). */
|
|
118
|
+
#refused(method, refusal, reads) {
|
|
119
|
+
if (reads || refusal.code !== "provider_unavailable")
|
|
120
|
+
return refusal;
|
|
121
|
+
return new CliError("outcome_unknown", `Telegram failed on ${method}; it may or may not have carried it out — check before repeating it`, { ...refusal.details, retryable: false });
|
|
122
|
+
}
|
|
99
123
|
#unanswered(method, error, reads, timeoutMs) {
|
|
100
124
|
// A proxy that refused, or was not there, never passed the request on — not an unknown outcome.
|
|
101
125
|
if (isCliError(error) && error.details.proxy !== undefined)
|
|
102
126
|
return error;
|
|
103
|
-
|
|
104
|
-
if (this.#signal?.aborted && this.#signal.reason?.name !== "TimeoutError") {
|
|
105
|
-
return new CliError("cancelled", `${method} was cancelled`, { operation: method });
|
|
106
|
-
}
|
|
127
|
+
// A cut write may have reached Telegram, and a caller told "cancelled" would send it again (WC-LIFE-9).
|
|
107
128
|
if (!reads) {
|
|
108
129
|
return new CliError("outcome_unknown", `${method} got no answer; Telegram may or may not have carried it out — check before repeating it`, { operation: method, retryable: false });
|
|
109
130
|
}
|
|
131
|
+
if (this.#signal?.aborted && this.#signal.reason?.name !== "TimeoutError") {
|
|
132
|
+
return new CliError("cancelled", `${method} was cancelled`, { operation: method });
|
|
133
|
+
}
|
|
134
|
+
const timedOut = error?.name === "TimeoutError";
|
|
110
135
|
return new CliError(timedOut ? "timeout" : "network_error", timedOut ? `${method} got no answer within ${timeoutMs} ms` : `${method} could not reach Telegram`, { operation: method, retryable: true });
|
|
111
136
|
}
|
|
112
137
|
}
|
|
@@ -122,15 +147,15 @@ const multipart = (params, files) => {
|
|
|
122
147
|
return form;
|
|
123
148
|
};
|
|
124
149
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
150
|
+
* The message is ours, keyed by Telegram's code and its documented `parameters`: Telegram's `description` may quote
|
|
151
|
+
* a chat title or a user's text, so it never reaches a message (WC-SECR-6). A token Telegram cannot parse answers
|
|
152
|
+
* 404, a revoked one 401; the methods called are this code's own.
|
|
127
153
|
*/
|
|
128
154
|
const refusalOf = (method, answer, status) => {
|
|
129
|
-
const said = answer.description ?? `HTTP ${status}`;
|
|
130
155
|
const details = { operation: method, status };
|
|
131
156
|
const retryAfter = answer.parameters?.retry_after;
|
|
132
157
|
if (retryAfter !== undefined) {
|
|
133
|
-
return new CliError("rate_limited", `Telegram asks to wait ${retryAfter} s before ${method}
|
|
158
|
+
return new CliError("rate_limited", `Telegram asks to wait ${retryAfter} s before ${method}`, {
|
|
134
159
|
...details,
|
|
135
160
|
retry_after_ms: retryAfter * 1000,
|
|
136
161
|
retryable: true,
|
|
@@ -138,21 +163,22 @@ const refusalOf = (method, answer, status) => {
|
|
|
138
163
|
}
|
|
139
164
|
const migrated = answer.parameters?.migrate_to_chat_id;
|
|
140
165
|
if (migrated !== undefined) {
|
|
141
|
-
return new CliError("not_found", `this group became a supergroup with id ${migrated} — use that id from now on
|
|
166
|
+
return new CliError("not_found", `this group became a supergroup with id ${migrated} — use that id from now on`, {
|
|
167
|
+
...details,
|
|
168
|
+
migrated_chat_id: String(migrated),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const refused = answer.error_code ?? status;
|
|
172
|
+
if (refused === 401 || refused === 404)
|
|
173
|
+
return new CliError("authentication_error", "Telegram did not accept this bot token", details);
|
|
174
|
+
if (refused === 403) {
|
|
175
|
+
return new CliError("permission_error", `Telegram does not let this bot ${method} there — it may be blocked, not in the chat, or without the right`, details);
|
|
176
|
+
}
|
|
177
|
+
if (refused >= 500)
|
|
178
|
+
return new CliError("provider_unavailable", `Telegram failed on ${method} (${refused})`, details);
|
|
179
|
+
if (refused === 400) {
|
|
180
|
+
return new CliError("validation_error", `Telegram refused ${method} (400): a chat, message or value in it is wrong, or the bot cannot see it`, details);
|
|
142
181
|
}
|
|
143
|
-
|
|
144
|
-
const code = status === 401 || status === 404
|
|
145
|
-
? "authentication_error"
|
|
146
|
-
: status === 403
|
|
147
|
-
? "permission_error"
|
|
148
|
-
: status >= 500
|
|
149
|
-
? "provider_unavailable"
|
|
150
|
-
: /not found/i.test(said)
|
|
151
|
-
? "not_found"
|
|
152
|
-
: status === 400
|
|
153
|
-
? "validation_error"
|
|
154
|
-
: "provider_error";
|
|
155
|
-
const message = code === "authentication_error" ? `Telegram did not accept this bot token (${said})` : `${method}: ${said}`;
|
|
156
|
-
return new CliError(code, message, details);
|
|
182
|
+
return new CliError("provider_error", `Telegram refused ${method} (${refused})`, details);
|
|
157
183
|
};
|
|
158
184
|
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwB,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5G,MAAM,GAAG,GAAG,0BAA0B,CAAA;AACtC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAuBjC;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAQ;IACd,QAAQ,CAAQ;IAChB,MAAM,CAAW;IACjB,UAAU,CAAQ;IAClB,OAAO,CAAyB;IAChC,OAAO,CAAuB;IAEvC,YAAY,OAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;QACpC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAA;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,MAAM,GAA4B,EAAE,EAAE,OAAO,GAAgB,EAAE;QACxF,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAA;QACtD,gHAAgH;QAChH,qGAAqG;QACrG,MAAM,QAAQ,GAAG,IAAI,eAAe,EAA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gB,EAAE,oBAAoB,MAAM,KAAK,OAAO,GAAG,EAAE,OAAO,CAAC,CAAA;AAC3F,CAAC,CAAA"}
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
bareCheck,
|
|
8
8
|
formatMarkdown,
|
|
9
9
|
providerRequest
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-VMCQGZIA.js";
|
|
11
|
+
import "./chunk-FEKXHILZ.js";
|
|
12
12
|
import {
|
|
13
13
|
answerId,
|
|
14
14
|
attachmentsOf,
|
|
@@ -44,68 +44,69 @@ import {
|
|
|
44
44
|
toUploadParams,
|
|
45
45
|
videoMime,
|
|
46
46
|
withCause
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-RDH2QBUE.js";
|
|
48
48
|
import {
|
|
49
49
|
proxiedTransport
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
56
|
-
import "./chunk-
|
|
50
|
+
} from "./chunk-NUCDEOFC.js";
|
|
51
|
+
import "./chunk-JWIUK3SK.js";
|
|
52
|
+
import "./chunk-4JDGN6OD.js";
|
|
53
|
+
import "./chunk-2XLKZL6K.js";
|
|
54
|
+
import "./chunk-3RJYLN5V.js";
|
|
55
|
+
import "./chunk-MLHKQDUN.js";
|
|
56
|
+
import "./chunk-V2T7NYNU.js";
|
|
57
57
|
import {
|
|
58
58
|
pickChat,
|
|
59
59
|
uploadBlob,
|
|
60
60
|
validateFormattedText
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import "./chunk-
|
|
63
|
-
import "./chunk-
|
|
64
|
-
import "./chunk-
|
|
61
|
+
} from "./chunk-UGPZCNYC.js";
|
|
62
|
+
import "./chunk-66FZBLRJ.js";
|
|
63
|
+
import "./chunk-G7B5UIE7.js";
|
|
64
|
+
import "./chunk-VRDVXXXD.js";
|
|
65
65
|
import "./chunk-2ABQZVK4.js";
|
|
66
|
-
import "./chunk-
|
|
66
|
+
import "./chunk-UYK5AXSW.js";
|
|
67
67
|
import {
|
|
68
68
|
currentAttempt,
|
|
69
69
|
runEvent
|
|
70
|
-
} from "./chunk-
|
|
71
|
-
import "./chunk-
|
|
72
|
-
import "./chunk-
|
|
73
|
-
import "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
-
import "./chunk-
|
|
76
|
-
import "./chunk-
|
|
77
|
-
import "./chunk-
|
|
78
|
-
import "./chunk-
|
|
79
|
-
import "./chunk-
|
|
80
|
-
import "./chunk-
|
|
81
|
-
import "./chunk-
|
|
70
|
+
} from "./chunk-X3CD475M.js";
|
|
71
|
+
import "./chunk-AG6HWPQP.js";
|
|
72
|
+
import "./chunk-ZPILMEFY.js";
|
|
73
|
+
import "./chunk-HORGORHK.js";
|
|
74
|
+
import "./chunk-3MQOLYAN.js";
|
|
75
|
+
import "./chunk-VW6BF6M7.js";
|
|
76
|
+
import "./chunk-M7V5XRM6.js";
|
|
77
|
+
import "./chunk-HZZGOLGP.js";
|
|
78
|
+
import "./chunk-Q7O4CQDO.js";
|
|
79
|
+
import "./chunk-FAHHERJ7.js";
|
|
80
|
+
import "./chunk-AUBRELCM.js";
|
|
81
|
+
import "./chunk-EL6I4WTB.js";
|
|
82
82
|
import {
|
|
83
83
|
observedCounters
|
|
84
|
-
} from "./chunk-
|
|
85
|
-
import "./chunk-
|
|
86
|
-
import "./chunk-
|
|
87
|
-
import "./chunk-
|
|
88
|
-
import "./chunk-
|
|
89
|
-
import "./chunk-
|
|
90
|
-
import "./chunk-
|
|
91
|
-
import "./chunk-
|
|
92
|
-
import "./chunk-
|
|
93
|
-
import "./chunk-
|
|
94
|
-
import "./chunk-
|
|
95
|
-
import "./chunk-
|
|
96
|
-
import "./chunk-
|
|
97
|
-
import "./chunk-
|
|
84
|
+
} from "./chunk-Z4QKLHJW.js";
|
|
85
|
+
import "./chunk-C6TUVV7E.js";
|
|
86
|
+
import "./chunk-XW5C4TI7.js";
|
|
87
|
+
import "./chunk-TG6ZYL4B.js";
|
|
88
|
+
import "./chunk-7Y3RUEVY.js";
|
|
89
|
+
import "./chunk-SQXB5ZUZ.js";
|
|
90
|
+
import "./chunk-RDSLSV4M.js";
|
|
91
|
+
import "./chunk-7NBUT62O.js";
|
|
92
|
+
import "./chunk-56Q5JV3Z.js";
|
|
93
|
+
import "./chunk-2452HCIV.js";
|
|
94
|
+
import "./chunk-KVTLT4V7.js";
|
|
95
|
+
import "./chunk-F6KBVIJP.js";
|
|
96
|
+
import "./chunk-3GRX7WP6.js";
|
|
97
|
+
import "./chunk-P3ASN72F.js";
|
|
98
|
+
import "./chunk-VOXIGICJ.js";
|
|
98
99
|
import "./chunk-D72URWJE.js";
|
|
99
|
-
import "./chunk-
|
|
100
|
-
import "./chunk-
|
|
101
|
-
import "./chunk-
|
|
102
|
-
import "./chunk-
|
|
100
|
+
import "./chunk-MP7M6FFU.js";
|
|
101
|
+
import "./chunk-EZTYJ43A.js";
|
|
102
|
+
import "./chunk-YHZFGUAP.js";
|
|
103
|
+
import "./chunk-EPCFXKTX.js";
|
|
103
104
|
import "./chunk-Y5E2WNWB.js";
|
|
104
105
|
import {
|
|
105
106
|
CliError,
|
|
106
107
|
isCliError
|
|
107
|
-
} from "./chunk-
|
|
108
|
-
import "./chunk-
|
|
108
|
+
} from "./chunk-BXTDAGM4.js";
|
|
109
|
+
import "./chunk-6HRN7BW6.js";
|
|
109
110
|
import {
|
|
110
111
|
__name
|
|
111
112
|
} from "./chunk-ZVVMGPBJ.js";
|
|
@@ -153,7 +154,8 @@ var health = /* @__PURE__ */ __name((feature) => {
|
|
|
153
154
|
});
|
|
154
155
|
}, "health");
|
|
155
156
|
var updateProfile = /* @__PURE__ */ __name((feature, { firstName, lastName, description, photo }) => {
|
|
156
|
-
|
|
157
|
+
const what = photo ? "the profile may have changed; repeating it is safe for the name and bio, but puts the photo up again" : "the profile may have changed \u2014 repeating it is safe";
|
|
158
|
+
return feature.write(what, async () => {
|
|
157
159
|
if (firstName !== void 0 || lastName !== void 0 || description !== void 0) {
|
|
158
160
|
await feature.client.updateProfile({
|
|
159
161
|
...firstName === void 0 ? {} : { firstName },
|
|
@@ -181,7 +183,7 @@ var retryDetails = /* @__PURE__ */ __name((sendId, sendAs) => ({
|
|
|
181
183
|
}), "retryDetails");
|
|
182
184
|
var unknownIfUnanswered = /* @__PURE__ */ __name((error, what, details = {}) => {
|
|
183
185
|
const known = toCliError(error, bareCheck);
|
|
184
|
-
if (known instanceof CliError && ["timeout", "network_error"].includes(known.code)) {
|
|
186
|
+
if (known instanceof CliError && ["timeout", "network_error", "provider_unavailable"].includes(known.code)) {
|
|
185
187
|
return withCause(new CliError("outcome_unknown", `no answer from Telegram \u2014 ${what}`, { ...details, reason: "write.unanswered" }), known);
|
|
186
188
|
}
|
|
187
189
|
return error;
|
|
@@ -1206,6 +1208,9 @@ var loginAskingForSms = /* @__PURE__ */ __name(async ({ client }, prompts) => {
|
|
|
1206
1208
|
}
|
|
1207
1209
|
}
|
|
1208
1210
|
}
|
|
1211
|
+
return askPassword(client, prompts);
|
|
1212
|
+
}, "loginAskingForSms");
|
|
1213
|
+
var askPassword = /* @__PURE__ */ __name(async (client, prompts) => {
|
|
1209
1214
|
for (; ; ) {
|
|
1210
1215
|
try {
|
|
1211
1216
|
return await client.checkPassword(await prompts.password());
|
|
@@ -1215,12 +1220,34 @@ var loginAskingForSms = /* @__PURE__ */ __name(async ({ client }, prompts) => {
|
|
|
1215
1220
|
prompts.note("that password was not accepted \u2014 try again");
|
|
1216
1221
|
}
|
|
1217
1222
|
}
|
|
1218
|
-
}, "
|
|
1223
|
+
}, "askPassword");
|
|
1224
|
+
var LOGIN_ENDED = ["SESSION_REVOKED", "USER_DEACTIVATED", "USER_DEACTIVATED_BAN"];
|
|
1225
|
+
var loginByQr = /* @__PURE__ */ __name(async ({ client }, prompts) => {
|
|
1226
|
+
try {
|
|
1227
|
+
return await client.getMe();
|
|
1228
|
+
} catch (error) {
|
|
1229
|
+
if (tl5.RpcError.is(error, "SESSION_PASSWORD_NEEDED"))
|
|
1230
|
+
return askPassword(client, prompts);
|
|
1231
|
+
if (LOGIN_ENDED.some((text) => tl5.RpcError.is(error, text)))
|
|
1232
|
+
await client.logOut().catch(() => {
|
|
1233
|
+
});
|
|
1234
|
+
else if (!tl5.RpcError.is(error, "AUTH_KEY_UNREGISTERED"))
|
|
1235
|
+
throw error;
|
|
1236
|
+
}
|
|
1237
|
+
return client.signInQr({
|
|
1238
|
+
onUrlUpdated: prompts.showQr,
|
|
1239
|
+
onQrScanned: prompts.scanned,
|
|
1240
|
+
password: prompts.password,
|
|
1241
|
+
invalidPasswordCallback: /* @__PURE__ */ __name(() => prompts.note("that password was not accepted \u2014 try again"), "invalidPasswordCallback")
|
|
1242
|
+
});
|
|
1243
|
+
}, "loginByQr");
|
|
1219
1244
|
var login = /* @__PURE__ */ __name((feature, prompts) => feature.call(async () => {
|
|
1220
|
-
if (prompts.method === "
|
|
1245
|
+
if (prompts.method === "qr")
|
|
1246
|
+
return toAccount(await loginByQr(feature, prompts));
|
|
1247
|
+
if (prompts.forceSms)
|
|
1221
1248
|
return toAccount(await loginAskingForSms(feature, prompts));
|
|
1222
1249
|
const user = await feature.client.start({
|
|
1223
|
-
|
|
1250
|
+
phone: prompts.phone,
|
|
1224
1251
|
code: prompts.code,
|
|
1225
1252
|
password: prompts.password,
|
|
1226
1253
|
codeSentCallback: /* @__PURE__ */ __name((sent) => prompts.note(`Telegram sent a login code (${sent.type})`), "codeSentCallback"),
|
|
@@ -1961,19 +1988,27 @@ var recordRequest = /* @__PURE__ */ __name(async (context, next) => {
|
|
|
1961
1988
|
end();
|
|
1962
1989
|
return answer;
|
|
1963
1990
|
}, "recordRequest");
|
|
1991
|
+
var READ = /^[a-z]+\.(get|search|check|resolve)[A-Z]/;
|
|
1992
|
+
var NOT_READ = /* @__PURE__ */ new Set(["messages.getBotCallbackAnswer", "messages.getMessagesViews"]);
|
|
1993
|
+
var isRead = /* @__PURE__ */ __name((method) => READ.test(method) && !NOT_READ.has(method), "isRead");
|
|
1994
|
+
var internalErrors = /* @__PURE__ */ __name(() => {
|
|
1995
|
+
const reads = networkMiddlewares.internalErrorsHandler({});
|
|
1996
|
+
const writes = networkMiddlewares.internalErrorsHandler({ maxRetries: 0 });
|
|
1997
|
+
return (context, next) => (isRead(context.request._) ? reads : writes)(context, next);
|
|
1998
|
+
}, "internalErrors");
|
|
1964
1999
|
var middlewaresOf = /* @__PURE__ */ __name(({ maxWait, maxRetries }, say) => [
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
2000
|
+
networkMiddlewares.mediaThrottle(),
|
|
2001
|
+
networkMiddlewares.floodWaiter({
|
|
2002
|
+
maxWait,
|
|
2003
|
+
maxRetries,
|
|
2004
|
+
onBeforeWait: /* @__PURE__ */ __name((context, seconds) => {
|
|
2005
|
+
const tried = tries.get(context);
|
|
2006
|
+
if (tried)
|
|
2007
|
+
tried.waitMs = seconds * 1e3;
|
|
2008
|
+
say(`Telegram asks to wait ${seconds} s before ${context.request._} \u2014 waiting, then going on`);
|
|
2009
|
+
}, "onBeforeWait")
|
|
1976
2010
|
}),
|
|
2011
|
+
internalErrors(),
|
|
1977
2012
|
// Inside the flood and internal-error waiters, so each retry they make is a line of its own.
|
|
1978
2013
|
recordRequest,
|
|
1979
2014
|
noteAcceptedSend
|
|
@@ -2,28 +2,29 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
answeredWire
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PTIB7NEE.js";
|
|
6
6
|
import {
|
|
7
7
|
CALLER_META_KEY,
|
|
8
8
|
PROXY_CLIENT_NAME,
|
|
9
9
|
StdioServerTransport,
|
|
10
10
|
callerOf,
|
|
11
11
|
serveStdio
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EA2PGDER.js";
|
|
13
13
|
import {
|
|
14
14
|
McpServer
|
|
15
15
|
} from "./chunk-5D4AEUVA.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-ZPILMEFY.js";
|
|
17
|
+
import "./chunk-XW5C4TI7.js";
|
|
18
|
+
import "./chunk-VOXIGICJ.js";
|
|
19
|
+
import "./chunk-YHZFGUAP.js";
|
|
20
|
+
import "./chunk-EPCFXKTX.js";
|
|
20
21
|
import "./chunk-Y5E2WNWB.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-BXTDAGM4.js";
|
|
22
23
|
import {
|
|
23
24
|
__name
|
|
24
25
|
} from "./chunk-ZVVMGPBJ.js";
|
|
25
26
|
|
|
26
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
27
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
27
28
|
import { spawn } from "node:child_process";
|
|
28
29
|
import { randomUUID } from "node:crypto";
|
|
29
30
|
var PROTOCOL = "2025-06-18";
|
|
@@ -257,7 +258,7 @@ var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {})
|
|
|
257
258
|
}, "serveAllProfilesOverStdio");
|
|
258
259
|
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
259
260
|
const { build, close } = allProfilesServer(options);
|
|
260
|
-
const { serveOverHttp } = await import("./serve-
|
|
261
|
+
const { serveOverHttp } = await import("./serve-YCPSEWP3.js");
|
|
261
262
|
const listening = await serveOverHttp(build, {
|
|
262
263
|
...http,
|
|
263
264
|
appName: options.command,
|
|
@@ -2,28 +2,28 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
checkedOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7NBUT62O.js";
|
|
6
6
|
import {
|
|
7
7
|
messagesFor,
|
|
8
8
|
systemFor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-56Q5JV3Z.js";
|
|
10
10
|
import {
|
|
11
11
|
Anthropic
|
|
12
12
|
} from "./chunk-ADLS6FVG.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-YHZFGUAP.js";
|
|
14
14
|
import {
|
|
15
15
|
array,
|
|
16
16
|
optional,
|
|
17
17
|
strictObject,
|
|
18
18
|
string
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EPCFXKTX.js";
|
|
20
20
|
import "./chunk-Y5E2WNWB.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-BXTDAGM4.js";
|
|
22
22
|
import {
|
|
23
23
|
__name
|
|
24
24
|
} from "./chunk-ZVVMGPBJ.js";
|
|
25
25
|
|
|
26
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
26
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._6a3165a3e9bffd3483d86046d9ef2956/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
27
27
|
var options = strictObject({
|
|
28
28
|
stop_sequences: optional(array(string()))
|
|
29
29
|
});
|