shadok-ai 0.17.54 → 0.17.56

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.
@@ -33,6 +33,22 @@ export declare function profileWriteRefusal(i: {
33
33
  fromBrowser: boolean;
34
34
  role: Role | null;
35
35
  }): Refusal;
36
+ /**
37
+ * `PUT /profiles/prompt` — the agent-side prompt write (invariant 26).
38
+ *
39
+ * In multi-tenant it is refused outright. Profiles are GLOBAL and any agent may
40
+ * be spawned on any of them, so "its own profile" is a role every group can
41
+ * carry: an agent rewriting it — or, under the lead profile, rewriting ANY role
42
+ * — plants instructions that other groups' agents (private ones included) load
43
+ * through `--append-system-prompt` at their next spawn, as their OS user, with
44
+ * their secrets. That is the exact write `profileWriteRefusal` reserves to an
45
+ * admin person; this route was the side door around it. Scoping the edit to
46
+ * "profiles only my group uses" does not close it: the next spawn elsewhere can
47
+ * still pick the role. Mono-tenant keeps the rule — there is no wall to cross.
48
+ */
49
+ export declare function promptWriteRefusal(i: {
50
+ mode: DeploymentMode;
51
+ }): Refusal;
36
52
  /**
37
53
  * `DELETE /profiles`. It had no check at all: a read-only agent could delete
38
54
  * its own profile, `POST /reload`, and come back with no deny list — invariant
@@ -15,6 +15,27 @@ export function profileWriteRefusal(i) {
15
15
  return { status: 403, error: "only an admin can edit profiles on a multi-tenant instance" };
16
16
  return null;
17
17
  }
18
+ /**
19
+ * `PUT /profiles/prompt` — the agent-side prompt write (invariant 26).
20
+ *
21
+ * In multi-tenant it is refused outright. Profiles are GLOBAL and any agent may
22
+ * be spawned on any of them, so "its own profile" is a role every group can
23
+ * carry: an agent rewriting it — or, under the lead profile, rewriting ANY role
24
+ * — plants instructions that other groups' agents (private ones included) load
25
+ * through `--append-system-prompt` at their next spawn, as their OS user, with
26
+ * their secrets. That is the exact write `profileWriteRefusal` reserves to an
27
+ * admin person; this route was the side door around it. Scoping the edit to
28
+ * "profiles only my group uses" does not close it: the next spawn elsewhere can
29
+ * still pick the role. Mono-tenant keeps the rule — there is no wall to cross.
30
+ */
31
+ export function promptWriteRefusal(i) {
32
+ if (i.mode === "multi-tenant")
33
+ return {
34
+ status: 403,
35
+ error: "profiles are shared by every group on a multi-tenant instance — an admin edits their prompts from the web UI",
36
+ };
37
+ return null;
38
+ }
18
39
  /**
19
40
  * `DELETE /profiles`. It had no check at all: a read-only agent could delete
20
41
  * its own profile, `POST /reload`, and come back with no deny list — invariant
@@ -1 +1 @@
1
- {"version":3,"file":"route-guards.js","sourceRoot":"","sources":["../src/route-guards.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAoE;IACtG,IAAI,CAAC,CAAC,CAAC,WAAW;QAChB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,6EAA6E,EAAE,CAAC;IAC/G,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;QACjD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,4DAA4D,EAAE,CAAC;IAC9F,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,CAA8C;IACjF,IAAI,CAAC,CAAC,CAAC,WAAW;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC;IAC/F,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;IAC5F,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAA8C;IAC7E,OAAO,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC;AA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,CAAC,CAAC,mCAAmC,CAAC;AACvH,CAAC"}
package/dist/server.js CHANGED
@@ -71,7 +71,7 @@ import { ledgerFileFor, scopeVisible, recordIntoTable, saveLedger, mintLedgerId,
71
71
  // The skill's pure core is the single source of the ledger's logic (CLAUDE.md):
72
72
  // the server imports it rather than keeping a second copy of the kind inference.
73
73
  import { rowKind } from "../context/ledger-skill/ledger-core.mjs";
74
- import { profileWriteRefusal, profileDeleteRefusal, mayReadMcpValues, redactMcpServers, setProfileRefusal, restartAllPlan, monoSecretRefusal, } from "./route-guards.js";
74
+ import { profileWriteRefusal, profileDeleteRefusal, promptWriteRefusal, mayReadMcpValues, redactMcpServers, setProfileRefusal, restartAllPlan, monoSecretRefusal, } from "./route-guards.js";
75
75
  import { linkRefusal, markAgentPrompt, notificationText, } from "./kinship.js";
76
76
  import { talkVerdict, talkLetter } from "./talk.js";
77
77
  import { loadConfig, saveConfig, telegramConfig, applyTelegramPatch, titleForCwd, setTitleForCwd, instanceContextForCwd, setInstanceContextForCwd, themeForCwd, setThemeForCwd, mutedForCwd, setMutedForCwd, agentAuthForCwd, setAgentAuthForCwd, twoFactorForCwd, setTwoFactorForCwd, backendForCwd, setBackendForCwd, } from "./config.js";
@@ -4696,6 +4696,11 @@ app.put("/profiles/prompt", (req, res) => {
4696
4696
  const id = localSessionForKey(req, key);
4697
4697
  if (!id)
4698
4698
  return res.status(403).json({ error: "unknown or missing session key" });
4699
+ // Profiles are global: in multi-tenant this write crosses every group's wall
4700
+ // (invariant 63) — refused before any per-profile rule is consulted.
4701
+ const modeRefusal = promptWriteRefusal({ mode: DEPLOYMENT_MODE });
4702
+ if (modeRefusal)
4703
+ return res.status(modeRefusal.status).json({ error: modeRefusal.error });
4699
4704
  const caller = sessions.get(id)?.profile ?? loadChannels().find((c) => c.sessionId === id)?.profile ?? null;
4700
4705
  const target = typeof b.name === "string" && b.name.trim() ? b.name.trim() : (caller ?? "");
4701
4706
  const existing = target ? getProfile(target) : undefined;