agentgui 1.0.973 → 1.0.975
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/AGENTS.md +14 -6
- package/lib/http-handler.js +27 -17
- package/package.json +1 -1
- package/scripts/validate-mutations.mjs +3 -0
- package/site/app/js/app.js +28 -15
- package/site/app/vendor/anentrypoint-design/247420.css +70 -26
- package/site/app/vendor/anentrypoint-design/247420.js +11 -11
- package/site/theme.mjs +2 -2
- package/test.js +0 -89
- package/scripts/harvest-fixtures.mjs +0 -219
- package/site/app/vendor/cdn/dompurify.js +0 -9
- package/site/app/vendor/cdn/fonts/1291de6d401a.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/1ba89a87e0b8.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/3644d51c507b.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/4b91d2650dc2.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/530d036ba64a.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/570a2bdd8f8b.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/5dd6d880fee9.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/62de9143afe3.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/64884efa2f11.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/68cd7063be2e.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/6c252abcf99b.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/71e69e06516a.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/9ea68c62083f.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/c010f9b7d6b2.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/d69723fc74be.woff2 +0 -0
- package/site/app/vendor/cdn/fonts/fonts.css +0 -459
- package/site/app/vendor/cdn/marked.js +0 -8
- package/site/app/vendor/cdn/prismjs/components/prism-bash.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-clike.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-core.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-css.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-diff.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-go.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-javascript.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-json.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-jsx.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-markdown.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-markup.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-python.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-rust.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-sql.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-toml.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-tsx.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-typescript.min.js +0 -1
- package/site/app/vendor/cdn/prismjs/components/prism-yaml.min.js +0 -1
package/site/theme.mjs
CHANGED
|
@@ -80,7 +80,7 @@ function Quickstart() {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function Footer() {
|
|
83
|
-
return h('footer', { class: '
|
|
83
|
+
return h('footer', { class: 'site-footer' },
|
|
84
84
|
h('span', { class: 'item' }, 'styled with '),
|
|
85
85
|
h('a', { class: 'item', href: 'https://anentrypoint.github.io/design/' }, 'anentrypoint-design'),
|
|
86
86
|
h('span', { class: 'item' }, '·'),
|
|
@@ -110,7 +110,7 @@ const { site, nav, page } = data;
|
|
|
110
110
|
const navItems = (nav && nav.links ? nav.links : []).map(l => [String(l.label || ''), l.href]);
|
|
111
111
|
|
|
112
112
|
function Footer() {
|
|
113
|
-
return h('footer', { class: '
|
|
113
|
+
return h('footer', { class: 'site-footer' },
|
|
114
114
|
h('span', { class: 'item' }, 'styled with '),
|
|
115
115
|
h('a', { class: 'item', href: 'https://anentrypoint.github.io/design/' }, 'anentrypoint-design'),
|
|
116
116
|
h('span', { class: 'item' }, '·'),
|
package/test.js
CHANGED
|
@@ -13,15 +13,6 @@ import { initializeDescriptors, getAgentDescriptor } from './lib/agent-descripto
|
|
|
13
13
|
import { createACPProtocolHandler } from './lib/acp-protocol.js';
|
|
14
14
|
import { sendJSON, compressAndSend, acceptsEncoding } from './lib/http-utils.js';
|
|
15
15
|
const require = createRequire(import.meta.url);
|
|
16
|
-
// lib/jsonl-parser.js was also removed in the pivot (ccsniff owns JSONL parsing
|
|
17
|
-
// now). Load it dynamically so its test skips rather than crashing the suite.
|
|
18
|
-
let JsonlParser = null;
|
|
19
|
-
try { ({ JsonlParser } = await import('./lib/jsonl-parser.js')); } catch { JsonlParser = null; }
|
|
20
|
-
// lib/db-queries.js was removed in the 2026-05-19 single-surface pivot (history
|
|
21
|
-
// now flows through ccsniff, not the local query layer). Import it dynamically
|
|
22
|
-
// so its absence skips only the db-queries tests instead of crashing the suite.
|
|
23
|
-
let createQueries = null;
|
|
24
|
-
try { ({ createQueries } = await import('./lib/db-queries.js')); } catch { createQueries = null; }
|
|
25
16
|
let Database, dbAvailable = false;
|
|
26
17
|
try {
|
|
27
18
|
try { Database = (await import('bun:sqlite')).default; }
|
|
@@ -33,10 +24,6 @@ let passed = 0, failed = 0, skipped = 0;
|
|
|
33
24
|
const ok = (name, fn) => Promise.resolve().then(fn).then(
|
|
34
25
|
() => { console.log(`ok - ${name}`); passed++; },
|
|
35
26
|
(err) => { console.error(`FAIL - ${name}: ${err.message}`); failed++; });
|
|
36
|
-
// Skip a test when sqlite is unavailable OR when it needs the removed db-queries layer.
|
|
37
|
-
const okDb = (name, fn) => (dbAvailable && createQueries)
|
|
38
|
-
? ok(name, fn)
|
|
39
|
-
: (console.log(`skip (${dbAvailable ? 'no db-queries' : 'no sqlite'}) - ${name}`), skipped++, Promise.resolve());
|
|
40
27
|
function inMemDb() {
|
|
41
28
|
const db = new Database(':memory:');
|
|
42
29
|
if (db.pragma) db.pragma('foreign_keys = ON'); else db.run('PRAGMA foreign_keys = ON');
|
|
@@ -66,32 +53,6 @@ await ok('codec: json roundtrip + wire-byte decode', () => {
|
|
|
66
53
|
await (dbAvailable ? ok : (n) => (console.log(`skip (no sqlite) - ${n}`), skipped++, Promise.resolve()))('db: init schema creates conversations table', () => {
|
|
67
54
|
assert.ok(inMemDb().db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='conversations'").get());
|
|
68
55
|
});
|
|
69
|
-
await okDb('db-queries: createConversation round-trip', () => {
|
|
70
|
-
const { db, prep, gid } = inMemDb();
|
|
71
|
-
const q = createQueries(db, prep, gid);
|
|
72
|
-
const c = q.createConversation('claude-code', 'Test', '/tmp', 'sonnet', null);
|
|
73
|
-
assert.equal(q.getConversation(c.id).title, 'Test');
|
|
74
|
-
assert.equal(q.getConversation(c.id).status, 'active');
|
|
75
|
-
});
|
|
76
|
-
await okDb('db-queries: archive + restore + streaming flag', () => {
|
|
77
|
-
const { db, prep, gid } = inMemDb();
|
|
78
|
-
const q = createQueries(db, prep, gid);
|
|
79
|
-
const c = q.createConversation('claude-code', 'A');
|
|
80
|
-
q.archiveConversation(c.id); assert.equal(q.getConversation(c.id).status, 'archived');
|
|
81
|
-
q.restoreConversation(c.id); assert.equal(q.getConversation(c.id).status, 'active');
|
|
82
|
-
q.setIsStreaming(c.id, true); assert.equal(q.getIsStreaming(c.id), true);
|
|
83
|
-
q.setIsStreaming(c.id, false); assert.equal(q.getIsStreaming(c.id), false);
|
|
84
|
-
});
|
|
85
|
-
await okDb('acp-queries: thread crud + search', () => {
|
|
86
|
-
const { db, prep, gid } = inMemDb();
|
|
87
|
-
const q = createQueries(db, prep, gid);
|
|
88
|
-
const t = q.createThread({ foo: 'bar' });
|
|
89
|
-
assert.deepEqual(q.getThread(t.thread_id).metadata, { foo: 'bar' });
|
|
90
|
-
q.patchThread(t.thread_id, { metadata: { foo: 'baz' }, status: 'active' });
|
|
91
|
-
assert.deepEqual(q.getThread(t.thread_id).metadata, { foo: 'baz' });
|
|
92
|
-
q.createThread({ kind: 'b' });
|
|
93
|
-
assert.equal(q.searchThreads({}).total, 2);
|
|
94
|
-
});
|
|
95
56
|
await ok('WsRouter: dispatch + 404 + error + legacy', async () => {
|
|
96
57
|
const router = new WsRouter();
|
|
97
58
|
router.handle('ping', async (p) => ({ pong: p.n }));
|
|
@@ -122,18 +83,6 @@ await ok('workflow-plugin + agent-registry hermes', async () => {
|
|
|
122
83
|
const h = registry.get('hermes');
|
|
123
84
|
assert.equal(h.protocol, 'acp'); assert.deepEqual(h.buildArgs(), ['acp']);
|
|
124
85
|
});
|
|
125
|
-
await okDb('delete-all: soft-deletes + wipes related', () => {
|
|
126
|
-
const { db, prep, gid } = inMemDb();
|
|
127
|
-
const q = createQueries(db, prep, gid);
|
|
128
|
-
const c1 = q.createConversation('claude-code', 'A');
|
|
129
|
-
q.createConversation('claude-code', 'B');
|
|
130
|
-
q.createSession(c1.id); q.createMessage(c1.id, 'user', 'hello');
|
|
131
|
-
const oL = console.log; console.log = () => {};
|
|
132
|
-
try { q.deleteAllConversations(); } finally { console.log = oL; }
|
|
133
|
-
assert.deepEqual(db.prepare('SELECT status, count(*) as c FROM conversations GROUP BY status').all(), [{ status: 'deleted', c: 2 }]);
|
|
134
|
-
assert.equal(db.prepare('SELECT count(*) as c FROM messages').get().c, 0);
|
|
135
|
-
assert.equal(q.getConversationsList().length, 0);
|
|
136
|
-
});
|
|
137
86
|
await ok('provider-config: maskKey + buildSystemPrompt', () => {
|
|
138
87
|
assert.equal(maskKey(''), '****'); assert.equal(maskKey('short'), '****'); assert.equal(maskKey('sk-abcd1234efgh'), '****efgh');
|
|
139
88
|
assert.equal(buildSystemPrompt('claude-code'), '');
|
|
@@ -173,44 +122,6 @@ await ok('http-utils: sendJSON + compressAndSend size threshold', () => {
|
|
|
173
122
|
const big = mockRes(); compressAndSend(req, big, 200, 'text/plain', 'x'.repeat(2000)); assert.equal(big.headers['Content-Encoding'], 'gzip');
|
|
174
123
|
const ng = mockRes(); compressAndSend({ headers: {} }, ng, 200, 'text/html', 'y'.repeat(2000)); assert.equal(ng.headers['Cache-Control'], 'no-store');
|
|
175
124
|
});
|
|
176
|
-
await (JsonlParser ? ok : (n) => (console.log(`skip (no jsonl-parser) - ${n}`), skipped++, Promise.resolve()))('jsonl-parser: register + remove + clear', () => {
|
|
177
|
-
const p = new JsonlParser({ broadcastSync: () => {}, queries: { getConversationByClaudeSessionId: () => null } });
|
|
178
|
-
p.registerSession('s1', 'c1', 'd1'); assert.equal(p._convMap.get('s1'), 'c1');
|
|
179
|
-
p.removeSid('s1'); assert.equal(p._convMap.has('s1'), false);
|
|
180
|
-
p.registerSession('s2', 'c2', 'd2'); p.clear(); assert.equal(p._convMap.size, 0);
|
|
181
|
-
});
|
|
182
|
-
await okDb('conv-routes+thread-routes+auth-config+util-routes', async () => {
|
|
183
|
-
const [{ register: rC }, { register: rT }, { register: rA }, { register: rU }] = await Promise.all(['./lib/routes-conversations.js','./lib/routes-threads.js','./lib/routes-auth-config.js','./lib/routes-util.js'].map(m => import(m)));
|
|
184
|
-
const { db: d2, prep: p2, gid: g2 } = inMemDb(); const q2 = createQueries(d2, p2, g2);
|
|
185
|
-
const sj2 = (req, res, c, data) => { res.statusCode = c; res.body = JSON.stringify(data); };
|
|
186
|
-
const pb2 = async (req) => req?._b || {}; const mr = () => mockRes();
|
|
187
|
-
const cR = rC({ sendJSON: sj2, parseBody: pb2, queries: q2, activeExecutions: new Map(), broadcastSync: () => {} });
|
|
188
|
-
const c1 = q2.createConversation('claude-code', 'T');
|
|
189
|
-
const lr = mr(); await cR['GET /api/conversations'](null, lr); assert.equal(lr.statusCode, 200);
|
|
190
|
-
const cr = mr(); await cR['POST /api/conversations']({ _b: { agentId: 'claude-code', title: 'N' } }, cr);
|
|
191
|
-
assert.equal(cr.statusCode, 201); const nid = JSON.parse(cr.body).conversation.id;
|
|
192
|
-
const gr = mr(); await cR._match('GET', `/api/conversations/${nid}`)(null, gr); assert.equal(gr.statusCode, 200);
|
|
193
|
-
const dr = mr(); await cR._match('DELETE', `/api/conversations/${nid}`)(null, dr); assert.equal(dr.statusCode, 200);
|
|
194
|
-
const nr = mr(); await cR._match('GET', '/api/conversations/nope')(null, nr); assert.equal(nr.statusCode, 404);
|
|
195
|
-
const ar = mr(); await cR._match('POST', `/api/conversations/${c1.id}/archive`)(null, ar); assert.equal(ar.statusCode, 200);
|
|
196
|
-
const rr = mr(); await cR._match('POST', `/api/conversations/${c1.id}/restore`)(null, rr); assert.equal(rr.statusCode, 200);
|
|
197
|
-
const tR = rT({ sendJSON: sj2, parseBody: pb2, queries: q2 });
|
|
198
|
-
const tr = mr(); await tR['POST /api/threads']({ _b: { metadata: { k: 1 } } }, tr); assert.equal(tr.statusCode, 201);
|
|
199
|
-
const tid = JSON.parse(tr.body).thread_id;
|
|
200
|
-
const tgr = mr(); await tR._match('GET', `/api/threads/${tid}`)(null, tgr); assert.equal(tgr.statusCode, 200);
|
|
201
|
-
const tpr = mr(); await tR._match('PATCH', `/api/threads/${tid}`)({ _b: { metadata: { k: 2 } } }, tpr); assert.equal(tpr.statusCode, 200);
|
|
202
|
-
const tsr = { statusCode: 0, writeHead: (c) => { tsr.statusCode = c; }, end: () => {} };
|
|
203
|
-
await tR._match('DELETE', `/api/threads/${tid}`)(null, tsr); assert.equal(tsr.statusCode, 204);
|
|
204
|
-
const ssr = mr(); await tR['POST /api/threads/search']({ _b: {} }, ssr); assert.equal(ssr.statusCode, 200);
|
|
205
|
-
const aR = rA({ sendJSON: sj2, parseBody: pb2, getProviderConfigs: () => ({ anthropic: { hasKey: false } }), saveProviderConfig: () => '/x' });
|
|
206
|
-
const agr = mr(); aR['GET /api/auth/configs'](null, agr); assert.equal(agr.statusCode, 200); assert.ok(JSON.parse(agr.body).anthropic !== undefined);
|
|
207
|
-
const br = mr(); await aR['POST /api/auth/save-config']({ _b: { providerId: '', apiKey: 'x' } }, br); assert.equal(br.statusCode, 400);
|
|
208
|
-
const sr = mr(); await aR['POST /api/auth/save-config']({ _b: { providerId: 'anthropic', apiKey: 'sk-123456789' } }, sr); assert.equal(sr.statusCode, 200);
|
|
209
|
-
const uR = rU({ sendJSON: sj2, parseBody: pb2, queries: q2, STARTUP_CWD: process.cwd(), PKG_VERSION: '1.0.0' });
|
|
210
|
-
const hr = mr(); await uR['GET /api/home'](null, hr); assert.equal(hr.statusCode, 200); assert.ok(JSON.parse(hr.body).home);
|
|
211
|
-
const vr = mr(); await uR['GET /api/version'](null, vr); assert.equal(vr.statusCode, 200);
|
|
212
|
-
const fr = mr(); await uR['POST /api/folders']({ _b: { path: process.cwd() } }, fr); assert.equal(fr.statusCode, 200); assert.ok(Array.isArray(JSON.parse(fr.body).folders));
|
|
213
|
-
});
|
|
214
125
|
console.log(`\n${passed} passed, ${failed} failed, ${skipped} skipped`);
|
|
215
126
|
process.exit(failed === 0 ? 0 : 1);
|
|
216
127
|
}; run();
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Build fixtures/demo.sqlite from ~/.claude/projects/*.jsonl.
|
|
3
|
-
// Output is deterministic (seeded timestamps, sorted inserts) so the same source
|
|
4
|
-
// JSONL produces byte-identical DB output.
|
|
5
|
-
//
|
|
6
|
-
// Anonymisation: absolute paths -> /home/demo/..., emails redacted, API-key-looking
|
|
7
|
-
// strings redacted, real session IDs replaced with deterministic uuids per-conv.
|
|
8
|
-
//
|
|
9
|
-
// If ~/.claude/projects is missing or has no usable JSONL, the script still produces
|
|
10
|
-
// a valid DB using six synthesized reference conversations.
|
|
11
|
-
|
|
12
|
-
import fs from 'fs';
|
|
13
|
-
import path from 'path';
|
|
14
|
-
import os from 'os';
|
|
15
|
-
import crypto from 'crypto';
|
|
16
|
-
import { fileURLToPath } from 'url';
|
|
17
|
-
import { createRequire } from 'module';
|
|
18
|
-
import { initSchema } from '../database-schema.js';
|
|
19
|
-
import { migrateFromJson, migrateToACP, migrateConversationColumns } from '../database-migrations.js';
|
|
20
|
-
import { migrateACPSchema, migrateBackfillMessages, migrateFTS, migrateAutoVacuum } from '../database-migrations-acp.js';
|
|
21
|
-
|
|
22
|
-
const require = createRequire(import.meta.url);
|
|
23
|
-
|
|
24
|
-
let Database;
|
|
25
|
-
try {
|
|
26
|
-
Database = (await import('bun:sqlite')).default;
|
|
27
|
-
} catch {
|
|
28
|
-
Database = require('better-sqlite3');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function openDb(path) {
|
|
32
|
-
try {
|
|
33
|
-
const db = new Database(path);
|
|
34
|
-
db.run('PRAGMA journal_mode = WAL');
|
|
35
|
-
db.run('PRAGMA foreign_keys = ON');
|
|
36
|
-
return db;
|
|
37
|
-
} catch {
|
|
38
|
-
const db = new Database(path);
|
|
39
|
-
db.pragma('journal_mode = WAL');
|
|
40
|
-
db.pragma('foreign_keys = ON');
|
|
41
|
-
return db;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
46
|
-
const ROOT = path.resolve(__dirname, '..');
|
|
47
|
-
const OUT_DIR = path.join(ROOT, 'fixtures');
|
|
48
|
-
const OUT_DB = path.join(OUT_DIR, 'data.db');
|
|
49
|
-
const SRC_DIR = path.join(os.homedir(), '.claude', 'projects');
|
|
50
|
-
|
|
51
|
-
// Fixed base timestamp so the DB is reproducible
|
|
52
|
-
const BASE_TS = Date.parse('2026-03-15T10:00:00Z');
|
|
53
|
-
|
|
54
|
-
// Titles we want in the demo sidebar
|
|
55
|
-
const DEMO_TITLES = [
|
|
56
|
-
'Fix failing tests in db-queries',
|
|
57
|
-
'Refactor auth middleware',
|
|
58
|
-
'Add dark mode toggle',
|
|
59
|
-
'Write migration for user schema',
|
|
60
|
-
'Debug WebSocket reconnect loop',
|
|
61
|
-
'Generate API docs from handlers',
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
function det(prefix, ...seeds) {
|
|
65
|
-
const h = crypto.createHash('sha256').update(prefix + '::' + seeds.join('|')).digest('hex');
|
|
66
|
-
return `${prefix}-${h.slice(0, 16)}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Anonymise - returns cleaned text
|
|
70
|
-
function scrub(text) {
|
|
71
|
-
if (typeof text !== 'string') return text;
|
|
72
|
-
return text
|
|
73
|
-
.replace(/\/(?:config|home|root|Users)\/[A-Za-z0-9_\-./]+/g, '/home/demo/workspace')
|
|
74
|
-
.replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, 'dev@example.com')
|
|
75
|
-
.replace(/sk-[A-Za-z0-9]{20,}/g, 'sk-REDACTED')
|
|
76
|
-
.replace(/ghp_[A-Za-z0-9]{20,}/g, 'ghp_REDACTED')
|
|
77
|
-
.replace(/Bearer\s+[A-Za-z0-9._-]{20,}/gi, 'Bearer REDACTED');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Synthesize a realistic assistant reply given a user prompt theme
|
|
81
|
-
function synthAssistant(title) {
|
|
82
|
-
const lookup = {
|
|
83
|
-
'Fix failing tests in db-queries':
|
|
84
|
-
`I'll run the test suite first to see which specs are failing, then trace the errors.\n\n` +
|
|
85
|
-
`After running \`bun test\`, I can see three assertions in \`createConversation\` are failing ` +
|
|
86
|
-
`because the \`agentId\` column was renamed. I'll update the query builder in ` +
|
|
87
|
-
`\`lib/db-queries.js\` to use the new column and patch the associated tests.\n\n` +
|
|
88
|
-
`The fix is a one-line change to the INSERT statement. All 19 tests pass now.`,
|
|
89
|
-
'Refactor auth middleware':
|
|
90
|
-
`The current auth middleware has three responsibilities - rate limiting, basic-auth check, ` +
|
|
91
|
-
`and CORS - packed into a single 80-line function. I'll split them into three small ` +
|
|
92
|
-
`middlewares in \`lib/http-middlewares/\` and compose them in \`http-handler.js\`. ` +
|
|
93
|
-
`No behaviour change, just readability.`,
|
|
94
|
-
'Add dark mode toggle':
|
|
95
|
-
`Dark mode is already wired through CSS custom properties in \`main.css\` (\`:root\` + \`html.dark\`). ` +
|
|
96
|
-
`We just need a toggle button in the header and a listener that flips the class on \`<html>\` ` +
|
|
97
|
-
`and persists the choice in \`localStorage\`. I'll also respect \`prefers-color-scheme\` for the ` +
|
|
98
|
-
`first visit.`,
|
|
99
|
-
'Write migration for user schema':
|
|
100
|
-
`Adding \`last_login_at INTEGER\` and \`preferences JSON\` to the users table. I'll write the ` +
|
|
101
|
-
`migration as \`database-migrations-user.js\`, gate it on a schema-version row, and backfill ` +
|
|
102
|
-
`\`last_login_at\` from the \`sessions\` table's most-recent entry per user. Safe under concurrent writes.`,
|
|
103
|
-
'Debug WebSocket reconnect loop':
|
|
104
|
-
`Found it. The ws-machine transitions to \`reconnecting\` on \`close\`, but the timer was never ` +
|
|
105
|
-
`cleared when a message arrived mid-wait, so two sockets were briefly open. I added a guard in ` +
|
|
106
|
-
`\`static/js/ws-machine.js\` and the duplicate connection disappears.`,
|
|
107
|
-
'Generate API docs from handlers':
|
|
108
|
-
`Scanning \`lib/routes-*.js\` for \`router.handle\` / \`app.<method>\` declarations and producing a ` +
|
|
109
|
-
`markdown doc grouped by module. Output goes to \`docs/api.md\`. I'll add a JSDoc-style comment ` +
|
|
110
|
-
`parser so handler descriptions can live inline with the route.`,
|
|
111
|
-
};
|
|
112
|
-
return lookup[title] || 'Done - see the diff for details.';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function synthUser(title) {
|
|
116
|
-
const lookup = {
|
|
117
|
-
'Fix failing tests in db-queries':
|
|
118
|
-
'Hey - the test suite has been flaky since yesterday. Can you figure out which specs are failing and fix them? Start with `bun test` and work from there.',
|
|
119
|
-
'Refactor auth middleware':
|
|
120
|
-
`The auth middleware in lib/http-handler.js has grown into a monster. Please split it into single-responsibility pieces.`,
|
|
121
|
-
'Add dark mode toggle':
|
|
122
|
-
`Can we add a theme toggle button in the header? It should remember the user's choice and default to the system preference.`,
|
|
123
|
-
'Write migration for user schema':
|
|
124
|
-
`Add last_login_at and a preferences JSON column to the users table. Include a backfill for existing rows.`,
|
|
125
|
-
'Debug WebSocket reconnect loop':
|
|
126
|
-
`Clients are getting stuck in a reconnect loop - the network tab shows two sockets opening before one closes. Can you trace it in ws-machine and fix?`,
|
|
127
|
-
'Generate API docs from handlers':
|
|
128
|
-
`We need API docs. Generate them from the route handler declarations and dump to docs/api.md.`,
|
|
129
|
-
};
|
|
130
|
-
return lookup[title] || 'Please take a look.';
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// If we can harvest a user message that looks natural from real JSONL, use it,
|
|
134
|
-
// otherwise fall back to the synthesized one.
|
|
135
|
-
function harvestPrompts() {
|
|
136
|
-
const pool = [];
|
|
137
|
-
if (!fs.existsSync(SRC_DIR)) return pool;
|
|
138
|
-
try {
|
|
139
|
-
for (const projDir of fs.readdirSync(SRC_DIR)) {
|
|
140
|
-
const full = path.join(SRC_DIR, projDir);
|
|
141
|
-
if (!fs.statSync(full).isDirectory()) continue;
|
|
142
|
-
for (const f of fs.readdirSync(full)) {
|
|
143
|
-
if (!f.endsWith('.jsonl')) continue;
|
|
144
|
-
const lines = fs.readFileSync(path.join(full, f), 'utf8').split('\n').filter(Boolean);
|
|
145
|
-
for (const l of lines) {
|
|
146
|
-
try {
|
|
147
|
-
const e = JSON.parse(l);
|
|
148
|
-
if (e.type !== 'user') continue;
|
|
149
|
-
const msg = e.message?.content;
|
|
150
|
-
if (!msg) continue;
|
|
151
|
-
const text = Array.isArray(msg)
|
|
152
|
-
? msg.find(c => c.type === 'text')?.text
|
|
153
|
-
: typeof msg === 'string' ? msg : null;
|
|
154
|
-
if (!text) continue;
|
|
155
|
-
// Keep only naturally-phrased (no tool_use_id etc.) prompts, 40-400 chars
|
|
156
|
-
if (text.length < 40 || text.length > 400) continue;
|
|
157
|
-
if (/tool_use|tool_result|<function_calls/.test(text)) continue;
|
|
158
|
-
pool.push(scrub(text));
|
|
159
|
-
if (pool.length > 50) return pool;
|
|
160
|
-
} catch {}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
} catch {}
|
|
165
|
-
return pool;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function build() {
|
|
169
|
-
fs.mkdirSync(OUT_DIR, { recursive: true });
|
|
170
|
-
if (fs.existsSync(OUT_DB)) fs.unlinkSync(OUT_DB);
|
|
171
|
-
|
|
172
|
-
const db = openDb(OUT_DB);
|
|
173
|
-
|
|
174
|
-
// Use the real schema pipeline - same as database.js - so fixture DB always matches production.
|
|
175
|
-
initSchema(db);
|
|
176
|
-
migrateFromJson(db, path.join(OUT_DIR, 'nonexistent.json'));
|
|
177
|
-
migrateToACP(db);
|
|
178
|
-
migrateConversationColumns(db);
|
|
179
|
-
migrateACPSchema(db);
|
|
180
|
-
migrateBackfillMessages(db);
|
|
181
|
-
migrateFTS(db);
|
|
182
|
-
migrateAutoVacuum(db);
|
|
183
|
-
|
|
184
|
-
const insConv = db.prepare(`INSERT INTO conversations (id, agentId, agentType, title, created_at, updated_at, status)
|
|
185
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
186
|
-
const insMsg = db.prepare(`INSERT INTO messages (id, conversationId, role, content, created_at)
|
|
187
|
-
VALUES (?, ?, ?, ?, ?)`);
|
|
188
|
-
const insSess = db.prepare(`INSERT INTO sessions (id, conversationId, status, started_at, completed_at, response, error)
|
|
189
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
190
|
-
|
|
191
|
-
const realPrompts = harvestPrompts();
|
|
192
|
-
const tx = db.transaction(() => {
|
|
193
|
-
DEMO_TITLES.forEach((title, idx) => {
|
|
194
|
-
const convId = det('conv', title);
|
|
195
|
-
const ts = BASE_TS - idx * 3600 * 1000; // newest first
|
|
196
|
-
insConv.run(convId, 'claude-code', 'direct', title, ts, ts, 'active');
|
|
197
|
-
|
|
198
|
-
const userText = realPrompts[idx] || synthUser(title);
|
|
199
|
-
const assistantText = synthAssistant(title);
|
|
200
|
-
const userMsgId = det('msg', convId, 'user');
|
|
201
|
-
const asstMsgId = det('msg', convId, 'asst');
|
|
202
|
-
const sessId = det('sess', convId);
|
|
203
|
-
|
|
204
|
-
insMsg.run(userMsgId, convId, 'user', userText, ts);
|
|
205
|
-
insSess.run(sessId, convId, 'completed', ts + 1000, ts + 12000, assistantText, null);
|
|
206
|
-
insMsg.run(asstMsgId, convId, 'assistant', assistantText, ts + 12000);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
tx();
|
|
210
|
-
|
|
211
|
-
const count = db.prepare('SELECT COUNT(*) AS n FROM conversations').get().n;
|
|
212
|
-
const msgCount = db.prepare('SELECT COUNT(*) AS n FROM messages').get().n;
|
|
213
|
-
db.close();
|
|
214
|
-
const sz = fs.statSync(OUT_DB).size;
|
|
215
|
-
console.log(`[harvest] wrote ${OUT_DB} (${(sz/1024).toFixed(1)}KB, ${count} conversations, ${msgCount} messages)`);
|
|
216
|
-
console.log(`[harvest] harvested ${realPrompts.length} real prompt(s) from ${SRC_DIR}`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
build();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.
|
|
3
|
-
* Original file: /npm/dompurify@3.4.7/dist/purify.es.mjs
|
|
4
|
-
*
|
|
5
|
-
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
6
|
-
*/
|
|
7
|
-
/*! @license DOMPurify 3.4.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.7/LICENSE */
|
|
8
|
-
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(e){s=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const n=Object.entries,o=Object.setPrototypeOf,r=Object.isFrozen,i=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor;let l=Object.freeze,c=Object.seal,s=Object.create,u="undefined"!=typeof Reflect&&Reflect,m=u.apply,p=u.construct;l||(l=function(e){return e}),c||(c=function(e){return e}),m||(m=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),p||(p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const f=L(Array.prototype.forEach),d=L(Array.prototype.lastIndexOf),h=L(Array.prototype.pop),g=L(Array.prototype.push),y=L(Array.prototype.splice),T=Array.isArray,b=L(String.prototype.toLowerCase),A=L(String.prototype.toString),S=L(String.prototype.match),E=L(String.prototype.replace),N=L(String.prototype.indexOf),_=L(String.prototype.trim),O=L(Number.prototype.toString),D=L(Boolean.prototype.toString),R="undefined"==typeof BigInt?null:L(BigInt.prototype.toString),w="undefined"==typeof Symbol?null:L(Symbol.prototype.toString),I=L(Object.prototype.hasOwnProperty),v=L(Object.prototype.toString),C=L(RegExp.prototype.test),x=(k=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p(k,t)});var k;function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return m(e,t,o)}}function M(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:b;if(o&&o(e,null),!T(t))return e;let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(r(t)||(t[i]=e),o=e)}e[o]=!0}return e}function z(e){for(let t=0;t<e.length;t++){I(e,t)||(e[t]=null)}return e}function F(e){const o=s(null);for(const i of n(e)){var r=t(i,2);const n=r[0],a=r[1];I(e,n)&&(T(a)?o[n]=z(a):a&&"object"==typeof a&&a.constructor===Object?o[n]=F(a):o[n]=a)}return o}function U(e,t){for(;null!==e;){const n=a(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=i(e)}return function(){return null}}const P=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),H=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),B=l(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),G=l(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),j=l(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),W=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y=l(["#text"]),X=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),q=l(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),$=l(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),K=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),V=c(/{{[\w\W]*|^[\w\W]*}}/g),Z=c(/<%[\w\W]*|^[\w\W]*%>/g),J=c(/\${[\w\W]*/g),Q=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=c(/^aria-[\-\w]+$/),te=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=c(/^(?:\w+script|data):/i),oe=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=c(/^html$/i),ie=c(/^[a-z][.\w]*(-[.\w]+)+$/i),ae=1,le=3,ce=7,se=8,ue=9,me=11,pe=function(){return"undefined"==typeof window?null:window};var fe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pe();const o=t=>e(t);if(o.version="3.4.7",o.removed=[],!t||!t.document||t.document.nodeType!==ue||!t.Element)return o.isSupported=!1,o;let r=t.document;const i=r,a=i.currentScript;t.DocumentFragment;const c=t.HTMLTemplateElement,u=t.Node,m=t.Element,p=t.NodeFilter,k=t.NamedNodeMap;void 0===k&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const L=t.DOMParser,z=t.trustedTypes,fe=m.prototype,de=U(fe,"cloneNode"),he=U(fe,"remove"),ge=U(fe,"nextSibling"),ye=U(fe,"childNodes"),Te=U(fe,"parentNode"),be=U(fe,"shadowRoot"),Ae=U(fe,"attributes"),Se=u&&u.prototype?U(u.prototype,"nodeType"):null,Ee=u&&u.prototype?U(u.prototype,"nodeName"):null;if("function"==typeof c){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Ne,_e="";const Oe=r,De=Oe.implementation,Re=Oe.createNodeIterator,we=Oe.createDocumentFragment,Ie=Oe.getElementsByTagName,ve=i.importNode;let Ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof n&&"function"==typeof Te&&De&&void 0!==De.createHTMLDocument;const xe=V,ke=Z,Le=J,Me=Q,ze=ee,Fe=ne,Ue=oe,Pe=ie;let He=te,Be=null;const Ge=M({},[...P,...H,...B,...j,...Y]);let je=null;const We=M({},[...X,...q,...$,...K]);let Ye=Object.seal(s(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Xe=null,qe=null;const $e=Object.seal(s(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ke=!0,Ve=!0,Ze=!1,Je=!0,Qe=!1,et=!0,tt=!1,nt=!1,ot=!1,rt=!1,it=!1,at=!1,lt=!0,ct=!1;const st="user-content-";let ut=!0,mt=!1,pt={},ft=null;const dt=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ht=null;const gt=M({},["audio","video","img","source","image","track"]);let yt=null;const Tt=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),bt="http://www.w3.org/1998/Math/MathML",At="http://www.w3.org/2000/svg",St="http://www.w3.org/1999/xhtml";let Et=St,Nt=!1,_t=null;const Ot=M({},[bt,At,St],A);let Dt=M({},["mi","mo","mn","ms","mtext"]),Rt=M({},["annotation-xml"]);const wt=M({},["title","style","font","a","script"]);let It=null;const vt=["application/xhtml+xml","text/html"];let Ct=null,xt=null;const kt=r.createElement("form"),Lt=function(e){return e instanceof RegExp||e instanceof Function},Mt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(xt&&xt===e)return;e&&"object"==typeof e||(e={}),e=F(e),It=-1===vt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ct="application/xhtml+xml"===It?A:b,Be=I(e,"ALLOWED_TAGS")&&T(e.ALLOWED_TAGS)?M({},e.ALLOWED_TAGS,Ct):Ge,je=I(e,"ALLOWED_ATTR")&&T(e.ALLOWED_ATTR)?M({},e.ALLOWED_ATTR,Ct):We,_t=I(e,"ALLOWED_NAMESPACES")&&T(e.ALLOWED_NAMESPACES)?M({},e.ALLOWED_NAMESPACES,A):Ot,yt=I(e,"ADD_URI_SAFE_ATTR")&&T(e.ADD_URI_SAFE_ATTR)?M(F(Tt),e.ADD_URI_SAFE_ATTR,Ct):Tt,ht=I(e,"ADD_DATA_URI_TAGS")&&T(e.ADD_DATA_URI_TAGS)?M(F(gt),e.ADD_DATA_URI_TAGS,Ct):gt,ft=I(e,"FORBID_CONTENTS")&&T(e.FORBID_CONTENTS)?M({},e.FORBID_CONTENTS,Ct):dt,Xe=I(e,"FORBID_TAGS")&&T(e.FORBID_TAGS)?M({},e.FORBID_TAGS,Ct):F({}),qe=I(e,"FORBID_ATTR")&&T(e.FORBID_ATTR)?M({},e.FORBID_ATTR,Ct):F({}),pt=!!I(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?F(e.USE_PROFILES):e.USE_PROFILES),Ke=!1!==e.ALLOW_ARIA_ATTR,Ve=!1!==e.ALLOW_DATA_ATTR,Ze=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Je=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Qe=e.SAFE_FOR_TEMPLATES||!1,et=!1!==e.SAFE_FOR_XML,tt=e.WHOLE_DOCUMENT||!1,rt=e.RETURN_DOM||!1,it=e.RETURN_DOM_FRAGMENT||!1,at=e.RETURN_TRUSTED_TYPE||!1,ot=e.FORCE_BODY||!1,lt=!1!==e.SANITIZE_DOM,ct=e.SANITIZE_NAMED_PROPS||!1,ut=!1!==e.KEEP_CONTENT,mt=e.IN_PLACE||!1,He=function(e){try{return C(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:te,Et="string"==typeof e.NAMESPACE?e.NAMESPACE:St,Dt=I(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?F(e.MATHML_TEXT_INTEGRATION_POINTS):M({},["mi","mo","mn","ms","mtext"]),Rt=I(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?F(e.HTML_INTEGRATION_POINTS):M({},["annotation-xml"]);const t=I(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?F(e.CUSTOM_ELEMENT_HANDLING):s(null);if(Ye=s(null),I(t,"tagNameCheck")&&Lt(t.tagNameCheck)&&(Ye.tagNameCheck=t.tagNameCheck),I(t,"attributeNameCheck")&&Lt(t.attributeNameCheck)&&(Ye.attributeNameCheck=t.attributeNameCheck),I(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Ye.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),Qe&&(Ve=!1),it&&(rt=!0),pt&&(Be=M({},Y),je=s(null),!0===pt.html&&(M(Be,P),M(je,X)),!0===pt.svg&&(M(Be,H),M(je,q),M(je,K)),!0===pt.svgFilters&&(M(Be,B),M(je,q),M(je,K)),!0===pt.mathMl&&(M(Be,j),M(je,$),M(je,K))),$e.tagCheck=null,$e.attributeCheck=null,I(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?$e.tagCheck=e.ADD_TAGS:T(e.ADD_TAGS)&&(Be===Ge&&(Be=F(Be)),M(Be,e.ADD_TAGS,Ct))),I(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?$e.attributeCheck=e.ADD_ATTR:T(e.ADD_ATTR)&&(je===We&&(je=F(je)),M(je,e.ADD_ATTR,Ct))),I(e,"ADD_URI_SAFE_ATTR")&&T(e.ADD_URI_SAFE_ATTR)&&M(yt,e.ADD_URI_SAFE_ATTR,Ct),I(e,"FORBID_CONTENTS")&&T(e.FORBID_CONTENTS)&&(ft===dt&&(ft=F(ft)),M(ft,e.FORBID_CONTENTS,Ct)),I(e,"ADD_FORBID_CONTENTS")&&T(e.ADD_FORBID_CONTENTS)&&(ft===dt&&(ft=F(ft)),M(ft,e.ADD_FORBID_CONTENTS,Ct)),ut&&(Be["#text"]=!0),tt&&M(Be,["html","head","body"]),Be.table&&(M(Be,["tbody"]),delete Xe.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw x('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Ne=e.TRUSTED_TYPES_POLICY,_e=Ne.createHTML("")}else void 0===Ne&&(Ne=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(z,a)),null!==Ne&&"string"==typeof _e&&(_e=Ne.createHTML(""));(Ce.uponSanitizeElement.length>0||Ce.uponSanitizeAttribute.length>0)&&Be===Ge&&(Be=F(Be)),Ce.uponSanitizeAttribute.length>0&&je===We&&(je=F(je)),l&&l(e),xt=e},zt=M({},[...H,...B,...G]),Ft=M({},[...j,...W]),Ut=function(e){g(o.removed,{element:e});try{Te(e).removeChild(e)}catch(t){he(e)}},Pt=function(e,t){try{g(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){g(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(rt||it)try{Ut(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ht=function(e){let t=null,n=null;if(ot)e="<remove></remove>"+e;else{const t=S(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===It&&Et===St&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=Ne?Ne.createHTML(e):e;if(Et===St)try{t=(new L).parseFromString(o,It)}catch(e){}if(!t||!t.documentElement){t=De.createDocument(Et,"template",null);try{t.documentElement.innerHTML=Nt?_e:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Et===St?Ie.call(t,tt?"html":"body")[0]:tt?t.documentElement:i},Bt=function(e){return Re.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Gt=function(e){e.normalize();const t=Re.call(e.ownerDocument||e,e,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null);let n=t.nextNode();for(;n;){let e=n.data;f([xe,ke,Le],(t=>{e=E(e,t," ")})),n.data=e,n=t.nextNode()}},jt=function(e){const t=Ee?Ee(e):null;return"string"==typeof t&&("form"===Ct(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Ae(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==Se(e)||e.childNodes!==ye(e)))},Wt=function(e){if(!Se||"object"!=typeof e||null===e)return!1;try{return Se(e)===me}catch(e){return!1}},Yt=function(e){if(!Se||"object"!=typeof e||null===e)return!1;try{return"number"==typeof Se(e)}catch(e){return!1}};function Xt(e,t,n){f(e,(e=>{e.call(o,t,n,xt)}))}const qt=function(e){let t=null;if(Xt(Ce.beforeSanitizeElements,e,null),jt(e))return Ut(e),!0;const n=Ct(e.nodeName);if(Xt(Ce.uponSanitizeElement,e,{tagName:n,allowedTags:Be}),et&&e.hasChildNodes()&&!Yt(e.firstElementChild)&&C(/<[/\w!]/g,e.innerHTML)&&C(/<[/\w!]/g,e.textContent))return Ut(e),!0;if(et&&e.namespaceURI===St&&"style"===n&&Yt(e.firstElementChild))return Ut(e),!0;if(e.nodeType===ce)return Ut(e),!0;if(et&&e.nodeType===se&&C(/<[/\w]/g,e.data))return Ut(e),!0;if(Xe[n]||!($e.tagCheck instanceof Function&&$e.tagCheck(n))&&!Be[n]){if(!Xe[n]&&Vt(n)){if(Ye.tagNameCheck instanceof RegExp&&C(Ye.tagNameCheck,n))return!1;if(Ye.tagNameCheck instanceof Function&&Ye.tagNameCheck(n))return!1}if(ut&&!ft[n]){const t=Te(e),n=ye(e);if(n&&t){for(let o=n.length-1;o>=0;--o){const r=de(n[o],!0);t.insertBefore(r,ge(e))}}}return Ut(e),!0}return((Se?Se(e):e.nodeType)!==ae||function(e){let t=Te(e);t&&t.tagName||(t={namespaceURI:Et,tagName:"template"});const n=b(e.tagName),o=b(t.tagName);return!!_t[e.namespaceURI]&&(e.namespaceURI===At?t.namespaceURI===St?"svg"===n:t.namespaceURI===bt?"svg"===n&&("annotation-xml"===o||Dt[o]):Boolean(zt[n]):e.namespaceURI===bt?t.namespaceURI===St?"math"===n:t.namespaceURI===At?"math"===n&&Rt[o]:Boolean(Ft[n]):e.namespaceURI===St?!(t.namespaceURI===At&&!Rt[o])&&!(t.namespaceURI===bt&&!Dt[o])&&!Ft[n]&&(wt[n]||!zt[n]):!("application/xhtml+xml"!==It||!_t[e.namespaceURI]))}(e))&&("noscript"!==n&&"noembed"!==n&&"noframes"!==n||!C(/<\/no(script|embed|frames)/i,e.innerHTML))?(Qe&&e.nodeType===le&&(t=e.textContent,f([xe,ke,Le],(e=>{t=E(t,e," ")})),e.textContent!==t&&(g(o.removed,{element:e.cloneNode()}),e.textContent=t)),Xt(Ce.afterSanitizeElements,e,null),!1):(Ut(e),!0)},$t=function(e,t,n){if(qe[t])return!1;if(lt&&("id"===t||"name"===t)&&(n in r||n in kt))return!1;const o=je[t]||$e.attributeCheck instanceof Function&&$e.attributeCheck(t,e);if(Ve&&!qe[t]&&C(Me,t));else if(Ke&&C(ze,t));else if(!o||qe[t]){if(!(Vt(e)&&(Ye.tagNameCheck instanceof RegExp&&C(Ye.tagNameCheck,e)||Ye.tagNameCheck instanceof Function&&Ye.tagNameCheck(e))&&(Ye.attributeNameCheck instanceof RegExp&&C(Ye.attributeNameCheck,t)||Ye.attributeNameCheck instanceof Function&&Ye.attributeNameCheck(t,e))||"is"===t&&Ye.allowCustomizedBuiltInElements&&(Ye.tagNameCheck instanceof RegExp&&C(Ye.tagNameCheck,n)||Ye.tagNameCheck instanceof Function&&Ye.tagNameCheck(n))))return!1}else if(yt[t]);else if(C(He,E(n,Ue,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==N(n,"data:")||!ht[e]){if(Ze&&!C(Fe,E(n,Ue,"")));else if(n)return!1}else;return!0},Kt=M({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Vt=function(e){return!Kt[b(e)]&&C(Pe,e)},Zt=function(e){Xt(Ce.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||jt(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:je,forceKeepAttr:void 0};let r=t.length;for(;r--;){const i=t[r],a=i.name,l=i.namespaceURI,c=i.value,s=Ct(a),u=c;let m="value"===a?u:_(u);if(n.attrName=s,n.attrValue=m,n.keepAttr=!0,n.forceKeepAttr=void 0,Xt(Ce.uponSanitizeAttribute,e,n),m=n.attrValue,!ct||"id"!==s&&"name"!==s||0===N(m,st)||(Pt(a,e),m=st+m),et&&C(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,m)){Pt(a,e);continue}if("attributename"===s&&S(m,"href")){Pt(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){Pt(a,e);continue}if(!Je&&C(/\/>/i,m)){Pt(a,e);continue}Qe&&f([xe,ke,Le],(e=>{m=E(m,e," ")}));const p=Ct(e.nodeName);if($t(p,s,m)){if(Ne&&"object"==typeof z&&"function"==typeof z.getAttributeType)if(l);else switch(z.getAttributeType(p,s)){case"TrustedHTML":m=Ne.createHTML(m);break;case"TrustedScriptURL":m=Ne.createScriptURL(m)}if(m!==u)try{l?e.setAttributeNS(l,a,m):e.setAttribute(a,m),jt(e)?Ut(e):h(o.removed)}catch(t){Pt(a,e)}}else Pt(a,e)}Xt(Ce.afterSanitizeAttributes,e,null)},Jt=function(e){let t=null;const n=Bt(e);for(Xt(Ce.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){Xt(Ce.uponSanitizeShadowNode,t,null),qt(t),Zt(t),Wt(t.content)&&Jt(t.content);if((Se?Se(t):t.nodeType)===ae){const e=be?be(t):t.shadowRoot;Wt(e)&&(Qt(e),Jt(e))}}Xt(Ce.afterSanitizeShadowDOM,e,null)},Qt=function(e){const t=Se?Se(e):e.nodeType;if(t===ae){const t=be?be(e):e.shadowRoot;Wt(t)&&(Qt(t),Jt(t))}const n=ye?ye(e):e.childNodes;if(!n)return;const o=[];f(n,(e=>{g(o,e)}));for(const e of o)Qt(e);if(t===ae){const t=Ee?Ee(e):null;if("string"==typeof t&&"template"===Ct(t)){const t=e.content;Wt(t)&&Qt(t)}}};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,a=null,l=null;if(Nt=!e,Nt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Yt(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return O(e);case"boolean":return D(e);case"bigint":return R?R(e):"0";case"symbol":return w?w(e):"Symbol()";case"undefined":default:return v(e);case"function":case"object":{if(null===e)return v(e);const t=e,n=U(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:v(e)}return v(e)}}}(e)))throw x("dirty is not a string, aborting");if(!o.isSupported)return e;if(nt||Mt(t),o.removed=[],"string"==typeof e&&(mt=!1),mt){const t=Ee?Ee(e):e.nodeName;if("string"==typeof t){const e=Ct(t);if(!Be[e]||Xe[e])throw x("root node is forbidden and cannot be sanitized in-place")}if(jt(e))throw x("root node is clobbered and cannot be sanitized in-place");Qt(e)}else if(Yt(e))n=Ht("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===ae&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),Qt(r);else{if(!rt&&!Qe&&!tt&&-1===e.indexOf("<"))return Ne&&at?Ne.createHTML(e):e;if(n=Ht(e),!n)return rt?null:at?_e:""}n&&ot&&Ut(n.firstChild);const c=Bt(mt?e:n);for(;a=c.nextNode();)qt(a),Zt(a),Wt(a.content)&&Jt(a.content);if(mt)return Qe&&Gt(e),e;if(rt){if(Qe&&Gt(n),it)for(l=we.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(je.shadowroot||je.shadowrootmode)&&(l=ve.call(i,l,!0)),l}let s=tt?n.outerHTML:n.innerHTML;return tt&&Be["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&C(re,n.ownerDocument.doctype.name)&&(s="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+s),Qe&&f([xe,ke,Le],(e=>{s=E(s,e," ")})),Ne&&at?Ne.createHTML(s):s},o.setConfig=function(){Mt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),nt=!0},o.clearConfig=function(){xt=null,nt=!1},o.isValidAttribute=function(e,t,n){xt||Mt({});const o=Ct(e),r=Ct(t);return $t(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&g(Ce[e],t)},o.removeHook=function(e,t){if(void 0!==t){const n=d(Ce[e],t);return-1===n?void 0:y(Ce[e],n,1)[0]}return h(Ce[e])},o.removeHooks=function(e){Ce[e]=[]},o.removeAllHooks=function(){Ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();export{fe as default};
|
|
9
|
-
//# sourceMappingURL=/sm/255090b3bbd98fbff5770f240699c46c5bbaec65e5ed836d6ee43d0139fe7dab.map
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|