shadok-ai 0.20.24 → 0.20.26

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
@@ -972,6 +972,10 @@ from the phone's *Linked devices* list too.
972
972
  someone who has (a schedule, a notification, you from the cockpit).
973
973
  - **Nothing is lost across a restart.** A message received while an agent was
974
974
  being started, or while the server was updating, is answered once it is back.
975
+ - **"Seen" means the agent has it.** A message's ticks turn blue once its
976
+ agent has actually taken it in (or it answered a question on screen) — not
977
+ when the server merely received it, and never with the door shut. If the
978
+ linked phone has read receipts turned off, nothing turns blue, as on the phone.
975
979
  - **Closing a guest's agent in the cockpit** ends that conversation: their next
976
980
  message starts a new agent. A link that drops ends nothing.
977
981
  - **Pictures, documents, voice notes and videos** reach the person's agent the
@@ -49,6 +49,12 @@ export declare function ownerGitCommand(owner: Owner, cwd: string, args: readonl
49
49
  argv: string[];
50
50
  env: Record<string, string>;
51
51
  };
52
+ /** Pure: the passwd row for user `name` as an `Owner`, or null when absent. */
53
+ export declare function passwdOwner(passwd: string, name: string): Owner | null;
54
+ /** The OS user `name` as an `Owner`, read from /etc/passwd; null when unknown. */
55
+ export declare function ownerByName(name: string): Owner | null;
56
+ /** Run `git -C cwd …args` AS `owner` (no root attempt first). */
57
+ export declare function gitAs(owner: Owner, cwd: string, args: readonly string[], opts?: Omit<ExecFileSyncOptionsWithStringEncoding, "encoding">): string;
52
58
  /** Who owns `dir`, when the server is root and that is someone else; else null. */
53
59
  export declare function foreignOwner(dir: string): Owner | null;
54
60
  /**
package/dist/git-exec.js CHANGED
@@ -57,6 +57,29 @@ export function ownerGitCommand(owner, cwd, args) {
57
57
  env,
58
58
  };
59
59
  }
60
+ /** Pure: the passwd row for user `name` as an `Owner`, or null when absent. */
61
+ export function passwdOwner(passwd, name) {
62
+ for (const line of passwd.split("\n")) {
63
+ const f = line.split(":");
64
+ if (f.length >= 6 && f[0] === name && /^\d+$/.test(f[2]) && /^\d+$/.test(f[3]))
65
+ return { uid: Number(f[2]), gid: Number(f[3]), name, home: f[5] || null };
66
+ }
67
+ return null;
68
+ }
69
+ /** The OS user `name` as an `Owner`, read from /etc/passwd; null when unknown. */
70
+ export function ownerByName(name) {
71
+ try {
72
+ return passwdOwner(fs.readFileSync("/etc/passwd", "utf8"), name);
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ }
78
+ /** Run `git -C cwd …args` AS `owner` (no root attempt first). */
79
+ export function gitAs(owner, cwd, args, opts = {}) {
80
+ const run = ownerGitCommand(owner, cwd, args);
81
+ return execFileSync(run.cmd, run.argv, { ...opts, encoding: "utf8", env: { ...process.env, ...run.env } });
82
+ }
60
83
  /** Who owns `dir`, when the server is root and that is someone else; else null. */
61
84
  export function foreignOwner(dir) {
62
85
  if (typeof process.getuid !== "function" || process.getuid() !== 0)
@@ -1 +1 @@
1
- {"version":3,"file":"git-exec.js","sourceRoot":"","sources":["../src/git-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA8C,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,uDAAuD;AACvD,MAAM,UAAU,kBAAkB,CAAC,CAAU;IAC3C,MAAM,GAAG,GAAG,CAAwC,CAAC;IACrD,OAAO,6BAA6B,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC;AASD,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,GAAW;IACrD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CA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;IACnC,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CACnB,GAAW,EACX,IAAuB,EACvB,IAAI,GAA4D,EAAE;IAElE,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAClF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAAE,MAAM,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK;YAAE,MAAM,CAAC,CAAC;QACpB,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC7G,CAAC;AACH,CAAC"}
package/dist/server.js CHANGED
@@ -108,7 +108,8 @@ import { AGENT_CREDENTIAL_VARS, agentAccount, headerPresent, isBrowserPerson, re
108
108
  import { admins2fa, authenticationOptions, enrollCodeVerdict, isInternalClient, keepsTwoAdminsVerdict, loginNext, newEnrollCode, publicPasskey, putChallenge, readPending, registrationOptions, resetVerdict, signPending, takeChallenge, twoFactorEnableVerdict, verifyAuthentication, verifyRegistration, PENDING_TTL_MS, } from "./twofactor.js";
109
109
  import { ensureSelfRepo } from "./selfrepo.js";
110
110
  import { supersedeSession } from "./live-handover.js";
111
- import { createWorktree, pruneWorktree, ensureWorktreeCheckout, gitDiff, isGitRepo, listPastSessions, } from "./worktree.js";
111
+ import { ownerByName } from "./git-exec.js";
112
+ import { createWorktree, createIsolatedClone, needsClone, pruneWorktree, ensureWorktreeCheckout, gitDiff, isGitRepo, listPastSessions, } from "./worktree.js";
112
113
  import { latestVersion, update } from "./updater.js";
113
114
  import { resolveAutoUpdate, resolveChannel } from "./update-channel.js";
114
115
  import { isNewer } from "./version.js";
@@ -11724,7 +11725,19 @@ wss.on("connection", (ws, req) => {
11724
11725
  // actually work in it instead of landing on the invalid-settings
11725
11726
  // screen. `agentStateHome(null)` is the server home, so mono-tenant
11726
11727
  // is byte-for-byte unchanged.
11727
- worktree = createWorktree(cwd, id.slice(0, 8), agentStateHome(earlyUser));
11728
+ // An agent running as ANOTHER OS user than the repo's owner (a
11729
+ // private or restricted group) gets a clone of its own instead:
11730
+ // it could neither create nor write a worktree of that repo
11731
+ // (`needsClone`).
11732
+ const dropOwner = earlyUser ? ownerByName(earlyUser) : null;
11733
+ let repoUid = null;
11734
+ try {
11735
+ repoUid = fs.statSync(cwd).uid;
11736
+ }
11737
+ catch { /* createWorktree reports it */ }
11738
+ worktree = needsClone(repoUid, dropOwner)
11739
+ ? createIsolatedClone(cwd, id.slice(0, 8), agentStateHome(earlyUser), dropOwner)
11740
+ : createWorktree(cwd, id.slice(0, 8), agentStateHome(earlyUser));
11728
11741
  effectiveCwd = worktree.path;
11729
11742
  await chownAgentStateToDropUser(worktree.path, earlyUser);
11730
11743
  }