@wirecat/mail-cli 0.33.0 → 0.35.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +4 -1
  3. package/contracts/wirecat.json +54 -4
  4. package/dist/bin/mail.js +2 -2
  5. package/dist/bundle/agent-KWLCQCSC.js +39 -0
  6. package/dist/bundle/{all-profiles-W3CGXEEJ.js → all-profiles-6BDSMVOO.js} +63 -21
  7. package/dist/bundle/{anthropic-UMDO5AKP.js → anthropic-C3XUXUCJ.js} +8 -8
  8. package/dist/bundle/{app-server-4SICQ5RP.js → app-server-GUHDK4OR.js} +82 -64
  9. package/dist/bundle/{bun-QVVCH4MJ.js → bun-FN7AM4AG.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-CHD4AIUK.js → bun-sqlite-56IVBF22.js} +6 -6
  11. package/dist/bundle/{chunk-HFFHL7SV.js → chunk-2B67TUIF.js} +101 -69
  12. package/dist/bundle/{chunk-OOYIPK4F.js → chunk-2UNQTKRH.js} +1 -1
  13. package/dist/bundle/{chunk-LXUHYDNE.js → chunk-3ACF6TIV.js} +1 -1
  14. package/dist/bundle/chunk-3EV2B7KZ.js +726 -0
  15. package/dist/bundle/chunk-3KAJCOJP.js +109 -0
  16. package/dist/bundle/{chunk-2BFXHCZW.js → chunk-3WAZKCDF.js} +2 -2
  17. package/dist/bundle/{chunk-LKGJMM6W.js → chunk-46SBNO67.js} +12 -63
  18. package/dist/bundle/{chunk-LB5FTCPZ.js → chunk-4IASS7NQ.js} +128 -10
  19. package/dist/bundle/chunk-4U5ODZO7.js +360 -0
  20. package/dist/bundle/{chunk-QN423PC6.js → chunk-5WYBI35N.js} +3 -3
  21. package/dist/bundle/{chunk-GZYICXO4.js → chunk-5XQI7WCJ.js} +1 -1
  22. package/dist/bundle/{chunk-JUYUWMTG.js → chunk-635AFLZO.js} +4 -4
  23. package/dist/bundle/{chunk-2P44S7XK.js → chunk-6B4WZVLN.js} +36 -28
  24. package/dist/bundle/{chunk-47YNANPZ.js → chunk-6Q5THDNW.js} +3 -3
  25. package/dist/bundle/chunk-6VARUB3J.js +787 -0
  26. package/dist/bundle/{chunk-BRRHYXUP.js → chunk-7FXZKQAC.js} +87 -76
  27. package/dist/bundle/{chunk-EW3JFV7J.js → chunk-7JVKQ6NM.js} +4 -4
  28. package/dist/bundle/{chunk-OWAJN74H.js → chunk-7KMI47AP.js} +106 -257
  29. package/dist/bundle/{chunk-BF73DBAA.js → chunk-7PXAUMK5.js} +30 -15
  30. package/dist/bundle/{chunk-UX76GMQM.js → chunk-7YMLEWTX.js} +43 -64
  31. package/dist/bundle/{chunk-2L6D54BR.js → chunk-AISQNKT7.js} +8 -8
  32. package/dist/bundle/chunk-AV2ZJ4WX.js +7 -0
  33. package/dist/bundle/{chunk-OFMYFFEF.js → chunk-AXKIXVQA.js} +991 -1609
  34. package/dist/bundle/{chunk-UAV74EY4.js → chunk-CDGVYQXG.js} +1 -1
  35. package/dist/bundle/{chunk-RXUVXAMM.js → chunk-CFQQTDSA.js} +1 -1
  36. package/dist/bundle/chunk-CMGZXBJW.js +259 -0
  37. package/dist/bundle/{chunk-H46MANPR.js → chunk-DD2P67NP.js} +3 -3
  38. package/dist/bundle/{chunk-IBIFX2LK.js → chunk-DFHUJTP5.js} +2 -2
  39. package/dist/bundle/{chunk-DI74RP6R.js → chunk-DREU6TN6.js} +31 -85
  40. package/dist/bundle/{chunk-XQXYAOBV.js → chunk-DZHEVVXA.js} +53 -33
  41. package/dist/bundle/{chunk-LFBD6RTX.js → chunk-E6HSSKRX.js} +4 -4
  42. package/dist/bundle/{chunk-UYZDH5LK.js → chunk-EHAXFDDP.js} +1 -1
  43. package/dist/bundle/chunk-EU4J6GCJ.js +52 -0
  44. package/dist/bundle/{chunk-CHNNKHLL.js → chunk-EX4Z7CCO.js} +4051 -2788
  45. package/dist/bundle/chunk-G662S2M4.js +559 -0
  46. package/dist/bundle/{chunk-XN5KH24X.js → chunk-GG634DR3.js} +5 -5
  47. package/dist/bundle/{chunk-FSMCXQH2.js → chunk-GU3PYIV2.js} +2 -2
  48. package/dist/bundle/{chunk-SW7YGW3T.js → chunk-HF5QWKK2.js} +18 -8
  49. package/dist/bundle/chunk-HJDIMVFW.js +108 -0
  50. package/dist/bundle/chunk-HKWZG7CZ.js +334 -0
  51. package/dist/bundle/{chunk-BI5P7JWM.js → chunk-HM6AMYHR.js} +2 -2
  52. package/dist/bundle/{chunk-35AH33VJ.js → chunk-HVXOA4FO.js} +1 -1
  53. package/dist/bundle/{chunk-LXAX6AZU.js → chunk-I3QZCQJT.js} +6 -6
  54. package/dist/bundle/{chunk-I3UAD4EI.js → chunk-ILEKGH44.js} +68 -59
  55. package/dist/bundle/{chunk-SDWYOYGN.js → chunk-J5ULUTWE.js} +4 -4
  56. package/dist/bundle/{chunk-TK77DCE5.js → chunk-L4RCWRWS.js} +1 -1
  57. package/dist/bundle/chunk-MCJYJIH5.js +192 -0
  58. package/dist/bundle/{chunk-S6CHYNFE.js → chunk-NEDS4ORI.js} +2 -2
  59. package/dist/bundle/{chunk-QO7BK4WD.js → chunk-ODQCRZX5.js} +35 -12
  60. package/dist/bundle/chunk-OO4OKMNB.js +80 -0
  61. package/dist/bundle/{chunk-JCQ47WR4.js → chunk-OOQFBRNR.js} +144 -10
  62. package/dist/bundle/{chunk-LACMDMDI.js → chunk-OTP2HJ67.js} +9 -9
  63. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  64. package/dist/bundle/{chunk-AEKWEYIG.js → chunk-PQDQCCGG.js} +19 -19
  65. package/dist/bundle/{chunk-BZY5W35X.js → chunk-Q5U2HIBJ.js} +7 -7
  66. package/dist/bundle/{chunk-74BYHR44.js → chunk-QFMKCU42.js} +3738 -3415
  67. package/dist/bundle/{chunk-SYUIAMVA.js → chunk-QYCMB7JY.js} +373 -533
  68. package/dist/bundle/{chunk-KLLT572M.js → chunk-RBV2AM52.js} +2 -100
  69. package/dist/bundle/{chunk-6VCQ4CTK.js → chunk-RJNKM3CQ.js} +1 -1
  70. package/dist/bundle/{chunk-6IS4BEN4.js → chunk-RQHWSNX4.js} +4 -4
  71. package/dist/bundle/chunk-RQJGX7F7.js +170 -0
  72. package/dist/bundle/{chunk-RENCSP47.js → chunk-TARNPINT.js} +3 -3
  73. package/dist/bundle/chunk-TP2BCK2Z.js +721 -0
  74. package/dist/bundle/{chunk-MJ7DUSHT.js → chunk-TP766H4O.js} +18 -14
  75. package/dist/bundle/{chunk-2X344EUT.js → chunk-UHGKN5US.js} +8 -8
  76. package/dist/bundle/{chunk-L3MKFI3Y.js → chunk-UWDRU3R6.js} +2 -2
  77. package/dist/bundle/chunk-V4O47JV6.js +72 -0
  78. package/dist/bundle/{chunk-CIG4UVP6.js → chunk-W4JYGMTU.js} +14 -13
  79. package/dist/bundle/{chunk-JADBHKBP.js → chunk-W7ICCFG5.js} +1 -1
  80. package/dist/bundle/{chunk-MNJ3BMPZ.js → chunk-WDEVKKAD.js} +3 -3
  81. package/dist/bundle/{chunk-TBZLGT7R.js → chunk-WZKM5I7B.js} +23 -119
  82. package/dist/bundle/{chunk-MT7T5N2N.js → chunk-XKKYRMGG.js} +4 -4
  83. package/dist/bundle/chunk-XQNKAM26.js +338 -0
  84. package/dist/bundle/{chunk-UWF3SSRL.js → chunk-YA44BG3N.js} +58 -9
  85. package/dist/bundle/{chunk-Y2P2LC5R.js → chunk-YCIWSKOH.js} +9 -9
  86. package/dist/bundle/{chunk-7OYZU5SP.js → chunk-YQTRKNZQ.js} +4 -4
  87. package/dist/bundle/chunk-YRAJFTFU.js +353 -0
  88. package/dist/bundle/chunk-YTI533XF.js +29 -0
  89. package/dist/bundle/{chunk-UG2QDGAH.js → chunk-ZMYRPMAJ.js} +1 -1
  90. package/dist/bundle/{chunk-CZ6ZXDSO.js → chunk-ZX7HZDD6.js} +182 -562
  91. package/dist/bundle/{chunk-IPSLQX64.js → chunk-ZYEU35MB.js} +2 -2
  92. package/dist/bundle/command-contract-D5UXWHMS.js +39 -0
  93. package/dist/bundle/{command-server-entry-G2ZHCN5J.js → command-server-entry-TPJ47FYS.js} +28 -25
  94. package/dist/bundle/decode-XHUASXQK.js +296 -0
  95. package/dist/bundle/{dispatch-RHIK22OA.js → dispatch-MQZHGGVP.js} +8 -8
  96. package/dist/bundle/{dist-X5G2IMYG.js → dist-BAE4IQ52.js} +34 -29
  97. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  98. package/dist/bundle/{echarts-UZJ6AREV.js → echarts-U7Z2PKIG.js} +2 -2
  99. package/dist/bundle/{embed-FEXLUH3T.js → embed-W7GPB6EI.js} +6 -6
  100. package/dist/bundle/{embedder-NHQARKFJ.js → embedder-T72XLFQ5.js} +9 -9
  101. package/dist/bundle/{failure-7DIA4OET.js → failure-MP6VKL5Y.js} +2 -2
  102. package/dist/bundle/{first-run-PS5NR2QG.js → first-run-C44TJXRI.js} +12 -12
  103. package/dist/bundle/first-screen-IESI7DAU.js +39 -0
  104. package/dist/bundle/{instructions-SDDUBGH4.js → instructions-WGMWQNPP.js} +1 -1
  105. package/dist/bundle/mail.js +12 -12
  106. package/dist/bundle/{mcp-GN4FTJX5.js → mcp-YGOAUNC3.js} +2 -2
  107. package/dist/bundle/meeting-combined-XGZBSWIQ.js +24 -0
  108. package/dist/bundle/meeting-model-QVHLD4WI.js +24 -0
  109. package/dist/bundle/meeting-semantic-QKQHUHXX.js +21 -0
  110. package/dist/bundle/{node-ELCNUOCE.js → node-WANDMJJQ.js} +2 -2
  111. package/dist/bundle/{node-sqlite-2E5MKZMH.js → node-sqlite-NM5XA4DR.js} +7 -7
  112. package/dist/bundle/{oauth-JGPEIY3M.js → oauth-6E63ELEE.js} +8 -8
  113. package/dist/bundle/{open-6DEMCZAB.js → open-5542RTLE.js} +5 -5
  114. package/dist/bundle/{openai-IVKDU5AH.js → openai-NOYNPFB5.js} +28 -26
  115. package/dist/bundle/{process-67DAKAAQ.js → process-7AEXXSBX.js} +1 -1
  116. package/dist/bundle/{program-ESJDQMAJ.js → program-VMA5CGNR.js} +5712 -3640
  117. package/dist/bundle/{prompt-ZBWOT5KG.js → prompt-WYYO4AJL.js} +5 -5
  118. package/dist/bundle/{recognize-UUBH2DOH.js → recognize-UGCCOMAS.js} +4 -4
  119. package/dist/bundle/{remote-UYTNWNOB.js → remote-VZS6BNQB.js} +9 -9
  120. package/dist/bundle/{rerank-X2633CQN.js → rerank-O46D5GJ2.js} +7 -7
  121. package/dist/bundle/{serve-CP7Q4OVW.js → serve-QAAF2LCW.js} +10 -10
  122. package/dist/bundle/server-456MYK3X.js +84 -0
  123. package/dist/bundle/{server-I7MXRSAG.js → server-Q3PUZLLX.js} +77 -58
  124. package/dist/bundle/{sqlite-runtime-BX55LI5G.js → sqlite-runtime-EQBCDO2U.js} +6 -6
  125. package/dist/bundle/{state-LLNJQXFH.js → state-XIOHYXCR.js} +6 -6
  126. package/dist/bundle/{store-N27XI3VV.js → store-OXJZZUR7.js} +34 -17
  127. package/dist/bundle/{store-K4KU5N75.js → store-VJBL5XKR.js} +30 -20
  128. package/dist/bundle/store-maintenance-command-D7XYIX52.js +71 -0
  129. package/dist/bundle/surface-N7LK7PKN.js +70 -0
  130. package/dist/commands/read.d.ts +2 -2
  131. package/dist/commands/read.d.ts.map +1 -1
  132. package/dist/commands/read.js +5 -4
  133. package/dist/commands/read.js.map +1 -1
  134. package/dist/commands/sync.d.ts +2 -1
  135. package/dist/commands/sync.d.ts.map +1 -1
  136. package/dist/commands/sync.js +16 -9
  137. package/dist/commands/sync.js.map +1 -1
  138. package/dist/config.d.ts +6 -0
  139. package/dist/config.d.ts.map +1 -1
  140. package/dist/config.js +16 -1
  141. package/dist/config.js.map +1 -1
  142. package/dist/identity.d.ts.map +1 -1
  143. package/dist/identity.js +2 -2
  144. package/dist/identity.js.map +1 -1
  145. package/dist/version.d.ts +1 -1
  146. package/dist/version.js +1 -1
  147. package/package.json +3 -3
  148. package/dist/bundle/chunk-BDCC2J2Z.js +0 -2
  149. package/dist/bundle/command-contract-NRNQAFFE.js +0 -36
  150. package/dist/bundle/decode-U6V6D6XH.js +0 -162
  151. package/dist/bundle/first-screen-C2WTLOG2.js +0 -34
  152. package/dist/bundle/server-QGTMJ7SF.js +0 -67
  153. package/dist/bundle/store-maintenance-command-VPAFQCNA.js +0 -58
@@ -0,0 +1,80 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ timezoneOf,
5
+ zonedMoment
6
+ } from "./chunk-AXKIXVQA.js";
7
+ import {
8
+ CliError
9
+ } from "./chunk-HM6AMYHR.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.709.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_d98198650466e0f5373009c2596db072/node_modules/@wirecat/cli-core/dist/domain/moment.js
15
+ var calendarMoment = /* @__PURE__ */ __name((wanted, flag, { zone, end = false } = {}) => {
16
+ try {
17
+ return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
18
+ } catch (error) {
19
+ if (!(error instanceof CliError))
20
+ throw error;
21
+ const alternative = error.details?.alternative;
22
+ throw new CliError("validation_error", `${flag}: "${wanted}" is not a time${alternative ? ` \u2014 ${alternative}` : ""}`);
23
+ }
24
+ }, "calendarMoment");
25
+ var dayIn = /* @__PURE__ */ __name((at, zone) => new Intl.DateTimeFormat("en-CA", { timeZone: zone, year: "numeric", month: "2-digit", day: "2-digit" }).format(at), "dayIn");
26
+ var MINUTE = 6e4;
27
+ var YEAR = 365 * 24 * 60 * MINUTE;
28
+ var RELATIVE = /^(\d+)(m|h|d)$/;
29
+ var RELATIVE_MS = { m: MINUTE, h: 60 * MINUTE, d: 24 * 60 * MINUTE };
30
+ var DATE_ALONE = /^\d{4}-\d{2}-\d{2}$/;
31
+ var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
32
+ var dayWord = /* @__PURE__ */ __name((word, zone, now) => {
33
+ const today = new Intl.DateTimeFormat("en-CA", { timeZone: zone }).format(now);
34
+ if (word === "today")
35
+ return today;
36
+ const date = /* @__PURE__ */ new Date(`${today}T00:00:00Z`);
37
+ date.setUTCDate(date.getUTCDate() - 1);
38
+ return date.toISOString().slice(0, 10);
39
+ }, "dayWord");
40
+ var readMoment = /* @__PURE__ */ __name((typed, flag, { zone, end = false, now = Date.now(), direction = -1 } = {}) => {
41
+ const wanted = typed.trim();
42
+ const [, amount, unit] = RELATIVE.exec(wanted) ?? [];
43
+ if (amount && unit)
44
+ return { time: now + direction * Number(amount) * (RELATIVE_MS[unit] ?? 0), local: false, dateAlone: false };
45
+ const word = wanted.toLowerCase();
46
+ const date = word === "today" || word === "yesterday" ? dayWord(word, timezoneOf(zone), now) : wanted;
47
+ if (!/^\d{4}-\d{2}-\d{2}/.test(date))
48
+ return void 0;
49
+ const iso = date.replace(/^(\d{4}-\d{2}-\d{2}) +(?=\d)/, "$1T");
50
+ return {
51
+ time: calendarMoment(iso, flag, { ...zone === void 0 ? {} : { zone }, end }),
52
+ local: !ZONED.test(iso),
53
+ dateAlone: DATE_ALONE.test(iso)
54
+ };
55
+ }, "readMoment");
56
+ var lead = /* @__PURE__ */ __name((ms) => ms === MINUTE ? "a minute" : ms === YEAR ? "a year" : `${Math.ceil(ms / MINUTE)} minutes`, "lead");
57
+ var aheadOf = /* @__PURE__ */ __name((reference, flag, now = Date.now(), options = {}) => {
58
+ const { refuseDate = false, soonest, latest, ...at } = options;
59
+ const read = readMoment(reference, flag, { ...at, now, direction: 1 });
60
+ if (read === void 0)
61
+ throw new CliError("validation_error", `${flag} takes an ISO 8601 time, today, or 30m, 2h, 3d from now \u2014 not "${reference.trim()}"`);
62
+ if (refuseDate && read.dateAlone)
63
+ throw new CliError("validation_error", DATE_ALONE.test(reference.trim()) ? `${flag} needs a time of day as well: ${reference.trim()}T09:00` : `${flag} needs a time of day as well, like 2026-11-20T09:00`);
64
+ if (soonest === 0 && read.time <= now)
65
+ throw new CliError("validation_error", `${flag} is in the past`);
66
+ if (soonest !== void 0 && soonest > 0 && read.time < now + soonest)
67
+ throw new CliError("validation_error", `${flag} has to be at least ${lead(soonest)} from now`);
68
+ if (latest !== void 0 && read.time > now + latest)
69
+ throw new CliError("validation_error", `${flag} can be at most ${lead(latest)} from now`);
70
+ return read.time;
71
+ }, "aheadOf");
72
+
73
+ export {
74
+ calendarMoment,
75
+ dayIn,
76
+ MINUTE,
77
+ YEAR,
78
+ readMoment,
79
+ aheadOf
80
+ };
@@ -3,12 +3,97 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  CliError,
5
5
  isCliError
6
- } from "./chunk-BI5P7JWM.js";
6
+ } from "./chunk-HM6AMYHR.js";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-ZVVMGPBJ.js";
10
10
 
11
- // node_modules/.pnpm/@wirecat+cli-base@0.100.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
11
+ // node_modules/.pnpm/@wirecat+cli-base@0.124.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.124.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.100.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
108
+ // node_modules/.pnpm/@wirecat+cli-base@0.124.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 checked = /* @__PURE__ */ __name((url, hosts) => {
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 = checked(new URL(request?.url ?? String(input)), hosts);
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 = checked(new URL(location, url), hosts);
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`, { retryable: true });
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.100.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
226
+ // node_modules/.pnpm/@wirecat+cli-base@0.124.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.663.0_@wirecat+cli-base@0.100.0_commander@15.0.0_esbuild@0.28.2_typ_3651938dd4032f987ce713acb104c9b9/node_modules/@wirecat/cli-core/dist/models/endpoint.js
267
+ // node_modules/.pnpm/@wirecat+cli-core@0.709.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_d98198650466e0f5373009c2596db072/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,
@@ -4,18 +4,18 @@ import {
4
4
  PLAIN_HTTP_REFUSED,
5
5
  modelAddressAllowed,
6
6
  onThisComputer
7
- } from "./chunk-JCQ47WR4.js";
7
+ } from "./chunk-OOQFBRNR.js";
8
8
  import {
9
9
  readSharedSection,
10
10
  sharedConfigPath,
11
11
  writeSharedSection
12
- } from "./chunk-BZY5W35X.js";
12
+ } from "./chunk-Q5U2HIBJ.js";
13
13
  import {
14
14
  unit
15
- } from "./chunk-UX76GMQM.js";
15
+ } from "./chunk-7YMLEWTX.js";
16
16
  import {
17
17
  storePath
18
- } from "./chunk-IPSLQX64.js";
18
+ } from "./chunk-ZYEU35MB.js";
19
19
  import {
20
20
  boolean,
21
21
  isoTimestamp,
@@ -23,18 +23,18 @@ import {
23
23
  safeParse,
24
24
  strictObject,
25
25
  string
26
- } from "./chunk-UWF3SSRL.js";
26
+ } from "./chunk-YA44BG3N.js";
27
27
  import {
28
28
  CliError
29
- } from "./chunk-BI5P7JWM.js";
29
+ } from "./chunk-HM6AMYHR.js";
30
30
  import {
31
31
  __name
32
32
  } from "./chunk-ZVVMGPBJ.js";
33
33
 
34
- // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.100.0_commander@15.0.0_esbuild@0.28.2_typ_3651938dd4032f987ce713acb104c9b9/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.709.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_d98198650466e0f5373009c2596db072/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
35
35
  import { setTimeout } from "node:timers/promises";
36
36
 
37
- // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.100.0_commander@15.0.0_esbuild@0.28.2_typ_3651938dd4032f987ce713acb104c9b9/node_modules/@wirecat/cli-core/dist/models/local-only.js
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.709.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_d98198650466e0f5373009c2596db072/node_modules/@wirecat/cli-core/dist/models/local-only.js
38
38
  var SECTION = "local_only";
39
39
  var Setting = strictObject({
40
40
  on: boolean(),
@@ -68,7 +68,7 @@ var refuseModelAddress = /* @__PURE__ */ __name((env, address, what) => {
68
68
  refuseOffComputer(env, address, what);
69
69
  }, "refuseModelAddress");
70
70
 
71
- // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.100.0_commander@15.0.0_esbuild@0.28.2_typ_3651938dd4032f987ce713acb104c9b9/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
71
+ // node_modules/.pnpm/@wirecat+cli-core@0.709.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_d98198650466e0f5373009c2596db072/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
72
72
  var OPENAI_URL = "https://api.openai.com/v1";
73
73
  var OPENAI_MODELS = {
74
74
  "text-embedding-3-small": { dims: 1536, perMillion: 0.02 },