shadok-ai 0.17.9 → 0.17.10

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
@@ -501,6 +501,16 @@ across OS users (Claude rewrites the credential single-owner on refresh), which
501
501
  is why each user logs in separately. Design:
502
502
  `docs/superpowers/specs/2026-11-04-connectors-via-global-login-design.md`.
503
503
 
504
+ **Persist the group homes (recommended in Docker).** Each dropped agent runs as
505
+ its own OS user with HOME under `SHADOK_HOME_BASE` (default `/home`), which is
506
+ **not** on the `shadok-data` volume by default — so a `docker rm` + recreate
507
+ wipes those homes, taking their Claude first-run/trust state (agents briefly land
508
+ on the "trust this folder" dialog until it is re-seeded) and, in **login** mode,
509
+ the per-user credentials (every user has to log in again). shadok re-seeds the
510
+ trust robustly on boot, but to avoid the churn entirely mount the home base on a
511
+ volume, the same move as the SSH key (below): e.g. add `-v shadok-homes:/home` to
512
+ the `docker run`. A plain restart never needed this; only a recreate does.
513
+
504
514
  Telegram stays single-owner, and there are no
505
515
  disk quotas yet. Design: `docs/superpowers/specs/2026-10-29-multi-tenant-scoped-isolation-design.md`.
506
516
 
@@ -39,6 +39,23 @@ export declare function seedPlan(existing: ClaudeHome, opts: {
39
39
  version: string;
40
40
  cwd?: string;
41
41
  }): ClaudeHome | null;
42
+ /**
43
+ * Pure: the object to write after trusting EVERY cwd in `cwds` (plus the
44
+ * globals), or null when nothing is missing.
45
+ *
46
+ * This is `seedPlan` folded over many directories so a shared group HOME is
47
+ * seeded in ONE atomic write instead of one racy write per spawn. The
48
+ * motivating bug: N agents share a single `~/.claude.json`, and rebuilding it
49
+ * one cwd at a time during a boot respawn storm let a sibling `claude`'s stale
50
+ * write clobber a trust entry before that agent's own process read it —
51
+ * stranding it on the "trust this folder" dialog. Seeding the complete set up
52
+ * front (before any such process starts) removes the window entirely. Each
53
+ * `cwd` keeps `seedPlan`'s additive, never-overwrite discipline.
54
+ */
55
+ export declare function seedPlanForCwds(existing: ClaudeHome, opts: {
56
+ version: string;
57
+ cwds: readonly string[];
58
+ }): ClaudeHome | null;
42
59
  export interface ClaudeSettings {
43
60
  tui?: string;
44
61
  [k: string]: unknown;
@@ -124,6 +124,35 @@ export function seedPlan(existing, opts) {
124
124
  }
125
125
  return changed ? out : null;
126
126
  }
127
+ /**
128
+ * Pure: the object to write after trusting EVERY cwd in `cwds` (plus the
129
+ * globals), or null when nothing is missing.
130
+ *
131
+ * This is `seedPlan` folded over many directories so a shared group HOME is
132
+ * seeded in ONE atomic write instead of one racy write per spawn. The
133
+ * motivating bug: N agents share a single `~/.claude.json`, and rebuilding it
134
+ * one cwd at a time during a boot respawn storm let a sibling `claude`'s stale
135
+ * write clobber a trust entry before that agent's own process read it —
136
+ * stranding it on the "trust this folder" dialog. Seeding the complete set up
137
+ * front (before any such process starts) removes the window entirely. Each
138
+ * `cwd` keeps `seedPlan`'s additive, never-overwrite discipline.
139
+ */
140
+ export function seedPlanForCwds(existing, opts) {
141
+ let current = existing;
142
+ let changed = false;
143
+ // Globals first (no cwd), then each directory — threading the running object
144
+ // so every change lands in one result. seedPlan returns null for "nothing to
145
+ // add", in which case we keep the object we already have.
146
+ const steps = [undefined, ...opts.cwds];
147
+ for (const cwd of steps) {
148
+ const next = seedPlan(current, { version: opts.version, cwd });
149
+ if (next) {
150
+ current = next;
151
+ changed = true;
152
+ }
153
+ }
154
+ return changed ? current : null;
155
+ }
127
156
  /**
128
157
  * Pure: `~/.claude/settings.json` after adding the keys that suppress a
129
158
  * first-run *upsell*, or null when nothing is missing.
@@ -1 +1 @@
1
- {"version":3,"file":"claude-home.js","sourceRoot":"","sources":["../src/claude-home.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI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AAO,IAAI,CAAC,KAAK,CAAC;QACvB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,GAAG,IAAI,WAAW,OAAO,CAAC,GAAG,MAAM,CAAC;QAChD,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACrD,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
package/dist/server.js CHANGED
@@ -19,7 +19,7 @@ import { extractLiveText } from "../public/live-text.js";
19
19
  import { findTransientErrors, newTransientErrors, RETRY_DELAYS_MS } from "./retry.js";
20
20
  import { backgroundTasks, screenShowsWork, moveToOption } from "./detect.js";
21
21
  import { PtyPilot } from "./session.js";
22
- import { ensureClaudeHome, ensureProjectTrusted, getDefaultModel, setDefaultModel, parseClaudeVersion, seedPlan, settingsPlan, } from "./claude-home.js";
22
+ import { ensureClaudeHome, ensureProjectTrusted, getDefaultModel, setDefaultModel, parseClaudeVersion, seedPlanForCwds, settingsPlan, } from "./claude-home.js";
23
23
  import { authStatus, cancelLogin, invalidateAuthStatus, startLogin, submitLoginCode } from "./claude-auth.js";
24
24
  import { startSetupToken, submitSetupTokenCode, cancelSetupToken } from "./setup-token.js";
25
25
  import { startAgentLogin, submitAgentLoginCode, cancelAgentLogin, agentLoginPending, agentLoginInfo, } from "./agent-login.js";
@@ -2571,6 +2571,10 @@ async function ensureGroupsProvisioned() {
2571
2571
  // invite-redeem hook nor the per-account migration loop ever fires for it.
2572
2572
  // Give it a Personal group here; idempotent (reuses an existing private group).
2573
2573
  await ensurePrivateGroupProvisioned(BOOTSTRAP_ADMIN);
2574
+ // Before any agent comes back: fill every drop user's HOME with the full set
2575
+ // of trusted directories in one write each, so none strands on the trust
2576
+ // dialog when the resume storm rebuilds a wiped (ephemeral) group HOME.
2577
+ preseedGroupHomes();
2574
2578
  }
2575
2579
  /** Step 1 — create the non-root commons user `main` (+ HOME). Idempotent. */
2576
2580
  async function migCreateCommonsUser() {
@@ -4917,7 +4921,7 @@ function ensureAgentSshKey(user, home) {
4917
4921
  * seed the shadok SKILLS into the group HOME (they live only in the server's
4918
4922
  * ~/.claude/skills); that gap is tracked separately.
4919
4923
  */
4920
- function seedGroupAgentHome(user, home, cwd) {
4924
+ function seedHomeTrust(user, home, cwds) {
4921
4925
  const version = currentClaudeVersion() ?? "0.0.0";
4922
4926
  const readObj = (file) => {
4923
4927
  const r = spawnAsUserSync(user, "cat", [file]);
@@ -4937,7 +4941,9 @@ function seedGroupAgentHome(user, home, cwd) {
4937
4941
  const homeJson = `${home}/.claude.json`;
4938
4942
  const existing = readObj(homeJson);
4939
4943
  if (existing) {
4940
- const plan = seedPlan(existing, { version, cwd });
4944
+ // ONE write for the globals + every cwd (not one racy write per cwd) —
4945
+ // see `seedPlanForCwds` and `preseedGroupHomes` for why that matters.
4946
+ const plan = seedPlanForCwds(existing, { version, cwds });
4941
4947
  if (plan)
4942
4948
  writeAsUserAtomic(user, homeJson, JSON.stringify(plan, null, 2));
4943
4949
  }
@@ -4956,6 +4962,75 @@ function seedGroupAgentHome(user, home, cwd) {
4956
4962
  console.log(`claude-home: could not seed group HOME ${home} — ${e instanceof Error ? e.message : String(e)}`);
4957
4963
  }
4958
4964
  }
4965
+ /**
4966
+ * The drop user each channel's agent runs as, mapped to the directories that
4967
+ * user's agents live in. The input to seeding a group HOME with the right set
4968
+ * of trusted directories. Only DROP users appear (commons `main`, private
4969
+ * `sk-*`); a public/mono channel runs as the server's own user (null), whose
4970
+ * `/root` is handled by `ensureClaudeHome` + `ensureProjectTrusted` and lives
4971
+ * on the shadok-data volume — it never suffers the ephemeral-rebuild race this
4972
+ * map exists to close.
4973
+ */
4974
+ function dropUserCwds() {
4975
+ const out = new Map();
4976
+ const groups = new Map(loadGroups().map((g) => [g.id, g]));
4977
+ const commons = commonsOsUser({ migrated: groupsMigrated, mode: DEPLOYMENT_MODE });
4978
+ const add = (user, cwd) => {
4979
+ if (!user || !cwd)
4980
+ return;
4981
+ let s = out.get(user);
4982
+ if (!s) {
4983
+ s = new Set();
4984
+ out.set(user, s);
4985
+ }
4986
+ s.add(cwd);
4987
+ };
4988
+ for (const ch of loadChannels()) {
4989
+ const g = ch.group ? groups.get(ch.group) : undefined;
4990
+ add((g ? osUserFor(g) : null) ?? commons, ch.cwd);
4991
+ }
4992
+ // The commons also runs the lead agent in the launch dir itself.
4993
+ if (commons)
4994
+ add(commons, process.cwd());
4995
+ return out;
4996
+ }
4997
+ /**
4998
+ * Seed a dropped agent's OWN HOME before it spawns — this agent's cwd AND every
4999
+ * sibling cwd that shares the HOME, in ONE write. The shared `~/.claude.json`
5000
+ * is read-modify-written by every agent in the HOME (commons agents all share
5001
+ * `/home/main`), so rebuilding it one cwd at a time during a respawn storm let
5002
+ * a stale sibling `claude` write clobber a trust entry before its owner read it
5003
+ * — stranding that agent on the "trust this folder" dialog (invariant 23's
5004
+ * family, on the group HOME). A complete write closes the window. See the file
5005
+ * comment on `seedHomeTrust` / `preseedGroupHomes`. Runs AS the group user,
5006
+ * SYNCHRONOUSLY and ADDITIVELY; best-effort.
5007
+ */
5008
+ function seedGroupAgentHome(user, home, cwd) {
5009
+ const cwds = new Set([cwd]);
5010
+ const siblings = dropUserCwds().get(user);
5011
+ if (siblings)
5012
+ for (const c of siblings)
5013
+ cwds.add(c);
5014
+ seedHomeTrust(user, home, [...cwds]);
5015
+ }
5016
+ /**
5017
+ * Boot pre-seed: seed EVERY drop user's HOME with its full set of trusted
5018
+ * directories, in one atomic write each, BEFORE the resume/respawn storm — so a
5019
+ * `claude` that starts in that storm always finds its cwd already trusted. The
5020
+ * group HOMEs are not on the shadok-data volume, so a `docker` recreate wipes
5021
+ * them and they are rebuilt from empty exactly when many agents come back at
5022
+ * once; the per-spawn seed alone then raced (measured: an agent stuck on the
5023
+ * trust dialog with its entry missing from the shared `/home/main/.claude.json`
5024
+ * while `/root`'s — volume-backed — had it). Best-effort; mono-tenant or
5025
+ * un-migrated → no drop users → no-op.
5026
+ */
5027
+ function preseedGroupHomes() {
5028
+ if (DEPLOYMENT_MODE !== "multi-tenant" || !groupsMigrated)
5029
+ return;
5030
+ for (const [user, cwds] of dropUserCwds()) {
5031
+ seedHomeTrust(user, homeForUser(user, GROUP_HOME_BASE), [...cwds]);
5032
+ }
5033
+ }
4959
5034
  function makePilot(id, cwd, args, profileName, model, effort,
4960
5035
  /**
4961
5036
  * The OS user to drop this agent to (multi-tenant isolation, `src/osusers.ts`).