@wirecat/drive-cli 0.52.1 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/drive.js +2 -2
- package/dist/bin/drive.js.map +1 -1
- package/dist/bundle/{chunk-ZWSG7OCA.js → all-profiles-WRN35CUF.js} +11 -6
- package/dist/bundle/{anthropic-KW6KU36Y.js → anthropic-DZASXWG3.js} +1 -1
- package/dist/bundle/{app-server-TCJZ333E.js → app-server-4VHT7QZN.js} +33 -41
- package/dist/bundle/{bun-sqlite-RI7DR6RZ.js → bun-sqlite-2GOM5PM3.js} +1 -1
- package/dist/bundle/{chunk-LONV6HIK.js → chunk-2HHOMN2G.js} +440 -25
- package/dist/bundle/{chunk-NYOPEHEU.js → chunk-2PVDFLJJ.js} +8 -3
- package/dist/bundle/{chunk-725OHXKR.js → chunk-3RYX7IB6.js} +2218 -30
- package/dist/bundle/{chunk-CB7SBYLO.js → chunk-54BYJQ77.js} +41 -21
- package/dist/bundle/{chunk-5FONRUG6.js → chunk-5D4AEUVA.js} +1 -23
- package/dist/bundle/{chunk-RNSP57TC.js → chunk-6BNALDGA.js} +1 -1
- package/dist/bundle/{chunk-H47W2J6S.js → chunk-6XYGTRMQ.js} +812 -381
- package/dist/bundle/{chunk-UR32UWTQ.js → chunk-7IUMHMTP.js} +11 -0
- package/dist/bundle/{chunk-W7IK7E4B.js → chunk-BEL4XZ3M.js} +5 -7
- package/dist/bundle/{chunk-43QVYW3K.js → chunk-CL4GVCXS.js} +230 -56
- package/dist/bundle/{chunk-PQYVPCJ2.js → chunk-CNKILAWA.js} +18 -24
- package/dist/bundle/chunk-DOZOLBXE.js +110 -0
- package/dist/bundle/{chunk-2AUXBJRX.js → chunk-DT2YCB2V.js} +84 -11
- package/dist/bundle/{chunk-HQVJK5E7.js → chunk-DZMK255Y.js} +210 -357
- package/dist/bundle/{chunk-G6QF5KWF.js → chunk-E6XDFMRZ.js} +22 -28
- package/dist/bundle/{chunk-54O62JWP.js → chunk-F3KHUJEE.js} +24 -5
- package/dist/bundle/{chunk-I7UH5CTA.js → chunk-FXWBUTR7.js} +7 -9
- package/dist/bundle/{chunk-ZNZUZGSV.js → chunk-GE4DP24O.js} +131 -4
- package/dist/bundle/{chunk-PEOCBV2Z.js → chunk-GPJEYW2J.js} +1 -1
- package/dist/bundle/{chunk-A4UNTWAX.js → chunk-HM352LJR.js} +84 -15
- package/dist/bundle/{chunk-KYVXMEBC.js → chunk-IAQ4L6SM.js} +1 -1
- package/dist/bundle/{chunk-PQJYM5ES.js → chunk-IJFZKQC4.js} +1 -1
- package/dist/bundle/{chunk-O6IOL6RX.js → chunk-KPBCGUJC.js} +1 -1
- package/dist/bundle/{chunk-XOLQSCMF.js → chunk-KXMJE3XC.js} +2 -2
- package/dist/bundle/{chunk-33NVQGUY.js → chunk-LSGAJYVN.js} +2 -2
- package/dist/bundle/{chunk-2UIMEMWU.js → chunk-MK3N7WX7.js} +1 -1
- package/dist/bundle/{chunk-IDUNJCFO.js → chunk-OQMK6WXQ.js} +1 -1
- package/dist/bundle/{chunk-CM7GAXGD.js → chunk-PC4UA6UN.js} +1 -1
- package/dist/bundle/{chunk-YNFELLNQ.js → chunk-PIMMF67N.js} +2 -2
- package/dist/bundle/{chunk-WBTVGFXI.js → chunk-PR3DA7KA.js} +9 -9
- package/dist/bundle/{chunk-VJZST5RD.js → chunk-QXYGK6G5.js} +1 -1
- package/dist/bundle/{chunk-WQJBAWQP.js → chunk-R4TE4ZSD.js} +549 -224
- package/dist/bundle/{chunk-BSSCTWWK.js → chunk-RNIHKIQP.js} +1 -1
- package/dist/bundle/{chunk-PAXKALHV.js → chunk-SIWBUGBU.js} +116 -5
- package/dist/bundle/{chunk-2623YE5I.js → chunk-SQHPJBNO.js} +6 -8
- package/dist/bundle/chunk-SVTYS36O.js +5305 -0
- package/dist/bundle/{chunk-WLFUBNFX.js → chunk-T334CFU4.js} +2 -2
- package/dist/bundle/{chunk-IEXPOEEO.js → chunk-TZLO3ZZF.js} +3 -3
- package/dist/bundle/{chunk-5PLJKSG4.js → chunk-UFWK3L5Z.js} +4 -6
- package/dist/bundle/{chunk-FCJAHD4R.js → chunk-VTWADVEQ.js} +2 -2
- package/dist/bundle/{chunk-HX7Y2ASG.js → chunk-WJRJBQIM.js} +26040 -15126
- package/dist/bundle/{chunk-VSOLLTYT.js → chunk-YLKQSVLI.js} +5 -0
- package/dist/bundle/{chunk-IWFBAWZK.js → chunk-YQOVVCIA.js} +282 -10
- package/dist/bundle/{chunk-7YMDL4JQ.js → chunk-ZG6X24ON.js} +4 -1
- package/dist/bundle/{command-contract-I2YB5IXI.js → command-contract-D4UG3D33.js} +12 -15
- package/dist/bundle/{decode-EDN2ARXZ.js → decode-WAPM2VBH.js} +1 -1
- package/dist/bundle/drive.js +9 -20
- package/dist/bundle/{embed-3GSQIQXE.js → embed-HW3N3KNP.js} +4 -4
- package/dist/bundle/{embedder-6ULWRG3R.js → embedder-7WNFXYYP.js} +4 -4
- package/dist/bundle/{entry-IPRJLFHO.js → entry-J7YIRDPD.js} +4 -4
- package/dist/bundle/{first-run-FGHGWHC2.js → first-run-53CL2IYH.js} +6 -6
- package/dist/bundle/{first-screen-M62KTPZG.js → first-screen-2KT7HM2K.js} +13 -16
- package/dist/bundle/{google-BD3ZNFVJ.js → google-5NNVARNR.js} +2 -2
- package/dist/bundle/{chunk-GR5GGZKH.js → google-api-EQQH53QD.js} +60 -4
- package/dist/bundle/grants-4NETZ4MR.js +98 -0
- package/dist/bundle/{identity-U7IHZEMR.js → identity-LBTXDMTA.js} +4 -2
- package/dist/bundle/{login-7HRYPZMM.js → login-Y6ENYKC3.js} +44 -50
- package/dist/bundle/{node-sqlite-J3OODPYK.js → node-sqlite-FSQIKGED.js} +1 -1
- package/dist/bundle/{oauth-L4VTCBLF.js → oauth-HF5USWXY.js} +5 -5
- package/dist/bundle/{open-SGUN7ZVF.js → open-NHGJENCX.js} +2 -2
- package/dist/bundle/{openai-RLVISEDH.js → openai-3JCJYKNX.js} +6 -6
- package/dist/bundle/{program-YVLXSKZV.js → program-QAJ66K3Z.js} +713 -902
- package/dist/bundle/{prompt-AUWTBLO7.js → prompt-LQJBCCUF.js} +3 -3
- package/dist/bundle/{recognize-ORX2UBQW.js → recognize-QM3LN4ZF.js} +1 -1
- package/dist/bundle/{remote-AGIJY73X.js → remote-WREGEZJQ.js} +5 -5
- package/dist/bundle/{rerank-R6PE44M5.js → rerank-YFUB6J6M.js} +4 -4
- package/dist/bundle/{chunk-G7DCVJ4F.js → serve-7NFEZ564.js} +7 -4
- package/dist/bundle/{chunk-F7UUZATI.js → server-KBCFZ2AU.js} +38 -11
- package/dist/bundle/server-UYVL2CFI.js +63 -0
- package/dist/bundle/{services-HZFTTZSF.js → services-C3XWRA2W.js} +16 -21
- package/dist/bundle/{sqlite-runtime-DTGPR2T2.js → sqlite-runtime-H3TSAMIN.js} +3 -3
- package/dist/bundle/{state-WG3JKJM3.js → state-S2Q53L6L.js} +3 -3
- package/dist/bundle/{store-33VHIMEO.js → store-H345VQHP.js} +6 -8
- package/dist/bundle/{store-EV72MT5U.js → store-I27LAJPU.js} +7 -9
- package/dist/bundle/store-maintenance-command-3XA73XMC.js +52 -0
- package/dist/bundle/{chunk-GNI7INK6.js → terminal-DHJ4D3BC.js} +2 -3
- package/dist/bundle/tokens-7MUGKFEM.js +96 -0
- package/dist/commands/context.d.ts +14 -13
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +1 -4
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/mirrors.d.ts.map +1 -1
- package/dist/commands/mirrors.js +1 -2
- package/dist/commands/mirrors.js.map +1 -1
- package/dist/commands/upgrade.d.ts +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +4 -9
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +38 -3
- package/dist/config.js.map +1 -1
- package/dist/contract-overrides.d.ts +0 -3
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +0 -234
- package/dist/contract-overrides.js.map +1 -1
- package/dist/first-screen.d.ts +3 -2
- package/dist/first-screen.d.ts.map +1 -1
- package/dist/first-screen.js +17 -22
- package/dist/first-screen.js.map +1 -1
- package/dist/grants.d.ts +9 -0
- package/dist/grants.d.ts.map +1 -0
- package/dist/grants.js +30 -0
- package/dist/grants.js.map +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +2 -0
- package/dist/identity.js.map +1 -1
- package/dist/policy-keys.d.ts +12 -0
- package/dist/policy-keys.d.ts.map +1 -0
- package/dist/policy-keys.js +107 -0
- package/dist/policy-keys.js.map +1 -0
- package/dist/policy.d.ts +1 -8
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +2 -105
- package/dist/policy.js.map +1 -1
- package/dist/program.d.ts +8 -4
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +251 -222
- package/dist/program.js.map +1 -1
- package/dist/testing/mcp.d.ts +28 -0
- package/dist/testing/mcp.d.ts.map +1 -0
- package/dist/testing/mcp.js +56 -0
- package/dist/testing/mcp.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/scenarios/agent-access.md +4 -2
- package/dist/bundle/all-profiles-CYW6XBBS.js +0 -26
- package/dist/bundle/chunk-234MHU76.js +0 -384
- package/dist/bundle/chunk-BBYD2FA3.js +0 -9
- package/dist/bundle/chunk-DO4PDQY5.js +0 -48
- package/dist/bundle/chunk-FDWYPONW.js +0 -1988
- package/dist/bundle/chunk-FQRJWVEB.js +0 -2
- package/dist/bundle/chunk-GJN5B5JK.js +0 -522
- package/dist/bundle/chunk-NPSZPUK6.js +0 -193
- package/dist/bundle/chunk-PDGECM5D.js +0 -138
- package/dist/bundle/chunk-Q765VPZY.js +0 -421
- package/dist/bundle/chunk-QYUHS6DE.js +0 -1714
- package/dist/bundle/chunk-WQRGA75U.js +0 -256
- package/dist/bundle/chunk-YVPHJHIL.js +0 -15572
- package/dist/bundle/chunk-Z47LOJUS.js +0 -484
- package/dist/bundle/failure-IXS2ZHA5.js +0 -37
- package/dist/bundle/google-api-BDUWZMRV.js +0 -83
- package/dist/bundle/mcp-F67RATLF.js +0 -502
- package/dist/bundle/mcp-JZSYPQA4.js +0 -96
- package/dist/bundle/serve-VOBAQHAQ.js +0 -20
- package/dist/bundle/server-24PS4M7U.js +0 -70
- package/dist/bundle/server-G6HFZ2CK.js +0 -57
- package/dist/bundle/store-maintenance-command-ZTUEI4EC.js +0 -58
- package/dist/bundle/terminal-TFCTWLOS.js +0 -11
- package/dist/bundle/tokens-XMOGQFI6.js +0 -102
- package/dist/commands/doctor.d.ts +0 -56
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -75
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -6
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -156
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/skill.d.ts +0 -6
- package/dist/commands/skill.d.ts.map +0 -1
- package/dist/commands/skill.js +0 -34
- package/dist/commands/skill.js.map +0 -1
- package/dist/failure.d.ts +0 -88
- package/dist/failure.d.ts.map +0 -1
- package/dist/failure.js +0 -60
- package/dist/failure.js.map +0 -1
- package/dist/mcp.d.ts +0 -175
- package/dist/mcp.d.ts.map +0 -1
- package/dist/mcp.js +0 -412
- package/dist/mcp.js.map +0 -1
|
@@ -6,44 +6,46 @@ import {
|
|
|
6
6
|
GOOGLE_READ,
|
|
7
7
|
GOOGLE_WRITE,
|
|
8
8
|
PROFILE_SET_COMMANDS,
|
|
9
|
-
checkPolicy,
|
|
10
9
|
commandsDocument,
|
|
11
10
|
describeDriveProgram,
|
|
12
|
-
discoveryAvailability,
|
|
13
|
-
ensureProfileDir,
|
|
14
11
|
examples,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} from "./chunk-
|
|
12
|
+
markProfileFree
|
|
13
|
+
} from "./chunk-DOZOLBXE.js";
|
|
14
|
+
import {
|
|
15
|
+
apiMethod,
|
|
16
|
+
apiMethods,
|
|
17
|
+
jsonObject,
|
|
18
|
+
operationOf,
|
|
19
|
+
schemas,
|
|
20
|
+
validateApiParams,
|
|
21
|
+
validateRequest
|
|
22
|
+
} from "./chunk-SVTYS36O.js";
|
|
23
|
+
import {
|
|
24
|
+
DOC,
|
|
25
|
+
DOCUMENT_LIST_FIELDS,
|
|
26
|
+
FOLDER,
|
|
27
|
+
MAX_ENTRIES,
|
|
28
|
+
metadataJson,
|
|
29
|
+
supported,
|
|
30
|
+
tooManyEntries
|
|
31
|
+
} from "./chunk-CKBHR7QO.js";
|
|
35
32
|
import {
|
|
36
33
|
DEFAULTS_ONLY,
|
|
34
|
+
DEFAULT_LEVELS,
|
|
37
35
|
SETTING_NAMES,
|
|
38
36
|
activeProfile,
|
|
39
37
|
application,
|
|
40
38
|
checkTextLimit,
|
|
41
39
|
configIssues,
|
|
40
|
+
configuration,
|
|
42
41
|
configuredMirrors,
|
|
43
42
|
configuredSessions,
|
|
44
43
|
fileId,
|
|
45
44
|
inspectConfig,
|
|
45
|
+
methodPolicyKeys,
|
|
46
46
|
paths,
|
|
47
|
+
permissionKeys,
|
|
48
|
+
permissionNames,
|
|
47
49
|
pictureSearch,
|
|
48
50
|
profileName,
|
|
49
51
|
readConfig,
|
|
@@ -52,102 +54,81 @@ import {
|
|
|
52
54
|
textLimit,
|
|
53
55
|
unknownProfile,
|
|
54
56
|
writeConfig
|
|
55
|
-
} from "./chunk-
|
|
56
|
-
import {
|
|
57
|
-
DOC,
|
|
58
|
-
DOCUMENT_LIST_FIELDS,
|
|
59
|
-
FOLDER,
|
|
60
|
-
MAX_ENTRIES,
|
|
61
|
-
metadataJson,
|
|
62
|
-
supported,
|
|
63
|
-
tooManyEntries
|
|
64
|
-
} from "./chunk-CKBHR7QO.js";
|
|
65
|
-
import {
|
|
66
|
-
blockKey,
|
|
67
|
-
blocksMarkdown,
|
|
68
|
-
catalogFiles,
|
|
69
|
-
diffBlocks,
|
|
70
|
-
documentIngestion,
|
|
71
|
-
documentKnowledge,
|
|
72
|
-
extractDocumentMemories,
|
|
73
|
-
fileMirrorState,
|
|
74
|
-
markdownBlocks,
|
|
75
|
-
mergeBlocks,
|
|
76
|
-
mirrorId,
|
|
77
|
-
mirrorStatus,
|
|
78
|
-
normalizeInlines,
|
|
79
|
-
spliceMarkdown,
|
|
80
|
-
syncDocuments,
|
|
81
|
-
syncMirrors,
|
|
82
|
-
watchMirrors
|
|
83
|
-
} from "./chunk-O6IOL6RX.js";
|
|
84
|
-
import {
|
|
85
|
-
apiMethod,
|
|
86
|
-
apiMethods,
|
|
87
|
-
jsonObject,
|
|
88
|
-
operationOf,
|
|
89
|
-
operations,
|
|
90
|
-
schemas,
|
|
91
|
-
validateApiParams,
|
|
92
|
-
validateRequest
|
|
93
|
-
} from "./chunk-YVPHJHIL.js";
|
|
57
|
+
} from "./chunk-SIWBUGBU.js";
|
|
94
58
|
import {
|
|
95
59
|
DISCOVERY_DESCRIPTIONS,
|
|
96
60
|
MEMO_SCENARIOS,
|
|
97
61
|
addContractInfo,
|
|
98
62
|
answerFields,
|
|
99
63
|
apiPlainJson,
|
|
64
|
+
appDoctorCommand,
|
|
65
|
+
appMcpCommand,
|
|
100
66
|
checkApiBody,
|
|
101
67
|
checkApiParameter,
|
|
102
68
|
checkJson,
|
|
69
|
+
commandRuns,
|
|
70
|
+
createProgram,
|
|
103
71
|
entityFields,
|
|
104
72
|
formatSuggestions,
|
|
105
73
|
generatedApiCommand,
|
|
106
74
|
guideCommand,
|
|
107
75
|
identifier,
|
|
108
|
-
liftJson,
|
|
109
|
-
mcpServerCommand,
|
|
110
76
|
modelCatalogueCommand,
|
|
77
|
+
operations,
|
|
111
78
|
parseApiJson,
|
|
112
|
-
privateFiles,
|
|
113
79
|
readApiBody,
|
|
114
|
-
|
|
80
|
+
run,
|
|
115
81
|
runsCommand,
|
|
116
82
|
sharedCommandTemplate,
|
|
117
83
|
signInSteps,
|
|
118
|
-
skillCommand
|
|
84
|
+
skillCommand,
|
|
119
85
|
suggest,
|
|
120
86
|
upgradeCommand
|
|
121
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-WJRJBQIM.js";
|
|
88
|
+
import {
|
|
89
|
+
blockKey,
|
|
90
|
+
blocksMarkdown,
|
|
91
|
+
catalogFiles,
|
|
92
|
+
diffBlocks,
|
|
93
|
+
documentIngestion,
|
|
94
|
+
documentKnowledge,
|
|
95
|
+
extractDocumentMemories,
|
|
96
|
+
fileMirrorState,
|
|
97
|
+
markdownBlocks,
|
|
98
|
+
mergeBlocks,
|
|
99
|
+
mirrorId,
|
|
100
|
+
mirrorStatus,
|
|
101
|
+
normalizeInlines,
|
|
102
|
+
spliceMarkdown,
|
|
103
|
+
syncDocuments,
|
|
104
|
+
syncMirrors,
|
|
105
|
+
watchMirrors
|
|
106
|
+
} from "./chunk-KPBCGUJC.js";
|
|
122
107
|
import {
|
|
123
108
|
googleError
|
|
124
109
|
} from "./chunk-R276546S.js";
|
|
125
|
-
import "./chunk-
|
|
126
|
-
import "./chunk-A4UNTWAX.js";
|
|
127
|
-
import "./chunk-DO4PDQY5.js";
|
|
110
|
+
import "./chunk-HM352LJR.js";
|
|
128
111
|
import "./chunk-PSNHPFSK.js";
|
|
129
|
-
import
|
|
130
|
-
skillCommand
|
|
131
|
-
} from "./chunk-IWFBAWZK.js";
|
|
112
|
+
import "./chunk-YQOVVCIA.js";
|
|
132
113
|
import "./chunk-SBZB7HMU.js";
|
|
133
114
|
import {
|
|
134
|
-
DRIVE_APP
|
|
135
|
-
} from "./chunk-NYOPEHEU.js";
|
|
136
|
-
import "./chunk-QYUHS6DE.js";
|
|
137
|
-
import "./chunk-WQRGA75U.js";
|
|
138
|
-
import {
|
|
115
|
+
DRIVE_APP,
|
|
139
116
|
VERSION
|
|
140
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-2PVDFLJJ.js";
|
|
141
118
|
import {
|
|
142
119
|
REASONS
|
|
143
120
|
} from "./chunk-EKFEY3KP.js";
|
|
144
|
-
import "./chunk-
|
|
145
|
-
import "./chunk-
|
|
121
|
+
import "./chunk-6DHQTUB2.js";
|
|
122
|
+
import "./chunk-6BNALDGA.js";
|
|
146
123
|
import {
|
|
147
124
|
modelGateway,
|
|
148
125
|
storeInfo
|
|
149
|
-
} from "./chunk-
|
|
150
|
-
import
|
|
126
|
+
} from "./chunk-CL4GVCXS.js";
|
|
127
|
+
import {
|
|
128
|
+
RecipientList,
|
|
129
|
+
SendJournal,
|
|
130
|
+
sendGuard
|
|
131
|
+
} from "./chunk-54BYJQ77.js";
|
|
151
132
|
import {
|
|
152
133
|
LIST_QUERY_GUIDE,
|
|
153
134
|
listQuery,
|
|
@@ -158,117 +139,112 @@ import {
|
|
|
158
139
|
typedQuery,
|
|
159
140
|
unfilteredQuery,
|
|
160
141
|
withQuery
|
|
161
|
-
} from "./chunk-
|
|
162
|
-
import "./chunk-
|
|
163
|
-
import "./chunk-KYVXMEBC.js";
|
|
142
|
+
} from "./chunk-DT2YCB2V.js";
|
|
143
|
+
import "./chunk-IAQ4L6SM.js";
|
|
164
144
|
import {
|
|
165
145
|
newOperationId
|
|
166
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-6XYGTRMQ.js";
|
|
147
|
+
import "./chunk-7SH4JHYW.js";
|
|
167
148
|
import {
|
|
168
149
|
columnName,
|
|
169
150
|
readSpreadsheet
|
|
170
151
|
} from "./chunk-WUX7AUOQ.js";
|
|
171
|
-
import "./chunk-7SH4JHYW.js";
|
|
172
|
-
import "./chunk-Z47LOJUS.js";
|
|
173
152
|
import {
|
|
174
153
|
applyDocumentTransfer,
|
|
175
154
|
previewDocumentTransfer
|
|
176
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-BEL4XZ3M.js";
|
|
177
156
|
import {
|
|
178
157
|
commandsText,
|
|
179
|
-
inSection
|
|
180
|
-
|
|
181
|
-
} from "./chunk-I7UH5CTA.js";
|
|
158
|
+
inSection
|
|
159
|
+
} from "./chunk-FXWBUTR7.js";
|
|
182
160
|
import "./chunk-HTQTIKWP.js";
|
|
183
161
|
import {
|
|
184
162
|
answerEntity
|
|
185
|
-
} from "./chunk-
|
|
186
|
-
import "./chunk-
|
|
163
|
+
} from "./chunk-UFWK3L5Z.js";
|
|
164
|
+
import "./chunk-SQHPJBNO.js";
|
|
187
165
|
import {
|
|
188
166
|
FETCH,
|
|
167
|
+
InvalidArgumentError,
|
|
189
168
|
LOCAL_READ,
|
|
190
169
|
LOCAL_WRITE,
|
|
191
170
|
NO_EFFECTS,
|
|
171
|
+
Option,
|
|
192
172
|
REMOTE_WRITE,
|
|
173
|
+
annotate,
|
|
193
174
|
changesAuthority,
|
|
194
175
|
commandWords,
|
|
176
|
+
customizeSharedCommand,
|
|
177
|
+
describeOptions,
|
|
195
178
|
environmentOf,
|
|
179
|
+
flatten,
|
|
196
180
|
grantsAuthority,
|
|
181
|
+
hasSharedContract,
|
|
197
182
|
itemOf,
|
|
198
183
|
jsonlRecords,
|
|
199
|
-
liftProfile,
|
|
200
184
|
listOf,
|
|
185
|
+
metaOf,
|
|
201
186
|
modelTarget,
|
|
202
|
-
|
|
187
|
+
outputFor,
|
|
188
|
+
overrideSharedContract,
|
|
203
189
|
refuseCommandName,
|
|
204
190
|
renderAnswer,
|
|
205
191
|
resolveAISettings,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
} from "./chunk-
|
|
209
|
-
import "./chunk-
|
|
210
|
-
import {
|
|
211
|
-
Command,
|
|
212
|
-
Help,
|
|
213
|
-
InvalidArgumentError,
|
|
214
|
-
Option,
|
|
215
|
-
annotate,
|
|
216
|
-
assertSharedContracts,
|
|
217
|
-
customizeSharedCommand,
|
|
218
|
-
describeOptions,
|
|
219
|
-
flatten,
|
|
220
|
-
hasSharedContract,
|
|
221
|
-
metaOf,
|
|
222
|
-
overrideSharedContract
|
|
223
|
-
} from "./chunk-725OHXKR.js";
|
|
192
|
+
rootOf,
|
|
193
|
+
snakeKeys
|
|
194
|
+
} from "./chunk-3RYX7IB6.js";
|
|
195
|
+
import "./chunk-GPJEYW2J.js";
|
|
224
196
|
import "./chunk-NSIFQ5OP.js";
|
|
225
197
|
import {
|
|
198
|
+
CEILING_KEY,
|
|
199
|
+
LEVELS,
|
|
200
|
+
guardedWrite,
|
|
201
|
+
inRun,
|
|
202
|
+
layerPermissions,
|
|
203
|
+
levelFor,
|
|
226
204
|
parseDuration
|
|
227
|
-
} from "./chunk-
|
|
228
|
-
import "./chunk-
|
|
229
|
-
import {
|
|
230
|
-
levelFor
|
|
231
|
-
} from "./chunk-Q765VPZY.js";
|
|
205
|
+
} from "./chunk-2HHOMN2G.js";
|
|
206
|
+
import "./chunk-YLKQSVLI.js";
|
|
232
207
|
import {
|
|
233
208
|
note
|
|
234
209
|
} from "./chunk-GVCN3GLZ.js";
|
|
235
|
-
import "./chunk-
|
|
210
|
+
import "./chunk-PR3DA7KA.js";
|
|
236
211
|
import {
|
|
237
212
|
installerOf,
|
|
238
213
|
latestVersion,
|
|
239
214
|
runUpdate,
|
|
240
215
|
updateNotice
|
|
241
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-ZG6X24ON.js";
|
|
242
217
|
import "./chunk-DLAFGSTN.js";
|
|
243
|
-
import "./chunk-WLFUBNFX.js";
|
|
244
|
-
import "./chunk-54O62JWP.js";
|
|
245
218
|
import {
|
|
219
|
+
setupPermissionCeiling
|
|
220
|
+
} from "./chunk-T334CFU4.js";
|
|
221
|
+
import "./chunk-F3KHUJEE.js";
|
|
222
|
+
import {
|
|
223
|
+
readOnlyLockOf,
|
|
246
224
|
readOnlyRefusal
|
|
247
225
|
} from "./chunk-ZDLIO76S.js";
|
|
248
|
-
import "./chunk-
|
|
249
|
-
import "./chunk-
|
|
226
|
+
import "./chunk-IJFZKQC4.js";
|
|
227
|
+
import "./chunk-7IUMHMTP.js";
|
|
250
228
|
import "./chunk-LJAX6YCF.js";
|
|
251
229
|
import "./chunk-VZ2I62HN.js";
|
|
252
|
-
import "./chunk-
|
|
253
|
-
import "./chunk-
|
|
230
|
+
import "./chunk-MK3N7WX7.js";
|
|
231
|
+
import "./chunk-PC4UA6UN.js";
|
|
254
232
|
import "./chunk-5DPV7X27.js";
|
|
255
|
-
import "./chunk-
|
|
256
|
-
import "./chunk-
|
|
233
|
+
import "./chunk-RNIHKIQP.js";
|
|
234
|
+
import "./chunk-OQMK6WXQ.js";
|
|
257
235
|
import {
|
|
258
236
|
CATALOG_QUERY,
|
|
259
237
|
IMPORTED_DOCUMENT_QUERY,
|
|
260
238
|
openStore
|
|
261
|
-
} from "./chunk-
|
|
239
|
+
} from "./chunk-R4TE4ZSD.js";
|
|
262
240
|
import "./chunk-JEOYFKUK.js";
|
|
263
|
-
import "./chunk-234MHU76.js";
|
|
264
241
|
import {
|
|
265
242
|
FACT_STATUSES,
|
|
266
243
|
FACT_TYPES,
|
|
267
244
|
MEMORY_KINDS,
|
|
268
245
|
MEMORY_SCOPES,
|
|
269
246
|
MEMORY_STATUSES
|
|
270
|
-
} from "./chunk-
|
|
271
|
-
import "./chunk-ZNZUZGSV.js";
|
|
247
|
+
} from "./chunk-GE4DP24O.js";
|
|
272
248
|
import {
|
|
273
249
|
dateRange,
|
|
274
250
|
defineQuery,
|
|
@@ -281,32 +257,36 @@ import {
|
|
|
281
257
|
} from "./chunk-NHBUTCNR.js";
|
|
282
258
|
import "./chunk-62EDJKGP.js";
|
|
283
259
|
import "./chunk-7XKAVMCF.js";
|
|
284
|
-
import "./chunk-
|
|
260
|
+
import "./chunk-KXMJE3XC.js";
|
|
285
261
|
import {
|
|
286
262
|
storePath
|
|
287
|
-
} from "./chunk-
|
|
288
|
-
import "./chunk-
|
|
263
|
+
} from "./chunk-QXYGK6G5.js";
|
|
264
|
+
import "./chunk-LSGAJYVN.js";
|
|
289
265
|
import {
|
|
290
|
-
createDeadline,
|
|
291
|
-
createOutputBuffer,
|
|
292
|
-
createRenderer,
|
|
293
|
-
fieldsOf,
|
|
294
266
|
processStreams,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
} from "./chunk-
|
|
267
|
+
saveConfigFile,
|
|
268
|
+
writeSecurely
|
|
269
|
+
} from "./chunk-DZMK255Y.js";
|
|
298
270
|
import {
|
|
299
271
|
CliError,
|
|
272
|
+
array,
|
|
300
273
|
boolean,
|
|
301
274
|
defineSteps,
|
|
275
|
+
integer,
|
|
302
276
|
isCliError,
|
|
303
277
|
isoTime,
|
|
278
|
+
literal,
|
|
304
279
|
looseObject,
|
|
280
|
+
minValue,
|
|
305
281
|
nullable,
|
|
306
282
|
number,
|
|
283
|
+
object,
|
|
307
284
|
optional,
|
|
308
285
|
picklist,
|
|
286
|
+
pipe,
|
|
309
287
|
record,
|
|
288
|
+
regex,
|
|
289
|
+
safeParse,
|
|
310
290
|
stepOf,
|
|
311
291
|
strictObject,
|
|
312
292
|
string,
|
|
@@ -1879,12 +1859,12 @@ var require_adapter = __commonJS({
|
|
|
1879
1859
|
}
|
|
1880
1860
|
__name(createSyncFs, "createSyncFs");
|
|
1881
1861
|
function toPromise(method) {
|
|
1882
|
-
return (...args) => new Promise((
|
|
1862
|
+
return (...args) => new Promise((resolve7, reject) => {
|
|
1883
1863
|
args.push((err, result) => {
|
|
1884
1864
|
if (err) {
|
|
1885
1865
|
reject(err);
|
|
1886
1866
|
} else {
|
|
1887
|
-
|
|
1867
|
+
resolve7(result);
|
|
1888
1868
|
}
|
|
1889
1869
|
});
|
|
1890
1870
|
method(...args);
|
|
@@ -1968,7 +1948,8 @@ var require_proper_lockfile = __commonJS({
|
|
|
1968
1948
|
|
|
1969
1949
|
// dist/program.js
|
|
1970
1950
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1971
|
-
import { readFileSync as
|
|
1951
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6 } from "node:fs";
|
|
1952
|
+
import { join as join10 } from "node:path";
|
|
1972
1953
|
|
|
1973
1954
|
// dist/catalog.js
|
|
1974
1955
|
var catalogInput = /* @__PURE__ */ __name((file) => ({
|
|
@@ -2215,6 +2196,151 @@ var allOf = /* @__PURE__ */ __name((items) => listOf("", { items, limit: Math.ma
|
|
|
2215
2196
|
|
|
2216
2197
|
// dist/profile-lock.js
|
|
2217
2198
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
2199
|
+
|
|
2200
|
+
// dist/state.js
|
|
2201
|
+
import { mkdirSync, readFileSync, unlinkSync } from "node:fs";
|
|
2202
|
+
import { join } from "node:path";
|
|
2203
|
+
var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
|
|
2204
|
+
var User = object({ id: optional(string()), email: optional(string()), name: optional(string()) });
|
|
2205
|
+
var File = object({
|
|
2206
|
+
id: ID,
|
|
2207
|
+
name: string(),
|
|
2208
|
+
mime: string(),
|
|
2209
|
+
parents: array(ID),
|
|
2210
|
+
version: optional(string()),
|
|
2211
|
+
modifiedAt: optional(string()),
|
|
2212
|
+
url: string(),
|
|
2213
|
+
trashed: boolean(),
|
|
2214
|
+
canDownload: boolean(),
|
|
2215
|
+
size: optional(number()),
|
|
2216
|
+
createdAt: optional(string()),
|
|
2217
|
+
description: optional(string()),
|
|
2218
|
+
driveId: optional(string()),
|
|
2219
|
+
owners: optional(array(User)),
|
|
2220
|
+
lastModifiedBy: optional(User),
|
|
2221
|
+
providerMetadata: optional(unknown())
|
|
2222
|
+
});
|
|
2223
|
+
var Skip = object({
|
|
2224
|
+
id: ID,
|
|
2225
|
+
reason: string(),
|
|
2226
|
+
file: optional(File),
|
|
2227
|
+
textLimit: optional(number()),
|
|
2228
|
+
storeRefusedIn: optional(string())
|
|
2229
|
+
});
|
|
2230
|
+
var State = object({
|
|
2231
|
+
version: literal(1),
|
|
2232
|
+
store: optional(string()),
|
|
2233
|
+
linkedThrough: optional(string()),
|
|
2234
|
+
linksPending: optional(boolean()),
|
|
2235
|
+
linksVersion: optional(pipe(number(), integer(), minValue(1))),
|
|
2236
|
+
principal: string(),
|
|
2237
|
+
scope: string(),
|
|
2238
|
+
cursor: optional(string()),
|
|
2239
|
+
folders: record(ID, File),
|
|
2240
|
+
documents: record(ID, object({
|
|
2241
|
+
metadata: File,
|
|
2242
|
+
hash: string(),
|
|
2243
|
+
reference: string(),
|
|
2244
|
+
tabs: number(),
|
|
2245
|
+
notRead: optional(string()),
|
|
2246
|
+
picture: optional(picklist(["saved", "too-large"]))
|
|
2247
|
+
})),
|
|
2248
|
+
skipped: array(Skip),
|
|
2249
|
+
lastSync: optional(string()),
|
|
2250
|
+
pending: optional(object({
|
|
2251
|
+
cursor: string(),
|
|
2252
|
+
scope: string(),
|
|
2253
|
+
folders: record(ID, File),
|
|
2254
|
+
jobs: array(object({ id: ID, kind: picklist(["save", "remove"]), file: optional(File) })),
|
|
2255
|
+
skipped: array(Skip)
|
|
2256
|
+
}))
|
|
2257
|
+
});
|
|
2258
|
+
var Walk = object({
|
|
2259
|
+
scope: string(),
|
|
2260
|
+
cursor: string(),
|
|
2261
|
+
stack: array(object({ id: ID, ancestry: array(ID), folder: optional(File) })),
|
|
2262
|
+
visited: array(ID),
|
|
2263
|
+
folders: record(ID, File),
|
|
2264
|
+
files: array(File),
|
|
2265
|
+
discovered: number()
|
|
2266
|
+
});
|
|
2267
|
+
var profileDir = /* @__PURE__ */ __name((env, name) => join(paths(env).state, "profiles", profileName(name)), "profileDir");
|
|
2268
|
+
var statePath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "state.json"), "statePath");
|
|
2269
|
+
var readState = /* @__PURE__ */ __name((env, name, principal) => {
|
|
2270
|
+
let value;
|
|
2271
|
+
try {
|
|
2272
|
+
value = JSON.parse(readFileSync(statePath(env, name), "utf8"));
|
|
2273
|
+
} catch (error) {
|
|
2274
|
+
if (error.code === "ENOENT")
|
|
2275
|
+
return { version: 1, principal, scope: "", folders: {}, documents: {}, skipped: [] };
|
|
2276
|
+
throw new CliError("configuration_error", "sync state is unreadable; refusing to reset its checkpoint", {
|
|
2277
|
+
reason: "state.invalid"
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
const parsed = safeParse(State, value);
|
|
2281
|
+
if (!parsed.success || parsed.output.principal !== principal)
|
|
2282
|
+
throw new CliError("configuration_error", "sync state is invalid or belongs to another Google account", {
|
|
2283
|
+
reason: "state.invalid"
|
|
2284
|
+
});
|
|
2285
|
+
return parsed.output;
|
|
2286
|
+
}, "readState");
|
|
2287
|
+
var saveState = /* @__PURE__ */ __name((env, name, state) => {
|
|
2288
|
+
writeSecurely(statePath(env, name), `${JSON.stringify(state)}
|
|
2289
|
+
`, 384);
|
|
2290
|
+
}, "saveState");
|
|
2291
|
+
var walkPath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "walk.json"), "walkPath");
|
|
2292
|
+
var readWalk = /* @__PURE__ */ __name((env, name, scope) => {
|
|
2293
|
+
try {
|
|
2294
|
+
const parsed = safeParse(Walk, JSON.parse(readFileSync(walkPath(env, name), "utf8")));
|
|
2295
|
+
return parsed.success && parsed.output.scope === scope ? parsed.output : void 0;
|
|
2296
|
+
} catch {
|
|
2297
|
+
return void 0;
|
|
2298
|
+
}
|
|
2299
|
+
}, "readWalk");
|
|
2300
|
+
var saveWalk = /* @__PURE__ */ __name((env, name, walk) => {
|
|
2301
|
+
writeSecurely(walkPath(env, name), `${JSON.stringify(walk)}
|
|
2302
|
+
`, 384);
|
|
2303
|
+
}, "saveWalk");
|
|
2304
|
+
var removeWalk = /* @__PURE__ */ __name((env, name) => {
|
|
2305
|
+
try {
|
|
2306
|
+
unlinkSync(walkPath(env, name));
|
|
2307
|
+
} catch (error) {
|
|
2308
|
+
if (error.code !== "ENOENT")
|
|
2309
|
+
throw error;
|
|
2310
|
+
}
|
|
2311
|
+
}, "removeWalk");
|
|
2312
|
+
var ensureProfileDir = /* @__PURE__ */ __name((env, name) => {
|
|
2313
|
+
mkdirSync(profileDir(env, name), { recursive: true, mode: 448 });
|
|
2314
|
+
}, "ensureProfileDir");
|
|
2315
|
+
var snapshotPath = /* @__PURE__ */ __name((env, name, id) => join(profileDir(env, name), "documents", `${fileId(id)}.json`), "snapshotPath");
|
|
2316
|
+
var saveSnapshot = /* @__PURE__ */ __name((env, name, content) => {
|
|
2317
|
+
const path = snapshotPath(env, name, content.metadata.id);
|
|
2318
|
+
writeSecurely(path, `${JSON.stringify(content)}
|
|
2319
|
+
`, 384);
|
|
2320
|
+
writeSecurely(path.replace(/\.json$/, ".md"), content.markdown, 384);
|
|
2321
|
+
}, "saveSnapshot");
|
|
2322
|
+
var removeSnapshot = /* @__PURE__ */ __name((env, name, id) => {
|
|
2323
|
+
const path = snapshotPath(env, name, id);
|
|
2324
|
+
for (const file of [path, path.replace(/\.json$/, ".md")]) {
|
|
2325
|
+
try {
|
|
2326
|
+
unlinkSync(file);
|
|
2327
|
+
} catch (error) {
|
|
2328
|
+
if (error.code !== "ENOENT")
|
|
2329
|
+
throw error;
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
}, "removeSnapshot");
|
|
2333
|
+
var readSnapshot = /* @__PURE__ */ __name((env, name, id) => {
|
|
2334
|
+
try {
|
|
2335
|
+
return JSON.parse(readFileSync(snapshotPath(env, name, id), "utf8"));
|
|
2336
|
+
} catch {
|
|
2337
|
+
throw new CliError("not_found", "source snapshot is unavailable \u2014 run drive <profile> sync --rescan", {
|
|
2338
|
+
reason: "state.snapshot-missing"
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
}, "readSnapshot");
|
|
2342
|
+
|
|
2343
|
+
// dist/profile-lock.js
|
|
2218
2344
|
var lockProfile = /* @__PURE__ */ __name(async (env, name) => {
|
|
2219
2345
|
ensureProfileDir(env, name);
|
|
2220
2346
|
let compromised = false;
|
|
@@ -2245,7 +2371,7 @@ var local = /* @__PURE__ */ __name((command, mutates = false) => annotate(comman
|
|
|
2245
2371
|
var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
|
|
2246
2372
|
const { env, selected, output, positive: positive2, offset: offset2, withIndex } = helpers;
|
|
2247
2373
|
const catalog = local(program.command("catalog")).description("browse stored Drive files and folders offline");
|
|
2248
|
-
const
|
|
2374
|
+
const run3 = /* @__PURE__ */ __name(async (fn, write = false) => {
|
|
2249
2375
|
const profile = activeProfile(env, selected());
|
|
2250
2376
|
return withIndex(async (index) => {
|
|
2251
2377
|
const lock = write ? await lockProfile(env, selected()) : void 0;
|
|
@@ -2271,16 +2397,16 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
|
|
|
2271
2397
|
});
|
|
2272
2398
|
return found;
|
|
2273
2399
|
}, "entry");
|
|
2274
|
-
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
|
|
2400
|
+
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) => {
|
|
2275
2401
|
const state = readState(env, selected(), principal);
|
|
2276
2402
|
return index.catalog.import(principal, catalogFiles(state, activeProfile(env, selected()).roots));
|
|
2277
2403
|
}, true))));
|
|
2278
2404
|
examples(annotate(local(catalog.command("show").description("show stored metadata and the stable file or folder reference")), {
|
|
2279
2405
|
output: { entity: "document", view: "drive_catalog" }
|
|
2280
|
-
}), ["drive personal catalog show FILE_ID --offline"]).argument("<file>", "Google file or folder id, or its Drive URL").action(async (id) => output(itemOf(await
|
|
2406
|
+
}), ["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))))));
|
|
2281
2407
|
const list = /* @__PURE__ */ __name(async (words, args, search) => {
|
|
2282
2408
|
const ast = words.length ? validateQuery(parseLucene(words.join(" "), { defaultField: search ? "text" : "none" }), CATALOG_QUERY) : void 0;
|
|
2283
|
-
const result = await
|
|
2409
|
+
const result = await run3((index, principal) => index.catalog.list(principal, { ast, limit: args.limit, offset: (args.page - 1) * args.limit }));
|
|
2284
2410
|
output(listOf(`catalog ${search ? "search" : "list"}`, {
|
|
2285
2411
|
items: result.items.map(catalogOutput),
|
|
2286
2412
|
limit: args.limit,
|
|
@@ -2295,7 +2421,7 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
|
|
|
2295
2421
|
]).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"));
|
|
2296
2422
|
annotate(command, { query: CATALOG_QUERY, output: { entity: "document", view: "drive_catalog" } });
|
|
2297
2423
|
}
|
|
2298
|
-
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
|
|
2424
|
+
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) => {
|
|
2299
2425
|
const items = [];
|
|
2300
2426
|
for (let skip = 0; skip < 1e4; skip += 1e3) {
|
|
2301
2427
|
const page = await index.catalog.list(principal, { limit: 1e3, offset: skip });
|
|
@@ -2316,7 +2442,7 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
|
|
|
2316
2442
|
command.argument("<tags...>", "local tag names");
|
|
2317
2443
|
command.action(async (id, values2 = []) => {
|
|
2318
2444
|
const filter = action === "list" ? termsOf(values2, TAGS_QUERY, "catalog tags list") : void 0;
|
|
2319
|
-
return output(allOf(await
|
|
2445
|
+
return output(allOf(await run3(async (index, principal) => {
|
|
2320
2446
|
const found = await entry(index, principal, id);
|
|
2321
2447
|
if (!index.knowledge)
|
|
2322
2448
|
throw new CliError("configuration_error", "index has no shared knowledge adapter");
|
|
@@ -2328,7 +2454,110 @@ var installCatalogCommands = /* @__PURE__ */ __name((program, helpers) => {
|
|
|
2328
2454
|
}, "installCatalogCommands");
|
|
2329
2455
|
|
|
2330
2456
|
// dist/commands/config.js
|
|
2331
|
-
import { join } from "node:path";
|
|
2457
|
+
import { join as join3 } from "node:path";
|
|
2458
|
+
|
|
2459
|
+
// dist/policy.js
|
|
2460
|
+
import { join as join2 } from "node:path";
|
|
2461
|
+
var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
|
|
2462
|
+
var overridesOf = /* @__PURE__ */ __name((entries = []) => {
|
|
2463
|
+
const levels = {};
|
|
2464
|
+
for (const entry of entries) {
|
|
2465
|
+
const [key = "", level = "", extra] = entry.split("=");
|
|
2466
|
+
if (!/^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/.test(key) || !LEVELS.includes(level) || extra)
|
|
2467
|
+
throw new CliError("validation_error", "--permission takes a command path and level, e.g. files.trash=deny (deny, readonly, ask, allow)");
|
|
2468
|
+
levels[key] = level;
|
|
2469
|
+
}
|
|
2470
|
+
return levels;
|
|
2471
|
+
}, "overridesOf");
|
|
2472
|
+
var policySettings = /* @__PURE__ */ __name((env, profile, flags = {}) => {
|
|
2473
|
+
const keys = flags.permissionKeys;
|
|
2474
|
+
const names = keys && permissionNames(keys);
|
|
2475
|
+
const { config, issues } = inspectConfig(env, names);
|
|
2476
|
+
const [first] = issues;
|
|
2477
|
+
if (first)
|
|
2478
|
+
throw first.kind === "unknown_permission" ? new CliError("configuration_error", refusal(issues).message, {
|
|
2479
|
+
reason: "policy.unknown-key",
|
|
2480
|
+
permission: first.key?.slice("permissions.".length)
|
|
2481
|
+
}) : refusal(issues);
|
|
2482
|
+
const own = config.profiles[profile];
|
|
2483
|
+
const overrides = overridesOf(flags.permission);
|
|
2484
|
+
if (names) {
|
|
2485
|
+
for (const key of Object.keys(overrides))
|
|
2486
|
+
if (!names.has(key))
|
|
2487
|
+
throw new CliError("validation_error", `--permission names ${key}, which is no drive command; see drive commands`, {
|
|
2488
|
+
reason: "policy.unknown-key",
|
|
2489
|
+
permission: key
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
const saved = layerPermissions([
|
|
2493
|
+
["profile", own?.permissions],
|
|
2494
|
+
["defaults", config.defaults?.permissions]
|
|
2495
|
+
]).levels;
|
|
2496
|
+
for (const [key, level] of Object.entries(overrides)) {
|
|
2497
|
+
const under = [...Object.keys(saved), ...Object.keys(DEFAULT_LEVELS)].filter((named) => named.startsWith(`${key}.`));
|
|
2498
|
+
const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(saved, named, DEFAULT_LEVELS).level]);
|
|
2499
|
+
if (lifted !== void 0)
|
|
2500
|
+
throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(saved, lifted, DEFAULT_LEVELS).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { reason: "policy.flag-loosens", permission: lifted });
|
|
2501
|
+
}
|
|
2502
|
+
const { levels } = layerPermissions([
|
|
2503
|
+
["flags", overrides],
|
|
2504
|
+
["profile", own?.permissions],
|
|
2505
|
+
["defaults", config.defaults?.permissions]
|
|
2506
|
+
]);
|
|
2507
|
+
const lock = readOnlyLockOf(DRIVE_APP, env);
|
|
2508
|
+
const ceiling = setupPermissionCeiling(env);
|
|
2509
|
+
return {
|
|
2510
|
+
levels: ceiling ? { ...levels, [CEILING_KEY]: ceiling } : levels,
|
|
2511
|
+
lock,
|
|
2512
|
+
readOnly: lock !== void 0 || ceiling === "readonly" || flags.readOnly === true
|
|
2513
|
+
};
|
|
2514
|
+
}, "policySettings");
|
|
2515
|
+
var refuseUnderReadOnly = /* @__PURE__ */ __name((env, what) => {
|
|
2516
|
+
const lock = readOnlyLockOf(DRIVE_APP, env);
|
|
2517
|
+
if (lock)
|
|
2518
|
+
throw readOnlyRefusal(lock, what);
|
|
2519
|
+
}, "refuseUnderReadOnly");
|
|
2520
|
+
var checkPolicy = /* @__PURE__ */ __name(async (env, profile, key, mutates, flags = {}, ask) => {
|
|
2521
|
+
const { levels, readOnly, lock } = policySettings(env, profile, flags);
|
|
2522
|
+
const { level } = levelFor(levels, key, DEFAULT_LEVELS);
|
|
2523
|
+
if (mutates && lock)
|
|
2524
|
+
throw readOnlyRefusal(lock, "change local or Google data");
|
|
2525
|
+
if (level === "deny" || mutates && (readOnly || level === "readonly"))
|
|
2526
|
+
throw new CliError("permission_error", "profile policy refuses this operation", {
|
|
2527
|
+
reason: "policy.denied",
|
|
2528
|
+
permission: key
|
|
2529
|
+
});
|
|
2530
|
+
if (mutates && level === "ask" && !flags.dryRun) {
|
|
2531
|
+
const destructive = DEFAULT_LEVELS[key] === "ask";
|
|
2532
|
+
if (destructive ? flags.allowDangerous : flags.yes)
|
|
2533
|
+
return;
|
|
2534
|
+
if (ask && await ask(key))
|
|
2535
|
+
return;
|
|
2536
|
+
throw new CliError("confirmation_required", destructive ? "this deletion requires --allow-dangerous or an explicit permission" : "profile policy requires --yes or confirmation", { reason: "policy.confirm", permission: key });
|
|
2537
|
+
}
|
|
2538
|
+
}, "checkPolicy");
|
|
2539
|
+
var guardedGoogleWrite = /* @__PURE__ */ __name(async (env, profile, key, act, flags = {}, ask, operationId = newOperationId()) => {
|
|
2540
|
+
const settings = policySettings(env, profile, flags);
|
|
2541
|
+
const guard = sendGuard({
|
|
2542
|
+
profile,
|
|
2543
|
+
command: "drive",
|
|
2544
|
+
readOnlyLock: settings.lock ?? (settings.readOnly ? "profile" : void 0),
|
|
2545
|
+
permissions: settings.levels,
|
|
2546
|
+
permissionDefaults: DEFAULT_LEVELS,
|
|
2547
|
+
ask: /* @__PURE__ */ __name(async (permission) => checkPolicy(env, profile, permission, true, flags, ask), "ask"),
|
|
2548
|
+
sendsPerHour: Number.MAX_SAFE_INTEGER,
|
|
2549
|
+
journal: new SendJournal(join2(paths(env).state, "sends", `${profile}.jsonl`), {
|
|
2550
|
+
service: "drive",
|
|
2551
|
+
version: VERSION
|
|
2552
|
+
}),
|
|
2553
|
+
recipients: new RecipientList(join2(paths(env).state, "recipients", `${profile}.json`), "drive"),
|
|
2554
|
+
warn: /* @__PURE__ */ __name(() => {
|
|
2555
|
+
}, "warn")
|
|
2556
|
+
});
|
|
2557
|
+
return guardedWrite(guard, { chatId: null, kind: "edit", key, operationId }, act);
|
|
2558
|
+
}, "guardedGoogleWrite");
|
|
2559
|
+
|
|
2560
|
+
// dist/commands/config.js
|
|
2332
2561
|
var isNode = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isNode");
|
|
2333
2562
|
var without = /* @__PURE__ */ __name((raw, at) => {
|
|
2334
2563
|
const copy = structuredClone(raw);
|
|
@@ -2480,7 +2709,7 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
|
|
|
2480
2709
|
throw new CliError("permission_error", "downloading a model needs the network; --offline was requested", {
|
|
2481
2710
|
reason: "offline.refused"
|
|
2482
2711
|
});
|
|
2483
|
-
const { downloadImageModel, downloadTextModel } = await import("./services-
|
|
2712
|
+
const { downloadImageModel, downloadTextModel } = await import("./services-C3XWRA2W.js");
|
|
2484
2713
|
const progress = /* @__PURE__ */ __name((line) => {
|
|
2485
2714
|
if (!program.opts().quiet)
|
|
2486
2715
|
streams.diagnostic(line);
|
|
@@ -2494,7 +2723,7 @@ var installModelCommands = /* @__PURE__ */ __name((program, { env, output, strea
|
|
|
2494
2723
|
licence: model.licence,
|
|
2495
2724
|
size_bytes: model.files.reduce((sum, file) => sum + file.bytes, 0),
|
|
2496
2725
|
downloaded: true,
|
|
2497
|
-
path:
|
|
2726
|
+
path: join3(directory, model.id)
|
|
2498
2727
|
}));
|
|
2499
2728
|
}, "download");
|
|
2500
2729
|
const sharedModels = modelCatalogueCommand(DRIVE_APP, {
|
|
@@ -2526,243 +2755,9 @@ var offset = /* @__PURE__ */ __name((input) => {
|
|
|
2526
2755
|
}, "offset");
|
|
2527
2756
|
|
|
2528
2757
|
// dist/contract-overrides.js
|
|
2529
|
-
var MCP_REASON = "Drive exposes Google document tools over stdio and HTTP using OAuth grants and its document permission adapter; its tool listing and command catalogue replace the messenger setup commands.";
|
|
2530
2758
|
var NOTES_REASON = "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.";
|
|
2531
2759
|
var SEARCH_REASON = "Drive searches imported documents and embeddings rather than live messenger messages; its default action and pagination are explicitly provider-specific.";
|
|
2532
|
-
var PROFILES_OPTION = {
|
|
2533
|
-
flags: "--profiles <names|all>",
|
|
2534
|
-
description: "serve several profiles from one server instead of one: names, comma-separated, or all for every profile",
|
|
2535
|
-
takes_value: true,
|
|
2536
|
-
mandatory: false
|
|
2537
|
-
};
|
|
2538
|
-
var SERVER_PROFILES_OPTION = {
|
|
2539
|
-
flags: "--profiles <names|all>",
|
|
2540
|
-
description: "the server of several profiles that `mcp serve --profiles` serves: names, comma-separated, or all",
|
|
2541
|
-
takes_value: true,
|
|
2542
|
-
mandatory: false
|
|
2543
|
-
};
|
|
2544
2760
|
var SHELL_OVERRIDES = {
|
|
2545
|
-
skill: [
|
|
2546
|
-
{
|
|
2547
|
-
command: ["skill"],
|
|
2548
|
-
field: "effects",
|
|
2549
|
-
before: null,
|
|
2550
|
-
after: {
|
|
2551
|
-
remote: "none",
|
|
2552
|
-
local: "none"
|
|
2553
|
-
},
|
|
2554
|
-
reason: "Drive binds agent installation to its own output renderer and provider skill locations."
|
|
2555
|
-
},
|
|
2556
|
-
{
|
|
2557
|
-
command: ["skill", "show"],
|
|
2558
|
-
field: "summary",
|
|
2559
|
-
before: "print the tool's instructions for AI agents",
|
|
2560
|
-
after: "print drive's SKILL.md",
|
|
2561
|
-
reason: "Drive binds agent installation to its own output renderer and provider skill locations."
|
|
2562
|
-
},
|
|
2563
|
-
{
|
|
2564
|
-
command: ["skill", "install"],
|
|
2565
|
-
field: "summary",
|
|
2566
|
-
before: "install the tool's instructions for AI agents",
|
|
2567
|
-
after: "put SKILL.md for Claude Code, Codex, Gemini CLI, OpenClaw, and Hermes on request",
|
|
2568
|
-
reason: "Drive binds agent installation to its own output renderer and provider skill locations."
|
|
2569
|
-
},
|
|
2570
|
-
{
|
|
2571
|
-
command: ["skill", "install"],
|
|
2572
|
-
field: "examples",
|
|
2573
|
-
before: ["drive skill install --for agents"],
|
|
2574
|
-
after: ["drive skill install --for all"],
|
|
2575
|
-
reason: "Drive binds agent installation to its own output renderer and provider skill locations."
|
|
2576
|
-
}
|
|
2577
|
-
],
|
|
2578
|
-
doctor: [
|
|
2579
|
-
{
|
|
2580
|
-
command: ["doctor"],
|
|
2581
|
-
field: "description",
|
|
2582
|
-
before: "the state this installation is in, without connecting unless --online",
|
|
2583
|
-
after: "check this installation: config, profiles, paths; no keyring, store or network",
|
|
2584
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2585
|
-
},
|
|
2586
|
-
{
|
|
2587
|
-
command: ["doctor"],
|
|
2588
|
-
field: "effects",
|
|
2589
|
-
before: {
|
|
2590
|
-
remote: "read",
|
|
2591
|
-
local: "read"
|
|
2592
|
-
},
|
|
2593
|
-
after: {
|
|
2594
|
-
remote: "none",
|
|
2595
|
-
local: "read"
|
|
2596
|
-
},
|
|
2597
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2598
|
-
},
|
|
2599
|
-
{
|
|
2600
|
-
command: ["doctor"],
|
|
2601
|
-
field: "runnable",
|
|
2602
|
-
before: true,
|
|
2603
|
-
after: null,
|
|
2604
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2605
|
-
},
|
|
2606
|
-
{
|
|
2607
|
-
command: ["doctor"],
|
|
2608
|
-
field: "options",
|
|
2609
|
-
before: [
|
|
2610
|
-
{
|
|
2611
|
-
flags: "--online",
|
|
2612
|
-
description: "also connect once and read the account; sends nothing",
|
|
2613
|
-
takes_value: false,
|
|
2614
|
-
mandatory: false
|
|
2615
|
-
}
|
|
2616
|
-
],
|
|
2617
|
-
after: [],
|
|
2618
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2619
|
-
},
|
|
2620
|
-
{
|
|
2621
|
-
command: ["doctor"],
|
|
2622
|
-
field: "children",
|
|
2623
|
-
before: ["reports"],
|
|
2624
|
-
after: [],
|
|
2625
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2626
|
-
},
|
|
2627
|
-
{
|
|
2628
|
-
command: ["doctor"],
|
|
2629
|
-
field: "examples",
|
|
2630
|
-
before: null,
|
|
2631
|
-
after: ["drive doctor", "drive doctor --json"],
|
|
2632
|
-
reason: "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection."
|
|
2633
|
-
}
|
|
2634
|
-
],
|
|
2635
|
-
mcp: [
|
|
2636
|
-
{
|
|
2637
|
-
command: ["mcp"],
|
|
2638
|
-
field: "children",
|
|
2639
|
-
before: ["serve", "revoke", "server", "config", "add", "check"],
|
|
2640
|
-
after: ["serve", "revoke", "server"],
|
|
2641
|
-
reason: MCP_REASON
|
|
2642
|
-
},
|
|
2643
|
-
{
|
|
2644
|
-
command: ["mcp", "serve"],
|
|
2645
|
-
field: "examples",
|
|
2646
|
-
before: [
|
|
2647
|
-
"drive personal mcp serve",
|
|
2648
|
-
"drive mcp serve --profiles work,personal",
|
|
2649
|
-
"drive personal mcp serve --http --public-url https://laptop.example.ts.net"
|
|
2650
|
-
],
|
|
2651
|
-
after: [
|
|
2652
|
-
"drive personal mcp serve --tools",
|
|
2653
|
-
"drive personal mcp serve",
|
|
2654
|
-
"drive personal mcp serve --http --public-url https://laptop.example.ts.net"
|
|
2655
|
-
],
|
|
2656
|
-
reason: MCP_REASON
|
|
2657
|
-
},
|
|
2658
|
-
{
|
|
2659
|
-
command: ["mcp", "serve"],
|
|
2660
|
-
field: "options",
|
|
2661
|
-
before: [
|
|
2662
|
-
{
|
|
2663
|
-
flags: "--permission <key=level>",
|
|
2664
|
-
description: "make a permission stricter for this server only, like messages.send=deny; it never loosens the profile; repeat for more keys",
|
|
2665
|
-
takes_value: true,
|
|
2666
|
-
mandatory: false
|
|
2667
|
-
},
|
|
2668
|
-
PROFILES_OPTION,
|
|
2669
|
-
{
|
|
2670
|
-
flags: "--http",
|
|
2671
|
-
description: "serve over HTTP on 127.0.0.1 for ChatGPT and Claude in the browser, behind your tunnel; the profile's permissions decide",
|
|
2672
|
-
takes_value: false,
|
|
2673
|
-
mandatory: false
|
|
2674
|
-
},
|
|
2675
|
-
{
|
|
2676
|
-
flags: "--port <port>",
|
|
2677
|
-
description: "the local port for --http (default 8765)",
|
|
2678
|
-
takes_value: true,
|
|
2679
|
-
mandatory: false
|
|
2680
|
-
},
|
|
2681
|
-
{
|
|
2682
|
-
flags: "--public-url <url>",
|
|
2683
|
-
description: "the tunnel's https address the browser apps use, e.g. https://<name>.ts.net or https://<name>.ts.net/tg",
|
|
2684
|
-
takes_value: true,
|
|
2685
|
-
mandatory: false
|
|
2686
|
-
}
|
|
2687
|
-
],
|
|
2688
|
-
after: [
|
|
2689
|
-
{
|
|
2690
|
-
flags: "--tools",
|
|
2691
|
-
description: "list the commands the server offers instead of starting it",
|
|
2692
|
-
takes_value: false,
|
|
2693
|
-
mandatory: false
|
|
2694
|
-
},
|
|
2695
|
-
{
|
|
2696
|
-
flags: "--http",
|
|
2697
|
-
description: "serve over HTTP on 127.0.0.1 for ChatGPT and Claude in the browser, behind your tunnel; the profile's permissions decide",
|
|
2698
|
-
takes_value: false,
|
|
2699
|
-
mandatory: false
|
|
2700
|
-
},
|
|
2701
|
-
{
|
|
2702
|
-
flags: "--port <port>",
|
|
2703
|
-
description: "the local port for --http (default 8765)",
|
|
2704
|
-
takes_value: true,
|
|
2705
|
-
mandatory: false
|
|
2706
|
-
},
|
|
2707
|
-
{
|
|
2708
|
-
flags: "--public-url <url>",
|
|
2709
|
-
description: "the tunnel's https address the browser apps use, e.g. https://<name>.ts.net or https://<name>.ts.net/drive",
|
|
2710
|
-
takes_value: true,
|
|
2711
|
-
mandatory: false
|
|
2712
|
-
},
|
|
2713
|
-
PROFILES_OPTION
|
|
2714
|
-
],
|
|
2715
|
-
reason: MCP_REASON
|
|
2716
|
-
},
|
|
2717
|
-
{
|
|
2718
|
-
command: ["mcp", "revoke"],
|
|
2719
|
-
field: "examples",
|
|
2720
|
-
before: ["drive personal mcp revoke", "drive mcp revoke --profiles all"],
|
|
2721
|
-
after: ["drive personal mcp revoke"],
|
|
2722
|
-
reason: MCP_REASON
|
|
2723
|
-
},
|
|
2724
|
-
{
|
|
2725
|
-
command: ["mcp", "server", "start"],
|
|
2726
|
-
field: "options",
|
|
2727
|
-
before: [
|
|
2728
|
-
{
|
|
2729
|
-
flags: "--port <port>",
|
|
2730
|
-
description: "the local port (default 8765)",
|
|
2731
|
-
takes_value: true,
|
|
2732
|
-
mandatory: false
|
|
2733
|
-
},
|
|
2734
|
-
{
|
|
2735
|
-
flags: "--public-url <url>",
|
|
2736
|
-
description: "the tunnel's https address the browser apps use, e.g. https://<name>.ts.net or https://<name>.ts.net/tg",
|
|
2737
|
-
takes_value: true,
|
|
2738
|
-
mandatory: false
|
|
2739
|
-
},
|
|
2740
|
-
{
|
|
2741
|
-
flags: "--permission <key=level>",
|
|
2742
|
-
description: "make a permission stricter for this server only; repeat for more keys",
|
|
2743
|
-
takes_value: true,
|
|
2744
|
-
mandatory: false
|
|
2745
|
-
},
|
|
2746
|
-
SERVER_PROFILES_OPTION
|
|
2747
|
-
],
|
|
2748
|
-
after: [
|
|
2749
|
-
{
|
|
2750
|
-
flags: "--port <port>",
|
|
2751
|
-
description: "the local port (default 8765)",
|
|
2752
|
-
takes_value: true,
|
|
2753
|
-
mandatory: false
|
|
2754
|
-
},
|
|
2755
|
-
{
|
|
2756
|
-
flags: "--public-url <url>",
|
|
2757
|
-
description: "the tunnel's https address the browser apps use, e.g. https://<name>.ts.net or https://<name>.ts.net/tg",
|
|
2758
|
-
takes_value: true,
|
|
2759
|
-
mandatory: false
|
|
2760
|
-
},
|
|
2761
|
-
SERVER_PROFILES_OPTION
|
|
2762
|
-
],
|
|
2763
|
-
reason: MCP_REASON
|
|
2764
|
-
}
|
|
2765
|
-
],
|
|
2766
2761
|
notes: [
|
|
2767
2762
|
{
|
|
2768
2763
|
command: ["notes"],
|
|
@@ -3509,68 +3504,8 @@ var installCommandsCommand = /* @__PURE__ */ __name((...args) => {
|
|
|
3509
3504
|
}, SHELL_OVERRIDES.commands);
|
|
3510
3505
|
}, "installCommandsCommand");
|
|
3511
3506
|
|
|
3512
|
-
// dist/commands/doctor.js
|
|
3513
|
-
import { existsSync } from "node:fs";
|
|
3514
|
-
import { resolve } from "node:path";
|
|
3515
|
-
var failure = /* @__PURE__ */ __name((error) => {
|
|
3516
|
-
if (error instanceof CliError)
|
|
3517
|
-
return error.message;
|
|
3518
|
-
throw error;
|
|
3519
|
-
}, "failure");
|
|
3520
|
-
var doctorReport = /* @__PURE__ */ __name((env, permissionKeys2) => {
|
|
3521
|
-
const where = paths(env);
|
|
3522
|
-
const file = inspectConfig(env, permissionNames(permissionKeys2));
|
|
3523
|
-
const config = { path: file.path, found: file.found, issues: file.issues };
|
|
3524
|
-
const profiles = Object.entries(file.config.profiles).map(([name, profile]) => ({
|
|
3525
|
-
profile: name,
|
|
3526
|
-
selected_folders: profile.roots.length,
|
|
3527
|
-
storage: profile.storage
|
|
3528
|
-
}));
|
|
3529
|
-
let oauth;
|
|
3530
|
-
try {
|
|
3531
|
-
application(env);
|
|
3532
|
-
oauth = { client: env.DRIVE_GOOGLE_CLIENT_ID ? "own" : "wirecat" };
|
|
3533
|
-
} catch (error) {
|
|
3534
|
-
oauth = { client: "own", error: failure(error) };
|
|
3535
|
-
}
|
|
3536
|
-
const store = resolve(storePath(env));
|
|
3537
|
-
const files = privateFiles({ files: [file.path], dirs: [where.config] });
|
|
3538
|
-
return {
|
|
3539
|
-
version: VERSION,
|
|
3540
|
-
runtime: { node: process.versions.node, platform: process.platform },
|
|
3541
|
-
paths: { config: where.config, state: where.state, cache: where.cache },
|
|
3542
|
-
config,
|
|
3543
|
-
profiles,
|
|
3544
|
-
oauth_application: oauth,
|
|
3545
|
-
store: { path: store, exists: existsSync(store) },
|
|
3546
|
-
read_only: env.DRIVE_READ_ONLY && env.DRIVE_READ_ONLY !== "0" ? "DRIVE_READ_ONLY" : null,
|
|
3547
|
-
profile_lock: env.DRIVE_PROFILE_LOCK || null,
|
|
3548
|
-
login: "not checked",
|
|
3549
|
-
files: files.checked ? { ...files, problems: files.problems.map(({ path, mode, want }) => ({ path, mode, want })) } : files,
|
|
3550
|
-
fixes: files.checked ? files.problems.map((problem) => problem.fix) : []
|
|
3551
|
-
};
|
|
3552
|
-
}, "doctorReport");
|
|
3553
|
-
var installDoctorCommandDefinition = /* @__PURE__ */ __name((program, { env, output, streams, policyFlags }) => {
|
|
3554
|
-
examples(annotate(program.command("doctor"), { effects: LOCAL_READ }).description("check this installation: config, profiles, paths; no keyring, store or network"), ["drive doctor", "drive doctor --json"]).action(() => {
|
|
3555
|
-
const { fixes, ...report } = doctorReport(env, policyFlags().permissionKeys ?? /* @__PURE__ */ new Set());
|
|
3556
|
-
output(itemOf(report));
|
|
3557
|
-
for (const fix of fixes)
|
|
3558
|
-
streams.diagnostic(`to make it private: ${fix}`);
|
|
3559
|
-
});
|
|
3560
|
-
}, "installDoctorCommandDefinition");
|
|
3561
|
-
var installDoctorCommand = /* @__PURE__ */ __name((...args) => {
|
|
3562
|
-
customizeSharedCommand(sharedCommandTemplate(DRIVE_APP, "doctor"), "Drive diagnoses public OAuth configuration and local paths without opening a keyring, database or Google connection.", () => {
|
|
3563
|
-
installDoctorCommandDefinition(...args);
|
|
3564
|
-
const command = args[0].commands.find((command2) => command2.name() === "doctor");
|
|
3565
|
-
if (!command)
|
|
3566
|
-
throw new Error("doctor builder did not install its command");
|
|
3567
|
-
return command;
|
|
3568
|
-
}, SHELL_OVERRIDES.doctor);
|
|
3569
|
-
}, "installDoctorCommand");
|
|
3570
|
-
|
|
3571
3507
|
// dist/commands/documents.js
|
|
3572
|
-
import {
|
|
3573
|
-
import { dirname } from "node:path";
|
|
3508
|
+
import { writeFileSync } from "node:fs";
|
|
3574
3509
|
|
|
3575
3510
|
// dist/age.js
|
|
3576
3511
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
@@ -3673,8 +3608,6 @@ var installDocumentCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
3673
3608
|
});
|
|
3674
3609
|
examples(annotate(documents.command("export"), { effects: LOCAL_WRITE }).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) => {
|
|
3675
3610
|
const { id, snapshot } = imported(input);
|
|
3676
|
-
if (context.options.mcp)
|
|
3677
|
-
mkdirSync(dirname(args.output), { recursive: true, mode: 448 });
|
|
3678
3611
|
try {
|
|
3679
3612
|
writeFileSync(args.output, snapshot.markdown, { flag: "wx", mode: 384 });
|
|
3680
3613
|
} catch (error) {
|
|
@@ -3823,41 +3756,41 @@ var memorySearch = /* @__PURE__ */ __name((words) => {
|
|
|
3823
3756
|
|
|
3824
3757
|
// dist/commands/knowledge.js
|
|
3825
3758
|
var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helpers) => {
|
|
3826
|
-
const { run, output, positive: positive2 } = helpers;
|
|
3759
|
+
const { run: run3, output, positive: positive2 } = helpers;
|
|
3827
3760
|
const documentArgument = "Google file or folder id or URL in the local catalog";
|
|
3828
3761
|
const scopes = ["personal", "work"];
|
|
3829
3762
|
const documents = program.commands.find((command) => command.name() === "documents");
|
|
3830
|
-
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
|
|
3763
|
+
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)))));
|
|
3831
3764
|
const tags = annotate(program.command("tags"), { effects: LOCAL_READ }).description("label imported documents; labels survive a sync");
|
|
3832
3765
|
for (const action of ["list", "add", "remove"]) {
|
|
3833
3766
|
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"}`]);
|
|
3834
3767
|
if (action === "list") {
|
|
3835
3768
|
bindQuery(command, TAGS_QUERY, tagRow).action(async (doc, words) => {
|
|
3836
3769
|
const filter = termsOf(words, TAGS_QUERY, "tags list");
|
|
3837
|
-
output(allOf((await
|
|
3770
|
+
output(allOf((await run3(doc, (k, p, ref) => k.tags(p, ref, "list", [], filter))).map((tag) => ({ tag }))));
|
|
3838
3771
|
});
|
|
3839
3772
|
} else
|
|
3840
|
-
command.argument("<tags...>", "one or more tags").action(async (doc, values2) => output(itemOf({ tags: await
|
|
3773
|
+
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)) })));
|
|
3841
3774
|
}
|
|
3842
3775
|
const relationships = annotate(program.command("relationships"), { effects: LOCAL_READ }).description("connect a document to people, projects, notes and other references");
|
|
3843
3776
|
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) => {
|
|
3844
3777
|
const { confirmed, ...filter } = termsOf(words, LINKS_QUERY, "relationships list");
|
|
3845
|
-
output(allOf(await
|
|
3778
|
+
output(allOf(await run3(doc, (k, p, ref) => k.links(p, ref, { ...filter, ...confirmed === void 0 ? {} : { confirmed: confirmed === "true" } }))));
|
|
3846
3779
|
});
|
|
3847
3780
|
examples(annotate(relationships.command("add"), { effects: LOCAL_WRITE }).description("connect a document to another reference"), [
|
|
3848
3781
|
"drive personal relationships add DOC_ID project:PROJECT_ID --kind about",
|
|
3849
3782
|
"drive personal relationships add DOC_ID person:PERSON_UID --kind assigned-to --role reviewer"
|
|
3850
|
-
]).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
|
|
3851
|
-
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
|
|
3783
|
+
]).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, ...reason ? { evidence: reason } : {} })))));
|
|
3784
|
+
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)))));
|
|
3852
3785
|
const notes = annotate(program.command("notes"), { effects: LOCAL_READ }).description("write notes about an imported document");
|
|
3853
3786
|
const noteArgument = "note:<id> reference, as notes list prints it";
|
|
3854
|
-
examples(annotate(notes.command("add"), { effects: LOCAL_WRITE, output: { entity: "note" } }).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
|
|
3787
|
+
examples(annotate(notes.command("add"), { effects: LOCAL_WRITE, output: { entity: "note" } }).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)))));
|
|
3855
3788
|
withQuery(examples(annotate(notes.command("list"), { effects: LOCAL_READ }).description("list a document's notes"), [
|
|
3856
3789
|
"drive personal notes list DOC_ID",
|
|
3857
3790
|
"drive personal notes list DOC_ID text:review --limit 10"
|
|
3858
3791
|
]).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 }) => {
|
|
3859
3792
|
const query = termsOf(words, NOTES_QUERY, "notes list").text;
|
|
3860
|
-
const found = await
|
|
3793
|
+
const found = await run3(doc, (k, p, ref) => k.notes(p, ref, { ...query ? { search: query } : {}, limit, offset: (page - 1) * limit }));
|
|
3861
3794
|
output(listOf("notes list", {
|
|
3862
3795
|
items: found.items,
|
|
3863
3796
|
limit,
|
|
@@ -3866,15 +3799,15 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3866
3799
|
args: { document: doc, query: words.join(" ") }
|
|
3867
3800
|
}));
|
|
3868
3801
|
});
|
|
3869
|
-
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
|
|
3870
|
-
examples(annotate(notes.command("edit"), { effects: LOCAL_WRITE, output: { entity: "note" } }).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
|
|
3802
|
+
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)))));
|
|
3803
|
+
examples(annotate(notes.command("edit"), { effects: LOCAL_WRITE, output: { entity: "note" } }).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)))));
|
|
3871
3804
|
examples(annotate(notes.command("remove"), { effects: LOCAL_WRITE }).description("delete one note"), [
|
|
3872
3805
|
"drive personal notes remove DOC_ID note:NOTE_ID"
|
|
3873
|
-
]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await
|
|
3806
|
+
]).argument("<document>", documentArgument).argument("<note>", noteArgument).action(async (doc, noteRef) => output(itemOf(await run3(doc, (k, p, ref) => k.removeNote(p, ref, noteRef)))));
|
|
3874
3807
|
const memories = annotate(program.command("memories"), { effects: LOCAL_READ }).description("keep what was learned from a document, with evidence; an agent's stay proposed");
|
|
3875
3808
|
const memoryArgument = "memory:<id> reference, as memories list prints it";
|
|
3876
3809
|
const scope = /* @__PURE__ */ __name((description) => new Option("--scope <scope>", description).choices(scopes), "scope");
|
|
3877
|
-
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
|
|
3810
|
+
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" }))))));
|
|
3878
3811
|
withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
|
|
3879
3812
|
"drive personal memories list DOC_ID scope:work",
|
|
3880
3813
|
"drive personal memories list DOC_ID kind:preference status:confirmed"
|
|
@@ -3885,7 +3818,7 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3885
3818
|
...terms.has("status") ? { status: terms.get("status") } : {},
|
|
3886
3819
|
...terms.has("scope") ? { scope: terms.get("scope") } : {}
|
|
3887
3820
|
};
|
|
3888
|
-
output(allOf((await
|
|
3821
|
+
output(allOf((await run3(doc, (k, p, ref) => k.memories(p, ref, { ...filters, limit }))).map(memoryItem)));
|
|
3889
3822
|
});
|
|
3890
3823
|
const memoryActions = {
|
|
3891
3824
|
show: "show one memory",
|
|
@@ -3893,13 +3826,13 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3893
3826
|
stale: "mark a memory as out of date"
|
|
3894
3827
|
};
|
|
3895
3828
|
for (const [action, description] of Object.entries(memoryActions))
|
|
3896
|
-
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
|
|
3829
|
+
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) => k.memory(p, ref, memoryRef, action))))));
|
|
3897
3830
|
const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [
|
|
3898
3831
|
"drive personal memories search DOC_ID reviews scope:work",
|
|
3899
3832
|
`drive personal memories search DOC_ID "async reviews"`
|
|
3900
3833
|
]).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) => {
|
|
3901
3834
|
const { text, scope: scope2 } = memorySearch(words);
|
|
3902
|
-
const found = await
|
|
3835
|
+
const found = await run3(doc, (k, p, ref) => k.searchMemories(p, ref, text, scope2));
|
|
3903
3836
|
output({
|
|
3904
3837
|
...allOf(found.items.map(memoryItem)),
|
|
3905
3838
|
...found.limit_reached ? { meta: { truncated: true } } : {}
|
|
@@ -3911,7 +3844,7 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3911
3844
|
"drive personal memories extract DOC_ID --scope work --yes"
|
|
3912
3845
|
]).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) {
|
|
3913
3846
|
const args = this.optsWithGlobals();
|
|
3914
|
-
await
|
|
3847
|
+
await run3(doc, async () => void 0);
|
|
3915
3848
|
const result = await extractDocumentMemories({
|
|
3916
3849
|
read: /* @__PURE__ */ __name(() => helpers.document(doc), "read"),
|
|
3917
3850
|
complete: helpers.complete(),
|
|
@@ -3919,7 +3852,7 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3919
3852
|
author: "drive-memory",
|
|
3920
3853
|
tab: args.tab,
|
|
3921
3854
|
save: args.yes,
|
|
3922
|
-
withWrite: /* @__PURE__ */ __name((write) =>
|
|
3855
|
+
withWrite: /* @__PURE__ */ __name((write) => run3(doc, write), "withWrite")
|
|
3923
3856
|
});
|
|
3924
3857
|
output(itemOf({ ...result, saved: result.saved.map((item) => "type" in item ? factItem(item) : memoryItem(item)) }));
|
|
3925
3858
|
});
|
|
@@ -3927,7 +3860,7 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3927
3860
|
const factArgument = "fact:<id> reference, as facts list prints it";
|
|
3928
3861
|
examples(annotate(facts.command("add"), { effects: LOCAL_WRITE }).description("record a fact a document shows"), [
|
|
3929
3862
|
`drive personal facts add DOC_ID "Budget approved" --type decision --scope work`
|
|
3930
|
-
]).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
|
|
3863
|
+
]).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, {
|
|
3931
3864
|
statement,
|
|
3932
3865
|
...args,
|
|
3933
3866
|
...occurredTime === void 0 ? {} : { occurredAt: occurredTime }
|
|
@@ -3941,7 +3874,7 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3941
3874
|
...terms.has("kind") ? { type: terms.get("kind") } : {},
|
|
3942
3875
|
...terms.has("status") ? { status: terms.get("status") } : {}
|
|
3943
3876
|
};
|
|
3944
|
-
output(allOf((await
|
|
3877
|
+
output(allOf((await run3(doc, (k, p, ref) => k.facts(p, ref, { ...filters, limit }))).map(factItem)));
|
|
3945
3878
|
});
|
|
3946
3879
|
const factActions = {
|
|
3947
3880
|
show: "show one fact",
|
|
@@ -3949,13 +3882,13 @@ var installKnowledgeCommandsDefinition = /* @__PURE__ */ __name((program, helper
|
|
|
3949
3882
|
reverse: "an accepted decision no longer holds, and nothing replaced it"
|
|
3950
3883
|
};
|
|
3951
3884
|
for (const [action, description] of Object.entries(factActions))
|
|
3952
|
-
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
|
|
3885
|
+
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) => k.fact(p, ref, factRef, action))))));
|
|
3953
3886
|
const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description("the Google accounts seen on a document, and the people they belong to");
|
|
3954
3887
|
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) => {
|
|
3955
3888
|
const filter = termsOf(words, IDENTITIES_QUERY, "identities list");
|
|
3956
|
-
output(itemOf(await
|
|
3889
|
+
output(itemOf(await run3(doc, (k, p, ref) => k.people(p, ref, filter))));
|
|
3957
3890
|
});
|
|
3958
|
-
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
|
|
3891
|
+
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)))));
|
|
3959
3892
|
}, "installKnowledgeCommandsDefinition");
|
|
3960
3893
|
var installKnowledgeCommands = /* @__PURE__ */ __name((...args) => {
|
|
3961
3894
|
customizeSharedCommand(sharedCommandTemplate(DRIVE_APP, "notes"), "Drive notes annotate one explicitly selected imported document; document-bound arguments and receipts replace the generic note scope.", () => {
|
|
@@ -3967,147 +3900,16 @@ var installKnowledgeCommands = /* @__PURE__ */ __name((...args) => {
|
|
|
3967
3900
|
}, SHELL_OVERRIDES.notes);
|
|
3968
3901
|
}, "installKnowledgeCommands");
|
|
3969
3902
|
|
|
3970
|
-
// dist/commands/mcp.js
|
|
3971
|
-
var DEFAULT_PORT = 8765;
|
|
3972
|
-
var SERVER_PURPOSE = {
|
|
3973
|
-
stop: "whose server to stop",
|
|
3974
|
-
status: "whose server to check"
|
|
3975
|
-
};
|
|
3976
|
-
var installMcpCommandDefinition = /* @__PURE__ */ __name((program, { env, streams, options, selected, output, policyFlags, signal, profileWord }, createProgram2) => {
|
|
3977
|
-
const profiles = /* @__PURE__ */ __name(() => Object.keys(readConfig(env, permissionNames(policyFlags().permissionKeys ?? /* @__PURE__ */ new Set())).profiles).sort(), "profiles");
|
|
3978
|
-
const served = /* @__PURE__ */ __name((given, words, purpose = "to serve") => {
|
|
3979
|
-
const word = profileWord();
|
|
3980
|
-
const listed = /* @__PURE__ */ __name(() => `profiles here: ${profiles().join(", ") || "none"}`, "listed");
|
|
3981
|
-
if (given === void 0 && (word ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK))
|
|
3982
|
-
return { profile: selected() };
|
|
3983
|
-
if (given !== void 0 && word !== void 0)
|
|
3984
|
-
throw new CliError("validation_error", `name one profile or --profiles, not both: \`drive ${word} ${words}\` or \`drive ${words} --profiles ${given}\``, { profiles: profiles() });
|
|
3985
|
-
if (given === void 0) {
|
|
3986
|
-
if (profiles().length === 0)
|
|
3987
|
-
throw new CliError("configuration_error", "no drive profile here yet; create one with drive personal session start (any name in place of personal)");
|
|
3988
|
-
throw new CliError("validation_error", `name the profiles ${purpose}: \`drive <profile> ${words}\`, or \`drive ${words} --profiles <a,b>\` or \`--profiles all\` \u2014 ${listed()}`, { profiles: profiles() });
|
|
3989
|
-
}
|
|
3990
|
-
const names = [...new Set(given.split(",").map((one) => one.trim()))].filter(Boolean).sort();
|
|
3991
|
-
const lock = env.DRIVE_PROFILE_LOCK?.trim();
|
|
3992
|
-
if (lock && names.some((one) => one !== lock))
|
|
3993
|
-
throw new CliError("permission_error", `this process is locked to profile ${lock} (DRIVE_PROFILE_LOCK) \u2014 --profiles may name only ${lock}`, { reason: "profile.lock-refused" });
|
|
3994
|
-
if (lock)
|
|
3995
|
-
return { set: { option: lock, profiles: /* @__PURE__ */ __name(() => [lock], "profiles") } };
|
|
3996
|
-
if (names.length === 1 && names[0] === "all")
|
|
3997
|
-
return { set: { option: "all", profiles } };
|
|
3998
|
-
if (names.length === 0 || names.includes("all"))
|
|
3999
|
-
throw new CliError("validation_error", `--profiles takes profile names, comma-separated, or \`all\` alone for every profile \u2014 a profile named all is served as \`drive all ${words}\`; ${listed()}`, { profiles: profiles() });
|
|
4000
|
-
const unknown2 = names.filter((one) => !profiles().includes(one));
|
|
4001
|
-
if (unknown2.length > 0)
|
|
4002
|
-
throw new CliError("validation_error", `no profile named ${unknown2.map((one) => `"${one}"`).join(", ")} \u2014 ${listed()}`, { profiles: profiles() });
|
|
4003
|
-
return { set: { option: names.join(","), profiles: /* @__PURE__ */ __name(() => names, "profiles") } };
|
|
4004
|
-
}, "served");
|
|
4005
|
-
const withProfiles = /* @__PURE__ */ __name((command) => command.option("--profiles <names|all>", "serve several profiles from one server instead of one: names, comma-separated, or all for every profile"), "withProfiles");
|
|
4006
|
-
const group = annotate(program.command("mcp"), { effects: LOCAL_READ, mcp: false }).summary("serve this profile's commands to an AI agent, and set that up").description("serve this profile to an agent over MCP and set it up \u2014 `claude mcp add drive -- drive <profile> mcp serve`");
|
|
4007
|
-
const serve = examples(annotate(group.command("serve"), { effects: REMOTE_WRITE, lifetime: "persistent", mcp: false }).summary("serve this profile's commands to an AI agent").description("serve this profile to an agent over MCP, on stdin and stdout \u2014 `claude mcp add drive -- drive <profile> mcp serve`; `drive mcp serve --profiles a,b` or `--profiles all` serves those profiles from one server and each tool asks which"), [
|
|
4008
|
-
"drive personal mcp serve --tools",
|
|
4009
|
-
"drive personal mcp serve",
|
|
4010
|
-
"drive personal mcp serve --http --public-url https://laptop.example.ts.net"
|
|
4011
|
-
]).option("--tools", "list the commands the server offers instead of starting it").option("--http", "serve over HTTP on 127.0.0.1 for ChatGPT and Claude in the browser, behind your tunnel; the profile's permissions decide").option("--port <port>", `the local port for --http (default ${DEFAULT_PORT})`).option("--public-url <url>", "the tunnel's https address the browser apps use, e.g. https://<name>.ts.net or https://<name>.ts.net/drive");
|
|
4012
|
-
withProfiles(serve).action(async (args) => {
|
|
4013
|
-
const { mcpTools, serveMcp, serveMcpOverHttp, serveProfiles } = await import("./mcp-F67RATLF.js");
|
|
4014
|
-
const { portOf, publicUrlOf } = await import("./mcp-JZSYPQA4.js");
|
|
4015
|
-
const tunnel = /* @__PURE__ */ __name(() => publicUrlOf(args.publicUrl, { missing: "--http", reaches: "the browser apps reach drive", path: true }), "tunnel");
|
|
4016
|
-
const one = served(args.profiles, "mcp serve");
|
|
4017
|
-
if ("set" in one) {
|
|
4018
|
-
if (args.tools)
|
|
4019
|
-
throw new CliError("validation_error", "--tools lists one profile's commands: `drive <profile> mcp serve --tools`");
|
|
4020
|
-
const active = signal();
|
|
4021
|
-
await serveProfiles({
|
|
4022
|
-
env,
|
|
4023
|
-
set: one.set,
|
|
4024
|
-
permissions: policyFlags().permission ?? [],
|
|
4025
|
-
note: /* @__PURE__ */ __name((text) => streams.diagnostic(text), "note"),
|
|
4026
|
-
...active ? { signal: active } : {},
|
|
4027
|
-
...args.http ? { http: { publicUrl: tunnel(), port: portOf(args.port, DEFAULT_PORT) } } : {}
|
|
4028
|
-
});
|
|
4029
|
-
} else if (args.http) {
|
|
4030
|
-
const active = signal();
|
|
4031
|
-
await serveMcpOverHttp(createProgram2, { ...options, env, ...active ? { signal: active } : {} }, one.profile, policyFlags(), {
|
|
4032
|
-
publicUrl: tunnel(),
|
|
4033
|
-
port: portOf(args.port, DEFAULT_PORT),
|
|
4034
|
-
note: /* @__PURE__ */ __name((text) => streams.diagnostic(text), "note")
|
|
4035
|
-
});
|
|
4036
|
-
} else if (args.tools)
|
|
4037
|
-
output(allOf(mcpTools(createProgram2, { ...options, env }, one.profile, policyFlags()).map(({ schema, command, availability }) => ({
|
|
4038
|
-
command: command.path.join(" "),
|
|
4039
|
-
writes: writes(command.effects),
|
|
4040
|
-
input_schema: schema,
|
|
4041
|
-
effects: command.effects,
|
|
4042
|
-
availability: availability?.() ?? { available: true }
|
|
4043
|
-
}))));
|
|
4044
|
-
else {
|
|
4045
|
-
const active = signal();
|
|
4046
|
-
await serveMcp(createProgram2, { ...options, env, ...active ? { signal: active } : {} }, one.profile, policyFlags());
|
|
4047
|
-
}
|
|
4048
|
-
});
|
|
4049
|
-
withProfiles(examples(annotate(group.command("revoke"), { effects: LOCAL_WRITE, mcp: false }).summary("forget every login given to a browser app").description("forget every login `mcp serve --http` gave a browser app, of this profile or of the server `--profiles` names; each app must log in again"), ["drive personal mcp revoke"])).action(async (args) => {
|
|
4050
|
-
refuseUnderReadOnly(env, "forget the browser logins");
|
|
4051
|
-
if (policyFlags().readOnly)
|
|
4052
|
-
throw readOnlyRefusal("--read-only", "forget the browser logins");
|
|
4053
|
-
const { revokeAll } = await import("./mcp-JZSYPQA4.js");
|
|
4054
|
-
const one = served(args.profiles, "mcp revoke", "whose browser logins to forget");
|
|
4055
|
-
if ("set" in one) {
|
|
4056
|
-
revokeAll(profileSetTokenFile(env, one.set.option));
|
|
4057
|
-
output(itemOf({ revoked: true, profile: null, profiles: one.set.option }));
|
|
4058
|
-
} else {
|
|
4059
|
-
revokeAll(httpTokenFile(env, one.profile));
|
|
4060
|
-
output(itemOf({ revoked: true, profile: one.profile }));
|
|
4061
|
-
}
|
|
4062
|
-
});
|
|
4063
|
-
const server = mcpServerCommand({
|
|
4064
|
-
example: "drive personal",
|
|
4065
|
-
profiles: true,
|
|
4066
|
-
target: /* @__PURE__ */ __name((self) => {
|
|
4067
|
-
const one = served(self.opts().profiles, `mcp server ${self.name()}`, SERVER_PURPOSE[self.name()]);
|
|
4068
|
-
if ("set" in one)
|
|
4069
|
-
return {
|
|
4070
|
-
invocation: "drive",
|
|
4071
|
-
// drive 0.45 marked every set's server "default"; a new key would leave those servers unstoppable.
|
|
4072
|
-
profiles: { option: one.set.option, key: "default", label: profileSetLabel(one.set) },
|
|
4073
|
-
envPrefix: DRIVE_APP.envPrefix,
|
|
4074
|
-
env,
|
|
4075
|
-
tokenFile: profileSetTokenFile(env, one.set.option),
|
|
4076
|
-
argv: ["mcp", "serve", "--http", "--profiles", one.set.option],
|
|
4077
|
-
version: DRIVE_APP.version
|
|
4078
|
-
};
|
|
4079
|
-
return {
|
|
4080
|
-
invocation: `drive ${one.profile}`,
|
|
4081
|
-
profile: one.profile,
|
|
4082
|
-
envPrefix: DRIVE_APP.envPrefix,
|
|
4083
|
-
env,
|
|
4084
|
-
tokenFile: httpTokenFile(env, one.profile),
|
|
4085
|
-
argv: [one.profile, "mcp", "serve", "--http"],
|
|
4086
|
-
version: DRIVE_APP.version
|
|
4087
|
-
};
|
|
4088
|
-
}, "target"),
|
|
4089
|
-
answer: /* @__PURE__ */ __name((_self, item) => output(itemOf(item)), "answer")
|
|
4090
|
-
});
|
|
4091
|
-
group.addCommand(server);
|
|
4092
|
-
}, "installMcpCommandDefinition");
|
|
4093
|
-
var installMcpCommand = /* @__PURE__ */ __name((...args) => customizeSharedCommand(sharedCommandTemplate(DRIVE_APP, "mcp"), "Drive exposes Google document tools over stdio and HTTP using OAuth grants and its document permission adapter; its tool listing and command catalogue replace the messenger setup commands.", () => {
|
|
4094
|
-
installMcpCommandDefinition(...args);
|
|
4095
|
-
const command = args[0].commands.find((command2) => command2.name() === "mcp");
|
|
4096
|
-
if (!command)
|
|
4097
|
-
throw new Error("mcp builder did not install its command");
|
|
4098
|
-
return command;
|
|
4099
|
-
}, SHELL_OVERRIDES.mcp), "installMcpCommand");
|
|
4100
|
-
|
|
4101
3903
|
// dist/commands/mirrors.js
|
|
4102
3904
|
import { statSync } from "node:fs";
|
|
4103
|
-
import { join as
|
|
3905
|
+
import { join as join4, resolve } from "node:path";
|
|
4104
3906
|
|
|
4105
3907
|
// dist/mirror-docs.js
|
|
4106
|
-
import { readFileSync as
|
|
3908
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
4107
3909
|
|
|
4108
3910
|
// dist/mirror-sheets.js
|
|
4109
3911
|
import { createHash } from "node:crypto";
|
|
4110
|
-
import { readFileSync } from "node:fs";
|
|
3912
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
4111
3913
|
var lastChange = /* @__PURE__ */ __name(async (call, id) => {
|
|
4112
3914
|
try {
|
|
4113
3915
|
let last;
|
|
@@ -4178,7 +3980,7 @@ var parseDelimited = /* @__PURE__ */ __name((text, delimiter) => {
|
|
|
4178
3980
|
}, "parseDelimited");
|
|
4179
3981
|
var stem = /* @__PURE__ */ __name((path) => (path.split("/").at(-1) ?? path).replace(/\.[^.]+$/, ""), "stem");
|
|
4180
3982
|
var readLocalTabs = /* @__PURE__ */ __name(async (file) => {
|
|
4181
|
-
const bytes =
|
|
3983
|
+
const bytes = readFileSync2(file.absolute);
|
|
4182
3984
|
let tabs;
|
|
4183
3985
|
if (/\.(csv|tsv)$/i.test(file.path)) {
|
|
4184
3986
|
const text = new TextDecoder().decode(bytes).replace(/^/, "");
|
|
@@ -4370,7 +4172,7 @@ var prepareSheet = /* @__PURE__ */ __name(async (call, input) => {
|
|
|
4370
4172
|
};
|
|
4371
4173
|
const rows = current[0] ?? [];
|
|
4372
4174
|
return {
|
|
4373
|
-
local: delimitedText(rows,
|
|
4175
|
+
local: delimitedText(rows, readFileSync2(input.file.absolute, "utf8"), delimiter),
|
|
4374
4176
|
remote: false,
|
|
4375
4177
|
write: /* @__PURE__ */ __name(async () => pushed(pulled(rows)), "write")
|
|
4376
4178
|
};
|
|
@@ -4445,14 +4247,14 @@ var representable = /* @__PURE__ */ __name((blocks) => blocks.map((block) => {
|
|
|
4445
4247
|
return block;
|
|
4446
4248
|
}
|
|
4447
4249
|
}), "representable");
|
|
4448
|
-
var localBlocks = /* @__PURE__ */ __name(async (file) => representable(await markdownBlocks(
|
|
4250
|
+
var localBlocks = /* @__PURE__ */ __name(async (file) => representable(await markdownBlocks(readFileSync3(file.absolute, "utf8"))), "localBlocks");
|
|
4449
4251
|
var sameBlocks = /* @__PURE__ */ __name((a, b) => a.length === b.length && a.every((block, index) => blockKey(block) === blockKey(b[index])), "sameBlocks");
|
|
4450
4252
|
var inlinesOf = /* @__PURE__ */ __name((elements) => normalizeInlines(elements.flatMap((element) => {
|
|
4451
|
-
const
|
|
4452
|
-
if (!
|
|
4253
|
+
const run3 = element.textRun;
|
|
4254
|
+
if (!run3?.content)
|
|
4453
4255
|
return [];
|
|
4454
|
-
const style =
|
|
4455
|
-
const inline = { text:
|
|
4256
|
+
const style = run3.textStyle ?? {};
|
|
4257
|
+
const inline = { text: run3.content.replace(/\n$/, "").replaceAll(LINE_BREAK, "\n") };
|
|
4456
4258
|
if (style.bold)
|
|
4457
4259
|
inline.bold = true;
|
|
4458
4260
|
if (style.italic)
|
|
@@ -4748,7 +4550,7 @@ var prepareDoc = /* @__PURE__ */ __name(async (call, input) => {
|
|
|
4748
4550
|
const doc = await fetchDoc(call, id);
|
|
4749
4551
|
if (doc.suggestions)
|
|
4750
4552
|
return { conflict: "the Doc has pending suggestions; accept or reject them in Google first" };
|
|
4751
|
-
const text =
|
|
4553
|
+
const text = readFileSync3(input.file.absolute, "utf8");
|
|
4752
4554
|
const local2 = representable(await markdownBlocks(text));
|
|
4753
4555
|
const current = doc.placed.map((item) => item.block);
|
|
4754
4556
|
const merged = mergeBlocks(recorded.local, recorded.written, local2, current, keep);
|
|
@@ -4870,7 +4672,7 @@ var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call })
|
|
|
4870
4672
|
});
|
|
4871
4673
|
return mirror;
|
|
4872
4674
|
}, "find");
|
|
4873
|
-
const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(
|
|
4675
|
+
const stateOf = /* @__PURE__ */ __name((name, principal) => (mirror) => fileMirrorState(join4(profileDir(env, name), "mirrors"), mirror, principal, ["doc", "sheet"]), "stateOf");
|
|
4874
4676
|
const syncing = /* @__PURE__ */ __name((name, principal, google) => ({
|
|
4875
4677
|
target: googleTarget(call, () => google.identity()),
|
|
4876
4678
|
stateOf: stateOf(name, principal),
|
|
@@ -4892,7 +4694,7 @@ var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call })
|
|
|
4892
4694
|
return chosen;
|
|
4893
4695
|
}, "chosenOf");
|
|
4894
4696
|
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) => {
|
|
4895
|
-
const root =
|
|
4697
|
+
const root = resolve(path);
|
|
4896
4698
|
let directory = false;
|
|
4897
4699
|
try {
|
|
4898
4700
|
directory = statSync(root).isDirectory();
|
|
@@ -4981,7 +4783,7 @@ var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call })
|
|
|
4981
4783
|
const name = selected();
|
|
4982
4784
|
const profile = activeProfile(env, name);
|
|
4983
4785
|
const chosen = chosenOf(name, id);
|
|
4984
|
-
const signal = context.
|
|
4786
|
+
const signal = context.endsOnStop() ?? new AbortController().signal;
|
|
4985
4787
|
const google = await source();
|
|
4986
4788
|
const states = stateOf(name, profile.principal);
|
|
4987
4789
|
let token = await google.startToken();
|
|
@@ -4999,7 +4801,6 @@ var installMirrorCommands = /* @__PURE__ */ __name((program, context, { call })
|
|
|
4999
4801
|
}
|
|
5000
4802
|
return chosen.filter((mirror) => Object.values(states(mirror).read().entries).some((entry) => changed.has(entry.id))).map((mirror) => mirror.id);
|
|
5001
4803
|
}, "remoteChanges");
|
|
5002
|
-
context.endsOnStop();
|
|
5003
4804
|
let cycles = 0;
|
|
5004
4805
|
for await (const event of watchMirrors((mirrors2) => syncMirrors({ ...syncing(name, profile.principal, google), mirrors: mirrors2 }), { mirrors: chosen, signal, kindOf: mirrorKind, stateOf: states, remoteChanges, pollMs })) {
|
|
5005
4806
|
cycles++;
|
|
@@ -5037,7 +4838,7 @@ var describeCycle = /* @__PURE__ */ __name((cycle) => {
|
|
|
5037
4838
|
// dist/download.js
|
|
5038
4839
|
import { randomUUID } from "node:crypto";
|
|
5039
4840
|
import { closeSync, linkSync, lstatSync, mkdirSync as mkdirSync2, openSync, renameSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5040
|
-
import { dirname
|
|
4841
|
+
import { dirname, join as join5 } from "node:path";
|
|
5041
4842
|
var EXPORT_FORMATS = {
|
|
5042
4843
|
pdf: "application/pdf",
|
|
5043
4844
|
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
@@ -5060,8 +4861,8 @@ var saveDownload = /* @__PURE__ */ __name(async (path, overwrite, read, createDi
|
|
|
5060
4861
|
}
|
|
5061
4862
|
const bytes = await read();
|
|
5062
4863
|
if (createDirectory)
|
|
5063
|
-
mkdirSync2(
|
|
5064
|
-
const temp =
|
|
4864
|
+
mkdirSync2(dirname(path), { recursive: true, mode: 448 });
|
|
4865
|
+
const temp = join5(dirname(path), `.${randomUUID()}.tmp`);
|
|
5065
4866
|
let created = false;
|
|
5066
4867
|
try {
|
|
5067
4868
|
const fd = openSync(temp, "wx", 384);
|
|
@@ -22347,12 +22148,12 @@ var namedRectangle = /* @__PURE__ */ __name((range2) => {
|
|
|
22347
22148
|
}, "namedRectangle");
|
|
22348
22149
|
|
|
22349
22150
|
// dist/commands/sheets-structure.js
|
|
22350
|
-
var
|
|
22151
|
+
var integer2 = /* @__PURE__ */ __name((name, raw, maximum, minimum = 0) => {
|
|
22351
22152
|
if (!/^\d+$/.test(raw) || !Number.isSafeInteger(Number(raw)) || Number(raw) < minimum || Number(raw) > maximum)
|
|
22352
22153
|
throw new CliError("validation_error", `${name} must be an integer from ${minimum} to ${maximum}`);
|
|
22353
22154
|
return Number(raw);
|
|
22354
22155
|
}, "integer");
|
|
22355
|
-
var sheetId = /* @__PURE__ */ __name((raw) =>
|
|
22156
|
+
var sheetId = /* @__PURE__ */ __name((raw) => integer2("sheet-id", raw, 2147483647), "sheetId");
|
|
22356
22157
|
var title = /* @__PURE__ */ __name((raw) => {
|
|
22357
22158
|
if (!raw.trim() || raw.length > 100)
|
|
22358
22159
|
throw new CliError("validation_error", "title must contain 1 to 100 characters");
|
|
@@ -22404,7 +22205,7 @@ var installSheetsStructureCommands = /* @__PURE__ */ __name((group, { call, outp
|
|
|
22404
22205
|
if (raw !== "rows" && raw !== "columns")
|
|
22405
22206
|
throw new CliError("validation_error", "axis must be rows or columns");
|
|
22406
22207
|
return raw;
|
|
22407
|
-
}).argument("<index>", "zero-based index to insert before", (raw) =>
|
|
22208
|
+
}).argument("<index>", "zero-based index to insert before", (raw) => integer2("index", raw, 9999999)).argument("<count>", "number to insert, from 1 to 1000", (raw) => integer2("count", raw, 1e3, 1)), ["drive personal sheets insert SHEET_ID 0 rows 1 3"]).action(async (spreadsheet, id, axis, index, count) => {
|
|
22408
22209
|
if (index + count > (axis === "rows" ? 1e7 : 18278))
|
|
22409
22210
|
throw new CliError("validation_error", "index and count exceed the dimension bound");
|
|
22410
22211
|
return batch(spreadsheet, {
|
|
@@ -22715,7 +22516,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22715
22516
|
json: json === true || jsonl === true || !process.stdout.isTTY,
|
|
22716
22517
|
answers: false
|
|
22717
22518
|
});
|
|
22718
|
-
const { login } = await import("./login-
|
|
22519
|
+
const { login } = await import("./login-Y6ENYKC3.js");
|
|
22719
22520
|
output(itemOf(await login({
|
|
22720
22521
|
env,
|
|
22721
22522
|
profile: selected(),
|
|
@@ -22745,7 +22546,7 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22745
22546
|
const name = selected();
|
|
22746
22547
|
const config = readConfig(env);
|
|
22747
22548
|
const profile = activeProfile(env, name);
|
|
22748
|
-
const { credentials } = await import("./tokens-
|
|
22549
|
+
const { credentials } = await import("./tokens-7MUGKFEM.js");
|
|
22749
22550
|
const store = credentials(env, profile.storage, options.keyring);
|
|
22750
22551
|
store.remove(name);
|
|
22751
22552
|
writeConfig(env, config);
|
|
@@ -22759,37 +22560,9 @@ var installSessionCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22759
22560
|
});
|
|
22760
22561
|
}, "installSessionCommands");
|
|
22761
22562
|
|
|
22762
|
-
// dist/commands/skill.js
|
|
22763
|
-
var installSkillCommandDefinition = /* @__PURE__ */ __name((program, { env, streams, output }) => {
|
|
22764
|
-
const skill = skillCommand({ command: "drive", appName: "drive-cli", version: VERSION }, new URL("../../skills/drive-cli/SKILL.md", new URL("../commands/skill.js", import.meta.url).href), () => ({
|
|
22765
|
-
renderer: {
|
|
22766
|
-
...createRenderer({ format: "pretty", color: false, streams, quiet: program.opts().quiet === true }),
|
|
22767
|
-
result: /* @__PURE__ */ __name((value) => output(itemOf(value)), "result")
|
|
22768
|
-
},
|
|
22769
|
-
streams,
|
|
22770
|
-
env
|
|
22771
|
-
}));
|
|
22772
|
-
for (const child of skill.commands) {
|
|
22773
|
-
if (child.name() === "install")
|
|
22774
|
-
annotate(grantsAuthority(child), { effects: LOCAL_WRITE, examples: ["drive skill install --for all"] }).summary("put SKILL.md for Claude Code, Codex, Gemini CLI, OpenClaw, and Hermes on request");
|
|
22775
|
-
if (child.name() === "show")
|
|
22776
|
-
annotate(child, { examples: ["drive skill show"] }).summary("print drive's SKILL.md");
|
|
22777
|
-
}
|
|
22778
|
-
program.addCommand(annotate(skill, { effects: NO_EFFECTS }));
|
|
22779
|
-
}, "installSkillCommandDefinition");
|
|
22780
|
-
var installSkillCommand = /* @__PURE__ */ __name((...args) => {
|
|
22781
|
-
customizeSharedCommand(skillCommand2(DRIVE_APP, new URL("../../skills/drive-cli/SKILL.md", new URL("../commands/skill.js", import.meta.url).href)), "Drive binds agent installation to its own output renderer and provider skill locations.", () => {
|
|
22782
|
-
installSkillCommandDefinition(...args);
|
|
22783
|
-
const command = args[0].commands.find((command2) => command2.name() === "skill");
|
|
22784
|
-
if (!command)
|
|
22785
|
-
throw new Error("skill builder did not install its command");
|
|
22786
|
-
return command;
|
|
22787
|
-
}, SHELL_OVERRIDES.skill);
|
|
22788
|
-
}, "installSkillCommand");
|
|
22789
|
-
|
|
22790
22563
|
// dist/store-import.js
|
|
22791
|
-
import { readFileSync as
|
|
22792
|
-
import { resolve as
|
|
22564
|
+
import { readFileSync as readFileSync4, statSync as statSync2 } from "node:fs";
|
|
22565
|
+
import { resolve as resolve2 } from "node:path";
|
|
22793
22566
|
var transferBindings = /* @__PURE__ */ __name((path) => {
|
|
22794
22567
|
if (path === void 0)
|
|
22795
22568
|
return {};
|
|
@@ -22798,7 +22571,7 @@ var transferBindings = /* @__PURE__ */ __name((path) => {
|
|
|
22798
22571
|
const stat = statSync2(path);
|
|
22799
22572
|
if (!stat.isFile() || stat.size > 256 * 1024)
|
|
22800
22573
|
throw new Error("bounds");
|
|
22801
|
-
parsed = JSON.parse(
|
|
22574
|
+
parsed = JSON.parse(readFileSync4(path, "utf8"));
|
|
22802
22575
|
} catch {
|
|
22803
22576
|
throw new CliError("validation_error", "bindings must be a readable JSON object file no larger than 256 KiB");
|
|
22804
22577
|
}
|
|
@@ -22809,7 +22582,7 @@ var transferBindings = /* @__PURE__ */ __name((path) => {
|
|
|
22809
22582
|
var selection = /* @__PURE__ */ __name((env, name, source) => {
|
|
22810
22583
|
const profile = activeProfile(env, name);
|
|
22811
22584
|
const state = readState(env, name, profile.principal);
|
|
22812
|
-
const destination =
|
|
22585
|
+
const destination = resolve2(storePath(env));
|
|
22813
22586
|
for (const [id] of Object.entries(state.documents)) {
|
|
22814
22587
|
const snapshot = readSnapshot(env, name, id);
|
|
22815
22588
|
if (snapshot.metadata.id !== id)
|
|
@@ -22820,7 +22593,7 @@ var selection = /* @__PURE__ */ __name((env, name, source) => {
|
|
|
22820
22593
|
return { profile, state, options: { source, destination, collection: `google-drive:${profile.principal}`, env } };
|
|
22821
22594
|
}, "selection");
|
|
22822
22595
|
var checkStoreImport = /* @__PURE__ */ __name(async (env, name, source, bindings) => {
|
|
22823
|
-
const { ensureSqlite } = await import("./sqlite-runtime-
|
|
22596
|
+
const { ensureSqlite } = await import("./sqlite-runtime-H3TSAMIN.js");
|
|
22824
22597
|
await ensureSqlite();
|
|
22825
22598
|
const { state, options } = selection(env, name, source);
|
|
22826
22599
|
const preview = await previewDocumentTransfer({ ...options, bindings });
|
|
@@ -22829,7 +22602,7 @@ var checkStoreImport = /* @__PURE__ */ __name(async (env, name, source, bindings
|
|
|
22829
22602
|
if (!stored || stored.content_hash !== document.hash)
|
|
22830
22603
|
throw new CliError("configuration_error", "source content does not match the cached profile checkpoint; the original checkpoint was kept");
|
|
22831
22604
|
}
|
|
22832
|
-
if (
|
|
22605
|
+
if (resolve2(state.store ?? "") === options.destination && !preview.already_transferred)
|
|
22833
22606
|
throw new CliError("configuration_error", "this profile already uses the selected store; only an existing transfer can be retried");
|
|
22834
22607
|
return preview;
|
|
22835
22608
|
}, "checkStoreImport");
|
|
@@ -22880,11 +22653,11 @@ var installStoreCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22880
22653
|
}, "installStoreCommands");
|
|
22881
22654
|
|
|
22882
22655
|
// dist/commands/sync.js
|
|
22883
|
-
import { existsSync
|
|
22884
|
-
import { join as
|
|
22656
|
+
import { existsSync } from "node:fs";
|
|
22657
|
+
import { join as join6, resolve as resolve4 } from "node:path";
|
|
22885
22658
|
|
|
22886
22659
|
// dist/sync.js
|
|
22887
|
-
import { resolve as
|
|
22660
|
+
import { resolve as resolve3 } from "node:path";
|
|
22888
22661
|
var MESSAGE_LINKS_VERSION = 1;
|
|
22889
22662
|
var skipReason = /* @__PURE__ */ __name((file) => !file.canDownload ? "downloads restricted" : supported(file) ? void 0 : `unsupported type: ${file.mime}`, "skipReason");
|
|
22890
22663
|
var retryable = /* @__PURE__ */ __name((skip, limit) => skip.reason === "downloads restricted" || skip.reason.startsWith("unsupported type: ") || skip.textLimit !== void 0 && skip.textLimit < limit || // The store's own bounds change only with the shared package drive pins.
|
|
@@ -22917,7 +22690,7 @@ var sync = /* @__PURE__ */ __name(async (source, index, env, name, max, signal,
|
|
|
22917
22690
|
storeVersion: VERSION,
|
|
22918
22691
|
state: {
|
|
22919
22692
|
read: /* @__PURE__ */ __name(() => readState(env, name, profile.principal), "read"),
|
|
22920
|
-
save: /* @__PURE__ */ __name((state) => saveState(env, name, { ...state, store:
|
|
22693
|
+
save: /* @__PURE__ */ __name((state) => saveState(env, name, { ...state, store: resolve3(storePath(env)) }), "save"),
|
|
22921
22694
|
readWalk: /* @__PURE__ */ __name((scope) => readWalk(env, name, scope), "readWalk"),
|
|
22922
22695
|
saveWalk: /* @__PURE__ */ __name((walk) => saveWalk(env, name, walk), "saveWalk"),
|
|
22923
22696
|
removeWalk: /* @__PURE__ */ __name(() => removeWalk(env, name), "removeWalk"),
|
|
@@ -22973,12 +22746,12 @@ var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22973
22746
|
const name = selected();
|
|
22974
22747
|
const profile = activeProfile(env, name);
|
|
22975
22748
|
const state = readState(env, name, profile.principal);
|
|
22976
|
-
const legacyStore =
|
|
22749
|
+
const legacyStore = join6(paths(env).state, "drive.db");
|
|
22977
22750
|
output(itemOf({
|
|
22978
22751
|
profile: name,
|
|
22979
22752
|
store: {
|
|
22980
|
-
selected:
|
|
22981
|
-
checkpoint: state.store ?? (
|
|
22753
|
+
selected: resolve4(storePath(env)),
|
|
22754
|
+
checkpoint: state.store ?? (existsSync(legacyStore) ? resolve4(legacyStore) : null)
|
|
22982
22755
|
},
|
|
22983
22756
|
selected_folders: profile.roots,
|
|
22984
22757
|
documents: Object.keys(state.documents).length,
|
|
@@ -22992,7 +22765,7 @@ var installSyncCommands = /* @__PURE__ */ __name((program, context) => {
|
|
|
22992
22765
|
}, "installSyncCommands");
|
|
22993
22766
|
|
|
22994
22767
|
// dist/commands/upgrade.js
|
|
22995
|
-
import { join as
|
|
22768
|
+
import { join as join7 } from "node:path";
|
|
22996
22769
|
|
|
22997
22770
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/update/index.js
|
|
22998
22771
|
import { realpathSync } from "node:fs";
|
|
@@ -23065,21 +22838,17 @@ var update = appUpdate({
|
|
|
23065
22838
|
command: "drive",
|
|
23066
22839
|
version: DRIVE_APP.version,
|
|
23067
22840
|
entry: new URL("../commands/upgrade.js", import.meta.url).href,
|
|
23068
|
-
statePath: /* @__PURE__ */ __name((env) =>
|
|
22841
|
+
statePath: /* @__PURE__ */ __name((env) => join7(paths(env).state, "update-check.json"), "statePath"),
|
|
23069
22842
|
enabled: /* @__PURE__ */ __name(() => false, "enabled"),
|
|
23070
22843
|
offVariables: ["DRIVE_NO_UPDATE_CHECK"]
|
|
23071
22844
|
});
|
|
23072
|
-
var installUpgradeCommand = /* @__PURE__ */ __name((program, { env,
|
|
23073
|
-
const environment = options.update ?? {};
|
|
22845
|
+
var installUpgradeCommand = /* @__PURE__ */ __name((program, { env, options }) => {
|
|
23074
22846
|
program.addCommand(upgradeCommand(DRIVE_APP, PACKAGE, (command) => {
|
|
22847
|
+
const environment = options.update ?? {};
|
|
23075
22848
|
if (!command.opts().check)
|
|
23076
22849
|
refuseUnderReadOnly(env, "install a newer drive");
|
|
23077
|
-
const globals = program.opts();
|
|
23078
|
-
const format = globals.jsonl ? "jsonl" : globals.json || !process.stdout.isTTY ? "json" : "pretty";
|
|
23079
22850
|
return {
|
|
23080
|
-
|
|
23081
|
-
format,
|
|
23082
|
-
streams,
|
|
22851
|
+
...outputFor(command),
|
|
23083
22852
|
installer: /* @__PURE__ */ __name(() => update.installer(environment), "installer"),
|
|
23084
22853
|
latest: /* @__PURE__ */ __name(() => update.latest(environment), "latest"),
|
|
23085
22854
|
install: /* @__PURE__ */ __name((argv) => update.runUpdate(argv, environment), "install")
|
|
@@ -23144,7 +22913,21 @@ var guide = /* @__PURE__ */ __name(() => guideCommand({ command: "drive" }, {
|
|
|
23144
22913
|
directory: fileURLToPath2(new URL("../scenarios", new URL("../first-screen.js", import.meta.url).href)),
|
|
23145
22914
|
worksWith: [MEMO_SCENARIOS.personBrief, MEMO_SCENARIOS.decisionTrail]
|
|
23146
22915
|
}), "guide");
|
|
23147
|
-
var
|
|
22916
|
+
var FIRST_SCREEN = {
|
|
22917
|
+
pitch: "chosen Google Drive folders as a local, searchable library: Docs, Sheets, PDF and docx as text, offline.",
|
|
22918
|
+
can: [
|
|
22919
|
+
{ command: "folders add <url>", does: "choose folders; only these are imported" },
|
|
22920
|
+
{ command: "sync --embed", does: "import what changed and index it by meaning" },
|
|
22921
|
+
{ command: 'search "budget decision"', does: "every imported document, by words and meaning" },
|
|
22922
|
+
{ command: "documents context <doc>", does: "a document with its tags, notes and editors" },
|
|
22923
|
+
{ command: "documents history <doc> --activity", does: "who did what (needs --grant activity)" },
|
|
22924
|
+
{ command: "memories extract <doc>", does: "memories with exact quotes, proposed by a model" },
|
|
22925
|
+
{ command: "documents export <doc>", does: "Markdown in a new file (--output); never overwrites" },
|
|
22926
|
+
{ command: "--read-only \u2026", does: "this run refuses every change" }
|
|
22927
|
+
],
|
|
22928
|
+
start: "drive personal session start"
|
|
22929
|
+
};
|
|
22930
|
+
var placeInSections = /* @__PURE__ */ __name((program) => {
|
|
23148
22931
|
for (const command of program.commands) {
|
|
23149
22932
|
const section = SECTIONS[command.name()];
|
|
23150
22933
|
if (section)
|
|
@@ -23153,25 +22936,7 @@ var installFirstScreen = /* @__PURE__ */ __name((program) => {
|
|
|
23153
22936
|
for (const child of command.commands)
|
|
23154
22937
|
inSection(child, metaOf(child).effects?.remote === "write" ? "write" : "read");
|
|
23155
22938
|
}
|
|
23156
|
-
|
|
23157
|
-
pitch: "chosen Google Drive folders as a local, searchable library: Docs, Sheets, PDF and docx as text, offline.",
|
|
23158
|
-
can: [
|
|
23159
|
-
{ command: "folders add <url>", does: "choose folders; only these are imported" },
|
|
23160
|
-
{ command: "sync --embed", does: "import what changed and index it by meaning" },
|
|
23161
|
-
{ command: 'search "budget decision"', does: "every imported document, by words and meaning" },
|
|
23162
|
-
{ command: "documents context <doc>", does: "a document with its tags, notes and editors" },
|
|
23163
|
-
{ command: "documents history <doc> --activity", does: "who did what (needs --grant activity)" },
|
|
23164
|
-
{ command: "memories extract <doc>", does: "memories with exact quotes, proposed by a model" },
|
|
23165
|
-
{ command: "documents export <doc>", does: "Markdown in a new file (--output); never overwrites" },
|
|
23166
|
-
{ command: "--read-only \u2026", does: "this run refuses every change" }
|
|
23167
|
-
],
|
|
23168
|
-
start: "drive personal session start"
|
|
23169
|
-
});
|
|
23170
|
-
const help = program.commands.find((command) => command.name() === "help");
|
|
23171
|
-
if (help)
|
|
23172
|
-
annotate(help, { mcp: false });
|
|
23173
|
-
help?.exitOverride().configureOutput(program.configureOutput());
|
|
23174
|
-
}, "installFirstScreen");
|
|
22939
|
+
}, "placeInSections");
|
|
23175
22940
|
|
|
23176
22941
|
// dist/provider-json.js
|
|
23177
22942
|
var providerJsonFields = entityFields({
|
|
@@ -23315,21 +23080,21 @@ var saveContributors = /* @__PURE__ */ __name(async (store, principal, metadata,
|
|
|
23315
23080
|
}, "saveContributors");
|
|
23316
23081
|
|
|
23317
23082
|
// dist/store-transition.js
|
|
23318
|
-
import { existsSync as
|
|
23319
|
-
import { join as
|
|
23083
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
23084
|
+
import { join as join8, resolve as resolve5 } from "node:path";
|
|
23320
23085
|
var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = false) => {
|
|
23321
23086
|
const profile = activeProfile(env, name);
|
|
23322
|
-
const target =
|
|
23087
|
+
const target = resolve5(storePath(env));
|
|
23323
23088
|
const current = readState(env, name, profile.principal);
|
|
23324
|
-
if (current.store &&
|
|
23089
|
+
if (current.store && resolve5(current.store) === target) {
|
|
23325
23090
|
await index.registerProfile?.(name, profile.principal);
|
|
23326
23091
|
return;
|
|
23327
23092
|
}
|
|
23328
23093
|
const lock = await lockProfile(env, name);
|
|
23329
23094
|
try {
|
|
23330
23095
|
const state = readState(env, name, profile.principal);
|
|
23331
|
-
const previous =
|
|
23332
|
-
if (previous !== target &&
|
|
23096
|
+
const previous = resolve5(state.store ?? join8(paths(env).state, "drive.db"));
|
|
23097
|
+
if (previous !== target && existsSync2(previous)) {
|
|
23333
23098
|
const old = await openStore({ path: previous, env, command: "drive", version: VERSION });
|
|
23334
23099
|
try {
|
|
23335
23100
|
const folder = await old.notes.documentsAccount({ provider: "google-drive", account: profile.principal });
|
|
@@ -23402,9 +23167,9 @@ var prepareStore = /* @__PURE__ */ __name(async (index, env, name, rescan = fals
|
|
|
23402
23167
|
var openIndex = /* @__PURE__ */ __name(async (env, name, rescan = false) => {
|
|
23403
23168
|
if (name)
|
|
23404
23169
|
activeProfile(env, name);
|
|
23405
|
-
const { ensureSqlite } = await import("./sqlite-runtime-
|
|
23170
|
+
const { ensureSqlite } = await import("./sqlite-runtime-H3TSAMIN.js");
|
|
23406
23171
|
await ensureSqlite();
|
|
23407
|
-
const { openStore: openStore2, storePath: storePath2 } = await import("./store-
|
|
23172
|
+
const { openStore: openStore2, storePath: storePath2 } = await import("./store-I27LAJPU.js");
|
|
23408
23173
|
if (env.DRIVE_STORE)
|
|
23409
23174
|
throw new CliError("configuration_error", "DRIVE_STORE has been retired; use MESSAGING_STORE to select the shared database", { reason: "store.override-retired" });
|
|
23410
23175
|
const store = await openStore2({ path: storePath2(env), env, command: "drive", version: VERSION });
|
|
@@ -23448,7 +23213,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
|
|
|
23448
23213
|
linkMessages: /* @__PURE__ */ __name((documents, since) => store.notes.linkMessages({ documents, ...since ? { since } : {} }), "linkMessages"),
|
|
23449
23214
|
knowledge: documentKnowledge2(store, async (principal) => (await folder(principal, false))?.id),
|
|
23450
23215
|
openPictures: /* @__PURE__ */ __name(async () => {
|
|
23451
|
-
const { openPictureEmbedderFor, savePicture } = await import("./services-
|
|
23216
|
+
const { openPictureEmbedderFor, savePicture } = await import("./services-C3XWRA2W.js");
|
|
23452
23217
|
const embedder = pictureEmbedder ?? await openPictureEmbedderFor({ env, command: "drive" });
|
|
23453
23218
|
return {
|
|
23454
23219
|
save: /* @__PURE__ */ __name((reference, bytes) => savePicture(store, { ref: reference }, bytes, { embedder }), "save"),
|
|
@@ -23467,7 +23232,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
|
|
|
23467
23232
|
has_more: false,
|
|
23468
23233
|
meaning_skipped: "this Google account has no imported sources"
|
|
23469
23234
|
};
|
|
23470
|
-
const { searchNotes } = await import("./services-
|
|
23235
|
+
const { searchNotes } = await import("./services-C3XWRA2W.js");
|
|
23471
23236
|
const result = await searchNotes(store, query, {
|
|
23472
23237
|
...options,
|
|
23473
23238
|
folderIds: selected ? [selected.id] : [],
|
|
@@ -23498,7 +23263,7 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
|
|
|
23498
23263
|
};
|
|
23499
23264
|
}, "search"),
|
|
23500
23265
|
embed: /* @__PURE__ */ __name(async (max) => {
|
|
23501
|
-
const { embedNotes } = await import("./services-
|
|
23266
|
+
const { embedNotes } = await import("./services-C3XWRA2W.js");
|
|
23502
23267
|
return embedNotes(store, { maxChunks: max, env, command: "drive" });
|
|
23503
23268
|
}, "embed"),
|
|
23504
23269
|
close: /* @__PURE__ */ __name(() => store.close(), "close")
|
|
@@ -23507,9 +23272,9 @@ var indexOver = /* @__PURE__ */ __name((store, env, pictureEmbedder) => {
|
|
|
23507
23272
|
|
|
23508
23273
|
// dist/upload.js
|
|
23509
23274
|
import { createHash as createHash2 } from "node:crypto";
|
|
23510
|
-
import { createReadStream, mkdirSync as mkdirSync3, readFileSync as
|
|
23275
|
+
import { createReadStream, mkdirSync as mkdirSync3, readFileSync as readFileSync5, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
23511
23276
|
import { open } from "node:fs/promises";
|
|
23512
|
-
import { basename, join as
|
|
23277
|
+
import { basename, join as join9, resolve as resolve6 } from "node:path";
|
|
23513
23278
|
var START = "https://www.googleapis.com/upload/drive/v3/files";
|
|
23514
23279
|
var FIELDS = "id,name,size,md5Checksum,mimeType,parents";
|
|
23515
23280
|
var QUANTUM = 256 * 1024;
|
|
@@ -23524,7 +23289,7 @@ var nextByte = /* @__PURE__ */ __name((response) => {
|
|
|
23524
23289
|
}, "nextByte");
|
|
23525
23290
|
var done = /* @__PURE__ */ __name((status) => status === 200 || status === 201, "done");
|
|
23526
23291
|
var uploadFile = /* @__PURE__ */ __name(async (input) => {
|
|
23527
|
-
const path =
|
|
23292
|
+
const path = resolve6(input.path);
|
|
23528
23293
|
let stat;
|
|
23529
23294
|
try {
|
|
23530
23295
|
stat = statSync3(path);
|
|
@@ -23540,16 +23305,16 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
|
|
|
23540
23305
|
throw new CliError("validation_error", "a chunk must be a multiple of 256 KiB");
|
|
23541
23306
|
const sleep = input.sleep ?? ((ms) => new Promise((wake) => setTimeout(wake, ms)));
|
|
23542
23307
|
const key = createHash2("sha256").update(JSON.stringify([path, size2, stat.mtimeMs, name, input.parent ?? ""])).digest("hex").slice(0, 24);
|
|
23543
|
-
const checkpointPath =
|
|
23308
|
+
const checkpointPath = join9(input.stateDir, "uploads", `${key}.json`);
|
|
23544
23309
|
const readCheckpoint = /* @__PURE__ */ __name(() => {
|
|
23545
23310
|
try {
|
|
23546
|
-
return JSON.parse(
|
|
23311
|
+
return JSON.parse(readFileSync5(checkpointPath, "utf8"));
|
|
23547
23312
|
} catch {
|
|
23548
23313
|
return void 0;
|
|
23549
23314
|
}
|
|
23550
23315
|
}, "readCheckpoint");
|
|
23551
23316
|
const saveCheckpoint = /* @__PURE__ */ __name((sessionUri) => {
|
|
23552
|
-
mkdirSync3(
|
|
23317
|
+
mkdirSync3(join9(input.stateDir, "uploads"), { recursive: true, mode: 448 });
|
|
23553
23318
|
const checkpoint = {
|
|
23554
23319
|
session_uri: sessionUri,
|
|
23555
23320
|
path,
|
|
@@ -23676,37 +23441,42 @@ var uploadFile = /* @__PURE__ */ __name(async (input) => {
|
|
|
23676
23441
|
}, "uploadFile");
|
|
23677
23442
|
|
|
23678
23443
|
// dist/program.js
|
|
23444
|
+
var SKILL = new URL("../skills/drive-cli/SKILL.md", new URL("../program.js", import.meta.url).href);
|
|
23679
23445
|
var eachItem = /* @__PURE__ */ __name((body, change) => "items" in body ? { ...body, items: body.items.map(change) } : { ...body, item: change(body.item) }, "eachItem");
|
|
23680
|
-
var commandIn = /* @__PURE__ */ __name((root, words) => {
|
|
23681
|
-
let at = root;
|
|
23682
|
-
for (const word of words) {
|
|
23683
|
-
if (word.startsWith("-"))
|
|
23684
|
-
continue;
|
|
23685
|
-
const child = at?.commands.find((command) => command.name() === word);
|
|
23686
|
-
if (child)
|
|
23687
|
-
at = child;
|
|
23688
|
-
}
|
|
23689
|
-
return at === root ? void 0 : at;
|
|
23690
|
-
}, "commandIn");
|
|
23691
23446
|
var Preview = class extends Error {
|
|
23692
23447
|
static {
|
|
23693
23448
|
__name(this, "Preview");
|
|
23694
23449
|
}
|
|
23695
23450
|
};
|
|
23696
|
-
var
|
|
23451
|
+
var EXPORTS = /* @__PURE__ */ new Set(["documents export", "files download", "files export"]);
|
|
23452
|
+
var googleOnly = /* @__PURE__ */ __name((effects) => effects?.local === "none" && effects.remote !== "none", "googleOnly");
|
|
23453
|
+
var lateEnv = /* @__PURE__ */ __name((environment) => {
|
|
23454
|
+
const current = /* @__PURE__ */ __name(() => environment().env ?? process.env, "current");
|
|
23455
|
+
return new Proxy({}, {
|
|
23456
|
+
get: /* @__PURE__ */ __name((_, key) => Reflect.get(current(), key), "get"),
|
|
23457
|
+
has: /* @__PURE__ */ __name((_, key) => Reflect.has(current(), key), "has"),
|
|
23458
|
+
ownKeys: /* @__PURE__ */ __name(() => Reflect.ownKeys(current()), "ownKeys"),
|
|
23459
|
+
getOwnPropertyDescriptor: /* @__PURE__ */ __name((_, key) => Reflect.getOwnPropertyDescriptor(current(), key), "getOwnPropertyDescriptor")
|
|
23460
|
+
});
|
|
23461
|
+
}, "lateEnv");
|
|
23462
|
+
var lateStreams = /* @__PURE__ */ __name((environment) => ({
|
|
23463
|
+
data: /* @__PURE__ */ __name((text) => (environment().streams ?? processStreams).data(text), "data"),
|
|
23464
|
+
diagnostic: /* @__PURE__ */ __name((text) => (environment().streams ?? processStreams).diagnostic(text), "diagnostic")
|
|
23465
|
+
}), "lateStreams");
|
|
23466
|
+
var runsOf = /* @__PURE__ */ new WeakMap();
|
|
23467
|
+
var installDrive = /* @__PURE__ */ __name((program) => {
|
|
23697
23468
|
const startedAt = Date.now();
|
|
23698
|
-
const
|
|
23699
|
-
const
|
|
23700
|
-
const
|
|
23701
|
-
program.
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
})
|
|
23706
|
-
let profileWord;
|
|
23469
|
+
const environment = /* @__PURE__ */ __name(() => environmentOf(program), "environment");
|
|
23470
|
+
const env = lateEnv(environment);
|
|
23471
|
+
const streams = lateStreams(environment);
|
|
23472
|
+
program.option("--read-only", "refuse local and remote mutations").option("--allow-dangerous", "answer a permanent-deletion confirmation").option("--permission <key=level>", "make a permission stricter for this run only; repeat to add keys", (value, previous = []) => [...previous, value]);
|
|
23473
|
+
const profileWord = /* @__PURE__ */ __name(() => {
|
|
23474
|
+
const word = program.opts().profile;
|
|
23475
|
+
return word === void 0 ? void 0 : profileName(word);
|
|
23476
|
+
}, "profileWord");
|
|
23707
23477
|
const selected = /* @__PURE__ */ __name(() => {
|
|
23708
23478
|
const lock = env.DRIVE_PROFILE_LOCK || void 0;
|
|
23709
|
-
const named = profileWord ?? (env.DRIVE_PROFILE || void 0);
|
|
23479
|
+
const named = profileWord() ?? (env.DRIVE_PROFILE || void 0);
|
|
23710
23480
|
if (lock !== void 0) {
|
|
23711
23481
|
profileName(lock);
|
|
23712
23482
|
if (named !== void 0 && profileName(named) !== lock)
|
|
@@ -23721,15 +23491,16 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23721
23491
|
}, "selected");
|
|
23722
23492
|
let currentAction;
|
|
23723
23493
|
let checkedMethod;
|
|
23724
|
-
let
|
|
23725
|
-
let
|
|
23726
|
-
|
|
23727
|
-
let stopEnds = false;
|
|
23494
|
+
let stopSignal;
|
|
23495
|
+
let previewsRequest = false;
|
|
23496
|
+
const agent = /* @__PURE__ */ __name(() => environment().agent !== void 0, "agent");
|
|
23728
23497
|
const confirmations = /* @__PURE__ */ new Set();
|
|
23729
23498
|
const askOnce = /* @__PURE__ */ __name(async (key) => {
|
|
23499
|
+
if (agent())
|
|
23500
|
+
return true;
|
|
23730
23501
|
if (confirmations.has(key))
|
|
23731
23502
|
return true;
|
|
23732
|
-
const answered = await
|
|
23503
|
+
const answered = await environment().ask?.(key) ?? false;
|
|
23733
23504
|
if (answered)
|
|
23734
23505
|
confirmations.add(key);
|
|
23735
23506
|
return answered;
|
|
@@ -23737,19 +23508,20 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23737
23508
|
let knownKeys;
|
|
23738
23509
|
const policyFlags = /* @__PURE__ */ __name(() => {
|
|
23739
23510
|
knownKeys ??= permissionKeys(flatten(describeDriveProgram(program)).map((info) => info.path));
|
|
23511
|
+
const flags = program.opts();
|
|
23740
23512
|
return {
|
|
23741
|
-
...
|
|
23742
|
-
|
|
23513
|
+
...flags,
|
|
23514
|
+
permission: [...environment().agent?.overrides ?? [], ...flags.permission ?? []],
|
|
23515
|
+
allowDangerous: flags.allowDangerous || currentAction?.opts().allowDelete,
|
|
23516
|
+
dryRun: flags.dryRun || previewsRequest,
|
|
23743
23517
|
permissionKeys: knownKeys
|
|
23744
23518
|
};
|
|
23745
23519
|
}, "policyFlags");
|
|
23746
23520
|
const runId = randomUUID2();
|
|
23521
|
+
const shown = /* @__PURE__ */ __name(() => outputFor(currentAction ?? program), "shown");
|
|
23747
23522
|
const print = /* @__PURE__ */ __name((render) => {
|
|
23748
|
-
const format
|
|
23749
|
-
|
|
23750
|
-
const buffered = { ...streams, data: /* @__PURE__ */ __name((text) => buffer.data(text), "data") };
|
|
23751
|
-
render(createRenderer({ format, color: false, streams: buffered, quiet: program.opts().quiet === true }), format, buffered);
|
|
23752
|
-
buffer.flush((text) => streams.data(text));
|
|
23523
|
+
const { renderer, format, streams: out } = shown();
|
|
23524
|
+
render(renderer, format, out);
|
|
23753
23525
|
}, "print");
|
|
23754
23526
|
const output = /* @__PURE__ */ __name((body) => {
|
|
23755
23527
|
const snaked = eachItem(body, (item) => snakeKeys2(item));
|
|
@@ -23762,58 +23534,95 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23762
23534
|
...body.meta
|
|
23763
23535
|
}
|
|
23764
23536
|
};
|
|
23537
|
+
const fields = program.opts().fields;
|
|
23765
23538
|
if (fields && currentAction)
|
|
23766
23539
|
checkResultFields(currentAction, whole, fields);
|
|
23767
|
-
const
|
|
23768
|
-
const
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
|
|
23772
|
-
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
if (shown.changed || answer.meta.timezone)
|
|
23777
|
-
buffered.data(`times in ${answer.meta.timezone ?? zone}`);
|
|
23778
|
-
});
|
|
23540
|
+
const command = currentAction ?? program;
|
|
23541
|
+
const out = shown();
|
|
23542
|
+
if (out.format !== "pretty")
|
|
23543
|
+
return renderAnswer(command, out, whole);
|
|
23544
|
+
const zone = timezoneOf();
|
|
23545
|
+
const local2 = localTimes(whole, zone);
|
|
23546
|
+
renderAnswer(command, out, local2.value);
|
|
23547
|
+
if (local2.changed || whole.meta.timezone)
|
|
23548
|
+
out.streams.data(`times in ${whole.meta.timezone ?? zone}`);
|
|
23779
23549
|
}, "output");
|
|
23780
|
-
const
|
|
23781
|
-
|
|
23782
|
-
const
|
|
23783
|
-
|
|
23550
|
+
const signal = /* @__PURE__ */ __name(() => environment().signal, "signal");
|
|
23551
|
+
const signedIn = /* @__PURE__ */ __name(async (name, scope2) => {
|
|
23552
|
+
const { authorizedClient, checkAuthorization } = await import("./tokens-7MUGKFEM.js");
|
|
23553
|
+
const client = authorizedClient(env, name, environment().keyring, signal());
|
|
23554
|
+
await checkAuthorization(client, scope2);
|
|
23784
23555
|
return client;
|
|
23785
23556
|
}, "signedIn");
|
|
23786
23557
|
const source = /* @__PURE__ */ __name(async () => {
|
|
23787
23558
|
const name = selected();
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23559
|
+
const fake = environment().source;
|
|
23560
|
+
if (fake)
|
|
23561
|
+
return fake(name);
|
|
23562
|
+
const [{ googleSource }, client] = await Promise.all([import("./google-5NNVARNR.js"), signedIn(name)]);
|
|
23791
23563
|
return googleSource(client);
|
|
23792
23564
|
}, "source");
|
|
23793
23565
|
const withIndex = /* @__PURE__ */ __name(async (fn) => {
|
|
23794
|
-
const index = await (
|
|
23566
|
+
const index = await (environment().index?.() ?? openIndex(env, selected(), currentAction?.opts().rescan === true));
|
|
23795
23567
|
try {
|
|
23796
23568
|
return await fn(index);
|
|
23797
23569
|
} finally {
|
|
23798
23570
|
await index.close();
|
|
23799
23571
|
}
|
|
23800
23572
|
}, "withIndex");
|
|
23573
|
+
const options = {
|
|
23574
|
+
get keyring() {
|
|
23575
|
+
return environment().keyring;
|
|
23576
|
+
},
|
|
23577
|
+
get openBrowser() {
|
|
23578
|
+
return environment().openBrowser;
|
|
23579
|
+
},
|
|
23580
|
+
get update() {
|
|
23581
|
+
return environment().update;
|
|
23582
|
+
},
|
|
23583
|
+
get mcp() {
|
|
23584
|
+
return agent();
|
|
23585
|
+
}
|
|
23586
|
+
};
|
|
23801
23587
|
const context = {
|
|
23802
23588
|
env,
|
|
23803
23589
|
streams,
|
|
23804
23590
|
options,
|
|
23805
23591
|
selected,
|
|
23806
|
-
signal
|
|
23592
|
+
signal,
|
|
23807
23593
|
output,
|
|
23808
23594
|
print,
|
|
23809
23595
|
source,
|
|
23810
23596
|
withIndex,
|
|
23811
23597
|
policyFlags,
|
|
23812
|
-
profileWord
|
|
23598
|
+
profileWord,
|
|
23813
23599
|
endsOnStop: /* @__PURE__ */ __name(() => {
|
|
23814
|
-
|
|
23600
|
+
const timeout = program.opts().timeout;
|
|
23601
|
+
stopSignal = AbortSignal.any([
|
|
23602
|
+
environment().untilStopped?.(),
|
|
23603
|
+
signal(),
|
|
23604
|
+
timeout === void 0 ? void 0 : AbortSignal.timeout(parseDuration(timeout, "--timeout"))
|
|
23605
|
+
].filter((one) => one !== void 0));
|
|
23606
|
+
return stopSignal;
|
|
23815
23607
|
}, "endsOnStop")
|
|
23816
23608
|
};
|
|
23609
|
+
const runs = commandRuns({
|
|
23610
|
+
app: DRIVE_APP,
|
|
23611
|
+
profile: /* @__PURE__ */ __name(() => profileWord() ?? (env.DRIVE_PROFILE_LOCK || env.DRIVE_PROFILE || void 0), "profile"),
|
|
23612
|
+
settings: /* @__PURE__ */ __name(() => {
|
|
23613
|
+
const defaults = readConfig(env).defaults;
|
|
23614
|
+
return {
|
|
23615
|
+
record: defaults?.record,
|
|
23616
|
+
keepRunsForDays: defaults?.keep_runs_for_days,
|
|
23617
|
+
keepSuccessfulRunsForDays: defaults?.keep_successful_runs_for_days,
|
|
23618
|
+
runsSizeLimitMb: defaults?.runs_size_limit_mb,
|
|
23619
|
+
recordInput: defaults?.record_input
|
|
23620
|
+
};
|
|
23621
|
+
}, "settings"),
|
|
23622
|
+
env,
|
|
23623
|
+
streams
|
|
23624
|
+
});
|
|
23625
|
+
runsOf.set(program, runs);
|
|
23817
23626
|
const imported = importedDocument(context);
|
|
23818
23627
|
installSessionCommands(program, context);
|
|
23819
23628
|
installFolderCommands(program, context);
|
|
@@ -23826,7 +23635,7 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23826
23635
|
document: imported,
|
|
23827
23636
|
output,
|
|
23828
23637
|
positive,
|
|
23829
|
-
complete: /* @__PURE__ */ __name(() =>
|
|
23638
|
+
complete: /* @__PURE__ */ __name(() => environment().complete ?? memoryModel(env, selected(), signal()), "complete"),
|
|
23830
23639
|
run: /* @__PURE__ */ __name(async (input, fn) => withIndex(async (index) => {
|
|
23831
23640
|
const lock = await lockProfile(env, selected());
|
|
23832
23641
|
try {
|
|
@@ -23845,20 +23654,25 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23845
23654
|
}), "run")
|
|
23846
23655
|
});
|
|
23847
23656
|
const remote = {
|
|
23848
|
-
mcp
|
|
23657
|
+
get mcp() {
|
|
23658
|
+
return agent();
|
|
23659
|
+
},
|
|
23849
23660
|
stored: storedDocument(context),
|
|
23850
23661
|
output,
|
|
23851
23662
|
positive,
|
|
23852
|
-
readBody:
|
|
23663
|
+
readBody: /* @__PURE__ */ __name((path) => {
|
|
23664
|
+
const fake = environment().readBody;
|
|
23665
|
+
if (fake)
|
|
23666
|
+
return fake(path);
|
|
23853
23667
|
try {
|
|
23854
|
-
return
|
|
23668
|
+
return readFileSync6(path, "utf8");
|
|
23855
23669
|
} catch {
|
|
23856
23670
|
throw new CliError("validation_error", "the request body file could not be read", {
|
|
23857
23671
|
reason: "body.unreadable",
|
|
23858
23672
|
param: "--body-file"
|
|
23859
23673
|
});
|
|
23860
23674
|
}
|
|
23861
|
-
}),
|
|
23675
|
+
}, "readBody"),
|
|
23862
23676
|
call: /* @__PURE__ */ __name(async (method, params, body) => {
|
|
23863
23677
|
const descriptor = apiMethod(method);
|
|
23864
23678
|
validateRequest(method, params, body);
|
|
@@ -23880,10 +23694,11 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23880
23694
|
}
|
|
23881
23695
|
const act = /* @__PURE__ */ __name(async () => {
|
|
23882
23696
|
try {
|
|
23883
|
-
|
|
23884
|
-
|
|
23697
|
+
const fake = environment().api;
|
|
23698
|
+
if (fake)
|
|
23699
|
+
return await fake.call(method, params, body);
|
|
23885
23700
|
const [{ googleApi }, client] = await Promise.all([
|
|
23886
|
-
import("./google-api-
|
|
23701
|
+
import("./google-api-EQQH53QD.js"),
|
|
23887
23702
|
signedIn(selected(), descriptor.scope)
|
|
23888
23703
|
]);
|
|
23889
23704
|
return await googleApi(client).call(method, params, body);
|
|
@@ -23905,10 +23720,11 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23905
23720
|
const flags = policyFlags();
|
|
23906
23721
|
for (const key of methodPolicyKeys(method))
|
|
23907
23722
|
await checkPolicy(env, selected(), key, false, flags, askOnce);
|
|
23908
|
-
|
|
23909
|
-
|
|
23723
|
+
const fake = environment().download;
|
|
23724
|
+
if (fake)
|
|
23725
|
+
return fake(id, mime);
|
|
23910
23726
|
const [{ googleDownload }, client] = await Promise.all([
|
|
23911
|
-
import("./google-api-
|
|
23727
|
+
import("./google-api-EQQH53QD.js"),
|
|
23912
23728
|
signedIn(selected(), apiMethod(method).scope)
|
|
23913
23729
|
]);
|
|
23914
23730
|
return googleDownload(client)(id, mime);
|
|
@@ -23923,10 +23739,10 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23923
23739
|
throw new Preview();
|
|
23924
23740
|
}
|
|
23925
23741
|
const act = /* @__PURE__ */ __name(async () => {
|
|
23926
|
-
let request =
|
|
23742
|
+
let request = environment().uploadRequest;
|
|
23927
23743
|
if (!request) {
|
|
23928
23744
|
const [{ googleUploadRequest }, client] = await Promise.all([
|
|
23929
|
-
import("./google-api-
|
|
23745
|
+
import("./google-api-EQQH53QD.js"),
|
|
23930
23746
|
signedIn(selected(), apiMethod(method).scope)
|
|
23931
23747
|
]);
|
|
23932
23748
|
request = googleUploadRequest(client);
|
|
@@ -23946,47 +23762,24 @@ var createProgram = /* @__PURE__ */ __name((options = {}) => {
|
|
|
23946
23762
|
installConfigCommands(program, context);
|
|
23947
23763
|
installCompleteCommand(program, context);
|
|
23948
23764
|
installModelCommands(program, context);
|
|
23949
|
-
installMcpCommand(program, context, createProgram);
|
|
23950
23765
|
installCommandsCommand(program, context);
|
|
23951
|
-
installSkillCommand(program, context);
|
|
23952
|
-
installDoctorCommand(program, context);
|
|
23953
23766
|
installUpgradeCommand(program, context);
|
|
23954
|
-
program.addCommand(overrideSharedContract(runsCommand(DRIVE_APP), "Every drive command declares its effects, groups included; the shared runs group reads only local files.", (
|
|
23955
|
-
annotate(
|
|
23767
|
+
program.addCommand(overrideSharedContract(runsCommand(DRIVE_APP), "Every drive command declares its effects, groups included; the shared runs group reads only local files.", (runs2) => {
|
|
23768
|
+
annotate(runs2, { effects: LOCAL_READ });
|
|
23956
23769
|
}));
|
|
23957
|
-
markProfileFree(program);
|
|
23958
|
-
provide(program, {
|
|
23959
|
-
env,
|
|
23960
|
-
streams,
|
|
23961
|
-
discoveryAvailability: /* @__PURE__ */ __name((info) => {
|
|
23962
|
-
if (!(profileWord ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK))
|
|
23963
|
-
return void 0;
|
|
23964
|
-
try {
|
|
23965
|
-
const command = flatten(describeDriveProgram(program)).find((one) => one.path.join(" ") === info.path.join(" "));
|
|
23966
|
-
return command ? discoveryAvailability(command, policySettings(env, selected(), policyFlags())) : void 0;
|
|
23967
|
-
} catch {
|
|
23968
|
-
return void 0;
|
|
23969
|
-
}
|
|
23970
|
-
}, "discoveryAvailability")
|
|
23971
|
-
});
|
|
23972
|
-
for (const info of flatten(describeDriveProgram(program))) {
|
|
23973
|
-
if (info.commands.length)
|
|
23974
|
-
continue;
|
|
23975
|
-
let command = program;
|
|
23976
|
-
for (const word of info.path)
|
|
23977
|
-
command = command.commands.find((one) => one.name() === word) ?? command;
|
|
23978
|
-
command.addHelpText("after", () => {
|
|
23979
|
-
const availability = environmentOf(program).discoveryAvailability?.(info);
|
|
23980
|
-
return availability?.available === false ? `
|
|
23981
|
-
Availability: unavailable \u2014 ${availability.reason}
|
|
23982
|
-
` : "";
|
|
23983
|
-
});
|
|
23984
|
-
}
|
|
23985
23770
|
program.addCommand(guide());
|
|
23771
|
+
markProfileFree(program);
|
|
23986
23772
|
for (const info of flatten(describeDriveProgram(program))) {
|
|
23987
23773
|
let command = program;
|
|
23988
23774
|
for (const part of info.path)
|
|
23989
23775
|
command = command.commands.find((child) => child.name() === part) ?? command;
|
|
23776
|
+
if (!info.commands.length)
|
|
23777
|
+
command.addHelpText("after", () => {
|
|
23778
|
+
const availability = environment().discoveryAvailability?.(info);
|
|
23779
|
+
return availability?.available === false ? `
|
|
23780
|
+
Availability: unavailable \u2014 ${availability.reason}
|
|
23781
|
+
` : "";
|
|
23782
|
+
});
|
|
23990
23783
|
const metadata = { origin: metaOf(command).origin ?? "handwritten", state: "beta" };
|
|
23991
23784
|
if (hasSharedContract(command))
|
|
23992
23785
|
overrideSharedContract(command, "Drive explicitly labels its public CLI commands beta while its provider integration is reviewed.", (one) => {
|
|
@@ -23995,6 +23788,7 @@ Availability: unavailable \u2014 ${availability.reason}
|
|
|
23995
23788
|
else
|
|
23996
23789
|
annotate(command, metadata);
|
|
23997
23790
|
}
|
|
23791
|
+
placeInSections(program);
|
|
23998
23792
|
const pathOf = /* @__PURE__ */ __name((command) => {
|
|
23999
23793
|
const path = [];
|
|
24000
23794
|
for (let at = command; at?.parent; at = at.parent)
|
|
@@ -24003,14 +23797,9 @@ Availability: unavailable \u2014 ${availability.reason}
|
|
|
24003
23797
|
}, "pathOf");
|
|
24004
23798
|
program.hook("preAction", async (_root, action) => {
|
|
24005
23799
|
currentAction = action;
|
|
24006
|
-
|
|
24007
|
-
|
|
24008
|
-
|
|
24009
|
-
timeoutMs: program.opts().timeout,
|
|
24010
|
-
...options.signal ? { signal: options.signal } : {}
|
|
24011
|
-
});
|
|
24012
|
-
activeSignal = deadline.signal;
|
|
24013
|
-
}
|
|
23800
|
+
runs.start(action);
|
|
23801
|
+
const fields = program.opts().fields;
|
|
23802
|
+
checkProviderJson(action, { json: program.opts().json === true, ...fields ? { fields } : {} }, environment().tty ?? process.stdout.isTTY);
|
|
24014
23803
|
const path = pathOf(action);
|
|
24015
23804
|
const words = path.join(" ");
|
|
24016
23805
|
const metadata = metaOf(action);
|
|
@@ -24022,26 +23811,43 @@ Availability: unavailable \u2014 ${availability.reason}
|
|
|
24022
23811
|
if (program.opts().dryRun === true && (writes(metadata.effects) || changesAuthority(action)))
|
|
24023
23812
|
preview();
|
|
24024
23813
|
}, "previewWrite");
|
|
24025
|
-
if (ACCOUNT_FREE_COMMANDS.has(words) && !
|
|
23814
|
+
if (ACCOUNT_FREE_COMMANDS.has(words) && !agent())
|
|
24026
23815
|
return previewWrite();
|
|
24027
|
-
await options.atStart?.(action);
|
|
24028
23816
|
if (ANY_PROFILE_COMMANDS.has(words)) {
|
|
24029
|
-
if (profileWord ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK)
|
|
23817
|
+
if (profileWord() ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK)
|
|
24030
23818
|
selected();
|
|
24031
23819
|
return;
|
|
24032
23820
|
}
|
|
24033
|
-
if (words === "config unset" && !
|
|
23821
|
+
if (words === "config unset" && !agent() && !profileWord()) {
|
|
24034
23822
|
refuseUnderReadOnly(env, "change a setting");
|
|
24035
23823
|
return previewWrite();
|
|
24036
23824
|
}
|
|
24037
|
-
if (
|
|
23825
|
+
if (words === "mcp serve" && program.opts().readOnly) {
|
|
23826
|
+
const served = environment().env ?? process.env;
|
|
23827
|
+
served.DRIVE_READ_ONLY = "1";
|
|
23828
|
+
}
|
|
23829
|
+
if (words === "mcp revoke" && program.opts().readOnly)
|
|
23830
|
+
throw readOnlyRefusal("--read-only", "forget the browser logins");
|
|
23831
|
+
if (PROFILE_SET_COMMANDS.has(words) || path[0] === "mcp") {
|
|
23832
|
+
const named = profileWord() ?? env.DRIVE_PROFILE ?? env.DRIVE_PROFILE_LOCK;
|
|
23833
|
+
if (words === "mcp serve" && named && action.opts().profiles === void 0)
|
|
23834
|
+
await checkPolicy(env, selected(), "mcp", false, policyFlags(), askOnce);
|
|
24038
23835
|
return;
|
|
23836
|
+
}
|
|
24039
23837
|
selected();
|
|
24040
|
-
if ((words === "config set" || words === "config unset") && !
|
|
23838
|
+
if ((words === "config set" || words === "config unset") && !agent()) {
|
|
24041
23839
|
refuseUnderReadOnly(env, "change a setting");
|
|
24042
23840
|
return previewWrite();
|
|
24043
23841
|
}
|
|
24044
|
-
if (
|
|
23842
|
+
if (agent() && EXPORTS.has(words)) {
|
|
23843
|
+
const name = action.opts().output;
|
|
23844
|
+
if (typeof name !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(name))
|
|
23845
|
+
throw new CliError("validation_error", "MCP exports take a filename inside the profile export folder");
|
|
23846
|
+
const directory = join10(paths(env).cache, "exports", selected());
|
|
23847
|
+
mkdirSync4(directory, { recursive: true, mode: 448 });
|
|
23848
|
+
action.setOptionValue("output", join10(directory, name));
|
|
23849
|
+
}
|
|
23850
|
+
if (agent() && changesAuthority(action)) {
|
|
24045
23851
|
const authority = policySettings(env, selected(), policyFlags());
|
|
24046
23852
|
if (!["ask", "allow"].includes(levelFor(authority.levels, "mcp.authority").level))
|
|
24047
23853
|
throw new CliError("permission_error", "MCP authority changes require the owner's mcp.authority permission");
|
|
@@ -24052,8 +23858,6 @@ Availability: unavailable \u2014 ${availability.reason}
|
|
|
24052
23858
|
}
|
|
24053
23859
|
}
|
|
24054
23860
|
const flags = policyFlags();
|
|
24055
|
-
if (words === "mcp serve")
|
|
24056
|
-
return checkPolicy(env, selected(), "mcp", false, flags, askOnce);
|
|
24057
23861
|
const rawMethod = words === "api call" ? action.args[0] : void 0;
|
|
24058
23862
|
const method = metadata.api_operation ?? rawMethod;
|
|
24059
23863
|
if (rawMethod) {
|
|
@@ -24076,82 +23880,89 @@ Availability: unavailable \u2014 ${availability.reason}
|
|
|
24076
23880
|
throw new CliError("permission_error", "this command may require network access; --offline was requested", {
|
|
24077
23881
|
reason: "offline.refused"
|
|
24078
23882
|
});
|
|
24079
|
-
|
|
24080
|
-
if (flags.dryRun && !googleOnly)
|
|
23883
|
+
if (flags.dryRun && !googleOnly(metadata.effects))
|
|
24081
23884
|
preview();
|
|
23885
|
+
if (flags.dryRun) {
|
|
23886
|
+
previewsRequest = true;
|
|
23887
|
+
program.setOptionValue("dryRun", false);
|
|
23888
|
+
}
|
|
24082
23889
|
if (words === "session start")
|
|
24083
23890
|
refuseCommandName(selected(), commandWords(program), "drive");
|
|
24084
23891
|
});
|
|
23892
|
+
program.hook("postAction", () => runs.succeed());
|
|
24085
23893
|
const parse = program.parseAsync.bind(program);
|
|
24086
|
-
|
|
24087
|
-
|
|
24088
|
-
|
|
24089
|
-
|
|
24090
|
-
|
|
24091
|
-
|
|
24092
|
-
|
|
24093
|
-
|
|
24094
|
-
|
|
24095
|
-
|
|
24096
|
-
|
|
24097
|
-
|
|
24098
|
-
program.setOptionValue("profile", profileWord);
|
|
24099
|
-
const rest = lifted.rest;
|
|
23894
|
+
const scope = {
|
|
23895
|
+
get runId() {
|
|
23896
|
+
return runs.runId() ?? runId;
|
|
23897
|
+
},
|
|
23898
|
+
command: "",
|
|
23899
|
+
startedAt,
|
|
23900
|
+
events: /* @__PURE__ */ __name(((event) => {
|
|
23901
|
+
if (event.event === "request" || event.event === "response")
|
|
23902
|
+
runs.events(event);
|
|
23903
|
+
}), "events")
|
|
23904
|
+
};
|
|
23905
|
+
program.parseAsync = async (argv, settings) => {
|
|
24100
23906
|
try {
|
|
24101
|
-
|
|
24102
|
-
return deadline ? await deadline.race(async () => running) : await running;
|
|
23907
|
+
return await inRun(scope, () => parse(argv, settings));
|
|
24103
23908
|
} catch (error) {
|
|
24104
|
-
|
|
24105
|
-
|
|
24106
|
-
|
|
24107
|
-
|
|
24108
|
-
|
|
24109
|
-
} finally {
|
|
24110
|
-
deadline?.dispose();
|
|
23909
|
+
const stopped = stopSignal?.aborted && (!isCliError(error) || error.code !== "outcome_unknown");
|
|
23910
|
+
if (!(error instanceof Preview) && !stopped)
|
|
23911
|
+
throw error;
|
|
23912
|
+
await runs.succeed();
|
|
23913
|
+
return program;
|
|
24111
23914
|
}
|
|
24112
23915
|
};
|
|
24113
|
-
recordRuns(program, {
|
|
24114
|
-
app: DRIVE_APP,
|
|
24115
|
-
agent: options.mcp === true,
|
|
24116
|
-
profile: selected,
|
|
24117
|
-
settings: /* @__PURE__ */ __name(() => {
|
|
24118
|
-
const defaults = readConfig(env).defaults;
|
|
24119
|
-
return {
|
|
24120
|
-
record: defaults?.record,
|
|
24121
|
-
keepRunsForDays: defaults?.keep_runs_for_days,
|
|
24122
|
-
keepSuccessfulRunsForDays: defaults?.keep_successful_runs_for_days,
|
|
24123
|
-
runsSizeLimitMb: defaults?.runs_size_limit_mb,
|
|
24124
|
-
recordInput: defaults?.record_input
|
|
24125
|
-
};
|
|
24126
|
-
}, "settings"),
|
|
24127
|
-
env,
|
|
24128
|
-
streams
|
|
24129
|
-
});
|
|
24130
|
-
for (const info of flatten(describeDriveProgram(program))) {
|
|
24131
|
-
let command = program;
|
|
24132
|
-
for (const part of info.path)
|
|
24133
|
-
command = command.commands.find((child) => child.name() === part) ?? command;
|
|
24134
|
-
command.configureHelp({
|
|
24135
|
-
commandUsage: /* @__PURE__ */ __name((target) => {
|
|
24136
|
-
const usage = new Help().commandUsage(target);
|
|
24137
|
-
return takesProfile(target) ? usage.replace(/^drive /, "drive <profile> ") : usage;
|
|
24138
|
-
}, "commandUsage")
|
|
24139
|
-
});
|
|
24140
|
-
command.exitOverride().configureOutput({
|
|
24141
|
-
writeOut: /* @__PURE__ */ __name((text) => streams.data(text.replace(/\n$/, "")), "writeOut"),
|
|
24142
|
-
writeErr: /* @__PURE__ */ __name((text) => streams.diagnostic(text.replace(/\n$/, "")), "writeErr"),
|
|
24143
|
-
outputError: /* @__PURE__ */ __name(() => {
|
|
24144
|
-
}, "outputError")
|
|
24145
|
-
});
|
|
24146
|
-
}
|
|
24147
|
-
installFirstScreen(program);
|
|
24148
23916
|
addContractInfo(program, (value) => streams.data(JSON.stringify(value)), {
|
|
24149
23917
|
fields: providerJsonFields,
|
|
24150
23918
|
errors: { reasons: REASONS }
|
|
24151
23919
|
});
|
|
24152
|
-
|
|
24153
|
-
|
|
24154
|
-
|
|
23920
|
+
}, "installDrive");
|
|
23921
|
+
var oauthClient = /* @__PURE__ */ __name((env) => {
|
|
23922
|
+
application(env);
|
|
23923
|
+
return { client: env.DRIVE_GOOGLE_CLIENT_ID ? "own" : "wirecat" };
|
|
23924
|
+
}, "oauthClient");
|
|
23925
|
+
var mcpCommand = /* @__PURE__ */ __name(() => {
|
|
23926
|
+
let availability;
|
|
23927
|
+
const mcp = appMcpCommand(DRIVE_APP, configuration, {
|
|
23928
|
+
name: "Google Drive",
|
|
23929
|
+
untrusted: ["document text", "file names", "comments", "author and editor names", "folder names"],
|
|
23930
|
+
permissionExample: "files.trash=deny",
|
|
23931
|
+
skill: SKILL,
|
|
23932
|
+
availability: /* @__PURE__ */ __name((path, profile) => availability?.(path, profile), "availability"),
|
|
23933
|
+
// A profile enters the file only when its sign-in succeeds; the keyring is never opened here.
|
|
23934
|
+
signedIn: /* @__PURE__ */ __name((profile, env) => {
|
|
23935
|
+
try {
|
|
23936
|
+
return Object.hasOwn(readConfig(env).profiles, profile);
|
|
23937
|
+
} catch {
|
|
23938
|
+
return false;
|
|
23939
|
+
}
|
|
23940
|
+
}, "signedIn")
|
|
23941
|
+
});
|
|
23942
|
+
return mcp.hook("preAction", async (root, action) => {
|
|
23943
|
+
const environment = environmentOf(action);
|
|
23944
|
+
if (environment.api)
|
|
23945
|
+
return;
|
|
23946
|
+
const { grantAvailability } = await import("./grants-4NETZ4MR.js");
|
|
23947
|
+
availability = grantAvailability(rootOf(root), environment.env ?? process.env, environment.keyring);
|
|
23948
|
+
});
|
|
23949
|
+
}, "mcpCommand");
|
|
23950
|
+
var definition = /* @__PURE__ */ __name(() => ({
|
|
23951
|
+
app: DRIVE_APP,
|
|
23952
|
+
configuration,
|
|
23953
|
+
firstScreen: FIRST_SCREEN,
|
|
23954
|
+
commands: /* @__PURE__ */ __name(() => [
|
|
23955
|
+
appDoctorCommand(DRIVE_APP, configuration, { oauthClient }),
|
|
23956
|
+
skillCommand(DRIVE_APP, SKILL),
|
|
23957
|
+
mcpCommand()
|
|
23958
|
+
], "commands"),
|
|
23959
|
+
configure: installDrive,
|
|
23960
|
+
onFailure: /* @__PURE__ */ __name((error, program) => runsOf.get(program)?.fail(error), "onFailure")
|
|
23961
|
+
}), "definition");
|
|
23962
|
+
var createProgram2 = /* @__PURE__ */ __name(() => createProgram(definition()), "createProgram");
|
|
23963
|
+
var run2 = /* @__PURE__ */ __name((argv, options = {}) => run(argv, definition(), options), "run");
|
|
24155
23964
|
export {
|
|
24156
|
-
createProgram
|
|
23965
|
+
createProgram2 as createProgram,
|
|
23966
|
+
definition,
|
|
23967
|
+
run2 as run
|
|
24157
23968
|
};
|