shadok-ai 0.20.37 → 0.20.38
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 +15 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.js +17 -2
- package/dist/config.js.map +1 -1
- package/dist/guest-admit.d.ts +158 -0
- package/dist/guest-admit.js +151 -0
- package/dist/guest-admit.js.map +1 -0
- package/dist/server.js +106 -28
- package/dist/server.js.map +1 -1
- package/dist/telegram.js +20 -0
- package/dist/telegram.js.map +1 -1
- package/dist/tg-guests.d.ts +15 -1
- package/dist/tg-guests.js +20 -0
- package/dist/tg-guests.js.map +1 -1
- package/dist/wa-bridge.js +10 -0
- package/dist/wa-bridge.js.map +1 -1
- package/dist/wa-guests.js +3 -0
- package/dist/wa-guests.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -416,7 +416,17 @@ Enter to skip; you can add it later from the web UI).
|
|
|
416
416
|
They can talk and answer their agent's questions, and nothing else: no
|
|
417
417
|
command reaches the bot. Two things worth knowing before you open it — every
|
|
418
418
|
conversation is a real agent that stays resident, and they all draw on **your**
|
|
419
|
-
Claude subscription
|
|
419
|
+
Claude subscription.
|
|
420
|
+
There **is** a ceiling, and it is not a queue: **200 conversations at once**
|
|
421
|
+
and **30 new people an hour**, counted per group — so two doors onto one group
|
|
422
|
+
share one ceiling. Someone turned away is told in one line that nothing was
|
|
423
|
+
opened and to come back later; their message is not queued, and a person you
|
|
424
|
+
are already talking to is never turned away, whatever the ceiling says. Change
|
|
425
|
+
it per door with `limits` on the guest setup — `PUT /telegram`
|
|
426
|
+
(`{"guests": {…, "limits": {"live": 400, "perHour": 60}}}`) or
|
|
427
|
+
`PUT /whatsapp/guests` (`{…, "limits": {…}}`); `{"limits": {}}` goes back to
|
|
428
|
+
the defaults. The panel has no field for it yet, and saving from the panel
|
|
429
|
+
leaves what you set alone. Go back to
|
|
420
430
|
**Board group** and every such conversation is closed at once.
|
|
421
431
|
- **Link to a message** — every message (yours and the agent's, and a **room**'s
|
|
422
432
|
too) has a 🔗 link button beside copy. It copies a URL like
|
|
@@ -992,6 +1002,10 @@ from the phone's *Linked devices* list too.
|
|
|
992
1002
|
number) on another day. Only the group's members see those conversations
|
|
993
1003
|
(and the person's number), from the cockpit, like any other agent; what you
|
|
994
1004
|
type there reaches the person, labelled with your name.
|
|
1005
|
+
- **A ceiling, shared with Telegram's door.** 200 live conversations and 30 new
|
|
1006
|
+
people an hour by default, counted per group (see the Telegram door above for
|
|
1007
|
+
the numbers and how to change them). Someone turned away hears one line and is
|
|
1008
|
+
invited back later; someone you are already talking to is never turned away.
|
|
995
1009
|
- **A guest can only talk.** Nothing typed in WhatsApp is a command: a message
|
|
996
1010
|
starting with `/clear` or `/login` reaches the agent as text, and the server
|
|
997
1011
|
refuses a command from WhatsApp anyway. Groups, status, channels, calls and
|
package/dist/config.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface Config {
|
|
|
37
37
|
group?: string | null;
|
|
38
38
|
profile?: string | null;
|
|
39
39
|
joined?: boolean;
|
|
40
|
+
limits?: {
|
|
41
|
+
live?: number;
|
|
42
|
+
perHour?: number;
|
|
43
|
+
};
|
|
40
44
|
}>;
|
|
41
45
|
/**
|
|
42
46
|
* Per launch-directory WhatsApp guest door (`src/wa-guests.ts`): the same
|
|
@@ -49,6 +53,10 @@ export interface Config {
|
|
|
49
53
|
group?: string | null;
|
|
50
54
|
profile?: string | null;
|
|
51
55
|
joined?: boolean;
|
|
56
|
+
limits?: {
|
|
57
|
+
live?: number;
|
|
58
|
+
perHour?: number;
|
|
59
|
+
};
|
|
52
60
|
}>;
|
|
53
61
|
/** Optional GUI password (also settable via SHADOK_GUI_PASSWORD). */
|
|
54
62
|
guiPassword?: string;
|
package/dist/config.js
CHANGED
|
@@ -248,7 +248,15 @@ export function guestSetupForCwd(cfg, cwd) {
|
|
|
248
248
|
const group = typeof row.group === "string" && row.group.trim() ? row.group.trim() : null;
|
|
249
249
|
const profile = typeof row.profile === "string" && row.profile.trim() ? row.profile.trim() : null;
|
|
250
250
|
const mode = row.mode === undefined && row.on === true ? "group+dm" : normalizeTgMode(row.mode);
|
|
251
|
-
|
|
251
|
+
// The ceiling rides along untouched: `guestLimitsOf` is what reads it, and
|
|
252
|
+
// what is malformed there reads as unset rather than as a shut door.
|
|
253
|
+
return normalizeGuestSetup({
|
|
254
|
+
mode,
|
|
255
|
+
group,
|
|
256
|
+
profile,
|
|
257
|
+
joined: row.joined === true,
|
|
258
|
+
...(row.limits && typeof row.limits === "object" ? { limits: row.limits } : {}),
|
|
259
|
+
});
|
|
252
260
|
}
|
|
253
261
|
/**
|
|
254
262
|
* Pure: set this directory's Telegram mode and open-DM setup on `cfg` (caller
|
|
@@ -267,6 +275,7 @@ export function applyGuestSetup(cfg, cwd, s) {
|
|
|
267
275
|
group: s.group,
|
|
268
276
|
profile: s.profile,
|
|
269
277
|
...(s.joined ? { joined: true } : {}),
|
|
278
|
+
...(s.limits ? { limits: s.limits } : {}),
|
|
270
279
|
};
|
|
271
280
|
return cfg;
|
|
272
281
|
}
|
|
@@ -278,7 +287,13 @@ export function waGuestSetupForCwd(cfg, cwd) {
|
|
|
278
287
|
export function applyWaGuestSetup(cfg, cwd, s) {
|
|
279
288
|
cfg.whatsappGuests ??= {};
|
|
280
289
|
const w = waGuestSetup(s);
|
|
281
|
-
cfg.whatsappGuests[cwd] = {
|
|
290
|
+
cfg.whatsappGuests[cwd] = {
|
|
291
|
+
mode: w.mode,
|
|
292
|
+
group: w.group,
|
|
293
|
+
profile: w.profile,
|
|
294
|
+
...(w.joined ? { joined: true } : {}),
|
|
295
|
+
...(w.limits ? { limits: w.limits } : {}),
|
|
296
|
+
};
|
|
282
297
|
return cfg;
|
|
283
298
|
}
|
|
284
299
|
export function setWaGuestSetupForCwd(cfg, cwd, s) {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config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,KAAK,SAAS,IAAI,CAAC,WAAW;QAAE,OAAO;IAC5D,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,CAAC;QACH,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ;QAAE,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC;IAC/E,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,CAAC,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACjC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,2BAA2B;IACrD,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,0BAA0B;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;IACD,UAAU,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type GuestSetup } from "./tg-guests.js";
|
|
2
|
+
/**
|
|
3
|
+
* The admission ceiling of an open door: how many strangers it holds at once,
|
|
4
|
+
* and how fast it takes new ones.
|
|
5
|
+
*
|
|
6
|
+
* Both doors WERE uncapped by construction — "no cap on the number of guests, no
|
|
7
|
+
* queue, no per-person block" — and that was tenable while a guest cost a
|
|
8
|
+
* directory under a shared Unix user. It stopped being tenable in two steps. A
|
|
9
|
+
* guest already costs a `claude` process and a tmux pane, so anyone who
|
|
10
|
+
* knows the number can make the instance spawn until it falls over. And the
|
|
11
|
+
* external-group design makes a guest cost a `useradd`, i.e. a row in
|
|
12
|
+
* `/etc/passwd`, which is not a scratch resource: an uncapped door would then be
|
|
13
|
+
* a provisioning DoS reachable from a phone.
|
|
14
|
+
*
|
|
15
|
+
* So the cap lands BEFORE the wall it pays for — the design's step 2, built
|
|
16
|
+
* before step 3 on purpose. See
|
|
17
|
+
* docs/superpowers/specs/2026-11-26-external-groups-per-conversation-isolation-design.md,
|
|
18
|
+
* decision 3.
|
|
19
|
+
*
|
|
20
|
+
* Why its own module rather than `src/tg-guests.ts`, where the rest of the door
|
|
21
|
+
* lives: the occupancy count has to name a conversation on EITHER transport,
|
|
22
|
+
* and `wa-guests.ts` already imports `tg-guests.ts`. Putting it there would
|
|
23
|
+
* close an import cycle; here both name builders are reused as they are.
|
|
24
|
+
*
|
|
25
|
+
* Pure and dependency-free, like the two door modules, so the whole decision is
|
|
26
|
+
* unit-tested with no server, no bot and no phone.
|
|
27
|
+
*/
|
|
28
|
+
/** What one door admits at most. */
|
|
29
|
+
export interface GuestLimits {
|
|
30
|
+
/** Guest conversations alive in the group at once. */
|
|
31
|
+
live: number;
|
|
32
|
+
/** New conversations admitted per hour. */
|
|
33
|
+
perHour: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The defaults, settled with the operator: large enough that an ordinary flow
|
|
37
|
+
* never meets them, small enough that a flood stops costing at 30 accounts an
|
|
38
|
+
* hour. An instance holding 200 live guest conversations is already at the end
|
|
39
|
+
* of what one host runs; the point of the ceiling is that the 201st is a
|
|
40
|
+
* refusal and not a crash.
|
|
41
|
+
*/
|
|
42
|
+
export declare const GUEST_LIMITS: GuestLimits;
|
|
43
|
+
/** The window `perHour` is counted over. */
|
|
44
|
+
export declare const GUEST_RATE_WINDOW_MS = 3600000;
|
|
45
|
+
/** The refusal's `code` on the wire, so a bridge classifies it without
|
|
46
|
+
* matching on the message text (the `busy` convention). */
|
|
47
|
+
export declare const GUEST_FULL_CODE = "guest-full";
|
|
48
|
+
/**
|
|
49
|
+
* This door's limits: what the operator stored, else the defaults.
|
|
50
|
+
*
|
|
51
|
+
* A value that is not a positive integer reads as "not set" rather than as a
|
|
52
|
+
* refusal: the config file is hand-editable (`normalizeTgMode` makes the same
|
|
53
|
+
* choice), and a typo that silently shut the door would be indistinguishable
|
|
54
|
+
* from a bot that stopped working. Closing a door is what the MODE is for.
|
|
55
|
+
*
|
|
56
|
+
* There is deliberately no upper bound. An operator who raises the ceiling to
|
|
57
|
+
* a number their host cannot serve has made a decision about their own
|
|
58
|
+
* machine; pretending to know better would be the cosmetic cap of invariant 47.
|
|
59
|
+
*/
|
|
60
|
+
export declare function guestLimitsOf(setup: Pick<GuestSetup, "limits">): GuestLimits;
|
|
61
|
+
/**
|
|
62
|
+
* The ceiling a REQUEST asks for, or `undefined` when it names none.
|
|
63
|
+
*
|
|
64
|
+
* `undefined` is not "the defaults": a patch that does not mention the ceiling
|
|
65
|
+
* must leave the operator's numbers alone (`guestPatchFlow` keeps them,
|
|
66
|
+
* ASSERT-only like `branch` / `repo` / `parent` — invariant 19). An EMPTY
|
|
67
|
+
* object is the way back to the defaults, so there is a route out as well as in.
|
|
68
|
+
*
|
|
69
|
+
* Only positive integers survive; anything else is dropped rather than
|
|
70
|
+
* refused, for the reason `guestLimitsOf` gives.
|
|
71
|
+
*/
|
|
72
|
+
export declare function requestedLimits(b: Record<string, unknown>): Partial<GuestLimits> | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The conversation a channel belongs to, named the way its directory is
|
|
75
|
+
* (`tg-<id>` / `wa-<digits>`), or null when the channel is not a guest's.
|
|
76
|
+
*
|
|
77
|
+
* That name is the key the whole ceiling counts on, and it is REUSED rather
|
|
78
|
+
* than invented: it is already what makes a person come back to their own
|
|
79
|
+
* folder, it is rebuilt from untrusted input in one place, and two spellings of
|
|
80
|
+
* one id (a chat id as a number or as a string) collapse to one string there.
|
|
81
|
+
* Two keys for one person would be two admissions, i.e. a returning guest
|
|
82
|
+
* charged as a new one.
|
|
83
|
+
*
|
|
84
|
+
* It inherits that name's one limit, and the ceiling can say so honestly: a
|
|
85
|
+
* WhatsApp sender's LID and their phone address are two keys, as they are two
|
|
86
|
+
* directories. It costs nothing in practice — the same person is found by
|
|
87
|
+
* `findWaChannel` and RESUMED, which never reaches the ceiling — and at worst,
|
|
88
|
+
* with no channel row left, it charges one admission twice.
|
|
89
|
+
*
|
|
90
|
+
* The bindings are `SERVER_OWNED`, so no client can rename a conversation into
|
|
91
|
+
* a free slot.
|
|
92
|
+
*/
|
|
93
|
+
export declare function guestConversationKey(c: {
|
|
94
|
+
telegram?: {
|
|
95
|
+
chatId: number;
|
|
96
|
+
threadId?: number;
|
|
97
|
+
} | null;
|
|
98
|
+
whatsapp?: {
|
|
99
|
+
id: string;
|
|
100
|
+
} | null;
|
|
101
|
+
} | null | undefined): string | null;
|
|
102
|
+
/**
|
|
103
|
+
* The guest conversations this group is holding — as a SET of conversation
|
|
104
|
+
* keys, not a channel count.
|
|
105
|
+
*
|
|
106
|
+
* Deliberately per group rather than per door: the group is where a
|
|
107
|
+
* conversation costs something (a Unix user, a home, a vault slice at step 4),
|
|
108
|
+
* and two doors pointed at one group share that cost. Counting a door's own
|
|
109
|
+
* channels would let an operator double the ceiling by opening a second door
|
|
110
|
+
* onto the same group.
|
|
111
|
+
*
|
|
112
|
+
* The owner's own DM is excluded without having to know who the owner is: it
|
|
113
|
+
* lives in the board's group, never in the guest group, and only this group is
|
|
114
|
+
* counted.
|
|
115
|
+
*/
|
|
116
|
+
export declare function liveGuestKeys(list: readonly {
|
|
117
|
+
group?: string | null;
|
|
118
|
+
telegram?: {
|
|
119
|
+
chatId: number;
|
|
120
|
+
threadId?: number;
|
|
121
|
+
} | null;
|
|
122
|
+
whatsapp?: {
|
|
123
|
+
id: string;
|
|
124
|
+
} | null;
|
|
125
|
+
}[], groupId: string): Set<string>;
|
|
126
|
+
/** Why a stranger was not admitted. The person hears one line either way
|
|
127
|
+
* (`guestNotice("door-full")`); the two reasons are for the operator's log. */
|
|
128
|
+
export type GuestAdmit = {
|
|
129
|
+
ok: true;
|
|
130
|
+
returning: boolean;
|
|
131
|
+
} | {
|
|
132
|
+
ok: false;
|
|
133
|
+
why: "full" | "rate";
|
|
134
|
+
message: string;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* May this conversation be admitted?
|
|
138
|
+
*
|
|
139
|
+
* A **returning** conversation is never subject to either limit, and that is
|
|
140
|
+
* the load-bearing half: the cap exists to stop an unknown number of NEW
|
|
141
|
+
* strangers, never to cut off someone the instance is already talking to. A
|
|
142
|
+
* guest whose agent the operator deleted comes back through this path (their
|
|
143
|
+
* channel row went with it), so "returning" is asked on the conversation key
|
|
144
|
+
* and not on the presence of an agent.
|
|
145
|
+
*
|
|
146
|
+
* `recent` is the admission times of this group, newest or oldest first makes
|
|
147
|
+
* no difference: only how many fall inside the window counts.
|
|
148
|
+
*/
|
|
149
|
+
export declare function guestAdmitVerdict(input: {
|
|
150
|
+
limits: GuestLimits;
|
|
151
|
+
/** The conversation keys this group already holds (`liveGuestKeys`). */
|
|
152
|
+
live: ReadonlySet<string>;
|
|
153
|
+
/** The conversation asking to be admitted (`guestConversationKey`). */
|
|
154
|
+
key: string;
|
|
155
|
+
recent: readonly number[];
|
|
156
|
+
now: number;
|
|
157
|
+
windowMs?: number;
|
|
158
|
+
}): GuestAdmit;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { guestWorkDirName } from "./tg-guests.js";
|
|
2
|
+
import { waGuestWorkDirName } from "./wa-guests.js";
|
|
3
|
+
/**
|
|
4
|
+
* The defaults, settled with the operator: large enough that an ordinary flow
|
|
5
|
+
* never meets them, small enough that a flood stops costing at 30 accounts an
|
|
6
|
+
* hour. An instance holding 200 live guest conversations is already at the end
|
|
7
|
+
* of what one host runs; the point of the ceiling is that the 201st is a
|
|
8
|
+
* refusal and not a crash.
|
|
9
|
+
*/
|
|
10
|
+
export const GUEST_LIMITS = { live: 200, perHour: 30 };
|
|
11
|
+
/** The window `perHour` is counted over. */
|
|
12
|
+
export const GUEST_RATE_WINDOW_MS = 3_600_000;
|
|
13
|
+
/** The refusal's `code` on the wire, so a bridge classifies it without
|
|
14
|
+
* matching on the message text (the `busy` convention). */
|
|
15
|
+
export const GUEST_FULL_CODE = "guest-full";
|
|
16
|
+
/**
|
|
17
|
+
* This door's limits: what the operator stored, else the defaults.
|
|
18
|
+
*
|
|
19
|
+
* A value that is not a positive integer reads as "not set" rather than as a
|
|
20
|
+
* refusal: the config file is hand-editable (`normalizeTgMode` makes the same
|
|
21
|
+
* choice), and a typo that silently shut the door would be indistinguishable
|
|
22
|
+
* from a bot that stopped working. Closing a door is what the MODE is for.
|
|
23
|
+
*
|
|
24
|
+
* There is deliberately no upper bound. An operator who raises the ceiling to
|
|
25
|
+
* a number their host cannot serve has made a decision about their own
|
|
26
|
+
* machine; pretending to know better would be the cosmetic cap of invariant 47.
|
|
27
|
+
*/
|
|
28
|
+
export function guestLimitsOf(setup) {
|
|
29
|
+
const one = (v, fallback) => typeof v === "number" && Number.isSafeInteger(v) && v > 0 ? v : fallback;
|
|
30
|
+
return {
|
|
31
|
+
live: one(setup.limits?.live, GUEST_LIMITS.live),
|
|
32
|
+
perHour: one(setup.limits?.perHour, GUEST_LIMITS.perHour),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The ceiling a REQUEST asks for, or `undefined` when it names none.
|
|
37
|
+
*
|
|
38
|
+
* `undefined` is not "the defaults": a patch that does not mention the ceiling
|
|
39
|
+
* must leave the operator's numbers alone (`guestPatchFlow` keeps them,
|
|
40
|
+
* ASSERT-only like `branch` / `repo` / `parent` — invariant 19). An EMPTY
|
|
41
|
+
* object is the way back to the defaults, so there is a route out as well as in.
|
|
42
|
+
*
|
|
43
|
+
* Only positive integers survive; anything else is dropped rather than
|
|
44
|
+
* refused, for the reason `guestLimitsOf` gives.
|
|
45
|
+
*/
|
|
46
|
+
export function requestedLimits(b) {
|
|
47
|
+
if (!("limits" in b))
|
|
48
|
+
return undefined;
|
|
49
|
+
const raw = (b.limits ?? {});
|
|
50
|
+
if (typeof raw !== "object")
|
|
51
|
+
return {};
|
|
52
|
+
const out = {};
|
|
53
|
+
for (const k of ["live", "perHour"]) {
|
|
54
|
+
const v = raw[k];
|
|
55
|
+
if (typeof v === "number" && Number.isSafeInteger(v) && v > 0)
|
|
56
|
+
out[k] = v;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The conversation a channel belongs to, named the way its directory is
|
|
62
|
+
* (`tg-<id>` / `wa-<digits>`), or null when the channel is not a guest's.
|
|
63
|
+
*
|
|
64
|
+
* That name is the key the whole ceiling counts on, and it is REUSED rather
|
|
65
|
+
* than invented: it is already what makes a person come back to their own
|
|
66
|
+
* folder, it is rebuilt from untrusted input in one place, and two spellings of
|
|
67
|
+
* one id (a chat id as a number or as a string) collapse to one string there.
|
|
68
|
+
* Two keys for one person would be two admissions, i.e. a returning guest
|
|
69
|
+
* charged as a new one.
|
|
70
|
+
*
|
|
71
|
+
* It inherits that name's one limit, and the ceiling can say so honestly: a
|
|
72
|
+
* WhatsApp sender's LID and their phone address are two keys, as they are two
|
|
73
|
+
* directories. It costs nothing in practice — the same person is found by
|
|
74
|
+
* `findWaChannel` and RESUMED, which never reaches the ceiling — and at worst,
|
|
75
|
+
* with no channel row left, it charges one admission twice.
|
|
76
|
+
*
|
|
77
|
+
* The bindings are `SERVER_OWNED`, so no client can rename a conversation into
|
|
78
|
+
* a free slot.
|
|
79
|
+
*/
|
|
80
|
+
export function guestConversationKey(c) {
|
|
81
|
+
if (!c)
|
|
82
|
+
return null;
|
|
83
|
+
if (c.whatsapp)
|
|
84
|
+
return waGuestWorkDirName(c.whatsapp.id);
|
|
85
|
+
const t = c.telegram;
|
|
86
|
+
// A topic (`threadId`) is a board agent and a negative id is a group chat:
|
|
87
|
+
// neither is a guest's conversation. `guestWorkDirName` refuses both.
|
|
88
|
+
if (!t || t.threadId != null)
|
|
89
|
+
return null;
|
|
90
|
+
return guestWorkDirName(t.chatId);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The guest conversations this group is holding — as a SET of conversation
|
|
94
|
+
* keys, not a channel count.
|
|
95
|
+
*
|
|
96
|
+
* Deliberately per group rather than per door: the group is where a
|
|
97
|
+
* conversation costs something (a Unix user, a home, a vault slice at step 4),
|
|
98
|
+
* and two doors pointed at one group share that cost. Counting a door's own
|
|
99
|
+
* channels would let an operator double the ceiling by opening a second door
|
|
100
|
+
* onto the same group.
|
|
101
|
+
*
|
|
102
|
+
* The owner's own DM is excluded without having to know who the owner is: it
|
|
103
|
+
* lives in the board's group, never in the guest group, and only this group is
|
|
104
|
+
* counted.
|
|
105
|
+
*/
|
|
106
|
+
export function liveGuestKeys(list, groupId) {
|
|
107
|
+
const keys = new Set();
|
|
108
|
+
for (const c of list) {
|
|
109
|
+
if (c.group !== groupId)
|
|
110
|
+
continue;
|
|
111
|
+
const k = guestConversationKey(c);
|
|
112
|
+
if (k)
|
|
113
|
+
keys.add(k);
|
|
114
|
+
}
|
|
115
|
+
return keys;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* May this conversation be admitted?
|
|
119
|
+
*
|
|
120
|
+
* A **returning** conversation is never subject to either limit, and that is
|
|
121
|
+
* the load-bearing half: the cap exists to stop an unknown number of NEW
|
|
122
|
+
* strangers, never to cut off someone the instance is already talking to. A
|
|
123
|
+
* guest whose agent the operator deleted comes back through this path (their
|
|
124
|
+
* channel row went with it), so "returning" is asked on the conversation key
|
|
125
|
+
* and not on the presence of an agent.
|
|
126
|
+
*
|
|
127
|
+
* `recent` is the admission times of this group, newest or oldest first makes
|
|
128
|
+
* no difference: only how many fall inside the window counts.
|
|
129
|
+
*/
|
|
130
|
+
export function guestAdmitVerdict(input) {
|
|
131
|
+
const { limits } = input;
|
|
132
|
+
if (input.live.has(input.key))
|
|
133
|
+
return { ok: true, returning: true };
|
|
134
|
+
if (input.live.size >= limits.live)
|
|
135
|
+
return {
|
|
136
|
+
ok: false,
|
|
137
|
+
why: "full",
|
|
138
|
+
message: `this instance is already holding its maximum of ${limits.live} guest conversations`,
|
|
139
|
+
};
|
|
140
|
+
const window = input.windowMs ?? GUEST_RATE_WINDOW_MS;
|
|
141
|
+
const since = input.now - window;
|
|
142
|
+
const burst = input.recent.filter((t) => t > since).length;
|
|
143
|
+
if (burst >= limits.perHour)
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
why: "rate",
|
|
147
|
+
message: `this instance has admitted its maximum of ${limits.perHour} new guest conversations in the last hour`,
|
|
148
|
+
};
|
|
149
|
+
return { ok: true, returning: false };
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=guest-admit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guest-admit.js","sourceRoot":"","sources":["../src/guest-admit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAqCpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEpE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C;4DAC4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiC;IAC7D,MAAM,GAAG,GAAG,CAAC,CAAU,EAAE,QAAgB,EAAE,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3E,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;QAChD,OAAO,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EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -45,6 +45,7 @@ import { ensureSshIdentity, groupKeyRows, volumeKeyPaths } from "./ssh.js";
|
|
|
45
45
|
import { accountsEnabled, deploymentMode, migratedIsolationRefusal, probeCanProvision } from "./capability.js";
|
|
46
46
|
import { startWhatsApp } from "./whatsapp.js";
|
|
47
47
|
import { waGuestWorkDirName } from "./wa-guests.js";
|
|
48
|
+
import { GUEST_FULL_CODE, GUEST_RATE_WINDOW_MS, guestAdmitVerdict, guestLimitsOf, liveGuestKeys, requestedLimits, } from "./guest-admit.js";
|
|
48
49
|
import { startWaBridge } from "./wa-bridge.js";
|
|
49
50
|
import { openInbox, waStateDir } from "./wa-inbox.js";
|
|
50
51
|
import { waSessionDir } from "./wa-transport.js";
|
|
@@ -769,6 +770,42 @@ async function drainWebhook(hookId) {
|
|
|
769
770
|
* window, and the expensive case partly corrects itself.
|
|
770
771
|
*/
|
|
771
772
|
const parentInbox = new Map();
|
|
773
|
+
/**
|
|
774
|
+
* When each guest GROUP last admitted a new conversation, for the hourly half
|
|
775
|
+
* of the door's ceiling (`guestAdmitVerdict`, src/guest-admit.ts).
|
|
776
|
+
*
|
|
777
|
+
* In memory, like the sign-in limiter and for the same reason: a restart
|
|
778
|
+
* forgets the burst, and that is the right way round. The durable half of the
|
|
779
|
+
* ceiling is the live count, which is read from the channel registry and so
|
|
780
|
+
* survives everything; the rate is only there to slow a flood down, and a
|
|
781
|
+
* limiter that could keep a door shut across restarts would be worse than one
|
|
782
|
+
* a restart clears.
|
|
783
|
+
*
|
|
784
|
+
* Keyed by group, not by door: two doors onto one group share the ceiling,
|
|
785
|
+
* because the group is where a conversation costs a Unix user and a home.
|
|
786
|
+
*/
|
|
787
|
+
const guestAdmissions = new Map();
|
|
788
|
+
/** This group's admissions inside the window, pruned as they are read — so the
|
|
789
|
+
* map cannot grow with the age of the process. */
|
|
790
|
+
function admissionsOf(groupId) {
|
|
791
|
+
const kept = (guestAdmissions.get(groupId) ?? []).filter((t) => t > Date.now() - GUEST_RATE_WINDOW_MS);
|
|
792
|
+
if (kept.length)
|
|
793
|
+
guestAdmissions.set(groupId, kept);
|
|
794
|
+
else
|
|
795
|
+
guestAdmissions.delete(groupId);
|
|
796
|
+
return kept;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Charge one admission to this group.
|
|
800
|
+
*
|
|
801
|
+
* Charged when the door ADMITS, not when the agent reaches `ready`: a spawn
|
|
802
|
+
* costs its work whether or not it completes, and the rate exists to bound
|
|
803
|
+
* exactly that. The live count, being read from the registry, corrects itself
|
|
804
|
+
* either way.
|
|
805
|
+
*/
|
|
806
|
+
function chargeAdmission(groupId) {
|
|
807
|
+
guestAdmissions.set(groupId, [...admissionsOf(groupId), Date.now()]);
|
|
808
|
+
}
|
|
772
809
|
/** A session's display name — the cockpit tab — falling back to a short id.
|
|
773
810
|
* What a parent is told its child is called, and what an agent's own prompts
|
|
774
811
|
* are signed with (`agentNameForKey`). */
|
|
@@ -7694,12 +7731,15 @@ app.put("/whatsapp/guests", (req, res) => {
|
|
|
7694
7731
|
return res.status(409).json({ error: refusal });
|
|
7695
7732
|
const b = (req.body ?? {});
|
|
7696
7733
|
const cwd = process.cwd();
|
|
7734
|
+
const waLimits = requestedLimits(b);
|
|
7697
7735
|
const want = {
|
|
7698
7736
|
// Only an explicit `true` opens: a hand-made request must never open a
|
|
7699
7737
|
// door by omitting a field.
|
|
7700
7738
|
mode: b.on === true ? "dm-only" : "group",
|
|
7701
7739
|
group: typeof b.group === "string" ? b.group : null,
|
|
7702
7740
|
profile: typeof b.profile === "string" ? b.profile : null,
|
|
7741
|
+
// The admission ceiling — see the twin in `PUT /telegram`.
|
|
7742
|
+
...(waLimits !== undefined ? { limits: waLimits } : {}),
|
|
7703
7743
|
};
|
|
7704
7744
|
const flow = guestPatchFlow({
|
|
7705
7745
|
mode: DEPLOYMENT_MODE,
|
|
@@ -7811,6 +7851,7 @@ app.put("/telegram", async (req, res) => {
|
|
|
7811
7851
|
let guestsChanged = false;
|
|
7812
7852
|
if (b.guests && typeof b.guests === "object") {
|
|
7813
7853
|
const g = b.guests;
|
|
7854
|
+
const tgLimits = requestedLimits(g);
|
|
7814
7855
|
const want = {
|
|
7815
7856
|
// Anything the body does not spell as one of the three modes is the
|
|
7816
7857
|
// classic one: the panel sends the mode it painted, and a hand-made
|
|
@@ -7818,6 +7859,10 @@ app.put("/telegram", async (req, res) => {
|
|
|
7818
7859
|
mode: normalizeTgMode(g.mode),
|
|
7819
7860
|
group: typeof g.group === "string" ? String(g.group) : null,
|
|
7820
7861
|
profile: typeof g.profile === "string" ? String(g.profile) : null,
|
|
7862
|
+
// The admission ceiling, when the request names one. The panel does not,
|
|
7863
|
+
// so omitting it KEEPS what the operator set (`guestPatchFlow`); an
|
|
7864
|
+
// explicitly empty ceiling goes back to the defaults.
|
|
7865
|
+
...(tgLimits !== undefined ? { limits: tgLimits } : {}),
|
|
7821
7866
|
};
|
|
7822
7867
|
const flow = guestPatchFlow({
|
|
7823
7868
|
mode: DEPLOYMENT_MODE,
|
|
@@ -11727,23 +11772,65 @@ wss.on("connection", (ws, req) => {
|
|
|
11727
11772
|
// Two bridges, two doors: the setup is the one of the bridge this socket
|
|
11728
11773
|
// PROVED (its secret), never one a frame names — a Telegram socket
|
|
11729
11774
|
// never spawns on the WhatsApp door's profile, nor the reverse.
|
|
11730
|
-
const
|
|
11731
|
-
?
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
:
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
setup: msg.guest === true ? guestSetupForCwd(loadConfig(), process.cwd()) : GUEST_SETUP_OFF,
|
|
11742
|
-
});
|
|
11775
|
+
const doorSetup = msg.guest === true
|
|
11776
|
+
? isWhatsAppBridge
|
|
11777
|
+
? waGuestSetupForCwd(loadConfig(), process.cwd())
|
|
11778
|
+
: guestSetupForCwd(loadConfig(), process.cwd())
|
|
11779
|
+
: GUEST_SETUP_OFF;
|
|
11780
|
+
const guestPlan = guestSpawnPlan({
|
|
11781
|
+
marker: msg.guest,
|
|
11782
|
+
fromBridge: isWhatsAppBridge || isTelegramBridge,
|
|
11783
|
+
resuming: !!msg.resume,
|
|
11784
|
+
setup: doorSetup,
|
|
11785
|
+
});
|
|
11743
11786
|
if (guestPlan.kind === "refused")
|
|
11744
11787
|
return fail(guestPlan.message, guestPlan.code);
|
|
11745
11788
|
const guestSetup = guestPlan.kind === "guest" ? guestPlan : null;
|
|
11746
11789
|
const guestGroupId = guestSetup?.group ?? null;
|
|
11790
|
+
// The door's ADMISSION CEILING (`src/guest-admit.ts`). Both doors
|
|
11791
|
+
// WERE uncapped by construction, and a stranger already costs a `claude`
|
|
11792
|
+
// process and a pane — so anyone who knows the number can make the
|
|
11793
|
+
// instance spawn until it falls over, and the external-group design
|
|
11794
|
+
// turns that cost into a row in `/etc/passwd`. The ceiling therefore
|
|
11795
|
+
// lands BEFORE the wall it pays for.
|
|
11796
|
+
//
|
|
11797
|
+
// Asked here: after the door is known, before the working directory
|
|
11798
|
+
// is created and before anything is spawned, and only on a FRESH
|
|
11799
|
+
// guest spawn. A RETURNING conversation is exempt inside the verdict
|
|
11800
|
+
// — the ceiling bounds new strangers, and must never cut off someone
|
|
11801
|
+
// the instance is already talking to.
|
|
11802
|
+
//
|
|
11803
|
+
// `wa-<digits>` for a WhatsApp sender, `tg-<id>` for a Telegram one:
|
|
11804
|
+
// each rebuilt from its own bridge's id, never from the other's. One
|
|
11805
|
+
// name for one conversation, resolved once here and reused for the
|
|
11806
|
+
// directory below — the ceiling and the folder MUST agree, or someone
|
|
11807
|
+
// admitted under one name would be filed under another's.
|
|
11808
|
+
let guestDir = null;
|
|
11809
|
+
if (guestSetup) {
|
|
11810
|
+
guestDir = isWhatsAppBridge ? waGuestWorkDirName(msg.guestKey) : guestWorkDirName(msg.guestKey);
|
|
11811
|
+
// No usable id → REFUSE, never fall back to the shared home: a
|
|
11812
|
+
// silent fallback is exactly the mixing this closes, and it would
|
|
11813
|
+
// come back the day a caller forgets the field (invariant 24).
|
|
11814
|
+
if (!guestDir)
|
|
11815
|
+
return fail("a guest's agent needs the person it belongs to", "guest-key");
|
|
11816
|
+
if (freshSpawn) {
|
|
11817
|
+
const verdict = guestAdmitVerdict({
|
|
11818
|
+
limits: guestLimitsOf(doorSetup),
|
|
11819
|
+
live: liveGuestKeys(loadChannels(), guestSetup.group),
|
|
11820
|
+
key: guestDir,
|
|
11821
|
+
recent: admissionsOf(guestSetup.group),
|
|
11822
|
+
now: Date.now(),
|
|
11823
|
+
});
|
|
11824
|
+
if (!verdict.ok) {
|
|
11825
|
+
// The admin's log line, with the reason the guest is not told:
|
|
11826
|
+
// they hear one `guestNotice("door-full")` either way.
|
|
11827
|
+
console.log(`guests: ${guestDir} not admitted to ${guestSetup.group} — ${verdict.why}: ${verdict.message}`);
|
|
11828
|
+
return fail(verdict.message, GUEST_FULL_CODE);
|
|
11829
|
+
}
|
|
11830
|
+
if (!verdict.returning)
|
|
11831
|
+
chargeAdmission(guestSetup.group);
|
|
11832
|
+
}
|
|
11833
|
+
}
|
|
11747
11834
|
// Deterministic id: enforced with --session-id for a new session,
|
|
11748
11835
|
// known for a resume. NEVER derive it from the most recent file
|
|
11749
11836
|
// in the directory — with several channels in the same directory
|
|
@@ -11884,22 +11971,13 @@ wss.on("connection", (ws, req) => {
|
|
|
11884
11971
|
// memory and where `CLAUDE.md` is read, so one person's agent
|
|
11885
11972
|
// loaded the notes another person's agent had written, with
|
|
11886
11973
|
// nothing on screen to show it (`guestWorkDirName`).
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
if (!
|
|
11892
|
-
return fail("a guest's agent needs the person it belongs to", "guest-key");
|
|
11893
|
-
effectiveCwd = ensureGuestWorkDir(agentStateHome(earlyUser), sub, earlyUser);
|
|
11894
|
-
}
|
|
11895
|
-
else if (guestSetup) {
|
|
11896
|
-
const sub = guestWorkDirName(msg.guestKey);
|
|
11897
|
-
// No usable id → REFUSE, never fall back to the shared home: a
|
|
11898
|
-
// silent fallback is exactly the mixing this closes, and it would
|
|
11899
|
-
// come back the day a caller forgets the field (invariant 24).
|
|
11900
|
-
if (!sub)
|
|
11974
|
+
if (guestSetup) {
|
|
11975
|
+
// The name was resolved with the admission ceiling above
|
|
11976
|
+
// (`wa-<digits>` / `tg-<id>`), so the folder and the ceiling can
|
|
11977
|
+
// never name the same person differently.
|
|
11978
|
+
if (!guestDir)
|
|
11901
11979
|
return fail("a guest's agent needs the person it belongs to", "guest-key");
|
|
11902
|
-
effectiveCwd = ensureGuestWorkDir(agentStateHome(earlyUser),
|
|
11980
|
+
effectiveCwd = ensureGuestWorkDir(agentStateHome(earlyUser), guestDir, earlyUser);
|
|
11903
11981
|
}
|
|
11904
11982
|
const early = await connectRefusal(earlyUser);
|
|
11905
11983
|
if (early)
|