@wirecat/tg-cli 0.133.0 → 0.134.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 +2 -3
- package/contracts/wirecat.json +82 -2
- package/dist/bin/tg.js +2 -2
- package/dist/bot/generated/types.d.ts +188 -0
- package/dist/bot/generated/types.d.ts.map +1 -1
- package/dist/bundle/{adapter-GSGX3WBH.js → adapter-Y4IXTXAG.js} +104 -69
- package/dist/bundle/agent-G7VHOJMS.js +37 -0
- package/dist/bundle/{all-profiles-VOCJ55YH.js → all-profiles-SUGID6CX.js} +62 -20
- package/dist/bundle/{anthropic-J6CTLU3W.js → anthropic-4QKTXT4B.js} +5 -5
- package/dist/bundle/{app-server-GVFGA4TJ.js → app-server-TPOD6LIJ.js} +72 -62
- package/dist/bundle/{bot-api-LWONPIGK.js → bot-api-KBESP422.js} +73 -92
- package/dist/bundle/{bot-history-XOW7Y2GC.js → bot-history-3EORA23G.js} +23 -22
- package/dist/bundle/{bun-436CH6CP.js → bun-FL76M4M2.js} +2 -2
- package/dist/bundle/{bun-sqlite-ZLB5RK5Q.js → bun-sqlite-H37OSTAJ.js} +6 -6
- package/dist/bundle/{chunk-YY6FGKGD.js → chunk-2GT563YH.js} +2 -2
- package/dist/bundle/{chunk-5L44DSHV.js → chunk-2JWY7CXJ.js} +4 -4
- package/dist/bundle/{chunk-OX73ERZW.js → chunk-3O25FAPA.js} +3 -4
- package/dist/bundle/{chunk-TCI7I6YF.js → chunk-3PG6QVQZ.js} +11 -25
- package/dist/bundle/{chunk-NTWXL2QV.js → chunk-3QQWTP77.js} +2 -2
- package/dist/bundle/{chunk-TTDZVWDU.js → chunk-3ZNO27UE.js} +1 -1
- package/dist/bundle/{chunk-7NYP4RBO.js → chunk-4R2ZJGFF.js} +2125 -1179
- package/dist/bundle/{chunk-VGN5YXYI.js → chunk-4S2DHHJM.js} +2 -100
- package/dist/bundle/{chunk-H7ML7X3G.js → chunk-4X6BX3XP.js} +144 -10
- package/dist/bundle/{chunk-D2SJLZSH.js → chunk-6DGVK5KS.js} +2 -2
- package/dist/bundle/chunk-6DJJVFSG.js +388 -0
- package/dist/bundle/{chunk-M6QOM6SL.js → chunk-6MEHKUN6.js} +1 -1
- package/dist/bundle/{chunk-6CHIGUCY.js → chunk-6UNLEQA5.js} +31 -20
- package/dist/bundle/{chunk-WCYKVX3B.js → chunk-77E7Q4EQ.js} +7 -7
- package/dist/bundle/chunk-7GGDCQJ5.js +353 -0
- package/dist/bundle/{chunk-UIAKLELF.js → chunk-AHVWZDXO.js} +79 -64
- package/dist/bundle/{chunk-NO2LIHWA.js → chunk-ANBI3OXK.js} +1 -1
- package/dist/bundle/{chunk-LQQSDGQ6.js → chunk-AYWST6NA.js} +56 -46
- package/dist/bundle/{chunk-NAXOT35J.js → chunk-CA7DY2YU.js} +3 -3
- package/dist/bundle/{chunk-UKBK2VWZ.js → chunk-CDKXZLMP.js} +225 -175
- package/dist/bundle/{chunk-5HKPQPD4.js → chunk-CNGNR4CY.js} +6 -6
- package/dist/bundle/{chunk-KUA24HWG.js → chunk-CSXCCK6J.js} +2 -2
- package/dist/bundle/{chunk-VTQMR3XG.js → chunk-DG35TQ6P.js} +3 -3
- package/dist/bundle/{chunk-IPPCQ7IK.js → chunk-EXMAWEHC.js} +2 -2
- package/dist/bundle/{chunk-CEJYNB3I.js → chunk-FR3ATU5I.js} +4 -4
- package/dist/bundle/{chunk-XOX4BX5A.js → chunk-FR4Y5CGW.js} +4 -4
- package/dist/bundle/{chunk-JPNVEPS4.js → chunk-GIGZTI74.js} +2023 -1928
- package/dist/bundle/{chunk-UZ63ORMY.js → chunk-H3TLAYGY.js} +4 -4
- package/dist/bundle/{chunk-LBZEZO32.js → chunk-HD7DV5B2.js} +65 -43
- package/dist/bundle/{chunk-TPD37ECC.js → chunk-HETHFOHC.js} +3 -3
- package/dist/bundle/{chunk-JKSD43L7.js → chunk-HEZK4W3U.js} +6 -6
- package/dist/bundle/{chunk-SMU6NA7F.js → chunk-IJ7R2WMK.js} +4 -4
- package/dist/bundle/{chunk-7NF3V5L2.js → chunk-ITJ7DGNA.js} +4 -4
- package/dist/bundle/{chunk-JGMXBAGH.js → chunk-J5RB4ASI.js} +140 -433
- package/dist/bundle/{chunk-57KJ3TRS.js → chunk-JAL443BH.js} +9 -9
- package/dist/bundle/{chunk-IH4Z3KZU.js → chunk-JCDD5T3A.js} +2 -2
- package/dist/bundle/{chunk-BXVB42KJ.js → chunk-JHZJBNDO.js} +2 -2
- package/dist/bundle/chunk-JWLODUN3.js +555 -0
- package/dist/bundle/{chunk-54WLIPIQ.js → chunk-JWNSG5GI.js} +1 -1
- package/dist/bundle/{chunk-UGS57TT5.js → chunk-JXEO5EIN.js} +2 -2
- package/dist/bundle/{chunk-QYLZD4DS.js → chunk-K5FK6WWN.js} +1 -1
- package/dist/bundle/{chunk-QWO7L4UH.js → chunk-L47PFECD.js} +7 -7
- package/dist/bundle/{chunk-IYAXLLGR.js → chunk-L4PNDW4S.js} +6 -6
- package/dist/bundle/{chunk-ZHO3TPHM.js → chunk-M323L5SG.js} +30 -15
- package/dist/bundle/{chunk-6A44ZZFC.js → chunk-MMDFPBFZ.js} +43 -64
- package/dist/bundle/{chunk-OWY52JBO.js → chunk-MUV73B5A.js} +7 -7
- package/dist/bundle/{chunk-2KQDJHF3.js → chunk-MXA3FU2R.js} +29 -1
- package/dist/bundle/{chunk-6H2NW6HK.js → chunk-NUD4CBHK.js} +3 -3
- package/dist/bundle/{chunk-RABUG4KA.js → chunk-NYEVPAF2.js} +511 -472
- package/dist/bundle/{chunk-VWJTYAIQ.js → chunk-O3QBO6NW.js} +17 -17
- package/dist/bundle/{chunk-N7QREPZW.js → chunk-O4ZOQJ6W.js} +9 -9
- package/dist/bundle/{chunk-KEN4B57V.js → chunk-OJSPB4LA.js} +2 -2
- package/dist/bundle/{chunk-UQYL6TJ7.js → chunk-PCBVSHKD.js} +4 -4
- package/dist/bundle/{chunk-LIQMUDIZ.js → chunk-PK5WEGPJ.js} +2 -2
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-O6JUVATT.js → chunk-PRI2XTM7.js} +35 -12
- package/dist/bundle/chunk-PRM7GKBV.js +340 -0
- package/dist/bundle/{chunk-YAPDU3SV.js → chunk-PZ2ZFPGO.js} +1 -1
- package/dist/bundle/chunk-QYRK4XXH.js +727 -0
- package/dist/bundle/{chunk-XDQU5HBO.js → chunk-RVA3CRSY.js} +12 -12
- package/dist/bundle/{chunk-QVGEL66U.js → chunk-SPXNI53Z.js} +38 -9
- package/dist/bundle/{chunk-QGWISM4W.js → chunk-TI5U6AUT.js} +34 -28
- package/dist/bundle/{chunk-THYGLTRB.js → chunk-TKWYXM7L.js} +7 -7
- package/dist/bundle/{chunk-XKOMP3HV.js → chunk-TZCFJJEU.js} +6 -6
- package/dist/bundle/chunk-UTTEAOJ3.js +7 -0
- package/dist/bundle/chunk-V6G4LTXU.js +50 -0
- package/dist/bundle/{chunk-KVFUH5IT.js → chunk-VH4J7IIS.js} +1 -1
- package/dist/bundle/{chunk-VCAOH45X.js → chunk-VNJRWFHP.js} +1 -1
- package/dist/bundle/chunk-W2QSDPG6.js +80 -0
- package/dist/bundle/{chunk-LOS4D6ZB.js → chunk-WGGUKQE7.js} +113 -567
- package/dist/bundle/{chunk-ZYAHZKYF.js → chunk-WPXVJGSL.js} +3 -3
- package/dist/bundle/{chunk-IBCXEVNY.js → chunk-XLNV3U6N.js} +3 -3
- package/dist/bundle/{chunk-6S77EKZU.js → chunk-XS4EE7MO.js} +17 -15
- package/dist/bundle/{chunk-6VCSOQFL.js → chunk-XVRLD3LN.js} +2 -2
- package/dist/bundle/{chunk-HB5DP6L5.js → chunk-XZ6XEAJP.js} +18 -18
- package/dist/bundle/{chunk-N3JUHGKM.js → chunk-YHTSJMZ5.js} +3706 -3372
- package/dist/bundle/chunk-YPJCURT6.js +108 -0
- package/dist/bundle/{chunk-SMI2EUH4.js → chunk-Z77R76S2.js} +1 -1
- package/dist/bundle/{chunk-KHUXDSXN.js → chunk-ZC7OEYDX.js} +1 -1
- package/dist/bundle/{chunk-5LRTYBZW.js → chunk-ZW2N2GI2.js} +12 -12
- package/dist/bundle/command-contract-LEFXJAA3.js +37 -0
- package/dist/bundle/{command-server-entry-AE27QXTE.js → command-server-entry-WQAE5UGU.js} +27 -27
- package/dist/bundle/{decode-RQPPZ72F.js → decode-2J2DOVGV.js} +5 -5
- package/dist/bundle/{dispatch-KQO2MCSH.js → dispatch-IZ2TP5GW.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-FZRIACN4.js → echarts-GFIIHZ4U.js} +2 -2
- package/dist/bundle/{embed-TOSWWMDL.js → embed-AGOXADHW.js} +6 -6
- package/dist/bundle/{embedder-JHIQSBGD.js → embedder-PCIXGM2Y.js} +9 -9
- package/dist/bundle/{entry-DU4KRXTG.js → entry-HUQXUV52.js} +9 -9
- package/dist/bundle/{failure-3YC3YGYO.js → failure-JSRHZ2S6.js} +2 -2
- package/dist/bundle/{first-run-DQQT4FID.js → first-run-2LXN7B33.js} +12 -12
- package/dist/bundle/first-screen-VUE6RCSF.js +37 -0
- package/dist/bundle/{instructions-WI64CJQ6.js → instructions-RSLTJVFJ.js} +1 -1
- package/dist/bundle/{mcp-VMS6PBCU.js → mcp-MMENCB7I.js} +2 -2
- package/dist/bundle/meeting-combined-PBNPHOM3.js +23 -0
- package/dist/bundle/{meeting-model-XNRSREIK.js → meeting-model-SI77WMMK.js} +11 -11
- package/dist/bundle/{meeting-semantic-OOSCHQMB.js → meeting-semantic-WRXWUR4M.js} +6 -6
- package/dist/bundle/{node-JLKDNVKV.js → node-5XGMCUGQ.js} +2 -2
- package/dist/bundle/{node-sqlite-YOGH26O2.js → node-sqlite-ES7SQSIC.js} +7 -7
- package/dist/bundle/{oauth-FOMXM5HP.js → oauth-QFM4Y6N7.js} +8 -8
- package/dist/bundle/{open-SM2UXUKM.js → open-2MD2DKGQ.js} +5 -5
- package/dist/bundle/{openai-J2H7S6ZF.js → openai-6TMKJKYO.js} +15 -15
- package/dist/bundle/{process-HI7OZBOI.js → process-VA2DP7MY.js} +1 -1
- package/dist/bundle/{program-VY4HFU25.js → program-K3SLEA42.js} +70 -64
- package/dist/bundle/{prompt-NUUVFMOF.js → prompt-VZSPCE6E.js} +5 -5
- package/dist/bundle/{proxy-transport-AN4VMRRN.js → proxy-transport-OJU2EOOC.js} +5 -5
- package/dist/bundle/{recognize-MALJHPDI.js → recognize-LH3ZZEIL.js} +4 -4
- package/dist/bundle/{remote-QUDRSTS2.js → remote-JNW5HN2I.js} +9 -9
- package/dist/bundle/{rerank-2DSO3D3S.js → rerank-P23UJMII.js} +7 -7
- package/dist/bundle/{serve-NCJ52MY3.js → serve-VSLLMILH.js} +15 -15
- package/dist/bundle/{server-Y3M544AM.js → server-FBRRRKCS.js} +65 -54
- package/dist/bundle/server-TA4QP7PG.js +78 -0
- package/dist/bundle/{sqlite-runtime-NJUSXVKK.js → sqlite-runtime-LWATDAAU.js} +6 -6
- package/dist/bundle/{state-AVOWQVET.js → state-3AFJL2EL.js} +6 -6
- package/dist/bundle/{store-MMIYOL4H.js → store-6TLYL2VU.js} +28 -17
- package/dist/bundle/{store-BZ5ICDRP.js → store-PEXV5DNA.js} +20 -19
- package/dist/bundle/store-maintenance-command-IYJLUQ5X.js +65 -0
- package/dist/bundle/surface-L4VY4WFG.js +64 -0
- package/dist/bundle/tg.js +13 -13
- package/dist/telegram/adapter.d.ts +9 -2
- package/dist/telegram/adapter.d.ts.map +1 -1
- package/dist/telegram/adapter.js +5 -6
- package/dist/telegram/adapter.js.map +1 -1
- package/dist/telegram/messages.d.ts +12 -0
- package/dist/telegram/messages.d.ts.map +1 -1
- package/dist/telegram/messages.js +40 -0
- package/dist/telegram/messages.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/skills/tg-cli/SKILL.md +4 -2
- package/skills/tg-cli/references/messages.md +5 -1
- package/skills/tg-cli/references/search.md +2 -0
- package/dist/bundle/chunk-SHTHNBHG.js +0 -2
- package/dist/bundle/command-contract-TQIARAB4.js +0 -37
- package/dist/bundle/first-screen-7N4CTZSA.js +0 -37
- package/dist/bundle/meeting-combined-3RAOFQ7M.js +0 -23
- package/dist/bundle/server-CHGON5I2.js +0 -70
- package/dist/bundle/store-maintenance-command-VKZ4WHUB.js +0 -61
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
CLIENT_INFO_META_KEY,
|
|
5
4
|
DEFAULT_MAX_SUBSCRIPTIONS,
|
|
6
5
|
McpServer,
|
|
7
6
|
ProtocolErrorCode,
|
|
@@ -24,12 +23,7 @@ import {
|
|
|
24
23
|
serverIdentityOf,
|
|
25
24
|
setNegotiatedProtocolVersion,
|
|
26
25
|
validateEnvelopeMeta
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import {
|
|
29
|
-
agentOf,
|
|
30
|
-
clientHash,
|
|
31
|
-
currentCaller
|
|
32
|
-
} from "./chunk-QWO7L4UH.js";
|
|
26
|
+
} from "./chunk-PL5P7UKW.js";
|
|
33
27
|
import {
|
|
34
28
|
__name
|
|
35
29
|
} from "./chunk-ZVVMGPBJ.js";
|
|
@@ -541,95 +535,7 @@ function toError(value) {
|
|
|
541
535
|
}
|
|
542
536
|
__name(toError, "toError");
|
|
543
537
|
|
|
544
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
545
|
-
var callingAgent = /* @__PURE__ */ __name((fallback, caller = currentCaller()) => {
|
|
546
|
-
const client = caller?.agent?.client?.name;
|
|
547
|
-
if (client && client !== "unknown")
|
|
548
|
-
return client;
|
|
549
|
-
const kind = caller?.agent?.kind;
|
|
550
|
-
return kind && kind !== "mcp-client" ? kind : fallback;
|
|
551
|
-
}, "callingAgent");
|
|
552
|
-
var CALLER_META_KEY = "wirecat.dev/caller";
|
|
553
|
-
var PROXY_CLIENT_NAME = "all-profiles";
|
|
554
|
-
var NAME = /^[\w .@()/+-]{1,64}$/;
|
|
555
|
-
var plain = /* @__PURE__ */ __name((value) => typeof value === "string" && NAME.test(value.trim()) ? value.trim() : void 0, "plain");
|
|
556
|
-
var clientFrom = /* @__PURE__ */ __name((value) => {
|
|
557
|
-
if (!value || typeof value !== "object")
|
|
558
|
-
return void 0;
|
|
559
|
-
const { name, version } = value;
|
|
560
|
-
const named = plain(name);
|
|
561
|
-
if (!named)
|
|
562
|
-
return void 0;
|
|
563
|
-
const versioned = plain(version);
|
|
564
|
-
return { name: named, ...versioned ? { version: versioned } : {} };
|
|
565
|
-
}, "clientFrom");
|
|
566
|
-
var callerOf = /* @__PURE__ */ __name((ctx, tool, source) => {
|
|
567
|
-
const meta = ctx?.mcpReq?._meta;
|
|
568
|
-
const requestId = ctx?.mcpReq?.id;
|
|
569
|
-
const initialized = source.client?.();
|
|
570
|
-
const proxied = initialized?.name === PROXY_CLIENT_NAME && !ctx?.http ? passedOn(meta?.[CALLER_META_KEY], tool) : void 0;
|
|
571
|
-
if (proxied)
|
|
572
|
-
return proxied;
|
|
573
|
-
const client = clientFrom(meta?.[CLIENT_INFO_META_KEY]) ?? clientFrom(initialized);
|
|
574
|
-
const mcp = /* @__PURE__ */ __name((connection) => ({
|
|
575
|
-
tool,
|
|
576
|
-
...requestId === void 0 ? {} : { request_id: String(requestId) },
|
|
577
|
-
...connection ? { connection_id: connection } : {}
|
|
578
|
-
}), "mcp");
|
|
579
|
-
const auth = ctx?.http?.authInfo;
|
|
580
|
-
if (auth) {
|
|
581
|
-
const registered = plain(auth.extra?.clientName);
|
|
582
|
-
return {
|
|
583
|
-
via: "mcp-http",
|
|
584
|
-
agent: {
|
|
585
|
-
kind: "mcp-client",
|
|
586
|
-
session_id: ctx?.sessionId ?? null,
|
|
587
|
-
client: {
|
|
588
|
-
name: registered ?? client?.name ?? "unknown",
|
|
589
|
-
...client?.version ? { version: client.version } : {},
|
|
590
|
-
id: clientHash(auth.clientId)
|
|
591
|
-
}
|
|
592
|
-
},
|
|
593
|
-
mcp: mcp(ctx?.sessionId)
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
const agent = agentOf(source.env) ?? { kind: "mcp-client", session_id: null };
|
|
597
|
-
return { via: "mcp-stdio", agent: { ...agent, ...client ? { client } : {} }, mcp: mcp(source.connectionId) };
|
|
598
|
-
}, "callerOf");
|
|
599
|
-
var passedOn = /* @__PURE__ */ __name((value, tool) => {
|
|
600
|
-
if (!value || typeof value !== "object")
|
|
601
|
-
return void 0;
|
|
602
|
-
const { via, agent, mcp } = value;
|
|
603
|
-
if (via !== "mcp-stdio" && via !== "mcp-http")
|
|
604
|
-
return void 0;
|
|
605
|
-
const a = agent && typeof agent === "object" ? agent : void 0;
|
|
606
|
-
const kind = plain(a?.kind);
|
|
607
|
-
const session = typeof a?.session_id === "string" && /^[A-Za-z0-9._:-]{1,128}$/.test(a.session_id) ? a.session_id : null;
|
|
608
|
-
const client = clientFrom(a?.client);
|
|
609
|
-
const id = a?.client && typeof a.client === "object" ? a.client.id : void 0;
|
|
610
|
-
const m = mcp && typeof mcp === "object" ? mcp : {};
|
|
611
|
-
const request = plain(m.request_id);
|
|
612
|
-
const connection = typeof m.connection_id === "string" && /^[\w-]{1,128}$/.test(m.connection_id) ? m.connection_id : void 0;
|
|
613
|
-
return {
|
|
614
|
-
via,
|
|
615
|
-
...kind ? {
|
|
616
|
-
agent: {
|
|
617
|
-
kind,
|
|
618
|
-
session_id: session,
|
|
619
|
-
...a?.from_chat === true ? { from_chat: true } : {},
|
|
620
|
-
...client ? { client: { ...client, ...typeof id === "string" && /^[0-9a-f]{8}$/.test(id) ? { id } : {} } } : {}
|
|
621
|
-
}
|
|
622
|
-
} : {},
|
|
623
|
-
mcp: {
|
|
624
|
-
tool,
|
|
625
|
-
...request ? { request_id: request } : {},
|
|
626
|
-
...connection ? { connection_id: connection } : {},
|
|
627
|
-
proxied: true
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
}, "passedOn");
|
|
631
|
-
|
|
632
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.681.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.106.0_commander@15_8d845c31697914d824aa80d8eec93941/node_modules/@wirecat/cli-core/dist/mcp/stdio-wire.js
|
|
538
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.714.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.122.0_commander@15_dd9fedf917a0d541ef7fdcdb0be0e64b/node_modules/@wirecat/cli-core/dist/mcp/stdio-wire.js
|
|
633
539
|
import { PassThrough, Writable } from "node:stream";
|
|
634
540
|
var lineReader = /* @__PURE__ */ __name((onMessage) => {
|
|
635
541
|
let rest = "";
|
|
@@ -723,9 +629,5 @@ var answeredWire = /* @__PURE__ */ __name((source, sink) => {
|
|
|
723
629
|
export {
|
|
724
630
|
StdioServerTransport,
|
|
725
631
|
serveStdio,
|
|
726
|
-
callingAgent,
|
|
727
|
-
CALLER_META_KEY,
|
|
728
|
-
PROXY_CLIENT_NAME,
|
|
729
|
-
callerOf,
|
|
730
632
|
answeredWire
|
|
731
633
|
};
|
|
@@ -3,12 +3,97 @@ const require = __bundleRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
CliError,
|
|
5
5
|
isCliError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PK5WEGPJ.js";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "./chunk-ZVVMGPBJ.js";
|
|
10
10
|
|
|
11
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
11
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.122.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/body.js
|
|
12
|
+
var interrupted = /* @__PURE__ */ __name((signal) => isCliError(signal.reason) ? signal.reason : new CliError(signal.reason instanceof Error && signal.reason.name === "TimeoutError" ? "timeout" : "cancelled", "HTTP response read was interrupted"), "interrupted");
|
|
13
|
+
var checked = /* @__PURE__ */ __name((signal) => {
|
|
14
|
+
if (signal?.aborted)
|
|
15
|
+
throw interrupted(signal);
|
|
16
|
+
}, "checked");
|
|
17
|
+
var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
|
|
18
|
+
if (!signal)
|
|
19
|
+
return pending;
|
|
20
|
+
let abort = /* @__PURE__ */ __name(() => {
|
|
21
|
+
}, "abort");
|
|
22
|
+
const stopped = new Promise((_, reject) => {
|
|
23
|
+
abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
|
|
24
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
25
|
+
if (signal.aborted)
|
|
26
|
+
abort();
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
return await Promise.race([pending, stopped]);
|
|
30
|
+
} finally {
|
|
31
|
+
signal.removeEventListener("abort", abort);
|
|
32
|
+
}
|
|
33
|
+
}, "abortable");
|
|
34
|
+
var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
|
|
35
|
+
const { maxBytes, signal } = options ?? {};
|
|
36
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
|
|
37
|
+
throw new CliError("validation_error", "maxBytes must be a positive safe integer");
|
|
38
|
+
if (signal !== void 0 && !(signal instanceof AbortSignal))
|
|
39
|
+
throw new CliError("validation_error", "signal must be an AbortSignal");
|
|
40
|
+
if (signal?.aborted) {
|
|
41
|
+
void response.body?.cancel().catch(() => {
|
|
42
|
+
});
|
|
43
|
+
throw interrupted(signal);
|
|
44
|
+
}
|
|
45
|
+
const length = response.headers.get("content-length");
|
|
46
|
+
if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
|
|
47
|
+
void response.body?.cancel().catch(() => {
|
|
48
|
+
});
|
|
49
|
+
throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
|
|
50
|
+
}
|
|
51
|
+
if (!response.body)
|
|
52
|
+
throw new CliError("invalid_response", "HTTP response has no body");
|
|
53
|
+
if (response.body.locked)
|
|
54
|
+
throw new CliError("invalid_response", "HTTP response body is already in use");
|
|
55
|
+
const reader = response.body.getReader();
|
|
56
|
+
const chunks = [];
|
|
57
|
+
let bytes = 0;
|
|
58
|
+
try {
|
|
59
|
+
for (; ; ) {
|
|
60
|
+
checked(signal);
|
|
61
|
+
const part = await abortable(reader.read(), signal);
|
|
62
|
+
checked(signal);
|
|
63
|
+
if (part.done)
|
|
64
|
+
break;
|
|
65
|
+
if (!(part.value instanceof Uint8Array))
|
|
66
|
+
throw new CliError("invalid_response", "HTTP response is not bytes");
|
|
67
|
+
bytes += part.value.byteLength;
|
|
68
|
+
if (bytes > maxBytes)
|
|
69
|
+
throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
|
|
70
|
+
if (part.value.byteLength)
|
|
71
|
+
chunks.push(new Uint8Array(part.value));
|
|
72
|
+
}
|
|
73
|
+
const body = new Uint8Array(bytes);
|
|
74
|
+
let offset = 0;
|
|
75
|
+
for (const chunk of chunks) {
|
|
76
|
+
body.set(chunk, offset);
|
|
77
|
+
offset += chunk.byteLength;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
|
|
81
|
+
} catch {
|
|
82
|
+
throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
checked(signal);
|
|
86
|
+
if (isCliError(error))
|
|
87
|
+
throw error;
|
|
88
|
+
throw new CliError("network_error", "HTTP response could not be read");
|
|
89
|
+
} finally {
|
|
90
|
+
void reader.cancel().catch(() => {
|
|
91
|
+
});
|
|
92
|
+
reader.releaseLock();
|
|
93
|
+
}
|
|
94
|
+
}, "readJsonResponse");
|
|
95
|
+
|
|
96
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.122.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/hosts.js
|
|
12
97
|
var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
|
|
13
98
|
var HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
|
|
14
99
|
var hostProblems = /* @__PURE__ */ __name((hosts) => [
|
|
@@ -20,7 +105,7 @@ var hostCovered = /* @__PURE__ */ __name((hostname, hosts) => {
|
|
|
20
105
|
return hosts.some((host) => host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host);
|
|
21
106
|
}, "hostCovered");
|
|
22
107
|
|
|
23
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
108
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.122.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/fetch.js
|
|
24
109
|
var HOST_FETCH_TIMEOUT_MS = 3e4;
|
|
25
110
|
var REDIRECTS = 5;
|
|
26
111
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
@@ -46,7 +131,7 @@ var released = /* @__PURE__ */ __name((response, clear) => {
|
|
|
46
131
|
return Object.defineProperties(wrapped, { url: { value: url }, redirected: { value: redirected } });
|
|
47
132
|
}, "released");
|
|
48
133
|
var undeclared = /* @__PURE__ */ __name((url) => new CliError("configuration_error", `${url.hostname} is not a host this CLI declares: add "${url.hostname}" to \`hosts\` in its WCAT identity and run cli-dev manifest`, { reason: "network.host-undeclared", sent: false }), "undeclared");
|
|
49
|
-
var
|
|
134
|
+
var checked2 = /* @__PURE__ */ __name((url, hosts) => {
|
|
50
135
|
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
51
136
|
throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
|
|
52
137
|
sent: false
|
|
@@ -55,14 +140,35 @@ var checked = /* @__PURE__ */ __name((url, hosts) => {
|
|
|
55
140
|
throw undeclared(url);
|
|
56
141
|
return url;
|
|
57
142
|
}, "checked");
|
|
143
|
+
var ENCODED_SLASH = /%2f|%5c/i;
|
|
144
|
+
var scopeOf = /* @__PURE__ */ __name((scope) => {
|
|
145
|
+
if (scope === void 0)
|
|
146
|
+
return void 0;
|
|
147
|
+
if (!URL.canParse(scope))
|
|
148
|
+
throw new CliError("configuration_error", `credentialScope ${scope} is not a URL`);
|
|
149
|
+
const { origin, pathname } = new URL(scope);
|
|
150
|
+
const prefix = pathname.endsWith("/") ? pathname : `${pathname}/`;
|
|
151
|
+
return (url) => url.origin === origin && (url.pathname === pathname || url.pathname.startsWith(prefix)) && !ENCODED_SLASH.test(url.pathname);
|
|
152
|
+
}, "scopeOf");
|
|
153
|
+
var signedHeaders = /* @__PURE__ */ __name((headers) => CREDENTIAL_HEADERS.some((name) => headers.has(name)), "signedHeaders");
|
|
154
|
+
var NOT_SENT = /* @__PURE__ */ new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
|
|
155
|
+
var neverSent = /* @__PURE__ */ __name((error) => {
|
|
156
|
+
for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
|
|
157
|
+
const code = at.code;
|
|
158
|
+
if (typeof code === "string" && NOT_SENT.has(code))
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}, "neverSent");
|
|
58
163
|
var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
59
164
|
const problems = hostProblems(options.hosts);
|
|
60
165
|
if (problems.length > 0)
|
|
61
166
|
throw new CliError("configuration_error", problems.join("; "));
|
|
62
167
|
const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
|
|
168
|
+
const inScope = scopeOf(options.credentialScope);
|
|
63
169
|
return async (input, init = {}) => {
|
|
64
170
|
const request = input instanceof Request ? input : void 0;
|
|
65
|
-
let url =
|
|
171
|
+
let url = checked2(new URL(request?.url ?? String(input)), hosts);
|
|
66
172
|
const caller = init.signal ?? request?.signal;
|
|
67
173
|
const timeout = deadline(timeoutMs);
|
|
68
174
|
const signal = caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal;
|
|
@@ -70,8 +176,14 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
|
70
176
|
let method = (init.method ?? request?.method ?? "GET").toUpperCase();
|
|
71
177
|
let body = init.body ?? request?.body ?? void 0;
|
|
72
178
|
const headers = new Headers(init.headers ?? request?.headers);
|
|
179
|
+
if (inScope && signedHeaders(headers) && !inScope(url))
|
|
180
|
+
throw new CliError("configuration_error", `the sign-in goes only under ${options.credentialScope}, not ${url.origin}${url.pathname}`, {
|
|
181
|
+
sent: false
|
|
182
|
+
});
|
|
183
|
+
let answered = false;
|
|
73
184
|
try {
|
|
74
185
|
let response = await send(input, { ...init, signal, ...follow ? { redirect: "manual" } : {} });
|
|
186
|
+
answered = true;
|
|
75
187
|
for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
|
|
76
188
|
const location = response.headers.get("location");
|
|
77
189
|
if (!location)
|
|
@@ -80,7 +192,7 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
|
80
192
|
throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
|
|
81
193
|
void response.body?.cancel().catch(() => {
|
|
82
194
|
});
|
|
83
|
-
const next =
|
|
195
|
+
const next = checked2(new URL(location, url), hosts);
|
|
84
196
|
if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
|
|
85
197
|
method = method === "HEAD" ? "HEAD" : "GET";
|
|
86
198
|
body = void 0;
|
|
@@ -88,7 +200,7 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
|
88
200
|
headers.delete("content-length");
|
|
89
201
|
} else if (body instanceof ReadableStream)
|
|
90
202
|
throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
|
|
91
|
-
if (next.origin !== url.origin)
|
|
203
|
+
if (inScope ? !inScope(next) : next.origin !== url.origin)
|
|
92
204
|
for (const name of CREDENTIAL_HEADERS)
|
|
93
205
|
headers.delete(name);
|
|
94
206
|
url = next;
|
|
@@ -103,12 +215,15 @@ var hostFetch = /* @__PURE__ */ __name((options) => {
|
|
|
103
215
|
throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
|
|
104
216
|
if (timeout.signal.aborted)
|
|
105
217
|
throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
|
|
106
|
-
throw new CliError("network_error", `${url.hostname} could not be reached`, {
|
|
218
|
+
throw new CliError("network_error", `${url.hostname} could not be reached`, {
|
|
219
|
+
retryable: true,
|
|
220
|
+
...!answered && neverSent(error) ? { sent: false } : {}
|
|
221
|
+
});
|
|
107
222
|
}
|
|
108
223
|
};
|
|
109
224
|
}, "hostFetch");
|
|
110
225
|
|
|
111
|
-
// node_modules/.pnpm/@wirecat+cli-base@0.
|
|
226
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.122.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/http/index.js
|
|
112
227
|
var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
|
|
113
228
|
if (!header)
|
|
114
229
|
return void 0;
|
|
@@ -131,8 +246,25 @@ var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
|
|
|
131
246
|
return delta > 0 ? delta : void 0;
|
|
132
247
|
}, "parseRateLimitReset");
|
|
133
248
|
var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
|
|
249
|
+
var statusToCode = /* @__PURE__ */ __name((status) => {
|
|
250
|
+
if (status === 400 || status === 422)
|
|
251
|
+
return "validation_error";
|
|
252
|
+
if (status === 401)
|
|
253
|
+
return "authentication_error";
|
|
254
|
+
if (status === 403)
|
|
255
|
+
return "permission_error";
|
|
256
|
+
if (status === 404)
|
|
257
|
+
return "not_found";
|
|
258
|
+
if (status === 408)
|
|
259
|
+
return "timeout";
|
|
260
|
+
if (status === 429)
|
|
261
|
+
return "rate_limited";
|
|
262
|
+
if (status === 502 || status === 503 || status === 504)
|
|
263
|
+
return "provider_unavailable";
|
|
264
|
+
return "provider_error";
|
|
265
|
+
}, "statusToCode");
|
|
134
266
|
|
|
135
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
267
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.714.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.122.0_commander@15_dd9fedf917a0d541ef7fdcdb0be0e64b/node_modules/@wirecat/cli-core/dist/models/endpoint.js
|
|
136
268
|
var endpoint = /* @__PURE__ */ __name((value) => {
|
|
137
269
|
try {
|
|
138
270
|
const url = new URL(value);
|
|
@@ -186,8 +318,10 @@ var endpointFetch = /* @__PURE__ */ __name((address, timeoutMs) => {
|
|
|
186
318
|
}, "endpointFetch");
|
|
187
319
|
|
|
188
320
|
export {
|
|
321
|
+
readJsonResponse,
|
|
189
322
|
hostFetch,
|
|
190
323
|
providerWaitMs,
|
|
324
|
+
statusToCode,
|
|
191
325
|
endpoint,
|
|
192
326
|
onThisComputer,
|
|
193
327
|
modelAddressAllowed,
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
} from "./chunk-Y5E2WNWB.js";
|
|
6
6
|
import {
|
|
7
7
|
CliError
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PK5WEGPJ.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.714.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.122.0_commander@15_dd9fedf917a0d541ef7fdcdb0be0e64b/node_modules/@wirecat/cli-core/dist/store/vector-extension.js
|
|
14
14
|
import { readFileSync } from "node:fs";
|
|
15
15
|
var musl = /* @__PURE__ */ __name(() => {
|
|
16
16
|
if (process.platform !== "linux")
|