@wirecat/drive-cli 0.44.0 → 0.45.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 +35 -40
- package/dist/bundle/all-profiles-LTHNCWQW.js +26 -0
- package/dist/bundle/anthropic-NOJEF3V2.js +71 -0
- package/dist/bundle/bun-ADJVI4HY.js +169 -0
- package/dist/bundle/bun-sqlite-GNXLBF2A.js +70 -0
- package/dist/bundle/chunk-2FTZBZOB.js +2315 -0
- package/dist/bundle/chunk-2YU3CXFD.js +3391 -0
- package/dist/bundle/chunk-35GRI4DI.js +375 -0
- package/dist/bundle/chunk-37MAA6F2.js +5624 -0
- package/dist/bundle/chunk-3V6NPZY7.js +2352 -0
- package/dist/bundle/chunk-4TIC23D2.js +9 -0
- package/dist/bundle/chunk-4TQSNQVV.js +1071 -0
- package/dist/bundle/chunk-4UE7AVHZ.js +150 -0
- package/dist/bundle/chunk-5DPV7X27.js +663 -0
- package/dist/bundle/chunk-5FONRUG6.js +24805 -0
- package/dist/bundle/chunk-5ZVLM6YR.js +19 -0
- package/dist/bundle/chunk-64WJYT2F.js +3954 -0
- package/dist/bundle/chunk-65GGKAQ7.js +82 -0
- package/dist/bundle/chunk-66N2DGGC.js +515 -0
- package/dist/bundle/chunk-6KFA6HOM.js +2941 -0
- package/dist/bundle/chunk-6Y2BYFXQ.js +65 -0
- package/dist/bundle/chunk-7NCG2SHR.js +74 -0
- package/dist/bundle/chunk-7PVNJAQ2.js +73 -0
- package/dist/bundle/chunk-7XWUOCGW.js +190 -0
- package/dist/bundle/chunk-A6ZKTNTZ.js +168 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AH3SNVCV.js +498 -0
- package/dist/bundle/chunk-AN3GVZTU.js +76 -0
- package/dist/bundle/chunk-BPBIBVFH.js +166 -0
- package/dist/bundle/chunk-C4XP5T73.js +264 -0
- package/dist/bundle/chunk-C6SMAEED.js +18102 -0
- package/dist/bundle/chunk-CDI67JSB.js +1092 -0
- package/dist/bundle/chunk-CEO5HPRL.js +25 -0
- package/dist/bundle/chunk-CFT7UHF6.js +15572 -0
- package/dist/bundle/chunk-DC4T3FNP.js +1913 -0
- package/dist/bundle/chunk-DCTXOMOR.js +35 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-EVWXODYV.js +754 -0
- package/dist/bundle/chunk-GKHM6I64.js +2356 -0
- package/dist/bundle/chunk-GNI7INK6.js +18 -0
- package/dist/bundle/chunk-GTYY6BIE.js +58 -0
- package/dist/bundle/chunk-GX4WEMAG.js +164 -0
- package/dist/bundle/chunk-HA3WCVGY.js +8179 -0
- package/dist/bundle/chunk-HLONHTSG.js +281 -0
- package/dist/bundle/chunk-HOIUIKWS.js +236 -0
- package/dist/bundle/chunk-HTQTIKWP.js +928 -0
- package/dist/bundle/chunk-I5EJHKNC.js +111 -0
- package/dist/bundle/chunk-ICKNJIGE.js +31 -0
- package/dist/bundle/chunk-IGB5CJCA.js +62 -0
- package/dist/bundle/chunk-IP4OK7RQ.js +24 -0
- package/dist/bundle/chunk-IVQ6342B.js +2 -0
- package/dist/bundle/chunk-K4N2DKE5.js +17 -0
- package/dist/bundle/chunk-LNB7BIZL.js +844 -0
- package/dist/bundle/chunk-LVDHWNJF.js +193 -0
- package/dist/bundle/chunk-LW2G4U6W.js +570 -0
- package/dist/bundle/chunk-LWT55XC5.js +60 -0
- package/dist/bundle/chunk-LY26NW3I.js +6848 -0
- package/dist/bundle/chunk-MJR2OTO4.js +1714 -0
- package/dist/bundle/chunk-MWUITL6N.js +42 -0
- package/dist/bundle/chunk-N47CYWEM.js +454 -0
- package/dist/bundle/chunk-NKZ6V4JW.js +263 -0
- package/dist/bundle/chunk-NQ6LLDDC.js +161 -0
- package/dist/bundle/chunk-NZIHPYY5.js +215 -0
- package/dist/bundle/chunk-OECPFZLP.js +3541 -0
- package/dist/bundle/chunk-P5KGFT7U.js +18 -0
- package/dist/bundle/chunk-PDH2QQQV.js +484 -0
- package/dist/bundle/chunk-PIN5RZ3D.js +63 -0
- package/dist/bundle/chunk-PJDO7AFZ.js +421 -0
- package/dist/bundle/chunk-PWKXHDBQ.js +18078 -0
- package/dist/bundle/chunk-QLZGLPJL.js +100 -0
- package/dist/bundle/chunk-SBZB7HMU.js +1055 -0
- package/dist/bundle/chunk-SGOPYPVW.js +835 -0
- package/dist/bundle/chunk-TDC6JGDA.js +630 -0
- package/dist/bundle/chunk-TOYPN2XX.js +288 -0
- package/dist/bundle/chunk-UC44ZMQV.js +78 -0
- package/dist/bundle/chunk-V7GN5BI7.js +99 -0
- package/dist/bundle/chunk-VO4KOLQZ.js +119 -0
- package/dist/bundle/chunk-WPGCDWPU.js +1855 -0
- package/dist/bundle/chunk-WQMVSQPP.js +886 -0
- package/dist/bundle/chunk-WZUJKUBK.js +384 -0
- package/dist/bundle/chunk-X5DFDGWS.js +2 -0
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/chunk-XPEWOPJR.js +431 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-Y5EJSZXV.js +220 -0
- package/dist/bundle/chunk-YE3J6DLY.js +106 -0
- package/dist/bundle/chunk-YFLKH3NZ.js +48 -0
- package/dist/bundle/chunk-YJX4X564.js +138 -0
- package/dist/bundle/chunk-YJZBJ2TM.js +71 -0
- package/dist/bundle/chunk-Z4O6C7WR.js +1973 -0
- package/dist/bundle/chunk-ZIHLE7LG.js +15992 -0
- package/dist/bundle/chunk-ZPMLLONT.js +1054 -0
- package/dist/bundle/chunk-ZQNXKWUY.js +35584 -0
- package/dist/bundle/chunk-ZS635F4O.js +45 -0
- package/dist/bundle/chunk-ZU732VCC.js +122 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-HX35D7KV.js +38 -0
- package/dist/bundle/dist-MWTMOYWT.js +7577 -0
- package/dist/bundle/dist-PY3MVR3G.js +21 -0
- package/dist/bundle/drive.js +50 -0
- package/dist/bundle/echarts-RFTK737T.js +42501 -0
- package/dist/bundle/embed-5NAGJUMD.js +37 -0
- package/dist/bundle/embedder-EWXLIGBY.js +110 -0
- package/dist/bundle/entry-YCPJ6H6U.js +15 -0
- package/dist/bundle/failure-XBWHHBEW.js +37 -0
- package/dist/bundle/first-run-LNAZDBB4.js +24 -0
- package/dist/bundle/first-screen-P5NNFJD7.js +36 -0
- package/dist/bundle/google-5FFKRHHC.js +32 -0
- package/dist/bundle/google-api-TJCFOOAP.js +82 -0
- package/dist/bundle/identity-53ZMPL2O.js +10 -0
- package/dist/bundle/instructions-FHNL7CMW.js +9 -0
- package/dist/bundle/login-VXXZZR6G.js +158 -0
- package/dist/bundle/mcp-2CJCJXSW.js +95 -0
- package/dist/bundle/mcp-F4XZO76F.js +507 -0
- package/dist/bundle/mcp-IXFC2VVR.js +165 -0
- package/dist/bundle/mdast-util-from-markdown-FXEPSNER.js +1958 -0
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +2103 -0
- package/dist/bundle/micromark-extension-gfm-GRL24TU6.js +1838 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-ZMCACJVS.js +176 -0
- package/dist/bundle/node-sqlite-QJQ5S7KS.js +46 -0
- package/dist/bundle/oauth-TZFDPAFE.js +18 -0
- package/dist/bundle/open-IYM25QTL.js +20 -0
- package/dist/bundle/process-ZPTLNVQS.js +91 -0
- package/dist/bundle/program-YX7DZMPR.js +24100 -0
- package/dist/bundle/prompt-TGWTVIEK.js +13 -0
- package/dist/bundle/reasons-Q5LOQESQ.js +11 -0
- package/dist/bundle/recognize-AGPMWKIY.js +191 -0
- package/dist/bundle/remote-QV7QSLAK.js +28 -0
- package/dist/bundle/rerank-HZKJJCS4.js +51 -0
- package/dist/bundle/serve-NRJQOVT4.js +20 -0
- package/dist/bundle/server-2UQDEWTS.js +818 -0
- package/dist/bundle/server-R4JUHFSW.js +56 -0
- package/dist/bundle/services-NZQWVMOE.js +333 -0
- package/dist/bundle/sqlite-runtime-6MXHTYYU.js +17 -0
- package/dist/bundle/state-IF2FLTSY.js +34 -0
- package/dist/bundle/store-HBD54IRL.js +142 -0
- package/dist/bundle/store-HVIBXOXS.js +125 -0
- package/dist/bundle/store-maintenance-command-U3F4RGJB.js +57 -0
- package/dist/bundle/terminal-TFCTWLOS.js +11 -0
- package/dist/bundle/tokens-5D5YUA2Q.js +103 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +87 -37
- package/dist/commands/mcp.js.map +1 -1
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +78 -53
- package/dist/contract-overrides.js.map +1 -1
- package/dist/mcp.d.ts +13 -5
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +20 -10
- package/dist/mcp.js.map +1 -1
- package/dist/program.js +4 -4
- package/dist/program.js.map +1 -1
- package/dist/registry.d.ts +2 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +1 -1
- package/dist/state.d.ts +5 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +5 -2
- package/dist/state.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -5
- package/skills/drive-cli/SKILL.md +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MAX_SECRET_INPUT,
|
|
5
|
+
bufferedInput,
|
|
6
|
+
inputPolicy
|
|
7
|
+
} from "./chunk-YJZBJ2TM.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError
|
|
10
|
+
} from "./chunk-GKHM6I64.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.469.0_@wirecat+cli-base@0.65.0_commander@15.0.0_typescript@7.0.2_vi_80b586dbc8b099637a6e461856c2ee6b/node_modules/@wirecat/cli-core/dist/terminal/prompt.js
|
|
16
|
+
import { createInterface } from "node:readline";
|
|
17
|
+
import { Writable } from "node:stream";
|
|
18
|
+
var readSecret = /* @__PURE__ */ __name(async (prompt, { input = process.stdin, output = process.stderr, echo = false, signal: givenSignal } = {}) => {
|
|
19
|
+
const policy = inputPolicy(input);
|
|
20
|
+
const signals = [givenSignal, policy.signal].filter((one) => one !== void 0);
|
|
21
|
+
const signal = signals.length ? AbortSignal.any(signals) : void 0;
|
|
22
|
+
const cancelled = /* @__PURE__ */ __name(() => new CliError("cancelled", "cancelled \u2014 nothing was stored"), "cancelled");
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
throw cancelled();
|
|
25
|
+
if (input.isTTY && policy.noInput)
|
|
26
|
+
throw new CliError("validation_error", "interactive input is disabled \u2014 provide the input through a pipe", {
|
|
27
|
+
reason: "input.required"
|
|
28
|
+
});
|
|
29
|
+
if (!input.isTTY) {
|
|
30
|
+
return (await bufferedInput(input, {
|
|
31
|
+
maxBytes: Math.min(policy.maxBytes ?? MAX_SECRET_INPUT, MAX_SECRET_INPUT),
|
|
32
|
+
...signal ? { signal } : {}
|
|
33
|
+
})).toString("utf8").trim();
|
|
34
|
+
}
|
|
35
|
+
let muted = false;
|
|
36
|
+
const shim = new Writable({
|
|
37
|
+
write(chunk, _encoding, done) {
|
|
38
|
+
if (!muted)
|
|
39
|
+
output.write(chunk);
|
|
40
|
+
done();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const reader = createInterface({ input, output: shim, terminal: true });
|
|
44
|
+
const abort = /* @__PURE__ */ __name(() => reader.close(), "abort");
|
|
45
|
+
let bytes = 0;
|
|
46
|
+
let inputFailure;
|
|
47
|
+
const data = /* @__PURE__ */ __name((chunk) => {
|
|
48
|
+
bytes += Buffer.byteLength(chunk);
|
|
49
|
+
if (bytes > Math.min(policy.maxBytes ?? MAX_SECRET_INPUT, MAX_SECRET_INPUT)) {
|
|
50
|
+
inputFailure = new CliError("validation_error", "secret input exceeds its byte limit", {
|
|
51
|
+
reason: "input.too-large",
|
|
52
|
+
retryable: false
|
|
53
|
+
});
|
|
54
|
+
reader.close();
|
|
55
|
+
}
|
|
56
|
+
}, "data");
|
|
57
|
+
const inputError = /* @__PURE__ */ __name((error) => {
|
|
58
|
+
inputFailure = error;
|
|
59
|
+
reader.close();
|
|
60
|
+
}, "inputError");
|
|
61
|
+
input.on("data", data).on("error", inputError);
|
|
62
|
+
try {
|
|
63
|
+
const answer = await new Promise((resolve, reject) => {
|
|
64
|
+
const cancel = /* @__PURE__ */ __name(() => reject(inputFailure ?? cancelled()), "cancel");
|
|
65
|
+
reader.once("SIGINT", cancel);
|
|
66
|
+
reader.once("close", cancel);
|
|
67
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
68
|
+
reader.question(prompt, resolve);
|
|
69
|
+
muted = !echo;
|
|
70
|
+
});
|
|
71
|
+
return answer.trim();
|
|
72
|
+
} finally {
|
|
73
|
+
input.off("data", data).off("error", inputError);
|
|
74
|
+
signal?.removeEventListener("abort", abort);
|
|
75
|
+
reader.close();
|
|
76
|
+
output.write("\n");
|
|
77
|
+
}
|
|
78
|
+
}, "readSecret");
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
readSecret
|
|
82
|
+
};
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
operations
|
|
5
|
+
} from "./chunk-CFT7UHF6.js";
|
|
6
|
+
import {
|
|
7
|
+
fileId,
|
|
8
|
+
inspectConfig,
|
|
9
|
+
paths,
|
|
10
|
+
profileName,
|
|
11
|
+
refusal
|
|
12
|
+
} from "./chunk-Y5EJSZXV.js";
|
|
13
|
+
import {
|
|
14
|
+
DRIVE_APP
|
|
15
|
+
} from "./chunk-5ZVLM6YR.js";
|
|
16
|
+
import {
|
|
17
|
+
VERSION
|
|
18
|
+
} from "./chunk-4TIC23D2.js";
|
|
19
|
+
import {
|
|
20
|
+
RecipientList,
|
|
21
|
+
SendJournal,
|
|
22
|
+
sendGuard
|
|
23
|
+
} from "./chunk-DC4T3FNP.js";
|
|
24
|
+
import {
|
|
25
|
+
newOperationId
|
|
26
|
+
} from "./chunk-C6SMAEED.js";
|
|
27
|
+
import {
|
|
28
|
+
profileFree
|
|
29
|
+
} from "./chunk-Z4O6C7WR.js";
|
|
30
|
+
import {
|
|
31
|
+
annotate,
|
|
32
|
+
commandsDocument,
|
|
33
|
+
describeProgram,
|
|
34
|
+
flatten
|
|
35
|
+
} from "./chunk-64WJYT2F.js";
|
|
36
|
+
import {
|
|
37
|
+
guardedWrite
|
|
38
|
+
} from "./chunk-CDI67JSB.js";
|
|
39
|
+
import {
|
|
40
|
+
CEILING_KEY,
|
|
41
|
+
LEVELS,
|
|
42
|
+
layerPermissions,
|
|
43
|
+
levelFor
|
|
44
|
+
} from "./chunk-PJDO7AFZ.js";
|
|
45
|
+
import {
|
|
46
|
+
setupPermissionCeiling
|
|
47
|
+
} from "./chunk-LWT55XC5.js";
|
|
48
|
+
import {
|
|
49
|
+
readOnlyLockOf,
|
|
50
|
+
readOnlyRefusal
|
|
51
|
+
} from "./chunk-CEO5HPRL.js";
|
|
52
|
+
import {
|
|
53
|
+
writeSecurely
|
|
54
|
+
} from "./chunk-6KFA6HOM.js";
|
|
55
|
+
import {
|
|
56
|
+
CliError,
|
|
57
|
+
array,
|
|
58
|
+
boolean,
|
|
59
|
+
integer,
|
|
60
|
+
literal,
|
|
61
|
+
minValue,
|
|
62
|
+
number,
|
|
63
|
+
object,
|
|
64
|
+
optional,
|
|
65
|
+
picklist,
|
|
66
|
+
pipe,
|
|
67
|
+
record,
|
|
68
|
+
regex,
|
|
69
|
+
safeParse,
|
|
70
|
+
string,
|
|
71
|
+
unknown,
|
|
72
|
+
writes
|
|
73
|
+
} from "./chunk-GKHM6I64.js";
|
|
74
|
+
import {
|
|
75
|
+
__name
|
|
76
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
77
|
+
|
|
78
|
+
// dist/state.js
|
|
79
|
+
import { mkdirSync, readFileSync, unlinkSync } from "node:fs";
|
|
80
|
+
import { join } from "node:path";
|
|
81
|
+
var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
|
|
82
|
+
var User = object({ id: optional(string()), email: optional(string()), name: optional(string()) });
|
|
83
|
+
var File = object({
|
|
84
|
+
id: ID,
|
|
85
|
+
name: string(),
|
|
86
|
+
mime: string(),
|
|
87
|
+
parents: array(ID),
|
|
88
|
+
version: optional(string()),
|
|
89
|
+
modifiedAt: optional(string()),
|
|
90
|
+
url: string(),
|
|
91
|
+
trashed: boolean(),
|
|
92
|
+
canDownload: boolean(),
|
|
93
|
+
size: optional(number()),
|
|
94
|
+
createdAt: optional(string()),
|
|
95
|
+
description: optional(string()),
|
|
96
|
+
driveId: optional(string()),
|
|
97
|
+
owners: optional(array(User)),
|
|
98
|
+
lastModifiedBy: optional(User),
|
|
99
|
+
providerMetadata: optional(unknown())
|
|
100
|
+
});
|
|
101
|
+
var Skip = object({
|
|
102
|
+
id: ID,
|
|
103
|
+
reason: string(),
|
|
104
|
+
file: optional(File),
|
|
105
|
+
textLimit: optional(number()),
|
|
106
|
+
storeRefusedIn: optional(string())
|
|
107
|
+
});
|
|
108
|
+
var State = object({
|
|
109
|
+
version: literal(1),
|
|
110
|
+
store: optional(string()),
|
|
111
|
+
linkedThrough: optional(string()),
|
|
112
|
+
linksPending: optional(boolean()),
|
|
113
|
+
linksVersion: optional(pipe(number(), integer(), minValue(1))),
|
|
114
|
+
principal: string(),
|
|
115
|
+
scope: string(),
|
|
116
|
+
cursor: optional(string()),
|
|
117
|
+
folders: record(ID, File),
|
|
118
|
+
documents: record(ID, object({
|
|
119
|
+
metadata: File,
|
|
120
|
+
hash: string(),
|
|
121
|
+
reference: string(),
|
|
122
|
+
tabs: number(),
|
|
123
|
+
notRead: optional(string()),
|
|
124
|
+
picture: optional(picklist(["saved", "too-large"]))
|
|
125
|
+
})),
|
|
126
|
+
skipped: array(Skip),
|
|
127
|
+
lastSync: optional(string()),
|
|
128
|
+
pending: optional(object({
|
|
129
|
+
cursor: string(),
|
|
130
|
+
scope: string(),
|
|
131
|
+
folders: record(ID, File),
|
|
132
|
+
jobs: array(object({ id: ID, kind: picklist(["save", "remove"]), file: optional(File) })),
|
|
133
|
+
skipped: array(Skip)
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
var Walk = object({
|
|
137
|
+
scope: string(),
|
|
138
|
+
cursor: string(),
|
|
139
|
+
stack: array(object({ id: ID, ancestry: array(ID), folder: optional(File) })),
|
|
140
|
+
visited: array(ID),
|
|
141
|
+
folders: record(ID, File),
|
|
142
|
+
files: array(File),
|
|
143
|
+
discovered: number()
|
|
144
|
+
});
|
|
145
|
+
var profileDir = /* @__PURE__ */ __name((env, name) => join(paths(env).state, "profiles", profileName(name)), "profileDir");
|
|
146
|
+
var statePath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "state.json"), "statePath");
|
|
147
|
+
var readState = /* @__PURE__ */ __name((env, name, principal) => {
|
|
148
|
+
let value;
|
|
149
|
+
try {
|
|
150
|
+
value = JSON.parse(readFileSync(statePath(env, name), "utf8"));
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (error.code === "ENOENT")
|
|
153
|
+
return { version: 1, principal, scope: "", folders: {}, documents: {}, skipped: [] };
|
|
154
|
+
throw new CliError("configuration_error", "sync state is unreadable; refusing to reset its checkpoint", {
|
|
155
|
+
reason: "state.invalid"
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const parsed = safeParse(State, value);
|
|
159
|
+
if (!parsed.success || parsed.output.principal !== principal)
|
|
160
|
+
throw new CliError("configuration_error", "sync state is invalid or belongs to another Google account", {
|
|
161
|
+
reason: "state.invalid"
|
|
162
|
+
});
|
|
163
|
+
return parsed.output;
|
|
164
|
+
}, "readState");
|
|
165
|
+
var saveState = /* @__PURE__ */ __name((env, name, state) => {
|
|
166
|
+
writeSecurely(statePath(env, name), `${JSON.stringify(state)}
|
|
167
|
+
`, 384);
|
|
168
|
+
}, "saveState");
|
|
169
|
+
var walkPath = /* @__PURE__ */ __name((env, name) => join(profileDir(env, name), "walk.json"), "walkPath");
|
|
170
|
+
var readWalk = /* @__PURE__ */ __name((env, name, scope) => {
|
|
171
|
+
try {
|
|
172
|
+
const parsed = safeParse(Walk, JSON.parse(readFileSync(walkPath(env, name), "utf8")));
|
|
173
|
+
return parsed.success && parsed.output.scope === scope ? parsed.output : void 0;
|
|
174
|
+
} catch {
|
|
175
|
+
return void 0;
|
|
176
|
+
}
|
|
177
|
+
}, "readWalk");
|
|
178
|
+
var saveWalk = /* @__PURE__ */ __name((env, name, walk) => {
|
|
179
|
+
writeSecurely(walkPath(env, name), `${JSON.stringify(walk)}
|
|
180
|
+
`, 384);
|
|
181
|
+
}, "saveWalk");
|
|
182
|
+
var removeWalk = /* @__PURE__ */ __name((env, name) => {
|
|
183
|
+
try {
|
|
184
|
+
unlinkSync(walkPath(env, name));
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (error.code !== "ENOENT")
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}, "removeWalk");
|
|
190
|
+
var ensureProfileDir = /* @__PURE__ */ __name((env, name) => {
|
|
191
|
+
mkdirSync(profileDir(env, name), { recursive: true, mode: 448 });
|
|
192
|
+
}, "ensureProfileDir");
|
|
193
|
+
var snapshotPath = /* @__PURE__ */ __name((env, name, id) => join(profileDir(env, name), "documents", `${fileId(id)}.json`), "snapshotPath");
|
|
194
|
+
var saveSnapshot = /* @__PURE__ */ __name((env, name, content) => {
|
|
195
|
+
const path = snapshotPath(env, name, content.metadata.id);
|
|
196
|
+
writeSecurely(path, `${JSON.stringify(content)}
|
|
197
|
+
`, 384);
|
|
198
|
+
writeSecurely(path.replace(/\.json$/, ".md"), content.markdown, 384);
|
|
199
|
+
}, "saveSnapshot");
|
|
200
|
+
var removeSnapshot = /* @__PURE__ */ __name((env, name, id) => {
|
|
201
|
+
const path = snapshotPath(env, name, id);
|
|
202
|
+
for (const file of [path, path.replace(/\.json$/, ".md")]) {
|
|
203
|
+
try {
|
|
204
|
+
unlinkSync(file);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (error.code !== "ENOENT")
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}, "removeSnapshot");
|
|
211
|
+
var readSnapshot = /* @__PURE__ */ __name((env, name, id) => {
|
|
212
|
+
try {
|
|
213
|
+
return JSON.parse(readFileSync(snapshotPath(env, name, id), "utf8"));
|
|
214
|
+
} catch {
|
|
215
|
+
throw new CliError("not_found", "source snapshot is unavailable \u2014 run drive <profile> sync --rescan", {
|
|
216
|
+
reason: "state.snapshot-missing"
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}, "readSnapshot");
|
|
220
|
+
var profileSetTokenFile = /* @__PURE__ */ __name((env, option) => join(paths(env).state, `mcp-http-${option}.json`), "profileSetTokenFile");
|
|
221
|
+
var httpTokenFile = /* @__PURE__ */ __name((env, profile) => join(profileDir(env, profile), "mcp-http.json"), "httpTokenFile");
|
|
222
|
+
|
|
223
|
+
// dist/registry.js
|
|
224
|
+
var ACCOUNT_FREE_COMMANDS = /* @__PURE__ */ new Set([
|
|
225
|
+
"commands",
|
|
226
|
+
"commands info",
|
|
227
|
+
"models list",
|
|
228
|
+
"complete",
|
|
229
|
+
"doctor",
|
|
230
|
+
"upgrade",
|
|
231
|
+
"api show",
|
|
232
|
+
"api list",
|
|
233
|
+
"help",
|
|
234
|
+
"guide",
|
|
235
|
+
"skill show",
|
|
236
|
+
"skill install",
|
|
237
|
+
"skill status",
|
|
238
|
+
"models download",
|
|
239
|
+
"images models download",
|
|
240
|
+
"runs list",
|
|
241
|
+
"runs show",
|
|
242
|
+
"runs path"
|
|
243
|
+
]);
|
|
244
|
+
var PROFILE_SET_COMMANDS = /* @__PURE__ */ new Set([
|
|
245
|
+
"mcp serve",
|
|
246
|
+
"mcp revoke",
|
|
247
|
+
"mcp server start",
|
|
248
|
+
"mcp server stop",
|
|
249
|
+
"mcp server status"
|
|
250
|
+
]);
|
|
251
|
+
var ANY_PROFILE_COMMANDS = /* @__PURE__ */ new Set([
|
|
252
|
+
"commands",
|
|
253
|
+
"commands info",
|
|
254
|
+
"complete",
|
|
255
|
+
"config show",
|
|
256
|
+
"session list",
|
|
257
|
+
"store info"
|
|
258
|
+
]);
|
|
259
|
+
var PROFILE_FREE_COMMANDS = /* @__PURE__ */ new Set([...ACCOUNT_FREE_COMMANDS, ...ANY_PROFILE_COMMANDS]);
|
|
260
|
+
var GOOGLE_READ = { remote: "read", local: "none" };
|
|
261
|
+
var GOOGLE_WRITE = { remote: "write", local: "none" };
|
|
262
|
+
var examples = /* @__PURE__ */ __name((command, lines) => annotate(command, { examples: lines }), "examples");
|
|
263
|
+
var CONTRACT = 4;
|
|
264
|
+
var isProfileFree = /* @__PURE__ */ __name((info) => PROFILE_FREE_COMMANDS.has(info.path.join(" ")) || info.commands.length > 0 && info.commands.every(isProfileFree), "isProfileFree");
|
|
265
|
+
var markProfileFree = /* @__PURE__ */ __name((program) => {
|
|
266
|
+
for (const info of flatten(describeProgram(program))) {
|
|
267
|
+
if (!isProfileFree(info))
|
|
268
|
+
continue;
|
|
269
|
+
let command = program;
|
|
270
|
+
for (const word of info.path)
|
|
271
|
+
command = command.commands.find((one) => one.name() === word) ?? command;
|
|
272
|
+
profileFree(command);
|
|
273
|
+
}
|
|
274
|
+
}, "markProfileFree");
|
|
275
|
+
var describeDriveProgram = /* @__PURE__ */ __name((program) => {
|
|
276
|
+
const scoped = /* @__PURE__ */ __name((info) => ({
|
|
277
|
+
...info,
|
|
278
|
+
usage: isProfileFree(info) ? info.usage : info.usage.replace(/^drive /, "drive <profile> "),
|
|
279
|
+
commands: info.commands.map(scoped)
|
|
280
|
+
}), "scoped");
|
|
281
|
+
return describeProgram(program).map(scoped);
|
|
282
|
+
}, "describeDriveProgram");
|
|
283
|
+
var commandsDocument2 = /* @__PURE__ */ __name((program, path = []) => {
|
|
284
|
+
const all = describeDriveProgram(program);
|
|
285
|
+
const inherited = [];
|
|
286
|
+
let available = all;
|
|
287
|
+
let found;
|
|
288
|
+
for (const word of path) {
|
|
289
|
+
if (found?.options.length)
|
|
290
|
+
inherited.push({ path: [...found.path], options: [...found.options] });
|
|
291
|
+
found = available.find((command) => command.name === word);
|
|
292
|
+
if (!found)
|
|
293
|
+
throw new CliError("not_found", "command path was not found");
|
|
294
|
+
available = [...found.commands];
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
...commandsDocument(program, { cli: "drive", version: VERSION, contract: CONTRACT }),
|
|
298
|
+
...found ? { scope: [...found.path], inherited_options: inherited } : {},
|
|
299
|
+
commands: found ? [found] : all
|
|
300
|
+
};
|
|
301
|
+
}, "commandsDocument");
|
|
302
|
+
|
|
303
|
+
// dist/policy.js
|
|
304
|
+
import { join as join2 } from "node:path";
|
|
305
|
+
var ORDER = { deny: 0, readonly: 1, ask: 2, allow: 3 };
|
|
306
|
+
var overridesOf = /* @__PURE__ */ __name((entries = []) => {
|
|
307
|
+
const levels = {};
|
|
308
|
+
for (const entry of entries) {
|
|
309
|
+
const [key = "", level = "", extra] = entry.split("=");
|
|
310
|
+
if (!/^[a-z][a-z-]*(\.[a-zA-Z][a-zA-Z-]*)*$/.test(key) || !LEVELS.includes(level) || extra)
|
|
311
|
+
throw new CliError("validation_error", "--permission takes a command path and level, e.g. files.trash=deny (deny, readonly, ask, allow)");
|
|
312
|
+
levels[key] = level;
|
|
313
|
+
}
|
|
314
|
+
return levels;
|
|
315
|
+
}, "overridesOf");
|
|
316
|
+
var permissionKeys = /* @__PURE__ */ __name((paths2) => {
|
|
317
|
+
const keys = /* @__PURE__ */ new Set([
|
|
318
|
+
"mcp.authority",
|
|
319
|
+
"mcp",
|
|
320
|
+
"sheets.create",
|
|
321
|
+
"sheets.rename",
|
|
322
|
+
"sheets.insert",
|
|
323
|
+
"sheets.format",
|
|
324
|
+
"sheets.update"
|
|
325
|
+
]);
|
|
326
|
+
for (const path of paths2)
|
|
327
|
+
keys.add(path.join("."));
|
|
328
|
+
for (const operation of operations)
|
|
329
|
+
for (const key of methodPolicyKeys(operation.id))
|
|
330
|
+
keys.add(key);
|
|
331
|
+
return keys;
|
|
332
|
+
}, "permissionKeys");
|
|
333
|
+
var permissionNames = /* @__PURE__ */ __name((keys) => {
|
|
334
|
+
const names = /* @__PURE__ */ new Set();
|
|
335
|
+
for (const key of keys) {
|
|
336
|
+
const parts = key.split(".");
|
|
337
|
+
for (let end = 1; end <= parts.length; end++)
|
|
338
|
+
names.add(parts.slice(0, end).join("."));
|
|
339
|
+
}
|
|
340
|
+
return names;
|
|
341
|
+
}, "permissionNames");
|
|
342
|
+
var policySettings = /* @__PURE__ */ __name((env, profile, flags = {}) => {
|
|
343
|
+
const keys = flags.permissionKeys;
|
|
344
|
+
const names = keys && permissionNames(keys);
|
|
345
|
+
const { config, issues } = inspectConfig(env, names);
|
|
346
|
+
const [first] = issues;
|
|
347
|
+
if (first)
|
|
348
|
+
throw first.kind === "unknown_permission" ? new CliError("configuration_error", refusal(issues).message, {
|
|
349
|
+
reason: "policy.unknown-key",
|
|
350
|
+
permission: first.key?.slice("permissions.".length)
|
|
351
|
+
}) : refusal(issues);
|
|
352
|
+
const own = config.profiles[profile];
|
|
353
|
+
const overrides = overridesOf(flags.permission);
|
|
354
|
+
if (names) {
|
|
355
|
+
for (const key of Object.keys(overrides))
|
|
356
|
+
if (!names.has(key))
|
|
357
|
+
throw new CliError("validation_error", `--permission names ${key}, which is no drive command; see drive commands`, {
|
|
358
|
+
reason: "policy.unknown-key",
|
|
359
|
+
permission: key
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
const saved = layerPermissions([
|
|
363
|
+
["profile", own?.permissions],
|
|
364
|
+
["defaults", config.defaults?.permissions]
|
|
365
|
+
]).levels;
|
|
366
|
+
for (const [key, level] of Object.entries(overrides)) {
|
|
367
|
+
const under = [...Object.keys(saved), ...Object.keys(defaults)].filter((named) => named.startsWith(`${key}.`));
|
|
368
|
+
const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(saved, named, defaults).level]);
|
|
369
|
+
if (lifted !== void 0)
|
|
370
|
+
throw new CliError("validation_error", `--permission ${key}=${level} would loosen ${lifted} from ${levelFor(saved, lifted, defaults).level}; it only tightens \u2014 change the profile's permissions to loosen it`, { reason: "policy.flag-loosens", permission: lifted });
|
|
371
|
+
}
|
|
372
|
+
const { levels } = layerPermissions([
|
|
373
|
+
["flags", overrides],
|
|
374
|
+
["profile", own?.permissions],
|
|
375
|
+
["defaults", config.defaults?.permissions]
|
|
376
|
+
]);
|
|
377
|
+
const lock = readOnlyLockOf(DRIVE_APP, env);
|
|
378
|
+
const ceiling = setupPermissionCeiling(env);
|
|
379
|
+
return {
|
|
380
|
+
levels: ceiling ? { ...levels, [CEILING_KEY]: ceiling } : levels,
|
|
381
|
+
lock,
|
|
382
|
+
readOnly: lock !== void 0 || ceiling === "readonly" || flags.readOnly === true
|
|
383
|
+
};
|
|
384
|
+
}, "policySettings");
|
|
385
|
+
var defaults = {
|
|
386
|
+
"mcp.authority": "deny",
|
|
387
|
+
...Object.fromEntries(operations.filter((op) => op.effect === "destructive").map((op) => [`api.${op.id}`, "ask"]))
|
|
388
|
+
};
|
|
389
|
+
var methodPolicyKeys = /* @__PURE__ */ __name((method, body) => {
|
|
390
|
+
const parts = method.split(".");
|
|
391
|
+
const verb = parts.at(-1);
|
|
392
|
+
const alias = method.startsWith("drive.files.") ? `files.${verb}` : method.startsWith("docs.documents.") ? `documents.${verb === "batchUpdate" ? "update" : verb}` : method.startsWith("sheets.spreadsheets.") ? `sheets.${method === "sheets.spreadsheets.get" ? "info" : method === "sheets.spreadsheets.values.get" ? "show" : verb === "append" ? "add" : verb}` : method === "driveactivity.activity.query" ? "documents.history" : method.startsWith("drive.") ? `${parts[1]}.${verb}` : void 0;
|
|
393
|
+
const keys = [`api.${method}`, ...alias ? [alias] : []];
|
|
394
|
+
if (method === "drive.replies.create" && body)
|
|
395
|
+
keys.push(body.action === "resolve" ? "comments.resolve" : body.action === "reopen" ? "comments.reopen" : "comments.reply");
|
|
396
|
+
if (method === "drive.replies.create" && body?.content !== void 0)
|
|
397
|
+
keys.push("comments.reply");
|
|
398
|
+
if (method === "sheets.spreadsheets.batchUpdate" && Array.isArray(body?.requests)) {
|
|
399
|
+
const object2 = /* @__PURE__ */ __name((value) => !!value && typeof value === "object" && !Array.isArray(value), "object");
|
|
400
|
+
for (const request of body.requests) {
|
|
401
|
+
if (!object2(request))
|
|
402
|
+
continue;
|
|
403
|
+
if (request.addSheet || request.duplicateSheet)
|
|
404
|
+
keys.push("sheets.create");
|
|
405
|
+
if (object2(request.updateSheetProperties)) {
|
|
406
|
+
const update = request.updateSheetProperties;
|
|
407
|
+
if (object2(update.properties) && update.properties.title !== void 0 || String(update.fields).split(",").some((field) => field.trim() === "title" || field.trim() === "*"))
|
|
408
|
+
keys.push("sheets.rename");
|
|
409
|
+
if (object2(update.properties) && update.properties.gridProperties)
|
|
410
|
+
keys.push("sheets.insert");
|
|
411
|
+
}
|
|
412
|
+
if (request.insertDimension || request.appendDimension || request.insertRange)
|
|
413
|
+
keys.push("sheets.insert");
|
|
414
|
+
if (request.repeatCell || request.updateCells || request.appendCells || request.updateBorders || request.addConditionalFormatRule || request.updateConditionalFormatRule || request.deleteConditionalFormatRule || request.addBanding || request.updateBanding || request.deleteBanding)
|
|
415
|
+
keys.push("sheets.format");
|
|
416
|
+
if (request.updateCells || request.appendCells || request.findReplace || request.pasteData || request.copyPaste || request.cutPaste || request.autoFill)
|
|
417
|
+
keys.push("sheets.update");
|
|
418
|
+
if (request.pasteData || request.copyPaste || request.cutPaste || request.autoFill)
|
|
419
|
+
keys.push("sheets.format");
|
|
420
|
+
if (object2(request.repeatCell) && (String(request.repeatCell.fields).split(",").some((field) => field.trim() === "*" || field.includes("userEnteredValue")) || object2(request.repeatCell.cell) && request.repeatCell.cell.userEnteredValue !== void 0))
|
|
421
|
+
keys.push("sheets.update");
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return [...new Set(keys)];
|
|
425
|
+
}, "methodPolicyKeys");
|
|
426
|
+
var refuseUnderReadOnly = /* @__PURE__ */ __name((env, what) => {
|
|
427
|
+
const lock = readOnlyLockOf(DRIVE_APP, env);
|
|
428
|
+
if (lock)
|
|
429
|
+
throw readOnlyRefusal(lock, what);
|
|
430
|
+
}, "refuseUnderReadOnly");
|
|
431
|
+
var checkPolicy = /* @__PURE__ */ __name(async (env, profile, key, mutates, flags = {}, ask) => {
|
|
432
|
+
const { levels, readOnly, lock } = policySettings(env, profile, flags);
|
|
433
|
+
const { level } = levelFor(levels, key, defaults);
|
|
434
|
+
if (mutates && lock)
|
|
435
|
+
throw readOnlyRefusal(lock, "change local or Google data");
|
|
436
|
+
if (level === "deny" || mutates && (readOnly || level === "readonly"))
|
|
437
|
+
throw new CliError("permission_error", "profile policy refuses this operation", {
|
|
438
|
+
reason: "policy.denied",
|
|
439
|
+
permission: key
|
|
440
|
+
});
|
|
441
|
+
if (mutates && level === "ask" && !flags.dryRun) {
|
|
442
|
+
const destructive = defaults[key] === "ask";
|
|
443
|
+
if (destructive ? flags.allowDangerous : flags.yes)
|
|
444
|
+
return;
|
|
445
|
+
if (ask && await ask(key))
|
|
446
|
+
return;
|
|
447
|
+
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 });
|
|
448
|
+
}
|
|
449
|
+
}, "checkPolicy");
|
|
450
|
+
var guardedGoogleWrite = /* @__PURE__ */ __name(async (env, profile, key, act, flags = {}, ask, operationId = newOperationId()) => {
|
|
451
|
+
const settings = policySettings(env, profile, flags);
|
|
452
|
+
const guard = sendGuard({
|
|
453
|
+
profile,
|
|
454
|
+
command: "drive",
|
|
455
|
+
readOnlyLock: settings.lock ?? (settings.readOnly ? "profile" : void 0),
|
|
456
|
+
permissions: settings.levels,
|
|
457
|
+
permissionDefaults: defaults,
|
|
458
|
+
ask: /* @__PURE__ */ __name(async (permission) => checkPolicy(env, profile, permission, true, flags, ask), "ask"),
|
|
459
|
+
sendsPerHour: Number.MAX_SAFE_INTEGER,
|
|
460
|
+
journal: new SendJournal(join2(paths(env).state, "sends", `${profile}.jsonl`), {
|
|
461
|
+
service: "drive",
|
|
462
|
+
version: VERSION
|
|
463
|
+
}),
|
|
464
|
+
recipients: new RecipientList(join2(paths(env).state, "recipients", `${profile}.json`), "drive"),
|
|
465
|
+
warn: /* @__PURE__ */ __name(() => {
|
|
466
|
+
}, "warn")
|
|
467
|
+
});
|
|
468
|
+
return guardedWrite(guard, { chatId: null, kind: "edit", key, operationId }, act);
|
|
469
|
+
}, "guardedGoogleWrite");
|
|
470
|
+
var discoveryAvailability = /* @__PURE__ */ __name((command, settings, authority = false, mcp = false) => {
|
|
471
|
+
if (mcp && authority && !["ask", "allow"].includes(levelFor(settings.levels, "mcp.authority").level))
|
|
472
|
+
return { available: false, reason: "the profile keeps mcp.authority off", permission: "mcp.authority" };
|
|
473
|
+
if (!mcp && command.path.join(" ") === "config set")
|
|
474
|
+
return settings.lock ? { available: false, reason: "the process is read-only" } : { available: true };
|
|
475
|
+
if (writes(command.effects) && settings.readOnly)
|
|
476
|
+
return { available: false, reason: "the profile is read-only" };
|
|
477
|
+
const keys = command.api_operation ? methodPolicyKeys(command.api_operation) : [command.path.join(".")];
|
|
478
|
+
const denied = keys.find((key) => {
|
|
479
|
+
const level = levelFor(settings.levels, key).level;
|
|
480
|
+
return level === "deny" || writes(command.effects) && level === "readonly";
|
|
481
|
+
});
|
|
482
|
+
return denied ? { available: false, reason: `the profile does not allow ${denied}`, permission: denied } : { available: true };
|
|
483
|
+
}, "discoveryAvailability");
|
|
484
|
+
|
|
485
|
+
export {
|
|
486
|
+
profileDir,
|
|
487
|
+
readState,
|
|
488
|
+
saveState,
|
|
489
|
+
readWalk,
|
|
490
|
+
saveWalk,
|
|
491
|
+
removeWalk,
|
|
492
|
+
ensureProfileDir,
|
|
493
|
+
saveSnapshot,
|
|
494
|
+
removeSnapshot,
|
|
495
|
+
readSnapshot,
|
|
496
|
+
profileSetTokenFile,
|
|
497
|
+
httpTokenFile,
|
|
498
|
+
ACCOUNT_FREE_COMMANDS,
|
|
499
|
+
PROFILE_SET_COMMANDS,
|
|
500
|
+
ANY_PROFILE_COMMANDS,
|
|
501
|
+
GOOGLE_READ,
|
|
502
|
+
GOOGLE_WRITE,
|
|
503
|
+
examples,
|
|
504
|
+
markProfileFree,
|
|
505
|
+
describeDriveProgram,
|
|
506
|
+
commandsDocument2 as commandsDocument,
|
|
507
|
+
permissionKeys,
|
|
508
|
+
permissionNames,
|
|
509
|
+
policySettings,
|
|
510
|
+
methodPolicyKeys,
|
|
511
|
+
refuseUnderReadOnly,
|
|
512
|
+
checkPolicy,
|
|
513
|
+
guardedGoogleWrite,
|
|
514
|
+
discoveryAvailability
|
|
515
|
+
};
|