@ai-ecoverse/slicc-agent 7.34.0 → 7.34.2

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
@@ -408,7 +408,7 @@ MCP servers reachable over Streamable HTTP become native agent tools. The client
408
408
 
409
409
  **Per agent.** Every cone gets every enabled server from the one file above: `/etc/slicc/agent/mcp.json` with users on, `/home/.pi/agent/mcp.json` with users off. A scoop doesn't read a file of its own: it inherits its cone's servers, and a role's `tools:` or `agent --tools` list narrows them. A list with no `mcp__` entry gets no MCP servers. A list with `mcp__docs__search` or `mcp__docs__*` keeps only those, and `codemode` is added so codemode tools stay reachable. The resource tools must be listed by name, and they reach only the servers the list names. A nested scoop without a list inherits its calling scoop's list. A `beforeTool` hook blocks the model's calls outside the list, and codemode scripts only get the tools on it.
410
410
 
411
- **Secrets.** `${NAME}` placeholders resolve to the vault's placeholders for that server (`records()`: an `mcp` record with `server` equal to the `mcp.json` key and that name, else the server's only record when the headers use one name, else an unbound record of that name, which covers mcpcat's `${MCP_<NAME>_TOKEN}` bridge tokens). The headers go out holding placeholders, and the vault fills them in its `mcp` op, only for that server's registered URL. The headers are passed to the vault and on to the kernel's transport as data, never through a browser `Request`, so a forbidden request header such as `Cookie` isn't dropped on the way; whether it then reaches the server is up to the transport's route (the page's own fetch drops it, see slicc-kernel#1796). A server whose record is missing comes up as needing one, with a lick, and reconnects when the record appears. The worker never holds a value; server log lines are scrubbed through the vault before they reach `~/.pi/agent/mcp.log`. **OAuth.** A server without an `Authorization` header that answers 401 needs a sign-in, as in pi. Its row in Settings › MCP servers offers Connect, which opens a held pop-up (`slicc-mcp-oauth`, see **Held sign-in windows**) on the authorization server, found through the server's protected-resource metadata (RFC 9728) or `oauth.authServerMetadataUrl`. SLICC registers itself dynamically as a public client named `SLICC` (`oauth.clientName` changes it), or uses `oauth.clientId`, with PKCE S256 and the redirect URI `https://<origin>/oauth/mcp-callback`. slicc-bios serves that path from `dist/oauth/mcp-callback.html` in this package. The callback page hands the code back over the `slicc-mcp-oauth` BroadcastChannel and clears it from its address. Before the pop-up opens, the worker registers the server's `tokenUrl` (the discovered `token_endpoint`, else `<authServer>/token`) with the vault. It exchanges the code, checking `state` and `iss`, as a prepared `mcp` request to that `tokenUrl`, and hands the token response straight to the vault's `grant`; the raw response is dropped, and pi-mcp keeps only the reply, which holds placeholders, with the client and discovery state in `/.slicc/accounts.json` under the server's name and URL. When the server answers 401, the worker asks the vault to `refresh` once and sends again; pi-mcp's own refresh is off, because the refresh token is a placeholder. When that fails, the row shows the sign-in as expired. Disconnect deletes the local state; spectrum removes the vault records. Without a vault, the exchange is refused ("MCP sign-in needs seven's vault: update seven") before any token is issued. `oauth.scope` sets the scopes, else the server's advertised ones are used. `clientSecret`, `callbackPort`, `callbackUrl` and `clientRegistration` are refused, because SLICC signs in as a public client through its own page.
411
+ **Secrets.** `${NAME}` placeholders resolve to the vault's placeholders for that server (`records()`: an `mcp` record with `server` equal to the `mcp.json` key and that name, else the server's only record when the headers use one name, else an unbound record of that name, which covers mcpcat's `${MCP_<NAME>_TOKEN}` bridge tokens). The headers go out holding placeholders, and the vault fills them in its `mcp` op, only for that server's registered URL. The headers are passed to the vault and on to the kernel's transport as data, never through a browser `Request`, so a forbidden request header such as `Cookie` isn't dropped on the way; whether it then reaches the server is up to the transport's route (the page's own fetch drops it, see slicc-kernel#1796). A server whose record is missing comes up as needing one, with a lick, and reconnects when the record appears. The worker never holds a value; server log lines are scrubbed through the vault before they reach `~/.pi/agent/mcp.log`. **OAuth.** A server without an `Authorization` header that answers 401 needs a sign-in, as in pi. Its row in Settings › MCP servers offers Connect, which opens a held pop-up (`slicc-mcp-oauth`, see **Held sign-in windows**) on the authorization server, found through the server's protected-resource metadata (RFC 9728) or `oauth.authServerMetadataUrl`. SLICC registers itself dynamically as a public client named `SLICC` (`oauth.clientName` changes it), or uses `oauth.clientId`, with PKCE S256 and the redirect URI `https://<origin>/oauth/mcp-callback`. slicc-bios serves that path from `dist/oauth/mcp-callback.html` in this package. The callback page hands the code back over the `slicc-mcp-oauth` BroadcastChannel and clears it from its address only when its `state` has a `slicc-mcp-oauth:<state>` key in `localStorage`, which SLICC writes when it starts the sign-in; for any other answer it says no sign-in from SLICC was waiting, broadcasts nothing, stays open and keeps its address, so a sign-in started elsewhere can still copy the code from it. It never shows the code. Before the pop-up opens, the worker registers the server's `tokenUrl` (the discovered `token_endpoint`, else `<authServer>/token`) with the vault. It exchanges the code, checking `state` and `iss`, as a prepared `mcp` request to that `tokenUrl`, and hands the token response straight to the vault's `grant`; the raw response is dropped, and pi-mcp keeps only the reply, which holds placeholders, with the client and discovery state in `/.slicc/accounts.json` under the server's name and URL. When the server answers 401, the worker asks the vault to `refresh` once and sends again; pi-mcp's own refresh is off, because the refresh token is a placeholder. When that fails, the row shows the sign-in as expired. Disconnect deletes the local state; spectrum removes the vault records. Without a vault, the exchange is refused ("MCP sign-in needs seven's vault: update seven") before any token is issued. `oauth.scope` sets the scopes, else the server's advertised ones are used. `clientSecret`, `callbackPort`, `callbackUrl` and `clientRegistration` are refused, because SLICC signs in as a public client through its own page.
412
412
 
413
413
  **Settings › MCP servers** lists every server in the file, under its own heading below Accounts, with the URL host. A row's `state` says what it's doing: `connecting`, `connected`, `needs-secret`, `needs-auth` or `failed`, or `disabled` (`enabled: false`) and `refused` (the entry's check failed; the warn lick says why, `refusals()` below gives the owner the same sentence, and the row's only action is Remove). A server that needs nothing has `auth: 'local'` and no Connect; it turns into an `oauth` row with Connect if it answers 401. **Adding and removing.** `addServer(name, entry)` and `removeServer('mcp:<server>')` on the settings service are for the owner's page only: a view-only or control seat gets `{ ok: false, code: 'not-owner', reason }`, a guest has no settings service, and the spectrum adapter offers them only on the owner's connection. No tool or kernel command reaches them, so an agent still needs `sudo` to change the file. Both answer `{ ok: true }` or `{ ok: false, code, reason }`, where `code` is a stable `McpRefusalCode` from `src/services.ts`, for a page to act on, and `reason` is the sentence to show. `refusals()`, also the owner's alone (other seats and guests get `EACCES`, and an agent without MCP answers `{}`), answers `{ [server]: { code, reason } }` for the entries refused in the file, with no URL, header value or secret. `entry` goes through the same checks as reading the file, so a stdio or `type: "sse"` entry, a literal secret, or a URL with a password or key returns the reason and writes nothing, and so does a name that's taken. `token: true` writes `Authorization: Bearer ${MCP_<NAME>_TOKEN}` (`<NAME>` in upper case with anything else as `_`, the name mcpcat and jerk use), so the row offers Connect like any token server; without it, the server signs in through the OAuth path above if it answers 401. The other servers and unknown fields stay. A file that doesn't parse or can't be read is refused, with the reason, and never overwritten. The write goes to a `0600` temporary file beside it and is renamed over it, and the file watch does the rest. `removeServer` also forgets the server's local OAuth state; the vault's records and the page's endpoint registration are the page's to clear, as on Disconnect. The page can ask for a server's URL, the `mcp.json` URL without user name, password, query or fragment, with `serverUrl('mcp:<server>')`, so it can register it with the vault (its `endpoints` op) before it connects a token it put there; from slicc-vault 1.13.0 a page-sealed token is filled only on a URL the page registered. The URL is never in the replicated settings state, since a path can carry a token and view-only principals read that state; `serverUrl` is a settings method, which view-only principals don't get, and it answers `null` for model accounts. The spectrum adapter fills each MCP account's `url` from it. Connect takes the token, which fills every placeholder of a server that uses one name; a server whose headers use several different names can't be filled from Settings yet. The server then reconnects. A server that answers 401 shows as **Rejected**, with Reconnect, and Disconnect deletes the token. Tool cards and remote summaries label MCP calls `server · tool`, unless the name is ambiguous (a server name that starts or ends with `_`, or a name with more than two `__` separators); then they show the raw name.
414
414
 
@@ -897,8 +897,9 @@ The agent worker never holds a secret's value. Values live in the vault (`vault.
897
897
  - **The listing**, read in the home env at start and whenever `version` changes (pi-fnox's `fnox export`; nothing goes into the worker's environment), joins three commands by name, none of which prints a value:
898
898
  - `fnox env --json --describe` gives the fnox config's keys (`kind: "secret"`), which are the `$NAME`s bash sees. It runs only with `--describe`: without it fnox prints values, so every command goes through one guard that refuses `fnox env` without `--describe`. `--for exec|shell` isn't passed, since fnox 1.39 ignores it when describing (both print the same keys).
899
899
  - the vault's own `list` op on `/dev/sealed` (`exec 3<>/dev/sealed`, write `{"v":1,"op":"list"}`, read the reply) gives each sealed secret's placeholder, its `[exec]` mode from `/etc/slicc/secrets-policy.toml` and the rules the vault accepted. fnox's describe output has no placeholders, and the agent port's `records` has no `secret` records.
900
- - `fnox proxy rules --json` gives the config's `[[proxy.rules]]`, shown as proposed for a secret the vault has no accepted rule for. A config without `[proxy]` (exit 1, "No [proxy] configuration found") has no rules.
900
+ - `fnox proxy rules --json` gives the config's `[[proxy.rules]]`, shown for a secret the vault uses no rule of, each marked `in the fnox config but not in effect`. A config without `[proxy]` (exit 1, "No [proxy] configuration found") has no rules.
901
901
  - **Shown as:** `- NAME = <placeholder>: <rules>; in every bash` for a sealed secret; a fnox key the vault doesn't hold reads `- NAME = $NAME: not sealed` (a plain fnox secret), and a sealed secret the config lacks says `not in the fnox config`.
902
+ - **No accept step.** The owner accepts a rule by approving the `sudo` that writes `/etc/fnox/config.toml`; nothing else in seven, Settings included, accepts or proposes rules. bios hands the vault the file whenever it changes, and the vault uses its rules at once while the file is trusted (root-owned, not writable by group or others, under root-owned directories, kernel users `enforce`) and the secret's `[secrets]` entry holds the secret's own placeholder, `NAME = { provider = "seven", value = "<placeholder>" }` (`sealed placeholder NAME` prints it). An entry without `value` is ignored with every rule naming it, though `fnox check` passes and `fnox proxy rules` lists the rules, and requests are then refused `no-rule` (bios's sentence, which asks for a rule). The vault's warning (`GITHUB_PAT: its value isn't a vault placeholder`) goes only to its `status.policy`, which Settings › Secrets doesn't show yet, so the section says it instead: a sealed secret whose rules are all only in the config gets `the vault uses none of these rules yet, and there is nothing for the user to accept: …` with the entry it needs, and points at `sealed list --json`, which shows the rules the vault uses now, since the listing is read only at start and when the vault's values change. `fnox set NAME --ask` writes its entry to `fnox.toml` in the current directory, which the vault never reads, so the section says to copy the entry into `/etc/fnox/config.toml` with sudo (#957).
902
903
  - **Failures are loud.** When fnox is missing (exit 127), a command exits non-zero, `/dev/sealed` fails or a reply doesn't parse, the `secrets` section is "Secrets are unavailable: <reason>.", `/secrets` says the same, and the worker logs one `slicc-secrets: secrets are unavailable: <reason>` line until the reason changes. The reason is a fixed sentence: fnox's error `kind` (`config` reads "the fnox config has an error; check /etc/fnox/config.toml") or the vault's error `code`, never their message, since fnox quotes the offending config line and a plain secret's value can sit on it, which the vault's scrub doesn't know. The message goes only to that log line, redacted by the vault and cut to 200 characters. stderr is never read. Only a config with no keys and a vault with no sealed secrets shows "No secrets are configured".
903
904
  - **Shell grants stay off while fnox would hand out unsealed values.** `fnox exec` also sets every config secret it may inject (`injectable.exec`, which is `env = true` and `env = "exec"`), and a plain or age secret's value isn't one the vault scrubs. So while any such key isn't in the vault's list, the wrapper isn't used, the section and `/secrets` say "Shell grants are off: fnox exec would also give every command the unsealed fnox secrets <names>; seal them or set env = false for them.", and one line is logged.
904
905
  - **Prefer argv over shell.** In `/etc/slicc/secrets-policy.toml`, a secret used by one program should be `[exec] NAME = { argv = [["/absolute/program", …]] }` (or `true` / `any` when every non-shell program may see it). `{ shell = true }` is only for secrets every conversation command needs: while any listed secret has that grant, every bash runs as `fnox exec --shell-grants -- <argv>` and the vault reveals all shell-granted values to it. The agent never chooses the set; narrow policy instead of asking the model to pick env vars.
@@ -908,7 +909,7 @@ The agent worker never holds a secret's value. Values live in the vault (`vault.
908
909
  - **In spectrum.** The agent port's `hold()` is `{ reason: 'locked', held }` while the vault needs a passkey, `{ reason: 'waiting', held }` while scrubbing is needed and the port isn't `ready`, and `null` otherwise, with a `hold` event on each change (and `null` when it clears); spectrum (≥ 1.62.0) shows it above the composer, and older spectrum ignores it. While a hold is up, the worker's active cone is busy (`working` when it isn't running), so the composer steers and queues; a send made during the hold waits in the tab, shown in that cone's queue, and goes to the worker once the hold clears; removing it before then means it's never sent. `/secrets` entries (`slicc.secrets`) show as a "Secrets listed" notice, or "Secrets unavailable" with the reason.
909
910
  - **The 3.x store is wiped.** 3.x kept model and MCP keys in the IndexedDB database `slicc-agent-credentials`; 4.x doesn't migrate them. At start, before any model call, the worker reads only that database's record keys (never decrypting), deletes it, and keeps the accounts it found (`adobe` as Adobe, `amazon-bedrock` as Bedrock, `mcp:<server>|…` as the server, anything else by its providerId) in the session document `slicc.keys-moved`. A missing database, or no `indexedDB`, does nothing. The worker waits up to 3 s for the delete and claims the keys moved only once it succeeds. A delete blocked by an open 3.x tab shows no notice yet: if it succeeds later in the session (the tab closes) its accounts are added then, and otherwise the next start tries again. A delete that fails reports nothing. Once the vault's records are read, the accounts still without a record are the settings state's `moved`, and the spectrum adapter's `notices` port shows one notice, with model accounts first and MCP servers grouped after them: "Your keys moved to seven's vault. Add them again in Settings › Accounts: Adobe, Bedrock; MCP servers: github, jira." (or "…, and the MCP server github" for one). Dismissing it calls `AgentSettings.dismissMoved`, which marks the document, so it stays dismissed across reloads. An account without a record reads not connected. A model call that finds no credential ("Provider is not configured", "No API key") leads with "Adobe isn't connected." or "Bedrock isn't connected.", with "Connect it in Settings › Accounts." underneath instead of the raw error, and opens settings, and a send whose run finds no model because its account isn't connected (Adobe lists models only once signed in) shows the same error. "Your Adobe session has expired." is kept for a 401 from a token that exists. The settings state's `labels` names every model of a provider without a record from the agent's catalogue ("Claude Haiku 4.5 (US) on Bedrock"), and the adapter puts that name in the header of a reply whose model isn't in the picker, instead of the raw id.
910
911
  - **For bios:** the agent's `notices` (keys moved) would replace bios's own port in `{ ...bios, ...createAgentModel(connection) }`, so pass that port in instead, as `createAgentModel(connection, { notices: biosPort })`. The returned port lists bios's notices and then the agent's, sends `act` and `dismiss` to whichever port listed the id (never dismissing one with `dismissible: false`), and passes on both ports' `notices` events. Without the option, it lists only the agent's.
911
- - **Tests.** The worker never compiles values: `src/` takes only `import type { Hit }` from [`@ai-ecoverse/slicc-scrub`](https://www.npmjs.com/package/@ai-ecoverse/slicc-scrub), the vault's scrubber, and the package is a devDependency. [`@ai-ecoverse/slicc-vault`](https://www.npmjs.com/package/@ai-ecoverse/slicc-vault) is a devDependency for `npm run lint:vault-pi` only (the agent does not import it). The fake vault the tests use scrubs with that package, and its `vectors.json` (every form, line-wrapped base64 and hex included) runs through each scrub point and each cut. A suite-wide check asserts that no captured model request, entry, slot or memory file holds any form of a seeded value. `test/integration/secrets-fnox.test.mjs` runs the listing on the page kernel with `@ai-ecoverse/wasi-fnox` (a devDependency) and the fake vault's `/dev/sealed` side (`fakeSealed`: `list`, `placeholder`, `materialize`, `materializeConsume` and `ask`): a sealed secret in the section and `/secrets`, a shell grant reaching a command through `fnox exec --shell-grants`, shell grants kept off by an unsealed `env = true` secret, fnox missing, fnox exiting non-zero on a config error that quotes a plain value (which never reaches the prompt, `/secrets` or the transcript), an empty config, and the kernel's `sealed ask` (slicc-kernel 1.175 on): a revealed value reaches the command while the transcript and every model request hold only its placeholder, and a cancelled ask exits 1; and `fnox set NAME --ask` (wasi-fnox 1.45.0-2 on), which seals what the user typed and prints only its placeholder.
912
+ - **Tests.** The worker never compiles values: `src/` takes only `import type { Hit }` from [`@ai-ecoverse/slicc-scrub`](https://www.npmjs.com/package/@ai-ecoverse/slicc-scrub), the vault's scrubber, and the package is a devDependency. [`@ai-ecoverse/slicc-vault`](https://www.npmjs.com/package/@ai-ecoverse/slicc-vault) is a devDependency for `npm run lint:vault-pi` only (the agent does not import it). The fake vault the tests use scrubs with that package, and its `vectors.json` (every form, line-wrapped base64 and hex included) runs through each scrub point and each cut. A suite-wide check asserts that no captured model request, entry, slot or memory file holds any form of a seeded value. `test/integration/secrets-fnox.test.mjs` runs the listing on the page kernel with `@ai-ecoverse/wasi-fnox` (a devDependency) and the fake vault's `/dev/sealed` side (`fakeSealed`: `list`, `placeholder`, `materialize`, `materializeConsume` and `ask`): a sealed secret in the section and `/secrets`, a shell grant reaching a command through `fnox exec --shell-grants`, shell grants kept off by an unsealed `env = true` secret, fnox missing, fnox exiting non-zero on a config error that quotes a plain value (which never reaches the prompt, `/secrets` or the transcript), an empty config, and the kernel's `sealed ask` (slicc-kernel 1.175 on): a revealed value reaches the command while the transcript and every model request hold only its placeholder, and a cancelled ask exits 1; `fnox set NAME --ask` (wasi-fnox 1.45.0-2 on), which seals what the user typed and prints only its placeholder; and a sealed secret whose `[secrets]` entry has no `value`, whose rules the section shows as not in effect with the entry the vault needs, while `fnox set --ask` writes `./fnox.toml` and leaves `/etc/fnox/config.toml` alone.
912
913
 
913
914
  ## The kernel
914
915
 
@@ -49,6 +49,9 @@
49
49
  [data-state="failed"] .mark {
50
50
  background: var(--bad);
51
51
  }
52
+ [data-state="unknown"] .mark {
53
+ background: var(--muted);
54
+ }
52
55
  h1 {
53
56
  font-size: 1.25rem;
54
57
  margin: 0 0 0.5rem;
@@ -80,7 +83,6 @@
80
83
  const answer = {};
81
84
  for (const key of ['code', 'state', 'iss', 'error', 'error_description'])
82
85
  if (params.has(key)) answer[key] = params.get(key);
83
- history.replaceState(null, '', location.pathname);
84
86
  const main = document.querySelector('main');
85
87
  const show = (state, title, text, mark) => {
86
88
  main.dataset.state = state;
@@ -88,8 +90,14 @@
88
90
  main.querySelector('p').textContent = text;
89
91
  main.querySelector('.mark').textContent = mark;
90
92
  };
91
- const named = answer.state ? localStorage.getItem(`slicc-mcp-oauth:${answer.state}`) : null;
92
- const where = named ? ` to ${named}` : '';
93
+ const named = (() => {
94
+ if (!answer.state) return null;
95
+ try {
96
+ return localStorage.getItem(`slicc-mcp-oauth:${answer.state}`);
97
+ } catch {
98
+ return null;
99
+ }
100
+ })();
93
101
  if (!answer.state)
94
102
  show(
95
103
  'failed',
@@ -97,7 +105,19 @@
97
105
  'This page only works as the end of a sign-in from SLICC.',
98
106
  '!'
99
107
  );
100
- else {
108
+ else if (named === null) {
109
+ const said = answer.error
110
+ ? `The authorization server answered: ${answer.error_description ?? answer.error}. `
111
+ : '';
112
+ show(
113
+ 'unknown',
114
+ 'No sign-in from SLICC was waiting for this',
115
+ `${said}SLICC didn't start this sign-in, so nothing was handed over. The full address is still in the address bar if you need to copy it.`,
116
+ '?'
117
+ );
118
+ } else {
119
+ const where = named ? ` to ${named}` : '';
120
+ history.replaceState(null, '', location.pathname);
101
121
  new BroadcastChannel('slicc-mcp-oauth').postMessage(answer);
102
122
  if (answer.error)
103
123
  show('failed', `Couldn't sign in${where}`, answer.error_description ?? answer.error, '!');
@@ -9,8 +9,8 @@ import { exposedLine, listedLine, SECRETS_KIND, unavailableLine } from "./view.j
9
9
  const SECRETS = "slicc-secrets";
10
10
  const SECRETS_COMMAND = "/secrets";
11
11
  const SHELL_GRANTS = ["fnox", "exec", "--shell-grants", "--"];
12
- const MODEL_LINE = "Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo, which the user approves. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as 'in every bash' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [[\"/absolute/program\"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.";
13
- const ASK_LINE = "When a secret you need is missing, ask the user for it: `fnox set NAME --ask` adds it to the fnox config, and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.";
12
+ const MODEL_LINE = 'Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo: the user approving that sudo is the only acceptance there is, and the vault uses the rules in it as soon as it is written (`sealed list --json` shows the rules it uses now; the list below is read at start and can lag behind). It uses the rules of a secret only while the file is root-owned and not writable by others, and its `[secrets]` entry holds the placeholder of that secret: `NAME = { provider = "seven", value = "<placeholder>" }` (`sealed placeholder NAME` prints it); without the `value` the vault ignores the entry and every rule naming it, though `fnox check` passes. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as \'in every bash\' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [["/absolute/program"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.';
13
+ const ASK_LINE = "When a secret you need is missing, ask the user for it: `fnox set NAME --ask` seals it and writes its entry to `fnox.toml` in the current directory, which the vault doesn't read (copy the entry into `/etc/fnox/config.toml` with sudo before adding its rules there), and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.";
14
14
  function leaves(value, out, set) {
15
15
  if (typeof value === "string") {
16
16
  out.push({ get: () => value, set });
@@ -73,6 +73,7 @@ async function scrubResult(result, scrub) {
73
73
  ...output === void 0 ? {} : { structuredOutput: output }
74
74
  };
75
75
  }
76
+ const unusedLine = (name, placeholder) => `the vault uses none of these rules yet, and there is nothing for the user to accept: it takes rules only from a root-owned \`/etc/fnox/config.toml\` whose \`[secrets]\` entry is \`${name} = { provider = "seven", value = "${placeholder}" }\`; fix the file with sudo, then \`sealed list --json\` shows the rules the vault uses`;
76
77
  function where(name, granted) {
77
78
  const rules = name.rules.map(
78
79
  (rule) => [
@@ -80,13 +81,14 @@ function where(name, granted) {
80
81
  rule.header ? `header ${rule.header}` : "",
81
82
  rule.methods?.length ? rule.methods.join(" ") : "",
82
83
  rule.paths?.length ? rule.paths.join(" ") : "",
83
- rule.proposed ? "proposed in the fnox config, not yet accepted by the vault" : ""
84
+ rule.proposed ? "in the fnox config but not in effect" : ""
84
85
  ].filter(Boolean).join(", ")
85
86
  );
87
+ const idle = name.placeholder !== null && name.rules.some((rule) => rule.proposed) ? [unusedLine(name.name, name.placeholder)] : [];
86
88
  const shell = name.exec === "shell" && granted ? ["in every bash"] : [];
87
89
  const sealed = name.placeholder === null ? ["not sealed"] : [];
88
90
  const config = name.fnox ? [] : ["not in the fnox config"];
89
- const parts = [...rules, ...shell, ...sealed, ...config];
91
+ const parts = [...rules, ...idle, ...shell, ...sealed, ...config];
90
92
  return parts.length ? `: ${parts.join("; ")}` : "";
91
93
  }
92
94
  const NO_SECRETS = "No secrets are configured: the fnox config has no keys and the vault no sealed secrets.";
@@ -148,6 +150,7 @@ export {
148
150
  secretsEntry,
149
151
  secretsExtension,
150
152
  shellGrants,
151
- unavailableLine
153
+ unavailableLine,
154
+ unusedLine
152
155
  };
153
156
  //# sourceMappingURL=extension.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/secrets/extension.ts"],
4
- "sourcesContent": ["import type { JsonValue } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n GenerationTask,\n hook,\n section,\n type ToolExecutionResult,\n ToolTask,\n} from '@earendil-works/pi-durable';\nimport type { Names, SecretListing, SecretName } from './names.ts';\nimport type { Scrub } from './scrub.ts';\nimport type { Vault } from './vault.ts';\nimport { exposedLine, listedLine, SECRETS_KIND, unavailableLine } from './view.ts';\n\nexport { exposedLine, listedLine, SECRETS_KIND, unavailableLine };\n\nexport const SECRETS = 'slicc-secrets';\nexport const SECRETS_COMMAND = '/secrets';\nexport const SHELL_GRANTS = ['fnox', 'exec', '--shell-grants', '--'] as const;\n\nexport const MODEL_LINE =\n 'Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo, which the user approves. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as \\'in every bash\\' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [[\"/absolute/program\"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.';\n\nexport const ASK_LINE =\n \"When a secret you need is missing, ask the user for it: `fnox set NAME --ask` adds it to the fnox config, and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.\";\n\ntype Leaf = { get(): string; set(text: string): void };\n\nfunction leaves(value: JsonValue, out: Leaf[], set: (next: JsonValue) => void): void {\n if (typeof value === 'string') {\n out.push({ get: () => value, set });\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, at) => {\n leaves(item, out, (next) => {\n value[at] = next;\n });\n });\n return;\n }\n if (value && typeof value === 'object')\n for (const [key, item] of Object.entries(value))\n leaves(item as JsonValue, out, (next) => {\n (value as Record<string, JsonValue>)[key] = next;\n });\n}\n\nexport async function scrubResult(\n result: ToolExecutionResult,\n scrub: Pick<Scrub, 'texts'>\n): Promise<ToolExecutionResult | undefined> {\n const content = [...(result.output ?? [])];\n const diagnostics = [...(result.diagnostics ?? [])];\n const copy = (value: JsonValue | undefined) =>\n value === undefined ? undefined : (structuredClone(value) as JsonValue);\n const details = copy(result.details);\n const structured = copy(result.structuredOutput);\n const found: Leaf[] = [];\n content.forEach((item, at) => {\n if (item.type === 'text')\n found.push({ get: () => item.text, set: (text) => void (content[at] = { ...item, text }) });\n });\n diagnostics.forEach((item, at) => {\n found.push({\n get: () => item.message,\n set: (message) => void (diagnostics[at] = { ...item, message }),\n });\n });\n let replaced = details;\n if (details !== undefined)\n leaves(details, found, (next) => {\n replaced = next;\n });\n let output = structured;\n if (structured !== undefined)\n leaves(structured, found, (next) => {\n output = next;\n });\n const before = found.map((leaf) => leaf.get());\n const after = await scrub.texts(before);\n if (after.every((text, at) => text === before[at])) return undefined;\n found.forEach((leaf, at) => {\n leaf.set(after[at] as string);\n });\n const kept = result.output as ToolExecutionResult['output'] & unknown[];\n if (kept) kept.splice(0, kept.length, ...content);\n return {\n ...result,\n ...(kept ? { output: kept } : {}),\n ...(result.diagnostics ? { diagnostics } : {}),\n ...(replaced === undefined ? {} : { details: replaced }),\n ...(output === undefined ? {} : { structuredOutput: output }),\n };\n}\n\nfunction where(name: SecretName, granted: boolean): string {\n const rules = name.rules.map((rule) =>\n [\n rule.domain,\n rule.header ? `header ${rule.header}` : '',\n rule.methods?.length ? rule.methods.join(' ') : '',\n rule.paths?.length ? rule.paths.join(' ') : '',\n rule.proposed ? 'proposed in the fnox config, not yet accepted by the vault' : '',\n ]\n .filter(Boolean)\n .join(', ')\n );\n const shell = name.exec === 'shell' && granted ? ['in every bash'] : [];\n const sealed = name.placeholder === null ? ['not sealed'] : [];\n const config = name.fnox ? [] : ['not in the fnox config'];\n const parts = [...rules, ...shell, ...sealed, ...config];\n return parts.length ? `: ${parts.join('; ')}` : '';\n}\n\nexport const NO_SECRETS =\n 'No secrets are configured: the fnox config has no keys and the vault no sealed secrets.';\n\nexport function renderSecrets(listing: SecretListing): string {\n if (listing.error !== null) return unavailableLine(listing.error);\n if (!listing.names.length) return [NO_SECRETS, '', ASK_LINE].join('\\n');\n const granted = !listing.exposed.length;\n const lines = listing.names.map(\n (name) => `- ${name.name} = ${name.placeholder ?? `$${name.name}`}${where(name, granted)}`\n );\n const off = granted ? [] : ['', exposedLine(listing.exposed)];\n return [MODEL_LINE, ASK_LINE, '', ...lines, ...off].join('\\n');\n}\n\nexport function secretsEntry(listing: SecretListing) {\n return {\n kind: SECRETS_KIND,\n data: {\n names: structuredClone(listing.names) as unknown as JsonValue,\n error: listing.error,\n exposed: [...listing.exposed],\n },\n model: [{ role: 'user' as const, content: listedLine(listing), timestamp: Date.now() }],\n };\n}\n\nexport function granting(listing: SecretListing): boolean {\n return (\n listing.error === null &&\n !listing.exposed.length &&\n listing.names.some((name) => name.exec === 'shell')\n );\n}\n\nexport function shellGrants(names: Pick<Names, 'state'>) {\n return (argv: readonly string[]): readonly string[] =>\n granting(names.state.value) ? [...SHELL_GRANTS, ...argv] : argv;\n}\n\nexport function secretsExtension(deps: {\n names: Pick<Names, 'state'>;\n vault: Pick<Vault, 'ready' | 'texts'>;\n}): Extension {\n return defineExtension({\n name: SECRETS,\n sections: [section('secrets', () => renderSecrets(deps.names.state.value))],\n hooks: [\n hook(ToolTask, { afterTool: (_call, result) => scrubResult(result, deps.vault) }),\n hook(GenerationTask, {\n beforeRequest: async () => {\n await deps.vault.ready();\n return undefined;\n },\n }),\n ],\n });\n}\n"],
5
- "mappings": "AACA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAIP,SAAS,aAAa,YAAY,cAAc,uBAAuB;AAIhE,MAAM,UAAU;AAChB,MAAM,kBAAkB;AACxB,MAAM,eAAe,CAAC,QAAQ,QAAQ,kBAAkB,IAAI;AAE5D,MAAM,aACX;AAEK,MAAM,WACX;AAIF,SAAS,OAAO,OAAkB,KAAa,KAAsC;AACnF,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,KAAK,EAAE,KAAK,MAAM,OAAO,IAAI,CAAC;AAClC;AAAA,EACF;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,UAAM,QAAQ,CAAC,MAAM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,gBAAgB;AAAA,IACrB,MAAM;AAAA,IACN,UAAU,CAAC,QAAQ,WAAW,MAAM,cAAc,KAAK,MAAM,MAAM,KAAK,CAAC,CAAC;AAAA,IAC1E,OAAO;AAAA,MACL,KAAK,UAAU,EAAE,WAAW,CAAC,OAAO,WAAW,YAAY,QAAQ,KAAK,KAAK,EAAE,CAAC;AAAA,MAChF,KAAK,gBAAgB;AAAA,QACnB,eAAe,YAAY;AACzB,gBAAM,KAAK,MAAM,MAAM;AACvB,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["import type { JsonValue } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n GenerationTask,\n hook,\n section,\n type ToolExecutionResult,\n ToolTask,\n} from '@earendil-works/pi-durable';\nimport type { Names, SecretListing, SecretName } from './names.ts';\nimport type { Scrub } from './scrub.ts';\nimport type { Vault } from './vault.ts';\nimport { exposedLine, listedLine, SECRETS_KIND, unavailableLine } from './view.ts';\n\nexport { exposedLine, listedLine, SECRETS_KIND, unavailableLine };\n\nexport const SECRETS = 'slicc-secrets';\nexport const SECRETS_COMMAND = '/secrets';\nexport const SHELL_GRANTS = ['fnox', 'exec', '--shell-grants', '--'] as const;\n\nexport const MODEL_LINE =\n 'Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo: the user approving that sudo is the only acceptance there is, and the vault uses the rules in it as soon as it is written (`sealed list --json` shows the rules it uses now; the list below is read at start and can lag behind). It uses the rules of a secret only while the file is root-owned and not writable by others, and its `[secrets]` entry holds the placeholder of that secret: `NAME = { provider = \"seven\", value = \"<placeholder>\" }` (`sealed placeholder NAME` prints it); without the `value` the vault ignores the entry and every rule naming it, though `fnox check` passes. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as \\'in every bash\\' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [[\"/absolute/program\"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.';\n\nexport const ASK_LINE =\n \"When a secret you need is missing, ask the user for it: `fnox set NAME --ask` seals it and writes its entry to `fnox.toml` in the current directory, which the vault doesn't read (copy the entry into `/etc/fnox/config.toml` with sudo before adding its rules there), and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.\";\n\ntype Leaf = { get(): string; set(text: string): void };\n\nfunction leaves(value: JsonValue, out: Leaf[], set: (next: JsonValue) => void): void {\n if (typeof value === 'string') {\n out.push({ get: () => value, set });\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, at) => {\n leaves(item, out, (next) => {\n value[at] = next;\n });\n });\n return;\n }\n if (value && typeof value === 'object')\n for (const [key, item] of Object.entries(value))\n leaves(item as JsonValue, out, (next) => {\n (value as Record<string, JsonValue>)[key] = next;\n });\n}\n\nexport async function scrubResult(\n result: ToolExecutionResult,\n scrub: Pick<Scrub, 'texts'>\n): Promise<ToolExecutionResult | undefined> {\n const content = [...(result.output ?? [])];\n const diagnostics = [...(result.diagnostics ?? [])];\n const copy = (value: JsonValue | undefined) =>\n value === undefined ? undefined : (structuredClone(value) as JsonValue);\n const details = copy(result.details);\n const structured = copy(result.structuredOutput);\n const found: Leaf[] = [];\n content.forEach((item, at) => {\n if (item.type === 'text')\n found.push({ get: () => item.text, set: (text) => void (content[at] = { ...item, text }) });\n });\n diagnostics.forEach((item, at) => {\n found.push({\n get: () => item.message,\n set: (message) => void (diagnostics[at] = { ...item, message }),\n });\n });\n let replaced = details;\n if (details !== undefined)\n leaves(details, found, (next) => {\n replaced = next;\n });\n let output = structured;\n if (structured !== undefined)\n leaves(structured, found, (next) => {\n output = next;\n });\n const before = found.map((leaf) => leaf.get());\n const after = await scrub.texts(before);\n if (after.every((text, at) => text === before[at])) return undefined;\n found.forEach((leaf, at) => {\n leaf.set(after[at] as string);\n });\n const kept = result.output as ToolExecutionResult['output'] & unknown[];\n if (kept) kept.splice(0, kept.length, ...content);\n return {\n ...result,\n ...(kept ? { output: kept } : {}),\n ...(result.diagnostics ? { diagnostics } : {}),\n ...(replaced === undefined ? {} : { details: replaced }),\n ...(output === undefined ? {} : { structuredOutput: output }),\n };\n}\n\nexport const unusedLine = (name: string, placeholder: string) =>\n `the vault uses none of these rules yet, and there is nothing for the user to accept: it takes rules only from a root-owned \\`/etc/fnox/config.toml\\` whose \\`[secrets]\\` entry is \\`${name} = { provider = \"seven\", value = \"${placeholder}\" }\\`; fix the file with sudo, then \\`sealed list --json\\` shows the rules the vault uses`;\n\nfunction where(name: SecretName, granted: boolean): string {\n const rules = name.rules.map((rule) =>\n [\n rule.domain,\n rule.header ? `header ${rule.header}` : '',\n rule.methods?.length ? rule.methods.join(' ') : '',\n rule.paths?.length ? rule.paths.join(' ') : '',\n rule.proposed ? 'in the fnox config but not in effect' : '',\n ]\n .filter(Boolean)\n .join(', ')\n );\n const idle =\n name.placeholder !== null && name.rules.some((rule) => rule.proposed)\n ? [unusedLine(name.name, name.placeholder)]\n : [];\n const shell = name.exec === 'shell' && granted ? ['in every bash'] : [];\n const sealed = name.placeholder === null ? ['not sealed'] : [];\n const config = name.fnox ? [] : ['not in the fnox config'];\n const parts = [...rules, ...idle, ...shell, ...sealed, ...config];\n return parts.length ? `: ${parts.join('; ')}` : '';\n}\n\nexport const NO_SECRETS =\n 'No secrets are configured: the fnox config has no keys and the vault no sealed secrets.';\n\nexport function renderSecrets(listing: SecretListing): string {\n if (listing.error !== null) return unavailableLine(listing.error);\n if (!listing.names.length) return [NO_SECRETS, '', ASK_LINE].join('\\n');\n const granted = !listing.exposed.length;\n const lines = listing.names.map(\n (name) => `- ${name.name} = ${name.placeholder ?? `$${name.name}`}${where(name, granted)}`\n );\n const off = granted ? [] : ['', exposedLine(listing.exposed)];\n return [MODEL_LINE, ASK_LINE, '', ...lines, ...off].join('\\n');\n}\n\nexport function secretsEntry(listing: SecretListing) {\n return {\n kind: SECRETS_KIND,\n data: {\n names: structuredClone(listing.names) as unknown as JsonValue,\n error: listing.error,\n exposed: [...listing.exposed],\n },\n model: [{ role: 'user' as const, content: listedLine(listing), timestamp: Date.now() }],\n };\n}\n\nexport function granting(listing: SecretListing): boolean {\n return (\n listing.error === null &&\n !listing.exposed.length &&\n listing.names.some((name) => name.exec === 'shell')\n );\n}\n\nexport function shellGrants(names: Pick<Names, 'state'>) {\n return (argv: readonly string[]): readonly string[] =>\n granting(names.state.value) ? [...SHELL_GRANTS, ...argv] : argv;\n}\n\nexport function secretsExtension(deps: {\n names: Pick<Names, 'state'>;\n vault: Pick<Vault, 'ready' | 'texts'>;\n}): Extension {\n return defineExtension({\n name: SECRETS,\n sections: [section('secrets', () => renderSecrets(deps.names.state.value))],\n hooks: [\n hook(ToolTask, { afterTool: (_call, result) => scrubResult(result, deps.vault) }),\n hook(GenerationTask, {\n beforeRequest: async () => {\n await deps.vault.ready();\n return undefined;\n },\n }),\n ],\n });\n}\n"],
5
+ "mappings": "AACA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAIP,SAAS,aAAa,YAAY,cAAc,uBAAuB;AAIhE,MAAM,UAAU;AAChB,MAAM,kBAAkB;AACxB,MAAM,eAAe,CAAC,QAAQ,QAAQ,kBAAkB,IAAI;AAE5D,MAAM,aACX;AAEK,MAAM,WACX;AAIF,SAAS,OAAO,OAAkB,KAAa,KAAsC;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C,EAAE,MAAM,QAAiB,SAAS,WAAW,OAAO,GAAG,WAAW,KAAK,IAAI,EAAE,CAAC;AAAA,EACxF;AACF;AAEO,SAAS,SAAS,SAAiC;AACxD,SACE,QAAQ,UAAU,QAClB,CAAC,QAAQ,QAAQ,UACjB,QAAQ,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,OAAO;AAEtD;AAEO,SAAS,YAAY,OAA6B;AACvD,SAAO,CAAC,SACN,SAAS,MAAM,MAAM,KAAK,IAAI,CAAC,GAAG,cAAc,GAAG,IAAI,IAAI;AAC/D;AAEO,SAAS,iBAAiB,MAGnB;AACZ,SAAO,gBAAgB;AAAA,IACrB,MAAM;AAAA,IACN,UAAU,CAAC,QAAQ,WAAW,MAAM,cAAc,KAAK,MAAM,MAAM,KAAK,CAAC,CAAC;AAAA,IAC1E,OAAO;AAAA,MACL,KAAK,UAAU,EAAE,WAAW,CAAC,OAAO,WAAW,YAAY,QAAQ,KAAK,KAAK,EAAE,CAAC;AAAA,MAChF,KAAK,gBAAgB;AAAA,QACnB,eAAe,YAAY;AACzB,gBAAM,KAAK,MAAM,MAAM;AACvB,iBAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -8,9 +8,10 @@ export { exposedLine, listedLine, SECRETS_KIND, unavailableLine };
8
8
  export declare const SECRETS = "slicc-secrets";
9
9
  export declare const SECRETS_COMMAND = "/secrets";
10
10
  export declare const SHELL_GRANTS: readonly ['fnox', 'exec', '--shell-grants', '--'];
11
- export declare const MODEL_LINE = "Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo, which the user approves. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as 'in every bash' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [[\"/absolute/program\"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.";
12
- export declare const ASK_LINE = "When a secret you need is missing, ask the user for it: `fnox set NAME --ask` adds it to the fnox config, and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.";
11
+ export declare const MODEL_LINE = "Credentials are env vars (`$NAME`) holding placeholders, listed below with where each works (`fnox list` shows the fnox config). The vault fills in the real value only in the listed header, for the listed domain, method and path, over HTTPS (curl, git, fetch). Adding a rule means editing `/etc/fnox/config.toml` with sudo: the user approving that sudo is the only acceptance there is, and the vault uses the rules in it as soon as it is written (`sealed list --json` shows the rules it uses now; the list below is read at start and can lag behind). It uses the rules of a secret only while the file is root-owned and not writable by others, and its `[secrets]` entry holds the placeholder of that secret: `NAME = { provider = \"seven\", value = \"<placeholder>\" }` (`sealed placeholder NAME` prints it); without the `value` the vault ignores the entry and every rule naming it, though `fnox check` passes. `fnox exec` gives real values only for secrets the user enabled for exec, and the secrets listed as 'in every bash' already hold real values in your commands. Prefer an argv grant in `/etc/slicc/secrets-policy.toml` (`NAME = { argv = [[\"/absolute/program\"]] }`) for a secret one program needs; `{ shell = true }` hands it to every bash. Everything is logged, and stored values are replaced by their placeholder in everything you see; edit around placeholders, since files show them too. Never ask the user to paste a credential into the chat.";
12
+ export declare const ASK_LINE = "When a secret you need is missing, ask the user for it: `fnox set NAME --ask` seals it and writes its entry to `fnox.toml` in the current directory, which the vault doesn't read (copy the entry into `/etc/fnox/config.toml` with sudo before adding its rules there), and `sealed ask NAME` keeps it in the vault only (`--prompt TEXT` says why you need it). The user types the value in a dialog, and the command prints only its placeholder. `fnox set` always asks for a new value and replaces an existing one, so use it only for a missing secret. Add `--reveal` to `sealed ask` only when a tool needs the plaintext itself, not where the vault fills it in a header, and pipe it straight into that tool (`sealed ask NAME --reveal | tool --password-stdin`): the user must allow every reveal, and you still see only the placeholder. A non-zero exit means the user declined or the request ended; don't ask again unless the user wants you to.";
13
13
  export declare function scrubResult(result: ToolExecutionResult, scrub: Pick<Scrub, 'texts'>): Promise<ToolExecutionResult | undefined>;
14
+ export declare const unusedLine: (name: string, placeholder: string) => string;
14
15
  export declare const NO_SECRETS = "No secrets are configured: the fnox config has no keys and the vault no sealed secrets.";
15
16
  export declare function renderSecrets(listing: SecretListing): string;
16
17
  export declare function secretsEntry(listing: SecretListing): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "7.34.0",
3
+ "version": "7.34.2",
4
4
  "description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -72,22 +72,22 @@
72
72
  "release": "semantic-release"
73
73
  },
74
74
  "devDependencies": {
75
- "@ai-ecoverse/slicc-jsh": "0.64.4",
76
- "@ai-ecoverse/slicc-kernel": "1.186.0",
75
+ "@ai-ecoverse/slicc-jsh": "0.64.5",
76
+ "@ai-ecoverse/slicc-kernel": "1.191.2",
77
77
  "@ai-ecoverse/slicc-scrub": "1.1.1",
78
78
  "@ai-ecoverse/slicc-shared-web": "2.14.4",
79
79
  "@ai-ecoverse/slicc-spectrum": "2.16.1",
80
- "@ai-ecoverse/slicc-vault": "1.26.0",
81
- "@ai-ecoverse/wasi-fnox": "1.47.0-1",
80
+ "@ai-ecoverse/slicc-vault": "1.26.3",
81
+ "@ai-ecoverse/wasi-fnox": "1.48.0-1",
82
82
  "@ai-ecoverse/wasm-bash": "5.3.0-23",
83
83
  "@ai-ecoverse/wasm-coreutils": "9.12.0-15",
84
84
  "@ai-ecoverse/wasm-git": "2.55.0-22",
85
85
  "@biomejs/biome": "2.6.6",
86
86
  "@types/node": "26.6.6",
87
87
  "esbuild": "0.28.2",
88
- "fake-indexeddb": "6.2.7",
88
+ "fake-indexeddb": "6.2.8",
89
89
  "lefthook": "2.2.2",
90
- "monocart-coverage-reports": "3.2.0",
90
+ "monocart-coverage-reports": "3.2.1",
91
91
  "playwright-core": "1.65.0",
92
92
  "semantic-release": "25.0.9",
93
93
  "slicc-agent-5": "npm:@ai-ecoverse/slicc-agent@5.10.1",