@xiaolikt/ai-vault 0.9.1 → 0.10.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 +1 -1
- package/README.md +357 -243
- package/README.zh.md +388 -0
- package/crates/ai-vault/Cargo.toml +1 -1
- package/crates/ai-vault/src/cli.rs +55 -39
- package/crates/ai-vault/src/dialog.rs +14 -7
- package/crates/ai-vault/src/i18n.rs +56 -0
- package/crates/ai-vault/src/main.rs +1 -0
- package/package.json +5 -5
- package/packages/pi-ai-vault/README.md +40 -45
- package/packages/pi-ai-vault/README.zh.md +84 -0
- package/packages/pi-ai-vault/package.json +5 -4
- package/packages/pi-ai-vault/src/bitwarden.ts +2 -1
- package/packages/pi-ai-vault/src/cli.ts +2 -1
- package/packages/pi-ai-vault/src/ente.ts +4 -3
- package/packages/pi-ai-vault/src/i18n.ts +31 -0
- package/packages/pi-ai-vault/src/index.ts +77 -76
- package/packages/pi-ai-vault/src/prompt.ts +3 -2
- package/tests/mocks/bin/zenity +7 -2
|
@@ -87,9 +87,10 @@ mod mac {
|
|
|
87
87
|
|
|
88
88
|
pub fn prompt_secret(title: &str, label: &str) -> Answer<String> {
|
|
89
89
|
let script = format!(
|
|
90
|
-
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" default answer \"\" with hidden answer buttons {{\"
|
|
90
|
+
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" default answer \"\" with hidden answer buttons {{\"{}\", \"OK\"}} default button \"OK\" giving up after {}",
|
|
91
91
|
quote(label),
|
|
92
92
|
quote(title),
|
|
93
|
+
crate::i18n::tr("Cancel", "取消"),
|
|
93
94
|
DIALOG_SECONDS
|
|
94
95
|
);
|
|
95
96
|
let out = osascript(&script);
|
|
@@ -115,9 +116,10 @@ mod mac {
|
|
|
115
116
|
|
|
116
117
|
pub fn prompt_text(title: &str, label: &str) -> Answer<String> {
|
|
117
118
|
let script = format!(
|
|
118
|
-
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" default answer \"\" buttons {{\"
|
|
119
|
+
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" default answer \"\" buttons {{\"{}\", \"OK\"}} default button \"OK\" giving up after {}",
|
|
119
120
|
quote(label),
|
|
120
121
|
quote(title),
|
|
122
|
+
crate::i18n::tr("Cancel", "取消"),
|
|
121
123
|
DIALOG_SECONDS
|
|
122
124
|
);
|
|
123
125
|
let out = osascript(&script);
|
|
@@ -139,16 +141,20 @@ mod mac {
|
|
|
139
141
|
|
|
140
142
|
pub fn confirm(title: &str, message: &str) -> Answer<bool> {
|
|
141
143
|
let script = format!(
|
|
142
|
-
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" buttons {{\"
|
|
144
|
+
"tell application \"System Events\" to display dialog \"{}\" with title \"{}\" buttons {{\"{}\", \"{}\"}} default button \"{}\" giving up after {}",
|
|
143
145
|
quote(message),
|
|
144
146
|
quote(title),
|
|
147
|
+
crate::i18n::tr("Deny", "拒绝"),
|
|
148
|
+
crate::i18n::tr("Allow", "允许"),
|
|
149
|
+
crate::i18n::tr("Deny", "拒绝"),
|
|
145
150
|
DIALOG_SECONDS
|
|
146
151
|
);
|
|
147
152
|
let out = osascript(&script);
|
|
148
153
|
if failed(&out) {
|
|
149
154
|
return Answer::NoUi;
|
|
150
155
|
}
|
|
151
|
-
|
|
156
|
+
let allow = crate::i18n::tr("Allow", "允许");
|
|
157
|
+
Answer::Value(out.code == 0 && out.stdout.contains(&format!("button returned:{allow}")))
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
|
|
@@ -177,7 +183,7 @@ $f.Controls.Add($box)
|
|
|
177
183
|
$ok = New-Object System.Windows.Forms.Button
|
|
178
184
|
$ok.Text = 'OK'; $ok.DialogResult = 'OK'; $ok.Left = 280; $ok.Top = 115; $f.AcceptButton = $ok
|
|
179
185
|
$cancel = New-Object System.Windows.Forms.Button
|
|
180
|
-
$cancel.Text =
|
|
186
|
+
$cancel.Text = $env:AI_VAULT_DLG_CANCEL; $cancel.DialogResult = 'Cancel'; $cancel.Left = 370; $cancel.Top = 115; $f.CancelButton = $cancel
|
|
181
187
|
$f.Controls.Add($ok); $f.Controls.Add($cancel)
|
|
182
188
|
$f.Add_Shown({ $box.Focus() })
|
|
183
189
|
if ($f.ShowDialog() -eq 'OK') { [Console]::Out.Write($box.Text); exit 0 } else { exit 1 }
|
|
@@ -203,6 +209,7 @@ if ($r -eq 'Yes') { exit 0 } else { exit 1 }
|
|
|
203
209
|
.env("AI_VAULT_DLG_TITLE", title)
|
|
204
210
|
.env("AI_VAULT_DLG_TEXT", text)
|
|
205
211
|
.env("AI_VAULT_DLG_SECRET", if secret { "1" } else { "0" })
|
|
212
|
+
.env("AI_VAULT_DLG_CANCEL", crate::i18n::tr("Cancel", "取消"))
|
|
206
213
|
.stdin(Stdio::null())
|
|
207
214
|
.stdout(Stdio::piped())
|
|
208
215
|
.stderr(Stdio::piped());
|
|
@@ -497,8 +504,8 @@ fn confirm_zenity(title: &str, message: &str) -> Answer<bool> {
|
|
|
497
504
|
arg("--no-markup"),
|
|
498
505
|
arg("--width=520"),
|
|
499
506
|
arg("--default-cancel"),
|
|
500
|
-
arg("--ok-label
|
|
501
|
-
arg("--cancel-label
|
|
507
|
+
arg(format!("--ok-label={}", crate::i18n::tr("Allow", "允许"))),
|
|
508
|
+
arg(format!("--cancel-label={}", crate::i18n::tr("Deny", "拒绝"))),
|
|
502
509
|
timeout_arg(),
|
|
503
510
|
]);
|
|
504
511
|
if failed_to_open(&z) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//! User-facing strings, English by default, Chinese with `AI_VAULT_LANG=zh`
|
|
2
|
+
//! (or a `zh_*` locale). Rust-side texts: dialogs, prompts, notices, errors.
|
|
3
|
+
//!
|
|
4
|
+
//! The rule: a message that a human reads is English unless they asked for
|
|
5
|
+
//! Chinese. Strings that a *host* parses (exit codes, `needs-ui:`,
|
|
6
|
+
//! `no such entry`, the JSON keys) never change.
|
|
7
|
+
|
|
8
|
+
use std::sync::OnceLock;
|
|
9
|
+
|
|
10
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
11
|
+
pub enum Lang {
|
|
12
|
+
En,
|
|
13
|
+
Zh,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static LANG: OnceLock<Lang> = OnceLock::new();
|
|
17
|
+
|
|
18
|
+
pub fn lang() -> Lang {
|
|
19
|
+
*LANG.get_or_init(detect)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fn detect() -> Lang {
|
|
23
|
+
let explicit = std::env::var("AI_VAULT_LANG").unwrap_or_default().to_lowercase();
|
|
24
|
+
if explicit.starts_with("zh") {
|
|
25
|
+
return Lang::Zh;
|
|
26
|
+
}
|
|
27
|
+
if explicit == "en" || !explicit.is_empty() {
|
|
28
|
+
return Lang::En;
|
|
29
|
+
}
|
|
30
|
+
let locale = ["LC_ALL", "LC_MESSAGES", "LANG"]
|
|
31
|
+
.iter()
|
|
32
|
+
.find_map(|name| std::env::var(name).ok())
|
|
33
|
+
.unwrap_or_default()
|
|
34
|
+
.to_lowercase();
|
|
35
|
+
if locale.starts_with("zh") {
|
|
36
|
+
Lang::Zh
|
|
37
|
+
} else {
|
|
38
|
+
Lang::En
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// Pick the English or the Chinese text.
|
|
43
|
+
pub fn tr(en: &'static str, zh: &'static str) -> &'static str {
|
|
44
|
+
match lang() {
|
|
45
|
+
Lang::En => en,
|
|
46
|
+
Lang::Zh => zh,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// The same with owned strings (formatted text).
|
|
51
|
+
pub fn tr_owned(en: String, zh: String) -> String {
|
|
52
|
+
match lang() {
|
|
53
|
+
Lang::En => en,
|
|
54
|
+
Lang::Zh => zh,
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiaolikt/ai-vault",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "One machine-wide encrypted secret store for AI coding agents: the ai-vault Rust CLI (npm-installable) plus the pi-ai-vault extension for pi and omp.",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "One machine-wide encrypted secret store for AI coding agents: the ai-vault Rust CLI (npm-installable, Linux/macOS/Windows) plus the pi-ai-vault extension for pi and omp.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/xiaolikt/ai-vault.git"
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@xiaolikt/ai-vault-linux-x64": "0.
|
|
37
|
-
"@xiaolikt/ai-vault-linux-arm64": "0.
|
|
38
|
-
"@xiaolikt/ai-vault-win32-x64": "0.
|
|
36
|
+
"@xiaolikt/ai-vault-linux-x64": "0.10.0",
|
|
37
|
+
"@xiaolikt/ai-vault-linux-arm64": "0.10.0",
|
|
38
|
+
"@xiaolikt/ai-vault-win32-x64": "0.10.0"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"bin",
|
|
@@ -1,82 +1,77 @@
|
|
|
1
1
|
# pi-ai-vault
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文版](README.zh.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The pi extension for [ai-vault](https://www.npmjs.com/package/@xiaolikt/ai-vault) — **omp installs the same package** (omp is a pi-compatible fork; the manifest and tool API are identical, and the only differences are feature-detected at runtime in `src/host.ts`).
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It hands one machine-wide encrypted secret store to your agent: `~/.ai-vault`, shared by every agent on the machine. The extension does no cryptography itself; it only holds a session token.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
pi install npm:pi-ai-vault
|
|
11
|
-
omp plugin install npm:pi-ai-vault
|
|
12
|
+
pi install npm:pi-ai-vault # pi; brings the ai-vault CLI along
|
|
13
|
+
omp plugin install npm:pi-ai-vault # omp; the same package
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
Then, in that host's session:
|
|
15
17
|
|
|
16
18
|
```
|
|
17
19
|
/vault init
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
(A dialog asks for the master password, twice. With a desktop it is the CLI's own window; without one, the host's prompt.)
|
|
23
|
+
|
|
24
|
+
You can also install straight from the repository: `pi install git:github.com/xiaolikt/ai-vault`.
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
Do not install `pi-bitwarden` or `omp-vault` as well: they register the same `bw_*` / `vault_*` tools. Both are archived.
|
|
23
27
|
|
|
24
|
-
##
|
|
28
|
+
## Tools
|
|
25
29
|
|
|
26
|
-
|
|
|
30
|
+
| Tool | What it does | Model sees the secret? |
|
|
27
31
|
|---|---|---|
|
|
28
|
-
| `vault_list` |
|
|
29
|
-
| `vault_get` |
|
|
30
|
-
| `vault_add` |
|
|
31
|
-
| `vault_import` |
|
|
32
|
-
| `bw_list` / `bw_run` / `bw_clipboard` / `bw_reveal` |
|
|
33
|
-
| `bw_inject` |
|
|
34
|
-
| `ente_list` | Ente Auth
|
|
35
|
-
| `ente_code` |
|
|
32
|
+
| `vault_list` | local store metadata | no |
|
|
33
|
+
| `vault_get` | read one: local store first, then Bitwarden; a Bitwarden hit follows `bitwarden.import` (ask / import / read once) | yes, user-approved on the spot |
|
|
34
|
+
| `vault_add` | store one; the password is typed in a dialog | no |
|
|
35
|
+
| `vault_import` | copy Bitwarden logins into the local store (asks first) | no |
|
|
36
|
+
| `bw_list` / `bw_run` / `bw_clipboard` / `bw_reveal` | live Bitwarden through the `bw` CLI | no (`bw_reveal` excepted) |
|
|
37
|
+
| `bw_inject` | inject into the bash env (**pi only**; omp does not register it) | no |
|
|
38
|
+
| `ente_list` | Ente Auth entry metadata | no |
|
|
39
|
+
| `ente_code` | one current TOTP/Steam code, confirmed per call | yes, user-approved on the spot |
|
|
36
40
|
|
|
37
|
-
##
|
|
41
|
+
## Commands
|
|
38
42
|
|
|
39
43
|
```
|
|
40
44
|
/vault init | unlock | lock | status | list | add | remove
|
|
41
|
-
/vault
|
|
42
|
-
/vault
|
|
45
|
+
/vault mode [never|time|session] unlock policy (switching needs the master password)
|
|
46
|
+
/vault settings [key value] bitwarden.*, ente.*
|
|
47
|
+
/vault ente-key save Ente's ENTE_CLI_VAULT_KEY
|
|
48
|
+
/vault grant <name> [minutes] | revoke <name|all> | audit [n]
|
|
49
|
+
/vault import <bitwarden.json> | import-bw [search]
|
|
43
50
|
/bw status|unlock|lock|clear
|
|
44
51
|
```
|
|
45
52
|
|
|
46
|
-
##
|
|
53
|
+
## Unlock policies
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
When the local store asks for its master password is a per-machine setting (`/vault mode`, switching needs the password):
|
|
49
56
|
|
|
50
|
-
|
|
|
57
|
+
| Mode | Behaviour |
|
|
51
58
|
|---|---|
|
|
52
|
-
| `never` |
|
|
53
|
-
| `time` |
|
|
54
|
-
| `session` |
|
|
59
|
+
| `never` | never asks, and reads open no window — the "the agent may use these freely" passwords |
|
|
60
|
+
| `time` | asks again N hours after the unlock (default 8) |
|
|
61
|
+
| `session` | once per session, dies with it (default) |
|
|
55
62
|
|
|
56
|
-
`vault_get`
|
|
57
|
-
|
|
58
|
-
| `bitwarden.import` | 行为 |
|
|
59
|
-
|---|---|
|
|
60
|
-
| `ask`(默认) | 给你看这一条 → 读一次 → 问「导入 ai-vault / 只用这一次」 |
|
|
61
|
-
| `always` | 命中直接导入并返回,不开窗口 |
|
|
62
|
-
| `never` | 只读一次,永不写入本地库 |
|
|
63
|
+
`vault_get` searches Bitwarden on a local miss; a hit is shown to you, then read once, then — following `bitwarden.import` — offered for import into ai-vault (so it never touches Bitwarden again) or used just this once. So **only the passwords you approve for import ever enter ai-vault**.
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
Bitwarden's own master-password prompts follow their own switch (`bitwarden.unlock`), and Ente's keychain is bypassed by `ente.unlock` — see `/vault settings`.
|
|
65
66
|
|
|
66
67
|
## Ente
|
|
67
68
|
|
|
68
|
-
`ente` CLI
|
|
69
|
-
|
|
70
|
-
想完全免钥匙串:`ente vault key generate` → `/vault ente-key` 粘进去 → `/vault settings ente.unlock never`。密钥由 ai-vault 加密封存。详见仓库 README。
|
|
71
|
-
|
|
72
|
-
## 安全边界(一句话版)
|
|
73
|
-
|
|
74
|
-
模型的 `bash` 能找到会话令牌、能 `list`,但**签不出读取确认**(签名密钥只在插件进程内存里)、**改不了令牌文件**(带 HMAC,改了就作废)、**免费拿不到 `grant`**(要主密码)。详见仓库 README「安全」一节。
|
|
69
|
+
The `ente` CLI logs in once (`ente account login --app auth`); the extension is only its client: `ente_list` is metadata, `ente_code` confirms every time.
|
|
75
70
|
|
|
76
|
-
|
|
71
|
+
To skip the keychain entirely: `ente vault key generate` → `/vault ente-key` → `/vault settings ente.unlock never`. The key is sealed by ai-vault.
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
## Security boundary, in one paragraph
|
|
79
74
|
|
|
80
|
-
|
|
75
|
+
The model's `bash` can find a session token and even `list` with one you opened by hand — but it **cannot sign a read confirmation** (the signing secret lives only in the extension process), **cannot edit a token file** (HMAC'd; an edit voids it), and **cannot get a free `grant`** (that costs the master password). Full details in the repository README, *Security*.
|
|
81
76
|
|
|
82
77
|
MIT
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# pi-ai-vault
|
|
2
|
+
|
|
3
|
+
[English](README.md)
|
|
4
|
+
|
|
5
|
+
ai-vault 的 pi 扩展——**omp 也能直接装同一个包**(omp 是 pi 的兼容分支,清单和工具 API 一致;差别只在 `src/host.ts` 的运行时探测里)。
|
|
6
|
+
|
|
7
|
+
它把本地加密密码库交给 [`ai-vault`](https://www.npmjs.com/package/@xiaolikt/ai-vault) 这个 Rust CLI:一台电脑一个库(`~/.ai-vault`),所有 agent 共用。插件本身不做加解密,只持有会话令牌。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pi install npm:pi-ai-vault # pi,自动带上 ai-vault CLI
|
|
13
|
+
omp plugin install npm:pi-ai-vault # omp,同一个包
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
然后在该宿主的会话里:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
/vault init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
(弹窗设主密码,两次。有桌面就开 zenity,没有就退回宿主自己的输入框。)
|
|
23
|
+
|
|
24
|
+
不想用 npm 也可以从仓库装:`pi install git:github.com/xiaolikt/ai-vault`。
|
|
25
|
+
|
|
26
|
+
## 工具
|
|
27
|
+
|
|
28
|
+
| 工具 | 作用 | 模型看到密码? |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `vault_list` | 本地库条目元数据 | 否 |
|
|
31
|
+
| `vault_get` | 读一条:**先本地库,再 Bitwarden**;Bitwarden 命中会问「读一次 / 导入 ai-vault」 | 是,用户当场允许 |
|
|
32
|
+
| `vault_add` | 存一条;密码由用户在弹出的窗口里输入 | 否 |
|
|
33
|
+
| `vault_import` | 把 Bitwarden 登录项抄进本地库(先确认) | 否 |
|
|
34
|
+
| `bw_list` / `bw_run` / `bw_clipboard` / `bw_reveal` | 在线 Bitwarden(`bw` CLI) | 否,`bw_reveal` 除外 |
|
|
35
|
+
| `bw_inject` | 注入 bash 环境(**仅 pi**,omp 不注册) | 否 |
|
|
36
|
+
| `ente_list` | Ente Auth 条目元数据 | 否 |
|
|
37
|
+
| `ente_code` | 当前 TOTP/Steam 验证码(每次确认) | 是,用户当场允许 |
|
|
38
|
+
|
|
39
|
+
## 命令
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/vault init | unlock | lock | status | list | add | remove
|
|
43
|
+
/vault grant <名称> [分钟] | revoke <名称|all> | audit [n]
|
|
44
|
+
/vault import <bitwarden.json> | import-bw [搜索词]
|
|
45
|
+
/bw status|unlock|lock|clear
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 解锁模式
|
|
49
|
+
|
|
50
|
+
本地库什么时候要主密码,由这台机器的模式决定(`/vault mode`,切换要主密码):
|
|
51
|
+
|
|
52
|
+
| 模式 | 行为 |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `never` | 永远不问,读取也不弹确认窗——「agent 可以自由使用」的那批密码 |
|
|
55
|
+
| `time` | 解锁后 N 小时(默认 8)再问一次 |
|
|
56
|
+
| `session` | 每个会话一次,会话结束失效(默认) |
|
|
57
|
+
|
|
58
|
+
`vault_get` 找不到本地条目时会去 Bitwarden 搜;命中后按 `bitwarden.import` 处理:
|
|
59
|
+
|
|
60
|
+
| `bitwarden.import` | 行为 |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `ask`(默认) | 给你看这一条 → 读一次 → 问「导入 ai-vault / 只用这一次」 |
|
|
63
|
+
| `always` | 命中直接导入并返回,不开窗口 |
|
|
64
|
+
| `never` | 只读一次,永不写入本地库 |
|
|
65
|
+
|
|
66
|
+
所以默认情况下 **只有你同意导入的密码才会进 ai-vault**。Bitwarden 自己的主密码请求频率也有单独设置(`bitwarden.unlock`:`never` / `time` / `session`),用 `/vault settings` 查看和修改。
|
|
67
|
+
|
|
68
|
+
## Ente
|
|
69
|
+
|
|
70
|
+
`ente` CLI 自己登录一次(`ente account login --app auth`),插件只是它的客户端:`ente_list` 只给元数据,`ente_code` 每次弹窗确认。
|
|
71
|
+
|
|
72
|
+
想完全免钥匙串:`ente vault key generate` → `/vault ente-key` 粘进去 → `/vault settings ente.unlock never`。密钥由 ai-vault 加密封存。详见仓库 README。
|
|
73
|
+
|
|
74
|
+
## 安全边界(一句话版)
|
|
75
|
+
|
|
76
|
+
模型的 `bash` 能找到会话令牌、能 `list`,但**签不出读取确认**(签名密钥只在插件进程内存里)、**改不了令牌文件**(带 HMAC,改了就作废)、**免费拿不到 `grant`**(要主密码)。详见仓库 README「安全」一节。
|
|
77
|
+
|
|
78
|
+
## 隔离
|
|
79
|
+
|
|
80
|
+
每个会话、每个子代理各自 `ai-vault unlock`,拿自己的令牌和读授权;父会话的解锁子代理继承不到。空闲 10 分钟自动失效,`/new`、`/fork`、退出会清掉本绑定的令牌。
|
|
81
|
+
|
|
82
|
+
完整说明(CLI 参数、退出码契约、Bitwarden 擦洗、审计、安全模型)见仓库 README:https://github.com/xiaolikt/ai-vault
|
|
83
|
+
|
|
84
|
+
MIT
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ai-vault",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "pi extension for ai-vault: one machine-wide encrypted secret store
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "pi extension for ai-vault: one machine-wide encrypted secret store, live Bitwarden and Ente Auth. Works in pi and in omp (the omp fork reads the same manifest).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/xiaolikt/ai-vault.git"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"security"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@xiaolikt/ai-vault": "0.
|
|
28
|
+
"@xiaolikt/ai-vault": "0.10.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@earendil-works/pi-coding-agent": "^1.5.0",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"src",
|
|
40
|
-
"README.md"
|
|
40
|
+
"README.md",
|
|
41
|
+
"README.zh.md"
|
|
41
42
|
],
|
|
42
43
|
"pi": {
|
|
43
44
|
"extensions": [
|
|
@@ -56,6 +56,7 @@ import { bitwardenLogins, filterLogins, type LoginDraft } from "./import-map.js"
|
|
|
56
56
|
import { onSessionLeave, sessionLabel, withTier } from "./host.js";
|
|
57
57
|
import { confirmWindow, hasDisplay, promptSecret } from "./prompt.js";
|
|
58
58
|
import { getSettingsSafe, settingsCli } from "./settings.js";
|
|
59
|
+
import { tr } from "./i18n.js";
|
|
59
60
|
import { scrubDeep, scrubText } from "./scrub.js";
|
|
60
61
|
|
|
61
62
|
// ---------------------------------------------------------------------------
|
|
@@ -450,7 +451,7 @@ async function bwStatus(session?: string, signal?: AbortSignal): Promise<any> {
|
|
|
450
451
|
|
|
451
452
|
/** The Bitwarden master password, in a window or the host's input dialog. */
|
|
452
453
|
async function askMasterPassword(ctx: ExtensionContext | undefined, signal?: AbortSignal): Promise<string> {
|
|
453
|
-
const pw = await promptSecret(ctx, "Bitwarden · 主密码", "解锁 Bitwarden 保险库", signal);
|
|
454
|
+
const pw = await promptSecret(ctx, tr("Bitwarden · master password", "Bitwarden · 主密码"), tr("unlock the Bitwarden vault", "解锁 Bitwarden 保险库"), signal);
|
|
454
455
|
if (pw) return pw;
|
|
455
456
|
if (signal?.aborted) throw new Error("Cancelled.");
|
|
456
457
|
if (!hasDisplay() && !ctx?.hasUI) {
|
|
@@ -12,6 +12,7 @@ import { spawn } from "node:child_process";
|
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { delimiter, dirname, join } from "node:path";
|
|
15
|
+
import { lang } from "./i18n.js";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
|
|
17
18
|
export const EXIT = {
|
|
@@ -133,7 +134,7 @@ export class HostSecret {
|
|
|
133
134
|
|
|
134
135
|
/** Environment for a CLI child: marks us as the host and passes the secret. */
|
|
135
136
|
env(): Record<string, string> {
|
|
136
|
-
return { AI_VAULT_HOST: "1", AI_VAULT_HOST_SECRET: this.value };
|
|
137
|
+
return { AI_VAULT_HOST: "1", AI_VAULT_HOST_SECRET: this.value, AI_VAULT_LANG: lang() };
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/** HMAC over "allow:<token>:<entry>:<y|n>", what `get --answer-stdin` expects. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tr } from "./i18n.js";
|
|
1
2
|
/**
|
|
2
3
|
* Ente CLI client.
|
|
3
4
|
*
|
|
@@ -48,7 +49,7 @@ export class EnteError extends Error {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const ENTE_MISSING =
|
|
51
|
-
"ente CLI 没找到(要的是 ente.com 的 `ente`,0.4+)。装好后先 `ente account login --app auth` 登录一次;也可以用 ENTE_BIN 指到二进制。";
|
|
52
|
+
tr("ente CLI not found (that is ente.com's `ente`, 0.4+). After installing it, run `ente account login --app auth` once; ENTE_BIN can point at the binary.", "ente CLI 没找到(要的是 ente.com 的 `ente`,0.4+)。装好后先 `ente account login --app auth` 登录一次;也可以用 ENTE_BIN 指到二进制。");
|
|
52
53
|
|
|
53
54
|
/** `ENTE_BIN`, then PATH, then the usual install spots. */
|
|
54
55
|
export function resolveEnte(): string | undefined {
|
|
@@ -256,8 +257,8 @@ export function registerEnte(pi: ExtensionAPI): void {
|
|
|
256
257
|
}
|
|
257
258
|
const ok = await confirmWindow(
|
|
258
259
|
ctx as unknown as Parameters<typeof confirmWindow>[0],
|
|
259
|
-
"pi-ai-vault · Ente Auth 验证码",
|
|
260
|
-
`条目: ${item.name}\n签发方: ${item.issuer || "-"}\n账号: ${item.accountName || "-"}\n\n
|
|
260
|
+
tr("pi-ai-vault · Ente Auth code", "pi-ai-vault · Ente Auth 验证码"),
|
|
261
|
+
tr(`Entry: ${item.name}\n签发方: ${item.issuer || "-"}\n账号: ${item.accountName || "-"}\n\nRead the current code? (It enters the conversation.)`, `条目: ${item.name}\n签发方: ${item.issuer || "-"}\n账号: ${item.accountName || "-"}\n\n读取当前验证码?(会进入对话)`),
|
|
261
262
|
signal,
|
|
262
263
|
);
|
|
263
264
|
if (!ok) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-facing strings: English by default, Chinese with `AI_VAULT_LANG=zh`
|
|
3
|
+
* (or a `zh_*` locale). The same rule as the CLI's i18n.rs, and the language
|
|
4
|
+
* is passed down to the CLI so its windows and messages agree with ours.
|
|
5
|
+
*
|
|
6
|
+
* Texts a *host* parses (exit codes, `needs-ui:`, error patterns such as
|
|
7
|
+
* "no such entry") never change; only what a human reads does.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type Lang = "en" | "zh";
|
|
11
|
+
|
|
12
|
+
function detect(): Lang {
|
|
13
|
+
const explicit = (process.env.AI_VAULT_LANG ?? "").toLowerCase();
|
|
14
|
+
if (explicit.startsWith("zh")) return "zh";
|
|
15
|
+
if (explicit) return "en";
|
|
16
|
+
const locale = ["LC_ALL", "LC_MESSAGES", "LANG"]
|
|
17
|
+
.map((name) => (process.env[name] ?? "").toLowerCase())
|
|
18
|
+
.find((value) => value.length > 0);
|
|
19
|
+
return locale?.startsWith("zh") ? "zh" : "en";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let cached: Lang | undefined;
|
|
23
|
+
|
|
24
|
+
export function lang(): Lang {
|
|
25
|
+
return (cached ??= detect());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Pick the English or the Chinese text. */
|
|
29
|
+
export function tr(en: string, zh: string): string {
|
|
30
|
+
return lang() === "zh" ? zh : en;
|
|
31
|
+
}
|