PageSourceSearch

https://www.smartchats.ai/_site/_next/static/chunks/pages/docs/pac…/smartchats-sessions-b40e6ccf9ff7b81d.js

js smartchats.ai collected 2026-10-05 15:06:44 UTC 32,025 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[508],{2527:function(s,i,e){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs/packages/smartchats-sessions",function(){return e(2758)}])},2758:function(s,i,e){"use strict";e.r(i),e.d(i,{useTOC:function(){return l}});var n=e(2322),h=e(4974),r=e(5889),a=e(7854),t=e(5733);function l(s){return[{value:"What’s in the package",id:"whats-in-the-package",depth:2},{value:"Quick start — CLI",id:"quick-start--cli",depth:2},{value:"Quick start — programmatic",id:"quick-start--programmatic",depth:2},{value:"Cross-session error triage",id:"cross-session-error-triage",depth:2},{value:"Discovering sessions to pull",id:"discovering-sessions-to-pull",depth:2},{value:"Adding a new analyzer",id:"adding-a-new-analyzer",depth:2},{value:"Open vs closed boundary",id:"open-vs-closed-boundary",depth:2},{value:"When to use this package directly",id:"when-to-use-this-package-directly",depth:2},{value:"Source",id:"source",depth:2}]}i.default=(0,h.c)(function(s){let{toc:i=l(s)}=s,e={code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.a)(),...s.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e.h1,{children:"smartchats-sessions"}),"\n",(0,n.jsxs)(e.p,{children:["The ",(0,n.jsx)(e.strong,{children:"session forensics toolkit"}),": pull a session from your local or\ncloud SmartChats instance, drop it through analyzers (errors,\ntranscript, traces, performance), and de-duplicate failures across\nmany sessions for triage. This package is what powers the\n“what’s actually broken right now?” debug loop the team runs daily."]}),"\n",(0,n.jsxs)(e.p,{children:["It’s a pure-TypeScript package — no I/O at the analyzer layer. Every\nanalyzer is a pure function over a ",(0,n.jsx)(e.code,{children:"SessionBundle"}),", paired with a\nformatter for human-readable output. That means you can run analyzers\nprogrammatically (in CI, in a custom script, in another tool) as\neasily as from the CLI."]}),"\n",(0,n.jsx)(e.h2,{id:i[0].id,children:i[0].value}),"\n",(0,n.jsxs)(e.table,{children:[(0,n.jsx)(e.thead,{children:(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.th,{children:"Module"}),(0,n.jsx)(e.th,{children:"Purpose"})]})}),(0,n.jsxs)(e.tbody,{children:[(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"export.ts"})}),(0,n.jsxs)(e.td,{children:["Build a ",(0,n.jsx)(e.code,{children:"SessionBundle"})," from a database client + session id"]})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/transcript.ts"})}),(0,n.jsx)(e.td,{children:"User/agent transcript reconstruction, optionally with thoughts + code"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/errors.ts"})}),(0,n.jsx)(e.td,{children:"Error extraction + per-session signature grouping"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/performance.ts"})}),(0,n.jsx)(e.td,{children:"LLM/exec/voice latency stats, cache hit rate, turn pacing"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/traces.ts"})}),(0,n.jsxs)(e.td,{children:["Causality trees built from ",(0,n.jsx)(e.code,{children:"trace_id"})," / ",(0,n.jsx)(e.code,{children:"parent_event_id"})]})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/executions.ts"})}),(0,n.jsx)(e.td,{children:"Per-execution detail (code, function calls, result)"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/inspect.ts"})}),(0,n.jsx)(e.td,{children:"Drill into a specific event or trace"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"analysis/triage_errors.ts"})}),(0,n.jsx)(e.td,{children:"Cross-session signature merge + handled-state, the autonomous debug-loop driver"})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"queries.ts"})}),(0,n.jsxs)(e.td,{children:[(0,n.jsx)(e.code,{children:"SessionBundle"}),"-shape query specs"]})]}),(0,n.jsxs)(e.tr,{children:[(0,n.jsx)(e.td,{children:(0,n.jsx)(e.code,{children:"cli/"})}),(0,n.jsx)(e.td,{children:"Argv parsers + orchestrators for the npm scripts"})]})]})]}),"\n",(0,n.jsx)(e.h2,{id:i[1].id,children:i[1].value}),"\n",(0,n.jsx)(e.pre,{icon:t.Fx,tabIndex:"0","data-language":"bash","data-word-wrap":"",children:(0,n.jsxs)(e.code,{children:[(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Pull a bundle from the local AIO instance"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"bin/save_session"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" smartchats"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"                       # latest session"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"bin/save_session"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" smartchats"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --tag"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" simi"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --last"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" 5"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"   # filter + multi-export"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"cd"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" packages/smartchats-sessions"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Single-session deep dive"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:summary"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"      --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:transcript"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"   --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"     # --with-code, --markdown"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:errors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"       --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:performance"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"  --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:traces"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"       --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" analyze:inspect"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"      --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"bundle.jso"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"n"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --event="}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"<"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"id"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]})]})}),"\n",(0,n.jsx)(e.h2,{id:i[2].id,children:i[2].value}),"\n",(0,n.jsx)(e.pre,{icon:t.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,n.jsxs)(e.code,{children:[(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"import"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" {"})]}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"  analyzeErrors, formatErrors,"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"  analyzeTranscript, formatTranscript,"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"  buildTraceTrees, formatTraces,"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"} "}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"from"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 'smartchats-sessions'"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:";"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"import"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:" fs "}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"from"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 'node:fs'"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:";"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"const"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" bundle"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" ="}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" JSON"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"."}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"parse"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"(fs."}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"readFileSync"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'bundle.json'"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:", "}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"'utf8'"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"));"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"// Pure analysis — returns structured data"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"const"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" errors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" ="}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" analyzeErrors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"(bundle);"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"console."}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"log"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"(errors);  "}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"// { errorRecords: [...], byType: {...}, ... }"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"// Formatter renders it for humans"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"console."}),(0,n.jsx)(e.span,{styl
1e:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"log"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"("}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"formatErrors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"(errors));"})]})]})}),"\n",(0,n.jsxs)(e.p,{children:["Every analyzer follows the same shape: ",(0,n.jsx)(e.code,{children:"analyzeX(bundle)"})," returns a\ntyped result, ",(0,n.jsx)(e.code,{children:"formatX(result)"})," returns a string. Composable. Easy\nto test."]}),"\n",(0,n.jsx)(e.h2,{id:i[3].id,children:i[3].value}),"\n",(0,n.jsxs)(e.p,{children:["The most-used workflow: across the last week of sessions, what’s\nbroken, ",(0,n.jsx)(e.strong,{children:"deduped"})," by signature, hiding what we already fixed?"]}),"\n",(0,n.jsx)(e.pre,{icon:t.Fx,tabIndex:"0","data-language":"bash","data-word-wrap":"",children:(0,n.jsxs)(e.code,{children:[(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"cd"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" packages/smartchats-sessions"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" triage:errors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"                              # ~/.smartchats/session_bundles → ./triage/<ts>/"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" triage:errors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --since"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 7d"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --min-count"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" 2"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" triage:errors"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --dry-run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"                 # preview without writing"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Once you ship a fix:"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" triage:mark"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"report-slu"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"g"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --status"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" fixed"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --commit"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:" <"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:"sh"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"a"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:">"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# View handled-state:"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" triage:mark"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --list"})]})]})}),"\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"State file"}),": ",(0,n.jsx)(e.code,{children:"data/triage/handled.json"})," — force-tracked in git\ndespite ",(0,n.jsx)(e.code,{children:"data/"})," being gitignored, so the team shares a “we already\nfixed this” record. Override path via ",(0,n.jsx)(e.code,{children:"--state"})," or\n",(0,n.jsx)(e.code,{children:"SMARTCHATS_TRIAGE_STATE_FILE"}),"."]}),"\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Regression rule"}),": signatures marked ",(0,n.jsx)(e.code,{children:"fixed"})," re-surface as\n",(0,n.jsx)(e.code,{children:"REGRESSION:"})," reports when a session whose ",(0,n.jsx)(e.code,{children:"end_time > fixed_at"})," hits\nthe same signature. Catches stale fixes that didn’t reach production.\n",(0,n.jsx)(e.code,{children:"wontfix"})," entries land in ",(0,n.jsx)(e.code,{children:"wontfix_summary.md"})," so they’re not silently\ninvisible."]}),"\n",(0,n.jsx)(e.h2,{id:i[4].id,children:i[4].value}),"\n",(0,n.jsx)(e.p,{children:"Before you pull a bundle, you usually want to find candidates:"}),"\n",(0,n.jsx)(e.pre,{icon:t.Fx,tabIndex:"0","data-language":"bash","data-word-wrap":"",children:(0,n.jsxs)(e.code,{children:[(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Open (local AIO only, never cloud)"})}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:"cd"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" packages/smartchats-sessions"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" find-sessions"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --has-error"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --since"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 7d"})]}),"\n",(0,n.jsx)(e.span,{children:" "}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Filter flags:"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"#   --app, --tag, --has-error, --has-event-tag, --has-event-type,"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"#   --missing-event-type, --min-events, --max-events, --min-duration,"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"#   --max-duration, --since, --until, --limit"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"# Formats:"})}),"\n",(0,n.jsx)(e.span,{children:(0,n.jsx)(e.span,{style:{"--shiki-light":"#6A737D","--shiki-dark":"#6A737D"},children:"#   --format=table | json | ids   (pipe ids → save-session)"})})]})}),"\n",(0,n.jsxs)(e.p,{children:["Pair with ",(0,n.jsx)(e.code,{children:"bin/save_session"}),":"]}),"\n",(0,n.jsx)(e.pre,{icon:t.Fx,tabIndex:"0","data-language":"bash","data-word-wrap":"",children:(0,n.jsxs)(e.code,{children:[(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:"npm"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" run"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" find-sessions"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --has-error"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --since"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},children:" 7d"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" --format=ids"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" \\"})]}),"\n",(0,n.jsxs)(e.span,{children:[(0,n.jsx)(e.span,{style:{"--shiki-light":"#D73A49","--shiki-dark":"#F97583"},children:"  |"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#6F42C1","--shiki-dark":"#B392F0"},children:" xargs"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#005CC5","--shiki-dark":"#79B8FF"},children:" -I"}),(0,n.jsx)(e.span,{style:{"--shiki-light":"#24292E","--shiki-dark":"#E1E4E8"},children:"{} bin/save_session smartchats --session-id {}"})]})]})}),"\n",(0,n.jsx)(e.h2,{id:i[5].id,children:i[5].value}),"\n",(0,n.jsxs)(e.p,{children:["The pattern is documented in ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/src/analysis/README.md"}),".\nBriefly:"]}),"\n",(0,n.jsxs)(e.ol,{children:["\n",(0,n.jsxs)(e.li,{children:["Write ",(0,n.jsx)(e.code,{children:"analyzeX(bundle: SessionBundle): XResult"})," — pure function,\ntyped input + output."]}),"\n",(0,n.jsxs)(e.li,{children:["Write ",(0,n.jsx)(e.code,{children:"formatX(result: XResult, opts?): string"})," — pure formatter."]}),"\n",(0,n.jsxs)(e.li,{children:["Add a CLI in ",(0,n.jsx)(e.code,{children:"cli/"})," if you want an ",(0,n.jsx)(e.code,{children:"npm run analyze:x"})," script."]}),"\n",(0,n.jsxs)(e.li,{children:["Re-export from ",(0,n.jsx)(e.code,{children:"index.ts"}),"."]}),"\n"]}),"\n",(0,n.jsx)(e.p,{children:"The analyzers don’t share state. They don’t need to be ordered. Each\none is independently testable with a fixture bundle."}),"\n",(0,n.jsx)(e.h2,{id:i[6].id,children:i[6].value}),"\n",(0,n.jsxs)(e.p,{children:["This package is ",(0,n.jsx)(e.strong,{children:"open-source"}),". It never imports cloud credentials.\nThe closed-source ",(0,n.jsx)(e.code,{children:"smartchats-cloud"})," package has its own\n",(0,n.jsx)(e.code,{children:"save-session"})," admin CLI for cross-user cloud session triage —\nthat lives in the closed repo because it uses root admin creds. Both\nsides share ",(0,n.jsx)(e.code,{children:"findCandidateSessions"})," and ",(0,n.jsx)(e.code,{children:"buildSessionBundle"})," from this\npackage."]}),"\n",(0,n.jsx)(e.h2,{id:i[7].id,children:i[7].value}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"You want to write a custom analyzer (latency distribution, KG-write\npatterns, anything not in the default set)"}),"\n",(0,n.jsx)(e.li,{children:"You’re building a dashboard that reads SmartChats session data"}),"\n",(0,n.jsx)(e.li,{children:"You’re automating triage (CI job that pulls fresh failures and\nposts to Slack)"}),"\n"]}),"\n",(0,n.jsx)(e.h2,{id:i[8].id,children:i[8].value}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsxs)(e.li,{children:["Package: ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/"})]}),"\n",(0,n.jsxs)(e.li,{children:["Entry: ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/src/index.ts"})]}),"\n",(0,n.jsxs)(e.li,{children:["Analyzers: ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/src/analysis/"})]}),"\n",(0,n.jsxs)(e.li,{children:["CLI orchestrators: ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/src/cli/"})]}),"\n",(0,n.jsxs)(e.li,{children:["Analyzer conventions: ",(0,n.jsx)(e.code,{children:"packages/smartchats-sessions/src/analysis/README.md"})]}),"\n"]})]})},"/docs/packages/smartchats-sessions",{filePath:"pages/docs/packages/smartchats-sessions.mdx",timestamp:1786799065e3,pageMap:r.v,frontMatter:{},title:"smartchats-sessions"},"undefined"==typeof RemoteContent?l:RemoteContent.useTOC)},5889:function(s,i,e){"use strict";e.d(i,{v:function(){return n}});let n=[{name:"docs",route:"/docs",children:[{data:{index:"Welcome",quickstart:"Quick Start","self-host":"Self-Hosting",cli:"CLI Reference",architecture:"Architecture",packages:"Packages",mcp:"MCP Server",contributing:"Contributing"}}
1,{name:"architecture",route:"/docs/architecture",frontMatter:{sidebarTitle:"Architecture"}},{name:"cli",route:"/docs/cli",frontMatter:{sidebarTitle:"CLI"}},{name:"contributing",route:"/docs/contributing",frontMatter:{sidebarTitle:"Contributing"}},{name:"index",route:"/docs",frontMatter:{sidebarTitle:"Index"}},{name:"mcp",route:"/docs/mcp",frontMatter:{sidebarTitle:"Mcp"}},{name:"packages",route:"/docs/packages",children:[{data:{index:"Overview",tivi:"tivi — Voice Interface",cortex:"cortex — Agent Runtime","smartchats-database":"smartchats-database","smartchats-backend":"smartchats-backend","smartchats-sessions":"smartchats-sessions","llm-service":"llm-service",simi:"simi — Workflow Tests"}},{name:"cortex",route:"/docs/packages/cortex",frontMatter:{sidebarTitle:"Cortex"}},{name:"index",route:"/docs/packages",frontMatter:{sidebarTitle:"Index"}},{name:"llm-service",route:"/docs/packages/llm-service",frontMatter:{sidebarTitle:"Llm Service"}},{name:"simi",route:"/docs/packages/simi",frontMatter:{sidebarTitle:"Simi"}},{name:"smartchats-backend",route:"/docs/packages/smartchats-backend",frontMatter:{sidebarTitle:"Smartchats Backend"}},{name:"smartchats-database",route:"/docs/packages/smartchats-database",frontMatter:{sidebarTitle:"Smartchats Database"}},{name:"smartchats-sessions",route:"/docs/packages/smartchats-sessions",frontMatter:{sidebarTitle:"Smartchats Sessions"}},{name:"tivi",route:"/docs/packages/tivi",frontMatter:{sidebarTitle:"Tivi"}}]},{name:"quickstart",route:"/docs/quickstart",frontMatter:{sidebarTitle:"Quickstart"}},{name:"self-host",route:"/docs/self-host",frontMatter:{sidebarTitle:"Self Host"}}]}]}},function(s){s.O(0,[974,888,774,179],function(){return s(s.s=2527)}),_N_E=s.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.