@chatwarden/core 0.1.6 → 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 +173 -3
- package/dist/src/ai/agreement.d.ts +46 -0
- package/dist/src/ai/agreement.d.ts.map +1 -0
- package/dist/src/ai/agreement.js +71 -0
- package/dist/src/ai/agreement.js.map +1 -0
- package/dist/src/ai/breaker.d.ts +31 -0
- package/dist/src/ai/breaker.d.ts.map +1 -0
- package/dist/src/ai/breaker.js +62 -0
- package/dist/src/ai/breaker.js.map +1 -0
- package/dist/src/ai/budget.d.ts +26 -0
- package/dist/src/ai/budget.d.ts.map +1 -0
- package/dist/src/ai/budget.js +57 -0
- package/dist/src/ai/budget.js.map +1 -0
- package/dist/src/ai/case.d.ts +37 -0
- package/dist/src/ai/case.d.ts.map +1 -0
- package/dist/src/ai/case.js +30 -0
- package/dist/src/ai/case.js.map +1 -0
- package/dist/src/ai/casebook.d.ts +59 -0
- package/dist/src/ai/casebook.d.ts.map +1 -0
- package/dist/src/ai/casebook.js +47 -0
- package/dist/src/ai/casebook.js.map +1 -0
- package/dist/src/ai/ceilings.d.ts +42 -0
- package/dist/src/ai/ceilings.d.ts.map +1 -0
- package/dist/src/ai/ceilings.js +59 -0
- package/dist/src/ai/ceilings.js.map +1 -0
- package/dist/src/ai/fake.d.ts +41 -0
- package/dist/src/ai/fake.d.ts.map +1 -0
- package/dist/src/ai/fake.js +75 -0
- package/dist/src/ai/fake.js.map +1 -0
- package/dist/src/ai/hash.d.ts +15 -0
- package/dist/src/ai/hash.d.ts.map +1 -0
- package/dist/src/ai/hash.js +22 -0
- package/dist/src/ai/hash.js.map +1 -0
- package/dist/src/ai/inert.d.ts +5 -0
- package/dist/src/ai/inert.d.ts.map +1 -0
- package/dist/src/ai/inert.js +22 -0
- package/dist/src/ai/inert.js.map +1 -0
- package/dist/src/ai/injection.d.ts +8 -0
- package/dist/src/ai/injection.d.ts.map +1 -0
- package/dist/src/ai/injection.js +30 -0
- package/dist/src/ai/injection.js.map +1 -0
- package/dist/src/ai/lines.d.ts +64 -0
- package/dist/src/ai/lines.d.ts.map +1 -0
- package/dist/src/ai/lines.js +172 -0
- package/dist/src/ai/lines.js.map +1 -0
- package/dist/src/ai/prompt.d.ts +48 -0
- package/dist/src/ai/prompt.d.ts.map +1 -0
- package/dist/src/ai/prompt.js +196 -0
- package/dist/src/ai/prompt.js.map +1 -0
- package/dist/src/ai/redact.d.ts +29 -0
- package/dist/src/ai/redact.d.ts.map +1 -0
- package/dist/src/ai/redact.js +160 -0
- package/dist/src/ai/redact.js.map +1 -0
- package/dist/src/ai/schema.d.ts +6 -0
- package/dist/src/ai/schema.d.ts.map +1 -0
- package/dist/src/ai/schema.js +50 -0
- package/dist/src/ai/schema.js.map +1 -0
- package/dist/src/ai/service.d.ts +332 -0
- package/dist/src/ai/service.d.ts.map +1 -0
- package/dist/src/ai/service.js +751 -0
- package/dist/src/ai/service.js.map +1 -0
- package/dist/src/ai/types.d.ts +196 -0
- package/dist/src/ai/types.d.ts.map +1 -0
- package/dist/src/ai/types.js +23 -0
- package/dist/src/ai/types.js.map +1 -0
- package/dist/src/ai/validate.d.ts +30 -0
- package/dist/src/ai/validate.d.ts.map +1 -0
- package/dist/src/ai/validate.js +160 -0
- package/dist/src/ai/validate.js.map +1 -0
- package/dist/src/ai/worker.d.ts +76 -0
- package/dist/src/ai/worker.d.ts.map +1 -0
- package/dist/src/ai/worker.js +293 -0
- package/dist/src/ai/worker.js.map +1 -0
- package/dist/src/audit.d.ts +12 -3
- package/dist/src/audit.d.ts.map +1 -1
- package/dist/src/audit.js +30 -4
- package/dist/src/audit.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 +84 -1
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +168 -6
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/decide.d.ts +36 -1
- package/dist/src/decide.d.ts.map +1 -1
- package/dist/src/decide.js +62 -2
- package/dist/src/decide.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 +6 -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 +37 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -3
- 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 +64 -8
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +98 -27
- 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 +28 -0
- package/dist/src/retention.d.ts.map +1 -1
- package/dist/src/retention.js +42 -10
- 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 +324 -2
- 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/agreement.ts +106 -0
- package/src/ai/breaker.ts +73 -0
- package/src/ai/budget.ts +65 -0
- package/src/ai/case.ts +74 -0
- package/src/ai/casebook.ts +75 -0
- package/src/ai/ceilings.ts +68 -0
- package/src/ai/fake.ts +105 -0
- package/src/ai/hash.ts +23 -0
- package/src/ai/inert.ts +26 -0
- package/src/ai/injection.ts +32 -0
- package/src/ai/lines.ts +216 -0
- package/src/ai/prompt.ts +223 -0
- package/src/ai/redact.ts +174 -0
- package/src/ai/schema.ts +51 -0
- package/src/ai/service.ts +961 -0
- package/src/ai/types.ts +182 -0
- package/src/ai/validate.ts +173 -0
- package/src/ai/worker.ts +372 -0
- package/src/audit.ts +31 -5
- package/src/chat.ts +109 -8
- package/src/chatwarden.ts +248 -8
- package/src/decide.ts +97 -4
- package/src/documents.ts +7 -2
- package/src/freeze.ts +8 -0
- package/src/index.ts +91 -2
- 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 +149 -27
- package/src/profileError.ts +17 -0
- package/src/retention.ts +63 -10
- 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 +358 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// Redaction: the only path from player text to the prompt (design section 8). Pure and deterministic. The signal stays and the
|
|
2
|
+
// data goes: a speaker handle becomes its alias, and anything personal becomes a typed placeholder, so a read can still see
|
|
3
|
+
// that someone posted an address or a phone number without receiving it. It is best effort: it catches the common shapes of
|
|
4
|
+
// personal data, not every disguise.
|
|
5
|
+
/** The longest note that is sent, in characters. */
|
|
6
|
+
export const AI_NOTE_MAX = 300;
|
|
7
|
+
const WORD = String.raw `[\p{L}\p{N}_]`;
|
|
8
|
+
const NOT_WORD_BEFORE = String.raw `(?<!${WORD})`;
|
|
9
|
+
const NOT_WORD_AFTER = String.raw `(?!${WORD})`;
|
|
10
|
+
const URL_TAIL = String.raw `[^\s<>"']*[^\s<>"'.,;:!?)\]]`;
|
|
11
|
+
const H = '[0-9a-f]{1,4}';
|
|
12
|
+
// "bob at example dot com", "bob (at) example (dot) com", "bob[at]example[dot]com".
|
|
13
|
+
const AT = String.raw `(?:\s*[(\[{]at[)\]}]\s*|\s+at\s+)`;
|
|
14
|
+
const DOT = String.raw `(?:\s*[(\[{]dot[)\]}]\s*|\s+dot\s+)`;
|
|
15
|
+
const SPELLED_EMAIL = new RegExp(String.raw `[\p{L}\p{N}._%+-]+${AT}[\p{L}\p{N}-]+(?:${DOT}[\p{L}\p{N}-]+)+`, 'giu');
|
|
16
|
+
const EMAIL = /[\p{L}\p{N}._%+-]+@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/giu;
|
|
17
|
+
const LINK = new RegExp([
|
|
18
|
+
String.raw `\b[a-z][a-z0-9+.-]*://${URL_TAIL}`, // a scheme URL
|
|
19
|
+
String.raw `\bwww\.${URL_TAIL}`,
|
|
20
|
+
String.raw `\b[a-z0-9-]+(?:\.[a-z][a-z0-9-]*)+/${URL_TAIL}`, // a bare domain with a path (also discord.gg/x, t.me/x)
|
|
21
|
+
String.raw `\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,24}\b`, // a bare domain: label.ending, any letters-only ending of 2 to 24
|
|
22
|
+
].join('|'), 'giu');
|
|
23
|
+
const IPV6 = new RegExp([
|
|
24
|
+
String.raw `(?:${H}:){7}${H}`,
|
|
25
|
+
String.raw `(?:${H}:){1,7}:(?:${H}(?::${H}){0,6})?`,
|
|
26
|
+
String.raw `::(?:${H}:){0,6}${H}`,
|
|
27
|
+
]
|
|
28
|
+
.map((p) => String.raw `(?<![\w:])${p}(?![\w:])`)
|
|
29
|
+
.join('|'), 'giu');
|
|
30
|
+
const OCTET = String.raw `(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`;
|
|
31
|
+
// The dots may be spaced out ("192 . 168 . 1 . 1").
|
|
32
|
+
const IPV4 = new RegExp(String.raw `(?<![\w.])${OCTET}(?:\s?\.\s?${OCTET}){3}(?![\w]|\.\d)`, 'giu');
|
|
33
|
+
const TAG = new RegExp(String.raw `@?${NOT_WORD_BEFORE}[\p{L}\p{N}_]{2,32}#\d{4,6}${NOT_WORD_AFTER}`, 'giu');
|
|
34
|
+
const MENTION = new RegExp(String.raw `@(?!P\d+${NOT_WORD_AFTER})${WORD}+(?:[.-]${WORD}+)*`, 'giu');
|
|
35
|
+
const TOKEN = new RegExp([
|
|
36
|
+
String.raw `\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b`, // a UUID
|
|
37
|
+
String.raw `(?<![\p{L}\p{N}])[0-9a-f]{20,}(?![\p{L}\p{N}])`, // a hex run
|
|
38
|
+
// A base64-like or hyphenated-key run (sk-ant-api03-...) holding both a letter and a digit, so a long plain word is left alone.
|
|
39
|
+
String.raw `(?<![\p{L}\p{N}+/_=-])(?=[A-Za-z0-9+/_=-]*\d)(?=[A-Za-z0-9+/_=-]*[A-Za-z])[A-Za-z0-9+/_=-]{20,}(?![\p{L}\p{N}+/_=-])`,
|
|
40
|
+
].join('|'), 'giu');
|
|
41
|
+
// Seven or more digits, with at most two separators between neighbours (a space, a dash, a dot, brackets).
|
|
42
|
+
const PHONE = /(?<![\p{L}\p{N}])\+?\(?\d(?:[\s().-]{0,2}\d){6,}(?![\p{L}\p{N}])/gu;
|
|
43
|
+
/**
|
|
44
|
+
* A code point that is dropped: control, bidirectional, zero-width, tag and other default-ignorable or blank-looking characters
|
|
45
|
+
* (hangul and braille fillers, variation selectors). Tab and newline become a space instead in {@link cleanText}.
|
|
46
|
+
*/
|
|
47
|
+
export function isInvisible(c) {
|
|
48
|
+
return (c < 0x20 ||
|
|
49
|
+
(c >= 0x7f && c <= 0x9f) ||
|
|
50
|
+
c === 0xad || // soft hyphen
|
|
51
|
+
c === 0x34f ||
|
|
52
|
+
c === 0x61c || // arabic letter mark
|
|
53
|
+
c === 0x115f || // hangul fillers
|
|
54
|
+
c === 0x1160 ||
|
|
55
|
+
c === 0x17b4 || // khmer inherent vowels
|
|
56
|
+
c === 0x17b5 ||
|
|
57
|
+
c === 0x180e ||
|
|
58
|
+
(c >= 0x200b && c <= 0x200f) || // zero-width space .. right-to-left mark
|
|
59
|
+
(c >= 0x202a && c <= 0x202e) || // bidi embeddings and overrides
|
|
60
|
+
(c >= 0x2060 && c <= 0x206f) || // word joiner, invisible operators, bidi isolates
|
|
61
|
+
c === 0x2800 || // braille blank
|
|
62
|
+
c === 0x3164 ||
|
|
63
|
+
(c >= 0xfe00 && c <= 0xfe0f) || // variation selectors
|
|
64
|
+
c === 0xfeff || // zero-width no-break space
|
|
65
|
+
c === 0xffa0 ||
|
|
66
|
+
(c >= 0x1d173 && c <= 0x1d17a) || // musical formatting characters
|
|
67
|
+
(c >= 0xe0000 && c <= 0xe007f) || // tag characters
|
|
68
|
+
(c >= 0xe0100 && c <= 0xe01ef) // variation selectors supplement
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One piece of text as one line of NFKC: compatibility forms folded (full-width letters and dots, composed and decomposed accents
|
|
73
|
+
* agree), invisible characters removed, every run of whitespace one space, trimmed.
|
|
74
|
+
*/
|
|
75
|
+
export function cleanText(text) {
|
|
76
|
+
let out = '';
|
|
77
|
+
for (const ch of text.normalize('NFKC')) {
|
|
78
|
+
const c = ch.codePointAt(0) ?? 0;
|
|
79
|
+
if (c === 0x09 || c === 0x0a || c === 0x0b || c === 0x0c || c === 0x0d || c === 0x85)
|
|
80
|
+
out += ' ';
|
|
81
|
+
else if (!isInvisible(c))
|
|
82
|
+
out += ch;
|
|
83
|
+
}
|
|
84
|
+
return out.replace(/\s+/gu, ' ').trim();
|
|
85
|
+
}
|
|
86
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\/]/gu, String.raw `\$&`);
|
|
87
|
+
const isWordChar = (ch) => ch !== undefined && /^[\p{L}\p{N}_]$/u.test(ch);
|
|
88
|
+
/** One alternation for every handle: longest first, whole token, any case. */
|
|
89
|
+
function handlePattern(handles, aliasOf) {
|
|
90
|
+
const byText = new Map();
|
|
91
|
+
const entries = [];
|
|
92
|
+
const alts = [];
|
|
93
|
+
for (const raw of handles) {
|
|
94
|
+
const h = cleanText(raw);
|
|
95
|
+
if (h === '')
|
|
96
|
+
continue;
|
|
97
|
+
const alias = aliasOf(raw);
|
|
98
|
+
if (alias === null)
|
|
99
|
+
continue;
|
|
100
|
+
const chars = [...h];
|
|
101
|
+
const short = chars.length < 3;
|
|
102
|
+
// A handle under 3 characters would eat ordinary words, so only an explicit @-mention of it is replaced.
|
|
103
|
+
const text = short ? `@${h}` : h;
|
|
104
|
+
const to = short ? `@${alias}` : alias;
|
|
105
|
+
const key = text.toLowerCase();
|
|
106
|
+
if (!byText.has(key))
|
|
107
|
+
byText.set(key, to);
|
|
108
|
+
entries.push({ exact: new RegExp(`^${escapeRe(text)}$`, 'iu'), to });
|
|
109
|
+
const pre = short || !isWordChar(chars[0]) ? '' : NOT_WORD_BEFORE;
|
|
110
|
+
const post = !isWordChar(chars[chars.length - 1]) ? '' : NOT_WORD_AFTER;
|
|
111
|
+
alts.push({ re: `${pre}${escapeRe(text)}${post}`, len: [...text].length });
|
|
112
|
+
}
|
|
113
|
+
if (alts.length === 0)
|
|
114
|
+
return null;
|
|
115
|
+
alts.sort((a, b) => b.len - a.len);
|
|
116
|
+
// The pattern folds case the way `iu` does, which is wider than toLowerCase (a long s matches s): look the match up by the same
|
|
117
|
+
// fold, and never leave a matched handle in the text.
|
|
118
|
+
const replace = (m) => byText.get(m.toLowerCase()) ?? entries.find((e) => e.exact.test(m))?.to ?? entries[0]?.to ?? m;
|
|
119
|
+
return { re: new RegExp(alts.map((a) => a.re).join('|'), 'giu'), replace };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Redact one piece of player text for a provider. Order: the text is folded to NFKC, control, bidi, zero-width and filler
|
|
123
|
+
* characters are removed and whitespace collapsed (so a hidden character cannot disguise an address or a handle); each speaker
|
|
124
|
+
* handle becomes its alias, whole token and in any case; then `[email]` (also spelled out, "bob at host dot com"), `[link]` (URLs
|
|
125
|
+
* and any bare domain), `[ip]` (the dots may be spaced), `[tag]` (`name#1234`), `[mention]`, `[token]` and `[phone]`. A handle under
|
|
126
|
+
* 3 characters is replaced only as an @-mention. `aliasOf` returns the alias of a handle, or null to leave it. Pure and
|
|
127
|
+
* deterministic.
|
|
128
|
+
* @experimental
|
|
129
|
+
*/
|
|
130
|
+
export function redactText(text, handles, aliasOf) {
|
|
131
|
+
let out = cleanText(text);
|
|
132
|
+
const h = handlePattern(handles, aliasOf);
|
|
133
|
+
if (h)
|
|
134
|
+
out = out.replace(h.re, h.replace);
|
|
135
|
+
return out
|
|
136
|
+
.replace(SPELLED_EMAIL, '[email]')
|
|
137
|
+
.replace(EMAIL, '[email]')
|
|
138
|
+
.replace(LINK, '[link]')
|
|
139
|
+
.replace(IPV6, '[ip]')
|
|
140
|
+
.replace(IPV4, '[ip]')
|
|
141
|
+
.replace(TAG, '[tag]')
|
|
142
|
+
.replace(MENTION, '[mention]')
|
|
143
|
+
.replace(TOKEN, '[token]')
|
|
144
|
+
.replace(PHONE, '[phone]');
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The reporter's note for a provider: redacted like a line, then cut to `max` characters (default 300) without splitting a
|
|
148
|
+
* surrogate pair. Null when nothing is left.
|
|
149
|
+
* @experimental
|
|
150
|
+
*/
|
|
151
|
+
export function redactNote(note, handles, aliasOf, max = AI_NOTE_MAX) {
|
|
152
|
+
if (note === null || note === undefined)
|
|
153
|
+
return null;
|
|
154
|
+
const out = redactText(note, handles, aliasOf);
|
|
155
|
+
if (out === '')
|
|
156
|
+
return null;
|
|
157
|
+
const chars = [...out];
|
|
158
|
+
return chars.length > max ? chars.slice(0, max).join('').trimEnd() : out;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/ai/redact.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,4HAA4H;AAC5H,4HAA4H;AAC5H,qCAAqC;AAErC,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAE/B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,eAAe,CAAC;AACvC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA,OAAO,IAAI,GAAG,CAAC;AACjD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA,MAAM,IAAI,GAAG,CAAC;AAC/C,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA,8BAA8B,CAAC;AAC1D,MAAM,CAAC,GAAG,eAAe,CAAC;AAE1B,oFAAoF;AACpF,MAAM,EAAE,G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;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MA4B7B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// The JSON Schema for a read's answer. STATIC: it never mentions a rule number or a line ref, because those are checked in core
|
|
2
|
+
// (validate.ts), so a provider compiles the schema once. It uses only what structured outputs accept: types, enums, anyOf,
|
|
3
|
+
// `required` and `additionalProperties: false`; no minLength, maximum or the like (the limits are enforced by validate.ts).
|
|
4
|
+
function deepFreeze(value) {
|
|
5
|
+
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
6
|
+
for (const v of Object.values(value))
|
|
7
|
+
deepFreeze(v);
|
|
8
|
+
Object.freeze(value);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
const LEVELS = ['banter', 'rude', 'hostile', 'severe'];
|
|
13
|
+
const RULE = {
|
|
14
|
+
anyOf: [{ type: 'integer' }, { type: 'string', enum: ['uncovered'] }, { type: 'null' }],
|
|
15
|
+
};
|
|
16
|
+
const REFS = { type: 'array', items: { type: 'string' } };
|
|
17
|
+
/**
|
|
18
|
+
* The answer a model returns for one report. Core validates the parsed JSON again (`validateAIOutput`); the schema only shapes it.
|
|
19
|
+
* @experimental
|
|
20
|
+
*/
|
|
21
|
+
export const AI_OUTPUT_SCHEMA = deepFreeze({
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
severity: { type: 'string', enum: LEVELS },
|
|
25
|
+
rule: RULE,
|
|
26
|
+
summary: { type: 'string' },
|
|
27
|
+
evidence: REFS,
|
|
28
|
+
confidence: { type: 'string', enum: ['low', 'medium', 'high'] },
|
|
29
|
+
injectionSuspected: { type: 'boolean' },
|
|
30
|
+
recommendation: {
|
|
31
|
+
anyOf: [
|
|
32
|
+
{ type: 'null' },
|
|
33
|
+
{
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
verdict: { type: 'string', enum: ['upheld', 'noted', 'no_action', 'unclear'] },
|
|
37
|
+
severity: { type: 'string', enum: LEVELS },
|
|
38
|
+
rule: RULE,
|
|
39
|
+
evidence: REFS,
|
|
40
|
+
},
|
|
41
|
+
required: ['verdict', 'severity', 'rule', 'evidence'],
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
required: ['severity', 'rule', 'summary', 'evidence', 'confidence', 'injectionSuspected', 'recommendation'],
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/ai/schema.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,2HAA2H;AAC3H,4HAA4H;AAE5H,SAAS,UAAU,CAAI,KAAQ;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3E,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAe,CAAC;YAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACvD,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;CACxF,CAAC;AACF,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI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js';
|
|
3
|
+
import type { Suggestion } from '../ladder.js';
|
|
4
|
+
import type { ResolvedProfile } from '../profile.js';
|
|
5
|
+
import type { CommunityRules, RuleRef } from '../rules.js';
|
|
6
|
+
import type { AiOutcomeInsert, Clock, ConductLevel, Logger, ReportRecord, SanctionKind, Store, SubjectId } from '../types.js';
|
|
7
|
+
import { Breaker } from './breaker.js';
|
|
8
|
+
import { CallWindow } from './budget.js';
|
|
9
|
+
import type { Prepared } from './case.js';
|
|
10
|
+
import type { AiOutcomeArgs } from './casebook.js';
|
|
11
|
+
import type { AIExampleInput, AIRead, AISignal, ModerationAI } from './types.js';
|
|
12
|
+
import { Meter } from './worker.js';
|
|
13
|
+
import type { AiStore } from './worker.js';
|
|
14
|
+
/**
|
|
15
|
+
* What the code decides about the AI. The adapter and the ceilings on level and spend are code, never the hub's.
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
export interface AiOptions {
|
|
19
|
+
/** The model behind the reads. Runs on the server only. */
|
|
20
|
+
adapter: ModerationAI;
|
|
21
|
+
/** The highest level the hub may switch to. Default 2. */
|
|
22
|
+
maxLevel?: 1 | 2;
|
|
23
|
+
/** The most the AI may spend in a UTC day, in micro-dollars (1 = $0.000001). Default 1 000 000 ($1.00). Set in code: a hub cannot raise it. */
|
|
24
|
+
dailyBudgetMicros?: number;
|
|
25
|
+
/** The most calls in any minute. Default 30. */
|
|
26
|
+
perMinuteCalls?: number;
|
|
27
|
+
/** The most reads in flight at once. Default 2. */
|
|
28
|
+
concurrency?: number;
|
|
29
|
+
/** The hard deadline for one call, in milliseconds. Default 30 000. */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* `'raw'` (default) sends a line the filter touched (blocked, or starred in the room) as typed: the model needs the words to judge
|
|
33
|
+
* intent. `'mask'` sends it masked instead (a starred line as the room saw it, a blocked line as stars). Read the adapter's README
|
|
34
|
+
* before leaving the default: the provider receives abusive text.
|
|
35
|
+
*/
|
|
36
|
+
blockedLines?: 'raw' | 'mask';
|
|
37
|
+
/** Reserved. No room tag, and no tag value, is ever sent to a provider in this release. */
|
|
38
|
+
contextTags?: string[];
|
|
39
|
+
}
|
|
40
|
+
/** Where the AI stands, for Settings. */
|
|
41
|
+
export interface AiStatus {
|
|
42
|
+
/** An adapter is configured. */
|
|
43
|
+
available: boolean;
|
|
44
|
+
/** The effective level: the lower of the hub's setting and `maxLevel`; 0 without an adapter. */
|
|
45
|
+
level: 0 | 1 | 2;
|
|
46
|
+
maxLevel: 0 | 1 | 2;
|
|
47
|
+
state: 'ok' | 'paused_budget' | 'unavailable' | 'off';
|
|
48
|
+
/** Today's spend (UTC), in micro-dollars, from the store. */
|
|
49
|
+
spentMicros: number;
|
|
50
|
+
capMicros: number;
|
|
51
|
+
/** The owner's ceiling on calls in a UTC day (`profile.ai.dailyCalls`); `reads` is counted against it. */
|
|
52
|
+
capCalls: number;
|
|
53
|
+
/** The UTC day the spend is for, `YYYY-MM-DD`. */
|
|
54
|
+
day: string;
|
|
55
|
+
/** Calls made today (UTC), from the store. */
|
|
56
|
+
reads: number;
|
|
57
|
+
/** The share of input tokens the provider served from its cache, over the calls this process made; null before any. */
|
|
58
|
+
cacheHitRate: number | null;
|
|
59
|
+
/** Answers core refused, by validator code, since this process started. Codes only, never text. */
|
|
60
|
+
invalid: Record<string, number>;
|
|
61
|
+
}
|
|
62
|
+
/** What the queue carries for a report: no summary, no line ids. */
|
|
63
|
+
export interface AiBrief {
|
|
64
|
+
severity: ConductLevel;
|
|
65
|
+
confidence: AIRead['confidence'];
|
|
66
|
+
rule: number | 'uncovered' | null;
|
|
67
|
+
/** The read was made from older rules or an older version of the case. */
|
|
68
|
+
stale: boolean;
|
|
69
|
+
injectionSuspected: boolean;
|
|
70
|
+
/** Level 2 and a recommendation that is not `unclear`. */
|
|
71
|
+
hasRecommendation: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** The step the ladder gives for the AI's conduct level: what a one-click accept may fill. */
|
|
74
|
+
export interface SuggestionStep {
|
|
75
|
+
kind: SanctionKind;
|
|
76
|
+
durationMs: number | null;
|
|
77
|
+
label: string;
|
|
78
|
+
}
|
|
79
|
+
/** A stored read as the case page shows it. */
|
|
80
|
+
export interface AiReadView {
|
|
81
|
+
/** The read's id: what a decision echoes back. */
|
|
82
|
+
id: string;
|
|
83
|
+
severity: ConductLevel;
|
|
84
|
+
rule: number | 'uncovered' | null;
|
|
85
|
+
summary: string;
|
|
86
|
+
/** Real line ids, at most 5. */
|
|
87
|
+
evidenceLineIds: string[];
|
|
88
|
+
confidence: AIRead['confidence'];
|
|
89
|
+
/** From older rules, or from an older version of the case. */
|
|
90
|
+
stale: boolean;
|
|
91
|
+
injectionSuspected: boolean;
|
|
92
|
+
model: string | null;
|
|
93
|
+
/** When the read was started, epoch ms. */
|
|
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;
|
|
97
|
+
/** Level 2 only. */
|
|
98
|
+
recommendation: null | {
|
|
99
|
+
verdict: 'upheld' | 'noted' | 'no_action' | 'unclear';
|
|
100
|
+
severity: ConductLevel;
|
|
101
|
+
rule: number | 'uncovered' | null;
|
|
102
|
+
evidenceLineIds: string[];
|
|
103
|
+
/** `cw.suggest` for the AI's conduct level, now; null when it names no action. */
|
|
104
|
+
step: SuggestionStep | null;
|
|
105
|
+
/** `step` is within the ceilings (a warning, a note or a restriction of at most 24 hours, with a line by the reported person cited). */
|
|
106
|
+
stepWithinCeiling: boolean;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** The casebook counts for one rule. */
|
|
110
|
+
export interface AiStatsRuleView {
|
|
111
|
+
rule: number | 'uncovered' | null;
|
|
112
|
+
decided: number;
|
|
113
|
+
agree: number;
|
|
114
|
+
override: number;
|
|
115
|
+
none: number;
|
|
116
|
+
falsePositives: number;
|
|
117
|
+
/** Decisions that were a one-click accept of the AI's pre-fill. */
|
|
118
|
+
oneClick: number;
|
|
119
|
+
}
|
|
120
|
+
/** The casebook, overall and per rule. */
|
|
121
|
+
export interface AiStatsView {
|
|
122
|
+
since: number;
|
|
123
|
+
decided: number;
|
|
124
|
+
agree: number;
|
|
125
|
+
override: number;
|
|
126
|
+
none: number;
|
|
127
|
+
falsePositives: number;
|
|
128
|
+
oneClick: number;
|
|
129
|
+
/** agree / (agree + override); null with neither. */
|
|
130
|
+
agreementRate: number | null;
|
|
131
|
+
/** falsePositives / (agree + override); null with neither. */
|
|
132
|
+
falsePositiveRate: number | null;
|
|
133
|
+
/** oneClick / (agree + override): how often a shown recommendation was accepted as it stood; null with none shown. */
|
|
134
|
+
oneClickRate: number | null;
|
|
135
|
+
rules: AiStatsRuleView[];
|
|
136
|
+
}
|
|
137
|
+
/** What `cw.ai.readAgain` answers. */
|
|
138
|
+
export type AiReadAgain = AiReadView | 'pending' | 'budget' | 'off' | 'rate'
|
|
139
|
+
/** The read for this input ended without an answer and a moderator already retook it once: there is nothing more to ask. */
|
|
140
|
+
| 'final'
|
|
141
|
+
/** The breaker is open or the call window is full: nothing can be called for `retryAfterMs`. */
|
|
142
|
+
| {
|
|
143
|
+
unavailable: {
|
|
144
|
+
retryAfterMs: number;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* `cw.ai`. Every method is safe to call at any time: with the AI off, without an adapter or with a failing provider or store it
|
|
149
|
+
* answers as if there were no AI (null, an empty map, `'off'`), and never throws.
|
|
150
|
+
* @experimental
|
|
151
|
+
*/
|
|
152
|
+
export interface AiFacade {
|
|
153
|
+
/** The effective level now. */
|
|
154
|
+
level(): 0 | 1 | 2;
|
|
155
|
+
status(): AiStatus;
|
|
156
|
+
/**
|
|
157
|
+
* The newest finished read of a report as the case page shows it, or null. At level 0 nothing is read from the store. With
|
|
158
|
+
* `open: true` (the case page) a report with no read, or a stale one, is queued for a (re)read.
|
|
159
|
+
*/
|
|
160
|
+
read(reportId: string, opts?: {
|
|
161
|
+
open?: boolean;
|
|
162
|
+
}): AiReadView | null;
|
|
163
|
+
/**
|
|
164
|
+
* Whether a read of this report is on its way now, so the case page may wait for one: the effective level is 1 or 2, an adapter is
|
|
165
|
+
* configured, the breaker is closed, neither daily cap (money, calls) is reached, the report is open and its read has not ended
|
|
166
|
+
* without an answer. False otherwise, and on any failure; the page then renders exactly as with the AI off.
|
|
167
|
+
*/
|
|
168
|
+
expected(reportId: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* "Read again": the stored read when the input has not changed (no call), else a call is queued and the answer is `'pending'`.
|
|
171
|
+
* `'off'` at level 0 or for a report that is gone or decided, `'budget'` at the daily money or call cap, `'rate'` once `actor` has
|
|
172
|
+
* asked 10 times in a minute (counted in this process; every answer below uses an ask), `{ unavailable }` while the breaker is open or
|
|
173
|
+
* the call window is full, and `'final'` when the read for this input ended without an answer (declined, invalid twice, fatal, given
|
|
174
|
+
* up) and an explicit ask has already retaken it once. The first explicit ask on such a row retakes it (`'pending'`): it is charged
|
|
175
|
+
* to the spend and audited like any other read.
|
|
176
|
+
*/
|
|
177
|
+
readAgain(reportId: string, actor: string): Promise<AiReadAgain>;
|
|
178
|
+
/** The queue's brief of each report that has a read. Reports without one are absent. */
|
|
179
|
+
briefs(reportIds: readonly string[]): Map<string, AiBrief>;
|
|
180
|
+
/** The casebook counts for decisions at or after `since` (default: the last 30 days). */
|
|
181
|
+
stats(q?: {
|
|
182
|
+
since?: number;
|
|
183
|
+
}): AiStatsView;
|
|
184
|
+
/**
|
|
185
|
+
* The one function the appeals inbox calls when a decision is reversed (a granted appeal, a take-back): the report's casebook row can
|
|
186
|
+
* never teach again, loses its example text, and counts as an AI false positive when the AI had recommended action. True when the
|
|
187
|
+
* report has a row.
|
|
188
|
+
*/
|
|
189
|
+
markReversed(reportId: string): boolean;
|
|
190
|
+
/** A senior's "don't teach" mark on a decided case: the row can never teach again and loses its example text. True when the report has a row. */
|
|
191
|
+
dontTeach(reportId: string): boolean;
|
|
192
|
+
/** Resolves when no read is queued or running (tests, graceful shutdown). */
|
|
193
|
+
idle(): Promise<void>;
|
|
194
|
+
/** Run the sweeper once. The timer does this every 60 seconds. */
|
|
195
|
+
sweep(): Promise<void>;
|
|
196
|
+
/** Stop the sweeper and abort the calls in flight. `cw.close()` does this. */
|
|
197
|
+
close(): void;
|
|
198
|
+
}
|
|
199
|
+
/** How often the sweeper runs. */
|
|
200
|
+
export declare const SWEEP_EVERY_MS = 60000;
|
|
201
|
+
/** The most reports one sweep queues. */
|
|
202
|
+
export declare const SWEEP_BATCH = 20;
|
|
203
|
+
/** The most stale reads one idle sweep queues. */
|
|
204
|
+
export declare const STALE_PER_SWEEP = 5;
|
|
205
|
+
/** How many times one moderator may ask for a read again in a minute. */
|
|
206
|
+
export declare const READ_AGAIN_PER_MINUTE = 10;
|
|
207
|
+
/** The most reports the sweeper remembers as not to be queued (and the most final reads it remembers). */
|
|
208
|
+
export declare const PARKED_MAX = 2000;
|
|
209
|
+
/** The audit actor for the AI: `ai:` and the adapter's id with every character the trail refuses made an underscore, cut to fit. */
|
|
210
|
+
export declare function aiActorOf(adapterId: string): string;
|
|
211
|
+
/** The store, typed with its AI methods; throws a plain error when it has not got them. */
|
|
212
|
+
export declare function requireAiStore(store: Store): AiStore;
|
|
213
|
+
/**
|
|
214
|
+
* Check the AI option before anything is started (throws a plain error for a bad one) and name the AI methods the store lacks. A store that
|
|
215
|
+
* lacks some leaves the AI inert: `createChatwarden` says so once and carries on, as it does for any optional Store method.
|
|
216
|
+
*/
|
|
217
|
+
export declare function checkAiSetup(store: Store, options: AiOptions): string[];
|
|
218
|
+
declare function checkOptions(o: AiOptions): Required<Omit<AiOptions, 'adapter' | 'contextTags'>> & {
|
|
219
|
+
contextTags: string[];
|
|
220
|
+
};
|
|
221
|
+
/** What the service needs from the kit around it. */
|
|
222
|
+
export interface AiServiceDeps {
|
|
223
|
+
options: AiOptions;
|
|
224
|
+
store: Store;
|
|
225
|
+
clock: Clock;
|
|
226
|
+
logger: Logger | undefined;
|
|
227
|
+
/** The profile in force now (never kept across calls). */
|
|
228
|
+
profile: () => ResolvedProfile;
|
|
229
|
+
rules: CommunityRules;
|
|
230
|
+
/** `cw.suggest`. */
|
|
231
|
+
suggest: (subject: SubjectId, level: ConductLevel | null, rule: RuleRef, ctx: {
|
|
232
|
+
roomId: string | null;
|
|
233
|
+
}) => Suggestion;
|
|
234
|
+
subscribe: Subscribe;
|
|
235
|
+
/** `cw.audit.record`. */
|
|
236
|
+
audit: (input: AuditRecordInput) => boolean;
|
|
237
|
+
/** How long the text of a casebook example is kept (`retention.aiExamplesMs`); 0 keeps none. */
|
|
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[];
|
|
241
|
+
}
|
|
242
|
+
export declare class AiService implements AiFacade {
|
|
243
|
+
protected readonly store: AiStore;
|
|
244
|
+
protected readonly clock: Clock;
|
|
245
|
+
protected readonly adapter: ModerationAI;
|
|
246
|
+
protected readonly actor: string;
|
|
247
|
+
protected readonly opts: ReturnType<typeof checkOptions>;
|
|
248
|
+
protected readonly meter: Meter;
|
|
249
|
+
protected readonly breaker: Breaker;
|
|
250
|
+
protected readonly window: CallWindow;
|
|
251
|
+
private readonly queue;
|
|
252
|
+
private readonly queued;
|
|
253
|
+
private readonly running;
|
|
254
|
+
private readonly parked;
|
|
255
|
+
private readonly retakes;
|
|
256
|
+
private readonly controllers;
|
|
257
|
+
private readonly cache;
|
|
258
|
+
private readonly asked;
|
|
259
|
+
private pumpTimer;
|
|
260
|
+
private sweepTimer;
|
|
261
|
+
private unsubscribe;
|
|
262
|
+
private waiters;
|
|
263
|
+
private policyText;
|
|
264
|
+
private lastStable;
|
|
265
|
+
private stableKey;
|
|
266
|
+
private isClosed;
|
|
267
|
+
protected readonly deps: AiServiceDeps;
|
|
268
|
+
constructor(deps: AiServiceDeps);
|
|
269
|
+
level(): 0 | 1 | 2;
|
|
270
|
+
status(): AiStatus;
|
|
271
|
+
read(reportId: string, o?: {
|
|
272
|
+
open?: boolean;
|
|
273
|
+
}): AiReadView | null;
|
|
274
|
+
expected(reportId: string): boolean;
|
|
275
|
+
readAgain(reportId: string, actor: string): Promise<AiReadAgain>;
|
|
276
|
+
/** A sliding minute per actor. Held in memory: it guards the provider's bill from one eager hand, not a security boundary. */
|
|
277
|
+
private allowAsk;
|
|
278
|
+
briefs(reportIds: readonly string[]): Map<string, AiBrief>;
|
|
279
|
+
stats(q?: {
|
|
280
|
+
since?: number;
|
|
281
|
+
}): AiStatsView;
|
|
282
|
+
markReversed(reportId: string): boolean;
|
|
283
|
+
dontTeach(reportId: string): boolean;
|
|
284
|
+
private mark;
|
|
285
|
+
idle(): Promise<void>;
|
|
286
|
+
close(): void;
|
|
287
|
+
/**
|
|
288
|
+
* Put a report on the queue. Synchronous and cheap: no store read, no await. Does nothing at level 0. `force` is for a case that
|
|
289
|
+
* changed or was asked for (it forgets any wait the sweeper was keeping).
|
|
290
|
+
*/
|
|
291
|
+
enqueue(reportId: string, o?: {
|
|
292
|
+
force?: boolean;
|
|
293
|
+
}): boolean;
|
|
294
|
+
/** The reporter's follow-up changed the case: read it again once. Called by the facade's `reports.addDetail`. */
|
|
295
|
+
caseChanged(reportId: string): void;
|
|
296
|
+
private schedulePump;
|
|
297
|
+
private pump;
|
|
298
|
+
private runOne;
|
|
299
|
+
/** Remember not to queue `reportId` before `until`. Bounded: the oldest entry goes when the list is full. */
|
|
300
|
+
private park;
|
|
301
|
+
/** How many reports the sweeper is holding back (tests). */
|
|
302
|
+
parkedSize(): number;
|
|
303
|
+
private isIdle;
|
|
304
|
+
private settleIdle;
|
|
305
|
+
sweep(): Promise<void>;
|
|
306
|
+
private isParked;
|
|
307
|
+
/** A report made ready for a read, cached by what it is made from. */
|
|
308
|
+
protected prepare(report: ReportRecord): Prepared;
|
|
309
|
+
private view;
|
|
310
|
+
/** The step the ladder gives for the recommendation, and whether it is within the ceilings. */
|
|
311
|
+
private stepFor;
|
|
312
|
+
private env;
|
|
313
|
+
/**
|
|
314
|
+
* Casebook examples for a read: none unless learning is on, example text is kept at all, the case names a reason that maps to a rule,
|
|
315
|
+
* and at least 30 teachable decisions exist. Then the two newest of that rule at the conduct level the AI gave this report before
|
|
316
|
+
* (or, for a first read, at any level), newest first. Each is pseudonymised already; the row's report id is its id.
|
|
317
|
+
*/
|
|
318
|
+
protected examplesFor(report: ReportRecord, prepared: Prepared): AIExampleInput[];
|
|
319
|
+
/**
|
|
320
|
+
* The casebook row for a decision (the hook `DecisionService` calls inside its transaction), computed here from the stored read and
|
|
321
|
+
* the decision. The server always records it when a read exists at level 1 or 2, whichever way the decision came (the hub, `cw.decide`,
|
|
322
|
+
* a webhook, a bulk dismissal); the echo, when there is one, only names the read the moderator saw, says whether they clicked accept
|
|
323
|
+
* (kept only when the decision is the pre-fill) and gives the conduct level of their form (kept only when it fits the verdict).
|
|
324
|
+
* With no echo there is no example text. Null at level 0 and when the report has no read. Fenced by the caller.
|
|
325
|
+
*/
|
|
326
|
+
outcomeOf(args: AiOutcomeArgs): AiOutcomeInsert | null;
|
|
327
|
+
/** The owner's most calls in a UTC day, read live from the profile. */
|
|
328
|
+
private dailyCalls;
|
|
329
|
+
protected warn(event: string, err: unknown): void;
|
|
330
|
+
}
|
|
331
|
+
export {};
|
|
332
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +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,K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