shadok-ai 0.17.45 → 0.17.47

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.
@@ -7,14 +7,23 @@ export type DeploymentMode = "multi-tenant" | "mono-tenant";
7
7
  /** Accounts exist only when a GUI password is set (it is the admin account). */
8
8
  export declare function accountsEnabled(guiPassword: string): boolean;
9
9
  /**
10
- * Can this process create OS users? Root, or passwordless sudo.
10
+ * Can this process create OS users FOR GROUP ISOLATION? Root, or passwordless
11
+ * sudo — and only on Linux. The isolation is implemented with Linux-only tooling
12
+ * (`useradd`, `setpriv`, `runuser`); on macOS or Windows it cannot work, so a
13
+ * host there must never auto-enable multi-tenant. Without this gate, a Mac
14
+ * running as root (or with cached/passwordless sudo) plus a GUI password flipped
15
+ * to multi-tenant and failed the boot migration on the very first `useradd`,
16
+ * leaving the red "isolation did NOT complete" banner on an instance that was
17
+ * only ever meant to be a password-gated single-user cockpit.
11
18
  * `SHADOK_FORCE_MULTITENANT=1` forces true and `=0` forces false (tests,
12
- * unusual setups) — same style as `inContainer` in `ssh.ts`.
19
+ * unusual setups) — same style as `inContainer` in `ssh.ts`; the explicit
20
+ * override is checked BEFORE the platform gate so an operator keeps control.
13
21
  */
14
22
  export declare function probeCanProvision(deps?: {
15
23
  getuid?: () => number | undefined;
16
24
  canSudo?: () => boolean;
17
25
  env?: NodeJS.ProcessEnv;
26
+ platform?: NodeJS.Platform;
18
27
  }): boolean;
19
28
  /** Multi-tenant iff BOTH capabilities hold; otherwise stay mono-tenant. */
20
29
  export declare function deploymentMode(input: {
@@ -17,18 +17,29 @@ function defaultCanSudo() {
17
17
  }
18
18
  }
19
19
  /**
20
- * Can this process create OS users? Root, or passwordless sudo.
20
+ * Can this process create OS users FOR GROUP ISOLATION? Root, or passwordless
21
+ * sudo — and only on Linux. The isolation is implemented with Linux-only tooling
22
+ * (`useradd`, `setpriv`, `runuser`); on macOS or Windows it cannot work, so a
23
+ * host there must never auto-enable multi-tenant. Without this gate, a Mac
24
+ * running as root (or with cached/passwordless sudo) plus a GUI password flipped
25
+ * to multi-tenant and failed the boot migration on the very first `useradd`,
26
+ * leaving the red "isolation did NOT complete" banner on an instance that was
27
+ * only ever meant to be a password-gated single-user cockpit.
21
28
  * `SHADOK_FORCE_MULTITENANT=1` forces true and `=0` forces false (tests,
22
- * unusual setups) — same style as `inContainer` in `ssh.ts`.
29
+ * unusual setups) — same style as `inContainer` in `ssh.ts`; the explicit
30
+ * override is checked BEFORE the platform gate so an operator keeps control.
23
31
  */
24
32
  export function probeCanProvision(deps = {}) {
25
33
  const env = deps.env ?? process.env;
26
34
  const getuid = deps.getuid ?? (() => process.getuid?.());
27
35
  const canSudo = deps.canSudo ?? defaultCanSudo;
36
+ const platform = deps.platform ?? process.platform;
28
37
  if (env.SHADOK_FORCE_MULTITENANT === "1")
29
38
  return true;
30
39
  if (env.SHADOK_FORCE_MULTITENANT === "0")
31
40
  return false;
41
+ if (platform !== "linux")
42
+ return false;
32
43
  if (getuid() === 0)
33
44
  return true;
34
45
  return canSudo();
@@ -1 +1 @@
1
- {"version":3,"file":"capability.js","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/C,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,OAAO,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAChF,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED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47",
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",
@@ -83,3 +83,18 @@ export function reconcileTabGroup(local, synced, server) {
83
83
  export function groupIsDirty(local, synced) {
84
84
  return synced === undefined || (local ?? null) !== synced;
85
85
  }
86
+
87
+ /**
88
+ * Which agent to focus when a group view becomes current. Switching groups used
89
+ * to snap to the TOP agent every time; instead we return to the one you last had
90
+ * focused in that group (`rememberedId`), so flipping between groups no longer
91
+ * loses your place. Falls back to the first agent when nothing is remembered yet
92
+ * or the remembered one has since gone (closed, or moved to another group), and
93
+ * to `null` for an empty group. `idsInView` is the group's agent session ids, in
94
+ * display order.
95
+ */
96
+ export function focusTarget(idsInView, rememberedId) {
97
+ const ids = idsInView || [];
98
+ if (rememberedId != null && ids.includes(rememberedId)) return rememberedId;
99
+ return ids.length ? ids[0] : null;
100
+ }
package/public/index.html CHANGED
@@ -3898,7 +3898,7 @@
3898
3898
  window.buildMessageLink = buildMessageLink;
3899
3899
  window.parseMessageLink = parseMessageLink;
3900
3900
  window.samePrompt = samePrompt;
3901
- import { GROUP_ICONS, UNGROUPED, randomGroupIcon, resolveGroupView, groupMood, cleanGroupIcon, reconcileTabGroup, groupIsDirty } from "/group-nav.js?v=__ASSET_V__";
3901
+ import { GROUP_ICONS, UNGROUPED, randomGroupIcon, resolveGroupView, groupMood, cleanGroupIcon, reconcileTabGroup, groupIsDirty, focusTarget } from "/group-nav.js?v=__ASSET_V__";
3902
3902
  window.GROUP_ICONS = GROUP_ICONS;
3903
3903
  window.UNGROUPED = UNGROUPED;
3904
3904
  window.randomGroupIcon = randomGroupIcon;
@@ -3907,6 +3907,7 @@
3907
3907
  window.cleanGroupIcon = cleanGroupIcon;
3908
3908
  window.reconcileTabGroup = reconcileTabGroup;
3909
3909
  window.groupIsDirty = groupIsDirty;
3910
+ window.focusTarget = focusTarget;
3910
3911
  import { searchEmoji, looksLikeEmoji } from "/emoji-search.js?v=__ASSET_V__";
3911
3912
  window.searchEmoji = searchEmoji;
3912
3913
  window.looksLikeEmoji = looksLikeEmoji;
@@ -4087,6 +4088,11 @@
4087
4088
  return { move: true, synced: srv };
4088
4089
  },
4089
4090
  groupIsDirty: (local, synced) => synced === undefined || (local ?? null) !== synced,
4091
+ // A group switch is a user click, long after the module lands; the stub
4092
+ // mirrors the real "remembered-or-first" so even a race keeps today's
4093
+ // top-agent fallback.
4094
+ focusTarget: (ids, remembered) =>
4095
+ (remembered != null && (ids || []).includes(remembered)) ? remembered : ((ids || []).length ? ids[0] : null),
4090
4096
  // The emoji keyword search feeds the icon picker, which opens well after
4091
4097
  // load; before the module lands, no suggestions (and typed text is treated
4092
4098
  // as a word, not an emoji) — both harmless, repainted on bridge-ready.
@@ -5589,6 +5595,10 @@
5589
5595
  const railEl = $("groupRail"), railList = $("railList");
5590
5596
  const VIEW_KEY = () => dirKey("cp.groupView", instanceKey);
5591
5597
  let groupView = localStorage.getItem(VIEW_KEY()) || "ungrouped";
5598
+ // The agent last focused in each group view (view id → sessionId), so
5599
+ // switching groups returns to where you were instead of the top agent.
5600
+ // In-memory: a reload restores one active agent via `cp.activeSession`.
5601
+ const lastAgentByView = {};
5592
5602
 
5593
5603
  /** Is the two-column layout on screen? (Hidden on a phone.) */
5594
5604
  const railShown = () => getComputedStyle(railEl).display !== "none";
@@ -5637,10 +5647,14 @@
5637
5647
  applyView();
5638
5648
  animateViewSwitch(from, currentView());
5639
5649
  // Picking a group shows one of ITS agents: staying on an agent that is no
5640
- // longer in the list would leave the chat and the list disagreeing.
5650
+ // longer in the list would leave the chat and the list disagreeing. Return
5651
+ // to the agent you last had focused in this group rather than snapping to
5652
+ // the top one every time (focusTarget falls back to the first).
5641
5653
  if (follow && active && !active.btnEl.closest("#tweakSlot") && viewOfTab(active) !== currentView()) {
5642
- const first = tabsInView(currentView())[0];
5643
- if (first) activate(first);
5654
+ const inView = tabsInView(currentView());
5655
+ const wantId = window.focusTarget(inView.map((t) => t.sessionId), lastAgentByView[currentView()]);
5656
+ const pick = inView.find((t) => t.sessionId === wantId) || inView[0];
5657
+ if (pick) activate(pick);
5644
5658
  }
5645
5659
  }
5646
5660
  /** Whatever opens an agent (a click, a link, a notification) brings its group. */
@@ -6320,6 +6334,9 @@
6320
6334
  persistDraft(active);
6321
6335
  }
6322
6336
  active = tab;
6337
+ // Remember this as the group's last-focused agent, so returning to the
6338
+ // group comes back to it rather than the top one (consumed by setView).
6339
+ if (tab.sessionId) lastAgentByView[viewOfTab(tab)] = tab.sessionId;
6323
6340
  showTabGroup(tab);
6324
6341
  // A reload must come back to the channel you were watching: remember its
6325
6342
  // sessionId (outside the initial restore, which replays the activates itself).