shadok-ai 0.19.50 → 0.19.51

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
@@ -178,7 +178,12 @@ Enter to skip; you can add it later from the web UI).
178
178
  - **Secret vault** — stored under `~/.shadok-ai`, never in your repo, injected
179
179
  as env vars into the agents that need them. Add or **update** a secret from the
180
180
  panel, tick the **profiles** it should feed right there, and reload the running
181
- agents on those profiles in one click so a rotated value takes effect now. On
181
+ agents on those profiles in one click so a rotated value takes effect now.
182
+ On an existing secret's card, the *Shared with* / *Injected into* chips **are
183
+ the save**: a tick is written straight away, and a refused one goes back to
184
+ what the cockpit holds with the reason on the card — there is no Save button
185
+ to forget. (Only the creation form waits, since a secret must exist before it
186
+ can be bound to anything.) On
182
187
  an instance with groups, **Any profile** feeds a secret to every agent that can
183
188
  read it, whatever its profile (only a person can pick it, not an agent). An
184
189
  agent that **obtains** a credential (a CLI login, a key it just provisioned)
@@ -1578,7 +1583,8 @@ Light/dark **mode** is an orthogonal, **per-browser** choice in the same menu
1578
1583
  endpoint — the accent is the instance's shared identity, the mode is personal),
1579
1584
  `/profiles`, `/secrets`, `/secrets/audit` (GET, **admin only** — the secret
1580
1585
  audit log: who created/updated/deleted a secret, which profile it was attached
1581
- to, and which agent **received** it at spawn or in a cron guard, with the person
1586
+ to — from the profile's editor or from a tick on the secret's *Injected into*
1587
+ chips, both directions of the same link — and which agent **received** it at spawn or in a cron guard, with the person
1582
1588
  or door that caused it; names only, never a value; filters `secret`, `action`,
1583
1589
  `actor`, `agent`, `since`, `limit`. Also in the vault panel → *Audit log*, and
1584
1590
  🕘 on each secret), `/telegram`, `/defaults`, `/first-agent` (GET —
package/dist/server.js CHANGED
@@ -1418,6 +1418,15 @@ function auditProfileSecrets(req, profile, diff, detail) {
1418
1418
  recordSecretAudit({ action: "attached", secrets: diff.added, ...base });
1419
1419
  recordSecretAudit({ action: "detached", secrets: diff.removed, ...base });
1420
1420
  }
1421
+ /** One audit row per profile a SECRET gained or lost (the mirror of
1422
+ * `auditProfileSecrets`, which records the same link from the profile's side:
1423
+ * there the diff is over secret names, here over profile names). */
1424
+ function auditSecretProfiles(req, secret, diff) {
1425
+ const who = auditActorOf(req);
1426
+ for (const [action, profiles] of [["attached", diff.added], ["detached", diff.removed]])
1427
+ for (const profile of profiles)
1428
+ recordSecretAudit({ action, secrets: [secret], profile, ...who, instance: process.cwd() });
1429
+ }
1421
1430
  /**
1422
1431
  * A PERSON in a browser on our own origin — the only caller allowed through the
1423
1432
  * "browser-only" gates (guardrails, accounts, shell mode, uploads…).
@@ -4909,8 +4918,17 @@ app.put("/secrets/profiles", (req, res) => {
4909
4918
  const target = secretWriteTarget(req);
4910
4919
  if ("refused" in target)
4911
4920
  return res.status(403).json({ error: target.refused });
4921
+ // The binding BEFORE the write, so the audit can name the direction. Read
4922
+ // here and not from the body: the client sends the whole set, so "added" and
4923
+ // "removed" exist only as a difference with what the vault currently holds.
4924
+ const before = loadVault()[target.ownerGroup]?.[name]?.profiles;
4912
4925
  if (!setSecretProfiles(name, target.ownerGroup, profiles))
4913
4926
  return res.status(404).json({ error: "no such secret in your group", name });
4927
+ // One row per profile gained or lost. Which agents receive a credential is
4928
+ // the whole point of the log, and the vault panel now writes this on every
4929
+ // tick (no Save button), so an unrecorded binding would be the one move in
4930
+ // the vault that leaves no trace.
4931
+ auditSecretProfiles(req, name, profileSecretDiff(before, profiles));
4914
4932
  res.json({ ok: true });
4915
4933
  });
4916
4934
  // Who wrote, attached and RECEIVED which secret (names only). Admin only: it