@wirecat/tg-cli 0.100.0 → 0.102.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/README.md +3 -3
- package/dist/bin/tg.js +1 -1
- package/dist/bot/transport.d.ts.map +1 -1
- package/dist/bot/transport.js +14 -17
- package/dist/bot/transport.js.map +1 -1
- package/dist/bundle/{adapter-2LVPMFKF.js → adapter-M2HRSFFL.js} +95 -33
- package/dist/bundle/{all-profiles-BLTK2AAB.js → all-profiles-GOD2QNTK.js} +42 -12
- package/dist/bundle/{anthropic-RJE4XEOO.js → anthropic-LKU7RWMA.js} +5 -5
- package/dist/bundle/{bot-api-4XM3NVWG.js → bot-api-X3MPFVPL.js} +49 -53
- package/dist/bundle/{bot-history-WVM5GEQN.js → bot-history-OUMVVG22.js} +15 -15
- package/dist/bundle/{bun-UZXO2LRQ.js → bun-LIZ6MKFS.js} +2 -2
- package/dist/bundle/{bun-sqlite-GJLGSQIT.js → bun-sqlite-2IFQYQ44.js} +4 -4
- package/dist/bundle/chunk-264DAFJV.js +161 -0
- package/dist/bundle/{chunk-ASDZHG5I.js → chunk-2SUTCDGO.js} +2 -2
- package/dist/bundle/{chunk-2IM4M7Q2.js → chunk-2XBSVRT2.js} +1 -1
- package/dist/bundle/{chunk-Q26JMPBP.js → chunk-334UBWOB.js} +11 -11
- package/dist/bundle/{chunk-MQNFEVAH.js → chunk-4PDEQL6T.js} +2 -2
- package/dist/bundle/chunk-4QB4WDLT.js +922 -0
- package/dist/bundle/{chunk-66E5QDLH.js → chunk-5D6OJREA.js} +1 -1
- package/dist/bundle/{chunk-RDQMV6EU.js → chunk-5DFGJPT6.js} +4 -4
- package/dist/bundle/{chunk-GTURDJJD.js → chunk-5KU4UQBM.js} +1 -1
- package/dist/bundle/{chunk-JSKT5UZX.js → chunk-5VSR5ENL.js} +8 -8
- package/dist/bundle/{chunk-DN4QUTWU.js → chunk-AUOXTGTU.js} +1 -1
- package/dist/bundle/{chunk-X4Y2ROJI.js → chunk-BBC546ZA.js} +91 -2
- package/dist/bundle/{chunk-RER6DAHP.js → chunk-BQYTIYGB.js} +171 -148
- package/dist/bundle/{chunk-3S5CL55R.js → chunk-CLWYQNSC.js} +6 -6
- package/dist/bundle/{chunk-I6WZJVRT.js → chunk-CRZPQQHE.js} +59 -46
- package/dist/bundle/chunk-DE7LFMY2.js +440 -0
- package/dist/bundle/{chunk-GYEOQS2D.js → chunk-DG62L57H.js} +17 -17
- package/dist/bundle/{chunk-QU2FJMFB.js → chunk-ENE5CSVY.js} +2903 -1490
- package/dist/bundle/{chunk-P26LWFNZ.js → chunk-ERQDBK5I.js} +1 -1
- package/dist/bundle/{chunk-UD4DOZCN.js → chunk-F2TG3BA2.js} +6 -6
- package/dist/bundle/{chunk-4U7QOFDA.js → chunk-FBWOQMPE.js} +1698 -816
- package/dist/bundle/{chunk-JFJVS5JC.js → chunk-FOUE7XLK.js} +2 -2
- package/dist/bundle/{chunk-3QDPV34J.js → chunk-GSKFAE3I.js} +1297 -518
- package/dist/bundle/{chunk-BAIZAZ6Q.js → chunk-HLAZ65AW.js} +2 -2
- package/dist/bundle/{chunk-LI7TXFLS.js → chunk-JFSVXMN6.js} +3 -3
- package/dist/bundle/{chunk-6VEOR6GD.js → chunk-M5UH5CF3.js} +6 -8
- package/dist/bundle/{chunk-HXTTDIL7.js → chunk-MGG7JSNO.js} +3 -3
- package/dist/bundle/{chunk-6YLT4YVJ.js → chunk-OCWARAFE.js} +2 -2
- package/dist/bundle/{chunk-WE3LBRMB.js → chunk-OEJ5DMCX.js} +7 -7
- package/dist/bundle/{chunk-SGJYU3SB.js → chunk-OHBHHBYL.js} +3 -3
- package/dist/bundle/{chunk-2MXQ2EUN.js → chunk-PSH7K6TL.js} +617 -57
- package/dist/bundle/{chunk-H3X5LS6U.js → chunk-PYTOIDSM.js} +4 -4
- package/dist/bundle/{chunk-ATZ44Z77.js → chunk-Q2NYEX4A.js} +150 -52
- package/dist/bundle/{chunk-KE6L2UEG.js → chunk-QEPZUFPL.js} +70 -61
- package/dist/bundle/{chunk-CV5ASHTW.js → chunk-QL7CQ6VZ.js} +255 -80
- package/dist/bundle/{chunk-THVNP6S6.js → chunk-SRU3OF4R.js} +2 -2
- package/dist/bundle/{chunk-OOOV3JBZ.js → chunk-TV5DGHBT.js} +953 -677
- package/dist/bundle/{chunk-A7OBVRJV.js → chunk-TXBUDJ3P.js} +3 -3
- package/dist/bundle/{chunk-OW3COBN5.js → chunk-U4RRZUNP.js} +9 -9
- package/dist/bundle/{chunk-WKOY3POD.js → chunk-UK3GAN7Q.js} +7 -7
- package/dist/bundle/{chunk-BL36RR34.js → chunk-UR6ASUSG.js} +10 -7
- package/dist/bundle/{chunk-4VBDVZNE.js → chunk-V52SBQYF.js} +242 -19
- package/dist/bundle/{chunk-4YCLWWZ3.js → chunk-VUJ34PEQ.js} +11 -11
- package/dist/bundle/{chunk-2XUGPE5W.js → chunk-W5EB4JLV.js} +3 -3
- package/dist/bundle/{chunk-3KHKYYCR.js → chunk-WMOEOVWZ.js} +1 -0
- package/dist/bundle/{chunk-UMLPXNJI.js → chunk-WVEHUKCZ.js} +1 -1
- package/dist/bundle/{chunk-SYPL4PHV.js → chunk-XXTJUZMB.js} +1 -1
- package/dist/bundle/{chunk-SMJTL5U7.js → chunk-Y4XSWI22.js} +6 -4
- package/dist/bundle/{chunk-HKT5EOT5.js → chunk-YHB57PFN.js} +1 -1
- package/dist/bundle/{chunk-BZANDKWT.js → chunk-ZJVZXJOG.js} +2 -2
- package/dist/bundle/{chunk-QY3YOOTP.js → chunk-ZRNRQFTF.js} +2 -2
- package/dist/bundle/command-contract-A6VZN3ZR.js +31 -0
- package/dist/bundle/{echarts-YHSYUWLY.js → echarts-27W2CIBD.js} +2 -2
- package/dist/bundle/{embed-3HGI2XIW.js → embed-FGJ273X2.js} +4 -4
- package/dist/bundle/{embedder-2CJMZETJ.js → embedder-7ELL3CQ3.js} +7 -7
- package/dist/bundle/{entry-UVE53OV3.js → entry-SEE5YWIX.js} +5 -5
- package/dist/bundle/{first-run-6GYC2QS3.js → first-run-BD7FEC3W.js} +9 -9
- package/dist/bundle/first-screen-ASZV6LSA.js +29 -0
- package/dist/bundle/{identity-HEV5E57G.js → identity-QR4F42T6.js} +3 -3
- package/dist/bundle/{instructions-5UVAXSQV.js → instructions-L74K64PV.js} +1 -1
- package/dist/bundle/{mcp-NWXBVNUA.js → mcp-4Y37G2UY.js} +2 -2
- package/dist/bundle/{node-YHYEGYVE.js → node-RSL3HANO.js} +2 -2
- package/dist/bundle/{node-sqlite-CQ33A3R2.js → node-sqlite-7R3PYQGJ.js} +4 -4
- package/dist/bundle/{oauth-OB3JFAD7.js → oauth-4ESGXF6U.js} +7 -7
- package/dist/bundle/{open-JHGZIXU2.js → open-DFYEUGTA.js} +3 -3
- package/dist/bundle/{process-PSKS3N5B.js → process-RMV3AKLB.js} +1 -1
- package/dist/bundle/{program-RPYVPNRX.js → program-PIUYQHBF.js} +62 -67
- package/dist/bundle/{prompt-7BXUMJGG.js → prompt-H7GYQQLL.js} +4 -4
- package/dist/bundle/{proxy-transport-3EEMW2HW.js → proxy-transport-G4MA6BGU.js} +4 -4
- package/dist/bundle/{recognize-YMZPL47R.js → recognize-3GMOLZF4.js} +5 -5
- package/dist/bundle/{remote-LQ3Q22NG.js → remote-IRWTCI2B.js} +5 -5
- package/dist/bundle/{rerank-SM7IYVXJ.js → rerank-W3OSXXBN.js} +5 -5
- package/dist/bundle/{serve-GHUEP5H5.js → serve-ZCPO44NO.js} +24 -9
- package/dist/bundle/{server-A45HVXQY.js → server-FXU4QFRB.js} +42 -39
- package/dist/bundle/{server-K2BQPPHN.js → server-YWL4HDOP.js} +77 -68
- package/dist/bundle/{state-WIOL52GZ.js → state-MJPTDIB5.js} +9 -5
- package/dist/bundle/{store-XE5AKUJZ.js → store-6VNQG56O.js} +10 -10
- package/dist/bundle/store-maintenance-command-62TQTMER.js +43 -0
- package/dist/bundle/tg.js +4 -4
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +2 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/program.js +1 -1
- package/dist/program.js.map +1 -1
- package/dist/telegram/errors.js +1 -1
- package/dist/telegram/errors.js.map +1 -1
- package/dist/telegram/sending.d.ts.map +1 -1
- package/dist/telegram/sending.js +52 -3
- package/dist/telegram/sending.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/install/windows.ps1 +1 -1
- package/package.json +3 -3
- package/skills/tg-cli/SKILL.md +4 -4
- package/dist/bundle/chunk-3N6LXAPE.js +0 -724
- package/dist/bundle/chunk-DVOUKGFK.js +0 -1950
- package/dist/bundle/chunk-MUEXF4ME.js +0 -582
- package/dist/bundle/chunk-U7LXA4SO.js +0 -1007
- package/dist/bundle/chunk-V4JSVH4M.js +0 -190
- package/dist/bundle/chunk-YG7PNCSW.js +0 -230
- package/dist/bundle/chunk-Z2FHEIXN.js +0 -63
- package/dist/bundle/command-contract-AIVKJYIR.js +0 -31
- package/dist/bundle/first-screen-HRRLVLOG.js +0 -29
- package/dist/bundle/store-maintenance-command-YS5E7VUN.js +0 -46
- /package/dist/bundle/{chunk-3MVHRZWR.js → chunk-2SJOUK6J.js} +0 -0
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ Your agent. Your Telegram. Your rules.
|
|
|
104
104
|
tells them how: `tg personal setup --agent …` or `tg skill install` puts it in place, and `tg skill show`
|
|
105
105
|
prints it before login.
|
|
106
106
|
- **Apps without a terminal** (for example Claude Desktop, Cursor and other MCP clients) connect to
|
|
107
|
-
`tg personal mcp`. It comes with ready prompts: `/catch-up`, `/review`, `/reply`, `/find`, `/open-tasks` and `/link-conversations`.
|
|
107
|
+
`tg personal mcp serve`. It comes with ready prompts: `/catch-up`, `/review`, `/reply`, `/find`, `/open-tasks` and `/link-conversations`.
|
|
108
108
|
|
|
109
109
|
```sh
|
|
110
110
|
tg personal mcp add claude-code # or: tg personal mcp add codex
|
|
@@ -268,11 +268,11 @@ profile's `permissions` decide which may run. `readonly` stops writes; at `ask`
|
|
|
268
268
|
form, so set up approval in your agent app.
|
|
269
269
|
|
|
270
270
|
```sh
|
|
271
|
-
claude mcp add tg -- tg personal mcp # Claude Code, by hand
|
|
271
|
+
claude mcp add tg -- tg personal mcp serve # Claude Code, by hand
|
|
272
272
|
tg personal mcp check # check the local MCP server
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
-
**From the browser.** ChatGPT or Claude in the browser reach `tg personal mcp --http --public-url <url>` behind
|
|
275
|
+
**From the browser.** ChatGPT or Claude in the browser reach `tg personal mcp serve --http --public-url <url>` behind
|
|
276
276
|
your tunnel, after a login with a one-time access code from your terminal.
|
|
277
277
|
|
|
278
278
|
More: [the MCP server](https://github.com/WireCatLabs/tg-cli/blob/main/docs/mcp.md) · [on wirecat.dev](https://wirecat.dev/en/docs/tg/mcp) · [remote access](https://github.com/WireCatLabs/tg-cli/blob/main/docs/remote.md) · [on wirecat.dev](https://wirecat.dev/en/docs/tg/remote)
|
package/dist/bin/tg.js
CHANGED
|
@@ -18,7 +18,7 @@ if (serves && module.registerHooks) {
|
|
|
18
18
|
})
|
|
19
19
|
}
|
|
20
20
|
const running = import("../bundle/tg.js")
|
|
21
|
-
const chunks = ["../bundle/adapter-
|
|
21
|
+
const chunks = ["../bundle/adapter-M2HRSFFL.js","../bundle/all-profiles-GOD2QNTK.js","../bundle/anthropic-LKU7RWMA.js","../bundle/bot-api-X3MPFVPL.js","../bundle/bot-history-OUMVVG22.js","../bundle/bun-LIZ6MKFS.js","../bundle/bun-sqlite-2IFQYQ44.js","../bundle/command-contract-A6VZN3ZR.js","../bundle/dist-RJMT44PL.js","../bundle/echarts-27W2CIBD.js","../bundle/embed-FGJ273X2.js","../bundle/embedder-7ELL3CQ3.js","../bundle/entry-SEE5YWIX.js","../bundle/first-run-BD7FEC3W.js","../bundle/first-screen-ASZV6LSA.js","../bundle/identity-QR4F42T6.js","../bundle/instructions-L74K64PV.js","../bundle/mcp-4Y37G2UY.js","../bundle/node-IUL5HSYI.js","../bundle/node-RSL3HANO.js","../bundle/node-UPPL626U.js","../bundle/node-sqlite-7R3PYQGJ.js","../bundle/oauth-4ESGXF6U.js","../bundle/open-DFYEUGTA.js","../bundle/process-RMV3AKLB.js","../bundle/program-PIUYQHBF.js","../bundle/prompt-H7GYQQLL.js","../bundle/proxy-transport-G4MA6BGU.js","../bundle/recognize-3GMOLZF4.js","../bundle/remote-IRWTCI2B.js","../bundle/rerank-W3OSXXBN.js","../bundle/serve-ZCPO44NO.js","../bundle/server-FXU4QFRB.js","../bundle/server-YWL4HDOP.js","../bundle/state-MJPTDIB5.js","../bundle/store-6VNQG56O.js","../bundle/store-maintenance-command-62TQTMER.js"]
|
|
22
22
|
// After the server answers its first request, so it starts no later.
|
|
23
23
|
if (serves) setTimeout(() => void Promise.allSettled(chunks.map((chunk) => import(chunk))), 2000).unref()
|
|
24
24
|
await running
|
|
@@ -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,CACR,MAAM,E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E,OAAO,CAAA;QACf,IAAI,CAAC,EAAE,YAAY,CAAA;QACnB,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;QAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACd,GACL,OAAO,CAAC,OAAO,CAAC,CAkElB;CAsBF;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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
|
-
import { apiJson, apiPlainJson, parseApiJson } from "@wirecat/cli-core/cli";
|
|
2
|
+
import { apiJson, apiPlainJson, currentAttempt, parseApiJson, providerRequest } from "@wirecat/cli-core/cli";
|
|
3
3
|
const API = "https://api.telegram.org";
|
|
4
4
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
5
5
|
/**
|
|
@@ -31,9 +31,13 @@ export class TelegramBotTransport {
|
|
|
31
31
|
*/
|
|
32
32
|
async call(method, params = {}, { reads = true, file, files = [], body, secrets = [], timeoutMs = this.#timeoutMs, } = {}) {
|
|
33
33
|
// The token is the first segment of the real path; `:token` is how cli-core writes it in a run.
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const end = providerRequest(method, this.#events ?? (() => { }), {
|
|
35
|
+
method: "POST",
|
|
36
|
+
endpointTemplate: `/:token/${method}`,
|
|
37
|
+
transport: "http",
|
|
38
|
+
// A rate-limit retry is made above the transport (cli-core's `patiently`), which names the attempt itself.
|
|
39
|
+
...(currentAttempt() ? {} : { attempt: 1 }),
|
|
40
|
+
});
|
|
37
41
|
const signals = [AbortSignal.timeout(timeoutMs), ...(this.#signal ? [this.#signal] : [])];
|
|
38
42
|
let response;
|
|
39
43
|
try {
|
|
@@ -53,7 +57,7 @@ export class TelegramBotTransport {
|
|
|
53
57
|
}
|
|
54
58
|
catch (error) {
|
|
55
59
|
const failure = this.#unanswered(method, error, reads, timeoutMs);
|
|
56
|
-
|
|
60
|
+
end({ errorCode: failure.code });
|
|
57
61
|
throw failure;
|
|
58
62
|
}
|
|
59
63
|
let text;
|
|
@@ -62,30 +66,23 @@ export class TelegramBotTransport {
|
|
|
62
66
|
}
|
|
63
67
|
catch (error) {
|
|
64
68
|
const failure = this.#unanswered(method, error, reads, timeoutMs);
|
|
65
|
-
|
|
69
|
+
end({ status: response.status, errorCode: failure.code });
|
|
66
70
|
throw failure;
|
|
67
71
|
}
|
|
68
|
-
const answered = {
|
|
69
|
-
event: "response",
|
|
70
|
-
operation: method,
|
|
71
|
-
...http,
|
|
72
|
-
status: response.status,
|
|
73
|
-
bytes: Buffer.byteLength(text),
|
|
74
|
-
durationMs: Math.round(performance.now() - started),
|
|
75
|
-
};
|
|
72
|
+
const answered = { status: response.status, bytes: Buffer.byteLength(text) };
|
|
76
73
|
let answer;
|
|
77
74
|
try {
|
|
78
75
|
answer = apiPlainJson(parseApiJson(text));
|
|
79
76
|
}
|
|
80
77
|
catch {
|
|
81
|
-
|
|
78
|
+
end({ ...answered, errorCode: "invalid_response" });
|
|
82
79
|
throw new CliError("invalid_response", `Telegram answered ${method} with something that is not JSON`, {
|
|
83
80
|
operation: method,
|
|
84
81
|
status: response.status,
|
|
85
82
|
});
|
|
86
83
|
}
|
|
87
84
|
if (answer.ok === true) {
|
|
88
|
-
|
|
85
|
+
end(answered);
|
|
89
86
|
return answer.result;
|
|
90
87
|
}
|
|
91
88
|
const secretValues = [this.#token, ...secrets];
|
|
@@ -96,7 +93,7 @@ export class TelegramBotTransport {
|
|
|
96
93
|
answer.description = answer.description.replace(/\b\d+:[A-Za-z0-9_-]{20,}\b/g, "[redacted]");
|
|
97
94
|
}
|
|
98
95
|
const refusal = refusalOf(method, answer, response.status);
|
|
99
|
-
|
|
96
|
+
end({ ...answered, errorCode: refusal.code });
|
|
100
97
|
throw refusal;
|
|
101
98
|
}
|
|
102
99
|
#unanswered(method, error, reads, timeoutMs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/bot/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9F,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,M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b,CAAC,CAAC,MAAM,KAAK,GAAG;wBACd,CAAC,CAAC,kBAAkB;wBACpB,CAAC,CAAC,gBAAgB,CAAA;IAC9B,MAAM,OAAO,GACX,IAAI,KAAK,sBAAsB,CAAC,CAAC,CAAC,2CAA2C,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,EAAE,CAAA;IAC7G,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA"}
|
|
@@ -35,48 +35,71 @@ import {
|
|
|
35
35
|
toUploadParams,
|
|
36
36
|
videoMime,
|
|
37
37
|
withCause
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-TXBUDJ3P.js";
|
|
39
39
|
import {
|
|
40
40
|
proxiedTransport
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-ZJVZXJOG.js";
|
|
42
42
|
import {
|
|
43
43
|
ADMIN_RIGHTS,
|
|
44
44
|
ADMIN_RIGHT_FIELDS,
|
|
45
45
|
GROUP_SETTINGS,
|
|
46
46
|
bareCheck,
|
|
47
|
-
formatMarkdown
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
-
import "./chunk-
|
|
47
|
+
formatMarkdown,
|
|
48
|
+
providerRequest
|
|
49
|
+
} from "./chunk-ENE5CSVY.js";
|
|
50
|
+
import "./chunk-2XBSVRT2.js";
|
|
51
|
+
import "./chunk-AUOXTGTU.js";
|
|
52
|
+
import "./chunk-CRZPQQHE.js";
|
|
53
|
+
import "./chunk-5D6OJREA.js";
|
|
54
|
+
import "./chunk-V52SBQYF.js";
|
|
55
|
+
import "./chunk-QL7CQ6VZ.js";
|
|
56
|
+
import "./chunk-PSH7K6TL.js";
|
|
53
57
|
import {
|
|
54
58
|
pickChat,
|
|
55
59
|
uploadBlob,
|
|
56
60
|
validateFormattedText
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import "./chunk-
|
|
61
|
+
} from "./chunk-FBWOQMPE.js";
|
|
62
|
+
import "./chunk-5DFGJPT6.js";
|
|
63
|
+
import "./chunk-UK3GAN7Q.js";
|
|
59
64
|
import "./chunk-ZZLKX62Z.js";
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import
|
|
65
|
+
import "./chunk-M5UH5CF3.js";
|
|
66
|
+
import "./chunk-BQYTIYGB.js";
|
|
67
|
+
import {
|
|
68
|
+
currentAttempt,
|
|
69
|
+
runEvent
|
|
70
|
+
} from "./chunk-GSKFAE3I.js";
|
|
71
|
+
import "./chunk-Y4XSWI22.js";
|
|
72
|
+
import "./chunk-DE7LFMY2.js";
|
|
73
|
+
import "./chunk-334UBWOB.js";
|
|
74
|
+
import "./chunk-PYTOIDSM.js";
|
|
75
|
+
import "./chunk-5KU4UQBM.js";
|
|
76
|
+
import "./chunk-OHBHHBYL.js";
|
|
77
|
+
import "./chunk-VUJ34PEQ.js";
|
|
78
|
+
import "./chunk-2SUTCDGO.js";
|
|
79
|
+
import "./chunk-264DAFJV.js";
|
|
80
|
+
import "./chunk-W5EB4JLV.js";
|
|
81
|
+
import "./chunk-WVEHUKCZ.js";
|
|
82
|
+
import "./chunk-SRU3OF4R.js";
|
|
83
|
+
import "./chunk-OCWARAFE.js";
|
|
84
|
+
import "./chunk-JFSVXMN6.js";
|
|
85
|
+
import "./chunk-U4RRZUNP.js";
|
|
63
86
|
import {
|
|
64
87
|
observedCounters
|
|
65
|
-
} from "./chunk-
|
|
66
|
-
import "./chunk-
|
|
67
|
-
import "./chunk-
|
|
68
|
-
import "./chunk-
|
|
69
|
-
import "./chunk-
|
|
70
|
-
import "./chunk-
|
|
71
|
-
import "./chunk-
|
|
72
|
-
import "./chunk-
|
|
73
|
-
import "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
-
import "./chunk-
|
|
88
|
+
} from "./chunk-TV5DGHBT.js";
|
|
89
|
+
import "./chunk-QEPZUFPL.js";
|
|
90
|
+
import "./chunk-5VSR5ENL.js";
|
|
91
|
+
import "./chunk-F2TG3BA2.js";
|
|
92
|
+
import "./chunk-2SJOUK6J.js";
|
|
93
|
+
import "./chunk-ZRNRQFTF.js";
|
|
94
|
+
import "./chunk-CLWYQNSC.js";
|
|
95
|
+
import "./chunk-YHB57PFN.js";
|
|
96
|
+
import "./chunk-MGG7JSNO.js";
|
|
97
|
+
import "./chunk-HLAZ65AW.js";
|
|
98
|
+
import "./chunk-DG62L57H.js";
|
|
76
99
|
import {
|
|
77
100
|
CliError,
|
|
78
101
|
isCliError
|
|
79
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-OEJ5DMCX.js";
|
|
80
103
|
import "./chunk-BJG6JA5U.js";
|
|
81
104
|
import {
|
|
82
105
|
__name
|
|
@@ -1828,7 +1851,7 @@ var pollOf = /* @__PURE__ */ __name(async (feature, chatId, messageId) => {
|
|
|
1828
1851
|
|
|
1829
1852
|
// dist/telegram/sending.js
|
|
1830
1853
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1831
|
-
import { networkMiddlewares } from "@mtcute/node";
|
|
1854
|
+
import { networkMiddlewares, tl as tl8 } from "@mtcute/node";
|
|
1832
1855
|
var SENDS = /* @__PURE__ */ new Set([
|
|
1833
1856
|
"messages.sendMessage",
|
|
1834
1857
|
"messages.sendMedia",
|
|
@@ -1844,14 +1867,53 @@ var noteAcceptedSend = /* @__PURE__ */ __name(async (context, next) => {
|
|
|
1844
1867
|
current.accepted = true;
|
|
1845
1868
|
return answer;
|
|
1846
1869
|
}, "noteAcceptedSend");
|
|
1870
|
+
var tries = /* @__PURE__ */ new WeakMap();
|
|
1871
|
+
var codeOf = /* @__PURE__ */ __name((error) => {
|
|
1872
|
+
const known = toCliError(error, bareCheck);
|
|
1873
|
+
return isCliError(known) ? known.code : "network_error";
|
|
1874
|
+
}, "codeOf");
|
|
1875
|
+
var errorKey = /* @__PURE__ */ __name((message) => message.replace(/_\d+(?=_|$)/g, ""), "errorKey");
|
|
1876
|
+
var recordRequest = /* @__PURE__ */ __name(async (context, next) => {
|
|
1877
|
+
const tried = tries.get(context);
|
|
1878
|
+
const attempt = (tried?.attempt ?? 0) + 1;
|
|
1879
|
+
const retried = attempt > 1 ? { attempt, ...tried?.waitMs === void 0 ? {} : { waitMs: tried.waitMs } } : void 0;
|
|
1880
|
+
const end = providerRequest(context.request._, runEvent, {
|
|
1881
|
+
transport: "mtproto",
|
|
1882
|
+
...retried ?? currentAttempt() ?? { attempt: 1 }
|
|
1883
|
+
});
|
|
1884
|
+
tries.set(context, { attempt });
|
|
1885
|
+
let answer;
|
|
1886
|
+
try {
|
|
1887
|
+
answer = await next(context);
|
|
1888
|
+
} catch (error) {
|
|
1889
|
+
end({ errorCode: codeOf(error) });
|
|
1890
|
+
throw error;
|
|
1891
|
+
}
|
|
1892
|
+
const failure = answer;
|
|
1893
|
+
if (failure?._ === "mt_rpc_error" && typeof failure.errorMessage === "string") {
|
|
1894
|
+
end({
|
|
1895
|
+
errorCode: codeOf(tl8.RpcError.fromTl(failure)),
|
|
1896
|
+
providerError: errorKey(failure.errorMessage)
|
|
1897
|
+
});
|
|
1898
|
+
} else
|
|
1899
|
+
end();
|
|
1900
|
+
return answer;
|
|
1901
|
+
}, "recordRequest");
|
|
1847
1902
|
var middlewaresOf = /* @__PURE__ */ __name(({ maxWait, maxRetries }, say) => [
|
|
1848
1903
|
...networkMiddlewares.basic({
|
|
1849
1904
|
floodWaiter: {
|
|
1850
1905
|
maxWait,
|
|
1851
1906
|
maxRetries,
|
|
1852
|
-
onBeforeWait: /* @__PURE__ */ __name((context, seconds) =>
|
|
1907
|
+
onBeforeWait: /* @__PURE__ */ __name((context, seconds) => {
|
|
1908
|
+
const tried = tries.get(context);
|
|
1909
|
+
if (tried)
|
|
1910
|
+
tried.waitMs = seconds * 1e3;
|
|
1911
|
+
say(`Telegram asks to wait ${seconds} s before ${context.request._} \u2014 waiting, then going on`);
|
|
1912
|
+
}, "onBeforeWait")
|
|
1853
1913
|
}
|
|
1854
1914
|
}),
|
|
1915
|
+
// Inside the flood and internal-error waiters, so each retry they make is a line of its own.
|
|
1916
|
+
recordRequest,
|
|
1855
1917
|
noteAcceptedSend
|
|
1856
1918
|
], "middlewaresOf");
|
|
1857
1919
|
var sending = /* @__PURE__ */ __name(async (work) => {
|
|
@@ -1867,7 +1929,7 @@ var sending = /* @__PURE__ */ __name(async (work) => {
|
|
|
1867
1929
|
}, "sending");
|
|
1868
1930
|
|
|
1869
1931
|
// dist/telegram/stats.js
|
|
1870
|
-
import { tl as
|
|
1932
|
+
import { tl as tl9 } from "@mtcute/node";
|
|
1871
1933
|
var DAY_MS = 864e5;
|
|
1872
1934
|
var MS_FROM = 1e11;
|
|
1873
1935
|
var axisOf = /* @__PURE__ */ __name((values) => {
|
|
@@ -2021,7 +2083,7 @@ var officialChatStats = /* @__PURE__ */ __name((feature, reference) => {
|
|
|
2021
2083
|
return toOfficialGraph(loaded.json.data);
|
|
2022
2084
|
return { error: loaded._ === "statsGraphError" ? loaded.error : "Telegram did not finish this graph" };
|
|
2023
2085
|
} catch (error) {
|
|
2024
|
-
if (
|
|
2086
|
+
if (tl9.RpcError.is(error))
|
|
2025
2087
|
return { error: error.text };
|
|
2026
2088
|
throw error;
|
|
2027
2089
|
}
|
|
@@ -2029,7 +2091,7 @@ var officialChatStats = /* @__PURE__ */ __name((feature, reference) => {
|
|
|
2029
2091
|
try {
|
|
2030
2092
|
return broadcast ? await toOfficialChannelStats(chat2, await feature.client.call({ _: "stats.getBroadcastStats", channel }, options), graphOf) : await toOfficialGroupStats(chat2, await feature.client.call({ _: "stats.getMegagroupStats", channel }, options), graphOf);
|
|
2031
2093
|
} catch (error) {
|
|
2032
|
-
if (
|
|
2094
|
+
if (tl9.RpcError.is(error, "AUTH_KEY_UNREGISTERED"))
|
|
2033
2095
|
throw new CliError("provider_error", "Telegram's statistics server did not accept this login (AUTH_KEY_UNREGISTERED); the login itself works \u2014 try again later", { provider_error: error.text, status: error.code });
|
|
2034
2096
|
throw error;
|
|
2035
2097
|
}
|
|
@@ -2037,7 +2099,7 @@ var officialChatStats = /* @__PURE__ */ __name((feature, reference) => {
|
|
|
2037
2099
|
}, "officialChatStats");
|
|
2038
2100
|
|
|
2039
2101
|
// dist/telegram/topics.js
|
|
2040
|
-
import { getMarkedPeerId as getMarkedPeerId7, tl as
|
|
2102
|
+
import { getMarkedPeerId as getMarkedPeerId7, tl as tl10 } from "@mtcute/node";
|
|
2041
2103
|
var stateOf = /* @__PURE__ */ __name(async ({ client }, chatId) => {
|
|
2042
2104
|
let full = await client.getFullChat(Number(chatId));
|
|
2043
2105
|
if (full.migratedToId != null)
|
|
@@ -2104,7 +2166,7 @@ var enableForum = /* @__PURE__ */ __name((feature, chatId) => feature.call(async
|
|
|
2104
2166
|
});
|
|
2105
2167
|
return await stateOf(feature, state.chat.id);
|
|
2106
2168
|
} catch (error) {
|
|
2107
|
-
if (
|
|
2169
|
+
if (tl10.RpcError.is(error, "CHAT_NOT_MODIFIED"))
|
|
2108
2170
|
return stateOf(feature, state.chat.id);
|
|
2109
2171
|
throw unknownIfUnanswered(error, "topics may have been enabled; check the forum state before repeating");
|
|
2110
2172
|
}
|
|
@@ -2151,7 +2213,7 @@ var editTopic = /* @__PURE__ */ __name((feature, chatId, topicId, { title, close
|
|
|
2151
2213
|
return feature.call(async () => {
|
|
2152
2214
|
const { client } = feature;
|
|
2153
2215
|
const unchanged = /* @__PURE__ */ __name((error) => {
|
|
2154
|
-
if (!
|
|
2216
|
+
if (!tl10.RpcError.is(error, "TOPIC_NOT_MODIFIED") && !tl10.RpcError.is(error, "PINNED_TOPIC_NOT_MODIFIED"))
|
|
2155
2217
|
throw unknownIfUnanswered(error, "the topic may have changed \u2014 repeating it is safe");
|
|
2156
2218
|
}, "unchanged");
|
|
2157
2219
|
if (title !== void 0 || closed !== void 0) {
|
|
@@ -2,20 +2,29 @@ import { createRequire as __tgRequire } from "node:module";
|
|
|
2
2
|
const require = __tgRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
answeredWire
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-XXTJUZMB.js";
|
|
6
6
|
import {
|
|
7
|
+
CALLER_META_KEY,
|
|
8
|
+
PROXY_CLIENT_NAME,
|
|
7
9
|
StdioServerTransport,
|
|
10
|
+
callerOf,
|
|
8
11
|
serveStdio
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BBC546ZA.js";
|
|
10
13
|
import {
|
|
11
14
|
McpServer
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WMOEOVWZ.js";
|
|
16
|
+
import "./chunk-DE7LFMY2.js";
|
|
17
|
+
import "./chunk-2SJOUK6J.js";
|
|
18
|
+
import "./chunk-DG62L57H.js";
|
|
19
|
+
import "./chunk-OEJ5DMCX.js";
|
|
20
|
+
import "./chunk-BJG6JA5U.js";
|
|
13
21
|
import {
|
|
14
22
|
__name
|
|
15
23
|
} from "./chunk-AFV74GK3.js";
|
|
16
24
|
|
|
17
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/mcp/all-profiles.js
|
|
18
26
|
import { spawn } from "node:child_process";
|
|
27
|
+
import { randomUUID } from "node:crypto";
|
|
19
28
|
var PROTOCOL = "2025-06-18";
|
|
20
29
|
var START_MS = 3e4;
|
|
21
30
|
var CHILD_IDLE_MS = 10 * 60 * 1e3;
|
|
@@ -93,7 +102,7 @@ var startChild = /* @__PURE__ */ __name((spec, note, onExit) => {
|
|
|
93
102
|
return request("initialize", {
|
|
94
103
|
protocolVersion: PROTOCOL,
|
|
95
104
|
capabilities: {},
|
|
96
|
-
clientInfo: { name:
|
|
105
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" }
|
|
97
106
|
}).then(() => {
|
|
98
107
|
send({ method: "notifications/initialized" });
|
|
99
108
|
return { request, close };
|
|
@@ -145,8 +154,10 @@ var pool = /* @__PURE__ */ __name((options) => {
|
|
|
145
154
|
}, "close");
|
|
146
155
|
return { use, close };
|
|
147
156
|
}, "pool");
|
|
148
|
-
var withProfile = /* @__PURE__ */ __name((tool, profiles, name) => {
|
|
157
|
+
var withProfile = /* @__PURE__ */ __name((tool, profiles, name, signedIn = () => true) => {
|
|
149
158
|
const schema = tool.inputSchema;
|
|
159
|
+
const out = profiles.filter((profile) => !signedIn(profile));
|
|
160
|
+
const states = out.length === 0 ? "" : ` Signed in: ${profiles.filter(signedIn).join(", ") || "none"} \xB7 Not signed in: ${out.join(", ")}.`;
|
|
150
161
|
return {
|
|
151
162
|
...tool,
|
|
152
163
|
inputSchema: {
|
|
@@ -155,7 +166,11 @@ var withProfile = /* @__PURE__ */ __name((tool, profiles, name) => {
|
|
|
155
166
|
profile: {
|
|
156
167
|
type: "string",
|
|
157
168
|
enum: [...profiles],
|
|
158
|
-
|
|
169
|
+
oneOf: profiles.map((profile) => ({
|
|
170
|
+
const: profile,
|
|
171
|
+
title: signedIn(profile) ? profile : `${profile} \u2014 not signed in`
|
|
172
|
+
})),
|
|
173
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which \u2014 never guess.${states}`
|
|
159
174
|
},
|
|
160
175
|
...schema.properties
|
|
161
176
|
},
|
|
@@ -171,25 +186,40 @@ var allProfilesServer = /* @__PURE__ */ __name((options) => {
|
|
|
171
186
|
const children = pool(options);
|
|
172
187
|
let listed;
|
|
173
188
|
const tools = /* @__PURE__ */ __name((profiles) => {
|
|
174
|
-
listed ??= children.use(profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
189
|
+
listed ??= children.use(profiles.find(signedIn) ?? profiles[0], (child) => child.request("tools/list", {})).then((answer) => answer.tools ?? []);
|
|
175
190
|
listed.catch(() => {
|
|
176
191
|
listed = void 0;
|
|
177
192
|
});
|
|
178
193
|
return listed;
|
|
179
194
|
}, "tools");
|
|
195
|
+
const signedIn = /* @__PURE__ */ __name((profile) => options.signedIn?.(profile) ?? true, "signedIn");
|
|
180
196
|
const build = /* @__PURE__ */ __name(() => {
|
|
181
197
|
const profiles = [...options.profiles()].sort();
|
|
182
198
|
const server = new McpServer({ name: options.command, version: options.version }, { capabilities: { tools: {} }, instructions: options.instructions });
|
|
183
199
|
server.server.setRequestHandler("tools/list", async () => ({
|
|
184
|
-
tools: profiles.length === 0 ? [] : (await tools(profiles)).map((one) => withProfile(one, profiles, options.name))
|
|
200
|
+
tools: profiles.length === 0 ? [] : (await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn))
|
|
185
201
|
}));
|
|
186
|
-
|
|
202
|
+
const callers = {
|
|
203
|
+
env: options.env ?? process.env,
|
|
204
|
+
client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"),
|
|
205
|
+
connectionId: randomUUID()
|
|
206
|
+
};
|
|
207
|
+
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
187
208
|
const { name, arguments: given = {}, _meta } = request.params;
|
|
188
209
|
const { profile, ...rest } = given;
|
|
189
210
|
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
190
211
|
return refusal(`${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
212
|
+
if (!signedIn(profile))
|
|
213
|
+
return refusal(options.signIn?.(profile) ?? `profile ${profile} is not signed in.`);
|
|
191
214
|
try {
|
|
192
|
-
return await children.use(profile, (child) =>
|
|
215
|
+
return await children.use(profile, (child) => (
|
|
216
|
+
// Children are shared by every session, so each call names its own caller.
|
|
217
|
+
child.request("tools/call", {
|
|
218
|
+
name,
|
|
219
|
+
arguments: rest,
|
|
220
|
+
_meta: { ..._meta, [CALLER_META_KEY]: callerOf(ctx, name, callers) }
|
|
221
|
+
})
|
|
222
|
+
));
|
|
193
223
|
} catch (error) {
|
|
194
224
|
return refusal(`profile ${profile}: ${error instanceof Error ? error.message : String(error)}`);
|
|
195
225
|
}
|
|
@@ -226,7 +256,7 @@ var serveAllProfilesOverStdio = /* @__PURE__ */ __name(async (options, io = {})
|
|
|
226
256
|
}, "serveAllProfilesOverStdio");
|
|
227
257
|
var serveAllProfilesOverHttp = /* @__PURE__ */ __name(async (options, http) => {
|
|
228
258
|
const { build, close } = allProfilesServer(options);
|
|
229
|
-
const { serveOverHttp } = await import("./serve-
|
|
259
|
+
const { serveOverHttp } = await import("./serve-ZCPO44NO.js");
|
|
230
260
|
const listening = await serveOverHttp(build, {
|
|
231
261
|
...http,
|
|
232
262
|
appName: options.command,
|
|
@@ -2,27 +2,27 @@ import { createRequire as __tgRequire } from "node:module";
|
|
|
2
2
|
const require = __tgRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
checkedOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SRU3OF4R.js";
|
|
6
6
|
import {
|
|
7
7
|
messagesFor,
|
|
8
8
|
systemFor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OCWARAFE.js";
|
|
10
10
|
import {
|
|
11
11
|
Anthropic
|
|
12
12
|
} from "./chunk-AVWK4NCW.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-DG62L57H.js";
|
|
14
14
|
import {
|
|
15
15
|
array,
|
|
16
16
|
optional,
|
|
17
17
|
strictObject,
|
|
18
18
|
string
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-OEJ5DMCX.js";
|
|
20
20
|
import "./chunk-BJG6JA5U.js";
|
|
21
21
|
import {
|
|
22
22
|
__name
|
|
23
23
|
} from "./chunk-AFV74GK3.js";
|
|
24
24
|
|
|
25
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
25
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.467.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.64.0_commander@15._7a700db966f96e9df6d3178e7072efc2/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
26
26
|
var options = strictObject({
|
|
27
27
|
stop_sequences: optional(array(string()))
|
|
28
28
|
});
|