@duckcodeailabs/dql-cli 1.14.2 → 1.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/args.d.ts +6 -0
  2. package/dist/args.d.ts.map +1 -1
  3. package/dist/args.js +28 -0
  4. package/dist/args.js.map +1 -1
  5. package/dist/ask-runtime/analytical-planner.d.ts +14 -0
  6. package/dist/ask-runtime/analytical-planner.d.ts.map +1 -0
  7. package/dist/ask-runtime/analytical-planner.js +197 -0
  8. package/dist/ask-runtime/analytical-planner.js.map +1 -0
  9. package/dist/ask-runtime/readiness.d.ts +36 -0
  10. package/dist/ask-runtime/readiness.d.ts.map +1 -0
  11. package/dist/ask-runtime/readiness.js +65 -0
  12. package/dist/ask-runtime/readiness.js.map +1 -0
  13. package/dist/assets/dql-notebook/assets/{AgentLogPage-DKbGpRQS.js → AgentLogPage-XonDlOVv.js} +1 -1
  14. package/dist/assets/dql-notebook/assets/{AiBuildDialog-DPSu0Mly.js → AiBuildDialog-DwHVVFIS.js} +1 -1
  15. package/dist/assets/dql-notebook/assets/{AiBuildResult-1uaGnpi1.js → AiBuildResult-BImB4Wej.js} +1 -1
  16. package/dist/assets/dql-notebook/assets/{AiSidePanel-BwMREwa7.js → AiSidePanel-D7fFBhgc.js} +1 -1
  17. package/dist/assets/dql-notebook/assets/AnalyticsHome-CHvGWG92.js +6 -0
  18. package/dist/assets/dql-notebook/assets/{AppsView-CM1tPywy.js → AppsView-DNhs0MyO.js} +30 -35
  19. package/dist/assets/dql-notebook/assets/AskObservabilityPage-1WYjAf8-.js +1 -0
  20. package/dist/assets/dql-notebook/assets/AskTracePage-D6_RunIf.js +8 -0
  21. package/dist/assets/dql-notebook/assets/{BlockStudio--S6WFVO4.js → BlockStudio-DWMOCHy5.js} +9 -14
  22. package/dist/assets/dql-notebook/assets/BusinessArtifactView-guqlfQ0j.js +1 -0
  23. package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-CNyU5MBX.js → DbtFirstModelingPage-DE7ewjMK.js} +3 -3
  24. package/dist/assets/dql-notebook/assets/{GitPage-IcydAai3.js → GitPage-CM3cgHtf.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{GlobalAiRail-CSKW-5eD.js → GlobalAiRail-BWfeK8lb.js} +1 -1
  26. package/dist/assets/dql-notebook/assets/{GovernedContextPage-CFen0eFT.js → GovernedContextPage-2Ld4yIgE.js} +3 -3
  27. package/dist/assets/dql-notebook/assets/{HelpDocsPage-D0D9UCIz.js → HelpDocsPage-BxBzoxBO.js} +1 -1
  28. package/dist/assets/dql-notebook/assets/{HomePage-CmSxapR3.js → HomePage-D4ZjCFfB.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/LineageDAG-DLdogZMo.js +1 -0
  30. package/dist/assets/dql-notebook/assets/LineageDetailView-CqPB_tFP.js +1 -0
  31. package/dist/assets/dql-notebook/assets/LineageDrawer-LZyR3zHf.js +1 -0
  32. package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CTZJp4_r.js → LineagePathBreadcrumb-BZ7EcIxp.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/MiniLineageGraph-Be_kqIq2.js +1 -0
  34. package/dist/assets/dql-notebook/assets/{NewBlockModal-DMBFB7nE.js → NewBlockModal-C9MKCa6R.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/{NewNotebookModal-DsC9CWlW.js → NewNotebookModal-ZxHbTU9u.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{NotebookEditor-hs-kw8v9.js → NotebookEditor-Bh39Vsg0.js} +25 -30
  37. package/dist/assets/dql-notebook/assets/{ReadinessPage-DJ83cMik.js → ReadinessPage-jKOBKkED.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{SetupOnboarding-B1Pu_Bvv.js → SetupOnboarding-BRut9nLO.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{SkillsPage-BHKDay8n.js → SkillsPage-D9msUOxY.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/{TrustBadge-BkyGgob2.js → TrustBadge-D1CGSj0Y.js} +1 -1
  41. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BexNjqJd.js +88 -0
  42. package/dist/assets/dql-notebook/assets/{answer-to-notebook-DmNiuLQA.js → answer-to-notebook-zHFOdR6E.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/{arrow-left--1rsrxm8.js → arrow-left-C1tZBhgf.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{arrow-right-D5TdqY1G.js → arrow-right-BP5vPPNo.js} +1 -1
  45. package/dist/assets/dql-notebook/assets/{book-open-text-Bw7nHbzg.js → book-open-text-BD3-ATYI.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/chevron-left-3opVgscY.js +6 -0
  47. package/dist/assets/dql-notebook/assets/{circle-x-DLe6NNM4.js → circle-x-Bg9-70KN.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/clock-3-DLV5puGW.js +6 -0
  49. package/dist/assets/dql-notebook/assets/dagre.esm-B6nvU4OB.js +1 -0
  50. package/dist/assets/dql-notebook/assets/{external-link-C9Q97sA3.js → external-link-BjD8w9QU.js} +1 -1
  51. package/dist/assets/dql-notebook/assets/{grip-vertical-CztvkIgo.js → grip-vertical-DqIc09oX.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/index-B_kaoARS.css +1 -0
  53. package/dist/assets/dql-notebook/assets/{index-zHHzDn6l.js → index-C9KfoqCR.js} +133 -128
  54. package/dist/assets/dql-notebook/assets/{link-2-CiKAvumL.js → link-2-5s0hUu6w.js} +1 -1
  55. package/dist/assets/dql-notebook/assets/{list-tree-BtnP2nQ5.js → list-tree-67yz_uCY.js} +1 -1
  56. package/dist/assets/dql-notebook/assets/{minimize-2-TSFGxcCP.js → minimize-2-BJw5tlPC.js} +1 -1
  57. package/dist/assets/dql-notebook/assets/{panel-right-open-BfXIUWy0.js → panel-right-open-CyhTG-tw.js} +1 -1
  58. package/dist/assets/dql-notebook/assets/{play-DVbSFJHD.js → play-CsY8D5M2.js} +1 -1
  59. package/dist/assets/dql-notebook/assets/{rotate-ccw-D_cesDcX.js → rotate-ccw-RvwtBcw9.js} +1 -1
  60. package/dist/assets/dql-notebook/assets/{semantic-fields-CoVStdYB.js → semantic-fields-EorgHwAj.js} +1 -1
  61. package/dist/assets/dql-notebook/assets/{sliders-horizontal-l7xV9K5A.js → sliders-horizontal-jQ_fUiYf.js} +1 -1
  62. package/dist/assets/dql-notebook/assets/{star-CSBS0H3b.js → star-N_C8YvbB.js} +1 -1
  63. package/dist/assets/dql-notebook/assets/style-D6AlWDHX.js +23 -0
  64. package/dist/assets/dql-notebook/assets/{triangle-alert-BTrnyY4q.js → triangle-alert-D1WefIrN.js} +1 -1
  65. package/dist/assets/dql-notebook/assets/{upload-sySLq9zb.js → upload-CFJjpPL4.js} +1 -1
  66. package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-CzwgGdus.js → usePersistedAgentThreadId-B5pTglEr.js} +1 -1
  67. package/dist/assets/dql-notebook/assets/{user-round-ChlgXi9j.js → user-round-DL6DLw0m.js} +1 -1
  68. package/dist/assets/dql-notebook/assets/{wand-sparkles-CGw0ytyT.js → wand-sparkles-CNUjLDqT.js} +1 -1
  69. package/dist/assets/dql-notebook/assets/{workflow-C_RltiK5.js → workflow-0NUwpoQ4.js} +1 -1
  70. package/dist/assets/dql-notebook/assets/{wrench-D-wLfeu0.js → wrench-QNiznShi.js} +1 -1
  71. package/dist/assets/dql-notebook/assets/{x-B28hIJIC.js → x-BhTl5gZs.js} +1 -1
  72. package/dist/assets/dql-notebook/index.html +2 -2
  73. package/dist/commands/agent-eval-cassette.d.ts.map +1 -1
  74. package/dist/commands/agent-eval-cassette.js +15 -0
  75. package/dist/commands/agent-eval-cassette.js.map +1 -1
  76. package/dist/commands/agent-eval-runtime.d.ts +9 -0
  77. package/dist/commands/agent-eval-runtime.d.ts.map +1 -1
  78. package/dist/commands/agent-eval-runtime.js +7 -0
  79. package/dist/commands/agent-eval-runtime.js.map +1 -1
  80. package/dist/commands/agent-shadow-report.d.ts +17 -0
  81. package/dist/commands/agent-shadow-report.d.ts.map +1 -0
  82. package/dist/commands/agent-shadow-report.js +149 -0
  83. package/dist/commands/agent-shadow-report.js.map +1 -0
  84. package/dist/commands/agent-trace.d.ts +3 -0
  85. package/dist/commands/agent-trace.d.ts.map +1 -0
  86. package/dist/commands/agent-trace.js +169 -0
  87. package/dist/commands/agent-trace.js.map +1 -0
  88. package/dist/commands/agent.d.ts +28 -2
  89. package/dist/commands/agent.d.ts.map +1 -1
  90. package/dist/commands/agent.js +413 -36
  91. package/dist/commands/agent.js.map +1 -1
  92. package/dist/commands/notebook.d.ts +4 -1
  93. package/dist/commands/notebook.d.ts.map +1 -1
  94. package/dist/commands/notebook.js +12 -1
  95. package/dist/commands/notebook.js.map +1 -1
  96. package/dist/index.js +5 -0
  97. package/dist/index.js.map +1 -1
  98. package/dist/llm/providers/ask-v2-analyst-prompt.d.ts +32 -0
  99. package/dist/llm/providers/ask-v2-analyst-prompt.d.ts.map +1 -0
  100. package/dist/llm/providers/ask-v2-analyst-prompt.js +136 -0
  101. package/dist/llm/providers/ask-v2-analyst-prompt.js.map +1 -0
  102. package/dist/llm/providers/dql-agent-provider.d.ts +78 -2
  103. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  104. package/dist/llm/providers/dql-agent-provider.js +5438 -330
  105. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  106. package/dist/llm/types.d.ts +144 -3
  107. package/dist/llm/types.d.ts.map +1 -1
  108. package/dist/local-runtime.d.ts +607 -35
  109. package/dist/local-runtime.d.ts.map +1 -1
  110. package/dist/local-runtime.js +7734 -702
  111. package/dist/local-runtime.js.map +1 -1
  112. package/dist/metricflow.d.ts.map +1 -1
  113. package/dist/metricflow.js +80 -11
  114. package/dist/metricflow.js.map +1 -1
  115. package/dist/package.json +10 -10
  116. package/dist/providers/oauth/claude-oauth.d.ts +14 -0
  117. package/dist/providers/oauth/claude-oauth.d.ts.map +1 -1
  118. package/dist/providers/oauth/claude-oauth.js +84 -23
  119. package/dist/providers/oauth/claude-oauth.js.map +1 -1
  120. package/dist/providers/oauth/codex-oauth.d.ts.map +1 -1
  121. package/dist/providers/oauth/codex-oauth.js +72 -44
  122. package/dist/providers/oauth/codex-oauth.js.map +1 -1
  123. package/dist/providers/subscription-cli.d.ts +20 -0
  124. package/dist/providers/subscription-cli.d.ts.map +1 -1
  125. package/dist/providers/subscription-cli.js +69 -11
  126. package/dist/providers/subscription-cli.js.map +1 -1
  127. package/dist/research-lineage-program.d.ts +29 -0
  128. package/dist/research-lineage-program.d.ts.map +1 -0
  129. package/dist/research-lineage-program.js +389 -0
  130. package/dist/research-lineage-program.js.map +1 -0
  131. package/dist/retrieval-health.d.ts.map +1 -1
  132. package/dist/retrieval-health.js +5 -2
  133. package/dist/retrieval-health.js.map +1 -1
  134. package/dist/semantic-runtime.d.ts.map +1 -1
  135. package/dist/semantic-runtime.js +73 -2
  136. package/dist/semantic-runtime.js.map +1 -1
  137. package/package.json +10 -10
  138. package/dist/assets/dql-notebook/assets/AnalyticsHome-BGfey_ve.js +0 -6
  139. package/dist/assets/dql-notebook/assets/BusinessArtifactView-BEAJ-yNW.js +0 -1
  140. package/dist/assets/dql-notebook/assets/LineageDAG-BGUcIt1B.js +0 -1
  141. package/dist/assets/dql-notebook/assets/LineageDetailView-Dx48Zfzb.js +0 -1
  142. package/dist/assets/dql-notebook/assets/LineageDrawer-zaBfSLZO.js +0 -1
  143. package/dist/assets/dql-notebook/assets/MiniLineageGraph-CdivNR1S.js +0 -1
  144. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BYdrTaEW.js +0 -89
  145. package/dist/assets/dql-notebook/assets/dagre.esm-CW5QZdBt.js +0 -23
  146. package/dist/assets/dql-notebook/assets/index-B3shyZsg.css +0 -1
  147. /package/dist/assets/dql-notebook/assets/{dagre-BZV40eAE.css → style-BZV40eAE.css} +0 -0
@@ -0,0 +1 @@
1
+ import{h as Q,k as G,r as a,a as $,j as t,t as K,as as B,a0 as I,aJ as U,e as J,f as E,L,aL as X}from"./index-C9KfoqCR.js";import{C as Z}from"./chevron-left-3opVgscY.js";import{T as P}from"./triangle-alert-D1WefIrN.js";import{C as V}from"./circle-x-Bg9-70KN.js";import{A as Y}from"./arrow-right-BP5vPPNo.js";import"./react-CRB3T2We.js";const ee=25,z={status:"all",mode:"all",selectedTier:"all",trustState:"all"};function te(e,r){return{limit:ee,...r?{cursor:r}:{},...e.status!=="all"?{status:e.status}:{},...e.mode!=="all"?{mode:e.mode}:{},...e.selectedTier!=="all"?{selectedTier:e.selectedTier}:{},...e.trustState!=="all"?{trustState:e.trustState}:{}}}function re(e){var r,i;return((r=e.questionPreview)==null?void 0:r.trim())||((i=e.scenarioLabel)==null?void 0:i.trim())||`Ask run ${ce(e.runId)}`}function be(){const e=Q(n=>n.themeMode),r=K[e],i=G(),[l,o]=a.useState(z),[s,c]=a.useState([void 0]),[p,y]=a.useState(0),[C,W]=a.useState([]),[f,N]=a.useState(),[j,F]=a.useState(),[_,M]=a.useState(),[u,b]=a.useState(!0),[v,T]=a.useState(),[O,A]=a.useState(0),w=a.useMemo(()=>te(l,s[p]),[s,l,p]);a.useEffect(()=>{let n=!0;return b(!0),T(void 0),Promise.all([$.getAskTraceStatus(),$.listAskTraces(w)]).then(([d,S])=>{n&&(M(d.status),W(S.traces),N(S.nextCursor),F(S.total),b(!1))}).catch(d=>{n&&(T(pe(d)),b(!1))}),()=>{n=!1}},[w,O]);const g=n=>{o(d=>({...d,...n})),c([void 0]),y(0)},H=n=>i({type:"OPEN_ASK_TRACE",runId:n}),D=()=>{f&&(c(n=>{const d=n.slice(0,p+1);return d.push(f),d}),y(n=>n+1))},q=()=>y(n=>Math.max(0,n-1)),R=Object.values(l).some(n=>n!=="all");return t.jsx("main",{style:{flex:1,minWidth:0,overflow:"auto",background:r.appBg,color:r.textPrimary,fontFamily:r.font},children:t.jsxs("div",{style:{maxWidth:1280,margin:"0 auto",padding:"22px 24px 36px"},children:[t.jsxs("header",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:18,flexWrap:"wrap",marginBottom:18},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{display:"grid",placeItems:"center",width:28,height:28,borderRadius:8,background:`${r.accent}16`,color:r.accent},children:t.jsx(B,{size:15})}),t.jsx("h1",{style:{margin:0,fontSize:22,letterSpacing:"-0.02em"},children:"Ask observability"})]}),t.jsx("p",{style:{margin:"7px 0 0",color:r.textSecondary,fontSize:13,lineHeight:1.5,maxWidth:720},children:"Review what Ask tried, where it stopped, and the safe next action. Open a run for its redacted trace tree, cascade decisions, provider phase, and repair guidance."})]}),t.jsxs("button",{type:"button",onClick:()=>A(n=>n+1),disabled:u,style:m(r),children:[t.jsx(I,{size:13,className:u?"ask-trace-recording":void 0})," Refresh"]})]}),t.jsx(ne,{status:_,loading:u,error:v,t:r}),t.jsxs("section",{"aria-label":"Ask trace filters",style:{marginTop:16,padding:"12px 14px",border:`1px solid ${r.cellBorder}`,borderRadius:10,background:r.cellBg},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:9,color:r.textSecondary,fontSize:12,fontWeight:700},children:[t.jsx(U,{size:13})," Filter trace catalog",R?t.jsx("button",{type:"button",onClick:()=>g(z),style:xe(r),children:"Clear filters"}):null]}),t.jsxs("div",{style:{display:"flex",gap:9,flexWrap:"wrap"},children:[t.jsxs(h,{label:"Outcome",value:l.status,onChange:n=>g({status:n}),t:r,children:[t.jsx("option",{value:"all",children:"All outcomes"}),t.jsx("option",{value:"completed",children:"Completed"}),t.jsx("option",{value:"blocked",children:"Blocked"}),t.jsx("option",{value:"failed",children:"Failed"}),t.jsx("option",{value:"cancelled",children:"Cancelled"}),t.jsx("option",{value:"interrupted",children:"Interrupted"}),t.jsx("option",{value:"running",children:"Running"})]}),t.jsxs(h,{label:"Mode",value:l.mode,onChange:n=>g({mode:n}),t:r,children:[t.jsx("option",{value:"all",children:"Ask + Research"}),t.jsx("option",{value:"ask",children:"Ask"}),t.jsx("option",{value:"research",children:"Research"})]}),t.jsxs(h,{label:"Selected tier",value:l.selectedTier,onChange:n=>g({selectedTier:n}),t:r,children:[t.jsx("option",{value:"all",children:"All tiers"}),t.jsx("option",{value:"certified",children:"Certified"}),t.jsx("option",{value:"semantic",children:"Semantic"}),t.jsx("option",{value:"governed_relational",children:"Governed relational"}),t.jsx("option",{value:"exploratory_sql",children:"Exploratory SQL"}),t.jsx("option",{value:"clarify_or_gap",children:"Clarify or gap"})]}),t.jsxs(h,{label:"Trust",value:l.trustState,onChange:n=>g({trustState:n}),t:r,children:[t.jsx("option",{value:"all",children:"All trust states"}),t.jsx("option",{value:"certified",children:"Certified"}),t.jsx("option",{value:"governed",children:"Governed"}),t.jsx("option",{value:"review_required",children:"Review required"}),t.jsx("option",{value:"blocked",children:"Blocked"})]})]})]}),t.jsxs("section",{"aria-live":"polite",style:{marginTop:14},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,marginBottom:8,color:r.textMuted,fontSize:11.5},children:[t.jsx("span",{children:j===void 0?"Loading trace count…":`${j} local trace${j===1?"":"s"}`}),t.jsxs("span",{children:["Page ",p+1]})]}),u?t.jsx(ie,{t:r}):v?t.jsx(ae,{message:v,onRetry:()=>A(n=>n+1),t:r}):C.length===0?t.jsx(oe,{filtered:R,t:r}):t.jsx("div",{style:{display:"grid",gap:8},children:C.map(n=>t.jsx(le,{trace:n,t:r,onOpen:()=>H(n.runId)},n.traceId))})]}),t.jsxs("nav",{"aria-label":"Trace catalog pagination",style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:8,marginTop:14},children:[t.jsxs("button",{type:"button",onClick:q,disabled:p===0||u,style:m(r),children:[t.jsx(Z,{size:13})," Previous"]}),t.jsxs("button",{type:"button",onClick:D,disabled:!f||u,style:m(r),children:["Next ",t.jsx(J,{size:13})]})]})]})})}function ne({status:e,loading:r,error:i,t:l}){const o=!!i||e&&(!e.available||!e.recordingEnabled),s=o?P:e!=null&&e.recordingEnabled?E:L,c=i?"The local trace catalog could not be loaded.":e!=null&&e.available&&e.recordingEnabled?"Local trace recording is ready.":r?"Checking local trace recording…":"Local trace recording is unavailable.",p=i?"Check that the local DQL runtime is running, then refresh. Existing Ask results remain available.":e!=null&&e.available&&e.recordingEnabled?"Traces are local and redacted. Full prompts, SQL, rows, provider responses, credentials, and file paths are not retained here.":(e==null?void 0:e.reason)==="disabled"?"Enable local Ask trace recording in the project runtime, then run a new Ask.":(e==null?void 0:e.reason)==="unsupported_schema"?"Rebuild the local runtime or trace index to match this DQL version, then retry.":"The runtime did not report a usable local trace store.";return t.jsxs("section",{role:o?"alert":"status",style:{display:"flex",gap:10,padding:"11px 13px",borderRadius:10,border:`1px solid ${o?`${l.warning}55`:`${l.accent}33`}`,background:o?`${l.warning}0d`:`${l.accent}09`},children:[t.jsx(s,{size:16,color:o?l.warning:l.accent,style:{flexShrink:0,marginTop:1}}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("strong",{style:{display:"block",fontSize:12.5,color:l.textPrimary},children:c}),t.jsx("span",{style:{display:"block",marginTop:3,fontSize:11.5,lineHeight:1.45,color:l.textSecondary},children:p})]})]})}function le({trace:e,t:r,onOpen:i}){var c;const l=e.status==="blocked"||e.status==="failed"||e.status==="interrupted",o=l?r.error:e.status==="completed"?r.success:r.warning,s=l?t.jsx(X,{size:13}):e.status==="completed"?t.jsx(E,{size:13}):t.jsx(P,{size:13});return t.jsxs("article",{style:{display:"grid",gap:10,padding:"13px 14px",border:`1px solid ${r.cellBorder}`,borderRadius:10,background:r.cellBg},children:[t.jsxs("div",{style:{display:"flex",gap:12,alignItems:"flex-start",justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:o,fontSize:11.5,fontWeight:750},children:[s," ",se(e.status),t.jsxs("span",{style:{color:r.textMuted,fontWeight:500},children:["· ",e.mode==="research"?"Research":"Ask"," · ",e.surface]})]}),t.jsx("h2",{style:{margin:"5px 0 0",color:r.textPrimary,fontSize:14,lineHeight:1.4,fontWeight:700},children:re(e)})]}),t.jsxs("button",{type:"button",onClick:i,style:ue(r),children:["Open trace ",t.jsx(Y,{size:13})]})]}),t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",color:r.textSecondary,fontSize:11},children:[t.jsx(x,{label:e.trustState??"Trust not recorded",t:r}),t.jsx(x,{label:e.selectedTier??"No selected tier",t:r}),t.jsx(x,{label:((c=e.terminalOutcome)==null?void 0:c.replace(/_/g," "))??e.recordingStatus,t:r}),t.jsx(x,{label:`${e.spanCount} stage${e.spanCount===1?"":"s"}`,t:r}),t.jsx(x,{label:de(e.startedAt),t:r}),e.detailAvailable?null:t.jsx(x,{label:"Detail no longer available",t:r,warning:!0})]})]})}function x({label:e,t:r,warning:i=!1}){return t.jsx("span",{style:{padding:"3px 6px",border:`1px solid ${i?`${r.warning}55`:r.cellBorder}`,borderRadius:999,background:i?`${r.warning}0d`:r.pillBg,color:i?r.warning:r.textSecondary,whiteSpace:"nowrap"},children:e})}function h({label:e,value:r,onChange:i,t:l,children:o}){return t.jsxs("label",{style:{display:"grid",gap:3,minWidth:142,fontSize:10.5,color:l.textMuted},children:[e,t.jsx("select",{value:r,onChange:s=>i(s.target.value),style:{minHeight:31,padding:"4px 8px",border:`1px solid ${l.inputBorder}`,borderRadius:6,background:l.inputBg,color:l.textPrimary,font:`12px ${l.font}`},children:o})]})}function ie({t:e}){return t.jsxs("div",{role:"status",style:k(e),children:[t.jsx(L,{size:16,className:"ask-trace-recording"})," Loading local Ask traces…"]})}function ae({message:e,onRetry:r,t:i}){return t.jsxs("div",{role:"alert",style:k(i),children:[t.jsx(V,{size:16,color:i.error}),t.jsx("span",{style:{flex:1},children:e}),t.jsxs("button",{type:"button",onClick:r,style:m(i),children:[t.jsx(I,{size:12})," Retry"]})]})}function oe({filtered:e,t:r}){return t.jsxs("div",{style:k(r),children:[t.jsx(B,{size:16,color:r.textMuted}),e?"No local traces match these filters.":"No local Ask traces have been recorded yet. Run an Ask, then return here to inspect its typed execution evidence."]})}function se(e){return e==="completed"?"Completed":e.charAt(0).toUpperCase()+e.slice(1)}function de(e){const r=new Date(e);return Number.isNaN(r.getTime())?"Time unavailable":r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function ce(e){return e.length>16?`${e.slice(0,8)}…${e.slice(-6)}`:e}function pe(e){return e instanceof Error&&e.message?e.message:"The local trace catalog did not return a response."}function m(e){return{display:"inline-flex",alignItems:"center",gap:5,minHeight:30,padding:"5px 9px",border:`1px solid ${e.btnBorder}`,borderRadius:6,background:e.btnBg,color:e.textSecondary,cursor:"pointer",font:`650 11.5px ${e.font}`}}function ue(e){return{display:"inline-flex",alignItems:"center",gap:5,minHeight:30,padding:"5px 9px",border:`1px solid ${e.accent}`,borderRadius:6,background:e.accent,color:"var(--accent-fg)",cursor:"pointer",font:`700 11.5px ${e.font}`,whiteSpace:"nowrap"}}function xe(e){return{marginLeft:4,padding:0,border:"none",background:"transparent",color:e.accent,cursor:"pointer",font:`650 11px ${e.font}`}}function k(e){return{display:"flex",alignItems:"center",gap:8,minHeight:76,padding:"14px",border:`1px dashed ${e.cellBorder}`,borderRadius:10,color:e.textSecondary,fontSize:12,lineHeight:1.45,background:e.cellBg}}export{be as AskObservabilityPage,te as askObservabilityQuery,re as traceCatalogTitle};
@@ -0,0 +1,8 @@
1
+ import{c as Ce,h as Re,k as ze,r as S,j as r,t as Me,as as be,f as K,a as Ne,L as ve,l as Fe,G as ce,a0 as Be,D as we,aJ as De,d as Ee,e as Le}from"./index-C9KfoqCR.js";import{i as qe,B as Oe,C as He}from"./style-D6AlWDHX.js";import{A as Pe}from"./arrow-left-C1tZBhgf.js";import{T as L}from"./triangle-alert-D1WefIrN.js";import{C as Ie}from"./clock-3-DLV5puGW.js";import{C as We}from"./circle-x-Bg9-70KN.js";import"./react-CRB3T2We.js";/**
2
+ * @license lucide-react v0.563.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ge=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]],Qe=Ce("circle-off",Ge),H=50,Ue=1500,Ve="Canonical decision summary unavailable for this older run";function Ye(e){if(e)return new URLSearchParams(e).get("focus")==="research"?"research":void 0}function le(e){const t=e.spans.filter(n=>n.stage==="research"||n.name.startsWith("research."));return t.find(n=>n.name==="research.lineage")??t.find(n=>n.name==="research.validate")??t.find(n=>n.name==="research.plan")??t[0]}function Ke(e){if((e==null?void 0:e.name)!=="research.lineage"||e.payload.kind!=="research"||e.payload.evidenceKind!=="lineage_graph")return;const t=e.payload,n=t.lineageStatus??"unavailable",a=typeof t.upstreamNodeCount=="number"?t.upstreamNodeCount:0,o=typeof t.downstreamNodeCount=="number"?t.downstreamNodeCount:0,i=[typeof t.lineageMaxDepth=="number"?`depth ${t.lineageMaxDepth}`:void 0,typeof t.lineageMaxRoutes=="number"?`${t.lineageMaxRoutes} routes`:void 0,typeof t.lineageMaxNodes=="number"?`${t.lineageMaxNodes} nodes`:void 0,typeof t.lineageMaxEdges=="number"?`${t.lineageMaxEdges} edges`:void 0].filter(p=>!!p),s=i.length>0?` Bounded to ${i.join(", ")}.`:"",d=" It is non-causal evidence about local structure only—not provider, SQL, warehouse, result, or causal evidence.";return n==="completed"?`The frozen local lineage graph resolved the requested target and observed ${a} upstream and ${o} downstream nodes.${s}${d}`:n==="truncated"?`The frozen local lineage graph resolved the requested target, but the bounded traversal stopped before a complete structural view was available.${s}${d}`:n==="ambiguous"?`The frozen local lineage graph found more than one exact target. No broader search or query was attempted.${d}`:n==="missing"?`The frozen local lineage graph did not contain the exact requested target. No broader search or query was attempted.${d}`:n==="stale"?`The local lineage snapshot did not match the frozen Research snapshot, so structural evidence was not used.${d}`:`Local lineage evidence was unavailable for this Research branch. No broader search or query was attempted.${d}`}function Xe(e,t,n){var s;const a=new Map(e.spans.map(d=>[d.spanId,d])),o=new Set(n);let i=t;for(;i;)o.add(i),i=(s=a.get(i))==null?void 0:s.parentSpanId;return o}function rn({runId:e}){const t=Re(f=>f.themeMode),n=Me[t],a=ze(),[o,i]=S.useState(null),[s,d]=S.useState(null),[p,c]=S.useState(!0),[y,x]=S.useState("tree"),[l,h]=S.useState(null),[m,v]=S.useState(""),[w,u]=S.useState(new Set),[g,k]=S.useState(0),[T,$]=S.useState(!1),[_,D]=S.useState(()=>typeof window<"u"&&window.innerWidth<900),z=Ye(typeof window<"u"?window.location.search:void 0);S.useEffect(()=>{let f=!0,j;const R=async()=>{try{const E=await Ne.getAskTraceByRun(e);if(!f)return;i(E),d(null),c(!1),E.envelope.recordingStatus==="recording"&&(j=window.setTimeout(()=>void R(),Ue))}catch(E){if(!f)return;c(!1),d(Pt(E))}};return R(),()=>{f=!1,j!==void 0&&window.clearTimeout(j)}},[e]),S.useEffect(()=>{const f=()=>D(window.innerWidth<900);return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]),S.useEffect(()=>{o&&(u(Rt(o)),h(f=>f??{kind:"span",spanId:o.envelope.rootSpanId}),k(0),$(!1))},[o==null?void 0:o.envelope.traceId]),S.useEffect(()=>{if(!o||z!=="research")return;const f=le(o);if(!f)return;x("tree"),h({kind:"span",spanId:f.spanId}),u(R=>Xe(o,f.spanId,R));const j=()=>{var R;return(R=document.getElementById(`ask-trace-span-${f.spanId}`))==null?void 0:R.focus()};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(j):j()},[z,o==null?void 0:o.envelope.traceId]);const b=()=>{var f;if(typeof window<"u"&&((f=window.history.state)!=null&&f.askTraceRunId)&&window.history.length>1){window.history.back();return}a({type:"OPEN_ASK_OBSERVABILITY"})},M=()=>a({type:"OPEN_ASK_OBSERVABILITY"}),N=f=>{h({kind:"span",spanId:f}),window.requestAnimationFrame(()=>{var j;return(j=document.getElementById(`ask-trace-span-${f}`))==null?void 0:j.focus()})};if(p&&!o)return r.jsx(Gt,{t:n});if(s&&!o)return r.jsx(fe,{t:n,message:s,onBack:b,onRetry:()=>window.location.reload()});if(!o)return r.jsx(fe,{t:n,message:"No local trace data is available for this Ask run.",onBack:b,onRetry:()=>window.location.reload()});const C=z==="research"?le(o):void 0,O=Ke(C);return r.jsx("main",{style:{flex:1,minWidth:0,overflow:"auto",background:n.appBg,color:n.textPrimary,fontFamily:n.font},children:r.jsxs("div",{style:{maxWidth:1600,margin:"0 auto",padding:_?"16px 14px 28px":"20px 24px 34px"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsxs("button",{type:"button",onClick:b,style:ye(n),children:[r.jsx(Pe,{size:14})," Back"]}),r.jsxs("button",{type:"button",onClick:M,style:{...ye(n),color:n.textMuted},children:[r.jsx(be,{size:13})," All local traces"]})]}),r.jsx(Je,{trace:o,t:n,onRefresh:()=>window.location.reload()}),C?r.jsx("div",{role:"status","aria-live":"polite",style:{margin:"0 0 12px",padding:"9px 11px",border:`1px solid ${n.accent}`,borderRadius:8,background:`${n.accent}0d`,color:n.textSecondary,fontSize:12,lineHeight:1.45},children:O??"Research evidence selected. This trace retains bounded branch verdicts. A lineage branch records local structural evidence only; it never represents provider, SQL, warehouse, result, or causal evidence."}):null,r.jsx(it,{trace:o,t:n,onSelectSpan:N}),r.jsxs("details",{style:{marginTop:14},children:[r.jsx("summary",{style:{cursor:"pointer",color:n.textSecondary,fontSize:13,fontWeight:750,padding:"8px 0"},children:"Advanced evidence"}),r.jsxs("div",{style:{marginTop:8},children:[o.runtimeReceiptV8?r.jsx(ot,{receipt:o.runtimeReceiptV8,t:n}):null,r.jsx(tt,{selected:y,onSelect:x,t:n}),y==="graph"?r.jsxs("div",{id:"ask-trace-panel-graph",role:"tabpanel","aria-labelledby":"ask-trace-tab-graph",style:me(_),children:[r.jsx(At,{trace:o,t:n,selection:l,onSelect:f=>h({kind:"span",spanId:f})}),r.jsx(ae,{trace:o,t:n,selection:l,candidateOffset:g,onCandidateOffset:k,showExcluded:T,onShowExcluded:$})]}):y==="timeline"?r.jsxs("div",{id:"ask-trace-panel-timeline",role:"tabpanel","aria-labelledby":"ask-trace-tab-timeline",style:me(_),children:[r.jsx(Ct,{trace:o,t:n,selection:l,onSelect:f=>h({kind:"span",spanId:f})}),r.jsx(ae,{trace:o,t:n,selection:l,candidateOffset:g,onCandidateOffset:k,showExcluded:T,onShowExcluded:$})]}):r.jsxs("div",{id:"ask-trace-panel-tree",role:"tabpanel","aria-labelledby":"ask-trace-tab-tree",style:Ut(_),children:[r.jsx(kt,{trace:o,t:n,query:m,onQuery:v,expanded:w,onExpanded:u,selection:l,onSelect:h,isNarrow:_}),r.jsx(ae,{trace:o,t:n,selection:l,candidateOffset:g,onCandidateOffset:k,showExcluded:T,onShowExcluded:$})]})]})]})]})})}function Ze(e){var s,d,p;const{envelope:t}=e,n=((s=e.runtimeReceiptV8)==null?void 0:s.mode)==="authoritative_v2"?e.runtimeReceiptV8:void 0,a=((d=n==null?void 0:n.tierAttempts.find(c=>c.frozen))==null?void 0:d.tier)??((p=n==null?void 0:n.tierAttempts.find(c=>c.outcome==="executed"))==null?void 0:p.tier)??(n==null?void 0:n.controllerTier),o=n?a:t.selectedTier,i=n?n.initialCandidateCount:t.candidateDecisionCount;return{selectedTier:o,candidateCount:i,candidateLabel:n?"candidate admissions":"candidate decisions"}}function Je({trace:e,t,onRefresh:n}){var p;const{envelope:a}=e,o=((p=e.runtimeReceiptV8)==null?void 0:p.mode)??e.runtimeMode,i=Ze(e),s=a.recordingStatus==="recording",d=a.status==="failed"||a.status==="blocked"||a.status==="interrupted";return r.jsxs("header",{style:{margin:"10px 0 16px",padding:"16px 18px",border:`1px solid ${t.cellBorder}`,borderRadius:12,background:t.cellBg},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"flex-start",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontSize:19,fontWeight:750,letterSpacing:"-0.015em"},children:"Ask trace"}),r.jsxs("div",{style:{marginTop:4,fontSize:12,color:t.textMuted,fontFamily:t.fontMono},children:["Run ",U(a.runId)," · Trace ",U(a.traceId)]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[r.jsx(Wt,{t,value:a.status,issue:d}),r.jsx(W,{t,icon:r.jsx(Fe,{size:12}),children:a.trustState??"Trust not recorded"}),o?r.jsx(W,{t,icon:r.jsx(ce,{size:12}),children:et(o)}):null,r.jsx(W,{t,icon:r.jsx(ce,{size:12}),children:i.selectedTier??"No executable tier"}),r.jsxs(W,{t,icon:r.jsx(Ie,{size:12}),children:[q(a.durationMs)," "]}),r.jsxs("button",{type:"button",onClick:n,title:"Refresh local trace evidence",style:Vt(t),children:[r.jsx(Be,{size:13,className:s?"ask-trace-recording":void 0}),r.jsx("span",{className:"sr-only",children:"Refresh trace"})]})]})]}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:12,fontSize:11.5,color:t.textMuted},children:[r.jsxs("span",{children:[a.spanCount," recorded stages"]}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsxs("span",{children:[i.candidateCount," ",i.candidateLabel]}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{children:Ht(a.recordingStatus)}),a.droppedRecordCount>0?r.jsxs("span",{role:"status",children:["· ",a.droppedRecordCount," bounded records omitted"]}):null]}),r.jsx("div",{style:{marginTop:9,fontSize:11,color:t.textMuted,lineHeight:1.45},children:"This local trace contains typed execution evidence only. Prompts, SQL text, result rows, provider responses, credentials, and file paths are not retained."})]})}function et(e){return e==="authoritative_v2"?"Authoritative V2 runtime":e==="shadow_v2"?"Shadow V2 observation · legacy V1 served answers":"Legacy V1 runtime"}function tt({selected:e,onSelect:t,t:n}){const a=[{id:"tree",label:"Trace Tree"},{id:"graph",label:"Agent Graph"},{id:"timeline",label:"Timeline"}];return r.jsx("div",{role:"tablist","aria-label":"Ask trace views",style:{display:"flex",gap:4,borderBottom:`1px solid ${n.cellBorder}`,marginBottom:14,overflowX:"auto"},children:a.map(o=>{const i=o.id===e;return r.jsx("button",{id:`ask-trace-tab-${o.id}`,type:"button",role:"tab","aria-selected":i,"aria-controls":`ask-trace-panel-${o.id}`,onClick:()=>t(o.id),style:{border:"none",borderBottom:`2px solid ${i?n.accent:"transparent"}`,background:"transparent",color:i?n.textPrimary:n.textMuted,cursor:"pointer",padding:"8px 10px",font:`650 12px ${n.font}`,whiteSpace:"nowrap"},children:o.label},o.id)})})}function an(e){var m;if(((m=e.runtimeReceiptV8)==null?void 0:m.mode)==="authoritative_v2")return nt(e.runtimeReceiptV8);if(e.runtimeDecisionSummary)return rt(e.runtimeDecisionSummary);if(e.decisionSummary)return at(e.decisionSummary);const t=ke(e),n=ft(e,t);if(n)return{state:"attention",whatHappened:"The Ask stopped because the requested relationship is not certified.",why:"The cascade recorded MISSING_RELATIONSHIP: this request needs a certified relationship or approved allocation proof.",impact:"No query executed; DQL did not infer a relationship or allocation for the requested ranking.",howToFix:"Add or certify the required relationship or approved allocation proof, then retry the Ask.",spanId:n.span.spanId};const a=mt(e,t);if(a)return{state:"attention",whatHappened:"The Ask needs a declared fiscal calendar and date role before it can answer.",why:"The fiscal-period request could not bind to a declared fiscal calendar and date role in the recorded snapshot.",impact:"No query executed; DQL is waiting for a choice that changes the analytical plan.",howToFix:"Select or declare the fiscal calendar and date role, then retry the Ask.",spanId:a.span.spanId};const i=ct(e),s=ie(e),d=(s==null?void 0:s.span)??e.spans.find(v=>v.payload.kind==="cascade"),p=bt(d),c=i?"The data result completed. This issue may affect the explanation or a follow-up, not the recorded result.":"No executable data answer was completed for this Ask run.",y=pt(e,t);if(y){const v=y.tier==="certified";return{state:"attention",whatHappened:v?"The frozen certified plan could not reach a database connection.":"The frozen analytical plan could not reach a database connection.",why:v?"The certified plan was frozen, but no database connection was configured before DQL could compile or execute its block.":"The selected plan was frozen, but no database connection was configured before DQL could compile or execute it.",impact:v?"No query or data result executed after the frozen certified plan.":"No query or data result executed after the frozen analytical plan.",howToFix:"Open Connections, add or select a warehouse or local DuckDB/file connection, then retry the Ask. Recorded safe action: configure a database connection.",spanId:y.span.spanId}}const x=lt(e,t);if(x)return{state:"attention",whatHappened:"The frozen semantic plan did not complete.",why:`The semantic plan was frozen, then ${ut(x.failureCode)}.`,impact:"No data result or query completed after the frozen semantic plan failed.",howToFix:`Configure or restore the required semantic compiler, semantic layer, or execution target, then retry. Recorded safe action: ${ht(x.safeAction)}.`,spanId:x.span.spanId};const l=!!(s&&(e.envelope.terminalOutcome==="needs_clarification"||!t||t.stage==="cascade"||t.outcome==="skipped"));if(l&&(s==null?void 0:s.decision.stopReason)==="ambiguous")return{state:"attention",whatHappened:"The Ask needs one ambiguity-changing business choice before it can answer.",why:"The cascade recorded more than one business meaning that would change the analytical plan.",impact:"No query executed; DQL is waiting for a choice that changes the analytical plan.",howToFix:"Select the requested business meaning, then retry the Ask.",spanId:s.span.spanId};if(l&&((s==null?void 0:s.decision.stopReason)==="coverage_gap"||(s==null?void 0:s.decision.stopReason)==="denied"||(s==null?void 0:s.decision.stopReason)==="post_freeze_failure")){const v=s.decision.stopReason==="denied",w=s.decision.stopReason==="post_freeze_failure",u=p.length?`The trace recorded incomplete coverage from ${p.join(", ")}.`:v?"The cascade recorded a policy or safety denial before a plan could continue.":w?"The selected plan failed after it was frozen, so DQL did not silently choose another tier.":"The available evidence did not produce one safe executable plan.";return{state:"attention",whatHappened:w?"The frozen analytical plan did not complete.":"The Ask flow stopped before it could freeze an executable analytical plan.",why:u,impact:c,howToFix:v?"Review the supported model, permitted scope, and approved relationship path, then retry the Ask.":p.length?"Refresh or restore the listed local sources, then retry the Ask.":"Use the recorded candidate and cascade evidence to resolve the missing business meaning, then retry.",spanId:s.span.spanId}}if(!t&&e.envelope.terminalOutcome==="needs_clarification")return{state:"attention",whatHappened:"The Ask is waiting for one clarification before it can answer.",why:"The recorded run ended in a clarification state without an executable plan.",impact:"No query executed while the required choice remains unresolved.",howToFix:"Provide the requested business choice, then retry the Ask."};if(!t)return{state:"healthy",whatHappened:"The recorded Ask flow completed without a terminal trace issue.",why:"The selected route reached its recorded terminal stage.",impact:i?"A data result was recorded for this Ask run.":"The trace records a completed non-query response.",howToFix:"No recovery action is required. Open a stage below only if you need the execution evidence."};const h=yt(t);return h?{state:"attention",whatHappened:"A provider-dependent stage did not complete.",why:`The recorded provider cause is ${h.cause}.`,impact:c,howToFix:h.safeAction,spanId:t.spanId}:t.name==="sql.authorize"||t.outcome==="denied"&&t.stage==="sql"?{state:"attention",whatHappened:"The SQL plan was not authorized for execution.",why:"The trace records a SQL authorization denial; execution was not attempted after that denial.",impact:c,howToFix:"Review the supported model, permitted scope, and approved relationship path, then retry the Ask.",spanId:t.spanId}:t.stage==="tool"?{state:"attention",whatHappened:"A required local tool step failed.",why:"The trace records a typed tool failure without retaining the raw tool error.",impact:c,howToFix:"Inspect the related stage and retry after the required local source or tool is available.",spanId:t.spanId}:t.stage==="cascade"?{state:"attention",whatHappened:"The Ask flow stopped before it could freeze an executable analytical plan.",why:p.length?`The trace recorded incomplete coverage from ${p.join(", ")}.`:"The available evidence did not produce one safe executable plan.",impact:c,howToFix:p.length?"Refresh or restore the listed local sources, then retry the Ask.":"Use the recorded candidate and cascade evidence to resolve the missing business meaning, then retry.",spanId:t.spanId}:{state:"attention",whatHappened:`The ${F(t.name)} stage did not complete.`,why:`The recorded outcome is ${Z(t.outcome)}.`,impact:c,howToFix:"Open the related stage to review its typed evidence and follow the recorded safe recovery action, if present.",spanId:t.spanId}}function nt(e){const t=e.terminalOutcome;if(!(t&&t.kind!=="finish_answer"))return{state:"healthy",whatHappened:"The bounded Ask tool runtime completed this answer.",why:`${e.tierAttempts.length} ordered tier attempt${e.tierAttempts.length===1?"":"s"} were recorded before the final answer.`,impact:e.outcome.executionAttempts>0?"The recorded plan reached execution; inspect the result and fact receipt for the validated answer.":"This turn completed without a warehouse execution.",howToFix:"No recovery action is required for the recorded run."};const a=t.origin.replace(/_/g," "),o=t.reasonCode.replace(/_/g," ").toLowerCase(),i=t.origin==="validation"&&/^SEMANTIC_(?:ENGINE|TIME|FILTER|IDENTIFIER|CAPABILITY)_/.test(t.reasonCode);return{state:"attention",whatHappened:i?"The Ask rejected the selected semantic tool binding before execution.":t.kind==="clarification"?"The Ask needs one business choice before it can continue.":t.kind==="provider_failure"?"The Ask stopped at the AI provider boundary.":t.kind==="execution_failure"?"The Ask stopped after the selected plan reached execution.":t.kind==="denied"?"The Ask stopped at a safety or authorization boundary.":t.kind==="budget_exhausted"?"The Ask reached its bounded work budget before it could complete.":"The Ask did not find one safe executable route in the recorded workspace.",why:`Terminal boundary: ${a}. Recorded reason: ${o}.`,impact:e.outcome.executionAttempts>0?"A selected plan was attempted, but no completed data answer was retained for this run.":i?"No warehouse execution was started because the snapshot-bound semantic contract was not valid.":"No warehouse execution was started for this run.",howToFix:t.safeAction?B(t.safeAction):"Review the typed tool observations and source coverage, then retry only after the recorded gap is addressed."}}function rt(e){return{state:/did not complete|paused|blocked/i.test(e.whatHappened)?"attention":"healthy",whatHappened:e.whatHappened,why:e.why,impact:e.impact,howToFix:B(e.nextAction)}}function at(e){var o;const t=e.terminalIncident,n=e.researchBranchSummary;if(!t&&(n!=null&&n.partialSuccess)){const i=n.failedBranches+n.timedOutBranches+n.skippedBranches;return{state:"attention",whatHappened:`Research completed with ${n.receiptBackedBranches} receipt-backed ${n.receiptBackedBranches===1?"finding":"findings"} and ${i} limited ${i===1?"branch":"branches"}.`,why:`Recorded branch reasons: ${Se(n)}.${oe(n)?` ${oe(n)}`:""}`,impact:"The completed receipt-backed finding remains available; failed, timed-out, or skipped branches are limitations, not discarded evidence.",howToFix:B(n.safeAction)}}if(!t)return{state:"healthy",whatHappened:e.selectedPlan?`The ${e.selectedPlan.tier.replace("_"," ")} plan completed its recorded Ask path.`:"The Ask completed without a terminal incident.",why:`The stored decision summary ${e.summaryFingerprint.slice(0,12)} recorded the selected plan and tier decisions.`,impact:(o=e.selectedPlan)!=null&&o.reviewRequired?e.selectedPlan.tier==="semantic"?"The result requires review because semantic execution used an inferred business or dimension mapping.":e.selectedPlan.tier==="exploratory_sql"?"The result is review-required because it used exploratory SQL.":"The result is review-required because the selected plan requires review.":"The recorded result retains its selected trust state.",howToFix:"No recovery action is required."};const a=B(t.safeAction);return{state:"attention",whatHappened:t.code==="INTERNAL_EXPLORATORY_AUTHORIZATION_STATE_MISMATCH"?"DQL rejected an inconsistent exploratory SQL authorization receipt before execution.":`The Ask stopped at ${t.boundary.replace("."," ")}.`,why:`Recorded origin: ${t.origin.replace("_"," ")}; impact: ${t.impact.replace(/_/g," ")}.`,impact:t.impact==="execution_not_attempted"?"No SQL execution was attempted for this Ask run.":"No accepted data answer was completed for this Ask run.",howToFix:a}}function B(e){return e==="export_redacted_trace"?"Export the redacted trace and share the recorded SQL authorization incident with DQL support.":e==="configure_connection"?"Configure the selected database connection, then retry the same Ask.":e==="change_authorized_connection"?"Choose an authorized connection that contains the recorded governed relation, then retry the same Ask.":e==="retry_same_plan"?"Retry the same frozen plan after the recorded condition is resolved.":e==="edit_dql"?"Edit the recorded governed DQL or semantic mapping, then retry the same Ask.":e==="open_sql_notebook"?"Open a SQL notebook to inspect the compiler-ready plan, correct it, then retry the same Ask.":e==="refresh_snapshot"?"Refresh the recorded local snapshot, then retry the same Ask.":e==="reapply_semantic_runtime"?"Reapply the configured semantic runtime for the frozen plan, then retry the same Ask.":e==="request_access"?"Request access to the recorded governed source, then retry the same Ask.":e==="review_analytical_failure"?"Review the recorded analytical failure before changing the frozen plan.":e==="inspect_research_failures"?"Inspect the failed or timed-out Research branches, then retry a narrower Research question if the missing evidence still matters.":e==="none"?"No automatic recovery is safe for this run.":"Inspect the recorded decision and advanced evidence before retrying."}function Se(e){return e.failureReasons.map(n=>`${n.code.replace(/_/g," ")}: ${n.branchCount}`).join(" · ")||"limited child branches were recorded without a displayable failure reason"}function oe(e){if(e.availableChildPlans.length!==0)return`Persisted child plans: ${e.availableChildPlans.map(t=>`${t.tier.replace(/_/g," ")} frozen ×${t.frozenPlanCount} for ${t.branchCount} ${t.branchCount===1?"branch":"branches"}${t.reviewRequired?" (review required)":""}`).join(" · ")}.`}function ot({receipt:e,t}){const n=e.observations.map((a,o)=>({sequence:o+1,tool:a.tool,outcome:a.outcome,tier:a.tier,reasonCode:a.reasonCode,candidateIds:a.candidateIds,planId:a.planId,frozen:a.frozen,retryable:a.retryable,safeAction:a.safeAction,durationMs:a.durationMs,inputFingerprint:a.inputFingerprint,outputFingerprint:a.outputFingerprint,origin:a.origin,provider:a.provider&&{phase:a.provider.phase,cause:a.provider.cause,retryable:a.provider.retryable,safeAction:a.provider.safeAction}}));return r.jsxs("section",{"aria-label":"V2 advanced decision evidence",style:{margin:"0 0 14px",padding:"12px 13px",border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg},children:[r.jsx("div",{style:{color:t.textSecondary,fontSize:12,fontWeight:750},children:"V2 tool-runtime evidence"}),r.jsx("div",{style:{marginTop:4,color:t.textMuted,fontSize:11.5,lineHeight:1.45},children:"Qualified IDs, source state, reason codes, structural fingerprints, and timings only. SQL/DQL text, result rows, prompts, credentials, provider responses, and hidden reasoning are not retained."}),r.jsx("pre",{style:{margin:"10px 0 0",padding:10,overflow:"auto",maxHeight:340,borderRadius:7,background:t.appBg,color:t.textSecondary,fontSize:10.5,lineHeight:1.45,fontFamily:t.fontMono},children:JSON.stringify({version:e.version,mode:e.mode,snapshotId:e.snapshotId,contextCoverage:e.contextCoverage,exclusions:{count:e.excludedCandidateCount,reasonCodes:e.exclusionReasonCodes},tierAttempts:e.tierAttempts,planFrozen:e.planFrozen,terminalOutcome:e.terminalOutcome,outcome:e.outcome,activity:e.activity,toolDurationMs:e.toolDurationMs,finalStopReason:e.finalStopReason,observations:n},null,2)})]})}function it({trace:e,t,onSelectSpan:n}){var m,v,w,u,g,k,T,$,_,D,z;const a=e.runtimeReceiptV8;if((a==null?void 0:a.mode)==="authoritative_v2"){const b=a.terminalOutcome,M=!!(b&&b.kind!=="finish_answer"),N=a.contextCoverage.length>0?a.contextCoverage.map(I=>`${I.source.replace(/_/g," ")}: ${I.status} (${I.admittedCandidateCount} admitted${I.excludedCandidateCount?`, ${I.excludedCandidateCount} outside workspace`:""})`).join(" · "):"No retrieval source coverage was retained for this older V2 run.",C=((m=a.activity)==null?void 0:m.toolCalls)??a.observations.length,O=((v=a.activity)==null?void 0:v.providerDispatches)??0,f=((w=a.activity)==null?void 0:w.executionAttempts)??a.outcome.executionAttempts,j=((u=a.activity)==null?void 0:u.repairs)??0,R=a.observations.filter(I=>I.origin==="validation"||I.outcome==="ineligible"||I.outcome==="ambiguous"||I.outcome==="unavailable"),E=a.observations.filter(I=>I.retryable).length,ne=((g=a.tierAttempts.find(I=>I.frozen))==null?void 0:g.tier)??((k=a.tierAttempts.find(I=>I.outcome==="executed"))==null?void 0:k.tier)??a.controllerTier,Ae=[["Objective",`${a.objective.replace(/_/g," ")} turn · ${a.mode.replace(/_/g," ")} runtime.`],["Context coverage",`${N}${a.excludedCandidateCount?` Total workspace exclusions: ${a.excludedCandidateCount} (${a.exclusionReasonCodes.map(I=>I.replace(/_/g," ").toLowerCase()).join(", ")}).`:""}`],["LLM & tool decisions",`${C} tool call${C===1?"":"s"} · ${O} physical provider dispatch${O===1?"":"es"} · ${a.expansionCount} same-snapshot expansion${a.expansionCount===1?"":"s"}.`],["Validation & correction",`${R.length} validation/coverage observation${R.length===1?"":"s"} · ${Math.max(E,j)} bounded correction${Math.max(E,j)===1?"":"s"}.`],["Cascade & freeze",`${a.tierAttempts.length} ordered tier attempt${a.tierAttempts.length===1?"":"s"} · ${(ne==null?void 0:ne.replace(/_/g," "))??"no executable tier"}${a.planFrozen?" · frozen":" · not frozen"}.`],["Connection & execution",`${a.outcome.connectionAttempted?"connection attempted":"no connection attempted"} · ${f} execution attempt${f===1?"":"s"}.`],["Facts & narration",`${a.outcome.factCount} validated fact${a.outcome.factCount===1?"":"s"} · ${a.outcome.narration.replace(/_/g," ")}.`],["Failure boundary",b?`${b.origin.replace(/_/g," ")} · ${b.kind.replace(/_/g," ")} · ${b.reasonCode.replace(/_/g," ").toLowerCase()}.`:"No terminal failure was retained."],["Safe next action",b!=null&&b.safeAction?B(b.safeAction):"Inspect the validated result or continue with a grounded follow-up."]];return r.jsxs("section",{"aria-label":"Ask decision story",style:{margin:"0 0 14px",padding:"14px 16px",border:`1px solid ${M?t.warning:t.success}`,borderRadius:11,background:t.cellBg},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,color:M?t.warning:t.success,fontSize:13,fontWeight:750},children:[M?r.jsx(L,{size:15,"aria-hidden":"true"}):r.jsx(K,{size:15,"aria-hidden":"true"}),"Ask decision story",r.jsxs("span",{style:{color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5,fontWeight:500},children:["V8 · ",a.snapshotId?U(a.snapshotId):"snapshot unavailable"]})]}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:11,marginTop:12},children:Ae.map(([I,_e])=>r.jsxs("div",{style:{minWidth:0},children:[r.jsx("div",{style:{color:t.textMuted,fontSize:10.5,fontWeight:750,letterSpacing:".025em",textTransform:"uppercase"},children:I}),r.jsx("div",{style:{marginTop:4,color:t.textSecondary,fontSize:12,lineHeight:1.45},children:_e})]},I))})]})}const o=e.runtimeDecisionSummary,i=e.runtimeReceiptV6,s=(T=e.runtimeReceiptV7)==null?void 0:T.inspector;if(o){const b=/did not complete|paused|blocked/i.test(o.whatHappened),M=($=i==null?void 0:i.roleCoverage)!=null&&$.length?i.roleCoverage.map(f=>`${f.role.replace(/_/g," ")}: ${f.candidateCount}`).join(" · "):void 0,N=i==null?void 0:i.planning,C=i==null?void 0:i.cascade,O=s?[["What happened",o.whatHappened],["Why",o.why],["Evidence",`${s.evidence.admittedCandidateCount} qualified candidates across ${s.evidence.roleCount} role${s.evidence.roleCount===1?"":"s"}${s.evidence.recoveryAttempted?"; one targeted recovery was attempted":""}.`],["Planner",`${s.planning.mode.replace(/_/g," ")} · ${s.planning.plannerCalls} planner call${s.planning.plannerCalls===1?"":"s"} · verification ${s.planning.verification.replace(/_/g," ")}.`],["Route",`${s.route.tierAttemptCount} tier attempt${s.route.tierAttemptCount===1?"":"s"} · ${((_=s.route.selectedTier)==null?void 0:_.replace(/_/g," "))??"no executable tier"}${s.route.planFrozen?" · frozen":" · not frozen"}${s.route.reviewRequired?" · review required":""}.`],["Answer outcome",`${s.outcome.connectionAttempted?"connection attempted":"no connection attempted"} · ${s.outcome.executionAttempts} execution attempt${s.outcome.executionAttempts===1?"":"s"} · ${s.outcome.factCount} validated fact${s.outcome.factCount===1?"":"s"} · ${s.outcome.narration.replace(/_/g," ")}.`],["Safe next action",B((i==null?void 0:i.safeNextAction)??o.nextAction)]]:[["What happened",o.whatHappened],["Why",o.why],["Impact",o.impact],["Role coverage",M??`${o.admittedCandidateCount} qualified candidate${o.admittedCandidateCount===1?"":"s"} admitted.`],["Planner & verification",N?`${N.mode.replace(/_/g," ")} · ${N.plannerCalls} planner call${N.plannerCalls===1?"":"s"} · verification ${N.verification.status.replace(/_/g," ")}.`:`${o.runtimeMode} · ${o.programTaskCount} task${o.programTaskCount===1?"":"s"} · deterministic receipt.`],["Cascade & freeze",C?`${C.attempts.length} tier attempt${C.attempts.length===1?"":"s"} · ${((D=C.selectedTier)==null?void 0:D.replace(/_/g," "))??"no executable tier"}${C.planFrozen?" · frozen":" · not frozen"}.`:`${o.selectedCompiler??"none"} · no cascade receipt.`],["Connection & execution",i?`${i.connection.attempted?"connection attempted after freeze":"no connection attempted"} · ${i.execution.attempts} execution attempt${i.execution.attempts===1?"":"s"}.`:`${o.selectedCompiler??"none"} · ${o.executionAttempts} execution attempt${o.executionAttempts===1?"":"s"}.`],["Facts",i?`${i.facts.factCount} validated fact${i.facts.factCount===1?"":"s"}${i.facts.resultFingerprint?" bound to the result.":"."}`:"No V6 fact receipt was retained."],...i!=null&&i.origin?[["Origin boundary",`${i.origin.boundary.replace(/_/g," ")} · ${i.origin.origin.replace(/_/g," ")} · ${i.origin.impact.replace(/_/g," ")}.`]]:[],...(z=i==null?void 0:i.story)!=null&&z.length?[["Decision path",i.story.map(f=>`${f.stage.replace(/_/g," ")}: ${f.status.replace(/_/g," ")}`).join(" · ")]]:[],["Safe next action",B((i==null?void 0:i.safeNextAction)??o.nextAction)]];return r.jsxs("section",{"aria-label":"Ask decision story",style:{margin:"0 0 14px",padding:"14px 16px",border:`1px solid ${b?t.warning:t.success}`,borderRadius:11,background:t.cellBg},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,color:b?t.warning:t.success,fontSize:13,fontWeight:750},children:[b?r.jsx(L,{size:15,"aria-hidden":"true"}):r.jsx(K,{size:15,"aria-hidden":"true"}),"Ask decision story",r.jsxs("span",{style:{color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5,fontWeight:500},children:["#",o.summaryFingerprint.slice(0,12)]})]}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:11,marginTop:12},children:O.map(([f,j])=>r.jsxs("div",{style:{minWidth:0},children:[r.jsx("div",{style:{color:t.textMuted,fontSize:10.5,fontWeight:750,letterSpacing:".025em",textTransform:"uppercase"},children:f}),r.jsx("div",{style:{marginTop:4,color:t.textSecondary,fontSize:12,lineHeight:1.45},children:j})]},f))})]})}const d=e.decisionSummary;if(!d)return r.jsxs("section",{"aria-label":"Ask decision story unavailable",style:{margin:"0 0 14px",padding:"14px 16px",border:`1px solid ${t.warning}`,borderRadius:11,background:t.cellBg},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,color:t.warning,fontSize:13,fontWeight:750},children:[r.jsx(L,{size:15,"aria-hidden":"true"})," Ask decision story"]}),r.jsxs("p",{style:{margin:"8px 0 0",color:t.textSecondary,fontSize:12,lineHeight:1.45},children:[Ve,"."]}),r.jsx("p",{style:{margin:"4px 0 0",color:t.textMuted,fontSize:11.5,lineHeight:1.45},children:"This trace predates the stored canonical summary. Raw stages remain available only in Advanced evidence."})]});const p=d.understoodRequest,c=d.researchBranchSummary,y=(c==null?void 0:c.partialSuccess)===!0,x=c?`${c.receiptBackedBranches} receipt-backed ${c.receiptBackedBranches===1?"finding":"findings"} · ${c.failedBranches} failed · ${c.timedOutBranches} timed out · ${c.skippedBranches} skipped. Reasons: ${Se(c)}. ${oe(c)??"No frozen child plan evidence was retained."} ${c.linkedChildRunCount} linked child ${c.linkedChildRunCount===1?"run":"runs"}.`:void 0,l=[["Understood request",`${p.measures} measure${p.measures===1?"":"s"}, ${p.dimensions} dimension${p.dimensions===1?"":"s"}${p.entityRequested?", an entity output":""}${p.ranking?`, ${p.ranking.direction} ${p.ranking.limit}${p.ranking.defaultedLimit?" (default)":""}`:""}. Conversation binding: ${p.conversationBinding.replace(/_/g," ")}.`],["Evidence by role",d.evidenceByRole.length>0?d.evidenceByRole.map(b=>`${b.role.replace(/_/g," ")}: ${b.candidateCount}`).join(" · "):"No role evidence was retained for this legacy-compatible run."],["Tier decisions",d.tierDecisions.length>0?d.tierDecisions.map(b=>`${b.tier}: ${b.outcome}${b.planFrozen?" (frozen)":""}`).join(" · "):"No cascade tier receipt was recorded."],["Selected plan",d.selectedPlan?`${d.selectedPlan.tier.replace("_"," ")}${d.selectedPlan.planFrozen?" frozen":""}${d.selectedPlan.reviewRequired?"; review required":""}.`:"No executable plan was selected."],...x?[["Research branch evidence",x]]:[],["Failure or repair",d.terminalIncident?`${d.terminalIncident.code.replace(/_/g," ")} at ${d.terminalIncident.boundary}; ${d.terminalIncident.impact.replace(/_/g," ")}.`:y?`Research limitations: ${c.failedBranches+c.timedOutBranches+c.skippedBranches} child branches did not complete; completed receipt-backed findings remain available.`:"No terminal incident was recorded."],["Safe next action",B(d.safeNextAction)]],h=!!(d.terminalIncident||y);return r.jsxs("section",{"aria-label":"Ask decision story",style:{margin:"0 0 14px",padding:"14px 16px",border:`1px solid ${h?t.warning:t.success}`,borderRadius:11,background:t.cellBg},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,color:h?t.warning:t.success,fontSize:13,fontWeight:750},children:[h?r.jsx(L,{size:15,"aria-hidden":"true"}):r.jsx(K,{size:15,"aria-hidden":"true"}),"Ask decision story",r.jsxs("span",{style:{color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5,fontWeight:500},children:["#",d.summaryFingerprint.slice(0,12)]})]}),r.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(210px, 1fr))",gap:11,marginTop:12},children:l.map(([b,M])=>r.jsxs("div",{style:{minWidth:0},children:[r.jsx("div",{style:{color:t.textMuted,fontSize:10.5,fontWeight:750,letterSpacing:".025em",textTransform:"uppercase"},children:b}),r.jsx("div",{style:{marginTop:4,color:t.textSecondary,fontSize:12,lineHeight:1.45},children:M})]},b))})]})}function ke(e){var o;const t=e.spans.filter(i=>re(i)&&st(e,i)).sort((i,s)=>s.ordinal-i.ordinal)[0];if(t)return t;const n=(o=ie(e))==null?void 0:o.span;if(n)return n;const a=e.envelope.firstIssueSpanId?e.spans.find(i=>i.spanId===e.envelope.firstIssueSpanId):void 0;return a&&re(a)&&!pe(a)?a:e.spans.filter(i=>re(i)&&!pe(i)).sort((i,s)=>s.ordinal-i.ordinal)[0]}function re(e){return e.outcome==="error"||e.outcome==="denied"||e.outcome==="unavailable"||e.outcome==="interrupted"||e.outcome==="cancelled"?!0:e.outcome==="skipped"&&["meaning_rejected","snapshot_unavailable","source_stale","source_unavailable","cascade_ambiguous","cascade_unavailable","cascade_denied","post_freeze_failure","provider_failure","tool_failure","sql_denied","sql_failure","execution_failed","cancelled","interrupted","recording_failure","cap_reached"].includes(e.reasonCode)}function pe(e){if(e.stage!=="cascade"||!e.name.startsWith("cascade.")||e.name==="cascade.evaluate"||e.name==="cascade.clarify_or_gap"||e.outcome!=="unavailable"&&!(e.outcome==="skipped"&&e.reasonCode==="cascade_ineligible"))return!1;const t=J(e),n=t==null?void 0:t.selectedTier,a=Array.isArray(t==null?void 0:t.attempts)?t==null?void 0:t.attempts[0]:void 0,o=a&&typeof a=="object"?a.outcome:void 0;return(t==null?void 0:t.stopReason)==="selected"&&typeof n=="string"&&n!==dt(e.name)&&(o==="unavailable"||o==="ineligible")}function st(e,t){return t.reasonCode==="post_freeze_failure"?!0:t.stage!=="provider"&&t.stage!=="tool"&&t.stage!=="sql"&&t.stage!=="result"?!1:e.spans.some(n=>n.name==="plan.freeze"&&n.outcome==="ok"&&n.ordinal<t.ordinal)}function dt(e){return{"cascade.certified":"certified","cascade.semantic":"semantic","cascade.governed_relational":"governed_relational","cascade.exploratory_sql":"exploratory_sql","cascade.clarify_or_gap":"clarify_or_gap"}[e]}function ct(e){return e.envelope.status==="completed"&&e.envelope.terminalOutcome!=="blocked"&&e.envelope.terminalOutcome!=="needs_clarification"&&e.envelope.terminalOutcome!=="cancelled"&&e.spans.some(n=>n.name==="result.normalize"&&n.outcome==="ok"&&n.payload.kind==="result"&&typeof n.payload.resultFingerprint=="string"&&/^(?:sha256:)?[a-f0-9]{64}$/i.test(n.payload.resultFingerprint))}function lt(e,t){if(!(!t||t.name!=="result.normalize"||t.reasonCode!=="post_freeze_failure"||t.payload.kind!=="result"||!e.spans.some(a=>{var o;return a.name==="plan.freeze"&&a.outcome==="ok"&&((o=J(a))==null?void 0:o.selectedTier)==="semantic"})))return{span:t,...typeof t.payload.failureCode=="string"?{failureCode:t.payload.failureCode}:{},...typeof t.payload.safeAction=="string"?{safeAction:t.payload.safeAction}:{}}}function pt(e,t){var o;if(!t||t.name!=="result.normalize"||t.reasonCode!=="post_freeze_failure"||t.payload.kind!=="result"||t.payload.failureCode!=="CONNECTION_NOT_CONFIGURED")return;const n=e.spans.filter(i=>i.name==="plan.freeze"&&i.outcome==="ok"&&i.ordinal<t.ordinal).sort((i,s)=>s.ordinal-i.ordinal)[0];if(!n)return;const a=(o=J(n))==null?void 0:o.selectedTier;return{span:t,...typeof a=="string"?{tier:a}:{}}}function ut(e){const t={COMPILATION_FAILED:"semantic compilation failed (COMPILATION_FAILED)",SEMANTIC_ADAPTER_NOT_READY:"the required semantic layer was unavailable (SEMANTIC_ADAPTER_NOT_READY)",SEMANTIC_TARGET_BINDING_MISSING:"the semantic execution target was unavailable (SEMANTIC_TARGET_BINDING_MISSING)",EXECUTION_TARGET_MISMATCH:"the semantic execution target did not match the frozen plan (EXECUTION_TARGET_MISMATCH)",SEMANTIC_SOURCE_DRIFT:"the semantic source drifted after planning (SEMANTIC_SOURCE_DRIFT)",SEMANTIC_MEMBER_BINDING_FAILED:"a semantic member could not bind to the frozen plan (SEMANTIC_MEMBER_BINDING_FAILED)",SEMANTIC_PATH_AMBIGUOUS:"the semantic relationship path remained ambiguous (SEMANTIC_PATH_AMBIGUOUS)",SEMANTIC_COMPILATION_TIMEOUT:"semantic compilation timed out (SEMANTIC_COMPILATION_TIMEOUT)"};return e&&t[e]?t[e]:"the typed semantic execution stage failed"}function ht(e){const t={inspect_failure:"inspect the typed failure",retry_same_plan:"retry the same frozen plan",retry_same_request:"retry the same request",refresh_snapshot:"refresh the local snapshot",edit_dql:"edit the governed DQL or semantic mapping",open_sql_notebook:"open the SQL Notebook for review",request_access:"request access to the authorized execution target",change_authorized_connection:"change the authorized connection",configure_connection:"configure a database connection",reapply_semantic_runtime:"reapply the semantic runtime",review_analytical_failure:"review the analytical failure"};return e&&t[e]?t[e]:"inspect the typed failure"}function ft(e,t){const n=t?G(t):void 0;if(n!=null&&n.decision.terminalGap)return n;const a=ie(e);return a!=null&&a.decision.terminalGap?a:e.spans.flatMap(o=>{const i=G(o);return i!=null&&i.decision.terminalGap?[i]:[]}).sort((o,i)=>i.span.ordinal-o.span.ordinal).find(o=>o.span.name==="cascade.evaluate")??e.spans.flatMap(o=>{const i=G(o);return i!=null&&i.decision.terminalGap?[i]:[]}).sort((o,i)=>i.span.ordinal-o.span.ordinal)[0]}function ie(e){const t=e.spans.flatMap(a=>{const o=G(a);return o?[o]:[]}).sort((a,o)=>o.span.ordinal-a.span.ordinal),n=t.find(a=>a.decision.stopReason==="ambiguous"&&a.decision.requiresDeclaredFiscalCalendar);return n||(t.find(a=>a.span.name==="cascade.clarify_or_gap")??t.find(a=>a.span.name==="cascade.evaluate")??t[0])}function mt(e,t){const n=t?G(t):void 0;if((n==null?void 0:n.decision.stopReason)==="ambiguous"&&n.decision.requiresDeclaredFiscalCalendar)return n;const a=e.spans.flatMap(o=>{const i=G(o);return i?[i]:[]}).filter(o=>o.decision.stopReason==="ambiguous"&&o.decision.requiresDeclaredFiscalCalendar).sort((o,i)=>i.span.ordinal-o.span.ordinal);return a.find(o=>o.span.name==="cascade.clarify_or_gap")??a[0]}function G(e){const t=gt(e);return t&&t.stopReason!=="selected"?{span:e,decision:t}:void 0}function gt(e){const t=J(e);if(!t)return;const n=t.stopReason;if(n!=="selected"&&n!=="ambiguous"&&n!=="coverage_gap"&&n!=="denied"&&n!=="post_freeze_failure")return;const a=xt(t);return{stopReason:n,requiresDeclaredFiscalCalendar:t.requiresDeclaredFiscalCalendar===!0,...a?{terminalGap:a}:{}}}function xt(e){const t=e.terminalGap;if(!t||typeof t!="object"||Array.isArray(t))return;const n=t;if(!(n.code!=="MISSING_RELATIONSHIP"||n.requirement!=="certified_relationship_or_allocation_proof"))return{code:"MISSING_RELATIONSHIP",requirement:"certified_relationship_or_allocation_proof"}}function J(e){if(e.payload.kind!=="cascade")return;const t=e.payload,n=t.decision;return n&&typeof n=="object"&&!Array.isArray(n)?n:t}function yt(e){if(e.payload.kind!=="provider")return;const t=e.payload.attempt,n=vt(t.cause);if(n)return{cause:wt(n),safeAction:It(t.safeAction)}}function bt(e){const t=e?J(e):void 0;return t?(Array.isArray(t.sourceCoverage)?t.sourceCoverage:[]).flatMap(a=>{if(!a||typeof a!="object")return[];const o=a,i=St(o.source),s=o.status;return i&&(s==="unavailable"||s==="errored"||s==="stale")?[i]:[]}):[]}function vt(e){return typeof e=="string"&&new Set(["authentication","model_not_found","rate_limited","gateway","network","provider_timeout","run_deadline","admission_denied","dispatch_budget","cancelled","unknown"]).has(e)?e:void 0}function wt(e){return{authentication:"authentication is not ready",model_not_found:"the selected model is unavailable",rate_limited:"the provider rate limit was reached",gateway:"the provider gateway failed",network:"the provider network request failed",provider_timeout:"the provider timed out",run_deadline:"the Ask run reached its deadline",admission_denied:"provider admission was denied",dispatch_budget:"the dispatch budget was exhausted",cancelled:"the run was cancelled",unknown:"an unknown provider condition occurred"}[e]??"an unknown provider condition occurred"}function It(e){const t={retry_same_provider:"Retry once with the same configured provider when the recorded retry policy allows it.",fix_provider_configuration:"Check the configured provider credentials and selected model, then retry.",wait_and_retry:"Wait for the provider limit to clear, then retry with the same provider.",inspect_run:"Inspect the related stage and local provider readiness evidence before retrying.",none:"No automatic recovery is safe. Inspect the related stage before changing configuration."};return typeof e=="string"&&t[e]?t[e]:"Inspect the related stage and local provider readiness evidence before retrying."}function St(e){return typeof e=="string"?{certified:"certified blocks",semantic:"semantic models",dbt_manifest:"dbt manifest",runtime_schema:"runtime schema",vector:"local vector index",graph:"relationship graph",conversation:"conversation context",business:"business context",safe_value:"safe value lookup",relational:"governed relationships"}[e]:void 0}function kt({trace:e,t,query:n,onQuery:a,expanded:o,onExpanded:i,selection:s,onSelect:d,isNarrow:p}){const c=S.useRef({}),y=S.useMemo(()=>zt(e.spans,e.envelope.rootSpanId),[e.spans,e.envelope.rootSpanId]),x=n.trim().toLowerCase().split(/\s+/).filter(Boolean),l=S.useMemo(()=>new Set(e.spans.filter(u=>Nt(u,x)).map(u=>u.spanId)),[e.spans,x]),h=S.useMemo(()=>{if(!x.length)return o;const u=new Set(o),g=new Map(e.spans.map(k=>[k.spanId,k.parentSpanId]));for(const k of l){let T=g.get(k);for(;T;)u.add(T),T=g.get(T)}return u},[o,l,x.length,e.spans]),m=S.useMemo(()=>Mt(y,h,x.length?l:void 0),[y,h,x.length,l]),v=(u,g)=>{var $;const k=m.indexOf(u),T=m[Math.max(0,Math.min(m.length-1,k+g))];T&&(($=c.current[T])==null||$.focus())},w=(u,g)=>{var k,T,$,_,D;if(u.key==="ArrowDown"&&(u.preventDefault(),v(g.span.spanId,1)),u.key==="ArrowUp"&&(u.preventDefault(),v(g.span.spanId,-1)),u.key==="ArrowRight"&&g.children.length>0&&(u.preventDefault(),h.has(g.span.spanId)?(T=c.current[(k=g.children[0])==null?void 0:k.span.spanId])==null||T.focus():i(new Set([...o,g.span.spanId]))),u.key==="ArrowLeft"&&g.children.length>0&&h.has(g.span.spanId)){u.preventDefault();const z=new Set(o);z.delete(g.span.spanId),i(z)}else u.key==="ArrowLeft"&&g.parentId&&(u.preventDefault(),($=c.current[g.parentId])==null||$.focus());u.key==="Home"&&(u.preventDefault(),(_=c.current[m[0]??""])==null||_.focus()),u.key==="End"&&(u.preventDefault(),(D=c.current[m[m.length-1]??""])==null||D.focus())};return r.jsxs("aside",{style:{position:p?"static":"sticky",top:0,maxHeight:p?void 0:"calc(100vh - 116px)",display:"flex",flexDirection:"column",minWidth:0,border:`1px solid ${t.cellBorder}`,borderRadius:11,background:t.cellBg,overflow:"hidden"},children:[r.jsxs("div",{style:{padding:"11px 11px 9px",borderBottom:`1px solid ${t.cellBorder}`},children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8,alignItems:"center",marginBottom:8},children:[r.jsx("strong",{style:{fontSize:12.5},children:"Trace tree"}),r.jsxs("span",{style:{color:t.textMuted,fontSize:10.5},children:[e.spans.length," stages"]})]}),r.jsxs("label",{style:{position:"relative",display:"block"},children:[r.jsx(be,{size:13,style:{position:"absolute",left:8,top:8,color:t.textMuted},"aria-hidden":"true"}),r.jsx("input",{value:n,onChange:u=>a(u.target.value),placeholder:"Search stage or reason","aria-label":"Search trace stages",style:{width:"100%",boxSizing:"border-box",padding:"7px 8px 7px 28px",borderRadius:7,background:t.inputBg,border:`1px solid ${t.inputBorder}`,color:t.textPrimary,font:`12px ${t.font}`}})]})]}),r.jsxs("div",{role:"tree","aria-label":"Ask trace stages",style:{overflow:"auto",padding:"7px 5px 10px"},children:[y.map(u=>r.jsx(Te,{node:u,depth:0,t,queryActive:x.length>0,matches:l,expanded:h,persistedExpanded:o,onExpanded:i,selection:s,onSelect:d,onKeyDown:w,registerRef:(g,k)=>{c.current[g]=k}},u.span.spanId)),e.candidateDecisions.length>0?r.jsxs("button",{type:"button",role:"treeitem","aria-selected":(s==null?void 0:s.kind)==="candidates",onClick:()=>d({kind:"candidates"}),style:{...$e(t,(s==null?void 0:s.kind)==="candidates"),marginTop:5,paddingLeft:9},children:[r.jsx(we,{size:12,"aria-hidden":"true"})," Candidate decisions ",r.jsx("span",{style:{marginLeft:"auto",color:t.textMuted},children:e.candidateDecisions.length})]}):null]})]})}function Te({node:e,depth:t,t:n,queryActive:a,matches:o,expanded:i,persistedExpanded:s,onExpanded:d,selection:p,onSelect:c,onKeyDown:y,registerRef:x}){const l=e.children.length>0,h=i.has(e.span.spanId),m=(p==null?void 0:p.kind)==="span"&&p.spanId===e.span.spanId;if(!(!a||o.has(e.span.spanId)||e.children.some(u=>se(u,o))))return null;const w=u=>{u.stopPropagation();const g=new Set(s);h?g.delete(e.span.spanId):g.add(e.span.spanId),d(g)};return r.jsxs("div",{role:"none",children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:[l?r.jsx("button",{type:"button","aria-label":`${h?"Collapse":"Expand"} ${F(e.span.name)}`,"aria-expanded":h,onClick:w,style:Yt(n),children:h?r.jsx(Ee,{size:13}):r.jsx(Le,{size:13})}):r.jsx("span",{style:{width:24,flexShrink:0}}),r.jsxs("button",{ref:u=>x(e.span.spanId,u),id:`ask-trace-span-${e.span.spanId}`,type:"button",role:"treeitem","aria-level":t+1,"aria-selected":m,"aria-expanded":l?h:void 0,"data-trace-tree-id":e.span.spanId,onClick:()=>c({kind:"span",spanId:e.span.spanId}),onKeyDown:u=>y(u,e),style:{...$e(n,m),paddingLeft:7,minHeight:29},children:[r.jsx(de,{outcome:e.span.outcome,size:12}),r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",textAlign:"left"},children:F(e.span.name)}),r.jsx("span",{style:{marginLeft:"auto",fontFamily:n.fontMono,color:n.textMuted,fontSize:9.5},children:q(e.span.durationMs)})]})]}),l&&h?r.jsx("div",{role:"group",style:{marginLeft:13,borderLeft:`1px solid ${n.cellBorder}`},children:e.children.map(u=>r.jsx(Te,{node:u,depth:t+1,t:n,queryActive:a,matches:o,expanded:i,persistedExpanded:s,onExpanded:d,selection:p,onSelect:c,onKeyDown:y,registerRef:x},u.span.spanId))}):null]})}function ae({trace:e,t,selection:n,candidateOffset:a,onCandidateOffset:o,showExcluded:i,onShowExcluded:s}){if((n==null?void 0:n.kind)==="candidates")return r.jsx(jt,{trace:e,t,offset:a,onOffset:o,showExcluded:i,onShowExcluded:s});const d=e.spans.find(p=>p.spanId===((n==null?void 0:n.kind)==="span"?n.spanId:e.envelope.rootSpanId))??e.spans[0];return d?r.jsx(Tt,{trace:e,span:d,t}):r.jsx(Qt,{t})}function Tt({trace:e,span:t,t:n}){const a=S.useMemo(()=>Et(t.payload),[t.payload]),o=e.spans.filter(i=>i.parentSpanId===t.spanId);return r.jsxs("section",{"aria-label":`Trace detail for ${F(t.name)}`,style:te(n),children:[r.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",justifyContent:"space-between",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[r.jsx(de,{outcome:t.outcome,size:16}),r.jsx("h1",{style:{fontSize:18,margin:0},children:F(t.name)})]}),r.jsxs("div",{style:{color:n.textMuted,fontSize:12,marginTop:5},children:["Stage: ",t.stage," · ",Z(t.outcome)," · ",qt(t.reasonCode)]})]}),r.jsx(W,{t:n,icon:r.jsx(Ie,{size:12}),children:q(t.durationMs)})]}),r.jsx(ue,{t:n,rows:[["Started",he(t.startedAt)],["Completed",t.completedAt?he(t.completedAt):"Still recording"],["Span ID",U(t.spanId)],["Parent span",t.parentSpanId?U(t.parentSpanId):"Trace root"]]}),r.jsxs("section",{style:ge(n),children:[r.jsx("h2",{style:xe(n),children:"Recorded evidence"}),a.length?r.jsx(ue,{t:n,rows:a}):r.jsx("p",{style:Q(n),children:"No additional typed evidence was recorded for this stage."})]}),r.jsxs("section",{style:ge(n),children:[r.jsx("h2",{style:xe(n),children:"Downstream stages"}),o.length?r.jsx("ul",{style:{margin:0,paddingLeft:18,color:n.textSecondary,fontSize:12.5,lineHeight:1.7},children:o.map(i=>r.jsxs("li",{children:[F(i.name)," — ",Z(i.outcome)," (",q(i.durationMs),")"]},i.spanId))}):r.jsx("p",{style:Q(n),children:"No downstream physical stage was recorded."})]}),r.jsx("p",{style:{...Q(n),marginTop:15},children:"Evidence is metadata-only. It explains what the system attempted without showing request text, SQL, values, or returned rows."})]})}function jt({trace:e,t,offset:n,onOffset:a,showExcluded:o,onShowExcluded:i}){const s=e.candidateDecisions.filter(l=>l.decision!=="excluded"),d=e.candidateDecisions.filter(l=>l.decision==="excluded"),p=o?[...s,...d]:s,c=p.slice(n,n+H),y=Math.min(Math.max(0,p.length-H),n+H),x=Math.max(0,n-H);return r.jsxs("section",{"aria-label":"Candidate decision detail",style:te(t),children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"flex-start",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{style:{fontSize:18,margin:0},children:"Candidate decisions"}),r.jsx("p",{style:{...Q(t),margin:"5px 0 0"},children:"Lifecycle evidence is recorded before ranking and package trimming. Candidate identifiers are qualified IDs, not definitions or values."})]}),r.jsxs(W,{t,icon:r.jsx(we,{size:12}),children:[e.candidateDecisions.length," total"]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,margin:"14px 0 8px",flexWrap:"wrap"},children:[r.jsxs("button",{type:"button",onClick:()=>{i(!o),a(0)},style:X(t),"aria-pressed":o,children:[r.jsx(De,{size:12})," ",o?"Hide exclusions":`Show ${d.length} exclusions`]}),r.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:["Showing ",p.length?n+1:0,"–",Math.min(n+H,p.length)," of ",p.length]})]}),r.jsx("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:8,overflow:"auto"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:640,fontSize:11.5},children:[r.jsx("thead",{children:r.jsxs("tr",{style:{background:t.tableHeaderBg,color:t.textMuted,textAlign:"left"},children:[r.jsx("th",{style:V,children:"Lifecycle"}),r.jsx("th",{style:V,children:"Role"}),r.jsx("th",{style:V,children:"Source"}),r.jsx("th",{style:V,children:"Reason"}),r.jsx("th",{style:V,children:"Qualified ID"})]})}),r.jsx("tbody",{children:c.map(l=>r.jsx($t,{candidate:l,t},`${l.sequence}-${l.candidateId}-${l.decision}`))})]})}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7,marginTop:10},children:[r.jsx("button",{type:"button",disabled:n===0,onClick:()=>a(x),style:X(t),children:"Previous 50"}),r.jsx("button",{type:"button",disabled:n+H>=p.length,onClick:()=>a(y),style:X(t),children:"Next 50"})]})]})}function $t({candidate:e,t}){return r.jsxs("tr",{children:[r.jsx("td",{style:Y(t),children:A(e.decision)}),r.jsx("td",{style:Y(t),children:A(e.role)}),r.jsx("td",{style:Y(t),children:A(e.source)}),r.jsx("td",{style:Y(t),children:A(e.reasonCode)}),r.jsx("td",{style:{...Y(t),fontFamily:t.fontMono,color:t.textMuted,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.candidateId,children:U(e.candidateId,22)})]})}function At({trace:e,t,selection:n,onSelect:a}){const o=S.useMemo(()=>Ft(e.spans,e.envelope.rootSpanId,e.envelope.traceId,e.links,t),[e.spans,e.envelope.rootSpanId,e.envelope.traceId,e.links,t]),i=e.spans.length>250;return r.jsxs("section",{style:{height:620,minHeight:420,border:`1px solid ${t.cellBorder}`,borderRadius:11,overflow:"hidden",background:t.cellBg},children:[r.jsx("div",{style:{padding:"10px 13px",borderBottom:`1px solid ${t.cellBorder}`,fontSize:11.5,color:t.textMuted},children:i?"Large trace: stages are grouped by physical stage to keep the graph navigable.":`${e.links.length?`${e.links.length} continuation or Research link${e.links.length===1?"":"s"} shown with dashed edges. `:""}Select a stage node to inspect its typed detail.`}),r.jsx("div",{style:{height:"calc(100% - 40px)"},children:r.jsxs(qe,{nodes:o.nodes,edges:o.edges,fitView:!0,minZoom:.25,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,onNodeClick:(s,d)=>{const p=String(d.id);o.spanIds.has(p)&&a(p)},colorMode:t.appBg.toLowerCase().includes("0")?"dark":"light",proOptions:{hideAttribution:!0},children:[r.jsx(Oe,{gap:18,size:1}),r.jsx(He,{showInteractive:!1})]})}),(n==null?void 0:n.kind)==="span"?r.jsxs("span",{className:"sr-only",children:["Selected stage ",n.spanId]}):null]})}function _t(e,t=Date.now()){const n=[...e.spans].sort((c,y)=>c.startedAt.localeCompare(y.startedAt)),a=P(e.envelope.startedAt)??t,o=Math.max(...n.map(c=>P(c.completedAt)??P(c.startedAt)??a),a+1),i=P(e.envelope.completedAt)??o,s=Math.max(1,ee(i-a)??1),d=ee(e.envelope.durationMs),p=n.map(c=>{const y=P(c.startedAt)??a,x=ee(c.durationMs),l=ee((P(c.completedAt)??y)-y),h=Math.max(1,x??l??1),m=Math.max(0,Math.min(100,(y-a)/s*100)),v=Math.max(1.5,Math.min(100-m,h/s*100)),w=q(x);return{span:c,recordedDurationMs:x,visualDurationMs:h,leftPercent:m,widthPercent:v,durationLabel:w,accessibleLabel:`${F(c.name)}. ${Z(c.outcome)}. ${w}.`}});return{totalLabel:q(d),rows:p}}function Ct({trace:e,t,selection:n,onSelect:a}){const o=_t(e);return r.jsxs("section",{style:te(t),children:[r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,alignItems:"baseline",flexWrap:"wrap"},children:[r.jsxs("div",{children:[r.jsx("h1",{style:{fontSize:18,margin:0},children:"Timeline"}),r.jsx("p",{style:{...Q(t),margin:"5px 0 10px"},children:"Waterfall of bounded physical stages. Durations are recorded locally; no external telemetry exporter is used."})]}),r.jsxs("span",{style:{color:t.textMuted,fontFamily:t.fontMono,fontSize:11},children:[o.totalLabel," total"]})]}),r.jsx("div",{style:{display:"grid",gap:5},children:o.rows.map(i=>{const{span:s}=i,d=(n==null?void 0:n.kind)==="span"&&n.spanId===s.spanId;return r.jsxs("button",{type:"button","aria-label":i.accessibleLabel,onClick:()=>a(s.spanId),style:{display:"grid",gridTemplateColumns:"minmax(150px, 260px) minmax(90px, 1fr) 58px",gap:8,alignItems:"center",border:0,background:d?`${t.accent}10`:"transparent",color:t.textPrimary,cursor:"pointer",borderRadius:6,padding:"5px 6px",textAlign:"left"},children:[r.jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12},children:[r.jsx(de,{outcome:s.outcome,size:11})," ",F(s.name)]}),r.jsx("span",{style:{height:13,position:"relative",borderRadius:99,background:t.tableHeaderBg,overflow:"hidden"},children:r.jsx("span",{"data-trace-timeline-bar":s.spanId,style:{position:"absolute",left:`${i.leftPercent}%`,width:`${i.widthPercent}%`,top:0,bottom:0,borderRadius:99,background:je(t,s.outcome)}})}),r.jsx("span",{style:{color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5,textAlign:"right"},children:i.durationLabel})]},s.spanId)})})]})}function Rt(e){var o,i;const t=new Map(e.spans.map(s=>[s.spanId,s])),n=new Set([e.envelope.rootSpanId]);for(const s of e.spans)s.parentSpanId===e.envelope.rootSpanId&&n.add(s.spanId);let a=((o=ke(e))==null?void 0:o.spanId)??e.envelope.firstIssueSpanId;for(;a;)n.add(a),a=(i=t.get(a))==null?void 0:i.parentSpanId;return n}function zt(e,t){const n=new Map(e.map(s=>[s.spanId,{span:s,parentId:s.parentSpanId,children:[]}])),a=[];for(const s of n.values()){const d=s.parentId?n.get(s.parentId):void 0;d&&d.span.spanId!==s.span.spanId?d.children.push(s):a.push(s)}const o=(s,d)=>s.span.ordinal-d.span.ordinal;for(const s of n.values())s.children.sort(o);a.sort(o);const i=n.get(t);return i&&!a.includes(i)?[i,...a.filter(s=>s!==i)]:a}function Mt(e,t,n){const a=[],o=i=>{if((!n||n.has(i.span.spanId)||se(i,n))&&(a.push(i.span.spanId),t.has(i.span.spanId)))for(const d of i.children)o(d)};for(const i of e)o(i);return a}function se(e,t){return t.has(e.span.spanId)||e.children.some(n=>se(n,t))}function Nt(e,t){if(!t.length)return!0;const n=`${e.name} ${e.stage} ${e.outcome} ${e.reasonCode} ${e.payload.kind}`.toLowerCase();return t.every(a=>n.includes(a))}function Ft(e,t,n,a,o){const i=e.length>250?Bt(e):e,s=new Map(i.map(l=>[l.spanId,l])),d=l=>{var w;let h=0,m=l.parentSpanId;const v=new Set;for(;m&&s.has(m)&&!v.has(m);)h+=1,v.add(m),m=(w=s.get(m))==null?void 0:w.parentSpanId;return h},p=new Map,c=i.map(l=>{const h=d(l),m=p.get(h)??0;return p.set(h,m+1),{id:l.spanId,position:{x:h*230+28,y:m*78+22},data:{label:`${F(l.name)}
7
+ ${Z(l.outcome)} · ${q(l.durationMs)}`},style:{width:190,borderRadius:8,border:`1px solid ${je(o,l.outcome)}`,background:o.cellBg,color:o.textPrimary,fontSize:11,lineHeight:1.35,whiteSpace:"pre-line",padding:8}}}),y=i.filter(l=>l.parentSpanId&&s.has(l.parentSpanId)).map(l=>({id:`${l.parentSpanId}-${l.spanId}`,source:l.parentSpanId,target:l.spanId,style:{stroke:o.cellBorderActive},animated:!1})),x=[];return a.forEach((l,h)=>{var g;const m=l.sourceTraceId===n,v=l.targetTraceId===n;if(!m&&!v)return;const w=`trace-link-${h}`;x.push({id:w,position:{x:(m?1:-1)*240+28,y:Math.max(c.length,1)*78+x.length*68+22},data:{label:`${A(l.kind)}
8
+ linked Ask or Research run`},style:{width:190,borderRadius:8,border:`1px dashed ${o.accent}`,background:o.tableHeaderBg,color:o.textPrimary,fontSize:11,lineHeight:1.35,whiteSpace:"pre-line",padding:8},selectable:!1});const u=s.has(t)?t:(g=i[0])==null?void 0:g.spanId;u&&(m?y.push({id:`trace-link-${h}-out`,source:u,target:w,label:A(l.kind),style:{stroke:o.accent,strokeDasharray:"5 4"},labelStyle:{fill:o.textMuted,fontSize:10}}):y.push({id:`trace-link-${h}-in`,source:w,target:u,label:A(l.kind),style:{stroke:o.accent,strokeDasharray:"5 4"},labelStyle:{fill:o.textMuted,fontSize:10}}))}),c.push(...x),!c.some(l=>l.id===t)&&c.length&&(c[0].style={...c[0].style,borderColor:o.accent}),{nodes:c,edges:y,spanIds:new Set(i.map(l=>l.spanId))}}function Bt(e){const t=new Map;for(const n of e)t.set(n.stage,[...t.get(n.stage)??[],n]);return[...t.values()].map((n,a)=>{const o=n[0];return{...o,spanId:`group-${o.stage}-${a}`,parentSpanId:void 0,name:o.name,ordinal:a,durationMs:n.reduce((i,s)=>i+(s.durationMs??0),0),payload:{kind:"stage",count:n.length}}})}function ue({t:e,rows:t}){return r.jsx("dl",{style:{display:"grid",gridTemplateColumns:"minmax(120px, 0.36fr) minmax(0, 1fr)",gap:"7px 12px",margin:"16px 0 0",fontSize:12},children:t.map(([n,a])=>r.jsx(Dt,{label:n,value:a,t:e},n))})}function Dt({label:e,value:t,t:n}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:n.textMuted},children:e}),r.jsx("dd",{style:{margin:0,color:n.textSecondary,wordBreak:"break-word"},children:t})]})}function Et(e){const t=[];for(const[n,a]of Object.entries(e))n==="kind"||a===void 0||t.push([Ot(n),Lt(a)]);return t}function Lt(e){return e===null?"None":typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?e.length?`${e.length} recorded identifiers`:"None":typeof e=="object"?`${Object.keys(e).length} recorded fields`:"Not recorded"}function A(e){return e.replace(/_/g," ")}function Z(e){return A(e)}function qt(e){return A(e)}function F(e){return A(e.replace(/\./g," · "))}function Ot(e){return A(e.replace(/([A-Z])/g," $1")).replace(/^./,t=>t.toUpperCase())}function P(e){const t=e?Date.parse(e):Number.NaN;return Number.isFinite(t)?t:void 0}function ee(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function he(e){const t=new Date(e);return Number.isNaN(t.getTime())?"Not recorded":t.toLocaleString()}function q(e){return e===0?"0 ms":typeof e!="number"||!Number.isFinite(e)||e<0?"—":e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(e<1e4?1:0)} s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function U(e,t=16){return e.length<=t?e:`${e.slice(0,Math.max(6,Math.floor(t/2)))}…${e.slice(-Math.max(4,Math.floor(t/3)))}`}function Ht(e){return A(e)}function Pt(e){return e instanceof Error&&e.message?e.message:"Unable to load local trace evidence."}function de({outcome:e,size:t}){return e==="ok"?r.jsx(K,{size:t,"aria-label":"Completed"}):e==="error"||e==="denied"?r.jsx(We,{size:t,"aria-label":e==="denied"?"Denied":"Failed"}):e==="unavailable"||e==="interrupted"?r.jsx(L,{size:t,"aria-label":e}):e==="cancelled"||e==="skipped"?r.jsx(Qe,{size:t,"aria-label":e}):r.jsx(ve,{size:t,"aria-label":"Recording"})}function je(e,t){return t==="ok"?e.success:t==="error"||t==="denied"?e.error:t==="unavailable"||t==="interrupted"?e.warning:e.textMuted}function W({t:e,icon:t,children:n}){return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 7px",border:`1px solid ${e.cellBorder}`,borderRadius:999,color:e.textSecondary,fontSize:10.5,lineHeight:1.1,background:e.tableHeaderBg},children:[t,n]})}function Wt({t:e,value:t,issue:n}){return r.jsxs("span",{role:"status",style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 7px",border:`1px solid ${n?e.error:e.success}`,borderRadius:999,color:n?e.error:e.success,fontSize:10.5,fontWeight:700,background:n?`${e.error}0d`:`${e.success}0d`},children:[n?r.jsx(L,{size:12}):r.jsx(K,{size:12}),t]})}function Gt({t:e}){return r.jsx("div",{role:"status","aria-live":"polite",style:{flex:1,display:"grid",placeItems:"center",color:e.textMuted,fontFamily:e.font},children:r.jsxs("span",{style:{display:"inline-flex",gap:8,alignItems:"center"},children:[r.jsx(ve,{size:16})," Loading local Ask trace…"]})})}function fe({t:e,message:t,onBack:n,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"42px auto",maxWidth:640,padding:22,border:`1px solid ${e.error}`,borderRadius:11,color:e.textPrimary,fontFamily:e.font,background:e.cellBg},children:[r.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",color:e.error,fontWeight:700},children:[r.jsx(L,{size:17})," Trace unavailable"]}),r.jsx("p",{style:{color:e.textSecondary,lineHeight:1.5},children:t}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{type:"button",onClick:a,style:X(e),children:"Retry"}),r.jsx("button",{type:"button",onClick:n,style:X(e),children:"Back to Ask AI"})]})]})}function Qt({t:e}){return r.jsxs("section",{style:te(e),children:[r.jsx("h1",{style:{fontSize:18,marginTop:0},children:"No stage selected"}),r.jsx("p",{style:Q(e),children:"Select a trace stage or candidate decision from the tree."})]})}const te=e=>({padding:"18px",minWidth:0,border:`1px solid ${e.cellBorder}`,borderRadius:11,background:e.cellBg}),me=e=>({display:"grid",gridTemplateColumns:e?"minmax(0, 1fr)":"minmax(300px, 1.15fr) minmax(300px, 0.85fr)",gap:14,alignItems:"start"}),Ut=e=>({display:"grid",gridTemplateColumns:e?"minmax(0, 1fr)":"minmax(300px, 350px) minmax(0, 1fr)",gap:14,alignItems:"start"}),ge=e=>({marginTop:16,paddingTop:14,borderTop:`1px solid ${e.cellBorder}`}),xe=e=>({margin:"0 0 8px",fontSize:12.5,color:e.textPrimary}),Q=e=>({color:e.textMuted,fontSize:12,lineHeight:1.5}),ye=e=>({display:"inline-flex",alignItems:"center",gap:5,padding:0,border:0,background:"transparent",color:e.textMuted,cursor:"pointer",font:`600 12px ${e.font}`}),Vt=e=>({display:"inline-grid",placeItems:"center",width:27,height:27,border:`1px solid ${e.cellBorder}`,borderRadius:7,background:e.cellBg,color:e.textSecondary,cursor:"pointer"}),Yt=e=>({display:"grid",placeItems:"center",flex:"0 0 24px",width:24,height:29,padding:0,border:0,background:"transparent",color:e.textMuted,cursor:"pointer"}),$e=(e,t)=>({display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,padding:"5px 7px",border:`1px solid ${t?e.accent:"transparent"}`,borderRadius:6,background:t?`${e.accent}12`:"transparent",color:t?e.textPrimary:e.textSecondary,cursor:"pointer",font:`500 11px ${e.font}`}),X=e=>({display:"inline-flex",alignItems:"center",gap:5,padding:"6px 8px",border:`1px solid ${e.cellBorder}`,borderRadius:7,background:e.cellBg,color:e.textSecondary,cursor:"pointer",font:`600 11px ${e.font}`}),V={padding:"8px 9px",fontSize:10,fontWeight:750,letterSpacing:".02em",whiteSpace:"nowrap"},Y=e=>({padding:"8px 9px",borderTop:`1px solid ${e.cellBorder}`,color:e.textSecondary,verticalAlign:"top"});export{rn as AskTracePage,Ve as CANONICAL_DECISION_SUMMARY_UNAVAILABLE,it as TraceDecisionStory,Ct as TraceTimeline,Ye as askTraceFocusFromSearch,zt as buildSpanTree,Mt as flattenVisibleTree,q as formatMs,an as incidentSummaryForTrace,at as incidentSummaryFromDecisionSummary,rt as incidentSummaryFromRuntimeDecisionSummary,nt as incidentSummaryFromRuntimeReceiptV8,Ke as lineageResearchStoryForSpan,le as researchFocusSpanForTrace,F as stageLabel,Ft as traceGraph,Ze as traceHeaderFacts,Rt as traceInitialExpanded,_t as traceTimelinePresentation};