@dennisonbertram/agent-drive 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,11 +1,18 @@
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
 
11
18
  Documentation: https://agentdrive.xyz/docs
package/dist/SKILL.md CHANGED
@@ -33,6 +33,11 @@ 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
 
@@ -83,9 +88,12 @@ All take `--drive ID` unless noted. With one drive key saved for the current API
83
88
  - `versions PATH`, `restore PATH [--version ID]`, `mv`, `cp`, `rm`
84
89
  - `share PATH [--expires-in 24h]`, `share list`, `share revoke SHARE_ID`
85
90
  - 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]`
91
+ - `backup LOCAL_DIRECTORY [--prefix P] [--exclude GLOB]... [--gitignore] [--dry-run] [--yes]` —
92
+ scans first; `--gitignore` skips `.gitignore`d paths (off by default); `--exclude` matches the root-relative
93
+ path (`**/node_modules`, `build/**`); over 5000 files or 1 GiB it needs `--yes`; one run per prefix
94
+ at a time; progress prints to stderr
87
95
  - `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`
96
+ - `whoami`, `check`, `credentials ...`, `account seal`, `skill install`
89
97
  - `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
98
 
91
99
  `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>;