@wirecat/drive-cli 0.55.0 → 0.57.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 (132) hide show
  1. package/dist/bin/drive.js +2 -2
  2. package/dist/bundle/{all-profiles-I5KJKZPF.js → all-profiles-7LSZ3CC3.js} +9 -9
  3. package/dist/bundle/{anthropic-DPM7BRKX.js → anthropic-3QRM4QXB.js} +5 -5
  4. package/dist/bundle/{app-server-FTGLOZ2K.js → app-server-WWNMUHID.js} +48 -48
  5. package/dist/bundle/{bun-XRO6XJHQ.js → bun-NIIYUR5F.js} +2 -2
  6. package/dist/bundle/{bun-sqlite-7JJX6OUT.js → bun-sqlite-GSLSN3OT.js} +4 -4
  7. package/dist/bundle/{chunk-NPMVPKBD.js → chunk-2QLLKDE5.js} +48 -47
  8. package/dist/bundle/{chunk-P4ABC6C4.js → chunk-2ULJW5BA.js} +2 -2
  9. package/dist/bundle/{chunk-AR2HRFQO.js → chunk-373WJIHE.js} +2 -2
  10. package/dist/bundle/{chunk-K2DMCTTF.js → chunk-3BXSLNWW.js} +129 -97
  11. package/dist/bundle/{chunk-BO7ZKZCH.js → chunk-4F2VRJZE.js} +121 -46
  12. package/dist/bundle/{chunk-NDUYK676.js → chunk-4UQLL6RJ.js} +10 -9
  13. package/dist/bundle/{chunk-NFOUG7ES.js → chunk-566W4Q6L.js} +2 -2
  14. package/dist/bundle/{chunk-E7RDXCV2.js → chunk-5KNIVHP6.js} +5 -5
  15. package/dist/bundle/{chunk-VXZULAWV.js → chunk-64E6QXXQ.js} +14 -13
  16. package/dist/bundle/{chunk-FNDQFFLP.js → chunk-6CFSDU56.js} +11 -11
  17. package/dist/bundle/{chunk-ORRQDSDH.js → chunk-6ZA4NR5H.js} +3 -3
  18. package/dist/bundle/{chunk-PFTIYWOK.js → chunk-7SNS443B.js} +4 -4
  19. package/dist/bundle/{chunk-JPFF6MNK.js → chunk-AHBUTDS7.js} +8 -8
  20. package/dist/bundle/{chunk-TIEEVT2Z.js → chunk-AKPFH3KC.js} +1 -1
  21. package/dist/bundle/{chunk-FDCGTODC.js → chunk-AL7MY7MW.js} +1 -1
  22. package/dist/bundle/{chunk-RMQGFLT2.js → chunk-B3TPS7BW.js} +6 -6
  23. package/dist/bundle/{chunk-2DZMGPUC.js → chunk-B64EY2SC.js} +123 -34
  24. package/dist/bundle/{chunk-2OGANEKA.js → chunk-CD736BG3.js} +2 -2
  25. package/dist/bundle/{chunk-C4QKY33N.js → chunk-CGCQNYB3.js} +2 -2
  26. package/dist/bundle/{chunk-2KARCTUU.js → chunk-EE7R457T.js} +949 -581
  27. package/dist/bundle/{chunk-TQFCPUIM.js → chunk-EFEI724Z.js} +1 -1
  28. package/dist/bundle/{chunk-JBBZCTTF.js → chunk-EFX6FIDM.js} +1 -1
  29. package/dist/bundle/{chunk-DNJ43DT5.js → chunk-ELIYJXIY.js} +2 -2
  30. package/dist/bundle/{chunk-NPKFXGYG.js → chunk-EN7OZ5JH.js} +41 -23
  31. package/dist/bundle/{chunk-IXXVCKWL.js → chunk-G34Y5RAC.js} +26 -26
  32. package/dist/bundle/{chunk-TBD362SJ.js → chunk-GIQFBXQN.js} +11 -7
  33. package/dist/bundle/{chunk-KWKRTYRL.js → chunk-GKHUHRSL.js} +4 -4
  34. package/dist/bundle/{chunk-VGTDXEYD.js → chunk-HNUSPNUQ.js} +26 -13
  35. package/dist/bundle/{chunk-XTNEYXAQ.js → chunk-IJ2S53WJ.js} +5 -5
  36. package/dist/bundle/{chunk-FUKJQZED.js → chunk-ISK4K7UE.js} +1 -1
  37. package/dist/bundle/{chunk-YP5FDMTG.js → chunk-J2HGHSLX.js} +2 -2
  38. package/dist/bundle/{chunk-ULPS2OAL.js → chunk-JIGMCW4C.js} +4 -4
  39. package/dist/bundle/{chunk-ALMQEGYO.js → chunk-JLKNUFL2.js} +2 -2
  40. package/dist/bundle/{chunk-UDWMRZL6.js → chunk-JUKVJ7M2.js} +21 -21
  41. package/dist/bundle/{chunk-LAVWTS4P.js → chunk-KHNDZNQA.js} +5333 -5108
  42. package/dist/bundle/{chunk-GB5YM5HK.js → chunk-KM4Y55ZE.js} +5 -5
  43. package/dist/bundle/{chunk-CP6M5P4X.js → chunk-KYNTSA6K.js} +3 -3
  44. package/dist/bundle/{chunk-4XRLPQ3N.js → chunk-L4BBK7UX.js} +2 -2
  45. package/dist/bundle/chunk-LBFFI6FE.js +247 -0
  46. package/dist/bundle/{chunk-EOEDICIE.js → chunk-LSSIVBQI.js} +1 -1
  47. package/dist/bundle/{chunk-D6SRTPCV.js → chunk-NLLWLCUZ.js} +2 -2
  48. package/dist/bundle/{chunk-6OJMA4ZT.js → chunk-O5KDIVGE.js} +389 -255
  49. package/dist/bundle/{chunk-2LLNPNMB.js → chunk-OOR6PEHV.js} +1 -1
  50. package/dist/bundle/{chunk-UIPT6IAU.js → chunk-OYNSFQ7K.js} +1 -1
  51. package/dist/bundle/{chunk-67A2YFAT.js → chunk-OZJMZSFB.js} +4 -4
  52. package/dist/bundle/{chunk-GC4JNVYF.js → chunk-Q3TMNETS.js} +98 -37
  53. package/dist/bundle/{chunk-5DEEBWDI.js → chunk-QAT6UXZZ.js} +38 -37
  54. package/dist/bundle/{chunk-VY3TYRCK.js → chunk-R5GJZPRF.js} +114 -59
  55. package/dist/bundle/{chunk-4I7EBJJV.js → chunk-RAEKC6TV.js} +6 -6
  56. package/dist/bundle/{chunk-HNR2BJJU.js → chunk-RB674T6L.js} +75 -17
  57. package/dist/bundle/{chunk-NCCL4QWR.js → chunk-SRNXTXJN.js} +3 -3
  58. package/dist/bundle/{chunk-TD4RAOMZ.js → chunk-TKVSJV5P.js} +3 -3
  59. package/dist/bundle/{chunk-W6DMCGMK.js → chunk-TR5656OS.js} +47 -22
  60. package/dist/bundle/{chunk-VY2AUZMJ.js → chunk-TZHCS5MG.js} +2 -2
  61. package/dist/bundle/{chunk-KM7Q67Z3.js → chunk-U2RSVKR5.js} +1 -1
  62. package/dist/bundle/{chunk-IDK5QUBJ.js → chunk-UKMFPBAO.js} +4 -4
  63. package/dist/bundle/{chunk-GIRVMZD3.js → chunk-VTJF2L5E.js} +16 -16
  64. package/dist/bundle/{chunk-AQNY57J2.js → chunk-W5FOPSJZ.js} +7 -7
  65. package/dist/bundle/{chunk-FKHWVVMV.js → chunk-W6FYYQ2J.js} +3 -3
  66. package/dist/bundle/{chunk-VVMCGF5X.js → chunk-WAVJWGUC.js} +1811 -883
  67. package/dist/bundle/{chunk-FDM3JMQZ.js → chunk-WBYCUBYM.js} +89 -36
  68. package/dist/bundle/{chunk-TIVC4DB5.js → chunk-WJOKTIOJ.js} +2 -2
  69. package/dist/bundle/{chunk-7MVKSPEG.js → chunk-WJPVGXKA.js} +6 -6
  70. package/dist/bundle/{chunk-N4VNUOOD.js → chunk-XGNADVIA.js} +18 -18
  71. package/dist/bundle/{chunk-J6XLM4QW.js → chunk-XJVK7ETL.js} +28 -10
  72. package/dist/bundle/{chunk-3K4H2DTA.js → chunk-YZ6SYLDC.js} +12 -3
  73. package/dist/bundle/command-contract-XIACCAZL.js +35 -0
  74. package/dist/bundle/{decode-3LX3BLZM.js → decode-5MHMPYKE.js} +4 -4
  75. package/dist/bundle/drive.js +6 -6
  76. package/dist/bundle/{echarts-YNGCOYHW.js → echarts-CLB22SZS.js} +2 -2
  77. package/dist/bundle/{embed-FICTRZJL.js → embed-TF66ODAR.js} +5 -5
  78. package/dist/bundle/{embedder-DSMRCRSH.js → embedder-EDWOIAC2.js} +8 -8
  79. package/dist/bundle/{entry-4ZX3BNXK.js → entry-CWYCQ53A.js} +8 -6
  80. package/dist/bundle/{first-run-GRBQ3SQ5.js → first-run-YIH7EHJI.js} +9 -9
  81. package/dist/bundle/first-screen-THH3XD5Y.js +33 -0
  82. package/dist/bundle/{google-QV2B2KZA.js → google-A4F2WFO4.js} +9 -9
  83. package/dist/bundle/{google-api-EVO7F3WB.js → google-api-ZXGQOJUI.js} +51 -51
  84. package/dist/bundle/grants-3Z7DG3W3.js +98 -0
  85. package/dist/bundle/{identity-TKAX75OT.js → identity-4IO7WGG4.js} +4 -4
  86. package/dist/bundle/{instructions-GJHHFV64.js → instructions-BXZZNAMS.js} +1 -1
  87. package/dist/bundle/{login-R2YEAKEM.js → login-A4QHJ5DA.js} +57 -57
  88. package/dist/bundle/{mcp-EMNFFY4N.js → mcp-VVMPUDSL.js} +2 -2
  89. package/dist/bundle/{node-GFOH6FKP.js → node-R6ZNQ3NT.js} +2 -2
  90. package/dist/bundle/{node-sqlite-NZIBED3C.js → node-sqlite-AFQTE4XZ.js} +4 -4
  91. package/dist/bundle/{oauth-WUHT2JII.js → oauth-46XBJBML.js} +6 -6
  92. package/dist/bundle/{open-INBNHORD.js → open-WJCRBIP7.js} +3 -3
  93. package/dist/bundle/{openai-BMREUGJP.js → openai-3TIBDWZA.js} +13 -13
  94. package/dist/bundle/{process-XVDX4SPD.js → process-P36JP33R.js} +1 -1
  95. package/dist/bundle/{program-DUWFQOSL.js → program-AHZH65IT.js} +85 -77
  96. package/dist/bundle/{prompt-S7GHCPGR.js → prompt-FFGBIT4A.js} +4 -4
  97. package/dist/bundle/{reasons-T24V3AYS.js → reasons-VHCVYH54.js} +3 -3
  98. package/dist/bundle/{recognize-T3DABMW5.js → recognize-4EAKIMON.js} +3 -3
  99. package/dist/bundle/{remote-ASYGFT6E.js → remote-HX3JP4EH.js} +6 -6
  100. package/dist/bundle/{rerank-BQ5U252K.js → rerank-BW3A4PUU.js} +6 -6
  101. package/dist/bundle/{serve-JMLNKCUZ.js → serve-YYOOLIBS.js} +8 -8
  102. package/dist/bundle/{server-5E6RC7GZ.js → server-G6XTEEFI.js} +38 -38
  103. package/dist/bundle/server-YKYEUIJT.js +63 -0
  104. package/dist/bundle/{services-NFB3XSON.js → services-OAPILZOW.js} +45 -25
  105. package/dist/bundle/{sqlite-runtime-TAMYMQFR.js → sqlite-runtime-GTXDK4PE.js} +4 -4
  106. package/dist/bundle/{state-DS4G3ZXV.js → state-XG335LGZ.js} +5 -5
  107. package/dist/bundle/{store-MLMKYJLC.js → store-7KOXJNQP.js} +14 -12
  108. package/dist/bundle/{store-HAS2LRFE.js → store-N53SJOPS.js} +33 -15
  109. package/dist/bundle/store-maintenance-command-W3TI52X2.js +52 -0
  110. package/dist/bundle/tokens-P7TEHKDD.js +96 -0
  111. package/dist/commands/knowledge.d.ts.map +1 -1
  112. package/dist/commands/knowledge.js +10 -2
  113. package/dist/commands/knowledge.js.map +1 -1
  114. package/dist/config.d.ts +6 -0
  115. package/dist/config.d.ts.map +1 -1
  116. package/dist/config.js +4 -12
  117. package/dist/config.js.map +1 -1
  118. package/dist/profile-lock.js +2 -2
  119. package/dist/profile-lock.js.map +1 -1
  120. package/dist/reasons.js +1 -1
  121. package/dist/reasons.js.map +1 -1
  122. package/dist/version.d.ts +1 -1
  123. package/dist/version.js +1 -1
  124. package/package.json +3 -3
  125. package/dist/bundle/chunk-3NAVOBGH.js +0 -331
  126. package/dist/bundle/command-contract-VXLGE6NV.js +0 -35
  127. package/dist/bundle/first-screen-JK3MZVCU.js +0 -33
  128. package/dist/bundle/grants-B642KK5M.js +0 -98
  129. package/dist/bundle/server-QI4C3CQT.js +0 -63
  130. package/dist/bundle/store-maintenance-command-LI3JR22B.js +0 -52
  131. package/dist/bundle/tokens-UMSAYGOH.js +0 -96
  132. /package/dist/bundle/{chunk-NPGVOZVK.js → chunk-HPXYN7F3.js} +0 -0
@@ -8,10 +8,10 @@ import {
8
8
  installFiles,
9
9
  megabytes,
10
10
  sharedModelsDirectory
11
- } from "./chunk-67A2YFAT.js";
11
+ } from "./chunk-OZJMZSFB.js";
12
12
  import {
13
13
  CliError
14
- } from "./chunk-TBD362SJ.js";
14
+ } from "./chunk-GIQFBXQN.js";
15
15
  import {
16
16
  importFrom
17
17
  } from "./chunk-Y5E2WNWB.js";
@@ -19,12 +19,12 @@ import {
19
19
  __name
20
20
  } from "./chunk-ZVVMGPBJ.js";
21
21
 
22
- // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
22
+ // node_modules/.pnpm/@wirecat+cli-core@0.546.0_@wirecat+cli-base@0.73.0_commander@15.0.0_esbuild@0.28.2_type_6245070bff0a7c29971e74a96fde145c/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
23
23
  import { readFileSync as readFileSync2 } from "node:fs";
24
24
  import { availableParallelism } from "node:os";
25
25
  import { basename, join as join2 } from "node:path";
26
26
 
27
- // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.546.0_@wirecat+cli-base@0.73.0_commander@15.0.0_esbuild@0.28.2_type_6245070bff0a7c29971e74a96fde145c/node_modules/@wirecat/cli-core/dist/embeddings/onnx-runtime.js
28
28
  import { createHash } from "node:crypto";
29
29
  import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
30
30
  import { join } from "node:path";
@@ -207,7 +207,7 @@ var openSession = /* @__PURE__ */ __name(async (bytes, threads, options = {}) =>
207
207
  return { ort, session: await ort.InferenceSession.create(bytes, options) };
208
208
  }, "openSession");
209
209
 
210
- // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
210
+ // node_modules/.pnpm/@wirecat+cli-core@0.546.0_@wirecat+cli-base@0.73.0_commander@15.0.0_esbuild@0.28.2_type_6245070bff0a7c29971e74a96fde145c/node_modules/@wirecat/cli-core/dist/embeddings/embed.js
211
211
  var textModelsDirectory = /* @__PURE__ */ __name((env = process.env) => sharedModelsDirectory("text", env), "textModelsDirectory");
212
212
  var placedText = /* @__PURE__ */ __name((model, directory) => model.files.map((file) => [file, join2(directory, model.id, file.name)]), "placedText");
213
213
  var isTextModelInstalled = /* @__PURE__ */ __name((model, directory) => filesPresent(placedText(model, directory)), "isTextModelInstalled");
@@ -2,17 +2,17 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  VERSION
5
- } from "./chunk-D6SRTPCV.js";
5
+ } from "./chunk-NLLWLCUZ.js";
6
6
  import {
7
7
  annotate,
8
8
  commandsDocument,
9
9
  describeProgram,
10
10
  flatten,
11
11
  profileFree
12
- } from "./chunk-BO7ZKZCH.js";
12
+ } from "./chunk-4F2VRJZE.js";
13
13
  import {
14
14
  CliError
15
- } from "./chunk-TBD362SJ.js";
15
+ } from "./chunk-GIQFBXQN.js";
16
16
  import {
17
17
  __name
18
18
  } from "./chunk-ZVVMGPBJ.js";
@@ -10,12 +10,12 @@ import {
10
10
  optional,
11
11
  pipe,
12
12
  safeParse
13
- } from "./chunk-TBD362SJ.js";
13
+ } from "./chunk-GIQFBXQN.js";
14
14
  import {
15
15
  __name
16
16
  } from "./chunk-ZVVMGPBJ.js";
17
17
 
18
- // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/models/options.js
18
+ // node_modules/.pnpm/@wirecat+cli-core@0.546.0_@wirecat+cli-base@0.73.0_commander@15.0.0_esbuild@0.28.2_type_6245070bff0a7c29971e74a96fde145c/node_modules/@wirecat/cli-core/dist/models/options.js
19
19
  var checkedOptions = /* @__PURE__ */ __name((provider, schema, options) => {
20
20
  const parsed = safeParse(schema, options);
21
21
  if (!parsed.success) {
@@ -0,0 +1,247 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ activeProfile,
5
+ credentialStorage,
6
+ driveSessionCodec,
7
+ paths,
8
+ tokenKeeper
9
+ } from "./chunk-O5KDIVGE.js";
10
+ import {
11
+ READ_SCOPE,
12
+ WRITE_SCOPE,
13
+ providerRequest
14
+ } from "./chunk-EE7R457T.js";
15
+ import {
16
+ googleError
17
+ } from "./chunk-AKPFH3KC.js";
18
+ import {
19
+ Credentials,
20
+ isMovedRun,
21
+ systemKeyring
22
+ } from "./chunk-XGNADVIA.js";
23
+ import {
24
+ CliError,
25
+ isCliError,
26
+ minLength,
27
+ nullable,
28
+ number,
29
+ object,
30
+ optional,
31
+ pipe,
32
+ safeParse,
33
+ string
34
+ } from "./chunk-GIQFBXQN.js";
35
+ import {
36
+ __name
37
+ } from "./chunk-ZVVMGPBJ.js";
38
+
39
+ // dist/tokens.js
40
+ import { OAuth2Client } from "google-auth-library";
41
+ var Session = object({
42
+ principal: string(),
43
+ clientId: string(),
44
+ clientSecret: optional(string()),
45
+ tokens: object({
46
+ access_token: optional(nullable(string())),
47
+ refresh_token: pipe(string(), minLength(1)),
48
+ expiry_date: optional(nullable(number())),
49
+ scope: optional(string()),
50
+ token_type: optional(nullable(string()))
51
+ })
52
+ });
53
+ var credentialOptions = /* @__PURE__ */ __name((env, storage, keyring) => ({
54
+ configDir: paths(env).config,
55
+ service: "drive-cli",
56
+ // The keyring falls back to the private file by itself (WC-SECR-4); `file` skips the keyring.
57
+ storage: storage === "keyring" ? "auto" : storage,
58
+ env,
59
+ isolated: isMovedRun({ appName: "drive-cli", prefix: "DRIVE", env }),
60
+ ...keyring ? { keyring } : {}
61
+ }), "credentialOptions");
62
+ var credentials = /* @__PURE__ */ __name((env, storage, keyring) => new Credentials(credentialOptions(env, storage, keyring)), "credentials");
63
+ var notSaved = /* @__PURE__ */ __name(() => new CliError("configuration_error", "could not save Google sign-in: the private credentials file cannot be read; move it aside and sign in again", { reason: "sign-in.not-saved" }), "notSaved");
64
+ var saveSession = /* @__PURE__ */ __name((env, name, session, storage, keyring) => {
65
+ try {
66
+ credentials(env, storage, keyring).write(name, JSON.stringify(session));
67
+ } catch {
68
+ throw notSaved();
69
+ }
70
+ }, "saveSession");
71
+ var googleProvider = /* @__PURE__ */ __name((client) => ({
72
+ id: "google",
73
+ name: "Google",
74
+ authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
75
+ tokenUrl: "https://oauth2.googleapis.com/token",
76
+ revokeUrl: "https://oauth2.googleapis.com/revoke",
77
+ client,
78
+ redirect: { kind: "loopback" },
79
+ // Without offline access Google returns no refresh token; without consent it does not return one again.
80
+ authorizeParams: { access_type: "offline", prompt: "select_account consent" }
81
+ }), "googleProvider");
82
+ var sessionKeeper = /* @__PURE__ */ __name((options) => tokenKeeper({
83
+ provider: googleProvider(options.client),
84
+ storage: credentialStorage({
85
+ credentials: { ...credentialOptions(options.env, options.storage), keyring: options.keyring ?? systemKeyring },
86
+ account: options.name,
87
+ codec: driveSessionCodec
88
+ }),
89
+ lockDir: paths(options.env).config,
90
+ fetch: options.fetch ?? globalThis.fetch,
91
+ signInCommand: `drive ${options.name} session start`,
92
+ // Above the client's own 5-minute early refresh, so a token it asks to replace is replaced.
93
+ freshForMs: 6 * 6e4,
94
+ ...options.signal ? { signal: options.signal } : {}
95
+ }), "sessionKeeper");
96
+ var authorizedClient = /* @__PURE__ */ __name((env, name, keyring, signal) => {
97
+ const profile = activeProfile(env, name);
98
+ let parsed;
99
+ try {
100
+ const secret = credentials(env, profile.storage, keyring).read(name)?.secret;
101
+ if (!secret)
102
+ throw new Error("missing login");
103
+ parsed = safeParse(Session, JSON.parse(secret));
104
+ } catch {
105
+ throw new CliError("authentication_error", `could not load Google sign-in \u2014 run drive ${name} session start again`, {
106
+ reason: "sign-in.expired"
107
+ });
108
+ }
109
+ if (!parsed.success || parsed.output.principal !== profile.principal)
110
+ throw new CliError("authentication_error", "saved sign-in is invalid or belongs to another account", {
111
+ reason: "sign-in.expired"
112
+ });
113
+ const session = parsed.output;
114
+ const keeper = sessionKeeper({
115
+ env,
116
+ name,
117
+ storage: profile.storage,
118
+ client: { clientId: session.clientId, ...session.clientSecret ? { clientSecret: session.clientSecret } : {} },
119
+ ...keyring ? { keyring } : {},
120
+ ...signal ? { signal } : {}
121
+ });
122
+ const client = new OAuth2Client({
123
+ clientId: session.clientId,
124
+ clientSecret: session.clientSecret,
125
+ transporterOptions: { timeout: 3e4, ...signal ? { signal } : {} }
126
+ });
127
+ client.refreshHandler = async () => {
128
+ try {
129
+ const tokens = await keeper.tokens();
130
+ if (!tokens.accessToken || tokens.expiresAt === void 0)
131
+ throw new Error("no access token");
132
+ return { access_token: tokens.accessToken, expiry_date: tokens.expiresAt };
133
+ } catch (error) {
134
+ if (isCliError(error) && error.code !== "authentication_error")
135
+ throw error;
136
+ throw new CliError("authentication_error", `Google sign-in expired \u2014 run drive ${name} session start again`, {
137
+ reason: "sign-in.expired"
138
+ });
139
+ }
140
+ };
141
+ const { refresh_token: _refresh, ...current } = session.tokens;
142
+ client.setCredentials(current);
143
+ return observeRequests(client);
144
+ }, "authorizedClient");
145
+ var covers = /* @__PURE__ */ __name((granted, required) => granted.includes(required) || required === READ_SCOPE && granted.includes(WRITE_SCOPE), "covers");
146
+ var grantedScopes = /* @__PURE__ */ __name((env, name, keyring) => {
147
+ try {
148
+ const secret = credentials(env, activeProfile(env, name).storage, keyring).read(name)?.secret;
149
+ const parsed = secret ? safeParse(Session, JSON.parse(secret)) : void 0;
150
+ if (!parsed?.success)
151
+ return [];
152
+ return parsed.output.tokens.scope?.split(/\s+/).filter(Boolean);
153
+ } catch {
154
+ return [];
155
+ }
156
+ }, "grantedScopes");
157
+ var checkAuthorization = /* @__PURE__ */ __name(async (client, required = READ_SCOPE) => {
158
+ try {
159
+ const { token } = await client.getAccessToken();
160
+ if (!token)
161
+ throw new CliError("authentication_error", "Google returned no access token");
162
+ const info = await client.getTokenInfo(token);
163
+ if (!covers(info.scopes, required))
164
+ throw new CliError("permission_error", "sign-in lacks the required permission; run drive <profile> session start --grant write, activity or apps when needed", { reason: "sign-in.scope-missing" });
165
+ } catch (error) {
166
+ throw googleError(error);
167
+ }
168
+ }, "checkAuthorization");
169
+ var WORD = /^[a-z][a-z_]{0,23}$/;
170
+ var VERB = /^[a-z][A-Za-z]{0,31}$/;
171
+ var segment = /* @__PURE__ */ __name((part) => {
172
+ if (/^v\d+$/.test(part) || WORD.test(part))
173
+ return part;
174
+ const verb = part.split(":")[1];
175
+ return verb !== void 0 && VERB.test(verb) ? `:id:${verb}` : ":id";
176
+ }, "segment");
177
+ var operationOf = /* @__PURE__ */ __name((method, url) => {
178
+ let path = "";
179
+ try {
180
+ path = new URL(String(url ?? "")).pathname;
181
+ } catch {
182
+ }
183
+ const template = path.split("/").filter(Boolean).map((part) => segment(decodeURIComponent(part))).join("/");
184
+ return `${(method ?? "GET").toUpperCase()} /${template}`;
185
+ }, "operationOf");
186
+ var reasonOf = /* @__PURE__ */ __name((data) => {
187
+ const error = data?.error;
188
+ const reason = error?.errors?.[0]?.reason ?? error?.status;
189
+ return typeof reason === "string" ? reason : void 0;
190
+ }, "reasonOf");
191
+ var observeRequests = /* @__PURE__ */ __name((client) => {
192
+ const transporter = client.transporter;
193
+ const request = transporter.request.bind(transporter);
194
+ transporter.request = (async (options) => {
195
+ const method = (options.method ?? "GET").toUpperCase();
196
+ const operation = operationOf(method, options.url);
197
+ const call = { method, endpointTemplate: operation.slice(method.length + 1), transport: "http" };
198
+ let ended;
199
+ const adapter = /* @__PURE__ */ __name(async (prepared, next) => {
200
+ const attempt = (prepared.retryConfig?.currentRetryAttempt ?? 0) + 1;
201
+ const waitMs = ended === void 0 ? void 0 : Math.round(performance.now() - ended);
202
+ const answered = providerRequest(operation, void 0, {
203
+ ...call,
204
+ attempt,
205
+ ...waitMs === void 0 ? {} : { waitMs }
206
+ });
207
+ try {
208
+ const response = await (options.adapter ? options.adapter(prepared, next) : next(prepared));
209
+ const failed = !(prepared.validateStatus?.(response.status) ?? response.status < 400);
210
+ const providerError = failed ? reasonOf(response.data) : void 0;
211
+ answered({
212
+ status: response.status,
213
+ ...failed ? { errorCode: "provider_error" } : {},
214
+ ...providerError ? { providerError } : {}
215
+ });
216
+ return response;
217
+ } catch (error) {
218
+ answered({ error, errorCode: googleError(error).code });
219
+ throw error;
220
+ } finally {
221
+ ended = performance.now();
222
+ }
223
+ }, "adapter");
224
+ try {
225
+ return await request({ ...options, adapter });
226
+ } catch (error) {
227
+ if (ended === void 0)
228
+ providerRequest(operation, void 0, { ...call, attempt: 1 })({ error, errorCode: googleError(error).code });
229
+ throw error;
230
+ }
231
+ });
232
+ return client;
233
+ }, "observeRequests");
234
+
235
+ export {
236
+ credentials,
237
+ notSaved,
238
+ saveSession,
239
+ googleProvider,
240
+ sessionKeeper,
241
+ authorizedClient,
242
+ covers,
243
+ grantedScopes,
244
+ checkAuthorization,
245
+ operationOf,
246
+ observeRequests
247
+ };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.507.0_@wirecat+cli-base@0.68.1_commander@15.0.0_esbuild@0.28.2_type_d5beb0101c7a90701cc33879a5be8d28/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/shared-55XJMTPA.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.546.0_@wirecat+cli-base@0.73.0_commander@15.0.0_esbuild@0.28.2_type_6245070bff0a7c29971e74a96fde145c/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/shared-55XJMTPA.js
8
8
  var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
9
9
  var kindsByConstructor = /* @__PURE__ */ new WeakMap();
10
10
  function collectKinds(ctor) {
@@ -2,10 +2,10 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  REASONS
5
- } from "./chunk-2OGANEKA.js";
5
+ } from "./chunk-CD736BG3.js";
6
6
 
7
7
  // dist/version.js
8
- var VERSION = "0.55.0";
8
+ var VERSION = "0.57.0";
9
9
 
10
10
  // dist/identity.js
11
11
  var PACKAGE = "@wirecat/drive-cli";