@geslar/cli 1.0.0-rc.1 → 1.0.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,7 +1,5 @@
1
1
  # @geslar/cli
2
2
 
3
- > **Trial release.** This is a pre-release of 1.0 for testing. It is published under the npm tag `next`, so a plain `npm install -g @geslar/cli` does **not** install it; install it by its exact version (see [Install](#install)). Behaviour and options may still change before 1.0, and some things are not yet verified on every system (they are named below). Do not rely on it for production secrets yet.
4
-
5
3
  Command-line client for [Geslar](https://geslar.app): sign in, read a secret, run a command with secrets in its environment, and give AI tools and CI jobs narrowly scoped access to a Vault.
6
4
 
7
5
  Requires a Geslar account on a Premium, Family, Business or Enterprise plan. Agents and CI service accounts (machine identities) need a plan that includes them; on a Family plan they belong to the plan's owner. The server never sees secret values. Each item you read is recorded in your account's audit log.
@@ -11,12 +9,10 @@ Requires a Geslar account on a Premium, Family, Business or Enterprise plan. Age
11
9
  Requires Node.js 22 or newer.
12
10
 
13
11
  ```sh
14
- npm install -g @geslar/cli@1.0.0-rc.1
12
+ npm install -g @geslar/cli
15
13
  geslar --version
16
14
  ```
17
15
 
18
- `npm install -g @geslar/cli@next` installs the newest trial release. A plain `npm install -g @geslar/cli` never installs a trial release.
19
-
20
16
  ## Sign in
21
17
 
22
18
  ```sh
@@ -53,7 +49,7 @@ Every reference is resolved before the command starts; if one fails, the command
53
49
 
54
50
  ## PowerShell
55
51
 
56
- `--` is required: everything after it is the command, and without it `geslar` would read your command's own options as its own (`geslar run -e KEY=geslar://… node --version` prints the version of `geslar`, not of `node`). PowerShell may swallow a bare `--` before it reaches `geslar`; put it in quotes (`'--'`):
52
+ `--` is required: everything after it is the command, and without it `geslar` would read your command's own options as its own (`geslar run -e KEY=geslar://… node --version` prints the version of `geslar`, not of `node`). PowerShell swallows a bare `--` before it reaches `geslar`; put it in quotes (`'--'`):
57
53
 
58
54
  ```powershell
59
55
  geslar run -e DB_PASSWORD=geslar://personal/Database/password '--' node app.js
@@ -71,7 +67,7 @@ The local key that seals your session is kept in the OS keychain where there is
71
67
  geslar login --key-storage file # or: GESLAR_KEY_STORAGE=file
72
68
  ```
73
69
 
74
- **Linux without a Secret Service:** the keychain library does not fail there; it falls back to the kernel keyring (keyutils). The CLI notices this the first time it stores the key and warns you: the key lives in the kernel keyring of this login session and does **not** survive a logout or a restart, so you would sign in again; use `--key-storage file` to keep it. An agent profile cannot be created in that situation at all (see [Agents](#agents-ai-tools)).
70
+ **Linux without a Secret Service:** the keychain library does not fail there; it falls back to the kernel keyring (keyutils). The CLI notices this the first time it stores the key and warns you: the key lives in the kernel keyring of this login session and does **not** survive a restart of the computer, so you would sign in again; use `--key-storage file` to keep it. An agent profile cannot be created in that situation at all (see [Agents](#agents-ai-tools)).
75
71
 
76
72
  The local password (file mode) is separate from your master password and is asked for in the terminal. Switching between keychain and file requires `geslar logout` first.
77
73
 
@@ -138,12 +134,12 @@ geslar mcp init ci-bot # Claude Code (default; --scope us
138
134
  geslar mcp init ci-bot --client cursor # claude-code, claude-desktop, cursor, or json (print only)
139
135
  ```
140
136
 
141
- - The entry is only `{ command, args, env: { GESLAR_AGENT: "ci-bot" } }` — never the token. It starts `geslar mcp serve` if `geslar` is on your PATH, otherwise `npx -y @geslar/cli@<exact version> mcp serve`. For a trial release that is the exact trial version, never `latest`.
137
+ - The entry is only `{ command, args, env: { GESLAR_AGENT: "ci-bot" } }` — never the token. It starts `geslar mcp serve` if `geslar` is on your PATH, otherwise `npx -y @geslar/cli@<exact version> mcp serve` (the exact installed version, never `latest`).
142
138
  - A configuration file that cannot be parsed (for example one with comments), or is a symbolic link, is **not touched**: the entry is printed for you to paste. Otherwise a backup is written first, other servers are kept, and running it again changes nothing.
143
- - For Claude Code, `mcp init` runs `claude mcp add-json` where it can and otherwise prints the exact command. **Claude Desktop on Windows** is not yet verified on a real client in this trial release: the entry for it uses `cmd /c npx …` when `geslar` is not on the PATH — check that the server shows as running and report problems.
139
+ - For Claude Code, `mcp init` runs `claude mcp add-json` where it can and otherwise prints the exact command. **Claude Desktop on Windows** is not yet verified on a real client: the entry for it uses `cmd /c npx …` when `geslar` is not on the PATH — check that the server shows as running and report problems.
144
140
  - `mcp serve` needs the OS keychain (no key file) and refuses to start while `GESLAR_SERVICE_TOKEN` is set.
145
141
 
146
- The server offers five tools: `geslar_list_vaults`, `geslar_list_items` (names and types only), `geslar_whoami`, `geslar_provision_env` (writes `KEY=geslar://…` **reference** lines into an env file under the server's root, never values) and `geslar_run`. `geslar_run` starts a program with secrets in **its** environment and answers only with the exit code, how it ended, the duration and the number of output lines; the model gets no output unless you start the server with `--return-stdout-tail` (a filtered tail, best effort, **not** a security boundary). References are accepted in `env` and `env_file` only, never in the command, its arguments or the directory.
142
+ The server offers five tools: `geslar_list_vaults`, `geslar_list_items` (names and types only), `geslar_whoami`, `geslar_provision_env` (writes `KEY=geslar://…` **reference** lines into an env file under the server's root, never values) and `geslar_run`. `geslar_run` starts a program with secrets in **its** environment and answers only with the exit code, how it ended, the duration and the number of output lines; the model gets no output unless you start the server with `--return-stdout-tail` (a filtered tail, best effort, **not** a security boundary; values shorter than 6 characters are never masked in it). References are accepted in `env` and `env_file` only, never in the command, its arguments or the directory.
147
143
 
148
144
  You decide which commands the agent may start, in a terminal, with a typed confirmation:
149
145
 
@@ -155,6 +151,42 @@ geslar mcp revoke --all # or: geslar mcp revoke <id or pattern>
155
151
 
156
152
  A pattern lasts one hour unless you set `--ttl` (at most 8h), and `--max-uses` limits how many times it can be used. Keep patterns narrow (`npm test`, not `npm *`). **A pattern is not a security boundary:** a command that can run arbitrary code (a shell, `node`, `python`, `npx` and the like) can read the secrets in its own environment and send them anywhere. What protects your Vault is the Vault you gave the agent, its time and read limits, and the approval by a person with 2FA — not the pattern.
157
153
 
154
+ ### Other MCP clients
155
+
156
+ Any MCP client that can start a local stdio server should work: `geslar mcp serve` speaks the MCP protocol over standard input and output only (no network port) and relies on nothing that is specific to one client. The configuration of a client names a command, its arguments and an environment; for Geslar they are:
157
+
158
+ - command `geslar`, arguments `mcp serve`, environment `GESLAR_AGENT=<profile name>` (instead of the environment variable you can add `--agent <profile name>` to the arguments);
159
+ - when `geslar` is not on the PATH: command `npx`, arguments `-y @geslar/cli@<exact version> mcp serve`, the same environment.
160
+
161
+ The profile must exist (`geslar agent add <profile name>`) and the OS keychain must be usable: the server never asks for a password. `mcp init` can print the entry in the shape that many clients read:
162
+
163
+ ```sh
164
+ geslar mcp init ci-bot --client json
165
+ ```
166
+
167
+ ```json
168
+ {
169
+ "mcpServers": {
170
+ "geslar": {
171
+ "command": "geslar",
172
+ "args": [
173
+ "mcp",
174
+ "serve"
175
+ ],
176
+ "env": {
177
+ "GESLAR_AGENT": "ci-bot"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ Where that goes and what the fields are called is in the documentation of your client; `mcp init` does not guess it. On Windows the entry that `mcp init` writes for Claude Desktop starts `npx` through `cmd` (`cmd /c npx -y …`), which is not yet verified on a real client (see above); a client that starts commands without a shell may need the same, and installing `geslar` globally avoids the question.
185
+
186
+ **Tested with:** the official MCP TypeScript SDK client (pinned in the CLI, run in its test suite against the real `mcp serve` over a stdio pipe and a fake Geslar server) and MCP Inspector 2.9.0 in CLI mode (`initialize`, `tools/list` with the five tools, and calls of `geslar_whoami` and `geslar_list_vaults`, against a fake Geslar server). Both check the protocol; neither is a client that people use. **`mcp init` configures:** Claude Code, Claude Desktop and Cursor, and prints the generic entry above for anything else. If your client works, or does not, tell us which one and which version in an [issue](https://github.com/geslar-eu/geslar-cli/issues).
187
+
188
+ There is no hosted version of the Geslar MCP server, by design: your secrets are decrypted only on your own computer, so the server has to run there. Chat apps that run only in the browser or in the cloud cannot start it; use a client that runs on your computer.
189
+
158
190
  ## CI mode
159
191
 
160
192
  A CI job uses a **service account** (created in the web app under *Settings → Agents & automation → Agents & CI*, kind "Service (CI)") and its token. Put the whole `gsm_…` token in the secret store of your CI and hand it to the job as the environment variable `GESLAR_SERVICE_TOKEN`:
@@ -175,13 +207,35 @@ What happens:
175
207
  - **Only a service account's token works from the environment.** If the server says the token belongs to an agent, the CLI stops before it asks for any key; agents use `geslar agent add` on a machine of their own.
176
208
  - The child process of `geslar run` never receives the token or any other `GESLAR_*` credential, and the token is masked in the child's output. The token is in no message or error either.
177
209
  - The scope and the expiry of the account are the approval: there is no per-read approval for a service account.
210
+ - If the server refuses the token — it is unknown, revoked or expired; the server does not say which — `geslar` exits with code 2 and says exactly that: create a new service account in the browser and update the secret. (An agent profile gets a different message, because it is fixed differently: `geslar agent add` again.)
178
211
 
179
212
  Advice: one service account per repository, read-only, with the shortest expiry that suits you and a rotation date; one `geslar run` per job rather than one per step (every start exchanges the token once; the server limits exchanges per hour and per address); a CI *environment* with protection for production secrets; never run it for pull requests from forks (GitHub does not give them your secrets, and `pull_request_target` with code from the pull request must not be used). Honest limit: while `geslar` runs, the token is in its own process environment (on Linux, `/proc/<pid>/environ` is readable by the same user); it is not passed on to anything it starts.
180
213
 
214
+ ## Plans and limits
215
+
216
+ - **Signing in as a person** (`geslar login`, then `read`, `run`, `inject`) needs a Premium, Family, Business or Enterprise plan; the Free plan does not include it.
217
+ - **Agent profiles and CI service accounts** (machine identities) need the same plans, and their number is limited. Agents and service accounts count together; only an identity that is neither revoked nor expired counts.
218
+
219
+ | Plan | Machine identities |
220
+ |---|---|
221
+ | Free | 0 |
222
+ | Premium | 5 |
223
+ | Family | 5 |
224
+ | Business | 20 |
225
+ | Enterprise | 50 |
226
+
227
+ - On Premium and Family the limit is per person, across their personal and family organizations; on Business and Enterprise it is per organization.
228
+ - **Family: only the payer.** For a personal or family organization, the plan that counts is the plan of the issuing person's own personal organization. On a Family plan, that is the person who pays and holds it, so the Family plan gives agents and service accounts to the payer only. A member of the family counts only with a paid plan of their own.
229
+ - The plan is checked every time an identity is used, not only when it is created: when it lapses, the identity stops working.
230
+
181
231
  ## What this does not protect against
182
232
 
183
233
  - A person at a terminal can print any value they may read; masking covers the literal value only.
234
+ - In the output tail that `--return-stdout-tail` gives the model, values shorter than 6 characters are never masked (a 3-character value would wreck any output). `geslar run` itself masks a value of any length.
184
235
  - Anything that runs as you can read what you can read. The CLI is not a sandbox against a malicious process on your own account.
236
+ - **While your Vault is unlocked, anything that runs as you can use it, an AI agent with access to your terminal included.** `geslar unlock` leaves an unlock record on this computer, sealed with the local key. Until it ends, any process on your account can run `geslar read`, `run` or `inject` as you, with no approval and without an agent profile: an agent profile and its approvals protect your Vault only from an agent that does not also have your unlocked session. Run `geslar lock` before you let an agent work in your terminal, or run the agent under a separate OS user. The unlock also ends by itself: 15 minutes after the last use (every use moves that deadline), and in any case after the time you gave to `geslar unlock` (30 minutes by default, at most 8 hours). `geslar lock` removes the record on this computer, does not call the server, and succeeds when nothing is unlocked. With `--key-storage file` the key that seals the record needs the local password, which is asked for in the terminal.
237
+ - **The environment of a command started by `geslar run` can be read by other processes of the same OS user.** `geslar run` puts the secrets in the command's environment, and the CLI does nothing to hide it from them. On Linux the same user (and root) can read `/proc/<pid>/environ`; other systems have their own ways for a process of the same user to inspect it. On a shared machine, run the command in a container or under a dedicated user.
238
+ - **There is no offline mode.** The CLI keeps no copy of your Vault: its local state is the sealed sign-in, the unlock record (the key and its deadlines), the agent profiles and the MCP command patterns. Without a connection to Geslar, `login`, `unlock`, `whoami`, `read`, `run`, `inject` and `item list` fail with exit code 1 and "Can't connect to Geslar (network error)."; `run` starts nothing. `status` reports your sign-in from local state but cannot check the unlock, so it shows the Vault as locked. `lock`, `mcp allow-cmd`, `mcp grants`, `mcp revoke` and `agent remove` (without `--revoke`) work without a connection; `agent remove --revoke` asks the server first and deletes nothing if that fails. `agent list` shows each profile as unreachable. `logout` signs out on this computer and says that the server could not be told, so the sign-in may stay valid until it expires.
185
239
  - An agent that is allowed to run a program that can run code can send that program's secrets elsewhere (see [MCP](#mcp-ai-clients)); limit what you give it and approve with care.
186
240
 
187
241
  ## License
@@ -1,4 +1,4 @@
1
- THIRD-PARTY LICENSES — @geslar/cli 1.0.0-rc.1
1
+ THIRD-PARTY LICENSES — @geslar/cli 1.0.0
2
2
 
3
3
  The code below is bundled into dist/index.cjs (JavaScript) or compiled into
4
4
  dist/geslar_crypto_wasm_bg.wasm (Rust). The list is derived from what is
package/dist/index.cjs CHANGED
@@ -9455,6 +9455,42 @@ var AMBIGUOUS = new Set("lI1O0|".split(""));
9455
9455
  // ../../packages/domain/src/plans.ts
9456
9456
  var planSlugs = ["free", "premium", "family", "business", "enterprise"];
9457
9457
 
9458
+ // ../../packages/domain/src/safe-text.ts
9459
+ var UNSAFE_SINGLE_LINE = new RegExp("[\\p{Cc}\\p{Cs}\\p{Zl}\\p{Zp}]|(?![\\u200C\\u200D])\\p{Cf}", "u");
9460
+ var UNSAFE_MULTI_LINE = new RegExp("[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\u007F-\\u009F]|\\p{Cs}|(?![\\u200C\\u200D])\\p{Cf}", "u");
9461
+ var hasUnsafeSingleLineChars = (value) => UNSAFE_SINGLE_LINE.test(value);
9462
+ var hasUnsafeMultiLineChars = (value) => UNSAFE_MULTI_LINE.test(value);
9463
+ var TERMINAL_SEQUENCE = new RegExp(
9464
+ [
9465
+ "\\u001B\\[[0-?]*[ -/]*[@-~]",
9466
+ // CSI
9467
+ "\\u009B[0-?]*[ -/]*[@-~]",
9468
+ // 8-bit CSI
9469
+ "(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\\\|\\u009C|$)",
9470
+ // OSC
9471
+ "(?:\\u001B[PX^_]|[\\u0090\\u0098\\u009E\\u009F])[^\\u001B\\u009C]*(?:\\u001B\\\\|\\u009C|$)",
9472
+ // DCS SOS PM APC
9473
+ "\\u001B[ -/]+[0-~]",
9474
+ // nF escape (e.g. ESC ( B)
9475
+ "\\u001B[@-Z\\\\-_]"
9476
+ // two-byte escape (Fe, Fs)
9477
+ ].join("|"),
9478
+ "gu"
9479
+ );
9480
+ var DISPLAY_REPLACEMENT = "\uFFFD";
9481
+ function sanitizeForDisplay(text) {
9482
+ const withoutSequences = text.replace(TERMINAL_SEQUENCE, "");
9483
+ let out = "";
9484
+ for (const ch of withoutSequences) out += hasUnsafeSingleLineChars(ch) ? DISPLAY_REPLACEMENT : ch;
9485
+ return out;
9486
+ }
9487
+ function sanitizeMultilineForDisplay(text) {
9488
+ const withoutSequences = text.replace(TERMINAL_SEQUENCE, "").replace(/\r\n?/g, "\n");
9489
+ let out = "";
9490
+ for (const ch of withoutSequences) out += ch === "\n" || ch === " " || !hasUnsafeSingleLineChars(ch) ? ch : DISPLAY_REPLACEMENT;
9491
+ return out;
9492
+ }
9493
+
9458
9494
  // ../../packages/domain/src/vault-color.ts
9459
9495
  var vaultColorPalette = [
9460
9496
  "#407fc8",
@@ -9548,6 +9584,10 @@ var KEYS = {
9548
9584
  "uz --api-key: \u010Ditaj klju\u010D s jednog reda standardnog ulaza (cjevovod)",
9549
9585
  "with --api-key: read the key from a single line of standard input (a pipe)"
9550
9586
  ],
9587
+ opt_agent_stdin: [
9588
+ "\u010Ditaj token s jednog reda standardnog ulaza (cjevovod) umjesto iz skrivenog upita",
9589
+ "read the token from a single line of standard input (a pipe) instead of the hidden prompt"
9590
+ ],
9551
9591
  // D404 — personal API key login is switched off (see lib/api-key-login.ts)
9552
9592
  err_api_key_login_off: [
9553
9593
  "Prijava osobnim API klju\u010Dem trenutno je isklju\u010Dena. Koristi `geslar login` (preglednik) ili `geslar login --device`.",
@@ -9961,8 +10001,8 @@ var KEYS = {
9961
10001
  ],
9962
10002
  notice_key_backend: ["Lokalni klju\u010D se \u010Duva u: {backend}.", "The local key is kept in: {backend}."],
9963
10003
  notice_keyutils_warning: [
9964
- "Upozorenje: nema Secret Service servisa pa se koristi Linux keyutils \u2014 klju\u010D \u017Eivi u kernel keyringu ove prijave i NE pre\u017Eivljava odjavu/ponovno pokretanje. Za trajno \u010Duvanje upotrijebi --key-storage file.",
9965
- "Warning: no Secret Service is available, so Linux keyutils is used \u2014 the key lives in the kernel keyring of this login session and does NOT survive a logout/reboot. Use --key-storage file for persistent storage."
10004
+ "Upozorenje: nije dostupan Secret Service pa se koristi Linux keyutils \u2014 klju\u010D \u017Eivi u kernel keyringu i NE pre\u017Eivljava ponovno pokretanje ra\u010Dunala. Za trajno \u010Duvanje upotrijebi --key-storage file.",
10005
+ "Warning: no Secret Service is available, so Linux keyutils is used \u2014 the key lives in the kernel keyring and does NOT survive a restart of the computer. Use --key-storage file for persistent storage."
9966
10006
  ],
9967
10007
  warn_kill_tree_root_only: [
9968
10008
  "Upozorenje: stablo procesa nije se moglo zaustaviti u cijelosti (taskkill i popis procesa preko PowerShella nisu uspjeli); zaustavljen je samo glavni proces, podprocesi mo\u017Eda jo\u0161 rade.",
@@ -9972,6 +10012,10 @@ var KEYS = {
9972
10012
  "Upozorenje: pristup datoteci s klju\u010Dem nije se mogao ograni\u010Diti na tvoj Windows ra\u010Dun (icacls); vrijede naslje\u0111ena prava tvog korisni\u010Dkog profila.",
9973
10013
  "Warning: access to the key file could not be restricted to your Windows account (icacls); the inherited permissions of your user profile apply."
9974
10014
  ],
10015
+ warn_state_dir_acl: [
10016
+ "Upozorenje: mapa s lokalnim zapisima (sesija, otklju\u010Davanje, profili agenata) nije se mogla ograni\u010Diti na tvoj Windows ra\u010Dun (icacls); vrijede naslje\u0111ena prava tvog korisni\u010Dkog profila.",
10017
+ "Warning: the folder with the local records (session, unlock, agent profiles) could not be restricted to your Windows account (icacls); the inherited permissions of your user profile apply."
10018
+ ],
9975
10019
  // ── read / item list (D346-F2-2) ─────────────────────────────────────
9976
10020
  read_desc: [
9977
10021
  "ispisuje vrijednost jednog polja stavke na stdout (geslar://<\u0161krinja>/<stavka>[/<polje>])",
@@ -10036,8 +10080,8 @@ var KEYS = {
10036
10080
  "Warning: output goes to a terminal \u2014 secrets will be printed in clear on screen (and stay in the terminal scrollback). Redirect the output or use `geslar run`."
10037
10081
  ],
10038
10082
  err_env_spec_invalid: [
10039
- "Neispravan argument -e br. {position}: o\u010Dekujem KLJU\u010C=geslar://\u2026 (KLJU\u010C: slova, znamenke i _, ne po\u010Dinje znamenkom).",
10040
- "Invalid -e argument #{position}: expected KEY=geslar://\u2026 (KEY: letters, digits and _, not starting with a digit)."
10083
+ "Neispravan argument -e br. {position}: o\u010Dekujem KLJU\u010C=geslar://\u2026 (KLJU\u010C: slova, znamenke i _, ne po\u010Dinje znamenkom). U PowerShellu stavi '--' u navodnike: '--'",
10084
+ "Invalid -e argument #{position}: expected KEY=geslar://\u2026 (KEY: letters, digits and _, not starting with a digit). In PowerShell put '--' in quotes: '--'"
10041
10085
  ],
10042
10086
  err_env_spec_not_ref: [
10043
10087
  "Argument -e br. {position} nije geslar:// referenca. Obi\u010Dne vrijednosti ne idu na naredbenu liniju.",
@@ -10228,10 +10272,6 @@ var KEYS = {
10228
10272
  "Navedi id ili obrazac, ili --all.",
10229
10273
  "Give an id or a pattern, or --all."
10230
10274
  ],
10231
- opt_mcp_allow_shell: [
10232
- "dopusti geslar_run da pokrene ljusku (naredba kao shell-redak); samo korisnik, nikad agent",
10233
- "let geslar_run start a shell (the command as a shell line); the user's choice only, never the agent's"
10234
- ],
10235
10275
  opt_mcp_pass_env: [
10236
10276
  "imena varijabli ovog okru\u017Eenja koje dijete smije naslijediti, odvojena zarezom (npr. HTTPS_PROXY,SSL_CERT_FILE)",
10237
10277
  "names of variables of this environment the child may inherit, comma-separated (e.g. HTTPS_PROXY,SSL_CERT_FILE)"
@@ -10240,10 +10280,6 @@ var KEYS = {
10240
10280
  "geslar_run vra\u0107a filtrirani kraj stdouta (best-effort, NIJE sigurnosna granica)",
10241
10281
  "geslar_run returns a filtered tail of stdout (best-effort, NOT a security boundary)"
10242
10282
  ],
10243
- warn_mcp_allow_shell: [
10244
- "UPOZORENJE: --allow-shell: geslar_run smije pokrenuti ljusku. Obrazac naredbe tada vi\u0161e ne ograni\u010Dava ni\u0161ta \u0161to ljuska pove\u017Ee.",
10245
- "WARNING: --allow-shell: geslar_run may start a shell. A command pattern then no longer limits what the shell chains together."
10246
- ],
10247
10283
  warn_mcp_return_tail: [
10248
10284
  "UPOZORENJE: --return-stdout-tail: kraj izlaza naredbe ide modelu. Filtar je best-effort i mo\u017Ee propustiti tajnu.",
10249
10285
  "WARNING: --return-stdout-tail: the end of a command's output goes to the model. The filter is best-effort and can miss a secret."
@@ -10476,6 +10512,10 @@ var KEYS = {
10476
10512
  "Both an agent profile (--agent / GESLAR_AGENT) and a service token (GESLAR_SERVICE_TOKEN) are set. They are two different accesses; remove one of them. Nothing was run."
10477
10513
  ],
10478
10514
  msg_service_account_in_use: ["Koristi se servisni ra\u010Dun \u201E{name}\u201D.", 'Using the service account "{name}".'],
10515
+ err_service_token_rejected: [
10516
+ "Servisni token je nepoznat, opozvan ili istekao. Izradi novi servisni ra\u010Dun u pregledniku i a\u017Euriraj tajnu.",
10517
+ "The service token is unknown, revoked or expired. Create a new service account in the browser and update the secret."
10518
+ ],
10479
10519
  err_service_token_not_service: [
10480
10520
  "GESLAR_SERVICE_TOKEN nije token servisnog ra\u010Duna. Token agenta se nikad ne koristi iz okru\u017Eenja: dodaj ga s geslar agent add.",
10481
10521
  "GESLAR_SERVICE_TOKEN is not the token of a service account. An agent's token is never used from the environment: add it with geslar agent add."
@@ -10489,8 +10529,8 @@ var KEYS = {
10489
10529
  "--unlock is not used with a service token (GESLAR_SERVICE_TOKEN): there is nothing to unlock."
10490
10530
  ],
10491
10531
  err_keystore_not_persistent: [
10492
- "Agent profil na Linuxu tra\u017Ei trajnu pohranu klju\u010Da, a nje nema ({detail}). Bez Secret Servicea (gnome-keyring, KWallet, KeePassXC) klju\u010D ide u kernel keyutils, koji ne pre\u017Eivljava odjavu ni ponovno pokretanje ra\u010Dunala \u2014 profil bi nestao, a token vrijedi samo jednom. Token NIJE potro\u0161en. Instaliraj i pokreni Secret Service u korisni\u010Dkoj sesiji (npr. gnome-keyring uz D-Bus sesiju) i ponovi. CI ne treba keychain: servisni ra\u010Dun radi sa servisnim tokenom iz okru\u017Eenja (GESLAR_SERVICE_TOKEN) \u2014 geslar run, read i inject tada ne diraju ni keychain ni disk.",
10493
- "An agent profile on Linux needs a key store that survives a restart, and there is none ({detail}). Without a Secret Service (gnome-keyring, KWallet, KeePassXC) the key goes to the kernel keyutils keyring, which does not survive a logout or a reboot \u2014 the profile would be lost, and the token can be used only once. The token was NOT used up. Install and start a Secret Service in the user session (e.g. gnome-keyring with a D-Bus session) and try again. CI needs no keychain: a service account works with a service token from the environment (GESLAR_SERVICE_TOKEN) \u2014 geslar run, read and inject then touch neither the keychain nor the disk."
10532
+ "Agent profil na Linuxu tra\u017Ei trajnu pohranu klju\u010Da, a nje nema ({detail}). Bez Secret Servicea (gnome-keyring, KWallet, KeePassXC) klju\u010D ide u kernel keyutils, koji ne pre\u017Eivljava ponovno pokretanje ra\u010Dunala \u2014 profil bi nestao, a token vrijedi samo jednom. Token NIJE potro\u0161en. Instaliraj i pokreni Secret Service u korisni\u010Dkoj sesiji (npr. gnome-keyring uz D-Bus sesiju) i ponovi. CI ne treba keychain: servisni ra\u010Dun radi sa servisnim tokenom iz okru\u017Eenja (GESLAR_SERVICE_TOKEN) \u2014 geslar run, read i inject tada ne diraju ni keychain ni disk.",
10533
+ "An agent profile on Linux needs a key store that survives a restart, and there is none ({detail}). Without a Secret Service (gnome-keyring, KWallet, KeePassXC) the key goes to the kernel keyutils keyring, which does not survive a restart of the computer \u2014 the profile would be lost, and the token can be used only once. The token was NOT used up. Install and start a Secret Service in the user session (e.g. gnome-keyring with a D-Bus session) and try again. CI needs no keychain: a service account works with a service token from the environment (GESLAR_SERVICE_TOKEN) \u2014 geslar run, read and inject then touch neither the keychain nor the disk."
10494
10534
  ],
10495
10535
  err_agent_key_lost: [
10496
10536
  "Klju\u010D profila \u201E{name}\u201D nestao je iz keychaina (npr. nakon ponovnog pokretanja Linuxa bez Secret Servicea) ili je zamijenjen drugim. Profil se ne mo\u017Ee vratiti, a token je bio jednokratan. Ukloni ga s geslar agent remove {name}, izradi novog agenta u pregledniku (Strojni identiteti) i dodaj ga s geslar agent add {name}.",
@@ -10520,9 +10560,90 @@ function translate(key, lang) {
10520
10560
  function fmt(template, vars) {
10521
10561
  return template.replace(/\{(\w+)\}/g, (m, k) => k in vars ? String(vars[k]) : m);
10522
10562
  }
10563
+ function safeParams(params) {
10564
+ const out = {};
10565
+ for (const [k, v] of Object.entries(params)) out[k] = typeof v === "string" ? sanitizeForDisplay(v) : v;
10566
+ return out;
10567
+ }
10523
10568
  function t(key, params) {
10524
10569
  const template = translate(key, getLang());
10525
- return params ? fmt(template, params) : template;
10570
+ return params ? fmt(template, safeParams(params)) : template;
10571
+ }
10572
+
10573
+ // src/lib/cli-format.ts
10574
+ function displayOrgName(organizationId, organizationName, organizationType) {
10575
+ if (organizationType === "personal") return t("org_personal");
10576
+ return organizationName ?? organizationId;
10577
+ }
10578
+ function authMethodLabel(authMethod) {
10579
+ switch (authMethod) {
10580
+ case "browser":
10581
+ return t("auth_method_browser");
10582
+ case "device":
10583
+ return t("auth_method_device");
10584
+ case "api-key":
10585
+ return t("auth_method_apikey");
10586
+ default:
10587
+ return t("auth_method_unknown");
10588
+ }
10589
+ }
10590
+ var COMMANDER_ERROR_KEYS = {
10591
+ "commander.unknownCommand": "cmd_err_unknown_command",
10592
+ "commander.unknownOption": "cmd_err_unknown_option",
10593
+ "commander.missingArgument": "cmd_err_missing_argument",
10594
+ "commander.optionMissingArgument": "cmd_err_option_missing_argument",
10595
+ "commander.missingMandatoryOptionValue": "cmd_err_missing_mandatory_option",
10596
+ "commander.invalidArgument": "cmd_err_invalid_argument",
10597
+ "commander.conflictingOption": "cmd_err_conflicting_option"
10598
+ };
10599
+ function extractQuotedToken(message) {
10600
+ const match = message.match(/'([^']*)'/);
10601
+ return match ? match[1] : message;
10602
+ }
10603
+ var REFERENCE_FLAGS = /* @__PURE__ */ new Set(["-e", "--env", "-f", "--secrets-file"]);
10604
+ function missingDoubleDash(token, ctx) {
10605
+ if (ctx.platform !== "win32") return false;
10606
+ const args = ctx.argv;
10607
+ if (args.includes("--")) return false;
10608
+ if (!args.includes("run") && !args.includes("inject")) return false;
10609
+ const at = args.indexOf(token);
10610
+ if (at <= 0) return false;
10611
+ return args.slice(0, at).some((a) => REFERENCE_FLAGS.has(a) || a.includes("geslar://"));
10612
+ }
10613
+ function redactMachineTokens(text) {
10614
+ return text.replace(/gsm_[A-Za-z0-9_-]{8,}/g, "gsm_\u2026");
10615
+ }
10616
+ function localizeCommanderMessage(err, ctx) {
10617
+ return redactMachineTokens(localizeCommanderMessageRaw(err, ctx));
10618
+ }
10619
+ function localizeCommanderMessageRaw(err, ctx) {
10620
+ const key = COMMANDER_ERROR_KEYS[err.code];
10621
+ if (!key) return err.message;
10622
+ const arg = extractQuotedToken(err.message);
10623
+ const message = t(key, { arg });
10624
+ if (ctx && err.code === "commander.unknownOption" && missingDoubleDash(arg, ctx)) {
10625
+ return [message, t("hint_powershell_double_dash")].join("\n");
10626
+ }
10627
+ return message;
10628
+ }
10629
+ function formatLocalTime(iso) {
10630
+ return new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }).format(new Date(iso));
10631
+ }
10632
+ function minutesUntil(iso, nowMs) {
10633
+ return Math.max(0, Math.ceil((Date.parse(iso) - nowMs) / 6e4));
10634
+ }
10635
+ function formatVaultUnlockedLine(result, nowMs = Date.now()) {
10636
+ const effectiveMs = Date.parse(result.unlockExpiresAt);
10637
+ const absoluteMs = Date.parse(result.unlockAbsoluteExpiresAt);
10638
+ if (effectiveMs < absoluteMs) {
10639
+ return t("status_line_vault_unlocked_idle", { idle: minutesUntil(result.unlockExpiresAt, nowMs), time: formatLocalTime(result.unlockAbsoluteExpiresAt) });
10640
+ }
10641
+ return t("status_line_vault_unlocked_absolute", { time: formatLocalTime(result.unlockAbsoluteExpiresAt) });
10642
+ }
10643
+ var RAW_IN_JSON = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu;
10644
+ function jsonText(value) {
10645
+ const text = JSON.stringify(value);
10646
+ return text.replace(RAW_IN_JSON, (ch) => Array.from({ length: ch.length }, (_unit, i) => `\\u${ch.charCodeAt(i).toString(16).padStart(4, "0")}`).join(""));
10526
10647
  }
10527
10648
 
10528
10649
  // src/lib/errors.ts
@@ -10856,7 +10977,7 @@ function readOneLineFromStdin(stdin = process.stdin) {
10856
10977
  }
10857
10978
 
10858
10979
  // src/lib/version.ts
10859
- var CLI_VERSION = true ? "1.0.0-rc.1" : readPackageVersion();
10980
+ var CLI_VERSION = true ? "1.0.0" : readPackageVersion();
10860
10981
 
10861
10982
  // src/mcp/backend.ts
10862
10983
  var MachineBackendError = class extends Error {
@@ -25416,9 +25537,11 @@ var Timestamp = external_exports.iso.datetime();
25416
25537
  var MAX_DECODED_BYTES = 10 * 1024 * 1024;
25417
25538
  var MAX_BASE64_LENGTH = Math.ceil(MAX_DECODED_BYTES / 3) * 4;
25418
25539
  var Base64Bytes = external_exports.base64().max(MAX_BASE64_LENGTH);
25419
- var OpaqueMessage = external_exports.string().min(1).max(8192);
25540
+ var OpaqueMessage = external_exports.string().min(1).max(8192).regex(/^[A-Za-z0-9_-]+$/, "must be base64url");
25420
25541
  var KeyVersion = external_exports.number().int().nonnegative();
25421
25542
  var DeviceFingerprint = external_exports.string().min(1).max(128);
25543
+ var SingleLineText = (min, max) => external_exports.string().min(min).max(max).refine((v) => !hasUnsafeSingleLineChars(v), { message: "must be plain single-line text (no control or invisible formatting characters)" });
25544
+ var MultiLineText = (max) => external_exports.string().max(max).refine((v) => !hasUnsafeMultiLineChars(v), { message: "must be plain text (no control or invisible formatting characters)" });
25422
25545
 
25423
25546
  // ../../packages/contracts/src/admin.ts
25424
25547
  var AdminUserOrg = external_exports.object({
@@ -25499,7 +25622,7 @@ var AdminRevokeEntitlementResponse = external_exports.object({
25499
25622
  // ../../packages/contracts/src/audit.ts
25500
25623
  var AccessEventAction = external_exports.enum(["reveal", "copy", "fill"]);
25501
25624
  var MAX_FIELD_KEY_LENGTH = 64;
25502
- var AccessEventFieldKey = external_exports.string().min(1).max(MAX_FIELD_KEY_LENGTH);
25625
+ var AccessEventFieldKey = SingleLineText(1, MAX_FIELD_KEY_LENGTH);
25503
25626
  var AccessEvent = external_exports.object({
25504
25627
  itemId: Uuid,
25505
25628
  action: AccessEventAction,
@@ -25546,7 +25669,9 @@ var ItemActivityEntry = external_exports.object({
25546
25669
  actorDisplayName: external_exports.string().nullable(),
25547
25670
  source: external_exports.enum(["server", "client"]).optional(),
25548
25671
  clientAction: AccessEventAction.optional(),
25549
- fieldKey: AccessEventFieldKey.optional(),
25672
+ // D411 — a READ: the character rule applies when a key is written (AccessEvent above), never when one is read back. A key stored
25673
+ // before the rule existed must still load, so this stays a plain bounded string.
25674
+ fieldKey: external_exports.string().min(1).max(MAX_FIELD_KEY_LENGTH).optional(),
25550
25675
  at: Timestamp
25551
25676
  });
25552
25677
  var ItemActivityResponse = external_exports.object({
@@ -25798,7 +25923,7 @@ var ResendRequest = external_exports.object({
25798
25923
  var ResendResponse = external_exports.object({
25799
25924
  sent: external_exports.literal(true)
25800
25925
  });
25801
- var DisplayNameInput = external_exports.string().transform((s) => s.trim()).pipe(external_exports.string().max(80));
25926
+ var DisplayNameInput = external_exports.string().transform((s) => s.trim()).pipe(external_exports.string().max(80).refine((v) => v === "" || SingleLineText(1, 80).safeParse(v).success, { message: "must be plain single-line text (no control or invisible formatting characters)" }));
25802
25927
  var ProfileUpdateRequest = external_exports.object({
25803
25928
  displayName: DisplayNameInput
25804
25929
  });
@@ -26347,8 +26472,8 @@ var OrgListItem = external_exports.object({
26347
26472
  });
26348
26473
  var OrgListResponse = external_exports.object({ orgs: external_exports.array(OrgListItem) });
26349
26474
  var CreateOrgRequest = external_exports.object({
26350
- name: external_exports.string().min(1).max(255),
26351
- vaultName: external_exports.string().min(1).max(255),
26475
+ name: SingleLineText(1, 255),
26476
+ vaultName: SingleLineText(1, 255),
26352
26477
  ownerSealed: Base64Bytes,
26353
26478
  wrappedAccountKey: Base64Bytes,
26354
26479
  accountKeypair: WrappedKeypair
@@ -26358,7 +26483,7 @@ var CreateOrgResponse = external_exports.object({
26358
26483
  vaultId: Uuid
26359
26484
  });
26360
26485
  var DeleteOrgResponse = external_exports.object({ deleted: external_exports.literal(true) });
26361
- var UpdateOrgRequest = external_exports.object({ name: external_exports.string().min(1).max(255).optional(), colorHint: VaultColorHint.optional() }).refine((body) => body.name !== void 0 || body.colorHint !== void 0, {
26486
+ var UpdateOrgRequest = external_exports.object({ name: SingleLineText(1, 255).optional(), colorHint: VaultColorHint.optional() }).refine((body) => body.name !== void 0 || body.colorHint !== void 0, {
26362
26487
  message: "at least one of name or colorHint is required"
26363
26488
  });
26364
26489
  var UpdateOrgResponse = external_exports.object({ name: external_exports.string(), colorHint: VaultColorHint.nullable() });
@@ -26370,7 +26495,7 @@ var PrincipalPublicKeyResponse = external_exports.object({
26370
26495
  publicKey: Base64Bytes
26371
26496
  });
26372
26497
  var CreateVaultRequest = external_exports.object({
26373
- name: external_exports.string().min(1).max(255),
26498
+ name: SingleLineText(1, 255),
26374
26499
  ownerSealed: Base64Bytes,
26375
26500
  escrowSealed: Base64Bytes.optional()
26376
26501
  });
@@ -26455,7 +26580,7 @@ var VaultListResponse = external_exports.object({
26455
26580
  })
26456
26581
  )
26457
26582
  });
26458
- var PatchVaultRequest = external_exports.object({ name: external_exports.string().min(1).max(255).optional(), colorHint: VaultColorHint.optional() }).refine((body) => body.name !== void 0 || body.colorHint !== void 0, {
26583
+ var PatchVaultRequest = external_exports.object({ name: SingleLineText(1, 255).optional(), colorHint: VaultColorHint.optional() }).refine((body) => body.name !== void 0 || body.colorHint !== void 0, {
26459
26584
  message: "at least one of name or colorHint is required"
26460
26585
  });
26461
26586
  var PatchVaultResponse = external_exports.object({ name: external_exports.string(), colorHint: VaultColorHint.nullable() });
@@ -26889,13 +27014,13 @@ var KnownPasswordsMemberResponse = external_exports.object({
26889
27014
  // ../../packages/contracts/src/leads.ts
26890
27015
  var TeamSize = external_exports.enum(["1-10", "11-50", "51-200", "200+"]);
26891
27016
  var NoLineBreaks = /^[^\r\n]*$/;
26892
- var NonBlank = (max) => external_exports.string().min(1).max(max).regex(NoLineBreaks, "must not contain line breaks").refine((s) => s.trim().length > 0, { message: "must not be blank" }).transform((s) => s.trim());
27017
+ var NonBlank = (max) => external_exports.string().min(1).max(max).regex(NoLineBreaks, "must not contain line breaks").refine((s) => !hasUnsafeSingleLineChars(s), { message: "must be plain single-line text (no control or invisible formatting characters)" }).refine((s) => s.trim().length > 0, { message: "must not be blank" }).transform((s) => s.trim());
26893
27018
  var BusinessLeadRequest = external_exports.object({
26894
27019
  name: NonBlank(120),
26895
27020
  company: NonBlank(120),
26896
27021
  email: Email,
26897
27022
  teamSize: TeamSize,
26898
- message: external_exports.string().max(2e3).optional(),
27023
+ message: MultiLineText(2e3).optional(),
26899
27024
  hp_ref: external_exports.string().max(200).optional()
26900
27025
  });
26901
27026
  var BusinessLeadResponse = external_exports.object({ received: external_exports.literal(true) });
@@ -27239,7 +27364,7 @@ var LoginMfaResponse = external_exports.object({
27239
27364
  });
27240
27365
 
27241
27366
  // ../../packages/contracts/src/personal-api-key.ts
27242
- var PersonalApiKeyName = external_exports.string().min(1).max(128);
27367
+ var PersonalApiKeyName = SingleLineText(1, 128);
27243
27368
  var PersonalApiKeyLevel = external_exports.enum(["read", "read_write"]);
27244
27369
  var TtlDays = external_exports.number().int().min(1).max(365);
27245
27370
  var PersonalApiKeySecret = external_exports.string().regex(/^gsk_[0-9a-zA-Z]{49}$/);
@@ -45143,7 +45268,7 @@ var GeslarClient = class _GeslarClient {
45143
45268
  });
45144
45269
  } catch (err) {
45145
45270
  if (!this.isUnlocked) throw new RotationAbortedError(vaultId);
45146
- console.error(`[rotation] skipping item ${item.itemId} in vault ${vaultId} this pass \u2014 client-side re-encrypt failed:`, err);
45271
+ console.error("[rotation] skipping item %s in vault %s this pass \u2014 client-side re-encrypt failed:", item.itemId, vaultId, err);
45147
45272
  skipped.push(item.itemId);
45148
45273
  }
45149
45274
  }
@@ -45911,8 +46036,12 @@ var MachineClientError = class extends Error {
45911
46036
  };
45912
46037
  var MachineClient = class {
45913
46038
  baseUrl;
45914
- authPart;
45915
- wrapPart;
46039
+ // D374 follow-up — real JS private fields (`#`), not `private` (TypeScript's `private` is a compile-time check
46040
+ // only; at runtime the field is a plain enumerable own property, so JSON.stringify()/util.inspect() print it in
46041
+ // full, and any object that holds this instance — directly or nested — leaks the token the same way). `#` fields
46042
+ // are invisible to both: they are not own enumerable properties at all, so neither tool can reach them.
46043
+ #authPart;
46044
+ #wrapPart;
45916
46045
  clientVersion;
45917
46046
  fetchImpl;
45918
46047
  timeoutMs;
@@ -45925,8 +46054,8 @@ var MachineClient = class {
45925
46054
  constructor(opts) {
45926
46055
  const parts = parseMachineToken(opts.token);
45927
46056
  if (!parts) throw new MachineClientError("invalid_token");
45928
- this.authPart = parts.authPart;
45929
- this.wrapPart = parts.wrapPart;
46057
+ this.#authPart = parts.authPart;
46058
+ this.#wrapPart = parts.wrapPart;
45930
46059
  this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
45931
46060
  this.clientVersion = opts.clientVersion ?? "0";
45932
46061
  this.fetchImpl = opts.fetchImpl ?? fetch;
@@ -45962,7 +46091,7 @@ var MachineClient = class {
45962
46091
  return parsed;
45963
46092
  }
45964
46093
  async exchange() {
45965
- const raw = await this.send("POST", "/machine/exchange", { auth_key: this.authPart });
46094
+ const raw = await this.send("POST", "/machine/exchange", { auth_key: this.#authPart });
45966
46095
  const out = ExchangeMachineTokenResponse.safeParse(raw);
45967
46096
  if (!out.success) throw new MachineClientError("unexpected_response");
45968
46097
  this.bearer = { token: out.data.access_token, at: Date.now() };
@@ -46026,7 +46155,7 @@ var MachineClient = class {
46026
46155
  throw new MachineClientError("key_unavailable");
46027
46156
  }
46028
46157
  try {
46029
- const ring = this.ring ?? await unlockMachineKeyring(this.wrapPart, wrapped);
46158
+ const ring = this.ring ?? await unlockMachineKeyring(this.#wrapPart, wrapped);
46030
46159
  this.ring = ring;
46031
46160
  return ring.openWraps(keys.wraps.map((w) => ({ vaultId: w.vaultId, keyVersion: w.keyVersion, sealed: fromBase64(w.sealed) })));
46032
46161
  } catch {
@@ -46188,11 +46317,13 @@ function toBackendError(err) {
46188
46317
  return new MachineBackendError("unexpected");
46189
46318
  }
46190
46319
  var MachineClientBackend = class {
46191
- client;
46320
+ // D374 follow-up — real JS private field: MachineClient itself can hold a readable token internally even
46321
+ // after this fix elsewhere, and this field must not be the thing that exposes IT via JSON.stringify()/util.inspect() either.
46322
+ #client;
46192
46323
  identityId;
46193
46324
  constructor(opts) {
46194
46325
  try {
46195
- this.client = new MachineClient({
46326
+ this.#client = new MachineClient({
46196
46327
  baseUrl: opts.baseUrl,
46197
46328
  token: opts.token,
46198
46329
  ...opts.wrappedSecretKey ? { wrappedSecretKey: opts.wrappedSecretKey } : {},
@@ -46213,8 +46344,8 @@ var MachineClientBackend = class {
46213
46344
  }
46214
46345
  async me() {
46215
46346
  return this.call(async () => {
46216
- const me = await this.client.me();
46217
- const vaults = await this.client.listVaults();
46347
+ const me = await this.#client.me();
46348
+ const vaults = await this.#client.listVaults();
46218
46349
  const inScope = new Set(me.vaults);
46219
46350
  this.identityId = me.id;
46220
46351
  return {
@@ -46230,12 +46361,12 @@ var MachineClientBackend = class {
46230
46361
  });
46231
46362
  }
46232
46363
  async listItems(vaultId) {
46233
- return this.call(() => this.client.listItems(vaultId));
46364
+ return this.call(() => this.#client.listItems(vaultId));
46234
46365
  }
46235
46366
  /** The decrypted meta and content of ONE item. The caller MUST `.fill(0)` both. */
46236
46367
  async readItemRaw(vaultId, itemId) {
46237
46368
  return this.call(async () => {
46238
- const item = await this.client.readItem(vaultId, itemId);
46369
+ const item = await this.#client.readItem(vaultId, itemId);
46239
46370
  return { meta: item.meta, full: item.full };
46240
46371
  });
46241
46372
  }
@@ -46254,22 +46385,22 @@ var MachineClientBackend = class {
46254
46385
  * ONCE), proves that `W` opens it and that every vault key unwraps — before anything is saved. */
46255
46386
  async enroll() {
46256
46387
  return this.call(async () => {
46257
- const keys = await this.client.keys();
46388
+ const keys = await this.#client.keys();
46258
46389
  if (keys.wrappedSecretKey === null) throw new MachineClientError("invalid_key");
46259
- const opened = await this.client.openKeys();
46390
+ const opened = await this.#client.openKeys();
46260
46391
  opened.close();
46261
- const wrapped = this.client.wrappedSecretKey;
46392
+ const wrapped = this.#client.wrappedSecretKey;
46262
46393
  if (!wrapped) throw new MachineClientError("key_unavailable");
46263
46394
  return { me: await this.me(), wrappedSecretKey: wrapped };
46264
46395
  });
46265
46396
  }
46266
46397
  // ── approvals and the run report (M2-1) ─────────────────────────────
46267
46398
  async reportRun(report) {
46268
- await this.call(() => this.client.reportRun({ vaultId: report.vaultId, itemIds: report.itemIds, program: report.program }));
46399
+ await this.call(() => this.#client.reportRun({ vaultId: report.vaultId, itemIds: report.itemIds, program: report.program }));
46269
46400
  }
46270
46401
  async requestApproval(input2) {
46271
46402
  return this.call(
46272
- () => this.client.requestApproval({
46403
+ () => this.#client.requestApproval({
46273
46404
  vaultId: input2.vaultId,
46274
46405
  reason: input2.reason,
46275
46406
  ...input2.itemIds ? { itemIds: input2.itemIds } : {},
@@ -46279,7 +46410,7 @@ var MachineClientBackend = class {
46279
46410
  );
46280
46411
  }
46281
46412
  async requestStatus(requestId) {
46282
- const out = await this.call(() => this.client.approvalStatus(requestId));
46413
+ const out = await this.call(() => this.#client.approvalStatus(requestId));
46283
46414
  return { state: out.status, expiresAt: out.expiresAt, usesLeft: out.usesLeft, itemCount: out.itemCount };
46284
46415
  }
46285
46416
  /** The identity id, once `me()` has been called. */
@@ -46395,7 +46526,7 @@ async function agentList(opts, deps) {
46395
46526
  }
46396
46527
  entries.push(entry);
46397
46528
  }
46398
- if (opts.json) return `${JSON.stringify(entries)}
46529
+ if (opts.json) return `${jsonText(entries)}
46399
46530
  `;
46400
46531
  if (entries.length === 0) return `${t("msg_agent_list_none")}
46401
46532
  `;
@@ -46629,6 +46760,26 @@ async function openMachineSession(deps) {
46629
46760
  wipeAgentProfile(profile);
46630
46761
  }
46631
46762
  }
46763
+ function serviceTokenErrors(inner) {
46764
+ const refused = (err) => {
46765
+ if (err instanceof MachineBackendError && err.kind === "unauthorized") throw new CliError(t("err_service_token_rejected"), 2 /* AUTH */);
46766
+ throw err;
46767
+ };
46768
+ return new Proxy(inner, {
46769
+ get(target, prop) {
46770
+ const value = Reflect.get(target, prop, target);
46771
+ if (typeof value !== "function") return value;
46772
+ return (...args) => {
46773
+ try {
46774
+ const out = value.apply(target, args);
46775
+ return out instanceof Promise ? out.catch(refused) : out;
46776
+ } catch (err) {
46777
+ return refused(err);
46778
+ }
46779
+ };
46780
+ }
46781
+ });
46782
+ }
46632
46783
  async function openServiceSession(deps) {
46633
46784
  if (!parseMachineToken(deps.serviceToken)) throw new CliError(t("err_machine_token_format"), 2 /* AUTH */);
46634
46785
  let backend;
@@ -46643,7 +46794,7 @@ async function openServiceSession(deps) {
46643
46794
  } catch (err) {
46644
46795
  throw mapMachineError(err);
46645
46796
  }
46646
- const session = { service: true, backend, meta: void 0 };
46797
+ const session = { service: true, backend: serviceTokenErrors(backend), meta: void 0 };
46647
46798
  let me;
46648
46799
  try {
46649
46800
  me = await sessionMe(session);
@@ -46652,7 +46803,7 @@ async function openServiceSession(deps) {
46652
46803
  throw mapMachineError(err);
46653
46804
  }
46654
46805
  if (me.mode !== "service") throw new CliError(t("err_service_token_not_service"), 2 /* AUTH */);
46655
- const account = me.name.replace(/[\u0000-\u001f\u007f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g, "?");
46806
+ const account = sanitizeForDisplay(me.name);
46656
46807
  (deps.notice ?? ((m) => void process.stderr.write(`${m}
46657
46808
  `)))(t("msg_service_account_in_use", { name: account }));
46658
46809
  return session;
@@ -46770,8 +46921,14 @@ function errorResult(kind, extra) {
46770
46921
  const payload = { error: { kind, message: MESSAGES[kind], ...extra } };
46771
46922
  return { isError: true, content: [{ type: "text", text: JSON.stringify(payload) }] };
46772
46923
  }
46924
+ var REASON_HINTS = {
46925
+ invalid_command: "command must be a plain program name (letters, digits, . _ + -), not a path and not a shell line; send every argument as a separate element of args."
46926
+ };
46773
46927
  function toToolError(err) {
46774
- if (err instanceof ToolInputError) return errorResult("invalid_input", { reason: err.reason });
46928
+ if (err instanceof ToolInputError) {
46929
+ const hint = REASON_HINTS[err.reason];
46930
+ return errorResult("invalid_input", hint ? { reason: err.reason, hint } : { reason: err.reason });
46931
+ }
46775
46932
  return errorResult(kindOf(err));
46776
46933
  }
46777
46934
 
@@ -46967,7 +47124,7 @@ async function approvalStatus(requestId, opts, deps) {
46967
47124
  } catch (err) {
46968
47125
  throw mapMachineError(err);
46969
47126
  }
46970
- if (opts.json) return `${JSON.stringify({ requestId, ...status2 })}
47127
+ if (opts.json) return `${jsonText({ requestId, ...status2 })}
46971
47128
  `;
46972
47129
  const terms = status2.state === "approved" ? t("msg_approval_terms", { expires: status2.expiresAt ?? "-", uses: status2.usesLeft ?? "-" }) : "";
46973
47130
  return `${t("msg_approval_status_line", { requestId, state: t(STATE_KEYS[status2.state]), terms })}
@@ -46991,7 +47148,7 @@ async function approvalList(opts, deps) {
46991
47148
  requests.push({ requestId, state: "unknown" });
46992
47149
  }
46993
47150
  }
46994
- if (opts.json) return `${JSON.stringify({ approvals: active, requests })}
47151
+ if (opts.json) return `${jsonText({ approvals: active, requests })}
46995
47152
  `;
46996
47153
  const lines = [];
46997
47154
  if (active.length === 0) lines.push(t("msg_approval_list_none"));
@@ -48078,9 +48235,9 @@ async function itemList(deps) {
48078
48235
  });
48079
48236
  }
48080
48237
  function renderItemList(entries, json4) {
48081
- if (json4) return `${JSON.stringify(entries)}
48238
+ if (json4) return `${jsonText(entries)}
48082
48239
  `;
48083
- return entries.map((e) => `${[e.vault.name, e.type, e.name, e.id].join(" ")}
48240
+ return entries.map((e) => `${[e.vault.name, e.type, e.name, e.id].map(sanitizeForDisplay).join(" ")}
48084
48241
  `).join("");
48085
48242
  }
48086
48243
 
@@ -48552,7 +48709,7 @@ async function allowCmd(patternArg, opts, deps) {
48552
48709
  async function grantsList(opts, deps) {
48553
48710
  const grants = await new GrantStore(await storeOf(deps), deps.now).list();
48554
48711
  if (opts.json) {
48555
- return `${JSON.stringify(grants.map((g) => ({ id: g.id, pattern: g.pattern, expiresAt: new Date(g.expiresAt).toISOString(), ...g.usesLeft !== void 0 ? { usesLeft: g.usesLeft } : {} })))}
48712
+ return `${jsonText(grants.map((g) => ({ id: g.id, pattern: g.pattern, expiresAt: new Date(g.expiresAt).toISOString(), ...g.usesLeft !== void 0 ? { usesLeft: g.usesLeft } : {} })))}
48556
48713
  `;
48557
48714
  }
48558
48715
  if (grants.length === 0) return `${t("msg_mcp_grants_none")}
@@ -48620,7 +48777,7 @@ async function machineSummary(deps) {
48620
48777
  }
48621
48778
  }
48622
48779
  function renderMachineSummary(summary, json4) {
48623
- if (json4) return `${JSON.stringify(summary)}
48780
+ if (json4) return `${jsonText(summary)}
48624
48781
  `;
48625
48782
  return `${[
48626
48783
  t("msg_machine_profile", { profile: summary.profile }),
@@ -69961,7 +70118,6 @@ var import_node_fs4 = require("node:fs");
69961
70118
  var import_node_os6 = __toESM(require("node:os"), 1);
69962
70119
 
69963
70120
  // src/lib/file-key-guardian.ts
69964
- var import_node_child_process2 = require("node:child_process");
69965
70121
  var import_node_crypto5 = require("node:crypto");
69966
70122
  var import_node_fs3 = require("node:fs");
69967
70123
  var import_crypto_wasm6 = __toESM(require_geslar_crypto_wasm(), 1);
@@ -69972,6 +70128,30 @@ var import_node_fs2 = require("node:fs");
69972
70128
  var import_node_os4 = __toESM(require("node:os"), 1);
69973
70129
  var import_node_path = __toESM(require("node:path"), 1);
69974
70130
  var import_crypto_wasm5 = __toESM(require_geslar_crypto_wasm(), 1);
70131
+
70132
+ // src/lib/win-acl.ts
70133
+ var import_node_child_process2 = require("node:child_process");
70134
+ function windowsAccount(env = process.env) {
70135
+ const user = env.USERNAME;
70136
+ if (!user) return null;
70137
+ const domain4 = env.USERDOMAIN;
70138
+ return domain4 ? `${domain4}\\${user}` : user;
70139
+ }
70140
+ function runIcacls(args) {
70141
+ return new Promise((resolve) => {
70142
+ (0, import_node_child_process2.execFile)("icacls", args, { windowsHide: true }, (err) => resolve(!err));
70143
+ });
70144
+ }
70145
+ var icaclsRestrictToCurrentUser = (filePath) => {
70146
+ const account = windowsAccount();
70147
+ return account ? runIcacls([filePath, "/inheritance:r", "/grant:r", `${account}:(F)`]) : Promise.resolve(false);
70148
+ };
70149
+ var icaclsRestrictDirToCurrentUser = (dirPath) => {
70150
+ const account = windowsAccount();
70151
+ return account ? runIcacls([dirPath, "/inheritance:r", "/grant:r", `${account}:(OI)(CI)(F)`]) : Promise.resolve(false);
70152
+ };
70153
+
70154
+ // src/lib/local-store.ts
69975
70155
  function stateDir(env = process.env, platform = process.platform, homedir = import_node_os4.default.homedir) {
69976
70156
  if (platform === "win32") {
69977
70157
  const base2 = env.LOCALAPPDATA ?? import_node_path.default.win32.join(homedir(), "AppData", "Local");
@@ -70041,10 +70221,31 @@ var LocalStore = class {
70041
70221
  origin;
70042
70222
  guardian;
70043
70223
  baseDir;
70044
- constructor(origin, guardian, baseDir = stateDir()) {
70224
+ opts;
70225
+ /** The Windows ACL of the state directory is applied ONCE per store, before the first record is written. */
70226
+ dirAclDone = false;
70227
+ constructor(origin, guardian, baseDir = stateDir(), opts = {}) {
70045
70228
  this.origin = origin;
70046
70229
  this.guardian = guardian;
70047
70230
  this.baseDir = baseDir;
70231
+ this.opts = opts;
70232
+ }
70233
+ /** Windows only: the whole state directory (session, unlock, agent profiles, mcp grants, the temp files of an
70234
+ * atomic write) is locked to the current user, same `icacls` mechanism as the key file. Done before the
70235
+ * first write, so a new file never exists with wider rights; an existing installation is repaired by its
70236
+ * next write (the files in the directory inherit the new ACL). Failure: one warning, the write goes on
70237
+ * (the inherited permissions of the user's profile remain), exactly like the key file. */
70238
+ async tightenDirAcl() {
70239
+ if (this.dirAclDone || (this.opts.platform ?? process.platform) !== "win32") return;
70240
+ this.dirAclDone = true;
70241
+ await import_node_fs2.promises.mkdir(this.baseDir, { recursive: true });
70242
+ let ok = false;
70243
+ try {
70244
+ ok = await (this.opts.restrictDirToCurrentUser ?? icaclsRestrictDirToCurrentUser)(this.baseDir);
70245
+ } catch {
70246
+ ok = false;
70247
+ }
70248
+ if (!ok && this.opts.warn && this.opts.warnAclMessage) this.opts.warn(this.opts.warnAclMessage);
70048
70249
  }
70049
70250
  /** R2 fixup — exposed so `unlocked-client.ts`'s shared
70050
70251
  * `validateUnlockHeader()` can compare a record's own `header.origin`
@@ -70081,6 +70282,7 @@ var LocalStore = class {
70081
70282
  try {
70082
70283
  const sealed = itemKey.seal(plaintext, recordAad(kind, this.origin, header));
70083
70284
  const envelope = { header, sealed: Buffer.from(sealed).toString("base64") };
70285
+ await this.tightenDirAcl();
70084
70286
  await writeFileAtomic(this.filePath(kind), JSON.stringify(envelope));
70085
70287
  } finally {
70086
70288
  itemKey.free();
@@ -70208,13 +70410,6 @@ function parseEnvelope(raw, origin) {
70208
70410
  }
70209
70411
  return e;
70210
70412
  }
70211
- var icaclsRestrictToCurrentUser = (filePath) => new Promise((resolve) => {
70212
- const user = process.env.USERNAME;
70213
- if (!user) return resolve(false);
70214
- const domain4 = process.env.USERDOMAIN;
70215
- const account = domain4 ? `${domain4}\\${user}` : user;
70216
- (0, import_node_child_process2.execFile)("icacls", [filePath, "/inheritance:r", "/grant:r", `${account}:(F)`], { windowsHide: true }, (err) => resolve(!err));
70217
- });
70218
70413
  var FileKeyGuardian = class {
70219
70414
  opts;
70220
70415
  /** Unlocked key, kept for the life of this (short-lived) process so one
@@ -70667,7 +70862,7 @@ async function openLocal(opts, purpose, deps = {}) {
70667
70862
  guardian = opened.guardian;
70668
70863
  mode = opened.mode;
70669
70864
  }
70670
- const store = new LocalStore(origin, guardian, baseDir);
70865
+ const store = new LocalStore(origin, guardian, baseDir, { platform: deps.platform, warn: notify, warnAclMessage: t("warn_state_dir_acl") });
70671
70866
  const sessions = new SessionStore(store);
70672
70867
  if (mode === "keychain") {
70673
70868
  try {
@@ -78844,8 +79039,8 @@ function registerListItems(server, backend) {
78844
79039
  const vault = resolveVault(me.vaults, query);
78845
79040
  const items = await backend.listItems(vault.id);
78846
79041
  const structured = {
78847
- vault: { id: vault.id, name: vault.name },
78848
- items: items.map((i) => ({ id: i.id, name: i.name, type: i.type, fields: STANDARD_FIELDS[i.type] ?? [] })).sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id))
79042
+ vault: { id: vault.id, name: sanitizeForDisplay(vault.name) },
79043
+ items: items.map((i) => ({ id: i.id, name: sanitizeForDisplay(i.name), type: i.type, fields: STANDARD_FIELDS[i.type] ?? [] })).sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id))
78849
79044
  };
78850
79045
  return { content: [{ type: "text", text: JSON.stringify(structured) }], structuredContent: structured };
78851
79046
  } catch (err) {
@@ -78871,7 +79066,7 @@ function registerListVaults(server, backend) {
78871
79066
  async () => {
78872
79067
  try {
78873
79068
  const me = await backend.me();
78874
- const structured = { vaults: me.vaults.map((v) => ({ id: v.id, name: v.name })) };
79069
+ const structured = { vaults: me.vaults.map((v) => ({ id: v.id, name: sanitizeForDisplay(v.name) })) };
78875
79070
  return { content: [{ type: "text", text: JSON.stringify(structured) }], structuredContent: structured };
78876
79071
  } catch (err) {
78877
79072
  return toToolError(err);
@@ -79422,7 +79617,7 @@ var TailCollector = class {
79422
79617
  /** Call once, after the stream ended. */
79423
79618
  end() {
79424
79619
  this.append(this.masker.end());
79425
- return redactTokenLike(this.tail.toString("utf8"));
79620
+ return sanitizeMultilineForDisplay(redactTokenLike(this.tail.toString("utf8")));
79426
79621
  }
79427
79622
  };
79428
79623
 
@@ -79457,7 +79652,7 @@ async function runChild(options) {
79457
79652
  const child = (0, import_node_child_process4.spawn)(options.command, [...options.args], {
79458
79653
  cwd: options.cwd,
79459
79654
  env: options.env,
79460
- shell: options.shell,
79655
+ shell: false,
79461
79656
  stdio: ["ignore", "pipe", "pipe"],
79462
79657
  detached: process.platform !== "win32",
79463
79658
  windowsHide: true
@@ -79658,10 +79853,7 @@ function registerRun(server, deps) {
79658
79853
  if (args.length > MAX_ARGS) throw new ToolInputError("too_many_arguments");
79659
79854
  const command = input2.command;
79660
79855
  if (typeof command !== "string" || command.length === 0 || command.length > 500 || CONTROL4.test(command)) throw new ToolInputError("invalid_command");
79661
- const bare = BARE_PROGRAM.test(command);
79662
- const shell = !bare;
79663
- if (shell && !deps.options.allowShell) throw new ToolInputError("invalid_command");
79664
- if (shell && args.length > 0) throw new ToolInputError("invalid_argument");
79856
+ if (!BARE_PROGRAM.test(command)) throw new ToolInputError("invalid_command");
79665
79857
  for (const a of args) if (a.length > MAX_ARG_LENGTH || a.includes("\0")) throw new ToolInputError("invalid_argument");
79666
79858
  if ([command, ...args, input2.cwd ?? ""].some((s) => s.toLowerCase().includes("geslar://"))) throw new ToolInputError("reference_not_allowed_here");
79667
79859
  if (Object.keys(input2.env ?? {}).length > MAX_ENV_ENTRIES) throw new ToolInputError("too_many_entries");
@@ -79677,7 +79869,7 @@ function registerRun(server, deps) {
79677
79869
  }
79678
79870
  const entries = lastWins([...fileEntries, ...inputEntries]);
79679
79871
  if (entries.length > MAX_ENV_ENTRIES) throw new ToolInputError("too_many_entries");
79680
- const argv = shell ? command.split(/ +/).filter((s) => s !== "") : [command, ...args];
79872
+ const argv = [command, ...args];
79681
79873
  if (!deps.grants || !await deps.grants.find(argv)) {
79682
79874
  const suggestion = allowCmdSuggestion(argv);
79683
79875
  return errorResult(
@@ -79691,7 +79883,7 @@ function registerRun(server, deps) {
79691
79883
  const program = import_node_path5.default.basename(argv[0]);
79692
79884
  for (const [vaultId, itemIds] of resolved.itemsByVault) {
79693
79885
  try {
79694
- await deps.backend.reportRun({ vaultId, itemIds, program: REPORTABLE_PROGRAM.test(program) ? program : "shell" });
79886
+ await deps.backend.reportRun({ vaultId, itemIds, program: REPORTABLE_PROGRAM.test(program) ? program : "program" });
79695
79887
  } catch {
79696
79888
  }
79697
79889
  }
@@ -79699,7 +79891,6 @@ function registerRun(server, deps) {
79699
79891
  const result = await runChild({
79700
79892
  command,
79701
79893
  args,
79702
- shell,
79703
79894
  cwd,
79704
79895
  env,
79705
79896
  timeoutMs: timeoutS * 1e3,
@@ -79752,11 +79943,11 @@ function registerWhoami(server, backend) {
79752
79943
  try {
79753
79944
  const me = await backend.me();
79754
79945
  const structured = {
79755
- profile: me.name,
79946
+ profile: sanitizeForDisplay(me.name),
79756
79947
  mode: me.mode,
79757
79948
  organizationId: me.organizationId,
79758
79949
  expiresAt: me.expiresAt,
79759
- vaults: me.vaults.map((v) => ({ id: v.id, name: v.name })),
79950
+ vaults: me.vaults.map((v) => ({ id: v.id, name: sanitizeForDisplay(v.name) })),
79760
79951
  approvals: me.approvals.map((a) => ({ id: a.id, vaultId: a.vaultId, expiresAt: a.expiresAt, usesLeft: a.usesLeft, itemCount: a.itemCount }))
79761
79952
  };
79762
79953
  return { content: [{ type: "text", text: JSON.stringify(structured) }], structuredContent: structured };
@@ -79774,7 +79965,7 @@ function createMcpServer(backend, options = {}) {
79774
79965
  root: options.root ?? process.cwd(),
79775
79966
  approvals: options.approvals ?? new ApprovalRequester(backend, Date.now, void 0, options.webUrl),
79776
79967
  grants: options.grants,
79777
- run: { allowShell: false, passEnv: [], returnStdoutTail: false, ...options.run }
79968
+ run: { passEnv: [], returnStdoutTail: false, ...options.run }
79778
79969
  };
79779
79970
  const server = new McpServer({ name: "geslar", version: CLI_VERSION });
79780
79971
  registerWhoami(server, backend);
@@ -79839,13 +80030,12 @@ async function runMcpServe(opts, deps = {}) {
79839
80030
  });
79840
80031
  const notify = deps.notify ?? ((message) => void process.stderr.write(`${message}
79841
80032
  `));
79842
- if (opts.allowShell) notify(t("warn_mcp_allow_shell"));
79843
80033
  if (opts.returnStdoutTail) notify(t("warn_mcp_return_tail"));
79844
80034
  const server = createMcpServer(backend, {
79845
80035
  root,
79846
80036
  webUrl: ctx.webUrl,
79847
80037
  grants: new GrantStore(ctx.store),
79848
- run: { allowShell: opts.allowShell === true, passEnv: parsePassEnv(opts.passEnv), returnStdoutTail: opts.returnStdoutTail === true },
80038
+ run: { passEnv: parsePassEnv(opts.passEnv), returnStdoutTail: opts.returnStdoutTail === true },
79849
80039
  sourceEnv: env,
79850
80040
  extra: deps.extraTools
79851
80041
  });
@@ -80331,6 +80521,7 @@ async function status(apiUrl, sessions, fetchImpl, store) {
80331
80521
 
80332
80522
  // src/commands/unlock.ts
80333
80523
  var MAX_ABSOLUTE_TTL_MS2 = 8 * 60 * 60 * 1e3;
80524
+ var UNLOCK_IDLE_SECONDS = 15 * 60;
80334
80525
  async function unlock(deps) {
80335
80526
  const session = await loadSession(deps.sessions);
80336
80527
  if (!session) throw notLoggedInError();
@@ -80388,7 +80579,7 @@ async function unlock(deps) {
80388
80579
  unlockedAt: new Date(unlockedAtMs).toISOString(),
80389
80580
  lastActivityAt: new Date(unlockedAtMs).toISOString(),
80390
80581
  expiresAt: new Date(expiresAtMs).toISOString(),
80391
- idleSeconds: 15 * 60
80582
+ idleSeconds: UNLOCK_IDLE_SECONDS
80392
80583
  };
80393
80584
  await deps.store.write("unlock", header, Buffer.from(rawRoot));
80394
80585
  } finally {
@@ -80442,77 +80633,6 @@ async function whoami(apiUrl, sessions, fetchImpl) {
80442
80633
  };
80443
80634
  }
80444
80635
 
80445
- // src/lib/cli-format.ts
80446
- function displayOrgName(organizationId, organizationName, organizationType) {
80447
- if (organizationType === "personal") return t("org_personal");
80448
- return organizationName ?? organizationId;
80449
- }
80450
- function authMethodLabel(authMethod) {
80451
- switch (authMethod) {
80452
- case "browser":
80453
- return t("auth_method_browser");
80454
- case "device":
80455
- return t("auth_method_device");
80456
- case "api-key":
80457
- return t("auth_method_apikey");
80458
- default:
80459
- return t("auth_method_unknown");
80460
- }
80461
- }
80462
- var COMMANDER_ERROR_KEYS = {
80463
- "commander.unknownCommand": "cmd_err_unknown_command",
80464
- "commander.unknownOption": "cmd_err_unknown_option",
80465
- "commander.missingArgument": "cmd_err_missing_argument",
80466
- "commander.optionMissingArgument": "cmd_err_option_missing_argument",
80467
- "commander.missingMandatoryOptionValue": "cmd_err_missing_mandatory_option",
80468
- "commander.invalidArgument": "cmd_err_invalid_argument",
80469
- "commander.conflictingOption": "cmd_err_conflicting_option"
80470
- };
80471
- function extractQuotedToken(message) {
80472
- const match = message.match(/'([^']*)'/);
80473
- return match ? match[1] : message;
80474
- }
80475
- var REFERENCE_FLAGS = /* @__PURE__ */ new Set(["-e", "--env", "-f", "--secrets-file"]);
80476
- function missingDoubleDash(token, ctx) {
80477
- if (ctx.platform !== "win32") return false;
80478
- const args = ctx.argv;
80479
- if (args.includes("--")) return false;
80480
- if (!args.includes("run") && !args.includes("inject")) return false;
80481
- const at = args.indexOf(token);
80482
- if (at <= 0) return false;
80483
- return args.slice(0, at).some((a) => REFERENCE_FLAGS.has(a) || a.includes("geslar://"));
80484
- }
80485
- function redactMachineTokens(text) {
80486
- return text.replace(/gsm_[A-Za-z0-9_-]{8,}/g, "gsm_\u2026");
80487
- }
80488
- function localizeCommanderMessage(err, ctx) {
80489
- return redactMachineTokens(localizeCommanderMessageRaw(err, ctx));
80490
- }
80491
- function localizeCommanderMessageRaw(err, ctx) {
80492
- const key = COMMANDER_ERROR_KEYS[err.code];
80493
- if (!key) return err.message;
80494
- const arg = extractQuotedToken(err.message);
80495
- const message = t(key, { arg });
80496
- if (ctx && err.code === "commander.unknownOption" && missingDoubleDash(arg, ctx)) {
80497
- return [message, t("hint_powershell_double_dash")].join("\n");
80498
- }
80499
- return message;
80500
- }
80501
- function formatLocalTime(iso) {
80502
- return new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit", hour12: false }).format(new Date(iso));
80503
- }
80504
- function minutesUntil(iso, nowMs) {
80505
- return Math.max(0, Math.ceil((Date.parse(iso) - nowMs) / 6e4));
80506
- }
80507
- function formatVaultUnlockedLine(result, nowMs = Date.now()) {
80508
- const effectiveMs = Date.parse(result.unlockExpiresAt);
80509
- const absoluteMs = Date.parse(result.unlockAbsoluteExpiresAt);
80510
- if (effectiveMs < absoluteMs) {
80511
- return t("status_line_vault_unlocked_idle", { idle: minutesUntil(result.unlockExpiresAt, nowMs), time: formatLocalTime(result.unlockAbsoluteExpiresAt) });
80512
- }
80513
- return t("status_line_vault_unlocked_absolute", { time: formatLocalTime(result.unlockAbsoluteExpiresAt) });
80514
- }
80515
-
80516
80636
  // src/index.ts
80517
80637
  async function runCommand(fn) {
80518
80638
  try {
@@ -80675,7 +80795,7 @@ function buildProgram() {
80675
80795
  sessions: ctx.sessions
80676
80796
  };
80677
80797
  };
80678
- agent.command("add").description(t("agent_add_desc")).argument("<name>", "profile name").option("--stdin", t("opt_stdin")).allowExcessArguments(true).action(async (name, opts, command) => {
80798
+ agent.command("add").description(t("agent_add_desc")).argument("<name>", "profile name").option("--stdin", t("opt_agent_stdin")).allowExcessArguments(true).action(async (name, opts, command) => {
80679
80799
  await runCommand(async () => {
80680
80800
  refuseWithAgent(agentName());
80681
80801
  if (command.args.length > 1) throw new CliError(t("err_agent_token_not_arg"), 1 /* GENERAL */);
@@ -80742,13 +80862,12 @@ function buildProgram() {
80742
80862
  });
80743
80863
  });
80744
80864
  const mcp = program.command("mcp").description(t("mcp_desc"));
80745
- mcp.command("serve").description(t("mcp_serve_desc")).option("--agent <name>", t("opt_mcp_agent")).option("--root <dir>", t("opt_mcp_root")).option("--allow-shell", t("opt_mcp_allow_shell")).option("--pass-env <names>", t("opt_mcp_pass_env")).option("--return-stdout-tail", t("opt_mcp_return_tail")).action(async (opts) => {
80865
+ mcp.command("serve").description(t("mcp_serve_desc")).option("--agent <name>", t("opt_mcp_agent")).option("--root <dir>", t("opt_mcp_root")).option("--pass-env <names>", t("opt_mcp_pass_env")).option("--return-stdout-tail", t("opt_mcp_return_tail")).action(async (opts) => {
80746
80866
  await runCommand(async () => {
80747
80867
  const global2 = program.opts();
80748
80868
  process.exitCode = await mcpServe({
80749
80869
  agent: opts.agent ?? global2.agent,
80750
80870
  root: opts.root,
80751
- allowShell: opts.allowShell,
80752
80871
  passEnv: opts.passEnv,
80753
80872
  returnStdoutTail: opts.returnStdoutTail,
80754
80873
  keyStorage: global2.keyStorage,
@@ -80798,7 +80917,7 @@ function buildProgram() {
80798
80917
  }
80799
80918
  const result = await whoami(apiUrl, sessions);
80800
80919
  if (opts.json) {
80801
- process.stdout.write(`${JSON.stringify(result)}
80920
+ process.stdout.write(`${jsonText(result)}
80802
80921
  `);
80803
80922
  } else {
80804
80923
  process.stdout.write(`${t("whoami_line_email", { email: result.email })}
@@ -80831,7 +80950,7 @@ function buildProgram() {
80831
80950
  }
80832
80951
  const result = await status(apiUrl, sessions, void 0, store);
80833
80952
  if (opts.json) {
80834
- process.stdout.write(`${JSON.stringify(result)}
80953
+ process.stdout.write(`${jsonText(result)}
80835
80954
  `);
80836
80955
  } else if (!result.loggedIn) {
80837
80956
  if (result.loggedOutReason === "key_invalid_or_expired") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geslar/cli",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0",
4
4
  "description": "Geslar command-line client: sign in, read secrets and run commands with secrets injected.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://geslar.app",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "scripts": {
23
23
  "typecheck": "tsc --noEmit",
24
- "test": "node --import tsx --import ./tests/setup.mjs --test tests/unit/*.test.ts",
24
+ "test": "node --import tsx --import ./tests/setup.mjs --test --test-concurrency=2 tests/unit/*.test.ts",
25
25
  "test:keychain-real": "node --import tsx --test tests/keychain-real/*.test.ts",
26
26
  "build": "node scripts/build.mjs && node scripts/third-party.mjs licenses",
27
27
  "build:test": "node scripts/build.mjs --smoke-only",