@duckcodeailabs/dql-cli 1.13.2 → 1.13.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 (70) hide show
  1. package/dist/apps-api.d.ts +26 -3
  2. package/dist/apps-api.d.ts.map +1 -1
  3. package/dist/apps-api.js +1045 -175
  4. package/dist/apps-api.js.map +1 -1
  5. package/dist/assets/dql-notebook/assets/{AgentLogPage-BlUE3qsX.js → AgentLogPage-DYmHO6_i.js} +1 -1
  6. package/dist/assets/dql-notebook/assets/{AiBuildDialog-O88iK6UW.js → AiBuildDialog-BfhaOd1h.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/{AiBuildResult-D-6G4Sh3.js → AiBuildResult-DLKFAe6R.js} +3 -3
  8. package/dist/assets/dql-notebook/assets/{AiSidePanel-MRSGtQDV.js → AiSidePanel-C6Z3URGr.js} +1 -1
  9. package/dist/assets/dql-notebook/assets/{AnalyticsHome-CcRVO6zN.js → AnalyticsHome-uG3xCP_s.js} +1 -1
  10. package/dist/assets/dql-notebook/assets/AppsView-DfieNjkh.js +5595 -0
  11. package/dist/assets/dql-notebook/assets/BlockStudio-90J_wvWL.js +55 -0
  12. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-itEIUrYy.js → BusinessArtifactView-_zSMae5q.js} +1 -1
  13. package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-CbAqOpNc.js → DbtFirstModelingPage-DoXiPssu.js} +4 -4
  14. package/dist/assets/dql-notebook/assets/{GitPage-BxOqRYu2.js → GitPage-CUfAhS67.js} +3 -3
  15. package/dist/assets/dql-notebook/assets/{GlobalAiRail-Tfkx76CI.js → GlobalAiRail-ovtL7nQu.js} +1 -1
  16. package/dist/assets/dql-notebook/assets/{GovernedContextPage-CeaDbepP.js → GovernedContextPage-CaMiKAzA.js} +3 -3
  17. package/dist/assets/dql-notebook/assets/{HelpDocsPage-D1lAryYv.js → HelpDocsPage-CEGUx28b.js} +1 -1
  18. package/dist/assets/dql-notebook/assets/{HomePage-GB6se6xW.js → HomePage-2v3SRf8V.js} +1 -1
  19. package/dist/assets/dql-notebook/assets/{LineageDAG-zCyN-hdg.js → LineageDAG-AaqLEiBN.js} +1 -1
  20. package/dist/assets/dql-notebook/assets/{LineageDetailView-Cg0TgG2Y.js → LineageDetailView-CFc8pm91.js} +1 -1
  21. package/dist/assets/dql-notebook/assets/{LineageDrawer-DwMcenDf.js → LineageDrawer-DOkFjPq-.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-DUZx3ksU.js → LineagePathBreadcrumb-BrDwCuMs.js} +3 -3
  23. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-DT_ycl6s.js → MiniLineageGraph-CiHtQs3y.js} +1 -1
  24. package/dist/assets/dql-notebook/assets/{NewBlockModal-qdhzeJPF.js → NewBlockModal-DAgJZbws.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{NewNotebookModal-BnaDzs1A.js → NewNotebookModal-xjG7nZ3O.js} +1 -1
  26. package/dist/assets/dql-notebook/assets/{NotebookEditor-CouPFzdo.js → NotebookEditor-CXZaKfYT.js} +1 -1
  27. package/dist/assets/dql-notebook/assets/{ReadinessPage-DB_KbH9Y.js → ReadinessPage-MuJBFwwg.js} +1 -1
  28. package/dist/assets/dql-notebook/assets/{SetupOnboarding-CamQq_N2.js → SetupOnboarding-vKFtKtjh.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/{SkillsPage--mYkOAK2.js → SkillsPage-DCFVOV5f.js} +1 -1
  30. package/dist/assets/dql-notebook/assets/{TrustBadge-ClEYiYeA.js → TrustBadge-TcwXFFHK.js} +1 -1
  31. package/dist/assets/dql-notebook/assets/{UnifiedAgentRunPanel-DBfsmXes.js → UnifiedAgentRunPanel-Cu-YgIe4.js} +1 -1
  32. package/dist/assets/dql-notebook/assets/{answer-to-notebook-Cg3UyGwh.js → answer-to-notebook-DCFWlHB7.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{arrow-left-DnYPGqlr.js → arrow-left-BLnlJAtp.js} +1 -1
  34. package/dist/assets/dql-notebook/assets/{arrow-right-Ct_YGrmU.js → arrow-right-BmUAb1aW.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/{book-open-text-DULlwbj6.js → book-open-text-bdSChSag.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{circle-x-ByYxoiS9.js → circle-x-Cc6dEaf4.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{dagre.esm-BjYSO53F.js → dagre.esm-CPebQKQ9.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{external-link-DprWh9Yf.js → external-link-rmXvubf3.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{grip-vertical-CrEEYkXN.js → grip-vertical-Sg4zd5-Q.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/index-mQd_pC-P.js +635 -0
  41. package/dist/assets/dql-notebook/assets/{link-2-BkW-rkEC.js → link-2-BLaPoFxW.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{list-tree-BipBLmIE.js → list-tree-j0s4asFK.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/{minimize-2-BhXsglrO.js → minimize-2-Cl4pef4s.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{panel-right-open-BoCSilYB.js → panel-right-open-Clz-FtWi.js} +1 -1
  45. package/dist/assets/dql-notebook/assets/{play-mdoZawPu.js → play-DFdazMg7.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/{rotate-ccw-ELiDRUmj.js → rotate-ccw-C3tTaR7s.js} +1 -1
  47. package/dist/assets/dql-notebook/assets/{semantic-fields-DVNRLfeU.js → semantic-fields-DIAhTlfy.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{sliders-horizontal-GeUzpmKz.js → sliders-horizontal-BUiu2tfY.js} +1 -1
  49. package/dist/assets/dql-notebook/assets/{star-D63O81Wp.js → star--Yq77aH4.js} +1 -1
  50. package/dist/assets/dql-notebook/assets/{triangle-alert-BWrCxQVE.js → triangle-alert-D5Ng-xZO.js} +1 -1
  51. package/dist/assets/dql-notebook/assets/{upload-CI-ldXhC.js → upload-L8BKQAxP.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-Cv7Yq2hK.js → usePersistedAgentThreadId-DBu97YaM.js} +1 -1
  53. package/dist/assets/dql-notebook/assets/{user-round-Do21aFGo.js → user-round-BK5N1cJW.js} +1 -1
  54. package/dist/assets/dql-notebook/assets/{wand-sparkles-DT7u7F_x.js → wand-sparkles-D8XDQD9z.js} +1 -1
  55. package/dist/assets/dql-notebook/assets/{workflow-DHh2mMbn.js → workflow-Bl9zwG0q.js} +1 -1
  56. package/dist/assets/dql-notebook/assets/{wrench-7tYr_GKb.js → wrench-C-zLCMbW.js} +1 -1
  57. package/dist/assets/dql-notebook/assets/{x-CcYceFMz.js → x-stiJ-sP7.js} +1 -1
  58. package/dist/assets/dql-notebook/index.html +1 -1
  59. package/dist/local-operation-coordinator.d.ts.map +1 -1
  60. package/dist/local-operation-coordinator.js +16 -2
  61. package/dist/local-operation-coordinator.js.map +1 -1
  62. package/dist/local-runtime.d.ts +55 -19
  63. package/dist/local-runtime.d.ts.map +1 -1
  64. package/dist/local-runtime.js +1098 -581
  65. package/dist/local-runtime.js.map +1 -1
  66. package/dist/package.json +10 -10
  67. package/package.json +10 -10
  68. package/dist/assets/dql-notebook/assets/AppsView-BTkGC-wl.js +0 -5588
  69. package/dist/assets/dql-notebook/assets/BlockStudio-BrTNaDpb.js +0 -55
  70. package/dist/assets/dql-notebook/assets/index-9w93YPF9.js +0 -635
@@ -1 +1 @@
1
- import{u as x,t as m,j as n,G as y,aH as j,r as b,f as k}from"./index-9w93YPF9.js";import{A as S}from"./arrow-left-DnYPGqlr.js";import{W as M}from"./wrench-7tYr_GKb.js";import{C as v}from"./circle-x-ByYxoiS9.js";import"./react-CRB3T2We.js";function H(){const{state:e,dispatch:t}=x(),r=m[e.themeMode],s=e.agentLogRun;return s?n.jsxs("div",{style:{padding:"20px 28px",fontFamily:r.font,color:r.textPrimary,maxWidth:900,margin:"0 auto"},children:[n.jsxs("button",{type:"button",onClick:()=>t({type:"SET_MAIN_VIEW",view:"ask"}),style:C(r),children:[n.jsx(S,{size:14})," Back to Ask AI"]}),n.jsx(w,{run:s,t:r}),n.jsx(z,{run:s,t:r}),u(s).reason&&n.jsx(W,{run:s,t:r}),s.evaluations.length>0&&n.jsx(I,{run:s,t:r})]}):n.jsx("div",{style:{padding:32,color:r.textMuted,fontFamily:r.font},children:"No agent run selected. Open one from the “View steps” link on an AI answer."})}function w({run:e,t}){const r=f(e.startedAt,e.completedAt);return n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:8,lineHeight:1.35},children:e.question}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[n.jsxs("span",{style:c(t),children:[n.jsx(y,{size:12})," ",p(e.route)]}),n.jsx("span",{style:N(t,e.trustState),children:_(e.trustState)}),r!=null&&n.jsxs("span",{style:c(t),children:[n.jsx(j,{size:12})," ",g(r)," total"]}),n.jsx("span",{style:{...c(t),color:t.textMuted},children:e.status})]})]})}function z({run:e,t}){const r=b.useMemo(()=>$(e),[e]),s=r.reduce((i,o)=>Math.max(i,o.deltaMs),0);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"What the agent did · where the time went"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(i=>{const o=s>0&&i.deltaMs===s&&i.deltaMs>=250;return n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 10px",borderRadius:8,background:o?l(t.warning,.1):t.cellBg,border:`1px solid ${o?l(t.warning,.4):t.cellBorder}`},children:[n.jsx("span",{style:{marginTop:1,color:i.isTool?t.accent:t.textMuted,flexShrink:0},children:i.isTool?n.jsx(M,{size:13}):n.jsx("span",{style:{fontSize:13},children:"•"})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:500},children:i.label}),i.detail&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2,wordBreak:"break-word"},children:i.detail})]}),n.jsx("span",{style:{fontSize:12,fontFamily:t.fontMono,color:o?t.warning:t.textMuted,fontWeight:o?600:400,flexShrink:0,whiteSpace:"nowrap"},children:i.deltaMs>0?`+${g(i.deltaMs)}`:"—"})]},i.key)})}),s>=1e3&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:8},children:"The highlighted step took the longest. Long generation/tool steps usually mean the question fell through to LLM generation — a governed metric or certified block would answer it instantly."})]})}function W({run:e,t}){const r=u(e);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Why this route"}),n.jsxs("div",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.5},children:[r.reason,typeof r.confidence=="number"&&n.jsxs("span",{style:{color:t.textMuted},children:[" · confidence ",(r.confidence*100).toFixed(0),"%"]})]})]})}function u(e){const t=e.routeDecision;return{reason:typeof(t==null?void 0:t.reason)=="string"?t.reason:void 0,confidence:typeof(t==null?void 0:t.confidence)=="number"?t.confidence:void 0}}function I({run:e,t}){return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Governance checks"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.evaluations.map(r=>n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:13},children:[n.jsx("span",{style:{marginTop:1,color:r.passed?t.success:t.error,flexShrink:0},children:r.passed?n.jsx(k,{size:14}):n.jsx(v,{size:14})}),n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:500},children:r.label}),!r.passed&&r.message&&n.jsxs("span",{style:{color:t.textMuted},children:[" — ",r.message]})]})]},r.id))})]})}function d({t:e,children:t}){return n.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:e.textMuted,marginBottom:10},children:t})}function $(e){var i;const t=[...e.events].sort((o,a)=>o.at.localeCompare(a.at)),r=[];let s=e.startedAt??((i=t[0])==null?void 0:i.at);for(const o of t){const a=T(o);if(!a)continue;const h=f(s,o.at)??0;r.push({key:o.id,label:a,detail:A(o),deltaMs:h,isTool:B(o)}),s=o.at}return r}function B(e){const t=e.payload;return typeof(t==null?void 0:t.tool)=="string"}function T(e){switch(e.type){case"run.started":return"Started";case"route.decided":return`Routed to ${p(e.route)}`;case"plan.created":return"Planned the approach";case"step.started":return L(e)??"Working";case"executor.started":return R(e.route);case"evaluation.recorded":return"Checked grounding & trust";case"repair.attempted":return"Repaired and retried";case"replan.decided":return"Re-planned";case"escalated":return"Escalated to a deeper approach";case"artifact.created":return"Produced the answer";case"step.completed":return"Step complete";case"run.completed":return"Done";case"run.failed":return"Failed";default:return null}}function A(e){const t=e.payload;if(typeof(t==null?void 0:t.tool)=="string")return`tool: ${t.tool}`;if(e.type==="route.decided"||e.type==="run.failed")return e.message||void 0}function L(e){var r;const t=(r=e.payload)==null?void 0:r.goal;return t?`Working on: ${D(t,80)}`:null}function R(e){switch(e){case"certified_answer":return"Searching certified blocks & governed metrics";case"generated_answer":return"Composing the answer (semantic compile → generation)";case"research":return"Researching across governed data";case"app_build":return"Assembling the app";case"sql_cell":return"Writing the query";case"dql_block_draft":return"Drafting the block";case"modeling_draft":return"Drafting modeling changes";case"skill_draft":return"Drafting Skill guidance";case"conversation":return"Replying";default:return"Working"}}function p(e){return e?e.replace(/_/g," "):"the answer"}function _(e){return String(e).replace(/_/g," ")}function f(e,t){if(!e||!t)return null;const r=Date.parse(e),s=Date.parse(t);return Number.isNaN(r)||Number.isNaN(s)?null:Math.max(0,s-r)}function g(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?1:0)}s`}function D(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function l(e,t){const r=e.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);if(!s)return e;let i,o,a;return s[1].length===3?(i=parseInt(s[1][0]+s[1][0],16),o=parseInt(s[1][1]+s[1][1],16),a=parseInt(s[1][2]+s[1][2],16)):(i=parseInt(s[1].slice(0,2),16),o=parseInt(s[1].slice(2,4),16),a=parseInt(s[1].slice(4,6),16)),`rgba(${i}, ${o}, ${a}, ${t})`}function C(e){return{display:"inline-flex",alignItems:"center",gap:6,marginBottom:16,background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:13,fontFamily:e.font,padding:0}}function c(e){return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:e.pillBg,border:`1px solid ${e.cellBorder}`,color:e.textSecondary}}function N(e,t){const r=t==="certified"?e.success:t==="blocked"?e.error:e.accent;return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:l(r,.12),border:`1px solid ${l(r,.4)}`,color:r,fontWeight:500}}export{H as AgentLogPage};
1
+ import{u as x,t as m,j as n,G as y,aK as j,r as b,f as k}from"./index-mQd_pC-P.js";import{A as S}from"./arrow-left-BLnlJAtp.js";import{W as M}from"./wrench-C-zLCMbW.js";import{C as v}from"./circle-x-Cc6dEaf4.js";import"./react-CRB3T2We.js";function H(){const{state:e,dispatch:t}=x(),r=m[e.themeMode],s=e.agentLogRun;return s?n.jsxs("div",{style:{padding:"20px 28px",fontFamily:r.font,color:r.textPrimary,maxWidth:900,margin:"0 auto"},children:[n.jsxs("button",{type:"button",onClick:()=>t({type:"SET_MAIN_VIEW",view:"ask"}),style:C(r),children:[n.jsx(S,{size:14})," Back to Ask AI"]}),n.jsx(w,{run:s,t:r}),n.jsx(z,{run:s,t:r}),u(s).reason&&n.jsx(W,{run:s,t:r}),s.evaluations.length>0&&n.jsx(I,{run:s,t:r})]}):n.jsx("div",{style:{padding:32,color:r.textMuted,fontFamily:r.font},children:"No agent run selected. Open one from the “View steps” link on an AI answer."})}function w({run:e,t}){const r=f(e.startedAt,e.completedAt);return n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:8,lineHeight:1.35},children:e.question}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[n.jsxs("span",{style:c(t),children:[n.jsx(y,{size:12})," ",p(e.route)]}),n.jsx("span",{style:N(t,e.trustState),children:_(e.trustState)}),r!=null&&n.jsxs("span",{style:c(t),children:[n.jsx(j,{size:12})," ",g(r)," total"]}),n.jsx("span",{style:{...c(t),color:t.textMuted},children:e.status})]})]})}function z({run:e,t}){const r=b.useMemo(()=>$(e),[e]),s=r.reduce((i,o)=>Math.max(i,o.deltaMs),0);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"What the agent did · where the time went"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(i=>{const o=s>0&&i.deltaMs===s&&i.deltaMs>=250;return n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 10px",borderRadius:8,background:o?l(t.warning,.1):t.cellBg,border:`1px solid ${o?l(t.warning,.4):t.cellBorder}`},children:[n.jsx("span",{style:{marginTop:1,color:i.isTool?t.accent:t.textMuted,flexShrink:0},children:i.isTool?n.jsx(M,{size:13}):n.jsx("span",{style:{fontSize:13},children:"•"})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:500},children:i.label}),i.detail&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2,wordBreak:"break-word"},children:i.detail})]}),n.jsx("span",{style:{fontSize:12,fontFamily:t.fontMono,color:o?t.warning:t.textMuted,fontWeight:o?600:400,flexShrink:0,whiteSpace:"nowrap"},children:i.deltaMs>0?`+${g(i.deltaMs)}`:"—"})]},i.key)})}),s>=1e3&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:8},children:"The highlighted step took the longest. Long generation/tool steps usually mean the question fell through to LLM generation — a governed metric or certified block would answer it instantly."})]})}function W({run:e,t}){const r=u(e);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Why this route"}),n.jsxs("div",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.5},children:[r.reason,typeof r.confidence=="number"&&n.jsxs("span",{style:{color:t.textMuted},children:[" · confidence ",(r.confidence*100).toFixed(0),"%"]})]})]})}function u(e){const t=e.routeDecision;return{reason:typeof(t==null?void 0:t.reason)=="string"?t.reason:void 0,confidence:typeof(t==null?void 0:t.confidence)=="number"?t.confidence:void 0}}function I({run:e,t}){return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Governance checks"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.evaluations.map(r=>n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:13},children:[n.jsx("span",{style:{marginTop:1,color:r.passed?t.success:t.error,flexShrink:0},children:r.passed?n.jsx(k,{size:14}):n.jsx(v,{size:14})}),n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:500},children:r.label}),!r.passed&&r.message&&n.jsxs("span",{style:{color:t.textMuted},children:[" — ",r.message]})]})]},r.id))})]})}function d({t:e,children:t}){return n.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:e.textMuted,marginBottom:10},children:t})}function $(e){var i;const t=[...e.events].sort((o,a)=>o.at.localeCompare(a.at)),r=[];let s=e.startedAt??((i=t[0])==null?void 0:i.at);for(const o of t){const a=T(o);if(!a)continue;const h=f(s,o.at)??0;r.push({key:o.id,label:a,detail:A(o),deltaMs:h,isTool:B(o)}),s=o.at}return r}function B(e){const t=e.payload;return typeof(t==null?void 0:t.tool)=="string"}function T(e){switch(e.type){case"run.started":return"Started";case"route.decided":return`Routed to ${p(e.route)}`;case"plan.created":return"Planned the approach";case"step.started":return L(e)??"Working";case"executor.started":return R(e.route);case"evaluation.recorded":return"Checked grounding & trust";case"repair.attempted":return"Repaired and retried";case"replan.decided":return"Re-planned";case"escalated":return"Escalated to a deeper approach";case"artifact.created":return"Produced the answer";case"step.completed":return"Step complete";case"run.completed":return"Done";case"run.failed":return"Failed";default:return null}}function A(e){const t=e.payload;if(typeof(t==null?void 0:t.tool)=="string")return`tool: ${t.tool}`;if(e.type==="route.decided"||e.type==="run.failed")return e.message||void 0}function L(e){var r;const t=(r=e.payload)==null?void 0:r.goal;return t?`Working on: ${D(t,80)}`:null}function R(e){switch(e){case"certified_answer":return"Searching certified blocks & governed metrics";case"generated_answer":return"Composing the answer (semantic compile → generation)";case"research":return"Researching across governed data";case"app_build":return"Assembling the app";case"sql_cell":return"Writing the query";case"dql_block_draft":return"Drafting the block";case"modeling_draft":return"Drafting modeling changes";case"skill_draft":return"Drafting Skill guidance";case"conversation":return"Replying";default:return"Working"}}function p(e){return e?e.replace(/_/g," "):"the answer"}function _(e){return String(e).replace(/_/g," ")}function f(e,t){if(!e||!t)return null;const r=Date.parse(e),s=Date.parse(t);return Number.isNaN(r)||Number.isNaN(s)?null:Math.max(0,s-r)}function g(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?1:0)}s`}function D(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function l(e,t){const r=e.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);if(!s)return e;let i,o,a;return s[1].length===3?(i=parseInt(s[1][0]+s[1][0],16),o=parseInt(s[1][1]+s[1][1],16),a=parseInt(s[1][2]+s[1][2],16)):(i=parseInt(s[1].slice(0,2),16),o=parseInt(s[1].slice(2,4),16),a=parseInt(s[1].slice(4,6),16)),`rgba(${i}, ${o}, ${a}, ${t})`}function C(e){return{display:"inline-flex",alignItems:"center",gap:6,marginBottom:16,background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:13,fontFamily:e.font,padding:0}}function c(e){return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:e.pillBg,border:`1px solid ${e.cellBorder}`,color:e.textSecondary}}function N(e,t){const r=t==="certified"?e.success:t==="blocked"?e.error:e.accent;return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:l(r,.12),border:`1px solid ${l(r,.4)}`,color:r,fontWeight:500}}export{H as AgentLogPage};
@@ -1 +1 @@
1
- import{u,t as f,r as a,j as o,S as h,m as b}from"./index-9w93YPF9.js";import{s as g}from"./ai-build-bus-1BR770pY.js";import{u as y,A as k}from"./AiBuildResult-D-6G4Sh3.js";import{X as j}from"./x-CcYceFMz.js";import"./react-CRB3T2We.js";import"./user-round-Do21aFGo.js";import"./triangle-alert-BWrCxQVE.js";import"./rotate-ccw-ELiDRUmj.js";function z(){const{state:n,dispatch:c}=u(),t=f[n.themeMode],[e,l]=a.useState(null),p=y();if(a.useEffect(()=>g(i=>l(i)),[]),!e)return null;const s=()=>l(null),m=i=>{const r=i.trim();if(!r)return;const d=b("sql",r);d.name="ai_sql_preview",c({type:"ADD_CELL",cell:d})},x=(i,r)=>{p(i,r).finally(s)};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Ask AI to build",style:v,children:o.jsxs("div",{style:{width:"min(720px, calc(100vw - 32px))",maxHeight:"min(760px, calc(100vh - 64px))",background:t.appBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px rgba(0,0,0,0.34)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[o.jsx("div",{style:{width:30,height:30,borderRadius:8,background:`${t.accent}16`,border:`1px solid ${t.accent}38`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o.jsx(h,{size:16,strokeWidth:2.2})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:850,color:t.textPrimary,fontFamily:t.font},children:e.mode==="edit"?"Ask AI to modify a block":"Ask AI to build a block"}),o.jsx("div",{style:{fontSize:11.5,color:t.textMuted,fontFamily:t.font,marginTop:1},children:e.sourceLabel??(e.mode==="edit"?"Describe the change and review a before/after diff. Nothing is certified.":"Generate a draft from your dbt + semantic context. Nothing is certified.")})]}),o.jsx("button",{type:"button",onClick:s,title:"Close",style:{width:28,height:28,borderRadius:6,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(j,{size:15,strokeWidth:2})})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:o.jsx(k,{themeMode:n.themeMode,initialTarget:e.target,lockTarget:e.lockTarget,initialPrompt:e.prompt,context:e.context,initialMode:e.mode,initialBlockPath:e.blockPath,onInsertCell:m,onOpenBlock:x},`${e.target}:${e.mode??"create"}:${e.blockPath??""}:${e.prompt??""}:${e.sourceLabel??""}`)})]})})}const v={position:"fixed",inset:0,zIndex:60,background:"rgba(0,0,0,0.32)",display:"flex",alignItems:"center",justifyContent:"center",padding:16};export{z as AiBuildDialog};
1
+ import{u,t as f,r as a,j as o,S as h,m as b}from"./index-mQd_pC-P.js";import{s as g}from"./ai-build-bus-1BR770pY.js";import{u as y,A as k}from"./AiBuildResult-DLKFAe6R.js";import{X as j}from"./x-stiJ-sP7.js";import"./react-CRB3T2We.js";import"./user-round-BK5N1cJW.js";import"./triangle-alert-D5Ng-xZO.js";import"./rotate-ccw-C3tTaR7s.js";function z(){const{state:n,dispatch:c}=u(),t=f[n.themeMode],[e,l]=a.useState(null),p=y();if(a.useEffect(()=>g(i=>l(i)),[]),!e)return null;const s=()=>l(null),m=i=>{const r=i.trim();if(!r)return;const d=b("sql",r);d.name="ai_sql_preview",c({type:"ADD_CELL",cell:d})},x=(i,r)=>{p(i,r).finally(s)};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Ask AI to build",style:v,children:o.jsxs("div",{style:{width:"min(720px, calc(100vw - 32px))",maxHeight:"min(760px, calc(100vh - 64px))",background:t.appBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px rgba(0,0,0,0.34)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[o.jsx("div",{style:{width:30,height:30,borderRadius:8,background:`${t.accent}16`,border:`1px solid ${t.accent}38`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o.jsx(h,{size:16,strokeWidth:2.2})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:850,color:t.textPrimary,fontFamily:t.font},children:e.mode==="edit"?"Ask AI to modify a block":"Ask AI to build a block"}),o.jsx("div",{style:{fontSize:11.5,color:t.textMuted,fontFamily:t.font,marginTop:1},children:e.sourceLabel??(e.mode==="edit"?"Describe the change and review a before/after diff. Nothing is certified.":"Generate a draft from your dbt + semantic context. Nothing is certified.")})]}),o.jsx("button",{type:"button",onClick:s,title:"Close",style:{width:28,height:28,borderRadius:6,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(j,{size:15,strokeWidth:2})})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:o.jsx(k,{themeMode:n.themeMode,initialTarget:e.target,lockTarget:e.lockTarget,initialPrompt:e.prompt,context:e.context,initialMode:e.mode,initialBlockPath:e.blockPath,onInsertCell:m,onOpenBlock:x},`${e.target}:${e.mode??"create"}:${e.blockPath??""}:${e.prompt??""}:${e.sourceLabel??""}`)})]})})}const v={position:"fixed",inset:0,zIndex:60,background:"rgba(0,0,0,0.32)",display:"flex",alignItems:"center",justifyContent:"center",padding:16};export{z as AiBuildDialog};
@@ -1,4 +1,4 @@
1
- import{c as F,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be,ap as Me,f as K,b as re,T as se,d as le,e as ae,R as de}from"./index-9w93YPF9.js";import{U as ce,G as pe}from"./user-round-Do21aFGo.js";import{T as ue}from"./triangle-alert-BWrCxQVE.js";import{R as Y}from"./rotate-ccw-ELiDRUmj.js";/**
1
+ import{c as F,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be,as as Me,f as K,b as se,T as re,d as le,e as ae,R as de}from"./index-mQd_pC-P.js";import{U as ce,G as pe}from"./user-round-BK5N1cJW.js";import{T as ue}from"./triangle-alert-D5Ng-xZO.js";import{R as Y}from"./rotate-ccw-C3tTaR7s.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -28,6 +28,6 @@ import{c as F,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=F("square-plus",qe),Ee={cell:"Cell",block:"Block"};function ot({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:r,onInsertCell:p,onOpenBlock:a,quickActions:x,initialMode:f="create",initialBlockPath:c}){const s=Ce[e],{dispatch:o}=U(),y=u.useCallback(()=>{o({type:"SET_MAIN_VIEW",view:"skills"})},[o]),[g,R]=u.useState(f==="edit"?"block":n),[k,L]=u.useState(d),[z,v]=u.useState("idle"),[m,j]=u.useState(null),[W,b]=u.useState(null),[C,Se]=u.useState(null),[ve,D]=u.useState(!1),T=u.useRef(""),[S,we]=u.useState(f),[B,X]=u.useState(c),[I,ze]=u.useState(void 0);u.useEffect(()=>{let l=!1;return E.getIdentity().then(h=>{!l&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{l=!0}},[]);const P=u.useCallback(async(l,h)=>{const O=l.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),D(!1);try{const _=await E.aiBuild({prompt:O,context:r,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...I?{domain:I}:{}});j(_),v("ready")}catch(_){b(_ instanceof Error&&_.message?_.message:"Could not build that. Try rewording the request."),j(null),v("error")}}},[r,C,S,B,I]),ee=u.useCallback(()=>{P(k,g)},[k,P,g]),We=u.useCallback(l=>{const h=l.target&&!i?l.target:g;l.target&&!i&&R(l.target),L(l.prompt),P(l.prompt,h)},[i,P,g]),H=u.useCallback(()=>{v("idle"),j(null),b(null),D(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=u.useCallback(()=>{j(null),b(null),D(!1),v("idle")},[]),M=z==="building",q=g==="block"&&S==="edit",N=q&&!B;return t.jsx("div",{style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"auto"},children:t.jsxs("div",{style:{padding:12,display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{role:"group","aria-label":"Build target",style:ne(s),children:["cell","block"].map(l=>{const h=g===l;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(l),$())},"aria-pressed":h,style:ie(s,h,i&&!h),children:[l==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Ee[l]]},l)})}),t.jsx("span",{style:{fontSize:11,color:s.textMuted,fontFamily:s.font},children:g==="cell"?"Create a review-required SQL preview for a notebook cell.":S==="edit"?"Rewrite an existing draft DQL block.":"Generate a reusable draft DQL block."}),C&&t.jsxs("span",{title:"Drafts are attributed to you",style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:s.textMuted,fontFamily:s.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ke,{t:s,value:I,onChange:ze}):null,g==="block"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{role:"group","aria-label":"Block build mode",style:ne(s),children:["create","edit"].map(l=>{const h=S===l;return t.jsxs("button",{type:"button",onClick:()=>{we(l),$(),l==="create"&&X(void 0)},"aria-pressed":h,style:ie(s,h,!1),children:[l==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),l==="create"?"New block":"Modify existing"]},l)})}),S==="edit"?t.jsx(Ve,{t:s,selectedPath:B,onSelect:l=>{X(l),$()}}):null]}):null,x&&x.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:x.map(l=>t.jsxs("button",{type:"button",disabled:M,onClick:()=>We(l),style:{...w(s),opacity:M?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",l.label]},l.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:l=>L(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),ee())},rows:3,placeholder:g==="cell"?'Describe the preview SQL you want, e.g. "monthly revenue by region for the last 12 months".':S==="edit"?'Describe the change, e.g. "add a 12-month trailing window and exclude test accounts".':'Describe the reusable block, e.g. "active customers by signup cohort".',style:Ze(s)}),r!=null&&r.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.font},children:["Using the active SQL cell",r.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.font},children:"Pick the block you want to modify above."}):null,t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:t.jsxs("button",{type:"button",onClick:ee,disabled:M||!k.trim()||N,style:{...J(s),opacity:M||!k.trim()||N?.6:1},children:[M?t.jsx(oe,{size:13,strokeWidth:2}):t.jsx(Ie,{size:13,strokeWidth:2}),M?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ye,{t:s,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Te,{t:s,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),D(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(He,{t:s,result:m,owner:C,editing:q,onOpen:()=>a==null?void 0:a(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function Ae(){return{heading:"SQL preview",badge:"Review-required",guidance:"Use this as a notebook preview. For reusable governed analytics, promote the reviewed logic into a DQL draft.",insertLabel:"Insert preview",insertedLabel:"Preview inserted"}}function Te({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:r,route:p,inserted:a,onInsert:x,onRefine:f,onDiscard:c,onOpenSkills:s}){const o=Ae();return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(V,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:12.5,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:o.heading}),t.jsx("span",{style:je(e),children:o.badge}),t.jsx(ge,{t:e,route:p})]}),i?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:i}):null,t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.45,fontFamily:e.font},children:o.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:s}),t.jsx(ye,{t:e,diagnostics:r}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:x,disabled:a,style:{...J(e),opacity:a?.65:1},children:[a?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),a?o.insertedLabel:o.insertLabel]}),t.jsxs("button",{type:"button",onClick:f,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:c,style:w(e),children:[t.jsx(se,{size:13,strokeWidth:2})," Discard"]})]})]})}function He({t:e,result:n,owner:i,editing:d,onOpen:r,onRefine:p,onDiscard:a,onOpenSkills:x}){const[f,c]=u.useState(!1),{name:s,description:o,sqlPreview:y,grain:g,outputs:R,examples:k,certifierVerdict:L,appliedSkills:z,diagnostics:v,route:m,previousSql:j}=n,W=d||typeof j=="string";return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(Q,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:e.textPrimary,fontFamily:e.font},children:s}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Je(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),o?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:o}):null,W&&typeof j=="string"?t.jsx(Oe,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[f?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),f?"Hide SQL this block will run":"Show SQL this block will run"]}),f?t.jsx("div",{style:{marginTop:7},children:t.jsx(me,{t:e,code:y})}):null]}),R.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Outputs"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:R.map(b=>t.jsx("span",{style:Xe(e),children:b},b))})]}):null,k.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:k.slice(0,3).map(b=>t.jsx("li",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.45,fontFamily:e.font},children:b},b))})]}):null,t.jsx(Qe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:x}),t.jsx(ye,{t:e,diagnostics:v}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(ce,{size:12,strokeWidth:2})," drafting as ",i]}):null,t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:r,style:J(e),children:[W?t.jsx(xe,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),W?"Update block in Block Studio":"Open in Block Studio"]}),t.jsxs("button",{type:"button",onClick:p,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:a,style:w(e),children:[t.jsx(se,{size:13,strokeWidth:2})," Discard"]})]})]})}function Ne(e,n){const i=e.replace(/\s+$/g,"").split(`
31
+ */const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=F("square-plus",qe),Ee={cell:"Cell",block:"Block"};function ot({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:s,onInsertCell:p,onOpenBlock:a,quickActions:x,initialMode:f="create",initialBlockPath:c}){const r=Ce[e],{dispatch:o}=U(),y=u.useCallback(()=>{o({type:"SET_MAIN_VIEW",view:"skills"})},[o]),[g,R]=u.useState(f==="edit"?"block":n),[k,L]=u.useState(d),[z,v]=u.useState("idle"),[m,j]=u.useState(null),[W,b]=u.useState(null),[C,Se]=u.useState(null),[ve,D]=u.useState(!1),T=u.useRef(""),[S,we]=u.useState(f),[B,X]=u.useState(c),[I,ze]=u.useState(void 0);u.useEffect(()=>{let l=!1;return E.getIdentity().then(h=>{!l&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{l=!0}},[]);const P=u.useCallback(async(l,h)=>{const O=l.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),D(!1);try{const _=await E.aiBuild({prompt:O,context:s,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...I?{domain:I}:{}});j(_),v("ready")}catch(_){b(_ instanceof Error&&_.message?_.message:"Could not build that. Try rewording the request."),j(null),v("error")}}},[s,C,S,B,I]),ee=u.useCallback(()=>{P(k,g)},[k,P,g]),We=u.useCallback(l=>{const h=l.target&&!i?l.target:g;l.target&&!i&&R(l.target),L(l.prompt),P(l.prompt,h)},[i,P,g]),H=u.useCallback(()=>{v("idle"),j(null),b(null),D(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=u.useCallback(()=>{j(null),b(null),D(!1),v("idle")},[]),M=z==="building",q=g==="block"&&S==="edit",N=q&&!B;return t.jsx("div",{style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"auto"},children:t.jsxs("div",{style:{padding:12,display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{role:"group","aria-label":"Build target",style:ne(r),children:["cell","block"].map(l=>{const h=g===l;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(l),$())},"aria-pressed":h,style:ie(r,h,i&&!h),children:[l==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Ee[l]]},l)})}),t.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font},children:g==="cell"?"Create a review-required SQL preview for a notebook cell.":S==="edit"?"Rewrite an existing draft DQL block.":"Generate a reusable draft DQL block."}),C&&t.jsxs("span",{title:"Drafts are attributed to you",style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:r.textMuted,fontFamily:r.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ke,{t:r,value:I,onChange:ze}):null,g==="block"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{role:"group","aria-label":"Block build mode",style:ne(r),children:["create","edit"].map(l=>{const h=S===l;return t.jsxs("button",{type:"button",onClick:()=>{we(l),$(),l==="create"&&X(void 0)},"aria-pressed":h,style:ie(r,h,!1),children:[l==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),l==="create"?"New block":"Modify existing"]},l)})}),S==="edit"?t.jsx(Ve,{t:r,selectedPath:B,onSelect:l=>{X(l),$()}}):null]}):null,x&&x.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:x.map(l=>t.jsxs("button",{type:"button",disabled:M,onClick:()=>We(l),style:{...w(r),opacity:M?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",l.label]},l.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:l=>L(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),ee())},rows:3,placeholder:g==="cell"?'Describe the preview SQL you want, e.g. "monthly revenue by region for the last 12 months".':S==="edit"?'Describe the change, e.g. "add a 12-month trailing window and exclude test accounts".':'Describe the reusable block, e.g. "active customers by signup cohort".',style:Ze(r)}),s!=null&&s.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:["Using the active SQL cell",s.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:"Pick the block you want to modify above."}):null,t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:t.jsxs("button",{type:"button",onClick:ee,disabled:M||!k.trim()||N,style:{...J(r),opacity:M||!k.trim()||N?.6:1},children:[M?t.jsx(oe,{size:13,strokeWidth:2}):t.jsx(Ie,{size:13,strokeWidth:2}),M?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ye,{t:r,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Te,{t:r,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),D(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(He,{t:r,result:m,owner:C,editing:q,onOpen:()=>a==null?void 0:a(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function Ae(){return{heading:"SQL preview",badge:"Review-required",guidance:"Use this as a notebook preview. For reusable governed analytics, promote the reviewed logic into a DQL draft.",insertLabel:"Insert preview",insertedLabel:"Preview inserted"}}function Te({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:s,route:p,inserted:a,onInsert:x,onRefine:f,onDiscard:c,onOpenSkills:r}){const o=Ae();return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(V,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:12.5,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:o.heading}),t.jsx("span",{style:je(e),children:o.badge}),t.jsx(ge,{t:e,route:p})]}),i?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:i}):null,t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.45,fontFamily:e.font},children:o.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:r}),t.jsx(ye,{t:e,diagnostics:s}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:x,disabled:a,style:{...J(e),opacity:a?.65:1},children:[a?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),a?o.insertedLabel:o.insertLabel]}),t.jsxs("button",{type:"button",onClick:f,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:c,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function He({t:e,result:n,owner:i,editing:d,onOpen:s,onRefine:p,onDiscard:a,onOpenSkills:x}){const[f,c]=u.useState(!1),{name:r,description:o,sqlPreview:y,grain:g,outputs:R,examples:k,certifierVerdict:L,appliedSkills:z,diagnostics:v,route:m,previousSql:j}=n,W=d||typeof j=="string";return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(Q,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:e.textPrimary,fontFamily:e.font},children:r}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Je(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),o?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:o}):null,W&&typeof j=="string"?t.jsx(Oe,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[f?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),f?"Hide SQL this block will run":"Show SQL this block will run"]}),f?t.jsx("div",{style:{marginTop:7},children:t.jsx(me,{t:e,code:y})}):null]}),R.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Outputs"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:R.map(b=>t.jsx("span",{style:Xe(e),children:b},b))})]}):null,k.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:k.slice(0,3).map(b=>t.jsx("li",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.45,fontFamily:e.font},children:b},b))})]}):null,t.jsx(Qe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:x}),t.jsx(ye,{t:e,diagnostics:v}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(ce,{size:12,strokeWidth:2})," drafting as ",i]}):null,t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:s,style:J(e),children:[W?t.jsx(xe,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),W?"Update block in Block Studio":"Open in Block Studio"]}),t.jsxs("button",{type:"button",onClick:p,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:a,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function Ne(e,n){const i=e.replace(/\s+$/g,"").split(`
32
32
  `),d=n.replace(/\s+$/g,"").split(`
33
- `),r=i.length,p=d.length,a=Array.from({length:r+1},()=>new Array(p+1).fill(0));for(let s=r-1;s>=0;s--)for(let o=p-1;o>=0;o--)a[s][o]=i[s]===d[o]?a[s+1][o+1]+1:Math.max(a[s+1][o],a[s][o+1]);const x=[];let f=0,c=0;for(;f<r&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<r;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,r]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>r(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,s)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},s))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(r=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:r},r))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",r=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",r," allowed relation",r===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i,onSuggestCorrection:d}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((r,p)=>t.jsxs(de.Fragment,{children:[p>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:r.description??`Open the ${r.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:r.id})]},r.id)),d&&n.length===1?t.jsx("button",{type:"button",onClick:()=>d(n[0]),style:{marginLeft:5,border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-1)",color:e.accent,padding:"3px 7px",cursor:"pointer",fontSize:10},children:"Suggest skill correction"}):null]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,r=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:r,background:`${r}14`,border:`1px solid ${r}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,r]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let o=!1;return a(!0),E.getBlockLibrary().then(y=>{o||r(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{o||r([])}).finally(()=>{o||a(!1)}),()=>{o=!0}},[]);const c=d.filter(o=>{if(!x.trim())return!0;const y=x.toLowerCase();return o.name.toLowerCase().includes(y)||o.path.toLowerCase().includes(y)||(o.domain??"").toLowerCase().includes(y)}).slice(0,40),s=d.find(o=>o.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Me,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:o=>f(o.target.value),placeholder:s?`Modifying ${s.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(oe,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:o=>{if(o.key==="Enter"){const y=o.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(o=>{const y=o.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(o.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.domain?`${o.domain} · `:"",o.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},o.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:r}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>r({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain in the Modeling workspace",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return re(e,{variant:"primary",size:"md"})}function w(e){return re(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function rt(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const r={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:r});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:r,payload:p})},[n,e.files])}export{ot as A,Qe as C,he as G,ge as R,rt as u};
33
+ `),s=i.length,p=d.length,a=Array.from({length:s+1},()=>new Array(p+1).fill(0));for(let r=s-1;r>=0;r--)for(let o=p-1;o>=0;o--)a[r][o]=i[r]===d[o]?a[r+1][o+1]+1:Math.max(a[r+1][o],a[r][o+1]);const x=[];let f=0,c=0;for(;f<s&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<s;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,s]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>s(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,r)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},r))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(s=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:s},s))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",s=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",s," allowed relation",s===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i,onSuggestCorrection:d}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((s,p)=>t.jsxs(de.Fragment,{children:[p>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:s.description??`Open the ${s.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:s.id})]},s.id)),d&&n.length===1?t.jsx("button",{type:"button",onClick:()=>d(n[0]),style:{marginLeft:5,border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-1)",color:e.accent,padding:"3px 7px",cursor:"pointer",fontSize:10},children:"Suggest skill correction"}):null]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,s=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:s,background:`${s}14`,border:`1px solid ${s}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,s]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let o=!1;return a(!0),E.getBlockLibrary().then(y=>{o||s(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{o||s([])}).finally(()=>{o||a(!1)}),()=>{o=!0}},[]);const c=d.filter(o=>{if(!x.trim())return!0;const y=x.toLowerCase();return o.name.toLowerCase().includes(y)||o.path.toLowerCase().includes(y)||(o.domain??"").toLowerCase().includes(y)}).slice(0,40),r=d.find(o=>o.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Me,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:o=>f(o.target.value),placeholder:r?`Modifying ${r.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(oe,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:o=>{if(o.key==="Enter"){const y=o.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(o=>{const y=o.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(o.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.domain?`${o.domain} · `:"",o.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},o.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:s}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>s({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain in the Modeling workspace",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return se(e,{variant:"primary",size:"md"})}function w(e){return se(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function st(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const s={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:s});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:s,payload:p})},[n,e.files])}export{ot as A,Qe as C,he as G,ge as R,st as u};
@@ -1,4 +1,4 @@
1
- import{c as te,r as o,j as n,S as ne,L as ie}from"./index-9w93YPF9.js";import{M as re}from"./minimize-2-BhXsglrO.js";import{M as oe}from"./usePersistedAgentThreadId-Cv7Yq2hK.js";import{X as ae}from"./x-CcYceFMz.js";/**
1
+ import{c as te,r as o,j as n,S as ne,L as ie}from"./index-mQd_pC-P.js";import{M as re}from"./minimize-2-Cl4pef4s.js";import{M as oe}from"./usePersistedAgentThreadId-DBu97YaM.js";import{X as ae}from"./x-stiJ-sP7.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as ne,h as re,i as ie,k as oe,t as se,r as f,a as R,j as o,m as ae,P as de,L as J,l as ce,T as le}from"./index-9w93YPF9.js";import{u as ue,f as fe,c as pe}from"./answer-to-notebook-Cg3UyGwh.js";import{U as he}from"./UnifiedAgentRunPanel-DBfsmXes.js";import{S as G}from"./star-D63O81Wp.js";import{P as me}from"./usePersistedAgentThreadId-Cv7Yq2hK.js";import"./react-CRB3T2We.js";import"./AiBuildResult-D-6G4Sh3.js";import"./user-round-Do21aFGo.js";import"./triangle-alert-BWrCxQVE.js";import"./rotate-ccw-ELiDRUmj.js";import"./x-CcYceFMz.js";import"./list-tree-BipBLmIE.js";import"./wrench-7tYr_GKb.js";import"./minimize-2-BhXsglrO.js";import"./arrow-right-Ct_YGrmU.js";import"./TrustBadge-ClEYiYeA.js";/**
1
+ import{c as ne,h as re,i as ie,k as oe,t as se,r as f,a as R,j as o,m as ae,P as de,L as J,l as ce,T as le}from"./index-mQd_pC-P.js";import{u as ue,f as fe,c as pe}from"./answer-to-notebook-DCFWlHB7.js";import{U as he}from"./UnifiedAgentRunPanel-Cu-YgIe4.js";import{S as G}from"./star--Yq77aH4.js";import{P as me}from"./usePersistedAgentThreadId-DBu97YaM.js";import"./react-CRB3T2We.js";import"./AiBuildResult-DLKFAe6R.js";import"./user-round-BK5N1cJW.js";import"./triangle-alert-D5Ng-xZO.js";import"./rotate-ccw-C3tTaR7s.js";import"./x-stiJ-sP7.js";import"./list-tree-j0s4asFK.js";import"./wrench-C-zLCMbW.js";import"./minimize-2-Cl4pef4s.js";import"./arrow-right-BmUAb1aW.js";import"./TrustBadge-TcwXFFHK.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.