@xiaolikt/ai-vault 0.10.0 → 0.12.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/Cargo.lock CHANGED
@@ -14,7 +14,7 @@ dependencies = [
14
14
 
15
15
  [[package]]
16
16
  name = "ai-vault"
17
- version = "0.10.0"
17
+ version = "0.12.0"
18
18
  dependencies = [
19
19
  "base64",
20
20
  "chacha20poly1305",
package/README.md CHANGED
@@ -152,12 +152,12 @@ ai-vault [--dir DIR] [--json] <command>
152
152
  | `lock --token T \| --all` | drop a token (`--all` ends every session on the machine) |
153
153
  | `list --token T` | entry metadata (name/username/URI); no passwords |
154
154
  | `get <name> [--reason R] [--answer-stdin]` | read one entry; a confirm window opens unless a grant is live |
155
- | `add --name N [--username U] [--uri U] [--notes N] [--password-stdin] [--yes]` | create/update; the password is typed in a dialog |
155
+ | `add --name N [--type TYPE] [--field NAME[=VALUE]]… [--secret NAME=VALUE]… [--username U] [--uri U] [--notes N] [--password-stdin] [--yes]` | create/update any type; a hidden field left out is typed in a dialog (`--secret` is for a host that already asked) |
156
156
  | `save --yes [--file F]` | read an array of entries as JSON and write them (the import path) |
157
157
  | `remove <name> [--yes]` | delete (quote names with spaces) |
158
158
  | `grant <name> [--minutes N]` / `revoke <name\|--all>` | a standing read grant (default 5 min, max 60); `grant` costs the master password |
159
159
  | `audit [n]` | the last n audit lines (default 30) |
160
- | `import <bitwarden.json> [--yes]` | import an unencrypted Bitwarden export |
160
+ | `import <bitwarden.json> [--yes]` | import an unencrypted Bitwarden export, every item type |
161
161
 
162
162
  The token can also come from `AI_VAULT_TOKEN`. The store directory is `--dir`,
163
163
  then `AI_VAULT_DIR`, then `~/.ai-vault`.
@@ -196,9 +196,9 @@ cannot sign an "allow".
196
196
  | Tool | What it does | Tier | Model sees the secret? |
197
197
  |---|---|---|---|
198
198
  | `vault_list` | local store metadata | read | no |
199
- | `vault_get` | read one: **local store first, Bitwarden second**; a Bitwarden hit follows `bitwarden.import` (ask / import / read once) | exec | yes, user-approved on the spot |
200
- | `vault_add` | store one; the password is typed in a dialog | write | no |
201
- | `vault_import` | copy Bitwarden logins into the local store (asks first) | write | no |
199
+ | `vault_get` | read one, any type: **local store first, Bitwarden second**; a Bitwarden hit follows `bitwarden.import` (ask / import / read once) | exec | yes, user-approved on the spot |
200
+ | `vault_add` | store one, any type; secret fields are typed in a dialog | write | no |
201
+ | `vault_import` | copy Bitwarden items of every type into the local store, field for field (asks first) | write | no |
202
202
  | `bw_list` | live Bitwarden metadata | read | no |
203
203
  | `bw_run` | run one command with `$VAULT_SECRET` in its env; output scrubbed | exec | no |
204
204
  | `bw_inject` | inject into the bash env (**pi only**) | exec | no |
@@ -213,6 +213,43 @@ whether ai-vault keeps `ENTE_CLI_VAULT_KEY` sealed for it.
213
213
  Field selector: `password` (default) · `totp` (seed) · `code` (rotating code) ·
214
214
  `notes` · `field:<custom field name>`.
215
215
 
216
+ ### Item types
217
+
218
+ ai-vault stores the same item types Bitwarden does, with the same field names,
219
+ so an import is a copy and a manual entry is the same shape:
220
+
221
+ | Type | `--type` | Its own fields (`data`) | Secret field |
222
+ |---|---|---|---|
223
+ | Login | `login` (default) | `username`, `password`, `totp` + `uris` | `password` |
224
+ | Secure note | `note` | none — the content is `notes` | — |
225
+ | Card | `card` | `cardholderName`, `brand`, `number`, `expMonth`, `expYear`, `code` | `number`, `code` |
226
+ | Identity | `identity` | `title`, `firstName`, `middleName`, `lastName`, `address1–3`, `city`, `state`, `postalCode`, `country`, `company`, `email`, `phone`, `ssn`, `username`, `passportNumber`, `licenseNumber` | `ssn`, document numbers |
227
+ | SSH key | `sshkey` | `privateKey`, `publicKey`, `keyFingerprint` | `privateKey` |
228
+ | Bank account | `bankaccount` | `bankName`, `nameOnAccount`, `accountType`, `accountNumber`, `routingNumber`, `branchNumber`, `pin`, `swiftCode`, `iban`, `bankContactPhone` | `accountNumber`, `routingNumber`, `pin` |
229
+ | Driver's licence | `driverslicense` | `firstName`, `middleName`, `lastName`, `dateOfBirth`, `licenseNumber`, `issuingCountry`, `issuingState`, `issueDate`, `expirationDate`, `issuingAuthority`, `licenseClass` | `licenseNumber` |
230
+ | Passport | `passport` | `surname`, `givenName`, `dateOfBirth`, `sex`, `birthPlace`, `nationality`, `issuingCountry`, `passportNumber`, `passportType`, `nationalIdentificationNumber`, `issuingAuthority`, `issueDate`, `expirationDate` | `passportNumber`, `nationalIdentificationNumber` |
231
+
232
+ The last three are behind Bitwarden's "new item types" flag; the CLI stores
233
+ them the same way. Every type also carries `notes` and custom `fields[]`
234
+ (`type`: 0 text · 1 hidden · 2 boolean · 3 linked, as in Bitwarden). A hidden
235
+ custom field is treated as a secret everywhere.
236
+
237
+ ```bash
238
+ # by hand: non-secret fields on the line, the secret typed in a window
239
+ ai-vault add --name Visa --type card --field cardholderName="Li Jun" --field brand=Visa --field expYear=2029
240
+ ai-vault add --name "Wifi" --type note --notes "guest network: …"
241
+ ai-vault add --name server --type sshkey --field publicKey="ssh-ed25519 AAAA" # private key typed
242
+ ```
243
+
244
+ `list` shows the type and the non-secret fields (cardholder, brand, expiry,
245
+ a person's name, the key's fingerprint…); it never shows a password, card
246
+ number or code, private key, PIN, account or document number, a hidden custom
247
+ field, a TOTP seed, or a secure note's body. `get` returns the whole entry.
248
+
249
+ The `vault_add` tool takes `type` and `fields` the same way. A secret field the
250
+ model fills in itself is refused: those are typed by the user in a dialog, one
251
+ window per field.
252
+
216
253
  ### Lookup order: local first, Bitwarden as fallback
217
254
 
218
255
  `vault_get` asks `ai-vault` (the store this machine shares) first and only
@@ -287,13 +324,14 @@ policy goes back to `session`, and `/bw lock` clears it too.
287
324
 
288
325
  ```
289
326
  /vault init create the local store (dialog sets the master password)
327
+ /vault add card:Visa brand=Visa code type:name, fields on the line, a bare field typed in a dialog
290
328
  /vault unlock | lock unlock / lock this session
291
329
  /vault mode [never|time|session] show / switch the unlock policy (switching needs the password)
292
330
  /vault settings [key value] show / change settings (bitwarden.*, ente.*)
293
331
  /vault ente-key save Ente's ENTE_CLI_VAULT_KEY (no keychain, no login)
294
332
  /vault status state, expiry, grants left
295
333
  /vault list entry metadata
296
- /vault add [name] add (username and password typed in a dialog)
334
+ /vault add [type:]name [field=value|field]… add any type; a bare field is typed in a dialog
297
335
  /vault remove <name> delete (quote names like "GitHub (2)")
298
336
  /vault grant <name> [minutes] a standing read grant (needs the master password)
299
337
  /vault revoke <name|all> revoke grants
@@ -397,7 +435,7 @@ may *use* passwords but cannot *get around you* to take them.
397
435
  |---|---|---|
398
436
  | **You** (typing `ai-vault` in a terminal) | everything | — |
399
437
  | **The host** (the pi/omp extension process; `AI_VAULT_HOST=1` + a secret in memory) | relay your confirmations (signed), change settings | learn the master password unless you type it |
400
- | **The agent** (the model's `bash`, same user, can read `~/.ai-vault`) | read a token file (but a session the extension opened is useless without the secret — first use voids it) | **forge a read confirmation, mint a grant on a token, change the requester shown in a window, `list` an extension session, get the Bitwarden master password** |
438
+ | **The agent** (the model's `bash`, same user, can read `~/.ai-vault`) | read a token file (but a session the extension opened is useless without the secret — first use is refused) | **forge a read confirmation, mint a grant on a token, change the requester shown in a window, `list` an extension session, get the Bitwarden master password, change any setting by editing a file** |
401
439
  | **Another user / someone with the files offline** | read ciphertext | decrypt (scrypt + ChaCha20-Poly1305) |
402
440
 
403
441
  ### How
package/README.zh.md CHANGED
@@ -138,7 +138,7 @@ ai-vault [--dir DIR] [--json] <命令>
138
138
  | `lock --token T \| --all` | 丢掉令牌(`--all` 清空本机所有会话) |
139
139
  | `list --token T` | 条目元数据(名称/用户名/URI),没有密码 |
140
140
  | `get <名字> [--reason R] [--answer-stdin]` | 读一条;没有授权时先弹确认窗 |
141
- | `add --name N [--username U] [--uri U] [--notes N] [--password-stdin] [--yes]` | 新增/更新;密码由弹窗输入 |
141
+ | `add --name N [--type TYPE] [--field NAME[=VALUE]]… [--secret NAME=VALUE]… [--username U] [--uri U] [--notes N] [--password-stdin] [--yes]` | 新增/更新任意类型;没给的隐藏字段弹窗输(`--secret` 给已经问过用户的宿主用) |
142
142
  | `save --yes [--file F]` | 从 stdin 读一组条目 JSON,批量写入(导入用) |
143
143
  | `remove <名字> [--yes]` | 删除(带空格的名称加引号) |
144
144
  | `grant <名字> [--minutes N]` / `revoke <名字\|--all>` | 手动给/撤读授权(默认 5 分钟,上限 60);`grant` 要主密码 |
@@ -176,9 +176,9 @@ ai-vault get <条目> --token <T> --answer-stdin --approval <hex> <<< 'y'
176
176
  | 工具 | 作用 | 等级 | 模型看到密码? |
177
177
  |---|---|---|---|
178
178
  | `vault_list` | 本地库元数据 | read | 否 |
179
- | `vault_get` | 读一条:**先本地库,再 Bitwarden**;命中后按 `bitwarden.import` 处理(问 / 直接导入 / 只读一次) | exec | 是,用户当场允许 |
180
- | `vault_add` | 存一条;密码在弹窗里输入 | write | 否 |
181
- | `vault_import` | 把 Bitwarden 登录项抄进本地库(先确认) | write | 否 |
179
+ | `vault_get` | 读一条,任意类型:**先本地库,再 Bitwarden**;命中后按 `bitwarden.import` 处理 | exec | 是,用户当场允许 |
180
+ | `vault_add` | 存一条,任意类型;秘密字段在弹窗里输 | write | 否 |
181
+ | `vault_import` | 把 Bitwarden 每种类型的条目按字段抄进本地库(先确认) | write | 否 |
182
182
  | `bw_list` | 查在线 Bitwarden 元数据 | read | 否 |
183
183
  | `bw_run` | 用 `$VAULT_SECRET` 跑一条命令,输出擦洗 | exec | 否 |
184
184
  | `bw_inject` | 注入 bash 环境(**仅 pi**) | exec | 否 |
@@ -191,6 +191,34 @@ Ente 的会话由 `ente` 自己管(登录一次);`ente.unlock` 只决定
191
191
 
192
192
  字段选择:`password`(默认)· `totp`(种子)· `code`(动态验证码)· `notes` · `field:<自定义字段名>`。
193
193
 
194
+ ### 条目类型
195
+
196
+ ai-vault 存的和 Bitwarden 一样的条目类型、一样的字段名,所以导入就是复制,手动录入也是同一个形状:
197
+
198
+ | 类型 | `--type` | 自己的字段(`data`) | 秘密字段 |
199
+ |---|---|---|---|
200
+ | 登录 | `login`(默认) | `username`、`password`、`totp` + `uris` | `password` |
201
+ | 安全笔记 | `note` | 没有——内容就是 `notes` | — |
202
+ | 银行卡 | `card` | `cardholderName`、`brand`、`number`、`expMonth`、`expYear`、`code` | `number`、`code` |
203
+ | 身份 | `identity` | `title`、`firstName`、`middleName`、`lastName`、`address1–3`、`city`、`state`、`postalCode`、`country`、`company`、`email`、`phone`、`ssn`、`username`、`passportNumber`、`licenseNumber` | `ssn`、证件号 |
204
+ | SSH 密钥 | `sshkey` | `privateKey`、`publicKey`、`keyFingerprint` | `privateKey` |
205
+ | 银行账户 | `bankaccount` | `bankName`、`nameOnAccount`、`accountType`、`accountNumber`、`routingNumber`、`branchNumber`、`pin`、`swiftCode`、`iban`、`bankContactPhone` | `accountNumber`、`routingNumber`、`pin` |
206
+ | 驾照 | `driverslicense` | `firstName`、`middleName`、`lastName`、`dateOfBirth`、`licenseNumber`、`issuingCountry`、`issuingState`、`issueDate`、`expirationDate`、`issuingAuthority`、`licenseClass` | `licenseNumber` |
207
+ | 护照 | `passport` | `surname`、`givenName`、`dateOfBirth`、`sex`、`birthPlace`、`nationality`、`issuingCountry`、`passportNumber`、`passportType`、`nationalIdentificationNumber`、`issuingAuthority`、`issueDate`、`expirationDate` | `passportNumber`、`nationalIdentificationNumber` |
208
+
209
+ 后三种在 Bitwarden 的「新条目类型」开关后面,CLI 一视同仁地存。每种类型都还带 `notes` 和自定义 `fields[]`(`type`:0 文本 · 1 隐藏 · 2 布尔 · 3 链接,和 Bitwarden 一致)。隐藏的自定义字段在所有地方都按秘密处理。
210
+
211
+ ```bash
212
+ # 手动录入:非秘密字段写在命令行,秘密在弹窗里输
213
+ ai-vault add --name Visa --type card --field cardholderName="李军" --field brand=Visa --field expYear=2029
214
+ ai-vault add --name Wifi --type note --notes "访客网络:…"
215
+ ai-vault add --name server --type sshkey --field publicKey="ssh-ed25519 AAAA" # 私钥弹窗输
216
+ ```
217
+
218
+ `list` 显示类型和非秘密字段(持卡人、品牌、有效期、人名、密钥指纹……);绝不显示密码、卡号和 CVV、私钥、PIN、账号和证件号、隐藏的自定义字段、TOTP 种子、安全笔记的正文。`get` 返回整条。
219
+
220
+ `vault_add` 工具同样接受 `type` 和 `fields`。模型自己填秘密字段会被拒绝:那些由用户在弹窗里输,一个字段一个窗口。
221
+
194
222
  ### 查询顺序:本地优先,Bitwarden 兜底
195
223
 
196
224
  `vault_get` 先问 `ai-vault`(这台机器共用的库),只有本地没有才去搜 Bitwarden:
@@ -253,6 +281,7 @@ ai-vault settings bitwarden.hours 24
253
281
 
254
282
  ```
255
283
  /vault init 创建本地库(弹窗设主密码)
284
+ /vault add card:Visa brand=Visa code 类型:名称,字段写在行里,只写字段名的弹窗输
256
285
  /vault unlock | lock 解锁 / 锁定本会话
257
286
  /vault mode [never|time|session] 查看/切换解锁模式(切换要主密码)
258
287
  /vault settings [键 值] 查看/修改设置(bitwarden.* 也在这里)
@@ -335,7 +364,7 @@ pi-ai-vault 只是这套 CLI 的客户端,本身不保存 Ente 的任何密钥
335
364
  |---|---|---|
336
365
  | **你**(终端里手敲 `ai-vault`) | 一切 | — |
337
366
  | **宿主**(pi/omp 扩展进程,持 `AI_VAULT_HOST=1` + 内存里的 host secret) | 替你转发确认(要签名)、改设置 | 不知道主密码(除非你输了) |
338
- | **agent**(模型的 `bash`,同一用户,能读 `~/.ai-vault`) | 读到会话令牌文件(但插件开的会话没有 secret 用不了,一用就作废) | **伪造一次读取确认、给令牌加授权、改确认窗里的请求方、`list` 插件会话、拿到 Bitwarden 主密码** |
367
+ | **agent**(模型的 `bash`,同一用户,能读 `~/.ai-vault`) | 读到会话令牌文件(但插件开的会话没有 secret,一用就被拒) | **伪造一次读取确认、给令牌加授权、改确认窗里的请求方、`list` 插件会话、拿到 Bitwarden 主密码、靠改文件改任何设置** |
339
368
  | **别的用户 / 离线拿到文件的人** | 读到密文 | 解密(scrypt + ChaCha20-Poly1305) |
340
369
 
341
370
  ### 怎么做到的
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "ai-vault"
3
- version = "0.10.0"
3
+ version = "0.12.0"
4
4
  edition = "2021"
5
5
  description = "Machine-wide encrypted secret store shared by AI coding agents"
6
6
  license = "MIT"