@singularity-layer/agentvault 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 +58 -0
- package/dist/client.d.ts +38 -0
- package/dist/client.js +68 -0
- package/dist/commands/backup.d.ts +25 -0
- package/dist/commands/backup.js +48 -0
- package/dist/commands/daemon.d.ts +37 -0
- package/dist/commands/daemon.js +95 -0
- package/dist/commands/list.d.ts +8 -0
- package/dist/commands/list.js +12 -0
- package/dist/commands/login.d.ts +32 -0
- package/dist/commands/login.js +43 -0
- package/dist/commands/logout.d.ts +8 -0
- package/dist/commands/logout.js +5 -0
- package/dist/commands/passphrase.d.ts +17 -0
- package/dist/commands/passphrase.js +20 -0
- package/dist/commands/restore.d.ts +15 -0
- package/dist/commands/restore.js +20 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +46 -0
- package/dist/daemon/descriptors.d.ts +15 -0
- package/dist/daemon/descriptors.js +52 -0
- package/dist/deps.d.ts +39 -0
- package/dist/deps.js +104 -0
- package/dist/deviceAuth.d.ts +23 -0
- package/dist/deviceAuth.js +42 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +164 -0
- package/dist/io.d.ts +32 -0
- package/dist/io.js +76 -0
- package/dist/keychain.d.ts +20 -0
- package/dist/keychain.js +135 -0
- package/dist/r2key.d.ts +6 -0
- package/dist/r2key.js +16 -0
- package/package.json +53 -0
package/dist/keychain.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
const SERVICE = "agentvault";
|
|
3
|
+
/** Build the OS keychain CLI invocation for an operation. Pure + testable. */
|
|
4
|
+
export function buildKeychainCommand(platform, op, account, service) {
|
|
5
|
+
if (platform === "darwin") {
|
|
6
|
+
if (op === "set") {
|
|
7
|
+
// `-w` with NO value makes `security` read the password from stdin
|
|
8
|
+
// (it prompts twice, so the secret is written twice). Passing it as an
|
|
9
|
+
// argv element would expose it to process inspection during storage.
|
|
10
|
+
return {
|
|
11
|
+
cmd: "security",
|
|
12
|
+
args: [
|
|
13
|
+
"add-generic-password",
|
|
14
|
+
"-U",
|
|
15
|
+
"-a",
|
|
16
|
+
account,
|
|
17
|
+
"-s",
|
|
18
|
+
service,
|
|
19
|
+
"-w",
|
|
20
|
+
],
|
|
21
|
+
secretViaStdin: true,
|
|
22
|
+
secretAsLastArg: false,
|
|
23
|
+
secretStdinRepeat: 2,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (op === "get") {
|
|
27
|
+
return {
|
|
28
|
+
cmd: "security",
|
|
29
|
+
args: ["find-generic-password", "-a", account, "-s", service, "-w"],
|
|
30
|
+
secretViaStdin: false,
|
|
31
|
+
secretAsLastArg: false,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
cmd: "security",
|
|
36
|
+
args: ["delete-generic-password", "-a", account, "-s", service],
|
|
37
|
+
secretViaStdin: false,
|
|
38
|
+
secretAsLastArg: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (platform === "linux") {
|
|
42
|
+
if (op === "set") {
|
|
43
|
+
return {
|
|
44
|
+
cmd: "secret-tool",
|
|
45
|
+
args: [
|
|
46
|
+
"store",
|
|
47
|
+
`--label=${service}`,
|
|
48
|
+
"account",
|
|
49
|
+
account,
|
|
50
|
+
"service",
|
|
51
|
+
service,
|
|
52
|
+
],
|
|
53
|
+
secretViaStdin: true,
|
|
54
|
+
secretAsLastArg: false,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (op === "get") {
|
|
58
|
+
return {
|
|
59
|
+
cmd: "secret-tool",
|
|
60
|
+
args: ["lookup", "account", account, "service", service],
|
|
61
|
+
secretViaStdin: false,
|
|
62
|
+
secretAsLastArg: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
cmd: "secret-tool",
|
|
67
|
+
args: ["clear", "account", account, "service", service],
|
|
68
|
+
secretViaStdin: false,
|
|
69
|
+
secretAsLastArg: false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`unsupported platform for keychain: ${platform}`);
|
|
73
|
+
}
|
|
74
|
+
function run(cmd, args, stdin) {
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
const child = execFile(cmd, args, (err, stdout) => {
|
|
77
|
+
resolve({
|
|
78
|
+
code: err && typeof err.code === "number"
|
|
79
|
+
? err.code
|
|
80
|
+
: err
|
|
81
|
+
? 1
|
|
82
|
+
: 0,
|
|
83
|
+
stdout: stdout ?? "",
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
if (stdin !== undefined) {
|
|
87
|
+
child.stdin?.write(stdin);
|
|
88
|
+
child.stdin?.end();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Real OS keychain backed by `security` (macOS) / `secret-tool` (Linux). */
|
|
93
|
+
export function createKeychain(platform = process.platform) {
|
|
94
|
+
return {
|
|
95
|
+
async get(account) {
|
|
96
|
+
const c = buildKeychainCommand(platform, "get", account, SERVICE);
|
|
97
|
+
const { code, stdout } = await run(c.cmd, c.args);
|
|
98
|
+
if (code !== 0)
|
|
99
|
+
return null;
|
|
100
|
+
return stdout.replace(/\n$/, "");
|
|
101
|
+
},
|
|
102
|
+
async set(account, secret) {
|
|
103
|
+
const c = buildKeychainCommand(platform, "set", account, SERVICE);
|
|
104
|
+
const args = c.secretAsLastArg ? [...c.args, secret] : c.args;
|
|
105
|
+
const stdin = c.secretViaStdin
|
|
106
|
+
? c.secretStdinRepeat
|
|
107
|
+
? `${secret}\n`.repeat(c.secretStdinRepeat)
|
|
108
|
+
: secret
|
|
109
|
+
: undefined;
|
|
110
|
+
const { code } = await run(c.cmd, args, stdin);
|
|
111
|
+
if (code !== 0)
|
|
112
|
+
throw new Error("failed to store secret in keychain");
|
|
113
|
+
},
|
|
114
|
+
async delete(account) {
|
|
115
|
+
const c = buildKeychainCommand(platform, "delete", account, SERVICE);
|
|
116
|
+
await run(c.cmd, c.args);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** In-memory keychain for tests. */
|
|
121
|
+
export function createFakeKeychain() {
|
|
122
|
+
const store = new Map();
|
|
123
|
+
return {
|
|
124
|
+
async get(account) {
|
|
125
|
+
return store.has(account) ? store.get(account) : null;
|
|
126
|
+
},
|
|
127
|
+
async set(account, secret) {
|
|
128
|
+
store.set(account, secret);
|
|
129
|
+
},
|
|
130
|
+
async delete(account) {
|
|
131
|
+
store.delete(account);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export const PASSPHRASE_ACCOUNT = "agentvault-passphrase";
|
package/dist/r2key.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Aad } from "@singularity-layer/agentvault-core";
|
|
2
|
+
/**
|
|
3
|
+
* Parse an R2 object key of the form `backups/{userId}/{agentId}/{backupId}/blob.enc`
|
|
4
|
+
* into the AAD used for envelope encryption. Throws if the key does not match.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseAad(r2Key: string): Aad;
|
package/dist/r2key.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an R2 object key of the form `backups/{userId}/{agentId}/{backupId}/blob.enc`
|
|
3
|
+
* into the AAD used for envelope encryption. Throws if the key does not match.
|
|
4
|
+
*/
|
|
5
|
+
export function parseAad(r2Key) {
|
|
6
|
+
const parts = r2Key.split("/");
|
|
7
|
+
if (parts.length !== 5 || parts[0] !== "backups" || parts[4] !== "blob.enc") {
|
|
8
|
+
throw new Error(`malformed r2 key: ${r2Key}`);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
userId: parts[1],
|
|
12
|
+
agentId: parts[2],
|
|
13
|
+
backupId: parts[3],
|
|
14
|
+
formatVersion: 1,
|
|
15
|
+
};
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@singularity-layer/agentvault",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"agentvault": "dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@clack/prompts": "^0.7.0",
|
|
11
|
+
"commander": "^12.1.0",
|
|
12
|
+
"@singularity-layer/agentvault-core": "0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"vitest": "^2.1.0",
|
|
16
|
+
"@types/node": "^22.7.0",
|
|
17
|
+
"typescript": "^5.6.0"
|
|
18
|
+
},
|
|
19
|
+
"description": "Agent Vault: zero-knowledge encrypted backup, restore, and migration for AI agents (OpenClaw, Hermes) on Singularity Layer.",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/Singularity-Layer/agentvault.git",
|
|
24
|
+
"directory": "packages/cli"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://cloud.x402compute.cc/network/backups",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"agent",
|
|
40
|
+
"backup",
|
|
41
|
+
"restore",
|
|
42
|
+
"migration",
|
|
43
|
+
"openclaw",
|
|
44
|
+
"hermes",
|
|
45
|
+
"cli",
|
|
46
|
+
"singularity-layer",
|
|
47
|
+
"agentvault"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"test": "vitest run"
|
|
52
|
+
}
|
|
53
|
+
}
|