@wirecat/drive-cli 0.68.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 (225) 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-BU6XUFUP.js → all-profiles-FW3GK3QO.js} +24 -34
  8. package/dist/bundle/{anthropic-ZP5B7S2Z.js → anthropic-QVKJT3II.js} +8 -8
  9. package/dist/bundle/{app-server-EB4DH6T7.js → app-server-QU73RD5R.js} +68 -76
  10. package/dist/bundle/{bun-PWMM6L45.js → bun-5XCD5CBB.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-6VPR2SVC.js → bun-sqlite-TIGSVNSV.js} +9 -9
  12. package/dist/bundle/{chunk-7BXVI7XF.js → chunk-2SBC4DVV.js} +4 -4
  13. package/dist/bundle/{chunk-UFPRP7MG.js → chunk-3AHBZP33.js} +10 -15
  14. package/dist/bundle/{chunk-QRSPFCRY.js → chunk-3CHW7JGR.js} +17 -17
  15. package/dist/bundle/chunk-3TCMANIM.js +387 -0
  16. package/dist/bundle/{chunk-EOC7RHJ2.js → chunk-3UWRAIWA.js} +5 -7
  17. package/dist/bundle/{chunk-5G2BY4B6.js → chunk-3UZ4OH22.js} +32 -31
  18. package/dist/bundle/{chunk-UIKVP23D.js → chunk-4WK26MPY.js} +1 -1
  19. package/dist/bundle/{chunk-WUFZGPXX.js → chunk-54BQWRJL.js} +7 -7
  20. package/dist/bundle/{chunk-EA2OB75T.js → chunk-54NDYVZA.js} +1 -1
  21. package/dist/bundle/{chunk-QKY24RWV.js → chunk-5JTB4URG.js} +12 -12
  22. package/dist/bundle/{chunk-M4OP5ASJ.js → chunk-66PL7P4C.js} +1 -1
  23. package/dist/bundle/{chunk-JMZQBRRZ.js → chunk-6BMTW5A6.js} +9 -9
  24. package/dist/bundle/{chunk-CVAJMRRD.js → chunk-6DPOWBKA.js} +6 -6
  25. package/dist/bundle/{chunk-YUGTJBV3.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-AV5UKJZM.js +729 -0
  31. package/dist/bundle/{chunk-IVOG6T6P.js → chunk-BBFXQPKD.js} +3 -3
  32. package/dist/bundle/{chunk-BXHFJTU5.js → chunk-BBRMDMIR.js} +3 -3
  33. package/dist/bundle/{chunk-DYLYH7VE.js → chunk-BD2K2ONK.js} +4 -4
  34. package/dist/bundle/{chunk-AIEMFRBU.js → chunk-BFKFKDPC.js} +1 -1
  35. package/dist/bundle/{chunk-JZ3MT7IE.js → chunk-BXPC5TFG.js} +2 -2
  36. package/dist/bundle/chunk-DHX27E5M.js +31 -0
  37. package/dist/bundle/{chunk-6QR7NKMG.js → chunk-DR57KDAY.js} +109 -5
  38. package/dist/bundle/{chunk-2VYEGKQ3.js → chunk-DVI72ZQG.js} +1 -1
  39. package/dist/bundle/{chunk-WGX4DZPW.js → chunk-DVVUJ254.js} +2 -2
  40. package/dist/bundle/{chunk-PJ3FKBXG.js → chunk-EDO5LZVF.js} +1 -1
  41. package/dist/bundle/{chunk-QTRYJZL7.js → chunk-EG62WVR2.js} +6 -6
  42. package/dist/bundle/{chunk-WCNTDETD.js → chunk-F5KJWRF5.js} +98 -6
  43. package/dist/bundle/{chunk-D4MVEOU2.js → chunk-FADAOLGB.js} +4 -4
  44. package/dist/bundle/{chunk-FAMXUI2X.js → chunk-FCSHWUMW.js} +5 -5
  45. package/dist/bundle/{chunk-O7T3WGCV.js → chunk-FN3RXBO7.js} +6 -6
  46. package/dist/bundle/{chunk-5W65QTYS.js → chunk-FONIFRYI.js} +4 -4
  47. package/dist/bundle/{chunk-UUQJVKPB.js → chunk-FVTKFIQH.js} +2340 -1436
  48. package/dist/bundle/{chunk-7A77GYCE.js → chunk-FYPW7NMH.js} +4 -4
  49. package/dist/bundle/{chunk-FIVFP53N.js → chunk-GA3URWIF.js} +1 -1
  50. package/dist/bundle/{chunk-GTLXBAJV.js → chunk-GAHIHE4K.js} +3035 -2482
  51. package/dist/bundle/{chunk-CMWFYZ45.js → chunk-GJZSVSV3.js} +2 -2
  52. package/dist/bundle/{chunk-QWGEOQHA.js → chunk-GK3BJMGK.js} +1 -1
  53. package/dist/bundle/{chunk-TI2OANJZ.js → chunk-GPDPEHYX.js} +1 -1
  54. package/dist/bundle/{chunk-KPKIHJIT.js → chunk-GV5DGHSA.js} +4 -4
  55. package/dist/bundle/{chunk-JRFKCYMW.js → chunk-HHAZ6DCY.js} +23 -6
  56. package/dist/bundle/{chunk-ZVQDOKDY.js → chunk-HK225DAG.js} +1 -1
  57. package/dist/bundle/{chunk-MW46BLWH.js → chunk-HRATXUFH.js} +22 -20
  58. package/dist/bundle/{chunk-Z5BMYI2V.js → chunk-HWUPU6WX.js} +8 -8
  59. package/dist/bundle/{chunk-6WAC2LOS.js → chunk-HYXXMSVD.js} +8614 -8597
  60. package/dist/bundle/{chunk-YYIWPH53.js → chunk-I7YSHUPW.js} +13 -13
  61. package/dist/bundle/{chunk-MWCPKUU4.js → chunk-IFTX7AQU.js} +5 -5
  62. package/dist/bundle/{chunk-SOS4U2RF.js → chunk-IGNIUDI3.js} +71 -49
  63. package/dist/bundle/{chunk-7JKECODO.js → chunk-ILAQIBEO.js} +1 -11
  64. package/dist/bundle/{chunk-CK2SQ2CE.js → chunk-KSJAFMU5.js} +78 -31
  65. package/dist/bundle/{chunk-ZSVMZH5O.js → chunk-LINBDWJK.js} +2 -2
  66. package/dist/bundle/{chunk-43NEDPXB.js → chunk-LMJBQFW6.js} +6 -6
  67. package/dist/bundle/{chunk-IJCUAKR5.js → chunk-ML3R2UHV.js} +4 -4
  68. package/dist/bundle/{chunk-PGPHEC2X.js → chunk-MXNQZAJQ.js} +2 -2
  69. package/dist/bundle/{chunk-RT5NT62B.js → chunk-NP7LJATI.js} +16 -70
  70. package/dist/bundle/chunk-OY7TNUEC.js +16 -0
  71. package/dist/bundle/{chunk-74NCZKRW.js → chunk-P77FL6RY.js} +18 -18
  72. package/dist/bundle/chunk-P7PLKNPX.js +3611 -0
  73. package/dist/bundle/{chunk-QVJMFZFW.js → chunk-PAPY6Q6H.js} +1 -1
  74. package/dist/bundle/{chunk-Q6BD6RUH.js → chunk-PN4JYURZ.js} +102 -57
  75. package/dist/bundle/{chunk-MOKEB656.js → chunk-PR7XD2DI.js} +2 -2
  76. package/dist/bundle/{chunk-UPCEHSIZ.js → chunk-Q5C6YKAY.js} +21 -16
  77. package/dist/bundle/{chunk-EXWZCI5G.js → chunk-QBAOIMVB.js} +1 -1
  78. package/dist/bundle/{chunk-ULNN3LCY.js → chunk-RCTOWLCD.js} +44 -37
  79. package/dist/bundle/{chunk-7TNQZKRD.js → chunk-REM5WHHQ.js} +77 -76
  80. package/dist/bundle/{chunk-Y2QVNVHK.js → chunk-RHSBXOQM.js} +1 -1
  81. package/dist/bundle/{chunk-UYBLNGZ2.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-CRIEW4FP.js → chunk-T5D4OGDC.js} +2 -2
  85. package/dist/bundle/{chunk-MLSXHTUB.js → chunk-TGS5VPJD.js} +1228 -455
  86. package/dist/bundle/chunk-TNKQDS5A.js +335 -0
  87. package/dist/bundle/{chunk-DU23ET2O.js → chunk-VVN6GHAZ.js} +60 -81
  88. package/dist/bundle/{chunk-PWIEOATY.js → chunk-WJK6KTCS.js} +325 -14
  89. package/dist/bundle/{chunk-U52QE4QV.js → chunk-WWE5GO6G.js} +3 -3
  90. package/dist/bundle/{chunk-6HFZZ2PW.js → chunk-XOL346TJ.js} +2 -2
  91. package/dist/bundle/{chunk-ZAIE3G5I.js → chunk-XZBA6FVH.js} +3 -3
  92. package/dist/bundle/chunk-YCL3SK4T.js +1978 -0
  93. package/dist/bundle/{chunk-DIZBJLPM.js → chunk-YRUR3E3E.js} +68 -78
  94. package/dist/bundle/{chunk-EEE4H2PA.js → chunk-YZPE72GE.js} +12 -12
  95. package/dist/bundle/{chunk-F7KAMSXA.js → chunk-ZCXWV4XO.js} +4 -4
  96. package/dist/bundle/{chunk-NV75QPML.js → chunk-ZHZYGY5R.js} +4 -4
  97. package/dist/bundle/{cli-L7P36YUH.js → cli-K4D4DIGQ.js} +137 -88
  98. package/dist/bundle/command-contract-V3F452QI.js +43 -0
  99. package/dist/bundle/{command-server-entry-H3VGPOLJ.js → command-server-entry-WREK3QBB.js} +33 -31
  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-SDZA2SWG.js → echarts-WZ5RKFCX.js} +2 -2
  104. package/dist/bundle/{embed-WUKOASQG.js → embed-B2UCRZZR.js} +9 -9
  105. package/dist/bundle/{embedder-UBRAXRDZ.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-SQQ4BSNR.js → google-api-SAND2F7L.js} +70 -63
  112. package/dist/bundle/grants-PLNFYARD.js +118 -0
  113. package/dist/bundle/{identity-SRL6RSU2.js → identity-JVVGS4U6.js} +6 -6
  114. package/dist/bundle/{instructions-7T6JJIFS.js → instructions-JSMTSB22.js} +1 -1
  115. package/dist/bundle/{login-N243GGEE.js → login-6WG3YBDU.js} +78 -71
  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-BZDMUFTW.js → node-VJMVHOWD.js} +2 -2
  121. package/dist/bundle/{node-sqlite-SZQCCMV2.js → node-sqlite-DCNT3HVE.js} +10 -10
  122. package/dist/bundle/oauth-KCMNQ3ZP.js +22 -0
  123. package/dist/bundle/{open-RVTPKDA3.js → open-NFOEHVW7.js} +8 -8
  124. package/dist/bundle/{openai-6NN63BMH.js → openai-D47WY7EC.js} +32 -30
  125. package/dist/bundle/{process-756VBE7E.js → process-Q2FRU5VA.js} +1 -1
  126. package/dist/bundle/{program-B4QBJYB5.js → program-T2AJJQEM.js} +1327 -1329
  127. package/dist/bundle/{prompt-HGP2DSRW.js → prompt-YJSDABXN.js} +8 -8
  128. package/dist/bundle/{reasons-KSYP5VDJ.js → reasons-WEHPCSJX.js} +5 -5
  129. package/dist/bundle/{recognize-26SHB7HI.js → recognize-6OBEIEB3.js} +7 -7
  130. package/dist/bundle/{remote-Z4PWHZ5N.js → remote-3SL2QJ7T.js} +13 -13
  131. package/dist/bundle/{rerank-QHJZJK3Q.js → rerank-L6F5SLIB.js} +10 -10
  132. package/dist/bundle/{serve-MYJW5IEM.js → serve-GYSWIWH4.js} +12 -12
  133. package/dist/bundle/server-BI46BSRE.js +80 -0
  134. package/dist/bundle/{server-XFW3V7CR.js → server-GWWP3RIT.js} +62 -53
  135. package/dist/bundle/{services-IQG2RVTO.js → services-BDQBRXT5.js} +91 -51
  136. package/dist/bundle/{sqlite-runtime-X4GB5PBV.js → sqlite-runtime-ZSZGAUYB.js} +9 -9
  137. package/dist/bundle/{start-C6EXYXAL.js → start-BJ275RUK.js} +7 -7
  138. package/dist/bundle/{state-ATQK2X3W.js → state-HLNGFI2T.js} +9 -9
  139. package/dist/bundle/{store-QUBUPK6F.js → store-I43KZNJW.js} +35 -26
  140. package/dist/bundle/{store-MEHEUOJH.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/policy.d.ts +1 -1
  190. package/dist/policy.d.ts.map +1 -1
  191. package/dist/policy.js +3 -3
  192. package/dist/policy.js.map +1 -1
  193. package/dist/program.d.ts.map +1 -1
  194. package/dist/program.js +2 -3
  195. package/dist/program.js.map +1 -1
  196. package/dist/provider-json.d.ts.map +1 -1
  197. package/dist/provider-json.js +5 -5
  198. package/dist/provider-json.js.map +1 -1
  199. package/dist/reasons.d.ts.map +1 -1
  200. package/dist/reasons.js +0 -10
  201. package/dist/reasons.js.map +1 -1
  202. package/dist/version.d.ts +1 -1
  203. package/dist/version.js +1 -1
  204. package/package.json +3 -3
  205. package/dist/bundle/chunk-2UHQVRH2.js +0 -1235
  206. package/dist/bundle/chunk-AXYG2DDY.js +0 -4721
  207. package/dist/bundle/chunk-J5LXL435.js +0 -1316
  208. package/dist/bundle/chunk-R5FTCNLJ.js +0 -76
  209. package/dist/bundle/command-contract-EYFGMKIG.js +0 -41
  210. package/dist/bundle/decode-JEU6JWCV.js +0 -165
  211. package/dist/bundle/entry-C4NUQFTF.js +0 -25
  212. package/dist/bundle/first-run-PKHBS7B4.js +0 -30
  213. package/dist/bundle/first-screen-QOVOM4BF.js +0 -39
  214. package/dist/bundle/google-XXHSMTVK.js +0 -45
  215. package/dist/bundle/grants-2U4JVT6O.js +0 -111
  216. package/dist/bundle/oauth-CMAFXX6A.js +0 -22
  217. package/dist/bundle/server-HBZPIHDX.js +0 -74
  218. package/dist/bundle/store-maintenance-command-33ULVDWY.js +0 -65
  219. package/dist/bundle/tokens-A2GP4F34.js +0 -111
  220. package/dist/knowledge-query.d.ts +0 -77
  221. package/dist/knowledge-query.d.ts.map +0 -1
  222. package/dist/knowledge-query.js +0 -104
  223. package/dist/knowledge-query.js.map +0 -1
  224. package/dist/bundle/{chunk-XWBPP2HX.js → chunk-ZI3YTXSF.js} +0 -0
  225. 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-JZ3MT7IE.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-YUGTJBV3.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-RT5NT62B.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-DU23ET2O.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-7BXVI7XF.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,68 +128,76 @@ import {
143
128
  signInSteps,
144
129
  skillCommand,
145
130
  upgradeCommand
146
- } from "./chunk-UUQJVKPB.js";
147
- import "./chunk-EXWZCI5G.js";
148
- import "./chunk-TI2OANJZ.js";
149
- import "./chunk-ULNN3LCY.js";
150
- import "./chunk-CK2SQ2CE.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-7TNQZKRD.js";
154
- import "./chunk-Z5BMYI2V.js";
155
- import "./chunk-5G2BY4B6.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";
156
149
  import {
157
150
  LIST_QUERY_GUIDE,
151
+ RecipientList,
152
+ SendJournal,
158
153
  listQuery,
159
154
  nativeField,
155
+ newOperationId,
160
156
  queryHelp,
161
157
  queryTerms,
158
+ sendGuard,
162
159
  termField,
163
160
  typedQuery,
164
161
  unfilteredQuery,
165
162
  withQuery
166
- } from "./chunk-2UHQVRH2.js";
167
- import {
168
- RecipientList,
169
- SendJournal,
170
- newOperationId,
171
- sendGuard
172
- } from "./chunk-GTLXBAJV.js";
163
+ } from "./chunk-GAHIHE4K.js";
173
164
  import {
174
165
  columnName,
175
166
  modelGateway,
176
167
  readSpreadsheet
177
- } from "./chunk-Q6BD6RUH.js";
178
- import "./chunk-YYIWPH53.js";
179
- import "./chunk-QTRYJZL7.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";
180
174
  import "./chunk-HTQTIKWP.js";
181
- import "./chunk-QKY24RWV.js";
175
+ import "./chunk-5JTB4URG.js";
182
176
  import {
183
177
  latestVersion,
184
178
  runUpdate,
185
179
  updateNotice
186
- } from "./chunk-D4MVEOU2.js";
187
- import "./chunk-FIVFP53N.js";
188
- import "./chunk-EEE4H2PA.js";
189
- import "./chunk-NV75QPML.js";
190
- import "./chunk-U52QE4QV.js";
191
- import "./chunk-F7KAMSXA.js";
192
- import "./chunk-FAMXUI2X.js";
193
- import "./chunk-O7T3WGCV.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";
194
185
  import {
195
186
  applyDocumentTransfer,
196
187
  previewDocumentTransfer
197
- } from "./chunk-QRSPFCRY.js";
198
- import "./chunk-MWCPKUU4.js";
188
+ } from "./chunk-3CHW7JGR.js";
189
+ import "./chunk-IFTX7AQU.js";
199
190
  import "./chunk-5DPV7X27.js";
200
- import "./chunk-JMZQBRRZ.js";
201
- import "./chunk-PJ3FKBXG.js";
202
- import "./chunk-2VYEGKQ3.js";
203
- import "./chunk-ZSVMZH5O.js";
204
- import "./chunk-EOC7RHJ2.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";
205
196
  import {
197
+ CEILING_KEY,
206
198
  FETCH,
207
199
  InvalidArgumentError,
200
+ LEVELS,
208
201
  LOCAL_READ,
209
202
  LOCAL_WRITE,
210
203
  NO_EFFECTS,
@@ -219,102 +212,108 @@ import {
219
212
  fetchesOnly,
220
213
  flatten,
221
214
  grantsAuthority,
215
+ guardedWrite,
222
216
  hasSharedContract,
223
217
  itemOf,
224
218
  jsonlRecords,
219
+ layerPermissions,
220
+ levelFor,
225
221
  listOf,
226
222
  metaOf,
227
223
  outputFor,
228
224
  overrideSharedContract,
225
+ parseDuration,
229
226
  refuseCommandName,
230
227
  renderAnswer,
231
228
  resolveAISettings,
232
229
  rootOf,
233
230
  settingRows,
231
+ sharedCommand,
234
232
  sharedContracts,
235
233
  snakeKeys
236
- } from "./chunk-MLSXHTUB.js";
237
- import "./chunk-WUFZGPXX.js";
238
- import {
239
- CEILING_KEY,
240
- LEVELS,
241
- guardedWrite,
242
- layerPermissions,
243
- levelFor,
244
- parseDuration
245
- } from "./chunk-J5LXL435.js";
234
+ } from "./chunk-TGS5VPJD.js";
246
235
  import {
247
236
  modelTarget
248
- } from "./chunk-7A77GYCE.js";
249
- import {
250
- setupPermissionCeiling
251
- } from "./chunk-KPKIHJIT.js";
237
+ } from "./chunk-FYPW7NMH.js";
238
+ import "./chunk-54BQWRJL.js";
252
239
  import {
253
240
  readOnlyLockOf,
254
241
  readOnlyRefusal
255
- } from "./chunk-MOKEB656.js";
256
- import "./chunk-UIKVP23D.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";
257
248
  import {
258
249
  hostFetch
259
- } from "./chunk-6QR7NKMG.js";
260
- import "./chunk-IVOG6T6P.js";
261
- import "./chunk-5W65QTYS.js";
262
- import "./chunk-ZAIE3G5I.js";
263
- import "./chunk-PGPHEC2X.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";
264
257
  import {
265
258
  CATALOG_QUERY,
266
259
  IMPORTED_DOCUMENT_QUERY,
267
260
  openStore
268
- } from "./chunk-6WAC2LOS.js";
269
- import "./chunk-BXHFJTU5.js";
270
- import "./chunk-UFPRP7MG.js";
271
- import "./chunk-CVAJMRRD.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";
272
267
  import {
273
268
  FACT_STATUSES,
274
- FACT_TYPES,
275
269
  MEMORY_KINDS,
276
270
  MEMORY_SCOPES,
277
271
  MEMORY_STATUSES,
278
272
  inRun
279
- } from "./chunk-AXYG2DDY.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";
280
280
  import {
281
281
  defineQuery,
282
282
  parseLucene,
283
283
  queryError,
284
+ queryFieldsOf,
284
285
  timezoneOf,
285
286
  validateQuery,
286
287
  zonedMoment
287
- } from "./chunk-UPCEHSIZ.js";
288
- import "./chunk-QWGEOQHA.js";
289
- import "./chunk-UYBLNGZ2.js";
290
- import "./chunk-PWIEOATY.js";
291
- import "./chunk-QVJMFZFW.js";
288
+ } from "./chunk-Q5C6YKAY.js";
289
+ import "./chunk-WJK6KTCS.js";
290
+ import "./chunk-PAPY6Q6H.js";
292
291
  import "./chunk-D72URWJE.js";
293
292
  import {
294
293
  installerOf
295
- } from "./chunk-M4OP5ASJ.js";
294
+ } from "./chunk-66PL7P4C.js";
296
295
  import {
297
296
  DRIVE_APP,
298
297
  PACKAGE,
299
298
  VERSION
300
- } from "./chunk-6HFZZ2PW.js";
299
+ } from "./chunk-XOL346TJ.js";
301
300
  import {
302
301
  REASONS
303
- } from "./chunk-7JKECODO.js";
304
- import "./chunk-XWBPP2HX.js";
305
- import "./chunk-ZVQDOKDY.js";
302
+ } from "./chunk-ILAQIBEO.js";
303
+ import "./chunk-ZI3YTXSF.js";
304
+ import "./chunk-HK225DAG.js";
306
305
  import {
307
306
  storePath
308
- } from "./chunk-CRIEW4FP.js";
307
+ } from "./chunk-T5D4OGDC.js";
309
308
  import {
310
309
  processStreams,
311
310
  saveConfigFile,
312
311
  writeSecurely
313
- } from "./chunk-MW46BLWH.js";
314
- import "./chunk-PV3AWPHR.js";
312
+ } from "./chunk-HRATXUFH.js";
313
+ import "./chunk-SONPLYV7.js";
315
314
  import "./chunk-Y5E2WNWB.js";
316
- import "./chunk-HCZYJMBP.js";
317
- import "./chunk-5TK2YQCO.js";
315
+ import "./chunk-ABZ2NYDT.js";
316
+ import "./chunk-7IBENBCK.js";
318
317
  import {
319
318
  array,
320
319
  boolean,
@@ -337,11 +336,11 @@ import {
337
336
  string,
338
337
  unknown,
339
338
  writes
340
- } from "./chunk-JRFKCYMW.js";
339
+ } from "./chunk-HHAZ6DCY.js";
341
340
  import {
342
341
  CliError,
343
342
  isCliError
344
- } from "./chunk-EA2OB75T.js";
343
+ } from "./chunk-54NDYVZA.js";
345
344
  import {
346
345
  __commonJS,
347
346
  __name,
@@ -442,30 +441,30 @@ var require_polyfills = __commonJS({
442
441
  })(fs.rename);
443
442
  }
444
443
  fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
445
- function read(fd, buffer, offset2, length, position, callback_) {
444
+ function read(fd, buffer, offset, length, position, callback_) {
446
445
  var callback;
447
446
  if (callback_ && typeof callback_ === "function") {
448
447
  var eagCounter = 0;
449
448
  callback = /* @__PURE__ */ __name(function(er, _, __) {
450
449
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
451
450
  eagCounter++;
452
- return fs$read.call(fs, fd, buffer, offset2, length, position, callback);
451
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
453
452
  }
454
453
  callback_.apply(this, arguments);
455
454
  }, "callback");
456
455
  }
457
- return fs$read.call(fs, fd, buffer, offset2, length, position, callback);
456
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback);
458
457
  }
459
458
  __name(read, "read");
460
459
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
461
460
  return read;
462
461
  })(fs.read);
463
462
  fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
464
- return function(fd, buffer, offset2, length, position) {
463
+ return function(fd, buffer, offset, length, position) {
465
464
  var eagCounter = 0;
466
465
  while (true) {
467
466
  try {
468
- return fs$readSync.call(fs, fd, buffer, offset2, length, position);
467
+ return fs$readSync.call(fs, fd, buffer, offset, length, position);
469
468
  } catch (er) {
470
469
  if (er.code === "EAGAIN" && eagCounter < 10) {
471
470
  eagCounter++;
@@ -2180,7 +2179,7 @@ var profileLocked2 = /* @__PURE__ */ __name((env, name) => import_proper_lockfil
2180
2179
  var removal = {
2181
2180
  signOut: /* @__PURE__ */ __name(async (profile, { env, keyring, mayRevoke }) => {
2182
2181
  const storage = readConfig(env).profiles[profile]?.storage ?? "keyring";
2183
- const { sessionKeeper } = await import("./tokens-A2GP4F34.js");
2182
+ const { sessionKeeper } = await import("./tokens-DB7O7QNB.js");
2184
2183
  const { revoked } = await sessionKeeper({
2185
2184
  env,
2186
2185
  name: profile,
@@ -2201,74 +2200,322 @@ var installAccountCommands = /* @__PURE__ */ __name((program, _context) => {
2201
2200
  annotate(program.command("account"), { effects: LOCAL_READ }).description("remove this profile from this computer").addCommand(accountRemoveCommand(DRIVE_APP, removal, { resolveSettings: configuration.resolveSettings }));
2202
2201
  }, "installAccountCommands");
2203
2202
 
2204
- // dist/catalog.js
2205
- var catalogInput = /* @__PURE__ */ __name((file) => ({
2206
- externalId: `${file.id}.md`,
2207
- kind: file.mime === FOLDER ? "folder" : "file",
2208
- name: file.name,
2209
- parents: file.parents.map((id) => `${id}.md`),
2210
- url: file.url,
2211
- mime: file.mime,
2212
- size: file.size,
2213
- createdAt: file.createdAt,
2214
- modifiedAt: file.modifiedAt,
2215
- description: file.description,
2216
- actors: [
2217
- ...(file.owners ?? []).map((actor) => ({ ...actor, role: "owner" })),
2218
- ...file.lastModifiedBy ? [{ ...file.lastModifiedBy, role: "editor" }] : []
2219
- ],
2220
- metadata: file.providerMetadata ?? file,
2221
- frontMatter: {
2222
- source: "google-drive",
2223
- sourceUrl: file.url,
2224
- fileId: file.id,
2225
- mime: file.mime,
2226
- owners: file.owners ?? [],
2227
- lastModifiedBy: file.lastModifiedBy ?? null
2228
- }
2229
- }), "catalogInput");
2230
- 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) => {
2231
2456
  if (!Number.isSafeInteger(depth) || depth < 0 || depth > 50)
2232
2457
  throw new CliError("validation_error", "tree depth must be between 0 and 50", { reason: "catalog.depth-invalid" });
2233
- const byId = new Map(entries.map((entry) => [entry.externalId, entry]));
2234
- const children = /* @__PURE__ */ new Map();
2235
- for (const entry of entries)
2236
- for (const parent of entry.parents) {
2237
- const list = children.get(parent) ?? [];
2238
- list.push(entry);
2239
- 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;
2240
2473
  }
2241
- let count = 0;
2242
- const node = /* @__PURE__ */ __name((item, level, ancestors) => {
2243
- if (ancestors.has(item.externalId))
2474
+ }, "childrenOf");
2475
+ const node = /* @__PURE__ */ __name(async (entry, level, ancestors) => {
2476
+ if (ancestors.has(entry.externalId))
2244
2477
  throw new CliError("invalid_response", "local folder ancestry contains a cycle", { reason: "catalog.cycle" });
2245
- if (++count > 1e4)
2246
- throw new CliError("validation_error", "tree output exceeds 10000 nodes; choose a smaller folder", {
2247
- reason: "catalog.tree-limit"
2248
- });
2249
- const found = children.get(item.externalId) ?? [];
2250
- const next = /* @__PURE__ */ new Set([...ancestors, item.externalId]);
2251
- return {
2478
+ if (++nodes > limit)
2479
+ throw tooLarge(limit);
2480
+ const tree = {
2252
2481
  item: {
2253
- id: catalogId(item),
2254
- ref: item.ref,
2255
- name: item.name,
2256
- kind: item.kind,
2257
- url: item.url,
2258
- content: item.content
2259
- },
2260
- children: level >= depth ? [] : found.map((child) => node(child, level + 1, next)),
2261
- 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
2262
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;
2263
2504
  }, "node");
2264
- return roots2.map((id) => {
2265
- const entry = byId.get(id);
2266
- if (entry?.kind !== "folder")
2267
- 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", {
2268
2510
  reason: "catalog.not-found"
2269
2511
  });
2270
- 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]);
2271
2517
  });
2518
+ return trees;
2272
2519
  }, "catalogTree");
2273
2520
  var catalogId = /* @__PURE__ */ __name((entry) => entry.externalId.replace(/\.md$/, ""), "catalogId");
2274
2521
  var catalogOutput = /* @__PURE__ */ __name((entry) => ({
@@ -2307,116 +2554,64 @@ var CATALOG_FIELDS = Object.keys({
2307
2554
  active: true,
2308
2555
  content: true
2309
2556
  });
2310
-
2311
- // dist/output.js
2312
- var VERBATIM = /* @__PURE__ */ new Set([
2313
- "frontMatter",
2314
- "front_matter",
2315
- "provider_metadata",
2316
- "metadata",
2317
- "headers",
2318
- "properties",
2319
- "appProperties",
2320
- "app_properties",
2321
- "request_schema",
2322
- "response_schema",
2323
- "body_schema",
2324
- "schema",
2325
- "inputSchema",
2326
- "input_schema",
2327
- "outputSchema",
2328
- "output_schema"
2329
- ]);
2330
- var RECORDS = /* @__PURE__ */ new Set(["profiles", "permissions", "models"]);
2331
- 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");
2332
- var snakeKeys2 = /* @__PURE__ */ __name((value, record2 = false) => {
2333
- if (Array.isArray(value))
2334
- return value.map((item) => snakeKeys2(item));
2335
- if (!value || typeof value !== "object" || value instanceof Date)
2336
- return value;
2337
- return Object.fromEntries(Object.entries(value).map(([key, item]) => [
2338
- record2 ? key : keyOf(key),
2339
- VERBATIM.has(key) ? item : snakeKeys2(item, RECORDS.has(key))
2340
- ]));
2341
- }, "snakeKeys");
2342
- var allOf = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false }), "allOf");
2343
-
2344
- // dist/commands/catalog.js
2345
2557
  var local = /* @__PURE__ */ __name((command, mutates = false) => annotate(command, { effects: mutates ? LOCAL_WRITE : LOCAL_READ }), "local");
2346
- var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
2347
- const { env, selected, output, positive: positive2, offset: offset2, withIndex } = helpers;
2348
- const catalog = local(program.command("catalog")).description("browse stored Drive files and folders offline");
2349
- const run3 = /* @__PURE__ */ __name(async (fn, write = false) => {
2350
- const profile = activeProfile(env, selected());
2351
- return withIndex(async (index) => {
2352
- const lock = write ? await lockProfile(env, selected()) : void 0;
2353
- try {
2354
- if (!index.catalog)
2355
- throw new CliError("configuration_error", "index has no shared catalog adapter", {
2356
- reason: "catalog.unavailable"
2357
- });
2358
- lock?.assertHeld();
2359
- const value = await fn({ ...index, catalog: index.catalog }, profile.principal);
2360
- lock?.assertHeld();
2361
- return value;
2362
- } finally {
2363
- await lock?.release();
2364
- }
2365
- });
2366
- }, "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");
2367
2572
  const entry = /* @__PURE__ */ __name(async (index, principal, id) => {
2368
- const found = await index.catalog?.get(principal, fileId(id));
2573
+ const found = await index.catalog?.get(principal, helpers.id(id));
2369
2574
  if (!found)
2370
2575
  throw new CliError("not_found", "file or folder is not in the active local catalog; run catalog import or sync", {
2371
2576
  reason: "catalog.not-found"
2372
2577
  });
2373
2578
  return found;
2374
2579
  }, "entry");
2375
- 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) => {
2376
- const state = readState(env, selected(), principal);
2377
- return index.catalog.import(principal, catalogFiles(state, activeProfile(env, selected()).roots));
2378
- }, true))));
2379
- examples(annotate(local(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
2380
- output: { entity: "document", view: "drive_catalog" }
2381
- }), ["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))))));
2382
- const list = /* @__PURE__ */ __name(async (words, args, search) => {
2383
- 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;
2384
2586
  const result = await run3((index, principal) => index.catalog.list(principal, { ast, limit: args.limit, offset: (args.page - 1) * args.limit }));
2385
2587
  output(listOf(`catalog ${search ? "search" : "list"}`, {
2386
2588
  items: result.items.map(catalogOutput),
2387
2589
  limit: args.limit,
2388
2590
  has_more: result.hasMore,
2389
2591
  page: args.page,
2390
- args: { query: words.length ? words.join(" ") : void 0 }
2592
+ args: { query: terms.length ? terms.join(" ") : void 0 }
2391
2593
  }));
2392
2594
  }, "list");
2393
2595
  for (const action of ["list", "search"]) {
2394
- 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")), [
2395
- action === "list" ? 'drive personal catalog list "parent:FOLDER_ID AND kind:file" --offline' : 'drive personal catalog search "budget AND person:Rin*" --offline'
2396
- ]).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"));
2397
- 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 } });
2398
2600
  }
2399
- 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) => {
2400
- const items = [];
2401
- for (let skip = 0; skip < 1e4; skip += 1e3) {
2402
- const page = await index.catalog.list(principal, { limit: 1e3, offset: skip });
2403
- for (const item of page.items)
2404
- items.push(item);
2405
- if (!page.hasMore)
2406
- break;
2407
- }
2408
- const roots2 = id ? [fileId(id)] : activeProfile(env, selected()).roots;
2409
- 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);
2410
2605
  })));
2411
2606
  const tags = local(catalog.command("tags")).description("add owner tags to cached files or folders");
2412
2607
  for (const action of ["list", "add", "remove"]) {
2413
- 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);
2414
2609
  if (action === "list")
2415
- bindQuery(command, TAGS_QUERY, tagRow);
2610
+ bindQuery2(command, queries.tags, tagRow);
2416
2611
  else
2417
2612
  command.argument("<tags...>", "local tag names");
2418
2613
  command.action(async (id, values2 = []) => {
2419
- 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;
2420
2615
  return output(allOf(await run3(async (index, principal) => {
2421
2616
  const found = await entry(index, principal, id);
2422
2617
  if (!index.knowledge)
@@ -2426,7 +2621,550 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
2426
2621
  }, action !== "list")));
2427
2622
  });
2428
2623
  }
2429
- }, "installCatalogCommands");
2624
+ }, "addDocumentCatalogCommandsDefinition");
2625
+ var addDocumentCatalogCommands = honoursDryRun(sharedCommand(addDocumentCatalogCommandsDefinition));
2626
+
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");
2430
3168
 
2431
3169
  // dist/commands/config.js
2432
3170
  import { join as join4 } from "node:path";
@@ -2494,11 +3232,11 @@ var refuseUnderReadOnly = /* @__PURE__ */ __name((env, what) => {
2494
3232
  }, "refuseUnderReadOnly");
2495
3233
  var checkPolicy = /* @__PURE__ */ __name(async (env, profile, key, mutates, flags = {}, ask) => {
2496
3234
  const { levels, readOnly, lock } = policySettings(env, profile, flags);
2497
- const { level, key: named } = levelFor(levels, key, DEFAULT_LEVELS);
3235
+ const { level } = levelFor(levels, key, DEFAULT_LEVELS);
2498
3236
  if (mutates && lock)
2499
3237
  throw readOnlyRefusal(lock, "change local or Google data");
2500
- const answerOnly = flags.fetches === true && flags.readOnly !== true && named === CEILING_KEY;
2501
- if (level === "deny" || mutates && !answerOnly && (readOnly || level === "readonly"))
3238
+ const fetchOnly = flags.fetches === true && flags.readOnly !== true;
3239
+ if (level === "deny" || mutates && !fetchOnly && (readOnly || level === "readonly"))
2502
3240
  throw new CliError("permission_error", "profile policy refuses this operation", {
2503
3241
  reason: "policy.denied",
2504
3242
  permission: key
@@ -2696,7 +3434,7 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2696
3434
  const download = /* @__PURE__ */ __name(async (kind, id, acceptTerms) => {
2697
3435
  if (policyFlags().offline)
2698
3436
  throw offlineRefused("downloading a model needs the network");
2699
- const { downloadImageModel, downloadTextModel } = await import("./services-IQG2RVTO.js");
3437
+ const { downloadImageModel, downloadTextModel } = await import("./services-BDQBRXT5.js");
2700
3438
  const progress = /* @__PURE__ */ __name((line) => {
2701
3439
  if (!program.opts().quiet)
2702
3440
  streams.diagnostic(line);
@@ -2729,24 +3467,8 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
2729
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));
2730
3468
  }, "installModelCommands");
2731
3469
 
2732
- // dist/commands/context.js
2733
- var positive = /* @__PURE__ */ __name((input) => {
2734
- const n = Number(input);
2735
- if (!Number.isSafeInteger(n) || n < 1)
2736
- throw new InvalidArgumentError("use a positive integer");
2737
- return n;
2738
- }, "positive");
2739
- var offset = /* @__PURE__ */ __name((input) => {
2740
- const n = Number(input);
2741
- if (!Number.isSafeInteger(n) || n < 0)
2742
- throw new InvalidArgumentError("use a nonnegative integer");
2743
- return n;
2744
- }, "offset");
2745
-
2746
3470
  // dist/contract-overrides.js
2747
3471
  import { createHash } from "node:crypto";
2748
- var NOTES_REASON = "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.";
2749
- var SEARCH_REASON = "Drive searches imported documents and embeddings rather than live messenger messages; its default action and pagination are explicitly provider-specific.";
2750
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");
2751
3473
  var fingerprint = /* @__PURE__ */ __name((value) => createHash("sha256").update(JSON.stringify(canonical(value ?? null))).digest("hex").slice(0, 16), "fingerprint");
2752
3474
  var reviewedOverrides = /* @__PURE__ */ __name((reference, reviewed) => reviewed.map((override) => {
@@ -2757,248 +3479,6 @@ var reviewedOverrides = /* @__PURE__ */ __name((reference, reviewed) => reviewed
2757
3479
  return { ...override, before: fingerprint(before) === override.before ? before : override.before };
2758
3480
  }), "reviewedOverrides");
2759
3481
  var SHELL_OVERRIDES = {
2760
- notes: [
2761
- {
2762
- command: ["notes"],
2763
- field: "description",
2764
- before: "073d38b6d7256579",
2765
- after: "write notes about an imported document",
2766
- reason: NOTES_REASON
2767
- },
2768
- {
2769
- command: ["notes"],
2770
- field: "effects",
2771
- before: "b98c7b06ed808dfb",
2772
- after: { remote: "none", local: "read" },
2773
- reason: NOTES_REASON
2774
- },
2775
- {
2776
- command: ["notes"],
2777
- field: "children",
2778
- before: "6cfec8425c19582f",
2779
- after: ["add", "list", "show", "edit", "remove"],
2780
- reason: NOTES_REASON
2781
- },
2782
- {
2783
- command: ["notes", "add"],
2784
- field: "description",
2785
- before: "98b319044cba6b7f",
2786
- after: "write a note about a document",
2787
- reason: NOTES_REASON
2788
- },
2789
- {
2790
- command: ["notes", "add"],
2791
- field: "arguments",
2792
- before: "d5010f078464b8d0",
2793
- after: [
2794
- {
2795
- name: "document",
2796
- required: true,
2797
- variadic: false,
2798
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2799
- },
2800
- { name: "text", required: true, variadic: false, description: "the note's text" }
2801
- ],
2802
- reason: NOTES_REASON
2803
- },
2804
- {
2805
- command: ["notes", "add"],
2806
- field: "options",
2807
- before: "213adb539c248d7f",
2808
- after: [{ flags: "--title <title>", description: "a title for the note", takes_value: true, mandatory: false }],
2809
- reason: NOTES_REASON
2810
- },
2811
- {
2812
- command: ["notes", "add"],
2813
- field: "examples",
2814
- before: "74234e98afe7498f",
2815
- after: ['drive personal notes add DOC_ID "Check the numbers" --title Review'],
2816
- reason: NOTES_REASON
2817
- },
2818
- {
2819
- command: ["notes", "list"],
2820
- field: "description",
2821
- before: "6b866a022b5e84ce",
2822
- after: "list a document's notes",
2823
- reason: NOTES_REASON
2824
- },
2825
- {
2826
- command: ["notes", "list"],
2827
- field: "query",
2828
- before: "0b0517429a4f9613",
2829
- after: {
2830
- entity: "note",
2831
- backend: "native",
2832
- fields: [
2833
- { name: "ref", type: "ref", operators: ["term", "phrase"], example: 'ref:"note:42"' },
2834
- { name: "kind", type: "enum", values: ["note", "document"], operators: ["term"], example: "kind:note" },
2835
- { name: "provider", type: "kw", operators: ["term", "phrase", "wildcard"], example: "provider:abc" },
2836
- { name: "account", type: "kw", operators: ["term", "phrase", "wildcard"], example: "account:abc" },
2837
- { name: "url", type: "kw", operators: ["term", "phrase", "wildcard"], example: "url:abc" },
2838
- { name: "id", type: "kw", operators: ["term", "phrase", "wildcard"], example: "id:abc" },
2839
- { name: "source", type: "enum", values: ["file", "internal"], operators: ["term"], example: "source:file" },
2840
- { name: "folder_id", type: "kw", operators: ["term", "phrase", "wildcard"], example: "folder_id:abc" },
2841
- { name: "path", type: "kw", operators: ["term", "phrase", "wildcard"], example: "path:abc" },
2842
- { name: "title", type: "kw", operators: ["term", "phrase", "wildcard"], example: "title:abc" },
2843
- { name: "text", type: "kw", operators: ["term", "phrase"], example: "text:review", native: true },
2844
- { name: "revision", type: "num", operators: ["term", "range"], example: "revision>0" },
2845
- { name: "content_hash", type: "kw", operators: ["term", "phrase", "wildcard"], example: "content_hash:abc" },
2846
- { name: "export_path", type: "kw", operators: ["term", "phrase", "wildcard"], example: "export_path:abc" },
2847
- { name: "created_at", type: "time", operators: ["term", "range"], example: "created_at>=7d" },
2848
- { name: "updated_at", type: "time", operators: ["term", "range"], example: "updated_at>=7d" },
2849
- { name: "deleted_at", type: "time", operators: ["term", "range"], example: "deleted_at>=7d" },
2850
- { name: "tags", type: "kw", operators: ["term", "phrase", "wildcard"], example: "tags:abc" },
2851
- { name: "excerpt", type: "kw", operators: ["term", "phrase", "wildcard"], example: "excerpt:abc" },
2852
- {
2853
- name: "found_by",
2854
- type: "enum",
2855
- values: ["title", "words", "meaning"],
2856
- operators: ["term"],
2857
- example: "found_by:title"
2858
- }
2859
- ]
2860
- },
2861
- reason: NOTES_REASON
2862
- },
2863
- {
2864
- command: ["notes", "list"],
2865
- field: "arguments",
2866
- before: "350998d1fcef909c",
2867
- after: [
2868
- {
2869
- name: "document",
2870
- required: true,
2871
- variadic: false,
2872
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2873
- },
2874
- {
2875
- name: "query",
2876
- required: false,
2877
- variadic: true,
2878
- description: "field:value terms that narrow the list \u2014 the fields are below"
2879
- }
2880
- ],
2881
- reason: NOTES_REASON
2882
- },
2883
- {
2884
- command: ["notes", "list"],
2885
- field: "options",
2886
- before: "4f53cda18c2baa0c",
2887
- after: [
2888
- {
2889
- flags: "--limit <n>",
2890
- description: "how many notes to return",
2891
- takes_value: true,
2892
- mandatory: false,
2893
- default: 50
2894
- },
2895
- { flags: "--page <n>", description: "which page to return", takes_value: true, mandatory: false, default: 1 }
2896
- ],
2897
- reason: NOTES_REASON
2898
- },
2899
- {
2900
- command: ["notes", "list"],
2901
- field: "examples",
2902
- before: "74234e98afe7498f",
2903
- after: ["drive personal notes list DOC_ID", "drive personal notes list DOC_ID text:review --limit 10"],
2904
- reason: NOTES_REASON
2905
- },
2906
- {
2907
- command: ["notes", "show"],
2908
- field: "arguments",
2909
- before: "ae549d47fb4ad5ab",
2910
- after: [
2911
- {
2912
- name: "document",
2913
- required: true,
2914
- variadic: false,
2915
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2916
- },
2917
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" }
2918
- ],
2919
- reason: NOTES_REASON
2920
- },
2921
- {
2922
- command: ["notes", "show"],
2923
- field: "examples",
2924
- before: "74234e98afe7498f",
2925
- after: ["drive personal notes show DOC_ID note:NOTE_ID"],
2926
- reason: NOTES_REASON
2927
- },
2928
- {
2929
- command: ["notes", "edit"],
2930
- field: "description",
2931
- before: "e67289f2731a50ff",
2932
- after: "replace a note's text",
2933
- reason: NOTES_REASON
2934
- },
2935
- {
2936
- command: ["notes", "edit"],
2937
- field: "arguments",
2938
- before: "c7d2686d3041bb14",
2939
- after: [
2940
- {
2941
- name: "document",
2942
- required: true,
2943
- variadic: false,
2944
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2945
- },
2946
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" },
2947
- { name: "text", required: true, variadic: false, description: "the note's new text" }
2948
- ],
2949
- reason: NOTES_REASON
2950
- },
2951
- {
2952
- command: ["notes", "edit"],
2953
- field: "options",
2954
- before: "4f53cda18c2baa0c",
2955
- after: [
2956
- {
2957
- flags: "--revision <n>",
2958
- description: "revision from notes show; a newer note is not overwritten",
2959
- takes_value: true,
2960
- mandatory: true
2961
- }
2962
- ],
2963
- reason: NOTES_REASON
2964
- },
2965
- {
2966
- command: ["notes", "edit"],
2967
- field: "examples",
2968
- before: "74234e98afe7498f",
2969
- after: ['drive personal notes edit DOC_ID note:NOTE_ID "Numbers checked" --revision 2'],
2970
- reason: NOTES_REASON
2971
- },
2972
- {
2973
- command: ["notes", "remove"],
2974
- field: "description",
2975
- before: "aa644f1603858b41",
2976
- after: "delete one note",
2977
- reason: NOTES_REASON
2978
- },
2979
- {
2980
- command: ["notes", "remove"],
2981
- field: "arguments",
2982
- before: "ae549d47fb4ad5ab",
2983
- after: [
2984
- {
2985
- name: "document",
2986
- required: true,
2987
- variadic: false,
2988
- description: "Google file or folder id or URL in the local catalog, or a document:<n> ref"
2989
- },
2990
- { name: "note", required: true, variadic: false, description: "note:<id> reference, as notes list prints it" }
2991
- ],
2992
- reason: NOTES_REASON
2993
- },
2994
- {
2995
- command: ["notes", "remove"],
2996
- field: "examples",
2997
- before: "74234e98afe7498f",
2998
- after: ["drive personal notes remove DOC_ID note:NOTE_ID"],
2999
- reason: NOTES_REASON
3000
- }
3001
- ],
3002
3482
  commands: [
3003
3483
  {
3004
3484
  command: ["commands"],
@@ -3035,79 +3515,6 @@ var SHELL_OVERRIDES = {
3035
3515
  ],
3036
3516
  reason: "Drive binds discovery to its profile-aware usage renderer while retaining the shared command document and evidence endpoint."
3037
3517
  }
3038
- ],
3039
- search: [
3040
- {
3041
- command: ["search"],
3042
- field: "summary",
3043
- before: "d8f6dac5b4fe912b",
3044
- after: null,
3045
- reason: SEARCH_REASON
3046
- },
3047
- {
3048
- command: ["search"],
3049
- field: "description",
3050
- before: "600ae3fd56e9ef36",
3051
- after: "search imported documents by words, and by meaning when indexed",
3052
- reason: SEARCH_REASON
3053
- },
3054
- {
3055
- command: ["search"],
3056
- field: "arguments",
3057
- before: "4f53cda18c2baa0c",
3058
- after: [
3059
- {
3060
- name: "query",
3061
- required: true,
3062
- variadic: false,
3063
- description: "words to look for, and fields such as tag: and date: that every hit must match"
3064
- }
3065
- ],
3066
- reason: SEARCH_REASON
3067
- },
3068
- {
3069
- command: ["search"],
3070
- field: "options",
3071
- before: "4f53cda18c2baa0c",
3072
- after: [
3073
- {
3074
- flags: "--limit <n>",
3075
- description: "how many results to return",
3076
- takes_value: true,
3077
- mandatory: false,
3078
- default: 20
3079
- },
3080
- { flags: "--page <n>", description: "which page to return", takes_value: true, mandatory: false, default: 1 },
3081
- {
3082
- flags: "--exact",
3083
- description: "match the words exactly: no word forms, no meaning",
3084
- takes_value: false,
3085
- mandatory: false
3086
- }
3087
- ],
3088
- reason: SEARCH_REASON
3089
- },
3090
- {
3091
- command: ["search"],
3092
- field: "children",
3093
- before: "595cc576273270f2",
3094
- after: [],
3095
- reason: SEARCH_REASON
3096
- },
3097
- {
3098
- command: ["search"],
3099
- field: "effects",
3100
- before: "74234e98afe7498f",
3101
- after: { remote: "none", local: "read" },
3102
- reason: SEARCH_REASON
3103
- },
3104
- {
3105
- command: ["search"],
3106
- field: "examples",
3107
- before: "74234e98afe7498f",
3108
- after: ["drive personal search budget", 'drive personal search "quarterly plan" --exact --limit 5'],
3109
- reason: SEARCH_REASON
3110
- }
3111
3518
  ]
3112
3519
  };
3113
3520
 
@@ -3143,46 +3550,6 @@ var installCommandsCommand = /* @__PURE__ */ __name((...args) => {
3143
3550
  }, reviewedOverrides(reference, SHELL_OVERRIDES.commands));
3144
3551
  }, "installCommandsCommand");
3145
3552
 
3146
- // dist/commands/documents.js
3147
- import { writeFileSync } from "node:fs";
3148
-
3149
- // dist/age.js
3150
- var DAY = 24 * 60 * 60 * 1e3;
3151
- var SYNC = defineSteps([
3152
- { id: "sync.run", command: "sync", args: [], why: "copy the changes Google has made into the local store" }
3153
- ])[0];
3154
- var ageOf = /* @__PURE__ */ __name((state, now = Date.now()) => {
3155
- const at = state.lastSync ? Date.parse(state.lastSync) : Number.NaN;
3156
- 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)) };
3157
- }, "ageOf");
3158
- var staleCopy = /* @__PURE__ */ __name((state, now = Date.now()) => {
3159
- const { synced_at, age_days } = ageOf(state, now);
3160
- const old = synced_at === null || now - Date.parse(synced_at) > DAY;
3161
- if (!old)
3162
- return {};
3163
- 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`;
3164
- return {
3165
- missing: [{ field: "synced_at", why, step: SYNC.id }],
3166
- next: [stepOf(SYNC)],
3167
- meta: { complete: false }
3168
- };
3169
- }, "staleCopy");
3170
- var freshness = /* @__PURE__ */ __name((remote, local2) => ({
3171
- changed: local2 === void 0 || Date.parse(remote) !== Date.parse(local2),
3172
- remote_modified_at: remote,
3173
- local_modified_at: local2 ?? null
3174
- }), "freshness");
3175
- var changedCopy = /* @__PURE__ */ __name(({ changed, local_modified_at }) => {
3176
- if (!changed)
3177
- return {};
3178
- 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})`;
3179
- return {
3180
- missing: [{ field: "modified_at", why, step: SYNC.id }],
3181
- next: [stepOf(SYNC)],
3182
- meta: { complete: false }
3183
- };
3184
- }, "changedCopy");
3185
-
3186
3553
  // dist/documents-add.js
3187
3554
  var PASSES_ON = /* @__PURE__ */ new Set(["not_found", "permission_error", "authentication_error"]);
3188
3555
  var HOW = "drive <profile> documents add <url>, or --profiles <a,b|all>";
@@ -3314,66 +3681,36 @@ var addProfilesOf = /* @__PURE__ */ __name((env, command, word) => profilesToAdd
3314
3681
  option: command.opts().profiles,
3315
3682
  word,
3316
3683
  chosen: env.DRIVE_PROFILE || void 0,
3317
- lock: env.DRIVE_PROFILE_LOCK || void 0
3318
- }), "addProfilesOf");
3319
- var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
3320
- const { env, selected, output, withIndex, source, profileWord } = context;
3321
- const imported = importedDocument(context);
3322
- const documents = annotate(program.command("documents"), { effects: LOCAL_READ }).description("read imported documents and Google Docs");
3323
- const documentArgument = "document id, Google Docs URL, or a search hit's document: ref";
3324
- annotate(withQuery(examples(annotate(documents.command("list"), { effects: LOCAL_READ }).description("list imported documents with their Google URLs"), [
3325
- "drive personal documents list",
3326
- "drive personal documents list tag:budget",
3327
- "drive personal documents list person:PERSON_UID --limit 10"
3328
- ]), 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 }) => {
3329
- const profile = activeProfile(env, selected());
3330
- const query = typedQuery(words);
3331
- const ast = listQuery(query, IMPORTED_DOCUMENT_QUERY, "documents list");
3332
- const found = await withIndex(async (index) => {
3333
- if (!index.knowledge)
3334
- throw new CliError("configuration_error", "index has no shared knowledge adapter");
3335
- return index.knowledge.documents(profile.principal, ast, { limit, offset: (page - 1) * limit });
3336
- });
3337
- const state = readState(env, selected(), profile.principal);
3338
- const age = ageOf(state);
3339
- output(listOf("documents list", {
3340
- ...staleCopy(state),
3341
- items: found.items.map((note) => {
3342
- const id = (note.path ?? "").replace(/\.md$/, "");
3343
- const doc = state.documents[id];
3344
- return doc ? { ...metadataJson(doc.metadata), reference: doc.reference, tabs: doc.tabs, ...age } : { id, name: note.title, reference: note.ref, tabs: 0, ...age };
3345
- }),
3346
- limit,
3347
- has_more: found.hasMore,
3348
- page,
3349
- args: { query: query || void 0 }
3350
- }));
3351
- });
3352
- 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) => {
3353
- const { snapshot } = imported(input);
3354
- const state = readState(env, selected(), activeProfile(env, selected()).principal);
3355
- output(itemOf({
3356
- metadata: metadataJson(snapshot.metadata),
3357
- ...ageOf(state),
3358
- text: snapshot.text,
3359
- tabs: snapshot.tabs,
3360
- ...snapshot.notRead ? { not_read: snapshot.notRead } : {}
3361
- }, staleCopy(state)));
3362
- });
3363
- 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) => {
3364
- const { id, snapshot } = imported(input);
3365
- try {
3366
- writeFileSync(args.output, snapshot.markdown, { flag: "wx", mode: 384 });
3367
- } catch (error) {
3368
- if (error.code === "EEXIST")
3369
- throw new CliError("validation_error", "the output file already exists; choose another --output", {
3370
- reason: "export.exists",
3371
- param: "--output"
3372
- });
3373
- throw error;
3374
- }
3375
- const state = readState(env, selected(), activeProfile(env, selected()).principal);
3376
- 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")
3377
3714
  });
3378
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"), [
3379
3716
  "drive documents add https://docs.google.com/document/d/DOC_ID/edit --profiles work,personal",
@@ -3490,348 +3827,99 @@ var roots = /* @__PURE__ */ __name(async (call, added) => {
3490
3827
  if (!myDrive.id)
3491
3828
  throw new CliError("invalid_response", "Google did not return the My Drive folder");
3492
3829
  const { rows: drives } = await everyPage(call, "drive.drives.list", { pageSize: 100, fields: "nextPageToken,drives(id,name)" }, "drives");
3493
- const shared = drives.flatMap((drive) => drive.id ? [{ id: drive.id, name: drive.name ?? "" }] : []);
3494
- const counts = await childCounts(call, [myDrive.id, ...shared.map((drive) => drive.id)]);
3495
- const top = /* @__PURE__ */ __name((id, name, kind) => ({
3496
- id,
3497
- name,
3498
- kind,
3499
- parent: null,
3500
- location: kind,
3501
- drive_id: kind === "shared_drive" ? id : null,
3502
- child_folders: kind === "shared_with_me" ? null : counts?.get(id) ?? null,
3503
- added: added(id) || kind === "my_drive" && added("root")
3504
- }), "top");
3505
- return listed([
3506
- top(myDrive.id, "My Drive", "my_drive"),
3507
- top(SHARED_WITH_ME, "Shared with me", "shared_with_me"),
3508
- ...shared.map((drive) => top(drive.id, drive.name, "shared_drive")).sort(byName)
3509
- ], false);
3510
- }, "roots");
3511
- var browseFolders = /* @__PURE__ */ __name(async (call, parent, selected) => {
3512
- const added = /* @__PURE__ */ __name((id) => selected.includes(id), "added");
3513
- if (parent === void 0)
3514
- return roots(call, added);
3515
- const { rows, incomplete } = await everyPage(call, "drive.files.list", {
3516
- q: parent === SHARED_WITH_ME ? `sharedWithMe = true and ${NOT_TRASHED_FOLDER}` : `'${parent}' in parents and ${NOT_TRASHED_FOLDER}`,
3517
- fields: "nextPageToken,incompleteSearch,files(id,name,driveId,ownedByMe)",
3518
- pageSize: 1e3,
3519
- ...ACROSS_DRIVES
3520
- }, "files");
3521
- const folders = rows.filter((row) => Boolean(row.id));
3522
- const counts = await childCounts(call, folders.map((folder) => folder.id));
3523
- const items = folders.map((folder) => ({
3524
- id: folder.id,
3525
- name: folder.name ?? "",
3526
- kind: "folder",
3527
- parent,
3528
- location: folder.driveId ? "shared_drive" : folder.ownedByMe === false ? "shared_with_me" : "my_drive",
3529
- drive_id: folder.driveId ?? null,
3530
- child_folders: counts?.get(folder.id) ?? null,
3531
- added: added(folder.id)
3532
- }));
3533
- return listed(items.sort(byName), incomplete);
3534
- }, "browseFolders");
3535
-
3536
- // dist/commands/folders.js
3537
- var installFolderCommands = /* @__PURE__ */ __name((program, context, call) => {
3538
- const { env, selected, output, source } = context;
3539
- const folders = annotate(program.command("folders"), { effects: LOCAL_READ }).description("choose the Google Drive folders that sync imports");
3540
- const folderArgument = "folder id or Google Drive URL";
3541
- 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) => {
3542
- const id = fileId(input);
3543
- const config = readConfig(env);
3544
- const name = selected();
3545
- const profile = activeProfile(env, name);
3546
- const metadata = await (await source()).metadata(id);
3547
- if (metadata.mime !== FOLDER || metadata.trashed)
3548
- throw new CliError("validation_error", "source is not an accessible Google folder");
3549
- if (!profile.roots.includes(metadata.id))
3550
- profile.roots.push(metadata.id);
3551
- config.profiles[name] = profile;
3552
- writeConfig(env, config);
3553
- output(itemOf({ id: metadata.id, name: metadata.name, added: true }));
3554
- });
3555
- 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) => {
3556
- const filter = termsOf(words, FOLDERS_QUERY, "folders list");
3557
- output(allOf(selectedFolders(env, selected(), filter)));
3558
- });
3559
- 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), [
3560
- "drive personal folders browse",
3561
- "drive personal folders browse --parent FOLDER_ID --json",
3562
- `drive personal folders browse --parent ${SHARED_WITH_ME}`
3563
- ]).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) => {
3564
- const parent = args.parent === void 0 || args.parent === SHARED_WITH_ME ? args.parent : fileId(args.parent);
3565
- const roots2 = activeProfile(env, selected()).roots;
3566
- output(await browseFolders(call, parent, roots2));
3567
- });
3568
- 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) => {
3569
- const id = fileId(input);
3570
- const config = readConfig(env);
3571
- const name = selected();
3572
- const profile = activeProfile(env, name);
3573
- profile.roots = profile.roots.filter((root) => root !== id);
3574
- config.profiles[name] = profile;
3575
- writeConfig(env, config);
3576
- output(itemOf({ id, removed: true }));
3577
- });
3578
- }, "installFolderCommands");
3579
-
3580
- // dist/knowledge-query.js
3581
- var FACT_QUERY = {
3582
- entity: "fact",
3583
- backend: "native",
3584
- fields: [
3585
- termField("kind", "enum", "kind:decision", { values: FACT_TYPES }),
3586
- termField("status", "enum", "status:proposed", { values: FACT_STATUSES })
3587
- ]
3588
- };
3589
- var MEMORY_QUERY = {
3590
- entity: "memory",
3591
- backend: "native",
3592
- fields: [
3593
- termField("kind", "enum", "kind:preference", { values: MEMORY_KINDS }),
3594
- termField("status", "enum", "status:proposed", { values: MEMORY_STATUSES }),
3595
- termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
3596
- ]
3597
- };
3598
- var MEMORY_SEARCH_QUERY = {
3599
- entity: "memory",
3600
- backend: "native",
3601
- fields: [
3602
- nativeField({
3603
- name: "text",
3604
- type: "txt",
3605
- operators: ["term", "phrase"],
3606
- example: "text:reviews",
3607
- relation: "words of the memory; a bare word means the same"
3608
- }),
3609
- termField("scope", "enum", "scope:work", { values: MEMORY_SCOPES })
3610
- ]
3611
- };
3612
- var factItem = /* @__PURE__ */ __name(({ type, statement, source, confirmedBy, ...fact }) => ({
3613
- ref: fact.ref,
3614
- id: fact.id,
3615
- kind: type,
3616
- text: statement,
3617
- status: fact.status,
3618
- project: fact.project,
3619
- subject: fact.subject,
3620
- occurred_at: fact.occurredAt,
3621
- supersedes: fact.supersedes,
3622
- author: fact.author,
3623
- model: fact.model,
3624
- confirmed_by: confirmedBy,
3625
- scope: fact.scope,
3626
- origin: source,
3627
- evidence: fact.evidence,
3628
- created_at: fact.createdAt,
3629
- updated_at: fact.updatedAt
3630
- }), "factItem");
3631
- var memoryItem = /* @__PURE__ */ __name(({ body, ...memory }) => ({
3632
- ref: memory.ref,
3633
- id: memory.id,
3634
- kind: memory.kind,
3635
- text: body,
3636
- subject: memory.subject,
3637
- author: memory.author,
3638
- model: memory.model,
3639
- confidence: memory.confidence,
3640
- status: memory.status,
3641
- scope: memory.scope,
3642
- supersedes: memory.supersedes,
3643
- evidence: memory.evidence,
3644
- last_verified_at: memory.lastVerifiedAt,
3645
- created_at: memory.createdAt,
3646
- updated_at: memory.updatedAt
3647
- }), "memoryItem");
3648
- var memorySearch = /* @__PURE__ */ __name((words) => {
3649
- const command = "memories search";
3650
- const context = { command, guide: LIST_QUERY_GUIDE };
3651
- const ast = validateQuery(parseLucene(typedQuery(words), { defaultField: "text", ...context }), MEMORY_SEARCH_QUERY, context);
3652
- const text = [];
3653
- let scope;
3654
- const add = /* @__PURE__ */ __name((node) => {
3655
- if (node.kind === "boolean") {
3656
- for (const clause of node.clauses) {
3657
- if (clause.occur !== "must")
3658
- queryError("query.unsupported-placement", clause.node.span, "this search joins its terms by AND", context);
3659
- add(clause.node);
3660
- }
3661
- return;
3662
- }
3663
- if (node.field === "text")
3664
- text.push(node.value);
3665
- else if (scope !== void 0)
3666
- queryError("query.unsupported-placement", node.span, "scope only once here", context);
3667
- else
3668
- scope = node.value.toLowerCase();
3669
- }, "add");
3670
- add(ast.root);
3671
- if (text.length === 0)
3672
- queryError("query.missing-value", ast.root.span, "say which words to look for beside scope:", context);
3673
- return { text: text.join(" "), ...scope === void 0 ? {} : { scope } };
3674
- }, "memorySearch");
3675
-
3676
- // dist/commands/knowledge.js
3677
- var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
3678
- const { run: run3, output, positive: positive2, author, decider } = helpers;
3679
- const documentArgument = "Google file or folder id or URL in the local catalog, or a document:<n> ref";
3680
- const scopes = ["personal", "work"];
3681
- const documents = program.commands.find((command) => command.name() === "documents");
3682
- 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)))));
3683
- const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
3684
- for (const action of ["list", "add", "remove"]) {
3685
- 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"}`]);
3686
- if (action === "list") {
3687
- bindQuery(command, TAGS_QUERY, tagRow).action(async (doc, words) => {
3688
- const filter = termsOf(words, TAGS_QUERY, "tags list");
3689
- output(allOf((await run3(doc, (k, p, ref) => k.tags(p, ref, "list", [], filter))).map((tag) => ({ tag }))));
3690
- });
3691
- } else
3692
- 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)) })));
3693
- }
3694
- const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
3695
- 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) => {
3696
- const { confirmed, ...filter } = termsOf(words, LINKS_QUERY, "relationships list");
3697
- output(allOf(await run3(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...confirmed === void 0 ? {} : { confirmed: confirmed === "true" } }))));
3698
- });
3699
- examples(annotate(relationships.command("add"), { effects: LOCAL_WRITE }).description("connect a document to another reference"), [
3700
- "drive personal relationships add DOC_ID project:PROJECT_ID --kind about",
3701
- "drive personal relationships add DOC_ID person:PERSON_UID --kind assigned-to --role reviewer"
3702
- ]).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 } : {} })))));
3703
- 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())))));
3704
- const notes = annotate(program.command("notes"), { effects: LOCAL_READ }).description("write notes about an imported document");
3705
- const noteArgument = "note:<id> reference, as notes list prints it";
3706
- examples(annotate(notes.command("add"), {
3707
- effects: LOCAL_WRITE,
3708
- output: { entity: "note" },
3709
- literal_after_dashes: true
3710
- }).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)))));
3711
- withQuery(examples(annotate(notes.command("list"), { effects: LOCAL_READ }).description("list a document's notes"), [
3712
- "drive personal notes list DOC_ID",
3713
- "drive personal notes list DOC_ID text:review --limit 10"
3714
- ]).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 }) => {
3715
- const query = termsOf(words, NOTES_QUERY, "notes list").text;
3716
- const found = await run3(doc, (k, p, ref) => k.notes(p, ref, { ...query ? { search: query } : {}, limit, offset: (page - 1) * limit }));
3717
- output(listOf("notes list", {
3718
- items: found.items,
3719
- limit,
3720
- has_more: found.hasMore,
3721
- page,
3722
- args: { document: doc, query: words.join(" ") }
3723
- }));
3724
- });
3725
- 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)))));
3726
- examples(annotate(notes.command("edit"), {
3727
- effects: LOCAL_WRITE,
3728
- output: { entity: "note" },
3729
- literal_after_dashes: true
3730
- }).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)))));
3731
- examples(annotate(notes.command("remove"), { effects: LOCAL_WRITE }).description("delete one note"), [
3732
- "drive personal notes remove DOC_ID note:NOTE_ID"
3733
- ]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.removeNote(p, ref, noteRef)))));
3734
- const memories = annotate(program.command("memories"), { effects: LOCAL_READ }).description("keep what was learned from a document, with evidence; an agent's stay proposed");
3735
- const memoryArgument = "memory:<id> reference, as memories list prints it";
3736
- const scope = /* @__PURE__ */ __name((description) => new Option("--scope <scope>", description).choices(scopes), "scope");
3737
- 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() }))))));
3738
- withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
3739
- "drive personal memories list DOC_ID scope:work",
3740
- "drive personal memories list DOC_ID kind:preference status:confirmed"
3741
- ]).argument("<document>", documentArgument), MEMORY_QUERY).option("--limit <n>", "how many memories to return", positive2, 50).action(async (doc, words, { limit }) => {
3742
- const terms = queryTerms(words, MEMORY_QUERY, "memories list");
3743
- const filters = {
3744
- ...terms.has("kind") ? { kind: terms.get("kind") } : {},
3745
- ...terms.has("status") ? { status: terms.get("status") } : {},
3746
- ...terms.has("scope") ? { scope: terms.get("scope") } : {}
3747
- };
3748
- output(allOf((await run3(doc, (k, p, ref) => k.memories(p, ref, { ...filters, limit }))).items.map(memoryItem)));
3749
- });
3750
- const memoryActions = {
3751
- show: "show one memory",
3752
- confirm: "confirm a proposed memory as true",
3753
- stale: "mark a memory as out of date"
3754
- };
3755
- for (const [action, description] of Object.entries(memoryActions))
3756
- 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()))))));
3757
- const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [
3758
- "drive personal memories search DOC_ID reviews scope:work",
3759
- `drive personal memories search DOC_ID "async reviews"`
3760
- ]).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) => {
3761
- const { text, scope: scope2 } = memorySearch(words);
3762
- const found = await run3(doc, (k, p, ref) => k.searchMemories(p, ref, text, scope2));
3763
- output({
3764
- ...allOf(found.items.map(memoryItem)),
3765
- ...found.hasMore ? { meta: { truncated: true } } : {}
3766
- });
3767
- });
3768
- annotate(search, { query: defineQuery(MEMORY_SEARCH_QUERY), output: { entity: "memory" } });
3769
- 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"), [
3770
- "drive personal memories extract DOC_ID --scope work",
3771
- "drive personal memories extract DOC_ID --scope work --yes"
3772
- ]).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) {
3773
- const args = this.optsWithGlobals();
3774
- await run3(doc, async () => void 0);
3775
- const result = await extractDocumentMemories({
3776
- read: /* @__PURE__ */ __name(() => helpers.document(doc), "read"),
3777
- complete: helpers.complete(),
3778
- scope: args.scope,
3779
- author: "drive-memory",
3780
- tab: args.tab,
3781
- save: args.yes,
3782
- withWrite: /* @__PURE__ */ __name((write) => run3(doc, write), "withWrite")
3783
- });
3784
- output(itemOf({ ...result, saved: result.saved.map((item) => "type" in item ? factItem(item) : memoryItem(item)) }));
3785
- });
3786
- const facts = annotate(program.command("facts"), { effects: LOCAL_READ }).description("what happened, as a document shows it; an agent's stay proposed until confirmed");
3787
- const factArgument = "fact:<id> reference, as facts list prints it";
3788
- examples(annotate(facts.command("add"), { effects: LOCAL_WRITE }).description("record a fact a document shows"), [
3789
- `drive personal facts add DOC_ID "Budget approved" --type decision --scope work`
3790
- ]).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, {
3791
- statement,
3792
- ...args,
3793
- by: author(),
3794
- ...occurredTime === void 0 ? {} : { occurredAt: occurredTime }
3795
- }))))));
3796
- withQuery(examples(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
3797
- "drive personal facts list DOC_ID status:proposed",
3798
- "drive personal facts list DOC_ID kind:decision"
3799
- ]).argument("<document>", documentArgument), FACT_QUERY).option("--limit <n>", "how many facts to return", positive2, 50).action(async (doc, words, { limit }) => {
3800
- const terms = queryTerms(words, FACT_QUERY, "facts list");
3801
- const filters = {
3802
- ...terms.has("kind") ? { type: terms.get("kind") } : {},
3803
- ...terms.has("status") ? { status: terms.get("status") } : {}
3804
- };
3805
- output(allOf((await run3(doc, (k, p, ref) => k.facts(p, ref, { ...filters, limit }))).items.map(factItem)));
3806
- });
3807
- const factActions = {
3808
- show: "show one fact",
3809
- confirm: "confirm a proposed fact; a decision it supersedes stops holding",
3810
- reverse: "an accepted decision no longer holds, and nothing replaced it"
3811
- };
3812
- for (const [action, description] of Object.entries(factActions))
3813
- 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()))))));
3814
- const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description("the Google accounts seen on a document, and the people they belong to");
3815
- 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) => {
3816
- const filter = termsOf(words, IDENTITIES_QUERY, "identities list");
3817
- 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")
3818
3915
  });
3819
- 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)))));
3820
- }, "installKnowledgeCommandsDefinition");
3821
- var installKnowledgeCommands = /* @__PURE__ */ __name((...args) => {
3822
- const reference = sharedCommandTemplate(DRIVE_APP, "notes");
3823
- customizeSharedCommand(reference, "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.", () => {
3824
- installKnowledgeCommandsDefinition(...args);
3825
- const command = args[0].commands.find((command2) => command2.name() === "notes");
3826
- if (!command)
3827
- throw new Error("notes builder did not install its command");
3828
- return command;
3829
- }, reviewedOverrides(reference, SHELL_OVERRIDES.notes));
3830
- }, "installKnowledgeCommands");
3916
+ }, "installFolderCommands");
3917
+
3918
+ // dist/commands/knowledge.js
3919
+ var installKnowledgeCommands = /* @__PURE__ */ __name((program, helpers) => addDocumentKnowledgeCommands(program, { ...helpers, words: DRIVE_WORDS }), "installKnowledgeCommands");
3831
3920
 
3832
3921
  // dist/commands/mirrors.js
3833
- import { statSync } from "node:fs";
3834
- import { join as join5, resolve } from "node:path";
3922
+ import { join as join5 } from "node:path";
3835
3923
 
3836
3924
  // dist/mirror-docs.js
3837
3925
  import { readFileSync as readFileSync3 } from "node:fs";
@@ -4303,10 +4391,10 @@ var PLAIN_PARAGRAPH = {
4303
4391
  };
4304
4392
  var textRequests = /* @__PURE__ */ __name((inlines, at, extra = {}) => {
4305
4393
  const requests = [];
4306
- let offset2 = at;
4394
+ let offset = at;
4307
4395
  for (const inline of inlines) {
4308
4396
  const length = inline.text.length;
4309
- const range2 = { startIndex: offset2, endIndex: offset2 + length };
4397
+ const range2 = { startIndex: offset, endIndex: offset + length };
4310
4398
  const style = {
4311
4399
  ...inline.bold ? { bold: true } : {},
4312
4400
  ...inline.italic ? { italic: true } : {},
@@ -4317,7 +4405,7 @@ var textRequests = /* @__PURE__ */ __name((inlines, at, extra = {}) => {
4317
4405
  const fields = Object.keys(style);
4318
4406
  if (fields.length && length)
4319
4407
  requests.push({ updateTextStyle: { range: range2, textStyle: style, fields: fields.join(",") } });
4320
- offset2 += length;
4408
+ offset += length;
4321
4409
  }
4322
4410
  return requests;
4323
4411
  }, "textRequests");
@@ -4398,24 +4486,24 @@ var insertRequests = /* @__PURE__ */ __name((blocks, at) => {
4398
4486
  }
4399
4487
  });
4400
4488
  requests.push({ deleteParagraphBullets: { range: range2 } });
4401
- let offset2 = at;
4489
+ let offset = at;
4402
4490
  group.forEach((block, index) => {
4403
4491
  const line = lines[index] ?? "";
4404
4492
  if (block.kind === "item") {
4405
4493
  const done2 = block.list === "check" && block.checked;
4406
- requests.push(...textRequests(block.inlines, offset2 + block.depth, done2 ? { strike: true } : {}));
4494
+ requests.push(...textRequests(block.inlines, offset + block.depth, done2 ? { strike: true } : {}));
4407
4495
  } else if (block.kind === "code") {
4408
4496
  if (line)
4409
4497
  requests.push({
4410
4498
  updateTextStyle: {
4411
- range: { startIndex: offset2, endIndex: offset2 + line.length },
4499
+ range: { startIndex: offset, endIndex: offset + line.length },
4412
4500
  textStyle: { weightedFontFamily: { fontFamily: MONO } },
4413
4501
  fields: "weightedFontFamily"
4414
4502
  }
4415
4503
  });
4416
4504
  } else if (block.kind === "heading" || block.kind === "paragraph" || block.kind === "quote")
4417
- requests.push(...textRequests(block.inlines, offset2));
4418
- offset2 += line.length + 1;
4505
+ requests.push(...textRequests(block.inlines, offset));
4506
+ offset += line.length + 1;
4419
4507
  });
4420
4508
  if (first.kind === "item")
4421
4509
  requests.push({ createParagraphBullets: { range: range2, bulletPreset: PRESETS[first.list] } });
@@ -4591,178 +4679,69 @@ var googleTarget = /* @__PURE__ */ __name((call, identity) => ({
4591
4679
  // dist/commands/mirrors.js
4592
4680
  var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call }) => {
4593
4681
  const { env, selected, output, source } = context;
4594
- const mirrors = annotate(program.command("mirrors"), { effects: LOCAL_READ }).description("keep local folders mirrored into Google Docs and Sheets");
4595
- const mirrorsOf = /* @__PURE__ */ __name(() => activeProfile(env, selected()).mirrors ?? [], "mirrorsOf");
4596
- const find = /* @__PURE__ */ __name((id) => {
4597
- const mirror = mirrorsOf().find((item) => item.id === id);
4598
- if (!mirror)
4599
- throw new CliError("not_found", `no mirror ${id} in profile ${selected()}; see drive ${selected()} mirrors list`, {
4600
- reason: "mirror.not-found"
4601
- });
4602
- return mirror;
4603
- }, "find");
4604
- const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(join5(profileDir(env, name), "mirrors"), mirror, principal, ["doc", "sheet"]), "stateOf");
4605
- const syncing = /* @__PURE__ */ __name((name, principal, google) => ({
4606
- target: googleTarget(call, () => google.identity()),
4607
- stateOf: stateOf(name, principal),
4608
- principal,
4609
- // `call` already checks policy and journals each Google write it makes.
4610
- guard: /* @__PURE__ */ __name((_attempt, act) => act(), "guard"),
4611
- operationId: newOperationId,
4612
- errorOf: googleError,
4613
- lock: /* @__PURE__ */ __name(() => lockProfile(env, name), "lock"),
4614
- ...context.signal() ? { signal: context.signal() } : {},
4615
- remote: "google"
4616
- }), "syncing");
4617
- const chosenOf = /* @__PURE__ */ __name((name, id) => {
4618
- const chosen = id ? [find(id)] : mirrorsOf();
4619
- if (!chosen.length)
4620
- throw new CliError("not_found", `profile ${name} has no mirrors; add one with drive ${name} mirrors add`, {
4621
- reason: "mirror.none"
4622
- });
4623
- return chosen;
4624
- }, "chosenOf");
4625
- 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) => {
4626
- const root = resolve(path);
4627
- let directory = false;
4628
- try {
4629
- directory = statSync(root).isDirectory();
4630
- } catch {
4631
- }
4632
- if (!directory)
4633
- throw new CliError("validation_error", "the path to mirror is not a folder", { reason: "mirror.not-folder" });
4634
- const folder = fileId(args.parent);
4635
- const metadata = await (await source()).metadata(folder);
4636
- if (metadata.mime !== FOLDER || metadata.trashed)
4637
- throw new CliError("validation_error", "--parent is not an accessible Google folder");
4638
- const config = readConfig(env);
4639
- const name = selected();
4640
- const profile = activeProfile(env, name);
4641
- const id = mirrorId(root, folder);
4642
- const list = profile.mirrors ?? [];
4643
- if (!list.some((mirror) => mirror.id === id))
4644
- list.push({ id, path: root, folder });
4645
- config.profiles[name] = { ...profile, mirrors: list };
4646
- writeConfig(env, config);
4647
- output(itemOf({ id, path: root, folder, folder_name: metadata.name, added: true }));
4648
- });
4649
- bindQuery(examples(annotate(mirrors.command("list"), { effects: LOCAL_READ }).description("list this profile's mirrors"), [
4650
- "drive personal mirrors list"
4651
- ]), MIRRORS_QUERY, mirrorRow).action((words) => {
4652
- const filter = termsOf(words, MIRRORS_QUERY, "mirrors list");
4653
- output(allOf(configuredMirrors(env, selected(), filter)));
4654
- });
4655
- 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) => {
4656
- find(id);
4657
- const config = readConfig(env);
4658
- const name = selected();
4659
- const profile = activeProfile(env, name);
4660
- config.profiles[name] = { ...profile, mirrors: (profile.mirrors ?? []).filter((mirror) => mirror.id !== id) };
4661
- writeConfig(env, config);
4662
- output(itemOf({ id, removed: true }));
4663
- });
4664
- 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) => {
4665
- const name = selected();
4666
- const { principal } = activeProfile(env, name);
4667
- const items = await mirrorStatus(id ? [find(id)] : mirrorsOf(), mirrorKind, stateOf(name, principal));
4668
- output(allOf(items.map(({ id: id2, folder, create, update: update2, unchanged, orphans, unsupported, remote_checked }) => ({
4669
- id: id2,
4670
- folder,
4671
- create: create.length,
4672
- update: update2.length,
4673
- unchanged,
4674
- orphans: orphans.length,
4675
- unsupported,
4676
- remote_checked
4677
- }))));
4678
- });
4679
- 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([
4680
- "local",
4681
- "google",
4682
- "both"
4683
- ])).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"), [
4684
- "drive personal mirrors sync",
4685
- "drive personal mirrors sync 1a2b3c4d --keep google",
4686
- "drive personal mirrors sync 1a2b3c4d --replace"
4687
- ]).action(async (id, args) => {
4688
- const name = selected();
4689
- const profile = activeProfile(env, name);
4690
- const chosen = chosenOf(name, id);
4691
- if (args.replace && args.keep && args.keep !== "local")
4692
- throw new CliError("validation_error", "--replace keeps the local side; it cannot be combined with --keep google or both");
4693
- const keep = args.replace ? "local" : args.keep === "google" ? "remote" : args.keep;
4694
- const google = await source();
4695
- const { items, issues } = await syncMirrors({
4696
- ...syncing(name, profile.principal, google),
4697
- mirrors: chosen,
4698
- ...keep ? { keep } : {},
4699
- recreate: args.replace === true
4700
- });
4701
- const body = allOf(items);
4702
- if (issues.length)
4703
- body.meta = { complete: false, issues };
4704
- output(body);
4705
- if (issues.length)
4706
- 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" });
4707
- });
4708
- 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) => {
4709
- const pollMs = parseDuration(args.every, "--every");
4710
- if (pollMs < 1e4)
4711
- throw new CliError("validation_error", "--every must be at least 10s");
4712
- const name = selected();
4713
- const profile = activeProfile(env, name);
4714
- const chosen = chosenOf(name, id);
4715
- const signal = context.endsOnStop() ?? new AbortController().signal;
4716
- const google = await source();
4717
- const states = stateOf(name, profile.principal);
4718
- let token = await google.startToken();
4719
- const remoteChanges = /* @__PURE__ */ __name(async () => {
4720
- let changed;
4721
- try {
4722
- const feed = await google.changes(token);
4723
- token = feed.cursor;
4724
- changed = new Set(feed.items.map((item) => item.id));
4725
- } catch (error) {
4726
- if (!isCliError(error) || error.details?.reason !== "listing.too-large")
4727
- throw error;
4728
- token = await google.startToken();
4729
- return "all";
4730
- }
4731
- return chosen.filter((mirror) => Object.values(states(mirror).read().entries).some((entry) => changed.has(entry.id))).map((mirror) => mirror.id);
4732
- }, "remoteChanges");
4733
- let cycles = 0;
4734
- for await (const event of watchMirrors((mirrors2) => syncMirrors({ ...syncing(name, profile.principal, google), mirrors: mirrors2 }), { mirrors: chosen, signal, kindOf: mirrorKind, stateOf: states, remoteChanges, pollMs })) {
4735
- cycles++;
4736
- const data = {
4737
- at: (/* @__PURE__ */ new Date()).toISOString(),
4738
- triggers: event.triggers,
4739
- mirrors: event.mirrors,
4740
- ..."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")
4741
4720
  };
4742
- context.print((_renderer, format, streams) => streams.data(format === "pretty" ? describeCycle(data) : JSON.stringify({ type: "item", data })));
4743
- }
4744
- context.print((_renderer, format, streams) => {
4745
- if (format === "pretty")
4746
- return;
4747
- const end = listOf("mirrors watch", {
4748
- items: [],
4749
- limit: Math.max(1, cycles),
4750
- has_more: false,
4751
- paging: "cursor",
4752
- meta: { complete: true }
4753
- });
4754
- for (const record2 of jsonlRecords(end))
4755
- streams.data(JSON.stringify(record2));
4756
- });
4721
+ }, "connect"),
4722
+ endsOnStop: /* @__PURE__ */ __name(() => context.endsOnStop(), "endsOnStop")
4757
4723
  });
4758
4724
  }, "installMirrorCommands");
4759
- var describeCycle = /* @__PURE__ */ __name((cycle) => {
4760
- const time = cycle.at.slice(11, 19);
4761
- if (cycle.error)
4762
- return `${time} ${cycle.triggers.join("+")}: ${cycle.error.message}; trying again`;
4763
- 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)` : ""));
4764
- return `${time} ${cycle.triggers.join("+")}: ${parts.join("; ") || "nothing to do"}`;
4765
- }, "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");
4766
4745
 
4767
4746
  // dist/download.js
4768
4747
  import { randomUUID } from "node:crypto";
@@ -4827,6 +4806,39 @@ var saveDownload = /* @__PURE__ */ __name(async (path, overwrite, read, createDi
4827
4806
  return size2;
4828
4807
  }, "saveDownload");
4829
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
+
4830
4842
  // dist/generated/definitions.js
4831
4843
  var definitions = {
4832
4844
  DriveOperation: {
@@ -22013,10 +22025,10 @@ var DRIVE_TIME = /\b(modifiedTime|createdTime|viewedByMeTime|sharedWithMeTime)(\
22013
22025
  var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
22014
22026
  var utcDriveQuery = /* @__PURE__ */ __name((query, zone = timezoneOf()) => {
22015
22027
  let changed = false;
22016
- 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) => {
22017
22029
  if (ZONED.test(value))
22018
22030
  return whole;
22019
- const start = offset2 + whole.length - value.length - 1;
22031
+ const start = offset + whole.length - value.length - 1;
22020
22032
  const end = operator === "<=" || operator === ">";
22021
22033
  const time = zonedMoment(value, zone, { start, end: start + value.length }, { end });
22022
22034
  changed = true;
@@ -22254,11 +22266,11 @@ var sentParams = /* @__PURE__ */ __name((method, params) => {
22254
22266
  }, "sentParams");
22255
22267
  var zoneMeta = /* @__PURE__ */ __name((meta) => meta ? { meta } : {}, "zoneMeta");
22256
22268
  var installRemoteCommands = /* @__PURE__ */ __name((program, helpers) => {
22257
- const { call, output, positive: positive2 } = helpers;
22258
- 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");
22259
22271
  const fileArgument = "file id or Google Drive URL";
22260
22272
  const api = annotate(program.command("api"), { effects: LOCAL_READ }).description("discover and call the official Drive, Docs, Sheets and Activity API methods");
22261
- 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")))));
22262
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) })));
22263
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"), [
22264
22276
  `drive personal api call drive.files.get --params '{"fileId":"FILE_ID"}'`,
@@ -22407,35 +22419,27 @@ var installRemoteCommands = /* @__PURE__ */ __name((program, helpers) => {
22407
22419
  }, "installRemoteCommands");
22408
22420
 
22409
22421
  // dist/commands/search.js
22410
- var installSearchCommandDefinition = /* @__PURE__ */ __name((program, { env, selected, output, withIndex }) => {
22411
- 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) => {
22412
22426
  const name = selected();
22413
22427
  const profile = activeProfile(env, name);
22414
- const result = await withIndex((index) => index.search(profile.principal, query, {
22415
- ...args,
22416
- offset: (page - 1) * args.limit,
22417
- exact: args.exact ?? false,
22428
+ return withIndex(async (index) => await index.search(profile.principal, query, {
22429
+ ...options,
22418
22430
  ...pictureSearch(env, name) ? { pictures: true } : {}
22419
22431
  }));
22420
- const hint = notImported(name, profile.roots.length > 0 || transcriptsOf(env, name).mode === "include", Object.keys(readState(env, name, profile.principal).documents));
22421
- output(itemOf(hint ? { ...result, not_imported: hint } : result));
22422
- });
22423
- }, "installSearchCommandDefinition");
22424
- var notImported = /* @__PURE__ */ __name((name, chosen, documents) => {
22425
- if (documents.length > 0)
22426
- return void 0;
22427
- 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`;
22428
- }, "notImported");
22429
- var installSearchCommand = /* @__PURE__ */ __name((...args) => {
22430
- const reference = sharedCommandTemplate(DRIVE_APP, "search");
22431
- return customizeSharedCommand(reference, "Drive searches imported documents and embeddings rather than live messenger messages; its default action and pagination are explicitly provider-specific.", () => {
22432
- installSearchCommandDefinition(...args);
22433
- const command = args[0].commands.find((command2) => command2.name() === "search");
22434
- if (!command)
22435
- throw new Error("search builder did not install its command");
22436
- return command;
22437
- }, reviewedOverrides(reference, SHELL_OVERRIDES.search));
22438
- }, "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");
22439
22443
 
22440
22444
  // dist/commands/session.js
22441
22445
  var GRANTS = ["write", "activity", "apps"];
@@ -22466,7 +22470,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22466
22470
  const app = application(env, { file: args.clientFile, clientId: args.clientId, profile: selected() });
22467
22471
  if (!app.clientSecret)
22468
22472
  streams.diagnostic("your Google app has no secret here, and Google refuses a Desktop app without one: set DRIVE_GOOGLE_CLIENT_SECRET\n");
22469
- const { login } = await import("./login-N243GGEE.js");
22473
+ const { login } = await import("./login-6WG3YBDU.js");
22470
22474
  output(itemOf(await login({
22471
22475
  env,
22472
22476
  profile: selected(),
@@ -22497,7 +22501,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
22497
22501
  const name = selected();
22498
22502
  const config = readConfig(env);
22499
22503
  const profile = activeProfile(env, name);
22500
- const { credentials } = await import("./tokens-A2GP4F34.js");
22504
+ const { credentials } = await import("./tokens-DB7O7QNB.js");
22501
22505
  const store = credentials(env, profile.storage, options.keyring);
22502
22506
  store.remove(name);
22503
22507
  writeConfig(env, config);
@@ -22544,7 +22548,7 @@ var selection = /* @__PURE__ */ __name((env, name, source) => {
22544
22548
  return { profile, state, options: { source, destination, collection: `google-drive:${profile.principal}`, env } };
22545
22549
  }, "selection");
22546
22550
  var checkStoreImport = /* @__PURE__ */ __name(async (env, name, source, bindings) => {
22547
- const { ensureSqlite } = await import("./sqlite-runtime-X4GB5PBV.js");
22551
+ const { ensureSqlite } = await import("./sqlite-runtime-ZSZGAUYB.js");
22548
22552
  await ensureSqlite();
22549
22553
  const { state, options } = selection(env, name, source);
22550
22554
  const preview = await previewDocumentTransfer({ ...options, bindings });
@@ -22676,46 +22680,40 @@ var sync = /* @__PURE__ */ __name(async (source, index, env, name, max, signal,
22676
22680
  // dist/commands/sync.js
22677
22681
  var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
22678
22682
  const { env, streams, selected, output, source, withIndex } = context;
22679
- 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) => {
22680
- const profile = activeProfile(env, selected());
22681
- const remote = profile.roots.length || profile.transcripts === "include" ? await source() : void 0;
22682
- const result = await withIndex(async (index) => ({
22683
- ...await sync(remote, index, env, selected(), args.limit, context.signal(), args.rescan),
22684
- ...args.embed ? { embeddings: await index.embed(600) } : {}
22685
- }));
22686
- output(itemOf(result, {
22687
- meta: result.errors.length ? {
22688
- complete: false,
22689
- issues: [{ code: "provider_error", reason: "sync.partial", source: "google-drive" }]
22690
- } : {}
22691
- }));
22692
- if (result.errors.length || result.pending)
22693
- streams.diagnostic(`${result.pending} source operations remain; run drive ${selected()} sync again
22694
- `);
22695
- if (result.errors.length)
22696
- throw new CliError("provider_error", "sync completed partially; failed operations remain pending", {
22697
- reason: "sync.partial"
22698
- });
22699
- });
22700
- examples(annotate(program.command("status"), { effects: LOCAL_READ }).description("show the last sync, imported documents and pending work"), ["drive personal status"]).action(() => {
22701
- const name = selected();
22702
- const profile = activeProfile(env, name);
22703
- const state = readState(env, name, profile.principal);
22704
- const legacyStore = join7(paths(env).state, "drive.db");
22705
- output(itemOf({
22706
- profile: name,
22707
- store: {
22708
- selected: resolve4(storePath(env)),
22709
- checkpoint: state.store ?? (existsSync(legacyStore) ? resolve4(legacyStore) : null)
22710
- },
22711
- selected_folders: profile.roots,
22712
- documents: Object.keys(state.documents).length,
22713
- pending: state.pending?.jobs.length ?? 0,
22714
- skipped: state.skipped.map(({ id, reason }) => ({ id, reason })),
22715
- last_sync: state.lastSync ?? null,
22716
- coverage: "Google Docs/Sheets, PDF/DOCX/XLSX and Markdown/TXT/CSV/TSV; native export layout, tab fidelity and assets are not verified",
22717
- remote_checked: false
22718
- }));
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")
22719
22717
  });
22720
22718
  }, "installSyncCommands");
22721
22719
 
@@ -22746,14 +22744,14 @@ var installTranscriptCommands = /* @__PURE__ */ __name((program, context) => {
22746
22744
  owned_by_me: file.providerMetadata?.ownedByMe ?? null,
22747
22745
  modified_at: file.modifiedAt ?? null
22748
22746
  }));
22749
- 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)));
22750
22748
  });
22751
22749
  }, "installTranscriptCommands");
22752
22750
 
22753
22751
  // dist/commands/upgrade.js
22754
22752
  import { join as join8 } from "node:path";
22755
22753
 
22756
- // node_modules/.pnpm/@wirecat+cli-core@0.656.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_dceb8977715cf47b69a8fd97c630c977/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
22757
22755
  import { realpathSync } from "node:fs";
22758
22756
  import { fileURLToPath } from "node:url";
22759
22757
  var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
@@ -22926,11 +22924,11 @@ var placeInSections = /* @__PURE__ */ __name((program) => {
22926
22924
 
22927
22925
  // dist/provider-json.js
22928
22926
  var providerJsonFields = entityFields({
22929
- "document.drive_catalog": CATALOG_FIELDS,
22930
- drive_document: DOCUMENT_LIST_FIELDS
22927
+ "document.catalog": CATALOG_FIELDS,
22928
+ "document.imported": DOCUMENT_LIST_FIELDS
22931
22929
  });
22932
22930
  var DRIVE_ROWS = {
22933
- drive_document: {
22931
+ "document.imported": {
22934
22932
  columns: [
22935
22933
  { field: "reference" },
22936
22934
  { field: "name" },
@@ -22938,7 +22936,7 @@ var DRIVE_ROWS = {
22938
22936
  { field: "age_days", as: "count", tag: "days since sync" }
22939
22937
  ]
22940
22938
  },
22941
- "document.drive_catalog": {
22939
+ "document.catalog": {
22942
22940
  columns: [{ field: "ref" }, { field: "name" }, { field: "kind" }, { field: "modified_at", as: "time" }]
22943
22941
  }
22944
22942
  };
@@ -22965,9 +22963,9 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22965
22963
  const port = {
22966
22964
  ...shared,
22967
22965
  context: /* @__PURE__ */ __name(async (principal, ref) => {
22968
- const note = await document(principal, ref);
22966
+ const note2 = await document(principal, ref);
22969
22967
  return {
22970
- document: note,
22968
+ document: note2,
22971
22969
  tags: await store.notes.noteTags(ref),
22972
22970
  links: await store.notes.links({ from: ref }),
22973
22971
  notes: await store.notes.notes({ source: "internal", about: ref, limit: 100 }),
@@ -22977,19 +22975,20 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22977
22975
  };
22978
22976
  }, "context"),
22979
22977
  people: /* @__PURE__ */ __name(async (principal, ref, filter = {}) => {
22980
- const note = await document(principal, ref);
22981
- const metadata = note.frontMatter;
22978
+ const note2 = await document(principal, ref);
22979
+ const metadata = note2.frontMatter;
22982
22980
  const contributors = [
22983
22981
  ...(metadata.owners ?? []).map((user) => ({ ...user, role: "owner" })),
22984
22982
  ...metadata.lastModifiedBy ? [{ ...metadata.lastModifiedBy, role: "last-editor" }] : []
22985
- ].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));
22986
22984
  return {
22987
22985
  items: await Promise.all(contributors.map(async (user) => {
22988
22986
  const id = googleUserId(user);
22989
22987
  const person = id ? await store.people.personOf({ provider: "google-drive", id }) : void 0;
22990
22988
  return {
22991
22989
  ...user,
22992
- google_id: id ?? null,
22990
+ remote_id: id ?? null,
22991
+ provider: "google-drive",
22993
22992
  person: person ? { ref: `person:${person.uid}`, ...person } : null
22994
22993
  };
22995
22994
  })),
@@ -22997,8 +22996,8 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
22997
22996
  };
22998
22997
  }, "people"),
22999
22998
  linkPerson: /* @__PURE__ */ __name(async (principal, ref, googleId, personRef) => {
23000
- const note = await document(principal, ref);
23001
- const metadata = note.frontMatter;
22999
+ const note2 = await document(principal, ref);
23000
+ const metadata = note2.frontMatter;
23002
23001
  const users = [...metadata.owners ?? [], ...metadata.lastModifiedBy ? [metadata.lastModifiedBy] : []];
23003
23002
  if (!users.some((user) => googleUserId(user) === googleId))
23004
23003
  throw new CliError("not_found", "Google identity was not observed on this document");
@@ -23015,8 +23014,8 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23015
23014
  if (sourceFolder.account?.provider !== "google-drive")
23016
23015
  continue;
23017
23016
  const principal2 = sourceFolder.account.account;
23018
- for (let offset2 = 0; offset2 <= 1e4; offset2 += 500) {
23019
- 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 });
23020
23019
  for (const source of page.items) {
23021
23020
  const data = source.frontMatter;
23022
23021
  if (data?.source !== "google-drive" || !data.fileId)
@@ -23032,7 +23031,7 @@ var documentKnowledge2 = /* @__PURE__ */ __name((store, folder) => {
23032
23031
  }
23033
23032
  if (!page.hasMore)
23034
23033
  break;
23035
- if (offset2 === 1e4)
23034
+ if (offset === 1e4)
23036
23035
  throw new CliError("provider_error", "identity linked; document relationship refresh exceeded its bound");
23037
23036
  }
23038
23037
  }
@@ -23094,15 +23093,15 @@ var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = fals
23094
23093
  const folder = await old.notes.documentsAccount({ provider: "google-drive", account: profile.principal });
23095
23094
  const counts = { tags: 0, notes: 0, memories: 0, facts: 0, links: 0 };
23096
23095
  if (folder) {
23097
- for (let offset2 = 0; ; offset2 += 500) {
23098
- const page = await old.notes.notes({ folderId: folder.id, source: "file", limit: 500, offset: offset2 });
23099
- for (const note of page.items) {
23100
- counts.tags += (await old.notes.noteTags(note.ref)).length;
23101
- counts.notes += (await old.notes.notes({ source: "internal", about: note.ref, limit: 1 })).items.length;
23102
- counts.memories += (await old.memories.list({ subject: note.ref, limit: 1 })).items.length;
23103
- counts.facts += (await old.facts.list({ subject: note.ref, limit: 1 })).items.length;
23104
- counts.links += (await old.notes.links({ from: note.ref })).filter((link) => link.origin !== "file").length;
23105
- 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;
23106
23105
  }
23107
23106
  if (!page.hasMore)
23108
23107
  break;
@@ -23180,7 +23179,7 @@ var openIndex = /* @__PURE__ */ __name(async (env, name, rescan = false) => {
23180
23179
  activeProfile(env, name);
23181
23180
  if (env.DRIVE_STORE)
23182
23181
  throw new CliError("configuration_error", "DRIVE_STORE has been retired; use MESSAGING_STORE to select the shared database", { reason: "store.override-retired" });
23183
- const { openAppStore } = await import("./cli-L7P36YUH.js");
23182
+ const { openAppStore } = await import("./cli-K4D4DIGQ.js");
23184
23183
  const store = await openAppStore(env, { app: { command: "drive", version: VERSION }, provider: DRIVE_PROVIDER });
23185
23184
  const index = indexOver(store, env);
23186
23185
  try {
@@ -23231,7 +23230,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23231
23230
  linkMessages: /* @__PURE__ */ __name((documents, since) => store.notes.linkMessages({ documents, ...since ? { since } : {} }), "linkMessages"),
23232
23231
  knowledge: documentKnowledge2(store, async (principal) => (await folder(principal, false))?.id),
23233
23232
  openPictures: /* @__PURE__ */ __name(async () => {
23234
- const { openPictureEmbedderFor, savePicture } = await import("./services-IQG2RVTO.js");
23233
+ const { openPictureEmbedderFor, savePicture } = await import("./services-BDQBRXT5.js");
23235
23234
  const embedder = pictureEmbedder ?? await openPictureEmbedderFor({ env, command: "drive" });
23236
23235
  return {
23237
23236
  save: /* @__PURE__ */ __name((reference, bytes) => savePicture(store, { ref: reference }, bytes, { embedder }), "save"),
@@ -23250,7 +23249,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23250
23249
  has_more: false,
23251
23250
  meaning_skipped: "this Google account has no imported sources"
23252
23251
  };
23253
- const { searchNotes } = await import("./services-IQG2RVTO.js");
23252
+ const { searchNotes } = await import("./services-BDQBRXT5.js");
23254
23253
  const result = await searchNotes(store, query, {
23255
23254
  ...options,
23256
23255
  folderIds: selected ? [selected.id] : [],
@@ -23259,9 +23258,9 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23259
23258
  ...pictureEmbedder ? { pictureEmbedder } : {}
23260
23259
  });
23261
23260
  const pictures = await Promise.all((result.pictures ?? []).map(async (picture) => {
23262
- const note = await store.notes.note(picture.ref);
23261
+ const note2 = await store.notes.note(picture.ref);
23263
23262
  const [file] = await store.files.ofDocument(picture.ref);
23264
- return { ...picture, title: note.title, url: file?.url ?? null };
23263
+ return { ...picture, title: note2.title, url: file?.url ?? null };
23265
23264
  }));
23266
23265
  const { pictures: _, items, hasMore, nextOffset, ...rest } = result;
23267
23266
  return {
@@ -23270,9 +23269,9 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23270
23269
  ...nextOffset === void 0 ? {} : { next_offset: nextOffset },
23271
23270
  ...result.pictures ? { pictures } : {},
23272
23271
  hits: await Promise.all(items.map(async (hit) => {
23273
- const note = await store.notes.note(hit.ref);
23274
- const metadata = note.frontMatter;
23275
- 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;
23276
23275
  return {
23277
23276
  ...hit,
23278
23277
  tabs: Array.isArray(metadata?.tabs) ? metadata.tabs : [],
@@ -23283,7 +23282,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
23283
23282
  };
23284
23283
  }, "search"),
23285
23284
  embed: /* @__PURE__ */ __name(async (max) => {
23286
- const { embedNotes } = await import("./services-IQG2RVTO.js");
23285
+ const { embedNotes } = await import("./services-BDQBRXT5.js");
23287
23286
  return embedNotes(store, { maxChunks: max, env, command: "drive" });
23288
23287
  }, "embed"),
23289
23288
  close: /* @__PURE__ */ __name(() => store.close(), "close")
@@ -23367,7 +23366,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23367
23366
  }, "start");
23368
23367
  const status = /* @__PURE__ */ __name((session2) => input.request({ url: session2, method: "PUT", headers: { "Content-Range": `bytes */${size2}` } }), "status");
23369
23368
  let session = "";
23370
- let offset2 = 0;
23369
+ let offset = 0;
23371
23370
  let resumed = false;
23372
23371
  let finished;
23373
23372
  const saved = readCheckpoint();
@@ -23377,7 +23376,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23377
23376
  finished = answer;
23378
23377
  if (answer?.status === 308) {
23379
23378
  session = saved.session_uri;
23380
- offset2 = nextByte(answer);
23379
+ offset = nextByte(answer);
23381
23380
  resumed = true;
23382
23381
  } else if (!finished) {
23383
23382
  clearCheckpoint();
@@ -23389,11 +23388,11 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23389
23388
  try {
23390
23389
  let failures = 0;
23391
23390
  while (!finished) {
23392
- const end = Math.min(offset2 + chunk, size2);
23393
- const body = Buffer.alloc(end - offset2);
23391
+ const end = Math.min(offset + chunk, size2);
23392
+ const body = Buffer.alloc(end - offset);
23394
23393
  if (body.length)
23395
- await handle.read(body, 0, body.length, offset2);
23396
- 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}`;
23397
23396
  let response;
23398
23397
  try {
23399
23398
  response = await input.request({
@@ -23410,7 +23409,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23410
23409
  break;
23411
23410
  }
23412
23411
  if (response?.status === 308) {
23413
- offset2 = nextByte(response);
23412
+ offset = nextByte(response);
23414
23413
  failures = 0;
23415
23414
  continue;
23416
23415
  }
@@ -23436,7 +23435,7 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
23436
23435
  if (answer && done(answer.status))
23437
23436
  finished = answer;
23438
23437
  else if (answer?.status === 308)
23439
- offset2 = nextByte(answer);
23438
+ offset = nextByte(answer);
23440
23439
  }
23441
23440
  } finally {
23442
23441
  await handle.close();
@@ -23570,7 +23569,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23570
23569
  }, "output");
23571
23570
  const signal = /* @__PURE__ */ __name(() => environment().signal, "signal");
23572
23571
  const signedIn = /* @__PURE__ */ __name(async (name, scope2) => {
23573
- const { authorizedClient, checkAuthorization } = await import("./tokens-A2GP4F34.js");
23572
+ const { authorizedClient, checkAuthorization } = await import("./tokens-DB7O7QNB.js");
23574
23573
  const client = authorizedClient(env, name, environment().keyring, signal());
23575
23574
  await checkAuthorization(client, scope2);
23576
23575
  return client;
@@ -23580,7 +23579,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23580
23579
  const fake = environment().source;
23581
23580
  if (fake)
23582
23581
  return fake(name);
23583
- const [{ googleSource }, client] = await Promise.all([import("./google-XXHSMTVK.js"), signedIn(name)]);
23582
+ const [{ googleSource }, client] = await Promise.all([import("./google-BSO3YB7N.js"), signedIn(name)]);
23584
23583
  return googleSource(client);
23585
23584
  }, "source");
23586
23585
  const withIndex = /* @__PURE__ */ __name(async (fn, profile) => {
@@ -23654,11 +23653,10 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23654
23653
  installStoreCommands(program, context);
23655
23654
  installDocumentCommands(program, context);
23656
23655
  installSearchCommand(program, context);
23657
- installCatalogCommands(program, { env, selected, output, positive, offset, withIndex });
23656
+ installCatalogCommands(program, { env, selected, output, withIndex });
23658
23657
  installKnowledgeCommands(program, {
23659
23658
  document: imported,
23660
23659
  output,
23661
- positive,
23662
23660
  complete: /* @__PURE__ */ __name(() => environment().complete ?? memoryModel(env, selected(), signal()), "complete"),
23663
23661
  author: /* @__PURE__ */ __name(() => agent() ? { bot: MCP_AGENT, kind: "agent" } : "owner", "author"),
23664
23662
  decider: /* @__PURE__ */ __name(() => agent() ? { bot: MCP_AGENT, reason: "asked over drive's MCP server" } : "owner", "decider"),
@@ -23686,7 +23684,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23686
23684
  },
23687
23685
  stored: storedDocument(context),
23688
23686
  output,
23689
- positive,
23687
+ positive: positive2,
23690
23688
  readBody: /* @__PURE__ */ __name((path) => {
23691
23689
  const fake = environment().readBody;
23692
23690
  if (fake)
@@ -23725,7 +23723,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23725
23723
  if (fake)
23726
23724
  return await fake.call(method, params, body);
23727
23725
  const [{ googleApi }, client] = await Promise.all([
23728
- import("./google-api-SQQ4BSNR.js"),
23726
+ import("./google-api-SAND2F7L.js"),
23729
23727
  signedIn(selected(), descriptor.scope)
23730
23728
  ]);
23731
23729
  return await googleApi(client).call(method, params, body);
@@ -23751,7 +23749,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23751
23749
  if (fake)
23752
23750
  return fake(id, mime);
23753
23751
  const [{ googleDownload }, client] = await Promise.all([
23754
- import("./google-api-SQQ4BSNR.js"),
23752
+ import("./google-api-SAND2F7L.js"),
23755
23753
  signedIn(selected(), apiMethod(method).scope)
23756
23754
  ]);
23757
23755
  return googleDownload(client)(id, mime);
@@ -23769,7 +23767,7 @@ var installDrive = /* @__PURE__ */ __name((program) => {
23769
23767
  let request = environment().uploadRequest;
23770
23768
  if (!request) {
23771
23769
  const [{ googleUploadRequest }, client] = await Promise.all([
23772
- import("./google-api-SQQ4BSNR.js"),
23770
+ import("./google-api-SAND2F7L.js"),
23773
23771
  signedIn(selected(), apiMethod(method).scope)
23774
23772
  ]);
23775
23773
  request = googleUploadRequest(client);
@@ -23982,7 +23980,7 @@ var mcpCommand = /* @__PURE__ */ __name(() => {
23982
23980
  const environment = environmentOf(action);
23983
23981
  if (environment.api)
23984
23982
  return;
23985
- const { grantAvailability } = await import("./grants-2U4JVT6O.js");
23983
+ const { grantAvailability } = await import("./grants-PLNFYARD.js");
23986
23984
  availability = grantAvailability(rootOf(root), environment.env ?? process.env, environment.keyring);
23987
23985
  });
23988
23986
  }, "mcpCommand");