shadok-ai 0.20.12 → 0.20.13

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
@@ -74,7 +74,7 @@ import { RoomStore, canSeeRoom, isRoomId, newRoomId, pageMessages, patchRoomIn,
74
74
  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";
75
75
  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";
76
76
  import { mayActOnSession, cronCheckAllowed, mayReachGroup, osUserForChannelGroup, cronCheckEnv, cronCheckCommand, statAsUserArgv, parseStatOutput, readAsUserArgv, writeNewAsUserArgv, sameOfferedFile, } from "./group-exec.js";
77
- import { mediaDirForGroup, mediaFileMode, parseMediaRequest, groupForMediaKey, passwdGid, mediaDirSpec, mediaDirTrusted, mediaServable, } from "./media-scope.js";
77
+ import { mediaDirForGroup, mediaFileMode, parseMediaRequest, groupForMediaKey, passwdGid, mediaDirSpec, mediaDirTrusted, mediaServable, mediaAddDirArgs, } from "./media-scope.js";
78
78
  import { runPrivileged, TREE_OP_TIMEOUT_MS } from "./privileged.js";
79
79
  import { HOME_SKILLS_BASE, missingHomeSkillLinks, rewriteSkillsBase } from "./skill-paths.js";
80
80
  import { instanceKey } from "./paths.js";
@@ -9417,6 +9417,17 @@ group) {
9417
9417
  // and only for a dropped agent, so a mono-tenant/root spawn stays byte-for-byte
9418
9418
  // as before. See `resolveSpawnModel`.
9419
9419
  const resolvedProfile = effectiveProfile(profile);
9420
+ // The directory this agent's attachments are written to (its group's in
9421
+ // multi-tenant, invariant 60), granted as an extra working directory so
9422
+ // reading a file the person just pasted asks for no permission. Best-effort:
9423
+ // a group that vanished keeps the old behaviour (a prompt), never a failed spawn.
9424
+ let mediaDirArg = null;
9425
+ try {
9426
+ mediaDirArg = DEPLOYMENT_MODE === "multi-tenant" ? mediaDirForGroupId(group ?? null) : mediaDirForSession(null);
9427
+ }
9428
+ catch (e) {
9429
+ console.warn(`media: no --add-dir for ${id.slice(0, 8)} (${e instanceof Error ? e.message : String(e)})`);
9430
+ }
9420
9431
  const spawnModel = resolveSpawnModel({
9421
9432
  requested: model,
9422
9433
  profileModel: resolvedProfile?.model,
@@ -9427,6 +9438,9 @@ group) {
9427
9438
  // (src/prompt-args.ts), which silently dropped the role and the pilot prompt.
9428
9439
  const fullArgs = mergeAppendedPrompts([
9429
9440
  ...args,
9441
+ // A flag+value pair placed early: `--add-dir` is variadic, so it must be
9442
+ // followed by another flag, never by a bare word it would swallow.
9443
+ ...mediaAddDirArgs(mediaDirArg),
9430
9444
  ...permissionModeArgs(permissionMode),
9431
9445
  // A flag+value pair, before the profile's flags: nothing here can land
9432
9446
  // after `--mcp-config`'s variadic JSON as a bare word.