@wirecat/drive-cli 0.69.0 → 0.70.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 (217) hide show
  1. package/contracts/wirecat.json +14 -13
  2. package/dist/age.d.ts +0 -36
  3. package/dist/age.d.ts.map +1 -1
  4. package/dist/age.js +0 -22
  5. package/dist/age.js.map +1 -1
  6. package/dist/bin/drive.js +2 -2
  7. package/dist/bundle/{all-profiles-B4A737YW.js → all-profiles-FW3GK3QO.js} +13 -13
  8. package/dist/bundle/{anthropic-RZGPDESM.js → anthropic-QVKJT3II.js} +8 -8
  9. package/dist/bundle/{app-server-OWEW7DY5.js → app-server-QU73RD5R.js} +66 -58
  10. package/dist/bundle/{bun-V5QLYBZU.js → bun-5XCD5CBB.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-KHLHXXGH.js → bun-sqlite-TIGSVNSV.js} +9 -9
  12. package/dist/bundle/{chunk-GK6KXBL6.js → chunk-2SBC4DVV.js} +4 -4
  13. package/dist/bundle/{chunk-E7URRFBB.js → chunk-3AHBZP33.js} +10 -15
  14. package/dist/bundle/{chunk-V4FMN5A6.js → chunk-3CHW7JGR.js} +17 -17
  15. package/dist/bundle/chunk-3TCMANIM.js +387 -0
  16. package/dist/bundle/{chunk-6EL5AVXX.js → chunk-3UWRAIWA.js} +4 -4
  17. package/dist/bundle/{chunk-2DS2TDGW.js → chunk-3UZ4OH22.js} +18 -18
  18. package/dist/bundle/{chunk-WQOGHND4.js → chunk-4WK26MPY.js} +1 -1
  19. package/dist/bundle/{chunk-AD7VI3XU.js → chunk-54BQWRJL.js} +7 -7
  20. package/dist/bundle/{chunk-EA2OB75T.js → chunk-54NDYVZA.js} +1 -1
  21. package/dist/bundle/{chunk-4YECZ6CN.js → chunk-5JTB4URG.js} +12 -12
  22. package/dist/bundle/{chunk-M4OP5ASJ.js → chunk-66PL7P4C.js} +1 -1
  23. package/dist/bundle/{chunk-BVVXYZSU.js → chunk-6BMTW5A6.js} +9 -9
  24. package/dist/bundle/{chunk-6D44YQ5X.js → chunk-6DPOWBKA.js} +6 -6
  25. package/dist/bundle/{chunk-AMQGKMLZ.js → chunk-7C5KENNU.js} +3 -3
  26. package/dist/bundle/chunk-7DJNURKV.js +823 -0
  27. package/dist/bundle/{chunk-5TK2YQCO.js → chunk-7IBENBCK.js} +2 -2
  28. package/dist/bundle/chunk-7QSRODXM.js +259 -0
  29. package/dist/bundle/{chunk-HCZYJMBP.js → chunk-ABZ2NYDT.js} +1 -1
  30. package/dist/bundle/{chunk-RLGQMMYE.js → chunk-AV5UKJZM.js} +35 -13
  31. package/dist/bundle/{chunk-533XOW74.js → chunk-BBFXQPKD.js} +3 -3
  32. package/dist/bundle/{chunk-ZUG67442.js → chunk-BBRMDMIR.js} +3 -3
  33. package/dist/bundle/{chunk-LRCSDAYK.js → chunk-BD2K2ONK.js} +4 -4
  34. package/dist/bundle/{chunk-CAQ5GW3A.js → chunk-BFKFKDPC.js} +1 -1
  35. package/dist/bundle/{chunk-OOIAJRKQ.js → chunk-BXPC5TFG.js} +2 -2
  36. package/dist/bundle/chunk-DHX27E5M.js +31 -0
  37. package/dist/bundle/{chunk-L342KHIZ.js → chunk-DR57KDAY.js} +6 -6
  38. package/dist/bundle/{chunk-XUHQ7DVT.js → chunk-DVI72ZQG.js} +1 -1
  39. package/dist/bundle/{chunk-N4ACIIQB.js → chunk-DVVUJ254.js} +2 -2
  40. package/dist/bundle/{chunk-MHXZ62CU.js → chunk-EDO5LZVF.js} +1 -1
  41. package/dist/bundle/{chunk-LUZRVBQR.js → chunk-EG62WVR2.js} +6 -6
  42. package/dist/bundle/{chunk-WNMPIRRF.js → chunk-F5KJWRF5.js} +3 -3
  43. package/dist/bundle/{chunk-U3RXH6RY.js → chunk-FADAOLGB.js} +4 -4
  44. package/dist/bundle/{chunk-4ZFO2CVH.js → chunk-FCSHWUMW.js} +5 -5
  45. package/dist/bundle/{chunk-GHFBT2ZM.js → chunk-FN3RXBO7.js} +6 -6
  46. package/dist/bundle/{chunk-GTDCP5OG.js → chunk-FONIFRYI.js} +4 -4
  47. package/dist/bundle/{chunk-IQ2QU2X6.js → chunk-FVTKFIQH.js} +981 -589
  48. package/dist/bundle/{chunk-F5UUJU6R.js → chunk-FYPW7NMH.js} +4 -4
  49. package/dist/bundle/{chunk-FIVFP53N.js → chunk-GA3URWIF.js} +1 -1
  50. package/dist/bundle/{chunk-HEBZCKMU.js → chunk-GAHIHE4K.js} +1778 -2232
  51. package/dist/bundle/{chunk-4J5GJJ2I.js → chunk-GJZSVSV3.js} +2 -2
  52. package/dist/bundle/{chunk-VUPWDCYV.js → chunk-GK3BJMGK.js} +1 -1
  53. package/dist/bundle/{chunk-6XNTELM5.js → chunk-GPDPEHYX.js} +1 -1
  54. package/dist/bundle/{chunk-CU6RATZH.js → chunk-GV5DGHSA.js} +4 -4
  55. package/dist/bundle/{chunk-JRFKCYMW.js → chunk-HHAZ6DCY.js} +23 -6
  56. package/dist/bundle/{chunk-OUM4ZO53.js → chunk-HK225DAG.js} +1 -1
  57. package/dist/bundle/{chunk-5SJZDEIO.js → chunk-HRATXUFH.js} +20 -20
  58. package/dist/bundle/{chunk-TZ75K6R7.js → chunk-HWUPU6WX.js} +8 -8
  59. package/dist/bundle/{chunk-3RLRJHAI.js → chunk-HYXXMSVD.js} +7688 -8301
  60. package/dist/bundle/{chunk-EL2E3ABX.js → chunk-I7YSHUPW.js} +13 -13
  61. package/dist/bundle/{chunk-EWUQIUTB.js → chunk-IFTX7AQU.js} +5 -5
  62. package/dist/bundle/{chunk-BBJVV4E2.js → chunk-IGNIUDI3.js} +61 -38
  63. package/dist/bundle/{chunk-7JKECODO.js → chunk-ILAQIBEO.js} +1 -11
  64. package/dist/bundle/{chunk-SY2HLH5R.js → chunk-KSJAFMU5.js} +57 -23
  65. package/dist/bundle/{chunk-PB6NWKH3.js → chunk-LINBDWJK.js} +2 -2
  66. package/dist/bundle/{chunk-CZ4UEXCE.js → chunk-LMJBQFW6.js} +6 -6
  67. package/dist/bundle/{chunk-IJCUAKR5.js → chunk-ML3R2UHV.js} +4 -4
  68. package/dist/bundle/{chunk-2Q4CB4EI.js → chunk-MXNQZAJQ.js} +2 -2
  69. package/dist/bundle/{chunk-WOUIHZRI.js → chunk-NP7LJATI.js} +15 -67
  70. package/dist/bundle/chunk-OY7TNUEC.js +16 -0
  71. package/dist/bundle/{chunk-2VFAXC6O.js → chunk-P77FL6RY.js} +18 -18
  72. package/dist/bundle/{chunk-I55XYREN.js → chunk-P7PLKNPX.js} +993 -2512
  73. package/dist/bundle/{chunk-3URYKAJP.js → chunk-PAPY6Q6H.js} +1 -1
  74. package/dist/bundle/{chunk-5B5NOAIA.js → chunk-PN4JYURZ.js} +45 -45
  75. package/dist/bundle/{chunk-ZBYKCVSV.js → chunk-PR7XD2DI.js} +2 -2
  76. package/dist/bundle/{chunk-UPCEHSIZ.js → chunk-Q5C6YKAY.js} +21 -16
  77. package/dist/bundle/{chunk-SEJBS7SI.js → chunk-QBAOIMVB.js} +1 -1
  78. package/dist/bundle/{chunk-KUQDBWPU.js → chunk-RCTOWLCD.js} +31 -32
  79. package/dist/bundle/{chunk-22SH77TG.js → chunk-REM5WHHQ.js} +64 -64
  80. package/dist/bundle/{chunk-Y2QVNVHK.js → chunk-RHSBXOQM.js} +1 -1
  81. package/dist/bundle/{chunk-3YKAFLXY.js → chunk-RLNZ7NX5.js} +2 -2
  82. package/dist/bundle/chunk-RQNRYF6D.js +170 -0
  83. package/dist/bundle/{chunk-PV3AWPHR.js → chunk-SONPLYV7.js} +5 -5
  84. package/dist/bundle/{chunk-RWQ7T4Y5.js → chunk-T5D4OGDC.js} +2 -2
  85. package/dist/bundle/{chunk-25FT44S3.js → chunk-TGS5VPJD.js} +282 -525
  86. package/dist/bundle/chunk-TNKQDS5A.js +335 -0
  87. package/dist/bundle/{chunk-NVDR72GP.js → chunk-VVN6GHAZ.js} +60 -81
  88. package/dist/bundle/{chunk-CDSB7WVG.js → chunk-WJK6KTCS.js} +8 -8
  89. package/dist/bundle/{chunk-T6X6EZ5N.js → chunk-WWE5GO6G.js} +3 -3
  90. package/dist/bundle/{chunk-SYUXKV2E.js → chunk-XOL346TJ.js} +2 -2
  91. package/dist/bundle/{chunk-T4FMXDDV.js → chunk-XZBA6FVH.js} +3 -3
  92. package/dist/bundle/chunk-YCL3SK4T.js +1978 -0
  93. package/dist/bundle/{chunk-XVH3WZSZ.js → chunk-YRUR3E3E.js} +53 -53
  94. package/dist/bundle/{chunk-QJGFQRTL.js → chunk-YZPE72GE.js} +12 -12
  95. package/dist/bundle/{chunk-O6PD7RZY.js → chunk-ZCXWV4XO.js} +4 -4
  96. package/dist/bundle/{chunk-376ZGVUZ.js → chunk-ZHZYGY5R.js} +4 -4
  97. package/dist/bundle/{cli-BS4L3HAP.js → cli-K4D4DIGQ.js} +88 -69
  98. package/dist/bundle/command-contract-V3F452QI.js +43 -0
  99. package/dist/bundle/{command-server-entry-CJ2CV7ZV.js → command-server-entry-WREK3QBB.js} +33 -30
  100. package/dist/bundle/decode-SEETPKBH.js +299 -0
  101. package/dist/bundle/{dispatch-WBEOHZDV.js → dispatch-SQCEURVK.js} +9 -9
  102. package/dist/bundle/drive.js +11 -11
  103. package/dist/bundle/{echarts-QIXLXS3G.js → echarts-WZ5RKFCX.js} +2 -2
  104. package/dist/bundle/{embed-YNZW5X6M.js → embed-B2UCRZZR.js} +9 -9
  105. package/dist/bundle/{embedder-LRC2PKTS.js → embedder-4R6Z7G7L.js} +12 -12
  106. package/dist/bundle/entry-ORZYRJ5N.js +25 -0
  107. package/dist/bundle/{failure-X6PSLVSO.js → failure-CYNXH3RQ.js} +4 -4
  108. package/dist/bundle/first-run-KAKA6KBY.js +31 -0
  109. package/dist/bundle/first-screen-R645UHRH.js +41 -0
  110. package/dist/bundle/google-BSO3YB7N.js +45 -0
  111. package/dist/bundle/{google-api-7JDZDCWE.js → google-api-SAND2F7L.js} +70 -62
  112. package/dist/bundle/grants-PLNFYARD.js +118 -0
  113. package/dist/bundle/{identity-E43WKN5F.js → identity-JVVGS4U6.js} +6 -6
  114. package/dist/bundle/{instructions-MD2RZT5Z.js → instructions-JSMTSB22.js} +1 -1
  115. package/dist/bundle/{login-RBDJPQAG.js → login-6WG3YBDU.js} +78 -70
  116. package/dist/bundle/{mcp-TDKGDB4V.js → mcp-VFIOZDVY.js} +2 -2
  117. package/dist/bundle/meeting-combined-SUKMFK3F.js +27 -0
  118. package/dist/bundle/meeting-model-S4YGKIFI.js +29 -0
  119. package/dist/bundle/meeting-semantic-5U7JQCFF.js +25 -0
  120. package/dist/bundle/{node-IEVT2FSJ.js → node-VJMVHOWD.js} +2 -2
  121. package/dist/bundle/{node-sqlite-IENH4TRX.js → node-sqlite-DCNT3HVE.js} +10 -10
  122. package/dist/bundle/oauth-KCMNQ3ZP.js +22 -0
  123. package/dist/bundle/{open-TZ5H7NYM.js → open-NFOEHVW7.js} +8 -8
  124. package/dist/bundle/{openai-XF2KB7W2.js → openai-D47WY7EC.js} +32 -30
  125. package/dist/bundle/{process-6Q23D3TO.js → process-Q2FRU5VA.js} +1 -1
  126. package/dist/bundle/{program-D5XWOHV5.js → program-T2AJJQEM.js} +1332 -1331
  127. package/dist/bundle/{prompt-KUC5D4GX.js → prompt-YJSDABXN.js} +8 -8
  128. package/dist/bundle/{reasons-KSYP5VDJ.js → reasons-WEHPCSJX.js} +5 -5
  129. package/dist/bundle/{recognize-DPFW7HO3.js → recognize-6OBEIEB3.js} +7 -7
  130. package/dist/bundle/{remote-MODTSUNH.js → remote-3SL2QJ7T.js} +13 -13
  131. package/dist/bundle/{rerank-JK7SERLE.js → rerank-L6F5SLIB.js} +10 -10
  132. package/dist/bundle/{serve-BV2WHZLW.js → serve-GYSWIWH4.js} +12 -12
  133. package/dist/bundle/server-BI46BSRE.js +80 -0
  134. package/dist/bundle/{server-N3WPEU7Z.js → server-GWWP3RIT.js} +54 -46
  135. package/dist/bundle/{services-SV6CFUCS.js → services-BDQBRXT5.js} +79 -54
  136. package/dist/bundle/{sqlite-runtime-RZ5PLZVQ.js → sqlite-runtime-ZSZGAUYB.js} +9 -9
  137. package/dist/bundle/{start-C6EXYXAL.js → start-BJ275RUK.js} +7 -7
  138. package/dist/bundle/{state-RAZIREVG.js → state-HLNGFI2T.js} +9 -9
  139. package/dist/bundle/{store-2DLGLYS6.js → store-I43KZNJW.js} +31 -26
  140. package/dist/bundle/{store-DQKJKX2G.js → store-OSRTGYGI.js} +23 -19
  141. package/dist/bundle/store-maintenance-command-FO7LEVSL.js +72 -0
  142. package/dist/bundle/tokens-DB7O7QNB.js +118 -0
  143. package/dist/catalog.d.ts +0 -28
  144. package/dist/catalog.d.ts.map +1 -1
  145. package/dist/catalog.js +0 -82
  146. package/dist/catalog.js.map +1 -1
  147. package/dist/commands/catalog.d.ts +3 -8
  148. package/dist/commands/catalog.d.ts.map +1 -1
  149. package/dist/commands/catalog.js +36 -109
  150. package/dist/commands/catalog.js.map +1 -1
  151. package/dist/commands/context.d.ts +3 -0
  152. package/dist/commands/context.d.ts.map +1 -1
  153. package/dist/commands/context.js +20 -0
  154. package/dist/commands/context.js.map +1 -1
  155. package/dist/commands/documents.d.ts.map +1 -1
  156. package/dist/commands/documents.js +30 -72
  157. package/dist/commands/documents.js.map +1 -1
  158. package/dist/commands/folders.d.ts +1 -1
  159. package/dist/commands/folders.d.ts.map +1 -1
  160. package/dist/commands/folders.js +45 -48
  161. package/dist/commands/folders.js.map +1 -1
  162. package/dist/commands/knowledge.d.ts +4 -21
  163. package/dist/commands/knowledge.d.ts.map +1 -1
  164. package/dist/commands/knowledge.js +3 -241
  165. package/dist/commands/knowledge.js.map +1 -1
  166. package/dist/commands/mirrors.d.ts +2 -2
  167. package/dist/commands/mirrors.d.ts.map +1 -1
  168. package/dist/commands/mirrors.js +46 -202
  169. package/dist/commands/mirrors.js.map +1 -1
  170. package/dist/commands/search.d.ts +1 -3
  171. package/dist/commands/search.d.ts.map +1 -1
  172. package/dist/commands/search.js +20 -42
  173. package/dist/commands/search.js.map +1 -1
  174. package/dist/commands/sync.d.ts.map +1 -1
  175. package/dist/commands/sync.js +36 -53
  176. package/dist/commands/sync.js.map +1 -1
  177. package/dist/contract-overrides.d.ts +0 -2
  178. package/dist/contract-overrides.d.ts.map +1 -1
  179. package/dist/contract-overrides.js +0 -317
  180. package/dist/contract-overrides.js.map +1 -1
  181. package/dist/knowledge.d.ts +1 -1
  182. package/dist/knowledge.d.ts.map +1 -1
  183. package/dist/knowledge.js +4 -3
  184. package/dist/knowledge.js.map +1 -1
  185. package/dist/list-queries.d.ts +0 -31
  186. package/dist/list-queries.d.ts.map +1 -1
  187. package/dist/list-queries.js +0 -36
  188. package/dist/list-queries.js.map +1 -1
  189. package/dist/program.d.ts.map +1 -1
  190. package/dist/program.js +2 -3
  191. package/dist/program.js.map +1 -1
  192. package/dist/provider-json.d.ts.map +1 -1
  193. package/dist/provider-json.js +5 -5
  194. package/dist/provider-json.js.map +1 -1
  195. package/dist/reasons.d.ts.map +1 -1
  196. package/dist/reasons.js +0 -10
  197. package/dist/reasons.js.map +1 -1
  198. package/dist/version.d.ts +1 -1
  199. package/dist/version.js +1 -1
  200. package/package.json +3 -3
  201. package/dist/bundle/command-contract-HYURWSD6.js +0 -40
  202. package/dist/bundle/decode-E2NM5SSM.js +0 -165
  203. package/dist/bundle/entry-2IMSWRJU.js +0 -25
  204. package/dist/bundle/first-run-7CPHQDM5.js +0 -30
  205. package/dist/bundle/first-screen-OKZ7GMFR.js +0 -38
  206. package/dist/bundle/google-WDKDBDD4.js +0 -45
  207. package/dist/bundle/grants-AU25GWKF.js +0 -110
  208. package/dist/bundle/oauth-3JGSN47Z.js +0 -22
  209. package/dist/bundle/server-6YDI4Y36.js +0 -72
  210. package/dist/bundle/store-maintenance-command-UJ5F5L4H.js +0 -64
  211. package/dist/bundle/tokens-LY3WML55.js +0 -110
  212. package/dist/knowledge-query.d.ts +0 -77
  213. package/dist/knowledge-query.d.ts.map +0 -1
  214. package/dist/knowledge-query.js +0 -104
  215. package/dist/knowledge-query.js.map +0 -1
  216. package/dist/bundle/{chunk-XWBPP2HX.js → chunk-ZI3YTXSF.js} +0 -0
  217. package/dist/bundle/{mdast-util-from-markdown-CE73EWJ2.js → mdast-util-from-markdown-FXEPSNER.js} +3 -3
@@ -1,10 +1,5 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
- import {
4
- MAX_ENTRIES,
5
- supported,
6
- tooManyEntries
7
- } from "./chunk-OOIAJRKQ.js";
8
3
  import {
9
4
  ACCOUNT_FREE_COMMANDS,
10
5
  ANY_PROFILE_COMMANDS,
@@ -15,20 +10,14 @@ import {
15
10
  describeDriveProgram,
16
11
  examples,
17
12
  markProfileFree
18
- } from "./chunk-AMQGKMLZ.js";
13
+ } from "./chunk-7C5KENNU.js";
19
14
  import {
20
15
  DEFAULTS_ONLY,
21
16
  DEFAULT_LEVELS,
22
17
  FILES_QUERY,
23
- FOLDERS_QUERY,
24
- IDENTITIES_QUERY,
25
- LINKS_QUERY,
26
- MIRRORS_QUERY,
27
- NOTES_QUERY,
28
18
  PROFILE_ONLY,
29
19
  SESSIONS_QUERY,
30
20
  SETTING_NAMES,
31
- TAGS_QUERY,
32
21
  TRANSCRIPTS_QUERY,
33
22
  activeProfile,
34
23
  application,
@@ -38,20 +27,15 @@ import {
38
27
  configIssues,
39
28
  configPath,
40
29
  configuration,
41
- configuredMirrors,
42
30
  configuredSessions,
43
31
  driveFileQuery,
44
32
  fileId,
45
33
  fileRow,
46
34
  findTranscripts,
47
- folderRow,
48
35
  googleAppOf,
49
- identityRow,
50
36
  inspectConfig,
51
- linkRow,
52
37
  maxAddProfiles,
53
38
  methodPolicyKeys,
54
- mirrorRow,
55
39
  oauthClientReport,
56
40
  paths,
57
41
  permissionKeys,
@@ -64,7 +48,6 @@ import {
64
48
  refusal,
65
49
  selectedFolders,
66
50
  sessionRow,
67
- tagRow,
68
51
  termsOf,
69
52
  textLimit,
70
53
  transcriptQuery,
@@ -73,7 +56,12 @@ import {
73
56
  unknownProfile,
74
57
  withDefaults,
75
58
  writeConfig
76
- } from "./chunk-WOUIHZRI.js";
59
+ } from "./chunk-NP7LJATI.js";
60
+ import {
61
+ MAX_ENTRIES,
62
+ supported,
63
+ tooManyEntries
64
+ } from "./chunk-BXPC5TFG.js";
77
65
  import {
78
66
  DOC,
79
67
  DOCUMENT_LIST_FIELDS,
@@ -96,7 +84,7 @@ import {
96
84
  syncDocuments,
97
85
  syncMirrors,
98
86
  watchMirrors
99
- } from "./chunk-NVDR72GP.js";
87
+ } from "./chunk-VVN6GHAZ.js";
100
88
  import {
101
89
  apiMethod,
102
90
  apiMethods,
@@ -105,14 +93,10 @@ import {
105
93
  schemas,
106
94
  validateApiParams,
107
95
  validateRequest
108
- } from "./chunk-GK6KXBL6.js";
96
+ } from "./chunk-2SBC4DVV.js";
109
97
  import {
110
98
  operations
111
99
  } from "./chunk-NYECVHFH.js";
112
- import {
113
- googleError,
114
- offlineRefused
115
- } from "./chunk-Y2QVNVHK.js";
116
100
  import {
117
101
  DISCOVERY_DESCRIPTIONS,
118
102
  MEMO_SCENARIOS,
@@ -132,6 +116,7 @@ import {
132
116
  entityFields,
133
117
  generatedApiCommand,
134
118
  guideCommand,
119
+ honoursDryRun,
135
120
  identifier,
136
121
  inSection,
137
122
  modelCatalogueCommand,
@@ -143,17 +128,24 @@ import {
143
128
  signInSteps,
144
129
  skillCommand,
145
130
  upgradeCommand
146
- } from "./chunk-IQ2QU2X6.js";
147
- import "./chunk-SEJBS7SI.js";
148
- import "./chunk-6XNTELM5.js";
149
- import "./chunk-KUQDBWPU.js";
150
- import "./chunk-SY2HLH5R.js";
131
+ } from "./chunk-FVTKFIQH.js";
132
+ import {
133
+ googleError,
134
+ offlineRefused
135
+ } from "./chunk-RHSBXOQM.js";
136
+ import "./chunk-QBAOIMVB.js";
137
+ import "./chunk-YZPE72GE.js";
138
+ import "./chunk-GPDPEHYX.js";
139
+ import "./chunk-RCTOWLCD.js";
140
+ import "./chunk-KSJAFMU5.js";
141
+ import "./chunk-ZHZYGY5R.js";
151
142
  import {
152
143
  storeInfo
153
- } from "./chunk-22SH77TG.js";
154
- import "./chunk-TZ75K6R7.js";
155
- import "./chunk-2DS2TDGW.js";
156
- import "./chunk-RLGQMMYE.js";
144
+ } from "./chunk-REM5WHHQ.js";
145
+ import "./chunk-HWUPU6WX.js";
146
+ import "./chunk-3UZ4OH22.js";
147
+ import "./chunk-AV5UKJZM.js";
148
+ import "./chunk-WWE5GO6G.js";
157
149
  import {
158
150
  LIST_QUERY_GUIDE,
159
151
  RecipientList,
@@ -168,39 +160,39 @@ import {
168
160
  typedQuery,
169
161
  unfilteredQuery,
170
162
  withQuery
171
- } from "./chunk-HEBZCKMU.js";
163
+ } from "./chunk-GAHIHE4K.js";
172
164
  import {
173
165
  columnName,
174
166
  modelGateway,
175
167
  readSpreadsheet
176
- } from "./chunk-5B5NOAIA.js";
177
- import "./chunk-EL2E3ABX.js";
178
- import "./chunk-LUZRVBQR.js";
168
+ } from "./chunk-PN4JYURZ.js";
169
+ import "./chunk-I7YSHUPW.js";
170
+ import "./chunk-7QSRODXM.js";
171
+ import "./chunk-3TCMANIM.js";
172
+ import "./chunk-RQNRYF6D.js";
173
+ import "./chunk-EG62WVR2.js";
179
174
  import "./chunk-HTQTIKWP.js";
180
- import "./chunk-4YECZ6CN.js";
175
+ import "./chunk-5JTB4URG.js";
181
176
  import {
182
177
  latestVersion,
183
178
  runUpdate,
184
179
  updateNotice
185
- } from "./chunk-U3RXH6RY.js";
186
- import "./chunk-FIVFP53N.js";
187
- import "./chunk-QJGFQRTL.js";
188
- import "./chunk-376ZGVUZ.js";
189
- import "./chunk-T6X6EZ5N.js";
190
- import "./chunk-O6PD7RZY.js";
191
- import "./chunk-4ZFO2CVH.js";
192
- import "./chunk-GHFBT2ZM.js";
180
+ } from "./chunk-FADAOLGB.js";
181
+ import "./chunk-GA3URWIF.js";
182
+ import "./chunk-ZCXWV4XO.js";
183
+ import "./chunk-FCSHWUMW.js";
184
+ import "./chunk-FN3RXBO7.js";
193
185
  import {
194
186
  applyDocumentTransfer,
195
187
  previewDocumentTransfer
196
- } from "./chunk-V4FMN5A6.js";
197
- import "./chunk-EWUQIUTB.js";
188
+ } from "./chunk-3CHW7JGR.js";
189
+ import "./chunk-IFTX7AQU.js";
198
190
  import "./chunk-5DPV7X27.js";
199
- import "./chunk-BVVXYZSU.js";
200
- import "./chunk-MHXZ62CU.js";
201
- import "./chunk-XUHQ7DVT.js";
202
- import "./chunk-PB6NWKH3.js";
203
- import "./chunk-6EL5AVXX.js";
191
+ import "./chunk-6BMTW5A6.js";
192
+ import "./chunk-DVI72ZQG.js";
193
+ import "./chunk-EDO5LZVF.js";
194
+ import "./chunk-LINBDWJK.js";
195
+ import "./chunk-3UWRAIWA.js";
204
196
  import {
205
197
  CEILING_KEY,
206
198
  FETCH,
@@ -236,82 +228,92 @@ import {
236
228
  resolveAISettings,
237
229
  rootOf,
238
230
  settingRows,
231
+ sharedCommand,
239
232
  sharedContracts,
240
233
  snakeKeys
241
- } from "./chunk-25FT44S3.js";
234
+ } from "./chunk-TGS5VPJD.js";
242
235
  import {
243
236
  modelTarget
244
- } from "./chunk-F5UUJU6R.js";
245
- import "./chunk-AD7VI3XU.js";
246
- import {
247
- setupPermissionCeiling
248
- } from "./chunk-CU6RATZH.js";
237
+ } from "./chunk-FYPW7NMH.js";
238
+ import "./chunk-54BQWRJL.js";
249
239
  import {
250
240
  readOnlyLockOf,
251
241
  readOnlyRefusal
252
- } from "./chunk-ZBYKCVSV.js";
253
- import "./chunk-WQOGHND4.js";
242
+ } from "./chunk-PR7XD2DI.js";
243
+ import "./chunk-4WK26MPY.js";
244
+ import "./chunk-TNKQDS5A.js";
245
+ import {
246
+ setupPermissionCeiling
247
+ } from "./chunk-GV5DGHSA.js";
254
248
  import {
255
249
  hostFetch
256
- } from "./chunk-L342KHIZ.js";
257
- import "./chunk-533XOW74.js";
258
- import "./chunk-GTDCP5OG.js";
259
- import "./chunk-T4FMXDDV.js";
260
- import "./chunk-2Q4CB4EI.js";
250
+ } from "./chunk-DR57KDAY.js";
251
+ import {
252
+ note
253
+ } from "./chunk-BBFXQPKD.js";
254
+ import "./chunk-FONIFRYI.js";
255
+ import "./chunk-XZBA6FVH.js";
256
+ import "./chunk-MXNQZAJQ.js";
261
257
  import {
262
258
  CATALOG_QUERY,
263
259
  IMPORTED_DOCUMENT_QUERY,
264
260
  openStore
265
- } from "./chunk-3RLRJHAI.js";
266
- import "./chunk-ZUG67442.js";
267
- import "./chunk-E7URRFBB.js";
268
- import "./chunk-6D44YQ5X.js";
261
+ } from "./chunk-HYXXMSVD.js";
262
+ import "./chunk-BBRMDMIR.js";
263
+ import "./chunk-7DJNURKV.js";
264
+ import "./chunk-3AHBZP33.js";
265
+ import "./chunk-OY7TNUEC.js";
266
+ import "./chunk-6DPOWBKA.js";
269
267
  import {
270
268
  FACT_STATUSES,
271
- FACT_TYPES,
272
269
  MEMORY_KINDS,
273
270
  MEMORY_SCOPES,
274
271
  MEMORY_STATUSES,
275
272
  inRun
276
- } from "./chunk-I55XYREN.js";
273
+ } from "./chunk-YCL3SK4T.js";
274
+ import "./chunk-GK3BJMGK.js";
275
+ import "./chunk-RLNZ7NX5.js";
276
+ import "./chunk-DHX27E5M.js";
277
+ import {
278
+ FACT_TYPES
279
+ } from "./chunk-P7PLKNPX.js";
277
280
  import {
278
281
  defineQuery,
279
282
  parseLucene,
280
283
  queryError,
284
+ queryFieldsOf,
281
285
  timezoneOf,
282
286
  validateQuery,
283
287
  zonedMoment
284
- } from "./chunk-UPCEHSIZ.js";
285
- import "./chunk-VUPWDCYV.js";
286
- import "./chunk-3YKAFLXY.js";
287
- import "./chunk-CDSB7WVG.js";
288
- import "./chunk-3URYKAJP.js";
288
+ } from "./chunk-Q5C6YKAY.js";
289
+ import "./chunk-WJK6KTCS.js";
290
+ import "./chunk-PAPY6Q6H.js";
289
291
  import "./chunk-D72URWJE.js";
290
292
  import {
291
293
  installerOf
292
- } from "./chunk-M4OP5ASJ.js";
294
+ } from "./chunk-66PL7P4C.js";
293
295
  import {
294
296
  DRIVE_APP,
295
297
  PACKAGE,
296
298
  VERSION
297
- } from "./chunk-SYUXKV2E.js";
299
+ } from "./chunk-XOL346TJ.js";
298
300
  import {
299
301
  REASONS
300
- } from "./chunk-7JKECODO.js";
301
- import "./chunk-XWBPP2HX.js";
302
- import "./chunk-OUM4ZO53.js";
302
+ } from "./chunk-ILAQIBEO.js";
303
+ import "./chunk-ZI3YTXSF.js";
304
+ import "./chunk-HK225DAG.js";
303
305
  import {
304
306
  storePath
305
- } from "./chunk-RWQ7T4Y5.js";
307
+ } from "./chunk-T5D4OGDC.js";
306
308
  import {
307
309
  processStreams,
308
310
  saveConfigFile,
309
311
  writeSecurely
310
- } from "./chunk-5SJZDEIO.js";
311
- import "./chunk-PV3AWPHR.js";
312
+ } from "./chunk-HRATXUFH.js";
313
+ import "./chunk-SONPLYV7.js";
312
314
  import "./chunk-Y5E2WNWB.js";
313
- import "./chunk-HCZYJMBP.js";
314
- import "./chunk-5TK2YQCO.js";
315
+ import "./chunk-ABZ2NYDT.js";
316
+ import "./chunk-7IBENBCK.js";
315
317
  import {
316
318
  array,
317
319
  boolean,
@@ -334,11 +336,11 @@ import {
334
336
  string,
335
337
  unknown,
336
338
  writes
337
- } from "./chunk-JRFKCYMW.js";
339
+ } from "./chunk-HHAZ6DCY.js";
338
340
  import {
339
341
  CliError,
340
342
  isCliError
341
- } from "./chunk-EA2OB75T.js";
343
+ } from "./chunk-54NDYVZA.js";
342
344
  import {
343
345
  __commonJS,
344
346
  __name,
@@ -439,30 +441,30 @@ var require_polyfills = __commonJS({
439
441
  })(fs.rename);
440
442
  }
441
443
  fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
442
- function read(fd, buffer, offset2, length, position, callback_) {
444
+ function read(fd, buffer, offset, length, position, callback_) {
443
445
  var callback;
444
446
  if (callback_ && typeof callback_ === "function") {
445
447
  var eagCounter = 0;
446
448
  callback = /* @__PURE__ */ __name(function(er, _, __) {
447
449
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
448
450
  eagCounter++;
449
- return fs$read.call(fs, fd, buffer, offset2, length, position, callback);
451
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
450
452
  }
451
453
  callback_.apply(this, arguments);
452
454
  }, "callback");
453
455
  }
454
- return fs$read.call(fs, fd, buffer, offset2, length, position, callback);
456
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
455
457
  }
456
458
  __name(read, "read");
457
459
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
458
460
  return read;
459
461
  })(fs.read);
460
462
  fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
461
- return function(fd, buffer, offset2, length, position) {
463
+ return function(fd, buffer, offset, length, position) {
462
464
  var eagCounter = 0;
463
465
  while (true) {
464
466
  try {
465
- return fs$readSync.call(fs, fd, buffer, offset2, length, position);
467
+ return fs$readSync.call(fs, fd, buffer, offset, length, position);
466
468
  } catch (er) {
467
469
  if (er.code === "EAGAIN" && eagCounter < 10) {
468
470
  eagCounter++;
@@ -2177,7 +2179,7 @@ var profileLocked2 = /* @__PURE__ */ __name((env, name) => import_proper_lockfil
2177
2179
  var removal = {
2178
2180
  signOut: /* @__PURE__ */ __name(async (profile, { env, keyring, mayRevoke }) => {
2179
2181
  const storage = readConfig(env).profiles[profile]?.storage ?? "keyring";
2180
- const { sessionKeeper } = await import("./tokens-LY3WML55.js");
2182
+ const { sessionKeeper } = await import("./tokens-DB7O7QNB.js");
2181
2183
  const { revoked } = await sessionKeeper({
2182
2184
  env,
2183
2185
  name: profile,
@@ -2198,74 +2200,322 @@ var installAccountCommands = /* @__PURE__ */ __name((program, _context) => {
2198
2200
  annotate(program.command("account"), { effects: LOCAL_READ }).description("remove this profile from this computer").addCommand(accountRemoveCommand(DRIVE_APP, removal, { resolveSettings: configuration.resolveSettings }));
2199
2201
  }, "installAccountCommands");
2200
2202
 
2201
- // dist/catalog.js
2202
- var catalogInput = /* @__PURE__ */ __name((file) => ({
2203
- externalId: `${file.id}.md`,
2204
- kind: file.mime === FOLDER ? "folder" : "file",
2205
- name: file.name,
2206
- parents: file.parents.map((id) => `${id}.md`),
2207
- url: file.url,
2208
- mime: file.mime,
2209
- size: file.size,
2210
- createdAt: file.createdAt,
2211
- modifiedAt: file.modifiedAt,
2212
- description: file.description,
2213
- actors: [
2214
- ...(file.owners ?? []).map((actor) => ({ ...actor, role: "owner" })),
2215
- ...file.lastModifiedBy ? [{ ...file.lastModifiedBy, role: "editor" }] : []
2216
- ],
2217
- metadata: file.providerMetadata ?? file,
2218
- frontMatter: {
2219
- source: "google-drive",
2220
- sourceUrl: file.url,
2221
- fileId: file.id,
2222
- mime: file.mime,
2223
- owners: file.owners ?? [],
2224
- lastModifiedBy: file.lastModifiedBy ?? null
2225
- }
2226
- }), "catalogInput");
2227
- var catalogTree = /* @__PURE__ */ __name((entries, roots2, depth) => {
2203
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/queries.js
2204
+ var registry = /* @__PURE__ */ __name((entity, schema, native, examples3) => ({
2205
+ entity,
2206
+ backend: "native",
2207
+ fields: queryFieldsOf(schema, { native, examples: examples3 }).map((field) => field.native ? { ...field, operators: ["term", "phrase"] } : field)
2208
+ }), "registry");
2209
+ var folderRow = strictObject({ id: string() });
2210
+ var mirrorRow = strictObject({ id: string(), path: string(), folder: string() });
2211
+ var tagRow = strictObject({ tag: string() });
2212
+ var linkRow = looseObject({
2213
+ id: string(),
2214
+ from: string(),
2215
+ to: nullable(string()),
2216
+ kind: string(),
2217
+ role: nullable(string()),
2218
+ confirmed: boolean(),
2219
+ origin: picklist(["file", "owner", "suggested", "message"])
2220
+ });
2221
+ var IDENTITY_ROLES = ["owner", "last-editor"];
2222
+ var identityRow = looseObject({
2223
+ remote_id: nullable(string()),
2224
+ provider: string(),
2225
+ role: picklist(IDENTITY_ROLES),
2226
+ person: nullable(record(string(), unknown()))
2227
+ });
2228
+ var documentQueries = /* @__PURE__ */ __name(() => {
2229
+ return {
2230
+ folders: registry("selected_folder", folderRow, ["id"], { id: "id:FOLDER_ID" }),
2231
+ mirrors: registry("mirror", mirrorRow, ["id", "path", "folder"], {
2232
+ id: "id:example",
2233
+ path: 'path:"/example/notes"',
2234
+ folder: "folder:FOLDER_ID"
2235
+ }),
2236
+ tags: registry("document_tag", tagRow, ["tag"], { tag: "tag:budget" }),
2237
+ notes: registry("note", note, ["text"], { text: "text:review" }),
2238
+ links: registry("document_relationship", linkRow, ["id", "role", "origin", "confirmed"], {
2239
+ id: "id:1",
2240
+ role: "role:reviewer",
2241
+ origin: "origin:owner",
2242
+ confirmed: "confirmed:true"
2243
+ }),
2244
+ identities: registry("document_identity", identityRow, ["remote_id", "role"], {
2245
+ remote_id: "remote_id:example",
2246
+ role: "role:owner"
2247
+ })
2248
+ };
2249
+ }, "documentQueries");
2250
+ var bindQuery2 = /* @__PURE__ */ __name((command, query, schema) => answerEntity(withQuery(command, query), query.entity, schema), "bindQuery");
2251
+ var termsOf2 = /* @__PURE__ */ __name((words, query, command) => Object.fromEntries(queryTerms(words, query, command)), "termsOf");
2252
+ var FACT_QUERY = {
2253
+ entity: "fact",
2254
+ backend: "native",
2255
+ fields: [
2256
+ termField("kind", "enum", "kind:decision", { values: FACT_TYPES }),
2257
+ termField("status", "enum", "status:proposed", { values: FACT_STATUSES })
2258
+ ]
2259
+ };
2260
+ var MEMORY_QUERY = {
2261
+ entity: "memory",
2262
+ backend: "native",
2263
+ fields: [
2264
+ termField("kind", "enum", "kind:preference", { values: MEMORY_KINDS }),
2265
+ termField("status", "enum", "status:proposed", { values: MEMORY_STATUSES }),
2266
+ termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
2267
+ ]
2268
+ };
2269
+ var MEMORY_SEARCH_QUERY = {
2270
+ entity: "memory",
2271
+ backend: "native",
2272
+ fields: [
2273
+ nativeField({
2274
+ name: "text",
2275
+ type: "txt",
2276
+ operators: ["term", "phrase"],
2277
+ example: "text:reviews",
2278
+ relation: "words of the memory; a bare word means the same"
2279
+ }),
2280
+ termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
2281
+ ]
2282
+ };
2283
+ var factItem = /* @__PURE__ */ __name(({ type, statement, source, confirmedBy, ...fact }) => ({
2284
+ ref: fact.ref,
2285
+ id: fact.id,
2286
+ kind: type,
2287
+ text: statement,
2288
+ status: fact.status,
2289
+ project: fact.project,
2290
+ subject: fact.subject,
2291
+ occurred_at: fact.occurredAt,
2292
+ supersedes: fact.supersedes,
2293
+ author: fact.author,
2294
+ model: fact.model,
2295
+ confirmed_by: confirmedBy,
2296
+ scope: fact.scope,
2297
+ origin: source,
2298
+ evidence: fact.evidence,
2299
+ created_at: fact.createdAt,
2300
+ updated_at: fact.updatedAt
2301
+ }), "factItem");
2302
+ var memoryItem = /* @__PURE__ */ __name(({ body, ...memory }) => ({
2303
+ ref: memory.ref,
2304
+ id: memory.id,
2305
+ kind: memory.kind,
2306
+ text: body,
2307
+ subject: memory.subject,
2308
+ author: memory.author,
2309
+ model: memory.model,
2310
+ confidence: memory.confidence,
2311
+ status: memory.status,
2312
+ scope: memory.scope,
2313
+ supersedes: memory.supersedes,
2314
+ evidence: memory.evidence,
2315
+ last_verified_at: memory.lastVerifiedAt,
2316
+ created_at: memory.createdAt,
2317
+ updated_at: memory.updatedAt
2318
+ }), "memoryItem");
2319
+ var memorySearch = /* @__PURE__ */ __name((words) => {
2320
+ const command = "memories search";
2321
+ const context = { command, guide: LIST_QUERY_GUIDE };
2322
+ const ast = validateQuery(parseLucene(typedQuery(words), { defaultField: "text", ...context }), MEMORY_SEARCH_QUERY, context);
2323
+ const text = [];
2324
+ let scope;
2325
+ const add = /* @__PURE__ */ __name((node) => {
2326
+ if (node.kind === "boolean") {
2327
+ for (const clause of node.clauses) {
2328
+ if (clause.occur !== "must")
2329
+ queryError("query.unsupported-placement", clause.node.span, "this search joins its terms by AND", context);
2330
+ add(clause.node);
2331
+ }
2332
+ return;
2333
+ }
2334
+ if (node.field === "text")
2335
+ text.push(node.value);
2336
+ else if (scope !== void 0)
2337
+ queryError("query.unsupported-placement", node.span, "scope only once here", context);
2338
+ else
2339
+ scope = node.value.toLowerCase();
2340
+ }, "add");
2341
+ add(ast.root);
2342
+ if (text.length === 0)
2343
+ queryError("query.missing-value", ast.root.span, "say which words to look for beside scope:", context);
2344
+ return { text: text.join(" "), ...scope === void 0 ? {} : { scope } };
2345
+ }, "memorySearch");
2346
+
2347
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/words.js
2348
+ var wordsOf = /* @__PURE__ */ __name((words) => {
2349
+ const profile = words.profile ?? "personal";
2350
+ const place = words.place ?? words.provider;
2351
+ const { provider } = words;
2352
+ return {
2353
+ ...words,
2354
+ profile,
2355
+ place,
2356
+ prefix: `${words.app} ${profile}`,
2357
+ text: {
2358
+ documents: `read imported documents and ${provider} documents`,
2359
+ documentsList: `list imported documents with their ${provider} URLs`,
2360
+ documentArgument: `document id, ${provider} URL, or a search hit's document: ref`,
2361
+ knowledgeArgument: `${provider} file or folder id or URL in the local catalog, or a document:<n> ref`,
2362
+ catalog: `browse stored ${place} files and folders offline`,
2363
+ catalogArgument: `${provider} file or folder id, or its URL`,
2364
+ treeArgument: `${provider} folder id or URL; defaults to the explicitly selected profile's roots`,
2365
+ folders: `choose the ${place} folders that sync imports`,
2366
+ folderArgument: `folder id or ${place} URL`,
2367
+ syncLimit: `how many documents to read from ${provider} in this run`,
2368
+ identities: `the ${provider} accounts seen on a document, and the people they belong to`,
2369
+ identitiesList: `list the people ${provider} shows for a document`,
2370
+ identitiesLink: `record that a ${provider} account belongs to a known person`,
2371
+ identityArgument: `${provider} account id, as identities list prints it`,
2372
+ mirrors: `keep local folders mirrored into ${place}`,
2373
+ mirrorsAdd: `mirror a local folder into ${place}`,
2374
+ mirrorsSync: `sync both ways with ${place}; a part changed on both sides is reported`,
2375
+ mirrorParent: `the ${place} folder to write into, by id or URL`,
2376
+ ...words.text
2377
+ }
2378
+ };
2379
+ }, "wordsOf");
2380
+ var examples2 = /* @__PURE__ */ __name((command, lines) => annotate(command, { examples: lines }), "examples");
2381
+ var positive = /* @__PURE__ */ __name((input) => {
2382
+ const n = Number(input);
2383
+ if (!Number.isSafeInteger(n) || n < 1)
2384
+ throw new InvalidArgumentError("use a positive integer");
2385
+ return n;
2386
+ }, "positive");
2387
+ var nonnegative = /* @__PURE__ */ __name((input) => {
2388
+ const n = Number(input);
2389
+ if (!Number.isSafeInteger(n) || n < 0)
2390
+ throw new InvalidArgumentError("use a nonnegative integer");
2391
+ return n;
2392
+ }, "nonnegative");
2393
+ var allOf = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false }), "allOf");
2394
+ var documentsGroup = /* @__PURE__ */ __name((program, words) => program.commands.find((command) => command.name() === "documents") ?? annotate(program.command("documents"), { effects: { remote: "none", local: "read" } }).description(words.text.documents), "documentsGroup");
2395
+ var DAY = 24 * 60 * 60 * 1e3;
2396
+ var ageOf = /* @__PURE__ */ __name((lastSync, now = Date.now()) => {
2397
+ const at = lastSync ? Date.parse(lastSync) : Number.NaN;
2398
+ return Number.isNaN(at) ? { synced_at: null, age_days: null } : { synced_at: lastSync ?? null, age_days: Math.max(0, Math.floor((now - at) / DAY)) };
2399
+ }, "ageOf");
2400
+ var staleCopy = /* @__PURE__ */ __name((provider, lastSync, now = Date.now()) => {
2401
+ const sync2 = defineSteps([
2402
+ { id: "sync.run", command: "sync", args: [], why: `copy the changes ${provider} has made into the local store` }
2403
+ ])[0];
2404
+ const { synced_at, age_days } = ageOf(lastSync, now);
2405
+ const old = synced_at === null || now - Date.parse(synced_at) > DAY;
2406
+ if (!old)
2407
+ return {};
2408
+ const why = age_days === null ? `the local copy has no sync time; ${provider} may have changed the document since it was copied` : `the local copy was synced ${age_days} day${age_days === 1 ? "" : "s"} ago; ${provider} may have changed the document since`;
2409
+ return {
2410
+ missing: [{ field: "synced_at", why, step: sync2.id }],
2411
+ next: [stepOf(sync2)],
2412
+ meta: { complete: false }
2413
+ };
2414
+ }, "staleCopy");
2415
+
2416
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/catalog.js
2417
+ var CATALOG_TREE_LIMIT = 1e4;
2418
+ var CATALOG_PAGE = 1e3;
2419
+ var PARENT_BATCH = 200;
2420
+ var anyParent = /* @__PURE__ */ __name((ids) => {
2421
+ const ast = parseLucene(Array.from({ length: Math.max(2, ids.length) }, () => "parent:x").join(" OR "), {
2422
+ defaultField: "none"
2423
+ });
2424
+ const clauses = ast.root.clauses;
2425
+ clauses.forEach((clause, i) => {
2426
+ clause.node.value = ids[Math.min(i, ids.length - 1)];
2427
+ });
2428
+ return validateQuery(ast, CATALOG_QUERY);
2429
+ }, "anyParent");
2430
+ var catalogSource = /* @__PURE__ */ __name((catalog, principal) => ({
2431
+ get: /* @__PURE__ */ __name((externalId) => catalog.get(principal, catalogId({ externalId })), "get"),
2432
+ children: /* @__PURE__ */ __name((externalId, page) => catalog.list(principal, { parent: catalogId({ externalId }), ...page }), "children"),
2433
+ // Each read scans the account's catalog, so the branches cut at the depth are asked about 200 at a time.
2434
+ withChildren: /* @__PURE__ */ __name(async (externalIds) => {
2435
+ const found = /* @__PURE__ */ new Set();
2436
+ for (let start = 0; start < externalIds.length; start += PARENT_BATCH) {
2437
+ const batch = new Set(externalIds.slice(start, start + PARENT_BATCH));
2438
+ const ast = anyParent([...batch].map((externalId) => catalogId({ externalId })));
2439
+ for (let offset = 0; ; offset += CATALOG_PAGE) {
2440
+ const page = await catalog.list(principal, { ast, limit: CATALOG_PAGE, offset });
2441
+ for (const item of page.items)
2442
+ for (const parent of item.parents)
2443
+ if (batch.delete(parent))
2444
+ found.add(parent);
2445
+ if (!page.hasMore || batch.size === 0)
2446
+ break;
2447
+ }
2448
+ }
2449
+ return found;
2450
+ }, "withChildren")
2451
+ }), "catalogSource");
2452
+ var tooLarge = /* @__PURE__ */ __name((limit) => new CliError("validation_error", `the tree is over ${limit} entries; name a smaller FOLDER or lower --depth`, {
2453
+ reason: "catalog.tree-limit"
2454
+ }), "tooLarge");
2455
+ var catalogTree = /* @__PURE__ */ __name(async (source, roots2, depth, limit = CATALOG_TREE_LIMIT) => {
2228
2456
  if (!Number.isSafeInteger(depth) || depth < 0 || depth > 50)
2229
2457
  throw new CliError("validation_error", "tree depth must be between 0 and 50", { reason: "catalog.depth-invalid" });
2230
- const byId = new Map(entries.map((entry) => [entry.externalId, entry]));
2231
- const children = /* @__PURE__ */ new Map();
2232
- for (const entry of entries)
2233
- for (const parent of entry.parents) {
2234
- const list = children.get(parent) ?? [];
2235
- list.push(entry);
2236
- children.set(parent, list);
2458
+ let nodes = 0;
2459
+ const seen = /* @__PURE__ */ new Set();
2460
+ const cut = [];
2461
+ const cutIds = [];
2462
+ const hasChildren = /* @__PURE__ */ __name(async (externalId) => (await source.children(externalId, { limit: 1, offset: 0 })).items.length > 0, "hasChildren");
2463
+ const childrenOf = /* @__PURE__ */ __name(async (externalId) => {
2464
+ const items = [];
2465
+ for (let offset = 0; ; offset += CATALOG_PAGE) {
2466
+ const page = await source.children(externalId, { limit: CATALOG_PAGE, offset });
2467
+ for (const item of page.items)
2468
+ items.push(item);
2469
+ if (nodes + items.length > limit)
2470
+ throw tooLarge(limit);
2471
+ if (!page.hasMore)
2472
+ return items;
2237
2473
  }
2238
- let count = 0;
2239
- const node = /* @__PURE__ */ __name((item, level, ancestors) => {
2240
- if (ancestors.has(item.externalId))
2474
+ }, "childrenOf");
2475
+ const node = /* @__PURE__ */ __name(async (entry, level, ancestors) => {
2476
+ if (ancestors.has(entry.externalId))
2241
2477
  throw new CliError("invalid_response", "local folder ancestry contains a cycle", { reason: "catalog.cycle" });
2242
- if (++count > 1e4)
2243
- throw new CliError("validation_error", "tree output exceeds 10000 nodes; choose a smaller folder", {
2244
- reason: "catalog.tree-limit"
2245
- });
2246
- const found = children.get(item.externalId) ?? [];
2247
- const next = /* @__PURE__ */ new Set([...ancestors, item.externalId]);
2248
- return {
2478
+ if (++nodes > limit)
2479
+ throw tooLarge(limit);
2480
+ const tree = {
2249
2481
  item: {
2250
- id: catalogId(item),
2251
- ref: item.ref,
2252
- name: item.name,
2253
- kind: item.kind,
2254
- url: item.url,
2255
- content: item.content
2256
- },
2257
- children: level >= depth ? [] : found.map((child) => node(child, level + 1, next)),
2258
- truncated: level >= depth && found.length > 0
2482
+ id: catalogId(entry),
2483
+ ref: entry.ref,
2484
+ name: entry.name,
2485
+ kind: entry.kind,
2486
+ url: entry.url,
2487
+ content: entry.content
2488
+ },
2489
+ children: [],
2490
+ truncated: false
2259
2491
  };
2492
+ if (seen.has(entry.externalId))
2493
+ return { ...tree, repeated: true };
2494
+ seen.add(entry.externalId);
2495
+ if (level >= depth) {
2496
+ cut.push(tree);
2497
+ cutIds.push(entry.externalId);
2498
+ return tree;
2499
+ }
2500
+ const next = new Set(ancestors).add(entry.externalId);
2501
+ for (const child of await childrenOf(entry.externalId))
2502
+ tree.children.push(await node(child, level + 1, next));
2503
+ return tree;
2260
2504
  }, "node");
2261
- return roots2.map((id) => {
2262
- const entry = byId.get(id);
2263
- if (entry?.kind !== "folder")
2264
- throw new CliError("not_found", "folder is not in the active local catalog; run catalog import or sync", {
2505
+ const trees = [];
2506
+ for (const id of roots2) {
2507
+ const entry = await source.get(id);
2508
+ if (!entry || entry.kind !== "folder" && !await hasChildren(entry.externalId))
2509
+ throw new CliError("not_found", "no folder or page with sub-pages by that id in the active local catalog", {
2265
2510
  reason: "catalog.not-found"
2266
2511
  });
2267
- return node(entry, 0, /* @__PURE__ */ new Set());
2512
+ trees.push(await node(entry, 0, /* @__PURE__ */ new Set()));
2513
+ }
2514
+ const parents = source.withChildren ? await source.withChildren(cutIds) : new Set((await Promise.all(cutIds.map(async (id) => await hasChildren(id) ? id : ""))).filter(Boolean));
2515
+ cut.forEach((tree, i) => {
2516
+ tree.truncated = parents.has(cutIds[i]);
2268
2517
  });
2518
+ return trees;
2269
2519
  }, "catalogTree");
2270
2520
  var catalogId = /* @__PURE__ */ __name((entry) => entry.externalId.replace(/\.md$/, ""), "catalogId");
2271
2521
  var catalogOutput = /* @__PURE__ */ __name((entry) => ({
@@ -2304,116 +2554,64 @@ var CATALOG_FIELDS = Object.keys({
2304
2554
  active: true,
2305
2555
  content: true
2306
2556
  });
2307
-
2308
- // dist/output.js
2309
- var VERBATIM = /* @__PURE__ */ new Set([
2310
- "frontMatter",
2311
- "front_matter",
2312
- "provider_metadata",
2313
- "metadata",
2314
- "headers",
2315
- "properties",
2316
- "appProperties",
2317
- "app_properties",
2318
- "request_schema",
2319
- "response_schema",
2320
- "body_schema",
2321
- "schema",
2322
- "inputSchema",
2323
- "input_schema",
2324
- "outputSchema",
2325
- "output_schema"
2326
- ]);
2327
- var RECORDS = /* @__PURE__ */ new Set(["profiles", "permissions", "models"]);
2328
- var keyOf = /* @__PURE__ */ __name((key) => /^[a-z][a-zA-Z0-9]*$/.test(key) ? key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase() : key, "keyOf");
2329
- var snakeKeys2 = /* @__PURE__ */ __name((value, record2 = false) => {
2330
- if (Array.isArray(value))
2331
- return value.map((item) => snakeKeys2(item));
2332
- if (!value || typeof value !== "object" || value instanceof Date)
2333
- return value;
2334
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [
2335
- record2 ? key : keyOf(key),
2336
- VERBATIM.has(key) ? item : snakeKeys2(item, RECORDS.has(key))
2337
- ]));
2338
- }, "snakeKeys");
2339
- var allOf = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false }), "allOf");
2340
-
2341
- // dist/commands/catalog.js
2342
2557
  var local = /* @__PURE__ */ __name((command, mutates = false) => annotate(command, { effects: mutates ? LOCAL_WRITE : LOCAL_READ }), "local");
2343
- var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
2344
- const { env, selected, output, positive: positive2, offset: offset2, withIndex } = helpers;
2345
- const catalog = local(program.command("catalog")).description("browse stored Drive files and folders offline");
2346
- const run3 = /* @__PURE__ */ __name(async (fn, write = false) => {
2347
- const profile = activeProfile(env, selected());
2348
- return withIndex(async (index) => {
2349
- const lock = write ? await lockProfile(env, selected()) : void 0;
2350
- try {
2351
- if (!index.catalog)
2352
- throw new CliError("configuration_error", "index has no shared catalog adapter", {
2353
- reason: "catalog.unavailable"
2354
- });
2355
- lock?.assertHeld();
2356
- const value = await fn({ ...index, catalog: index.catalog }, profile.principal);
2357
- lock?.assertHeld();
2358
- return value;
2359
- } finally {
2360
- await lock?.release();
2361
- }
2362
- });
2363
- }, "run");
2558
+ var addDocumentCatalogCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
2559
+ const { output } = helpers;
2560
+ const wording = wordsOf(helpers.words);
2561
+ const { prefix, text } = wording;
2562
+ const queries = documentQueries();
2563
+ const view = "catalog";
2564
+ const catalog = local(program.command("catalog")).description(text.catalog);
2565
+ const run3 = /* @__PURE__ */ __name((fn, write = false) => helpers.run(async (index, principal) => {
2566
+ if (!index.catalog)
2567
+ throw new CliError("configuration_error", "index has no shared catalog adapter", {
2568
+ reason: "catalog.unavailable"
2569
+ });
2570
+ return fn({ ...index, catalog: index.catalog }, principal);
2571
+ }, write), "run");
2364
2572
  const entry = /* @__PURE__ */ __name(async (index, principal, id) => {
2365
- const found = await index.catalog?.get(principal, fileId(id));
2573
+ const found = await index.catalog?.get(principal, helpers.id(id));
2366
2574
  if (!found)
2367
2575
  throw new CliError("not_found", "file or folder is not in the active local catalog; run catalog import or sync", {
2368
2576
  reason: "catalog.not-found"
2369
2577
  });
2370
2578
  return found;
2371
2579
  }, "entry");
2372
- examples(local(catalog.command("import").description("put cached file and folder metadata into the shared database"), true), ["drive personal catalog import --offline"]).action(async () => output(itemOf(await run3(async (index, principal) => {
2373
- const state = readState(env, selected(), principal);
2374
- return index.catalog.import(principal, catalogFiles(state, activeProfile(env, selected()).roots));
2375
- }, true))));
2376
- examples(annotate(local(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
2377
- output: { entity: "document", view: "drive_catalog" }
2378
- }), ["drive personal catalog show FILE_ID --offline"]).argument("<file>", "Google file or folder id, or its Drive URL").action(async (id) => output(itemOf(await run3(async (index, principal) => catalogOutput(await entry(index, principal, id))))));
2379
- const list = /* @__PURE__ */ __name(async (words, args, search) => {
2380
- const ast = words.length ? validateQuery(parseLucene(words.join(" "), { defaultField: search ? "text" : "none" }), CATALOG_QUERY) : void 0;
2580
+ examples2(local(catalog.command("import").description("put cached file and folder metadata into the shared database"), true), [`${prefix} catalog import --offline`]).action(async () => output(itemOf(await run3((index, principal) => index.catalog.import(principal), true))));
2581
+ examples2(annotate(local(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
2582
+ output: { entity: "document", view }
2583
+ }), [`${prefix} catalog show FILE_ID --offline`]).argument("<file>", text.catalogArgument).action(async (id) => output(itemOf(await run3(async (index, principal) => catalogOutput(await entry(index, principal, id))))));
2584
+ const list = /* @__PURE__ */ __name(async (terms, args, search) => {
2585
+ const ast = terms.length ? validateQuery(parseLucene(terms.join(" "), { defaultField: search ? "text" : "none" }), CATALOG_QUERY) : void 0;
2381
2586
  const result = await run3((index, principal) => index.catalog.list(principal, { ast, limit: args.limit, offset: (args.page - 1) * args.limit }));
2382
2587
  output(listOf(`catalog ${search ? "search" : "list"}`, {
2383
2588
  items: result.items.map(catalogOutput),
2384
2589
  limit: args.limit,
2385
2590
  has_more: result.hasMore,
2386
2591
  page: args.page,
2387
- args: { query: words.length ? words.join(" ") : void 0 }
2592
+ args: { query: terms.length ? terms.join(" ") : void 0 }
2388
2593
  }));
2389
2594
  }, "list");
2390
2595
  for (const action of ["list", "search"]) {
2391
- const command = examples(local(catalog.command(action).description(action === "list" ? "list cached files and folders using metadata queries" : "search cached names, descriptions, types and observed people")), [
2392
- action === "list" ? 'drive personal catalog list "parent:FOLDER_ID AND kind:file" --offline' : 'drive personal catalog search "budget AND person:Rin*" --offline'
2393
- ]).argument(action === "list" ? "[query...]" : "<query...>", "metadata query: kind, mime, name, parent, person, tag; AND, OR, NOT").option("--limit <n>", "how many entries to return (at most 1000)", positive2, 50).option("--page <n>", "which page to return", positive2, 1).action(async (words, args) => list(words, args, action === "search"));
2394
- annotate(command, { query: CATALOG_QUERY, output: { entity: "document", view: "drive_catalog" } });
2596
+ const command = examples2(local(catalog.command(action).description(action === "list" ? "list cached files and folders using metadata queries" : "search cached names, descriptions, types and observed people")), [
2597
+ action === "list" ? `${prefix} catalog list "parent:FOLDER_ID AND kind:file" --offline` : `${prefix} catalog search "budget AND person:Rin*" --offline`
2598
+ ]).argument(action === "list" ? "[query...]" : "<query...>", "metadata query: kind, mime, name, parent, person, tag; AND, OR, NOT").option("--limit <n>", "how many entries to return (at most 1000)", positive, 50).option("--page <n>", "which page to return", positive, 1).action(async (terms, args) => list(terms, args, action === "search"));
2599
+ annotate(command, { query: CATALOG_QUERY, output: { entity: "document", view } });
2395
2600
  }
2396
- examples(local(catalog.command("tree").description("show the cached hierarchy below a folder or all selected roots")), ["drive personal catalog tree --offline", "drive personal catalog tree FOLDER_ID --depth 3 --offline"]).argument("[folder]", "Google folder id or URL; defaults to the explicitly selected profile's roots").option("--depth <n>", "maximum descendant depth, from 0 to 50", offset2, 5).action(async (id, args) => output(await run3(async (index, principal) => {
2397
- const items = [];
2398
- for (let skip = 0; skip < 1e4; skip += 1e3) {
2399
- const page = await index.catalog.list(principal, { limit: 1e3, offset: skip });
2400
- for (const item of page.items)
2401
- items.push(item);
2402
- if (!page.hasMore)
2403
- break;
2404
- }
2405
- const roots2 = id ? [fileId(id)] : activeProfile(env, selected()).roots;
2406
- return allOf(catalogTree(items, roots2.map((root) => `${root}.md`), args.depth));
2601
+ examples2(local(catalog.command("tree").description("show the cached hierarchy below a folder or all selected roots")), [`${prefix} catalog tree --offline`, `${prefix} catalog tree FOLDER_ID --depth 3 --offline`]).argument("[folder]", text.treeArgument).option("--depth <n>", "maximum descendant depth, from 0 to 50", nonnegative, 5).action(async (id, args) => output(await run3(async (index, principal) => {
2602
+ const roots2 = id ? [helpers.id(id)] : helpers.roots();
2603
+ const tree = await catalogTree(catalogSource(index.catalog, principal), roots2.map((root) => `${root}.md`), args.depth);
2604
+ return allOf(tree);
2407
2605
  })));
2408
2606
  const tags = local(catalog.command("tags")).description("add owner tags to cached files or folders");
2409
2607
  for (const action of ["list", "add", "remove"]) {
2410
- const command = examples(local(tags.command(action).description(`${action} local tags on a cached file or folder`), action !== "list"), [`drive personal catalog tags ${action} FOLDER_ID${action === "list" ? "" : " project"} --offline`]).argument("<file>", "Google file or folder id, or its Drive URL");
2608
+ const command = examples2(local(tags.command(action).description(`${action} local tags on a cached file or folder`), action !== "list"), [`${prefix} catalog tags ${action} FOLDER_ID${action === "list" ? "" : " project"} --offline`]).argument("<file>", text.catalogArgument);
2411
2609
  if (action === "list")
2412
- bindQuery(command, TAGS_QUERY, tagRow);
2610
+ bindQuery2(command, queries.tags, tagRow);
2413
2611
  else
2414
2612
  command.argument("<tags...>", "local tag names");
2415
2613
  command.action(async (id, values2 = []) => {
2416
- const filter = action === "list" ? termsOf(values2, TAGS_QUERY, "catalog tags list") : void 0;
2614
+ const filter = action === "list" ? termsOf2(values2, queries.tags, "catalog tags list") : void 0;
2417
2615
  return output(allOf(await run3(async (index, principal) => {
2418
2616
  const found = await entry(index, principal, id);
2419
2617
  if (!index.knowledge)
@@ -2423,26 +2621,569 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
2423
2621
  }, action !== "list")));
2424
2622
  });
2425
2623
  }
2426
- }, "installCatalogCommands");
2427
-
2428
- // dist/commands/config.js
2429
- import { join as join4 } from "node:path";
2624
+ }, "addDocumentCatalogCommandsDefinition");
2625
+ var addDocumentCatalogCommands = honoursDryRun(sharedCommand(addDocumentCatalogCommandsDefinition));
2430
2626
 
2431
- // dist/policy.js
2432
- import { join as join3 } from "node:path";
2433
- var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
2434
- var overridesOf = /* @__PURE__ */ __name((entries = []) => {
2435
- const levels = {};
2436
- for (const entry of entries) {
2437
- const [key = "", level = "", extra] = entry.split("=");
2438
- if (!/^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/.test(key) || !LEVELS.includes(level) || extra)
2439
- throw new CliError("validation_error", "--permission takes a command path and level, e.g. files.trash=deny (deny, readonly, ask, allow)");
2440
- levels[key] = level;
2441
- }
2442
- return levels;
2443
- }, "overridesOf");
2444
- var policySettings = /* @__PURE__ */ __name((env, profile, flags = {}) => {
2445
- const keys = flags.permissionKeys;
2627
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/documents.js
2628
+ import { writeFileSync } from "node:fs";
2629
+ var addLocalDocumentCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
2630
+ const { output, lastSync } = helpers;
2631
+ const wording = wordsOf(helpers.words);
2632
+ const { prefix, provider, text } = wording;
2633
+ const documents = documentsGroup(program, wording);
2634
+ annotate(withQuery(examples2(annotate(documents.command("list"), { effects: LOCAL_READ }).description(text.documentsList), [
2635
+ `${prefix} documents list`,
2636
+ `${prefix} documents list tag:budget`,
2637
+ `${prefix} documents list person:PERSON_UID --limit 10`
2638
+ ]), IMPORTED_DOCUMENT_QUERY), { output: { entity: "document", view: "imported" }, partial: true }).option("--limit <n>", "how many documents to return", positive, 50).option("--page <n>", "which page to return", positive, 1).action(async (words, { limit, page }) => {
2639
+ const query = typedQuery(words);
2640
+ const ast = listQuery(query, IMPORTED_DOCUMENT_QUERY, "documents list");
2641
+ const found = await helpers.list(ast, { limit, offset: (page - 1) * limit });
2642
+ const synced = lastSync();
2643
+ const age = ageOf(synced);
2644
+ output(listOf("documents list", {
2645
+ ...staleCopy(provider, synced),
2646
+ items: found.items.map((item) => ({ ...item, ...age })),
2647
+ limit,
2648
+ has_more: found.hasMore,
2649
+ page,
2650
+ args: { query: query || void 0 }
2651
+ }));
2652
+ });
2653
+ examples2(annotate(documents.command("show"), { effects: LOCAL_READ, partial: true }).argument("<document>", text.documentArgument).description("show an imported document's text, tabs and metadata"), [`${prefix} documents show DOC_ID`, `${prefix} documents show document:42 --offline`]).action((input) => {
2654
+ const { metadata, snapshot } = helpers.document(input);
2655
+ const synced = lastSync();
2656
+ output(itemOf({
2657
+ metadata,
2658
+ ...ageOf(synced),
2659
+ text: snapshot.text,
2660
+ tabs: snapshot.tabs,
2661
+ ...snapshot.notRead ? { not_read: snapshot.notRead } : {}
2662
+ }, staleCopy(provider, synced)));
2663
+ });
2664
+ examples2(annotate(documents.command("export"), { effects: LOCAL_WRITE, partial: true }).argument("<document>", text.documentArgument).description("write an imported document to a new Markdown file"), [`${prefix} documents export DOC_ID --output notes.md`]).requiredOption("--output <file>", "path of the Markdown file to write; an existing file is refused").action((input, args) => {
2665
+ const { id, snapshot } = helpers.document(input);
2666
+ try {
2667
+ writeFileSync(args.output, snapshot.markdown, { flag: "wx", mode: 384 });
2668
+ } catch (error) {
2669
+ if (error.code === "EEXIST")
2670
+ throw new CliError("validation_error", "the output file already exists; choose another --output", {
2671
+ reason: "export.exists",
2672
+ param: "--output"
2673
+ });
2674
+ throw error;
2675
+ }
2676
+ const synced = lastSync();
2677
+ output(itemOf({ id, path: args.output, format: "markdown", ...ageOf(synced) }, staleCopy(provider, synced)));
2678
+ });
2679
+ return documents;
2680
+ }, "addLocalDocumentCommandsDefinition");
2681
+ var addLocalDocumentCommands = honoursDryRun(sharedCommand(addLocalDocumentCommandsDefinition));
2682
+
2683
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/folders.js
2684
+ var addDocumentFolderCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
2685
+ const { output } = helpers;
2686
+ const wording = wordsOf(helpers.words);
2687
+ const { prefix, text } = wording;
2688
+ const queries = documentQueries();
2689
+ const folders = annotate(program.command("folders"), { effects: LOCAL_READ }).description(text.folders);
2690
+ examples2(annotate(folders.command("add"), { effects: FETCH }).argument("<folder>", text.folderArgument).description("import a folder and everything under it on the next sync"), [`${prefix} folders add FOLDER_ID`]).action(async (input) => {
2691
+ const { id, name } = await helpers.add(input);
2692
+ output(itemOf({ id, name, added: true }));
2693
+ });
2694
+ bindQuery2(examples2(annotate(folders.command("list"), { effects: LOCAL_READ }).description("list the folder ids sync imports"), [`${prefix} folders list`]), queries.folders, folderRow).action((words) => {
2695
+ const filter = termsOf2(words, queries.folders, "folders list");
2696
+ output(allOf(helpers.list(filter)));
2697
+ });
2698
+ examples2(annotate(folders.command("remove"), { effects: LOCAL_WRITE }).argument("<folder>", text.folderArgument).description("stop importing a folder; the next sync drops its documents"), [`${prefix} folders remove FOLDER_ID`]).action((input) => {
2699
+ output(itemOf({ id: helpers.remove(input), removed: true }));
2700
+ });
2701
+ return folders;
2702
+ }, "addDocumentFolderCommandsDefinition");
2703
+ var sharedFolderCommands = honoursDryRun(sharedCommand(addDocumentFolderCommandsDefinition));
2704
+ var addDocumentFolderCommands = /* @__PURE__ */ __name((program, helpers) => {
2705
+ const folders = sharedFolderCommands(program, helpers);
2706
+ if (!helpers.browse)
2707
+ return folders;
2708
+ const before = new Set(folders.commands);
2709
+ helpers.browse(folders);
2710
+ const added = folders.commands.filter((command) => !before.has(command));
2711
+ const children = folders.commands;
2712
+ const rest = children.filter((command) => before.has(command));
2713
+ const at = rest.findIndex((command) => command.name() === "remove");
2714
+ children.splice(0, children.length, ...rest.slice(0, at), ...added, ...rest.slice(at));
2715
+ return folders;
2716
+ }, "addDocumentFolderCommands");
2717
+
2718
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/knowledge.js
2719
+ var addDocumentKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
2720
+ const { run: run3, output, author, decider } = helpers;
2721
+ const wording = wordsOf(helpers.words);
2722
+ const { prefix, text } = wording;
2723
+ const queries = documentQueries();
2724
+ const documentArgument = text.knowledgeArgument;
2725
+ const scopes = ["personal", "work"];
2726
+ const documents = documentsGroup(program, wording);
2727
+ examples2(annotate(documents.command("context"), { effects: LOCAL_READ }).argument("<document>", documentArgument).description("show a document with its tags, relationships, notes, memories and editors"), [`${prefix} documents context DOC_ID`]).action(async (doc) => output(itemOf(await run3(doc, (k, p, ref) => k.context(p, ref)))));
2728
+ const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
2729
+ for (const action of ["list", "add", "remove"]) {
2730
+ const command = examples2(annotate(tags.command(action), { effects: action === "list" ? LOCAL_READ : LOCAL_WRITE }).description(action === "list" ? "list a document's tags" : action === "add" ? "tag a document" : "untag a document").argument("<document>", documentArgument), [`${prefix} tags ${action} DOC_ID${action === "list" ? "" : " budget q3"}`]);
2731
+ if (action === "list") {
2732
+ bindQuery2(command, queries.tags, tagRow).action(async (doc, words) => {
2733
+ const filter = termsOf2(words, queries.tags, "tags list");
2734
+ output(allOf((await run3(doc, (k, p, ref) => k.tags(p, ref, "list", [], filter))).map((tag) => ({ tag }))));
2735
+ });
2736
+ } else
2737
+ command.argument("<tags...>", "one or more tags").action(async (doc, values2) => output(itemOf({ tags: await run3(doc, (k, p, ref) => k.tags(p, ref, action, values2)) })));
2738
+ }
2739
+ const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
2740
+ bindQuery2(examples2(annotate(relationships.command("list"), { effects: LOCAL_READ }).description("list a document's relationships"), [`${prefix} relationships list DOC_ID`]).argument("<document>", documentArgument), queries.links, linkRow).action(async (doc, words) => {
2741
+ const { confirmed, ...filter } = termsOf2(words, queries.links, "relationships list");
2742
+ output(allOf(await run3(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...confirmed === void 0 ? {} : { confirmed: confirmed === "true" } }))));
2743
+ });
2744
+ examples2(annotate(relationships.command("add"), { effects: LOCAL_WRITE }).description("connect a document to another reference"), [
2745
+ `${prefix} relationships add DOC_ID project:PROJECT_ID --kind about`,
2746
+ `${prefix} relationships add DOC_ID person:PERSON_UID --kind assigned-to --role reviewer`
2747
+ ]).argument("<document>", documentArgument).argument("<reference>", "what it connects to, such as person:<uid>, project:<id> or note:<id>").addOption(new Option("--kind <kind>", "how the two relate").choices(["links-to", "about", "evidence", "created-from", "related-to", "assigned-to"]).default("related-to")).option("--role <role>", "the part the reference plays, in a word or two").option("--reason <text>", "why the two are connected").action(async (doc, to, { reason, ...args }) => output(itemOf(await run3(doc, (k, p, ref) => k.addLink(p, ref, { to, ...args, by: decider(), ...reason ? { evidence: reason } : {} })))));
2748
+ examples2(annotate(relationships.command("remove"), { effects: LOCAL_WRITE }).description("remove one of a document's relationships"), [`${prefix} relationships remove DOC_ID LINK_ID`]).argument("<document>", documentArgument).argument("<relationship-id>", "id, as relationships list prints it").action(async (doc, id) => output(itemOf(await run3(doc, (k, p, ref) => k.removeLink(p, ref, id, decider())))));
2749
+ const notes = annotate(program.command("notes"), { effects: LOCAL_READ }).description("write notes about an imported document");
2750
+ const noteArgument = "note:<id> reference, as notes list prints it";
2751
+ examples2(annotate(notes.command("add"), {
2752
+ effects: LOCAL_WRITE,
2753
+ output: { entity: "note" },
2754
+ literal_after_dashes: true
2755
+ }).description("write a note about a document"), [`${prefix} notes add DOC_ID "Check the numbers" --title Review`]).argument("<document>", documentArgument).argument("<text>", "the note's text").option("--title <title>", "a title for the note").action(async (doc, text2, args) => output(itemOf(await run3(doc, (k, p, ref) => k.addNote(p, ref, text2, args.title)))));
2756
+ withQuery(examples2(annotate(notes.command("list"), { effects: LOCAL_READ }).description("list a document's notes"), [
2757
+ `${prefix} notes list DOC_ID`,
2758
+ `${prefix} notes list DOC_ID text:review --limit 10`
2759
+ ]).argument("<document>", documentArgument), queries.notes).option("--limit <n>", "how many notes to return", positive, 50).option("--page <n>", "which page to return", positive, 1).action(async (doc, words, { page, limit }) => {
2760
+ const query = termsOf2(words, queries.notes, "notes list").text;
2761
+ const found = await run3(doc, (k, p, ref) => k.notes(p, ref, { ...query ? { search: query } : {}, limit, offset: (page - 1) * limit }));
2762
+ output(listOf("notes list", {
2763
+ items: found.items,
2764
+ limit,
2765
+ has_more: found.hasMore,
2766
+ page,
2767
+ args: { document: doc, query: words.join(" ") }
2768
+ }));
2769
+ });
2770
+ examples2(annotate(notes.command("show"), { effects: LOCAL_READ, output: { entity: "note" } }).description("show one note"), [`${prefix} notes show DOC_ID note:NOTE_ID`]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.note(p, ref, noteRef)))));
2771
+ examples2(annotate(notes.command("edit"), {
2772
+ effects: LOCAL_WRITE,
2773
+ output: { entity: "note" },
2774
+ literal_after_dashes: true
2775
+ }).description("replace a note's text"), [`${prefix} notes edit DOC_ID note:NOTE_ID "Numbers checked" --revision 2`]).argument("<document>", documentArgument).argument("<note>", noteArgument).argument("<text>", "the note's new text").requiredOption("--revision <n>", "revision from notes show; a newer note is not overwritten", positive).action(async (doc, noteRef, text2, args) => output(itemOf(await run3(doc, (k, p, ref) => k.editNote(p, ref, noteRef, text2, args.revision)))));
2776
+ examples2(annotate(notes.command("remove"), { effects: LOCAL_WRITE }).description("delete one note"), [
2777
+ `${prefix} notes remove DOC_ID note:NOTE_ID`
2778
+ ]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.removeNote(p, ref, noteRef)))));
2779
+ const memories = annotate(program.command("memories"), { effects: LOCAL_READ }).description("keep what was learned from a document, with evidence; an agent's stay proposed");
2780
+ const memoryArgument = "memory:<id> reference, as memories list prints it";
2781
+ const scope = /* @__PURE__ */ __name((description) => new Option("--scope <scope>", description).choices(scopes), "scope");
2782
+ examples2(annotate(memories.command("add"), { effects: LOCAL_WRITE }).description("record a memory about a document"), [`${prefix} memories add DOC_ID "The team prefers async reviews" --scope work --kind preference`]).argument("<document>", documentArgument).argument("<text>", "what to remember").addOption(scope("whose memory it is: personal or work").makeOptionMandatory()).addOption(new Option("--kind <kind>", "what kind of memory it is").choices(MEMORY_KINDS).default("summary")).option("--supersedes <ref>", "a memory:<id> about the same document that this one replaces").action(async (doc, body, args) => output(itemOf(memoryItem(await run3(doc, (k, p, ref) => k.addMemory(p, ref, { body, ...args, status: "proposed", author: author() }))))));
2783
+ withQuery(examples2(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
2784
+ `${prefix} memories list DOC_ID scope:work`,
2785
+ `${prefix} memories list DOC_ID kind:preference status:confirmed`
2786
+ ]).argument("<document>", documentArgument), MEMORY_QUERY).option("--limit <n>", "how many memories to return", positive, 50).action(async (doc, words, { limit }) => {
2787
+ const terms = queryTerms(words, MEMORY_QUERY, "memories list");
2788
+ const filters = {
2789
+ ...terms.has("kind") ? { kind: terms.get("kind") } : {},
2790
+ ...terms.has("status") ? { status: terms.get("status") } : {},
2791
+ ...terms.has("scope") ? { scope: terms.get("scope") } : {}
2792
+ };
2793
+ output(allOf((await run3(doc, (k, p, ref) => k.memories(p, ref, { ...filters, limit }))).items.map(memoryItem)));
2794
+ });
2795
+ const memoryActions = {
2796
+ show: "show one memory",
2797
+ confirm: "confirm a proposed memory as true",
2798
+ stale: "mark a memory as out of date"
2799
+ };
2800
+ for (const [action, description] of Object.entries(memoryActions))
2801
+ examples2(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} memories ${action} DOC_ID memory:MEMORY_ID`]).argument("<document>", documentArgument).argument("<memory>", memoryArgument).action(async (doc, memoryRef) => output(itemOf(memoryItem(await run3(doc, (k, p, ref) => action === "show" ? k.memory(p, ref, memoryRef) : k.memory(p, ref, memoryRef, action, decider()))))));
2802
+ const search = examples2(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [`${prefix} memories search DOC_ID reviews scope:work`, `${prefix} memories search DOC_ID "async reviews"`]).argument("<document>", documentArgument).argument("<query...>", "words to look for, and scope:personal or scope:work \u2014 the fields are below").allowUnknownOption().addHelpText("after", queryHelp(MEMORY_SEARCH_QUERY)).action(async (doc, words) => {
2803
+ const { text: text2, scope: scope2 } = memorySearch(words);
2804
+ const found = await run3(doc, (k, p, ref) => k.searchMemories(p, ref, text2, scope2));
2805
+ output({
2806
+ ...allOf(found.items.map(memoryItem)),
2807
+ ...found.hasMore ? { meta: { truncated: true } } : {}
2808
+ });
2809
+ });
2810
+ annotate(search, { query: defineQuery(MEMORY_SEARCH_QUERY), output: { entity: "memory" } });
2811
+ examples2(annotate(memories.command("extract"), { effects: REMOTE_WRITE }).argument("<document>", documentArgument).description("send a document's text to the model and show the memories it proposes"), [`${prefix} memories extract DOC_ID --scope work`, `${prefix} memories extract DOC_ID --scope work --yes`]).addOption(scope("whose memories they become: personal or work").makeOptionMandatory()).option("--tab <id>", "send only this tab of the document").option("--yes", "save the proposals, each with its quote and the document's version").action(async function(doc) {
2812
+ const args = this.opts();
2813
+ await run3(doc, async () => void 0);
2814
+ const result = await extractDocumentMemories({
2815
+ read: /* @__PURE__ */ __name(() => helpers.document(doc), "read"),
2816
+ complete: helpers.complete(),
2817
+ scope: args.scope,
2818
+ author: `${wording.app}-memory`,
2819
+ tab: args.tab,
2820
+ save: args.yes,
2821
+ withWrite: /* @__PURE__ */ __name((write) => run3(doc, write), "withWrite")
2822
+ });
2823
+ output(itemOf({ ...result, saved: result.saved.map((item) => "type" in item ? factItem(item) : memoryItem(item)) }));
2824
+ });
2825
+ const facts = annotate(program.command("facts"), { effects: LOCAL_READ }).description("what happened, as a document shows it; an agent's stay proposed until confirmed");
2826
+ const factArgument = "fact:<id> reference, as facts list prints it";
2827
+ examples2(annotate(facts.command("add"), { effects: LOCAL_WRITE }).description("record a fact a document shows"), [
2828
+ `${prefix} facts add DOC_ID "Budget approved" --type decision --scope work`
2829
+ ]).argument("<document>", documentArgument).argument("<statement>", "the fact, in one sentence").addOption(new Option("--type <type>", "what kind of fact it is").choices(FACT_TYPES).default("fact")).addOption(scope("whose fact it is: personal or work")).option("--supersedes <ref>", "a decision only: the decision this one replaces").option("--occurred-time <time>", "when it happened, as the evidence shows, ISO 8601; a time without a zone is read in this computer's zone, a date alone as its midnight").action(async (doc, statement, { occurredTime, ...args }) => output(itemOf(factItem(await run3(doc, (k, p, ref) => k.addFact(p, ref, {
2830
+ statement,
2831
+ ...args,
2832
+ by: author(),
2833
+ ...occurredTime === void 0 ? {} : { occurredAt: occurredTime }
2834
+ }))))));
2835
+ withQuery(examples2(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
2836
+ `${prefix} facts list DOC_ID status:proposed`,
2837
+ `${prefix} facts list DOC_ID kind:decision`
2838
+ ]).argument("<document>", documentArgument), FACT_QUERY).option("--limit <n>", "how many facts to return", positive, 50).action(async (doc, words, { limit }) => {
2839
+ const terms = queryTerms(words, FACT_QUERY, "facts list");
2840
+ const filters = {
2841
+ ...terms.has("kind") ? { type: terms.get("kind") } : {},
2842
+ ...terms.has("status") ? { status: terms.get("status") } : {}
2843
+ };
2844
+ output(allOf((await run3(doc, (k, p, ref) => k.facts(p, ref, { ...filters, limit }))).items.map(factItem)));
2845
+ });
2846
+ const factActions = {
2847
+ show: "show one fact",
2848
+ confirm: "confirm a proposed fact; a decision it supersedes stops holding",
2849
+ reverse: "an accepted decision no longer holds, and nothing replaced it"
2850
+ };
2851
+ for (const [action, description] of Object.entries(factActions))
2852
+ examples2(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} facts ${action} DOC_ID fact:FACT_ID`]).argument("<document>", documentArgument).argument("<fact>", factArgument).action(async (doc, factRef) => output(itemOf(factItem(await run3(doc, (k, p, ref) => action === "show" ? k.fact(p, ref, factRef) : k.fact(p, ref, factRef, action, decider()))))));
2853
+ const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description(text.identities);
2854
+ bindQuery2(examples2(annotate(identities.command("list"), { effects: LOCAL_READ }).description(text.identitiesList), [
2855
+ `${prefix} identities list DOC_ID`
2856
+ ]).argument("<document>", documentArgument), queries.identities, identityRow).action(async (doc, words) => {
2857
+ const filter = termsOf2(words, queries.identities, "identities list");
2858
+ output(itemOf(await run3(doc, (k, p, ref) => k.people(p, ref, filter))));
2859
+ });
2860
+ examples2(annotate(identities.command("link"), { effects: LOCAL_WRITE }).description(text.identitiesLink), [
2861
+ `${prefix} identities link DOC_ID ${wording.remote.toUpperCase()}_ID person:PERSON_UID`
2862
+ ]).argument("<document>", documentArgument).argument(`<${wording.remote}-id>`, text.identityArgument).argument("<person>", "person:<uid> reference of someone already known").action(async (doc, remoteId, personRef) => output(itemOf(await run3(doc, (k, p, ref) => k.linkPerson(p, ref, remoteId, personRef)))));
2863
+ }, "addDocumentKnowledgeCommandsDefinition");
2864
+ var addDocumentKnowledgeCommands = honoursDryRun(sharedCommand(addDocumentKnowledgeCommandsDefinition));
2865
+
2866
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/mirrors.js
2867
+ import { statSync } from "node:fs";
2868
+ import { resolve } from "node:path";
2869
+ var addDocumentMirrorCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
2870
+ const { output } = helpers;
2871
+ const wording = wordsOf(helpers.words);
2872
+ const { app, prefix, provider, remote, text } = wording;
2873
+ const queries = documentQueries();
2874
+ const mirrors = annotate(program.command("mirrors"), { effects: LOCAL_READ }).description(text.mirrors);
2875
+ const find = /* @__PURE__ */ __name((id) => {
2876
+ const mirror = helpers.mirrors().find((item) => item.id === id);
2877
+ if (!mirror)
2878
+ throw new CliError("not_found", `no mirror ${id} in profile ${helpers.profile()}; see ${app} ${helpers.profile()} mirrors list`, {
2879
+ reason: "mirror.not-found"
2880
+ });
2881
+ return mirror;
2882
+ }, "find");
2883
+ const syncing = /* @__PURE__ */ __name((connection) => ({
2884
+ ...connection.sync,
2885
+ stateOf: /* @__PURE__ */ __name((mirror) => helpers.stateOf(mirror), "stateOf"),
2886
+ remote
2887
+ }), "syncing");
2888
+ const chosenOf = /* @__PURE__ */ __name((id) => {
2889
+ const name = helpers.profile();
2890
+ const chosen = id ? [find(id)] : helpers.mirrors();
2891
+ if (!chosen.length)
2892
+ throw new CliError("not_found", `profile ${name} has no mirrors; add one with ${app} ${name} mirrors add`, {
2893
+ reason: "mirror.none"
2894
+ });
2895
+ return chosen;
2896
+ }, "chosenOf");
2897
+ examples2(annotate(mirrors.command("add"), { effects: FETCH }).argument("<path>", "local folder to mirror").requiredOption("--parent <id>", text.mirrorParent).description(text.mirrorsAdd), [`${prefix} mirrors add ./notes --parent FOLDER_ID`]).action(async (path, args) => {
2898
+ const root = resolve(path);
2899
+ let directory = false;
2900
+ try {
2901
+ directory = statSync(root).isDirectory();
2902
+ } catch {
2903
+ }
2904
+ if (!directory)
2905
+ throw new CliError("validation_error", "the path to mirror is not a folder", { reason: "mirror.not-folder" });
2906
+ const parent = await helpers.parent(args.parent);
2907
+ const folder = parent.id;
2908
+ const id = mirrorId(root, folder);
2909
+ const list = helpers.mirrors();
2910
+ if (!list.some((mirror) => mirror.id === id))
2911
+ list.push({ id, path: root, folder });
2912
+ helpers.save(list);
2913
+ output(itemOf({ id, path: root, folder, folder_name: parent.name, added: true }));
2914
+ });
2915
+ bindQuery2(examples2(annotate(mirrors.command("list"), { effects: LOCAL_READ }).description("list this profile's mirrors"), [
2916
+ `${prefix} mirrors list`
2917
+ ]), queries.mirrors, mirrorRow).action((words) => {
2918
+ const filter = termsOf2(words, queries.mirrors, "mirrors list");
2919
+ output(allOf(helpers.mirrors().filter((row) => Object.entries(filter).every(([key, value]) => row[key] === value))));
2920
+ });
2921
+ examples2(annotate(mirrors.command("remove"), { effects: LOCAL_WRITE }).argument("<id>", "mirror id from mirrors list").description(`stop mirroring a folder; nothing in ${wording.place} is changed or deleted`), [`${prefix} mirrors remove 1a2b3c4d`]).action((id) => {
2922
+ find(id);
2923
+ helpers.save(helpers.mirrors().filter((mirror) => mirror.id !== id));
2924
+ output(itemOf({ id, removed: true }));
2925
+ });
2926
+ examples2(annotate(mirrors.command("status"), { effects: LOCAL_READ }).argument("[id]", "mirror id; every mirror of the profile when omitted").description(`show which local files the next sync would create or send; ${provider} is not asked`), [`${prefix} mirrors status`]).action(async (id) => {
2927
+ const items = await mirrorStatus(id ? [find(id)] : helpers.mirrors(), helpers.kindOf, (mirror) => helpers.stateOf(mirror));
2928
+ output(allOf(items.map(({ id: id2, folder, create, update: update2, unchanged, orphans, unsupported, remote_checked }) => ({
2929
+ id: id2,
2930
+ folder,
2931
+ create: create.length,
2932
+ update: update2.length,
2933
+ unchanged,
2934
+ orphans: orphans.length,
2935
+ unsupported,
2936
+ remote_checked
2937
+ }))));
2938
+ });
2939
+ examples2(annotate(mirrors.command("sync"), { effects: REMOTE_WRITE }).argument("[id]", "mirror id; every mirror of the profile when omitted").addOption(new Option("--keep <side>", "where a part changed on both sides, keep this side").choices([
2940
+ "local",
2941
+ remote,
2942
+ "both"
2943
+ ])).option("--replace", `same as --keep local, and create again files deleted in ${provider}`).description(text.mirrorsSync), [
2944
+ `${prefix} mirrors sync`,
2945
+ `${prefix} mirrors sync 1a2b3c4d --keep ${remote}`,
2946
+ `${prefix} mirrors sync 1a2b3c4d --replace`
2947
+ ]).action(async (id, args) => {
2948
+ const chosen = chosenOf(id);
2949
+ if (args.replace && args.keep && args.keep !== "local")
2950
+ throw new CliError("validation_error", `--replace keeps the local side; it cannot be combined with --keep ${remote} or both`);
2951
+ const keep = args.replace ? "local" : args.keep === remote ? "remote" : args.keep;
2952
+ const connection = await helpers.connect();
2953
+ const { items, issues } = await syncMirrors({
2954
+ ...syncing(connection),
2955
+ mirrors: chosen,
2956
+ ...keep ? { keep } : {},
2957
+ recreate: args.replace === true
2958
+ });
2959
+ const body = allOf(items);
2960
+ if (issues.length)
2961
+ body.meta = { complete: false, issues };
2962
+ output(body);
2963
+ if (issues.length)
2964
+ throw new CliError("provider_error", `some files were not synced; see conflicts, missing and errors, then rerun with --keep local, ${remote} or both`, { reason: "mirror.partial" });
2965
+ });
2966
+ examples2(annotate(mirrors.command("watch"), { effects: REMOTE_WRITE, lifetime: "persistent" }).argument("[id]", "mirror id; every mirror of the profile when omitted").option("--every <duration>", `how often to ask ${provider} for changes`, "60s").summary("keep syncing both ways until Ctrl-C or --timeout").description(`keep syncing both ways until Ctrl-C or --timeout: on each local save and each ${provider} change; a part changed on both sides is reported and left for mirrors sync --keep`), [`${prefix} mirrors watch`, `${prefix} mirrors watch 1a2b3c4d --every 2m --jsonl`]).action(async (id, args) => {
2967
+ const pollMs = parseDuration(args.every, "--every");
2968
+ if (pollMs < 1e4)
2969
+ throw new CliError("validation_error", "--every must be at least 10s");
2970
+ const chosen = chosenOf(id);
2971
+ const signal = helpers.endsOnStop() ?? new AbortController().signal;
2972
+ const connection = await helpers.connect();
2973
+ const states = /* @__PURE__ */ __name((mirror) => helpers.stateOf(mirror), "states");
2974
+ let token = await connection.startToken();
2975
+ const remoteChanges = /* @__PURE__ */ __name(async () => {
2976
+ let changed;
2977
+ try {
2978
+ const feed = await connection.changes(token);
2979
+ token = feed.cursor;
2980
+ changed = new Set(feed.items.map((item) => item.id));
2981
+ } catch (error) {
2982
+ if (!isCliError(error) || error.details?.reason !== "listing.too-large")
2983
+ throw error;
2984
+ token = await connection.startToken();
2985
+ return "all";
2986
+ }
2987
+ return chosen.filter((mirror) => Object.values(states(mirror).read().entries).some((entry) => changed.has(entry.id))).map((mirror) => mirror.id);
2988
+ }, "remoteChanges");
2989
+ let cycles = 0;
2990
+ for await (const event of watchMirrors((mirrors2) => syncMirrors({ ...syncing(connection), mirrors: mirrors2 }), {
2991
+ mirrors: chosen,
2992
+ signal,
2993
+ kindOf: helpers.kindOf,
2994
+ stateOf: states,
2995
+ remoteChanges,
2996
+ pollMs
2997
+ })) {
2998
+ cycles++;
2999
+ const data = {
3000
+ at: (/* @__PURE__ */ new Date()).toISOString(),
3001
+ triggers: event.triggers,
3002
+ mirrors: event.mirrors,
3003
+ ..."error" in event ? { error: { code: event.error.code, message: event.error.message } } : { results: event.result.items, ...event.result.issues.length ? { issues: event.result.issues } : {} }
3004
+ };
3005
+ helpers.print((format, write) => write(format === "pretty" ? describeCycle(data) : JSON.stringify({ type: "item", data })));
3006
+ }
3007
+ helpers.print((format, write) => {
3008
+ if (format === "pretty")
3009
+ return;
3010
+ const end = listOf("mirrors watch", {
3011
+ items: [],
3012
+ limit: Math.max(1, cycles),
3013
+ has_more: false,
3014
+ paging: "cursor",
3015
+ meta: { complete: true }
3016
+ });
3017
+ for (const record2 of jsonlRecords(end))
3018
+ write(JSON.stringify(record2));
3019
+ });
3020
+ });
3021
+ }, "addDocumentMirrorCommandsDefinition");
3022
+ var describeCycle = /* @__PURE__ */ __name((cycle) => {
3023
+ const time = cycle.at.slice(11, 19);
3024
+ if (cycle.error)
3025
+ return `${time} ${cycle.triggers.join("+")}: ${cycle.error.message}; trying again`;
3026
+ const parts = (cycle.results ?? []).map((result) => `${result.id} ${result.created.length} created, ${result.updated.length} sent, ${result.pulled.length} pulled` + (result.conflicts.length ? `, ${result.conflicts.length} conflicts (mirrors sync ${result.id} --keep \u2026)` : ""));
3027
+ return `${time} ${cycle.triggers.join("+")}: ${parts.join("; ") || "nothing to do"}`;
3028
+ }, "describeCycle");
3029
+ var addDocumentMirrorCommands = honoursDryRun(sharedCommand(addDocumentMirrorCommandsDefinition));
3030
+
3031
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/search.js
3032
+ var notImported = /* @__PURE__ */ __name((app, { profile, chosen, documents }) => {
3033
+ if (documents > 0)
3034
+ return void 0;
3035
+ return !chosen ? `profile ${profile} has no folders selected, so nothing is imported to search \u2014 ${app} ${profile} folders add FOLDER_ID, then ${app} ${profile} sync` : `profile ${profile} has imported no documents yet \u2014 ${app} ${profile} sync`;
3036
+ }, "notImported");
3037
+ var addDocumentSearchCommandDefinition = /* @__PURE__ */ __name((program, helpers) => {
3038
+ const wording = wordsOf(helpers.words);
3039
+ const { prefix } = wording;
3040
+ return examples2(annotate(program.command("search"), { effects: LOCAL_READ }).argument("<query>", "words to look for, and fields such as tag: and date: that every hit must match").description("search imported documents by words, and by meaning when indexed"), [`${prefix} search budget`, `${prefix} search "quarterly plan" --exact --limit 5`]).option("--limit <n>", "how many results to return", positive, 20).option("--page <n>", "which page to return", positive, 1).option("--exact", "match the words exactly: no word forms, no meaning").action(async (query, { page, ...args }) => {
3041
+ const result = await helpers.search(query, {
3042
+ ...args,
3043
+ offset: (page - 1) * args.limit,
3044
+ exact: args.exact ?? false
3045
+ });
3046
+ const hint = notImported(wording.app, helpers.imported());
3047
+ helpers.output(itemOf(hint ? { ...result, not_imported: hint } : result));
3048
+ });
3049
+ }, "addDocumentSearchCommandDefinition");
3050
+ var addDocumentSearchCommand = honoursDryRun(sharedCommand(addDocumentSearchCommandDefinition));
3051
+
3052
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/cli/documents/sync.js
3053
+ var addDocumentSyncCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
3054
+ const { output } = helpers;
3055
+ const wording = wordsOf(helpers.words);
3056
+ const { prefix, text } = wording;
3057
+ const sync2 = examples2(annotate(program.command("sync"), { effects: FETCH }).summary("import what changed in the chosen folders, and finish an unfinished sync").description(`import what changed in the chosen folders, and finish an unfinished sync; one sync reads at most ${helpers.maxEntries} entries under the chosen folders, and as many changes`), [`${prefix} sync`, `${prefix} sync --rescan --limit 500`]).option("--limit <n>", text.syncLimit, positive, 200).option("--rescan", "read every chosen folder again instead of only what changed").option("--embed", "also index pending text for meaning search, with a model already downloaded").action(async (args) => {
3058
+ const result = await helpers.sync(args);
3059
+ output(itemOf(result, {
3060
+ meta: result.errors.length ? {
3061
+ complete: false,
3062
+ issues: [{ code: "provider_error", reason: "sync.partial", source: wording.source }]
3063
+ } : {}
3064
+ }));
3065
+ if (result.errors.length || result.pending)
3066
+ helpers.diagnostic(`${result.pending} source operations remain; run ${wording.app} ${helpers.profile()} sync again
3067
+ `);
3068
+ if (result.errors.length)
3069
+ throw new CliError("provider_error", "sync completed partially; failed operations remain pending", {
3070
+ reason: "sync.partial"
3071
+ });
3072
+ });
3073
+ const status = examples2(annotate(program.command("status"), { effects: LOCAL_READ }).description("show the last sync, imported documents and pending work"), [`${prefix} status`]).action(async () => {
3074
+ output(itemOf(await helpers.status()));
3075
+ });
3076
+ return [sync2, status];
3077
+ }, "addDocumentSyncCommandsDefinition");
3078
+ var addDocumentSyncCommands = honoursDryRun(sharedCommand(addDocumentSyncCommandsDefinition));
3079
+
3080
+ // dist/catalog.js
3081
+ var catalogInput = /* @__PURE__ */ __name((file) => ({
3082
+ externalId: `${file.id}.md`,
3083
+ kind: file.mime === FOLDER ? "folder" : "file",
3084
+ name: file.name,
3085
+ parents: file.parents.map((id) => `${id}.md`),
3086
+ url: file.url,
3087
+ mime: file.mime,
3088
+ size: file.size,
3089
+ createdAt: file.createdAt,
3090
+ modifiedAt: file.modifiedAt,
3091
+ description: file.description,
3092
+ actors: [
3093
+ ...(file.owners ?? []).map((actor) => ({ ...actor, role: "owner" })),
3094
+ ...file.lastModifiedBy ? [{ ...file.lastModifiedBy, role: "editor" }] : []
3095
+ ],
3096
+ metadata: file.providerMetadata ?? file,
3097
+ frontMatter: {
3098
+ source: "google-drive",
3099
+ sourceUrl: file.url,
3100
+ fileId: file.id,
3101
+ mime: file.mime,
3102
+ owners: file.owners ?? [],
3103
+ lastModifiedBy: file.lastModifiedBy ?? null
3104
+ }
3105
+ }), "catalogInput");
3106
+
3107
+ // dist/commands/context.js
3108
+ var positive2 = /* @__PURE__ */ __name((input) => {
3109
+ const n = Number(input);
3110
+ if (!Number.isSafeInteger(n) || n < 1)
3111
+ throw new InvalidArgumentError("use a positive integer");
3112
+ return n;
3113
+ }, "positive");
3114
+ var DRIVE_WORDS = {
3115
+ app: "drive",
3116
+ remote: "google",
3117
+ provider: "Google",
3118
+ place: "Google Drive",
3119
+ source: "google-drive",
3120
+ text: {
3121
+ documents: "read imported documents and Google Docs",
3122
+ documentArgument: "document id, Google Docs URL, or a search hit's document: ref",
3123
+ knowledgeArgument: "Google file or folder id or URL in the local catalog, or a document:<n> ref",
3124
+ catalog: "browse stored Drive files and folders offline",
3125
+ catalogArgument: "Google file or folder id, or its Drive URL",
3126
+ treeArgument: "Google folder id or URL; defaults to the explicitly selected profile's roots",
3127
+ identitiesList: "list the owners and last editor Google shows for a document",
3128
+ mirrors: "keep local folders mirrored into Google Docs and Sheets",
3129
+ mirrorsAdd: "mirror a local folder: Markdown to Google Docs, CSV/TSV/XLSX to Sheets",
3130
+ mirrorsSync: "sync both ways with Docs and Sheets; a part changed on both sides is reported"
3131
+ }
3132
+ };
3133
+
3134
+ // dist/commands/catalog.js
3135
+ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
3136
+ const { env, selected, output, withIndex } = helpers;
3137
+ addDocumentCatalogCommands(program, {
3138
+ words: DRIVE_WORDS,
3139
+ output,
3140
+ run: /* @__PURE__ */ __name(async (fn, write) => {
3141
+ const profile = activeProfile(env, selected());
3142
+ return withIndex(async (index) => {
3143
+ const lock = write ? await lockProfile(env, selected()) : void 0;
3144
+ try {
3145
+ lock?.assertHeld();
3146
+ const { catalog } = index;
3147
+ const value = await fn({
3148
+ ...catalog ? {
3149
+ catalog: {
3150
+ import: /* @__PURE__ */ __name((principal) => catalog.import(principal, catalogFiles(readState(env, selected(), principal), activeProfile(env, selected()).roots)), "import"),
3151
+ get: /* @__PURE__ */ __name((principal, id) => catalog.get(principal, id), "get"),
3152
+ list: /* @__PURE__ */ __name((principal, query) => catalog.list(principal, query), "list")
3153
+ }
3154
+ } : {},
3155
+ ...index.knowledge ? { knowledge: index.knowledge } : {}
3156
+ }, profile.principal);
3157
+ lock?.assertHeld();
3158
+ return value;
3159
+ } finally {
3160
+ await lock?.release();
3161
+ }
3162
+ });
3163
+ }, "run"),
3164
+ id: fileId,
3165
+ roots: /* @__PURE__ */ __name(() => activeProfile(env, selected()).roots, "roots")
3166
+ });
3167
+ }, "installCatalogCommands");
3168
+
3169
+ // dist/commands/config.js
3170
+ import { join as join4 } from "node:path";
3171
+
3172
+ // dist/policy.js
3173
+ import { join as join3 } from "node:path";
3174
+ var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
3175
+ var overridesOf = /* @__PURE__ */ __name((entries = []) => {
3176
+ const levels = {};
3177
+ for (const entry of entries) {
3178
+ const [key = "", level = "", extra] = entry.split("=");
3179
+ if (!/^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/.test(key) || !LEVELS.includes(level) || extra)
3180
+ throw new CliError("validation_error", "--permission takes a command path and level, e.g. files.trash=deny (deny, readonly, ask, allow)");
3181
+ levels[key] = level;
3182
+ }
3183
+ return levels;
3184
+ }, "overridesOf");
3185
+ var policySettings = /* @__PURE__ */ __name((env, profile, flags = {}) => {
3186
+ const keys = flags.permissionKeys;
2446
3187
  const names = keys && permissionNames(keys);
2447
3188
  const { config, issues } = inspectConfig(env, names);
2448
3189
  const [first] = issues;
@@ -2693,7 +3434,7 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2693
3434
  const download = /* @__PURE__ */ __name(async (kind, id, acceptTerms) => {
2694
3435
  if (policyFlags().offline)
2695
3436
  throw offlineRefused("downloading a model needs the network");
2696
- const { downloadImageModel, downloadTextModel } = await import("./services-SV6CFUCS.js");
3437
+ const { downloadImageModel, downloadTextModel } = await import("./services-BDQBRXT5.js");
2697
3438
  const progress = /* @__PURE__ */ __name((line) => {
2698
3439
  if (!program.opts().quiet)
2699
3440
  streams.diagnostic(line);
@@ -2726,24 +3467,8 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2726
3467
  examples(annotate(imageModels.command("download"), { effects: FETCH, output: { entity: "model" } }).description("download a picture model once into the folder every WireCat CLI shares"), ["drive images models download clip-b32"]).argument("<model>", "model id, such as clip-b32").action((id) => download("image", id, false));
2727
3468
  }, "installModelCommands");
2728
3469
 
2729
- // dist/commands/context.js
2730
- var positive = /* @__PURE__ */ __name((input) => {
2731
- const n = Number(input);
2732
- if (!Number.isSafeInteger(n) || n < 1)
2733
- throw new InvalidArgumentError("use a positive integer");
2734
- return n;
2735
- }, "positive");
2736
- var offset = /* @__PURE__ */ __name((input) => {
2737
- const n = Number(input);
2738
- if (!Number.isSafeInteger(n) || n < 0)
2739
- throw new InvalidArgumentError("use a nonnegative integer");
2740
- return n;
2741
- }, "offset");
2742
-
2743
3470
  // dist/contract-overrides.js
2744
3471
  import { createHash } from "node:crypto";
2745
- var NOTES_REASON = "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.";
2746
- var SEARCH_REASON = "Drive searches imported documents and embeddings rather than live messenger messages; its default action and pagination are explicitly provider-specific.";
2747
3472
  var canonical = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])])) : value, "canonical");
2748
3473
  var fingerprint = /* @__PURE__ */ __name((value) => createHash("sha256").update(JSON.stringify(canonical(value ?? null))).digest("hex").slice(0, 16), "fingerprint");
2749
3474
  var reviewedOverrides = /* @__PURE__ */ __name((reference, reviewed) => reviewed.map((override) => {
@@ -2754,248 +3479,6 @@ var reviewedOverrides = /* @__PURE__ */ __name((reference, reviewed) => reviewed
2754
3479
  return { ...override, before: fingerprint(before) === override.before ? before : override.before };
2755
3480
  }), "reviewedOverrides");
2756
3481
  var SHELL_OVERRIDES = {
2757
- notes: [
2758
- {
2759
- command: ["notes"],
2760
- field: "description",
2761
- before: "073d38b6d7256579",
2762
- after: "write notes about an imported document",
2763
- reason: NOTES_REASON
2764
- },
2765
- {
2766
- command: ["notes"],
2767
- field: "effects",
2768
- before: "b98c7b06ed808dfb",
2769
- after: { remote: "none", local: "read" },
2770
- reason: NOTES_REASON
2771
- },
2772
- {
2773
- command: ["notes"],
2774
- field: "children",
2775
- before: "6cfec8425c19582f",
2776
- after: ["add", "list", "show", "edit", "remove"],
2777
- reason: NOTES_REASON
2778
- },
2779
- {
2780
- command: ["notes", "add"],
2781
- field: "description",
2782
- before: "98b319044cba6b7f",
2783
- after: "write a note about a document",
2784
- reason: NOTES_REASON
2785
- },
2786
- {
2787
- command: ["notes", "add"],
2788
- field: "arguments",
2789
- before: "d5010f078464b8d0",
2790
- after: [
2791
- {
2792
- name: "document",
2793
- required: true,
2794
- variadic: false,
2795
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2796
- },
2797
- { name: "text", required: true, variadic: false, description: "the note's text" }
2798
- ],
2799
- reason: NOTES_REASON
2800
- },
2801
- {
2802
- command: ["notes", "add"],
2803
- field: "options",
2804
- before: "213adb539c248d7f",
2805
- after: [{ flags: "--title <title>", description: "a title for the note", takes_value: true, mandatory: false }],
2806
- reason: NOTES_REASON
2807
- },
2808
- {
2809
- command: ["notes", "add"],
2810
- field: "examples",
2811
- before: "74234e98afe7498f",
2812
- after: ['drive personal notes add DOC_ID "Check the numbers" --title Review'],
2813
- reason: NOTES_REASON
2814
- },
2815
- {
2816
- command: ["notes", "list"],
2817
- field: "description",
2818
- before: "6b866a022b5e84ce",
2819
- after: "list a document's notes",
2820
- reason: NOTES_REASON
2821
- },
2822
- {
2823
- command: ["notes", "list"],
2824
- field: "query",
2825
- before: "0b0517429a4f9613",
2826
- after: {
2827
- entity: "note",
2828
- backend: "native",
2829
- fields: [
2830
- { name: "ref", type: "ref", operators: ["term", "phrase"], example: 'ref:"note:42"' },
2831
- { name: "kind", type: "enum", values: ["note", "document"], operators: ["term"], example: "kind:note" },
2832
- { name: "provider", type: "kw", operators: ["term", "phrase", "wildcard"], example: "provider:abc" },
2833
- { name: "account", type: "kw", operators: ["term", "phrase", "wildcard"], example: "account:abc" },
2834
- { name: "url", type: "kw", operators: ["term", "phrase", "wildcard"], example: "url:abc" },
2835
- { name: "id", type: "kw", operators: ["term", "phrase", "wildcard"], example: "id:abc" },
2836
- { name: "source", type: "enum", values: ["file", "internal"], operators: ["term"], example: "source:file" },
2837
- { name: "folder_id", type: "kw", operators: ["term", "phrase", "wildcard"], example: "folder_id:abc" },
2838
- { name: "path", type: "kw", operators: ["term", "phrase", "wildcard"], example: "path:abc" },
2839
- { name: "title", type: "kw", operators: ["term", "phrase", "wildcard"], example: "title:abc" },
2840
- { name: "text", type: "kw", operators: ["term", "phrase"], example: "text:review", native: true },
2841
- { name: "revision", type: "num", operators: ["term", "range"], example: "revision>0" },
2842
- { name: "content_hash", type: "kw", operators: ["term", "phrase", "wildcard"], example: "content_hash:abc" },
2843
- { name: "export_path", type: "kw", operators: ["term", "phrase", "wildcard"], example: "export_path:abc" },
2844
- { name: "created_at", type: "time", operators: ["term", "range"], example: "created_at>=7d" },
2845
- { name: "updated_at", type: "time", operators: ["term", "range"], example: "updated_at>=7d" },
2846
- { name: "deleted_at", type: "time", operators: ["term", "range"], example: "deleted_at>=7d" },
2847
- { name: "tags", type: "kw", operators: ["term", "phrase", "wildcard"], example: "tags:abc" },
2848
- { name: "excerpt", type: "kw", operators: ["term", "phrase", "wildcard"], example: "excerpt:abc" },
2849
- {
2850
- name: "found_by",
2851
- type: "enum",
2852
- values: ["title", "words", "meaning"],
2853
- operators: ["term"],
2854
- example: "found_by:title"
2855
- }
2856
- ]
2857
- },
2858
- reason: NOTES_REASON
2859
- },
2860
- {
2861
- command: ["notes", "list"],
2862
- field: "arguments",
2863
- before: "350998d1fcef909c",
2864
- after: [
2865
- {
2866
- name: "document",
2867
- required: true,
2868
- variadic: false,
2869
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2870
- },
2871
- {
2872
- name: "query",
2873
- required: false,
2874
- variadic: true,
2875
- description: "field:value terms that narrow the list \u2014 the fields are below"
2876
- }
2877
- ],
2878
- reason: NOTES_REASON
2879
- },
2880
- {
2881
- command: ["notes", "list"],
2882
- field: "options",
2883
- before: "4f53cda18c2baa0c",
2884
- after: [
2885
- {
2886
- flags: "--limit <n>",
2887
- description: "how many notes to return",
2888
- takes_value: true,
2889
- mandatory: false,
2890
- default: 50
2891
- },
2892
- { flags: "--page <n>", description: "which page to return", takes_value: true, mandatory: false, default: 1 }
2893
- ],
2894
- reason: NOTES_REASON
2895
- },
2896
- {
2897
- command: ["notes", "list"],
2898
- field: "examples",
2899
- before: "74234e98afe7498f",
2900
- after: ["drive personal notes list DOC_ID", "drive personal notes list DOC_ID text:review --limit 10"],
2901
- reason: NOTES_REASON
2902
- },
2903
- {
2904
- command: ["notes", "show"],
2905
- field: "arguments",
2906
- before: "ae549d47fb4ad5ab",
2907
- after: [
2908
- {
2909
- name: "document",
2910
- required: true,
2911
- variadic: false,
2912
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2913
- },
2914
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" }
2915
- ],
2916
- reason: NOTES_REASON
2917
- },
2918
- {
2919
- command: ["notes", "show"],
2920
- field: "examples",
2921
- before: "74234e98afe7498f",
2922
- after: ["drive personal notes show DOC_ID note:NOTE_ID"],
2923
- reason: NOTES_REASON
2924
- },
2925
- {
2926
- command: ["notes", "edit"],
2927
- field: "description",
2928
- before: "e67289f2731a50ff",
2929
- after: "replace a note's text",
2930
- reason: NOTES_REASON
2931
- },
2932
- {
2933
- command: ["notes", "edit"],
2934
- field: "arguments",
2935
- before: "c7d2686d3041bb14",
2936
- after: [
2937
- {
2938
- name: "document",
2939
- required: true,
2940
- variadic: false,
2941
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2942
- },
2943
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" },
2944
- { name: "text", required: true, variadic: false, description: "the note's new text" }
2945
- ],
2946
- reason: NOTES_REASON
2947
- },
2948
- {
2949
- command: ["notes", "edit"],
2950
- field: "options",
2951
- before: "4f53cda18c2baa0c",
2952
- after: [
2953
- {
2954
- flags: "--revision <n>",
2955
- description: "revision from notes show; a newer note is not overwritten",
2956
- takes_value: true,
2957
- mandatory: true
2958
- }
2959
- ],
2960
- reason: NOTES_REASON
2961
- },
2962
- {
2963
- command: ["notes", "edit"],
2964
- field: "examples",
2965
- before: "74234e98afe7498f",
2966
- after: ['drive personal notes edit DOC_ID note:NOTE_ID "Numbers checked" --revision 2'],
2967
- reason: NOTES_REASON
2968
- },
2969
- {
2970
- command: ["notes", "remove"],
2971
- field: "description",
2972
- before: "aa644f1603858b41",
2973
- after: "delete one note",
2974
- reason: NOTES_REASON
2975
- },
2976
- {
2977
- command: ["notes", "remove"],
2978
- field: "arguments",
2979
- before: "ae549d47fb4ad5ab",
2980
- after: [
2981
- {
2982
- name: "document",
2983
- required: true,
2984
- variadic: false,
2985
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2986
- },
2987
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" }
2988
- ],
2989
- reason: NOTES_REASON
2990
- },
2991
- {
2992
- command: ["notes", "remove"],
2993
- field: "examples",
2994
- before: "74234e98afe7498f",
2995
- after: ["drive personal notes remove DOC_ID note:NOTE_ID"],
2996
- reason: NOTES_REASON
2997
- }
2998
- ],
2999
3482
  commands: [
3000
3483
  {
3001
3484
  command: ["commands"],
@@ -3032,79 +3515,6 @@ var SHELL_OVERRIDES = {
3032
3515
  ],
3033
3516
  reason: "Drive binds discovery to its profile-aware usage renderer while retaining the shared command document and evidence endpoint."
3034
3517
  }
3035
- ],
3036
- search: [
3037
- {
3038
- command: ["search"],
3039
- field: "summary",
3040
- before: "d8f6dac5b4fe912b",
3041
- after: null,
3042
- reason: SEARCH_REASON
3043
- },
3044
- {
3045
- command: ["search"],
3046
- field: "description",
3047
- before: "600ae3fd56e9ef36",
3048
- after: "search imported documents by words, and by meaning when indexed",
3049
- reason: SEARCH_REASON
3050
- },
3051
- {
3052
- command: ["search"],
3053
- field: "arguments",
3054
- before: "4f53cda18c2baa0c",
3055
- after: [
3056
- {
3057
- name: "query",
3058
- required: true,
3059
- variadic: false,
3060
- description: "words to look for, and fields such as tag: and date: that every hit must match"
3061
- }
3062
- ],
3063
- reason: SEARCH_REASON
3064
- },
3065
- {
3066
- command: ["search"],
3067
- field: "options",
3068
- before: "4f53cda18c2baa0c",
3069
- after: [
3070
- {
3071
- flags: "--limit <n>",
3072
- description: "how many results to return",
3073
- takes_value: true,
3074
- mandatory: false,
3075
- default: 20
3076
- },
3077
- { flags: "--page <n>", description: "which page to return", takes_value: true, mandatory: false, default: 1 },
3078
- {
3079
- flags: "--exact",
3080
- description: "match the words exactly: no word forms, no meaning",
3081
- takes_value: false,
3082
- mandatory: false
3083
- }
3084
- ],
3085
- reason: SEARCH_REASON
3086
- },
3087
- {
3088
- command: ["search"],
3089
- field: "children",
3090
- before: "595cc576273270f2",
3091
- after: [],
3092
- reason: SEARCH_REASON
3093
- },
3094
- {
3095
- command: ["search"],
3096
- field: "effects",
3097
- before: "74234e98afe7498f",
3098
- after: { remote: "none", local: "read" },
3099
- reason: SEARCH_REASON
3100
- },
3101
- {
3102
- command: ["search"],
3103
- field: "examples",
3104
- before: "74234e98afe7498f",
3105
- after: ["drive personal search budget", 'drive personal search "quarterly plan" --exact --limit 5'],
3106
- reason: SEARCH_REASON
3107
- }
3108
3518
  ]
3109
3519
  };
3110
3520
 
@@ -3140,46 +3550,6 @@ var installCommandsCommand = /* @__PURE__ */ __name((...args) => {
3140
3550
  }, reviewedOverrides(reference, SHELL_OVERRIDES.commands));
3141
3551
  }, "installCommandsCommand");
3142
3552
 
3143
- // dist/commands/documents.js
3144
- import { writeFileSync } from "node:fs";
3145
-
3146
- // dist/age.js
3147
- var DAY = 24 * 60 * 60 * 1e3;
3148
- var SYNC = defineSteps([
3149
- { id: "sync.run", command: "sync", args: [], why: "copy the changes Google has made into the local store" }
3150
- ])[0];
3151
- var ageOf = /* @__PURE__ */ __name((state, now = Date.now()) => {
3152
- const at = state.lastSync ? Date.parse(state.lastSync) : Number.NaN;
3153
- return Number.isNaN(at) ? { synced_at: null, age_days: null } : { synced_at: state.lastSync ?? null, age_days: Math.max(0, Math.floor((now - at) / DAY)) };
3154
- }, "ageOf");
3155
- var staleCopy = /* @__PURE__ */ __name((state, now = Date.now()) => {
3156
- const { synced_at, age_days } = ageOf(state, now);
3157
- const old = synced_at === null || now - Date.parse(synced_at) > DAY;
3158
- if (!old)
3159
- return {};
3160
- const why = age_days === null ? "the local copy has no sync time; Google may have changed the document since it was copied" : `the local copy was synced ${age_days} day${age_days === 1 ? "" : "s"} ago; Google may have changed the document since`;
3161
- return {
3162
- missing: [{ field: "synced_at", why, step: SYNC.id }],
3163
- next: [stepOf(SYNC)],
3164
- meta: { complete: false }
3165
- };
3166
- }, "staleCopy");
3167
- var freshness = /* @__PURE__ */ __name((remote, local2) => ({
3168
- changed: local2 === void 0 || Date.parse(remote) !== Date.parse(local2),
3169
- remote_modified_at: remote,
3170
- local_modified_at: local2 ?? null
3171
- }), "freshness");
3172
- var changedCopy = /* @__PURE__ */ __name(({ changed, local_modified_at }) => {
3173
- if (!changed)
3174
- return {};
3175
- const why = local_modified_at === null ? "the local copy has no modified time, so it cannot be compared with Google" : `Google changed the document after the local copy was made (${local_modified_at})`;
3176
- return {
3177
- missing: [{ field: "modified_at", why, step: SYNC.id }],
3178
- next: [stepOf(SYNC)],
3179
- meta: { complete: false }
3180
- };
3181
- }, "changedCopy");
3182
-
3183
3553
  // dist/documents-add.js
3184
3554
  var PASSES_ON = /* @__PURE__ */ new Set(["not_found", "permission_error", "authentication_error"]);
3185
3555
  var HOW = "drive <profile> documents add <url>, or --profiles <a,b|all>";
@@ -3311,66 +3681,36 @@ var addProfilesOf = /* @__PURE__ */ __name((env, command, word) => profilesToAdd
3311
3681
  option: command.opts().profiles,
3312
3682
  word,
3313
3683
  chosen: env.DRIVE_PROFILE || void 0,
3314
- lock: env.DRIVE_PROFILE_LOCK || void 0
3315
- }), "addProfilesOf");
3316
- var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
3317
- const { env, selected, output, withIndex, source, profileWord } = context;
3318
- const imported = importedDocument(context);
3319
- const documents = annotate(program.command("documents"), { effects: LOCAL_READ }).description("read imported documents and Google Docs");
3320
- const documentArgument = "document id, Google Docs URL, or a search hit's document: ref";
3321
- annotate(withQuery(examples(annotate(documents.command("list"), { effects: LOCAL_READ }).description("list imported documents with their Google URLs"), [
3322
- "drive personal documents list",
3323
- "drive personal documents list tag:budget",
3324
- "drive personal documents list person:PERSON_UID --limit 10"
3325
- ]), IMPORTED_DOCUMENT_QUERY), { output: { entity: "drive_document" }, partial: true }).option("--limit <n>", "how many documents to return", positive, 50).option("--page <n>", "which page to return", positive, 1).action(async (words, { limit, page }) => {
3326
- const profile = activeProfile(env, selected());
3327
- const query = typedQuery(words);
3328
- const ast = listQuery(query, IMPORTED_DOCUMENT_QUERY, "documents list");
3329
- const found = await withIndex(async (index) => {
3330
- if (!index.knowledge)
3331
- throw new CliError("configuration_error", "index has no shared knowledge adapter");
3332
- return index.knowledge.documents(profile.principal, ast, { limit, offset: (page - 1) * limit });
3333
- });
3334
- const state = readState(env, selected(), profile.principal);
3335
- const age = ageOf(state);
3336
- output(listOf("documents list", {
3337
- ...staleCopy(state),
3338
- items: found.items.map((note) => {
3339
- const id = (note.path ?? "").replace(/\.md$/, "");
3340
- const doc = state.documents[id];
3341
- return doc ? { ...metadataJson(doc.metadata), reference: doc.reference, tabs: doc.tabs, ...age } : { id, name: note.title, reference: note.ref, tabs: 0, ...age };
3342
- }),
3343
- limit,
3344
- has_more: found.hasMore,
3345
- page,
3346
- args: { query: query || void 0 }
3347
- }));
3348
- });
3349
- examples(annotate(documents.command("show"), { effects: LOCAL_READ, partial: true }).argument("<document>", documentArgument).description("show an imported document's text, tabs and metadata"), ["drive personal documents show DOC_ID", "drive personal documents show document:42 --offline"]).action((input) => {
3350
- const { snapshot } = imported(input);
3351
- const state = readState(env, selected(), activeProfile(env, selected()).principal);
3352
- output(itemOf({
3353
- metadata: metadataJson(snapshot.metadata),
3354
- ...ageOf(state),
3355
- text: snapshot.text,
3356
- tabs: snapshot.tabs,
3357
- ...snapshot.notRead ? { not_read: snapshot.notRead } : {}
3358
- }, staleCopy(state)));
3359
- });
3360
- examples(annotate(documents.command("export"), { effects: LOCAL_WRITE, partial: true }).argument("<document>", documentArgument).description("write an imported document to a new Markdown file"), ["drive personal documents export DOC_ID --output notes.md"]).requiredOption("--output <file>", "path of the Markdown file to write; an existing file is refused").action((input, args) => {
3361
- const { id, snapshot } = imported(input);
3362
- try {
3363
- writeFileSync(args.output, snapshot.markdown, { flag: "wx", mode: 384 });
3364
- } catch (error) {
3365
- if (error.code === "EEXIST")
3366
- throw new CliError("validation_error", "the output file already exists; choose another --output", {
3367
- reason: "export.exists",
3368
- param: "--output"
3369
- });
3370
- throw error;
3371
- }
3372
- const state = readState(env, selected(), activeProfile(env, selected()).principal);
3373
- output(itemOf({ id, path: args.output, format: "markdown", ...ageOf(state) }, staleCopy(state)));
3684
+ lock: env.DRIVE_PROFILE_LOCK || void 0
3685
+ }), "addProfilesOf");
3686
+ var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
3687
+ const { env, selected, output, withIndex, source, profileWord } = context;
3688
+ const imported = importedDocument(context);
3689
+ const documents = addLocalDocumentCommands(program, {
3690
+ words: DRIVE_WORDS,
3691
+ output,
3692
+ list: /* @__PURE__ */ __name(async (query, page) => {
3693
+ const profile = activeProfile(env, selected());
3694
+ const found = await withIndex(async (index) => {
3695
+ if (!index.knowledge)
3696
+ throw new CliError("configuration_error", "index has no shared knowledge adapter");
3697
+ return index.knowledge.documents(profile.principal, query, page);
3698
+ });
3699
+ const state = readState(env, selected(), profile.principal);
3700
+ return {
3701
+ items: found.items.map((note2) => {
3702
+ const id = (note2.path ?? "").replace(/\.md$/, "");
3703
+ const doc = state.documents[id];
3704
+ return doc ? { ...metadataJson(doc.metadata), reference: doc.reference, tabs: doc.tabs } : { id, name: note2.title, reference: note2.ref, tabs: 0 };
3705
+ }),
3706
+ hasMore: found.hasMore
3707
+ };
3708
+ }, "list"),
3709
+ document: /* @__PURE__ */ __name((input) => {
3710
+ const { id, snapshot } = imported(input);
3711
+ return { id, metadata: metadataJson(snapshot.metadata), snapshot };
3712
+ }, "document"),
3713
+ lastSync: /* @__PURE__ */ __name(() => readState(env, selected(), activeProfile(env, selected()).principal).lastSync, "lastSync")
3374
3714
  });
3375
3715
  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"), [
3376
3716
  "drive documents add https://docs.google.com/document/d/DOC_ID/edit --profiles work,personal",
@@ -3487,348 +3827,99 @@ var roots = /* @__PURE__ */ __name(async (call, added) => {
3487
3827
  if (!myDrive.id)
3488
3828
  throw new CliError("invalid_response", "Google did not return the My Drive folder");
3489
3829
  const { rows: drives } = await everyPage(call, "drive.drives.list", { pageSize: 100, fields: "nextPageToken,drives(id,name)" }, "drives");
3490
- const shared = drives.flatMap((drive) => drive.id ? [{ id: drive.id, name: drive.name ?? "" }] : []);
3491
- const counts = await childCounts(call, [myDrive.id, ...shared.map((drive) => drive.id)]);
3492
- const top = /* @__PURE__ */ __name((id, name, kind) => ({
3493
- id,
3494
- name,
3495
- kind,
3496
- parent: null,
3497
- location: kind,
3498
- drive_id: kind === "shared_drive" ? id : null,
3499
- child_folders: kind === "shared_with_me" ? null : counts?.get(id) ?? null,
3500
- added: added(id) || kind === "my_drive" && added("root")
3501
- }), "top");
3502
- return listed([
3503
- top(myDrive.id, "My Drive", "my_drive"),
3504
- top(SHARED_WITH_ME, "Shared with me", "shared_with_me"),
3505
- ...shared.map((drive) => top(drive.id, drive.name, "shared_drive")).sort(byName)
3506
- ], false);
3507
- }, "roots");
3508
- var browseFolders = /* @__PURE__ */ __name(async (call, parent, selected) => {
3509
- const added = /* @__PURE__ */ __name((id) => selected.includes(id), "added");
3510
- if (parent === void 0)
3511
- return roots(call, added);
3512
- const { rows, incomplete } = await everyPage(call, "drive.files.list", {
3513
- q: parent === SHARED_WITH_ME ? `sharedWithMe = true and ${NOT_TRASHED_FOLDER}` : `'${parent}' in parents and ${NOT_TRASHED_FOLDER}`,
3514
- fields: "nextPageToken,incompleteSearch,files(id,name,driveId,ownedByMe)",
3515
- pageSize: 1e3,
3516
- ...ACROSS_DRIVES
3517
- }, "files");
3518
- const folders = rows.filter((row) => Boolean(row.id));
3519
- const counts = await childCounts(call, folders.map((folder) => folder.id));
3520
- const items = folders.map((folder) => ({
3521
- id: folder.id,
3522
- name: folder.name ?? "",
3523
- kind: "folder",
3524
- parent,
3525
- location: folder.driveId ? "shared_drive" : folder.ownedByMe === false ? "shared_with_me" : "my_drive",
3526
- drive_id: folder.driveId ?? null,
3527
- child_folders: counts?.get(folder.id) ?? null,
3528
- added: added(folder.id)
3529
- }));
3530
- return listed(items.sort(byName), incomplete);
3531
- }, "browseFolders");
3532
-
3533
- // dist/commands/folders.js
3534
- var installFolderCommands = /* @__PURE__ */ __name((program, context, call) => {
3535
- const { env, selected, output, source } = context;
3536
- const folders = annotate(program.command("folders"), { effects: LOCAL_READ }).description("choose the Google Drive folders that sync imports");
3537
- const folderArgument = "folder id or Google Drive URL";
3538
- examples(annotate(folders.command("add"), { effects: FETCH }).argument("<folder>", folderArgument).description("import a folder and everything under it on the next sync"), ["drive personal folders add FOLDER_ID"]).action(async (input) => {
3539
- const id = fileId(input);
3540
- const config = readConfig(env);
3541
- const name = selected();
3542
- const profile = activeProfile(env, name);
3543
- const metadata = await (await source()).metadata(id);
3544
- if (metadata.mime !== FOLDER || metadata.trashed)
3545
- throw new CliError("validation_error", "source is not an accessible Google folder");
3546
- if (!profile.roots.includes(metadata.id))
3547
- profile.roots.push(metadata.id);
3548
- config.profiles[name] = profile;
3549
- writeConfig(env, config);
3550
- output(itemOf({ id: metadata.id, name: metadata.name, added: true }));
3551
- });
3552
- bindQuery(examples(annotate(folders.command("list"), { effects: LOCAL_READ }).description("list the folder ids sync imports"), ["drive personal folders list"]), FOLDERS_QUERY, folderRow).action((words) => {
3553
- const filter = termsOf(words, FOLDERS_QUERY, "folders list");
3554
- output(allOf(selectedFolders(env, selected(), filter)));
3555
- });
3556
- examples(answerEntity(annotate(folders.command("browse"), { effects: GOOGLE_READ }).description("list Google Drive folders one level at a time, to choose one for folders add"), "drive_remote_folder", browseRow), [
3557
- "drive personal folders browse",
3558
- "drive personal folders browse --parent FOLDER_ID --json",
3559
- `drive personal folders browse --parent ${SHARED_WITH_ME}`
3560
- ]).option("--parent <id>", `folder id or URL to list inside, or ${SHARED_WITH_ME}; the top level without it`).addHelpText("after", BROWSE_HELP).action(async (args) => {
3561
- const parent = args.parent === void 0 || args.parent === SHARED_WITH_ME ? args.parent : fileId(args.parent);
3562
- const roots2 = activeProfile(env, selected()).roots;
3563
- output(await browseFolders(call, parent, roots2));
3564
- });
3565
- examples(annotate(folders.command("remove"), { effects: LOCAL_WRITE }).argument("<folder>", folderArgument).description("stop importing a folder; the next sync drops its documents"), ["drive personal folders remove FOLDER_ID"]).action((input) => {
3566
- const id = fileId(input);
3567
- const config = readConfig(env);
3568
- const name = selected();
3569
- const profile = activeProfile(env, name);
3570
- profile.roots = profile.roots.filter((root) => root !== id);
3571
- config.profiles[name] = profile;
3572
- writeConfig(env, config);
3573
- output(itemOf({ id, removed: true }));
3574
- });
3575
- }, "installFolderCommands");
3576
-
3577
- // dist/knowledge-query.js
3578
- var FACT_QUERY = {
3579
- entity: "fact",
3580
- backend: "native",
3581
- fields: [
3582
- termField("kind", "enum", "kind:decision", { values: FACT_TYPES }),
3583
- termField("status", "enum", "status:proposed", { values: FACT_STATUSES })
3584
- ]
3585
- };
3586
- var MEMORY_QUERY = {
3587
- entity: "memory",
3588
- backend: "native",
3589
- fields: [
3590
- termField("kind", "enum", "kind:preference", { values: MEMORY_KINDS }),
3591
- termField("status", "enum", "status:proposed", { values: MEMORY_STATUSES }),
3592
- termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
3593
- ]
3594
- };
3595
- var MEMORY_SEARCH_QUERY = {
3596
- entity: "memory",
3597
- backend: "native",
3598
- fields: [
3599
- nativeField({
3600
- name: "text",
3601
- type: "txt",
3602
- operators: ["term", "phrase"],
3603
- example: "text:reviews",
3604
- relation: "words of the memory; a bare word means the same"
3605
- }),
3606
- termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
3607
- ]
3608
- };
3609
- var factItem = /* @__PURE__ */ __name(({ type, statement, source, confirmedBy, ...fact }) => ({
3610
- ref: fact.ref,
3611
- id: fact.id,
3612
- kind: type,
3613
- text: statement,
3614
- status: fact.status,
3615
- project: fact.project,
3616
- subject: fact.subject,
3617
- occurred_at: fact.occurredAt,
3618
- supersedes: fact.supersedes,
3619
- author: fact.author,
3620
- model: fact.model,
3621
- confirmed_by: confirmedBy,
3622
- scope: fact.scope,
3623
- origin: source,
3624
- evidence: fact.evidence,
3625
- created_at: fact.createdAt,
3626
- updated_at: fact.updatedAt
3627
- }), "factItem");
3628
- var memoryItem = /* @__PURE__ */ __name(({ body, ...memory }) => ({
3629
- ref: memory.ref,
3630
- id: memory.id,
3631
- kind: memory.kind,
3632
- text: body,
3633
- subject: memory.subject,
3634
- author: memory.author,
3635
- model: memory.model,
3636
- confidence: memory.confidence,
3637
- status: memory.status,
3638
- scope: memory.scope,
3639
- supersedes: memory.supersedes,
3640
- evidence: memory.evidence,
3641
- last_verified_at: memory.lastVerifiedAt,
3642
- created_at: memory.createdAt,
3643
- updated_at: memory.updatedAt
3644
- }), "memoryItem");
3645
- var memorySearch = /* @__PURE__ */ __name((words) => {
3646
- const command = "memories search";
3647
- const context = { command, guide: LIST_QUERY_GUIDE };
3648
- const ast = validateQuery(parseLucene(typedQuery(words), { defaultField: "text", ...context }), MEMORY_SEARCH_QUERY, context);
3649
- const text = [];
3650
- let scope;
3651
- const add = /* @__PURE__ */ __name((node) => {
3652
- if (node.kind === "boolean") {
3653
- for (const clause of node.clauses) {
3654
- if (clause.occur !== "must")
3655
- queryError("query.unsupported-placement", clause.node.span, "this search joins its terms by AND", context);
3656
- add(clause.node);
3657
- }
3658
- return;
3659
- }
3660
- if (node.field === "text")
3661
- text.push(node.value);
3662
- else if (scope !== void 0)
3663
- queryError("query.unsupported-placement", node.span, "scope only once here", context);
3664
- else
3665
- scope = node.value.toLowerCase();
3666
- }, "add");
3667
- add(ast.root);
3668
- if (text.length === 0)
3669
- queryError("query.missing-value", ast.root.span, "say which words to look for beside scope:", context);
3670
- return { text: text.join(" "), ...scope === void 0 ? {} : { scope } };
3671
- }, "memorySearch");
3672
-
3673
- // dist/commands/knowledge.js
3674
- var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
3675
- const { run: run3, output, positive: positive2, author, decider } = helpers;
3676
- const documentArgument = "Google file or folder id or URL in the local catalog, or a document:<n> ref";
3677
- const scopes = ["personal", "work"];
3678
- const documents = program.commands.find((command) => command.name() === "documents");
3679
- examples(annotate(documents.command("context"), { effects: LOCAL_READ }).argument("<document>", documentArgument).description("show a document with its tags, relationships, notes, memories and editors"), ["drive personal documents context DOC_ID"]).action(async (doc) => output(itemOf(await run3(doc, (k, p, ref) => k.context(p, ref)))));
3680
- const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
3681
- for (const action of ["list", "add", "remove"]) {
3682
- const command = examples(annotate(tags.command(action), { effects: action === "list" ? LOCAL_READ : LOCAL_WRITE }).description(action === "list" ? "list a document's tags" : action === "add" ? "tag a document" : "untag a document").argument("<document>", documentArgument), [`drive personal tags ${action} DOC_ID${action === "list" ? "" : " budget q3"}`]);
3683
- if (action === "list") {
3684
- bindQuery(command, TAGS_QUERY, tagRow).action(async (doc, words) => {
3685
- const filter = termsOf(words, TAGS_QUERY, "tags list");
3686
- output(allOf((await run3(doc, (k, p, ref) => k.tags(p, ref, "list", [], filter))).map((tag) => ({ tag }))));
3687
- });
3688
- } else
3689
- command.argument("<tags...>", "one or more tags").action(async (doc, values2) => output(itemOf({ tags: await run3(doc, (k, p, ref) => k.tags(p, ref, action, values2)) })));
3690
- }
3691
- const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
3692
- bindQuery(examples(annotate(relationships.command("list"), { effects: LOCAL_READ }).description("list a document's relationships"), ["drive personal relationships list DOC_ID"]).argument("<document>", documentArgument), LINKS_QUERY, linkRow).action(async (doc, words) => {
3693
- const { confirmed, ...filter } = termsOf(words, LINKS_QUERY, "relationships list");
3694
- output(allOf(await run3(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...confirmed === void 0 ? {} : { confirmed: confirmed === "true" } }))));
3695
- });
3696
- examples(annotate(relationships.command("add"), { effects: LOCAL_WRITE }).description("connect a document to another reference"), [
3697
- "drive personal relationships add DOC_ID project:PROJECT_ID --kind about",
3698
- "drive personal relationships add DOC_ID person:PERSON_UID --kind assigned-to --role reviewer"
3699
- ]).argument("<document>", documentArgument).argument("<reference>", "what it connects to, such as person:<uid>, project:<id> or note:<id>").addOption(new Option("--kind <kind>", "how the two relate").choices(["links-to", "about", "evidence", "created-from", "related-to", "assigned-to"]).default("related-to")).option("--role <role>", "the part the reference plays, in a word or two").option("--reason <text>", "why the two are connected").action(async (doc, to, { reason, ...args }) => output(itemOf(await run3(doc, (k, p, ref) => k.addLink(p, ref, { to, ...args, by: decider(), ...reason ? { evidence: reason } : {} })))));
3700
- examples(annotate(relationships.command("remove"), { effects: LOCAL_WRITE }).description("remove one of a document's relationships"), ["drive personal relationships remove DOC_ID LINK_ID"]).argument("<document>", documentArgument).argument("<relationship-id>", "id, as relationships list prints it").action(async (doc, id) => output(itemOf(await run3(doc, (k, p, ref) => k.removeLink(p, ref, id, decider())))));
3701
- const notes = annotate(program.command("notes"), { effects: LOCAL_READ }).description("write notes about an imported document");
3702
- const noteArgument = "note:<id> reference, as notes list prints it";
3703
- examples(annotate(notes.command("add"), {
3704
- effects: LOCAL_WRITE,
3705
- output: { entity: "note" },
3706
- literal_after_dashes: true
3707
- }).description("write a note about a document"), [`drive personal notes add DOC_ID "Check the numbers" --title Review`]).argument("<document>", documentArgument).argument("<text>", "the note's text").option("--title <title>", "a title for the note").action(async (doc, text, args) => output(itemOf(await run3(doc, (k, p, ref) => k.addNote(p, ref, text, args.title)))));
3708
- withQuery(examples(annotate(notes.command("list"), { effects: LOCAL_READ }).description("list a document's notes"), [
3709
- "drive personal notes list DOC_ID",
3710
- "drive personal notes list DOC_ID text:review --limit 10"
3711
- ]).argument("<document>", documentArgument), NOTES_QUERY).option("--limit <n>", "how many notes to return", positive2, 50).option("--page <n>", "which page to return", positive2, 1).action(async (doc, words, { page, limit }) => {
3712
- const query = termsOf(words, NOTES_QUERY, "notes list").text;
3713
- const found = await run3(doc, (k, p, ref) => k.notes(p, ref, { ...query ? { search: query } : {}, limit, offset: (page - 1) * limit }));
3714
- output(listOf("notes list", {
3715
- items: found.items,
3716
- limit,
3717
- has_more: found.hasMore,
3718
- page,
3719
- args: { document: doc, query: words.join(" ") }
3720
- }));
3721
- });
3722
- examples(annotate(notes.command("show"), { effects: LOCAL_READ, output: { entity: "note" } }).description("show one note"), ["drive personal notes show DOC_ID note:NOTE_ID"]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.note(p, ref, noteRef)))));
3723
- examples(annotate(notes.command("edit"), {
3724
- effects: LOCAL_WRITE,
3725
- output: { entity: "note" },
3726
- literal_after_dashes: true
3727
- }).description("replace a note's text"), [`drive personal notes edit DOC_ID note:NOTE_ID "Numbers checked" --revision 2`]).argument("<document>", documentArgument).argument("<note>", noteArgument).argument("<text>", "the note's new text").requiredOption("--revision <n>", "revision from notes show; a newer note is not overwritten", positive2).action(async (doc, noteRef, text, args) => output(itemOf(await run3(doc, (k, p, ref) => k.editNote(p, ref, noteRef, text, args.revision)))));
3728
- examples(annotate(notes.command("remove"), { effects: LOCAL_WRITE }).description("delete one note"), [
3729
- "drive personal notes remove DOC_ID note:NOTE_ID"
3730
- ]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.removeNote(p, ref, noteRef)))));
3731
- const memories = annotate(program.command("memories"), { effects: LOCAL_READ }).description("keep what was learned from a document, with evidence; an agent's stay proposed");
3732
- const memoryArgument = "memory:<id> reference, as memories list prints it";
3733
- const scope = /* @__PURE__ */ __name((description) => new Option("--scope <scope>", description).choices(scopes), "scope");
3734
- examples(annotate(memories.command("add"), { effects: LOCAL_WRITE }).description("record a memory about a document"), [`drive personal memories add DOC_ID "The team prefers async reviews" --scope work --kind preference`]).argument("<document>", documentArgument).argument("<text>", "what to remember").addOption(scope("whose memory it is: personal or work").makeOptionMandatory()).addOption(new Option("--kind <kind>", "what kind of memory it is").choices(MEMORY_KINDS).default("summary")).option("--supersedes <ref>", "a memory:<id> about the same document that this one replaces").action(async (doc, body, args) => output(itemOf(memoryItem(await run3(doc, (k, p, ref) => k.addMemory(p, ref, { body, ...args, status: "proposed", author: author() }))))));
3735
- withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
3736
- "drive personal memories list DOC_ID scope:work",
3737
- "drive personal memories list DOC_ID kind:preference status:confirmed"
3738
- ]).argument("<document>", documentArgument), MEMORY_QUERY).option("--limit <n>", "how many memories to return", positive2, 50).action(async (doc, words, { limit }) => {
3739
- const terms = queryTerms(words, MEMORY_QUERY, "memories list");
3740
- const filters = {
3741
- ...terms.has("kind") ? { kind: terms.get("kind") } : {},
3742
- ...terms.has("status") ? { status: terms.get("status") } : {},
3743
- ...terms.has("scope") ? { scope: terms.get("scope") } : {}
3744
- };
3745
- output(allOf((await run3(doc, (k, p, ref) => k.memories(p, ref, { ...filters, limit }))).items.map(memoryItem)));
3746
- });
3747
- const memoryActions = {
3748
- show: "show one memory",
3749
- confirm: "confirm a proposed memory as true",
3750
- stale: "mark a memory as out of date"
3751
- };
3752
- for (const [action, description] of Object.entries(memoryActions))
3753
- examples(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`drive personal memories ${action} DOC_ID memory:MEMORY_ID`]).argument("<document>", documentArgument).argument("<memory>", memoryArgument).action(async (doc, memoryRef) => output(itemOf(memoryItem(await run3(doc, (k, p, ref) => action === "show" ? k.memory(p, ref, memoryRef) : k.memory(p, ref, memoryRef, action, decider()))))));
3754
- const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [
3755
- "drive personal memories search DOC_ID reviews scope:work",
3756
- `drive personal memories search DOC_ID "async reviews"`
3757
- ]).argument("<document>", documentArgument).argument("<query...>", "words to look for, and scope:personal or scope:work \u2014 the fields are below").allowUnknownOption().addHelpText("after", queryHelp(MEMORY_SEARCH_QUERY)).action(async (doc, words) => {
3758
- const { text, scope: scope2 } = memorySearch(words);
3759
- const found = await run3(doc, (k, p, ref) => k.searchMemories(p, ref, text, scope2));
3760
- output({
3761
- ...allOf(found.items.map(memoryItem)),
3762
- ...found.hasMore ? { meta: { truncated: true } } : {}
3763
- });
3764
- });
3765
- annotate(search, { query: defineQuery(MEMORY_SEARCH_QUERY), output: { entity: "memory" } });
3766
- examples(annotate(memories.command("extract"), { effects: REMOTE_WRITE }).argument("<document>", documentArgument).description("send a document's text to the model and show the memories it proposes"), [
3767
- "drive personal memories extract DOC_ID --scope work",
3768
- "drive personal memories extract DOC_ID --scope work --yes"
3769
- ]).addOption(scope("whose memories they become: personal or work").makeOptionMandatory()).option("--tab <id>", "send only this tab of the document").option("--yes", "save the proposals, each with its quote and the document's version").action(async function(doc) {
3770
- const args = this.optsWithGlobals();
3771
- await run3(doc, async () => void 0);
3772
- const result = await extractDocumentMemories({
3773
- read: /* @__PURE__ */ __name(() => helpers.document(doc), "read"),
3774
- complete: helpers.complete(),
3775
- scope: args.scope,
3776
- author: "drive-memory",
3777
- tab: args.tab,
3778
- save: args.yes,
3779
- withWrite: /* @__PURE__ */ __name((write) => run3(doc, write), "withWrite")
3780
- });
3781
- output(itemOf({ ...result, saved: result.saved.map((item) => "type" in item ? factItem(item) : memoryItem(item)) }));
3782
- });
3783
- const facts = annotate(program.command("facts"), { effects: LOCAL_READ }).description("what happened, as a document shows it; an agent's stay proposed until confirmed");
3784
- const factArgument = "fact:<id> reference, as facts list prints it";
3785
- examples(annotate(facts.command("add"), { effects: LOCAL_WRITE }).description("record a fact a document shows"), [
3786
- `drive personal facts add DOC_ID "Budget approved" --type decision --scope work`
3787
- ]).argument("<document>", documentArgument).argument("<statement>", "the fact, in one sentence").addOption(new Option("--type <type>", "what kind of fact it is").choices(FACT_TYPES).default("fact")).addOption(scope("whose fact it is: personal or work")).option("--supersedes <ref>", "a decision only: the decision this one replaces").option("--occurred-time <time>", "when it happened, as the evidence shows, ISO 8601; a time without a zone is read in this computer's zone, a date alone as its midnight").action(async (doc, statement, { occurredTime, ...args }) => output(itemOf(factItem(await run3(doc, (k, p, ref) => k.addFact(p, ref, {
3788
- statement,
3789
- ...args,
3790
- by: author(),
3791
- ...occurredTime === void 0 ? {} : { occurredAt: occurredTime }
3792
- }))))));
3793
- withQuery(examples(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
3794
- "drive personal facts list DOC_ID status:proposed",
3795
- "drive personal facts list DOC_ID kind:decision"
3796
- ]).argument("<document>", documentArgument), FACT_QUERY).option("--limit <n>", "how many facts to return", positive2, 50).action(async (doc, words, { limit }) => {
3797
- const terms = queryTerms(words, FACT_QUERY, "facts list");
3798
- const filters = {
3799
- ...terms.has("kind") ? { type: terms.get("kind") } : {},
3800
- ...terms.has("status") ? { status: terms.get("status") } : {}
3801
- };
3802
- output(allOf((await run3(doc, (k, p, ref) => k.facts(p, ref, { ...filters, limit }))).items.map(factItem)));
3803
- });
3804
- const factActions = {
3805
- show: "show one fact",
3806
- confirm: "confirm a proposed fact; a decision it supersedes stops holding",
3807
- reverse: "an accepted decision no longer holds, and nothing replaced it"
3808
- };
3809
- for (const [action, description] of Object.entries(factActions))
3810
- examples(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`drive personal facts ${action} DOC_ID fact:FACT_ID`]).argument("<document>", documentArgument).argument("<fact>", factArgument).action(async (doc, factRef) => output(itemOf(factItem(await run3(doc, (k, p, ref) => action === "show" ? k.fact(p, ref, factRef) : k.fact(p, ref, factRef, action, decider()))))));
3811
- const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description("the Google accounts seen on a document, and the people they belong to");
3812
- bindQuery(examples(annotate(identities.command("list"), { effects: LOCAL_READ }).description("list the owners and last editor Google shows for a document"), ["drive personal identities list DOC_ID"]).argument("<document>", documentArgument), IDENTITIES_QUERY, identityRow).action(async (doc, words) => {
3813
- const filter = termsOf(words, IDENTITIES_QUERY, "identities list");
3814
- output(itemOf(await run3(doc, (k, p, ref) => k.people(p, ref, filter))));
3830
+ const shared = drives.flatMap((drive) => drive.id ? [{ id: drive.id, name: drive.name ?? "" }] : []);
3831
+ const counts = await childCounts(call, [myDrive.id, ...shared.map((drive) => drive.id)]);
3832
+ const top = /* @__PURE__ */ __name((id, name, kind) => ({
3833
+ id,
3834
+ name,
3835
+ kind,
3836
+ parent: null,
3837
+ location: kind,
3838
+ drive_id: kind === "shared_drive" ? id : null,
3839
+ child_folders: kind === "shared_with_me" ? null : counts?.get(id) ?? null,
3840
+ added: added(id) || kind === "my_drive" && added("root")
3841
+ }), "top");
3842
+ return listed([
3843
+ top(myDrive.id, "My Drive", "my_drive"),
3844
+ top(SHARED_WITH_ME, "Shared with me", "shared_with_me"),
3845
+ ...shared.map((drive) => top(drive.id, drive.name, "shared_drive")).sort(byName)
3846
+ ], false);
3847
+ }, "roots");
3848
+ var browseFolders = /* @__PURE__ */ __name(async (call, parent, selected) => {
3849
+ const added = /* @__PURE__ */ __name((id) => selected.includes(id), "added");
3850
+ if (parent === void 0)
3851
+ return roots(call, added);
3852
+ const { rows, incomplete } = await everyPage(call, "drive.files.list", {
3853
+ q: parent === SHARED_WITH_ME ? `sharedWithMe = true and ${NOT_TRASHED_FOLDER}` : `'${parent}' in parents and ${NOT_TRASHED_FOLDER}`,
3854
+ fields: "nextPageToken,incompleteSearch,files(id,name,driveId,ownedByMe)",
3855
+ pageSize: 1e3,
3856
+ ...ACROSS_DRIVES
3857
+ }, "files");
3858
+ const folders = rows.filter((row) => Boolean(row.id));
3859
+ const counts = await childCounts(call, folders.map((folder) => folder.id));
3860
+ const items = folders.map((folder) => ({
3861
+ id: folder.id,
3862
+ name: folder.name ?? "",
3863
+ kind: "folder",
3864
+ parent,
3865
+ location: folder.driveId ? "shared_drive" : folder.ownedByMe === false ? "shared_with_me" : "my_drive",
3866
+ drive_id: folder.driveId ?? null,
3867
+ child_folders: counts?.get(folder.id) ?? null,
3868
+ added: added(folder.id)
3869
+ }));
3870
+ return listed(items.sort(byName), incomplete);
3871
+ }, "browseFolders");
3872
+
3873
+ // dist/commands/folders.js
3874
+ var installFolderCommands = /* @__PURE__ */ __name((program, context, call) => {
3875
+ const { env, selected, output, source } = context;
3876
+ addDocumentFolderCommands(program, {
3877
+ words: DRIVE_WORDS,
3878
+ output,
3879
+ add: /* @__PURE__ */ __name(async (input) => {
3880
+ const id = fileId(input);
3881
+ const config = readConfig(env);
3882
+ const name = selected();
3883
+ const profile = activeProfile(env, name);
3884
+ const metadata = await (await source()).metadata(id);
3885
+ if (metadata.mime !== FOLDER || metadata.trashed)
3886
+ throw new CliError("validation_error", "source is not an accessible Google folder");
3887
+ if (!profile.roots.includes(metadata.id))
3888
+ profile.roots.push(metadata.id);
3889
+ config.profiles[name] = profile;
3890
+ writeConfig(env, config);
3891
+ return { id: metadata.id, name: metadata.name };
3892
+ }, "add"),
3893
+ list: /* @__PURE__ */ __name((filter) => selectedFolders(env, selected(), filter), "list"),
3894
+ browse: /* @__PURE__ */ __name((folders) => {
3895
+ examples(answerEntity(annotate(folders.command("browse"), { effects: GOOGLE_READ }).description("list Google Drive folders one level at a time, to choose one for folders add"), "drive_remote_folder", browseRow), [
3896
+ "drive personal folders browse",
3897
+ "drive personal folders browse --parent FOLDER_ID --json",
3898
+ `drive personal folders browse --parent ${SHARED_WITH_ME}`
3899
+ ]).option("--parent <id>", `folder id or URL to list inside, or ${SHARED_WITH_ME}; the top level without it`).addHelpText("after", BROWSE_HELP).action(async (args) => {
3900
+ const parent = args.parent === void 0 || args.parent === SHARED_WITH_ME ? args.parent : fileId(args.parent);
3901
+ const roots2 = activeProfile(env, selected()).roots;
3902
+ output(await browseFolders(call, parent, roots2));
3903
+ });
3904
+ }, "browse"),
3905
+ remove: /* @__PURE__ */ __name((input) => {
3906
+ const id = fileId(input);
3907
+ const config = readConfig(env);
3908
+ const name = selected();
3909
+ const profile = activeProfile(env, name);
3910
+ profile.roots = profile.roots.filter((root) => root !== id);
3911
+ config.profiles[name] = profile;
3912
+ writeConfig(env, config);
3913
+ return id;
3914
+ }, "remove")
3815
3915
  });
3816
- examples(annotate(identities.command("link"), { effects: LOCAL_WRITE }).description("record that a Google account belongs to a known person"), ["drive personal identities link DOC_ID GOOGLE_ID person:PERSON_UID"]).argument("<document>", documentArgument).argument("<google-id>", "Google account id, as identities list prints it").argument("<person>", "person:<uid> reference of someone already known").action(async (doc, googleId, personRef) => output(itemOf(await run3(doc, (k, p, ref) => k.linkPerson(p, ref, googleId, personRef)))));
3817
- }, "installKnowledgeCommandsDefinition");
3818
- var installKnowledgeCommands = /* @__PURE__ */ __name((...args) => {
3819
- const reference = sharedCommandTemplate(DRIVE_APP, "notes");
3820
- customizeSharedCommand(reference, "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.", () => {
3821
- installKnowledgeCommandsDefinition(...args);
3822
- const command = args[0].commands.find((command2) => command2.name() === "notes");
3823
- if (!command)
3824
- throw new Error("notes builder did not install its command");
3825
- return command;
3826
- }, reviewedOverrides(reference, SHELL_OVERRIDES.notes));
3827
- }, "installKnowledgeCommands");
3916
+ }, "installFolderCommands");
3917
+
3918
+ // dist/commands/knowledge.js
3919
+ var installKnowledgeCommands = /* @__PURE__ */ __name((program, helpers) => addDocumentKnowledgeCommands(program, { ...helpers, words: DRIVE_WORDS }), "installKnowledgeCommands");
3828
3920
 
3829
3921
  // dist/commands/mirrors.js
3830
- import { statSync } from "node:fs";
3831
- import { join as join5, resolve } from "node:path";
3922
+ import { join as join5 } from "node:path";
3832
3923
 
3833
3924
  // dist/mirror-docs.js
3834
3925
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -4300,10 +4391,10 @@ var PLAIN_PARAGRAPH = {
4300
4391
  };
4301
4392
  var textRequests = /* @__PURE__ */ __name((inlines, at, extra = {}) => {
4302
4393
  const requests = [];
4303
- let offset2 = at;
4394
+ let offset = at;
4304
4395
  for (const inline of inlines) {
4305
4396
  const length = inline.text.length;
4306
- const range2 = { startIndex: offset2, endIndex: offset2 + length };
4397
+ const range2 = { startIndex: offset, endIndex: offset + length };
4307
4398
  const style = {
4308
4399
  ...inline.bold ? { bold: true } : {},
4309
4400
  ...inline.italic ? { italic: true } : {},
@@ -4314,7 +4405,7 @@ var textRequests = /* @__PURE__ */ __name((inlines, at, extra = {}) => {
4314
4405
  const fields = Object.keys(style);
4315
4406
  if (fields.length && length)
4316
4407
  requests.push({ updateTextStyle: { range: range2, textStyle: style, fields: fields.join(",") } });
4317
- offset2 += length;
4408
+ offset += length;
4318
4409
  }
4319
4410
  return requests;
4320
4411
  }, "textRequests");
@@ -4395,24 +4486,24 @@ var insertRequests = /* @__PURE__ */ __name((blocks, at) => {
4395
4486
  }
4396
4487
  });
4397
4488
  requests.push({ deleteParagraphBullets: { range: range2 } });
4398
- let offset2 = at;
4489
+ let offset = at;
4399
4490
  group.forEach((block, index) => {
4400
4491
  const line = lines[index] ?? "";
4401
4492
  if (block.kind === "item") {
4402
4493
  const done2 = block.list === "check" && block.checked;
4403
- requests.push(...textRequests(block.inlines, offset2 + block.depth, done2 ? { strike: true } : {}));
4494
+ requests.push(...textRequests(block.inlines, offset + block.depth, done2 ? { strike: true } : {}));
4404
4495
  } else if (block.kind === "code") {
4405
4496
  if (line)
4406
4497
  requests.push({
4407
4498
  updateTextStyle: {
4408
- range: { startIndex: offset2, endIndex: offset2 + line.length },
4499
+ range: { startIndex: offset, endIndex: offset + line.length },
4409
4500
  textStyle: { weightedFontFamily: { fontFamily: MONO } },
4410
4501
  fields: "weightedFontFamily"
4411
4502
  }
4412
4503
  });
4413
4504
  } else if (block.kind === "heading" || block.kind === "paragraph" || block.kind === "quote")
4414
- requests.push(...textRequests(block.inlines, offset2));
4415
- offset2 += line.length + 1;
4505
+ requests.push(...textRequests(block.inlines, offset));
4506
+ offset += line.length + 1;
4416
4507
  });
4417
4508
  if (first.kind === "item")
4418
4509
  requests.push({ createParagraphBullets: { range: range2, bulletPreset: PRESETS[first.list] } });
@@ -4588,178 +4679,69 @@ var googleTarget = /* @__PURE__ */ __name((call, identity) => ({
4588
4679
  // dist/commands/mirrors.js
4589
4680
  var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call }) => {
4590
4681
  const { env, selected, output, source } = context;
4591
- const mirrors = annotate(program.command("mirrors"), { effects: LOCAL_READ }).description("keep local folders mirrored into Google Docs and Sheets");
4592
- const mirrorsOf = /* @__PURE__ */ __name(() => activeProfile(env, selected()).mirrors ?? [], "mirrorsOf");
4593
- const find = /* @__PURE__ */ __name((id) => {
4594
- const mirror = mirrorsOf().find((item) => item.id === id);
4595
- if (!mirror)
4596
- throw new CliError("not_found", `no mirror ${id} in profile ${selected()}; see drive ${selected()} mirrors list`, {
4597
- reason: "mirror.not-found"
4598
- });
4599
- return mirror;
4600
- }, "find");
4601
- const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(join5(profileDir(env, name), "mirrors"), mirror, principal, ["doc", "sheet"]), "stateOf");
4602
- const syncing = /* @__PURE__ */ __name((name, principal, google) => ({
4603
- target: googleTarget(call, () => google.identity()),
4604
- stateOf: stateOf(name, principal),
4605
- principal,
4606
- // `call` already checks policy and journals each Google write it makes.
4607
- guard: /* @__PURE__ */ __name((_attempt, act) => act(), "guard"),
4608
- operationId: newOperationId,
4609
- errorOf: googleError,
4610
- lock: /* @__PURE__ */ __name(() => lockProfile(env, name), "lock"),
4611
- ...context.signal() ? { signal: context.signal() } : {},
4612
- remote: "google"
4613
- }), "syncing");
4614
- const chosenOf = /* @__PURE__ */ __name((name, id) => {
4615
- const chosen = id ? [find(id)] : mirrorsOf();
4616
- if (!chosen.length)
4617
- throw new CliError("not_found", `profile ${name} has no mirrors; add one with drive ${name} mirrors add`, {
4618
- reason: "mirror.none"
4619
- });
4620
- return chosen;
4621
- }, "chosenOf");
4622
- examples(annotate(mirrors.command("add"), { effects: FETCH }).argument("<path>", "local folder to mirror").requiredOption("--parent <id>", "the Google Drive folder to write into, by id or URL").description("mirror a local folder: Markdown to Google Docs, CSV/TSV/XLSX to Sheets"), ["drive personal mirrors add ./notes --parent FOLDER_ID"]).action(async (path, args) => {
4623
- const root = resolve(path);
4624
- let directory = false;
4625
- try {
4626
- directory = statSync(root).isDirectory();
4627
- } catch {
4628
- }
4629
- if (!directory)
4630
- throw new CliError("validation_error", "the path to mirror is not a folder", { reason: "mirror.not-folder" });
4631
- const folder = fileId(args.parent);
4632
- const metadata = await (await source()).metadata(folder);
4633
- if (metadata.mime !== FOLDER || metadata.trashed)
4634
- throw new CliError("validation_error", "--parent is not an accessible Google folder");
4635
- const config = readConfig(env);
4636
- const name = selected();
4637
- const profile = activeProfile(env, name);
4638
- const id = mirrorId(root, folder);
4639
- const list = profile.mirrors ?? [];
4640
- if (!list.some((mirror) => mirror.id === id))
4641
- list.push({ id, path: root, folder });
4642
- config.profiles[name] = { ...profile, mirrors: list };
4643
- writeConfig(env, config);
4644
- output(itemOf({ id, path: root, folder, folder_name: metadata.name, added: true }));
4645
- });
4646
- bindQuery(examples(annotate(mirrors.command("list"), { effects: LOCAL_READ }).description("list this profile's mirrors"), [
4647
- "drive personal mirrors list"
4648
- ]), MIRRORS_QUERY, mirrorRow).action((words) => {
4649
- const filter = termsOf(words, MIRRORS_QUERY, "mirrors list");
4650
- output(allOf(configuredMirrors(env, selected(), filter)));
4651
- });
4652
- examples(annotate(mirrors.command("remove"), { effects: LOCAL_WRITE }).argument("<id>", "mirror id from mirrors list").description("stop mirroring a folder; nothing in Google Drive is changed or deleted"), ["drive personal mirrors remove 1a2b3c4d"]).action((id) => {
4653
- find(id);
4654
- const config = readConfig(env);
4655
- const name = selected();
4656
- const profile = activeProfile(env, name);
4657
- config.profiles[name] = { ...profile, mirrors: (profile.mirrors ?? []).filter((mirror) => mirror.id !== id) };
4658
- writeConfig(env, config);
4659
- output(itemOf({ id, removed: true }));
4660
- });
4661
- examples(annotate(mirrors.command("status"), { effects: LOCAL_READ }).argument("[id]", "mirror id; every mirror of the profile when omitted").description("show which local files the next sync would create or send; Google is not asked"), ["drive personal mirrors status"]).action(async (id) => {
4662
- const name = selected();
4663
- const { principal } = activeProfile(env, name);
4664
- const items = await mirrorStatus(id ? [find(id)] : mirrorsOf(), mirrorKind, stateOf(name, principal));
4665
- output(allOf(items.map(({ id: id2, folder, create, update: update2, unchanged, orphans, unsupported, remote_checked }) => ({
4666
- id: id2,
4667
- folder,
4668
- create: create.length,
4669
- update: update2.length,
4670
- unchanged,
4671
- orphans: orphans.length,
4672
- unsupported,
4673
- remote_checked
4674
- }))));
4675
- });
4676
- examples(annotate(mirrors.command("sync"), { effects: REMOTE_WRITE }).argument("[id]", "mirror id; every mirror of the profile when omitted").addOption(new Option("--keep <side>", "where a part changed on both sides, keep this side").choices([
4677
- "local",
4678
- "google",
4679
- "both"
4680
- ])).option("--replace", "same as --keep local, and create again files deleted in Google").description("sync both ways with Docs and Sheets; a part changed on both sides is reported"), [
4681
- "drive personal mirrors sync",
4682
- "drive personal mirrors sync 1a2b3c4d --keep google",
4683
- "drive personal mirrors sync 1a2b3c4d --replace"
4684
- ]).action(async (id, args) => {
4685
- const name = selected();
4686
- const profile = activeProfile(env, name);
4687
- const chosen = chosenOf(name, id);
4688
- if (args.replace && args.keep && args.keep !== "local")
4689
- throw new CliError("validation_error", "--replace keeps the local side; it cannot be combined with --keep google or both");
4690
- const keep = args.replace ? "local" : args.keep === "google" ? "remote" : args.keep;
4691
- const google = await source();
4692
- const { items, issues } = await syncMirrors({
4693
- ...syncing(name, profile.principal, google),
4694
- mirrors: chosen,
4695
- ...keep ? { keep } : {},
4696
- recreate: args.replace === true
4697
- });
4698
- const body = allOf(items);
4699
- if (issues.length)
4700
- body.meta = { complete: false, issues };
4701
- output(body);
4702
- if (issues.length)
4703
- throw new CliError("provider_error", `some files were not synced; see conflicts, missing and errors, then rerun with --keep local, google or both`, { reason: "mirror.partial" });
4704
- });
4705
- examples(annotate(mirrors.command("watch"), { effects: REMOTE_WRITE, lifetime: "persistent" }).argument("[id]", "mirror id; every mirror of the profile when omitted").option("--every <duration>", "how often to ask Google for changes", "60s").summary("keep syncing both ways until Ctrl-C or --timeout").description("keep syncing both ways until Ctrl-C or --timeout: on each local save and each Google change; a part changed on both sides is reported and left for mirrors sync --keep"), ["drive personal mirrors watch", "drive personal mirrors watch 1a2b3c4d --every 2m --jsonl"]).action(async (id, args) => {
4706
- const pollMs = parseDuration(args.every, "--every");
4707
- if (pollMs < 1e4)
4708
- throw new CliError("validation_error", "--every must be at least 10s");
4709
- const name = selected();
4710
- const profile = activeProfile(env, name);
4711
- const chosen = chosenOf(name, id);
4712
- const signal = context.endsOnStop() ?? new AbortController().signal;
4713
- const google = await source();
4714
- const states = stateOf(name, profile.principal);
4715
- let token = await google.startToken();
4716
- const remoteChanges = /* @__PURE__ */ __name(async () => {
4717
- let changed;
4718
- try {
4719
- const feed = await google.changes(token);
4720
- token = feed.cursor;
4721
- changed = new Set(feed.items.map((item) => item.id));
4722
- } catch (error) {
4723
- if (!isCliError(error) || error.details?.reason !== "listing.too-large")
4724
- throw error;
4725
- token = await google.startToken();
4726
- return "all";
4727
- }
4728
- return chosen.filter((mirror) => Object.values(states(mirror).read().entries).some((entry) => changed.has(entry.id))).map((mirror) => mirror.id);
4729
- }, "remoteChanges");
4730
- let cycles = 0;
4731
- for await (const event of watchMirrors((mirrors2) => syncMirrors({ ...syncing(name, profile.principal, google), mirrors: mirrors2 }), { mirrors: chosen, signal, kindOf: mirrorKind, stateOf: states, remoteChanges, pollMs })) {
4732
- cycles++;
4733
- const data = {
4734
- at: (/* @__PURE__ */ new Date()).toISOString(),
4735
- triggers: event.triggers,
4736
- mirrors: event.mirrors,
4737
- ..."error" in event ? { error: { code: event.error.code, message: event.error.message } } : { results: event.result.items, ...event.result.issues.length ? { issues: event.result.issues } : {} }
4682
+ addDocumentMirrorCommands(program, {
4683
+ words: DRIVE_WORDS,
4684
+ output,
4685
+ print: /* @__PURE__ */ __name((render) => context.print((_renderer, format, streams) => render(format, (text) => streams.data(text))), "print"),
4686
+ profile: selected,
4687
+ mirrors: /* @__PURE__ */ __name(() => activeProfile(env, selected()).mirrors ?? [], "mirrors"),
4688
+ save: /* @__PURE__ */ __name((mirrors) => {
4689
+ const config = readConfig(env);
4690
+ const name = selected();
4691
+ config.profiles[name] = { ...activeProfile(env, name), mirrors };
4692
+ writeConfig(env, config);
4693
+ }, "save"),
4694
+ parent: /* @__PURE__ */ __name(async (input) => {
4695
+ const folder = fileId(input);
4696
+ const metadata = await (await source()).metadata(folder);
4697
+ if (metadata.mime !== FOLDER || metadata.trashed)
4698
+ throw new CliError("validation_error", "--parent is not an accessible Google folder");
4699
+ return { id: folder, name: metadata.name };
4700
+ }, "parent"),
4701
+ kindOf: mirrorKind,
4702
+ stateOf: /* @__PURE__ */ __name((mirror) => fileMirrorState(join5(profileDir(env, selected()), "mirrors"), mirror, activeProfile(env, selected()).principal, ["doc", "sheet"]), "stateOf"),
4703
+ connect: /* @__PURE__ */ __name(async () => {
4704
+ const name = selected();
4705
+ const { principal } = activeProfile(env, name);
4706
+ const google = await source();
4707
+ return {
4708
+ sync: {
4709
+ target: googleTarget(call, () => google.identity()),
4710
+ principal,
4711
+ // `call` already checks policy and journals each Google write it makes.
4712
+ guard: /* @__PURE__ */ __name((_attempt, act) => act(), "guard"),
4713
+ operationId: newOperationId,
4714
+ errorOf: googleError,
4715
+ lock: /* @__PURE__ */ __name(() => lockProfile(env, name), "lock"),
4716
+ ...context.signal() ? { signal: context.signal() } : {}
4717
+ },
4718
+ startToken: /* @__PURE__ */ __name(() => google.startToken(), "startToken"),
4719
+ changes: /* @__PURE__ */ __name((token) => google.changes(token), "changes")
4738
4720
  };
4739
- context.print((_renderer, format, streams) => streams.data(format === "pretty" ? describeCycle(data) : JSON.stringify({ type: "item", data })));
4740
- }
4741
- context.print((_renderer, format, streams) => {
4742
- if (format === "pretty")
4743
- return;
4744
- const end = listOf("mirrors watch", {
4745
- items: [],
4746
- limit: Math.max(1, cycles),
4747
- has_more: false,
4748
- paging: "cursor",
4749
- meta: { complete: true }
4750
- });
4751
- for (const record2 of jsonlRecords(end))
4752
- streams.data(JSON.stringify(record2));
4753
- });
4721
+ }, "connect"),
4722
+ endsOnStop: /* @__PURE__ */ __name(() => context.endsOnStop(), "endsOnStop")
4754
4723
  });
4755
4724
  }, "installMirrorCommands");
4756
- var describeCycle = /* @__PURE__ */ __name((cycle) => {
4757
- const time = cycle.at.slice(11, 19);
4758
- if (cycle.error)
4759
- return `${time} ${cycle.triggers.join("+")}: ${cycle.error.message}; trying again`;
4760
- const parts = (cycle.results ?? []).map((result) => `${result.id} ${result.created.length} created, ${result.updated.length} sent, ${result.pulled.length} pulled` + (result.conflicts.length ? `, ${result.conflicts.length} conflicts (mirrors sync ${result.id} --keep \u2026)` : ""));
4761
- return `${time} ${cycle.triggers.join("+")}: ${parts.join("; ") || "nothing to do"}`;
4762
- }, "describeCycle");
4725
+
4726
+ // dist/age.js
4727
+ var SYNC = defineSteps([
4728
+ { id: "sync.run", command: "sync", args: [], why: "copy the changes Google has made into the local store" }
4729
+ ])[0];
4730
+ var freshness = /* @__PURE__ */ __name((remote, local2) => ({
4731
+ changed: local2 === void 0 || Date.parse(remote) !== Date.parse(local2),
4732
+ remote_modified_at: remote,
4733
+ local_modified_at: local2 ?? null
4734
+ }), "freshness");
4735
+ var changedCopy = /* @__PURE__ */ __name(({ changed, local_modified_at }) => {
4736
+ if (!changed)
4737
+ return {};
4738
+ const why = local_modified_at === null ? "the local copy has no modified time, so it cannot be compared with Google" : `Google changed the document after the local copy was made (${local_modified_at})`;
4739
+ return {
4740
+ missing: [{ field: "modified_at", why, step: SYNC.id }],
4741
+ next: [stepOf(SYNC)],
4742
+ meta: { complete: false }
4743
+ };
4744
+ }, "changedCopy");
4763
4745
 
4764
4746
  // dist/download.js
4765
4747
  import { randomUUID } from "node:crypto";
@@ -4824,6 +4806,39 @@ var saveDownload = /* @__PURE__ */ __name(async (path, overwrite, read, createDi
4824
4806
  return size2;
4825
4807
  }, "saveDownload");
4826
4808
 
4809
+ // dist/output.js
4810
+ var VERBATIM = /* @__PURE__ */ new Set([
4811
+ "frontMatter",
4812
+ "front_matter",
4813
+ "provider_metadata",
4814
+ "metadata",
4815
+ "headers",
4816
+ "properties",
4817
+ "appProperties",
4818
+ "app_properties",
4819
+ "request_schema",
4820
+ "response_schema",
4821
+ "body_schema",
4822
+ "schema",
4823
+ "inputSchema",
4824
+ "input_schema",
4825
+ "outputSchema",
4826
+ "output_schema"
4827
+ ]);
4828
+ var RECORDS = /* @__PURE__ */ new Set(["profiles", "permissions", "models"]);
4829
+ var keyOf = /* @__PURE__ */ __name((key) => /^[a-z][a-zA-Z0-9]*$/.test(key) ? key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase() : key, "keyOf");
4830
+ var snakeKeys2 = /* @__PURE__ */ __name((value, record2 = false) => {
4831
+ if (Array.isArray(value))
4832
+ return value.map((item) => snakeKeys2(item));
4833
+ if (!value || typeof value !== "object" || value instanceof Date)
4834
+ return value;
4835
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
4836
+ record2 ? key : keyOf(key),
4837
+ VERBATIM.has(key) ? item : snakeKeys2(item, RECORDS.has(key))
4838
+ ]));
4839
+ }, "snakeKeys");
4840
+ var allOf2 = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false }), "allOf");
4841
+
4827
4842
  // dist/generated/definitions.js
4828
4843
  var definitions = {
4829
4844
  DriveOperation: {
@@ -22010,10 +22025,10 @@ var DRIVE_TIME = /\b(modifiedTime|createdTime|viewedByMeTime|sharedWithMeTime)(\
22010
22025
  var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
22011
22026
  var utcDriveQuery = /* @__PURE__ */ __name((query, zone = timezoneOf()) => {
22012
22027
  let changed = false;
22013
- const sent = query.replace(DRIVE_TIME, (whole, field, before, operator, after, value, offset2) => {
22028
+ const sent = query.replace(DRIVE_TIME, (whole, field, before, operator, after, value, offset) => {
22014
22029
  if (ZONED.test(value))
22015
22030
  return whole;
22016
- const start = offset2 + whole.length - value.length - 1;
22031
+ const start = offset + whole.length - value.length - 1;
22017
22032
  const end = operator === "<=" || operator === ">";
22018
22033
  const time = zonedMoment(value, zone, { start, end: start + value.length }, { end });
22019
22034
  changed = true;
@@ -22251,11 +22266,11 @@ var sentParams = /* @__PURE__ */ __name((method, params) => {
22251
22266
  }, "sentParams");
22252
22267
  var zoneMeta = /* @__PURE__ */ __name((meta) => meta ? { meta } : {}, "zoneMeta");
22253
22268
  var installRemoteCommands = /* @__PURE__ */ __name((program, helpers) => {
22254
- const { call, output, positive: positive2 } = helpers;
22255
- const page = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many items one page holds", positive2, 100).option("--cursor <cursor>", "continue from page.next_cursor of the previous answer"), "page");
22269
+ const { call, output, positive: positive3 } = helpers;
22270
+ const page = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many items one page holds", positive3, 100).option("--cursor <cursor>", "continue from page.next_cursor of the previous answer"), "page");
22256
22271
  const fileArgument = "file id or Google Drive URL";
22257
22272
  const api = annotate(program.command("api"), { effects: LOCAL_READ }).description("discover and call the official Drive, Docs, Sheets and Activity API methods");
22258
- withQuery(examples(answerEntity(annotate(api.command("list"), { effects: NO_EFFECTS }).description("list the Google API methods drive can call"), "api_method", strictObject({ name: string(), mutates: boolean(), destructive: boolean(), scope: string() })), ["drive api list", "drive api list service:docs"]), API_METHOD_QUERY).action((words) => output(allOf(apiMethods(queryTerms(words, API_METHOD_QUERY, "api list").get("service")))));
22273
+ withQuery(examples(answerEntity(annotate(api.command("list"), { effects: NO_EFFECTS }).description("list the Google API methods drive can call"), "api_method", strictObject({ name: string(), mutates: boolean(), destructive: boolean(), scope: string() })), ["drive api list", "drive api list service:docs"]), API_METHOD_QUERY).action((words) => output(allOf2(apiMethods(queryTerms(words, API_METHOD_QUERY, "api list").get("service")))));
22259
22274
  examples(annotate(api.command("show"), { effects: NO_EFFECTS }).description("show one method's request schema and contract, without calling Google").argument("<method>", "Google method name, as api list prints it"), ["drive api show docs.documents.batchUpdate --json"]).action((method) => output(itemOf({ operation: operationOf(method), request_schema: requestSchema(method) })));
22260
22275
  examples(annotate(api.command("call"), { mcp: false, effects: GOOGLE_WRITE }).description("call one Google API method by name with JSON parameters").argument("<method>", "Google method name, as api list prints it"), [
22261
22276
  `drive personal api call drive.files.get --params '{"fileId":"FILE_ID"}'`,
@@ -22404,35 +22419,27 @@ var installRemoteCommands = /* @__PURE__ */ __name((program, helpers) => {
22404
22419
  }, "installRemoteCommands");
22405
22420
 
22406
22421
  // dist/commands/search.js
22407
- var installSearchCommandDefinition = /* @__PURE__ */ __name((program, { env, selected, output, withIndex }) => {
22408
- examples(annotate(program.command("search"), { effects: LOCAL_READ }).argument("<query>", "words to look for, and fields such as tag: and date: that every hit must match").description("search imported documents by words, and by meaning when indexed"), ["drive personal search budget", `drive personal search "quarterly plan" --exact --limit 5`]).option("--limit <n>", "how many results to return", positive, 20).option("--page <n>", "which page to return", positive, 1).option("--exact", "match the words exactly: no word forms, no meaning").action(async (query, { page, ...args }) => {
22422
+ var installSearchCommand = /* @__PURE__ */ __name((program, { env, selected, output, withIndex }) => addDocumentSearchCommand(program, {
22423
+ words: DRIVE_WORDS,
22424
+ output,
22425
+ search: /* @__PURE__ */ __name(async (query, options) => {
22409
22426
  const name = selected();
22410
22427
  const profile = activeProfile(env, name);
22411
- const result = await withIndex((index) => index.search(profile.principal, query, {
22412
- ...args,
22413
- offset: (page - 1) * args.limit,
22414
- exact: args.exact ?? false,
22428
+ return withIndex(async (index) => await index.search(profile.principal, query, {
22429
+ ...options,
22415
22430
  ...pictureSearch(env, name) ? { pictures: true } : {}
22416
22431
  }));
22417
- const hint = notImported(name, profile.roots.length > 0 || transcriptsOf(env, name).mode === "include", Object.keys(readState(env, name, profile.principal).documents));
22418
- output(itemOf(hint ? { ...result, not_imported: hint } : result));
22419
- });
22420
- }, "installSearchCommandDefinition");
22421
- var notImported = /* @__PURE__ */ __name((name, chosen, documents) => {
22422
- if (documents.length > 0)
22423
- return void 0;
22424
- return !chosen ? `profile ${name} has no folders selected, so nothing is imported to search \u2014 drive ${name} folders add FOLDER_ID, then drive ${name} sync` : `profile ${name} has imported no documents yet \u2014 drive ${name} sync`;
22425
- }, "notImported");
22426
- var installSearchCommand = /* @__PURE__ */ __name((...args) => {
22427
- const reference = sharedCommandTemplate(DRIVE_APP, "search");
22428
- return customizeSharedCommand(reference, "Drive searches imported documents and embeddings rather than live messenger messages; its default action and pagination are explicitly provider-specific.", () => {
22429
- installSearchCommandDefinition(...args);
22430
- const command = args[0].commands.find((command2) => command2.name() === "search");
22431
- if (!command)
22432
- throw new Error("search builder did not install its command");
22433
- return command;
22434
- }, reviewedOverrides(reference, SHELL_OVERRIDES.search));
22435
- }, "installSearchCommand");
22432
+ }, "search"),
22433
+ imported: /* @__PURE__ */ __name(() => {
22434
+ const name = selected();
22435
+ const profile = activeProfile(env, name);
22436
+ return {
22437
+ profile: name,
22438
+ chosen: profile.roots.length > 0 || transcriptsOf(env, name).mode === "include",
22439
+ documents: Object.keys(readState(env, name, profile.principal).documents).length
22440
+ };
22441
+ }, "imported")
22442
+ }), "installSearchCommand");
22436
22443
 
22437
22444
  // dist/commands/session.js
22438
22445
  var GRANTS = ["write", "activity", "apps"];
@@ -22463,7 +22470,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22463
22470
  const app = application(env, { file: args.clientFile, clientId: args.clientId, profile: selected() });
22464
22471
  if (!app.clientSecret)
22465
22472
  streams.diagnostic("your Google app has no secret here, and Google refuses a Desktop app without one: set DRIVE_GOOGLE_CLIENT_SECRET\n");
22466
- const { login } = await import("./login-RBDJPQAG.js");
22473
+ const { login } = await import("./login-6WG3YBDU.js");
22467
22474
  output(itemOf(await login({
22468
22475
  env,
22469
22476
  profile: selected(),
@@ -22494,7 +22501,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22494
22501
  const name = selected();
22495
22502
  const config = readConfig(env);
22496
22503
  const profile = activeProfile(env, name);
22497
- const { credentials } = await import("./tokens-LY3WML55.js");
22504
+ const { credentials } = await import("./tokens-DB7O7QNB.js");
22498
22505
  const store = credentials(env, profile.storage, options.keyring);
22499
22506
  store.remove(name);
22500
22507
  writeConfig(env, config);
@@ -22541,7 +22548,7 @@ var selection = /* @__PURE__ */ __name((env, name, source) => {
22541
22548
  return { profile, state, options: { source, destination, collection: `google-drive:${profile.principal}`, env } };
22542
22549
  }, "selection");
22543
22550
  var checkStoreImport = /* @__PURE__ */ __name(async (env, name, source, bindings) => {
22544
- const { ensureSqlite } = await import("./sqlite-runtime-RZ5PLZVQ.js");
22551
+ const { ensureSqlite } = await import("./sqlite-runtime-ZSZGAUYB.js");
22545
22552
  await ensureSqlite();
22546
22553
  const { state, options } = selection(env, name, source);
22547
22554
  const preview = await previewDocumentTransfer({ ...options, bindings });
@@ -22673,46 +22680,40 @@ var sync = /* @__PURE__ */ __name(async (source, index, env, name, max, signal,
22673
22680
  // dist/commands/sync.js
22674
22681
  var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
22675
22682
  const { env, streams, selected, output, source, withIndex } = context;
22676
- examples(annotate(program.command("sync"), { effects: FETCH }).summary("import what changed in the chosen folders, and finish an unfinished sync").description(`import what changed in the chosen folders, and finish an unfinished sync; one sync reads at most ${MAX_ENTRIES} entries under the chosen folders, and as many changes`), ["drive personal sync", "drive personal sync --rescan --limit 500"]).option("--limit <n>", "how many documents to read from Google in this run", positive, 200).option("--rescan", "read every chosen folder again instead of only what changed").option("--embed", "also index pending text for meaning search, with a model already downloaded").action(async (args) => {
22677
- const profile = activeProfile(env, selected());
22678
- const remote = profile.roots.length || profile.transcripts === "include" ? await source() : void 0;
22679
- const result = await withIndex(async (index) => ({
22680
- ...await sync(remote, index, env, selected(), args.limit, context.signal(), args.rescan),
22681
- ...args.embed ? { embeddings: await index.embed(600) } : {}
22682
- }));
22683
- output(itemOf(result, {
22684
- meta: result.errors.length ? {
22685
- complete: false,
22686
- issues: [{ code: "provider_error", reason: "sync.partial", source: "google-drive" }]
22687
- } : {}
22688
- }));
22689
- if (result.errors.length || result.pending)
22690
- streams.diagnostic(`${result.pending} source operations remain; run drive ${selected()} sync again
22691
- `);
22692
- if (result.errors.length)
22693
- throw new CliError("provider_error", "sync completed partially; failed operations remain pending", {
22694
- reason: "sync.partial"
22695
- });
22696
- });
22697
- examples(annotate(program.command("status"), { effects: LOCAL_READ }).description("show the last sync, imported documents and pending work"), ["drive personal status"]).action(() => {
22698
- const name = selected();
22699
- const profile = activeProfile(env, name);
22700
- const state = readState(env, name, profile.principal);
22701
- const legacyStore = join7(paths(env).state, "drive.db");
22702
- output(itemOf({
22703
- profile: name,
22704
- store: {
22705
- selected: resolve4(storePath(env)),
22706
- checkpoint: state.store ?? (existsSync(legacyStore) ? resolve4(legacyStore) : null)
22707
- },
22708
- selected_folders: profile.roots,
22709
- documents: Object.keys(state.documents).length,
22710
- pending: state.pending?.jobs.length ?? 0,
22711
- skipped: state.skipped.map(({ id, reason }) => ({ id, reason })),
22712
- last_sync: state.lastSync ?? null,
22713
- coverage: "Google Docs/Sheets, PDF/DOCX/XLSX and Markdown/TXT/CSV/TSV; native export layout, tab fidelity and assets are not verified",
22714
- remote_checked: false
22715
- }));
22683
+ addDocumentSyncCommands(program, {
22684
+ words: DRIVE_WORDS,
22685
+ output,
22686
+ diagnostic: /* @__PURE__ */ __name((text) => streams.diagnostic(text), "diagnostic"),
22687
+ profile: selected,
22688
+ maxEntries: MAX_ENTRIES,
22689
+ sync: /* @__PURE__ */ __name(async (args) => {
22690
+ const profile = activeProfile(env, selected());
22691
+ const remote = profile.roots.length || profile.transcripts === "include" ? await source() : void 0;
22692
+ return withIndex(async (index) => ({
22693
+ ...await sync(remote, index, env, selected(), args.limit, context.signal(), args.rescan),
22694
+ ...args.embed ? { embeddings: await index.embed(600) } : {}
22695
+ }));
22696
+ }, "sync"),
22697
+ status: /* @__PURE__ */ __name(() => {
22698
+ const name = selected();
22699
+ const profile = activeProfile(env, name);
22700
+ const state = readState(env, name, profile.principal);
22701
+ const legacyStore = join7(paths(env).state, "drive.db");
22702
+ return {
22703
+ profile: name,
22704
+ store: {
22705
+ selected: resolve4(storePath(env)),
22706
+ checkpoint: state.store ?? (existsSync(legacyStore) ? resolve4(legacyStore) : null)
22707
+ },
22708
+ selected_folders: profile.roots,
22709
+ documents: Object.keys(state.documents).length,
22710
+ pending: state.pending?.jobs.length ?? 0,
22711
+ skipped: state.skipped.map(({ id, reason }) => ({ id, reason })),
22712
+ last_sync: state.lastSync ?? null,
22713
+ coverage: "Google Docs/Sheets, PDF/DOCX/XLSX and Markdown/TXT/CSV/TSV; native export layout, tab fidelity and assets are not verified",
22714
+ remote_checked: false
22715
+ };
22716
+ }, "status")
22716
22717
  });
22717
22718
  }, "installSyncCommands");
22718
22719
 
@@ -22743,14 +22744,14 @@ var installTranscriptCommands = /* @__PURE__ */ __name((program, context) => {
22743
22744
  owned_by_me: file.providerMetadata?.ownedByMe ?? null,
22744
22745
  modified_at: file.modifiedAt ?? null
22745
22746
  }));
22746
- output(allOf(rows.filter((row) => filter.owned_by_me === void 0 || String(row.owned_by_me) === filter.owned_by_me)));
22747
+ output(allOf2(rows.filter((row) => filter.owned_by_me === void 0 || String(row.owned_by_me) === filter.owned_by_me)));
22747
22748
  });
22748
22749
  }, "installTranscriptCommands");
22749
22750
 
22750
22751
  // dist/commands/upgrade.js
22751
22752
  import { join as join8 } from "node:path";
22752
22753
 
22753
- // node_modules/.pnpm/@wirecat+cli-core@0.662.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_b96f03b0a44798bffec19d0b8a7273db/node_modules/@wirecat/cli-core/dist/update/index.js
22754
+ // node_modules/.pnpm/@wirecat+cli-core@0.666.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_02b130a271480a962759fcca79b3d7ec/node_modules/@wirecat/cli-core/dist/update/index.js
22754
22755
  import { realpathSync } from "node:fs";
22755
22756
  import { fileURLToPath } from "node:url";
22756
22757
  var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
@@ -22923,11 +22924,11 @@ var placeInSections = /* @__PURE__ */ __name((program) => {
22923
22924
 
22924
22925
  // dist/provider-json.js
22925
22926
  var providerJsonFields = entityFields({
22926
- "document.drive_catalog": CATALOG_FIELDS,
22927
- drive_document: DOCUMENT_LIST_FIELDS
22927
+ "document.catalog": CATALOG_FIELDS,
22928
+ "document.imported": DOCUMENT_LIST_FIELDS
22928
22929
  });
22929
22930
  var DRIVE_ROWS = {
22930
- drive_document: {
22931
+ "document.imported": {
22931
22932
  columns: [
22932
22933
  { field: "reference" },
22933
22934
  { field: "name" },
@@ -22935,7 +22936,7 @@ var DRIVE_ROWS = {
22935
22936
  { field: "age_days", as: "count", tag: "days since sync" }
22936
22937
  ]
22937
22938
  },
22938
- "document.drive_catalog": {
22939
+ "document.catalog": {
22939
22940
  columns: [{ field: "ref" }, { field: "name" }, { field: "kind" }, { field: "modified_at", as: "time" }]
22940
22941
  }
22941
22942
  };
@@ -22962,9 +22963,9 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22962
22963
  const port = {
22963
22964
  ...shared,
22964
22965
  context: /* @__PURE__ */ __name(async (principal, ref) => {
22965
- const note = await document(principal, ref);
22966
+ const note2 = await document(principal, ref);
22966
22967
  return {
22967
- document: note,
22968
+ document: note2,
22968
22969
  tags: await store.notes.noteTags(ref),
22969
22970
  links: await store.notes.links({ from: ref }),
22970
22971
  notes: await store.notes.notes({ source: "internal", about: ref, limit: 100 }),
@@ -22974,19 +22975,20 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22974
22975
  };
22975
22976
  }, "context"),
22976
22977
  people: /* @__PURE__ */ __name(async (principal, ref, filter = {}) => {
22977
- const note = await document(principal, ref);
22978
- const metadata = note.frontMatter;
22978
+ const note2 = await document(principal, ref);
22979
+ const metadata = note2.frontMatter;
22979
22980
  const contributors = [
22980
22981
  ...(metadata.owners ?? []).map((user) => ({ ...user, role: "owner" })),
22981
22982
  ...metadata.lastModifiedBy ? [{ ...metadata.lastModifiedBy, role: "last-editor" }] : []
22982
- ].filter((user) => (filter.role === void 0 || user.role === filter.role) && (filter.google_id === void 0 || googleUserId(user) === filter.google_id));
22983
+ ].filter((user) => (filter.role === void 0 || user.role === filter.role) && (filter.remote_id === void 0 || googleUserId(user) === filter.remote_id));
22983
22984
  return {
22984
22985
  items: await Promise.all(contributors.map(async (user) => {
22985
22986
  const id = googleUserId(user);
22986
22987
  const person = id ? await store.people.personOf({ provider: "google-drive", id }) : void 0;
22987
22988
  return {
22988
22989
  ...user,
22989
- google_id: id ?? null,
22990
+ remote_id: id ?? null,
22991
+ provider: "google-drive",
22990
22992
  person: person ? { ref: `person:${person.uid}`, ...person } : null
22991
22993
  };
22992
22994
  })),
@@ -22994,8 +22996,8 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22994
22996
  };
22995
22997
  }, "people"),
22996
22998
  linkPerson: /* @__PURE__ */ __name(async (principal, ref, googleId, personRef) => {
22997
- const note = await document(principal, ref);
22998
- const metadata = note.frontMatter;
22999
+ const note2 = await document(principal, ref);
23000
+ const metadata = note2.frontMatter;
22999
23001
  const users = [...metadata.owners ?? [], ...metadata.lastModifiedBy ? [metadata.lastModifiedBy] : []];
23000
23002
  if (!users.some((user) => googleUserId(user) === googleId))
23001
23003
  throw new CliError("not_found", "Google identity was not observed on this document");
@@ -23012,8 +23014,8 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23012
23014
  if (sourceFolder.account?.provider !== "google-drive")
23013
23015
  continue;
23014
23016
  const principal2 = sourceFolder.account.account;
23015
- for (let offset2 = 0; offset2 <= 1e4; offset2 += 500) {
23016
- const page = await store.notes.notes({ folderId: sourceFolder.id, source: "file", limit: 500, offset: offset2 });
23017
+ for (let offset = 0; offset <= 1e4; offset += 500) {
23018
+ const page = await store.notes.notes({ folderId: sourceFolder.id, source: "file", limit: 500, offset });
23017
23019
  for (const source of page.items) {
23018
23020
  const data = source.frontMatter;
23019
23021
  if (data?.source !== "google-drive" || !data.fileId)
@@ -23029,7 +23031,7 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23029
23031
  }
23030
23032
  if (!page.hasMore)
23031
23033
  break;
23032
- if (offset2 === 1e4)
23034
+ if (offset === 1e4)
23033
23035
  throw new CliError("provider_error", "identity linked; document relationship refresh exceeded its bound");
23034
23036
  }
23035
23037
  }
@@ -23091,15 +23093,15 @@ var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = fals
23091
23093
  const folder = await old.notes.documentsAccount({ provider: "google-drive", account: profile.principal });
23092
23094
  const counts = { tags: 0, notes: 0, memories: 0, facts: 0, links: 0 };
23093
23095
  if (folder) {
23094
- for (let offset2 = 0; ; offset2 += 500) {
23095
- const page = await old.notes.notes({ folderId: folder.id, source: "file", limit: 500, offset: offset2 });
23096
- for (const note of page.items) {
23097
- counts.tags += (await old.notes.noteTags(note.ref)).length;
23098
- counts.notes += (await old.notes.notes({ source: "internal", about: note.ref, limit: 1 })).items.length;
23099
- counts.memories += (await old.memories.list({ subject: note.ref, limit: 1 })).items.length;
23100
- counts.facts += (await old.facts.list({ subject: note.ref, limit: 1 })).items.length;
23101
- counts.links += (await old.notes.links({ from: note.ref })).filter((link) => link.origin !== "file").length;
23102
- counts.links += (await old.notes.links({ to: note.ref })).length;
23096
+ for (let offset = 0; ; offset += 500) {
23097
+ const page = await old.notes.notes({ folderId: folder.id, source: "file", limit: 500, offset });
23098
+ for (const note2 of page.items) {
23099
+ counts.tags += (await old.notes.noteTags(note2.ref)).length;
23100
+ counts.notes += (await old.notes.notes({ source: "internal", about: note2.ref, limit: 1 })).items.length;
23101
+ counts.memories += (await old.memories.list({ subject: note2.ref, limit: 1 })).items.length;
23102
+ counts.facts += (await old.facts.list({ subject: note2.ref, limit: 1 })).items.length;
23103
+ counts.links += (await old.notes.links({ from: note2.ref })).filter((link) => link.origin !== "file").length;
23104
+ counts.links += (await old.notes.links({ to: note2.ref })).length;
23103
23105
  }
23104
23106
  if (!page.hasMore)
23105
23107
  break;
@@ -23177,7 +23179,7 @@ var openIndex = /* @__PURE__ */ __name(async (env, name, rescan = false) => {
23177
23179
  activeProfile(env, name);
23178
23180
  if (env.DRIVE_STORE)
23179
23181
  throw new CliError("configuration_error", "DRIVE_STORE has been retired; use MESSAGING_STORE to select the shared database", { reason: "store.override-retired" });
23180
- const { openAppStore } = await import("./cli-BS4L3HAP.js");
23182
+ const { openAppStore } = await import("./cli-K4D4DIGQ.js");
23181
23183
  const store = await openAppStore(env, { app: { command: "drive", version: VERSION }, provider: DRIVE_PROVIDER });
23182
23184
  const index = indexOver(store, env);
23183
23185
  try {
@@ -23228,7 +23230,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23228
23230
  linkMessages: /* @__PURE__ */ __name((documents, since) => store.notes.linkMessages({ documents, ...since ? { since } : {} }), "linkMessages"),
23229
23231
  knowledge: documentKnowledge2(store, async (principal) => (await folder(principal, false))?.id),
23230
23232
  openPictures: /* @__PURE__ */ __name(async () => {
23231
- const { openPictureEmbedderFor, savePicture } = await import("./services-SV6CFUCS.js");
23233
+ const { openPictureEmbedderFor, savePicture } = await import("./services-BDQBRXT5.js");
23232
23234
  const embedder = pictureEmbedder ?? await openPictureEmbedderFor({ env, command: "drive" });
23233
23235
  return {
23234
23236
  save: /* @__PURE__ */ __name((reference, bytes) => savePicture(store, { ref: reference }, bytes, { embedder }), "save"),
@@ -23247,7 +23249,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23247
23249
  has_more: false,
23248
23250
  meaning_skipped: "this Google account has no imported sources"
23249
23251
  };
23250
- const { searchNotes } = await import("./services-SV6CFUCS.js");
23252
+ const { searchNotes } = await import("./services-BDQBRXT5.js");
23251
23253
  const result = await searchNotes(store, query, {
23252
23254
  ...options,
23253
23255
  folderIds: selected ? [selected.id] : [],
@@ -23256,9 +23258,9 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23256
23258
  ...pictureEmbedder ? { pictureEmbedder } : {}
23257
23259
  });
23258
23260
  const pictures = await Promise.all((result.pictures ?? []).map(async (picture) => {
23259
- const note = await store.notes.note(picture.ref);
23261
+ const note2 = await store.notes.note(picture.ref);
23260
23262
  const [file] = await store.files.ofDocument(picture.ref);
23261
- return { ...picture, title: note.title, url: file?.url ?? null };
23263
+ return { ...picture, title: note2.title, url: file?.url ?? null };
23262
23264
  }));
23263
23265
  const { pictures: _, items, hasMore, nextOffset, ...rest } = result;
23264
23266
  return {
@@ -23267,9 +23269,9 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23267
23269
  ...nextOffset === void 0 ? {} : { next_offset: nextOffset },
23268
23270
  ...result.pictures ? { pictures } : {},
23269
23271
  hits: await Promise.all(items.map(async (hit) => {
23270
- const note = await store.notes.note(hit.ref);
23271
- const metadata = note.frontMatter;
23272
- const entry = note.path ? await store.catalog.get(selected.id, note.path) : void 0;
23272
+ const note2 = await store.notes.note(hit.ref);
23273
+ const metadata = note2.frontMatter;
23274
+ const entry = note2.path ? await store.catalog.get(selected.id, note2.path) : void 0;
23273
23275
  return {
23274
23276
  ...hit,
23275
23277
  tabs: Array.isArray(metadata?.tabs) ? metadata.tabs : [],
@@ -23280,7 +23282,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23280
23282
  };
23281
23283
  }, "search"),
23282
23284
  embed: /* @__PURE__ */ __name(async (max) => {
23283
- const { embedNotes } = await import("./services-SV6CFUCS.js");
23285
+ const { embedNotes } = await import("./services-BDQBRXT5.js");
23284
23286
  return embedNotes(store, { maxChunks: max, env, command: "drive" });
23285
23287
  }, "embed"),
23286
23288
  close: /* @__PURE__ */ __name(() => store.close(), "close")
@@ -23364,7 +23366,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23364
23366
  }, "start");
23365
23367
  const status = /* @__PURE__ */ __name((session2) => input.request({ url: session2, method: "PUT", headers: { "Content-Range": `bytes */${size2}` } }), "status");
23366
23368
  let session = "";
23367
- let offset2 = 0;
23369
+ let offset = 0;
23368
23370
  let resumed = false;
23369
23371
  let finished;
23370
23372
  const saved = readCheckpoint();
@@ -23374,7 +23376,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23374
23376
  finished = answer;
23375
23377
  if (answer?.status === 308) {
23376
23378
  session = saved.session_uri;
23377
- offset2 = nextByte(answer);
23379
+ offset = nextByte(answer);
23378
23380
  resumed = true;
23379
23381
  } else if (!finished) {
23380
23382
  clearCheckpoint();
@@ -23386,11 +23388,11 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23386
23388
  try {
23387
23389
  let failures = 0;
23388
23390
  while (!finished) {
23389
- const end = Math.min(offset2 + chunk, size2);
23390
- const body = Buffer.alloc(end - offset2);
23391
+ const end = Math.min(offset + chunk, size2);
23392
+ const body = Buffer.alloc(end - offset);
23391
23393
  if (body.length)
23392
- await handle.read(body, 0, body.length, offset2);
23393
- const range2 = size2 === 0 ? `bytes */0` : `bytes ${offset2}-${end - 1}/${size2}`;
23394
+ await handle.read(body, 0, body.length, offset);
23395
+ const range2 = size2 === 0 ? `bytes */0` : `bytes ${offset}-${end - 1}/${size2}`;
23394
23396
  let response;
23395
23397
  try {
23396
23398
  response = await input.request({
@@ -23407,7 +23409,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23407
23409
  break;
23408
23410
  }
23409
23411
  if (response?.status === 308) {
23410
- offset2 = nextByte(response);
23412
+ offset = nextByte(response);
23411
23413
  failures = 0;
23412
23414
  continue;
23413
23415
  }
@@ -23433,7 +23435,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23433
23435
  if (answer && done(answer.status))
23434
23436
  finished = answer;
23435
23437
  else if (answer?.status === 308)
23436
- offset2 = nextByte(answer);
23438
+ offset = nextByte(answer);
23437
23439
  }
23438
23440
  } finally {
23439
23441
  await handle.close();
@@ -23567,7 +23569,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23567
23569
  }, "output");
23568
23570
  const signal = /* @__PURE__ */ __name(() => environment().signal, "signal");
23569
23571
  const signedIn = /* @__PURE__ */ __name(async (name, scope2) => {
23570
- const { authorizedClient, checkAuthorization } = await import("./tokens-LY3WML55.js");
23572
+ const { authorizedClient, checkAuthorization } = await import("./tokens-DB7O7QNB.js");
23571
23573
  const client = authorizedClient(env, name, environment().keyring, signal());
23572
23574
  await checkAuthorization(client, scope2);
23573
23575
  return client;
@@ -23577,7 +23579,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23577
23579
  const fake = environment().source;
23578
23580
  if (fake)
23579
23581
  return fake(name);
23580
- const [{ googleSource }, client] = await Promise.all([import("./google-WDKDBDD4.js"), signedIn(name)]);
23582
+ const [{ googleSource }, client] = await Promise.all([import("./google-BSO3YB7N.js"), signedIn(name)]);
23581
23583
  return googleSource(client);
23582
23584
  }, "source");
23583
23585
  const withIndex = /* @__PURE__ */ __name(async (fn, profile) => {
@@ -23651,11 +23653,10 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23651
23653
  installStoreCommands(program, context);
23652
23654
  installDocumentCommands(program, context);
23653
23655
  installSearchCommand(program, context);
23654
- installCatalogCommands(program, { env, selected, output, positive, offset, withIndex });
23656
+ installCatalogCommands(program, { env, selected, output, withIndex });
23655
23657
  installKnowledgeCommands(program, {
23656
23658
  document: imported,
23657
23659
  output,
23658
- positive,
23659
23660
  complete: /* @__PURE__ */ __name(() => environment().complete ?? memoryModel(env, selected(), signal()), "complete"),
23660
23661
  author: /* @__PURE__ */ __name(() => agent() ? { bot: MCP_AGENT, kind: "agent" } : "owner", "author"),
23661
23662
  decider: /* @__PURE__ */ __name(() => agent() ? { bot: MCP_AGENT, reason: "asked over drive's MCP server" } : "owner", "decider"),
@@ -23683,7 +23684,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23683
23684
  },
23684
23685
  stored: storedDocument(context),
23685
23686
  output,
23686
- positive,
23687
+ positive: positive2,
23687
23688
  readBody: /* @__PURE__ */ __name((path) => {
23688
23689
  const fake = environment().readBody;
23689
23690
  if (fake)
@@ -23722,7 +23723,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23722
23723
  if (fake)
23723
23724
  return await fake.call(method, params, body);
23724
23725
  const [{ googleApi }, client] = await Promise.all([
23725
- import("./google-api-7JDZDCWE.js"),
23726
+ import("./google-api-SAND2F7L.js"),
23726
23727
  signedIn(selected(), descriptor.scope)
23727
23728
  ]);
23728
23729
  return await googleApi(client).call(method, params, body);
@@ -23748,7 +23749,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23748
23749
  if (fake)
23749
23750
  return fake(id, mime);
23750
23751
  const [{ googleDownload }, client] = await Promise.all([
23751
- import("./google-api-7JDZDCWE.js"),
23752
+ import("./google-api-SAND2F7L.js"),
23752
23753
  signedIn(selected(), apiMethod(method).scope)
23753
23754
  ]);
23754
23755
  return googleDownload(client)(id, mime);
@@ -23766,7 +23767,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23766
23767
  let request = environment().uploadRequest;
23767
23768
  if (!request) {
23768
23769
  const [{ googleUploadRequest }, client] = await Promise.all([
23769
- import("./google-api-7JDZDCWE.js"),
23770
+ import("./google-api-SAND2F7L.js"),
23770
23771
  signedIn(selected(), apiMethod(method).scope)
23771
23772
  ]);
23772
23773
  request = googleUploadRequest(client);
@@ -23979,7 +23980,7 @@ var mcpCommand = /* @__PURE__ */ __name(() => {
23979
23980
  const environment = environmentOf(action);
23980
23981
  if (environment.api)
23981
23982
  return;
23982
- const { grantAvailability } = await import("./grants-AU25GWKF.js");
23983
+ const { grantAvailability } = await import("./grants-PLNFYARD.js");
23983
23984
  availability = grantAvailability(rootOf(root), environment.env ?? process.env, environment.keyring);
23984
23985
  });
23985
23986
  }, "mcpCommand");