shadok-ai 0.19.33 → 0.19.34

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
@@ -171,7 +171,10 @@ Enter to skip; you can add it later from the web UI).
171
171
  Claude** button right there signs you in again without waiting for the lapse,
172
172
  and in the last **48 hours** (or once it has lapsed) a reminder **banner**
173
173
  carries the same one-click re-login — so your agents never quietly start
174
- hitting `401` because nobody renewed the session.
174
+ hitting `401` because nobody renewed the session. On a multi-tenant instance
175
+ the rows describe what the **agents** authenticate with (the long-lived token
176
+ or their space's claude.ai login, and its expiry) rather than the server's own
177
+ sign-in, and the re-login button renews that credential.
175
178
  - **Secret vault** — stored under `~/.shadok-ai`, never in your repo, injected
176
179
  as env vars into the agents that need them. Add or **update** a secret from the
177
180
  panel, tick the **profiles** it should feed right there, and reload the running
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.33",
3
+ "version": "0.19.34",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test --test-timeout=120000 test/*.ts context/*/test/*.test.mjs",
@@ -80,6 +80,51 @@ export function accountExpiryLine(auth, now = Date.now()) {
80
80
  return null;
81
81
  }
82
82
 
83
+ /**
84
+ * The version menu's Account / Token rows and re-login buttons on a migrated
85
+ * MULTI-TENANT instance, or null when they do not apply (mono-tenant, a
86
+ * not-yet-migrated instance, a custom backend).
87
+ *
88
+ * There the agents run as their group's OS user, on the long-lived token or on
89
+ * that user's own claude.ai login (`connect`), and the SERVER's own sign-in —
90
+ * what `state`/`email` describe — is irrelevant to them and usually absent. The
91
+ * menu used to describe that root sign-in anyway: it read "signed out", and the
92
+ * early return on it hid "Re-login" AND "Replace subscription token", leaving an
93
+ * admin no button at all to renew what the agents actually use.
94
+ *
95
+ * @param {{backend?: string, longLived?: boolean,
96
+ * connect?: {state: string, multiTenant: boolean, agentAuth: string, user: string|null, expiresAt: number|null}}|null} auth
97
+ * @param {boolean} isAdmin
98
+ * @param {number} [now]
99
+ * @returns {{account: string, token: string, tokenTone: ""|"warn"|"err", relogin: string|null, replaceToken: boolean}|null}
100
+ */
101
+ export function agentCredentialRows(auth, isAdmin, now = Date.now()) {
102
+ const c = auth && auth.connect;
103
+ if (!c || !c.multiTenant || c.user == null || auth.backend === "custom") return null;
104
+ const login = c.agentAuth === "login";
105
+ const account =
106
+ c.state === "yes" ? "agents · " + (login ? "claude.ai login" : "long-lived token")
107
+ : c.state === "no" ? "agents not connected"
108
+ : "—";
109
+ let token = "—";
110
+ let tokenTone = "";
111
+ const ts = c.expiresAt;
112
+ if (c.state === "yes" && typeof ts === "number" && Number.isFinite(ts)) {
113
+ if (login) {
114
+ token = fmtExpiry(ts, now);
115
+ const ms = ts - now;
116
+ tokenTone = ms <= 0 ? "err" : ms < 3 * 86400000 ? "warn" : "";
117
+ } else {
118
+ const dt = new Date(ts);
119
+ token = "expires ≈ " + MONTHS[dt.getMonth()] + " " + dt.getFullYear();
120
+ }
121
+ }
122
+ // "unknown" is a failed probe, not a state to act on (invariant 27).
123
+ const relogin = !isAdmin || c.state === "unknown" ? null
124
+ : c.state === "no" ? "🔌 Connect Claude…" : "↻ Re-login to Claude";
125
+ return { account, token, tokenTone, relogin, replaceToken: isAdmin && !!auth.longLived && !login };
126
+ }
127
+
83
128
  /** 5 days: the usage-gauge login is a month-long credential whose renewal needs
84
129
  * the human's browser, so it gets more notice than the instance login. Kept in
85
130
  * step with GAUGE_WARN_MS in src/gauge-login.ts (the server derives `state`). */
package/public/index.html CHANGED
@@ -3472,8 +3472,10 @@
3472
3472
  setup-token cannot read usage). Hidden until /auth says it applies. -->
3473
3473
  <div class="vm-row" id="vmGaugeRow" hidden><span class="vm-label">Usage gauge</span><span id="vmGauge">—</span></div>
3474
3474
  <button class="vm-btn" id="gaugeLoginBtn" type="button" hidden>📊 Usage gauge login…</button>
3475
- <!-- Re-login to Claude without waiting for the token to lapse. Shown only
3476
- when signed in (when signed out the sign-in card opens on its own). -->
3475
+ <!-- Re-login to Claude without waiting for the token to lapse. Shown when
3476
+ signed in (signed out, the sign-in card opens on its own) — and on a
3477
+ migrated multi-tenant instance whenever the AGENTS' credential is known,
3478
+ whatever the server's own sign-in says (agentCredentialRows). -->
3477
3479
  <button class="vm-btn" id="reloginBtn" type="button" hidden>↻ Re-login to Claude</button>
3478
3480
  <!-- Rotate the long-lived subscription token group agents authenticate with
3479
3481
  (multi-tenant + admin only). Shown by renderAuthRows when a token is held. -->
@@ -4641,12 +4643,13 @@
4641
4643
  window.toggleProfile = toggleProfile;
4642
4644
  window.accountBanners = accountBanners;
4643
4645
  window.logEntryLine = logEntryLine;
4644
- import { fmtExpiry, expiryWarning, accountExpiryLine, gaugeWarning, gaugeLine } from "/auth-expiry.js?v=__ASSET_V__";
4646
+ import { fmtExpiry, expiryWarning, accountExpiryLine, gaugeWarning, gaugeLine, agentCredentialRows } from "/auth-expiry.js?v=__ASSET_V__";
4645
4647
  window.fmtExpiry = fmtExpiry;
4646
4648
  window.expiryWarning = expiryWarning;
4647
4649
  window.gaugeWarning = gaugeWarning;
4648
4650
  window.gaugeLine = gaugeLine;
4649
4651
  window.accountExpiryLine = accountExpiryLine;
4652
+ window.agentCredentialRows = agentCredentialRows;
4650
4653
  import { filterLedger, ledgerFacets, ledgerAge, LEDGER_AGES, LEDGER_SORTS } from "/ledger-view.js?v=__ASSET_V__";
4651
4654
  window.filterLedger = filterLedger;
4652
4655
  window.ledgerFacets = ledgerFacets;
@@ -4800,6 +4803,7 @@
4800
4803
  gaugeWarning: () => null,
4801
4804
  gaugeLine: () => null,
4802
4805
  accountExpiryLine: () => null,
4806
+ agentCredentialRows: () => null,
4803
4807
  // Before the module lands, never open the Connect card on a guess.
4804
4808
  connectCardPlan: () => ({ open: false, step: null, flow: null, user: null, dismissable: false }),
4805
4809
  sameConnectTarget: () => false,
@@ -10250,6 +10254,18 @@
10250
10254
  // even when the account row bails (signed-out, custom backend, unknown).
10251
10255
  const aaBtn = document.getElementById("agentAuthBtn");
10252
10256
  if (aaBtn) aaBtn.hidden = !(a && a.multiTenant && me && me.role === "admin");
10257
+ // A migrated multi-tenant instance: describe what the AGENTS authenticate
10258
+ // with, not the server's own sign-in (agentCredentialRows says why).
10259
+ const ag = window.agentCredentialRows(a, !me || me.role === "admin");
10260
+ if (ag) {
10261
+ accEl.textContent = ag.account; accEl.title = "";
10262
+ tokEl.textContent = ag.token; tokEl.title = "";
10263
+ tokEl.style.color = ag.tokenTone === "err" ? "var(--err)" : ag.tokenTone === "warn" ? "var(--amber)" : "";
10264
+ if (relBtn) { relBtn.hidden = !ag.relogin; if (ag.relogin) relBtn.textContent = ag.relogin; }
10265
+ if (mtBtn) mtBtn.hidden = !ag.replaceToken;
10266
+ return;
10267
+ }
10268
+ if (relBtn) relBtn.textContent = "↻ Re-login to Claude";
10253
10269
  if (a && a.backend === "custom" && a.state !== "signed-in") {
10254
10270
  accEl.textContent = a.backendModel ? a.backendModel + " · custom backend" : "custom model backend";
10255
10271
  accEl.title = "";