@wirecat/drive-cli 0.43.0 → 0.45.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 (182) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/drive.js +35 -40
  3. package/dist/bundle/all-profiles-LTHNCWQW.js +26 -0
  4. package/dist/bundle/anthropic-NOJEF3V2.js +71 -0
  5. package/dist/bundle/bun-ADJVI4HY.js +169 -0
  6. package/dist/bundle/bun-sqlite-GNXLBF2A.js +70 -0
  7. package/dist/bundle/chunk-2FTZBZOB.js +2315 -0
  8. package/dist/bundle/chunk-2YU3CXFD.js +3391 -0
  9. package/dist/bundle/chunk-35GRI4DI.js +375 -0
  10. package/dist/bundle/chunk-37MAA6F2.js +5624 -0
  11. package/dist/bundle/chunk-3V6NPZY7.js +2352 -0
  12. package/dist/bundle/chunk-4TIC23D2.js +9 -0
  13. package/dist/bundle/chunk-4TQSNQVV.js +1071 -0
  14. package/dist/bundle/chunk-4UE7AVHZ.js +150 -0
  15. package/dist/bundle/chunk-5DPV7X27.js +663 -0
  16. package/dist/bundle/chunk-5FONRUG6.js +24805 -0
  17. package/dist/bundle/chunk-5ZVLM6YR.js +19 -0
  18. package/dist/bundle/chunk-64WJYT2F.js +3954 -0
  19. package/dist/bundle/chunk-65GGKAQ7.js +82 -0
  20. package/dist/bundle/chunk-66N2DGGC.js +515 -0
  21. package/dist/bundle/chunk-6KFA6HOM.js +2941 -0
  22. package/dist/bundle/chunk-6Y2BYFXQ.js +65 -0
  23. package/dist/bundle/chunk-7NCG2SHR.js +74 -0
  24. package/dist/bundle/chunk-7PVNJAQ2.js +73 -0
  25. package/dist/bundle/chunk-7XWUOCGW.js +190 -0
  26. package/dist/bundle/chunk-A6ZKTNTZ.js +168 -0
  27. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  28. package/dist/bundle/chunk-AH3SNVCV.js +498 -0
  29. package/dist/bundle/chunk-AN3GVZTU.js +76 -0
  30. package/dist/bundle/chunk-BPBIBVFH.js +166 -0
  31. package/dist/bundle/chunk-C4XP5T73.js +264 -0
  32. package/dist/bundle/chunk-C6SMAEED.js +18102 -0
  33. package/dist/bundle/chunk-CDI67JSB.js +1092 -0
  34. package/dist/bundle/chunk-CEO5HPRL.js +25 -0
  35. package/dist/bundle/chunk-CFT7UHF6.js +15572 -0
  36. package/dist/bundle/chunk-DC4T3FNP.js +1913 -0
  37. package/dist/bundle/chunk-DCTXOMOR.js +35 -0
  38. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  39. package/dist/bundle/chunk-EVWXODYV.js +754 -0
  40. package/dist/bundle/chunk-GKHM6I64.js +2356 -0
  41. package/dist/bundle/chunk-GNI7INK6.js +18 -0
  42. package/dist/bundle/chunk-GTYY6BIE.js +58 -0
  43. package/dist/bundle/chunk-GX4WEMAG.js +164 -0
  44. package/dist/bundle/chunk-HA3WCVGY.js +8179 -0
  45. package/dist/bundle/chunk-HLONHTSG.js +281 -0
  46. package/dist/bundle/chunk-HOIUIKWS.js +236 -0
  47. package/dist/bundle/chunk-HTQTIKWP.js +928 -0
  48. package/dist/bundle/chunk-I5EJHKNC.js +111 -0
  49. package/dist/bundle/chunk-ICKNJIGE.js +31 -0
  50. package/dist/bundle/chunk-IGB5CJCA.js +62 -0
  51. package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
  52. package/dist/bundle/chunk-IVQ6342B.js +2 -0
  53. package/dist/bundle/chunk-K4N2DKE5.js +17 -0
  54. package/dist/bundle/chunk-LNB7BIZL.js +844 -0
  55. package/dist/bundle/chunk-LVDHWNJF.js +193 -0
  56. package/dist/bundle/chunk-LW2G4U6W.js +570 -0
  57. package/dist/bundle/chunk-LWT55XC5.js +60 -0
  58. package/dist/bundle/chunk-LY26NW3I.js +6848 -0
  59. package/dist/bundle/chunk-MJR2OTO4.js +1714 -0
  60. package/dist/bundle/chunk-MWUITL6N.js +42 -0
  61. package/dist/bundle/chunk-N47CYWEM.js +454 -0
  62. package/dist/bundle/chunk-NKZ6V4JW.js +263 -0
  63. package/dist/bundle/chunk-NQ6LLDDC.js +161 -0
  64. package/dist/bundle/chunk-NZIHPYY5.js +215 -0
  65. package/dist/bundle/chunk-OECPFZLP.js +3541 -0
  66. package/dist/bundle/chunk-P5KGFT7U.js +18 -0
  67. package/dist/bundle/chunk-PDH2QQQV.js +484 -0
  68. package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
  69. package/dist/bundle/chunk-PJDO7AFZ.js +421 -0
  70. package/dist/bundle/chunk-PWKXHDBQ.js +18078 -0
  71. package/dist/bundle/chunk-QLZGLPJL.js +100 -0
  72. package/dist/bundle/chunk-SBZB7HMU.js +1055 -0
  73. package/dist/bundle/chunk-SGOPYPVW.js +835 -0
  74. package/dist/bundle/chunk-TDC6JGDA.js +630 -0
  75. package/dist/bundle/chunk-TOYPN2XX.js +288 -0
  76. package/dist/bundle/chunk-UC44ZMQV.js +78 -0
  77. package/dist/bundle/chunk-V7GN5BI7.js +99 -0
  78. package/dist/bundle/chunk-VO4KOLQZ.js +119 -0
  79. package/dist/bundle/chunk-WPGCDWPU.js +1855 -0
  80. package/dist/bundle/chunk-WQMVSQPP.js +886 -0
  81. package/dist/bundle/chunk-WZUJKUBK.js +384 -0
  82. package/dist/bundle/chunk-X5DFDGWS.js +2 -0
  83. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  84. package/dist/bundle/chunk-XPEWOPJR.js +431 -0
  85. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  86. package/dist/bundle/chunk-Y5EJSZXV.js +220 -0
  87. package/dist/bundle/chunk-YE3J6DLY.js +106 -0
  88. package/dist/bundle/chunk-YFLKH3NZ.js +48 -0
  89. package/dist/bundle/chunk-YJX4X564.js +138 -0
  90. package/dist/bundle/chunk-YJZBJ2TM.js +71 -0
  91. package/dist/bundle/chunk-Z4O6C7WR.js +1973 -0
  92. package/dist/bundle/chunk-ZIHLE7LG.js +15992 -0
  93. package/dist/bundle/chunk-ZPMLLONT.js +1054 -0
  94. package/dist/bundle/chunk-ZQNXKWUY.js +35584 -0
  95. package/dist/bundle/chunk-ZS635F4O.js +45 -0
  96. package/dist/bundle/chunk-ZU732VCC.js +122 -0
  97. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  98. package/dist/bundle/command-contract-HX35D7KV.js +38 -0
  99. package/dist/bundle/dist-MWTMOYWT.js +7577 -0
  100. package/dist/bundle/dist-PY3MVR3G.js +21 -0
  101. package/dist/bundle/drive.js +50 -0
  102. package/dist/bundle/echarts-RFTK737T.js +42501 -0
  103. package/dist/bundle/embed-5NAGJUMD.js +37 -0
  104. package/dist/bundle/embedder-EWXLIGBY.js +110 -0
  105. package/dist/bundle/entry-YCPJ6H6U.js +15 -0
  106. package/dist/bundle/failure-XBWHHBEW.js +37 -0
  107. package/dist/bundle/first-run-LNAZDBB4.js +24 -0
  108. package/dist/bundle/first-screen-P5NNFJD7.js +36 -0
  109. package/dist/bundle/google-5FFKRHHC.js +32 -0
  110. package/dist/bundle/google-api-TJCFOOAP.js +82 -0
  111. package/dist/bundle/identity-53ZMPL2O.js +10 -0
  112. package/dist/bundle/instructions-FHNL7CMW.js +9 -0
  113. package/dist/bundle/login-VXXZZR6G.js +158 -0
  114. package/dist/bundle/mcp-2CJCJXSW.js +95 -0
  115. package/dist/bundle/mcp-F4XZO76F.js +507 -0
  116. package/dist/bundle/mcp-IXFC2VVR.js +165 -0
  117. package/dist/bundle/mdast-util-from-markdown-FXEPSNER.js +1958 -0
  118. package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +2103 -0
  119. package/dist/bundle/micromark-extension-gfm-GRL24TU6.js +1838 -0
  120. package/dist/bundle/node-P4E63KXA.js +2340 -0
  121. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  122. package/dist/bundle/node-ZMCACJVS.js +176 -0
  123. package/dist/bundle/node-sqlite-QJQ5S7KS.js +46 -0
  124. package/dist/bundle/oauth-TZFDPAFE.js +18 -0
  125. package/dist/bundle/open-IYM25QTL.js +20 -0
  126. package/dist/bundle/process-ZPTLNVQS.js +91 -0
  127. package/dist/bundle/program-YX7DZMPR.js +24100 -0
  128. package/dist/bundle/prompt-TGWTVIEK.js +13 -0
  129. package/dist/bundle/reasons-Q5LOQESQ.js +11 -0
  130. package/dist/bundle/recognize-AGPMWKIY.js +191 -0
  131. package/dist/bundle/remote-QV7QSLAK.js +28 -0
  132. package/dist/bundle/rerank-HZKJJCS4.js +51 -0
  133. package/dist/bundle/serve-NRJQOVT4.js +20 -0
  134. package/dist/bundle/server-2UQDEWTS.js +818 -0
  135. package/dist/bundle/server-R4JUHFSW.js +56 -0
  136. package/dist/bundle/services-NZQWVMOE.js +333 -0
  137. package/dist/bundle/sqlite-runtime-6MXHTYYU.js +17 -0
  138. package/dist/bundle/state-IF2FLTSY.js +34 -0
  139. package/dist/bundle/store-HBD54IRL.js +142 -0
  140. package/dist/bundle/store-HVIBXOXS.js +125 -0
  141. package/dist/bundle/store-maintenance-command-U3F4RGJB.js +57 -0
  142. package/dist/bundle/terminal-TFCTWLOS.js +11 -0
  143. package/dist/bundle/tokens-5D5YUA2Q.js +103 -0
  144. package/dist/commands/config.js +1 -1
  145. package/dist/commands/config.js.map +1 -1
  146. package/dist/commands/mcp.d.ts.map +1 -1
  147. package/dist/commands/mcp.js +106 -54
  148. package/dist/commands/mcp.js.map +1 -1
  149. package/dist/config.d.ts +3 -1
  150. package/dist/config.d.ts.map +1 -1
  151. package/dist/config.js +3 -1
  152. package/dist/config.js.map +1 -1
  153. package/dist/contract-overrides.d.ts.map +1 -1
  154. package/dist/contract-overrides.js +123 -83
  155. package/dist/contract-overrides.js.map +1 -1
  156. package/dist/mcp.d.ts +14 -6
  157. package/dist/mcp.d.ts.map +1 -1
  158. package/dist/mcp.js +26 -12
  159. package/dist/mcp.js.map +1 -1
  160. package/dist/program.d.ts.map +1 -1
  161. package/dist/program.js +7 -5
  162. package/dist/program.js.map +1 -1
  163. package/dist/reasons.d.ts.map +1 -1
  164. package/dist/reasons.js +0 -1
  165. package/dist/reasons.js.map +1 -1
  166. package/dist/registry.d.ts +2 -2
  167. package/dist/registry.d.ts.map +1 -1
  168. package/dist/registry.js +8 -2
  169. package/dist/registry.js.map +1 -1
  170. package/dist/state.d.ts +6 -3
  171. package/dist/state.d.ts.map +1 -1
  172. package/dist/state.js +6 -3
  173. package/dist/state.js.map +1 -1
  174. package/dist/tokens.d.ts +4 -1
  175. package/dist/tokens.d.ts.map +1 -1
  176. package/dist/tokens.js +44 -8
  177. package/dist/tokens.js.map +1 -1
  178. package/dist/version.d.ts +1 -1
  179. package/dist/version.js +1 -1
  180. package/package.json +7 -5
  181. package/scenarios/agent-access.md +2 -2
  182. package/skills/drive-cli/SKILL.md +2 -1
@@ -0,0 +1,431 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ isCliFailure
5
+ } from "./chunk-K4N2DKE5.js";
6
+ import {
7
+ isContentKey
8
+ } from "./chunk-GKHM6I64.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/run-context.js
14
+ import { AsyncLocalStorage } from "node:async_hooks";
15
+ import { createHash } from "node:crypto";
16
+
17
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
18
+ import { homedir } from "node:os";
19
+
20
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/events.js
21
+ var providerErrorKey = /* @__PURE__ */ __name((value) => typeof value === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(value) ? value : void 0, "providerErrorKey");
22
+ var renderEvent = /* @__PURE__ */ __name((event) => {
23
+ if (event.event === "warning") {
24
+ const counts = Object.entries(event.counts ?? {}).map(([field, count]) => `${count} ${field}`);
25
+ return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail].filter(Boolean).join(" ");
26
+ }
27
+ const parts = [];
28
+ if (event.event === "cache") {
29
+ parts.push(event.reason);
30
+ if (event.ageMs !== void 0)
31
+ parts.push(`cached ${age(event.ageMs)}`);
32
+ } else {
33
+ if (event.opcode !== void 0)
34
+ parts.push(`op ${event.opcode}`, `seq ${event.seq}`);
35
+ if (event.method !== void 0 || event.endpointTemplate !== void 0)
36
+ parts.push([event.method, event.endpointTemplate].filter(Boolean).join(" "));
37
+ if (event.status !== void 0)
38
+ parts.push(`${event.status}`);
39
+ if (event.attempt !== void 0 && event.attempt > 1)
40
+ parts.push(`attempt ${event.attempt}`);
41
+ if (event.waitMs !== void 0)
42
+ parts.push(`waited ${age(event.waitMs)}`);
43
+ }
44
+ if (event.ids)
45
+ for (const [name, value] of Object.entries(event.ids))
46
+ parts.push(`${name} ${value}`);
47
+ if (event.event !== "cache") {
48
+ if (event.durationMs !== void 0)
49
+ parts.push(`${event.durationMs}ms`);
50
+ if (event.bytes !== void 0)
51
+ parts.push(size(event.bytes));
52
+ }
53
+ if (event.counts)
54
+ for (const [field, count] of Object.entries(event.counts))
55
+ parts.push(`${count} ${field}`);
56
+ if (event.event !== "cache") {
57
+ if (event.errorCode)
58
+ parts.push(event.errorCode);
59
+ if (event.providerError)
60
+ parts.push(event.providerError);
61
+ }
62
+ return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
63
+ }, "renderEvent");
64
+ var MARK = { request: "\u2192", response: "\u2190", cache: "\u2022", warning: "!" };
65
+ var age = /* @__PURE__ */ __name((ms) => ms < 1e3 ? `${ms}ms` : `${Math.round(ms / 1e3)}s`, "age");
66
+ var size = /* @__PURE__ */ __name((bytes) => bytes < 1e3 ? `${bytes} B` : `${(bytes / 1e3).toFixed(1)} kB`, "size");
67
+
68
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/secrets.js
69
+ var SECRET_WORDS = /* @__PURE__ */ new Set([
70
+ "authorization",
71
+ "cookie",
72
+ "credential",
73
+ "credentials",
74
+ "passphrase",
75
+ "password",
76
+ "passwd",
77
+ "pwd",
78
+ "pass",
79
+ "passcode",
80
+ "pin",
81
+ "otp",
82
+ "2fa",
83
+ "secret",
84
+ "token",
85
+ "contrase\xF1a",
86
+ "contrasena",
87
+ "clave",
88
+ "\u043F\u0430\u0440\u043E\u043B\u044C",
89
+ "\u043F\u0438\u043D",
90
+ "\u043A\u043E\u0434",
91
+ ...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
92
+ ...["db", "database", "key"].map((word) => `${word}pass`)
93
+ ]);
94
+ var secretNamed = /* @__PURE__ */ __name((name) => {
95
+ const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
96
+ return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
97
+ }, "secretNamed");
98
+ var START = "(?<![A-Za-z0-9_-])";
99
+ var END = "(?![A-Za-z0-9_-])";
100
+ var KNOWN_TOKENS = new RegExp(`${[
101
+ "gh[pousr]_[A-Za-z0-9]{36,}",
102
+ "github_pat_[A-Za-z0-9_]{22,}",
103
+ "sk-[A-Za-z0-9_-]{20,}",
104
+ "xox[abprs]-[A-Za-z0-9-]{10,}",
105
+ "(?:AKIA|ASIA)[A-Z0-9]{16}",
106
+ "AIza[A-Za-z0-9_-]{35}",
107
+ "(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
108
+ "npm_[A-Za-z0-9]{36}",
109
+ "eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
110
+ ].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
111
+ var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
112
+ var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
113
+ var NAMED_PAIR = /(?<![\p{L}\p{N}])([\p{L}\p{N}_.-]*(?:token|pass|pwd|pin|otp|2fa|secret|credential|cookie|authorization|key|contrase|clave|пароль|пин|код)[\p{L}\p{N}_.-]*)(["']?\s*(?:=>|[:=])\s*["']?|\s+(?![\p{L}]+(?![\p{L}\p{N}])))((?:Bearer\s+|Basic\s+)?)([^\s"'&,;]+)/giu;
114
+ var looksRandom = /* @__PURE__ */ __name((run) => {
115
+ if (run.length < 20)
116
+ return false;
117
+ const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
118
+ if (classes < 3)
119
+ return false;
120
+ let switches = 0;
121
+ for (let at = 1; at < run.length; at++) {
122
+ const [before, after] = [run[at - 1], run[at]];
123
+ if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
124
+ switches += 1;
125
+ }
126
+ if (switches / run.length < 0.15)
127
+ return false;
128
+ const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
129
+ if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
130
+ return false;
131
+ return entropy(run) >= 3.5;
132
+ }, "looksRandom");
133
+ var entropy = /* @__PURE__ */ __name((text) => {
134
+ const counts = /* @__PURE__ */ new Map();
135
+ for (const char of text)
136
+ counts.set(char, (counts.get(char) ?? 0) + 1);
137
+ let bits = 0;
138
+ for (const count of counts.values())
139
+ bits -= count / text.length * Math.log2(count / text.length);
140
+ return bits;
141
+ }, "entropy");
142
+ var withoutSecrets = /* @__PURE__ */ __name((text, mark = "[redacted]") => text.replace(PRIVATE_KEY, mark).replace(KNOWN_TOKENS, mark).replace(SCHEME, `$1$2${mark}`).replace(NAMED_PAIR, (whole, name, separator, scheme) => secretNamed(name) ? `${name}${separator}${scheme}${mark}` : whole).replace(/[!-~]{20,}/g, (token) => (
143
+ // A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
144
+ token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
145
+ )), "withoutSecrets");
146
+ var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
147
+ var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
148
+
149
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/error-detail.js
150
+ var MESSAGE_AT_MOST = 500;
151
+ var CAUSES_AT_MOST = 5;
152
+ var FRAMES_AT_MOST = 15;
153
+ var errorDetailOf = /* @__PURE__ */ __name((error, response) => {
154
+ const details = isCliFailure(error) ? { ...error.details } : {};
155
+ const thrown = error instanceof Error ? error : void 0;
156
+ const code = isCliFailure(error) ? error.code : codeOf(error);
157
+ const reason = typeof details.reason === "string" ? details.reason : void 0;
158
+ const message = thrown ? redactText(thrown.message) : void 0;
159
+ const operation = stringOf(details.operation) ?? response?.operation;
160
+ const status = numberOf(details.status) ?? response?.status;
161
+ const method = stringOf(details.method) ?? response?.method;
162
+ const endpoint = stringOf(details.endpoint) ?? response?.endpointTemplate;
163
+ const key = providerErrorKey(details.provider_error) ?? providerErrorKey(response?.providerError);
164
+ const protocol = key !== void 0 && method === void 0 && endpoint === void 0;
165
+ const http = method !== void 0 || endpoint !== void 0 || status !== void 0 && !protocol ? {
166
+ ...method === void 0 ? {} : { method: method.toUpperCase().slice(0, 16) },
167
+ ...endpoint === void 0 ? {} : { endpoint_template: endpointTemplate(endpoint) },
168
+ ...status === void 0 ? {} : { status }
169
+ } : void 0;
170
+ const causes = causesOf(thrown?.cause ?? details.cause);
171
+ const stack = framesOf(thrown);
172
+ return {
173
+ class: classOf(error),
174
+ ...code === void 0 ? {} : { code },
175
+ ...reason === void 0 ? {} : { reason },
176
+ ...message ? { message } : {},
177
+ ...operation === void 0 ? {} : { operation },
178
+ ...http ? { http } : {},
179
+ ...key === void 0 ? {} : { provider: { key, ...protocol && status !== void 0 ? { code: status } : {} } },
180
+ ...causes.length > 0 ? { causes } : {},
181
+ ...stack.length > 0 ? { stack } : {}
182
+ };
183
+ }, "errorDetailOf");
184
+ var stringOf = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0, "stringOf");
185
+ var numberOf = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isInteger(value) ? value : void 0, "numberOf");
186
+ var classOf = /* @__PURE__ */ __name((error) => {
187
+ if (!(error instanceof Error))
188
+ return error === null ? "null" : typeof error;
189
+ const constructed = error.constructor?.name;
190
+ return constructed && constructed !== "Error" && constructed !== error.name ? constructed : error.name;
191
+ }, "classOf");
192
+ var codeOf = /* @__PURE__ */ __name((error) => {
193
+ const code = error?.code;
194
+ return typeof code === "string" && /^[A-Za-z][A-Za-z0-9._-]{0,63}$/.test(code) ? code : void 0;
195
+ }, "codeOf");
196
+ var causesOf = /* @__PURE__ */ __name((first) => {
197
+ const causes = [];
198
+ const seen = /* @__PURE__ */ new Set();
199
+ for (let cause = first; cause !== void 0 && cause !== null && causes.length < CAUSES_AT_MOST; ) {
200
+ if (seen.has(cause))
201
+ break;
202
+ seen.add(cause);
203
+ const message = cause instanceof Error ? redactText(cause.message) : void 0;
204
+ causes.push({ class: classOf(cause), ...message ? { message } : {} });
205
+ cause = cause instanceof Error ? cause.cause : void 0;
206
+ }
207
+ return causes;
208
+ }, "causesOf");
209
+ var framesOf = /* @__PURE__ */ __name((error, limit = FRAMES_AT_MOST) => {
210
+ const stack = error instanceof Error && typeof error.stack === "string" ? error.stack : "";
211
+ return stack.split("\n").filter((line) => line.trimStart().startsWith("at ")).flatMap((line) => {
212
+ const match = /^\s*at (?:async )?(?:(.+?) \()?(.+?):(\d+):\d+\)?$/.exec(line);
213
+ if (!match)
214
+ return [];
215
+ const [, fn, path = "", lineNumber] = match;
216
+ if (path.startsWith("node:"))
217
+ return [];
218
+ return [`${fn ?? "<anonymous>"} ${fileOf(path)}:${lineNumber}`];
219
+ }).slice(0, limit);
220
+ }, "framesOf");
221
+ var fileOf = /* @__PURE__ */ __name((path) => {
222
+ const plain = path.replace(/^file:\/\//, "");
223
+ const packaged = /\/node_modules\/((?:@[^/]+\/)?[^/]+\/.+)$/.exec(plain)?.[1];
224
+ if (packaged)
225
+ return packaged.replace(/\/(?:dist|src)\//, "/");
226
+ return /(?:^|\/)(?:dist|src)\/(.+)$/.exec(plain)?.[1] ?? plain.split("/").at(-1) ?? "?";
227
+ }, "fileOf");
228
+ var endpointTemplate = /* @__PURE__ */ __name((raw) => {
229
+ const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
230
+ const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
231
+ const path = origin ? trimmed.slice(origin[0].length) : trimmed;
232
+ const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
233
+ const segments = path.split("/").map((segment) => {
234
+ if (segment === "" || /^[:{].+/.test(segment))
235
+ return segment;
236
+ if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
237
+ return ":token";
238
+ if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
239
+ return ":id";
240
+ if (!/^[A-Za-z0-9._~-]{1,40}$/.test(segment))
241
+ return ":value";
242
+ return segment;
243
+ });
244
+ return `${scheme}${segments.join("/")}`.slice(0, 300);
245
+ }, "endpointTemplate");
246
+ var INTERNATIONAL_PHONE = /\+\d[\d\s()-]{6,}\d/.source;
247
+ var BARE_PHONE = /(^|[^\w-])\d{11,15}\b/.source;
248
+ var redactText = /* @__PURE__ */ __name((text) => {
249
+ const home = homedir();
250
+ let out = home && home !== "/" ? text.split(home).join("~") : text;
251
+ out = withoutSecrets(out.replace(/"[^"\n]*"|“[^”\n]*”|«[^»\n]*»/g, '"[redacted]"')).replace(/\b(bearer|basic|token|key|password|secret)(\s*[:=]\s*|\s+)[^\s'"]+/gi, "$1$2[redacted]").replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[email]").replace(new RegExp(INTERNATIONAL_PHONE, "g"), "[number]").replace(new RegExp(BARE_PHONE, "g"), "$1[number]").replace(/\bbot\d+:[\w-]+/g, "bot[token]").replace(/\b\d{6,}:[\w-]{20,}\b/g, "[token]").replace(/(\?|&)[^\s#]*/g, "$1[redacted]").replace(/\b[A-Za-z0-9_-]{40,}\b/g, "[redacted]");
252
+ return out.length > MESSAGE_AT_MOST ? `${out.slice(0, MESSAGE_AT_MOST)}\u2026` : out;
253
+ }, "redactText");
254
+
255
+ // node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/runs/run-context.js
256
+ var REDACTED = "[redacted]";
257
+ var keepsSuccess = /* @__PURE__ */ __name(({ record, fromFlag, env, caller, persistent = false }) => {
258
+ if (!record)
259
+ return false;
260
+ if (fromFlag)
261
+ return true;
262
+ if (persistent)
263
+ return false;
264
+ return caller !== void 0 || viaOf(env) !== "desktop";
265
+ }, "keepsSuccess");
266
+ var calls = new AsyncLocalStorage();
267
+ var withCaller = /* @__PURE__ */ __name((caller, work) => calls.run(caller, work), "withCaller");
268
+ var currentCaller = /* @__PURE__ */ __name(() => calls.getStore(), "currentCaller");
269
+ var clientHash = /* @__PURE__ */ __name((id) => createHash("sha256").update(id).digest("hex").slice(0, 8), "clientHash");
270
+ var viaOf = /* @__PURE__ */ __name((env) => env.WIRECAT_CALLER?.trim() === "desktop" ? "desktop" : "cli", "viaOf");
271
+ var agentOf = /* @__PURE__ */ __name((env) => {
272
+ const named = env.AI_AGENT?.trim().split("_")[0];
273
+ const kind = (named && plainWord(named) ? named.toLowerCase() : void 0) ?? (env.CLAUDECODE ? "claude-code" : void 0) ?? (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_SANDBOX ? "codex" : void 0) ?? (env.GEMINI_CLI ? "gemini-cli" : void 0) ?? (env.OPENCODE ? "opencode" : void 0) ?? (env.CURSOR_AGENT ? "cursor" : void 0) ?? // Only `exec` is the agent's own command: OpenClaw also sets `tui-local` for what the owner types in its TUI.
274
+ (env.OPENCLAW_SHELL?.trim() === "exec" ? "openclaw" : void 0);
275
+ if (!kind)
276
+ return void 0;
277
+ const session = sessionOf(kind, env);
278
+ return {
279
+ kind,
280
+ session_id: session && SESSION.test(session) ? session : null,
281
+ // OpenClaw passes the sender and chat ids of a chat-started run in this variable; only its presence is kept.
282
+ ...kind === "openclaw" && env.OPENCLAW_CHANNEL_CONTEXT?.trim() ? { from_chat: true } : {}
283
+ };
284
+ }, "agentOf");
285
+ var SESSION = /^[A-Za-z0-9._:-]{1,128}$/;
286
+ var SESSION_VARIABLE = {
287
+ "claude-code": "CLAUDE_CODE_SESSION_ID",
288
+ codex: "CODEX_THREAD_ID",
289
+ opencode: "OPENCODE_SESSION_ID",
290
+ "hermes-agent": "HERMES_SESSION_ID"
291
+ };
292
+ var sessionOf = /* @__PURE__ */ __name((kind, env) => {
293
+ const variable = SESSION_VARIABLE[kind];
294
+ return (variable === void 0 ? void 0 : env[variable]?.trim()) || void 0;
295
+ }, "sessionOf");
296
+ var plainWord = /* @__PURE__ */ __name((word) => /^[A-Za-z][A-Za-z0-9.-]{0,39}$/.test(word), "plainWord");
297
+ var secretInputs = /* @__PURE__ */ new WeakSet();
298
+ var secretInput = /* @__PURE__ */ __name((input) => {
299
+ secretInputs.add(input);
300
+ return input;
301
+ }, "secretInput");
302
+ var secretShaped = /* @__PURE__ */ __name((word) => /:\/\/[^/@\s:]+:[^/@\s]+@/.test(word) || /(^|[^A-Za-z0-9_-])[A-Za-z0-9_-]{40,}($|[^A-Za-z0-9_-])/.test(word), "secretShaped");
303
+ var withoutPhones = /* @__PURE__ */ __name((word) => word.replace(new RegExp(INTERNATIONAL_PHONE, "g"), REDACTED).replace(new RegExp(BARE_PHONE, "g"), `$1${REDACTED}`), "withoutPhones");
304
+ var maskArgv = /* @__PURE__ */ __name((program, words, { keep = false } = {}) => {
305
+ const argv = [];
306
+ let unknownCommand;
307
+ let current = program;
308
+ let positional = 0;
309
+ let profileSeen = false;
310
+ let lost = false;
311
+ const raw = /* @__PURE__ */ __name((word) => keep && !secretShaped(word) ? withoutPhones(withoutSecrets(word, REDACTED)) : REDACTED, "raw");
312
+ const keptValue = /* @__PURE__ */ __name((name, value, input) => keep ? input && secretInputs.has(input) || secretNamed(name) ? REDACTED : raw(value) : maskedValue(name, value, input?.argChoices), "keptValue");
313
+ const optionFor = /* @__PURE__ */ __name((flag) => {
314
+ for (let at = current; at; at = at.parent) {
315
+ const found = at.options.find((option) => option.long === flag || option.short === flag);
316
+ if (found)
317
+ return found;
318
+ }
319
+ return void 0;
320
+ }, "optionFor");
321
+ for (let at = 0; at < words.length; at++) {
322
+ const word = words[at];
323
+ if (word === "--") {
324
+ argv.push("--");
325
+ for (let after = at + 1; after < words.length; after++)
326
+ argv.push(raw(words[after]));
327
+ break;
328
+ }
329
+ if (word.startsWith("-") && word.length > 1 && !NUMBER.test(word)) {
330
+ const equals = word.indexOf("=");
331
+ const flag = equals > 0 ? word.slice(0, equals) : word;
332
+ if (!/^--?[A-Za-z0-9][A-Za-z0-9-]*$/.test(flag)) {
333
+ argv.push(raw(word));
334
+ continue;
335
+ }
336
+ const option = optionFor(flag);
337
+ const name = option?.attributeName() ?? flag.replace(/^-+/, "");
338
+ if (equals > 0) {
339
+ argv.push(`${flag}=${keptValue(name, word.slice(equals + 1), option)}`);
340
+ continue;
341
+ }
342
+ argv.push(flag);
343
+ if (!option && keep && secretNamed(name) && words[at + 1] !== void 0 && !words[at + 1]?.startsWith("-")) {
344
+ at += 1;
345
+ argv.push(REDACTED);
346
+ continue;
347
+ }
348
+ if (!option || !(option.required || option.optional))
349
+ continue;
350
+ const takes = /* @__PURE__ */ __name((next) => next !== void 0 && (option.required || !next.startsWith("-") || NUMBER.test(next)), "takes");
351
+ if (takes(words[at + 1])) {
352
+ at += 1;
353
+ argv.push(keptValue(name, words[at], option));
354
+ while (option.variadic && words[at + 1] !== void 0 && !words[at + 1].startsWith("-")) {
355
+ at += 1;
356
+ argv.push(keptValue(name, words[at], option));
357
+ }
358
+ }
359
+ continue;
360
+ }
361
+ if (!lost && positional === 0) {
362
+ const sub = current.commands.find((one) => one.name() === word || one.aliases().includes(word));
363
+ if (sub) {
364
+ argv.push(word);
365
+ current = sub;
366
+ continue;
367
+ }
368
+ if (current === program && !profileSeen) {
369
+ profileSeen = true;
370
+ argv.push(keep ? raw(word) : PROFILE.test(word) && withoutPhones(withoutSecrets(word)) === word ? word : REDACTED);
371
+ continue;
372
+ }
373
+ if (current.commands.length > 0 && current.registeredArguments.length === 0) {
374
+ lost = true;
375
+ unknownCommand = commandLike(word);
376
+ argv.push(keep ? raw(word) : unknownCommand);
377
+ continue;
378
+ }
379
+ }
380
+ const declared = lost ? void 0 : current.registeredArguments;
381
+ const argument = declared?.[Math.min(positional, declared.length - 1)];
382
+ positional += 1;
383
+ argv.push(secretInputs.has(current) ? REDACTED : argument ? keptValue(argument.name(), word, argument) : raw(word));
384
+ }
385
+ return { argv, ...unknownCommand === void 0 ? {} : { unknownCommand } };
386
+ }, "maskArgv");
387
+ var NUMBER = /^-?\d+(\.\d+)?$/;
388
+ var PROFILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
389
+ var commandLike = /* @__PURE__ */ __name((word) => /^[a-z][a-z0-9-]{0,31}$/i.test(word) && withoutSecrets(word) === word ? word : REDACTED, "commandLike");
390
+ var maskedValue = /* @__PURE__ */ __name((name, value, choices) => {
391
+ if (isContentKey(name))
392
+ return REDACTED;
393
+ if (name === "profile")
394
+ return PROFILE.test(value) ? value : REDACTED;
395
+ if (name === "json" || name === "fields")
396
+ return /^[a-z0-9_.,]{1,200}$/.test(value) ? value : REDACTED;
397
+ if (choices?.includes(value))
398
+ return value;
399
+ return safeShape(value) ? value : REDACTED;
400
+ }, "maskedValue");
401
+ var safeShape = /* @__PURE__ */ __name((value) => NUMBER.test(value) && !/^\d{11,}$/.test(value) || /^\d+(ms|s|m|h|d|w)$/.test(value) || /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/.test(value) || value === "true" || value === "false", "safeShape");
402
+ var runContextOf = /* @__PURE__ */ __name(({ bin, command, program, argv, env, recordInput = false, caller }) => {
403
+ const masked = program && argv ? maskArgv(program, argv, { keep: recordInput === true }) : void 0;
404
+ const ifFailed = program && argv && recordInput === "failed" ? maskArgv(program, argv, { keep: true }) : void 0;
405
+ const agent = caller ? caller.agent : agentOf(env);
406
+ return {
407
+ cliCommand: command ? `${bin} ${command}` : bin,
408
+ ...masked ? { argv: masked.argv } : {},
409
+ ...ifFailed ? { argvIfFailed: ifFailed.argv } : {},
410
+ ...masked?.unknownCommand === void 0 ? {} : { unknownCommand: masked.unknownCommand },
411
+ ...agent ? { agent } : {},
412
+ via: caller?.via ?? viaOf(env),
413
+ ...caller?.mcp ? { mcp: caller.mcp } : {}
414
+ };
415
+ }, "runContextOf");
416
+
417
+ export {
418
+ providerErrorKey,
419
+ renderEvent,
420
+ errorDetailOf,
421
+ framesOf,
422
+ endpointTemplate,
423
+ keepsSuccess,
424
+ withCaller,
425
+ currentCaller,
426
+ clientHash,
427
+ agentOf,
428
+ secretInput,
429
+ maskArgv,
430
+ runContextOf
431
+ };
@@ -0,0 +1,35 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // cli-dev-bundle:from:cli-dev-bundle:from
8
+ import * as module from "node:module";
9
+ import { dirname } from "node:path";
10
+ import { fileURLToPath, pathToFileURL } from "node:url";
11
+ var resolveFrom = /* @__PURE__ */ __name((parent, specifier) => {
12
+ if (globalThis.Bun) {
13
+ if (specifier.includes(":")) return import.meta.resolve(specifier);
14
+ try {
15
+ return pathToFileURL(globalThis.Bun.resolveSync(specifier, dirname(fileURLToPath(parent)))).href;
16
+ } catch {
17
+ return import.meta.resolve(specifier);
18
+ }
19
+ }
20
+ if (!module.registerHooks) return import.meta.resolve(specifier);
21
+ const hooks = module.registerHooks({
22
+ resolve: /* @__PURE__ */ __name((asked, context, next) => next(asked, asked === specifier ? { ...context, parentURL: parent } : context), "resolve")
23
+ });
24
+ try {
25
+ return import.meta.resolve(specifier);
26
+ } finally {
27
+ hooks.deregister();
28
+ }
29
+ }, "resolveFrom");
30
+ var importFrom = /* @__PURE__ */ __name(async (parent, specifier) => import(resolveFrom(parent, specifier)), "importFrom");
31
+
32
+ export {
33
+ resolveFrom,
34
+ importFrom
35
+ };