@wirecat/attio-cli 0.0.0-stage → 0.2.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 (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +204 -0
  3. package/README.md +249 -2
  4. package/contracts/wirecat.json +2339 -0
  5. package/dist/bin/attio.d.ts +3 -0
  6. package/dist/bin/attio.d.ts.map +1 -0
  7. package/dist/bin/attio.js +40 -0
  8. package/dist/bin/attio.js.map +1 -0
  9. package/dist/bundle/agent-DYTWDBTT.js +37 -0
  10. package/dist/bundle/all-profiles-LZDKPHN2.js +320 -0
  11. package/dist/bundle/anthropic-BF72H77D.js +91 -0
  12. package/dist/bundle/app-server-H57FZJX5.js +249 -0
  13. package/dist/bundle/attio.js +183 -0
  14. package/dist/bundle/bun-WO77T4LG.js +169 -0
  15. package/dist/bundle/bun-sqlite-2BP7JDVO.js +76 -0
  16. package/dist/bundle/chunk-2E6JGBM5.js +1392 -0
  17. package/dist/bundle/chunk-34FJ26K2.js +54 -0
  18. package/dist/bundle/chunk-3I2FGNWO.js +23 -0
  19. package/dist/bundle/chunk-3NVOKVRY.js +42148 -0
  20. package/dist/bundle/chunk-3YFDZSM3.js +37 -0
  21. package/dist/bundle/chunk-4SMGM2Q6.js +274 -0
  22. package/dist/bundle/chunk-4STBJZR4.js +3571 -0
  23. package/dist/bundle/chunk-5K3FGXZH.js +46 -0
  24. package/dist/bundle/chunk-6ALPRBNV.js +100 -0
  25. package/dist/bundle/chunk-6NDJDDSQ.js +2000 -0
  26. package/dist/bundle/chunk-6SK3YB2B.js +218 -0
  27. package/dist/bundle/chunk-76RRELCU.js +65310 -0
  28. package/dist/bundle/chunk-7MXCUMHG.js +18 -0
  29. package/dist/bundle/chunk-7ZUOI3HY.js +73 -0
  30. package/dist/bundle/chunk-AMUONYQR.js +106 -0
  31. package/dist/bundle/chunk-ASCUOOLO.js +53 -0
  32. package/dist/bundle/chunk-BUGROVF3.js +72 -0
  33. package/dist/bundle/chunk-CHZ26CW5.js +9578 -0
  34. package/dist/bundle/chunk-CMO5ND3Y.js +794 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-DF2IIO32.js +12645 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-DQ6P3R4B.js +170 -0
  39. package/dist/bundle/chunk-DSRXCLPO.js +7 -0
  40. package/dist/bundle/chunk-EEPE3SOW.js +338 -0
  41. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  42. package/dist/bundle/chunk-EQGXEKSV.js +1197 -0
  43. package/dist/bundle/chunk-EQXT7KO4.js +388 -0
  44. package/dist/bundle/chunk-ERW2WOJT.js +24 -0
  45. package/dist/bundle/chunk-ESH2QGCA.js +372 -0
  46. package/dist/bundle/chunk-G3JTLVVL.js +771 -0
  47. package/dist/bundle/chunk-G6FQMVKW.js +52 -0
  48. package/dist/bundle/chunk-GBZ6JUXU.js +108 -0
  49. package/dist/bundle/chunk-GLHFJPYS.js +156 -0
  50. package/dist/bundle/chunk-GW4G5KLS.js +2333 -0
  51. package/dist/bundle/chunk-H7QDPW3D.js +78 -0
  52. package/dist/bundle/chunk-HG7FT3H3.js +319 -0
  53. package/dist/bundle/chunk-I3WS6V5H.js +188 -0
  54. package/dist/bundle/chunk-IDU4ESRZ.js +95 -0
  55. package/dist/bundle/chunk-IXCIQ7FZ.js +161 -0
  56. package/dist/bundle/chunk-J5P5VSRG.js +1233 -0
  57. package/dist/bundle/chunk-JA26HG7T.js +353 -0
  58. package/dist/bundle/chunk-JSTBW7F4.js +259 -0
  59. package/dist/bundle/chunk-KHDXRFJZ.js +185 -0
  60. package/dist/bundle/chunk-L5WS6CYZ.js +288 -0
  61. package/dist/bundle/chunk-LWJ4ZGUM.js +407 -0
  62. package/dist/bundle/chunk-MC2RQ2OB.js +38 -0
  63. package/dist/bundle/chunk-MNQACPXG.js +1332 -0
  64. package/dist/bundle/chunk-MOSH2KPD.js +358 -0
  65. package/dist/bundle/chunk-MRREDVPY.js +733 -0
  66. package/dist/bundle/chunk-MT2ZUZRA.js +1028 -0
  67. package/dist/bundle/chunk-O4A33Y54.js +29 -0
  68. package/dist/bundle/chunk-OBXDRUO4.js +63 -0
  69. package/dist/bundle/chunk-OFR3YYT6.js +6848 -0
  70. package/dist/bundle/chunk-P4U6AGWD.js +41 -0
  71. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  72. package/dist/bundle/chunk-PMP37KLR.js +142 -0
  73. package/dist/bundle/chunk-Q3JCUUOR.js +80 -0
  74. package/dist/bundle/chunk-Q7BSTQ3T.js +633 -0
  75. package/dist/bundle/chunk-QLHDUYGE.js +16 -0
  76. package/dist/bundle/chunk-RU5J7DWY.js +988 -0
  77. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  78. package/dist/bundle/chunk-S7K2XFQB.js +95 -0
  79. package/dist/bundle/chunk-SQHDE3TC.js +230 -0
  80. package/dist/bundle/chunk-TF7ZGCOK.js +76 -0
  81. package/dist/bundle/chunk-V6BTAILB.js +4072 -0
  82. package/dist/bundle/chunk-VDMIJ3JW.js +50 -0
  83. package/dist/bundle/chunk-VW5F6FK3.js +206 -0
  84. package/dist/bundle/chunk-W6F2CQZ6.js +1068 -0
  85. package/dist/bundle/chunk-WARIIYSW.js +58 -0
  86. package/dist/bundle/chunk-WK7GLHHL.js +334 -0
  87. package/dist/bundle/chunk-X5S5KUSU.js +2788 -0
  88. package/dist/bundle/chunk-X6R74TWX.js +131 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-XXLQNHKF.js +82 -0
  91. package/dist/bundle/chunk-XXOTX4M3.js +362 -0
  92. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  93. package/dist/bundle/chunk-ZDBTYBFR.js +66 -0
  94. package/dist/bundle/chunk-ZGADZ4CH.js +557 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-7M6EPH3D.js +37 -0
  97. package/dist/bundle/command-server-entry-MNVPYQZ3.js +166 -0
  98. package/dist/bundle/decode-MQNKNXLK.js +297 -0
  99. package/dist/bundle/definitions-FODOIPM2.js +43379 -0
  100. package/dist/bundle/dispatch-TAQ7635E.js +411 -0
  101. package/dist/bundle/dist-EM7KLEG4.js +7577 -0
  102. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  103. package/dist/bundle/echarts-6ZSUNO4L.js +42501 -0
  104. package/dist/bundle/embed-PHCCJJ5Z.js +38 -0
  105. package/dist/bundle/embedder-WLZZQTKZ.js +111 -0
  106. package/dist/bundle/failure-MR2XVHFP.js +25 -0
  107. package/dist/bundle/first-run-64LREHSV.js +29 -0
  108. package/dist/bundle/first-screen-YSCAZIYJ.js +37 -0
  109. package/dist/bundle/instructions-22GCKNR5.js +11 -0
  110. package/dist/bundle/mcp-CNV7F2XZ.js +167 -0
  111. package/dist/bundle/meeting-combined-YX3T5WJD.js +24 -0
  112. package/dist/bundle/meeting-model-JWDTCGLZ.js +25 -0
  113. package/dist/bundle/meeting-semantic-375GYPZQ.js +22 -0
  114. package/dist/bundle/node-ITDTNRRZ.js +176 -0
  115. package/dist/bundle/node-KM3CUABH.js +2340 -0
  116. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  117. package/dist/bundle/node-sqlite-IRAGRMEZ.js +74 -0
  118. package/dist/bundle/oauth-CACOQJEL.js +20 -0
  119. package/dist/bundle/open-HU4KHKDR.js +23 -0
  120. package/dist/bundle/openai-JQUPAVKX.js +238 -0
  121. package/dist/bundle/process-QS5OHEUK.js +91 -0
  122. package/dist/bundle/program-QLCUCR76.js +33428 -0
  123. package/dist/bundle/prompt-VA5MKXJU.js +17 -0
  124. package/dist/bundle/recognize-JGA5IVKC.js +26 -0
  125. package/dist/bundle/remote-NPY2KZQ4.js +31 -0
  126. package/dist/bundle/rerank-4H2QR4XU.js +52 -0
  127. package/dist/bundle/schemas-THAI3G5S.js +21410 -0
  128. package/dist/bundle/serve-UH46SZQG.js +199 -0
  129. package/dist/bundle/server-6H7JS6SU.js +212 -0
  130. package/dist/bundle/server-SR52KBL3.js +79 -0
  131. package/dist/bundle/sqlite-runtime-EJWEUTBR.js +20 -0
  132. package/dist/bundle/state-34B6AUQZ.js +36 -0
  133. package/dist/bundle/store-3R4ILTCJ.js +177 -0
  134. package/dist/bundle/store-XSE35P3U.js +291 -0
  135. package/dist/bundle/store-maintenance-command-ABJARLI4.js +66 -0
  136. package/dist/bundle/surface-NOTIEJB5.js +65 -0
  137. package/dist/commands/api.d.ts +12 -0
  138. package/dist/commands/api.d.ts.map +1 -0
  139. package/dist/commands/api.js +27 -0
  140. package/dist/commands/api.js.map +1 -0
  141. package/dist/commands/crm.d.ts +4 -0
  142. package/dist/commands/crm.d.ts.map +1 -0
  143. package/dist/commands/crm.js +66 -0
  144. package/dist/commands/crm.js.map +1 -0
  145. package/dist/commands/session.d.ts +7 -0
  146. package/dist/commands/session.d.ts.map +1 -0
  147. package/dist/commands/session.js +22 -0
  148. package/dist/commands/session.js.map +1 -0
  149. package/dist/config.d.ts +14 -0
  150. package/dist/config.d.ts.map +1 -0
  151. package/dist/config.js +14 -0
  152. package/dist/config.js.map +1 -0
  153. package/dist/context.d.ts +37 -0
  154. package/dist/context.d.ts.map +1 -0
  155. package/dist/context.js +31 -0
  156. package/dist/context.js.map +1 -0
  157. package/dist/generated/definitions.d.ts +3 -0
  158. package/dist/generated/definitions.d.ts.map +1 -0
  159. package/dist/generated/definitions.js +43375 -0
  160. package/dist/generated/definitions.js.map +1 -0
  161. package/dist/generated/manifest.d.ts +6 -0
  162. package/dist/generated/manifest.d.ts.map +1 -0
  163. package/dist/generated/manifest.js +5158 -0
  164. package/dist/generated/manifest.js.map +1 -0
  165. package/dist/generated/schemas.d.ts +383 -0
  166. package/dist/generated/schemas.d.ts.map +1 -0
  167. package/dist/generated/schemas.js +21196 -0
  168. package/dist/generated/schemas.js.map +1 -0
  169. package/dist/generated/types.d.ts +10166 -0
  170. package/dist/generated/types.d.ts.map +1 -0
  171. package/dist/generated/types.js +5 -0
  172. package/dist/generated/types.js.map +1 -0
  173. package/dist/generated/wirecat-config.d.ts +15 -0
  174. package/dist/generated/wirecat-config.d.ts.map +1 -0
  175. package/dist/generated/wirecat-config.js +333 -0
  176. package/dist/generated/wirecat-config.js.map +1 -0
  177. package/dist/hooks.d.ts +3 -0
  178. package/dist/hooks.d.ts.map +1 -0
  179. package/dist/hooks.js +7 -0
  180. package/dist/hooks.js.map +1 -0
  181. package/dist/identity.d.ts +33 -0
  182. package/dist/identity.d.ts.map +1 -0
  183. package/dist/identity.js +31 -0
  184. package/dist/identity.js.map +1 -0
  185. package/dist/index.d.ts +3 -0
  186. package/dist/index.d.ts.map +1 -0
  187. package/dist/index.js +3 -0
  188. package/dist/index.js.map +1 -0
  189. package/dist/program.d.ts +6 -0
  190. package/dist/program.d.ts.map +1 -0
  191. package/dist/program.js +54 -0
  192. package/dist/program.js.map +1 -0
  193. package/dist/version.d.ts +2 -0
  194. package/dist/version.d.ts.map +1 -0
  195. package/dist/version.js +2 -0
  196. package/dist/version.js.map +1 -0
  197. package/dist/wcat.d.ts +3 -0
  198. package/dist/wcat.d.ts.map +1 -0
  199. package/dist/wcat.js +4 -0
  200. package/dist/wcat.js.map +1 -0
  201. package/package.json +87 -4
  202. package/skills/attio-cli/SKILL.md +58 -0
  203. package/skills/attio-cli/references/api/api-activities.md +62 -0
  204. package/skills/attio-cli/references/api/api-activity-records.md +96 -0
  205. package/skills/attio-cli/references/api/api-attributes.md +148 -0
  206. package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
  207. package/skills/attio-cli/references/api/api-comments.md +36 -0
  208. package/skills/attio-cli/references/api/api-emails.md +23 -0
  209. package/skills/attio-cli/references/api/api-entries.md +127 -0
  210. package/skills/attio-cli/references/api/api-files.md +63 -0
  211. package/skills/attio-cli/references/api/api-lists.md +44 -0
  212. package/skills/attio-cli/references/api/api-meetings.md +82 -0
  213. package/skills/attio-cli/references/api/api-meta.md +8 -0
  214. package/skills/attio-cli/references/api/api-notes.md +64 -0
  215. package/skills/attio-cli/references/api/api-objects.md +55 -0
  216. package/skills/attio-cli/references/api/api-records.md +168 -0
  217. package/skills/attio-cli/references/api/api-sequences.md +15 -0
  218. package/skills/attio-cli/references/api/api-sql.md +15 -0
  219. package/skills/attio-cli/references/api/api-tasks.md +67 -0
  220. package/skills/attio-cli/references/api/api-threads.md +35 -0
  221. package/skills/attio-cli/references/api/api-transcripts.md +17 -0
  222. package/skills/attio-cli/references/api/api-views.md +133 -0
  223. package/skills/attio-cli/references/api/api-webhooks.md +62 -0
  224. package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
  225. package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
  226. package/skills/attio-cli/references/api.md +35 -0
@@ -0,0 +1,52 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ readSharedSection,
5
+ writeSharedSection
6
+ } from "./chunk-EQGXEKSV.js";
7
+ import {
8
+ CliError
9
+ } from "./chunk-BUGROVF3.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/cli/setup-answers.js
15
+ var PERMISSION_ANSWERS = ["readonly", "allow"];
16
+ var QUESTIONS = ["languages", "tools", "permissions"];
17
+ var SECTION = "setup";
18
+ var readSetupAnswers = /* @__PURE__ */ __name((path) => {
19
+ const section = readSharedSection(path, SECTION);
20
+ if (section === void 0)
21
+ return {};
22
+ const answers = section;
23
+ if (section === null || typeof section !== "object" || Array.isArray(section) || answers.languages !== void 0 && answers.languages !== true || answers.tools !== void 0 && answers.tools !== true || answers.permissions !== void 0 && !PERMISSION_ANSWERS.includes(answers.permissions))
24
+ throw new CliError("configuration_error", `${path}: ${SECTION} holds what setup asked \u2014 languages: true, tools: true, permissions: ${PERMISSION_ANSWERS.join(" | ")}`);
25
+ return answers;
26
+ }, "readSetupAnswers");
27
+ var unanswered = /* @__PURE__ */ __name((answers) => QUESTIONS.filter((question) => answers[question] === void 0), "unanswered");
28
+ var writeSetupAnswers = /* @__PURE__ */ __name((path, answers) => {
29
+ let kept = {};
30
+ try {
31
+ kept = readSetupAnswers(path);
32
+ } catch (error) {
33
+ if (!(error instanceof CliError) || !error.message.includes(`${SECTION} holds`))
34
+ throw error;
35
+ }
36
+ writeSharedSection(path, SECTION, { ...kept, ...answers });
37
+ }, "writeSetupAnswers");
38
+ var permissionCeiling = /* @__PURE__ */ __name((path) => {
39
+ try {
40
+ return readSetupAnswers(path).permissions === "readonly" ? "readonly" : void 0;
41
+ } catch {
42
+ return void 0;
43
+ }
44
+ }, "permissionCeiling");
45
+
46
+ export {
47
+ QUESTIONS,
48
+ readSetupAnswers,
49
+ unanswered,
50
+ writeSetupAnswers,
51
+ permissionCeiling
52
+ };
@@ -0,0 +1,108 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CLIENT_INFO_META_KEY
5
+ } from "./chunk-PL5P7UKW.js";
6
+ import {
7
+ agentOf,
8
+ clientHash,
9
+ currentCaller
10
+ } from "./chunk-XXOTX4M3.js";
11
+ import {
12
+ __name
13
+ } from "./chunk-ZVVMGPBJ.js";
14
+
15
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/mcp/caller.js
16
+ var callingAgent = /* @__PURE__ */ __name((fallback, caller = currentCaller()) => {
17
+ const client = caller?.agent?.client?.name;
18
+ if (client && client !== "unknown")
19
+ return client;
20
+ const kind = caller?.agent?.kind;
21
+ return kind && kind !== "mcp-client" ? kind : fallback;
22
+ }, "callingAgent");
23
+ var CALLER_META_KEY = "wirecat.dev/caller";
24
+ var PROXY_CLIENT_NAME = "all-profiles";
25
+ var NAME = /^[\w .@()/+-]{1,64}$/;
26
+ var plain = /* @__PURE__ */ __name((value) => typeof value === "string" && NAME.test(value.trim()) ? value.trim() : void 0, "plain");
27
+ var clientFrom = /* @__PURE__ */ __name((value) => {
28
+ if (!value || typeof value !== "object")
29
+ return void 0;
30
+ const { name, version } = value;
31
+ const named = plain(name);
32
+ if (!named)
33
+ return void 0;
34
+ const versioned = plain(version);
35
+ return { name: named, ...versioned ? { version: versioned } : {} };
36
+ }, "clientFrom");
37
+ var callerOf = /* @__PURE__ */ __name((ctx, tool, source) => {
38
+ const meta = ctx?.mcpReq?._meta;
39
+ const requestId = ctx?.mcpReq?.id;
40
+ const initialized = source.client?.();
41
+ const proxied = initialized?.name === PROXY_CLIENT_NAME && !ctx?.http ? passedOn(meta?.[CALLER_META_KEY], tool) : void 0;
42
+ if (proxied)
43
+ return proxied;
44
+ const client = clientFrom(meta?.[CLIENT_INFO_META_KEY]) ?? clientFrom(initialized);
45
+ const mcp = /* @__PURE__ */ __name((connection) => ({
46
+ tool,
47
+ ...requestId === void 0 ? {} : { request_id: String(requestId) },
48
+ ...connection ? { connection_id: connection } : {}
49
+ }), "mcp");
50
+ const auth = ctx?.http?.authInfo;
51
+ if (auth) {
52
+ const registered = plain(auth.extra?.clientName);
53
+ return {
54
+ via: "mcp-http",
55
+ agent: {
56
+ kind: "mcp-client",
57
+ session_id: ctx?.sessionId ?? null,
58
+ client: {
59
+ name: registered ?? client?.name ?? "unknown",
60
+ ...client?.version ? { version: client.version } : {},
61
+ id: clientHash(auth.clientId)
62
+ }
63
+ },
64
+ mcp: mcp(ctx?.sessionId)
65
+ };
66
+ }
67
+ const agent = agentOf(source.env) ?? { kind: "mcp-client", session_id: null };
68
+ return { via: "mcp-stdio", agent: { ...agent, ...client ? { client } : {} }, mcp: mcp(source.connectionId) };
69
+ }, "callerOf");
70
+ var passedOn = /* @__PURE__ */ __name((value, tool) => {
71
+ if (!value || typeof value !== "object")
72
+ return void 0;
73
+ const { via, agent, mcp } = value;
74
+ if (via !== "mcp-stdio" && via !== "mcp-http")
75
+ return void 0;
76
+ const a = agent && typeof agent === "object" ? agent : void 0;
77
+ const kind = plain(a?.kind);
78
+ const session = typeof a?.session_id === "string" && /^[A-Za-z0-9._:-]{1,128}$/.test(a.session_id) ? a.session_id : null;
79
+ const client = clientFrom(a?.client);
80
+ const id = a?.client && typeof a.client === "object" ? a.client.id : void 0;
81
+ const m = mcp && typeof mcp === "object" ? mcp : {};
82
+ const request = plain(m.request_id);
83
+ const connection = typeof m.connection_id === "string" && /^[\w-]{1,128}$/.test(m.connection_id) ? m.connection_id : void 0;
84
+ return {
85
+ via,
86
+ ...kind ? {
87
+ agent: {
88
+ kind,
89
+ session_id: session,
90
+ ...a?.from_chat === true ? { from_chat: true } : {},
91
+ ...client ? { client: { ...client, ...typeof id === "string" && /^[0-9a-f]{8}$/.test(id) ? { id } : {} } } : {}
92
+ }
93
+ } : {},
94
+ mcp: {
95
+ tool,
96
+ ...request ? { request_id: request } : {},
97
+ ...connection ? { connection_id: connection } : {},
98
+ proxied: true
99
+ }
100
+ };
101
+ }, "passedOn");
102
+
103
+ export {
104
+ callingAgent,
105
+ CALLER_META_KEY,
106
+ PROXY_CLIENT_NAME,
107
+ callerOf
108
+ };
@@ -0,0 +1,156 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError,
5
+ errorCodes
6
+ } from "./chunk-BUGROVF3.js";
7
+ import {
8
+ __name
9
+ } from "./chunk-ZVVMGPBJ.js";
10
+
11
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/errors/failures.js
12
+ var isCliFailure = /* @__PURE__ */ __name((value) => value instanceof Error && value.name === "CliError" && errorCodes.includes(value.code), "isCliFailure");
13
+ var isCommanderFailure = /* @__PURE__ */ __name((value) => {
14
+ const { code, exitCode } = value ?? {};
15
+ return value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number";
16
+ }, "isCommanderFailure");
17
+ var USAGE_REASONS = {
18
+ "commander.unknownCommand": "usage.unknown-command",
19
+ "commander.unknownOption": "usage.unknown-option"
20
+ };
21
+ var usageReason = /* @__PURE__ */ __name((code) => USAGE_REASONS[code], "usageReason");
22
+ var failureKey = /* @__PURE__ */ __name((error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error", "failureKey");
23
+ var SQLITE_CORRUPT = 11;
24
+ var SQLITE_NOTADB = 26;
25
+ var DAMAGED_TEXT = /database disk image is malformed|file is not a database|fts5: corruption/i;
26
+ var sqliteCode = /* @__PURE__ */ __name((error) => {
27
+ const { errcode, errno, name } = error ?? {};
28
+ const code = typeof errcode === "number" ? errcode : name === "SQLiteError" && typeof errno === "number" ? errno : null;
29
+ return code === null ? void 0 : code & 255;
30
+ }, "sqliteCode");
31
+ var damageIn = /* @__PURE__ */ __name((error) => {
32
+ if (isCliFailure(error) || isCommanderFailure(error))
33
+ return void 0;
34
+ let at = error;
35
+ for (let depth = 0; depth < 5 && at instanceof Error; depth += 1) {
36
+ const code = sqliteCode(at);
37
+ if (code !== void 0 && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code) || DAMAGED_TEXT.test(at.message))
38
+ return at;
39
+ at = at.cause;
40
+ }
41
+ return void 0;
42
+ }, "damageIn");
43
+ var wrapping = /* @__PURE__ */ __name((error, original) => {
44
+ Object.defineProperty(error, "cause", { value: original, configurable: true, writable: true });
45
+ if (original instanceof Error && original.stack)
46
+ error.stack = original.stack;
47
+ return error;
48
+ }, "wrapping");
49
+ var storeDamaged = /* @__PURE__ */ __name((error, next) => damageIn(error) ? wrapping(new CliError("configuration_error", `the store file is damaged${next ? `; \`${next}\` says what is damaged and what to do` : ""}`, { reason: "store.damaged" }), error) : error, "storeDamaged");
50
+ var damagedFile = /* @__PURE__ */ __name(async (files, work) => {
51
+ try {
52
+ return await work();
53
+ } catch (error) {
54
+ if (!damageIn(error))
55
+ throw error;
56
+ throw wrapping(new CliError("validation_error", `${files.join(" or ")} is damaged or not a database`, {
57
+ reason: "store.file-damaged"
58
+ }), error);
59
+ }
60
+ }, "damagedFile");
61
+ var isStoreDamage = /* @__PURE__ */ __name((error) => damageIn(error) !== void 0, "isStoreDamage");
62
+
63
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/runs/secrets.js
64
+ var SECRET_WORDS = /* @__PURE__ */ new Set([
65
+ "authorization",
66
+ "cookie",
67
+ "credential",
68
+ "credentials",
69
+ "passphrase",
70
+ "password",
71
+ "passwd",
72
+ "pwd",
73
+ "pass",
74
+ "passcode",
75
+ "pin",
76
+ "otp",
77
+ "2fa",
78
+ "secret",
79
+ "token",
80
+ "contrase\xF1a",
81
+ "contrasena",
82
+ "clave",
83
+ "\u043F\u0430\u0440\u043E\u043B\u044C",
84
+ "\u043F\u0438\u043D",
85
+ "\u043A\u043E\u0434",
86
+ ...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
87
+ ...["db", "database", "key"].map((word) => `${word}pass`)
88
+ ]);
89
+ var secretNamed = /* @__PURE__ */ __name((name) => {
90
+ const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
91
+ return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
92
+ }, "secretNamed");
93
+ var START = "(?<![A-Za-z0-9_-])";
94
+ var END = "(?![A-Za-z0-9_-])";
95
+ var KNOWN_TOKENS = new RegExp(`${[
96
+ "gh[pousr]_[A-Za-z0-9]{36,}",
97
+ "github_pat_[A-Za-z0-9_]{22,}",
98
+ "sk-[A-Za-z0-9_-]{20,}",
99
+ "xox[abprs]-[A-Za-z0-9-]{10,}",
100
+ "(?:AKIA|ASIA)[A-Z0-9]{16}",
101
+ "AIza[A-Za-z0-9_-]{35}",
102
+ "(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
103
+ "npm_[A-Za-z0-9]{36}",
104
+ "eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
105
+ ].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
106
+ var WEBHOOK_PATH = /(\/rest\/\d+\/)[^/\s?#"']+/g;
107
+ var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
108
+ var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
109
+ 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;
110
+ var looksRandom = /* @__PURE__ */ __name((run) => {
111
+ if (run.length < 20)
112
+ return false;
113
+ const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
114
+ if (classes < 3)
115
+ return false;
116
+ let switches = 0;
117
+ for (let at = 1; at < run.length; at++) {
118
+ const [before, after] = [run[at - 1], run[at]];
119
+ if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
120
+ switches += 1;
121
+ }
122
+ if (switches / run.length < 0.15)
123
+ return false;
124
+ const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
125
+ if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
126
+ return false;
127
+ return entropy(run) >= 3.5;
128
+ }, "looksRandom");
129
+ var entropy = /* @__PURE__ */ __name((text) => {
130
+ const counts = /* @__PURE__ */ new Map();
131
+ for (const char of text)
132
+ counts.set(char, (counts.get(char) ?? 0) + 1);
133
+ let bits = 0;
134
+ for (const count of counts.values())
135
+ bits -= count / text.length * Math.log2(count / text.length);
136
+ return bits;
137
+ }, "entropy");
138
+ var withoutSecrets = /* @__PURE__ */ __name((text, mark = "[redacted]") => text.replace(WEBHOOK_PATH, `$1${mark}`).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) => (
139
+ // A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
140
+ token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
141
+ )), "withoutSecrets");
142
+ var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
143
+ var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
144
+
145
+ export {
146
+ isCliFailure,
147
+ isCommanderFailure,
148
+ usageReason,
149
+ failureKey,
150
+ sqliteCode,
151
+ storeDamaged,
152
+ damagedFile,
153
+ isStoreDamage,
154
+ secretNamed,
155
+ withoutSecrets
156
+ };