trace-codebook 0.1.1 → 0.1.5
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.ko.md +6 -4
- package/README.md +14 -12
- package/bin/trace-codebook.mjs +29 -4
- package/dist/assets/{index-C8QZxOcS.js → index-BQpDGt-F.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -27,7 +27,7 @@ LLM 앱의 실제 트레이스를 브라우저에서 읽고, 잘못된 점을
|
|
|
27
27
|
Node.js 22.22 이상이 필요합니다([내려받기](https://nodejs.org/) 또는 `brew install node`). 최소 리눅스 환경에서는 소스에서 빌드할 때만 `git` 이 추가로 필요하고, 다른 시스템 패키지는 없습니다.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
# 설치 없이 실행
|
|
30
|
+
# 설치 없이 실행
|
|
31
31
|
npx trace-codebook
|
|
32
32
|
|
|
33
33
|
# 또는 소스에서 빌드
|
|
@@ -43,9 +43,11 @@ node bin/trace-codebook.mjs
|
|
|
43
43
|
## 빠르게 시작하기
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
|
|
46
|
+
npx trace-codebook --no-open --port 4178
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
소스로 빌드했다면 `node bin/trace-codebook.mjs --no-open --port 4178` 를 쓰세요.
|
|
50
|
+
|
|
49
51
|

|
|
50
52
|
*서버가 주소를 출력합니다. 브라우저로 여세요(`--no-open` 을 빼면 자동으로 열립니다). 이 그림은 `npx` 형태에 `--lang ko` 를 붙이고(포트도 다르게) 찍어서 주소 끝에 `?lang=ko` 가 있습니다. 위 명령은 시스템 언어가 한국어가 아니면 이 접미사 없이 주소를 출력합니다.*
|
|
51
53
|
|
|
@@ -59,7 +61,7 @@ node bin/trace-codebook.mjs --no-open --port 4178
|
|
|
59
61
|
내 파일을 바로 열려면:
|
|
60
62
|
|
|
61
63
|
```bash
|
|
62
|
-
npx trace-codebook traces.jsonl # npm
|
|
64
|
+
npx trace-codebook traces.jsonl # npm 에서
|
|
63
65
|
node bin/trace-codebook.mjs traces.jsonl # 소스 빌드에서
|
|
64
66
|
```
|
|
65
67
|
|
|
@@ -194,7 +196,7 @@ flowchart LR
|
|
|
194
196
|
|
|
195
197
|
```bash
|
|
196
198
|
npm install
|
|
197
|
-
npm test # 10개 파일
|
|
199
|
+
npm test # 10개 파일 76개 테스트, 네트워크 없음
|
|
198
200
|
npm run lint
|
|
199
201
|
npm run typecheck
|
|
200
202
|
npm run build
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# trace-codebook
|
|
2
2
|
|
|
3
|
-
**English** | [한국어](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.
|
|
3
|
+
**English** | [한국어](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.5/README.ko.md)
|
|
4
4
|
|
|
5
5
|
Read your LLM app's real traces in the browser, write down what went wrong, group the notes into failure modes, and count them. No server, no account, no API key: your trace file never leaves the browser tab.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
*The axial coding board after loading the bundled example annotations: 16 failure notes grouped into 5 failure modes.*
|
|
9
9
|
|
|
10
10
|
## Who it is for
|
|
@@ -27,7 +27,7 @@ The counts tell you which problem to fix or to automate first. trace-codebook pu
|
|
|
27
27
|
Requires Node.js 22.22 or newer ([download](https://nodejs.org/) or `brew install node`). On a minimal Linux image you also need `git` only if you build from source; there are no other system packages.
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
# Run without installing
|
|
30
|
+
# Run without installing
|
|
31
31
|
npx trace-codebook
|
|
32
32
|
|
|
33
33
|
# Or build from source
|
|
@@ -43,10 +43,12 @@ The published package has zero runtime dependencies: React and the other librari
|
|
|
43
43
|
## Quick start
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
|
|
46
|
+
npx trace-codebook --no-open --port 4178
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
If you built from source, use `node bin/trace-codebook.mjs --no-open --port 4178` instead.
|
|
50
|
+
|
|
51
|
+

|
|
50
52
|
*The server prints its address. Open it in a browser (without `--no-open` it opens for you). The picture was taken with the `npx` form plus `--lang en` (and a different port), so its address ends in `?lang=en`; the command above prints the address without that suffix when your system language is not Korean.*
|
|
51
53
|
|
|
52
54
|
Then in the browser:
|
|
@@ -59,7 +61,7 @@ The sample is **synthetic practice data** written for this project, not real use
|
|
|
59
61
|
To open your own file directly:
|
|
60
62
|
|
|
61
63
|
```bash
|
|
62
|
-
npx trace-codebook traces.jsonl # from npm
|
|
64
|
+
npx trace-codebook traces.jsonl # from npm
|
|
63
65
|
node bin/trace-codebook.mjs traces.jsonl # from a source build
|
|
64
66
|
```
|
|
65
67
|
|
|
@@ -69,14 +71,14 @@ The file is served read-only from `127.0.0.1` and is never modified.
|
|
|
69
71
|
|
|
70
72
|
### 1. Open a file
|
|
71
73
|
|
|
72
|
-

|
|
73
75
|
*The summary line shows the detected format (`openai-jsonl`), the number of traces, and how many lines were broken and skipped.*
|
|
74
76
|
|
|
75
77
|
What you do: drop a file on the page, choose one, or click the sample. What you see: the detected format, the trace count, and the line numbers of any broken lines. Broken lines are skipped, not fatal.
|
|
76
78
|
|
|
77
79
|
### 2. Review and write notes (open coding)
|
|
78
80
|
|
|
79
|
-

|
|
80
82
|
*One failed trace. The tool call, its arguments and its result sit together in one box. The note records the first thing that went wrong.*
|
|
81
83
|
|
|
82
84
|
For each trace choose a verdict and write a short note. Keys:
|
|
@@ -92,14 +94,14 @@ For each trace choose a verdict and write a short note. Keys:
|
|
|
92
94
|
|
|
93
95
|
### 3. Group notes into failure modes (axial coding)
|
|
94
96
|
|
|
95
|
-

|
|
96
98
|
*Drag a note card into a column, or use the Mode menu on each card. A note belongs to one mode only.*
|
|
97
99
|
|
|
98
100
|
Create a mode with a name and a one-line definition ("when does a trace belong here?"). Deleting a mode moves its cards back to "Unassigned failures"; verdicts and notes are kept.
|
|
99
101
|
|
|
100
102
|
### 4. Count and check saturation
|
|
101
103
|
|
|
102
|
-

|
|
103
105
|
*Counts per failure mode and the share of all failures. The curve shows how many distinct modes you had found after N reviewed traces.*
|
|
104
106
|
|
|
105
107
|
When the curve stays flat for 20 reviews in a row, a "Saturated" badge appears: new failure modes stopped appearing, so reading more traces is unlikely to change the taxonomy. 20 is a rule of thumb built into the app, not a statistical guarantee.
|
|
@@ -194,7 +196,7 @@ flowchart LR
|
|
|
194
196
|
|
|
195
197
|
```bash
|
|
196
198
|
npm install
|
|
197
|
-
npm test #
|
|
199
|
+
npm test # 76 tests in 10 files, no network
|
|
198
200
|
npm run lint
|
|
199
201
|
npm run typecheck
|
|
200
202
|
npm run build
|
|
@@ -205,7 +207,7 @@ npm run check:docs
|
|
|
205
207
|
|
|
206
208
|
Known limits: the five formats are verified against hand-built fixtures that follow the official docs and the bundled samples, not against exports from real Langfuse or Phoenix servers. Very large files (tens of thousands of traces) are not optimized yet. Opening the same file in two tabs means the tab that saves last wins.
|
|
207
209
|
|
|
208
|
-
Bugs and ideas are welcome as issues. Changes are listed in [CHANGELOG.md](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.
|
|
210
|
+
Bugs and ideas are welcome as issues. Changes are listed in [CHANGELOG.md](https://github.com/LeeGyeongPil/trace-codebook/blob/v0.1.5/CHANGELOG.md).
|
|
209
211
|
|
|
210
212
|
## License
|
|
211
213
|
|
package/bin/trace-codebook.mjs
CHANGED
|
@@ -31,6 +31,7 @@ const TYPES = {
|
|
|
31
31
|
export function parseArgs(argv, env = process.env) {
|
|
32
32
|
const opts = { file: null, port: DEFAULT_PORT, open: true, help: false, version: false, lang: null };
|
|
33
33
|
const files = [];
|
|
34
|
+
let badOption = null;
|
|
34
35
|
for (let i = 0; i < argv.length; i++) {
|
|
35
36
|
const a = argv[i];
|
|
36
37
|
const value = () => (a.includes('=') ? a.slice(a.indexOf('=') + 1) : argv[++i]);
|
|
@@ -39,7 +40,7 @@ export function parseArgs(argv, env = process.env) {
|
|
|
39
40
|
else if (a === '--no-open') opts.open = false;
|
|
40
41
|
else if (a === '--port' || a.startsWith('--port=')) opts.port = value();
|
|
41
42
|
else if (a === '--lang' || a.startsWith('--lang=')) opts.lang = value();
|
|
42
|
-
else if (a.startsWith('-'))
|
|
43
|
+
else if (a.startsWith('-')) badOption ??= a; // 첫 번째만 기억하고 끝까지 훑는다
|
|
43
44
|
else files.push(a);
|
|
44
45
|
}
|
|
45
46
|
// 언어부터 정해야 오류 메시지도 그 언어로 낼 수 있다
|
|
@@ -47,10 +48,12 @@ export function parseArgs(argv, env = process.env) {
|
|
|
47
48
|
const l = String(opts.lang).toLowerCase();
|
|
48
49
|
if (l !== 'en' && l !== 'ko') {
|
|
49
50
|
opts.lang = langFromEnv(env);
|
|
51
|
+
if (badOption) return { opts, error: ['badOption', { option: badOption }] };
|
|
50
52
|
return { opts, error: ['badLang', { lang: l }] };
|
|
51
53
|
}
|
|
52
54
|
opts.lang = l;
|
|
53
55
|
} else opts.lang = langFromEnv(env);
|
|
56
|
+
if (badOption) return { opts, error: ['badOption', { option: badOption }] };
|
|
54
57
|
if (files.length > 1) return { opts, error: ['tooMany', {}] };
|
|
55
58
|
opts.file = files[0] ?? null;
|
|
56
59
|
const port = Number(opts.port);
|
|
@@ -91,9 +94,31 @@ export function makeServer({ root, file }) {
|
|
|
91
94
|
// 1) 사용자가 준 트레이스 파일(읽기 전용)
|
|
92
95
|
if (traceName && path === `/__trace/${traceName}`) {
|
|
93
96
|
const type = TYPES[extname(traceName).toLowerCase()] ?? 'application/octet-stream';
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
// 파일이 사라졌거나 일반 파일이 아니면 이 요청만 404 — 서버는 계속 돈다
|
|
98
|
+
let traceStat;
|
|
99
|
+
try {
|
|
100
|
+
traceStat = statSync(file);
|
|
101
|
+
} catch {
|
|
102
|
+
return notFound();
|
|
103
|
+
}
|
|
104
|
+
if (!traceStat.isFile()) return notFound();
|
|
105
|
+
const okHeaders = { ...headers, 'content-type': type, 'content-length': traceStat.size };
|
|
106
|
+
if (req.method === 'HEAD') {
|
|
107
|
+
res.writeHead(200, okHeaders);
|
|
108
|
+
return res.end();
|
|
109
|
+
}
|
|
110
|
+
const stream = createReadStream(file);
|
|
111
|
+
// stat 뒤 읽기 직전에 지워지는 경우 등: 헤더 전이면 404, 이미 보냈으면 연결만 끊는다
|
|
112
|
+
stream.on('error', () => {
|
|
113
|
+
if (!res.headersSent) notFound();
|
|
114
|
+
else res.destroy();
|
|
115
|
+
});
|
|
116
|
+
// 파일이 실제로 열린 뒤에만 200 헤더를 쓴다
|
|
117
|
+
stream.on('open', () => {
|
|
118
|
+
res.writeHead(200, okHeaders);
|
|
119
|
+
stream.pipe(res);
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
97
122
|
}
|
|
98
123
|
|
|
99
124
|
// 2) dist/ 안의 정적 파일
|
|
@@ -17,4 +17,4 @@ Error generating stack: `+e.message+`
|
|
|
17
17
|
`)+`
|
|
18
18
|
`}function Ve(e,t){let n=T(e),r=e=>e.replace(/\|/g,`\\|`).replace(/\r?\n/g,` `),i=[`# ${t(`md.title`)}`,``,t(`md.summary`,{reviewed:n.reviewed,pass:n.pass,fail:n.fail,defer:n.defer}),``,t(`md.header`),`|---|---|---:|---:|---|`],a=[...Me(e)].sort((e,t)=>t.count-e.count);for(let e of a)i.push(`| ${r(e.mode.name)} | ${r(e.mode.definition)} | ${e.count} | ${(e.share*100).toFixed(1)}% | ${e.examples.map(e=>"`"+e+"`").join(`, `)} |`);return i.push(``,t(`md.unassigned`,{n:Ne(e)}),``),i.join(`
|
|
19
19
|
`)}var He=new Set([`pass`,`fail`,`defer`]),Ue=e=>e&&Date.parse(e)||0;function We(e,t){let n=e.modes.find(e=>e.name===t.trim());if(n)return[e,n.id];let r=Te(e,{type:`addMode`,name:t});return[r,r.modes[r.modes.length-1].id]}function Ge(e,t,n,r=`annotations`,i=[]){let a={kind:r,imported:0,kept:0,unmatched:0,badLines:i},o={...e,annotations:{...e.annotations}},s=[...t].sort((e,t)=>(e.review_order??1/0)-(t.review_order??1/0));for(let e of s){let t=e.trace_id;if(!t||!n.has(t)){a.unmatched++;continue}let r=o.annotations[t];if(r&&r.reviewedAt&&Ue(r.reviewedAt)>=Ue(e.reviewed_at)){a.kept++;continue}let i=e.verdict&&He.has(e.verdict)?e.verdict:null,s=null;i===`fail`&&e.failure_mode&&([o,s]=We(o,e.failure_mode));let c={traceId:t,source:e.source||n.get(t)||``,verdict:i,note:e.note??r?.note??``,modeId:s,reviewOrder:e.review_order??r?.reviewOrder??null,reviewedAt:e.reviewed_at??r?.reviewedAt??null};c.reviewOrder??(c.reviewOrder=o.nextOrder,o={...o,nextOrder:o.nextOrder+1}),o.annotations[t]=c,a.imported++}let c=Math.max(0,...Object.values(o.annotations).map(e=>e.reviewOrder??0));return o={...o,nextOrder:Math.max(o.nextOrder,c+1)},{state:o,report:a}}function Ke(e){let t=[],n=[];return e.replace(/^/,``).split(`
|
|
20
|
-
`).forEach((e,r)=>{if(e.trim())try{let i=JSON.parse(e);i&&typeof i==`object`&&typeof i.trace_id==`string`?t.push(i):n.push(r+1)}catch{n.push(r+1)}}),{rows:t,badLines:n}}function qe(e,t){let[n,...r]=je(t),i=e=>n.indexOf(e),a=e,o=0;for(let e of r){let t=(e[i(`failure_mode`)]??``).trim();if(!t)continue;let n;[a,n]=We(a,t),a=Te(a,{type:`editMode`,modeId:n,definition:e[i(`definition`)]??``}),o++}return{state:a,report:{kind:`taxonomy`,imported:o,kept:0,unmatched:0,badLines:[]}}}function Je(e,t,n){let r=t.replace(/^/,``).split(/\r?\n/,1)[0].trim();if(r.startsWith(`failure_mode,definition,count,share_of_failures,example_trace_ids`.split(`,`).slice(0,2).join(`,`)))return qe(e,t);if(r===`trace_id,verdict,failure_mode`){let[,...r]=je(t);return Ge(e,r.map(e=>({trace_id:e[0],verdict:e[1]||null,failure_mode:e[2]||null})),n,`labels`)}let{rows:i,badLines:a}=Ke(t);return Ge(e,i,n,`annotations`,a)}var Ye=(e,t)=>t.some(t=>e instanceof t),Xe,Ze;function Qe(){return Xe||=[IDBIndex,IDBObjectStore,IDBCursor,IDBDatabase,IDBTransaction]}function $e(){return Ze||=[`advance`,`continue`,`continuePrimaryKey`].map(e=>IDBCursor.prototype[e])}var et=new WeakMap,tt=new WeakMap,nt=new WeakMap;function rt(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(lt(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return nt.set(t,e),t}function it(e){if(et.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});et.set(e,t)}var at={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return et.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return lt(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)||t in e}};function ot(e){at=e(at)}function st(e){return $e().includes(e)?function(...t){return e.apply(ut(this),t),lt(this.request)}:function(...t){return lt(e.apply(ut(this),t))}}function ct(e){return typeof e==`function`?st(e):(e instanceof IDBTransaction&&it(e),Ye(e,Qe())?new Proxy(e,at):e)}function lt(e){if(e instanceof IDBRequest)return rt(e);if(tt.has(e))return tt.get(e);let t=ct(e);return Object.is(t,e)||(tt.set(e,t),nt.set(t,e)),t}var ut=e=>nt.get(e);function dt(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=lt(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(lt(o.result),e.oldVersion,e.newVersion,lt(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var ft=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],pt=[`put`,`add`,`delete`,`clear`],mt={};function ht(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(mt[t])return mt[t];let n=t.replace(/FromIndex$/,``),r=t!==n,i=pt.includes(n);return!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||ft.includes(n))?void 0:mt[t]=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]}}ot(e=>({...e,get:(t,n,r)=>ht(t,n)||e.get(t,n,r),has:(t,n)=>!!ht(t,n)||e.has(t,n)}));var gt=[`advance`,`continue`,`continuePrimaryKey`],_t={},vt=new WeakMap,yt=new WeakMap,bt={get(e,t){if(!gt.includes(t))return e[t];let n=_t[t];return n||=_t[t]=function(...e){vt.set(this,yt.get(this)[t](...e))},n}};async function*xt(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,bt);for(yt.set(n,t),nt.set(n,ut(t));t;)yield n,t=await(vt.get(n)||t.continue()),vt.delete(n)}function St(e,t){return t===Symbol.asyncIterator&&Ye(e,[IDBIndex,IDBObjectStore,IDBCursor])||t===`iterate`&&Ye(e,[IDBIndex,IDBObjectStore])}ot(e=>({...e,get(t,n,r){return St(t,n)?xt:e.get(t,n,r)},has(t,n){return St(t,n)||e.has(t,n)}}));var Ct=`trace-codebook`,wt=1;async function Tt(e=Ct){let t=await dt(e,wt,{upgrade(e){e.createObjectStore(`projects`,{keyPath:`fingerprint`})}});return{load:e=>t.get(`projects`,e),async save(e,n,r){await t.put(`projects`,{fingerprint:e,fileName:n,savedAt:new Date().toISOString(),state:r})},list:()=>t.getAll(`projects`),remove:e=>t.delete(`projects`,e),close:()=>t.close()}}var Et={en:{"app.title":`trace-codebook`,"app.tagline":`Read LLM traces, write notes, group them into failure modes, and count them.`,"lang.label":`Language`,"tab.review":`Review`,"tab.axial":`Axial coding`,"tab.stats":`Stats`,"drop.title":`Open a trace file`,"drop.hint":`Drop a file here or choose one. Supported: OpenAI / Anthropic message JSONL, OTLP JSON, Langfuse trace JSON, Phoenix span JSONL.`,"drop.choose":`Choose file…`,"drop.sample":`Try sample traces`,"drop.sampleNotice":`The sample traces are synthetic practice data written for this project (a fictional support agent), not real user logs.`,"drop.privacy":`Your file never leaves this browser tab. Notes are saved in this browser (IndexedDB).`,"drop.loading":`Reading {name}…`,"error.read":`Could not read this file: {message}`,"error.empty":`No records found in this file.`,"error.fetch":`Could not load {name}.`,"summary.format":`Format`,"summary.traces":`{n} traces`,"summary.skipped":`{n} broken lines`,"summary.skippedList":`Skipped lines: {lines}`,"summary.resumed":`Resumed your saved notes for this file.`,"summary.openOther":`Open another file`,"summary.loadExample":`Load example annotations`,"summary.contentMissing":`{n} traces have spans but no message content — check the content capture setting of your instrumentation.`,"sample.badge":`Practice mode — synthetic sample data`,"review.list":`Traces`,"review.position":`{i} / {n}`,"review.spans":`{n} spans`,"review.contentMissing":`This trace has spans but no message content. Most instrumentations record content only when you opt in — check the content capture setting.`,"review.verdict":`Verdict`,"review.note":`Note — the first thing that went wrong`,"review.notePlaceholder":`e.g. quoted a 30-day refund window; the policy says 14 days`,"review.mode":`Failure mode`,"review.modeNone":`— none —`,"review.prev":`Previous (K)`,"review.next":`Next (J)`,"review.help":`Shortcuts (?)`,"review.hint":`P pass · F fail · D defer · J/K move · N note · 1–9 mode · ? help`,"verdict.pass":`Pass`,"verdict.fail":`Fail`,"verdict.defer":`Defer`,"verdict.none":`Not reviewed`,"role.system":`System`,"role.user":`User`,"role.assistant":`Assistant`,"role.tool":`Tool`,"msg.showMore":`Show more`,"msg.showLess":`Show less`,"msg.toolCall":`Tool call`,"msg.toolResult":`Result`,"msg.noResult":`No result recorded`,"msg.empty":`(empty)`,"shortcut.title":`Keyboard shortcuts`,"shortcut.pass":`Mark as pass`,"shortcut.fail":`Mark as fail`,"shortcut.defer":`Defer (decide later)`,"shortcut.next":`Next trace`,"shortcut.prev":`Previous trace`,"shortcut.note":`Focus the note field`,"shortcut.mode":`Assign the Nth failure mode (marks as fail)`,"shortcut.help":`Show or hide this help`,"shortcut.escape":`Leave the note field / close help`,"shortcut.close":`Close`,"axial.intro":`Drag failure notes into a column, or pick a mode on each card. A note belongs to one mode only.`,"axial.unassigned":`Unassigned failures`,"axial.newMode":`New failure mode`,"axial.newModePlaceholder":`Mode name, e.g. Policy hallucination`,"axial.add":`Add`,"axial.name":`Name`,"axial.definition":`Definition`,"axial.definitionPlaceholder":`When does a trace belong here?`,"axial.delete":`Delete mode`,"axial.count":`{n} notes`,"axial.empty":`No failures yet. Mark traces as Fail in Review first.`,"axial.moveTo":`Mode`,"axial.noNote":`(no note)`,"axial.dropHere":`Drop notes here`,"stats.verdicts":`Verdicts`,"stats.reviewed":`{reviewed} of {total} traces reviewed`,"stats.modes":`Failure modes`,"stats.count":`Count`,"stats.share":`Share of failures`,"stats.unassigned":`{n} failures without a mode`,"stats.noModes":`No failure modes yet.`,"stats.saturation":`Saturation`,"stats.saturationHelp":`x = traces reviewed, y = failure modes found so far. When the line goes flat, new failure modes stopped appearing.`,"stats.saturated":`Saturated — new failure modes stopped appearing`,"stats.notSaturated":`Not saturated yet — keep reading until {window} reviews pass without a new mode`,"stats.axisX":`traces reviewed`,"stats.axisY":`failure modes`,"export.title":`Export / import`,"export.annotations":`Annotations (JSONL)`,"export.taxonomyCsv":`Taxonomy (CSV)`,"export.taxonomyMd":`Taxonomy (Markdown)`,"export.labels":`Labels (CSV)`,"export.import":`Import annotations…`,"export.importDone":`Imported {imported}, kept {kept} newer local notes, {unmatched} unknown trace ids.`,"export.importTaxonomy":`Imported {imported} failure mode definitions.`,"export.importBad":`{n} lines could not be read.`,"save.failed":`Could not save to this browser ({message}). Your notes are still in memory — export annotations JSONL as a backup.`,"md.title":`Failure mode taxonomy`,"md.summary":`Reviewed {reviewed} traces: {pass} pass, {fail} fail, {defer} defer.`,"md.header":`| Failure mode | Definition | Count | Share of failures | Examples |`,"md.unassigned":`Failures without a mode: {n}`},ko:{"app.title":`trace-codebook`,"app.tagline":`LLM 트레이스를 읽고, 메모하고, 실패 유형으로 묶고, 세어 봅니다.`,"lang.label":`언어`,"tab.review":`검토`,"tab.axial":`축 코딩`,"tab.stats":`통계`,"drop.title":`트레이스 파일 열기`,"drop.hint":`파일을 여기에 끌어 놓거나 고르세요. 지원 형식: OpenAI / Anthropic 메시지 JSONL, OTLP JSON, Langfuse 트레이스 JSON, Phoenix span JSONL.`,"drop.choose":`파일 고르기…`,"drop.sample":`샘플 트레이스로 해 보기`,"drop.sampleNotice":`샘플 트레이스는 이 프로젝트용으로 직접 만든 가상의 연습용 데이터입니다(가상의 고객지원 에이전트, 실제 사용자 기록 아님).`,"drop.privacy":`파일은 이 브라우저 탭 밖으로 나가지 않습니다. 메모는 이 브라우저(IndexedDB)에 저장됩니다.`,"drop.loading":`{name} 읽는 중…`,"error.read":`이 파일을 읽지 못했습니다: {message}`,"error.empty":`이 파일에서 레코드를 찾지 못했습니다.`,"error.fetch":`{name} 을(를) 불러오지 못했습니다.`,"summary.format":`형식`,"summary.traces":`트레이스 {n}건`,"summary.skipped":`깨진 줄 {n}개`,"summary.skippedList":`건너뛴 줄: {lines}`,"summary.resumed":`이 파일에 저장해 둔 메모를 이어서 열었습니다.`,"summary.openOther":`다른 파일 열기`,"summary.loadExample":`예시 주석 불러오기`,"summary.contentMissing":`트레이스 {n}건은 span 만 있고 메시지 내용이 없습니다 — 계측 도구의 content capture 설정을 확인하세요.`,"sample.badge":`연습 모드 — 가상 샘플 데이터`,"review.list":`트레이스`,"review.position":`{i} / {n}`,"review.spans":`span {n}개`,"review.contentMissing":`이 트레이스는 span 만 있고 메시지 내용이 없습니다. 대부분의 계측 도구는 직접 켜야 내용을 기록합니다 — content capture 설정을 확인하세요.`,"review.verdict":`판정`,"review.note":`메모 — 처음 잘못된 지점`,"review.notePlaceholder":`예: 환불 기간을 30일이라고 답함, 정책은 14일`,"review.mode":`실패 유형`,"review.modeNone":`— 없음 —`,"review.prev":`이전 (K)`,"review.next":`다음 (J)`,"review.help":`단축키 (?)`,"review.hint":`P 통과 · F 실패 · D 보류 · J/K 이동 · N 메모 · 1–9 유형 · ? 도움말`,"verdict.pass":`통과`,"verdict.fail":`실패`,"verdict.defer":`보류`,"verdict.none":`미검토`,"role.system":`시스템`,"role.user":`사용자`,"role.assistant":`어시스턴트`,"role.tool":`도구`,"msg.showMore":`더 보기`,"msg.showLess":`접기`,"msg.toolCall":`도구 호출`,"msg.toolResult":`결과`,"msg.noResult":`기록된 결과 없음`,"msg.empty":`(비어 있음)`,"shortcut.title":`단축키`,"shortcut.pass":`통과로 판정`,"shortcut.fail":`실패로 판정`,"shortcut.defer":`보류(나중에 판단)`,"shortcut.next":`다음 트레이스`,"shortcut.prev":`이전 트레이스`,"shortcut.note":`메모 칸으로 이동`,"shortcut.mode":`N번째 실패 유형 붙이기(실패로 판정)`,"shortcut.help":`이 도움말 열기·닫기`,"shortcut.escape":`메모 칸에서 나가기 / 도움말 닫기`,"shortcut.close":`닫기`,"axial.intro":`실패 메모 카드를 열로 끌어 놓거나 카드마다 유형을 고르세요. 메모 하나는 한 유형에만 속합니다.`,"axial.unassigned":`미분류 실패`,"axial.newMode":`새 실패 유형`,"axial.newModePlaceholder":`유형 이름, 예: 정책 지어내기`,"axial.add":`추가`,"axial.name":`이름`,"axial.definition":`정의`,"axial.definitionPlaceholder":`어떤 트레이스가 여기에 속하나요?`,"axial.delete":`유형 삭제`,"axial.count":`메모 {n}개`,"axial.empty":`아직 실패가 없습니다. 먼저 검토 탭에서 실패로 판정하세요.`,"axial.moveTo":`유형`,"axial.noNote":`(메모 없음)`,"axial.dropHere":`여기에 메모를 놓으세요`,"stats.verdicts":`판정`,"stats.reviewed":`트레이스 {total}건 중 {reviewed}건 검토`,"stats.modes":`실패 유형`,"stats.count":`건수`,"stats.share":`실패 대비 비율`,"stats.unassigned":`유형이 없는 실패 {n}건`,"stats.noModes":`아직 실패 유형이 없습니다.`,"stats.saturation":`포화`,"stats.saturationHelp":`x = 검토한 트레이스 수, y = 지금까지 찾은 실패 유형 수. 선이 평평해지면 새 유형이 더는 나오지 않는다는 뜻입니다.`,"stats.saturated":`포화 — 새 실패 유형이 더 나오지 않습니다`,"stats.notSaturated":`아직 포화 아님 — 새 유형 없이 {window}건을 더 검토할 때까지 계속 읽으세요`,"stats.axisX":`검토한 트레이스`,"stats.axisY":`실패 유형`,"export.title":`내보내기 / 가져오기`,"export.annotations":`주석 (JSONL)`,"export.taxonomyCsv":`유형 분류표 (CSV)`,"export.taxonomyMd":`유형 분류표 (Markdown)`,"export.labels":`라벨 (CSV)`,"export.import":`주석 가져오기…`,"export.importDone":`{imported}건 가져옴, 더 새로운 기존 메모 {kept}건 유지, 없는 트레이스 ID {unmatched}개.`,"export.importTaxonomy":`실패 유형 정의 {imported}개를 가져왔습니다.`,"export.importBad":`읽지 못한 줄 {n}개.`,"save.failed":`이 브라우저에 저장하지 못했습니다({message}). 메모는 메모리에 남아 있으니 주석 JSONL 로 내보내 백업하세요.`,"md.title":`실패 유형 분류표`,"md.summary":`트레이스 {reviewed}건 검토: 통과 {pass}, 실패 {fail}, 보류 {defer}.`,"md.header":`| 실패 유형 | 정의 | 건수 | 실패 대비 비율 | 예시 |`,"md.unassigned":`유형이 없는 실패: {n}건`}},Dt=`trace-codebook.lang`,Ot=e=>e===`en`||e===`ko`;function kt(e){return(e?.[0]??``).toLowerCase().startsWith(`ko`)?`ko`:`en`}function At(){try{let e=globalThis.localStorage?.getItem(Dt);return Ot(e)?e:null}catch{return null}}function jt(){let e=typeof location<`u`?new URLSearchParams(location.search).get(`lang`):null;return Ot(e)?e:At()??kt(typeof navigator<`u`?navigator.languages:void 0)}function Mt(e,t,n){let r=Et[e][t]??Et.en[t]??t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e):r}var Nt=(0,l.createContext)({lang:`en`,setLang:()=>{},t:(e,t)=>Mt(`en`,e,t)});function Pt({children:e,initial:t}){let[n,r]=(0,l.useState)(()=>t??jt()),i=(0,l.useCallback)(e=>{r(e);try{globalThis.localStorage?.setItem(Dt,e)}catch{}typeof document<`u`&&(document.documentElement.lang=e)},[]),a=(0,l.useMemo)(()=>({lang:n,setLang:i,t:(e,t)=>Mt(n,e,t)}),[n,i]);return(0,l.createElement)(Nt.Provider,{value:a},e)}var D=()=>(0,l.useContext)(Nt),Ft=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=e(((e,t)=>{t.exports=Ft()}))(),It=`text/plain`;function Lt({annotation:e,modes:t,onAssign:n,onOpen:r}){let{t:i}=D();return(0,O.jsxs)(`div`,{className:`note-card`,draggable:!0,onDragStart:t=>{t.dataTransfer.setData(It,e.traceId),t.dataTransfer.effectAllowed=`move`},"data-trace-id":e.traceId,children:[(0,O.jsx)(`button`,{type:`button`,className:`link note-card__id`,onClick:()=>r(e.traceId),children:e.traceId}),(0,O.jsx)(`p`,{className:`note-card__text`,children:e.note||(0,O.jsx)(`em`,{className:`muted`,children:i(`axial.noNote`)})}),(0,O.jsxs)(`select`,{"aria-label":`${i(`axial.moveTo`)}: ${e.traceId}`,value:e.modeId??``,onChange:t=>n(e.traceId,t.target.value||null),children:[(0,O.jsx)(`option`,{value:``,children:i(`axial.unassigned`)}),t.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function Rt({mode:e,count:t,onDropCard:n,onRename:r,onDefine:i,onDelete:a,children:o}){let{t:s}=D(),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(e?.name??``),[p,m]=(0,l.useState)(e?.name);return e&&e.name!==p&&(m(e.name),f(e.name)),(0,O.jsxs)(`section`,{className:`column ${c?`column--over`:``} ${e?``:`column--unassigned`}`,"aria-label":e?e.name:s(`axial.unassigned`),onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1);let t=e.dataTransfer.getData(It);t&&n(t)},children:[(0,O.jsxs)(`header`,{className:`column__head`,children:[e?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{className:`column__name`,"aria-label":s(`axial.name`),value:d,onChange:e=>f(e.target.value),onBlur:()=>r?.(d),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),(0,O.jsx)(`textarea`,{className:`column__def`,"aria-label":s(`axial.definition`),rows:2,placeholder:s(`axial.definitionPlaceholder`),value:e.definition,onChange:e=>i?.(e.target.value)})]}):(0,O.jsx)(`h3`,{children:s(`axial.unassigned`)}),(0,O.jsxs)(`div`,{className:`column__meta`,children:[(0,O.jsx)(`span`,{className:`muted small`,children:s(`axial.count`,{n:t})}),e&&(0,O.jsx)(`button`,{type:`button`,className:`link danger`,onClick:a,children:s(`axial.delete`)})]})]}),(0,O.jsx)(`div`,{className:`column__cards`,children:t===0?(0,O.jsx)(`p`,{className:`muted small`,children:s(`axial.dropHere`)}):o})]})}function zt({state:e,dispatch:t,sourceOf:n,onOpen:r}){let{t:i}=D(),[a,o]=(0,l.useState)(``),s=(e,r)=>t({type:`assign`,traceId:e,source:n(e),modeId:r,at:new Date().toISOString()}),c=E(e,null),u=c.length+e.modes.reduce((t,n)=>t+E(e,n.id).length,0),d=t=>(0,O.jsx)(Lt,{annotation:t,modes:e.modes,onAssign:s,onOpen:r},t.traceId);return(0,O.jsxs)(`div`,{className:`axial`,children:[(0,O.jsx)(`p`,{className:`muted`,children:i(`axial.intro`)}),u===0&&(0,O.jsx)(`p`,{className:`notice`,children:i(`axial.empty`)}),(0,O.jsxs)(`form`,{className:`axial__new`,onSubmit:e=>{e.preventDefault(),t({type:`addMode`,name:a}),o(``)},children:[(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`span`,{className:`visually-hidden`,children:i(`axial.newMode`)}),(0,O.jsx)(`input`,{value:a,placeholder:i(`axial.newModePlaceholder`),onChange:e=>o(e.target.value)})]}),(0,O.jsx)(`button`,{type:`submit`,className:`btn btn--primary`,disabled:!a.trim(),children:i(`axial.add`)})]}),(0,O.jsxs)(`div`,{className:`board`,children:[(0,O.jsx)(Rt,{mode:null,count:c.length,onDropCard:e=>s(e,null),children:c.map(d)}),e.modes.map(n=>{let r=E(e,n.id);return(0,O.jsx)(Rt,{mode:n,count:r.length,onDropCard:e=>s(e,n.id),onRename:e=>t({type:`editMode`,modeId:n.id,name:e}),onDefine:e=>t({type:`editMode`,modeId:n.id,definition:e}),onDelete:()=>t({type:`deleteMode`,modeId:n.id}),children:r.map(d)},n.id)})]})]})}function Bt({onFile:e,onSample:t,busy:n,error:r}){let{t:i}=D(),a=(0,l.useRef)(null),[o,s]=(0,l.useState)(!1);return(0,O.jsxs)(`section`,{className:`drop ${o?`drop--over`:``}`,onDragOver:e=>{e.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:t=>{t.preventDefault(),s(!1);let n=t.dataTransfer.files?.[0];n&&e(n)},children:[(0,O.jsx)(`h2`,{children:i(`drop.title`)}),(0,O.jsx)(`p`,{className:`muted`,children:i(`drop.hint`)}),(0,O.jsxs)(`div`,{className:`drop__actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>a.current?.click(),children:i(`drop.choose`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:t,children:i(`drop.sample`)})]}),(0,O.jsx)(`input`,{ref:a,type:`file`,accept:`.jsonl,.json,.ndjson,.txt`,hidden:!0,onChange:t=>{let n=t.target.files?.[0];n&&e(n),t.target.value=``}}),(0,O.jsx)(`p`,{className:`notice`,children:i(`drop.sampleNotice`)}),(0,O.jsx)(`p`,{className:`muted small`,children:i(`drop.privacy`)}),n&&(0,O.jsx)(`p`,{className:`muted`,children:i(`drop.loading`,{name:n})}),r&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}function Vt(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Ht({state:e,baseName:t,onImport:n}){let{t:r}=D(),i=(0,l.useRef)(null);return(0,O.jsxs)(`details`,{className:`export-menu`,children:[(0,O.jsx)(`summary`,{className:`btn`,children:r(`export.title`)}),(0,O.jsxs)(`div`,{className:`export-menu__list`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.annotations.jsonl`,Re(e),`application/x-ndjson`),children:r(`export.annotations`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.taxonomy.csv`,ze(e),`text/csv`),children:r(`export.taxonomyCsv`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.taxonomy.md`,Ve(e,r),`text/markdown`),children:r(`export.taxonomyMd`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.labels.csv`,Be(e),`text/csv`),children:r(`export.labels`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>i.current?.click(),children:r(`export.import`)}),(0,O.jsx)(`input`,{ref:i,type:`file`,accept:`.jsonl,.csv,.json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t&&n(await t.text())}})]})]})}function Ut(){let{lang:e,setLang:t,t:n}=D();return(0,O.jsxs)(`label`,{className:`lang-menu`,children:[(0,O.jsx)(`span`,{className:`lang-menu__label`,children:n(`lang.label`)}),(0,O.jsxs)(`select`,{"aria-label":n(`lang.label`),value:e,onChange:e=>t(e.target.value),children:[(0,O.jsx)(`option`,{value:`en`,children:`English`}),(0,O.jsx)(`option`,{value:`ko`,children:`한국어`})]})]})}var Wt=[`pass`,`fail`,`defer`];function Gt({annotation:e,modes:t,noteRef:n,onVerdict:r,onNote:i,onMode:a,onPrev:o,onNext:s,onHelp:c}){let{t:l}=D(),u=e?.verdict??null;return(0,O.jsxs)(`aside`,{className:`note-panel`,children:[(0,O.jsx)(`h3`,{children:l(`review.verdict`)}),(0,O.jsx)(`div`,{className:`verdicts`,role:`group`,"aria-label":l(`review.verdict`),children:Wt.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`btn verdict verdict--${e}`,"aria-pressed":u===e,onClick:()=>r(e),children:[l(`verdict.${e}`),` `,(0,O.jsx)(`kbd`,{children:e[0].toUpperCase()})]},e))}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:l(`review.note`)}),(0,O.jsx)(`textarea`,{ref:n,rows:4,value:e?.note??``,placeholder:l(`review.notePlaceholder`),onChange:e=>i(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:l(`review.mode`)}),(0,O.jsxs)(`select`,{value:u===`fail`?e?.modeId??``:``,onChange:e=>a(e.target.value||null),children:[(0,O.jsx)(`option`,{value:``,children:l(`review.modeNone`)}),t.map((e,t)=>(0,O.jsxs)(`option`,{value:e.id,children:[t<9?`${t+1}. `:``,e.name]},e.id))]})]}),(0,O.jsxs)(`div`,{className:`note-panel__nav`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:l(`review.prev`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:s,children:l(`review.next`)})]}),(0,O.jsx)(`p`,{className:`muted small`,children:l(`review.hint`)}),(0,O.jsx)(`button`,{type:`button`,className:`link`,onClick:c,children:l(`review.help`)})]})}function k({onClose:e}){let{t}=D();return(0,O.jsx)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcut.title`),children:(0,O.jsxs)(`div`,{className:`modal__box`,children:[(0,O.jsx)(`h3`,{children:t(`shortcut.title`)}),(0,O.jsx)(`table`,{className:`shortcuts`,children:(0,O.jsx)(`tbody`,{children:De.map(e=>(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`td`,{children:(0,O.jsx)(`kbd`,{children:e.keys})}),(0,O.jsx)(`td`,{children:t(e.msgId)})]},e.keys))})}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:e,children:t(`shortcut.close`)})]})})}function Kt({traces:e,state:t,index:n,onSelect:r}){let{t:i}=D();return(0,O.jsxs)(`nav`,{className:`trace-list`,"aria-label":i(`review.list`),children:[(0,O.jsx)(`h3`,{children:i(`review.list`)}),(0,O.jsx)(`ol`,{children:e.map((e,a)=>{let o=t.annotations[e.id]?.verdict??`none`;return(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:`trace-list__item ${a===n?`is-current`:``}`,"aria-current":a===n?`true`:void 0,onClick:()=>r(a),children:[(0,O.jsx)(`span`,{className:`dot dot--${o}`,title:i(`verdict.${o}`)}),(0,O.jsx)(`span`,{className:`trace-list__id`,children:e.id})]})},e.id)})})]})}var qt=800;function Jt({text:e,pre:t=!1}){let{t:n}=D(),[r,i]=(0,l.useState)(!1),a=e.length>qt,o=a&&!r?e.slice(0,qt)+`…`:e;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t?`pre`:`div`,{className:`long-text`,children:o||(0,O.jsx)(`em`,{className:`muted`,children:n(`msg.empty`)})}),a&&(0,O.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>i(!r),children:n(r?`msg.showLess`:`msg.showMore`)})]})}function Yt(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Xt({call:e,result:t}){let{t:n}=D();return(0,O.jsxs)(`details`,{className:`tool-pair`,open:!0,children:[(0,O.jsxs)(`summary`,{children:[(0,O.jsx)(`span`,{className:`tool-pair__tag`,children:n(`msg.toolCall`)}),` `,(0,O.jsx)(`code`,{children:e.name||`?`})]}),(0,O.jsx)(`pre`,{className:`tool-pair__args`,children:Yt(e.args)||`{}`}),(0,O.jsxs)(`div`,{className:`tool-pair__result`,children:[(0,O.jsx)(`span`,{className:`tool-pair__tag`,children:n(`msg.toolResult`)}),t?(0,O.jsx)(Jt,{text:Yt(t.text),pre:!0}):(0,O.jsx)(`em`,{className:`muted`,children:n(`msg.noResult`)})]})]})}var Zt=new Set([`system`,`user`,`assistant`,`tool`]);function Qt({trace:e,position:t,total:n}){let{t:r}=D(),i=new Map;for(let t of e.messages)t.toolResultFor&&i.set(t.toolResultFor,t);let a=new Set(e.messages.flatMap(e=>e.toolCalls.map(e=>e.id)).filter(e=>i.has(e))),o=e=>Zt.has(e)?r(`role.${e}`):e||`?`;return(0,O.jsxs)(`article`,{className:`trace-view`,children:[(0,O.jsxs)(`header`,{className:`trace-view__head`,children:[(0,O.jsx)(`span`,{className:`muted`,children:r(`review.position`,{i:t,n})}),(0,O.jsx)(`code`,{className:`trace-view__id`,children:e.id}),(0,O.jsx)(`span`,{className:`chip`,children:e.source}),e.spanCount>0&&(0,O.jsx)(`span`,{className:`muted small`,children:r(`review.spans`,{n:e.spanCount})})]}),e.contentMissing&&(0,O.jsx)(`p`,{className:`notice`,role:`note`,children:r(`review.contentMissing`)}),e.messages.map((e,t)=>{if(e.toolResultFor&&a.has(e.toolResultFor))return null;let n=Zt.has(e.role)?e.role:`other`;return(0,O.jsxs)(`div`,{className:`bubble bubble--${n}`,children:[(0,O.jsx)(`div`,{className:`bubble__role`,children:o(e.role)}),(e.text||e.toolCalls.length===0)&&(0,O.jsx)(Jt,{text:e.text,pre:e.role===`tool`}),e.toolCalls.map((e,t)=>(0,O.jsx)(Xt,{call:e,result:i.get(e.id)},e.id||t))]},t)})]})}var $t=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.tagName===`SELECT`||e.isContentEditable),en=()=>new Date().toISOString();function A({traces:e,state:t,dispatch:n,index:r,setIndex:i,now:a=en}){let o=(0,l.useRef)(null),[s,c]=(0,l.useState)(!1),u=e[r],d=(0,l.useRef)({trace:u,index:r,state:t,traces:e,help:s,dispatch:n,setIndex:i,now:a});if((0,l.useLayoutEffect)(()=>{d.current={trace:u,index:r,state:t,traces:e,help:s,dispatch:n,setIndex:i,now:a}}),(0,l.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;let t=C(e.key);if(!t)return;if($t(e.target)){t.kind===`escape`&&e.target.blur();return}let{trace:n,index:r,state:i,traces:a,help:s,dispatch:l,setIndex:u,now:f}=d.current;if(t.kind===`help`)return c(!s);if(t.kind===`escape`)return c(!1);if(!n)return;let p={traceId:n.id,source:n.source,at:f()};switch(t.kind){case`verdict`:l({type:`verdict`,verdict:t.verdict,...p});break;case`move`:u(Math.min(a.length-1,Math.max(0,r+t.delta)));break;case`focusNote`:e.preventDefault(),o.current?.focus();break;case`assignIndex`:{let e=i.modes[t.index];e&&l({type:`assign`,modeId:e.id,...p});break}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),!u)return null;let f=()=>({traceId:u.id,source:u.source,at:a()});return(0,O.jsxs)(`div`,{className:`review`,children:[(0,O.jsx)(Kt,{traces:e,state:t,index:r,onSelect:i}),(0,O.jsx)(Qt,{trace:u,position:r+1,total:e.length}),(0,O.jsx)(Gt,{annotation:t.annotations[u.id],modes:t.modes,noteRef:o,onVerdict:e=>n({type:`verdict`,verdict:e,...f()}),onNote:e=>n({type:`note`,note:e,...f()}),onMode:e=>n({type:`assign`,modeId:e,...f()}),onPrev:()=>i(Math.max(0,r-1)),onNext:()=>i(Math.min(e.length-1,r+1)),onHelp:()=>c(!0)}),s&&(0,O.jsx)(k,{onClose:()=>c(!1)})]})}function tn(e,t=20){let n=Ee(e),r=new Map;n.forEach((e,t)=>{e.verdict===`fail`&&e.modeId&&!r.has(e.modeId)&&r.set(e.modeId,t+1)});let i=[...r.values()].sort((e,t)=>e-t),a=[],o=0;for(let e=1;e<=n.length;e++){for(;o<i.length&&i[o]<=e;)o++;a.push({n:e,modes:o})}let s=i[i.length-1]??0,c=i.length>0&&n.length-s>=t;return{points:a,firstSeen:i,reviewed:n.length,saturated:c}}var nn=560,rn=220,j={l:40,r:16,t:12,b:36};function an({data:e}){let{t}=D(),n=Math.max(1,e.reviewed),r=Math.max(1,e.firstSeen.length),i=e=>j.l+e/n*(nn-j.l-j.r),a=e=>rn-j.b-e/r*(rn-j.t-j.b),o=`M ${i(0)} ${a(0)}`,s=0;for(let t of e.points)t.modes!==s&&(o+=` L ${i(t.n)} ${a(s)} L ${i(t.n)} ${a(t.modes)}`),s=t.modes;o+=` L ${i(n)} ${a(s)}`;let c=Array.from({length:r+1},(e,t)=>t),l=[0,Math.round(n/2),n];return(0,O.jsxs)(`svg`,{className:`sat-chart`,viewBox:`0 0 ${nn} ${rn}`,role:`img`,"aria-label":t(`stats.saturation`),children:[c.map(e=>(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:j.l,x2:nn-j.r,y1:a(e),y2:a(e),className:`sat-chart__grid`}),(0,O.jsx)(`text`,{x:j.l-8,y:a(e)+4,textAnchor:`end`,className:`sat-chart__tick`,children:e})]},`y${e}`)),l.map(e=>(0,O.jsx)(`text`,{x:i(e),y:rn-j.b+16,textAnchor:`middle`,className:`sat-chart__tick`,children:e},`x${e}`)),(0,O.jsx)(`path`,{d:o,className:`sat-chart__line`}),e.firstSeen.map((e,t)=>(0,O.jsx)(`circle`,{cx:i(e),cy:a(t+1),r:4,className:`sat-chart__dot`},t)),(0,O.jsx)(`text`,{x:(nn+j.l)/2,y:216,textAnchor:`middle`,className:`sat-chart__axis`,children:t(`stats.axisX`)}),(0,O.jsx)(`text`,{x:12,y:j.t+4,className:`sat-chart__axis`,transform:`rotate(-90 12 ${j.t+4})`,textAnchor:`end`,children:t(`stats.axisY`)})]})}function on({state:e,total:t}){let{t:n}=D(),r=T(e),i=[...Me(e)].sort((e,t)=>t.count-e.count),a=Math.max(1,...i.map(e=>e.count)),o=tn(e),s=Ne(e);return(0,O.jsxs)(`div`,{className:`stats`,children:[(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.verdicts`)}),(0,O.jsx)(`p`,{className:`muted`,children:n(`stats.reviewed`,{reviewed:r.reviewed,total:t})}),(0,O.jsxs)(`div`,{className:`verdict-counts`,children:[(0,O.jsxs)(`span`,{className:`chip chip--pass`,children:[n(`verdict.pass`),` `,r.pass]}),(0,O.jsxs)(`span`,{className:`chip chip--fail`,children:[n(`verdict.fail`),` `,r.fail]}),(0,O.jsxs)(`span`,{className:`chip chip--defer`,children:[n(`verdict.defer`),` `,r.defer]})]})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.modes`)}),i.length===0?(0,O.jsx)(`p`,{className:`muted`,children:n(`stats.noModes`)}):(0,O.jsxs)(`table`,{className:`bars`,children:[(0,O.jsx)(`thead`,{children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{children:n(`review.mode`)}),(0,O.jsx)(`th`,{children:n(`stats.count`)}),(0,O.jsx)(`th`,{children:n(`stats.share`)})]})}),(0,O.jsx)(`tbody`,{children:i.map(e=>(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`td`,{children:e.mode.name}),(0,O.jsxs)(`td`,{className:`bars__cell`,children:[(0,O.jsx)(`span`,{className:`bars__bar`,style:{width:`${e.count/a*100}%`}}),(0,O.jsx)(`span`,{className:`bars__num`,children:e.count})]}),(0,O.jsxs)(`td`,{children:[(e.share*100).toFixed(1),`%`]})]},e.mode.id))})]}),s>0&&(0,O.jsx)(`p`,{className:`muted small`,children:n(`stats.unassigned`,{n:s})})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.saturation`)}),(0,O.jsx)(`p`,{className:`muted small`,children:n(`stats.saturationHelp`)}),(0,O.jsx)(`p`,{className:`badge ${o.saturated?`badge--on`:`badge--off`}`,"data-saturated":o.saturated,children:o.saturated?n(`stats.saturated`):n(`stats.notSaturated`,{window:20})}),(0,O.jsx)(an,{data:o})]})]})}var sn=`support-agent.jsonl`,cn=`__trace/`;function ln(){let{t:e}=D(),[t,n]=(0,l.useState)(null),[r,i]=(0,l.useReducer)(Te,void 0,Ce),[a,o]=(0,l.useState)(`review`),[s,c]=(0,l.useState)(0),[u,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(null),v=(0,l.useRef)(null),y=(0,l.useRef)(!1),b=(0,l.useRef)(null),ee=(0,l.useCallback)(()=>(b.current||=Tt().then(e=>(v.current=e,e)).catch(t=>(b.current=null,_(e(`save.failed`,{message:t.message})),null)),b.current),[e]),te=(0,l.useRef)(Promise.resolve()),ne=(0,l.useCallback)(async(t,r,a)=>{d(r),p(null),h(null),y.current=!1;try{let{records:s,skipped:l}=await _e(ve(t)),{format:u,traces:d}=Se(s);if(!u||d.length===0)throw Error(e(`error.empty`));let f=await Oe(t),p=await ee(),m=p?await p.load(f).catch(()=>void 0):void 0;i({type:`replace`,state:m?.state??Ce()}),n({name:r,format:u,traces:d,skipped:l,fingerprint:f,isSample:a,resumed:!!m}),c(0),o(`review`),y.current=!0}catch(t){p(e(`error.read`,{message:t.message}))}finally{d(null)}},[ee,e]),re=(0,l.useCallback)(async(t,n,r)=>{try{let e=await fetch(t);if(!e.ok)throw Error(String(e.status));await ne(await e.blob(),n,r)}catch{p(e(`error.fetch`,{name:n}))}},[ne,e]);(0,l.useEffect)(()=>{let e=new URLSearchParams(location.search).get(`trace`);e&&e.startsWith(cn)&&!e.includes(`..`)&&re(`./${e}`,decodeURIComponent(e.slice(8)),!1)},[]);let x=(0,l.useRef)(!1),ie=(0,l.useRef)({file:t,state:r});(0,l.useLayoutEffect)(()=>{ie.current={file:t,state:r}}),(0,l.useEffect)(()=>{if(!t||!y.current)return;x.current=!0;let n=setTimeout(async()=>{x.current=!1;let n=await ee();if(n)try{let e=n.save(t.fingerprint,t.name,r);te.current=e.catch(()=>{}),await e,_(null)}catch(t){_(e(`save.failed`,{message:t.message}))}},300);return()=>clearTimeout(n)},[r,t,ee,e]),(0,l.useEffect)(()=>{let e=()=>{let{file:e,state:t}=ie.current,n=v.current;e&&y.current&&n&&(te.current=n.save(e.fingerprint,e.name,t).catch(()=>{}))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),x.current&&(x.current=!1,e())}},[]),(0,l.useEffect)(()=>()=>{let e=b.current;b.current=null,v.current=null,te.current.then(()=>e).then(e=>e?.close())},[]);let S=(0,l.useMemo)(()=>new Map(t?.traces.map(e=>[e.id,e.source])??[]),[t]),ae=t=>{let n=t.kind===`taxonomy`?e(`export.importTaxonomy`,{imported:t.imported}):e(`export.importDone`,{imported:t.imported,kept:t.kept,unmatched:t.unmatched});return t.badLines.length?`${n} ${e(`export.importBad`,{n:t.badLines.length})}`:n},oe=e=>{let t=ie.current.state,n=[];for(let r of e){let{state:e,report:i}=Je(t,r,S);t=e,n.push(ae(i))}i({type:`replace`,state:t}),h(n.join(` `))},se=async()=>{try{let[e,t]=await Promise.all([fetch(`./samples/support-agent.annotations.jsonl`).then(e=>e.text()),fetch(`./samples/support-agent.taxonomy.csv`).then(e=>e.text())]);oe([e,t])}catch{p(e(`error.fetch`,{name:`support-agent.annotations.jsonl`}))}},ce=t?.traces.filter(e=>e.contentMissing).length??0;return(0,O.jsxs)(`div`,{className:`app`,children:[(0,O.jsxs)(`header`,{className:`app__head`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h1`,{children:e(`app.title`)}),(0,O.jsx)(`p`,{className:`muted small`,children:e(`app.tagline`)})]}),(0,O.jsx)(Ut,{})]}),g&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:g}),t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`summary`,"aria-live":`polite`,children:[(0,O.jsx)(`span`,{className:`summary__name`,children:t.name}),(0,O.jsxs)(`span`,{className:`chip`,children:[e(`summary.format`),`: `,(0,O.jsx)(`code`,{"data-testid":`format`,children:t.format})]}),(0,O.jsx)(`span`,{className:`chip`,children:e(`summary.traces`,{n:t.traces.length})}),(0,O.jsx)(`span`,{className:`chip ${t.skipped.length?`chip--fail`:``}`,children:e(`summary.skipped`,{n:t.skipped.length})}),t.isSample&&(0,O.jsx)(`span`,{className:`chip chip--sample`,children:e(`sample.badge`)}),(0,O.jsx)(`span`,{className:`summary__spacer`}),t.isSample&&(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void se(),children:e(`summary.loadExample`)}),(0,O.jsx)(Ht,{state:r,baseName:t.name.replace(/\.[^.]+$/,``),onImport:e=>oe([e])}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n(null),children:e(`summary.openOther`)})]}),t.skipped.length>0&&(0,O.jsx)(`p`,{className:`muted small`,children:e(`summary.skippedList`,{lines:t.skipped.slice(0,20).map(e=>e.line).join(`, `)})}),t.resumed&&(0,O.jsx)(`p`,{className:`muted small`,children:e(`summary.resumed`)}),t.isSample&&(0,O.jsx)(`p`,{className:`notice small`,children:e(`drop.sampleNotice`)}),ce>0&&(0,O.jsx)(`p`,{className:`notice`,children:e(`summary.contentMissing`,{n:ce})}),m&&(0,O.jsx)(`p`,{className:`ok small`,children:m}),f&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:f}),(0,O.jsx)(`nav`,{className:`tabs`,role:`tablist`,children:[`review`,`axial`,`stats`].map(t=>(0,O.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===t,className:`tab ${a===t?`is-active`:``}`,onClick:()=>o(t),children:e(`tab.${t}`)},t))}),a===`review`&&(0,O.jsx)(A,{traces:t.traces,state:r,dispatch:i,index:s,setIndex:c}),a===`axial`&&(0,O.jsx)(zt,{state:r,dispatch:i,sourceOf:e=>S.get(e)??``,onOpen:e=>{let n=t?.traces.findIndex(t=>t.id===e)??-1;n>=0&&(c(n),o(`review`))}}),a===`stats`&&(0,O.jsx)(on,{state:r,total:t.traces.length})]}):(0,O.jsx)(Bt,{busy:u,error:f,onFile:e=>void ne(e,e.name,!1),onSample:()=>void re(`./samples/${sn}`,sn,!0)}),!t&&(0,O.jsx)(`nav`,{className:`tabs tabs--idle`,children:[`review`,`axial`,`stats`].map(t=>(0,O.jsx)(`span`,{className:`tab tab--disabled`,children:e(`tab.${t}`)},t))})]})}(0,u.createRoot)(document.getElementById(`root`)).render((0,O.jsx)(l.StrictMode,{children:(0,O.jsx)(Pt,{children:(0,O.jsx)(ln,{})})}));
|
|
20
|
+
`).forEach((e,r)=>{if(e.trim())try{let i=JSON.parse(e);i&&typeof i==`object`&&typeof i.trace_id==`string`?t.push(i):n.push(r+1)}catch{n.push(r+1)}}),{rows:t,badLines:n}}function qe(e,t){let[n,...r]=je(t),i=e=>n.indexOf(e),a=e,o=0;for(let e of r){let t=(e[i(`failure_mode`)]??``).trim();if(!t)continue;let n;[a,n]=We(a,t),a=Te(a,{type:`editMode`,modeId:n,definition:e[i(`definition`)]??``}),o++}return{state:a,report:{kind:`taxonomy`,imported:o,kept:0,unmatched:0,badLines:[]}}}function Je(e,t,n){let r=t.replace(/^/,``).split(/\r?\n/,1)[0].trim();if(r.startsWith(`failure_mode,definition,count,share_of_failures,example_trace_ids`.split(`,`).slice(0,2).join(`,`)))return qe(e,t);if(r===`trace_id,verdict,failure_mode`){let[,...r]=je(t);return Ge(e,r.map(e=>({trace_id:e[0],verdict:e[1]||null,failure_mode:e[2]||null})),n,`labels`)}let{rows:i,badLines:a}=Ke(t);return Ge(e,i,n,`annotations`,a)}var Ye=(e,t)=>t.some(t=>e instanceof t),Xe,Ze;function Qe(){return Xe||=[IDBIndex,IDBObjectStore,IDBCursor,IDBDatabase,IDBTransaction]}function $e(){return Ze||=[`advance`,`continue`,`continuePrimaryKey`].map(e=>IDBCursor.prototype[e])}var et=new WeakMap,tt=new WeakMap,nt=new WeakMap;function rt(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(lt(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return nt.set(t,e),t}function it(e){if(et.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});et.set(e,t)}var at={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return et.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return lt(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)||t in e}};function ot(e){at=e(at)}function st(e){return $e().includes(e)?function(...t){return e.apply(ut(this),t),lt(this.request)}:function(...t){return lt(e.apply(ut(this),t))}}function ct(e){return typeof e==`function`?st(e):(e instanceof IDBTransaction&&it(e),Ye(e,Qe())?new Proxy(e,at):e)}function lt(e){if(e instanceof IDBRequest)return rt(e);if(tt.has(e))return tt.get(e);let t=ct(e);return Object.is(t,e)||(tt.set(e,t),nt.set(t,e)),t}var ut=e=>nt.get(e);function dt(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=lt(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(lt(o.result),e.oldVersion,e.newVersion,lt(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var ft=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],pt=[`put`,`add`,`delete`,`clear`],mt={};function ht(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(mt[t])return mt[t];let n=t.replace(/FromIndex$/,``),r=t!==n,i=pt.includes(n);return!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||ft.includes(n))?void 0:mt[t]=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]}}ot(e=>({...e,get:(t,n,r)=>ht(t,n)||e.get(t,n,r),has:(t,n)=>!!ht(t,n)||e.has(t,n)}));var gt=[`advance`,`continue`,`continuePrimaryKey`],_t={},vt=new WeakMap,yt=new WeakMap,bt={get(e,t){if(!gt.includes(t))return e[t];let n=_t[t];return n||=_t[t]=function(...e){vt.set(this,yt.get(this)[t](...e))},n}};async function*xt(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,bt);for(yt.set(n,t),nt.set(n,ut(t));t;)yield n,t=await(vt.get(n)||t.continue()),vt.delete(n)}function St(e,t){return t===Symbol.asyncIterator&&Ye(e,[IDBIndex,IDBObjectStore,IDBCursor])||t===`iterate`&&Ye(e,[IDBIndex,IDBObjectStore])}ot(e=>({...e,get(t,n,r){return St(t,n)?xt:e.get(t,n,r)},has(t,n){return St(t,n)||e.has(t,n)}}));var Ct=`trace-codebook`,wt=1;async function Tt(e=Ct){let t=await dt(e,wt,{upgrade(e){e.createObjectStore(`projects`,{keyPath:`fingerprint`})}});return{load:e=>t.get(`projects`,e),async save(e,n,r){await t.put(`projects`,{fingerprint:e,fileName:n,savedAt:new Date().toISOString(),state:r})},list:()=>t.getAll(`projects`),remove:e=>t.delete(`projects`,e),close:()=>t.close()}}var Et={en:{"app.title":`trace-codebook`,"app.tagline":`Read LLM traces, write notes, group them into failure modes, and count them.`,"lang.label":`Language`,"tab.review":`Review`,"tab.axial":`Axial coding`,"tab.stats":`Stats`,"drop.title":`Open a trace file`,"drop.hint":`Drop a file here or choose one. Supported: OpenAI / Anthropic message JSONL, OTLP JSON, Langfuse trace JSON, Phoenix span JSONL.`,"drop.choose":`Choose file…`,"drop.sample":`Try sample traces`,"drop.sampleNotice":`The sample traces are synthetic practice data written for this project (a fictional support agent), not real user logs.`,"drop.privacy":`Your file never leaves this browser tab. Notes are saved in this browser (IndexedDB).`,"drop.loading":`Reading {name}…`,"error.read":`Could not read this file: {message}`,"error.empty":`No records found in this file.`,"error.emptyBroken":`No records found: {n} broken lines ({lines})`,"error.fetch":`Could not load {name}.`,"summary.format":`Format`,"summary.traces":`{n} traces`,"summary.skipped":`{n} broken lines`,"summary.skippedList":`Skipped lines: {lines}`,"summary.resumed":`Resumed your saved notes for this file.`,"summary.openOther":`Open another file`,"summary.loadExample":`Load example annotations`,"summary.contentMissing":`{n} traces have spans but no message content — check the content capture setting of your instrumentation.`,"sample.badge":`Practice mode — synthetic sample data`,"review.list":`Traces`,"review.position":`{i} / {n}`,"review.spans":`{n} spans`,"review.contentMissing":`This trace has spans but no message content. Most instrumentations record content only when you opt in — check the content capture setting.`,"review.verdict":`Verdict`,"review.note":`Note — the first thing that went wrong`,"review.notePlaceholder":`e.g. quoted a 30-day refund window; the policy says 14 days`,"review.mode":`Failure mode`,"review.modeNone":`— none —`,"review.prev":`Previous (K)`,"review.next":`Next (J)`,"review.help":`Shortcuts (?)`,"review.hint":`P pass · F fail · D defer · J/K move · N note · 1–9 mode · ? help`,"verdict.pass":`Pass`,"verdict.fail":`Fail`,"verdict.defer":`Defer`,"verdict.none":`Not reviewed`,"role.system":`System`,"role.user":`User`,"role.assistant":`Assistant`,"role.tool":`Tool`,"msg.showMore":`Show more`,"msg.showLess":`Show less`,"msg.toolCall":`Tool call`,"msg.toolResult":`Result`,"msg.noResult":`No result recorded`,"msg.empty":`(empty)`,"shortcut.title":`Keyboard shortcuts`,"shortcut.pass":`Mark as pass`,"shortcut.fail":`Mark as fail`,"shortcut.defer":`Defer (decide later)`,"shortcut.next":`Next trace`,"shortcut.prev":`Previous trace`,"shortcut.note":`Focus the note field`,"shortcut.mode":`Assign the Nth failure mode (marks as fail)`,"shortcut.help":`Show or hide this help`,"shortcut.escape":`Leave the note field / close help`,"shortcut.close":`Close`,"axial.intro":`Drag failure notes into a column, or pick a mode on each card. A note belongs to one mode only.`,"axial.unassigned":`Unassigned failures`,"axial.newMode":`New failure mode`,"axial.newModePlaceholder":`Mode name, e.g. Policy hallucination`,"axial.add":`Add`,"axial.name":`Name`,"axial.definition":`Definition`,"axial.definitionPlaceholder":`When does a trace belong here?`,"axial.delete":`Delete mode`,"axial.count":`{n} notes`,"axial.empty":`No failures yet. Mark traces as Fail in Review first.`,"axial.moveTo":`Mode`,"axial.noNote":`(no note)`,"axial.dropHere":`Drop notes here`,"stats.verdicts":`Verdicts`,"stats.reviewed":`{reviewed} of {total} traces reviewed`,"stats.modes":`Failure modes`,"stats.count":`Count`,"stats.share":`Share of failures`,"stats.unassigned":`{n} failures without a mode`,"stats.noModes":`No failure modes yet.`,"stats.saturation":`Saturation`,"stats.saturationHelp":`x = traces reviewed, y = failure modes found so far. When the line goes flat, new failure modes stopped appearing.`,"stats.saturated":`Saturated — new failure modes stopped appearing`,"stats.notSaturated":`Not saturated yet — keep reading until {window} reviews pass without a new mode`,"stats.axisX":`traces reviewed`,"stats.axisY":`failure modes`,"export.title":`Export / import`,"export.annotations":`Annotations (JSONL)`,"export.taxonomyCsv":`Taxonomy (CSV)`,"export.taxonomyMd":`Taxonomy (Markdown)`,"export.labels":`Labels (CSV)`,"export.import":`Import annotations…`,"export.importDone":`Imported {imported}, kept {kept} newer local notes, {unmatched} unknown trace ids.`,"export.importTaxonomy":`Imported {imported} failure mode definitions.`,"export.importBad":`{n} lines could not be read.`,"save.failed":`Could not save to this browser ({message}). Your notes are still in memory — export annotations JSONL as a backup.`,"md.title":`Failure mode taxonomy`,"md.summary":`Reviewed {reviewed} traces: {pass} pass, {fail} fail, {defer} defer.`,"md.header":`| Failure mode | Definition | Count | Share of failures | Examples |`,"md.unassigned":`Failures without a mode: {n}`},ko:{"app.title":`trace-codebook`,"app.tagline":`LLM 트레이스를 읽고, 메모하고, 실패 유형으로 묶고, 세어 봅니다.`,"lang.label":`언어`,"tab.review":`검토`,"tab.axial":`축 코딩`,"tab.stats":`통계`,"drop.title":`트레이스 파일 열기`,"drop.hint":`파일을 여기에 끌어 놓거나 고르세요. 지원 형식: OpenAI / Anthropic 메시지 JSONL, OTLP JSON, Langfuse 트레이스 JSON, Phoenix span JSONL.`,"drop.choose":`파일 고르기…`,"drop.sample":`샘플 트레이스로 해 보기`,"drop.sampleNotice":`샘플 트레이스는 이 프로젝트용으로 직접 만든 가상의 연습용 데이터입니다(가상의 고객지원 에이전트, 실제 사용자 기록 아님).`,"drop.privacy":`파일은 이 브라우저 탭 밖으로 나가지 않습니다. 메모는 이 브라우저(IndexedDB)에 저장됩니다.`,"drop.loading":`{name} 읽는 중…`,"error.read":`이 파일을 읽지 못했습니다: {message}`,"error.empty":`이 파일에서 레코드를 찾지 못했습니다.`,"error.emptyBroken":`레코드를 찾지 못했습니다: 깨진 줄 {n}개 ({lines})`,"error.fetch":`{name} 을(를) 불러오지 못했습니다.`,"summary.format":`형식`,"summary.traces":`트레이스 {n}건`,"summary.skipped":`깨진 줄 {n}개`,"summary.skippedList":`건너뛴 줄: {lines}`,"summary.resumed":`이 파일에 저장해 둔 메모를 이어서 열었습니다.`,"summary.openOther":`다른 파일 열기`,"summary.loadExample":`예시 주석 불러오기`,"summary.contentMissing":`트레이스 {n}건은 span 만 있고 메시지 내용이 없습니다 — 계측 도구의 content capture 설정을 확인하세요.`,"sample.badge":`연습 모드 — 가상 샘플 데이터`,"review.list":`트레이스`,"review.position":`{i} / {n}`,"review.spans":`span {n}개`,"review.contentMissing":`이 트레이스는 span 만 있고 메시지 내용이 없습니다. 대부분의 계측 도구는 직접 켜야 내용을 기록합니다 — content capture 설정을 확인하세요.`,"review.verdict":`판정`,"review.note":`메모 — 처음 잘못된 지점`,"review.notePlaceholder":`예: 환불 기간을 30일이라고 답함, 정책은 14일`,"review.mode":`실패 유형`,"review.modeNone":`— 없음 —`,"review.prev":`이전 (K)`,"review.next":`다음 (J)`,"review.help":`단축키 (?)`,"review.hint":`P 통과 · F 실패 · D 보류 · J/K 이동 · N 메모 · 1–9 유형 · ? 도움말`,"verdict.pass":`통과`,"verdict.fail":`실패`,"verdict.defer":`보류`,"verdict.none":`미검토`,"role.system":`시스템`,"role.user":`사용자`,"role.assistant":`어시스턴트`,"role.tool":`도구`,"msg.showMore":`더 보기`,"msg.showLess":`접기`,"msg.toolCall":`도구 호출`,"msg.toolResult":`결과`,"msg.noResult":`기록된 결과 없음`,"msg.empty":`(비어 있음)`,"shortcut.title":`단축키`,"shortcut.pass":`통과로 판정`,"shortcut.fail":`실패로 판정`,"shortcut.defer":`보류(나중에 판단)`,"shortcut.next":`다음 트레이스`,"shortcut.prev":`이전 트레이스`,"shortcut.note":`메모 칸으로 이동`,"shortcut.mode":`N번째 실패 유형 붙이기(실패로 판정)`,"shortcut.help":`이 도움말 열기·닫기`,"shortcut.escape":`메모 칸에서 나가기 / 도움말 닫기`,"shortcut.close":`닫기`,"axial.intro":`실패 메모 카드를 열로 끌어 놓거나 카드마다 유형을 고르세요. 메모 하나는 한 유형에만 속합니다.`,"axial.unassigned":`미분류 실패`,"axial.newMode":`새 실패 유형`,"axial.newModePlaceholder":`유형 이름, 예: 정책 지어내기`,"axial.add":`추가`,"axial.name":`이름`,"axial.definition":`정의`,"axial.definitionPlaceholder":`어떤 트레이스가 여기에 속하나요?`,"axial.delete":`유형 삭제`,"axial.count":`메모 {n}개`,"axial.empty":`아직 실패가 없습니다. 먼저 검토 탭에서 실패로 판정하세요.`,"axial.moveTo":`유형`,"axial.noNote":`(메모 없음)`,"axial.dropHere":`여기에 메모를 놓으세요`,"stats.verdicts":`판정`,"stats.reviewed":`트레이스 {total}건 중 {reviewed}건 검토`,"stats.modes":`실패 유형`,"stats.count":`건수`,"stats.share":`실패 대비 비율`,"stats.unassigned":`유형이 없는 실패 {n}건`,"stats.noModes":`아직 실패 유형이 없습니다.`,"stats.saturation":`포화`,"stats.saturationHelp":`x = 검토한 트레이스 수, y = 지금까지 찾은 실패 유형 수. 선이 평평해지면 새 유형이 더는 나오지 않는다는 뜻입니다.`,"stats.saturated":`포화 — 새 실패 유형이 더 나오지 않습니다`,"stats.notSaturated":`아직 포화 아님 — 새 유형 없이 {window}건을 더 검토할 때까지 계속 읽으세요`,"stats.axisX":`검토한 트레이스`,"stats.axisY":`실패 유형`,"export.title":`내보내기 / 가져오기`,"export.annotations":`주석 (JSONL)`,"export.taxonomyCsv":`유형 분류표 (CSV)`,"export.taxonomyMd":`유형 분류표 (Markdown)`,"export.labels":`라벨 (CSV)`,"export.import":`주석 가져오기…`,"export.importDone":`{imported}건 가져옴, 더 새로운 기존 메모 {kept}건 유지, 없는 트레이스 ID {unmatched}개.`,"export.importTaxonomy":`실패 유형 정의 {imported}개를 가져왔습니다.`,"export.importBad":`읽지 못한 줄 {n}개.`,"save.failed":`이 브라우저에 저장하지 못했습니다({message}). 메모는 메모리에 남아 있으니 주석 JSONL 로 내보내 백업하세요.`,"md.title":`실패 유형 분류표`,"md.summary":`트레이스 {reviewed}건 검토: 통과 {pass}, 실패 {fail}, 보류 {defer}.`,"md.header":`| 실패 유형 | 정의 | 건수 | 실패 대비 비율 | 예시 |`,"md.unassigned":`유형이 없는 실패: {n}건`}},Dt=`trace-codebook.lang`,Ot=e=>e===`en`||e===`ko`;function kt(e){return(e?.[0]??``).toLowerCase().startsWith(`ko`)?`ko`:`en`}function At(){try{let e=globalThis.localStorage?.getItem(Dt);return Ot(e)?e:null}catch{return null}}function jt(){let e=typeof location<`u`?new URLSearchParams(location.search).get(`lang`):null;return Ot(e)?e:At()??kt(typeof navigator<`u`?navigator.languages:void 0)}function Mt(e,t,n){let r=Et[e][t]??Et.en[t]??t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>t in n?String(n[t]):e):r}var Nt=(0,l.createContext)({lang:`en`,setLang:()=>{},t:(e,t)=>Mt(`en`,e,t)});function Pt({children:e,initial:t}){let[n,r]=(0,l.useState)(()=>t??jt()),i=(0,l.useCallback)(e=>{r(e);try{globalThis.localStorage?.setItem(Dt,e)}catch{}typeof document<`u`&&(document.documentElement.lang=e)},[]),a=(0,l.useMemo)(()=>({lang:n,setLang:i,t:(e,t)=>Mt(n,e,t)}),[n,i]);return(0,l.createElement)(Nt.Provider,{value:a},e)}var D=()=>(0,l.useContext)(Nt),Ft=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),O=e(((e,t)=>{t.exports=Ft()}))(),It=`text/plain`;function Lt({annotation:e,modes:t,onAssign:n,onOpen:r}){let{t:i}=D();return(0,O.jsxs)(`div`,{className:`note-card`,draggable:!0,onDragStart:t=>{t.dataTransfer.setData(It,e.traceId),t.dataTransfer.effectAllowed=`move`},"data-trace-id":e.traceId,children:[(0,O.jsx)(`button`,{type:`button`,className:`link note-card__id`,onClick:()=>r(e.traceId),children:e.traceId}),(0,O.jsx)(`p`,{className:`note-card__text`,children:e.note||(0,O.jsx)(`em`,{className:`muted`,children:i(`axial.noNote`)})}),(0,O.jsxs)(`select`,{"aria-label":`${i(`axial.moveTo`)}: ${e.traceId}`,value:e.modeId??``,onChange:t=>n(e.traceId,t.target.value||null),children:[(0,O.jsx)(`option`,{value:``,children:i(`axial.unassigned`)}),t.map(e=>(0,O.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function Rt({mode:e,count:t,onDropCard:n,onRename:r,onDefine:i,onDelete:a,children:o}){let{t:s}=D(),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)(e?.name??``),[p,m]=(0,l.useState)(e?.name);return e&&e.name!==p&&(m(e.name),f(e.name)),(0,O.jsxs)(`section`,{className:`column ${c?`column--over`:``} ${e?``:`column--unassigned`}`,"aria-label":e?e.name:s(`axial.unassigned`),onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1);let t=e.dataTransfer.getData(It);t&&n(t)},children:[(0,O.jsxs)(`header`,{className:`column__head`,children:[e?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`input`,{className:`column__name`,"aria-label":s(`axial.name`),value:d,onChange:e=>f(e.target.value),onBlur:()=>r?.(d),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),(0,O.jsx)(`textarea`,{className:`column__def`,"aria-label":s(`axial.definition`),rows:2,placeholder:s(`axial.definitionPlaceholder`),value:e.definition,onChange:e=>i?.(e.target.value)})]}):(0,O.jsx)(`h3`,{children:s(`axial.unassigned`)}),(0,O.jsxs)(`div`,{className:`column__meta`,children:[(0,O.jsx)(`span`,{className:`muted small`,children:s(`axial.count`,{n:t})}),e&&(0,O.jsx)(`button`,{type:`button`,className:`link danger`,onClick:a,children:s(`axial.delete`)})]})]}),(0,O.jsx)(`div`,{className:`column__cards`,children:t===0?(0,O.jsx)(`p`,{className:`muted small`,children:s(`axial.dropHere`)}):o})]})}function zt({state:e,dispatch:t,sourceOf:n,onOpen:r}){let{t:i}=D(),[a,o]=(0,l.useState)(``),s=(e,r)=>t({type:`assign`,traceId:e,source:n(e),modeId:r,at:new Date().toISOString()}),c=E(e,null),u=c.length+e.modes.reduce((t,n)=>t+E(e,n.id).length,0),d=t=>(0,O.jsx)(Lt,{annotation:t,modes:e.modes,onAssign:s,onOpen:r},t.traceId);return(0,O.jsxs)(`div`,{className:`axial`,children:[(0,O.jsx)(`p`,{className:`muted`,children:i(`axial.intro`)}),u===0&&(0,O.jsx)(`p`,{className:`notice`,children:i(`axial.empty`)}),(0,O.jsxs)(`form`,{className:`axial__new`,onSubmit:e=>{e.preventDefault(),t({type:`addMode`,name:a}),o(``)},children:[(0,O.jsxs)(`label`,{children:[(0,O.jsx)(`span`,{className:`visually-hidden`,children:i(`axial.newMode`)}),(0,O.jsx)(`input`,{value:a,placeholder:i(`axial.newModePlaceholder`),onChange:e=>o(e.target.value)})]}),(0,O.jsx)(`button`,{type:`submit`,className:`btn btn--primary`,disabled:!a.trim(),children:i(`axial.add`)})]}),(0,O.jsxs)(`div`,{className:`board`,children:[(0,O.jsx)(Rt,{mode:null,count:c.length,onDropCard:e=>s(e,null),children:c.map(d)}),e.modes.map(n=>{let r=E(e,n.id);return(0,O.jsx)(Rt,{mode:n,count:r.length,onDropCard:e=>s(e,n.id),onRename:e=>t({type:`editMode`,modeId:n.id,name:e}),onDefine:e=>t({type:`editMode`,modeId:n.id,definition:e}),onDelete:()=>t({type:`deleteMode`,modeId:n.id}),children:r.map(d)},n.id)})]})]})}function Bt({onFile:e,onSample:t,busy:n,error:r}){let{t:i}=D(),a=(0,l.useRef)(null),[o,s]=(0,l.useState)(!1);return(0,O.jsxs)(`section`,{className:`drop ${o?`drop--over`:``}`,onDragOver:e=>{e.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:t=>{t.preventDefault(),s(!1);let n=t.dataTransfer.files?.[0];n&&e(n)},children:[(0,O.jsx)(`h2`,{children:i(`drop.title`)}),(0,O.jsx)(`p`,{className:`muted`,children:i(`drop.hint`)}),(0,O.jsxs)(`div`,{className:`drop__actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn--primary`,onClick:()=>a.current?.click(),children:i(`drop.choose`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:t,children:i(`drop.sample`)})]}),(0,O.jsx)(`input`,{ref:a,type:`file`,accept:`.jsonl,.json,.ndjson,.txt`,hidden:!0,onChange:t=>{let n=t.target.files?.[0];n&&e(n),t.target.value=``}}),(0,O.jsx)(`p`,{className:`notice`,children:i(`drop.sampleNotice`)}),(0,O.jsx)(`p`,{className:`muted small`,children:i(`drop.privacy`)}),n&&(0,O.jsx)(`p`,{className:`muted`,children:i(`drop.loading`,{name:n})}),r&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:r})]})}function Vt(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Ht({state:e,baseName:t,onImport:n}){let{t:r}=D(),i=(0,l.useRef)(null);return(0,O.jsxs)(`details`,{className:`export-menu`,children:[(0,O.jsx)(`summary`,{className:`btn`,children:r(`export.title`)}),(0,O.jsxs)(`div`,{className:`export-menu__list`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.annotations.jsonl`,Re(e),`application/x-ndjson`),children:r(`export.annotations`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.taxonomy.csv`,ze(e),`text/csv`),children:r(`export.taxonomyCsv`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.taxonomy.md`,Ve(e,r),`text/markdown`),children:r(`export.taxonomyMd`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Vt(`${t}.labels.csv`,Be(e),`text/csv`),children:r(`export.labels`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>i.current?.click(),children:r(`export.import`)}),(0,O.jsx)(`input`,{ref:i,type:`file`,accept:`.jsonl,.csv,.json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t&&n(await t.text())}})]})]})}function Ut(){let{lang:e,setLang:t,t:n}=D();return(0,O.jsxs)(`label`,{className:`lang-menu`,children:[(0,O.jsx)(`span`,{className:`lang-menu__label`,children:n(`lang.label`)}),(0,O.jsxs)(`select`,{"aria-label":n(`lang.label`),value:e,onChange:e=>t(e.target.value),children:[(0,O.jsx)(`option`,{value:`en`,children:`English`}),(0,O.jsx)(`option`,{value:`ko`,children:`한국어`})]})]})}var Wt=[`pass`,`fail`,`defer`];function Gt({annotation:e,modes:t,noteRef:n,onVerdict:r,onNote:i,onMode:a,onPrev:o,onNext:s,onHelp:c}){let{t:l}=D(),u=e?.verdict??null;return(0,O.jsxs)(`aside`,{className:`note-panel`,children:[(0,O.jsx)(`h3`,{children:l(`review.verdict`)}),(0,O.jsx)(`div`,{className:`verdicts`,role:`group`,"aria-label":l(`review.verdict`),children:Wt.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`btn verdict verdict--${e}`,"aria-pressed":u===e,onClick:()=>r(e),children:[l(`verdict.${e}`),` `,(0,O.jsx)(`kbd`,{children:e[0].toUpperCase()})]},e))}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:l(`review.note`)}),(0,O.jsx)(`textarea`,{ref:n,rows:4,value:e?.note??``,placeholder:l(`review.notePlaceholder`),onChange:e=>i(e.target.value)})]}),(0,O.jsxs)(`label`,{className:`field`,children:[(0,O.jsx)(`span`,{children:l(`review.mode`)}),(0,O.jsxs)(`select`,{value:u===`fail`?e?.modeId??``:``,onChange:e=>a(e.target.value||null),children:[(0,O.jsx)(`option`,{value:``,children:l(`review.modeNone`)}),t.map((e,t)=>(0,O.jsxs)(`option`,{value:e.id,children:[t<9?`${t+1}. `:``,e.name]},e.id))]})]}),(0,O.jsxs)(`div`,{className:`note-panel__nav`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:l(`review.prev`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:s,children:l(`review.next`)})]}),(0,O.jsx)(`p`,{className:`muted small`,children:l(`review.hint`)}),(0,O.jsx)(`button`,{type:`button`,className:`link`,onClick:c,children:l(`review.help`)})]})}function k({onClose:e}){let{t}=D();return(0,O.jsx)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`shortcut.title`),children:(0,O.jsxs)(`div`,{className:`modal__box`,children:[(0,O.jsx)(`h3`,{children:t(`shortcut.title`)}),(0,O.jsx)(`table`,{className:`shortcuts`,children:(0,O.jsx)(`tbody`,{children:De.map(e=>(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`td`,{children:(0,O.jsx)(`kbd`,{children:e.keys})}),(0,O.jsx)(`td`,{children:t(e.msgId)})]},e.keys))})}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:e,children:t(`shortcut.close`)})]})})}function Kt({traces:e,state:t,index:n,onSelect:r}){let{t:i}=D();return(0,O.jsxs)(`nav`,{className:`trace-list`,"aria-label":i(`review.list`),children:[(0,O.jsx)(`h3`,{children:i(`review.list`)}),(0,O.jsx)(`ol`,{children:e.map((e,a)=>{let o=t.annotations[e.id]?.verdict??`none`;return(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,className:`trace-list__item ${a===n?`is-current`:``}`,"aria-current":a===n?`true`:void 0,onClick:()=>r(a),children:[(0,O.jsx)(`span`,{className:`dot dot--${o}`,title:i(`verdict.${o}`)}),(0,O.jsx)(`span`,{className:`trace-list__id`,children:e.id})]})},e.id)})})]})}var qt=800;function Jt({text:e,pre:t=!1}){let{t:n}=D(),[r,i]=(0,l.useState)(!1),a=e.length>qt,o=a&&!r?e.slice(0,qt)+`…`:e;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(t?`pre`:`div`,{className:`long-text`,children:o||(0,O.jsx)(`em`,{className:`muted`,children:n(`msg.empty`)})}),a&&(0,O.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>i(!r),children:n(r?`msg.showLess`:`msg.showMore`)})]})}function Yt(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Xt({call:e,result:t}){let{t:n}=D();return(0,O.jsxs)(`details`,{className:`tool-pair`,open:!0,children:[(0,O.jsxs)(`summary`,{children:[(0,O.jsx)(`span`,{className:`tool-pair__tag`,children:n(`msg.toolCall`)}),` `,(0,O.jsx)(`code`,{children:e.name||`?`})]}),(0,O.jsx)(`pre`,{className:`tool-pair__args`,children:Yt(e.args)||`{}`}),(0,O.jsxs)(`div`,{className:`tool-pair__result`,children:[(0,O.jsx)(`span`,{className:`tool-pair__tag`,children:n(`msg.toolResult`)}),t?(0,O.jsx)(Jt,{text:Yt(t.text),pre:!0}):(0,O.jsx)(`em`,{className:`muted`,children:n(`msg.noResult`)})]})]})}var Zt=new Set([`system`,`user`,`assistant`,`tool`]);function Qt({trace:e,position:t,total:n}){let{t:r}=D(),i=new Map;for(let t of e.messages)t.toolResultFor&&i.set(t.toolResultFor,t);let a=new Set(e.messages.flatMap(e=>e.toolCalls.map(e=>e.id)).filter(e=>i.has(e))),o=e=>Zt.has(e)?r(`role.${e}`):e||`?`;return(0,O.jsxs)(`article`,{className:`trace-view`,children:[(0,O.jsxs)(`header`,{className:`trace-view__head`,children:[(0,O.jsx)(`span`,{className:`muted`,children:r(`review.position`,{i:t,n})}),(0,O.jsx)(`code`,{className:`trace-view__id`,children:e.id}),(0,O.jsx)(`span`,{className:`chip`,children:e.source}),e.spanCount>0&&(0,O.jsx)(`span`,{className:`muted small`,children:r(`review.spans`,{n:e.spanCount})})]}),e.contentMissing&&(0,O.jsx)(`p`,{className:`notice`,role:`note`,children:r(`review.contentMissing`)}),e.messages.map((e,t)=>{if(e.toolResultFor&&a.has(e.toolResultFor))return null;let n=Zt.has(e.role)?e.role:`other`;return(0,O.jsxs)(`div`,{className:`bubble bubble--${n}`,children:[(0,O.jsx)(`div`,{className:`bubble__role`,children:o(e.role)}),(e.text||e.toolCalls.length===0)&&(0,O.jsx)(Jt,{text:e.text,pre:e.role===`tool`}),e.toolCalls.map((e,t)=>(0,O.jsx)(Xt,{call:e,result:i.get(e.id)},e.id||t))]},t)})]})}var $t=e=>e instanceof HTMLElement&&(e.tagName===`TEXTAREA`||e.tagName===`INPUT`||e.tagName===`SELECT`||e.isContentEditable),en=()=>new Date().toISOString();function A({traces:e,state:t,dispatch:n,index:r,setIndex:i,now:a=en}){let o=(0,l.useRef)(null),[s,c]=(0,l.useState)(!1),u=e[r],d=(0,l.useRef)({trace:u,index:r,state:t,traces:e,help:s,dispatch:n,setIndex:i,now:a});if((0,l.useLayoutEffect)(()=>{d.current={trace:u,index:r,state:t,traces:e,help:s,dispatch:n,setIndex:i,now:a}}),(0,l.useEffect)(()=>{let e=e=>{if(e.ctrlKey||e.metaKey||e.altKey)return;let t=C(e.key);if(!t)return;if($t(e.target)){t.kind===`escape`&&e.target.blur();return}let{trace:n,index:r,state:i,traces:a,help:s,dispatch:l,setIndex:u,now:f}=d.current;if(t.kind===`help`)return c(!s);if(t.kind===`escape`)return c(!1);if(!n)return;let p={traceId:n.id,source:n.source,at:f()};switch(t.kind){case`verdict`:l({type:`verdict`,verdict:t.verdict,...p});break;case`move`:u(Math.min(a.length-1,Math.max(0,r+t.delta)));break;case`focusNote`:e.preventDefault(),o.current?.focus();break;case`assignIndex`:{let e=i.modes[t.index];e&&l({type:`assign`,modeId:e.id,...p});break}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),!u)return null;let f=()=>({traceId:u.id,source:u.source,at:a()});return(0,O.jsxs)(`div`,{className:`review`,children:[(0,O.jsx)(Kt,{traces:e,state:t,index:r,onSelect:i}),(0,O.jsx)(Qt,{trace:u,position:r+1,total:e.length}),(0,O.jsx)(Gt,{annotation:t.annotations[u.id],modes:t.modes,noteRef:o,onVerdict:e=>n({type:`verdict`,verdict:e,...f()}),onNote:e=>n({type:`note`,note:e,...f()}),onMode:e=>n({type:`assign`,modeId:e,...f()}),onPrev:()=>i(Math.max(0,r-1)),onNext:()=>i(Math.min(e.length-1,r+1)),onHelp:()=>c(!0)}),s&&(0,O.jsx)(k,{onClose:()=>c(!1)})]})}function tn(e,t=20){let n=Ee(e),r=new Map;n.forEach((e,t)=>{e.verdict===`fail`&&e.modeId&&!r.has(e.modeId)&&r.set(e.modeId,t+1)});let i=[...r.values()].sort((e,t)=>e-t),a=[],o=0;for(let e=1;e<=n.length;e++){for(;o<i.length&&i[o]<=e;)o++;a.push({n:e,modes:o})}let s=i[i.length-1]??0,c=i.length>0&&n.length-s>=t;return{points:a,firstSeen:i,reviewed:n.length,saturated:c}}var nn=560,rn=220,j={l:40,r:16,t:12,b:36};function an({data:e}){let{t}=D(),n=Math.max(1,e.reviewed),r=Math.max(1,e.firstSeen.length),i=e=>j.l+e/n*(nn-j.l-j.r),a=e=>rn-j.b-e/r*(rn-j.t-j.b),o=`M ${i(0)} ${a(0)}`,s=0;for(let t of e.points)t.modes!==s&&(o+=` L ${i(t.n)} ${a(s)} L ${i(t.n)} ${a(t.modes)}`),s=t.modes;o+=` L ${i(n)} ${a(s)}`;let c=Array.from({length:r+1},(e,t)=>t),l=[0,Math.round(n/2),n];return(0,O.jsxs)(`svg`,{className:`sat-chart`,viewBox:`0 0 ${nn} ${rn}`,role:`img`,"aria-label":t(`stats.saturation`),children:[c.map(e=>(0,O.jsxs)(`g`,{children:[(0,O.jsx)(`line`,{x1:j.l,x2:nn-j.r,y1:a(e),y2:a(e),className:`sat-chart__grid`}),(0,O.jsx)(`text`,{x:j.l-8,y:a(e)+4,textAnchor:`end`,className:`sat-chart__tick`,children:e})]},`y${e}`)),l.map(e=>(0,O.jsx)(`text`,{x:i(e),y:rn-j.b+16,textAnchor:`middle`,className:`sat-chart__tick`,children:e},`x${e}`)),(0,O.jsx)(`path`,{d:o,className:`sat-chart__line`}),e.firstSeen.map((e,t)=>(0,O.jsx)(`circle`,{cx:i(e),cy:a(t+1),r:4,className:`sat-chart__dot`},t)),(0,O.jsx)(`text`,{x:(nn+j.l)/2,y:216,textAnchor:`middle`,className:`sat-chart__axis`,children:t(`stats.axisX`)}),(0,O.jsx)(`text`,{x:12,y:j.t+4,className:`sat-chart__axis`,transform:`rotate(-90 12 ${j.t+4})`,textAnchor:`end`,children:t(`stats.axisY`)})]})}function on({state:e,total:t}){let{t:n}=D(),r=T(e),i=[...Me(e)].sort((e,t)=>t.count-e.count),a=Math.max(1,...i.map(e=>e.count)),o=tn(e),s=Ne(e);return(0,O.jsxs)(`div`,{className:`stats`,children:[(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.verdicts`)}),(0,O.jsx)(`p`,{className:`muted`,children:n(`stats.reviewed`,{reviewed:r.reviewed,total:t})}),(0,O.jsxs)(`div`,{className:`verdict-counts`,children:[(0,O.jsxs)(`span`,{className:`chip chip--pass`,children:[n(`verdict.pass`),` `,r.pass]}),(0,O.jsxs)(`span`,{className:`chip chip--fail`,children:[n(`verdict.fail`),` `,r.fail]}),(0,O.jsxs)(`span`,{className:`chip chip--defer`,children:[n(`verdict.defer`),` `,r.defer]})]})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.modes`)}),i.length===0?(0,O.jsx)(`p`,{className:`muted`,children:n(`stats.noModes`)}):(0,O.jsxs)(`table`,{className:`bars`,children:[(0,O.jsx)(`thead`,{children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{children:n(`review.mode`)}),(0,O.jsx)(`th`,{children:n(`stats.count`)}),(0,O.jsx)(`th`,{children:n(`stats.share`)})]})}),(0,O.jsx)(`tbody`,{children:i.map(e=>(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`td`,{children:e.mode.name}),(0,O.jsxs)(`td`,{className:`bars__cell`,children:[(0,O.jsx)(`span`,{className:`bars__bar`,style:{width:`${e.count/a*100}%`}}),(0,O.jsx)(`span`,{className:`bars__num`,children:e.count})]}),(0,O.jsxs)(`td`,{children:[(e.share*100).toFixed(1),`%`]})]},e.mode.id))})]}),s>0&&(0,O.jsx)(`p`,{className:`muted small`,children:n(`stats.unassigned`,{n:s})})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{children:n(`stats.saturation`)}),(0,O.jsx)(`p`,{className:`muted small`,children:n(`stats.saturationHelp`)}),(0,O.jsx)(`p`,{className:`badge ${o.saturated?`badge--on`:`badge--off`}`,"data-saturated":o.saturated,children:o.saturated?n(`stats.saturated`):n(`stats.notSaturated`,{window:20})}),(0,O.jsx)(an,{data:o})]})]})}var sn=`support-agent.jsonl`,cn=`__trace/`;function ln(){let{t:e}=D(),[t,n]=(0,l.useState)(null),[r,i]=(0,l.useReducer)(Te,void 0,Ce),[a,o]=(0,l.useState)(`review`),[s,c]=(0,l.useState)(0),[u,d]=(0,l.useState)(null),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(null),v=(0,l.useRef)(null),y=(0,l.useRef)(!1),b=(0,l.useRef)(null),ee=(0,l.useCallback)(()=>(b.current||=Tt().then(e=>(v.current=e,e)).catch(t=>(b.current=null,_(e(`save.failed`,{message:t.message})),null)),b.current),[e]),te=(0,l.useRef)(Promise.resolve()),ne=(0,l.useCallback)(async(t,r,a)=>{d(r),p(null),h(null),y.current=!1;try{let{records:s,skipped:l}=await _e(ve(t)),{format:u,traces:d}=Se(s);if(!u||d.length===0){if(l.length===0)throw Error(e(`error.empty`));let t=l.slice(0,20).map(e=>e.line).join(`, `);throw Error(e(`error.emptyBroken`,{n:l.length,lines:t}))}let f=await Oe(t),p=await ee(),m=p?await p.load(f).catch(()=>void 0):void 0;i({type:`replace`,state:m?.state??Ce()}),n({name:r,format:u,traces:d,skipped:l,fingerprint:f,isSample:a,resumed:!!m}),c(0),o(`review`),y.current=!0}catch(t){p(e(`error.read`,{message:t.message}))}finally{d(null)}},[ee,e]),re=(0,l.useCallback)(async(t,n,r)=>{try{let e=await fetch(t);if(!e.ok)throw Error(String(e.status));await ne(await e.blob(),n,r)}catch{p(e(`error.fetch`,{name:n}))}},[ne,e]);(0,l.useEffect)(()=>{let e=new URLSearchParams(location.search).get(`trace`);e&&e.startsWith(cn)&&!e.includes(`..`)&&re(`./${e}`,decodeURIComponent(e.slice(8)),!1)},[]);let x=(0,l.useRef)(!1),ie=(0,l.useRef)({file:t,state:r});(0,l.useLayoutEffect)(()=>{ie.current={file:t,state:r}}),(0,l.useEffect)(()=>{if(!t||!y.current)return;x.current=!0;let n=setTimeout(async()=>{x.current=!1;let n=await ee();if(n)try{let e=n.save(t.fingerprint,t.name,r);te.current=e.catch(()=>{}),await e,_(null)}catch(t){_(e(`save.failed`,{message:t.message}))}},300);return()=>clearTimeout(n)},[r,t,ee,e]),(0,l.useEffect)(()=>{let e=()=>{let{file:e,state:t}=ie.current,n=v.current;e&&y.current&&n&&(te.current=n.save(e.fingerprint,e.name,t).catch(()=>{}))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),x.current&&(x.current=!1,e())}},[]),(0,l.useEffect)(()=>()=>{let e=b.current;b.current=null,v.current=null,te.current.then(()=>e).then(e=>e?.close())},[]);let S=(0,l.useMemo)(()=>new Map(t?.traces.map(e=>[e.id,e.source])??[]),[t]),ae=t=>{let n=t.kind===`taxonomy`?e(`export.importTaxonomy`,{imported:t.imported}):e(`export.importDone`,{imported:t.imported,kept:t.kept,unmatched:t.unmatched});return t.badLines.length?`${n} ${e(`export.importBad`,{n:t.badLines.length})}`:n},oe=e=>{let t=ie.current.state,n=[];for(let r of e){let{state:e,report:i}=Je(t,r,S);t=e,n.push(ae(i))}i({type:`replace`,state:t}),h(n.join(` `))},se=async()=>{try{let[e,t]=await Promise.all([fetch(`./samples/support-agent.annotations.jsonl`).then(e=>e.text()),fetch(`./samples/support-agent.taxonomy.csv`).then(e=>e.text())]);oe([e,t])}catch{p(e(`error.fetch`,{name:`support-agent.annotations.jsonl`}))}},ce=t?.traces.filter(e=>e.contentMissing).length??0;return(0,O.jsxs)(`div`,{className:`app`,children:[(0,O.jsxs)(`header`,{className:`app__head`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h1`,{children:e(`app.title`)}),(0,O.jsx)(`p`,{className:`muted small`,children:e(`app.tagline`)})]}),(0,O.jsx)(Ut,{})]}),g&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:g}),t?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`section`,{className:`summary`,"aria-live":`polite`,children:[(0,O.jsx)(`span`,{className:`summary__name`,children:t.name}),(0,O.jsxs)(`span`,{className:`chip`,children:[e(`summary.format`),`: `,(0,O.jsx)(`code`,{"data-testid":`format`,children:t.format})]}),(0,O.jsx)(`span`,{className:`chip`,children:e(`summary.traces`,{n:t.traces.length})}),(0,O.jsx)(`span`,{className:`chip ${t.skipped.length?`chip--fail`:``}`,children:e(`summary.skipped`,{n:t.skipped.length})}),t.isSample&&(0,O.jsx)(`span`,{className:`chip chip--sample`,children:e(`sample.badge`)}),(0,O.jsx)(`span`,{className:`summary__spacer`}),t.isSample&&(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void se(),children:e(`summary.loadExample`)}),(0,O.jsx)(Ht,{state:r,baseName:t.name.replace(/\.[^.]+$/,``),onImport:e=>oe([e])}),(0,O.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>n(null),children:e(`summary.openOther`)})]}),t.skipped.length>0&&(0,O.jsx)(`p`,{className:`muted small`,children:e(`summary.skippedList`,{lines:t.skipped.slice(0,20).map(e=>e.line).join(`, `)})}),t.resumed&&(0,O.jsx)(`p`,{className:`muted small`,children:e(`summary.resumed`)}),t.isSample&&(0,O.jsx)(`p`,{className:`notice small`,children:e(`drop.sampleNotice`)}),ce>0&&(0,O.jsx)(`p`,{className:`notice`,children:e(`summary.contentMissing`,{n:ce})}),m&&(0,O.jsx)(`p`,{className:`ok small`,children:m}),f&&(0,O.jsx)(`p`,{className:`error`,role:`alert`,children:f}),(0,O.jsx)(`nav`,{className:`tabs`,role:`tablist`,children:[`review`,`axial`,`stats`].map(t=>(0,O.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===t,className:`tab ${a===t?`is-active`:``}`,onClick:()=>o(t),children:e(`tab.${t}`)},t))}),a===`review`&&(0,O.jsx)(A,{traces:t.traces,state:r,dispatch:i,index:s,setIndex:c}),a===`axial`&&(0,O.jsx)(zt,{state:r,dispatch:i,sourceOf:e=>S.get(e)??``,onOpen:e=>{let n=t?.traces.findIndex(t=>t.id===e)??-1;n>=0&&(c(n),o(`review`))}}),a===`stats`&&(0,O.jsx)(on,{state:r,total:t.traces.length})]}):(0,O.jsx)(Bt,{busy:u,error:f,onFile:e=>void ne(e,e.name,!1),onSample:()=>void re(`./samples/${sn}`,sn,!0)}),!t&&(0,O.jsx)(`nav`,{className:`tabs tabs--idle`,children:[`review`,`axial`,`stats`].map(t=>(0,O.jsx)(`span`,{className:`tab tab--disabled`,children:e(`tab.${t}`)},t))})]})}(0,u.createRoot)(document.getElementById(`root`)).render((0,O.jsx)(l.StrictMode,{children:(0,O.jsx)(Pt,{children:(0,O.jsx)(ln,{})})}));
|
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
8
8
|
<title>trace-codebook</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-BQpDGt-F.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-CPfzDIhf.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trace-codebook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Read LLM traces in your browser, write open-coding notes, group them into failure modes, and count them — no server, no account, no API key.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|