just-bash-gdrive 0.1.0 → 0.1.2
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/README.md +51 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,22 @@ Lets AI agents interact with Google Drive files using standard bash commands (`l
|
|
|
6
6
|
|
|
7
7
|
Inspired by [just-bash-dropbox](https://github.com/manishrc/just-bash-dropbox) — the same pattern, applied to Google Drive.
|
|
8
8
|
|
|
9
|
+
## Why not just use the Drive API or gogcli?
|
|
10
|
+
|
|
11
|
+
Tools like [gogcli](https://github.com/steipete/gogcli) are great when *you* know exactly what you want to do with Drive. You write the specific command, it runs.
|
|
12
|
+
|
|
13
|
+
`just-bash-gdrive` is for when you want to hand an *agent* the ability to figure that out — and do it safely.
|
|
14
|
+
|
|
15
|
+
**Compositional bash logic at runtime.** An LLM can write arbitrary pipelines on the fly — `find / -name "*.md" | xargs grep "keyword" | sort` — without you anticipating every possible query in advance. No new API code per use case.
|
|
16
|
+
|
|
17
|
+
**Drive as a mountable filesystem.** `MountableFs` lets you compose Drive with other filesystems. An agent works across `/drive` (real files) and `/tmp` (scratch space) in the same bash session. The Drive API has no composability story.
|
|
18
|
+
|
|
19
|
+
**Safe exploration mode.** Mount Drive read-only — the agent can `cat`, `grep`, and `find` freely with zero write risk. There's no equivalent in any Drive CLI.
|
|
20
|
+
|
|
21
|
+
**AI SDK tool wrapper.** The `bash-tool` package from just-bash wraps the whole thing as a single LLM tool. One line to give any model bash access to Drive.
|
|
22
|
+
|
|
23
|
+
**The rule of thumb:** use gogcli when you're writing the script. Use just-bash-gdrive when the agent is writing the script.
|
|
24
|
+
|
|
9
25
|
## Install
|
|
10
26
|
|
|
11
27
|
```bash
|
|
@@ -76,7 +92,32 @@ const { text } = await generateText({
|
|
|
76
92
|
|
|
77
93
|
### Getting an access token
|
|
78
94
|
|
|
79
|
-
|
|
95
|
+
The `accessToken` option accepts either a static string or an async function — use the async form for long-running agents so the token refreshes automatically.
|
|
96
|
+
|
|
97
|
+
**Option 1: [gogcli](https://github.com/steipete/gogcli) (recommended for quick setup)**
|
|
98
|
+
|
|
99
|
+
gogcli handles Google OAuth2 authentication and stores tokens locally. After running `gog auth login`, you can retrieve tokens programmatically:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Install gogcli
|
|
103
|
+
npm install -g gogcli
|
|
104
|
+
|
|
105
|
+
# Authenticate (opens browser)
|
|
106
|
+
gog auth login
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { execSync } from "child_process";
|
|
111
|
+
|
|
112
|
+
const fs = new GDriveFs({
|
|
113
|
+
accessToken: () => {
|
|
114
|
+
// gogcli outputs a fresh token to stdout
|
|
115
|
+
return execSync("gog auth token", { encoding: "utf8" }).trim();
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Option 2: googleapis (full OAuth2 flow)**
|
|
80
121
|
|
|
81
122
|
```ts
|
|
82
123
|
import { google } from "googleapis";
|
|
@@ -92,6 +133,14 @@ const fs = new GDriveFs({
|
|
|
92
133
|
});
|
|
93
134
|
```
|
|
94
135
|
|
|
136
|
+
**Option 3: Static token (scripts and testing)**
|
|
137
|
+
|
|
138
|
+
For short-lived scripts, pass a token directly. Get one via `gog auth token` or the [OAuth2 Playground](https://developers.google.com/oauthplayground).
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const fs = new GDriveFs({ accessToken: "ya29.your_token_here" });
|
|
142
|
+
```
|
|
143
|
+
|
|
95
144
|
## Options
|
|
96
145
|
|
|
97
146
|
| Option | Type | Default | Description |
|
|
@@ -110,7 +159,7 @@ Rate limit handling: automatically retries on HTTP 429 with `Retry-After` backof
|
|
|
110
159
|
- `chmod`, `symlink`, `link`, `readlink`, `utimes` throw `ENOSYS` — Drive has no POSIX permission or symlink concept
|
|
111
160
|
- `getAllPaths()` returns `[]` until `prefetchAllPaths()` is called — glob operations require prefetch
|
|
112
161
|
- `appendFile` reads the existing file, appends, then rewrites — Drive has no atomic append
|
|
113
|
-
- Google Workspace files (Docs, Sheets, Slides) cannot be read as raw content; use `gog
|
|
162
|
+
- Google Workspace files (Docs, Sheets, Slides) cannot be read as raw content; use `gog export` (gogcli) or the Drive export API to convert them first
|
|
114
163
|
|
|
115
164
|
## Inspiration
|
|
116
165
|
|