shadok-ai 0.20.39 → 0.20.40

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
@@ -1130,9 +1130,9 @@ see it:
1130
1130
  - **External** — for **strangers**: the group holds the conversations of people
1131
1131
  who write to an open door (WhatsApp, Telegram), and **each conversation is
1132
1132
  sealed from the others** — its own OS user, its own home, its own files and
1133
- attachments. Its members see them all, which is the point: you read those
1134
- conversations in the cockpit and take over. Chosen when you create the group
1135
- and never converted afterwards.
1133
+ attachments, and its own slice of the secret vault. Its members see them all,
1134
+ which is the point: you read those conversations in the cockpit and take over.
1135
+ Chosen when you create the group and never converted afterwards.
1136
1136
  - **Public** — everyone. `Main` is the default public group.
1137
1137
 
1138
1138
  You see and drive only your own groups plus the public ones; that covers the
@@ -1142,7 +1142,23 @@ user** with its own home and secrets, never as root — per group, or per
1142
1142
  conversation in an External one. An External group carries no shared ledger at
1143
1143
  all (a stranger's conversation is nobody's coordination log), and its door's
1144
1144
  profile may hold **no secret**: every guest runs the same profile, so a secret
1145
- on it would be a credential handed to every stranger. Crossing a wall is always a deliberate act:
1145
+ on it would be a credential handed to every stranger.
1146
+
1147
+ A guest's agent CAN keep a credential of its own, so the person does not have to
1148
+ send the same token again on their next message. It goes into that
1149
+ conversation's own slice of the vault, and that slice is sealed both ways:
1150
+ nothing of yours resolves into it (not the commons, not `Main`, not a secret
1151
+ lent to the group), and nothing in it resolves out — a guest cannot share it or
1152
+ attach it to a profile. It is capped (10 entries, 4 KiB a value), the person is
1153
+ told once that you are keeping it, and **it is erased when their agent is
1154
+ deleted** — their folder and their OS user survive, their credentials do not. In
1155
+ the vault panel you see those names under *Stored by guests*, never a value, and
1156
+ you can rotate or delete them; adding one to someone else's conversation is
1157
+ refused. The group itself has no vault — every slice belongs to a conversation —
1158
+ so a secret stored on it would reach nobody, and shadok says so instead of
1159
+ storing it.
1160
+
1161
+ Crossing a wall is always a deliberate act:
1146
1162
  drop a file in the shared `~/shared/` folder, record a ledger line with
1147
1163
  `--public`, push a branch, or message an agent (public groups freely, restricted
1148
1164
  ones only with a handle they gave you; private groups cannot be messaged).
@@ -0,0 +1,126 @@
1
+ import { type UnitId } from "./isolation-unit.js";
2
+ /**
3
+ * What a STRANGER may put in the operator's vault, and who may touch it.
4
+ *
5
+ * Step 3 gave an external group's conversation a Unix account, a HOME and a
6
+ * media directory of its own (`src/isolation-unit.ts`). This file carries the
7
+ * last store it was missing: a slice of the central vault, so a guest's agent
8
+ * can keep a credential it obtained and the person does not have to hand it
9
+ * over again on their next message.
10
+ *
11
+ * The vault itself does not change shape — it is already keyed by owner
12
+ * (`Vault = { [owner]: GroupVault }`), and an isolation unit is a string it can
13
+ * take. What changes is the POLICY, and it lives here because it is the first
14
+ * vault policy whose subject is not a tenant of this instance:
15
+ *
16
+ * - a stranger can now write to the operator's disk through a route, which was
17
+ * never true before — hence the quotas;
18
+ * - a stranger's slice must not be reachable from any other slice, in either
19
+ * direction — hence the boxed resolution in `src/secrets.ts`;
20
+ * - and a stranger is not a member, so the usual "your group's secrets are
21
+ * yours" rule does not say who may touch the slice — hence the write rules
22
+ * below.
23
+ *
24
+ * Pure and dependency-free, like `isolation-unit.ts`: the whole policy is
25
+ * testable with no server, no root and no vault on disk.
26
+ *
27
+ * See docs/superpowers/specs/2026-11-26-external-groups-per-conversation-isolation-design.md,
28
+ * decisions 4, 6 and 7.
29
+ */
30
+ export interface GuestSecretLimits {
31
+ /** How many names one conversation may hold. */
32
+ entries: number;
33
+ /** How large one value may be, in bytes of UTF-8. */
34
+ valueBytes: number;
35
+ }
36
+ /**
37
+ * The ceiling on a guest's slice. Not a guess at what a credential needs: it is
38
+ * what a conversation can cost the operator before it is abuse. A handful of
39
+ * tokens is a real need (an API key, a refresh token, a webhook URL); a hundred
40
+ * is someone using the vault as storage, and 4 KiB is already far past any
41
+ * credential format — a PEM private key fits in it.
42
+ *
43
+ * Deliberately NOT adjustable per door, unlike the admission ceiling
44
+ * (`GUEST_LIMITS`): that one caps a cost the operator feels (Unix accounts,
45
+ * homes, concurrent agents) and an operator legitimately wants it wider. This
46
+ * one caps what a stranger writes to disk, and an operator has no reason to want
47
+ * that wider — if one ever does, it is a per-door `limits` field like the other.
48
+ */
49
+ export declare const GUEST_SECRET_LIMITS: GuestSecretLimits;
50
+ /** Is this unit ONE CONVERSATION's slice (as opposed to a whole group's)? */
51
+ export declare function isGuestSlice(unit: UnitId): boolean;
52
+ /**
53
+ * Why this write into a guest's slice is over quota, or null when it fits.
54
+ *
55
+ * Returned to the agent rather than swallowed: an agent told "stored" while
56
+ * nothing was stored asks the person for the credential again on the next
57
+ * message and gets the same answer for ever. The refusal says which ceiling and
58
+ * what the number is, because an agent that knows the cap can split a value or
59
+ * drop a stale name on its own.
60
+ *
61
+ * `names` is the slice's CURRENT names; `creating` distinguishes a new name
62
+ * (which consumes an entry) from an overwrite (which does not).
63
+ */
64
+ export declare function guestSecretQuotaRefusal(input: {
65
+ names: readonly string[];
66
+ value: string;
67
+ creating: boolean;
68
+ limits?: GuestSecretLimits;
69
+ }): string | null;
70
+ /** The vault mutations a guest slice can be the target of. */
71
+ export type GuestSliceOp = "create" | "overwrite" | "delete" | "share" | "bind";
72
+ /**
73
+ * Why a mutation of a GUEST's slice is refused, or null when it may go ahead.
74
+ * Returns null immediately for a unit that is not a guest slice, so a caller can
75
+ * apply it to every vault write without asking whether it is relevant.
76
+ *
77
+ * `callerUnit` is the AGENT's own unit, derived server-side from its session —
78
+ * never a value a client sent. `null` means a person, from the web UI.
79
+ *
80
+ * Three rules, and the ORDER is load-bearing:
81
+ *
82
+ * 1. **A guest's slice is never shared out and never bound to a profile — by
83
+ * ANYONE, its own agent included.** Both are how a credential reaches agents
84
+ * OTHER than the owner's, and the whole point of the slice is that nothing
85
+ * else reaches it. This is checked FIRST, ahead of the own-slice allowance
86
+ * below, and that is not a style choice: `sharedWith` is read from the SHARING
87
+ * side (`resolveSecretEntry` scans every slice for one lent to the caller), so
88
+ * a guest's agent allowed to share its own entry could lend the operator's
89
+ * own agents a value of its choosing under a name of its choosing — and for
90
+ * a name Main does not already hold, those agents would receive the
91
+ * stranger's value. Injection inside the conversation needs neither route:
92
+ * the slice is already exactly one guest's (`secretNamesForProfile`).
93
+ * 2. **An agent otherwise touches only its OWN slice.** The server-side
94
+ * derivation already makes another slice unnameable, so this is a fail-closed
95
+ * restatement rather than a wall — but it is what would catch a future caller
96
+ * resolving the unit from something a client can influence.
97
+ * 3. **A person may rotate and delete, not create.** The design decided that
98
+ * members see the names and "can rotate and delete" — the operator is
99
+ * accountable for what their instance holds, and a slice nobody can empty is
100
+ * that accountability removed. Whether a member may *hand a credential in*
101
+ * is a different act and is still **[OPEN]** in the design, so creating a
102
+ * name in someone else's slice is refused, with the reason said out loud.
103
+ */
104
+ export declare function guestSliceWriteRefusal(input: {
105
+ unit: UnitId;
106
+ op: GuestSliceOp;
107
+ callerUnit: UnitId | null;
108
+ }): string | null;
109
+ /**
110
+ * Why the vault holds no slice for a whole EXTERNAL group, or null when the
111
+ * unit is fine.
112
+ *
113
+ * An external group is never a vault key: its agents resolve their OWN
114
+ * conversation's slice and nothing else (`resolveSecretEntry`). So a secret
115
+ * written under the group id would sit in a tenant no agent ever reads — stored,
116
+ * listed, apparently working, and reaching nobody. That is the worst way for a
117
+ * credential store to be wrong: the operator believes the value is in place and
118
+ * goes looking elsewhere for why it is not.
119
+ *
120
+ * Refused rather than redirected: there is no conversation to redirect it to —
121
+ * "the group's agents" is a different one for every stranger on the door.
122
+ */
123
+ export declare function externalGroupSliceRefusal(input: {
124
+ unit: UnitId;
125
+ external: boolean;
126
+ }): string | null;
@@ -0,0 +1,112 @@
1
+ import { unitConversation } from "./isolation-unit.js";
2
+ /**
3
+ * The ceiling on a guest's slice. Not a guess at what a credential needs: it is
4
+ * what a conversation can cost the operator before it is abuse. A handful of
5
+ * tokens is a real need (an API key, a refresh token, a webhook URL); a hundred
6
+ * is someone using the vault as storage, and 4 KiB is already far past any
7
+ * credential format — a PEM private key fits in it.
8
+ *
9
+ * Deliberately NOT adjustable per door, unlike the admission ceiling
10
+ * (`GUEST_LIMITS`): that one caps a cost the operator feels (Unix accounts,
11
+ * homes, concurrent agents) and an operator legitimately wants it wider. This
12
+ * one caps what a stranger writes to disk, and an operator has no reason to want
13
+ * that wider — if one ever does, it is a per-door `limits` field like the other.
14
+ */
15
+ export const GUEST_SECRET_LIMITS = { entries: 10, valueBytes: 4096 };
16
+ /** Is this unit ONE CONVERSATION's slice (as opposed to a whole group's)? */
17
+ export function isGuestSlice(unit) {
18
+ return unitConversation(unit) !== null;
19
+ }
20
+ /** UTF-8 byte length — a value is stored and injected as bytes, and a quota
21
+ * counted in UTF-16 code units would let an emoji-heavy value double it. */
22
+ function byteLength(s) {
23
+ return new TextEncoder().encode(s).length;
24
+ }
25
+ /**
26
+ * Why this write into a guest's slice is over quota, or null when it fits.
27
+ *
28
+ * Returned to the agent rather than swallowed: an agent told "stored" while
29
+ * nothing was stored asks the person for the credential again on the next
30
+ * message and gets the same answer for ever. The refusal says which ceiling and
31
+ * what the number is, because an agent that knows the cap can split a value or
32
+ * drop a stale name on its own.
33
+ *
34
+ * `names` is the slice's CURRENT names; `creating` distinguishes a new name
35
+ * (which consumes an entry) from an overwrite (which does not).
36
+ */
37
+ export function guestSecretQuotaRefusal(input) {
38
+ const limits = input.limits ?? GUEST_SECRET_LIMITS;
39
+ const size = byteLength(input.value);
40
+ if (size > limits.valueBytes)
41
+ return `that value is ${size} bytes and the limit for one secret in this conversation is ${limits.valueBytes}`;
42
+ if (input.creating && input.names.length >= limits.entries)
43
+ return `this conversation already holds ${input.names.length} secrets, which is the limit (${limits.entries}) — delete one before storing another`;
44
+ return null;
45
+ }
46
+ /**
47
+ * Why a mutation of a GUEST's slice is refused, or null when it may go ahead.
48
+ * Returns null immediately for a unit that is not a guest slice, so a caller can
49
+ * apply it to every vault write without asking whether it is relevant.
50
+ *
51
+ * `callerUnit` is the AGENT's own unit, derived server-side from its session —
52
+ * never a value a client sent. `null` means a person, from the web UI.
53
+ *
54
+ * Three rules, and the ORDER is load-bearing:
55
+ *
56
+ * 1. **A guest's slice is never shared out and never bound to a profile — by
57
+ * ANYONE, its own agent included.** Both are how a credential reaches agents
58
+ * OTHER than the owner's, and the whole point of the slice is that nothing
59
+ * else reaches it. This is checked FIRST, ahead of the own-slice allowance
60
+ * below, and that is not a style choice: `sharedWith` is read from the SHARING
61
+ * side (`resolveSecretEntry` scans every slice for one lent to the caller), so
62
+ * a guest's agent allowed to share its own entry could lend the operator's
63
+ * own agents a value of its choosing under a name of its choosing — and for
64
+ * a name Main does not already hold, those agents would receive the
65
+ * stranger's value. Injection inside the conversation needs neither route:
66
+ * the slice is already exactly one guest's (`secretNamesForProfile`).
67
+ * 2. **An agent otherwise touches only its OWN slice.** The server-side
68
+ * derivation already makes another slice unnameable, so this is a fail-closed
69
+ * restatement rather than a wall — but it is what would catch a future caller
70
+ * resolving the unit from something a client can influence.
71
+ * 3. **A person may rotate and delete, not create.** The design decided that
72
+ * members see the names and "can rotate and delete" — the operator is
73
+ * accountable for what their instance holds, and a slice nobody can empty is
74
+ * that accountability removed. Whether a member may *hand a credential in*
75
+ * is a different act and is still **[OPEN]** in the design, so creating a
76
+ * name in someone else's slice is refused, with the reason said out loud.
77
+ */
78
+ export function guestSliceWriteRefusal(input) {
79
+ if (!isGuestSlice(input.unit))
80
+ return null;
81
+ if (input.op === "share")
82
+ return "a guest conversation's secret is never shared with another group — it belongs to that conversation alone";
83
+ if (input.op === "bind")
84
+ return "a guest conversation's secrets are injected into that conversation's own agents and nowhere else, so there is no profile to bind them to";
85
+ if (input.callerUnit !== null)
86
+ return input.callerUnit === input.unit
87
+ ? null
88
+ : "an agent can only reach its own conversation's secrets";
89
+ if (input.op === "create")
90
+ return "you can rotate or delete a secret a guest stored, but not add one to their conversation: handing a credential to a guest is not decided yet";
91
+ return null;
92
+ }
93
+ /**
94
+ * Why the vault holds no slice for a whole EXTERNAL group, or null when the
95
+ * unit is fine.
96
+ *
97
+ * An external group is never a vault key: its agents resolve their OWN
98
+ * conversation's slice and nothing else (`resolveSecretEntry`). So a secret
99
+ * written under the group id would sit in a tenant no agent ever reads — stored,
100
+ * listed, apparently working, and reaching nobody. That is the worst way for a
101
+ * credential store to be wrong: the operator believes the value is in place and
102
+ * goes looking elsewhere for why it is not.
103
+ *
104
+ * Refused rather than redirected: there is no conversation to redirect it to —
105
+ * "the group's agents" is a different one for every stranger on the door.
106
+ */
107
+ export function externalGroupSliceRefusal(input) {
108
+ if (!input.external || isGuestSlice(input.unit))
109
+ return null;
110
+ return "an external group has no vault of its own — each conversation has a slice only its own agents can read, so a secret stored on the group itself would reach nobody";
111
+ }
112
+ //# sourceMappingURL=guest-vault.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-vault.js","sourceRoot":"","sources":["../src/guest-vault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,qBAAqB,CAAC;AAsCpE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAExF,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AACzC,CAAC;AAED;6EAC6E;AAC7E,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAKvC;IACC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,mBAAmB,CAAC;IACnD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,IAAI,GAAG,MAAM,CAAC,UAAU;QAC1B,OAAO,iBAAiB,IAAI,+DAA+D,MAAM,CAAC,UAAU,EAAE,CAAC;IACjH,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO;QACxD,OAAO,mCAAmC,KAAK,CAAC,KAAK,CAAC,MAAM,iCAAiC,MAAM,CAAC,OAAO,uCAAuC,CAAC;IACrJ,OAAO,IAAI,CAAC;AACd,CAAC;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAItC;IACC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO;QACtB,OAAO,0GAA0G,CAAC;IACpH,IAAI,KAAK,CAAC,EAAE,KAAK,MAAM;QACrB,OAAO,0IAA0I,CAAC;IACpJ,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;QAC3B,OAAO,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,IAAI;YACpC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,wDAAwD,CAAC;IAC/D,IAAI,KAAK,CAAC,EAAE,KAAK,QAAQ;QACvB,OAAO,6IAA6I,CAAC;IACvJ,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAA0C;IAClF,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,mKAAmK,CAAC;AAC7K,CAAC"}
package/dist/secrets.d.ts CHANGED
@@ -1,13 +1,21 @@
1
1
  import { type Group, type Viewer } from "./groups.js";
2
+ import { type UnitId } from "./isolation-unit.js";
2
3
  /**
3
4
  * Central secret vault: named secrets stored OUTSIDE any repo at
4
5
  * ~/.shadok-ai/secrets.json (600) and injected as environment variables into an
5
6
  * agent's `claude` process at spawn — never written into the working directory.
6
7
  *
7
- * Per-GROUP: `{ groupId: { NAME: SecretEntry } }`. One server-owned file with
8
- * policy scoping (not one file per group). Names are unique PER GROUP, never
8
+ * Per ISOLATION UNIT: `{ unit: { NAME: SecretEntry } }`. One server-owned file
9
+ * with policy scoping (not one file per unit). Names are unique PER UNIT, never
9
10
  * global. A group may SHARE a secret by reference (`sharedWith`), and `Main`
10
11
  * is the instance-wide fallback. A profile lists the NAMES it wants injected.
12
+ *
13
+ * The unit is a GROUP id for every group but an external one, byte for byte as
14
+ * it always was — an existing instance's file is untouched by this. In an
15
+ * EXTERNAL group it is `"<group>/<conversation>"` (`src/isolation-unit.ts`), so
16
+ * a stranger gets a slice of their own, sealed from every other conversation:
17
+ * see `src/guest-vault.ts` for the policy that seals it, and the design's
18
+ * decisions 4 and 6.
11
19
  */
12
20
  /**
13
21
  * In a secret's `profiles`: "every profile" — injected into EVERY agent the
@@ -57,8 +65,8 @@ export declare function migrateFlatVault(flat: Record<string, string>, mainId: s
57
65
  * first match wins — or undefined. The single selection rule behind both the
58
66
  * value resolution and the profile-binding lookup, so they can never disagree.
59
67
  */
60
- export declare function resolveSecretEntry(vault: Vault, groupId: string, name: string, commonsIds?: readonly string[]): SecretEntry | undefined;
61
- export declare function resolveSecretValues(vault: Vault, groupId: string, names: readonly string[], commonsIds?: readonly string[]): Record<string, string>;
68
+ export declare function resolveSecretEntry(vault: Vault, unit: UnitId, name: string, commonsIds?: readonly string[]): SecretEntry | undefined;
69
+ export declare function resolveSecretValues(vault: Vault, unit: UnitId, names: readonly string[], commonsIds?: readonly string[]): Record<string, string>;
62
70
  /**
63
71
  * The secret NAMES to inject into an agent running `profileName` in `groupId`.
64
72
  *
@@ -69,7 +77,7 @@ export declare function resolveSecretValues(vault: Vault, groupId: string, names
69
77
  * binds this profile, UNION the legacy `profileSecrets` (kept so a mono-tenant /
70
78
  * flat instance, where the binding still lives on the profile, is unchanged).
71
79
  */
72
- export declare function secretNamesForProfile(vault: Vault, groupId: string, profileName: string, profileSecrets?: readonly string[], commonsIds?: readonly string[]): string[];
80
+ export declare function secretNamesForProfile(vault: Vault, unit: UnitId, profileName: string, profileSecrets?: readonly string[], commonsIds?: readonly string[]): string[];
73
81
  /**
74
82
  * Normalize a parsed secrets.json into the per-group vault. Accepts the current
75
83
  * nested shape (missing entry fields get safe defaults), today's flat
@@ -77,12 +85,16 @@ export declare function secretNamesForProfile(vault: Vault, groupId: string, pro
77
85
  * the last two are migrated into Main (per-repo: last value wins on a collision).
78
86
  */
79
87
  export declare function normalizeVault(raw: unknown, now?: number): Vault;
80
- export type SecretSource = "own" | "shared" | "main";
88
+ export type SecretSource = "own" | "shared" | "main" | "guest";
81
89
  export interface VisibleSecret {
82
90
  name: string;
83
91
  source: SecretSource;
84
92
  /** The group that OWNS the secret — omitted for a Main secret (`source:"main"`). */
85
93
  ownerGroup?: string;
94
+ /** Only on `source:"guest"` — the conversation whose slice holds it, and the
95
+ * unit a write must target. The name is all a member ever sees of it. */
96
+ conversation?: string;
97
+ unit?: string;
86
98
  /** Audit fields — metadata only, never the value. */
87
99
  createdBy: string;
88
100
  createdAt: number;
@@ -130,7 +142,20 @@ export declare function longLivedTokenInfo(vault: Vault, mode: "multi-tenant" |
130
142
  * own > shared > main. In mono-tenant the caller resolves to Main only, so this
131
143
  * returns exactly today's Main names, all tagged `main` — unchanged behaviour.
132
144
  */
133
- export declare function visibleSecrets(vault: Vault, ownGroupIds: ReadonlySet<string>, mainWritable?: boolean): VisibleSecret[];
145
+ export declare function visibleSecrets(vault: Vault, ownGroupIds: ReadonlySet<string>, mainWritable?: boolean, ownUnit?: UnitId | null): VisibleSecret[];
146
+ /**
147
+ * Pure: the units a secret may ACTUALLY be lent to, from what a caller asked.
148
+ *
149
+ * Its own owner is dropped because a secret is already resolvable by its owner.
150
+ * A GUEST CONVERSATION is dropped because a conversation's slice resolves to
151
+ * ITSELF only (`resolveSecretEntry`), so a row claiming to lend a secret to one
152
+ * would be stored, listed as shared — and reach nobody: a grant that reads as
153
+ * real and is not, which is the worst way for an access listing to be wrong.
154
+ * The panel cannot even offer it (`shareTargets` lists groups), so this only
155
+ * ever catches a hand-made call — which is exactly why it belongs in the data's
156
+ * own rule rather than in the UI.
157
+ */
158
+ export declare function shareableTargets(asked: readonly unknown[], owner: UnitId): string[];
134
159
  export type SecretWrite = "created" | "updated" | "refused";
135
160
  /**
136
161
  * Pure: what a write to `name` should do. Overwriting is the only destructive
@@ -143,10 +168,12 @@ export declare function secretWriteVerdict(exists: boolean, overwrite: boolean):
143
168
  * The group a secret WRITE lands in. For an agent this is derived SERVER-SIDE
144
169
  * from identity and is NON-NEGOTIABLE; for a browser it may be a client REQUEST
145
170
  * that the authorization gate (`secretWriteDecision`) still has to clear.
146
- * - an AGENT (`agentGroupId` present, even as null): its OWN channel's group,
147
- * or Main when it has none. A `requestedGroup` that differs is IGNORED — an
148
- * agent must never aim another tenant's vault by naming it in the body; it writes only its own group
149
- * (Task 10's agent-own-group rule, private included).
171
+ * - an AGENT (`agentGroupId` present, even as null): its OWN channel's
172
+ * ISOLATION UNIT — its group, or its own conversation in an external group
173
+ * — or Main when it has none. A `requestedGroup` that differs is IGNORED —
174
+ * an agent must never aim another tenant's vault by naming it in the body;
175
+ * it writes only its own unit (Task 10's agent-own-group rule, private
176
+ * included, and now one stranger's conversation at a time).
150
177
  * - a BROWSER (`agentGroupId` undefined): the group it REQUESTED (the panel's
151
178
  * selected group — a request, authorized separately), or, when omitted,
152
179
  * `spawnGroupFor` — the same identity-derived "your one group or the
@@ -182,15 +209,38 @@ export declare function secretWriteDecision(input: {
182
209
  };
183
210
  export declare function loadVault(): Vault;
184
211
  export declare function saveVault(v: Vault): void;
185
- /** Secret names (never the values) in one group's own slice, sorted. */
186
- export declare function secretNames(groupId?: string): string[];
212
+ /** Secret names (never the values) in one unit's own slice, sorted. */
213
+ export declare function secretNames(unit?: UnitId): string[];
214
+ /**
215
+ * Wipe a whole slice, returning the names it held.
216
+ *
217
+ * The one gesture behind "the slice dies with the agent" (design decision 7):
218
+ * a guest's Unix user and HOME SURVIVE their agent's deletion on purpose — the
219
+ * person comes back to their own folder — while the credentials they handed
220
+ * over do not. Minimum retention, and no orphaned stranger credentials left on
221
+ * the operator's disk.
222
+ *
223
+ * Returns the names so the caller can write one audit row: a credential that
224
+ * disappears with no trace is the one vault move nobody could account for.
225
+ */
226
+ export declare function deleteVaultSlice(unit: UnitId): string[];
227
+ /**
228
+ * Every GUEST CONVERSATION slice of a group, with the names each holds — what
229
+ * the vault panel lists for a member and what a group teardown has to sweep.
230
+ * Names only, like every listing: the values never leave this module.
231
+ */
232
+ export declare function guestSlicesOf(vault: Vault, groupId: string): {
233
+ unit: UnitId;
234
+ conversation: string;
235
+ names: string[];
236
+ }[];
187
237
  /**
188
238
  * Create or update a secret in `groupId` (default Main); an update keeps its
189
239
  * sharing, provenance and profile binding. `profiles` applies to a CREATION
190
240
  * only — it is how an agent's create-and-attach lands in one write.
191
241
  */
192
- export declare function setSecret(name: string, value: string, groupId?: string, createdBy?: string, profiles?: readonly string[]): void;
193
- export declare function deleteSecret(name: string, groupId?: string): void;
242
+ export declare function setSecret(name: string, value: string, unit?: UnitId, createdBy?: string, profiles?: readonly string[]): void;
243
+ export declare function deleteSecret(name: string, unit?: UnitId): void;
194
244
  /**
195
245
  * Replace a secret's `sharedWith` list (the groups it is lent to) — an
196
246
  * own-property write on the OWNER group's slice. Returns false when the secret
@@ -238,7 +288,7 @@ export declare function createAttachRefusal(opts: {
238
288
  * resolved from `groupId` (own → shared-in → Main). `groupId` defaults to Main,
239
289
  * which is every agent in a mono-tenant instance.
240
290
  */
241
- export declare function secretsFor(names: string[] | undefined, groupId?: string, commonsIds?: readonly string[]): Record<string, string>;
291
+ export declare function secretsFor(names: string[] | undefined, unit?: UnitId, commonsIds?: readonly string[]): Record<string, string>;
242
292
  /**
243
293
  * The `{NAME: value}` env for an agent running `profileName` in `groupId` — the
244
294
  * authoritative injection: every secret bound to the profile (`entry.profiles`,
@@ -247,4 +297,4 @@ export declare function secretsFor(names: string[] | undefined, groupId?: string
247
297
  * `profileSecrets` alone delivered nothing in grouped mode, where the binding
248
298
  * lives on the secret, not the profile.
249
299
  */
250
- export declare function secretsForProfile(profileName: string | null | undefined, profileSecrets: string[] | undefined, groupId?: string, commonsIds?: readonly string[]): Record<string, string>;
300
+ export declare function secretsForProfile(profileName: string | null | undefined, profileSecrets: string[] | undefined, unit?: UnitId, commonsIds?: readonly string[]): Record<string, string>;