@wirecat/attio-cli 0.8.0 → 0.10.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 (207) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/contracts/wirecat.json +1 -0
  3. package/dist/bin/attio.js +11 -11
  4. package/dist/bundle/attio.js +5 -166
  5. package/dist/bundle/{chunk-UXJZISVL.js → chunk-OGWKDPR5.js} +2 -1
  6. package/dist/bundle/chunk-TQAECZFO.js +13 -0
  7. package/dist/bundle/{definitions-FODOIPM2.js → definitions-J73IBAHT.js} +1 -1
  8. package/dist/bundle/program-NSBWZ25F.js +6201 -0
  9. package/dist/bundle/{schemas-YGSTNU6F.js → schemas-G3HFAS45.js} +576 -29
  10. package/dist/commands/api.js +1 -2
  11. package/dist/commands/crm.js +1 -4
  12. package/dist/commands/schedule.js +1 -1
  13. package/dist/commands/session.js +1 -2
  14. package/dist/config.js +1 -2
  15. package/dist/context.js +1 -1
  16. package/dist/identity.js +1 -0
  17. package/dist/program.js +1 -2
  18. package/dist/version.js +1 -1
  19. package/package.json +4 -4
  20. package/dist/activities.d.ts +0 -4
  21. package/dist/activities.d.ts.map +0 -1
  22. package/dist/activities.js.map +0 -1
  23. package/dist/bin/attio.d.ts +0 -3
  24. package/dist/bin/attio.d.ts.map +0 -1
  25. package/dist/bin/attio.js.map +0 -1
  26. package/dist/bundle/agent-GUXXSLT5.js +0 -38
  27. package/dist/bundle/all-profiles-63N3EQ46.js +0 -320
  28. package/dist/bundle/anthropic-B4W7MZQE.js +0 -91
  29. package/dist/bundle/app-server-EXNGTHWO.js +0 -250
  30. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  31. package/dist/bundle/bun-sqlite-NBAY7FR2.js +0 -76
  32. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  33. package/dist/bundle/chunk-2QDUP74I.js +0 -794
  34. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  35. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  36. package/dist/bundle/chunk-3MSHGNVE.js +0 -1243
  37. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  38. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  39. package/dist/bundle/chunk-4RBMCXZT.js +0 -1337
  40. package/dist/bundle/chunk-4RSWOPKL.js +0 -323
  41. package/dist/bundle/chunk-5JKTVAXX.js +0 -2788
  42. package/dist/bundle/chunk-5N2V6XO7.js +0 -119
  43. package/dist/bundle/chunk-5WD22IXQ.js +0 -66
  44. package/dist/bundle/chunk-6K4Z6CAM.js +0 -43997
  45. package/dist/bundle/chunk-6TD3DCWC.js +0 -106
  46. package/dist/bundle/chunk-7Z53MLQP.js +0 -388
  47. package/dist/bundle/chunk-AATTOFNY.js +0 -2045
  48. package/dist/bundle/chunk-APARYILG.js +0 -743
  49. package/dist/bundle/chunk-D72URWJE.js +0 -532
  50. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  51. package/dist/bundle/chunk-DM7KWVDZ.js +0 -3752
  52. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  53. package/dist/bundle/chunk-DPD4FMHN.js +0 -388
  54. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  55. package/dist/bundle/chunk-DURNR4RO.js +0 -353
  56. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  57. package/dist/bundle/chunk-EVUMQKV7.js +0 -76
  58. package/dist/bundle/chunk-EY36BTKZ.js +0 -108
  59. package/dist/bundle/chunk-FH6OEGGN.js +0 -557
  60. package/dist/bundle/chunk-FOP6G45D.js +0 -358
  61. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  62. package/dist/bundle/chunk-GTEX4IUO.js +0 -334
  63. package/dist/bundle/chunk-HZ3C4WXD.js +0 -142
  64. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  65. package/dist/bundle/chunk-J6GVVISK.js +0 -185
  66. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  67. package/dist/bundle/chunk-JIGEJZ4I.js +0 -68943
  68. package/dist/bundle/chunk-KVTNYRDO.js +0 -1007
  69. package/dist/bundle/chunk-L45WN3AR.js +0 -80
  70. package/dist/bundle/chunk-L72WUJAS.js +0 -54
  71. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  72. package/dist/bundle/chunk-LM3W7YOM.js +0 -274
  73. package/dist/bundle/chunk-M4AC55ZB.js +0 -12733
  74. package/dist/bundle/chunk-MCLQTCGH.js +0 -1202
  75. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  76. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  77. package/dist/bundle/chunk-OYEVYOCL.js +0 -259
  78. package/dist/bundle/chunk-P7G5HFY3.js +0 -288
  79. package/dist/bundle/chunk-PAEKXVJW.js +0 -188
  80. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  81. package/dist/bundle/chunk-PLPBEWD4.js +0 -170
  82. package/dist/bundle/chunk-PMQ7GP6X.js +0 -95
  83. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  84. package/dist/bundle/chunk-QPPOIWPY.js +0 -1246
  85. package/dist/bundle/chunk-QSJKSPWF.js +0 -131
  86. package/dist/bundle/chunk-RDVTHFPP.js +0 -338
  87. package/dist/bundle/chunk-RQORQN2V.js +0 -4072
  88. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  89. package/dist/bundle/chunk-S4UUN6LD.js +0 -1410
  90. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  91. package/dist/bundle/chunk-SCI7QEHF.js +0 -362
  92. package/dist/bundle/chunk-SSA6JBPA.js +0 -778
  93. package/dist/bundle/chunk-T4J7XFXT.js +0 -9667
  94. package/dist/bundle/chunk-TTF5DP4V.js +0 -1197
  95. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  96. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  97. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  98. package/dist/bundle/chunk-UKHF37ZU.js +0 -1068
  99. package/dist/bundle/chunk-V57E7PJQ.js +0 -161
  100. package/dist/bundle/chunk-V7IF2K3P.js +0 -52
  101. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  102. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  103. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  104. package/dist/bundle/chunk-WXQGA6XK.js +0 -50
  105. package/dist/bundle/chunk-XQGN2D44.js +0 -86
  106. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  107. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  108. package/dist/bundle/chunk-YNGU36GW.js +0 -218
  109. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  110. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  111. package/dist/bundle/chunk-ZZD2YPOX.js +0 -156
  112. package/dist/bundle/command-contract-KCCW4LNI.js +0 -37
  113. package/dist/bundle/command-server-entry-3NPPABQQ.js +0 -166
  114. package/dist/bundle/decode-26M7XE2B.js +0 -297
  115. package/dist/bundle/dispatch-2FTOHA5D.js +0 -411
  116. package/dist/bundle/dist-EM7KLEG4.js +0 -7577
  117. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  118. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  119. package/dist/bundle/embed-XJLEAWXE.js +0 -38
  120. package/dist/bundle/embedder-OEL6PXEH.js +0 -111
  121. package/dist/bundle/failure-OHIXWTR6.js +0 -25
  122. package/dist/bundle/first-run-CIXGBXY6.js +0 -29
  123. package/dist/bundle/first-screen-5FK4D45F.js +0 -38
  124. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  125. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  126. package/dist/bundle/meeting-combined-DMVGQNJ7.js +0 -24
  127. package/dist/bundle/meeting-model-2THAT7OH.js +0 -25
  128. package/dist/bundle/meeting-semantic-Q6XYFYUD.js +0 -22
  129. package/dist/bundle/node-EGMCBAO7.js +0 -176
  130. package/dist/bundle/node-KM3CUABH.js +0 -2340
  131. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  132. package/dist/bundle/node-sqlite-2SWWGW6H.js +0 -74
  133. package/dist/bundle/oauth-V5LGTXF2.js +0 -20
  134. package/dist/bundle/open-25EKOTZA.js +0 -23
  135. package/dist/bundle/openai-VX3OLIHM.js +0 -238
  136. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  137. package/dist/bundle/program-Z5NUNXME.js +0 -34214
  138. package/dist/bundle/prompt-2VSPX5S7.js +0 -17
  139. package/dist/bundle/recognize-NA5XUFKK.js +0 -26
  140. package/dist/bundle/remote-BOME6XOE.js +0 -31
  141. package/dist/bundle/rerank-NG3XMFCV.js +0 -52
  142. package/dist/bundle/serve-MR67OBED.js +0 -199
  143. package/dist/bundle/server-4BWAGJQO.js +0 -80
  144. package/dist/bundle/server-OP2HJNXD.js +0 -213
  145. package/dist/bundle/sqlite-runtime-V5U6F5EB.js +0 -20
  146. package/dist/bundle/state-L4MWAATO.js +0 -36
  147. package/dist/bundle/store-2ALTEH55.js +0 -181
  148. package/dist/bundle/store-CXZFRG5D.js +0 -297
  149. package/dist/bundle/store-maintenance-command-LC55DRQA.js +0 -67
  150. package/dist/bundle/surface-3GRJ7473.js +0 -66
  151. package/dist/commands/api.d.ts +0 -12
  152. package/dist/commands/api.d.ts.map +0 -1
  153. package/dist/commands/api.js.map +0 -1
  154. package/dist/commands/crm.d.ts +0 -7
  155. package/dist/commands/crm.d.ts.map +0 -1
  156. package/dist/commands/crm.js.map +0 -1
  157. package/dist/commands/schedule.d.ts +0 -3
  158. package/dist/commands/schedule.d.ts.map +0 -1
  159. package/dist/commands/schedule.js.map +0 -1
  160. package/dist/commands/session.d.ts +0 -8
  161. package/dist/commands/session.d.ts.map +0 -1
  162. package/dist/commands/session.js.map +0 -1
  163. package/dist/config.d.ts +0 -13
  164. package/dist/config.d.ts.map +0 -1
  165. package/dist/config.js.map +0 -1
  166. package/dist/context.d.ts +0 -37
  167. package/dist/context.d.ts.map +0 -1
  168. package/dist/context.js.map +0 -1
  169. package/dist/generated/definitions.d.ts +0 -3
  170. package/dist/generated/definitions.d.ts.map +0 -1
  171. package/dist/generated/definitions.js.map +0 -1
  172. package/dist/generated/manifest.d.ts +0 -6
  173. package/dist/generated/manifest.d.ts.map +0 -1
  174. package/dist/generated/manifest.js.map +0 -1
  175. package/dist/generated/schemas.d.ts +0 -383
  176. package/dist/generated/schemas.d.ts.map +0 -1
  177. package/dist/generated/schemas.js.map +0 -1
  178. package/dist/generated/types.d.ts +0 -10166
  179. package/dist/generated/types.d.ts.map +0 -1
  180. package/dist/generated/types.js.map +0 -1
  181. package/dist/generated/wirecat-config.d.ts +0 -15
  182. package/dist/generated/wirecat-config.d.ts.map +0 -1
  183. package/dist/generated/wirecat-config.js.map +0 -1
  184. package/dist/hooks.d.ts +0 -33
  185. package/dist/hooks.d.ts.map +0 -1
  186. package/dist/hooks.js.map +0 -1
  187. package/dist/identity.d.ts +0 -33
  188. package/dist/identity.d.ts.map +0 -1
  189. package/dist/identity.js.map +0 -1
  190. package/dist/index.d.ts +0 -3
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js.map +0 -1
  193. package/dist/links.d.ts +0 -10
  194. package/dist/links.d.ts.map +0 -1
  195. package/dist/links.js.map +0 -1
  196. package/dist/meetings.d.ts +0 -57
  197. package/dist/meetings.d.ts.map +0 -1
  198. package/dist/meetings.js.map +0 -1
  199. package/dist/program.d.ts +0 -6
  200. package/dist/program.d.ts.map +0 -1
  201. package/dist/program.js.map +0 -1
  202. package/dist/version.d.ts +0 -2
  203. package/dist/version.d.ts.map +0 -1
  204. package/dist/version.js.map +0 -1
  205. package/dist/wcat.d.ts +0 -3
  206. package/dist/wcat.d.ts.map +0 -1
  207. package/dist/wcat.js.map +0 -1
@@ -1,106 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- CAPABILITY_STATEMENTS,
5
- storeCapable
6
- } from "./chunk-PMQ7GP6X.js";
7
- import {
8
- importFrom
9
- } from "./chunk-Y5E2WNWB.js";
10
- import {
11
- __name
12
- } from "./chunk-ZVVMGPBJ.js";
13
-
14
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/sqlite-runtime.js
15
- import { spawn, spawnSync } from "node:child_process";
16
- import { readFileSync } from "node:fs";
17
- import { dirname } from "node:path";
18
- var RESTARTED = "CLI_MESSAGING_SQLITE_RESTARTED";
19
- var USER_LIBRARY_PATH = "CLI_MESSAGING_USER_LD_LIBRARY_PATH";
20
- var FORWARDED = ["SIGTERM", "SIGHUP", "SIGQUIT"];
21
- var ensureSqlite = /* @__PURE__ */ __name(async (runtime = nodeRuntime()) => {
22
- const { env } = runtime;
23
- if (env[RESTARTED]) {
24
- if (env[USER_LIBRARY_PATH] === void 0)
25
- delete env.LD_LIBRARY_PATH;
26
- else
27
- env.LD_LIBRARY_PATH = env[USER_LIBRARY_PATH];
28
- delete env[USER_LIBRARY_PATH];
29
- delete env[RESTARTED];
30
- return;
31
- }
32
- if (runtime.bun || runtime.platform !== "linux")
33
- return;
34
- const maps = runtime.maps();
35
- if (!maps.includes("libsqlite3"))
36
- return;
37
- if (await runtime.capable())
38
- return;
39
- const library = await runtime.library(maps.includes("ld-musl"));
40
- if (!library)
41
- return;
42
- const restarted = {
43
- ...env,
44
- LD_LIBRARY_PATH: [dirname(library.path), env.LD_LIBRARY_PATH].filter(Boolean).join(":"),
45
- [RESTARTED]: "1"
46
- };
47
- if (env.LD_LIBRARY_PATH !== void 0)
48
- restarted[USER_LIBRARY_PATH] = env.LD_LIBRARY_PATH;
49
- if (!runtime.works(restarted, library.version))
50
- return;
51
- await runtime.restart(restarted);
52
- }, "ensureSqlite");
53
- var trialScript = /* @__PURE__ */ __name((version) => `
54
- const { DatabaseSync } = await import("node:sqlite")
55
- const database = new DatabaseSync(":memory:")
56
- if (database.prepare("SELECT sqlite_version() AS v").get().v !== ${JSON.stringify(version)}) process.exit(1)
57
- for (const statement of ${JSON.stringify(CAPABILITY_STATEMENTS)}) database.exec(statement)
58
- `, "trialScript");
59
- var nodeRuntime = /* @__PURE__ */ __name(() => ({
60
- env: process.env,
61
- platform: process.platform,
62
- bun: "Bun" in globalThis,
63
- maps: /* @__PURE__ */ __name(() => {
64
- try {
65
- return readFileSync("/proc/self/maps", "utf8");
66
- } catch {
67
- return "";
68
- }
69
- }, "maps"),
70
- capable: /* @__PURE__ */ __name(() => storeCapable().then(() => true, () => false), "capable"),
71
- library: /* @__PURE__ */ __name(async (musl) => {
72
- try {
73
- const { libraryFor, SQLITE_VERSION } = await importFrom(new URL("sqlite-runtime.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
74
- const path = libraryFor({ musl });
75
- return path === void 0 ? void 0 : { path, version: SQLITE_VERSION };
76
- } catch {
77
- return void 0;
78
- }
79
- }, "library"),
80
- works: /* @__PURE__ */ __name((env, version) => spawnSync(process.execPath, ["--no-warnings", "--input-type=module", "-e", trialScript(version)], {
81
- env,
82
- stdio: "ignore",
83
- timeout: 1e4
84
- }).status === 0, "works"),
85
- restart: /* @__PURE__ */ __name((env) => relay(spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], { env, stdio: "inherit" })), "restart")
86
- }), "nodeRuntime");
87
- var relay = /* @__PURE__ */ __name((child, host = process) => new Promise(() => {
88
- for (const signal of FORWARDED)
89
- host.on(signal, () => child.kill(signal));
90
- host.on("SIGINT", () => {
91
- });
92
- child.on("error", () => host.exit(1));
93
- child.on("exit", (code, signal) => {
94
- if (signal) {
95
- host.removeAllListeners(signal);
96
- host.kill(host.pid, signal);
97
- } else
98
- host.exit(code ?? 1);
99
- });
100
- }), "relay");
101
-
102
- export {
103
- ensureSqlite,
104
- nodeRuntime,
105
- relay
106
- };
@@ -1,388 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- DEFAULT_RETRY,
5
- backoffMs,
6
- realSleep,
7
- wallClock
8
- } from "./chunk-5JKTVAXX.js";
9
- import {
10
- CliError,
11
- isCliError
12
- } from "./chunk-S6JG4YUH.js";
13
- import {
14
- __name
15
- } from "./chunk-ZVVMGPBJ.js";
16
-
17
- // node_modules/.pnpm/@wirecat+cli-base@1.0.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
18
- 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");
19
- var checked = /* @__PURE__ */ __name((signal) => {
20
- if (signal?.aborted)
21
- throw interrupted(signal);
22
- }, "checked");
23
- var abortable = /* @__PURE__ */ __name(async (pending, signal) => {
24
- if (!signal)
25
- return pending;
26
- let abort = /* @__PURE__ */ __name(() => {
27
- }, "abort");
28
- const stopped = new Promise((_, reject) => {
29
- abort = /* @__PURE__ */ __name(() => reject(interrupted(signal)), "abort");
30
- signal.addEventListener("abort", abort, { once: true });
31
- if (signal.aborted)
32
- abort();
33
- });
34
- try {
35
- return await Promise.race([pending, stopped]);
36
- } finally {
37
- signal.removeEventListener("abort", abort);
38
- }
39
- }, "abortable");
40
- var readJsonResponse = /* @__PURE__ */ __name(async (response, options) => {
41
- const { maxBytes, signal } = options ?? {};
42
- if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
43
- throw new CliError("validation_error", "maxBytes must be a positive safe integer");
44
- if (signal !== void 0 && !(signal instanceof AbortSignal))
45
- throw new CliError("validation_error", "signal must be an AbortSignal");
46
- if (signal?.aborted) {
47
- void response.body?.cancel().catch(() => {
48
- });
49
- throw interrupted(signal);
50
- }
51
- const length = response.headers.get("content-length");
52
- if (length !== null && (!/^\d+$/.test(length) || Number(length) > maxBytes)) {
53
- void response.body?.cancel().catch(() => {
54
- });
55
- throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
56
- }
57
- if (!response.body)
58
- throw new CliError("invalid_response", "HTTP response has no body");
59
- if (response.body.locked)
60
- throw new CliError("invalid_response", "HTTP response body is already in use");
61
- const reader = response.body.getReader();
62
- const chunks = [];
63
- let bytes = 0;
64
- try {
65
- for (; ; ) {
66
- checked(signal);
67
- const part = await abortable(reader.read(), signal);
68
- checked(signal);
69
- if (part.done)
70
- break;
71
- if (!(part.value instanceof Uint8Array))
72
- throw new CliError("invalid_response", "HTTP response is not bytes");
73
- bytes += part.value.byteLength;
74
- if (bytes > maxBytes)
75
- throw new CliError("invalid_response", "HTTP response exceeds the byte budget");
76
- if (part.value.byteLength)
77
- chunks.push(new Uint8Array(part.value));
78
- }
79
- const body = new Uint8Array(bytes);
80
- let offset = 0;
81
- for (const chunk of chunks) {
82
- body.set(chunk, offset);
83
- offset += chunk.byteLength;
84
- }
85
- try {
86
- return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body));
87
- } catch {
88
- throw new CliError("invalid_response", "HTTP response is not valid UTF-8 JSON");
89
- }
90
- } catch (error) {
91
- checked(signal);
92
- if (isCliError(error))
93
- throw error;
94
- throw new CliError("network_error", "HTTP response could not be read");
95
- } finally {
96
- void reader.cancel().catch(() => {
97
- });
98
- reader.releaseLock();
99
- }
100
- }, "readJsonResponse");
101
-
102
- // node_modules/.pnpm/@wirecat+cli-base@1.0.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
103
- var LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
104
- var HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
105
- var hostProblems = /* @__PURE__ */ __name((hosts) => [
106
- ...hosts.filter((host) => !HOST_PATTERN.test(host) || host.length > 253).map((host) => `${JSON.stringify(host)} is not a host: a lower-case hostname with no scheme, port or path, or one leading *. before two labels or more`),
107
- ...hosts.filter((host, at) => hosts.indexOf(host) !== at).map((host) => `${JSON.stringify(host)} is listed twice`)
108
- ], "hostProblems");
109
- var hostCovered = /* @__PURE__ */ __name((hostname, hosts) => {
110
- const name = hostname.toLowerCase().replace(/\.$/, "");
111
- return hosts.some((host) => host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host);
112
- }, "hostCovered");
113
-
114
- // node_modules/.pnpm/@wirecat+cli-base@1.0.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
115
- var HOST_FETCH_TIMEOUT_MS = 3e4;
116
- var REDIRECTS = 5;
117
- var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
118
- var CREDENTIAL_HEADERS = ["authorization", "cookie", "proxy-authorization"];
119
- var NO_BODY = /* @__PURE__ */ new Set([204, 205, 304]);
120
- var deadline = /* @__PURE__ */ __name((ms) => {
121
- const controller = new AbortController();
122
- const timer = setTimeout(() => controller.abort(new DOMException(`no answer within ${ms} ms`, "TimeoutError")), ms);
123
- timer.unref?.();
124
- return { signal: controller.signal, clear: /* @__PURE__ */ __name(() => clearTimeout(timer), "clear") };
125
- }, "deadline");
126
- var released = /* @__PURE__ */ __name((response, clear) => {
127
- if (!response.body || NO_BODY.has(response.status) || response.status < 200 || response.status > 599) {
128
- clear();
129
- return response;
130
- }
131
- const { status, statusText, headers, url, redirected } = response;
132
- const wrapped = new Response(response.body.pipeThrough(new TransformStream({ flush: clear })), {
133
- status,
134
- statusText,
135
- headers
136
- });
137
- return Object.defineProperties(wrapped, { url: { value: url }, redirected: { value: redirected } });
138
- }, "released");
139
- 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");
140
- var checked2 = /* @__PURE__ */ __name((url, hosts) => {
141
- if (url.protocol !== "https:" && url.protocol !== "http:")
142
- throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
143
- sent: false
144
- });
145
- if (!hostCovered(url.hostname, hosts))
146
- throw undeclared(url);
147
- return url;
148
- }, "checked");
149
- var ENCODED_SLASH = /%2f|%5c/i;
150
- var scopeOf = /* @__PURE__ */ __name((scope) => {
151
- if (scope === void 0)
152
- return void 0;
153
- if (!URL.canParse(scope))
154
- throw new CliError("configuration_error", `credentialScope ${scope} is not a URL`);
155
- const { origin, pathname } = new URL(scope);
156
- const prefix = pathname.endsWith("/") ? pathname : `${pathname}/`;
157
- return (url) => url.origin === origin && (url.pathname === pathname || url.pathname.startsWith(prefix)) && !ENCODED_SLASH.test(url.pathname);
158
- }, "scopeOf");
159
- var signedHeaders = /* @__PURE__ */ __name((headers) => CREDENTIAL_HEADERS.some((name) => headers.has(name)), "signedHeaders");
160
- var NOT_SENT = /* @__PURE__ */ new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
161
- var neverSent = /* @__PURE__ */ __name((error) => {
162
- for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
163
- const code = at.code;
164
- if (typeof code === "string" && NOT_SENT.has(code))
165
- return true;
166
- }
167
- return false;
168
- }, "neverSent");
169
- var hostFetch = /* @__PURE__ */ __name((options) => {
170
- const problems = hostProblems(options.hosts);
171
- if (problems.length > 0)
172
- throw new CliError("configuration_error", problems.join("; "));
173
- const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
174
- const inScope = scopeOf(options.credentialScope);
175
- return async (input, init = {}) => {
176
- const request = input instanceof Request ? input : void 0;
177
- let url = checked2(new URL(request?.url ?? String(input)), hosts);
178
- const caller = init.signal ?? request?.signal;
179
- const timeout = deadline(timeoutMs);
180
- const signal = caller ? AbortSignal.any([caller, timeout.signal]) : timeout.signal;
181
- const follow = (init.redirect ?? request?.redirect ?? "follow") === "follow";
182
- let method = (init.method ?? request?.method ?? "GET").toUpperCase();
183
- let body = init.body ?? request?.body ?? void 0;
184
- const headers = new Headers(init.headers ?? request?.headers);
185
- if (inScope && signedHeaders(headers) && !inScope(url))
186
- throw new CliError("configuration_error", `the sign-in goes only under ${options.credentialScope}, not ${url.origin}${url.pathname}`, {
187
- sent: false
188
- });
189
- let answered = false;
190
- try {
191
- let response = await send(input, { ...init, signal, ...follow ? { redirect: "manual" } : {} });
192
- answered = true;
193
- for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
194
- const location = response.headers.get("location");
195
- if (!location)
196
- return released(response, timeout.clear);
197
- if (hop >= redirects)
198
- throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
199
- void response.body?.cancel().catch(() => {
200
- });
201
- const next = checked2(new URL(location, url), hosts);
202
- if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
203
- method = method === "HEAD" ? "HEAD" : "GET";
204
- body = void 0;
205
- headers.delete("content-type");
206
- headers.delete("content-length");
207
- } else if (body instanceof ReadableStream)
208
- throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
209
- if (inScope ? !inScope(next) : next.origin !== url.origin)
210
- for (const name of CREDENTIAL_HEADERS)
211
- headers.delete(name);
212
- url = next;
213
- response = await send(url, { ...init, method, headers, body, signal, redirect: "manual" });
214
- }
215
- return released(response, timeout.clear);
216
- } catch (error) {
217
- timeout.clear();
218
- if (isCliError(error))
219
- throw error;
220
- if (caller?.aborted)
221
- throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
222
- if (timeout.signal.aborted)
223
- throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
224
- throw new CliError("network_error", `${url.hostname} could not be reached`, {
225
- retryable: true,
226
- ...!answered && neverSent(error) ? { sent: false } : {}
227
- });
228
- }
229
- };
230
- }, "hostFetch");
231
-
232
- // node_modules/.pnpm/@wirecat+cli-base@1.0.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
233
- var parseRetryAfter = /* @__PURE__ */ __name((header, now) => {
234
- if (!header)
235
- return void 0;
236
- const trimmed = header.trim();
237
- if (/^\d+$/.test(trimmed))
238
- return Number(trimmed) * 1e3;
239
- const at = Date.parse(trimmed);
240
- if (Number.isNaN(at))
241
- return void 0;
242
- const delta = at - now().getTime();
243
- return delta > 0 ? delta : void 0;
244
- }, "parseRetryAfter");
245
- var parseRateLimitReset = /* @__PURE__ */ __name((header, now) => {
246
- if (!header)
247
- return void 0;
248
- const seconds = Number(header.trim());
249
- if (!Number.isFinite(seconds))
250
- return void 0;
251
- const delta = seconds * 1e3 - now().getTime();
252
- return delta > 0 ? delta : void 0;
253
- }, "parseRateLimitReset");
254
- var providerWaitMs = /* @__PURE__ */ __name((headers, now) => parseRetryAfter(headers.get("retry-after"), now) ?? parseRateLimitReset(headers.get("x-ratelimit-reset"), now), "providerWaitMs");
255
- var retryableStatus = /* @__PURE__ */ __name((status) => status === 408 || status === 429 || status >= 500, "retryableStatus");
256
- var statusToCode = /* @__PURE__ */ __name((status) => {
257
- if (status === 400 || status === 422)
258
- return "validation_error";
259
- if (status === 401)
260
- return "authentication_error";
261
- if (status === 403)
262
- return "permission_error";
263
- if (status === 404)
264
- return "not_found";
265
- if (status === 408)
266
- return "timeout";
267
- if (status === 429)
268
- return "rate_limited";
269
- if (status === 502 || status === 503 || status === 504)
270
- return "provider_unavailable";
271
- return "provider_error";
272
- }, "statusToCode");
273
- var SAFE = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
274
- var retrying = /* @__PURE__ */ __name((send, options = {}) => {
275
- const { retry = DEFAULT_RETRY, reads = /* @__PURE__ */ __name((method) => SAFE.has(method), "reads"), pacer, budget = Number.POSITIVE_INFINITY, sleep = realSleep, now = wallClock, random = Math.random } = options;
276
- return async (input, init = {}) => {
277
- const request = input instanceof Request ? input : void 0;
278
- const method = (init.method ?? request?.method ?? "GET").toUpperCase();
279
- const read = reads(method, new URL(request?.url ?? String(input)));
280
- const signal = init.signal ?? request?.signal ?? void 0;
281
- const once = init.body instanceof ReadableStream;
282
- let waited = 0;
283
- const pause = /* @__PURE__ */ __name(async (ms) => {
284
- waited += ms;
285
- await sleep(ms, signal, "retry");
286
- }, "pause");
287
- for (let attempt = 1; ; attempt++) {
288
- if (pacer) {
289
- const wait = await pacer.reserve() - now().getTime();
290
- if (wait > 0) {
291
- if (waited + wait > budget)
292
- throw new CliError("rate_limited", `the provider's pace needs a ${wait} ms wait, more than this run allows`, {
293
- retry_after_ms: wait,
294
- sent: false
295
- });
296
- await pause(wait);
297
- }
298
- }
299
- const last = once || attempt > retry.retries;
300
- try {
301
- const response = await send(request && !last ? request.clone() : input, init);
302
- if (last || !retryableStatus(response.status) || !(read || response.status === 429))
303
- return response;
304
- const wait = providerWaitMs(response.headers, now) ?? backoffMs(attempt, retry, random);
305
- if (wait > retry.maxRetryAfterMs || waited + wait > budget)
306
- return response;
307
- await response.body?.cancel().catch(() => {
308
- });
309
- if (response.status === 429)
310
- await pacer?.holdFor(wait);
311
- await pause(wait);
312
- } catch (error) {
313
- if (last || !read || signal?.aborted || !isCliError(error) || error.details.retryable !== true)
314
- throw error;
315
- const wait = backoffMs(attempt, retry, random);
316
- if (waited + wait > budget)
317
- throw error;
318
- await pause(wait);
319
- }
320
- }
321
- };
322
- }, "retrying");
323
-
324
- // node_modules/.pnpm/@wirecat+cli-core@1.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_dd5172c52281f8f1e2dd1d4e9555d5c3/node_modules/@wirecat/cli-core/dist/models/endpoint.js
325
- var endpoint = /* @__PURE__ */ __name((value) => {
326
- try {
327
- const url = new URL(value);
328
- return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
329
- } catch {
330
- return false;
331
- }
332
- }, "endpoint");
333
- var loopback = /* @__PURE__ */ __name((hostname) => hostname === "localhost" || hostname === "[::1]" || /^127(\.\d{1,3}){3}$/.test(hostname), "loopback");
334
- var onThisComputer = /* @__PURE__ */ __name((value) => {
335
- try {
336
- return loopback(new URL(value).hostname);
337
- } catch {
338
- return false;
339
- }
340
- }, "onThisComputer");
341
- var modelAddressAllowed = /* @__PURE__ */ __name((value) => endpoint(value) && (new URL(value).protocol === "https:" || onThisComputer(value)), "modelAddressAllowed");
342
- var PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
343
- var literalFetch = /* @__PURE__ */ __name((hostname, timeoutMs) => async (input, init = {}) => {
344
- const url = new URL(input instanceof Request ? input.url : String(input));
345
- if (url.hostname !== hostname)
346
- throw new CliError("configuration_error", `${url.hostname} is not the model address's host, ${hostname}`, {
347
- reason: "network.host-undeclared",
348
- sent: false
349
- });
350
- const deadline2 = AbortSignal.timeout(timeoutMs);
351
- const signal = init.signal ? AbortSignal.any([init.signal, deadline2]) : deadline2;
352
- try {
353
- const response = await fetch(input, { ...init, signal, redirect: "manual" });
354
- if (response.status >= 300 && response.status < 400) {
355
- void response.body?.cancel().catch(() => {
356
- });
357
- throw new CliError("invalid_response", `${hostname} answered with a redirect, which is not followed`);
358
- }
359
- return response;
360
- } catch (error) {
361
- if (isCliError(error))
362
- throw error;
363
- if (init.signal?.aborted)
364
- throw new CliError("cancelled", "request cancelled");
365
- if (deadline2.aborted)
366
- throw new CliError("timeout", `${hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
367
- throw new CliError("network_error", `${hostname} could not be reached`, { retryable: true });
368
- }
369
- }, "literalFetch");
370
- var endpointFetch = /* @__PURE__ */ __name((address, timeoutMs) => {
371
- const { hostname } = new URL(address);
372
- if (hostname === "[::1]")
373
- return fetch;
374
- return hostname.startsWith("[") ? literalFetch(hostname, timeoutMs) : hostFetch({ hosts: [hostname], timeoutMs });
375
- }, "endpointFetch");
376
-
377
- export {
378
- readJsonResponse,
379
- hostFetch,
380
- providerWaitMs,
381
- statusToCode,
382
- retrying,
383
- endpoint,
384
- onThisComputer,
385
- modelAddressAllowed,
386
- PLAIN_HTTP_REFUSED,
387
- endpointFetch
388
- };