phantomdisk 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 +77 -2
- package/dist/index.js +865 -0
- package/dist/types/sdk/src/index.d.ts +122 -0
- package/dist/types/shared/src/bytes.d.ts +16 -0
- package/dist/types/shared/src/crypto.d.ts +143 -0
- package/dist/types/shared/src/format.d.ts +35 -0
- package/dist/types/shared/src/index.d.ts +6 -0
- package/dist/types/shared/src/manifest.d.ts +22 -0
- package/dist/types/shared/src/md5.d.ts +1 -0
- package/dist/types/shared/src/transfer.d.ts +99 -0
- package/package.json +15 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PhantomDisk
|
|
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,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# phantomdisk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A PhantomDisk drive for programs and AI agents. One import and one access key: no mount, no helper program, no
|
|
4
|
+
special container permissions. It runs wherever `fetch` and Web Crypto do (Node 20+, Deno, Bun, Workers), so it works
|
|
5
|
+
inside a locked-down sandbox where a drive cannot be mounted.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install phantomdisk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
One file, no dependencies. The full reference is at https://phantomdisk.com/docs/sdk.
|
|
12
|
+
|
|
13
|
+
## Use it
|
|
14
|
+
|
|
15
|
+
Make a key on the web app's **Access keys** page (or `phantomdisk keys create --label agent --access write`), limited to
|
|
16
|
+
the one drive the agent should see. Put it in the environment, never in code:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
export PHANTOMDISK_KEY=pdk_...
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { PhantomDisk } from "phantomdisk";
|
|
24
|
+
|
|
25
|
+
const drive = await PhantomDisk.open(); // PHANTOMDISK_KEY
|
|
26
|
+
|
|
27
|
+
await drive.write("notes/plan.md", "first draft"); // folders are made as needed
|
|
28
|
+
const text = await drive.readText("notes/plan.md");
|
|
29
|
+
const files = await drive.list("notes"); // [{ path, name, kind, size, modified, … }]
|
|
30
|
+
|
|
31
|
+
// A part of a big file: only the blocks that hold it are fetched.
|
|
32
|
+
const head = await drive.read("footage/take-3.mov", { offset: 0, length: 64 * 1024 });
|
|
33
|
+
|
|
34
|
+
await drive.move("notes/plan.md", "archive/plan-v1.md"); // rename and move in one call
|
|
35
|
+
await drive.remove("archive"); // to Recently Deleted, undoable for 30 days
|
|
36
|
+
|
|
37
|
+
const versions = await drive.history("report.pdf"); // every save is kept for 30 days
|
|
38
|
+
await drive.restore("report.pdf", versions[1].id); // go back; nothing is copied
|
|
39
|
+
|
|
40
|
+
const fork = await drive.fork("experiment"); // a whole drive to try things in; no data is copied
|
|
41
|
+
await fork.write("notes/plan.md", "a risky rewrite"); // the original does not change
|
|
42
|
+
await drive.copy("footage", "footage backup"); // a file or folder, also without copying data
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`PhantomDisk.open({ key, drive, apiUrl })` overrides the environment. Errors are `PhantomDiskError` with the API's
|
|
46
|
+
`code` (`NOT_FOUND`, `KEY_READ_ONLY`, `QUOTA_EXCEEDED`, `READ_ONLY`, …) and a sentence fit to show.
|
|
47
|
+
|
|
48
|
+
## What it guarantees
|
|
49
|
+
|
|
50
|
+
- **Bytes never pass through our servers.** Reads and writes go straight to storage through presigned URLs.
|
|
51
|
+
- **Encryption stays on.** For an encrypted account the key is `pdk_….<key>`: the part after the dot is the account's
|
|
52
|
+
master key. It is never sent anywhere; names and content are sealed and opened in your process. Treat that key like
|
|
53
|
+
a password, and prefer a key limited to one drive.
|
|
54
|
+
- **Uploads are verified.** Every piece is checked against its hash before the version counts, and a write to an
|
|
55
|
+
existing file makes a new version: the old one stays in `history` for 30 days.
|
|
56
|
+
- **A key cannot delete for good.** `remove` moves to Recently Deleted; a read key cannot write at all.
|
|
57
|
+
|
|
58
|
+
## The other two ways in
|
|
59
|
+
|
|
60
|
+
| | When |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| [`phantomdisk`](https://phantomdisk.com/docs/cli) (command line) | Shell scripts and agents that work through a terminal: `phantomdisk ls`, `get`, `put`, `mv`, `rm`, `history`, `restore`, `rollback`, each with `--json`. |
|
|
63
|
+
| [`phantomdisk mcp`](https://phantomdisk.com/docs/mcp) | An MCP client (Claude Code, Claude Desktop, Cursor): the drive as tools, with no code to write. |
|
|
64
|
+
| [`phantomdisk-mount`](https://phantomdisk.com/docs/mount) (Linux, FUSE 3) | Programs that need real file paths. Needs `/dev/fuse` and `SYS_ADMIN` in a container; this SDK does not. |
|
|
65
|
+
|
|
66
|
+
## Limits today
|
|
67
|
+
|
|
68
|
+
- `fork` needs a key for every drive (a key limited to some drives cannot make one), sends about one request per 100
|
|
69
|
+
files, and a fork counts against the plan like any other files.
|
|
70
|
+
- One drive per `PhantomDisk` (`open({ drive })` picks it; a key limited to some drives opens its first).
|
|
71
|
+
- `write` takes the whole content (a string, bytes or a `Blob`); a file is sent as a new version, not patched in place.
|
|
72
|
+
- A partial `read` of an unencrypted file is not checked against the piece hash (a whole read is; an encrypted block
|
|
73
|
+
always proves itself).
|
|
74
|
+
- No search here: search inside files runs on the Mac (`phantomdisk search`, the MCP server on that Mac).
|
|
75
|
+
|
|
76
|
+
## Licence
|
|
77
|
+
|
|
78
|
+
MIT. It covers this package; the PhantomDisk service has its own [terms](https://phantomdisk.com/terms).
|