shadok-ai 0.20.15 → 0.20.16

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
@@ -454,7 +454,11 @@ Enter to skip; you can add it later from the web UI).
454
454
  served back to the browser by `GET /media/<name>` from the same directory
455
455
  Telegram attachments land in. On a multi-tenant instance each group has its own
456
456
  media directory (`/media/g-<group>/<name>`), readable only by that group's
457
- agents and served only to people who can see that group.
457
+ agents and served only to people who can see that group. Every agent is
458
+ started with that directory as an extra working directory (`--add-dir`), so
459
+ it reads what you sent **without asking for permission** — and nothing is
460
+ written into its project or worktree. An agent started before this change
461
+ needs one *Reload agent* to pick it up.
458
462
  - **Files an agent hands you** — when an agent's result IS a file (a report, an
459
463
  export, a screenshot, an archive) it arrives as a download card in the chat,
460
464
  inline if it is an image, and as an upload in the Telegram topic. It goes
@@ -74,3 +74,15 @@ export declare function mediaServable(st: {
74
74
  isSymbolicLink: boolean;
75
75
  uid: number;
76
76
  }, multiTenant: boolean, serverUid: number): boolean;
77
+ /**
78
+ * The `--add-dir` pair that lets an agent READ its attachments without a
79
+ * permission prompt. A pasted or Telegram file lands in the media directory,
80
+ * which is outside the agent's working directory, so Claude Code asked before
81
+ * every read of a file the person had just handed over. Writing attachments
82
+ * into the cwd instead was rejected: it litters every worktree (and a worktree
83
+ * holding untracked files is no longer pruned on close, invariant 5) and risks
84
+ * a commit of someone's screenshot. Empty when there is no directory to add —
85
+ * `--add-dir` refuses a path that does not exist, and a refused flag must never
86
+ * cost the spawn.
87
+ */
88
+ export declare function mediaAddDirArgs(dir: string | null | undefined): string[];
@@ -100,4 +100,18 @@ export function mediaServable(st, multiTenant, serverUid) {
100
100
  return false;
101
101
  return !multiTenant || st.uid === serverUid;
102
102
  }
103
+ /**
104
+ * The `--add-dir` pair that lets an agent READ its attachments without a
105
+ * permission prompt. A pasted or Telegram file lands in the media directory,
106
+ * which is outside the agent's working directory, so Claude Code asked before
107
+ * every read of a file the person had just handed over. Writing attachments
108
+ * into the cwd instead was rejected: it litters every worktree (and a worktree
109
+ * holding untracked files is no longer pruned on close, invariant 5) and risks
110
+ * a commit of someone's screenshot. Empty when there is no directory to add —
111
+ * `--add-dir` refuses a path that does not exist, and a refused flag must never
112
+ * cost the spawn.
113
+ */
114
+ export function mediaAddDirArgs(dir) {
115
+ return dir ? ["--add-dir", dir] : [];
116
+ }
103
117
  //# sourceMappingURL=media-scope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"media-scope.js","sourceRoot":"","sources":["../src/media-scope.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AAEH;0EAC0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAE5D;;;uDAGuD;AACvD,MAAM,UAAU,aAAa,CAAC,OAAkC;IAC9D,MAAM,EAAE,GAAG,OAAO,IAAI,aAAa,CAAC;IACpC,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,kBAAkB,GAAG,EAAE,CAAC;IACrE,OAAO,kBAAkB,GAAG,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAkC,EAAE,WAAoB;IACrG,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IA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;AACH,MAAM,UAAU,YAAY,CAAC,GAAkB;IAC7C,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,EAAkE,EAAE,SAAiB;IACnH,OAAO,EAAE,CAAC,WAAW,IAAI,CAAC,EAAE,CAAC,cAAc,IAAI,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,EAA6D,EAC7D,WAAoB,EACpB,SAAiB;IAEjB,IAAI,EAAE,CAAC,cAAc,IAAI,CAAC,EAAE,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAClD,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,GAA8B;IAC5D,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvC,CAAC"}
package/dist/server.js CHANGED
@@ -77,7 +77,7 @@ import { RoomStore, canSeeRoom, isRoomId, newRoomId, pageMessages, patchRoomIn,
77
77
  import { viewerFor, canResumeAs, canRestartInto, canSeeGroup, membershipVerdict, canSeeSession, spawnGroupFor, listableGroups, visibleChannels, secretOwnGroupIds, ledgerGroupsFor, groupsPutFlow, privateGroupFor, newPrivateGroup, accountDeleteGroups, orphanedGroupsHeal, MAIN_GROUP_ID, groupMoveRefusal, isAgentViewer, canWriteSecretGroup, } from "./groups.js";
78
78
  import { resolveSpawnIsolation, osUserFor, homeForUser, tierStateDir, tierStateDirAction, runAsUser, provisionGroupUser, teardownGroupUser, reconcileGroupProvisioning, DEFAULT_HOME_BASE, createGroupFlow, deleteGroupFlow, SHARED_POT_GROUP, DEFAULT_SHARED_POT_PATH, } from "./osusers.js";
79
79
  import { mayActOnSession, cronCheckAllowed, mayReachGroup, osUserForChannelGroup, cronCheckEnv, cronCheckCommand, statAsUserArgv, parseStatOutput, readAsUserArgv, writeNewAsUserArgv, sameOfferedFile, } from "./group-exec.js";
80
- import { mediaDirForGroup, mediaFileMode, parseMediaRequest, groupForMediaKey, passwdGid, mediaDirSpec, mediaDirTrusted, mediaServable, } from "./media-scope.js";
80
+ import { mediaDirForGroup, mediaFileMode, parseMediaRequest, groupForMediaKey, passwdGid, mediaDirSpec, mediaDirTrusted, mediaServable, mediaAddDirArgs, } from "./media-scope.js";
81
81
  import { runPrivileged, TREE_OP_TIMEOUT_MS } from "./privileged.js";
82
82
  import { HOME_SKILLS_BASE, missingHomeSkillLinks, rewriteSkillsBase } from "./skill-paths.js";
83
83
  import { instanceKey } from "./paths.js";
@@ -9350,8 +9350,8 @@ function ensureTierStateDir(user, home) {
9350
9350
  console.log(`osusers: could not secure ${dir} for ${user} — ${e instanceof Error ? e.message : String(e)}`);
9351
9351
  }
9352
9352
  }
9353
- function seedGroupAgentHome(user, home, cwd) {
9354
- const cwds = new Set([cwd]);
9353
+ function seedGroupAgentHome(user, home, cwd, extraTrusted = []) {
9354
+ const cwds = new Set([cwd, ...extraTrusted]);
9355
9355
  const siblings = dropUserCwds().get(user);
9356
9356
  if (siblings)
9357
9357
  for (const c of siblings)
@@ -9515,6 +9515,26 @@ group) {
9515
9515
  // and only for a dropped agent, so a mono-tenant/root spawn stays byte-for-byte
9516
9516
  // as before. See `resolveSpawnModel`.
9517
9517
  const resolvedProfile = effectiveProfile(profile);
9518
+ // The directory this agent's attachments are written to (its group's in
9519
+ // multi-tenant, invariant 60), granted as an extra working directory so
9520
+ // reading a file the person just pasted asks for no permission. Best-effort:
9521
+ // a group that vanished keeps the old behaviour (a prompt), never a failed spawn.
9522
+ let mediaDirArg = null;
9523
+ try {
9524
+ mediaDirArg = DEPLOYMENT_MODE === "multi-tenant" ? mediaDirForGroupId(group ?? null) : mediaDirForSession(null);
9525
+ }
9526
+ catch (e) {
9527
+ console.warn(`media: no --add-dir for ${id.slice(0, 8)} (${e instanceof Error ? e.message : String(e)})`);
9528
+ }
9529
+ // An `--add-dir` directory Claude Code has never seen opens a BLOCKING
9530
+ // "Adding a new directory … do you trust it?" screen at spawn, with "No, exit"
9531
+ // preselected — every agent stopped there, and one Enter ended it (the first
9532
+ // version of this shipped without the seed and was reverted). It reads the
9533
+ // same `projects[<dir>].hasTrustDialogAccepted` a worktree's trust does, so
9534
+ // seed it the same way: here for an agent running as the server user, and in
9535
+ // `seedGroupAgentHome` below for a dropped one, which reads its own HOME.
9536
+ if (mediaDirArg)
9537
+ ensureProjectTrusted(mediaDirArg);
9518
9538
  const spawnModel = resolveSpawnModel({
9519
9539
  requested: model,
9520
9540
  profileModel: resolvedProfile?.model,
@@ -9525,6 +9545,9 @@ group) {
9525
9545
  // (src/prompt-args.ts), which silently dropped the role and the pilot prompt.
9526
9546
  const fullArgs = mergeAppendedPrompts([
9527
9547
  ...args,
9548
+ // A flag+value pair placed early: `--add-dir` is variadic, so it must be
9549
+ // followed by another flag, never by a bare word it would swallow.
9550
+ ...mediaAddDirArgs(mediaDirArg),
9528
9551
  ...permissionModeArgs(permissionMode),
9529
9552
  // A flag+value pair, before the profile's flags: nothing here can land
9530
9553
  // after `--mcp-config`'s variadic JSON as a bare word.
@@ -9568,7 +9591,7 @@ group) {
9568
9591
  // the per-HOME onboarding/trust state needs seeding into the group user's HOME.
9569
9592
  // The group also gets its OWN SSH identity (one key per group).
9570
9593
  if (user && home) {
9571
- seedGroupAgentHome(user, home, cwd);
9594
+ seedGroupAgentHome(user, home, cwd, mediaDirArg ? [mediaDirArg] : []);
9572
9595
  ensureAgentSshKey(user, home);
9573
9596
  }
9574
9597
  // Isolated groups share the subscription token, injected in the forced-last