pi-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/README.md +40 -45
- package/README.zh.md +84 -0
- package/package.json +5 -4
- package/src/bitwarden.ts +2 -1
- package/src/cli.ts +2 -1
- package/src/ente.ts +4 -3
- package/src/i18n.ts +31 -0
- package/src/index.ts +77 -76
- package/src/prompt.ts +3 -2
package/README.md
CHANGED
|
@@ -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
|
package/README.zh.md
ADDED
|
@@ -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
|
package/package.json
CHANGED
|
@@ -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": [
|
package/src/bitwarden.ts
CHANGED
|
@@ -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) {
|
package/src/cli.ts
CHANGED
|
@@ -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. */
|
package/src/ente.ts
CHANGED
|
@@ -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) {
|
package/src/i18n.ts
ADDED
|
@@ -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
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tr } from "./i18n.js";
|
|
1
2
|
/**
|
|
2
3
|
* ai-vault — the pi/omp extension.
|
|
3
4
|
*
|
|
@@ -100,8 +101,8 @@ interface Scope {
|
|
|
100
101
|
const cli = new VaultCli();
|
|
101
102
|
|
|
102
103
|
const CLI_MISSING =
|
|
103
|
-
"ai-vault CLI 没找到。装一次就有全机共享的库:cargo install --path <repo>/crates/ai-vault(或用 AI_VAULT_BIN 指向编译好的二进制)";
|
|
104
|
-
const NOT_INITIALIZED = "本地库还没初始化 — 运行 /vault init";
|
|
104
|
+
tr("ai-vault CLI not found. Install it once for a machine-wide store: cargo install --path <repo>/crates/ai-vault (or point AI_VAULT_BIN at a compiled binary)", "ai-vault CLI 没找到。装一次就有全机共享的库:cargo install --path <repo>/crates/ai-vault(或用 AI_VAULT_BIN 指向编译好的二进制)");
|
|
105
|
+
const NOT_INITIALIZED = tr("the local store is not initialised — run /vault init", "本地库还没初始化 — 运行 /vault init");
|
|
105
106
|
const LOCKED = "local vault is locked (no master password entered, or the window was cancelled)";
|
|
106
107
|
|
|
107
108
|
const dialogs = (ctx: Ctx): PromptHost => ctx as unknown as PromptHost;
|
|
@@ -216,9 +217,9 @@ async function ensureUnlocked(scope: Scope, ctx: Ctx, signal?: AbortSignal): Pro
|
|
|
216
217
|
result = await attempt();
|
|
217
218
|
} catch (error) {
|
|
218
219
|
if (!(error instanceof CliError) || !error.needsUi) throw error;
|
|
219
|
-
const password = await promptSecret(dialogs(ctx), "ai-vault · 解锁", "本地库主密码", signal);
|
|
220
|
+
const password = await promptSecret(dialogs(ctx), tr("ai-vault · unlock", "ai-vault · 解锁"), tr("local store master password", "本地库主密码"), signal);
|
|
220
221
|
if (!password) {
|
|
221
|
-
if (!signal?.aborted) note(ctx, "没有输入主密码(窗口已取消,或没有桌面/界面)", "warning");
|
|
222
|
+
if (!signal?.aborted) note(ctx, tr("no master password entered (the window was cancelled, or there is no desktop/UI)", "没有输入主密码(窗口已取消,或没有桌面/界面)"), "warning");
|
|
222
223
|
return false;
|
|
223
224
|
}
|
|
224
225
|
result = await attempt(password);
|
|
@@ -237,7 +238,7 @@ async function ensureUnlocked(scope: Scope, ctx: Ctx, signal?: AbortSignal): Pro
|
|
|
237
238
|
return true;
|
|
238
239
|
} catch (error) {
|
|
239
240
|
if (error instanceof CliError && error.auth) {
|
|
240
|
-
note(ctx, "ai-vault: 主密码错误", "error");
|
|
241
|
+
note(ctx, tr("ai-vault: wrong master password", "ai-vault: 主密码错误"), "error");
|
|
241
242
|
return false;
|
|
242
243
|
}
|
|
243
244
|
if (error instanceof CliError && /not initialized/i.test(error.message)) {
|
|
@@ -358,8 +359,8 @@ async function bitwardenFallback(
|
|
|
358
359
|
const label = `${hit.name}${hit.username ? ` user:${hit.username}` : ""}`;
|
|
359
360
|
const allow = await confirmWindow(
|
|
360
361
|
dialogs(ctx),
|
|
361
|
-
"pi-ai-vault · Bitwarden 里找到",
|
|
362
|
-
`本地库没有「${forDialog(name)}」,Bitwarden 里有:\n${forDialog(label)}\n\n
|
|
362
|
+
tr("pi-ai-vault · found in Bitwarden", "pi-ai-vault · Bitwarden 里找到"),
|
|
363
|
+
tr(`Not in the local store as "${forDialog(name)}」,Bitwarden 里yes:\n${forDialog(label)}\n\n读取这一次吗?`, `本地库没有「${forDialog(name)}」,Bitwarden 里有:\n${forDialog(label)}\n\n读取这一次吗?`),
|
|
363
364
|
signal,
|
|
364
365
|
);
|
|
365
366
|
if (!allow) return fail(`user denied reading "${hit.name}" from Bitwarden — do not retry`, true);
|
|
@@ -367,8 +368,8 @@ async function bitwardenFallback(
|
|
|
367
368
|
|
|
368
369
|
const confirmed = await confirmWindow(
|
|
369
370
|
dialogs(ctx),
|
|
370
|
-
"pi-ai-vault · 导入到 ai-vault",
|
|
371
|
-
`把「${forDialog(hit.name)}」写进 ai-vault 吗?\n\n允许 → 以后直接读本地库(按当前解锁模式,可能免密)\n拒绝 →
|
|
371
|
+
tr("pi-ai-vault · import into ai-vault", "pi-ai-vault · 导入到 ai-vault"),
|
|
372
|
+
tr(`Write "${forDialog(hit.name)}」写进 ai-vault 吗?\n\nAllow → read from the local store from now on (no password under the current unlock policy)\nDeny → use it once only; nothing is written to the local store`, `把「${forDialog(hit.name)}」写进 ai-vault 吗?\n\n允许 → 以后直接读本地库(按当前解锁模式,可能免密)\n拒绝 → 只用这一次,不写入本地库`),
|
|
372
373
|
signal,
|
|
373
374
|
);
|
|
374
375
|
return confirmed ? importIt() : asValue("bitwarden-once");
|
|
@@ -407,9 +408,9 @@ function vaultGetTool(scope: Scope, bw: BwState): ToolDefinition<typeof vaultGet
|
|
|
407
408
|
const sub = subagentId(ctx);
|
|
408
409
|
const allowed = await confirmWindow(
|
|
409
410
|
dialogs(ctx),
|
|
410
|
-
"ai-vault · 读取本地密码",
|
|
411
|
-
`条目: ${forDialog(params.name)}\n请求方: ${sub ? `子代理 ${forDialog(sub, 32)}` : "主会话"}\n原因: ${forDialog(params.reason ?? "(未说明)", 120)}\n\n` +
|
|
412
|
-
"允许后 5 分钟内同一请求方可再次读取。密码会进入对话。",
|
|
411
|
+
tr("ai-vault · read local password", "ai-vault · 读取本地密码"),
|
|
412
|
+
tr(`Entry: ${forDialog(params.name)}\nRequester: ${sub ? `subagent ${forDialog(sub, 32)}` : "main session"}\nReason: ${forDialog(params.reason ?? "(none given)", 120)}\n\n`, `条目: ${forDialog(params.name)}\n请求方: ${sub ? `子代理 ${forDialog(sub, 32)}` : "主会话"}\n原因: ${forDialog(params.reason ?? "(未说明)", 120)}\n\n`) +
|
|
413
|
+
tr("Allowing lets the same requester read it again for 5 minutes. The password enters the conversation.", "允许后 5 分钟内同一请求方可再次读取。密码会进入对话。"),
|
|
413
414
|
signal,
|
|
414
415
|
);
|
|
415
416
|
// Relaying is our privilege as the host: sign the answer under the
|
|
@@ -518,7 +519,7 @@ async function saveLocalEntry(scope: Scope, ctx: Ctx, req: SaveRequest): Promise
|
|
|
518
519
|
if (!(await ensureUnlocked(scope, ctx, req.signal))) return LOCKED;
|
|
519
520
|
let name = req.name?.trim() ?? "";
|
|
520
521
|
if (!name) {
|
|
521
|
-
const entered = await promptText(dialogs(ctx), "ai-vault · 新条目", "名称", req.signal);
|
|
522
|
+
const entered = await promptText(dialogs(ctx), tr("ai-vault · new entry", "ai-vault · 新条目"), tr("name", "名称"), req.signal);
|
|
522
523
|
name = entered?.trim() ?? "";
|
|
523
524
|
}
|
|
524
525
|
if (!name) return "cancelled: no entry name";
|
|
@@ -542,16 +543,16 @@ async function saveLocalEntry(scope: Scope, ctx: Ctx, req: SaveRequest): Promise
|
|
|
542
543
|
}
|
|
543
544
|
if (error.needsUi === "confirm") {
|
|
544
545
|
const meta = [
|
|
545
|
-
req.username?.trim() ? `用户名: ${forDialog(req.username, 60)}` : "",
|
|
546
|
+
req.username?.trim() ? tr(`Username: ${forDialog(req.username, 60)}`, `用户名: ${forDialog(req.username, 60)}`) : "",
|
|
546
547
|
req.uri?.trim() ? `URI: ${forDialog(req.uri, 120)}` : "",
|
|
547
|
-
req.notes?.trim() ? `备注: ${forDialog(req.notes, 120)}` : "",
|
|
548
|
+
req.notes?.trim() ? tr(`Notes: ${forDialog(req.notes, 120)}`, `备注: ${forDialog(req.notes, 120)}`) : "",
|
|
548
549
|
]
|
|
549
550
|
.filter(Boolean)
|
|
550
551
|
.join("\n");
|
|
551
552
|
const ok = await confirmWindow(
|
|
552
553
|
dialogs(ctx),
|
|
553
|
-
"ai-vault · 保存到本地库",
|
|
554
|
-
`保存条目「${forDialog(name)}」。${meta ? `\n${meta}` : ""}\n
|
|
554
|
+
tr("ai-vault · save to local store", "ai-vault · 保存到本地库"),
|
|
555
|
+
tr(`Save the entry "${forDialog(name)}".${meta ? `\n${meta}` : ""}\nA window opens next for you to type the password. It never enters the conversation.`, `保存条目「${forDialog(name)}」。${meta ? `\n${meta}` : ""}\n下一步会弹出窗口,由你输入密码。密码不会进入对话。`),
|
|
555
556
|
req.signal,
|
|
556
557
|
);
|
|
557
558
|
if (!ok) return `user denied saving "${name}"`;
|
|
@@ -559,12 +560,12 @@ async function saveLocalEntry(scope: Scope, ctx: Ctx, req: SaveRequest): Promise
|
|
|
559
560
|
continue;
|
|
560
561
|
}
|
|
561
562
|
if (error.needsUi === "text") {
|
|
562
|
-
const entered = await promptText(dialogs(ctx), `ai-vault · ${name}`, "用户名(可留空)", req.signal);
|
|
563
|
+
const entered = await promptText(dialogs(ctx), `ai-vault · ${name}`, tr("username (optional)", "用户名(可留空)"), req.signal);
|
|
563
564
|
if (entered === undefined) return "cancelled";
|
|
564
565
|
args.push("--username", entered);
|
|
565
566
|
continue;
|
|
566
567
|
}
|
|
567
|
-
const password = await promptSecret(dialogs(ctx), "ai-vault · 密码", name, req.signal);
|
|
568
|
+
const password = await promptSecret(dialogs(ctx), tr("ai-vault · password", "ai-vault · 密码"), name, req.signal);
|
|
568
569
|
if (!password) return "cancelled: no password entered";
|
|
569
570
|
args.push("--password-stdin");
|
|
570
571
|
stdin = `${password}\n`;
|
|
@@ -594,11 +595,11 @@ async function importBitwarden(
|
|
|
594
595
|
.slice(0, 15)
|
|
595
596
|
.map((item) => `• ${item.name}${item.username ? ` user:${item.username}` : ""}${item.uri ? ` ${item.uri}` : ""}`)
|
|
596
597
|
.join("\n");
|
|
597
|
-
const more = meta.length > 15 ? `\n… 还有 ${meta.length - 15} 条` : "";
|
|
598
|
+
const more = meta.length > 15 ? tr(`\n… 还yes ${meta.length - 15} 条`, `\n… 还有 ${meta.length - 15} 条`) : "";
|
|
598
599
|
const allowed = await confirmWindow(
|
|
599
600
|
dialogs(ctx),
|
|
600
|
-
"ai-vault · 从 Bitwarden 导入",
|
|
601
|
-
`匹配 ${meta.length} 条。其中带密码的登录项会写入本地加密库,同名条目会被更新。\n\n${shown}${more}\n\n
|
|
601
|
+
tr("ai-vault · import from Bitwarden", "ai-vault · 从 Bitwarden 导入"),
|
|
602
|
+
tr(`Matched ${meta.length} 条。其中带密码的登录项会写入本地加密库,同名条目会被更新。\n\n${shown}${more}\n\nImport?`, `匹配 ${meta.length} 条。其中带密码的登录项会写入本地加密库,同名条目会被更新。\n\n${shown}${more}\n\n允许导入?`),
|
|
602
603
|
signal,
|
|
603
604
|
);
|
|
604
605
|
if (!allowed) return { text: "user denied the Bitwarden import", ok: false, count: 0 };
|
|
@@ -633,21 +634,21 @@ async function importBitwarden(
|
|
|
633
634
|
// ---------------------------------------------------------------- commands
|
|
634
635
|
|
|
635
636
|
const HELP = [
|
|
636
|
-
"/vault init 创建全机共享的本地加密库(弹出窗口设置主密码)",
|
|
637
|
-
"/vault unlock | lock 解锁 / 锁定(清空本会话的授权)",
|
|
638
|
-
"/vault mode [never|time|session] 查看/切换解锁模式(切换要主密码)",
|
|
639
|
-
"/vault settings [键 值] 查看/修改设置(vault.unlock、bitwarden.*、ente.* …)",
|
|
640
|
-
"/vault ente-key 保存 ente 的 ENTE_CLI_VAULT_KEY(免钥匙串/免登录)",
|
|
641
|
-
"/vault status 状态与授权剩余时间",
|
|
642
|
-
"/vault list 本地条目元数据",
|
|
643
|
-
"/vault add [名称] 新增本地条目(用户名、密码在弹窗里输入)",
|
|
644
|
-
'/vault remove <名称> 删除本地条目(带空格的名称加引号:"GitHub (2)")',
|
|
645
|
-
"/vault grant <名称> [分钟] 手动授权读取(默认 5 分钟,上限 60)",
|
|
646
|
-
"/vault revoke <名称|all> 撤销授权",
|
|
647
|
-
"/vault audit [n] 最近 n 条审计(默认 30)",
|
|
648
|
-
"/vault import <bitwarden.json> 从 Bitwarden 未加密 JSON 导出导入",
|
|
649
|
-
"/vault import-bw [搜索词] 直接从 bw CLI 导入登录项(先弹窗确认)",
|
|
650
|
-
"/bw status|unlock|lock|clear 在线 Bitwarden 会话(见 bw_* 工具)",
|
|
637
|
+
tr("/vault init create the machine-wide encrypted store (a dialog sets the master password)", "/vault init 创建全机共享的本地加密库(弹出窗口设置主密码)"),
|
|
638
|
+
tr("/vault unlock | lock unlock / lock (clears this session's grants)", "/vault unlock | lock 解锁 / 锁定(清空本会话的授权)"),
|
|
639
|
+
tr("/vault mode [never|time|session] show/switch the unlock policy (switching needs the master password)", "/vault mode [never|time|session] 查看/切换解锁模式(切换要主密码)"),
|
|
640
|
+
tr("/vault settings [key value] show/change settings (vault.unlock, bitwarden.*, ente.* …)", "/vault settings [键 值] 查看/修改设置(vault.unlock、bitwarden.*、ente.* …)"),
|
|
641
|
+
tr("/vault ente-key save Ente's ENTE_CLI_VAULT_KEY (no keychain, no login)", "/vault ente-key 保存 ente 的 ENTE_CLI_VAULT_KEY(免钥匙串/免登录)"),
|
|
642
|
+
tr("/vault status state and grants left", "/vault status 状态与授权剩余时间"),
|
|
643
|
+
tr("/vault list local entry metadata", "/vault list 本地条目元数据"),
|
|
644
|
+
tr("/vault add [name] add a local entry (username and password typed in a dialog)", "/vault add [名称] 新增本地条目(用户名、密码在弹窗里输入)"),
|
|
645
|
+
tr('/vault remove <name> delete an entry (quote names with spaces: "GitHub (2)")', '/vault remove <名称> 删除本地条目(带空格的名称加引号:"GitHub (2)")'),
|
|
646
|
+
tr("/vault grant <name> [minutes] a standing read grant (default 5 min, max 60)", "/vault grant <名称> [分钟] 手动授权读取(默认 5 分钟,上限 60)"),
|
|
647
|
+
tr("/vault revoke <name|all> revoke grants", "/vault revoke <名称|all> 撤销授权"),
|
|
648
|
+
tr("/vault audit [n] the last n audit lines (default 30)", "/vault audit [n] 最近 n 条审计(默认 30)"),
|
|
649
|
+
tr("/vault import <bitwarden.json> import an unencrypted Bitwarden JSON export", "/vault import <bitwarden.json> 从 Bitwarden 未加密 JSON 导出导入"),
|
|
650
|
+
tr("/vault import-bw [search] import logins straight from the bw CLI (asks first)", "/vault import-bw [搜索词] 直接从 bw CLI 导入登录项(先弹窗确认)"),
|
|
651
|
+
tr("/bw status|unlock|lock|clear the live Bitwarden session (see the bw_* tools)", "/bw status|unlock|lock|clear 在线 Bitwarden 会话(见 bw_* 工具)"),
|
|
651
652
|
].join("\n");
|
|
652
653
|
|
|
653
654
|
/** Split a command line into words; quotes keep a name such as "GitHub (2)" intact. */
|
|
@@ -666,7 +667,7 @@ async function initStore(scope: Scope, ctx: Ctx, label: string): Promise<void> {
|
|
|
666
667
|
scope.token = result.token;
|
|
667
668
|
scope.items = 0;
|
|
668
669
|
setStatus(ctx, scope);
|
|
669
|
-
note(ctx, `ai-vault 已创建: ${cli.dir}/store.json`);
|
|
670
|
+
note(ctx, tr(`ai-vault created: ${cli.dir}/store.json`, `ai-vault 已创建: ${cli.dir}/store.json`));
|
|
670
671
|
};
|
|
671
672
|
try {
|
|
672
673
|
finish(await cli.open<UnlockResult>("init", ["--requester", label]));
|
|
@@ -681,14 +682,14 @@ async function initStore(scope: Scope, ctx: Ctx, label: string): Promise<void> {
|
|
|
681
682
|
return;
|
|
682
683
|
}
|
|
683
684
|
}
|
|
684
|
-
const pass = await promptSecret(dialogs(ctx), "ai-vault · 创建主密码", "至少 8 位");
|
|
685
|
+
const pass = await promptSecret(dialogs(ctx), tr("ai-vault · set master password", "ai-vault · 创建主密码"), tr("at least 8 characters", "至少 8 位"));
|
|
685
686
|
if (!pass || pass.length < 8) {
|
|
686
|
-
note(ctx, "已取消,或密码短于 8 位", "warning");
|
|
687
|
+
note(ctx, tr("cancelled, or the password is shorter than 8 characters", "已取消,或密码短于 8 位"), "warning");
|
|
687
688
|
return;
|
|
688
689
|
}
|
|
689
|
-
const again = await promptSecret(dialogs(ctx), "ai-vault · 确认主密码", "再输入一次");
|
|
690
|
+
const again = await promptSecret(dialogs(ctx), tr("ai-vault · confirm master password", "ai-vault · 确认主密码"), tr("type it again", "再输入一次"));
|
|
690
691
|
if (again !== pass) {
|
|
691
|
-
note(ctx, "两次主密码不一致,已取消", "warning");
|
|
692
|
+
note(ctx, tr("the two passwords do not match; cancelled", "两次主密码不一致,已取消"), "warning");
|
|
692
693
|
return;
|
|
693
694
|
}
|
|
694
695
|
try {
|
|
@@ -701,20 +702,20 @@ async function initStore(scope: Scope, ctx: Ctx, label: string): Promise<void> {
|
|
|
701
702
|
function settingsText(s: Settings): string {
|
|
702
703
|
const persisted = s.bitwarden.persisted
|
|
703
704
|
? s.bitwarden.expiresAt
|
|
704
|
-
? `有(${Math.max(0, Math.round((s.bitwarden.expiresAt - Date.now()) / 60_000))} 分钟后过期)`
|
|
705
|
-
: "有(不过期)"
|
|
706
|
-
: "无";
|
|
705
|
+
? tr(`yes(${Math.max(0, Math.round((s.bitwarden.expiresAt - Date.now()) / 60_000))} 分钟后过期)`, `有(${Math.max(0, Math.round((s.bitwarden.expiresAt - Date.now()) / 60_000))} 分钟后过期)`)
|
|
706
|
+
: tr("yes (no expiry)", "有(不过期)")
|
|
707
|
+
: tr("no", "无");
|
|
707
708
|
return [
|
|
708
709
|
`vault.unlock: ${s.vault.unlock} (never | time | session)`,
|
|
709
|
-
`vault.hours: ${s.vault.hours} (time 模式用)
|
|
710
|
-
`vault 机器级会话: ${s.vault.auto ? "有(免密)" : "无"}
|
|
710
|
+
tr(`vault.hours: ${s.vault.hours} (time mode)`, `vault.hours: ${s.vault.hours} (time 模式用)`),
|
|
711
|
+
tr(`vault machine-wide session: ${s.vault.auto ? "yes (no password)" : "no"}`, `vault 机器级会话: ${s.vault.auto ? "有(免密)" : "无"}`),
|
|
711
712
|
`bitwarden.unlock: ${s.bitwarden.unlock} (never | time | session)`,
|
|
712
713
|
`bitwarden.hours: ${s.bitwarden.hours}`,
|
|
713
714
|
`bitwarden.import: ${s.bitwarden.import} (ask | always | never)`,
|
|
714
|
-
`bitwarden 已落盘的会话: ${persisted}
|
|
715
|
+
tr(`bitwarden persisted session: ${persisted}`, `bitwarden 已落盘的会话: ${persisted}`),
|
|
715
716
|
`ente.unlock: ${s.ente.unlock} (never | time | session)`,
|
|
716
717
|
`ente.hours: ${s.ente.hours}`,
|
|
717
|
-
`ente 已落盘的密钥: ${s.ente.persisted ? "有" : "无"}
|
|
718
|
+
tr(`ente persisted key: ${s.ente.persisted ? "yes" : "no"}`, `ente 已落盘的密钥: ${s.ente.persisted ? "有" : "无"}`),
|
|
718
719
|
].join("\n");
|
|
719
720
|
}
|
|
720
721
|
|
|
@@ -739,7 +740,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
739
740
|
case "lock": {
|
|
740
741
|
await lockNow(scope);
|
|
741
742
|
setStatus(ctx, scope);
|
|
742
|
-
note(ctx, "本地库已锁定,授权已清空");
|
|
743
|
+
note(ctx, tr("the local store is locked; grants cleared", "本地库已锁定,授权已清空"));
|
|
743
744
|
return;
|
|
744
745
|
}
|
|
745
746
|
case "status": {
|
|
@@ -754,10 +755,10 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
754
755
|
: "never";
|
|
755
756
|
const how =
|
|
756
757
|
status.mode === "never"
|
|
757
|
-
? "never(免密)"
|
|
758
|
+
? tr("never (no password)", "never(免密)")
|
|
758
759
|
: status.mode === "time"
|
|
759
|
-
? `time(每 ${status.hours}h 要一次密码)`
|
|
760
|
-
: "session(每个会话一次)";
|
|
760
|
+
? tr(`time (the password every ${status.hours}h)`, `time(每 ${status.hours}h 要一次密码)`)
|
|
761
|
+
: tr("session (once per session)", "session(每个会话一次)");
|
|
761
762
|
const lines = [
|
|
762
763
|
`store: ${cli.dir}/store.json`,
|
|
763
764
|
`session: ${status.requester}`,
|
|
@@ -789,16 +790,16 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
789
790
|
case "ente-key": {
|
|
790
791
|
// Ente's unattended key: generated by `ente vault key generate`.
|
|
791
792
|
// Saved sealed, so `ente.unlock = never | time` can use it.
|
|
792
|
-
const key = await promptSecret(dialogs(ctx), "ai-vault · Ente 密钥", "ente vault key generate 输出的密钥");
|
|
793
|
+
const key = await promptSecret(dialogs(ctx), tr("ai-vault · Ente key", "ai-vault · Ente 密钥"), tr("the key printed by ente vault key generate", "ente vault key generate 输出的密钥"));
|
|
793
794
|
if (!key) {
|
|
794
|
-
note(ctx, "已取消", "warning");
|
|
795
|
+
note(ctx, tr("cancelled", "已取消"), "warning");
|
|
795
796
|
return;
|
|
796
797
|
}
|
|
797
798
|
try {
|
|
798
799
|
const args = ["ente-session", "put"];
|
|
799
800
|
await cli.run(args, { stdin: key });
|
|
800
801
|
forgetSettings();
|
|
801
|
-
note(ctx, "已保存(封存)。现在可以设置 /vault settings ente.unlock never");
|
|
802
|
+
note(ctx, tr("saved (sealed). You can now set /vault settings ente.unlock never", "已保存(封存)。现在可以设置 /vault settings ente.unlock never"));
|
|
802
803
|
} catch (error) {
|
|
803
804
|
note(ctx, `ai-vault: ${describe(error)}`, "error");
|
|
804
805
|
}
|
|
@@ -820,14 +821,14 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
820
821
|
// `vault.unlock` opens its own password window (or answers
|
|
821
822
|
// needs-ui); the other keys do not prompt at all.
|
|
822
823
|
const run = await cli.withPassword(["settings", key, value], () =>
|
|
823
|
-
promptSecret(dialogs(ctx), "ai-vault · 主密码", "改变解锁模式需要验证"),
|
|
824
|
+
promptSecret(dialogs(ctx), tr("ai-vault · master password", "ai-vault · 主密码"), tr("changing the unlock policy needs verification", "改变解锁模式需要验证")),
|
|
824
825
|
);
|
|
825
826
|
forgetSettings();
|
|
826
827
|
const updated = JSON.parse(run.stdout) as Settings;
|
|
827
828
|
if (key.startsWith("vault.")) await lockNow(scope);
|
|
828
829
|
note(ctx, settingsText(updated));
|
|
829
830
|
} catch (error) {
|
|
830
|
-
note(ctx, `ai-vault: ${error instanceof CliError && error.denied ? "已取消" : describe(error)}`, "warning");
|
|
831
|
+
note(ctx, `ai-vault: ${error instanceof CliError && error.denied ? tr("cancelled", "已取消") : describe(error)}`, "warning");
|
|
831
832
|
}
|
|
832
833
|
return;
|
|
833
834
|
}
|
|
@@ -840,10 +841,10 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
840
841
|
ctx,
|
|
841
842
|
[
|
|
842
843
|
`mode: ${current.mode}`,
|
|
843
|
-
`hours: ${current.hours}(time
|
|
844
|
-
`machine-wide session: ${current.auto ? "yes(免密)" : "no"}`,
|
|
844
|
+
tr(`hours: ${current.hours}(time mode)`, `hours: ${current.hours}(time 模式用)`),
|
|
845
|
+
`machine-wide session: ${current.auto ? tr("yes (no password)", "yes(免密)") : "no"}`,
|
|
845
846
|
"",
|
|
846
|
-
"/vault mode never|time|session [小时] 切换(要主密码)",
|
|
847
|
+
tr("/vault mode never|time|session [hours] switch (needs the master password)", "/vault mode never|time|session [小时] 切换(要主密码)"),
|
|
847
848
|
].join("\n"),
|
|
848
849
|
);
|
|
849
850
|
} catch (error) {
|
|
@@ -852,13 +853,13 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
852
853
|
return;
|
|
853
854
|
}
|
|
854
855
|
if (!["never", "time", "session", "no-password"].includes(sub)) {
|
|
855
|
-
note(ctx, "用法: /vault mode [never|time|session] [小时]", "warning");
|
|
856
|
+
note(ctx, tr("usage: /vault mode [never|time|session] [hours]", "用法: /vault mode [never|time|session] [小时]"), "warning");
|
|
856
857
|
return;
|
|
857
858
|
}
|
|
858
859
|
const args = ["mode", "set", sub];
|
|
859
860
|
if (hoursArg) args.push("--hours", hoursArg);
|
|
860
861
|
try {
|
|
861
|
-
const run = await cli.withPassword(args, () => promptSecret(dialogs(ctx), "ai-vault · 主密码", "切换解锁模式"));
|
|
862
|
+
const run = await cli.withPassword(args, () => promptSecret(dialogs(ctx), tr("ai-vault · master password", "ai-vault · 主密码"), tr("switch the unlock policy", "切换解锁模式")));
|
|
862
863
|
const result = JSON.parse(run.stdout) as { mode: UnlockModeName; hours: number; auto: boolean };
|
|
863
864
|
forgetSettings();
|
|
864
865
|
await lockNow(scope);
|
|
@@ -867,13 +868,13 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
867
868
|
setStatus(ctx, scope);
|
|
868
869
|
const how =
|
|
869
870
|
result.mode === "never"
|
|
870
|
-
? "以后免密(密钥已写盘,任何能读你文件的程序都能读到库里的密码)"
|
|
871
|
+
? tr("no password from now on (the key is on disk: anything that can read your files can read every password in the store)", "以后免密(密钥已写盘,任何能读你文件的程序都能读到库里的密码)")
|
|
871
872
|
: result.mode === "time"
|
|
872
|
-
? `以后每 ${result.hours} 小时要一次密码`
|
|
873
|
-
: "以后每个会话要一次密码";
|
|
873
|
+
? tr(`the password is asked again every ${result.hours} hours from now on`, `以后每 ${result.hours} 小时要一次密码`)
|
|
874
|
+
: tr("the password is asked once per session from now on", "以后每个会话要一次密码");
|
|
874
875
|
note(ctx, `mode → ${result.mode},${how}`);
|
|
875
876
|
} catch (error) {
|
|
876
|
-
note(ctx, `ai-vault: ${error instanceof CliError && error.denied ? "已取消" : describe(error)}`, "warning");
|
|
877
|
+
note(ctx, `ai-vault: ${error instanceof CliError && error.denied ? tr("cancelled", "已取消") : describe(error)}`, "warning");
|
|
877
878
|
}
|
|
878
879
|
return;
|
|
879
880
|
}
|
|
@@ -898,7 +899,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
898
899
|
const name = rest.join(" ");
|
|
899
900
|
if (!(await ensureUnlocked(scope, ctx))) return;
|
|
900
901
|
if (!name) {
|
|
901
|
-
note(ctx, "用法: /vault remove <名称>", "warning");
|
|
902
|
+
note(ctx, tr("usage: /vault remove <name>", "用法: /vault remove <名称>"), "warning");
|
|
902
903
|
return;
|
|
903
904
|
}
|
|
904
905
|
const args = ["remove", name, "--token", scope.token!];
|
|
@@ -912,7 +913,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
912
913
|
note(ctx, `ai-vault: ${describe(error)}`, error instanceof CliError && error.denied ? "warning" : "error");
|
|
913
914
|
return;
|
|
914
915
|
}
|
|
915
|
-
const sure = await confirmWindow(dialogs(ctx), "ai-vault · 删除条目", `删除「${forDialog(name)}」?删除后无法恢复。`);
|
|
916
|
+
const sure = await confirmWindow(dialogs(ctx), tr("ai-vault · delete entry", "ai-vault · 删除条目"), tr(`Delete "${forDialog(name)}"? This cannot be undone.`, `删除「${forDialog(name)}」?删除后无法恢复。`));
|
|
916
917
|
if (!sure) return;
|
|
917
918
|
try {
|
|
918
919
|
const result = await cli.json<RemovingResult>([...args, "--yes"]);
|
|
@@ -932,7 +933,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
932
933
|
const minutes = rest.length > 1 && /^\d+$/.test(last) ? rest.pop() : undefined;
|
|
933
934
|
const name = rest.join(" ");
|
|
934
935
|
if (!(await ensureUnlocked(scope, ctx)) || !name) {
|
|
935
|
-
note(ctx, "先解锁;用法: /vault grant <名称> [分钟](带空格的名称加引号)", "warning");
|
|
936
|
+
note(ctx, tr("unlock first; usage: /vault grant <name> [minutes] (quote names with spaces)", "先解锁;用法: /vault grant <名称> [分钟](带空格的名称加引号)"), "warning");
|
|
936
937
|
return;
|
|
937
938
|
}
|
|
938
939
|
const args = ["grant", name, "--token", scope.token!];
|
|
@@ -940,7 +941,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
940
941
|
try {
|
|
941
942
|
// A standing grant costs the master password, like a mode change.
|
|
942
943
|
const run = await cli.withPassword(args, () =>
|
|
943
|
-
promptSecret(dialogs(ctx), "ai-vault · 授权读取", "主密码(给这条条目 N 分钟免确认)"),
|
|
944
|
+
promptSecret(dialogs(ctx), tr("ai-vault · grant read", "ai-vault · 授权读取"), tr("master password (lets this entry be read without confirmation for N minutes)", "主密码(给这条条目 N 分钟免确认)")),
|
|
944
945
|
);
|
|
945
946
|
const result = JSON.parse(run.stdout) as { name: string; minutes: number };
|
|
946
947
|
setStatus(ctx, scope, "·granted");
|
|
@@ -957,7 +958,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
957
958
|
if (target === "all") args.push("--all");
|
|
958
959
|
else if (target) args.push(target);
|
|
959
960
|
else {
|
|
960
|
-
note(ctx, "用法: /vault revoke <名称|all>", "warning");
|
|
961
|
+
note(ctx, tr("usage: /vault revoke <name|all>", "用法: /vault revoke <名称|all>"), "warning");
|
|
961
962
|
return;
|
|
962
963
|
}
|
|
963
964
|
try {
|
|
@@ -986,7 +987,7 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
986
987
|
case "import": {
|
|
987
988
|
const path = rest.join(" ");
|
|
988
989
|
if (!path) {
|
|
989
|
-
note(ctx, "用法: /vault import <bitwarden-export.json>", "warning");
|
|
990
|
+
note(ctx, tr("usage: /vault import <bitwarden-export.json>", "用法: /vault import <bitwarden-export.json>"), "warning");
|
|
990
991
|
return;
|
|
991
992
|
}
|
|
992
993
|
if (!(await ensureUnlocked(scope, ctx))) return;
|
|
@@ -1003,8 +1004,8 @@ function commandHandler(scope: Scope, bw: BwState) {
|
|
|
1003
1004
|
}
|
|
1004
1005
|
const sure = await confirmWindow(
|
|
1005
1006
|
dialogs(ctx),
|
|
1006
|
-
"ai-vault · 从 Bitwarden 导入",
|
|
1007
|
-
`导入 ${path} 里的 Bitwarden
|
|
1007
|
+
tr("ai-vault · import from Bitwarden", "ai-vault · 从 Bitwarden 导入"),
|
|
1008
|
+
tr(`Import ${path} Bitwarden logins? Same-name entries are updated.`, `导入 ${path} 里的 Bitwarden 登录项?同名条目会被更新。`),
|
|
1008
1009
|
);
|
|
1009
1010
|
if (!sure) return;
|
|
1010
1011
|
try {
|
|
@@ -1043,7 +1044,7 @@ export default function aiVault(pi: ExtensionAPI): void {
|
|
|
1043
1044
|
// Ente Auth: the `ente` CLI keeps its own login; these tools only read codes.
|
|
1044
1045
|
registerEnte(pi);
|
|
1045
1046
|
pi.registerCommand("vault", {
|
|
1046
|
-
description: "本地密码库 + Bitwarden 导入(/vault help)",
|
|
1047
|
+
description: tr("local secret store + Bitwarden import (/vault help)", "本地密码库 + Bitwarden 导入(/vault help)"),
|
|
1047
1048
|
handler: commandHandler(scope, bw),
|
|
1048
1049
|
});
|
|
1049
1050
|
// A transcript that starts fresh (/new, /fork) must not inherit this unlock
|
package/src/prompt.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* instead. Upstream pi shows typed text in the clear; OMP masks it.
|
|
9
9
|
*/
|
|
10
10
|
import { spawn, spawnSync } from "node:child_process";
|
|
11
|
+
import { tr } from "./i18n.js";
|
|
11
12
|
import { existsSync } from "node:fs";
|
|
12
13
|
import { join } from "node:path";
|
|
13
14
|
|
|
@@ -190,8 +191,8 @@ export async function confirmWindow(
|
|
|
190
191
|
"--no-markup",
|
|
191
192
|
"--width=520",
|
|
192
193
|
"--default-cancel",
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
`--ok-label=${tr("Allow", "允许")}`,
|
|
195
|
+
`--cancel-label=${tr("Deny", "拒绝")}`,
|
|
195
196
|
`--timeout=${DIALOG_MS / 1000}`,
|
|
196
197
|
],
|
|
197
198
|
signal,
|