agentic-drive 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +114 -2
- package/SKILL.md +25 -0
- package/dist/chunk-4QE7E5UQ.js +7 -0
- package/dist/chunk-QRGKXPLX.js +935 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +218 -0
- package/dist/drive-DRQ8LiHl.d.ts +144 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +38 -0
- package/dist/mcp.d.ts +12 -0
- package/dist/mcp.js +99 -0
- package/dist/worker.d.ts +36 -0
- package/dist/worker.js +230 -0
- package/llms.txt +14 -0
- package/package.json +73 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pooria Arab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# agentic-drive
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/agentic-drive)
|
|
4
|
+
[](https://opensource.org/license/mit)
|
|
5
|
+
|
|
6
|
+
[Package](https://www.npmjs.com/package/agentic-drive) · [Source](https://github.com/pooriaarab/agentic-drive) · [Support](https://github.com/pooriaarab/agentic-drive/issues)
|
|
7
|
+
|
|
8
|
+
Store, sort, and share files and folders.
|
|
9
|
+
|
|
10
|
+
> Status: early (0.1.0). The library, CLI, MCP server, and HTTP API work.
|
|
11
|
+
> Sharing and the web UI are not built yet.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install agentic-drive
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createDrive, createFileStore, createFileBlobs } from "agentic-drive";
|
|
23
|
+
|
|
24
|
+
const drive = createDrive({ store: createFileStore("./data/db"), blobs: createFileBlobs("./data/blobs") });
|
|
25
|
+
const me = { owner: "u1", actor: { id: "u1", kind: "human" as const } };
|
|
26
|
+
|
|
27
|
+
await drive.mkdir(me, "/reports/2026", { parents: true });
|
|
28
|
+
await drive.putFile(me, "/reports/2026/q1.txt", new TextEncoder().encode("hello"), { mime: "text/plain" });
|
|
29
|
+
await drive.putRef(me, "/reports/plan", "docs:abc123");
|
|
30
|
+
await drive.move(me, "/reports/plan", "/reports/2026");
|
|
31
|
+
await drive.trash(me, "/reports/2026");
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## CLI and MCP
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npx agentic-drive mkdir -p /reports
|
|
38
|
+
npx agentic-drive upload ./q1.pdf /reports/
|
|
39
|
+
npx agentic-drive search --name q1
|
|
40
|
+
npx agentic-drive export ./everything.zip
|
|
41
|
+
npx agentic-drive mcp
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Every command prints JSON. A failure prints `{"error":{"code","message"}}` on stderr and exits 1.
|
|
45
|
+
Set `--dir`, `--owner`, `--actor`, and `--actor-kind` (or the `AGENTIC_DRIVE_*` variables).
|
|
46
|
+
An agent sets `--actor-kind agent_of_human`. Each item then records that a machine made it.
|
|
47
|
+
|
|
48
|
+
## HTTP API
|
|
49
|
+
|
|
50
|
+
A Cloudflare Worker (Hono) serves `/api/v1/drive` and mirrors the CLI. It uses D1 and R2
|
|
51
|
+
through the shared adapters of `agentic-identity`.
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npx wrangler secret put DRIVE_API_TOKENS # {"<token of 32+ characters>":{"owner":"u1","actor":"u1","kind":"human"}}
|
|
55
|
+
npx wrangler secret put DRIVE_URL_SECRET # 32 bytes or more. It signs download URLs.
|
|
56
|
+
npx wrangler secret put DRIVE_PUBLIC_URL # The origin of the Worker, such as https://drive.example.com
|
|
57
|
+
npx wrangler deploy
|
|
58
|
+
curl -H "authorization: Bearer <token>" "$URL/api/v1/drive/items?path=/"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Routes: `GET /items`, `GET /stat`, `POST /folders`, `PUT /files`, `GET /files`, `GET /url`,
|
|
62
|
+
`POST /move`, `POST /trash`, `GET /trash`, `POST /restore`, `POST /purge`, `GET /search`,
|
|
63
|
+
`GET /export`, `DELETE /account?confirm=yes`. Without `DRIVE_API_TOKENS`, every request gets 401.
|
|
64
|
+
Without `DRIVE_URL_SECRET` or `DRIVE_PUBLIC_URL`, every request gets 503.
|
|
65
|
+
Create the R2 bucket with `--jurisdiction eu` and the D1 database with `--location weur`.
|
|
66
|
+
The Worker declares region `eu` and refuses a D1 query that a non-EU region served. `DRIVE_REGION=unknown` turns this off for local runs.
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
- Folders, files, and typed references to documents in other apps (`docs:<id>`).
|
|
71
|
+
- Paths that start with `/`. Anything else is an item id.
|
|
72
|
+
- Move, rename, trash, restore, and purge. Trashing a folder hides its whole tree.
|
|
73
|
+
- Names compare without regard to case or Unicode form. A clash fails, or renames, or replaces.
|
|
74
|
+
- Each item records its size, type, owner, and who made and last changed it, with the actor kind.
|
|
75
|
+
- Storage sits behind the `Store` and `Blobs` ports of `agentic-identity`. Tests use its memory adapters. The CLI uses a local file adapter that passes the same contract suites. The Worker uses its D1 and R2 adapters.
|
|
76
|
+
- Two live items never share a name in one folder. A claim document holds each name. It is written in the same transaction as the item, and it is deleted when the item goes to the trash.
|
|
77
|
+
- `upload()` reads a stream with a size cap, finds the type from the first bytes, and stores a SHA-256 hash.
|
|
78
|
+
- `downloadUrl()` returns a signed URL. The URL signs an attachment header with the file name and the stored type. The Worker verifies it and serves the bytes with those headers, so the link holder cannot change how the bytes are served. A link lasts 15 minutes by default and 1 hour at most. Trashing a file does not revoke a link already issued.
|
|
79
|
+
- `search()` finds live items by name, type, kind, size, and who made them.
|
|
80
|
+
- `buildExport()` writes everything one owner has to a zip with a `manifest.json`. Trashed items are flagged. Entries are named by item id. A file whose bytes are gone is marked `missing`.
|
|
81
|
+
- `deleteAll()` deletes all items and bytes of one owner for good. Only the owner can call it.
|
|
82
|
+
- A `can()` hook decides who may read, write, or delete. The default allows the owner only.
|
|
83
|
+
|
|
84
|
+
## Limits
|
|
85
|
+
|
|
86
|
+
- Drive reads the `store_docs` table in D1 and `store.jsonl` in the CLI folder. It does not read older layouts. There is no import and no claim backfill.
|
|
87
|
+
- Uploads buffer the stream in memory up to the cap. The default cap is 25 MiB.
|
|
88
|
+
- Local file blobs return a `file:` URL that nothing serves or checks.
|
|
89
|
+
- Drive writes each new blob only when its key is free (`ifNoneMatch`). A write that finds the key taken fails with `BLOB_EXISTS`.
|
|
90
|
+
- Only `upload()` enforces the size cap. A caller of `putFile()` must check size first.
|
|
91
|
+
- A claimed type that a browser would run (HTML, SVG, scripts) is stored as `application/octet-stream`.
|
|
92
|
+
- The file adapters allow one process at a time.
|
|
93
|
+
- The MCP `drive_export` tool writes a new `.zip` into `<dir>/exports` and never overwrites a file. It takes a plain file name, not a path.
|
|
94
|
+
- A purge or an erase works in chunks of 25 items, and each chunk commits. A Worker call has a cap on database queries, so a very large tree can need several calls. A failed or cut-off call leaves marked items hidden, and the same call finishes the job.
|
|
95
|
+
- Hard delete removes blobs first and then rows. If a blob delete fails, the call throws and the same call can run again.
|
|
96
|
+
- The export holds every file in memory. A very large drive needs a streaming export, which is not built yet.
|
|
97
|
+
- The zip export stores entries without compression and has no Zip64 support.
|
|
98
|
+
- No access log for personal data yet. That comes with agentic-identity.
|
|
99
|
+
- The D1 store checks every document a transaction read. If another Worker changed one, the transaction runs again, and after 50 tries it fails with a `BUSY` error.
|
|
100
|
+
- The D1 store keeps one generic table. A busy deployment needs an expression index on `owner` and `parentId`.
|
|
101
|
+
- `region: "eu"` on the D1 and R2 adapters is a promise made at deploy time. The D1 adapter refuses a query that a non-EU region served. The code cannot check where the bucket lives.
|
|
102
|
+
- Every API token is at least 32 characters. Its grant names an owner, an actor id, and an actor kind. A grant with a missing part gets 401.
|
|
103
|
+
- Tokens in `DRIVE_API_TOKENS` are a stopgap for sign-in. OIDC comes with agentic-identity.
|
|
104
|
+
- No sharing or roles yet. Roles come from agentic-identity.
|
|
105
|
+
|
|
106
|
+
## Develop
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
npm ci
|
|
110
|
+
npm run ci:local
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentic-drive
|
|
3
|
+
description: Store, sort, and share files and folders. Keywords: drive,files,folders,storage,upload,sharing,agents,mcp,cli,r2.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# agentic-drive
|
|
7
|
+
|
|
8
|
+
Store, sort, and share files and folders.
|
|
9
|
+
|
|
10
|
+
## Use the SDK
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { createDrive } from "agentic-drive";
|
|
14
|
+
import { createMemoryStore, createMemoryBlobs } from "agentic-identity";
|
|
15
|
+
|
|
16
|
+
const drive = createDrive({ store: createMemoryStore(), blobs: createMemoryBlobs() });
|
|
17
|
+
const me = { owner: "u1", actor: { id: "u1", kind: "human" } };
|
|
18
|
+
await drive.mkdir(me, "/notes");
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
- A path starts with `/`. Any other locator is an id.
|
|
24
|
+
- Trash before purge.
|
|
25
|
+
- Report a `DriveError` as a failure.
|