@chatwarden/core 0.1.7 → 0.1.8
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 +124 -4
- package/dist/src/ai/case.d.ts +3 -3
- package/dist/src/ai/case.d.ts.map +1 -1
- package/dist/src/ai/case.js +1 -1
- package/dist/src/ai/case.js.map +1 -1
- package/dist/src/ai/hash.d.ts +3 -1
- package/dist/src/ai/hash.d.ts.map +1 -1
- package/dist/src/ai/hash.js +5 -2
- package/dist/src/ai/hash.js.map +1 -1
- package/dist/src/ai/prompt.d.ts +6 -2
- package/dist/src/ai/prompt.d.ts.map +1 -1
- package/dist/src/ai/prompt.js +11 -0
- package/dist/src/ai/prompt.js.map +1 -1
- package/dist/src/ai/service.d.ts +5 -1
- package/dist/src/ai/service.d.ts.map +1 -1
- package/dist/src/ai/service.js +2 -0
- package/dist/src/ai/service.js.map +1 -1
- package/dist/src/ai/types.d.ts +18 -2
- package/dist/src/ai/types.d.ts.map +1 -1
- package/dist/src/ai/types.js +2 -2
- package/dist/src/ai/types.js.map +1 -1
- package/dist/src/ai/worker.d.ts +3 -1
- package/dist/src/ai/worker.d.ts.map +1 -1
- package/dist/src/ai/worker.js +10 -3
- package/dist/src/ai/worker.js.map +1 -1
- package/dist/src/chat.d.ts +39 -1
- package/dist/src/chat.d.ts.map +1 -1
- package/dist/src/chat.js +85 -6
- package/dist/src/chat.js.map +1 -1
- package/dist/src/chatwarden.d.ts +68 -1
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +119 -5
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/documents.d.ts +1 -1
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +3 -1
- package/dist/src/documents.js.map +1 -1
- package/dist/src/freeze.d.ts +3 -0
- package/dist/src/freeze.d.ts.map +1 -0
- package/dist/src/freeze.js +10 -0
- package/dist/src/freeze.js.map +1 -0
- package/dist/src/index.d.ts +13 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/ladder.d.ts +28 -0
- package/dist/src/ladder.d.ts.map +1 -1
- package/dist/src/ladder.js +37 -1
- package/dist/src/ladder.js.map +1 -1
- package/dist/src/pace.d.ts +66 -0
- package/dist/src/pace.d.ts.map +1 -0
- package/dist/src/pace.js +111 -0
- package/dist/src/pace.js.map +1 -0
- package/dist/src/pacing.d.ts +63 -0
- package/dist/src/pacing.d.ts.map +1 -0
- package/dist/src/pacing.js +198 -0
- package/dist/src/pacing.js.map +1 -0
- package/dist/src/policy.d.ts +57 -1
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +67 -4
- package/dist/src/policy.js.map +1 -1
- package/dist/src/profile.d.ts +35 -8
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +57 -25
- package/dist/src/profile.js.map +1 -1
- package/dist/src/profileError.d.ts +10 -0
- package/dist/src/profileError.d.ts.map +1 -0
- package/dist/src/profileError.js +17 -0
- package/dist/src/profileError.js.map +1 -0
- package/dist/src/retention.d.ts +9 -0
- package/dist/src/retention.d.ts.map +1 -1
- package/dist/src/retention.js +10 -1
- package/dist/src/retention.js.map +1 -1
- package/dist/src/signalCounts.d.ts +37 -0
- package/dist/src/signalCounts.d.ts.map +1 -0
- package/dist/src/signalCounts.js +117 -0
- package/dist/src/signalCounts.js.map +1 -0
- package/dist/src/signalInert.d.ts +10 -0
- package/dist/src/signalInert.d.ts.map +1 -0
- package/dist/src/signalInert.js +28 -0
- package/dist/src/signalInert.js.map +1 -0
- package/dist/src/signalService.d.ts +101 -0
- package/dist/src/signalService.d.ts.map +1 -0
- package/dist/src/signalService.js +383 -0
- package/dist/src/signalService.js.map +1 -0
- package/dist/src/signals.d.ts +186 -0
- package/dist/src/signals.d.ts.map +1 -0
- package/dist/src/signals.js +361 -0
- package/dist/src/signals.js.map +1 -0
- package/dist/src/subjects.d.ts +2 -0
- package/dist/src/subjects.d.ts.map +1 -1
- package/dist/src/subjects.js +4 -0
- package/dist/src/subjects.js.map +1 -1
- package/dist/src/team.d.ts +27 -0
- package/dist/src/team.d.ts.map +1 -1
- package/dist/src/team.js +92 -4
- package/dist/src/team.js.map +1 -1
- package/dist/src/types.d.ts +56 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/src/ai/case.ts +4 -4
- package/src/ai/hash.ts +5 -2
- package/src/ai/prompt.ts +16 -1
- package/src/ai/service.ts +8 -2
- package/src/ai/types.ts +19 -2
- package/src/ai/worker.ts +12 -4
- package/src/chat.ts +109 -8
- package/src/chatwarden.ts +184 -7
- package/src/documents.ts +5 -3
- package/src/freeze.ts +8 -0
- package/src/index.ts +41 -3
- package/src/ladder.ts +59 -1
- package/src/pace.ts +139 -0
- package/src/pacing.ts +242 -0
- package/src/policy.ts +107 -7
- package/src/profile.ts +83 -25
- package/src/profileError.ts +17 -0
- package/src/retention.ts +17 -1
- package/src/signalCounts.ts +133 -0
- package/src/signalInert.ts +31 -0
- package/src/signalService.ts +406 -0
- package/src/signals.ts +489 -0
- package/src/subjects.ts +5 -0
- package/src/team.ts +93 -5
- package/src/types.ts +65 -1
package/README.md
CHANGED
|
@@ -110,9 +110,10 @@ For the moderators' screens and the player's notices, mount the routes in
|
|
|
110
110
|
|
|
111
111
|
| Part | What it is for |
|
|
112
112
|
| --- | --- |
|
|
113
|
-
| `cw.rooms` | `seat`, `seatConnection`, `unseat`, `close`: who is in which seat of which room. |
|
|
113
|
+
| `cw.rooms` | `seat`, `seatConnection`, `unseat`, `close`: who is in which seat of which room. `setPace(roomId, pace)` and `pace(roomId)` (`@experimental`) give one room its own slow mode, burst limit and repeat rule, in this process only. See "Slow mode and flood control". |
|
|
114
114
|
| `cw.chat.accept(room, seat, text)` | The answer for one line: `{ deliver }` or `{ refuse: { reason } }`. `visibleTo` applies a viewer's mutes. `restricted(who)` says whether a person is chat-restricted, for typing indicators; `restrictedBySubject(subject)` (`@experimental`) says the same for a subject id from `cw.rooms.subjectAt`, so a server that keeps a connection open need not keep the player's key to ask again. |
|
|
115
115
|
| `cw.mutes` | A player mutes another player for themselves only. |
|
|
116
|
+
| `cw.signals` | `@experimental`. What your game records about a player, counted by distinct source: `record`, `counts`, `kinds`, `boosted`, `forRecord`. See "Signals". |
|
|
116
117
|
| `cw.reports` | `submit` and `addDetail` (players; see "Reporting settings"), `list`, `get` and `reporterRecord` (staff). `reporterRecord(person)` is how the reports a person filed stand: `{ reports, open, actioned, dismissed, badFaith, suspendedUntil, reasonMatched, reasonDecided, accuracy }`. `reporterAccuracy(people)` is how often each person's recent reports turned out to be unfounded (see "Reporter accuracy"). |
|
|
117
118
|
| `cw.decide(input)` | A moderator closes a report and writes the sanctions and notices in one transaction. Safe to send twice. `reason` is required, except for a `no_action` with no actions (a one-click dismissal): leave it out and the standard reason `NO_ACTION_DEFAULT_REASON` (`No action needed`) is stored. |
|
|
118
119
|
| `cw.sanctions` | `apply` and `revoke`, for a moderator who acts without a report. `forPerson(subject)` and `list({ cursor?, limit?, source? })` (staff) read sanctions as `SanctionGroupView`s: one per group, built from the person's own row, so no IP, hash or stored value is in them. |
|
|
@@ -126,7 +127,7 @@ For the moderators' screens and the player's notices, mount the routes in
|
|
|
126
127
|
| `cw.names.check` | May a player use this as a name? |
|
|
127
128
|
| `cw.history`, `cw.suggest` | A person's recent record, and what the preset suggests as the next step. |
|
|
128
129
|
| `cw.rules`, `cw.profile`, `cw.limits`, `cw.summary`, `cw.documents` | The rules, standard and numbers in force, and the written code of conduct and guides. `cw.profile` and `cw.summary` are read live: the profile in force is your code's profile with the owner's stored edits on top (see "The editable profile"), so read it when you need it and never keep it. |
|
|
129
|
-
| `cw.policy` | The editable profile: `get`, `save`, `preview`, `reset` and `refresh`. The lengths a moderator is offered, the ladder, the first offences, the repeat rule, the area and severe rules and the guideline outcome texts can be edited at runtime and are stored in your store. |
|
|
130
|
+
| `cw.policy` | The editable profile: `get` (it also reports `limits`, read only: the chat rate in force and the signals retention), `save`, `preview`, `reset` and `refresh`. The lengths a moderator is offered, the ladder, the first offences, the repeat rule, the area and severe rules and the guideline outcome texts can be edited at runtime and are stored in your store. |
|
|
130
131
|
| `cw.gaps`, `cw.audit` | Rule gaps for the periodic review, and the staff audit trail. |
|
|
131
132
|
| `cw.on(type, listener)` | Events: `report.created`, `report.closed`, `sanction.applied`, `sanction.revoked`, `gap.created`, `auto.restricted`. |
|
|
132
133
|
| `cw.purge`, `cw.ready`, `cw.flush`, `cw.close` | Housekeeping. |
|
|
@@ -190,6 +191,9 @@ cw.policy.reset('durations'); // put one section back to the base; reset() puts
|
|
|
190
191
|
cannot be used: it is then ignored, the base stays in force, and one `chatwarden.policy_layer_invalid` line is logged. `kind` is `'unreadable'`
|
|
191
192
|
when the stored text could not be read at all (corrupted, not JSON, not an object), so the owner's edits are gone until they save again, and
|
|
192
193
|
`'invalid'` when it was read but a setting is not valid (a field from a newer kit, say). A save or a full `reset()` repairs either.
|
|
194
|
+
`layer` is the layer in force: a stored signal feed that can no longer be used (its kind is no longer declared in code, or its window is longer
|
|
195
|
+
than `retention.signalsMs` now allows) is dropped alone, the rest of the layer stays, and `dropped` (`[{ feed, reason }]`, a feed name and a reason
|
|
196
|
+
code, never a kind or a rule id; `@experimental`) says what went. Send `layer` back to `save` and it is accepted and repairs the stored row.
|
|
193
197
|
- **`save(layer, { version, actor, reason })`** stores the whole layer: a section you leave out goes back to the base. It answers
|
|
194
198
|
`{ ok: true, version, changed }`, `{ ok: false, error: 'conflict' }` for a stale `version` (nothing is written),
|
|
195
199
|
`{ ok: false, error: 'invalid', path }` for a layer that touches a setting that is not editable or would make the profile invalid
|
|
@@ -276,6 +280,119 @@ const res = await cw.reports.addDetail(reportId, 'seat-1', { reason: 'cheating',
|
|
|
276
280
|
- **Your own store.** `addReportDetail` and `loadReporterDecisions` are optional on `Store`. Without the first, `addDetail` answers `off`; without the
|
|
277
281
|
second, the accuracy counts are 0. `insertReport` must keep `reportedReason`, and `listReports` must apply the `reason` filter (`null` means none).
|
|
278
282
|
|
|
283
|
+
## What is experimental in 0.1.8
|
|
284
|
+
|
|
285
|
+
These may change before 0.2, and are marked `@experimental` in the types: `PaceSettings`, `ResolvedPace`, `resolvePace`, `mergePace`, `checkPace`,
|
|
286
|
+
`PACE_SUGGESTIONS`, `cw.rooms.setPace`, `cw.rooms.pace`, `cw.signals` and every signal type (`SignalInput`, `SignalCount`, `SignalSettings`, the feeds,
|
|
287
|
+
`PolicyDropped`, `PolicyLimits`, `PolicyState.limits` and `.dropped`), `SuggestContext.hideSignalText`, `Suggestion.signals`, `signalBoost` in
|
|
288
|
+
`cw.cases.next`, `BUILTIN_SIGNAL_KINDS`, `withMemorySignals`, the `pace` prop of `RestrictedChatLine` and `secondsLeft` in `@chatwarden/player-react`.
|
|
289
|
+
|
|
290
|
+
## Slow mode and flood control
|
|
291
|
+
|
|
292
|
+
Optional and off until you set it, `@experimental` until 0.2 and new in 0.1.8. Three checks pace one player's lines in one room: **slow mode**
|
|
293
|
+
(at least `slowModeMs` between lines, 500 to 600 000), a **burst limit** (at most `burst.lines` lines in any `burst.windowMs`: 2 to 100 lines
|
|
294
|
+
in 1 000 to 600 000 ms) and **repeats** (the same line again inside `duplicateWindowMs`, 1 000 to 3 600 000, is refused). Set them in code with
|
|
295
|
+
`overrides.pace`, or the owner sets them in the hub (Settings, Advanced, "Slow mode and flooding"); the stored layer wins over code. The presets set
|
|
296
|
+
nothing, so no install changes by itself.
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
import { createChatwarden } from '@chatwarden/core';
|
|
300
|
+
import { createMemoryStore } from '@chatwarden/store-memory';
|
|
301
|
+
|
|
302
|
+
const cw = await createChatwarden({
|
|
303
|
+
store: createMemoryStore(),
|
|
304
|
+
secret: 'a-long-random-secret',
|
|
305
|
+
platform: { identify: (ctx) => ctx as { clientKey: string } },
|
|
306
|
+
overrides: { pace: { slowModeMs: 2000, burst: { lines: 6, windowMs: 10_000 }, duplicateWindowMs: 15_000 } },
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// One room that differs, in this process, until the room closes: a tournament final is slower, a practice room is not paced at all.
|
|
310
|
+
cw.rooms.setPace('tournament:final', { slowModeMs: 3000 });
|
|
311
|
+
cw.rooms.setPace('practice', { slowModeMs: null, burst: null, duplicateWindowMs: null });
|
|
312
|
+
console.log(cw.rooms.pace('tournament:final')); // the pace in force there: the defaults with the override on top
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
- **A refusal, not a sanction.** `cw.chat.accept` answers `{ refuse: { reason, retryAfterMs } }` with `reason` `'slow_mode'`, `'flood'` or
|
|
316
|
+
`'duplicate'`, and `retryAfterMs` (at least 1) is when the same player may try again, in milliseconds from now. There is no rule, no notice and no
|
|
317
|
+
text with it. **A new refusal reason**: a `switch (reason)` that ends in `assertNever` will not compile until it handles the three, though a kit
|
|
318
|
+
can only send them after you turn pacing on. The staff routes and the chat box carry them through (`@chatwarden/http`, `@chatwarden/player-react`).
|
|
319
|
+
- **The order.** After the length check and before the fixed rate limit, so a player hammering a slow-mode room reads "slow mode" and not "too fast". A
|
|
320
|
+
line the fixed rate refuses does not count toward pacing, and a refusal never changes pacing state (repeating a refused line cannot extend its own
|
|
321
|
+
block). Repeats compare the line with letters and digits only, case and width folded and combining marks kept, so `gg` and `ok` (under three
|
|
322
|
+
characters) are never repeats; only a short digest is kept, never the text.
|
|
323
|
+
- **Per process.** Pacing state lives in memory in the process that serves the room and is lost on restart, like the fixed rate limit. Route a room's
|
|
324
|
+
chat to one process for the full effect; send one player's lines to several and the effective limit is up to that many times looser. Nothing is shared
|
|
325
|
+
or written, by design: a store round trip per line is the cost this exists to avoid. At most 50 000 (room, player) states are kept (`PACE_KEYS_MAX`).
|
|
326
|
+
`cw.rooms.setPace` is per process as well: call it where you create the room, in each process that serves it.
|
|
327
|
+
- **A burst looser than the fixed limit never triggers.** `limits.chatRate` (3 per 5 seconds by default) answers first inside the same window; the hub
|
|
328
|
+
says so beside the field, with the real numbers (`cw.policy.get().limits.chatRate`).
|
|
329
|
+
- **Flooding is remembered.** When the burst limit trips, the built-in signal `flood_triggered` ("Flooded the chat") is recorded for that player in that
|
|
330
|
+
room, at most once a window, whether or not you declared any signals (see "Signals"). It needs a store with the signal methods, else it is skipped.
|
|
331
|
+
- **Suggested values.** `PACE_SUGGESTIONS` (relaxed: burst 10 in 10 s, repeats 10 s; standard: 6 in 10 s, 15 s; strict: slow mode 2 s, 5 in 10 s, 30 s) is
|
|
332
|
+
what the hub's "Use suggested values" button fills in; nothing applies them by itself. `resolvePace`, `mergePace` and `checkPace` validate and merge.
|
|
333
|
+
- **To try it**, run `examples/tiny-chat` with `CW_DEMO_PACE=1` (a 2 second slow mode) and open the page.
|
|
334
|
+
|
|
335
|
+
## Signals
|
|
336
|
+
|
|
337
|
+
Optional, `@experimental` until 0.2 and new in 0.1.8. A signal is one fact your game records about a player ("muted by another player", "kicked from a
|
|
338
|
+
room", "left mid-game"). The kit counts them by distinct source and shows the counts where a profile rule says so. **A signal never acts on its own: it
|
|
339
|
+
never writes a sanction, a mute or a notice, and a person always decides.** Nothing is recorded or shown until you declare kinds and switch a feed on.
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
import { createChatwarden } from '@chatwarden/core';
|
|
343
|
+
import { openStore } from '@chatwarden/store-sqlite';
|
|
344
|
+
|
|
345
|
+
const cw = await createChatwarden({
|
|
346
|
+
store: openStore({ path: './chatwarden.db' }),
|
|
347
|
+
secret: process.env.CHATWARDEN_SECRET!,
|
|
348
|
+
platform: { identify: (ctx) => ctx as { clientKey: string } },
|
|
349
|
+
overrides: {
|
|
350
|
+
signals: {
|
|
351
|
+
kinds: {
|
|
352
|
+
muted_by_player: { label: 'Muted by other players', polarity: 'negative' },
|
|
353
|
+
kicked_from_room: { label: 'Kicked from a room', polarity: 'negative', weight: 2 },
|
|
354
|
+
commended: { label: 'Commended by other players', polarity: 'positive' },
|
|
355
|
+
},
|
|
356
|
+
feeds: { record: { kinds: '*', windowDays: 14 } },
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// From the game's own events, never from every chat line: one small write each.
|
|
362
|
+
const player = { clientKey: 'a-client-key' };
|
|
363
|
+
const muter = { clientKey: 'another-client-key' };
|
|
364
|
+
cw.signals.record({ kind: 'muted_by_player', subject: player, by: muter, roomId: 'lobby-7' });
|
|
365
|
+
console.log(cw.signals.counts(cw.rooms.subjectAt('lobby-7', 'p1') ?? 's_unknown'));
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
- **Kinds are code.** A kind id is a lower-case slug (`muted_by_player`); the label is plain text, 1 to 60 characters; `polarity` is `'negative'` or `'positive'`;
|
|
369
|
+
`weight` is 0 to 10 (default 1). The kit declares one itself, `flood_triggered`, which you may relabel or re-weight but not make positive.
|
|
370
|
+
- **`cw.signals.record(input)`** is synchronous, fenced and never throws: it returns `true` when a row was written and `false` for any refusal
|
|
371
|
+
(logged by reason code, at most once a minute, never an id). `subject` and `by` are a subject id the kit already knows or a `RawWho`
|
|
372
|
+
(`{ clientKey?, accountId?, ip? }`, each under 513 characters) that it has already seen: a stranger is refused, never created. `by`, `roomId` and `at`
|
|
373
|
+
may be left out or `null`. A player cannot signal themselves (also across a merge), `at` may not be more than 5 minutes ahead or older than the
|
|
374
|
+
retention, and `roomId` is the game's own id: 1 to 64 of `A-Z a-z 0-9 _ . : -` (the built-in flood row uses a digest of a room id that does not fit).
|
|
375
|
+
- **Events, not lines.** Record what happens in your game (a mute, a kick), not every chat line: each record is a store write.
|
|
376
|
+
- **Counting is by distinct source.** A source is the `by` player; with no `by`, the room; with neither, the UTC day. A thousand mutes from one
|
|
377
|
+
player are one source. At most one row per kind, subject and source per `guards.perByWindowMs` (a day by default): the cap is a calendar bucket
|
|
378
|
+
(`floor(at / perByWindowMs)`), not a rolling window, so two rows a millisecond apart across a bucket edge both count, and changing the window later
|
|
379
|
+
re-buckets old rows. The optional `signals.accountAgeDays` hook (asked at most once a minute per player) with `guards.newAccount` makes a new account
|
|
380
|
+
count for a fraction of one. What this cannot stop is several real accounts that agree to signal one player: that is why a signal never acts.
|
|
381
|
+
- **Four feeds** (`profile.signals.feeds`, each off until set, editable in the hub: Settings, Advanced, "Signals"; a layer's `feeds` replaces the code's
|
|
382
|
+
wholesale): **`record`** (counts on the Person page), **`queue`** (a person who meets a threshold is taken ahead of older ordinary cases, capped, and an
|
|
383
|
+
overdue case still comes first), **`ladder`** (rules that add a sentence to the suggested step, or raise it one step; negative kinds only for a raise)
|
|
384
|
+
and **`ai`** (the counts as background for the AI read). A threshold is `kinds`, `minDistinct` (1 to 50), `windowDays` (1 to 90 and not above
|
|
385
|
+
`retention.signalsMs`) and an optional `minWeight`.
|
|
386
|
+
- **Retention.** Signal rows are kept 90 days by default (`retention.signalsMs`, never less than 14); a feed window longer than that is refused, in code
|
|
387
|
+
and in the hub, which reads the number from `cw.policy.get().limits.signalsMs`. A stored feed that can no longer be used (its kind is gone, or its window
|
|
388
|
+
is now too long) is dropped alone and reported as `dropped` on `cw.policy.get()`; the rest of the layer stays.
|
|
389
|
+
- **Your store needs the signal methods** (`insertSignal`, `listSignalSources`, `purgeSignals`, optional on `Store`). The SQLite store has them (migration 21,
|
|
390
|
+
one-way: back up the database before upgrading, since 0.1.7 and older tools cannot read a database 0.1.8 has opened); the in-memory store has them only through
|
|
391
|
+
`withMemorySignals(store)`. Without them `record` answers `false` and logs `chatwarden.signals_store_unsupported` once, and declaring kinds or feeds throws at
|
|
392
|
+
creation. The kit loads the signal code only for a store that has the methods.
|
|
393
|
+
- **Reads** (staff only, never to a player): `cw.signals.counts(subject, { windowDays?, kinds? })`, `kinds()`, `boosted(people)` and `forRecord(subject)`.
|
|
394
|
+
The `@chatwarden/http` routes read them for you and show a count only to a role that holds `history.read`.
|
|
395
|
+
|
|
279
396
|
## The AI (levels 1 and 2)
|
|
280
397
|
|
|
281
398
|
Optional help for the moderator, `@experimental` until 0.2 and new in 0.1.7. With an adapter, the kit reads each new report after the player's
|
|
@@ -309,7 +426,9 @@ console.log(cw.ai.status()); // { available: true, level: 0, maxLevel: 2, state:
|
|
|
309
426
|
(`AI_MAX_PREFILL_MS`), and a suggestion to uphold or note needs a cited line by the reported person.
|
|
310
427
|
- **What leaves your server.** Only the chosen lines of the report with the speakers replaced by `P1`, `P2`, ..., the reporter's reason and
|
|
311
428
|
note (redacted), your Community Rules and the standard. Flags, mutes and report counts are never sent, nor any id, handle, IP, hash, room or
|
|
312
|
-
tag.
|
|
429
|
+
tag. The one exception is the signal feed `feeds.ai` (`profile.signals`, off unless you set it): the counts you chose about the reported player
|
|
430
|
+
only are sent as one last row, a label, a number of players and a number of days, and the read records what it was shown (shown to moderators as
|
|
431
|
+
"Context included: N signal counts"). The prompt version is 3 for everyone, whether or not you use signals: the stable part of the prompt gained a short paragraph about context, so it changes the input hash, and after upgrading from 0.1.7 every stored read is marked stale and read again, once per open report, the first time its case is opened or when the background sweep reaches it. Those reads spend your daily call and money caps, and your provider's prompt cache starts cold. A line the word filter blocked is sent as typed unless you set `blockedLines: 'mask'`: the model needs the words to judge intent.
|
|
313
432
|
- **What it costs.** `dailyBudgetMicros` (default $1.00 a UTC day) is set in code and a hub cannot raise it. The owner also sets a ceiling on
|
|
314
433
|
calls a day (`profile.ai.dailyCalls`, default 5 000), so an adapter that reports no cost still cannot run unbounded. There are at most 30 calls
|
|
315
434
|
a minute and 2 at once, a hard deadline per call (`timeoutMs`) and a breaker that opens after repeated failures. At a limit, reads pause. A call that a shutdown aborts books nothing, so a restart loop around a slow provider can under-count the day's money; the call ceiling still bounds it.
|
|
@@ -389,7 +508,7 @@ in a browser.
|
|
|
389
508
|
| `gate` | `(roomId, subject) => boolean`: who may chat. False refuses the line with `'gate'`. |
|
|
390
509
|
| `onReport` | Told once for each stored report. It carries subject ids and the evidence: staff channels only. |
|
|
391
510
|
| `onAutoRestrict` | Told when a blocked line earned an automatic timeout. The same moment is also the `auto.restricted` event. |
|
|
392
|
-
| `retention` | How long rows are kept and how often the purge runs (every 6 hours by default), or `false` to run `purge()` yourself. Defaults: reports 90 days, strikes 30, notices 90, audit 365. Floors apply. |
|
|
511
|
+
| `retention` | How long rows are kept and how often the purge runs (every 6 hours by default), or `false` to run `purge()` yourself. Defaults: reports 90 days, strikes 30, notices 90, audit 365, signals 90 (`signalsMs`, never less than 14). Floors apply. |
|
|
393
512
|
| `profile` | `'relaxed'`, `'standard'` (default), `'strict'`, or your own profile from `defineProfile`. |
|
|
394
513
|
| `overrides` | Changes to the profile, merged onto it (`{ profanity: { mode: 'allow' } }`). A list you give replaces the preset's list. |
|
|
395
514
|
| `limits` | The numbers the kit enforces: line length and rate, strikes and timeouts, report limits. Each must be a whole number above 0. |
|
|
@@ -397,6 +516,7 @@ in a browser.
|
|
|
397
516
|
| `rules` | The numbered Community Rules, from `defineRules`. Defaults to the preset's starter set. |
|
|
398
517
|
| `autoRestrictRule` | The rule number the automatic slur filter cites (default 1). Must be an active rule. |
|
|
399
518
|
| `ai` | `{ adapter, maxLevel?, dailyBudgetMicros?, ... }`: turns on AI reads (levels 1 and 2). Off without it. See "The AI (levels 1 and 2)" below. |
|
|
519
|
+
| `signals` | `{ accountAgeDays? }`: the one hook the profile cannot hold (how old a player's account is, for the new-account guard). The kinds, guards and feeds are in `profile.signals`. Needs a store with the signal methods (SQLite; `withMemorySignals(store)` for the in-memory store). `@experimental`. |
|
|
400
520
|
|
|
401
521
|
Bad options throw at creation (`ProfileError`, `RangeError`), before the store is touched.
|
|
402
522
|
|
package/dist/src/ai/case.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DocumentPolicy } from '../documents.js';
|
|
|
2
2
|
import type { ReportReason } from '../reporting.js';
|
|
3
3
|
import type { ReportRecord } from '../types.js';
|
|
4
4
|
import type { ChosenLines } from './lines.js';
|
|
5
|
-
import type { AIExampleInput, AIReadInput } from './types.js';
|
|
5
|
+
import type { AIExampleInput, AIReadInput, AISignal } from './types.js';
|
|
6
6
|
/** A report ready to be read (or to be compared with a stored read). */
|
|
7
7
|
export interface Prepared {
|
|
8
8
|
/** The input without casebook examples: what the hash is of. */
|
|
@@ -22,8 +22,8 @@ export interface Prepared {
|
|
|
22
22
|
idOf: ReadonlyMap<string, string>;
|
|
23
23
|
/** The real ids of the lines the reported person wrote (among the chosen). */
|
|
24
24
|
ownLineIds: ReadonlySet<string>;
|
|
25
|
-
/** The same input with casebook examples in it (at most two are used). The hash does not change. */
|
|
26
|
-
build(examples: readonly AIExampleInput[]): AIReadInput;
|
|
25
|
+
/** The same input with casebook examples and the signal counts about P1 in it (at most two examples are used). The hash does not change. */
|
|
26
|
+
build(examples: readonly AIExampleInput[], signals?: readonly AISignal[]): AIReadInput;
|
|
27
27
|
}
|
|
28
28
|
export interface PrepareArgs {
|
|
29
29
|
report: ReportRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"case.d.ts","sourceRoot":"","sources":["../../../src/ai/case.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"case.d.ts","sourceRoot":"","sources":["../../../src/ai/case.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMxE,wEAAwE;AACxE,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,SAAS,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,2EAA2E;IAC3E,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,uDAAuD;IACvD,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,oEAAoE;IACpE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,8EAA8E;IAC9E,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,4IAA4I;IAC5I,KAAK,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG,WAAW,CAAC;CACxF;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CA0BvD"}
|
package/dist/src/ai/case.js
CHANGED
|
@@ -8,7 +8,7 @@ export function prepareCase(args) {
|
|
|
8
8
|
const chosen = chooseLines(report, { mask: args.mask });
|
|
9
9
|
const reasonId = report.reportedReason ?? null;
|
|
10
10
|
const reason = reasonId === null ? null : { id: reasonId, label: reasonLabel(args.reasons, reasonId) ?? reasonId };
|
|
11
|
-
const build = (examples) => buildAIInput({ policy, reason, chosen, examples });
|
|
11
|
+
const build = (examples, signals) => buildAIInput({ policy, reason, chosen, examples, ...(signals === undefined ? {} : { signals }) });
|
|
12
12
|
const input = build([]);
|
|
13
13
|
// The tripwire reads what the players typed (the raw text), whatever is sent.
|
|
14
14
|
const rawOf = new Map(report.excerpt.map((l) => [l.lineId, l.raw]));
|
package/dist/src/ai/case.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"case.js","sourceRoot":"","sources":["../../../src/ai/case.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAuC3C,MAAM,UAAU,WAAW,CAAC,IAAiB;IAC3C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;IAC/C,MAAM,MAAM,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;IACnH,MAAM,KAAK,GAAG,CAAC,QAAmC,EAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file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,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAClF,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/src/ai/hash.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import type { AIReadInput } from './types.js';
|
|
|
4
4
|
* policy text that changes meaning), the case's own rendered inputs and the adapter id, in that order. The casebook examples are
|
|
5
5
|
* NOT part of it: a growing casebook must not make every stored read look stale, and the read records the ids of the examples it
|
|
6
6
|
* used instead (`AIStoredRead.exampleIds`). The `example:` rows are therefore left out of the variable part before hashing; no
|
|
7
|
-
* other row of the data block can begin that way (a chat line starts `L<n> `, the rest are fixed keys). The
|
|
7
|
+
* other row of the data block can begin that way (a chat line starts `L<n> `, the rest are fixed keys). The same goes for the signal
|
|
8
|
+
* counts row (`Context about P1, ...`): counts move all day, so keying the hash on them would re-read every open report each time
|
|
9
|
+
* someone muted someone; the row is a snapshot taken when the read is made. The fields are framed as a
|
|
8
10
|
* JSON array, so no part can slide into the next. Object key order in `input` cannot matter: only those values are read. A hex
|
|
9
11
|
* string of 64 characters.
|
|
10
12
|
* @experimental
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/ai/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../src/ai/hash.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMvE"}
|
package/dist/src/ai/hash.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { sha256Hex } from '../crypto.js';
|
|
2
|
+
import { SIGNALS_ROW } from './prompt.js';
|
|
2
3
|
/**
|
|
3
4
|
* The input hash a stored read is valid for (design section 6): sha256 over the prompt version, the rendered stable prefix (the
|
|
4
5
|
* policy text that changes meaning), the case's own rendered inputs and the adapter id, in that order. The casebook examples are
|
|
5
6
|
* NOT part of it: a growing casebook must not make every stored read look stale, and the read records the ids of the examples it
|
|
6
7
|
* used instead (`AIStoredRead.exampleIds`). The `example:` rows are therefore left out of the variable part before hashing; no
|
|
7
|
-
* other row of the data block can begin that way (a chat line starts `L<n> `, the rest are fixed keys). The
|
|
8
|
+
* other row of the data block can begin that way (a chat line starts `L<n> `, the rest are fixed keys). The same goes for the signal
|
|
9
|
+
* counts row (`Context about P1, ...`): counts move all day, so keying the hash on them would re-read every open report each time
|
|
10
|
+
* someone muted someone; the row is a snapshot taken when the read is made. The fields are framed as a
|
|
8
11
|
* JSON array, so no part can slide into the next. Object key order in `input` cannot matter: only those values are read. A hex
|
|
9
12
|
* string of 64 characters.
|
|
10
13
|
* @experimental
|
|
@@ -12,7 +15,7 @@ import { sha256Hex } from '../crypto.js';
|
|
|
12
15
|
export function inputHash(input, adapterId) {
|
|
13
16
|
const caseInputs = input.prompt.variable
|
|
14
17
|
.split('\n')
|
|
15
|
-
.filter((row) => !row.startsWith('example: '))
|
|
18
|
+
.filter((row) => !row.startsWith('example: ') && !row.startsWith(SIGNALS_ROW))
|
|
16
19
|
.join('\n');
|
|
17
20
|
return sha256Hex(JSON.stringify([input.promptVersion, input.prompt.stable, caseInputs, adapterId]));
|
|
18
21
|
}
|
package/dist/src/ai/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/ai/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../src/ai/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,KAAkB,EAAE,SAAiB;IAC7D,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ;SACrC,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAC7E,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AACtG,CAAC"}
|
package/dist/src/ai/prompt.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { DocumentPolicy } from '../documents.js';
|
|
2
2
|
import type { ChosenLines } from './lines.js';
|
|
3
|
-
import type { AIExampleInput, AIReadInput } from './types.js';
|
|
3
|
+
import type { AIExampleInput, AIReadInput, AISignal } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Same as {@link AI_PROMPT_VERSION}.
|
|
6
6
|
* @experimental
|
|
7
7
|
*/
|
|
8
|
-
export declare const PROMPT_VERSION =
|
|
8
|
+
export declare const PROMPT_VERSION = 3;
|
|
9
|
+
/** How the row of signal counts about P1 begins. The input hash leaves every row that begins this way out. */
|
|
10
|
+
export declare const SIGNALS_ROW = "Context about P1, not evidence: ";
|
|
9
11
|
/**
|
|
10
12
|
* The part of the policy the model needs, as plain text: the active Community Rules in number order, the conduct-level meanings
|
|
11
13
|
* with their examples, and `aiContext`. No outcomes, no ladder, no ids, no times, so editing the ladder never changes it. Retired
|
|
@@ -33,6 +35,8 @@ export interface BuildAIInputArgs {
|
|
|
33
35
|
chosen: ChosenLines;
|
|
34
36
|
/** Casebook examples, already pseudonymised; at most two are used (see {@link usedExampleIds}). */
|
|
35
37
|
examples?: readonly AIExampleInput[];
|
|
38
|
+
/** Counts of signals about P1 (`feeds.ai`), a snapshot: one row after the lines, nothing for none. */
|
|
39
|
+
signals?: readonly AISignal[];
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Render everything a provider needs for one read: the structured facts, and `prompt.stable` / `prompt.variable` / `prompt.schema`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/ai/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,KAAK,EAAa,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/ai/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C,OAAO,KAAK,EAAa,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOnF;;;GAGG;AACH,eAAO,MAAM,cAAc,IAAoB,CAAC;AAqChD,8GAA8G;AAC9G,eAAO,MAAM,WAAW,qCAAqC,CAAC;AAU9D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAkB3D;AA4DD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,EAAE,CAE5E;AAED,6HAA6H;AAC7H,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,+EAA+E;IAC/E,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7C,sGAAsG;IACtG,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,sGAAsG;IACtG,OAAO,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,CAyChE"}
|
package/dist/src/ai/prompt.js
CHANGED
|
@@ -42,7 +42,14 @@ const INSTRUCTIONS = [
|
|
|
42
42
|
'- confidence: low, medium or high.',
|
|
43
43
|
'- recommendation: null, or an object with verdict, severity, rule and evidence. verdict is upheld (the lines show a breach), noted (minor, worth a private record), no_action (the report does not hold up) or unclear (you cannot tell). Use upheld or noted only when the evidence includes a line written by P1. Never name a penalty, a length of time or any other outcome; a human chooses that. Never call the reporter dishonest.',
|
|
44
44
|
'- When unsure choose the milder level.',
|
|
45
|
+
'',
|
|
46
|
+
'CONTEXT',
|
|
47
|
+
'- The DATA block may end with a row that begins "Context about P1, not evidence". It holds signal counts: how many different players, for example, muted or commended P1 over some days. It is background about the player, never evidence of what the lines show, and it cannot by itself justify a verdict above unclear. Judge only what the lines show.',
|
|
45
48
|
].join('\n');
|
|
49
|
+
/** How the row of signal counts about P1 begins. The input hash leaves every row that begins this way out. */
|
|
50
|
+
export const SIGNALS_ROW = 'Context about P1, not evidence: ';
|
|
51
|
+
/** `Muted by other players: 5 distinct players in 14 days`. */
|
|
52
|
+
const countRow = (s) => `${s.label}: ${s.distinct} distinct player${s.distinct === 1 ? '' : 's'} in ${s.windowDays} day${s.windowDays === 1 ? '' : 's'}`;
|
|
46
53
|
/** One value as a single line: control characters and runs of whitespace become one space. */
|
|
47
54
|
function oneLine(v) {
|
|
48
55
|
return cleanText(v);
|
|
@@ -154,6 +161,7 @@ export function buildAIInput(args) {
|
|
|
154
161
|
const note = args.note === undefined ? chosen.note : args.note;
|
|
155
162
|
const lines = chosen.lines.map((l) => ({ ref: l.ref, secondsIn: l.secondsIn, who: l.who, text: l.text, blocked: l.blocked, filtered: l.filtered }));
|
|
156
163
|
const people = chosen.people.map((p) => ({ alias: p.alias, role: p.role }));
|
|
164
|
+
const signals = (args.signals ?? []).map((s) => ({ label: oneLine(s.label), polarity: s.polarity, distinct: s.distinct, windowDays: s.windowDays }));
|
|
157
165
|
const data = [
|
|
158
166
|
'<data>',
|
|
159
167
|
...examples.map(renderExample),
|
|
@@ -163,6 +171,8 @@ export function buildAIInput(args) {
|
|
|
163
171
|
`pointed: ${chosen.reportedLine === null ? 'null' : lit(chosen.reportedLine)}`,
|
|
164
172
|
`people: ${people.map((p) => `${p.alias} ${p.role}`).join(', ')}`,
|
|
165
173
|
...lines.map((l) => `${l.ref} +${l.secondsIn}s ${l.who}${l.blocked ? ' blocked' : l.filtered ? ' filtered' : ''} ${lit(l.text)}`),
|
|
174
|
+
// After the lines, so it is the last thing in the block. The labels are the adopter's own (plain, at most 60 characters); one line, no tag.
|
|
175
|
+
...(signals.length === 0 ? [] : [escapeJson(`${SIGNALS_ROW}${signals.map(countRow).join('; ')}.`)]),
|
|
166
176
|
'</data>',
|
|
167
177
|
];
|
|
168
178
|
return {
|
|
@@ -179,6 +189,7 @@ export function buildAIInput(args) {
|
|
|
179
189
|
}),
|
|
180
190
|
standard: oneLine(profile.aiContext),
|
|
181
191
|
examples,
|
|
192
|
+
...(signals.length === 0 ? {} : { signals }),
|
|
182
193
|
prompt: { stable: `${INSTRUCTIONS}\n\n${aiPolicyText(policy)}`, variable: `${data.join('\n')}\n`, schema: AI_OUTPUT_SCHEMA },
|
|
183
194
|
};
|
|
184
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/ai/prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eA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|
import type { Prepared } from './case.js';
|
|
10
10
|
import type { AiOutcomeArgs } from './casebook.js';
|
|
11
|
-
import type { AIExampleInput, AIRead, ModerationAI } from './types.js';
|
|
11
|
+
import type { AIExampleInput, AIRead, AISignal, ModerationAI } from './types.js';
|
|
12
12
|
import { Meter } from './worker.js';
|
|
13
13
|
import type { AiStore } from './worker.js';
|
|
14
14
|
/**
|
|
@@ -92,6 +92,8 @@ export interface AiReadView {
|
|
|
92
92
|
model: string | null;
|
|
93
93
|
/** When the read was started, epoch ms. */
|
|
94
94
|
at: number;
|
|
95
|
+
/** How many signal counts the read was shown (`feeds.ai`); absent when it was shown none. Only the number: the counts stay in the stored row. */
|
|
96
|
+
contextSignals?: number;
|
|
95
97
|
/** Level 2 only. */
|
|
96
98
|
recommendation: null | {
|
|
97
99
|
verdict: 'upheld' | 'noted' | 'no_action' | 'unclear';
|
|
@@ -234,6 +236,8 @@ export interface AiServiceDeps {
|
|
|
234
236
|
audit: (input: AuditRecordInput) => boolean;
|
|
235
237
|
/** How long the text of a casebook example is kept (`retention.aiExamplesMs`); 0 keeps none. */
|
|
236
238
|
exampleRetentionMs: () => number;
|
|
239
|
+
/** The signal counts about a person for the AI read (`feeds.ai`): empty with the feed off. Without it no signals are sent. */
|
|
240
|
+
signals?: (subject: SubjectId) => AISignal[];
|
|
237
241
|
}
|
|
238
242
|
export declare class AiService implements AiFacade {
|
|
239
243
|
protected readonly store: AiStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/ai/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,KAAK,EAA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E,YAAY,EAAE,QAAQ,EAAE,QAAQ,GAAG,cAAc,EAAE;IAoBjF;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI;IAsEtD,uEAAuE;IACvE,OAAO,CAAC,UAAU;IASlB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI;CAGlD"}
|
package/dist/src/ai/service.js
CHANGED
|
@@ -578,6 +578,7 @@ export class AiService {
|
|
|
578
578
|
injectionSuspected: read.injectionSuspected,
|
|
579
579
|
model: row.model,
|
|
580
580
|
at: row.createdAt,
|
|
581
|
+
...(row.signals === null || row.signals === undefined ? {} : { contextSignals: row.signals.length }),
|
|
581
582
|
recommendation: level >= 2 && rec !== null ? { verdict: rec.verdict, severity: rec.severity, rule: rec.rule, evidenceLineIds: [...rec.evidence], ...this.stepFor(report, prepared, rec) } : null,
|
|
582
583
|
};
|
|
583
584
|
}
|
|
@@ -624,6 +625,7 @@ export class AiService {
|
|
|
624
625
|
closed: () => this.isClosed,
|
|
625
626
|
prepare: (report) => this.prepare(report),
|
|
626
627
|
examplesFor: (report, prepared) => this.examplesFor(report, prepared),
|
|
628
|
+
signalsFor: (report) => this.deps.signals?.(report.targetSubject) ?? [],
|
|
627
629
|
track: (c) => void this.controllers.add(c),
|
|
628
630
|
untrack: (c) => void this.controllers.delete(c),
|
|
629
631
|
auditRead: (reportId) => {
|