coauthored 0.0.0-stage → 1.0.1

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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/PRIVACY.md +107 -0
  3. package/README.md +113 -3
  4. package/THIRD_PARTY_LICENSES.md +105 -0
  5. package/dist/cli/analytics/anchors.js +39 -0
  6. package/dist/cli/analytics/archetypes.js +193 -0
  7. package/dist/cli/analytics/content/analyzer.js +945 -0
  8. package/dist/cli/analytics/content/classify.js +115 -0
  9. package/dist/cli/analytics/content/demo-corpus.js +301 -0
  10. package/dist/cli/analytics/content/sketch.js +54 -0
  11. package/dist/cli/analytics/dataset.js +321 -0
  12. package/dist/cli/analytics/demo-fixtures.js +531 -0
  13. package/dist/cli/analytics/fdr.js +183 -0
  14. package/dist/cli/analytics/helicorder.js +66 -0
  15. package/dist/cli/analytics/insights.js +589 -0
  16. package/dist/cli/analytics/models.js +75 -0
  17. package/dist/cli/analytics/pricing.js +121 -0
  18. package/dist/cli/analytics/probable-cause.js +115 -0
  19. package/dist/cli/analytics/report-builder.js +162 -0
  20. package/dist/cli/analytics/statistics.js +91 -0
  21. package/dist/cli/analytics/time.js +252 -0
  22. package/dist/cli/cli/args.js +105 -0
  23. package/dist/cli/cli/browser.js +71 -0
  24. package/dist/cli/cli/index.js +20 -0
  25. package/dist/cli/cli/main.js +520 -0
  26. package/dist/cli/cli/phrase-review.js +78 -0
  27. package/dist/cli/cli/server.js +481 -0
  28. package/dist/cli/cli/terminal.js +363 -0
  29. package/dist/cli/ingest/adapters/aider.js +116 -0
  30. package/dist/cli/ingest/adapters/claude-code.js +139 -0
  31. package/dist/cli/ingest/adapters/cline-roo.js +89 -0
  32. package/dist/cli/ingest/adapters/codex-cli.js +240 -0
  33. package/dist/cli/ingest/adapters/content.js +99 -0
  34. package/dist/cli/ingest/adapters/cursor-ide.js +149 -0
  35. package/dist/cli/ingest/adapters/gemini-cli.js +208 -0
  36. package/dist/cli/ingest/adapters/index.js +18 -0
  37. package/dist/cli/ingest/adapters/opencode.js +203 -0
  38. package/dist/cli/ingest/adapters/pi-agent.js +85 -0
  39. package/dist/cli/ingest/adapters/shared.js +484 -0
  40. package/dist/cli/ingest/content-sink.js +31 -0
  41. package/dist/cli/ingest/discovery.js +50 -0
  42. package/dist/cli/ingest/message-digests.js +61 -0
  43. package/dist/cli/ingest/pipeline.js +155 -0
  44. package/dist/cli/ingest/safe-fs.js +284 -0
  45. package/dist/cli/ingest/sqlite-stage.js +139 -0
  46. package/dist/cli/ingest/time-window.js +34 -0
  47. package/dist/cli/ingest/tool-map.js +24 -0
  48. package/dist/cli/ingest/types.js +1 -0
  49. package/dist/cli/ingest/worker.js +97 -0
  50. package/dist/cli/report/content/emoji-names.js +3956 -0
  51. package/dist/cli/report/content/insights.js +41 -0
  52. package/dist/cli/report/content/lexicons.js +112 -0
  53. package/dist/cli/report/content/policy.js +77 -0
  54. package/dist/cli/report/content/redact.js +164 -0
  55. package/dist/cli/report/content/stopwords.js +8848 -0
  56. package/dist/cli/report/content/suppression.js +2617 -0
  57. package/dist/cli/report/content/validate.js +152 -0
  58. package/dist/cli/report/copy-lint.js +105 -0
  59. package/dist/cli/report/share.js +132 -0
  60. package/dist/cli/report/types.js +1 -0
  61. package/dist/cli/report/validators.js +334 -0
  62. package/dist/web/assets/Archivo-VF-BohoA-Sn.woff2 +0 -0
  63. package/dist/web/assets/DelaGothicOne-subset-CpoJGhTq.woff2 +0 -0
  64. package/dist/web/assets/Film-BkhZFxG9.css +1 -0
  65. package/dist/web/assets/MartianMono-VF-CmJ1nXx9.woff2 +0 -0
  66. package/dist/web/assets/app-Dw1a5h5V.js +38 -0
  67. package/dist/web/assets/bricolage-grotesque-latin-700-normal-gtcctNPv.woff2 +0 -0
  68. package/dist/web/assets/bricolage-grotesque-latin-800-normal-J50vIsBe.woff2 +0 -0
  69. package/dist/web/assets/chorus-D7bfON5Z.ogg +0 -0
  70. package/dist/web/assets/chorus-bass-CBTKpMv_.ogg +0 -0
  71. package/dist/web/assets/chorus-drums-BOzgLSoq.ogg +0 -0
  72. package/dist/web/assets/chorus-harmony-DnJYs_tp.ogg +0 -0
  73. package/dist/web/assets/chorus-lead-CFpg5DC1.ogg +0 -0
  74. package/dist/web/assets/chunk-BNfsY4o8.js +1 -0
  75. package/dist/web/assets/chunk-BSm8IhPY.js +1 -0
  76. package/dist/web/assets/chunk-Bi6EQAkf.js +1 -0
  77. package/dist/web/assets/chunk-D6HyoJCB.js +46 -0
  78. package/dist/web/assets/chunk-DrEayQLY.js +1 -0
  79. package/dist/web/assets/chunk-V3YGpFIw.js +1 -0
  80. package/dist/web/assets/chunk-XGhNFWse.js +1 -0
  81. package/dist/web/assets/dialogue-card-A5zmbNhu.ogg +0 -0
  82. package/dist/web/assets/groove-bass-BFNelLKi.ogg +0 -0
  83. package/dist/web/assets/groove-drums-BY1SBntR.ogg +0 -0
  84. package/dist/web/assets/groove-harmony-C0CrBzu3.ogg +0 -0
  85. package/dist/web/assets/groove-lead-CEYPzm5U.ogg +0 -0
  86. package/dist/web/assets/groove-ln-zQmTb.ogg +0 -0
  87. package/dist/web/assets/guess-high-CL6mF18x.ogg +0 -0
  88. package/dist/web/assets/guess-low-C3UnKayZ.ogg +0 -0
  89. package/dist/web/assets/higher-BevsMIWl.ogg +0 -0
  90. package/dist/web/assets/identity-0EPS3msD.ogg +0 -0
  91. package/dist/web/assets/index-DpT0dtHc.css +1 -0
  92. package/dist/web/assets/intro-DeRh6kUx.ogg +0 -0
  93. package/dist/web/assets/intro-bass-D63IPU0H.ogg +0 -0
  94. package/dist/web/assets/intro-drums-Dt9QO534.ogg +0 -0
  95. package/dist/web/assets/intro-harmony-DBsMG9jJ.ogg +0 -0
  96. package/dist/web/assets/intro-lead-DWcWS1ia.ogg +0 -0
  97. package/dist/web/assets/jar-coin-rtCvspuq.ogg +0 -0
  98. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  99. package/dist/web/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
  100. package/dist/web/assets/ledger-tick-C1rQgQGX.ogg +0 -0
  101. package/dist/web/assets/night-B_bMOZcf.ogg +0 -0
  102. package/dist/web/assets/night-bass-B-7Ay9ME.ogg +0 -0
  103. package/dist/web/assets/night-drums-zEtqWXX3.ogg +0 -0
  104. package/dist/web/assets/night-harmony-C5Ix2yce.ogg +0 -0
  105. package/dist/web/assets/night-lead-B7KMlRyj.ogg +0 -0
  106. package/dist/web/assets/ourturn-DX78hTEz.ogg +0 -0
  107. package/dist/web/assets/plus-jakarta-sans-latin-400-normal-Dhut76fR.woff2 +0 -0
  108. package/dist/web/assets/plus-jakarta-sans-latin-500-normal-Bf-nb4oT.woff2 +0 -0
  109. package/dist/web/assets/plus-jakarta-sans-latin-600-normal-DLTa1BUW.woff2 +0 -0
  110. package/dist/web/assets/plus-jakarta-sans-latin-700-normal-CfpNZvy6.woff2 +0 -0
  111. package/dist/web/assets/reveal-BmWAGHih.ogg +0 -0
  112. package/dist/web/assets/review-split-Dac4zagw.ogg +0 -0
  113. package/dist/web/assets/shutter-uhz2Y9S9.ogg +0 -0
  114. package/dist/web/assets/soclose-CiUFR5St.ogg +0 -0
  115. package/dist/web/assets/stinger-TnnzHAMN.ogg +0 -0
  116. package/dist/web/assets/stomp-mzIk4cGm.ogg +0 -0
  117. package/dist/web/assets/syne-latin-700-normal-AF3Rs61n.woff2 +0 -0
  118. package/dist/web/assets/syne-latin-800-normal-EehdNYzx.woff2 +0 -0
  119. package/dist/web/assets/tension-BHvWG5ru.ogg +0 -0
  120. package/dist/web/assets/tension-bass-4G-2qA9W.ogg +0 -0
  121. package/dist/web/assets/tension-drums-D7sdehJr.ogg +0 -0
  122. package/dist/web/assets/tension-harmony-FyPldmLb.ogg +0 -0
  123. package/dist/web/assets/tension-lead-C5uoFMR8.ogg +0 -0
  124. package/dist/web/assets/why-clock-Dzs1A_ym.ogg +0 -0
  125. package/dist/web/favicon.svg +1 -0
  126. package/dist/web/index.html +16 -0
  127. package/dist/web/licenses/OFL-Archivo.txt +93 -0
  128. package/dist/web/licenses/OFL-DelaGothic.txt +93 -0
  129. package/dist/web/licenses/OFL-MartianMono.txt +93 -0
  130. package/package.json +63 -6
@@ -0,0 +1,334 @@
1
+ import { validateContentChapter, validateContentReceipt } from './content/validate.js';
2
+ export { validateContentChapter } from './content/validate.js';
3
+ const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
4
+ const FORBIDDEN_PATH_KEYS = new Set([
5
+ 'canonicalPath',
6
+ 'filePath',
7
+ 'absPath',
8
+ 'sourcePath',
9
+ 'localPath',
10
+ 'cwd',
11
+ ]);
12
+ const ALLOWED_RECEIPT_SOURCE_KEYS = new Set([
13
+ 'candidateId',
14
+ 'harness',
15
+ 'displayName',
16
+ 'adapterVersion',
17
+ 'snapshotMethod',
18
+ 'filesSeen',
19
+ 'filesOk',
20
+ 'filesQuarantined',
21
+ 'linesSeen',
22
+ 'linesSkipped',
23
+ 'bytesRead',
24
+ 'failureCodes',
25
+ ]);
26
+ const VALID_HARNESS_IDS = new Set([
27
+ 'claude-code',
28
+ 'codex-cli',
29
+ 'opencode',
30
+ 'gemini-cli',
31
+ 'cursor-ide',
32
+ 'cline',
33
+ 'roo-code',
34
+ 'pi-agent',
35
+ 'aider',
36
+ ]);
37
+ const VALID_CAPABILITY_STATUS = new Set(['present', 'partial', 'absent']);
38
+ const VALID_SNAPSHOT_METHODS = new Set([
39
+ 'stream-readonly',
40
+ 'sqlite-quiescent-copy',
41
+ 'sqlite-wal-pair-copy',
42
+ ]);
43
+ export function isPlainObject(value) {
44
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
45
+ return false;
46
+ }
47
+ const proto = Object.getPrototypeOf(value);
48
+ return proto === Object.prototype || proto === null;
49
+ }
50
+ export function assertNoPollutedKeys(value, depth = 0) {
51
+ if (depth > 32) {
52
+ throw new Error('VALIDATION_MAX_DEPTH_EXCEEDED');
53
+ }
54
+ if (Array.isArray(value)) {
55
+ for (let i = 0; i < value.length; i++) {
56
+ assertNoPollutedKeys(value[i], depth + 1);
57
+ }
58
+ return;
59
+ }
60
+ if (typeof value === 'object' && value !== null) {
61
+ for (const key of Object.keys(value)) {
62
+ if (FORBIDDEN_KEYS.has(key)) {
63
+ throw new Error(`VALIDATION_FORBIDDEN_KEY:${key}`);
64
+ }
65
+ assertNoPollutedKeys(value[key], depth + 1);
66
+ }
67
+ }
68
+ }
69
+ export function sanitizeShortLabel(raw, fallback, maxLen = 24) {
70
+ if (typeof raw !== 'string')
71
+ return fallback;
72
+ // Strip control chars, bidi overrides, path separators, angle brackets
73
+ const cleaned = raw
74
+ .replace(/[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, '')
75
+ .replace(/[\\/<>"'`]/g, '')
76
+ .trim()
77
+ .slice(0, maxLen);
78
+ return cleaned.length > 0 ? cleaned : fallback;
79
+ }
80
+ export function isFiniteNonNeg(v) {
81
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0;
82
+ }
83
+ export function isHarnessId(v) {
84
+ return typeof v === 'string' && VALID_HARNESS_IDS.has(v);
85
+ }
86
+ export function validateCapabilityMatrix(raw) {
87
+ if (!isPlainObject(raw)) {
88
+ throw new Error('INVALID_CAPABILITY_MATRIX');
89
+ }
90
+ const keys = [
91
+ 'humanPromptTimestamps',
92
+ 'agentRequestTimestamps',
93
+ 'tokenBreakdown',
94
+ 'cacheTokens',
95
+ 'reasoningTokens',
96
+ 'modelIds',
97
+ 'toolNames',
98
+ 'toolErrors',
99
+ 'subagentSpawns',
100
+ 'compactions',
101
+ 'interrupts',
102
+ ];
103
+ const out = {};
104
+ for (const k of keys) {
105
+ const val = Object.hasOwn(raw, k) ? raw[k] : undefined;
106
+ if (typeof val !== 'string' || !VALID_CAPABILITY_STATUS.has(val)) {
107
+ throw new Error(`INVALID_CAPABILITY_${k}`);
108
+ }
109
+ out[k] = val;
110
+ }
111
+ return out;
112
+ }
113
+ export function validateDiscoveryCandidate(raw) {
114
+ if (!isPlainObject(raw))
115
+ throw new Error('INVALID_DISCOVERY_CANDIDATE');
116
+ const candidateId = raw['candidateId'];
117
+ const harness = raw['harness'];
118
+ const displayName = raw['displayName'];
119
+ const tier = raw['tier'];
120
+ const channelLabel = raw['channelLabel'];
121
+ const fileCount = raw['fileCount'];
122
+ const totalBytes = raw['totalBytes'];
123
+ const earliestMtimeMs = raw['earliestMtimeMs'];
124
+ const latestMtimeMs = raw['latestMtimeMs'];
125
+ const snapshotMethod = raw['snapshotMethod'];
126
+ const notes = raw['notes'];
127
+ const hasCredentialRiskWarning = raw['hasCredentialRiskWarning'];
128
+ if (typeof candidateId !== 'string' || !/^rec_[a-zA-Z0-9_-]{1,32}$/.test(candidateId)) {
129
+ throw new Error('INVALID_CANDIDATE_ID');
130
+ }
131
+ if (!isHarnessId(harness))
132
+ throw new Error('INVALID_CANDIDATE_HARNESS');
133
+ if (typeof displayName !== 'string' || displayName.length === 0 || displayName.length > 64) {
134
+ throw new Error('INVALID_CANDIDATE_DISPLAY_NAME');
135
+ }
136
+ if (tier !== 1 && tier !== 2)
137
+ throw new Error('INVALID_CANDIDATE_TIER');
138
+ if (typeof channelLabel !== 'string' || !/^CH\d{1,2}$/.test(channelLabel)) {
139
+ throw new Error('INVALID_CANDIDATE_CHANNEL');
140
+ }
141
+ if (!isFiniteNonNeg(fileCount))
142
+ throw new Error('INVALID_CANDIDATE_FILE_COUNT');
143
+ if (!isFiniteNonNeg(totalBytes))
144
+ throw new Error('INVALID_CANDIDATE_BYTES');
145
+ if (earliestMtimeMs !== null && !isFiniteNonNeg(earliestMtimeMs)) {
146
+ throw new Error('INVALID_CANDIDATE_EARLIEST_MTIME');
147
+ }
148
+ if (latestMtimeMs !== null && !isFiniteNonNeg(latestMtimeMs)) {
149
+ throw new Error('INVALID_CANDIDATE_LATEST_MTIME');
150
+ }
151
+ if (typeof snapshotMethod !== 'string' || !VALID_SNAPSHOT_METHODS.has(snapshotMethod)) {
152
+ throw new Error('INVALID_SNAPSHOT_METHOD');
153
+ }
154
+ if (!Array.isArray(notes) || !notes.every((n) => typeof n === 'string' && n.length <= 200)) {
155
+ throw new Error('INVALID_CANDIDATE_NOTES');
156
+ }
157
+ if (typeof hasCredentialRiskWarning !== 'boolean') {
158
+ throw new Error('INVALID_CREDENTIAL_WARNING_FLAG');
159
+ }
160
+ return {
161
+ candidateId,
162
+ harness,
163
+ displayName,
164
+ tier,
165
+ channelLabel,
166
+ fileCount,
167
+ totalBytes,
168
+ earliestMtimeMs,
169
+ latestMtimeMs,
170
+ snapshotMethod: snapshotMethod,
171
+ notes: notes.slice(0, 8),
172
+ hasCredentialRiskWarning,
173
+ };
174
+ }
175
+ export function validateDiscoveryPlan(raw) {
176
+ assertNoPollutedKeys(raw);
177
+ if (!isPlainObject(raw))
178
+ throw new Error('INVALID_DISCOVERY_PLAN');
179
+ const planId = raw['planId'];
180
+ const generatedAtIso = raw['generatedAtIso'];
181
+ const year = raw['year'];
182
+ const timezone = raw['timezone'];
183
+ const candidates = raw['candidates'];
184
+ const neverReadManifest = raw['neverReadManifest'];
185
+ if (typeof planId !== 'string' || !/^plan_[a-zA-Z0-9_-]{8,64}$/.test(planId)) {
186
+ throw new Error('INVALID_PLAN_ID');
187
+ }
188
+ if (typeof generatedAtIso !== 'string' || Number.isNaN(Date.parse(generatedAtIso))) {
189
+ throw new Error('INVALID_PLAN_TIMESTAMP');
190
+ }
191
+ if (typeof year !== 'number' || !Number.isInteger(year) || year < 2020 || year > 2035) {
192
+ throw new Error('INVALID_PLAN_YEAR');
193
+ }
194
+ if (typeof timezone !== 'string' || timezone.length === 0 || timezone.length > 80) {
195
+ throw new Error('INVALID_PLAN_TIMEZONE');
196
+ }
197
+ if (!Array.isArray(candidates) || candidates.length > 64) {
198
+ throw new Error('INVALID_PLAN_CANDIDATES');
199
+ }
200
+ if (!Array.isArray(neverReadManifest) ||
201
+ !neverReadManifest.every((item) => typeof item === 'string' && item.length <= 120)) {
202
+ throw new Error('INVALID_NEVER_READ_MANIFEST');
203
+ }
204
+ return {
205
+ planId,
206
+ generatedAtIso,
207
+ year,
208
+ timezone,
209
+ candidates: candidates.map(validateDiscoveryCandidate),
210
+ neverReadManifest: neverReadManifest.slice(0, 24),
211
+ };
212
+ }
213
+ export function validateApiScanRequest(raw, expectedPlanId, allowedCandidateIds) {
214
+ assertNoPollutedKeys(raw);
215
+ if (!isPlainObject(raw))
216
+ throw new Error('INVALID_SCAN_REQUEST');
217
+ const planId = raw['planId'];
218
+ const candidateIds = raw['candidateIds'];
219
+ const investigatorInitials = raw['investigatorInitials'];
220
+ if (planId !== expectedPlanId) {
221
+ throw new Error('PLAN_ID_MISMATCH');
222
+ }
223
+ if (!Array.isArray(candidateIds) || candidateIds.length > 64) {
224
+ throw new Error('INVALID_CANDIDATE_IDS');
225
+ }
226
+ const uniqueIds = [];
227
+ const seen = new Set();
228
+ for (const id of candidateIds) {
229
+ if (typeof id !== 'string' || !allowedCandidateIds.has(id)) {
230
+ throw new Error('UNAPPROVED_CANDIDATE_ID');
231
+ }
232
+ if (!seen.has(id)) {
233
+ seen.add(id);
234
+ uniqueIds.push(id);
235
+ }
236
+ }
237
+ // the one-click word-count choice: required, strictly boolean, never defaulted (a missing or odd value is a 400,
238
+ // never a silent "yes" or "no")
239
+ const countWords = raw['countWords'];
240
+ if (typeof countWords !== 'boolean') {
241
+ throw new Error('INVALID_COUNT_WORDS');
242
+ }
243
+ const out = { planId, candidateIds: uniqueIds, countWords };
244
+ if (typeof investigatorInitials === 'string' && investigatorInitials.trim().length > 0) {
245
+ out.investigatorInitials = sanitizeShortLabel(investigatorInitials, 'the crew', 24);
246
+ }
247
+ return out;
248
+ }
249
+ export function assertNoForbiddenPathKeys(value, depth = 0) {
250
+ if (depth > 32) {
251
+ throw new Error('VALIDATION_MAX_DEPTH_EXCEEDED');
252
+ }
253
+ if (Array.isArray(value)) {
254
+ for (let i = 0; i < value.length; i++) {
255
+ assertNoForbiddenPathKeys(value[i], depth + 1);
256
+ }
257
+ return;
258
+ }
259
+ if (typeof value === 'object' && value !== null) {
260
+ for (const key of Object.keys(value)) {
261
+ if (FORBIDDEN_PATH_KEYS.has(key)) {
262
+ throw new Error(`PRIVACY_VIOLATION_FORBIDDEN_KEY:${key}`);
263
+ }
264
+ assertNoForbiddenPathKeys(value[key], depth + 1);
265
+ }
266
+ }
267
+ }
268
+ /**
269
+ * Validates structural invariants of a WrappedReport crossing Zone 1 -> Zone 2 IPC.
270
+ * Rejects polluted keys, unexpected schema versions, non-zero external egress claims,
271
+ * and raw local filesystem paths anywhere in the report or receipt rows.
272
+ */
273
+ export function validateWrappedReport(raw) {
274
+ assertNoPollutedKeys(raw);
275
+ assertNoForbiddenPathKeys(raw);
276
+ if (!isPlainObject(raw))
277
+ throw new Error('INVALID_REPORT_OBJECT');
278
+ if (raw['schemaVersion'] !== '1.1.0')
279
+ throw new Error('UNSUPPORTED_REPORT_SCHEMA_VERSION');
280
+ if (typeof raw['registration'] !== 'string' || !/^N-[A-Z0-9]{4,8}$/.test(raw['registration'])) {
281
+ throw new Error('INVALID_REGISTRATION');
282
+ }
283
+ if (typeof raw['docketNumber'] !== 'string' || !/^CR-\d{4}-[A-Z0-9]{4,8}$/.test(raw['docketNumber'])) {
284
+ throw new Error('INVALID_DOCKET_NUMBER');
285
+ }
286
+ if (typeof raw['year'] !== 'number' || !Number.isInteger(raw['year'])) {
287
+ throw new Error('INVALID_REPORT_YEAR');
288
+ }
289
+ if (typeof raw['timezone'] !== 'string' || raw['timezone'].length === 0) {
290
+ throw new Error('INVALID_REPORT_TIMEZONE');
291
+ }
292
+ validateCapabilityMatrix(raw['capabilities']);
293
+ const receipt = raw['receipt'];
294
+ if (!isPlainObject(receipt))
295
+ throw new Error('INVALID_RECEIPT');
296
+ if (Object.hasOwn(receipt, 'contentNote') && (receipt['contentNote'] !== 'CONTENT_ANALYSIS_UNAVAILABLE' || Object.hasOwn(raw, 'content'))) {
297
+ throw new Error('INVALID_CONTENT_NOTE');
298
+ }
299
+ if (Object.hasOwn(raw, 'content')) {
300
+ const content = validateContentChapter(raw['content']);
301
+ if (Object.hasOwn(receipt, 'content'))
302
+ validateContentReceipt(receipt['content'], content);
303
+ }
304
+ else if (Object.hasOwn(receipt, 'content')) {
305
+ throw new Error('UNEXPECTED_CONTENT_RECEIPT');
306
+ }
307
+ if (receipt['externalBytesSent'] !== 0)
308
+ throw new Error('NONZERO_EXTERNAL_BYTES');
309
+ const sources = receipt['sources'];
310
+ if (!Array.isArray(sources))
311
+ throw new Error('INVALID_RECEIPT_SOURCES');
312
+ for (const src of sources) {
313
+ if (!isPlainObject(src))
314
+ throw new Error('INVALID_RECEIPT_SOURCE_ROW');
315
+ for (const key of Object.keys(src)) {
316
+ if (FORBIDDEN_PATH_KEYS.has(key) || key === 'path') {
317
+ throw new Error('PRIVACY_VIOLATION_RAW_PATH_IN_RECEIPT');
318
+ }
319
+ if (!ALLOWED_RECEIPT_SOURCE_KEYS.has(key)) {
320
+ throw new Error(`INVALID_RECEIPT_SOURCE_KEY:${key}`);
321
+ }
322
+ }
323
+ if (typeof src['candidateId'] !== 'string' || !/^rec_[a-zA-Z0-9_-]{1,32}$/.test(src['candidateId'])) {
324
+ throw new Error('INVALID_RECEIPT_CANDIDATE_ID');
325
+ }
326
+ }
327
+ const totals = raw['totals'];
328
+ if (!isPlainObject(totals))
329
+ throw new Error('INVALID_TOTALS');
330
+ if (!isFiniteNonNeg(totals['sessions']) || !isFiniteNonNeg(totals['humanPrompts'])) {
331
+ throw new Error('INVALID_TOTAL_COUNTS');
332
+ }
333
+ return raw;
334
+ }
@@ -0,0 +1 @@
1
+ @font-face{font-family:Archivo;src:url(/assets/Archivo-VF-BohoA-Sn.woff2)format("woff2");font-weight:100 900;font-stretch:62% 125%;font-display:block}@font-face{font-family:Martian;src:url(/assets/MartianMono-VF-CmJ1nXx9.woff2)format("woff2");font-weight:100 800;font-stretch:75% 112.5%;font-display:block}@font-face{font-family:Dela;src:url(/assets/DelaGothicOne-subset-CpoJGhTq.woff2)format("woff2");font-display:block}.film{--fg:#16161a;--bg:#f4f1ea;--chrome-h:76px;position:fixed;inset:0}.film .chrome{z-index:3;padding:max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));color:var(--fg);pointer-events:none;position:absolute;top:0;left:0;right:0}.film .bars{gap:5px;height:4px;display:flex}.film .bar{opacity:1;background:currentColor;border-radius:2px;flex:1;height:100%;position:relative;overflow:hidden}.film .bar:before{content:"";background:var(--bg);opacity:.72;position:absolute;inset:0}.film .bar__fill{transform-origin:0;background:currentColor;position:absolute;inset:0;transform:scaleX(0)}.film .bar[data-state=done] .bar__fill{transform:scaleX(1)}.film .bar[data-state=wait] .bar__fill{animation:1s steps(2,jump-none) infinite film-wait}@keyframes film-wait{0%{opacity:1}to{opacity:.45}}.film .chrome__row{justify-content:space-between;align-items:center;margin-top:10px;display:flex}.film .f-brand{letter-spacing:.02em;font-family:Archivo;font-size:22px;font-weight:900;font-stretch:125%;line-height:1}.film .f-brand b{margin-left:.4em;font-weight:800;font-stretch:100%}.film .chrome__ctl{pointer-events:auto;gap:8px;display:flex}.film .f-icon-btn{width:44px;height:44px;color:inherit;cursor:pointer;background:0 0;border:2px solid;border-radius:999px;place-items:center;padding:0;display:grid}.film .ic{width:16px;height:16px;display:block;position:relative}.film .ic--pause:before,.film .ic--pause:after{content:"";background:currentColor;width:5px;position:absolute;top:1px;bottom:1px}.film .ic--pause:before{left:2px}.film .ic--pause:after{right:2px}.film .ic--play:before{content:"";border:7px solid #0000;border-left:12px solid;border-right-width:0;position:absolute;top:1px;left:3px}.film .ic--sound:before{content:"";background:currentColor;width:5px;height:6px;position:absolute;top:5px;left:0}.film .ic--sound:after{content:"";border:7px solid #0000;border-left-width:0;border-right:8px solid;position:absolute;top:1px;left:3px}.film .ic--mute:before{content:"";background:currentColor;width:5px;height:6px;position:absolute;top:5px;left:0}.film .ic--mute:after{content:"";opacity:.35;border:7px solid #0000;border-left-width:0;border-right:8px solid;position:absolute;top:1px;left:3px}.film .f-icon-btn[aria-pressed=false] .ic--sound{opacity:.4}.film .ic--left:before,.film .ic--right:before{content:"";border:0 solid;border-width:0 0 3px 3px;position:absolute;inset:3px;transform:rotate(45deg)}.film .ic--right:before{transform:rotate(-135deg)}.film .stage{left:0;right:0;top:var(--chrome-h);touch-action:manipulation;-webkit-user-select:none;user-select:none;position:absolute;bottom:0;overflow:hidden}.film #frame{transform-origin:0 0;position:absolute;top:0;left:0;overflow:hidden}.film #frame svg{display:block;position:absolute;top:0;left:0}.film .f-grain{pointer-events:none;mix-blend-mode:overlay;opacity:.6;background-size:256px 256px;position:absolute;inset:0}.film .guesses[hidden],.film .paused-badge[hidden],.film .start[hidden],.film .f-error[hidden]{display:none}.film .guess{cursor:pointer;color:#0000;background:0 0;border:0;border-radius:14px;margin:0;padding:0;font-size:1px;position:absolute}.film .guess:hover{background:#f4f1ea0f}.film .guess:disabled{display:none}.film .actions{flex-wrap:wrap;align-items:center;gap:12px;display:flex;position:absolute;top:0;left:0}.film .act{color:#f4f1ea;cursor:pointer;background:0 0;border:2px solid #f4f1ea;border-radius:999px;min-height:48px;padding:10px 24px;font-family:Archivo;font-size:18px;font-weight:800}.film .act--primary{color:#16161a;background:#ff48b0;border-color:#ff48b0}.film .act:hover{color:#0b0c1c;background:#f4f1ea}.film .tapfx{opacity:0;pointer-events:none;border:3px solid #f4f1ea;border-radius:50%;width:64px;height:64px;margin:-32px 0 0 -32px;position:absolute;top:0;left:0;box-shadow:0 0 0 3px #16161a99}.film .paused-badge{color:#f4f1ea;pointer-events:none;background:#16161ad1;border-radius:999px;padding:6px 14px;font-family:Martian;font-size:14px;font-weight:700;position:absolute;top:14px;left:50%;transform:translate(-50%)}.film .edge{z-index:3;color:#f4f1ea;cursor:pointer;opacity:0;background:#16161a8c;border:0;border-radius:999px;place-items:center;width:44px;height:44px;margin-top:-22px;transition:opacity .2s;display:none;position:absolute;top:50%}.film .edge--prev{left:10px}.film .edge--next{right:10px}@media (hover:hover) and (pointer:fine){.film .edge{display:grid}.film #app:hover .edge{opacity:.55}.film .edge:hover{opacity:1}}.film .edge:focus-visible{opacity:1}.film .edge:disabled{visibility:hidden}.film button:focus-visible{outline-offset:3px;outline:3px solid #ffe800;box-shadow:0 0 0 6px #16161a}.film .guess:focus-visible{outline-offset:6px}.film #slide-title:focus{outline:none}.film .start{z-index:5;color:#f4f1ea;text-align:center;background:#16161a;flex-direction:column;justify-content:center;align-items:center;gap:28px;padding:24px;display:flex;position:fixed;inset:0}.film .start h1{letter-spacing:-.02em;margin:0;font-family:Archivo;font-size:clamp(32px,7vw,84px);font-weight:900;font-stretch:125%;line-height:1}.film .start .cur{vertical-align:-.08em;background:#ff48b0;width:.42em;height:.82em;margin-left:.12em;display:inline-block}.film .start-actions{flex-wrap:wrap;justify-content:center;gap:12px;display:flex}.film .start button{color:#f4f1ea;cursor:pointer;background:0 0;border:2px solid #f4f1ea;border-radius:999px;min-width:44px;min-height:44px;padding:10px 20px;font-family:Archivo;font-size:18px;font-weight:800}.film .start button.primary{color:#16161a;background:#ff48b0;border-color:#ff48b0}.film .start button[aria-busy=true]{opacity:.6}.film .start .hint{opacity:.75;max-width:36em;margin:0;font-family:Martian;font-size:15px}.film .f-error{z-index:6;text-align:center;color:#16161a;font-family:Archivo;font-size:20px;font-weight:800;position:fixed;inset:auto 0 40%}.film .sr-only{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}svg.measure{visibility:hidden;position:absolute;top:0;left:-9999px}.film .ax,svg.measure .ax{font-family:Archivo;font-weight:900;font-stretch:125%}.film .ax112,svg.measure .ax112{font-family:Archivo;font-weight:900;font-stretch:112.5%}.film .ab,svg.measure .ab{font-family:Archivo;font-weight:800;font-stretch:100%}.film .am,svg.measure .am{font-family:Archivo;font-weight:700;font-stretch:100%}.film .mono,svg.measure .mono{font-family:Martian;font-weight:500}.film .monob,svg.measure .monob{font-family:Martian;font-weight:700}.film .dela,svg.measure .dela{font-family:Dela}@media (width<=600px){.film .f-brand{font-size:14px}.film .bars{gap:3px;height:3px}.film .chrome__row{margin-top:8px}}@media (prefers-reduced-motion:reduce){.film .edge{transition:none}.film .bar[data-state=wait] .bar__fill{animation:none}}.film.capture .start{display:none}.film .start{justify-content:flex-start;padding-top:max(40px,8vh);overflow-y:auto}.film .seal{box-sizing:border-box;text-align:left;border:2px solid #f4f1ea59;border-radius:18px;width:100%;max-width:40em;padding:16px 20px;font-family:Archivo}.film .seal[hidden]{display:none}.film .seal__row{cursor:pointer;align-items:center;gap:12px;display:flex}.film .seal__row input{accent-color:#ff48b0;flex:none;width:24px;height:24px}.film .seal__title{font-size:20px;font-weight:800}.film .seal__detail{opacity:.85;margin:8px 0 0;font-size:16px}.film .seal__detail--small{opacity:.7;font-size:14px}.film .seal__list{opacity:.9;margin:8px 0 0;padding-left:1.1em;font-size:15px;line-height:1.45}.film .seal__actions{flex-wrap:wrap;align-items:center;gap:14px;margin-top:12px;display:flex}.film .seal__row--small{font-size:15px;font-weight:700}.film .seal__btn{min-height:44px!important;padding:8px 16px!important;font-size:16px!important}.film .seal__status{margin:10px 0 0;font-family:Martian;font-size:14px;font-weight:700}.film .seal__sample{flex-wrap:wrap;gap:8px;margin-top:10px;display:flex}.film .seal__sample[hidden]{display:none}.film .seal__chip{color:#16161a;background:#ffe800;border-radius:999px;padding:6px 12px;font-family:Martian;font-size:14px;font-weight:700}.film input:focus-visible{outline-offset:3px;outline:3px solid #ffe800}.film .drawer{box-sizing:border-box;color:#16161a;background:#f4f1ea;border-radius:22px;width:min(880px,100% - 32px);max-height:78%;padding:24px 28px;font-family:Archivo;position:absolute;top:4%;left:50%;overflow-y:auto;transform:translate(-50%);box-shadow:10px 10px #ff48b0}.film .drawer[hidden]{display:none}.film .drawer__title{letter-spacing:-.02em;margin:0;font-size:40px;font-weight:900;font-stretch:125%}.film .drawer__intro{margin:8px 0 0;font-size:22px;font-weight:700;line-height:1.3}.film .drawer__chips{grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px;margin:18px 0 0;padding:0;list-style:none;display:grid}.film .chip{color:#f4f1ea;background:#16161a;border-radius:16px;flex-direction:column;justify-content:center;min-height:92px;display:flex}.film .chip__reveal{all:unset;box-sizing:border-box;cursor:pointer;border-radius:16px;flex-direction:column;gap:8px;width:100%;min-height:92px;padding:14px 16px;display:flex}.film .chip__reveal:focus-visible{outline-offset:3px;outline:3px solid #ffe800}.film .chip__blur{filter:blur(5px);background:repeating-linear-gradient(90deg,#f4f1ea8c 0 22px,#f4f1ea40 22px 30px);border-radius:8px;width:80%;height:26px;display:block}.film .chip__meta{opacity:.85;font-family:Martian;font-size:15px;font-weight:700}.film .chip--open{gap:6px;padding:14px 16px}.film .chip--kept{color:#16161a;background:#ff48b0}.film .chip__term{overflow-wrap:anywhere;font-size:24px;font-weight:900;font-stretch:112.5%}.film .chip__state{font-size:16px;font-weight:800}.film .chip__btns{gap:8px;margin-top:4px;display:flex}.film .chip__btns button,.film .drawer__actions button,.film .ws__close{min-height:44px;color:inherit;cursor:pointer;background:0 0;border:2px solid;border-radius:999px;padding:8px 18px;font-family:Archivo;font-size:17px;font-weight:800}.film .chip__hide{color:#16161a!important;background:#ffe800!important;border-color:#ffe800!important}.film .drawer__actions{flex-wrap:wrap;gap:12px;margin-top:18px;display:flex}.film .drawer__done{color:#f4f1ea!important;background:#16161a!important;border-color:#16161a!important}.film .drawer__footer{opacity:.75;margin:14px 0 0;font-family:Martian;font-size:14px;font-weight:500}@media (width<=600px){.film .drawer{max-height:84%;padding:16px;top:2%}.film .drawer__title{font-size:28px}.film .drawer__intro{font-size:16px}.film .drawer__chips{grid-template-columns:1fr 1fr;gap:8px}.film .chip,.film .chip__reveal{min-height:76px}.film .chip__reveal{padding:10px 12px}.film .chip__blur{height:20px}.film .chip__meta{font-size:14px}.film .chip__term{font-size:18px}.film .chip__btns button{padding:6px 12px;font-size:15px}}.film .act[hidden]{display:none}.film .wordstats{box-sizing:border-box;color:#16161a;overscroll-behavior:contain;touch-action:pan-y;scrollbar-gutter:stable;background:#f4f1ea;border-radius:18px;width:min(420px,100% - 32px);max-height:calc(100% - 100px);padding:16px 18px;font-family:Archivo;position:absolute;bottom:84px;right:16px;overflow-y:auto;box-shadow:8px 8px #ffe800}.film .wordstats[hidden]{display:none}.film .ws__title{margin:0 0 8px;font-size:20px;font-weight:900}.film .ws__list{gap:6px;margin:0;padding:0;list-style:none;display:grid}.film .ws__list label,.film .ws__swear{cursor:pointer;align-items:center;gap:10px;min-height:36px;font-size:16px;font-weight:700;display:flex}.film .ws__list b{margin-left:auto;font-family:Martian;font-size:15px}.film .ws__list input,.film .ws__swear input{accent-color:#ff48b0;width:22px;height:22px}.film .ws__swear{border-top:2px solid #16161a26;margin-top:10px;padding-top:10px}.film .ws__close{margin-top:12px}.film .ws__caption{margin:10px 0 0;font-size:15px;font-weight:600;line-height:1.35}.film{z-index:1;background:var(--bg);color:var(--fg);overscroll-behavior:none;-webkit-tap-highlight-color:transparent;overflow:hidden}.film,.film *,.film :before,.film :after{box-sizing:content-box}.film .seal,.film .drawer,.film .wordstats,.film .chip__reveal{box-sizing:border-box}.film .seal__list{list-style:outside}.film .drawer__chips,.film .ws__list{list-style:none}.film h1,.film h2,.film p{font-family:inherit}.film .f-pill{height:44px;color:inherit;cursor:pointer;background:0 0;border:2px solid;border-radius:999px;align-items:center;padding:0 16px;font-family:Archivo;font-size:15px;font-weight:800;display:inline-flex}.film .f-pill[hidden]{display:none}@media (width<=600px){.film .f-pill{padding:0 12px;font-size:13px}}