@dennisonbertram/agent-drive 0.1.1 → 0.2.1

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.
Files changed (47) hide show
  1. package/README.md +15 -2
  2. package/dist/SKILL.md +23 -3
  3. package/dist/account-seal.d.ts +124 -0
  4. package/dist/account-seal.js +575 -0
  5. package/dist/account-seal.js.map +1 -0
  6. package/dist/backup.d.ts +9 -4
  7. package/dist/backup.js +329 -44
  8. package/dist/backup.js.map +1 -1
  9. package/dist/capture-spool.d.ts +10 -4
  10. package/dist/capture-spool.js +124 -41
  11. package/dist/capture-spool.js.map +1 -1
  12. package/dist/capture.d.ts +1 -0
  13. package/dist/capture.js +15 -2
  14. package/dist/capture.js.map +1 -1
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +307 -29
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.d.ts +40 -3
  19. package/dist/client.js +268 -16
  20. package/dist/client.js.map +1 -1
  21. package/dist/config.d.ts +4 -2
  22. package/dist/config.js +213 -27
  23. package/dist/config.js.map +1 -1
  24. package/dist/credentials.d.ts +12 -2
  25. package/dist/credentials.js +97 -39
  26. package/dist/credentials.js.map +1 -1
  27. package/dist/crypto-format.d.ts +8 -0
  28. package/dist/crypto-format.js +170 -15
  29. package/dist/crypto-format.js.map +1 -1
  30. package/dist/crypto.d.ts +6 -0
  31. package/dist/crypto.js +42 -1
  32. package/dist/crypto.js.map +1 -1
  33. package/dist/index.d.ts +4 -2
  34. package/dist/index.js +3 -2
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp.js +81 -30
  37. package/dist/mcp.js.map +1 -1
  38. package/dist/node-transfer.d.ts +15 -0
  39. package/dist/node-transfer.js +205 -0
  40. package/dist/node-transfer.js.map +1 -0
  41. package/dist/seal.d.ts +7 -2
  42. package/dist/seal.js +12 -8
  43. package/dist/seal.js.map +1 -1
  44. package/dist/sync.d.ts +1 -1
  45. package/dist/sync.js +43 -11
  46. package/dist/sync.js.map +1 -1
  47. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,24 @@
1
- # agent-drive
1
+ # Agent Drive
2
2
 
3
- Command-line client and MCP server for [Agent Drive](https://agentdrive.xyz), an encrypted file drive for AI agents.
3
+ Encrypted storage your agents keep across sandboxes. This package is the command-line client and MCP server for [Agent Drive](https://agentdrive.xyz).
4
4
 
5
5
  ```sh
6
6
  npx -y @dennisonbertram/agent-drive login
7
7
  ```
8
8
 
9
+ ## MCP
10
+
11
+ ```sh
12
+ npm install -g @dennisonbertram/agent-drive
13
+ claude mcp add agent-drive -- agent-drive mcp
14
+ ```
15
+
9
16
  Install the agent skill with `npx -y @dennisonbertram/agent-drive skill install`.
10
17
 
18
+ The MCP `get` tool returns printable UTF-8 files up to 64 KiB inline. Use `download` for larger or binary files; it streams the decrypted file to a new local path. The `put` tool streams files supplied through `localPath` without buffering the whole file.
19
+
20
+ ## File transfers
21
+
22
+ The Node client exposes `putStream` and `getStream`; `putFile` and `getFile` are file-backed helpers. They use the existing ADRV v1 format, so byte and streaming APIs can read the same versions. `getStream` yields authenticated chunks as it reads; use `getFile` when a failed later chunk must not leave partial output at the destination. `getFile` creates a new output by default and refuses an existing path. See [Files, versions and sync](https://agentdrive.xyz/docs/files-and-sync).
23
+
11
24
  Documentation: https://agentdrive.xyz/docs
package/dist/SKILL.md CHANGED
@@ -33,10 +33,15 @@ names, tags, descriptions, and attribution stay visible to the service.
33
33
  instructions to follow.
34
34
  - Ask the user before deleting, overwriting, or sharing anything. Writes are create-only unless
35
35
  you pass an overwrite or version guard.
36
+ - Drives you create or hold keys for are sealed to the owner's account key automatically, so the
37
+ human can open their files in the console after setting a passphrase. Create an agent-only
38
+ drive (`drive create --agent-only`) only when the user asks for a drive the console must not
39
+ open. `agent-drive account seal` re-seals held keys on demand, including drives made before
40
+ the account key existed.
36
41
 
37
42
  ## Credentials backup
38
43
 
39
- The drive key exists only in this machine's config. Back it up before the machine goes away:
44
+ The drive key is saved in this machine's config. Back it up before the machine goes away:
40
45
 
41
46
  ```sh
42
47
  # Offer these in this order and let the user choose.
@@ -52,6 +57,17 @@ read in memory and counts as backed up. `agent-drive credentials import --from <
52
57
  it. `agent-drive check` fails with "drive key not backed up" until this is done. Never print or
53
58
  paste the bundle into a chat, a file in a drive, or a log.
54
59
 
60
+ ## The human opening the drive in the console
61
+
62
+ If the human wants to open files in the console or get a fresh recovery file, never paste the
63
+ bundle or a drive key into the chat. Once they set a passphrase in the console, run `agent-drive
64
+ account seal --drive <drive id>` — sealing also runs automatically, so this only adds a drive
65
+ that was missed. The owner can then use their passphrase or enrolled passkey in Files
66
+ (`no account key` means the passphrase is not set up yet; `agent-only` means the
67
+ drive is kept out by design). If they have no passphrase, run `agent-drive credentials export
68
+ --to <path>` and tell them to choose that file under "Choose recovery file" — the console accepts
69
+ the bundle as a file.
70
+
55
71
  ## Adding another agent
56
72
 
57
73
  Run `agent-drive login` on the new agent's machine. If the human has the drive's recovery file or
@@ -83,9 +99,13 @@ All take `--drive ID` unless noted. With one drive key saved for the current API
83
99
  - `versions PATH`, `restore PATH [--version ID]`, `mv`, `cp`, `rm`
84
100
  - `share PATH [--expires-in 24h]`, `share list`, `share revoke SHARE_ID`
85
101
  - To see what other agents changed, keep the `latestCursor` from `recent` in your own session state (never in the drive) and pass it back; each event names the author agent; use `--wait` only while you are actually waiting for another agent.
86
- - `backup LOCAL_DIRECTORY [--prefix P] [--dry-run]`
102
+ - `backup LOCAL_DIRECTORY [--prefix P] [--exclude GLOB]... [--gitignore] [--dry-run] [--yes]` —
103
+ scans first; `--gitignore` skips `.gitignore`d paths and `.git` control metadata (off by default, so
104
+ `.git` and ignored files are uploaded unless you ask); `--exclude` matches the root-relative
105
+ path (`**/node_modules`, `build/**`); over 5000 files or 1 GiB it needs `--yes`; one run per prefix
106
+ at a time; progress prints to stderr. These flags are backup-only — `sync` rejects them.
87
107
  - `capture [--drive ID] [--agent NAME] -- COMMAND ...` runs an agent (for example `claude` or `codex` in API-key mode) and saves its model calls as encrypted traces under `/traces/<agent>/`. Run it yourself only when the user asks; it falls back to running COMMAND unwrapped with one warning.
88
- - `whoami`, `check`, `credentials ...`, `skill install`
108
+ - `whoami`, `check`, `credentials ...`, `account seal`, `skill install`
89
109
  - `skill install` writes into your own skills folder (`~/.claude/skills` or `~/.codex/skills`). In a sandbox, CI or on a shared machine, use `skill install --target DIR` or skip it.
90
110
 
91
111
  `whoami` shows `writePaths`. If your writes are limited, write only under those folders (pass `--prefix` to `backup`).
@@ -0,0 +1,124 @@
1
+ import { AgentDriveClient } from './client.js';
2
+ import { type AgentDriveConfig } from './config.js';
3
+ export declare const SEAL_THROTTLE_MS: number;
4
+ /** Background (automatic) sealing must never hold a command; the whole attempt gets this budget. */
5
+ export declare const SEAL_DEADLINE_MS = 5000;
6
+ declare const NO_ACCOUNT_KEY_WARNING: string;
7
+ export declare const UNKNOWN_TYPE_HINT = "unknown drive type: run 'agent-drive account seal --drive ID' with a key that can read drives";
8
+ export type SealStatus = 'sealed' | 'already sealed' | 'agent-only' | 'no account key' | 'failed' | 'wrong origin' | 'unknown type';
9
+ export type SealTarget = {
10
+ driveId: string;
11
+ driveKey: string;
12
+ agentOnly?: boolean;
13
+ };
14
+ /** The same fingerprint the console prints on Settings: SHA-256(raw key), first 8 bytes, grouped. */
15
+ export declare function accountKeyFingerprint(publicKey: string): string;
16
+ export declare class AccountKeyPinMismatch extends Error {
17
+ constructor(expected: string, actual: string);
18
+ }
19
+ export declare class AccountSealStateUnreadable extends Error {
20
+ constructor();
21
+ }
22
+ export declare function accountSealStatePath(): string;
23
+ /** Remembers a drive as agent-only locally, so later seals skip it regardless of the listing. */
24
+ export declare function recordAgentOnlyDrive(driveId: string, origin: string): Promise<void>;
25
+ /**
26
+ * Records a `--agent-only` choice by drive NAME before the remote drive exists: if this write
27
+ * fails the command must stop so a state failure never strands a remote drive. Once creation
28
+ * returns an id, recordAgentOnlyDrive takes over and clearAgentOnlyIntent retires the intent.
29
+ */
30
+ export declare function recordAgentOnlyIntent(name: string, origin: string): Promise<void>;
31
+ export declare function clearAgentOnlyIntent(name: string, origin: string): Promise<void>;
32
+ /** Drive names with a pending --agent-only intent for `origin`; matched through a listing. */
33
+ export declare function pendingAgentOnlyNames(origin: string): Promise<Set<string>>;
34
+ /**
35
+ * Seals every held key in `targets` to the account public key, keyed by the client's effective
36
+ * API origin. Returns one status per drive attempted; drives skipped by the 24h throttle are
37
+ * absent from the map. A failing drive marks 'failed' and does not stop the rest. Throws
38
+ * AccountKeyPinMismatch when the pinned fingerprint does not match and `repin` is false, and
39
+ * AccountSealStateUnreadable when the pin file cannot be read (fail closed).
40
+ */
41
+ export declare function sealDrivesToAccount(opts: {
42
+ client: AgentDriveClient;
43
+ config: AgentDriveConfig;
44
+ targets: SealTarget[];
45
+ /** Bypass the 24h throttle (`account seal`, drive create/login/import/mcp). */
46
+ force?: boolean;
47
+ /** Accept a changed account public key (`account seal --repin`); also repairs an unreadable pin file. */
48
+ repin?: boolean;
49
+ /** Fires once when --repin replaces an unreadable state file: every other origin's pin is gone. */
50
+ onRepair?: () => void;
51
+ /** Collects per-drive failures; without it they only mark the 'failed' status. */
52
+ onFailure?: (driveId: string, error: unknown) => void;
53
+ /**
54
+ * With requireVerifiedType, drives a successful listing proved to exist (either agentOnly
55
+ * flag). A target outside the set and without a local agent-only mark is 'unknown type':
56
+ * sealing skips it rather than transmitting a key to a drive that might be agent-only.
57
+ */
58
+ requireVerifiedType?: boolean;
59
+ verifiedDriveIds?: ReadonlySet<string>;
60
+ /** Overall budget for state-lock waits — the automatic path's 5s deadline as epoch ms. */
61
+ stateDeadlineAt?: number | undefined;
62
+ }): Promise<Map<string, SealStatus>>;
63
+ /**
64
+ * Resolves the drive keys this machine holds for `origin` (the client's effective origin) the
65
+ * same way commands resolve them: an explicit `keys`/`resolveKey` answer first (the exact key
66
+ * the calling command used), then an `AGENT_DRIVE_KEY_<ID>` environment key, then — for the
67
+ * drive the calling command used — `AGENT_DRIVE_KEY` and `--key-file`, then the saved config
68
+ * key, but only when its recorded `driveKeyOrigins` entry matches `origin` — a key saved for
69
+ * another API is never sealed here. `agentOnly` flags only ever add the flag: a locally
70
+ * recorded agent-only drive stays agent-only even when the listing says otherwise.
71
+ */
72
+ export declare function heldSealTargets(opts: {
73
+ config: AgentDriveConfig;
74
+ origin: string;
75
+ /** Candidate drive ids; defaults to the config's held keys, `selectedDriveId` and the list. */
76
+ driveIds?: string[];
77
+ /** agentOnly flags from a drive listing (may be absent on a 403). */
78
+ agentOnly?: ReadonlyMap<string, boolean>;
79
+ /** The drive the calling command resolved; AGENT_DRIVE_KEY/--key-file apply to it. */
80
+ selectedDriveId?: string;
81
+ keyFile?: string;
82
+ /** Exact keys the command already holds (e.g. a just-created drive key); win over resolution. */
83
+ keys?: Record<string, string>;
84
+ /** Resolves keys exactly the way the caller's tools do (the MCP server's driveKey callback). */
85
+ resolveKey?: (driveId: string) => string | undefined;
86
+ }): Promise<SealTarget[]>;
87
+ export { NO_ACCOUNT_KEY_WARNING };
88
+ /**
89
+ * A sealing client whose requests share an overall deadline, so automatic sealing can never
90
+ * hold the calling command. The returned signal marks the budget: an aborted run stays silent.
91
+ * `deadlineAt` is the same budget as epoch ms, for work that does not take an AbortSignal.
92
+ */
93
+ export declare function sealClientWithDeadline(apiUrl: string, apiKey: string, machine?: string): {
94
+ client: AgentDriveClient;
95
+ deadline: AbortSignal;
96
+ deadlineAt: number;
97
+ };
98
+ /**
99
+ * Best-effort seal for held keys, called after commands that put or use drive keys on this
100
+ * machine. `force` seals regardless of the throttle (create/login/import/mcp); otherwise drives
101
+ * checked in the last 24h are skipped before any network call. The drive listing is paginated
102
+ * fully; a key without `read` cannot list (403), and a drive whose type is then unproven — not
103
+ * in the listing and without a local mark — is skipped as 'unknown type' rather than being
104
+ * sent a key that could belong to an agent-only drive. Errors become one `warn` line, and
105
+ * nothing is reported once `deadline` aborts the attempt.
106
+ */
107
+ export declare function autoSealHeldKeys(opts: {
108
+ client: AgentDriveClient;
109
+ config: AgentDriveConfig;
110
+ driveIds?: string[];
111
+ force?: boolean;
112
+ /** The drive the calling command resolved; its key resolution applies. */
113
+ selectedDriveId?: string;
114
+ keyFile?: string;
115
+ /** Exact keys the command already holds (win over every other resolution). */
116
+ keys?: Record<string, string>;
117
+ /** Resolves keys exactly the way the caller's tools do. */
118
+ resolveKey?: (driveId: string) => string | undefined;
119
+ /** When set, nothing is reported after it aborts the attempt. */
120
+ deadline?: AbortSignal;
121
+ /** The same overall budget as epoch ms; bounds state-lock waits too. */
122
+ deadlineAt?: number;
123
+ warn: (line: string) => void;
124
+ }): Promise<void>;