@wirecat/drive-cli 0.52.0 → 0.53.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 (194) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bin/drive.js.map +1 -1
  4. package/dist/bundle/{chunk-ZWSG7OCA.js → all-profiles-WRN35CUF.js} +11 -6
  5. package/dist/bundle/{anthropic-KW6KU36Y.js → anthropic-DZASXWG3.js} +1 -1
  6. package/dist/bundle/{app-server-TCJZ333E.js → app-server-4VHT7QZN.js} +33 -41
  7. package/dist/bundle/{bun-sqlite-RI7DR6RZ.js → bun-sqlite-2GOM5PM3.js} +1 -1
  8. package/dist/bundle/{chunk-LONV6HIK.js → chunk-2HHOMN2G.js} +440 -25
  9. package/dist/bundle/{chunk-4A2PIGC6.js → chunk-2PVDFLJJ.js} +8 -3
  10. package/dist/bundle/{chunk-725OHXKR.js → chunk-3RYX7IB6.js} +2218 -30
  11. package/dist/bundle/{chunk-CB7SBYLO.js → chunk-54BYJQ77.js} +41 -21
  12. package/dist/bundle/{chunk-5FONRUG6.js → chunk-5D4AEUVA.js} +1 -23
  13. package/dist/bundle/{chunk-RNSP57TC.js → chunk-6BNALDGA.js} +1 -1
  14. package/dist/bundle/{chunk-H47W2J6S.js → chunk-6XYGTRMQ.js} +812 -381
  15. package/dist/bundle/{chunk-UR32UWTQ.js → chunk-7IUMHMTP.js} +11 -0
  16. package/dist/bundle/{chunk-W7IK7E4B.js → chunk-BEL4XZ3M.js} +5 -7
  17. package/dist/bundle/{chunk-43QVYW3K.js → chunk-CL4GVCXS.js} +230 -56
  18. package/dist/bundle/{chunk-PQYVPCJ2.js → chunk-CNKILAWA.js} +18 -24
  19. package/dist/bundle/chunk-DOZOLBXE.js +110 -0
  20. package/dist/bundle/{chunk-2AUXBJRX.js → chunk-DT2YCB2V.js} +84 -11
  21. package/dist/bundle/{chunk-HQVJK5E7.js → chunk-DZMK255Y.js} +210 -357
  22. package/dist/bundle/{chunk-G6QF5KWF.js → chunk-E6XDFMRZ.js} +22 -28
  23. package/dist/bundle/{chunk-DW46P2DY.js → chunk-EKFEY3KP.js} +1 -1
  24. package/dist/bundle/{chunk-54O62JWP.js → chunk-F3KHUJEE.js} +24 -5
  25. package/dist/bundle/{chunk-I7UH5CTA.js → chunk-FXWBUTR7.js} +7 -9
  26. package/dist/bundle/{chunk-ZNZUZGSV.js → chunk-GE4DP24O.js} +131 -4
  27. package/dist/bundle/{chunk-PEOCBV2Z.js → chunk-GPJEYW2J.js} +1 -1
  28. package/dist/bundle/{chunk-A4UNTWAX.js → chunk-HM352LJR.js} +84 -15
  29. package/dist/bundle/{chunk-KYVXMEBC.js → chunk-IAQ4L6SM.js} +1 -1
  30. package/dist/bundle/{chunk-PQJYM5ES.js → chunk-IJFZKQC4.js} +1 -1
  31. package/dist/bundle/{chunk-O6IOL6RX.js → chunk-KPBCGUJC.js} +1 -1
  32. package/dist/bundle/{chunk-XOLQSCMF.js → chunk-KXMJE3XC.js} +2 -2
  33. package/dist/bundle/{chunk-33NVQGUY.js → chunk-LSGAJYVN.js} +2 -2
  34. package/dist/bundle/{chunk-2UIMEMWU.js → chunk-MK3N7WX7.js} +1 -1
  35. package/dist/bundle/{chunk-IDUNJCFO.js → chunk-OQMK6WXQ.js} +1 -1
  36. package/dist/bundle/{chunk-CM7GAXGD.js → chunk-PC4UA6UN.js} +1 -1
  37. package/dist/bundle/{chunk-YNFELLNQ.js → chunk-PIMMF67N.js} +2 -2
  38. package/dist/bundle/{chunk-WBTVGFXI.js → chunk-PR3DA7KA.js} +9 -9
  39. package/dist/bundle/{chunk-VJZST5RD.js → chunk-QXYGK6G5.js} +1 -1
  40. package/dist/bundle/{chunk-WQJBAWQP.js → chunk-R4TE4ZSD.js} +549 -224
  41. package/dist/bundle/{chunk-BSSCTWWK.js → chunk-RNIHKIQP.js} +1 -1
  42. package/dist/bundle/{chunk-PAXKALHV.js → chunk-SIWBUGBU.js} +116 -5
  43. package/dist/bundle/{chunk-2623YE5I.js → chunk-SQHPJBNO.js} +6 -8
  44. package/dist/bundle/chunk-SVTYS36O.js +5305 -0
  45. package/dist/bundle/{chunk-WLFUBNFX.js → chunk-T334CFU4.js} +2 -2
  46. package/dist/bundle/{chunk-UC22Q5KU.js → chunk-TZLO3ZZF.js} +16 -16
  47. package/dist/bundle/{chunk-5PLJKSG4.js → chunk-UFWK3L5Z.js} +4 -6
  48. package/dist/bundle/{chunk-FCJAHD4R.js → chunk-VTWADVEQ.js} +2 -2
  49. package/dist/bundle/{chunk-HX7Y2ASG.js → chunk-WJRJBQIM.js} +26040 -15126
  50. package/dist/bundle/{chunk-VSOLLTYT.js → chunk-YLKQSVLI.js} +5 -0
  51. package/dist/bundle/{chunk-IWFBAWZK.js → chunk-YQOVVCIA.js} +282 -10
  52. package/dist/bundle/{chunk-7YMDL4JQ.js → chunk-ZG6X24ON.js} +4 -1
  53. package/dist/bundle/{command-contract-I2YB5IXI.js → command-contract-D4UG3D33.js} +12 -15
  54. package/dist/bundle/{decode-EDN2ARXZ.js → decode-WAPM2VBH.js} +1 -1
  55. package/dist/bundle/drive.js +10 -21
  56. package/dist/bundle/{embed-3GSQIQXE.js → embed-HW3N3KNP.js} +4 -4
  57. package/dist/bundle/{embedder-6ULWRG3R.js → embedder-7WNFXYYP.js} +4 -4
  58. package/dist/bundle/{entry-IPRJLFHO.js → entry-J7YIRDPD.js} +4 -4
  59. package/dist/bundle/{first-run-FGHGWHC2.js → first-run-53CL2IYH.js} +6 -6
  60. package/dist/bundle/{first-screen-M62KTPZG.js → first-screen-2KT7HM2K.js} +13 -16
  61. package/dist/bundle/{google-BD3ZNFVJ.js → google-5NNVARNR.js} +2 -2
  62. package/dist/bundle/{chunk-GR5GGZKH.js → google-api-EQQH53QD.js} +60 -4
  63. package/dist/bundle/grants-4NETZ4MR.js +98 -0
  64. package/dist/bundle/{identity-QLBSASO5.js → identity-LBTXDMTA.js} +4 -2
  65. package/dist/bundle/{login-VNZKRSAD.js → login-Y6ENYKC3.js} +50 -52
  66. package/dist/bundle/{node-sqlite-J3OODPYK.js → node-sqlite-FSQIKGED.js} +1 -1
  67. package/dist/bundle/{oauth-L4VTCBLF.js → oauth-HF5USWXY.js} +5 -5
  68. package/dist/bundle/{open-SGUN7ZVF.js → open-NHGJENCX.js} +2 -2
  69. package/dist/bundle/{openai-RLVISEDH.js → openai-3JCJYKNX.js} +6 -6
  70. package/dist/bundle/{program-6S5EH7BS.js → program-QAJ66K3Z.js} +715 -904
  71. package/dist/bundle/{prompt-AUWTBLO7.js → prompt-LQJBCCUF.js} +3 -3
  72. package/dist/bundle/{reasons-M5AKCNCU.js → reasons-J57GSRWN.js} +1 -1
  73. package/dist/bundle/{recognize-ORX2UBQW.js → recognize-QM3LN4ZF.js} +1 -1
  74. package/dist/bundle/{remote-AGIJY73X.js → remote-WREGEZJQ.js} +5 -5
  75. package/dist/bundle/{rerank-R6PE44M5.js → rerank-YFUB6J6M.js} +4 -4
  76. package/dist/bundle/{chunk-G7DCVJ4F.js → serve-7NFEZ564.js} +7 -4
  77. package/dist/bundle/{chunk-F7UUZATI.js → server-KBCFZ2AU.js} +38 -11
  78. package/dist/bundle/server-UYVL2CFI.js +63 -0
  79. package/dist/bundle/{services-HZFTTZSF.js → services-C3XWRA2W.js} +16 -21
  80. package/dist/bundle/{sqlite-runtime-DTGPR2T2.js → sqlite-runtime-H3TSAMIN.js} +3 -3
  81. package/dist/bundle/{state-WG3JKJM3.js → state-S2Q53L6L.js} +3 -3
  82. package/dist/bundle/{store-33VHIMEO.js → store-H345VQHP.js} +6 -8
  83. package/dist/bundle/{store-EV72MT5U.js → store-I27LAJPU.js} +7 -9
  84. package/dist/bundle/store-maintenance-command-3XA73XMC.js +52 -0
  85. package/dist/bundle/{chunk-GNI7INK6.js → terminal-DHJ4D3BC.js} +2 -3
  86. package/dist/bundle/tokens-7MUGKFEM.js +96 -0
  87. package/dist/commands/context.d.ts +14 -13
  88. package/dist/commands/context.d.ts.map +1 -1
  89. package/dist/commands/context.js.map +1 -1
  90. package/dist/commands/documents.d.ts.map +1 -1
  91. package/dist/commands/documents.js +1 -4
  92. package/dist/commands/documents.js.map +1 -1
  93. package/dist/commands/mirrors.d.ts.map +1 -1
  94. package/dist/commands/mirrors.js +1 -2
  95. package/dist/commands/mirrors.js.map +1 -1
  96. package/dist/commands/session.d.ts.map +1 -1
  97. package/dist/commands/session.js +2 -1
  98. package/dist/commands/session.js.map +1 -1
  99. package/dist/commands/upgrade.d.ts +1 -1
  100. package/dist/commands/upgrade.d.ts.map +1 -1
  101. package/dist/commands/upgrade.js +4 -9
  102. package/dist/commands/upgrade.js.map +1 -1
  103. package/dist/config.d.ts +182 -0
  104. package/dist/config.d.ts.map +1 -1
  105. package/dist/config.js +38 -3
  106. package/dist/config.js.map +1 -1
  107. package/dist/contract-overrides.d.ts +0 -3
  108. package/dist/contract-overrides.d.ts.map +1 -1
  109. package/dist/contract-overrides.js +0 -234
  110. package/dist/contract-overrides.js.map +1 -1
  111. package/dist/first-screen.d.ts +3 -2
  112. package/dist/first-screen.d.ts.map +1 -1
  113. package/dist/first-screen.js +17 -22
  114. package/dist/first-screen.js.map +1 -1
  115. package/dist/grants.d.ts +9 -0
  116. package/dist/grants.d.ts.map +1 -0
  117. package/dist/grants.js +30 -0
  118. package/dist/grants.js.map +1 -0
  119. package/dist/identity.d.ts.map +1 -1
  120. package/dist/identity.js +2 -0
  121. package/dist/identity.js.map +1 -1
  122. package/dist/login.d.ts.map +1 -1
  123. package/dist/login.js +7 -3
  124. package/dist/login.js.map +1 -1
  125. package/dist/policy-keys.d.ts +12 -0
  126. package/dist/policy-keys.d.ts.map +1 -0
  127. package/dist/policy-keys.js +107 -0
  128. package/dist/policy-keys.js.map +1 -0
  129. package/dist/policy.d.ts +1 -8
  130. package/dist/policy.d.ts.map +1 -1
  131. package/dist/policy.js +2 -105
  132. package/dist/policy.js.map +1 -1
  133. package/dist/program.d.ts +8 -4
  134. package/dist/program.d.ts.map +1 -1
  135. package/dist/program.js +251 -222
  136. package/dist/program.js.map +1 -1
  137. package/dist/reasons.js +1 -1
  138. package/dist/reasons.js.map +1 -1
  139. package/dist/testing/mcp.d.ts +28 -0
  140. package/dist/testing/mcp.d.ts.map +1 -0
  141. package/dist/testing/mcp.js +56 -0
  142. package/dist/testing/mcp.js.map +1 -0
  143. package/dist/tokens.d.ts +0 -2
  144. package/dist/tokens.d.ts.map +1 -1
  145. package/dist/tokens.js +12 -13
  146. package/dist/tokens.js.map +1 -1
  147. package/dist/version.d.ts +1 -1
  148. package/dist/version.js +1 -1
  149. package/package.json +4 -3
  150. package/scenarios/agent-access.md +4 -2
  151. package/dist/bundle/all-profiles-CYW6XBBS.js +0 -26
  152. package/dist/bundle/chunk-234MHU76.js +0 -384
  153. package/dist/bundle/chunk-4CPLOMRK.js +0 -1714
  154. package/dist/bundle/chunk-4Z6TCU5T.js +0 -9
  155. package/dist/bundle/chunk-DO4PDQY5.js +0 -48
  156. package/dist/bundle/chunk-FDWYPONW.js +0 -1988
  157. package/dist/bundle/chunk-FQRJWVEB.js +0 -2
  158. package/dist/bundle/chunk-NPSZPUK6.js +0 -193
  159. package/dist/bundle/chunk-PDGECM5D.js +0 -138
  160. package/dist/bundle/chunk-Q765VPZY.js +0 -421
  161. package/dist/bundle/chunk-WQRGA75U.js +0 -256
  162. package/dist/bundle/chunk-X6ID5EAR.js +0 -522
  163. package/dist/bundle/chunk-YVPHJHIL.js +0 -15572
  164. package/dist/bundle/chunk-Z47LOJUS.js +0 -484
  165. package/dist/bundle/failure-4CVEVY45.js +0 -37
  166. package/dist/bundle/google-api-BDUWZMRV.js +0 -83
  167. package/dist/bundle/mcp-5SNSMI2M.js +0 -502
  168. package/dist/bundle/mcp-JZSYPQA4.js +0 -96
  169. package/dist/bundle/serve-VOBAQHAQ.js +0 -20
  170. package/dist/bundle/server-24PS4M7U.js +0 -70
  171. package/dist/bundle/server-G6HFZ2CK.js +0 -57
  172. package/dist/bundle/store-maintenance-command-ZTUEI4EC.js +0 -58
  173. package/dist/bundle/terminal-TFCTWLOS.js +0 -11
  174. package/dist/bundle/tokens-XDQXUFDQ.js +0 -104
  175. package/dist/commands/doctor.d.ts +0 -56
  176. package/dist/commands/doctor.d.ts.map +0 -1
  177. package/dist/commands/doctor.js +0 -75
  178. package/dist/commands/doctor.js.map +0 -1
  179. package/dist/commands/mcp.d.ts +0 -6
  180. package/dist/commands/mcp.d.ts.map +0 -1
  181. package/dist/commands/mcp.js +0 -156
  182. package/dist/commands/mcp.js.map +0 -1
  183. package/dist/commands/skill.d.ts +0 -6
  184. package/dist/commands/skill.d.ts.map +0 -1
  185. package/dist/commands/skill.js +0 -34
  186. package/dist/commands/skill.js.map +0 -1
  187. package/dist/failure.d.ts +0 -88
  188. package/dist/failure.d.ts.map +0 -1
  189. package/dist/failure.js +0 -60
  190. package/dist/failure.js.map +0 -1
  191. package/dist/mcp.d.ts +0 -175
  192. package/dist/mcp.d.ts.map +0 -1
  193. package/dist/mcp.js +0 -412
  194. package/dist/mcp.js.map +0 -1
@@ -1,522 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- fileId,
5
- inspectConfig,
6
- paths,
7
- profileName,
8
- refusal
9
- } from "./chunk-PAXKALHV.js";
10
- import {
11
- operations
12
- } from "./chunk-YVPHJHIL.js";
13
- import {
14
- DRIVE_APP
15
- } from "./chunk-4A2PIGC6.js";
16
- import {
17
- VERSION
18
- } from "./chunk-4Z6TCU5T.js";
19
- import {
20
- RecipientList,
21
- SendJournal,
22
- sendGuard
23
- } from "./chunk-CB7SBYLO.js";
24
- import {
25
- newOperationId
26
- } from "./chunk-H47W2J6S.js";
27
- import {
28
- profileFree
29
- } from "./chunk-FDWYPONW.js";
30
- import {
31
- annotate,
32
- commandsDocument,
33
- describeProgram,
34
- flatten
35
- } from "./chunk-725OHXKR.js";
36
- import {
37
- guardedWrite
38
- } from "./chunk-LONV6HIK.js";
39
- import {
40
- CEILING_KEY,
41
- LEVELS,
42
- layerPermissions,
43
- levelFor
44
- } from "./chunk-Q765VPZY.js";
45
- import {
46
- setupPermissionCeiling
47
- } from "./chunk-WLFUBNFX.js";
48
- import {
49
- readOnlyLockOf,
50
- readOnlyRefusal
51
- } from "./chunk-ZDLIO76S.js";
52
- import {
53
- writeSecurely
54
- } from "./chunk-HQVJK5E7.js";
55
- import {
56
- CliError,
57
- array,
58
- boolean,
59
- integer,
60
- literal,
61
- minValue,
62
- number,
63
- object,
64
- optional,
65
- picklist,
66
- pipe,
67
- record,
68
- regex,
69
- safeParse,
70
- string,
71
- unknown,
72
- writes
73
- } from "./chunk-YKZ4IPLB.js";
74
- import {
75
- __name
76
- } from "./chunk-ZVVMGPBJ.js";
77
-
78
- // dist/state.js
79
- import { mkdirSync, readFileSync, unlinkSync } from "node:fs";
80
- import { join } from "node:path";
81
- var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
82
- var User = object({ id: optional(string()), email: optional(string()), name: optional(string()) });
83
- var File = object({
84
- id: ID,
85
- name: string(),
86
- mime: string(),
87
- parents: array(ID),
88
- version: optional(string()),
89
- modifiedAt: optional(string()),
90
- url: string(),
91
- trashed: boolean(),
92
- canDownload: boolean(),
93
- size: optional(number()),
94
- createdAt: optional(string()),
95
- description: optional(string()),
96
- driveId: optional(string()),
97
- owners: optional(array(User)),
98
- lastModifiedBy: optional(User),
99
- providerMetadata: optional(unknown())
100
- });
101
- var Skip = object({
102
- id: ID,
103
- reason: string(),
104
- file: optional(File),
105
- textLimit: optional(number()),
106
- storeRefusedIn: optional(string())
107
- });
108
- var State = object({
109
- version: literal(1),
110
- store: optional(string()),
111
- linkedThrough: optional(string()),
112
- linksPending: optional(boolean()),
113
- linksVersion: optional(pipe(number(), integer(), minValue(1))),
114
- principal: string(),
115
- scope: string(),
116
- cursor: optional(string()),
117
- folders: record(ID, File),
118
- documents: record(ID, object({
119
- metadata: File,
120
- hash: string(),
121
- reference: string(),
122
- tabs: number(),
123
- notRead: optional(string()),
124
- picture: optional(picklist(["saved", "too-large"]))
125
- })),
126
- skipped: array(Skip),
127
- lastSync: optional(string()),
128
- pending: optional(object({
129
- cursor: string(),
130
- scope: string(),
131
- folders: record(ID, File),
132
- jobs: array(object({ id: ID, kind: picklist(["save", "remove"]), file: optional(File) })),
133
- skipped: array(Skip)
134
- }))
135
- });
136
- var Walk = object({
137
- scope: string(),
138
- cursor: string(),
139
- stack: array(object({ id: ID, ancestry: array(ID), folder: optional(File) })),
140
- visited: array(ID),
141
- folders: record(ID, File),
142
- files: array(File),
143
- discovered: number()
144
- });
145
- var profileDir = /* @__PURE__ */ __name((env, name) => join(paths(env).state, "profiles", profileName(name)), "profileDir");
146
- var statePath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "state.json"), "statePath");
147
- var readState = /* @__PURE__ */ __name((env, name, principal) => {
148
- let value;
149
- try {
150
- value = JSON.parse(readFileSync(statePath(env, name), "utf8"));
151
- } catch (error) {
152
- if (error.code === "ENOENT")
153
- return { version: 1, principal, scope: "", folders: {}, documents: {}, skipped: [] };
154
- throw new CliError("configuration_error", "sync state is unreadable; refusing to reset its checkpoint", {
155
- reason: "state.invalid"
156
- });
157
- }
158
- const parsed = safeParse(State, value);
159
- if (!parsed.success || parsed.output.principal !== principal)
160
- throw new CliError("configuration_error", "sync state is invalid or belongs to another Google account", {
161
- reason: "state.invalid"
162
- });
163
- return parsed.output;
164
- }, "readState");
165
- var saveState = /* @__PURE__ */ __name((env, name, state) => {
166
- writeSecurely(statePath(env, name), `${JSON.stringify(state)}
167
- `, 384);
168
- }, "saveState");
169
- var walkPath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "walk.json"), "walkPath");
170
- var readWalk = /* @__PURE__ */ __name((env, name, scope) => {
171
- try {
172
- const parsed = safeParse(Walk, JSON.parse(readFileSync(walkPath(env, name), "utf8")));
173
- return parsed.success && parsed.output.scope === scope ? parsed.output : void 0;
174
- } catch {
175
- return void 0;
176
- }
177
- }, "readWalk");
178
- var saveWalk = /* @__PURE__ */ __name((env, name, walk) => {
179
- writeSecurely(walkPath(env, name), `${JSON.stringify(walk)}
180
- `, 384);
181
- }, "saveWalk");
182
- var removeWalk = /* @__PURE__ */ __name((env, name) => {
183
- try {
184
- unlinkSync(walkPath(env, name));
185
- } catch (error) {
186
- if (error.code !== "ENOENT")
187
- throw error;
188
- }
189
- }, "removeWalk");
190
- var ensureProfileDir = /* @__PURE__ */ __name((env, name) => {
191
- mkdirSync(profileDir(env, name), { recursive: true, mode: 448 });
192
- }, "ensureProfileDir");
193
- var snapshotPath = /* @__PURE__ */ __name((env, name, id) => join(profileDir(env, name), "documents", `${fileId(id)}.json`), "snapshotPath");
194
- var saveSnapshot = /* @__PURE__ */ __name((env, name, content) => {
195
- const path = snapshotPath(env, name, content.metadata.id);
196
- writeSecurely(path, `${JSON.stringify(content)}
197
- `, 384);
198
- writeSecurely(path.replace(/\.json$/, ".md"), content.markdown, 384);
199
- }, "saveSnapshot");
200
- var removeSnapshot = /* @__PURE__ */ __name((env, name, id) => {
201
- const path = snapshotPath(env, name, id);
202
- for (const file of [path, path.replace(/\.json$/, ".md")]) {
203
- try {
204
- unlinkSync(file);
205
- } catch (error) {
206
- if (error.code !== "ENOENT")
207
- throw error;
208
- }
209
- }
210
- }, "removeSnapshot");
211
- var readSnapshot = /* @__PURE__ */ __name((env, name, id) => {
212
- try {
213
- return JSON.parse(readFileSync(snapshotPath(env, name, id), "utf8"));
214
- } catch {
215
- throw new CliError("not_found", "source snapshot is unavailable \u2014 run drive <profile> sync --rescan", {
216
- reason: "state.snapshot-missing"
217
- });
218
- }
219
- }, "readSnapshot");
220
- var profileSetTokenFile = /* @__PURE__ */ __name((env, option) => join(paths(env).state, `mcp-http-${option}.json`), "profileSetTokenFile");
221
- var httpTokenFile = /* @__PURE__ */ __name((env, profile) => join(profileDir(env, profile), "mcp-http.json"), "httpTokenFile");
222
- var profileSetLabel = /* @__PURE__ */ __name(({ option, profiles }) => {
223
- const names = profiles().join(", ");
224
- if (option === "all")
225
- return `every profile (${names || "none yet"})`;
226
- return profiles().length === 1 ? `profile ${names}` : `profiles ${names}`;
227
- }, "profileSetLabel");
228
-
229
- // dist/registry.js
230
- var ACCOUNT_FREE_COMMANDS = /* @__PURE__ */ new Set([
231
- "commands",
232
- "commands info",
233
- "models list",
234
- "complete",
235
- "doctor",
236
- "upgrade",
237
- "api show",
238
- "api list",
239
- "help",
240
- "guide",
241
- "skill show",
242
- "skill install",
243
- "skill status",
244
- "models download",
245
- "images models download",
246
- "runs list",
247
- "runs show",
248
- "runs path"
249
- ]);
250
- var PROFILE_SET_COMMANDS = /* @__PURE__ */ new Set([
251
- "mcp serve",
252
- "mcp revoke",
253
- "mcp server start",
254
- "mcp server stop",
255
- "mcp server status"
256
- ]);
257
- var ANY_PROFILE_COMMANDS = /* @__PURE__ */ new Set([
258
- "commands",
259
- "commands info",
260
- "complete",
261
- "config show",
262
- "session list",
263
- "store info"
264
- ]);
265
- var PROFILE_FREE_COMMANDS = /* @__PURE__ */ new Set([...ACCOUNT_FREE_COMMANDS, ...ANY_PROFILE_COMMANDS]);
266
- var GOOGLE_READ = { remote: "read", local: "none" };
267
- var GOOGLE_WRITE = { remote: "write", local: "none" };
268
- var examples = /* @__PURE__ */ __name((command, lines) => annotate(command, { examples: lines }), "examples");
269
- var CONTRACT = 4;
270
- var isProfileFree = /* @__PURE__ */ __name((info) => PROFILE_FREE_COMMANDS.has(info.path.join(" ")) || info.commands.length > 0 && info.commands.every(isProfileFree), "isProfileFree");
271
- var markProfileFree = /* @__PURE__ */ __name((program) => {
272
- for (const info of flatten(describeProgram(program))) {
273
- if (!isProfileFree(info))
274
- continue;
275
- let command = program;
276
- for (const word of info.path)
277
- command = command.commands.find((one) => one.name() === word) ?? command;
278
- profileFree(command);
279
- }
280
- }, "markProfileFree");
281
- var describeDriveProgram = /* @__PURE__ */ __name((program) => {
282
- const scoped = /* @__PURE__ */ __name((info) => ({
283
- ...info,
284
- usage: isProfileFree(info) ? info.usage : info.usage.replace(/^drive /, "drive <profile> "),
285
- commands: info.commands.map(scoped)
286
- }), "scoped");
287
- return describeProgram(program).map(scoped);
288
- }, "describeDriveProgram");
289
- var commandsDocument2 = /* @__PURE__ */ __name((program, path = []) => {
290
- const all = describeDriveProgram(program);
291
- const inherited = [];
292
- let available = all;
293
- let found;
294
- for (const word of path) {
295
- if (found?.options.length)
296
- inherited.push({ path: [...found.path], options: [...found.options] });
297
- found = available.find((command) => command.name === word);
298
- if (!found)
299
- throw new CliError("not_found", "command path was not found");
300
- available = [...found.commands];
301
- }
302
- return {
303
- ...commandsDocument(program, { cli: "drive", version: VERSION, contract: CONTRACT }),
304
- ...found ? { scope: [...found.path], inherited_options: inherited } : {},
305
- commands: found ? [found] : all
306
- };
307
- }, "commandsDocument");
308
-
309
- // dist/policy.js
310
- import { join as join2 } from "node:path";
311
- var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
312
- var overridesOf = /* @__PURE__ */ __name((entries = []) => {
313
- const levels = {};
314
- for (const entry of entries) {
315
- const [key = "", level = "", extra] = entry.split("=");
316
- if (!/^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/.test(key) || !LEVELS.includes(level) || extra)
317
- throw new CliError("validation_error", "--permission takes a command path and level, e.g. files.trash=deny (deny, readonly, ask, allow)");
318
- levels[key] = level;
319
- }
320
- return levels;
321
- }, "overridesOf");
322
- var permissionKeys = /* @__PURE__ */ __name((paths2) => {
323
- const keys = /* @__PURE__ */ new Set([
324
- "mcp.authority",
325
- "mcp",
326
- "sheets.create",
327
- "sheets.rename",
328
- "sheets.insert",
329
- "sheets.format",
330
- "sheets.update"
331
- ]);
332
- for (const path of paths2)
333
- keys.add(path.join("."));
334
- for (const operation of operations)
335
- for (const key of methodPolicyKeys(operation.id))
336
- keys.add(key);
337
- return keys;
338
- }, "permissionKeys");
339
- var permissionNames = /* @__PURE__ */ __name((keys) => {
340
- const names = /* @__PURE__ */ new Set();
341
- for (const key of keys) {
342
- const parts = key.split(".");
343
- for (let end = 1; end <= parts.length; end++)
344
- names.add(parts.slice(0, end).join("."));
345
- }
346
- return names;
347
- }, "permissionNames");
348
- var policySettings = /* @__PURE__ */ __name((env, profile, flags = {}) => {
349
- const keys = flags.permissionKeys;
350
- const names = keys && permissionNames(keys);
351
- const { config, issues } = inspectConfig(env, names);
352
- const [first] = issues;
353
- if (first)
354
- throw first.kind === "unknown_permission" ? new CliError("configuration_error", refusal(issues).message, {
355
- reason: "policy.unknown-key",
356
- permission: first.key?.slice("permissions.".length)
357
- }) : refusal(issues);
358
- const own = config.profiles[profile];
359
- const overrides = overridesOf(flags.permission);
360
- if (names) {
361
- for (const key of Object.keys(overrides))
362
- if (!names.has(key))
363
- throw new CliError("validation_error", `--permission names ${key}, which is no drive command; see drive commands`, {
364
- reason: "policy.unknown-key",
365
- permission: key
366
- });
367
- }
368
- const saved = layerPermissions([
369
- ["profile", own?.permissions],
370
- ["defaults", config.defaults?.permissions]
371
- ]).levels;
372
- for (const [key, level] of Object.entries(overrides)) {
373
- const under = [...Object.keys(saved), ...Object.keys(defaults)].filter((named) => named.startsWith(`${key}.`));
374
- const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(saved, named, defaults).level]);
375
- if (lifted !== void 0)
376
- throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(saved, lifted, defaults).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { reason: "policy.flag-loosens", permission: lifted });
377
- }
378
- const { levels } = layerPermissions([
379
- ["flags", overrides],
380
- ["profile", own?.permissions],
381
- ["defaults", config.defaults?.permissions]
382
- ]);
383
- const lock = readOnlyLockOf(DRIVE_APP, env);
384
- const ceiling = setupPermissionCeiling(env);
385
- return {
386
- levels: ceiling ? { ...levels, [CEILING_KEY]: ceiling } : levels,
387
- lock,
388
- readOnly: lock !== void 0 || ceiling === "readonly" || flags.readOnly === true
389
- };
390
- }, "policySettings");
391
- var defaults = {
392
- "mcp.authority": "deny",
393
- ...Object.fromEntries(operations.filter((op) => op.effect === "destructive").map((op) => [`api.${op.id}`, "ask"]))
394
- };
395
- var methodPolicyKeys = /* @__PURE__ */ __name((method, body) => {
396
- const parts = method.split(".");
397
- const verb = parts.at(-1);
398
- const alias = method.startsWith("drive.files.") ? `files.${verb}` : method.startsWith("docs.documents.") ? `documents.${verb === "batchUpdate" ? "update" : verb}` : method.startsWith("sheets.spreadsheets.") ? `sheets.${method === "sheets.spreadsheets.get" ? "info" : method === "sheets.spreadsheets.values.get" ? "show" : verb === "append" ? "add" : verb}` : method === "driveactivity.activity.query" ? "documents.history" : method.startsWith("drive.") ? `${parts[1]}.${verb}` : void 0;
399
- const keys = [`api.${method}`, ...alias ? [alias] : []];
400
- if (method === "drive.replies.create" && body)
401
- keys.push(body.action === "resolve" ? "comments.resolve" : body.action === "reopen" ? "comments.reopen" : "comments.reply");
402
- if (method === "drive.replies.create" && body?.content !== void 0)
403
- keys.push("comments.reply");
404
- if (method === "sheets.spreadsheets.batchUpdate" && Array.isArray(body?.requests)) {
405
- const object2 = /* @__PURE__ */ __name((value) => !!value && typeof value === "object" && !Array.isArray(value), "object");
406
- for (const request of body.requests) {
407
- if (!object2(request))
408
- continue;
409
- if (request.addSheet || request.duplicateSheet)
410
- keys.push("sheets.create");
411
- if (object2(request.updateSheetProperties)) {
412
- const update = request.updateSheetProperties;
413
- if (object2(update.properties) && update.properties.title !== void 0 || String(update.fields).split(",").some((field) => field.trim() === "title" || field.trim() === "*"))
414
- keys.push("sheets.rename");
415
- if (object2(update.properties) && update.properties.gridProperties)
416
- keys.push("sheets.insert");
417
- }
418
- if (request.insertDimension || request.appendDimension || request.insertRange)
419
- keys.push("sheets.insert");
420
- if (request.repeatCell || request.updateCells || request.appendCells || request.updateBorders || request.addConditionalFormatRule || request.updateConditionalFormatRule || request.deleteConditionalFormatRule || request.addBanding || request.updateBanding || request.deleteBanding)
421
- keys.push("sheets.format");
422
- if (request.updateCells || request.appendCells || request.findReplace || request.pasteData || request.copyPaste || request.cutPaste || request.autoFill)
423
- keys.push("sheets.update");
424
- if (request.pasteData || request.copyPaste || request.cutPaste || request.autoFill)
425
- keys.push("sheets.format");
426
- if (object2(request.repeatCell) && (String(request.repeatCell.fields).split(",").some((field) => field.trim() === "*" || field.includes("userEnteredValue")) || object2(request.repeatCell.cell) && request.repeatCell.cell.userEnteredValue !== void 0))
427
- keys.push("sheets.update");
428
- }
429
- }
430
- return [...new Set(keys)];
431
- }, "methodPolicyKeys");
432
- var refuseUnderReadOnly = /* @__PURE__ */ __name((env, what) => {
433
- const lock = readOnlyLockOf(DRIVE_APP, env);
434
- if (lock)
435
- throw readOnlyRefusal(lock, what);
436
- }, "refuseUnderReadOnly");
437
- var checkPolicy = /* @__PURE__ */ __name(async (env, profile, key, mutates, flags = {}, ask) => {
438
- const { levels, readOnly, lock } = policySettings(env, profile, flags);
439
- const { level } = levelFor(levels, key, defaults);
440
- if (mutates && lock)
441
- throw readOnlyRefusal(lock, "change local or Google data");
442
- if (level === "deny" || mutates && (readOnly || level === "readonly"))
443
- throw new CliError("permission_error", "profile policy refuses this operation", {
444
- reason: "policy.denied",
445
- permission: key
446
- });
447
- if (mutates && level === "ask" && !flags.dryRun) {
448
- const destructive = defaults[key] === "ask";
449
- if (destructive ? flags.allowDangerous : flags.yes)
450
- return;
451
- if (ask && await ask(key))
452
- return;
453
- throw new CliError("confirmation_required", destructive ? "this deletion requires --allow-dangerous or an explicit permission" : "profile policy requires --yes or confirmation", { reason: "policy.confirm", permission: key });
454
- }
455
- }, "checkPolicy");
456
- var guardedGoogleWrite = /* @__PURE__ */ __name(async (env, profile, key, act, flags = {}, ask, operationId = newOperationId()) => {
457
- const settings = policySettings(env, profile, flags);
458
- const guard = sendGuard({
459
- profile,
460
- command: "drive",
461
- readOnlyLock: settings.lock ?? (settings.readOnly ? "profile" : void 0),
462
- permissions: settings.levels,
463
- permissionDefaults: defaults,
464
- ask: /* @__PURE__ */ __name(async (permission) => checkPolicy(env, profile, permission, true, flags, ask), "ask"),
465
- sendsPerHour: Number.MAX_SAFE_INTEGER,
466
- journal: new SendJournal(join2(paths(env).state, "sends", `${profile}.jsonl`), {
467
- service: "drive",
468
- version: VERSION
469
- }),
470
- recipients: new RecipientList(join2(paths(env).state, "recipients", `${profile}.json`), "drive"),
471
- warn: /* @__PURE__ */ __name(() => {
472
- }, "warn")
473
- });
474
- return guardedWrite(guard, { chatId: null, kind: "edit", key, operationId }, act);
475
- }, "guardedGoogleWrite");
476
- var discoveryAvailability = /* @__PURE__ */ __name((command, settings, authority = false, mcp = false) => {
477
- if (mcp && authority && !["ask", "allow"].includes(levelFor(settings.levels, "mcp.authority").level))
478
- return { available: false, reason: "the profile keeps mcp.authority off", permission: "mcp.authority" };
479
- if (!mcp && command.path.join(" ") === "config set")
480
- return settings.lock ? { available: false, reason: "the process is read-only" } : { available: true };
481
- if (writes(command.effects) && settings.readOnly)
482
- return { available: false, reason: "the profile is read-only" };
483
- const keys = command.api_operation ? methodPolicyKeys(command.api_operation) : [command.path.join(".")];
484
- const denied = keys.find((key) => {
485
- const level = levelFor(settings.levels, key).level;
486
- return level === "deny" || writes(command.effects) && level === "readonly";
487
- });
488
- return denied ? { available: false, reason: `the profile does not allow ${denied}`, permission: denied } : { available: true };
489
- }, "discoveryAvailability");
490
-
491
- export {
492
- profileDir,
493
- readState,
494
- saveState,
495
- readWalk,
496
- saveWalk,
497
- removeWalk,
498
- ensureProfileDir,
499
- saveSnapshot,
500
- removeSnapshot,
501
- readSnapshot,
502
- profileSetTokenFile,
503
- httpTokenFile,
504
- profileSetLabel,
505
- ACCOUNT_FREE_COMMANDS,
506
- PROFILE_SET_COMMANDS,
507
- ANY_PROFILE_COMMANDS,
508
- GOOGLE_READ,
509
- GOOGLE_WRITE,
510
- examples,
511
- markProfileFree,
512
- describeDriveProgram,
513
- commandsDocument2 as commandsDocument,
514
- permissionKeys,
515
- permissionNames,
516
- policySettings,
517
- methodPolicyKeys,
518
- refuseUnderReadOnly,
519
- checkPolicy,
520
- guardedGoogleWrite,
521
- discoveryAvailability
522
- };