@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,220 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ AI_ENTRIES,
5
+ checkConfigText,
6
+ issueMessage,
7
+ usableProfileName
8
+ } from "./chunk-Z4O6C7WR.js";
9
+ import {
10
+ LEVELS
11
+ } from "./chunk-PJDO7AFZ.js";
12
+ import {
13
+ MAX_TEXT_CHARS
14
+ } from "./chunk-MWUITL6N.js";
15
+ import {
16
+ resolvePaths,
17
+ saveConfigFile
18
+ } from "./chunk-6KFA6HOM.js";
19
+ import {
20
+ CliError,
21
+ array,
22
+ boolean,
23
+ integer,
24
+ literal,
25
+ maxValue,
26
+ minLength,
27
+ minValue,
28
+ number,
29
+ object,
30
+ optional,
31
+ parse,
32
+ picklist,
33
+ pipe,
34
+ record,
35
+ regex,
36
+ strictObject,
37
+ string,
38
+ union
39
+ } from "./chunk-GKHM6I64.js";
40
+ import {
41
+ __name
42
+ } from "./chunk-ZVVMGPBJ.js";
43
+
44
+ // dist/config.js
45
+ import { readFileSync } from "node:fs";
46
+ import { join } from "node:path";
47
+
48
+ // dist/oauth-application.js
49
+ var WIRECAT_APPLICATION = Object.freeze({
50
+ clientId: "240274586781-vssrlm9c0l3n1ti12ce7tg95ro4bghal.apps.googleusercontent.com",
51
+ // biome-ignore lint/security/noSecrets: public installed-app OAuth identity, non-confidential per Google native-app guidance
52
+ clientSecret: "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"
53
+ // gitleaks:allow -- public installed-app identity
54
+ });
55
+
56
+ // dist/config.js
57
+ var Common = {
58
+ ...AI_ENTRIES,
59
+ permissions: optional(record(string(), picklist(LEVELS))),
60
+ max_text_chars: optional(pipe(number(), integer(), minValue(1), maxValue(MAX_TEXT_CHARS)))
61
+ };
62
+ var RunSettings = {
63
+ record: optional(boolean()),
64
+ keep_runs_for_days: optional(pipe(number(), integer(), minValue(1))),
65
+ keep_successful_runs_for_days: optional(pipe(number(), integer(), minValue(1))),
66
+ runs_size_limit_mb: optional(pipe(number(), integer(), minValue(1))),
67
+ record_input: optional(union([boolean(), literal("failed")]))
68
+ };
69
+ var DEFAULTS_ONLY = new Set(Object.keys(RunSettings));
70
+ var SETTING_NAMES = /* @__PURE__ */ new Set([...Object.keys(Common), "picture_search", ...DEFAULTS_ONLY]);
71
+ var Mirror = strictObject({
72
+ id: pipe(string(), regex(/^[a-z0-9-]{1,40}$/)),
73
+ path: pipe(string(), minLength(1)),
74
+ folder: pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/))
75
+ });
76
+ var Profile = strictObject({
77
+ principal: string(),
78
+ roots: optional(array(pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/))), []),
79
+ mirrors: optional(array(Mirror)),
80
+ storage: picklist(["keyring", "file"]),
81
+ picture_search: optional(boolean()),
82
+ ...Common
83
+ });
84
+ var ConfigSchema = strictObject({
85
+ profiles: optional(record(string(), Profile), {}),
86
+ defaults: optional(strictObject({ ...Common, ...RunSettings }))
87
+ });
88
+ var paths = /* @__PURE__ */ __name((env) => resolvePaths({ appName: "drive-cli", prefix: "DRIVE", env }), "paths");
89
+ var configPath = /* @__PURE__ */ __name((env) => join(paths(env).config, "config.json"), "configPath");
90
+ var TOOL = "drive";
91
+ var isNode = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isNode");
92
+ var withoutIncomplete = /* @__PURE__ */ __name((raw, issues) => {
93
+ const incomplete = new Set(issues.flatMap((issue) => issue.kind === "missing_setting" && issue.profile ? [issue.profile] : []));
94
+ if (!incomplete.size || !isNode(raw) || !isNode(raw.profiles))
95
+ return void 0;
96
+ return {
97
+ ...raw,
98
+ profiles: Object.fromEntries(Object.entries(raw.profiles).filter(([name]) => !incomplete.has(name)))
99
+ };
100
+ }, "withoutIncomplete");
101
+ var examine = /* @__PURE__ */ __name((text, file, knownPermissions) => {
102
+ const check = /* @__PURE__ */ __name((body) => checkConfigText(body, { file, tool: TOOL, schema: ConfigSchema, ...knownPermissions ? { knownPermissions } : {} }), "check");
103
+ const first = check(text);
104
+ if (first.issues.some((issue) => issue.kind === "invalid_json"))
105
+ return { raw: {}, config: { profiles: {} }, issues: first.issues };
106
+ const raw = JSON.parse(text);
107
+ if (first.config)
108
+ return { raw, config: first.config, issues: first.issues };
109
+ const rest = withoutIncomplete(raw, first.issues);
110
+ const second = rest && check(JSON.stringify(rest));
111
+ return {
112
+ raw,
113
+ config: second?.config ?? { profiles: {} },
114
+ // Saved permissions are checked only in what loads, and the first pass loaded nothing.
115
+ issues: [...first.issues, ...(second?.issues ?? []).filter((issue) => issue.kind === "unknown_permission")]
116
+ };
117
+ }, "examine");
118
+ var inspectConfig = /* @__PURE__ */ __name((env, knownPermissions) => {
119
+ const path = configPath(env);
120
+ let text;
121
+ try {
122
+ text = readFileSync(path, "utf8");
123
+ } catch {
124
+ return { path, found: false, raw: {}, config: { profiles: {} }, issues: [] };
125
+ }
126
+ return { path, found: true, ...examine(text, path, knownPermissions) };
127
+ }, "inspectConfig");
128
+ var configIssues = /* @__PURE__ */ __name((raw, file, knownPermissions) => examine(JSON.stringify(raw), file, knownPermissions).issues, "configIssues");
129
+ var refusal = /* @__PURE__ */ __name((issues) => new CliError("configuration_error", issueMessage(issues)), "refusal");
130
+ var readConfig = /* @__PURE__ */ __name((env, knownPermissions) => {
131
+ const { config, issues } = inspectConfig(env, knownPermissions);
132
+ if (issues.length)
133
+ throw refusal(issues);
134
+ return config;
135
+ }, "readConfig");
136
+ var writeConfig = /* @__PURE__ */ __name((env, config) => {
137
+ const [issue] = configIssues(config, "drive settings");
138
+ if (issue)
139
+ throw new CliError("configuration_error", `drive settings: ${issue.profile === void 0 ? "" : `profile ${issue.profile}: `}${issue.what}`);
140
+ saveConfigFile(configPath(env), parse(ConfigSchema, config));
141
+ }, "writeConfig");
142
+ var profileName = usableProfileName;
143
+ var fileId = /* @__PURE__ */ __name((input) => {
144
+ let id = input;
145
+ if (input.startsWith("https://")) {
146
+ const url = new URL(input);
147
+ if (url.hostname !== "drive.google.com" && url.hostname !== "docs.google.com")
148
+ throw new CliError("validation_error", "use a Google Drive/Docs URL or file ID");
149
+ id = url.pathname.match(/\/(?:folders|d)\/([^/]+)/)?.[1] ?? "";
150
+ }
151
+ if (!/^[A-Za-z0-9_-]{1,200}$/.test(id))
152
+ throw new CliError("validation_error", "invalid Google file ID");
153
+ return id;
154
+ }, "fileId");
155
+ var unknownProfile = /* @__PURE__ */ __name((name, profiles) => new CliError("validation_error", profiles.length ? `no profile ${name} here \u2014 profiles here: ${profiles.join(", ")}; a new one signs in with drive ${name} session start` : `no profiles here yet; create one with drive ${name} session start`, { reason: "profile.unknown", profiles }), "unknownProfile");
156
+ var activeProfile = /* @__PURE__ */ __name((env, name) => {
157
+ const config = readConfig(env);
158
+ const profile = config.profiles[profileName(name)];
159
+ if (!profile)
160
+ throw unknownProfile(name, Object.keys(config.profiles).sort());
161
+ return profile;
162
+ }, "activeProfile");
163
+ var checkTextLimit = /* @__PURE__ */ __name((value) => {
164
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1)
165
+ throw new CliError("validation_error", "max_text_chars must be a positive whole number of characters");
166
+ if (value > MAX_TEXT_CHARS)
167
+ throw new CliError("validation_error", `max_text_chars can be at most ${MAX_TEXT_CHARS}: the document readers return at most that many characters`);
168
+ return value;
169
+ }, "checkTextLimit");
170
+ var textLimit = /* @__PURE__ */ __name((env, name) => activeProfile(env, name).max_text_chars ?? readConfig(env).defaults?.max_text_chars ?? MAX_TEXT_CHARS, "textLimit");
171
+ var pictureSearch = /* @__PURE__ */ __name((env, name) => activeProfile(env, name).picture_search ?? false, "pictureSearch");
172
+ var application = /* @__PURE__ */ __name((env, file) => {
173
+ if (!file) {
174
+ if (!env.DRIVE_GOOGLE_CLIENT_ID) {
175
+ if (env.DRIVE_GOOGLE_CLIENT_SECRET)
176
+ throw new CliError("configuration_error", "DRIVE_GOOGLE_CLIENT_SECRET requires DRIVE_GOOGLE_CLIENT_ID");
177
+ return { ...WIRECAT_APPLICATION };
178
+ }
179
+ return {
180
+ clientId: env.DRIVE_GOOGLE_CLIENT_ID,
181
+ ...env.DRIVE_GOOGLE_CLIENT_SECRET ? { clientSecret: env.DRIVE_GOOGLE_CLIENT_SECRET } : {}
182
+ };
183
+ }
184
+ try {
185
+ const data = parse(object({
186
+ installed: object({ client_id: pipe(string(), minLength(1)), client_secret: optional(string()) })
187
+ }), JSON.parse(readFileSync(file, "utf8")));
188
+ return {
189
+ clientId: data.installed.client_id,
190
+ ...data.installed.client_secret ? { clientSecret: data.installed.client_secret } : {}
191
+ };
192
+ } catch {
193
+ throw new CliError("configuration_error", "could not read a valid Desktop OAuth client JSON; file contents were not logged");
194
+ }
195
+ }, "application");
196
+ var selectedFolders = /* @__PURE__ */ __name((env, profile, filter = {}) => activeProfile(env, profile).roots.flatMap((id) => filter.id === void 0 || id === filter.id ? [{ id }] : []), "selectedFolders");
197
+ var configuredMirrors = /* @__PURE__ */ __name((env, profile, filter = {}) => (activeProfile(env, profile).mirrors ?? []).filter((row) => Object.entries(filter).every(([key, value]) => row[key] === value)), "configuredMirrors");
198
+ var configuredSessions = /* @__PURE__ */ __name((env, filter, knownPermissions) => Object.entries(readConfig(env, knownPermissions).profiles).flatMap(([name, row]) => (filter.profile === void 0 || filter.profile === name) && (filter.storage === void 0 || filter.storage === row.storage) ? [{ profile: name, selected_folders: row.roots.length, storage: row.storage }] : []), "configuredSessions");
199
+
200
+ export {
201
+ DEFAULTS_ONLY,
202
+ SETTING_NAMES,
203
+ paths,
204
+ inspectConfig,
205
+ configIssues,
206
+ refusal,
207
+ readConfig,
208
+ writeConfig,
209
+ profileName,
210
+ fileId,
211
+ unknownProfile,
212
+ activeProfile,
213
+ checkTextLimit,
214
+ textLimit,
215
+ pictureSearch,
216
+ application,
217
+ selectedFolders,
218
+ configuredMirrors,
219
+ configuredSessions
220
+ };
@@ -0,0 +1,106 @@
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-QLZGLPJL.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@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/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
+ };
@@ -0,0 +1,48 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-GKHM6I64.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // 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/http/public-url.js
11
+ var EXAMPLE = "--public-url https://<name>.ts.net";
12
+ var publicUrlOf = /* @__PURE__ */ __name((given, { missing, reaches, path = false }) => {
13
+ if (!given)
14
+ throw new CliError("configuration_error", `${missing} needs the tunnel's address: ${EXAMPLE}`);
15
+ let url;
16
+ try {
17
+ url = new URL(given);
18
+ } catch {
19
+ throw new CliError("validation_error", `--public-url is not an address: ${EXAMPLE}`);
20
+ }
21
+ if (url.username || url.password)
22
+ throw new CliError("validation_error", "--public-url must not contain login credentials");
23
+ const local = url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname);
24
+ if (url.protocol !== "https:" && !local)
25
+ throw new CliError("validation_error", `--public-url must be https \u2014 ${reaches} through it`);
26
+ if (url.search || url.hash || !path && url.pathname !== "/")
27
+ throw new CliError("validation_error", path ? `--public-url is the tunnel's address, or a path of it, without a query: ${EXAMPLE}/tg` : `--public-url is the tunnel's address only, without a path: ${EXAMPLE}`);
28
+ if (path && !/^(\/[A-Za-z0-9_-][A-Za-z0-9._-]*)*\/?$/.test(url.pathname))
29
+ throw new CliError("validation_error", "--public-url's path takes letters, digits, dot, dash and underscore: /tg");
30
+ if (path)
31
+ url.pathname = url.pathname.replace(/\/+$/, "") || "/";
32
+ return url;
33
+ }, "publicUrlOf");
34
+ var portOf = /* @__PURE__ */ __name((given, fallback) => {
35
+ if (given === void 0)
36
+ return fallback;
37
+ const port = Number(given);
38
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
39
+ throw new CliError("validation_error", "--port takes 1\u201365535");
40
+ return port;
41
+ }, "portOf");
42
+ var mcpUrlOf = /* @__PURE__ */ __name((publicUrl) => new URL(`${publicUrl.pathname.replace(/\/+$/, "")}/mcp`, publicUrl.origin), "mcpUrlOf");
43
+
44
+ export {
45
+ publicUrlOf,
46
+ portOf,
47
+ mcpUrlOf
48
+ };
@@ -0,0 +1,138 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-GKHM6I64.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // 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/tasks/model.js
11
+ var TASK_KINDS = ["question", "request", "mention", "promise"];
12
+ var TASK_STATES = ["open", "done", "dismissed"];
13
+ var TASK_ORIGINS = ["rule", "agent", "owner"];
14
+ var TASK_VERDICTS = ["useful", "not_useful"];
15
+ function closeTask(task, state, by, at, reason) {
16
+ if (task.state !== "open")
17
+ throw new CliError("validation_error", `task ${task.id} is already ${task.state}`, { reason: "task.closed" });
18
+ const { claimedBy: _by, claimedUntil: _until, ...unclaimed } = task;
19
+ return { ...unclaimed, state, closedAt: at, closedBy: by, ...reason === void 0 ? {} : { reason } };
20
+ }
21
+ __name(closeTask, "closeTask");
22
+
23
+ // 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/tasks/service.js
24
+ function createTaskService({ store, now = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now"), newId = /* @__PURE__ */ __name(() => crypto.randomUUID(), "newId") }) {
25
+ async function find(id) {
26
+ const task = await store.get(id);
27
+ if (!task)
28
+ throw new CliError("not_found", `no task ${id}`);
29
+ return task;
30
+ }
31
+ __name(find, "find");
32
+ return {
33
+ /**
34
+ * A rule never makes a second task from a source it has seen, whatever that task's state, so a
35
+ * dismissed one stays dismissed — nor from a message attached or merged into a task. A person or an agent may
36
+ * add a task of another kind to it. A task a rule opens goes through the host's duplicate check.
37
+ */
38
+ async add(input) {
39
+ const rule = input.origin === "rule";
40
+ const existing = await store.findBySource(input.account, input.source, rule ? { linked: true } : void 0);
41
+ const same = rule ? existing[0] : existing.find((task2) => task2.kind === input.kind);
42
+ if (same)
43
+ return { task: same, created: false };
44
+ const task = { ...input, id: newId(), state: "open", createdAt: now() };
45
+ await store.insert(task);
46
+ if (!rule || !store.reviewDuplicates)
47
+ return { task, created: true };
48
+ return { task, created: true, review: await store.reviewDuplicates(task.id) };
49
+ },
50
+ async close(id, { as, by, reason }) {
51
+ const task = closeTask(await find(id), as, by, now(), reason);
52
+ await store.update(task);
53
+ return task;
54
+ },
55
+ list: /* @__PURE__ */ __name((filter = {}) => store.list(filter), "list"),
56
+ async stats(filter = {}) {
57
+ const byGroup = /* @__PURE__ */ new Map();
58
+ for (const task of await store.list(filter))
59
+ byGroup.set(task.group, [...byGroup.get(task.group) ?? [], task]);
60
+ return [...byGroup].map(([group, tasks]) => {
61
+ const open = tasks.filter((task) => task.state === "open");
62
+ const closeMs = tasks.flatMap((task) => task.closedAt ? [task.closedAt.getTime() - task.createdAt.getTime()] : []);
63
+ const oldestOpenAt = open.map((task) => task.createdAt).sort((a, b) => a.getTime() - b.getTime())[0];
64
+ return {
65
+ group,
66
+ open: open.length,
67
+ ...oldestOpenAt ? { oldestOpenAt } : {},
68
+ ...closeMs.length > 0 ? { medianCloseMs: median(closeMs) } : {}
69
+ };
70
+ });
71
+ }
72
+ };
73
+ }
74
+ __name(createTaskService, "createTaskService");
75
+ function median(values) {
76
+ const sorted = [...values].sort((a, b) => a - b);
77
+ const middle = Math.floor(sorted.length / 2);
78
+ const upper = sorted[middle] ?? 0;
79
+ return sorted.length % 2 === 1 ? upper : ((sorted[middle - 1] ?? 0) + upper) / 2;
80
+ }
81
+ __name(median, "median");
82
+
83
+ // 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/tasks/store.js
84
+ function matches(task, filter) {
85
+ return (filter.account === void 0 || task.account === filter.account) && (filter.state === void 0 || task.state === filter.state) && (filter.group === void 0 || task.group === filter.group) && (filter.kind === void 0 || task.kind === filter.kind) && (filter.createdBefore === void 0 || task.createdAt < filter.createdBefore);
86
+ }
87
+ __name(matches, "matches");
88
+
89
+ // 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/domain/knowledge.js
90
+ var FACT_TYPES = ["fact", "statement", "question", "decision", "promise"];
91
+ var FACT_STATUSES = ["proposed", "accepted", "superseded", "reversed"];
92
+ var MEMORY_KINDS = ["summary", "digest", "preference"];
93
+ var MEMORY_STATUSES = ["proposed", "confirmed", "stale", "superseded"];
94
+ var MEMORY_SCOPES = ["personal", "work"];
95
+ var WORK_TASK_TYPES = ["bug", "feature", "chore"];
96
+ var TASK_TYPES = [...WORK_TASK_TYPES, ...TASK_KINDS];
97
+
98
+ // 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/store/sqlite/link-kinds.js
99
+ var LINK_KINDS = [
100
+ "links-to",
101
+ "blocked-by",
102
+ "follow-up-of",
103
+ "about",
104
+ "member-of",
105
+ "labelled",
106
+ "answered-by",
107
+ "evidence",
108
+ "created-from",
109
+ "duplicate-of",
110
+ "related-to",
111
+ "assigned-to",
112
+ "attached"
113
+ ];
114
+ var LINK_ORIGINS = ["file", "owner", "suggested", "message"];
115
+ var LINK_SOURCES = [...LINK_ORIGINS, "calendar"];
116
+ var RELATION_KINDS = ["member-of", "related-to"];
117
+ var linkKind = /* @__PURE__ */ __name((kind) => `'${kind}'`, "linkKind");
118
+
119
+ export {
120
+ LINK_KINDS,
121
+ LINK_ORIGINS,
122
+ LINK_SOURCES,
123
+ RELATION_KINDS,
124
+ linkKind,
125
+ TASK_KINDS,
126
+ TASK_STATES,
127
+ TASK_ORIGINS,
128
+ TASK_VERDICTS,
129
+ createTaskService,
130
+ matches,
131
+ FACT_TYPES,
132
+ FACT_STATUSES,
133
+ MEMORY_KINDS,
134
+ MEMORY_STATUSES,
135
+ MEMORY_SCOPES,
136
+ WORK_TASK_TYPES,
137
+ TASK_TYPES
138
+ };
@@ -0,0 +1,71 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-GKHM6I64.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // 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/cli/input-policy.js
11
+ var MAX_BUFFERED_INPUT = 16 * 1024 * 1024;
12
+ var MAX_SECRET_INPUT = 64 * 1024;
13
+ var policies = /* @__PURE__ */ new WeakMap();
14
+ var inputPolicy = /* @__PURE__ */ __name((input) => policies.get(input) ?? {}, "inputPolicy");
15
+ var bufferedInput = /* @__PURE__ */ __name((input, options = {}) => {
16
+ const policy = inputPolicy(input);
17
+ const maxBytes = options.maxBytes ?? policy.maxBytes ?? MAX_BUFFERED_INPUT;
18
+ const signals = [options.signal, policy.signal].filter((one) => one !== void 0);
19
+ const signal = signals.length ? AbortSignal.any(signals) : void 0;
20
+ const state = input;
21
+ if (state.readableEnded)
22
+ return Promise.resolve(Buffer.alloc(0));
23
+ if (state.destroyed)
24
+ return Promise.reject(new CliError("validation_error", "input closed before EOF", { reason: "input.closed" }));
25
+ return new Promise((resolve, reject) => {
26
+ const chunks = [];
27
+ let bytes = 0;
28
+ const cleanup = /* @__PURE__ */ __name(() => {
29
+ input.off("data", data).off("end", end).off("error", error).off("close", closed);
30
+ signal?.removeEventListener("abort", aborted);
31
+ input.pause();
32
+ }, "cleanup");
33
+ const error = /* @__PURE__ */ __name((cause) => {
34
+ cleanup();
35
+ reject(cause);
36
+ }, "error");
37
+ const aborted = /* @__PURE__ */ __name(() => error(new CliError("cancelled", "input cancelled", { retryable: false })), "aborted");
38
+ const closed = /* @__PURE__ */ __name(() => error(new CliError("validation_error", "input closed before EOF", { reason: "input.closed" })), "closed");
39
+ const end = /* @__PURE__ */ __name(() => {
40
+ cleanup();
41
+ resolve(Buffer.concat(chunks, bytes));
42
+ }, "end");
43
+ const data = /* @__PURE__ */ __name((chunk) => {
44
+ const buffer = Buffer.from(chunk);
45
+ bytes += buffer.length;
46
+ if (bytes > maxBytes) {
47
+ error(new CliError("validation_error", `buffered input exceeds ${maxBytes} bytes \u2014 use a smaller input or --max-input-bytes`, {
48
+ reason: "input.too-large",
49
+ max_bytes: maxBytes,
50
+ retryable: false
51
+ }));
52
+ return;
53
+ }
54
+ chunks.push(buffer);
55
+ }, "data");
56
+ if (signal?.aborted) {
57
+ aborted();
58
+ return;
59
+ }
60
+ input.on("data", data).once("end", end).once("error", error).once("close", closed);
61
+ signal?.addEventListener("abort", aborted, { once: true });
62
+ input.resume();
63
+ });
64
+ }, "bufferedInput");
65
+
66
+ export {
67
+ MAX_BUFFERED_INPUT,
68
+ MAX_SECRET_INPUT,
69
+ inputPolicy,
70
+ bufferedInput
71
+ };