@wirecat/drive-cli 0.63.0 → 0.65.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 (193) hide show
  1. package/README.md +2 -1
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bundle/{all-profiles-GZJS3UKC.js → all-profiles-PD7GJHFA.js} +14 -13
  4. package/dist/bundle/{anthropic-RGV3WXX5.js → anthropic-PJKFON5H.js} +25 -14
  5. package/dist/bundle/{app-server-AA2PJ7PV.js → app-server-6ELQA6FJ.js} +59 -56
  6. package/dist/bundle/{bun-OXZYIA3R.js → bun-P54TGES2.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-D45NSDM3.js → bun-sqlite-TND5ZRJH.js} +12 -8
  8. package/dist/bundle/chunk-2AFI4KGI.js +185 -0
  9. package/dist/bundle/{chunk-Q5DJTRKV.js → chunk-3HXNDF6Q.js} +2 -2
  10. package/dist/bundle/{chunk-DJHLVUL6.js → chunk-3ONWN3IA.js} +278 -49
  11. package/dist/bundle/{chunk-WYGWWHZP.js → chunk-42G2XNPN.js} +2 -2
  12. package/dist/bundle/chunk-4AOINPN2.js +66 -0
  13. package/dist/bundle/{chunk-J4DIHPZ6.js → chunk-4EDWLR22.js} +1 -1
  14. package/dist/bundle/{chunk-ABYGSJZ4.js → chunk-4Y5YBFMS.js} +7 -7
  15. package/dist/bundle/{chunk-YGU6ULU5.js → chunk-54V4H6PM.js} +16 -16
  16. package/dist/bundle/{chunk-2TFXK3R4.js → chunk-5XSBCMAF.js} +4 -4
  17. package/dist/bundle/{chunk-2HF2MRXI.js → chunk-6DCLZLGX.js} +1 -1
  18. package/dist/bundle/{chunk-OD4U7GUY.js → chunk-7AQGVX5O.js} +20 -20
  19. package/dist/bundle/{chunk-YIP7ELON.js → chunk-7TAP7Y2E.js} +727 -518
  20. package/dist/bundle/{chunk-TF23BZW5.js → chunk-A27UVLPK.js} +3 -3
  21. package/dist/bundle/{chunk-LZEOQW7S.js → chunk-A4QNADEX.js} +58 -52
  22. package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
  23. package/dist/bundle/{chunk-LMAVCYLQ.js → chunk-B2LPCHQN.js} +4 -4
  24. package/dist/bundle/{chunk-5PPL7JDM.js → chunk-CGQRZRTH.js} +2 -2
  25. package/dist/bundle/{chunk-VAUMOZU5.js → chunk-CWLL63JD.js} +107 -48
  26. package/dist/bundle/{chunk-V3NVXIQR.js → chunk-D6Z43SOG.js} +1563 -266
  27. package/dist/bundle/{chunk-OXY6SSZG.js → chunk-D7WB54P7.js} +127 -28
  28. package/dist/bundle/{chunk-VJEOGKAN.js → chunk-DA63E2UM.js} +13 -9
  29. package/dist/bundle/{chunk-EOOGWUTP.js → chunk-ECEP4SO3.js} +20 -20
  30. package/dist/bundle/{chunk-NEFSGCVA.js → chunk-EHU6EYGO.js} +38 -28
  31. package/dist/bundle/{chunk-4OSSOWDM.js → chunk-ELJUBPY4.js} +1 -1
  32. package/dist/bundle/{chunk-FRIJUILO.js → chunk-EM7NL5ES.js} +3 -3
  33. package/dist/bundle/{chunk-3BZRKLJ6.js → chunk-EU5MD24W.js} +13 -13
  34. package/dist/bundle/{chunk-MOTRI3SY.js → chunk-EZ2OLYEK.js} +24 -2
  35. package/dist/bundle/{chunk-6MQSQ4LX.js → chunk-F56DRBGY.js} +370 -717
  36. package/dist/bundle/{chunk-ZOJU7ZFI.js → chunk-FA6JNXCC.js} +8 -8
  37. package/dist/bundle/{chunk-ND6LLYGF.js → chunk-FBHSWQU7.js} +1531 -136
  38. package/dist/bundle/{chunk-Z42YYLTS.js → chunk-GW3LBY3T.js} +74 -72
  39. package/dist/bundle/{chunk-Y6GNA7HE.js → chunk-HP3NT6JJ.js} +23 -5
  40. package/dist/bundle/{chunk-DJ3SDJZY.js → chunk-I272E6UR.js} +9 -8
  41. package/dist/bundle/{chunk-L37LMMRJ.js → chunk-IBO23OID.js} +2 -2
  42. package/dist/bundle/{chunk-CE2TJBLP.js → chunk-II4S2DBJ.js} +3 -3
  43. package/dist/bundle/{chunk-ZM5J6ZMB.js → chunk-IKHOIXJR.js} +2 -2
  44. package/dist/bundle/{chunk-PO5RQQIG.js → chunk-IMHW7VIV.js} +5 -5
  45. package/dist/bundle/{chunk-3HK5WMI5.js → chunk-JMJIH6JH.js} +6 -6
  46. package/dist/bundle/{chunk-FUITWY7O.js → chunk-JPPPLKAO.js} +26 -1
  47. package/dist/bundle/{chunk-4S4JMW6I.js → chunk-LMKPP2JP.js} +1 -1
  48. package/dist/bundle/{chunk-HZZCEQTH.js → chunk-M7ELUGU6.js} +4 -4
  49. package/dist/bundle/{chunk-ZMOUUOT2.js → chunk-MCPOZNWG.js} +1 -1
  50. package/dist/bundle/{chunk-XNVFKMVR.js → chunk-NI5PD5KM.js} +39485 -35729
  51. package/dist/bundle/{chunk-2TDUGC5D.js → chunk-NQ5XMSLA.js} +4927 -1978
  52. package/dist/bundle/chunk-NQRTKYJB.js +257 -0
  53. package/dist/bundle/{chunk-44SBK6KB.js → chunk-O6K2E7OA.js} +4201 -2565
  54. package/dist/bundle/{chunk-534OBX5Y.js → chunk-O7ZDCOZE.js} +1 -1
  55. package/dist/bundle/{chunk-7EMQ26BA.js → chunk-OFJXHEFT.js} +13 -13
  56. package/dist/bundle/chunk-OWMZUWCM.js +109 -0
  57. package/dist/bundle/chunk-PHOL2DZM.js +138 -0
  58. package/dist/bundle/{chunk-UQLWMGSD.js → chunk-PLP5527C.js} +5 -5
  59. package/dist/bundle/{chunk-3QINVLZI.js → chunk-RNHGQ35R.js} +1 -1
  60. package/dist/bundle/{chunk-27YUUGXQ.js → chunk-RX5CJ55S.js} +1 -1
  61. package/dist/bundle/{chunk-XIUDS3OK.js → chunk-SE352DBY.js} +1 -1
  62. package/dist/bundle/chunk-SEQWBZYH.js +18 -0
  63. package/dist/bundle/{chunk-33MGFUED.js → chunk-SIWXYB4E.js} +3789 -3538
  64. package/dist/bundle/{chunk-4CIZWCXV.js → chunk-SNLSEYJO.js} +1 -1
  65. package/dist/bundle/{chunk-XDC3TWTL.js → chunk-SS4LKLD7.js} +52 -605
  66. package/dist/bundle/{chunk-BKYMKVHT.js → chunk-TMHF4BCL.js} +2 -2
  67. package/dist/bundle/{chunk-FEZF3TII.js → chunk-TOVWMURV.js} +74 -6
  68. package/dist/bundle/{chunk-QCKZ3GAA.js → chunk-TTP4NOP3.js} +4 -4
  69. package/dist/bundle/chunk-UTNRBOEN.js +53 -0
  70. package/dist/bundle/{chunk-2NIC72HH.js → chunk-VDZY3L7U.js} +3 -1
  71. package/dist/bundle/chunk-VHQYWFWV.js +13 -0
  72. package/dist/bundle/{chunk-VKPCONDQ.js → chunk-VLXWAH5E.js} +4 -4
  73. package/dist/bundle/{chunk-6KQJSFYF.js → chunk-VMAMRFFC.js} +23 -23
  74. package/dist/bundle/{chunk-6EY46GAN.js → chunk-W2XY6C5S.js} +2 -2
  75. package/dist/bundle/{chunk-J24ZFCWM.js → chunk-WRAUO5EJ.js} +22 -24
  76. package/dist/bundle/{chunk-S4RXABDR.js → chunk-WRMJN6UQ.js} +3 -3
  77. package/dist/bundle/{chunk-UPOSDTPT.js → chunk-WVJHZIDH.js} +3 -3
  78. package/dist/bundle/{chunk-E4SDKMBJ.js → chunk-X7YGGWXI.js} +1 -59
  79. package/dist/bundle/{chunk-O2XOX4HB.js → chunk-XPWZSW6Y.js} +50 -34
  80. package/dist/bundle/{chunk-PDCCYHCH.js → chunk-XYE7XZPB.js} +5 -5
  81. package/dist/bundle/{chunk-RKELRWH7.js → chunk-Y5PKRITX.js} +5 -5
  82. package/dist/bundle/{chunk-XR6ESRU6.js → chunk-Z2ADO6UA.js} +2 -2
  83. package/dist/bundle/{chunk-YUWPNG7B.js → chunk-ZD4MB7NH.js} +1 -1
  84. package/dist/bundle/{chunk-TWUH22Z5.js → chunk-ZILALBYQ.js} +4 -4
  85. package/dist/bundle/{chunk-SXM6MHRR.js → chunk-ZR2EJPMQ.js} +44 -15
  86. package/dist/bundle/command-contract-25E4PYMD.js +40 -0
  87. package/dist/bundle/command-server-entry-36JXYIJB.js +170 -0
  88. package/dist/bundle/{decode-G5YEIPNC.js → decode-T5ZW57WZ.js} +8 -8
  89. package/dist/bundle/{dispatch-GEFIXA6X.js → dispatch-RMA2XFYA.js} +11 -11
  90. package/dist/bundle/drive.js +11 -11
  91. package/dist/bundle/{echarts-W2CWHNXR.js → echarts-KQ44LPSF.js} +2 -2
  92. package/dist/bundle/{embed-OBFFPVF4.js → embed-Q7XST53J.js} +9 -9
  93. package/dist/bundle/{embedder-NGCBQHIG.js → embedder-RWZSBVW2.js} +12 -12
  94. package/dist/bundle/entry-HPLW4QL2.js +25 -0
  95. package/dist/bundle/{failure-GV77W3CD.js → failure-7NP4QPIN.js} +4 -4
  96. package/dist/bundle/first-run-RL3RKYZW.js +30 -0
  97. package/dist/bundle/first-screen-NX3TM2VJ.js +38 -0
  98. package/dist/bundle/google-DPD5N6AQ.js +42 -0
  99. package/dist/bundle/{google-api-Z3NSTBBR.js → google-api-P5DRHD7L.js} +61 -56
  100. package/dist/bundle/grants-TX4MHLI4.js +109 -0
  101. package/dist/bundle/{identity-OM6GFZ7T.js → identity-VDV6CHRW.js} +6 -6
  102. package/dist/bundle/{instructions-YQBQSYSS.js → instructions-Q45FVY6H.js} +1 -1
  103. package/dist/bundle/{login-7RYSDVN3.js → login-XKN3NI6X.js} +67 -62
  104. package/dist/bundle/{mcp-GWDA3HOA.js → mcp-7KQUJNFN.js} +2 -2
  105. package/dist/bundle/{node-IVU33RL7.js → node-MSW565D3.js} +2 -2
  106. package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
  107. package/dist/bundle/{node-sqlite-SIH5BEW2.js → node-sqlite-S74XVVHL.js} +13 -9
  108. package/dist/bundle/oauth-6R7AWAES.js +22 -0
  109. package/dist/bundle/{open-IAO2SNII.js → open-P7UQG7XJ.js} +8 -8
  110. package/dist/bundle/{openai-SGOUBHXP.js → openai-DDHJ57KZ.js} +19 -40
  111. package/dist/bundle/{process-BPBMV3AT.js → process-NMUB5SHK.js} +1 -1
  112. package/dist/bundle/{program-MYKKJ4F6.js → program-PJNWP6JW.js} +517 -330
  113. package/dist/bundle/prompt-VOSMK4C2.js +19 -0
  114. package/dist/bundle/{reasons-57J2D77K.js → reasons-KDAXOC5S.js} +5 -5
  115. package/dist/bundle/{recognize-A5C5RPB3.js → recognize-GZIY63HS.js} +7 -7
  116. package/dist/bundle/{remote-VWYFLRGO.js → remote-V3YGN7LN.js} +10 -10
  117. package/dist/bundle/{rerank-4NGQWREA.js → rerank-XRU6AVN7.js} +10 -10
  118. package/dist/bundle/{serve-Y6LQTFH5.js → serve-NDOAFA57.js} +12 -12
  119. package/dist/bundle/{server-6AUHIIUA.js → server-BKGWJYMC.js} +46 -44
  120. package/dist/bundle/server-QD2MUJJZ.js +72 -0
  121. package/dist/bundle/{services-2W4J7EMW.js → services-TYDMFQCA.js} +129 -39
  122. package/dist/bundle/{sqlite-runtime-P6BBDX2H.js → sqlite-runtime-UAFJKSJR.js} +9 -9
  123. package/dist/bundle/{start-AFFA3LKM.js → start-2ZLDP2OE.js} +30 -8
  124. package/dist/bundle/{state-PXKKXR3R.js → state-6SP27J2K.js} +9 -9
  125. package/dist/bundle/{store-CN6JEUC4.js → store-4UUY545Q.js} +42 -18
  126. package/dist/bundle/{store-IVV2BAGZ.js → store-EJN27MXI.js} +69 -28
  127. package/dist/bundle/store-maintenance-command-LETURZDC.js +60 -0
  128. package/dist/bundle/tokens-MTFJPTYT.js +107 -0
  129. package/dist/commands/account.d.ts +4 -0
  130. package/dist/commands/account.d.ts.map +1 -0
  131. package/dist/commands/account.js +33 -0
  132. package/dist/commands/account.js.map +1 -0
  133. package/dist/commands/config.d.ts.map +1 -1
  134. package/dist/commands/config.js +6 -5
  135. package/dist/commands/config.js.map +1 -1
  136. package/dist/commands/context.d.ts +4 -2
  137. package/dist/commands/context.d.ts.map +1 -1
  138. package/dist/commands/context.js.map +1 -1
  139. package/dist/commands/documents.d.ts +2 -0
  140. package/dist/commands/documents.d.ts.map +1 -1
  141. package/dist/commands/documents.js +39 -3
  142. package/dist/commands/documents.js.map +1 -1
  143. package/dist/config.d.ts +13 -0
  144. package/dist/config.d.ts.map +1 -1
  145. package/dist/config.js +32 -2
  146. package/dist/config.js.map +1 -1
  147. package/dist/documents-add.d.ts +49 -0
  148. package/dist/documents-add.d.ts.map +1 -0
  149. package/dist/documents-add.js +122 -0
  150. package/dist/documents-add.js.map +1 -0
  151. package/dist/errors.d.ts +1 -0
  152. package/dist/errors.d.ts.map +1 -1
  153. package/dist/errors.js +9 -1
  154. package/dist/errors.js.map +1 -1
  155. package/dist/knowledge.d.ts +1 -1
  156. package/dist/knowledge.d.ts.map +1 -1
  157. package/dist/knowledge.js +15 -17
  158. package/dist/knowledge.js.map +1 -1
  159. package/dist/model.d.ts +3 -0
  160. package/dist/model.d.ts.map +1 -1
  161. package/dist/model.js.map +1 -1
  162. package/dist/profile-lock.d.ts +1 -0
  163. package/dist/profile-lock.d.ts.map +1 -1
  164. package/dist/profile-lock.js +1 -0
  165. package/dist/profile-lock.js.map +1 -1
  166. package/dist/program.d.ts.map +1 -1
  167. package/dist/program.js +24 -15
  168. package/dist/program.js.map +1 -1
  169. package/dist/reasons.d.ts.map +1 -1
  170. package/dist/reasons.js +25 -0
  171. package/dist/reasons.js.map +1 -1
  172. package/dist/store.d.ts.map +1 -1
  173. package/dist/store.js +20 -0
  174. package/dist/store.js.map +1 -1
  175. package/dist/version.d.ts +1 -1
  176. package/dist/version.js +1 -1
  177. package/package.json +4 -4
  178. package/dist/bundle/chunk-AEX37ETW.js +0 -35
  179. package/dist/bundle/chunk-OTROVC4E.js +0 -62
  180. package/dist/bundle/chunk-Z5KC7XBR.js +0 -33
  181. package/dist/bundle/command-contract-BRW3AP44.js +0 -38
  182. package/dist/bundle/entry-ET6HGM7A.js +0 -22
  183. package/dist/bundle/first-run-JG52UZVO.js +0 -30
  184. package/dist/bundle/first-screen-CIL3GFAA.js +0 -36
  185. package/dist/bundle/google-CIWUVJ5C.js +0 -36
  186. package/dist/bundle/grants-3S4RL3WB.js +0 -104
  187. package/dist/bundle/oauth-PT4JEHLL.js +0 -22
  188. package/dist/bundle/prompt-3ZM64DCB.js +0 -17
  189. package/dist/bundle/server-PFHI35HA.js +0 -69
  190. package/dist/bundle/store-maintenance-command-MSY2QNEH.js +0 -59
  191. package/dist/bundle/tokens-P4LPNUFW.js +0 -102
  192. package/dist/bundle/{chunk-ZQ3GWKDQ.js → chunk-YVNHQFLC.js} +0 -0
  193. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
@@ -8,7 +8,7 @@ import {
8
8
  metadataJson,
9
9
  supported,
10
10
  tooManyEntries
11
- } from "./chunk-YUWPNG7B.js";
11
+ } from "./chunk-ZD4MB7NH.js";
12
12
  import {
13
13
  ACCOUNT_FREE_COMMANDS,
14
14
  ANY_PROFILE_COMMANDS,
@@ -19,13 +19,14 @@ import {
19
19
  describeDriveProgram,
20
20
  examples,
21
21
  markProfileFree
22
- } from "./chunk-S4RXABDR.js";
22
+ } from "./chunk-WRMJN6UQ.js";
23
23
  import {
24
24
  DEFAULTS_ONLY,
25
25
  DEFAULT_LEVELS,
26
26
  SETTING_NAMES,
27
27
  activeProfile,
28
28
  application,
29
+ checkAddProfiles,
29
30
  checkTextLimit,
30
31
  configIssues,
31
32
  configPath,
@@ -35,13 +36,16 @@ import {
35
36
  fileId,
36
37
  googleAppOf,
37
38
  inspectConfig,
39
+ maxAddProfiles,
38
40
  methodPolicyKeys,
39
41
  oauthClientReport,
40
42
  paths,
41
43
  permissionKeys,
42
44
  permissionNames,
43
45
  pictureSearch,
46
+ profileLocked,
44
47
  profileName,
48
+ profileRequired,
45
49
  readConfig,
46
50
  refusal,
47
51
  selectedFolders,
@@ -49,7 +53,7 @@ import {
49
53
  unknownProfile,
50
54
  withDefaults,
51
55
  writeConfig
52
- } from "./chunk-SXM6MHRR.js";
56
+ } from "./chunk-ZR2EJPMQ.js";
53
57
  import {
54
58
  blockKey,
55
59
  blocksMarkdown,
@@ -68,7 +72,7 @@ import {
68
72
  syncDocuments,
69
73
  syncMirrors,
70
74
  watchMirrors
71
- } from "./chunk-6KQJSFYF.js";
75
+ } from "./chunk-VMAMRFFC.js";
72
76
  import {
73
77
  apiMethod,
74
78
  apiMethods,
@@ -77,10 +81,11 @@ import {
77
81
  schemas,
78
82
  validateApiParams,
79
83
  validateRequest
80
- } from "./chunk-TWUH22Z5.js";
84
+ } from "./chunk-ZILALBYQ.js";
81
85
  import {
82
86
  DISCOVERY_DESCRIPTIONS,
83
87
  MEMO_SCENARIOS,
88
+ accountRemoveCommand,
84
89
  addContractInfo,
85
90
  answerFields,
86
91
  apiPlainJson,
@@ -107,24 +112,21 @@ import {
107
112
  skillCommand,
108
113
  suggest,
109
114
  upgradeCommand
110
- } from "./chunk-2TDUGC5D.js";
115
+ } from "./chunk-NQ5XMSLA.js";
111
116
  import {
112
- googleError
113
- } from "./chunk-OTROVC4E.js";
114
- import "./chunk-XIUDS3OK.js";
117
+ googleError,
118
+ offlineRefused
119
+ } from "./chunk-NQRTKYJB.js";
120
+ import "./chunk-SE352DBY.js";
115
121
  import "./chunk-SBZB7HMU.js";
116
- import "./chunk-4CIZWCXV.js";
117
- import "./chunk-Z42YYLTS.js";
118
- import "./chunk-OXY6SSZG.js";
122
+ import "./chunk-PHOL2DZM.js";
123
+ import "./chunk-SNLSEYJO.js";
124
+ import "./chunk-GW3LBY3T.js";
125
+ import "./chunk-D7WB54P7.js";
119
126
  import {
120
- modelGateway,
121
127
  storeInfo
122
- } from "./chunk-YIP7ELON.js";
123
- import {
124
- RecipientList,
125
- SendJournal,
126
- sendGuard
127
- } from "./chunk-XDC3TWTL.js";
128
+ } from "./chunk-7TAP7Y2E.js";
129
+ import "./chunk-SS4LKLD7.js";
128
130
  import {
129
131
  LIST_QUERY_GUIDE,
130
132
  listQuery,
@@ -135,13 +137,47 @@ import {
135
137
  typedQuery,
136
138
  unfilteredQuery,
137
139
  withQuery
138
- } from "./chunk-J24ZFCWM.js";
140
+ } from "./chunk-WRAUO5EJ.js";
141
+ import {
142
+ RecipientList,
143
+ SendJournal,
144
+ newOperationId,
145
+ sendGuard
146
+ } from "./chunk-O6K2E7OA.js";
147
+ import {
148
+ columnName,
149
+ modelGateway,
150
+ readSpreadsheet
151
+ } from "./chunk-FBHSWQU7.js";
152
+ import "./chunk-EU5MD24W.js";
139
153
  import {
140
154
  commandsText,
141
155
  inSection
142
- } from "./chunk-DJ3SDJZY.js";
156
+ } from "./chunk-I272E6UR.js";
143
157
  import "./chunk-HTQTIKWP.js";
144
- import "./chunk-RKELRWH7.js";
158
+ import "./chunk-54V4H6PM.js";
159
+ import {
160
+ latestVersion,
161
+ runUpdate,
162
+ updateNotice
163
+ } from "./chunk-TTP4NOP3.js";
164
+ import "./chunk-MCPOZNWG.js";
165
+ import "./chunk-EHU6EYGO.js";
166
+ import "./chunk-5XSBCMAF.js";
167
+ import "./chunk-EM7NL5ES.js";
168
+ import "./chunk-EZ2OLYEK.js";
169
+ import "./chunk-II4S2DBJ.js";
170
+ import {
171
+ applyDocumentTransfer,
172
+ previewDocumentTransfer
173
+ } from "./chunk-CWLL63JD.js";
174
+ import "./chunk-IMHW7VIV.js";
175
+ import "./chunk-5DPV7X27.js";
176
+ import "./chunk-2AFI4KGI.js";
177
+ import "./chunk-SEQWBZYH.js";
178
+ import "./chunk-VHQYWFWV.js";
179
+ import "./chunk-TMHF4BCL.js";
180
+ import "./chunk-Y5PKRITX.js";
145
181
  import {
146
182
  FETCH,
147
183
  InvalidArgumentError,
@@ -164,7 +200,6 @@ import {
164
200
  jsonlRecords,
165
201
  listOf,
166
202
  metaOf,
167
- modelTarget,
168
203
  outputFor,
169
204
  overrideSharedContract,
170
205
  refuseCommandName,
@@ -173,70 +208,49 @@ import {
173
208
  rootOf,
174
209
  settingRows,
175
210
  snakeKeys
176
- } from "./chunk-33MGFUED.js";
177
- import "./chunk-VJEOGKAN.js";
178
- import "./chunk-YGU6ULU5.js";
179
- import {
180
- setupPermissionCeiling
181
- } from "./chunk-VKPCONDQ.js";
182
- import "./chunk-NEFSGCVA.js";
183
- import {
184
- readOnlyLockOf,
185
- readOnlyRefusal
186
- } from "./chunk-ZM5J6ZMB.js";
187
- import "./chunk-2TFXK3R4.js";
188
- import "./chunk-FRIJUILO.js";
189
- import "./chunk-534OBX5Y.js";
190
- import "./chunk-Z5KC7XBR.js";
191
- import {
192
- newOperationId
193
- } from "./chunk-44SBK6KB.js";
194
- import {
195
- columnName,
196
- readSpreadsheet
197
- } from "./chunk-ND6LLYGF.js";
198
- import "./chunk-3BZRKLJ6.js";
211
+ } from "./chunk-SIWXYB4E.js";
212
+ import "./chunk-DA63E2UM.js";
199
213
  import {
200
214
  CEILING_KEY,
201
215
  LEVELS,
202
216
  guardedWrite,
203
- inRun,
204
217
  layerPermissions,
205
218
  levelFor,
206
219
  parseDuration
207
- } from "./chunk-6MQSQ4LX.js";
220
+ } from "./chunk-F56DRBGY.js";
208
221
  import {
209
- latestVersion,
210
- runUpdate,
211
- updateNotice
212
- } from "./chunk-QCKZ3GAA.js";
213
- import "./chunk-ZMOUUOT2.js";
214
- import "./chunk-MOTRI3SY.js";
215
- import "./chunk-CE2TJBLP.js";
222
+ modelTarget
223
+ } from "./chunk-OWMZUWCM.js";
216
224
  import {
217
- applyDocumentTransfer,
218
- previewDocumentTransfer
219
- } from "./chunk-VAUMOZU5.js";
225
+ setupPermissionCeiling
226
+ } from "./chunk-VLXWAH5E.js";
227
+ import {
228
+ readOnlyLockOf,
229
+ readOnlyRefusal
230
+ } from "./chunk-IKHOIXJR.js";
231
+ import "./chunk-O7ZDCOZE.js";
220
232
  import {
221
233
  note
222
- } from "./chunk-TF23BZW5.js";
223
- import "./chunk-PO5RQQIG.js";
224
- import "./chunk-5DPV7X27.js";
225
- import "./chunk-LMAVCYLQ.js";
226
- import "./chunk-BKYMKVHT.js";
234
+ } from "./chunk-A27UVLPK.js";
235
+ import "./chunk-B2LPCHQN.js";
236
+ import "./chunk-HP3NT6JJ.js";
237
+ import "./chunk-Z2ADO6UA.js";
227
238
  import {
228
239
  CATALOG_QUERY,
229
240
  IMPORTED_DOCUMENT_QUERY,
230
241
  openStore
231
- } from "./chunk-XNVFKMVR.js";
232
- import "./chunk-UPOSDTPT.js";
242
+ } from "./chunk-NI5PD5KM.js";
243
+ import "./chunk-WVJHZIDH.js";
244
+ import "./chunk-FA6JNXCC.js";
245
+ import "./chunk-JMJIH6JH.js";
233
246
  import {
234
247
  FACT_STATUSES,
235
248
  FACT_TYPES,
236
249
  MEMORY_KINDS,
237
250
  MEMORY_SCOPES,
238
- MEMORY_STATUSES
239
- } from "./chunk-V3NVXIQR.js";
251
+ MEMORY_STATUSES,
252
+ inRun
253
+ } from "./chunk-D6Z43SOG.js";
240
254
  import {
241
255
  dateRange,
242
256
  defineQuery,
@@ -246,40 +260,37 @@ import {
246
260
  timezoneOf,
247
261
  validateQuery,
248
262
  zonedMoment
249
- } from "./chunk-EOOGWUTP.js";
250
- import "./chunk-E4SDKMBJ.js";
251
- import "./chunk-ZOJU7ZFI.js";
252
- import "./chunk-ABYGSJZ4.js";
253
- import {
254
- storePath
255
- } from "./chunk-AEX37ETW.js";
256
- import "./chunk-3HK5WMI5.js";
257
- import "./chunk-4S4JMW6I.js";
258
- import "./chunk-Y6GNA7HE.js";
259
- import "./chunk-XR6ESRU6.js";
263
+ } from "./chunk-ECEP4SO3.js";
264
+ import "./chunk-X7YGGWXI.js";
265
+ import "./chunk-4AOINPN2.js";
266
+ import "./chunk-4Y5YBFMS.js";
267
+ import "./chunk-LMKPP2JP.js";
260
268
  import "./chunk-D72URWJE.js";
261
269
  import {
262
270
  installerOf
263
- } from "./chunk-27YUUGXQ.js";
271
+ } from "./chunk-RX5CJ55S.js";
264
272
  import {
265
273
  DRIVE_APP,
266
274
  PACKAGE,
267
275
  VERSION
268
- } from "./chunk-5PPL7JDM.js";
276
+ } from "./chunk-CGQRZRTH.js";
269
277
  import {
270
278
  REASONS
271
- } from "./chunk-FUITWY7O.js";
272
- import "./chunk-ZQ3GWKDQ.js";
273
- import "./chunk-2NIC72HH.js";
279
+ } from "./chunk-JPPPLKAO.js";
280
+ import "./chunk-YVNHQFLC.js";
281
+ import "./chunk-VDZY3L7U.js";
282
+ import {
283
+ storePath
284
+ } from "./chunk-UTNRBOEN.js";
274
285
  import {
275
286
  processStreams,
276
287
  saveConfigFile,
277
288
  writeSecurely
278
- } from "./chunk-OD4U7GUY.js";
279
- import "./chunk-UQLWMGSD.js";
289
+ } from "./chunk-7AQGVX5O.js";
290
+ import "./chunk-PLP5527C.js";
280
291
  import "./chunk-Y5E2WNWB.js";
281
- import "./chunk-2HF2MRXI.js";
282
- import "./chunk-6EY46GAN.js";
292
+ import "./chunk-6DCLZLGX.js";
293
+ import "./chunk-W2XY6C5S.js";
283
294
  import {
284
295
  array,
285
296
  boolean,
@@ -303,11 +314,11 @@ import {
303
314
  string,
304
315
  unknown,
305
316
  writes
306
- } from "./chunk-FEZF3TII.js";
317
+ } from "./chunk-TOVWMURV.js";
307
318
  import {
308
319
  CliError,
309
320
  isCliError
310
- } from "./chunk-4OSSOWDM.js";
321
+ } from "./chunk-ELJUBPY4.js";
311
322
  import {
312
323
  __commonJS,
313
324
  __name,
@@ -1962,7 +1973,208 @@ var require_proper_lockfile = __commonJS({
1962
1973
  // dist/program.js
1963
1974
  import { randomUUID as randomUUID2 } from "node:crypto";
1964
1975
  import { mkdirSync as mkdirSync4, readFileSync as readFileSync6 } from "node:fs";
1965
- import { join as join10 } from "node:path";
1976
+ import { join as join11 } from "node:path";
1977
+
1978
+ // dist/commands/account.js
1979
+ import { join as join2 } from "node:path";
1980
+
1981
+ // dist/profile-lock.js
1982
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
1983
+
1984
+ // dist/state.js
1985
+ import { mkdirSync, readFileSync, unlinkSync } from "node:fs";
1986
+ import { join } from "node:path";
1987
+ var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
1988
+ var User = object({ id: optional(string()), email: optional(string()), name: optional(string()) });
1989
+ var File = object({
1990
+ id: ID,
1991
+ name: string(),
1992
+ mime: string(),
1993
+ parents: array(ID),
1994
+ version: optional(string()),
1995
+ modifiedAt: optional(string()),
1996
+ url: string(),
1997
+ trashed: boolean(),
1998
+ canDownload: boolean(),
1999
+ size: optional(number()),
2000
+ createdAt: optional(string()),
2001
+ description: optional(string()),
2002
+ driveId: optional(string()),
2003
+ owners: optional(array(User)),
2004
+ lastModifiedBy: optional(User),
2005
+ providerMetadata: optional(unknown())
2006
+ });
2007
+ var Skip = object({
2008
+ id: ID,
2009
+ reason: string(),
2010
+ file: optional(File),
2011
+ textLimit: optional(number()),
2012
+ storeRefusedIn: optional(string())
2013
+ });
2014
+ var State = object({
2015
+ version: literal(1),
2016
+ store: optional(string()),
2017
+ linkedThrough: optional(string()),
2018
+ linksPending: optional(boolean()),
2019
+ linksVersion: optional(pipe(number(), integer(), minValue(1))),
2020
+ principal: string(),
2021
+ scope: string(),
2022
+ cursor: optional(string()),
2023
+ folders: record(ID, File),
2024
+ documents: record(ID, object({
2025
+ metadata: File,
2026
+ hash: string(),
2027
+ reference: string(),
2028
+ tabs: number(),
2029
+ notRead: optional(string()),
2030
+ picture: optional(picklist(["saved", "too-large"]))
2031
+ })),
2032
+ skipped: array(Skip),
2033
+ lastSync: optional(string()),
2034
+ pending: optional(object({
2035
+ cursor: string(),
2036
+ scope: string(),
2037
+ folders: record(ID, File),
2038
+ jobs: array(object({ id: ID, kind: picklist(["save", "remove"]), file: optional(File) })),
2039
+ skipped: array(Skip)
2040
+ }))
2041
+ });
2042
+ var Walk = object({
2043
+ scope: string(),
2044
+ cursor: string(),
2045
+ stack: array(object({ id: ID, ancestry: array(ID), folder: optional(File) })),
2046
+ visited: array(ID),
2047
+ folders: record(ID, File),
2048
+ files: array(File),
2049
+ discovered: number()
2050
+ });
2051
+ var profileDir = /* @__PURE__ */ __name((env, name) => join(paths(env).state, "profiles", profileName(name)), "profileDir");
2052
+ var statePath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "state.json"), "statePath");
2053
+ var readState = /* @__PURE__ */ __name((env, name, principal) => {
2054
+ let value;
2055
+ try {
2056
+ value = JSON.parse(readFileSync(statePath(env, name), "utf8"));
2057
+ } catch (error) {
2058
+ if (error.code === "ENOENT")
2059
+ return { version: 1, principal, scope: "", folders: {}, documents: {}, skipped: [] };
2060
+ throw new CliError("configuration_error", "sync state is unreadable; refusing to reset its checkpoint", {
2061
+ reason: "state.invalid"
2062
+ });
2063
+ }
2064
+ const parsed = safeParse(State, value);
2065
+ if (!parsed.success || parsed.output.principal !== principal)
2066
+ throw new CliError("configuration_error", "sync state is invalid or belongs to another Google account", {
2067
+ reason: "state.invalid"
2068
+ });
2069
+ return parsed.output;
2070
+ }, "readState");
2071
+ var saveState = /* @__PURE__ */ __name((env, name, state) => {
2072
+ writeSecurely(statePath(env, name), `${JSON.stringify(state)}
2073
+ `, 384);
2074
+ }, "saveState");
2075
+ var walkPath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "walk.json"), "walkPath");
2076
+ var readWalk = /* @__PURE__ */ __name((env, name, scope) => {
2077
+ try {
2078
+ const parsed = safeParse(Walk, JSON.parse(readFileSync(walkPath(env, name), "utf8")));
2079
+ return parsed.success && parsed.output.scope === scope ? parsed.output : void 0;
2080
+ } catch {
2081
+ return void 0;
2082
+ }
2083
+ }, "readWalk");
2084
+ var saveWalk = /* @__PURE__ */ __name((env, name, walk) => {
2085
+ writeSecurely(walkPath(env, name), `${JSON.stringify(walk)}
2086
+ `, 384);
2087
+ }, "saveWalk");
2088
+ var removeWalk = /* @__PURE__ */ __name((env, name) => {
2089
+ try {
2090
+ unlinkSync(walkPath(env, name));
2091
+ } catch (error) {
2092
+ if (error.code !== "ENOENT")
2093
+ throw error;
2094
+ }
2095
+ }, "removeWalk");
2096
+ var ensureProfileDir = /* @__PURE__ */ __name((env, name) => {
2097
+ mkdirSync(profileDir(env, name), { recursive: true, mode: 448 });
2098
+ }, "ensureProfileDir");
2099
+ var snapshotPath = /* @__PURE__ */ __name((env, name, id) => join(profileDir(env, name), "documents", `${fileId(id)}.json`), "snapshotPath");
2100
+ var saveSnapshot = /* @__PURE__ */ __name((env, name, content) => {
2101
+ const path = snapshotPath(env, name, content.metadata.id);
2102
+ writeSecurely(path, `${JSON.stringify(content)}
2103
+ `, 384);
2104
+ writeSecurely(path.replace(/\.json$/, ".md"), content.markdown, 384);
2105
+ }, "saveSnapshot");
2106
+ var removeSnapshot = /* @__PURE__ */ __name((env, name, id) => {
2107
+ const path = snapshotPath(env, name, id);
2108
+ for (const file of [path, path.replace(/\.json$/, ".md")]) {
2109
+ try {
2110
+ unlinkSync(file);
2111
+ } catch (error) {
2112
+ if (error.code !== "ENOENT")
2113
+ throw error;
2114
+ }
2115
+ }
2116
+ }, "removeSnapshot");
2117
+ var readSnapshot = /* @__PURE__ */ __name((env, name, id) => {
2118
+ try {
2119
+ return JSON.parse(readFileSync(snapshotPath(env, name, id), "utf8"));
2120
+ } catch {
2121
+ throw new CliError("not_found", "source snapshot is unavailable \u2014 run drive <profile> sync --rescan", {
2122
+ reason: "state.snapshot-missing"
2123
+ });
2124
+ }
2125
+ }, "readSnapshot");
2126
+
2127
+ // dist/profile-lock.js
2128
+ var lockProfile = /* @__PURE__ */ __name(async (env, name) => {
2129
+ ensureProfileDir(env, name);
2130
+ let compromised = false;
2131
+ try {
2132
+ const release = await import_proper_lockfile.default.lock(profileDir(env, name), {
2133
+ stale: 3e4,
2134
+ retries: 0,
2135
+ onCompromised: /* @__PURE__ */ __name(() => {
2136
+ compromised = true;
2137
+ }, "onCompromised")
2138
+ });
2139
+ return {
2140
+ release,
2141
+ assertHeld: /* @__PURE__ */ __name(() => {
2142
+ if (compromised)
2143
+ throw new CliError("provider_unavailable", "profile lock was lost; retry the operation", {
2144
+ reason: "profile.busy"
2145
+ });
2146
+ }, "assertHeld")
2147
+ };
2148
+ } catch {
2149
+ throw new CliError("provider_unavailable", "another sync or knowledge operation holds this profile's lock; retry later", { reason: "profile.busy" });
2150
+ }
2151
+ }, "lockProfile");
2152
+ var profileLocked2 = /* @__PURE__ */ __name((env, name) => import_proper_lockfile.default.checkSync(profileDir(env, name), { stale: 3e4, realpath: false }), "profileLocked");
2153
+
2154
+ // dist/commands/account.js
2155
+ var removal = {
2156
+ signOut: /* @__PURE__ */ __name(async (profile, { env, keyring, mayRevoke }) => {
2157
+ const storage = readConfig(env).profiles[profile]?.storage ?? "keyring";
2158
+ const { sessionKeeper } = await import("./tokens-MTFJPTYT.js");
2159
+ const { revoked } = await sessionKeeper({
2160
+ env,
2161
+ name: profile,
2162
+ storage,
2163
+ client: application(env, { profile }),
2164
+ ...keyring ? { keyring } : {}
2165
+ }).signOut({ revoke: mayRevoke });
2166
+ return { revoked, removed: ["the Google sign-in"] };
2167
+ }, "signOut"),
2168
+ account: /* @__PURE__ */ __name((profile, { env }) => {
2169
+ const principal = readConfig(env).profiles[profile]?.principal;
2170
+ return principal ? { provider: "google-drive", account: principal } : void 0;
2171
+ }, "account"),
2172
+ dataFiles: /* @__PURE__ */ __name((profile, { env }) => [profileDir(env, profile), join2(paths(env).cache, "exports", profile)], "dataFiles"),
2173
+ busy: /* @__PURE__ */ __name((profile, { env }) => profileLocked2(env, profile) ? "a sync or knowledge operation" : void 0, "busy")
2174
+ };
2175
+ var installAccountCommands = /* @__PURE__ */ __name((program, _context) => {
2176
+ annotate(program.command("account"), { effects: LOCAL_READ }).description("remove this profile from this computer").addCommand(accountRemoveCommand(DRIVE_APP, removal, { resolveSettings: configuration.resolveSettings }));
2177
+ }, "installAccountCommands");
1966
2178
 
1967
2179
  // dist/catalog.js
1968
2180
  var catalogInput = /* @__PURE__ */ __name((file) => ({
@@ -2207,178 +2419,6 @@ var snakeKeys2 = /* @__PURE__ */ __name((value, record2 = false) => {
2207
2419
  }, "snakeKeys");
2208
2420
  var allOf = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false }), "allOf");
2209
2421
 
2210
- // dist/profile-lock.js
2211
- var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
2212
-
2213
- // dist/state.js
2214
- import { mkdirSync, readFileSync, unlinkSync } from "node:fs";
2215
- import { join } from "node:path";
2216
- var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
2217
- var User = object({ id: optional(string()), email: optional(string()), name: optional(string()) });
2218
- var File = object({
2219
- id: ID,
2220
- name: string(),
2221
- mime: string(),
2222
- parents: array(ID),
2223
- version: optional(string()),
2224
- modifiedAt: optional(string()),
2225
- url: string(),
2226
- trashed: boolean(),
2227
- canDownload: boolean(),
2228
- size: optional(number()),
2229
- createdAt: optional(string()),
2230
- description: optional(string()),
2231
- driveId: optional(string()),
2232
- owners: optional(array(User)),
2233
- lastModifiedBy: optional(User),
2234
- providerMetadata: optional(unknown())
2235
- });
2236
- var Skip = object({
2237
- id: ID,
2238
- reason: string(),
2239
- file: optional(File),
2240
- textLimit: optional(number()),
2241
- storeRefusedIn: optional(string())
2242
- });
2243
- var State = object({
2244
- version: literal(1),
2245
- store: optional(string()),
2246
- linkedThrough: optional(string()),
2247
- linksPending: optional(boolean()),
2248
- linksVersion: optional(pipe(number(), integer(), minValue(1))),
2249
- principal: string(),
2250
- scope: string(),
2251
- cursor: optional(string()),
2252
- folders: record(ID, File),
2253
- documents: record(ID, object({
2254
- metadata: File,
2255
- hash: string(),
2256
- reference: string(),
2257
- tabs: number(),
2258
- notRead: optional(string()),
2259
- picture: optional(picklist(["saved", "too-large"]))
2260
- })),
2261
- skipped: array(Skip),
2262
- lastSync: optional(string()),
2263
- pending: optional(object({
2264
- cursor: string(),
2265
- scope: string(),
2266
- folders: record(ID, File),
2267
- jobs: array(object({ id: ID, kind: picklist(["save", "remove"]), file: optional(File) })),
2268
- skipped: array(Skip)
2269
- }))
2270
- });
2271
- var Walk = object({
2272
- scope: string(),
2273
- cursor: string(),
2274
- stack: array(object({ id: ID, ancestry: array(ID), folder: optional(File) })),
2275
- visited: array(ID),
2276
- folders: record(ID, File),
2277
- files: array(File),
2278
- discovered: number()
2279
- });
2280
- var profileDir = /* @__PURE__ */ __name((env, name) => join(paths(env).state, "profiles", profileName(name)), "profileDir");
2281
- var statePath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "state.json"), "statePath");
2282
- var readState = /* @__PURE__ */ __name((env, name, principal) => {
2283
- let value;
2284
- try {
2285
- value = JSON.parse(readFileSync(statePath(env, name), "utf8"));
2286
- } catch (error) {
2287
- if (error.code === "ENOENT")
2288
- return { version: 1, principal, scope: "", folders: {}, documents: {}, skipped: [] };
2289
- throw new CliError("configuration_error", "sync state is unreadable; refusing to reset its checkpoint", {
2290
- reason: "state.invalid"
2291
- });
2292
- }
2293
- const parsed = safeParse(State, value);
2294
- if (!parsed.success || parsed.output.principal !== principal)
2295
- throw new CliError("configuration_error", "sync state is invalid or belongs to another Google account", {
2296
- reason: "state.invalid"
2297
- });
2298
- return parsed.output;
2299
- }, "readState");
2300
- var saveState = /* @__PURE__ */ __name((env, name, state) => {
2301
- writeSecurely(statePath(env, name), `${JSON.stringify(state)}
2302
- `, 384);
2303
- }, "saveState");
2304
- var walkPath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "walk.json"), "walkPath");
2305
- var readWalk = /* @__PURE__ */ __name((env, name, scope) => {
2306
- try {
2307
- const parsed = safeParse(Walk, JSON.parse(readFileSync(walkPath(env, name), "utf8")));
2308
- return parsed.success && parsed.output.scope === scope ? parsed.output : void 0;
2309
- } catch {
2310
- return void 0;
2311
- }
2312
- }, "readWalk");
2313
- var saveWalk = /* @__PURE__ */ __name((env, name, walk) => {
2314
- writeSecurely(walkPath(env, name), `${JSON.stringify(walk)}
2315
- `, 384);
2316
- }, "saveWalk");
2317
- var removeWalk = /* @__PURE__ */ __name((env, name) => {
2318
- try {
2319
- unlinkSync(walkPath(env, name));
2320
- } catch (error) {
2321
- if (error.code !== "ENOENT")
2322
- throw error;
2323
- }
2324
- }, "removeWalk");
2325
- var ensureProfileDir = /* @__PURE__ */ __name((env, name) => {
2326
- mkdirSync(profileDir(env, name), { recursive: true, mode: 448 });
2327
- }, "ensureProfileDir");
2328
- var snapshotPath = /* @__PURE__ */ __name((env, name, id) => join(profileDir(env, name), "documents", `${fileId(id)}.json`), "snapshotPath");
2329
- var saveSnapshot = /* @__PURE__ */ __name((env, name, content) => {
2330
- const path = snapshotPath(env, name, content.metadata.id);
2331
- writeSecurely(path, `${JSON.stringify(content)}
2332
- `, 384);
2333
- writeSecurely(path.replace(/\.json$/, ".md"), content.markdown, 384);
2334
- }, "saveSnapshot");
2335
- var removeSnapshot = /* @__PURE__ */ __name((env, name, id) => {
2336
- const path = snapshotPath(env, name, id);
2337
- for (const file of [path, path.replace(/\.json$/, ".md")]) {
2338
- try {
2339
- unlinkSync(file);
2340
- } catch (error) {
2341
- if (error.code !== "ENOENT")
2342
- throw error;
2343
- }
2344
- }
2345
- }, "removeSnapshot");
2346
- var readSnapshot = /* @__PURE__ */ __name((env, name, id) => {
2347
- try {
2348
- return JSON.parse(readFileSync(snapshotPath(env, name, id), "utf8"));
2349
- } catch {
2350
- throw new CliError("not_found", "source snapshot is unavailable \u2014 run drive <profile> sync --rescan", {
2351
- reason: "state.snapshot-missing"
2352
- });
2353
- }
2354
- }, "readSnapshot");
2355
-
2356
- // dist/profile-lock.js
2357
- var lockProfile = /* @__PURE__ */ __name(async (env, name) => {
2358
- ensureProfileDir(env, name);
2359
- let compromised = false;
2360
- try {
2361
- const release = await import_proper_lockfile.default.lock(profileDir(env, name), {
2362
- stale: 3e4,
2363
- retries: 0,
2364
- onCompromised: /* @__PURE__ */ __name(() => {
2365
- compromised = true;
2366
- }, "onCompromised")
2367
- });
2368
- return {
2369
- release,
2370
- assertHeld: /* @__PURE__ */ __name(() => {
2371
- if (compromised)
2372
- throw new CliError("provider_unavailable", "profile lock was lost; retry the operation", {
2373
- reason: "profile.busy"
2374
- });
2375
- }, "assertHeld")
2376
- };
2377
- } catch {
2378
- throw new CliError("provider_unavailable", "another sync or knowledge operation holds this profile's lock; retry later", { reason: "profile.busy" });
2379
- }
2380
- }, "lockProfile");
2381
-
2382
2422
  // dist/commands/catalog.js
2383
2423
  var local = /* @__PURE__ */ __name((command, mutates = false) => annotate(command, { effects: mutates ? LOCAL_WRITE : LOCAL_READ }), "local");
2384
2424
  var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
@@ -2467,10 +2507,10 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
2467
2507
  }, "installCatalogCommands");
2468
2508
 
2469
2509
  // dist/commands/config.js
2470
- import { join as join3 } from "node:path";
2510
+ import { join as join4 } from "node:path";
2471
2511
 
2472
2512
  // dist/policy.js
2473
- import { join as join2 } from "node:path";
2513
+ import { join as join3 } from "node:path";
2474
2514
  var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
2475
2515
  var overridesOf = /* @__PURE__ */ __name((entries = []) => {
2476
2516
  const levels = {};
@@ -2559,11 +2599,11 @@ var guardedGoogleWrite = /* @__PURE__ */ __name(async (env, profile, key, act, f
2559
2599
  permissionDefaults: DEFAULT_LEVELS,
2560
2600
  ask: /* @__PURE__ */ __name(async (permission) => checkPolicy(env, profile, permission, true, flags, ask), "ask"),
2561
2601
  sendsPerHour: Number.MAX_SAFE_INTEGER,
2562
- journal: new SendJournal(join2(paths(env).state, "sends", `${profile}.jsonl`), {
2602
+ journal: new SendJournal(join3(paths(env).state, "sends", `${profile}.jsonl`), {
2563
2603
  service: "drive",
2564
2604
  version: VERSION
2565
2605
  }),
2566
- recipients: new RecipientList(join2(paths(env).state, "recipients", `${profile}.json`), "drive"),
2606
+ recipients: new RecipientList(join3(paths(env).state, "recipients", `${profile}.json`), "drive"),
2567
2607
  warn: /* @__PURE__ */ __name(() => {
2568
2608
  }, "warn")
2569
2609
  });
@@ -2632,7 +2672,7 @@ var installConfigCommands = /* @__PURE__ */ __name((program, { env, selected, ou
2632
2672
  "drive personal config set max_text_chars 100000",
2633
2673
  `drive personal config set permissions.files '"readonly"' --defaults`,
2634
2674
  "drive personal config set record true --defaults"
2635
- ]).argument("<key>", "max_text_chars, picture_search, google_client_id, record, record_input, keep_runs_for_days, keep_successful_runs_for_days, runs_size_limit_mb, shared AI settings, permissions.<key> or models.<purpose>.<field>").argument("<json-value>", "the new value, as JSON").option("--defaults", "change the defaults instead of this profile").action((key, raw, args) => {
2675
+ ]).argument("<key>", "max_text_chars, picture_search, google_client_id, max_add_profiles, record, record_input, keep_runs_for_days, keep_successful_runs_for_days, runs_size_limit_mb, shared AI settings, permissions.<key> or models.<purpose>.<field>").argument("<json-value>", "the new value, as JSON").option("--defaults", "change the defaults instead of this profile").action((key, raw, args) => {
2636
2676
  const file = editable();
2637
2677
  const { at: scope, scope: name } = scopeOf(file, args.defaults);
2638
2678
  const setting = settingAt(key);
@@ -2654,6 +2694,8 @@ var installConfigCommands = /* @__PURE__ */ __name((program, { env, selected, ou
2654
2694
  throw new CliError("validation_error", "picture_search is true or false, set per profile");
2655
2695
  if (head === "max_text_chars")
2656
2696
  parsed = checkTextLimit(parsed);
2697
+ if (head === "max_add_profiles")
2698
+ parsed = checkAddProfiles(parsed);
2657
2699
  const at = [...scope, ...setting];
2658
2700
  const next = isNode(file.raw) ? structuredClone(file.raw) : {};
2659
2701
  let node = next;
@@ -2728,10 +2770,8 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2728
2770
  });
2729
2771
  const download = /* @__PURE__ */ __name(async (kind, id, acceptTerms) => {
2730
2772
  if (policyFlags().offline)
2731
- throw new CliError("permission_error", "downloading a model needs the network; --offline was requested", {
2732
- reason: "offline.refused"
2733
- });
2734
- const { downloadImageModel, downloadTextModel } = await import("./services-2W4J7EMW.js");
2773
+ throw offlineRefused("downloading a model needs the network");
2774
+ const { downloadImageModel, downloadTextModel } = await import("./services-TYDMFQCA.js");
2735
2775
  const progress = /* @__PURE__ */ __name((line) => {
2736
2776
  if (!program.opts().quiet)
2737
2777
  streams.diagnostic(line);
@@ -2745,7 +2785,7 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2745
2785
  licence: model.licence,
2746
2786
  size_bytes: model.files.reduce((sum, file) => sum + file.bytes, 0),
2747
2787
  downloaded: true,
2748
- path: join3(directory, model.id)
2788
+ path: join4(directory, model.id)
2749
2789
  }));
2750
2790
  }, "download");
2751
2791
  const sharedModels = modelCatalogueCommand(DRIVE_APP, {
@@ -3568,6 +3608,102 @@ var changedCopy = /* @__PURE__ */ __name(({ changed, local_modified_at }) => {
3568
3608
  };
3569
3609
  }, "changedCopy");
3570
3610
 
3611
+ // dist/documents-add.js
3612
+ var PASSES_ON = /* @__PURE__ */ new Set(["not_found", "permission_error", "authentication_error"]);
3613
+ var HOW = "drive <profile> documents add <url>, or --profiles <a,b|all>";
3614
+ var profilesToAdd = /* @__PURE__ */ __name((env, { option, word, chosen, lock }) => {
3615
+ if (option !== void 0 && word !== void 0)
3616
+ throw new CliError("validation_error", "name the profiles once: a profile word or --profiles, not both", {
3617
+ reason: "profile.conflict",
3618
+ param: "--profiles"
3619
+ });
3620
+ const listed2 = option === void 0 ? void 0 : option.trim() === "all" ? "all" : option.split(",").map((one) => one.trim()).filter(Boolean);
3621
+ if (lock !== void 0) {
3622
+ const locked = profileName(lock);
3623
+ if (listed2 === "all")
3624
+ throw profileLocked(locked, "every profile (all)");
3625
+ for (const name of listed2 ?? [word ?? chosen ?? locked])
3626
+ if (name !== locked)
3627
+ throw profileLocked(locked, "any other profile");
3628
+ return [locked];
3629
+ }
3630
+ const choices = Object.keys(readConfig(env).profiles).sort();
3631
+ const single = word ?? chosen;
3632
+ const names = listed2 === "all" ? choices : listed2 ?? (single === void 0 ? [] : [single]);
3633
+ if (names.length === 0)
3634
+ throw profileRequired(choices, HOW);
3635
+ const unique = [...new Set(names.map(profileName))];
3636
+ const most = maxAddProfiles(env);
3637
+ if (unique.length > most)
3638
+ throw new CliError("validation_error", `documents add tries at most ${most} profiles (max_add_profiles); name fewer with --profiles \u2014 profiles here: ${choices.join(", ")}`, { reason: "profile.too-many", profiles: choices, max_add_profiles: most });
3639
+ for (const name of unique)
3640
+ activeProfile(env, name);
3641
+ return unique;
3642
+ }, "profilesToAdd");
3643
+ var missOf = /* @__PURE__ */ __name((profile, error) => {
3644
+ if (!isCliError(error) || !PASSES_ON.has(error.code))
3645
+ return void 0;
3646
+ const told = error.details.google_reason;
3647
+ return {
3648
+ profile,
3649
+ code: error.code,
3650
+ reason: error.details.reason ?? null,
3651
+ ...typeof told === "string" ? { google_reason: told } : {}
3652
+ };
3653
+ }, "missOf");
3654
+ var stoppedAt = /* @__PURE__ */ __name((error, profile, tried) => isCliError(error) ? new CliError(error.code, error.message, { ...error.details, profile, tried }) : error, "stoppedAt");
3655
+ var notOpened = /* @__PURE__ */ __name((tried) => {
3656
+ const codes = new Set(tried.map((one) => one.code));
3657
+ const [only] = codes.size === 1 ? codes : [];
3658
+ const [code, reason] = only === "authentication_error" ? ["authentication_error", "document.signed-out"] : only === "permission_error" ? ["permission_error", "document.no-access"] : ["not_found", "document.not-opened"];
3659
+ const signIn = codes.has("authentication_error") ? "; sign in again with drive <profile> session start" : "";
3660
+ return new CliError(code, `no profile opened this document: ${tried.map((one) => `${one.profile} (${one.reason ?? one.code})`).join(", ")}${signIn}`, { reason, profiles: tried.map((one) => one.profile), tried });
3661
+ }, "notOpened");
3662
+ var addDocument = /* @__PURE__ */ __name(async (input) => {
3663
+ const id = fileId(input.url);
3664
+ const tried = [];
3665
+ for (const profile of input.profiles) {
3666
+ let content;
3667
+ try {
3668
+ content = await (await input.source(profile)).content(id, input.maxChars(profile));
3669
+ } catch (error) {
3670
+ const missed = missOf(profile, error);
3671
+ if (!missed)
3672
+ throw stoppedAt(error, profile, tried);
3673
+ tried.push(missed);
3674
+ continue;
3675
+ }
3676
+ const url = content.metadata.url;
3677
+ const added = await input.save({
3678
+ kind: "page",
3679
+ text: content.text,
3680
+ read: content.text.trim() ? "extracted" : "no-text",
3681
+ title: input.title ?? content.metadata.name,
3682
+ url,
3683
+ mime: content.metadata.mime,
3684
+ size: content.metadata.size ?? null,
3685
+ metadata: { source: "google-drive", google_file_id: id },
3686
+ ...input.subjects?.length ? { subjects: input.subjects } : {},
3687
+ by: input.by
3688
+ }, id);
3689
+ return {
3690
+ ref: added.note.ref,
3691
+ created: added.created,
3692
+ duplicate_of: added.duplicateOf,
3693
+ title: added.note.title,
3694
+ url,
3695
+ file_id: id,
3696
+ mime: content.metadata.mime,
3697
+ chars: content.text.length,
3698
+ kept: added.kept,
3699
+ subjects: added.subjects,
3700
+ profile,
3701
+ tried
3702
+ };
3703
+ }
3704
+ throw notOpened(tried);
3705
+ }, "addDocument");
3706
+
3571
3707
  // dist/commands/documents.js
3572
3708
  var DOCUMENT_REF = /^document:[1-9]\d*$/;
3573
3709
  var isDocumentRef = /* @__PURE__ */ __name((input) => DOCUMENT_REF.test(input), "isDocumentRef");
@@ -3599,8 +3735,14 @@ var importedDocument = /* @__PURE__ */ __name((context) => {
3599
3735
  return { id, ref: doc.reference, hash: doc.hash, snapshot: readSnapshot(context.env, context.selected(), id) };
3600
3736
  };
3601
3737
  }, "importedDocument");
3738
+ var addProfilesOf = /* @__PURE__ */ __name((env, command, word) => profilesToAdd(env, {
3739
+ option: command.opts().profiles,
3740
+ word,
3741
+ chosen: env.DRIVE_PROFILE || void 0,
3742
+ lock: env.DRIVE_PROFILE_LOCK || void 0
3743
+ }), "addProfilesOf");
3602
3744
  var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
3603
- const { env, selected, output, withIndex } = context;
3745
+ const { env, selected, output, withIndex, source, profileWord } = context;
3604
3746
  const imported = importedDocument(context);
3605
3747
  const documents = annotate(program.command("documents"), { effects: LOCAL_READ }).description("read imported documents and Google Docs");
3606
3748
  const documentArgument = "document id, Google Docs URL, or a search hit's document: ref";
@@ -3658,6 +3800,28 @@ var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
3658
3800
  const state = readState(env, selected(), activeProfile(env, selected()).principal);
3659
3801
  output(itemOf({ id, path: args.output, format: "markdown", ...ageOf(state) }, staleCopy(state)));
3660
3802
  });
3803
+ examples(annotate(documents.command("add"), { mcp: false, effects: FETCH }).argument("<url>", "Google Drive or Docs URL, or file id").description("keep a Drive document's text in memory, read by the first profile that opens it"), [
3804
+ "drive documents add https://docs.google.com/document/d/DOC_ID/edit --profiles work,personal",
3805
+ "drive personal documents add DOC_ID --subject person:PERSON_UID"
3806
+ ]).option("--profiles <names|all>", "profiles to try in this order, comma-separated, or all; at most max_add_profiles, in place of a profile word").option("--title <title>", "title to keep it under; the document's name when omitted").option("--subject <ref>", "a person, organization, project, task or meeting it is about; repeat to add more", (value, previous = []) => [...previous, value]).action(async (url, args, command) => {
3807
+ const profiles = addProfilesOf(env, command, profileWord());
3808
+ const added = await addDocument({
3809
+ url,
3810
+ profiles,
3811
+ source,
3812
+ maxChars: /* @__PURE__ */ __name((profile) => textLimit(env, profile), "maxChars"),
3813
+ // Opened only once a profile has read the document, so no Google call waits with the store open.
3814
+ save: /* @__PURE__ */ __name((input, driveFileId) => withIndex(async (index) => {
3815
+ if (!index.addSource)
3816
+ throw new CliError("configuration_error", "index cannot keep sources added by hand");
3817
+ return index.addSource(input, driveFileId);
3818
+ }, null), "save"),
3819
+ ...args.title ? { title: args.title } : {},
3820
+ ...args.subject ? { subjects: args.subject } : {},
3821
+ by: "owner"
3822
+ });
3823
+ output(itemOf(added));
3824
+ });
3661
3825
  }, "installDocumentCommands");
3662
3826
 
3663
3827
  // dist/browse.js
@@ -4091,7 +4255,7 @@ var installKnowledgeCommands = /* @__PURE__ */ __name((...args) => {
4091
4255
 
4092
4256
  // dist/commands/mirrors.js
4093
4257
  import { statSync } from "node:fs";
4094
- import { join as join4, resolve } from "node:path";
4258
+ import { join as join5, resolve } from "node:path";
4095
4259
 
4096
4260
  // dist/mirror-docs.js
4097
4261
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -4861,7 +5025,7 @@ var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call })
4861
5025
  });
4862
5026
  return mirror;
4863
5027
  }, "find");
4864
- const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(join4(profileDir(env, name), "mirrors"), mirror, principal, ["doc", "sheet"]), "stateOf");
5028
+ const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(join5(profileDir(env, name), "mirrors"), mirror, principal, ["doc", "sheet"]), "stateOf");
4865
5029
  const syncing = /* @__PURE__ */ __name((name, principal, google) => ({
4866
5030
  target: googleTarget(call, () => google.identity()),
4867
5031
  stateOf: stateOf(name, principal),
@@ -5027,7 +5191,7 @@ var describeCycle = /* @__PURE__ */ __name((cycle) => {
5027
5191
  // dist/download.js
5028
5192
  import { randomUUID } from "node:crypto";
5029
5193
  import { closeSync, createWriteStream, linkSync, lstatSync, mkdirSync as mkdirSync2, openSync, renameSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
5030
- import { dirname, join as join5 } from "node:path";
5194
+ import { dirname, join as join6 } from "node:path";
5031
5195
  import { pipeline } from "node:stream/promises";
5032
5196
  var EXPORT_FORMATS = {
5033
5197
  pdf: "application/pdf",
@@ -5052,7 +5216,7 @@ var saveDownload = /* @__PURE__ */ __name(async (path, overwrite, read, createDi
5052
5216
  const source = await read();
5053
5217
  if (createDirectory)
5054
5218
  mkdirSync2(dirname(path), { recursive: true, mode: 448 });
5055
- const temp = join5(dirname(path), `.${randomUUID()}.tmp`);
5219
+ const temp = join6(dirname(path), `.${randomUUID()}.tmp`);
5056
5220
  let created = false;
5057
5221
  let size2 = 0;
5058
5222
  try {
@@ -22723,7 +22887,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22723
22887
  const app = application(env, { file: args.clientFile, clientId: args.clientId, profile: selected() });
22724
22888
  if (!app.clientSecret)
22725
22889
  streams.diagnostic("your Google app has no secret here, and Google refuses a Desktop app without one: set DRIVE_GOOGLE_CLIENT_SECRET\n");
22726
- const { login } = await import("./login-7RYSDVN3.js");
22890
+ const { login } = await import("./login-XKN3NI6X.js");
22727
22891
  output(itemOf(await login({
22728
22892
  env,
22729
22893
  profile: selected(),
@@ -22754,7 +22918,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22754
22918
  const name = selected();
22755
22919
  const config = readConfig(env);
22756
22920
  const profile = activeProfile(env, name);
22757
- const { credentials } = await import("./tokens-P4LPNUFW.js");
22921
+ const { credentials } = await import("./tokens-MTFJPTYT.js");
22758
22922
  const store = credentials(env, profile.storage, options.keyring);
22759
22923
  store.remove(name);
22760
22924
  writeConfig(env, config);
@@ -22801,7 +22965,7 @@ var selection = /* @__PURE__ */ __name((env, name, source) => {
22801
22965
  return { profile, state, options: { source, destination, collection: `google-drive:${profile.principal}`, env } };
22802
22966
  }, "selection");
22803
22967
  var checkStoreImport = /* @__PURE__ */ __name(async (env, name, source, bindings) => {
22804
- const { ensureSqlite } = await import("./sqlite-runtime-P6BBDX2H.js");
22968
+ const { ensureSqlite } = await import("./sqlite-runtime-UAFJKSJR.js");
22805
22969
  await ensureSqlite();
22806
22970
  const { state, options } = selection(env, name, source);
22807
22971
  const preview = await previewDocumentTransfer({ ...options, bindings });
@@ -22862,7 +23026,7 @@ var installStoreCommands = /* @__PURE__ */ __name((program, context) => {
22862
23026
 
22863
23027
  // dist/commands/sync.js
22864
23028
  import { existsSync } from "node:fs";
22865
- import { join as join6, resolve as resolve4 } from "node:path";
23029
+ import { join as join7, resolve as resolve4 } from "node:path";
22866
23030
 
22867
23031
  // dist/sync.js
22868
23032
  import { resolve as resolve3 } from "node:path";
@@ -22954,7 +23118,7 @@ var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
22954
23118
  const name = selected();
22955
23119
  const profile = activeProfile(env, name);
22956
23120
  const state = readState(env, name, profile.principal);
22957
- const legacyStore = join6(paths(env).state, "drive.db");
23121
+ const legacyStore = join7(paths(env).state, "drive.db");
22958
23122
  output(itemOf({
22959
23123
  profile: name,
22960
23124
  store: {
@@ -22973,9 +23137,9 @@ var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
22973
23137
  }, "installSyncCommands");
22974
23138
 
22975
23139
  // dist/commands/upgrade.js
22976
- import { join as join7 } from "node:path";
23140
+ import { join as join8 } from "node:path";
22977
23141
 
22978
- // node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/update/index.js
23142
+ // node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/update/index.js
22979
23143
  import { realpathSync } from "node:fs";
22980
23144
  import { fileURLToPath } from "node:url";
22981
23145
  var QUIET_WORDS = [
@@ -23045,7 +23209,7 @@ var update = appUpdate({
23045
23209
  command: "drive",
23046
23210
  version: DRIVE_APP.version,
23047
23211
  entry: new URL("../commands/upgrade.js", import.meta.url).href,
23048
- statePath: /* @__PURE__ */ __name((env) => join7(paths(env).state, "update-check.json"), "statePath"),
23212
+ statePath: /* @__PURE__ */ __name((env) => join8(paths(env).state, "update-check.json"), "statePath"),
23049
23213
  enabled: /* @__PURE__ */ __name(() => false, "enabled"),
23050
23214
  offVariables: ["DRIVE_NO_UPDATE_CHECK"]
23051
23215
  });
@@ -23242,13 +23406,11 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23242
23406
  const data = source.frontMatter;
23243
23407
  if (data?.source !== "google-drive" || !data.fileId)
23244
23408
  continue;
23245
- const contributors = [...data.owners ?? [], ...data.lastModifiedBy ? [data.lastModifiedBy] : []];
23246
- if (!contributors.some((user) => googleUserId(user) === googleId))
23409
+ if (!(data.owners ?? []).some((user) => googleUserId(user) === googleId))
23247
23410
  continue;
23248
23411
  await saveContributors(store, principal2, {
23249
23412
  id: data.fileId,
23250
23413
  owners: data.owners,
23251
- lastModifiedBy: data.lastModifiedBy,
23252
23414
  version: data.sourceVersion,
23253
23415
  modifiedAt: data.modifiedAt
23254
23416
  }, source.id, false);
@@ -23264,35 +23426,32 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23264
23426
  };
23265
23427
  return port;
23266
23428
  }, "documentKnowledge");
23429
+ var ownerEvidence = /* @__PURE__ */ __name((metadata) => [
23430
+ "Google Drive lists this person as the document's owner",
23431
+ metadata.version && `version ${metadata.version}`,
23432
+ metadata.modifiedAt && `changed ${metadata.modifiedAt.slice(0, 10)}`
23433
+ ].filter(Boolean).join(", "), "ownerEvidence");
23267
23434
  var saveContributors = /* @__PURE__ */ __name(async (store, principal, metadata, documentId, register = true) => {
23268
- const users = [
23269
- ...(metadata.owners ?? []).map((user) => ({ user, role: "owner" })),
23270
- ...metadata.lastModifiedBy ? [{ user: metadata.lastModifiedBy, role: "last-editor" }] : []
23271
- ];
23272
23435
  const key = { provider: "google-drive", account: principal };
23273
- const identified = users.flatMap(({ user, role }) => {
23436
+ const identified = (metadata.owners ?? []).flatMap((user) => {
23274
23437
  const id = googleUserId(user);
23275
- return id ? [{ id, user, role }] : [];
23438
+ return id ? [{ id, user }] : [];
23276
23439
  });
23277
23440
  if (register && identified.length) {
23278
23441
  await store.accounts.saveAccount(key, { name: "Google Drive" });
23279
23442
  await store.people.savePeople(key, identified.map(({ id, user }) => ({ id, name: user.name ?? user.email ?? null, email: user.email ?? null })));
23280
23443
  }
23281
23444
  const links = [];
23282
- for (const { id, user, role } of identified) {
23445
+ for (const { id } of identified) {
23283
23446
  const person = await store.people.personOf({ provider: "google-drive", id });
23284
23447
  if (person)
23285
23448
  links.push({
23286
23449
  kind: "related-to",
23287
23450
  to: `person:${person.uid}`,
23288
- role,
23289
- evidence: JSON.stringify({
23290
- fileId: metadata.id,
23291
- version: metadata.version,
23292
- modifiedAt: metadata.modifiedAt,
23293
- user
23294
- }),
23451
+ role: "owner",
23452
+ evidence: ownerEvidence(metadata),
23295
23453
  provenance: "google-drive:files.get",
23454
+ // Google's word, not the owner's: the store files it as the account's report, never in his memory or review.
23296
23455
  confirmed: false
23297
23456
  });
23298
23457
  }
@@ -23301,7 +23460,7 @@ var saveContributors = /* @__PURE__ */ __name(async (store, principal, metadata,
23301
23460
 
23302
23461
  // dist/store-transition.js
23303
23462
  import { existsSync as existsSync2 } from "node:fs";
23304
- import { join as join8, resolve as resolve5 } from "node:path";
23463
+ import { join as join9, resolve as resolve5 } from "node:path";
23305
23464
  var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = false) => {
23306
23465
  const profile = activeProfile(env, name);
23307
23466
  const target = resolve5(storePath(env));
@@ -23313,7 +23472,7 @@ var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = fals
23313
23472
  const lock = await lockProfile(env, name);
23314
23473
  try {
23315
23474
  const state = readState(env, name, profile.principal);
23316
- const previous = resolve5(state.store ?? join8(paths(env).state, "drive.db"));
23475
+ const previous = resolve5(state.store ?? join9(paths(env).state, "drive.db"));
23317
23476
  if (previous !== target && existsSync2(previous)) {
23318
23477
  const old = await openStore({ path: previous, env, command: "drive", version: VERSION });
23319
23478
  try {
@@ -23391,12 +23550,22 @@ var DRIVE_PROVIDER = {
23391
23550
  command: "drive",
23392
23551
  opens: { document: "documents show" }
23393
23552
  };
23553
+ var syncedDocument = /* @__PURE__ */ __name(async (store, driveFileId) => {
23554
+ for (const account of await store.notes.documentsAccounts()) {
23555
+ if (account.account?.provider !== DRIVE_PROVIDER.name)
23556
+ continue;
23557
+ const entry = await store.catalog.get(account.id, `${driveFileId}.md`);
23558
+ if (entry?.active && entry.content === "indexed")
23559
+ return entry.ref;
23560
+ }
23561
+ return void 0;
23562
+ }, "syncedDocument");
23394
23563
  var openIndex = /* @__PURE__ */ __name(async (env, name, rescan = false) => {
23395
23564
  if (name)
23396
23565
  activeProfile(env, name);
23397
- const { ensureSqlite } = await import("./sqlite-runtime-P6BBDX2H.js");
23566
+ const { ensureSqlite } = await import("./sqlite-runtime-UAFJKSJR.js");
23398
23567
  await ensureSqlite();
23399
- const { openStore: openStore2, storePath: storePath2 } = await import("./store-IVV2BAGZ.js");
23568
+ const { openStore: openStore2, storePath: storePath2 } = await import("./store-EJN27MXI.js");
23400
23569
  if (env.DRIVE_STORE)
23401
23570
  throw new CliError("configuration_error", "DRIVE_STORE has been retired; use MESSAGING_STORE to select the shared database", { reason: "store.override-retired" });
23402
23571
  const store = await openStore2({ path: storePath2(env), env, command: "drive", version: VERSION });
@@ -23438,10 +23607,19 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23438
23607
  await folder(principal, true);
23439
23608
  await store.accounts.saveProfile("drive", name, { provider: "google-drive", account: principal });
23440
23609
  }, "registerProfile"),
23610
+ addSource: /* @__PURE__ */ __name(async (input, driveFileId) => {
23611
+ const synced = driveFileId === void 0 ? void 0 : await syncedDocument(store, driveFileId);
23612
+ if (!synced)
23613
+ return store.notes.saveAddedSource(input);
23614
+ for (const subject of input.subjects ?? [])
23615
+ await store.notes.addLink({ from: synced, to: subject, kind: "about", origin: "owner", by: input.by });
23616
+ const subjects = (await store.notes.links({ from: synced, kind: "about" })).flatMap((link) => link.to ?? []);
23617
+ return { note: await store.notes.note(synced), created: false, duplicateOf: synced, kept: null, subjects };
23618
+ }, "addSource"),
23441
23619
  linkMessages: /* @__PURE__ */ __name((documents, since) => store.notes.linkMessages({ documents, ...since ? { since } : {} }), "linkMessages"),
23442
23620
  knowledge: documentKnowledge2(store, async (principal) => (await folder(principal, false))?.id),
23443
23621
  openPictures: /* @__PURE__ */ __name(async () => {
23444
- const { openPictureEmbedderFor, savePicture } = await import("./services-2W4J7EMW.js");
23622
+ const { openPictureEmbedderFor, savePicture } = await import("./services-TYDMFQCA.js");
23445
23623
  const embedder = pictureEmbedder ?? await openPictureEmbedderFor({ env, command: "drive" });
23446
23624
  return {
23447
23625
  save: /* @__PURE__ */ __name((reference, bytes) => savePicture(store, { ref: reference }, bytes, { embedder }), "save"),
@@ -23460,7 +23638,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23460
23638
  has_more: false,
23461
23639
  meaning_skipped: "this Google account has no imported sources"
23462
23640
  };
23463
- const { searchNotes } = await import("./services-2W4J7EMW.js");
23641
+ const { searchNotes } = await import("./services-TYDMFQCA.js");
23464
23642
  const result = await searchNotes(store, query, {
23465
23643
  ...options,
23466
23644
  folderIds: selected ? [selected.id] : [],
@@ -23491,7 +23669,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23491
23669
  };
23492
23670
  }, "search"),
23493
23671
  embed: /* @__PURE__ */ __name(async (max) => {
23494
- const { embedNotes } = await import("./services-2W4J7EMW.js");
23672
+ const { embedNotes } = await import("./services-TYDMFQCA.js");
23495
23673
  return embedNotes(store, { maxChunks: max, env, command: "drive" });
23496
23674
  }, "embed"),
23497
23675
  close: /* @__PURE__ */ __name(() => store.close(), "close")
@@ -23502,7 +23680,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23502
23680
  import { createHash as createHash2 } from "node:crypto";
23503
23681
  import { createReadStream, mkdirSync as mkdirSync3, readFileSync as readFileSync5, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
23504
23682
  import { open } from "node:fs/promises";
23505
- import { basename, join as join9, resolve as resolve6 } from "node:path";
23683
+ import { basename, join as join10, resolve as resolve6 } from "node:path";
23506
23684
  var START = "https://www.googleapis.com/upload/drive/v3/files";
23507
23685
  var FIELDS = "id,name,size,md5Checksum,mimeType,parents";
23508
23686
  var QUANTUM = 256 * 1024;
@@ -23533,7 +23711,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23533
23711
  throw new CliError("validation_error", "a chunk must be a multiple of 256 KiB");
23534
23712
  const sleep = input.sleep ?? ((ms) => new Promise((wake) => setTimeout(wake, ms)));
23535
23713
  const key = createHash2("sha256").update(JSON.stringify([path, size2, stat.mtimeMs, name, input.parent ?? ""])).digest("hex").slice(0, 24);
23536
- const checkpointPath = join9(input.stateDir, "uploads", `${key}.json`);
23714
+ const checkpointPath = join10(input.stateDir, "uploads", `${key}.json`);
23537
23715
  const readCheckpoint = /* @__PURE__ */ __name(() => {
23538
23716
  try {
23539
23717
  return JSON.parse(readFileSync5(checkpointPath, "utf8"));
@@ -23542,7 +23720,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23542
23720
  }
23543
23721
  }, "readCheckpoint");
23544
23722
  const saveCheckpoint = /* @__PURE__ */ __name((sessionUri) => {
23545
- mkdirSync3(join9(input.stateDir, "uploads"), { recursive: true, mode: 448 });
23723
+ mkdirSync3(join10(input.stateDir, "uploads"), { recursive: true, mode: 448 });
23546
23724
  const checkpoint = {
23547
23725
  session_uri: sessionUri,
23548
23726
  path,
@@ -23709,14 +23887,13 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23709
23887
  if (lock !== void 0) {
23710
23888
  profileName(lock);
23711
23889
  if (named !== void 0 && profileName(named) !== lock)
23712
- throw new CliError("permission_error", `this process is locked to profile ${lock} (DRIVE_PROFILE_LOCK) \u2014 profile ${named} is refused`, { reason: "profile.locked" });
23890
+ throw profileLocked(lock, `profile ${named}`);
23713
23891
  return lock;
23714
23892
  }
23715
23893
  if (named)
23716
23894
  return profileName(named);
23717
23895
  const config = readConfig(env, permissionNames(policyFlags().permissionKeys ?? /* @__PURE__ */ new Set()));
23718
- const choices = Object.keys(config.profiles).sort();
23719
- throw new CliError("validation_error", choices.length ? `name a profile: drive <profile> \u2026 \u2014 profiles here: ${choices.join(", ")} (or set DRIVE_PROFILE)` : "no profiles here yet; create one with drive personal session start (any name in place of personal)", { reason: "profile.required", profiles: choices });
23896
+ throw profileRequired(Object.keys(config.profiles).sort());
23720
23897
  }, "selected");
23721
23898
  let currentAction;
23722
23899
  let checkedMethod;
@@ -23778,21 +23955,22 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23778
23955
  }, "output");
23779
23956
  const signal = /* @__PURE__ */ __name(() => environment().signal, "signal");
23780
23957
  const signedIn = /* @__PURE__ */ __name(async (name, scope2) => {
23781
- const { authorizedClient, checkAuthorization } = await import("./tokens-P4LPNUFW.js");
23958
+ const { authorizedClient, checkAuthorization } = await import("./tokens-MTFJPTYT.js");
23782
23959
  const client = authorizedClient(env, name, environment().keyring, signal());
23783
23960
  await checkAuthorization(client, scope2);
23784
23961
  return client;
23785
23962
  }, "signedIn");
23786
- const source = /* @__PURE__ */ __name(async () => {
23787
- const name = selected();
23963
+ const source = /* @__PURE__ */ __name(async (profile) => {
23964
+ const name = profile ?? selected();
23788
23965
  const fake = environment().source;
23789
23966
  if (fake)
23790
23967
  return fake(name);
23791
- const [{ googleSource }, client] = await Promise.all([import("./google-CIWUVJ5C.js"), signedIn(name)]);
23968
+ const [{ googleSource }, client] = await Promise.all([import("./google-DPD5N6AQ.js"), signedIn(name)]);
23792
23969
  return googleSource(client);
23793
23970
  }, "source");
23794
- const withIndex = /* @__PURE__ */ __name(async (fn) => {
23795
- const index = await (environment().index?.() ?? openIndex(env, selected(), currentAction?.opts().rescan === true));
23971
+ const withIndex = /* @__PURE__ */ __name(async (fn, profile) => {
23972
+ const name = profile === void 0 ? selected() : profile ?? void 0;
23973
+ const index = await (environment().index?.() ?? openIndex(env, name, currentAction?.opts().rescan === true));
23796
23974
  try {
23797
23975
  return await fn(index);
23798
23976
  } finally {
@@ -23854,6 +24032,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23854
24032
  runsOf.set(program, runs);
23855
24033
  const imported = importedDocument(context);
23856
24034
  installSessionCommands(program, context);
24035
+ installAccountCommands(program, context);
23857
24036
  installFolderCommands(program, context, (method, params) => remote.call(method, params));
23858
24037
  installSyncCommands(program, context);
23859
24038
  installStoreCommands(program, context);
@@ -23930,7 +24109,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23930
24109
  if (fake)
23931
24110
  return await fake.call(method, params, body);
23932
24111
  const [{ googleApi }, client] = await Promise.all([
23933
- import("./google-api-Z3NSTBBR.js"),
24112
+ import("./google-api-P5DRHD7L.js"),
23934
24113
  signedIn(selected(), descriptor.scope)
23935
24114
  ]);
23936
24115
  return await googleApi(client).call(method, params, body);
@@ -23956,7 +24135,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23956
24135
  if (fake)
23957
24136
  return fake(id, mime);
23958
24137
  const [{ googleDownload }, client] = await Promise.all([
23959
- import("./google-api-Z3NSTBBR.js"),
24138
+ import("./google-api-P5DRHD7L.js"),
23960
24139
  signedIn(selected(), apiMethod(method).scope)
23961
24140
  ]);
23962
24141
  return googleDownload(client)(id, mime);
@@ -23974,7 +24153,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23974
24153
  let request = environment().uploadRequest;
23975
24154
  if (!request) {
23976
24155
  const [{ googleUploadRequest }, client] = await Promise.all([
23977
- import("./google-api-Z3NSTBBR.js"),
24156
+ import("./google-api-P5DRHD7L.js"),
23978
24157
  signedIn(selected(), apiMethod(method).scope)
23979
24158
  ]);
23980
24159
  request = googleUploadRequest(client);
@@ -24064,6 +24243,16 @@ Availability: unavailable \u2014 ${availability.reason}
24064
24243
  }
24065
24244
  if (words === "mcp revoke" && program.opts().readOnly)
24066
24245
  throw readOnlyRefusal("--read-only", "forget the browser logins");
24246
+ if (words === "documents add") {
24247
+ const flags2 = policyFlags();
24248
+ for (const name of addProfilesOf(env, action, profileWord()))
24249
+ await checkPolicy(env, name, "documents.add", true, flags2, askOnce);
24250
+ if (flags2.offline)
24251
+ throw offlineRefused();
24252
+ if (flags2.dryRun)
24253
+ preview();
24254
+ return;
24255
+ }
24067
24256
  if (PROFILE_SET_COMMANDS.has(words) || path[0] === "mcp") {
24068
24257
  const named = profileWord() ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK;
24069
24258
  if (words === "mcp serve" && named && action.opts().profiles === void 0)
@@ -24079,9 +24268,9 @@ Availability: unavailable \u2014 ${availability.reason}
24079
24268
  const name = action.opts().output;
24080
24269
  if (typeof name !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(name))
24081
24270
  throw new CliError("validation_error", "MCP exports take a filename inside the profile export folder");
24082
- const directory = join10(paths(env).cache, "exports", selected());
24271
+ const directory = join11(paths(env).cache, "exports", selected());
24083
24272
  mkdirSync4(directory, { recursive: true, mode: 448 });
24084
- action.setOptionValue("output", join10(directory, name));
24273
+ action.setOptionValue("output", join11(directory, name));
24085
24274
  }
24086
24275
  if (agent() && changesAuthority(action)) {
24087
24276
  const authority = policySettings(env, selected(), policyFlags());
@@ -24115,9 +24304,7 @@ Availability: unavailable \u2014 ${availability.reason}
24115
24304
  await checkPolicy(env, selected(), permission, mutates, flags, askOnce);
24116
24305
  checkedMethod = method;
24117
24306
  if (flags.offline && (method || metadata.effects?.remote !== "none"))
24118
- throw new CliError("permission_error", "this command may require network access; --offline was requested", {
24119
- reason: "offline.refused"
24120
- });
24307
+ throw offlineRefused();
24121
24308
  if (flags.dryRun && !googleOnly(metadata.effects))
24122
24309
  preview();
24123
24310
  if (flags.dryRun) {
@@ -24178,7 +24365,7 @@ var mcpCommand = /* @__PURE__ */ __name(() => {
24178
24365
  const environment = environmentOf(action);
24179
24366
  if (environment.api)
24180
24367
  return;
24181
- const { grantAvailability } = await import("./grants-3S4RL3WB.js");
24368
+ const { grantAvailability } = await import("./grants-TX4MHLI4.js");
24182
24369
  availability = grantAvailability(rootOf(root), environment.env ?? process.env, environment.keyring);
24183
24370
  });
24184
24371
  }, "mcpCommand");