@duckcodeailabs/dql-cli 1.12.10 → 1.13.0

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 (101) hide show
  1. package/dist/apps-api.d.ts +151 -3
  2. package/dist/apps-api.d.ts.map +1 -1
  3. package/dist/apps-api.js +675 -97
  4. package/dist/apps-api.js.map +1 -1
  5. package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
  6. package/dist/assets/dql-notebook/assets/{AgentLogPage-uvVs284-.js → AgentLogPage-CBGEoGmU.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/{AiBuildDialog-DEUS19WF.js → AiBuildDialog-CwAD3tXE.js} +1 -1
  8. package/dist/assets/dql-notebook/assets/AiBuildResult-CyqTuQe5.js +33 -0
  9. package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
  10. package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
  11. package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
  12. package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
  13. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-D8FIgrkF.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
  14. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
  15. package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
  16. package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
  17. package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
  18. package/dist/assets/dql-notebook/assets/{HelpDocsPage-Bc5pLakt.js → HelpDocsPage-BDPNVot1.js} +3 -3
  19. package/dist/assets/dql-notebook/assets/{HomePage-DQSo-K4y.js → HomePage-DiOnRhEG.js} +9 -4
  20. package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
  21. package/dist/assets/dql-notebook/assets/{LineageDetailView-CZEx2r1H.js → LineageDetailView-CfbSvlPJ.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{LineageDrawer-P7ZdOW8-.js → LineageDrawer-CgTScaGB.js} +1 -1
  23. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-D7ZA7k68.js +14 -0
  24. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-Ctp_yFh8.js → MiniLineageGraph-GkD4y17x.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/NewBlockModal-B9TfRjt7.js +1 -0
  26. package/dist/assets/dql-notebook/assets/NewNotebookModal-BbO9NKUl.js +46 -0
  27. package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
  28. package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
  29. package/dist/assets/dql-notebook/assets/{SetupOnboarding-DX2f53J2.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
  30. package/dist/assets/dql-notebook/assets/{TrustBadge-DPnKzRSY.js → TrustBadge-vQQh8d0D.js} +1 -1
  31. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
  32. package/dist/assets/dql-notebook/assets/{answer-to-notebook-Bm9oByWA.js → answer-to-notebook-DuqCcDDl.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{arrow-left-D2FbLWqh.js → arrow-left-CMe1kkOL.js} +1 -1
  34. package/dist/assets/dql-notebook/assets/{arrow-right-OYItAZ-s.js → arrow-right-DvB_DONr.js} +2 -2
  35. package/dist/assets/dql-notebook/assets/{book-open-text-BnnirfAc.js → book-open-text-CJ3NAvrs.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{bot-BJNxPYFm.js → bot-CV8DYRrt.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{chevron-up-DM5LX-26.js → chevron-up-HxU1l85K.js} +2 -2
  38. package/dist/assets/dql-notebook/assets/{circle-x-Dic_-4tF.js → circle-x-BCgtha1W.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{codemirror-1_I9gm6Z.js → codemirror-DXt7RW72.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/{dagre.esm-C9zxjHHX.js → dagre.esm-GKp7qoUL.js} +1 -1
  41. package/dist/assets/dql-notebook/assets/{external-link-DHxAcoCE.js → external-link-C-PXokWV.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{grip-vertical-02I-EOjL.js → grip-vertical-B4EHbGXW.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
  44. package/dist/assets/dql-notebook/assets/{link-2-Delh-lai.js → link-2-BLx-goet.js} +2 -2
  45. package/dist/assets/dql-notebook/assets/{list-tree-BrIZg6l6.js → list-tree-BRFpEmvV.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/{maximize-2-CQOA-bbN.js → maximize-2-CCd5uRIZ.js} +1 -1
  47. package/dist/assets/dql-notebook/assets/{minimize-2-CUDBPkwe.js → minimize-2-CDwSCGlO.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{panel-right-open-CwhZfkKJ.js → panel-right-open-CunA1xO7.js} +2 -2
  49. package/dist/assets/dql-notebook/assets/{pencil-Cf6-MgpT.js → pencil-D_I14Wyk.js} +2 -2
  50. package/dist/assets/dql-notebook/assets/{rotate-ccw-DndbJAiz.js → rotate-ccw-DOrfTZk8.js} +2 -2
  51. package/dist/assets/dql-notebook/assets/{semantic-fields-DwKPY_mU.js → semantic-fields-AfQvjt5R.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/{star-DvcMC9wZ.js → star-DDhv4e8M.js} +2 -2
  53. package/dist/assets/dql-notebook/assets/{triangle-alert-DUf4Ook0.js → triangle-alert-2ZXx8wAu.js} +1 -1
  54. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
  55. package/dist/assets/dql-notebook/assets/{user-round-DSt0xU3K.js → user-round-BA074kiQ.js} +3 -3
  56. package/dist/assets/dql-notebook/assets/{wand-sparkles-ro8Cq0ro.js → wand-sparkles-CEYHLt9b.js} +1 -1
  57. package/dist/assets/dql-notebook/assets/{workflow-DVJXehjU.js → workflow-CZtyrcR-.js} +2 -2
  58. package/dist/assets/dql-notebook/assets/{wrench-DxUnoHtz.js → wrench-Ong23-wu.js} +1 -1
  59. package/dist/assets/dql-notebook/assets/{x-9Gtb3EAd.js → x-CSo1M3tu.js} +2 -2
  60. package/dist/assets/dql-notebook/index.html +1 -1
  61. package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
  62. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  63. package/dist/llm/providers/dql-agent-provider.js +13 -10
  64. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  65. package/dist/local-operation-coordinator.d.ts +59 -0
  66. package/dist/local-operation-coordinator.d.ts.map +1 -0
  67. package/dist/local-operation-coordinator.js +256 -0
  68. package/dist/local-operation-coordinator.js.map +1 -0
  69. package/dist/local-runtime.d.ts +89 -2
  70. package/dist/local-runtime.d.ts.map +1 -1
  71. package/dist/local-runtime.js +2158 -461
  72. package/dist/local-runtime.js.map +1 -1
  73. package/dist/package.json +12 -11
  74. package/dist/project-refresh-coordinator.d.ts +19 -0
  75. package/dist/project-refresh-coordinator.d.ts.map +1 -0
  76. package/dist/project-refresh-coordinator.js +134 -0
  77. package/dist/project-refresh-coordinator.js.map +1 -0
  78. package/dist/project-refresh-worker.d.ts +13 -0
  79. package/dist/project-refresh-worker.d.ts.map +1 -0
  80. package/dist/project-refresh-worker.js +58 -0
  81. package/dist/project-refresh-worker.js.map +1 -0
  82. package/package.json +13 -11
  83. package/dist/assets/dql-notebook/assets/AgentAnswerCard-Dp4odOLE.js +0 -5
  84. package/dist/assets/dql-notebook/assets/AiBuildResult-B9KmBRsh.js +0 -33
  85. package/dist/assets/dql-notebook/assets/AiSidePanel-C7BZVSkM.js +0 -6
  86. package/dist/assets/dql-notebook/assets/AnalyticsHome-4TgtH6SB.js +0 -6
  87. package/dist/assets/dql-notebook/assets/AppsView-CnfNtk5W.js +0 -4466
  88. package/dist/assets/dql-notebook/assets/BlockStudio-DUXN3MKz.js +0 -60
  89. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DR8hTZ95.js +0 -22
  90. package/dist/assets/dql-notebook/assets/GitPage-BS2sm9zh.js +0 -7
  91. package/dist/assets/dql-notebook/assets/GlobalAiRail-B_MZsB0z.js +0 -1
  92. package/dist/assets/dql-notebook/assets/GovernedContextPage-CNM5UCAH.js +0 -7
  93. package/dist/assets/dql-notebook/assets/LineageDAG-RdpWmGmR.js +0 -1
  94. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-DTUMFkJ8.js +0 -14
  95. package/dist/assets/dql-notebook/assets/NewBlockModal-BLtjuWGy.js +0 -1
  96. package/dist/assets/dql-notebook/assets/NewNotebookModal-xgaKB2kI.js +0 -46
  97. package/dist/assets/dql-notebook/assets/NotebookEditor-D6RgLQw-.js +0 -202
  98. package/dist/assets/dql-notebook/assets/ReadinessPage-C8hATaT_.js +0 -1
  99. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CwxQ4T19.js +0 -83
  100. package/dist/assets/dql-notebook/assets/index-Ca3UeUWI.js +0 -644
  101. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-DbdBi0oH.js +0 -18
@@ -1,33 +0,0 @@
1
- import{g as M,u as U,r as f,a as D,j as t,B as Q,t as Ce,S as V,L as se,ai as Be,e as K,c as oe,T as re,b as le,d as ae,R as de}from"./index-Ca3UeUWI.js";import{U as ce,G as pe}from"./user-round-DSt0xU3K.js";import{T as ue}from"./triangle-alert-DUf4Ook0.js";import{R as Y}from"./rotate-ccw-DndbJAiz.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 Fe=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Me=M("badge-check",Fe);/**
7
- * @license lucide-react v0.563.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Re=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],fe=M("file-code-corner",Re);/**
12
- * @license lucide-react v0.563.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Le=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],$e=M("git-compare-arrows",Le);/**
17
- * @license lucide-react v0.563.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const _e=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],De=M("hammer",_e);/**
22
- * @license lucide-react v0.563.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ie=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],xe=M("square-pen",Ie);/**
27
- * @license lucide-react v0.563.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Ee=[["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=M("square-plus",Ee),Pe={cell:"Cell",block:"Block"};function it({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:r,onInsertCell:p,onOpenBlock:o,quickActions:u,initialMode:x="create",initialBlockPath:c}){const l=Ce[e],{dispatch:s}=U(),y=f.useCallback(()=>{s({type:"SET_MAIN_VIEW",view:"skills"})},[s]),[g,R]=f.useState(x==="edit"?"block":n),[k,L]=f.useState(d),[z,v]=f.useState("idle"),[m,j]=f.useState(null),[W,b]=f.useState(null),[C,Se]=f.useState(null),[ve,I]=f.useState(!1),T=f.useRef(""),[S,we]=f.useState(x),[B,X]=f.useState(c),[E,ze]=f.useState(void 0);f.useEffect(()=>{let a=!1;return D.getIdentity().then(h=>{!a&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{a=!0}},[]);const P=f.useCallback(async(a,h)=>{const O=a.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),I(!1);try{const _=await D.aiBuild({prompt:O,context:r,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...E?{domain:E}:{}});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,E]),ee=f.useCallback(()=>{P(k,g)},[k,P,g]),We=f.useCallback(a=>{const h=a.target&&!i?a.target:g;a.target&&!i&&R(a.target),L(a.prompt),P(a.prompt,h)},[i,P,g]),H=f.useCallback(()=>{v("idle"),j(null),b(null),I(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=f.useCallback(()=>{j(null),b(null),I(!1),v("idle")},[]),F=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(l),children:["cell","block"].map(a=>{const h=g===a;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(a),$())},"aria-pressed":h,style:ie(l,h,i&&!h),children:[a==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Pe[a]]},a)})}),t.jsx("span",{style:{fontSize:11,color:l.textMuted,fontFamily:l.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:l.textMuted,fontFamily:l.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ve,{t:l,value:E,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(l),children:["create","edit"].map(a=>{const h=S===a;return t.jsxs("button",{type:"button",onClick:()=>{we(a),$(),a==="create"&&X(void 0)},"aria-pressed":h,style:ie(l,h,!1),children:[a==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),a==="create"?"New block":"Modify existing"]},a)})}),S==="edit"?t.jsx(Ue,{t:l,selectedPath:B,onSelect:a=>{X(a),$()}}):null]}):null,u&&u.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:u.map(a=>t.jsxs("button",{type:"button",disabled:F,onClick:()=>We(a),style:{...w(l),opacity:F?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",a.label]},a.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:a=>L(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&(a.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:Ye(l)}),r!=null&&r.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:l.textMuted,fontFamily:l.font},children:["Using the active SQL cell",r.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:l.textMuted,fontFamily:l.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:F||!k.trim()||N,style:{...J(l),opacity:F||!k.trim()||N?.6:1},children:[F?t.jsx(se,{size:13,strokeWidth:2}):t.jsx(De,{size:13,strokeWidth:2}),F?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ke,{t:l,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Ae,{t:l,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),I(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(Te,{t:l,result:m,owner:C,editing:q,onOpen:()=>o==null?void 0:o(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function qe(){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 Ae({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:r,route:p,inserted:o,onInsert:u,onRefine:x,onDiscard:c,onOpenSkills:l}){const s=qe();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:s.heading}),t.jsx("span",{style:je(e),children:s.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:s.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:l}),t.jsx(ye,{t:e,diagnostics:r}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:u,disabled:o,style:{...J(e),opacity:o?.65:1},children:[o?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),o?s.insertedLabel:s.insertLabel]}),t.jsxs("button",{type:"button",onClick:x,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 Te({t:e,result:n,owner:i,editing:d,onOpen:r,onRefine:p,onDiscard:o,onOpenSkills:u}){const[x,c]=f.useState(!1),{name:l,description:s,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:l}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Ze(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),s?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:s}):null,W&&typeof j=="string"?t.jsx(Ne,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[x?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),x?"Hide SQL this block will run":"Show SQL this block will run"]}),x?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:Je(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(Oe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:u}),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:o,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function He(e,n){const i=e.replace(/\s+$/g,"").split(`
32
- `),d=n.replace(/\s+$/g,"").split(`
33
- `),r=i.length,p=d.length,o=Array.from({length:r+1},()=>new Array(p+1).fill(0));for(let l=r-1;l>=0;l--)for(let s=p-1;s>=0;s--)o[l][s]=i[l]===d[s]?o[l+1][s+1]+1:Math.max(o[l+1][s],o[l][s+1]);const u=[];let x=0,c=0;for(;x<r&&c<p;)i[x]===d[c]?(u.push({kind:"context",text:i[x]}),x++,c++):o[x+1][c]>=o[x][c+1]?(u.push({kind:"remove",text:i[x]}),x++):(u.push({kind:"add",text:d[c]}),c++);for(;x<r;)u.push({kind:"remove",text:i[x]}),x++;for(;c<p;)u.push({kind:"add",text:d[c]}),c++;return u}function Ne({t:e,previousSql:n,nextSql:i}){const[d,r]=f.useState(!0),p=de.useMemo(()=>He(n.trim(),i.trim()),[n,i]),o=p.filter(c=>c.kind==="add").length,u=p.filter(c=>c.kind==="remove").length,x=o===0&&u===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"]}),x?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:["+",o]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",u]})," line",o+u===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,l)=>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||" "]},l))})}):null]})}function Oe({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}){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((d,r)=>t.jsxs(de.Fragment,{children:[r>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:d.description??`Open the ${d.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:d.id})]},d.id))]})}const Qe={certified_block:{tone:"success",icon:Me},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 o;if(!n)return null;const i=Qe[n.tier];if(!i)return null;const d=i.icon,r=e[i.tone]??e.textMuted,p=((o=n.label)==null?void 0:o.trim())||Ge(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 Ge(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 Ue({t:e,selectedPath:n,onSelect:i}){const[d,r]=f.useState([]),[p,o]=f.useState(!0),[u,x]=f.useState("");f.useEffect(()=>{let s=!1;return o(!0),D.getBlockLibrary().then(y=>{s||r(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{s||r([])}).finally(()=>{s||o(!1)}),()=>{s=!0}},[]);const c=d.filter(s=>{if(!u.trim())return!0;const y=u.toLowerCase();return s.name.toLowerCase().includes(y)||s.path.toLowerCase().includes(y)||(s.domain??"").toLowerCase().includes(y)}).slice(0,40),l=d.find(s=>s.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(Be,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:u,onChange:s=>x(s.target.value),placeholder:l?`Modifying ${l.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(se,{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:s=>{if(s.key==="Enter"){const y=s.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 “",u,"”."]}):c.map(s=>{const y=s.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(s.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:s.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s.domain?`${s.domain} · `:"",s.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},s.path)})})]})}function Ve({t:e,value:n,onChange:i}){const{dispatch:d}=U(),[r,p]=f.useState([]);return f.useEffect(()=>{let o=!1;return D.getDomains().then(u=>{o||p(Array.isArray(u==null?void 0:u.domains)?u.domains:[])}).catch(()=>{o||p([])}),()=>{o=!0}},[]),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:o=>i(o.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:r.length===0?"No domains yet":"No domain"}),r.map(o=>t.jsx("option",{value:o.id,children:o.name},o.id))]}),t.jsxs("button",{type:"button",onClick:()=>d({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain on the Domains page",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ke({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 Ye(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 oe(e,{variant:"primary",size:"md"})}function w(e){return oe(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 Ze(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 Je(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 f.useCallback(async(i,d)=>{const r={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(o=>o.path===i)||n({type:"FILE_ADDED",file:r});const p=await D.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:r,payload:p})},[n,e.files])}export{it as A,Oe as C,he as G,ge as R,st as u};
@@ -1,6 +0,0 @@
1
- import{g,j as i,S as j,L as w}from"./index-Ca3UeUWI.js";import{M as v}from"./minimize-2-CUDBPkwe.js";import{M as k}from"./maximize-2-CQOA-bbN.js";import{X as I}from"./x-9Gtb3EAd.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 A=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],S=g("message-square-plus",A),p=420,W=720;function B({t:e,title:a,subtitle:s,children:l,onClose:o,expanded:n=!1,onToggleExpanded:c,onNewChat:x,headerActions:f,running:u=!1,compact:r=!1,floating:t=!1,dock:h="column",ariaLabel:m=a,className:y,style:b}){return i.jsxs("aside",{"aria-label":m,className:y,"data-ai-side-panel":"true","data-expanded":n?"true":"false",style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",background:e.cellBg,...h==="overlay"&&!r?{position:"absolute",inset:"0 0 0 auto",zIndex:30,width:n?`min(${W}px, calc(100% - 40px))`:`min(${p}px, calc(100% - 40px))`,maxWidth:n?"72vw":"52vw",minWidth:Math.min(p,400),flex:"0 0 auto",boxShadow:"-16px 0 36px rgba(0,0,0,0.18)"}:{},...h==="overlay"&&r?{position:"relative",width:"100%",flex:"0 0 auto"}:{},borderLeft:r?"none":`1px solid ${e.headerBorder}`,border:t?`1px solid ${e.headerBorder}`:void 0,borderRadius:t?12:void 0,boxShadow:t?"0 18px 60px rgba(15, 23, 42, 0.22)":void 0,transition:"width 180ms ease, max-width 180ms ease",...b},children:[i.jsxs("div",{style:{minHeight:52,padding:"9px 12px",borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",alignItems:"center",gap:10,flex:"0 0 auto"},children:[i.jsx("div",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:`${e.accent}14`,border:`1px solid ${e.accent}36`,color:e.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:i.jsx(j,{size:16,strokeWidth:2.1})}),i.jsxs("div",{style:{flex:1,minWidth:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{fontSize:13,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:a}),u?i.jsx(w,{size:12,"aria-label":"AI is working",style:{color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):null]}),i.jsx("div",{title:s,style:{marginTop:2,color:e.textMuted,fontSize:11,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]}),f,x?i.jsx(d,{t:e,label:"New AI chat",onClick:x,children:i.jsx(S,{size:15,strokeWidth:2})}):null,!r&&c?i.jsx(d,{t:e,label:n?"Return AI panel to standard width":"Expand AI panel",onClick:c,children:n?i.jsx(v,{size:15,strokeWidth:2}):i.jsx(k,{size:15,strokeWidth:2})}):null,i.jsx(d,{t:e,label:`Close ${a}`,onClick:o,children:i.jsx(I,{size:15,strokeWidth:2})})]}),i.jsx("div",{style:{flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:l})]})}function d({t:e,label:a,onClick:s,active:l=!1,children:o}){return i.jsx("button",{type:"button","aria-label":a,title:a,onClick:s,style:{width:30,height:30,borderRadius:7,border:`1px solid ${l?`${e.accent}66`:e.btnBorder}`,background:l?`${e.accent}14`:e.btnBg,color:l?e.accent:e.textSecondary,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o})}export{B as A,S as M,W as a,p as b,d as c};
@@ -1,6 +0,0 @@
1
- import{g as ne,u as re,t as ie,r as f,a as R,j as o,m as oe,P as se,L as J,h as ae,T as de}from"./index-Ca3UeUWI.js";import{u as ce,f as le,c as ue}from"./answer-to-notebook-Bm9oByWA.js";import{U as fe}from"./UnifiedAgentRunPanel-CwxQ4T19.js";import{S as G}from"./star-DvcMC9wZ.js";import{P as pe}from"./pencil-Cf6-MgpT.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-Dp4odOLE.js";import"./usePersistedAgentThreadId-DbdBi0oH.js";import"./TrustBadge-DPnKzRSY.js";import"./AiBuildResult-B9KmBRsh.js";import"./user-round-DSt0xU3K.js";import"./triangle-alert-DUf4Ook0.js";import"./rotate-ccw-DndbJAiz.js";import"./x-9Gtb3EAd.js";import"./list-tree-BrIZg6l6.js";import"./wrench-DxUnoHtz.js";import"./arrow-right-OYItAZ-s.js";import"./chevron-up-DM5LX-26.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 he=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],me=ne("message-square",he),H="dql-ask-domain-scope",K="dql-ask-domain-context";function Y(e){if(e)try{const t=JSON.parse(e);return typeof t.domain!="string"||!t.domain.trim()?void 0:{domain:t.domain.trim(),purpose:typeof t.purpose=="string"?t.purpose:void 0,modelAreaId:typeof t.modelAreaId=="string"?t.modelAreaId:void 0}}catch{return}}function ge(e,t){try{const s=Y(e.getItem(K));return e.removeItem(K),s?(t.setItem(H,JSON.stringify(s)),s):Y(t.getItem(H))}catch{return}}function xe(e,t){try{t||e.removeItem(H)}catch{}}function Ae(){if(!(typeof window>"u"))return ge(window.sessionStorage,window.localStorage)}function Ie(e){typeof window>"u"||xe(window.localStorage,e)}const B="dql-ask-conversations",Z="dql-ask-active-conversation",Q="dql-ask-deleted-thread-queue",N=100;function Se(e){return(e??"AI analysis").replace(/[^a-zA-Z0-9_ -]+/g," ").replace(/\s+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"ai_analysis"}function ve(e){var S,p,a,d,w;const t=(p=(S=e.dqlArtifact)==null?void 0:S.source)==null?void 0:p.trim(),s=(a=e.sql)==null?void 0:a.trim(),n=t||s;if(!n)return;const u=oe(t?"dql":"sql",n);return u.name=Se(e.title??((d=e.dqlArtifact)==null?void 0:d.name)),e.result&&(u.result=e.result,u.status="success",u.executionCount=1),e.chartConfig&&(u.chartConfig=e.chartConfig),u.correctionProvenance=ue({question:e.question,generatedSql:e.sql??((w=e.dqlArtifact)==null?void 0:w.compiledSql),generatedDql:t,sourceRunId:e.sourceRunId}),e.dqlArtifact&&(u.dqlArtifact={source:e.dqlArtifact.source,sql:e.sql,name:e.dqlArtifact.name,sourcePath:e.dqlArtifact.sourcePath,kind:e.dqlArtifact.kind,metrics:e.dqlArtifact.metrics,dimensions:e.dqlArtifact.dimensions,parameters:e.dqlArtifact.parameters,parameterValues:e.dqlArtifact.parameterValues,persistence:e.dqlArtifact.persistence,trustState:e.dqlArtifact.trustState,compiledSql:e.dqlArtifact.compiledSql??e.sql,reviewState:e.dqlArtifact.trustState==="certified"?"certified":"review_required",...e.question?{question:e.question}:{}},u.dqlParameterValues=e.dqlArtifact.parameterValues),u}function L(){return`conv_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ee(e){return`conv_server_${e}`}function we(e,t,s=new Set){const n=t.filter(a=>!s.has(a.id)),u=new Map(e.flatMap(a=>a.threadId?[[a.threadId,a]]:[])),S=n.map(a=>{var w;const d=u.get(a.id);return{id:(d==null?void 0:d.id)??ee(a.id),title:((w=a.title)==null?void 0:w.trim())||(d!=null&&d.title&&d.title!=="New chat"?d.title:"Recovered chat"),createdAt:(d==null?void 0:d.createdAt)??a.createdAt,updatedAt:a.updatedAt>((d==null?void 0:d.updatedAt)??"")?a.updatedAt:(d==null?void 0:d.updatedAt)??a.updatedAt,items:(d==null?void 0:d.items)??[],threadId:a.id,favorite:a.favorite??(d==null?void 0:d.favorite)??!1}}),p=new Set(n.map(a=>a.id));return[...S,...e.filter(a=>(!a.threadId||!p.has(a.threadId))&&(!a.threadId||!s.has(a.threadId)))].sort((a,d)=>d.updatedAt.localeCompare(a.updatedAt)).slice(0,N)}function b(){if(typeof window>"u")return new Set;try{const e=JSON.parse(window.localStorage.getItem(Q)??"[]");return new Set(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}catch{return new Set}}function te(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Q,JSON.stringify([...e].slice(-N)))}catch{}}function ke(e){const t=b();t.add(e),te(t)}function U(e){const t=b();t.delete(e),te(t)}function ye(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t;if(s.kind==="run"&&s.run&&typeof s.run=="object"){const n=s.run;n.nextActions=Array.isArray(n.nextActions)?n.nextActions:[],n.artifacts=Array.isArray(n.artifacts)?n.artifacts:[],n.evaluations=Array.isArray(n.evaluations)?n.evaluations:[],n.steps=Array.isArray(n.steps)?n.steps:[]}return[t]}):[]}function Ce(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(B);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const s=b();return t.filter(n=>!n.threadId||!s.has(n.threadId)).map(n=>({...n,items:ye(n.items)}))}catch{return[]}}function qe(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Z)??void 0}catch{return}}function X(e){return e.map(t=>({...t,items:t.items.map(s=>s.kind==="run"?{...s,run:{...s.run,events:[]}}:s)}))}function C(e){const t=e.slice(0,N);if(typeof window>"u")return t;try{return window.localStorage.setItem(B,JSON.stringify(X(t))),t}catch{const s=t.slice(0,8);try{window.localStorage.setItem(B,JSON.stringify(X(s)))}catch{}return s}}function be(e){const t=e.find(n=>n.kind==="user"),s=t&&t.kind==="user"?t.text.trim():"";return s?s.length>48?`${s.slice(0,48).trimEnd()}…`:s:"New chat"}function je(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"";const s=Date.now()-t,n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m`;const u=Math.floor(n/60);if(u<24)return`${u}h`;const S=Math.floor(u/24);return S<7?`${S}d`:new Date(e).toLocaleDateString()}function Ke(){var V;const{state:e,dispatch:t}=re(),s=ce(),n=ie[e.themeMode],[u,S]=f.useState(()=>Ae()),[p,a]=f.useState(()=>Ce()),[d,w]=f.useState(!0),j=f.useMemo(()=>p.length>0,[]),[h,y]=f.useState(()=>{const r=qe();return r&&p.some(i=>i.id===r)?r:L()}),[v,D]=f.useState(!1);f.useEffect(()=>{try{window.localStorage.setItem(Z,h)}catch{}},[h]),f.useEffect(()=>{for(const r of b())R.deleteAgentThread(r).then(()=>U(r)).catch(()=>{})},[]),f.useEffect(()=>{let r=!1;const i=b();return R.listAgentThreads({limit:N}).then(({threads:l})=>{if(r)return;const m=l.filter(x=>x.surface==="ask"||x.surface==="notebook"&&!x.notebookPath),g=new Set([...i,...b()]),k=m.filter(x=>!g.has(x.id));a(x=>C(we(x,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),E=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),_=f.useCallback(r=>{r.length!==0&&a(i=>{const l=i.find(x=>x.id===h);if(l&&l.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:be(r),createdAt:(l==null?void 0:l.createdAt)??m,updatedAt:m,items:r,threadId:l==null?void 0:l.threadId},...i.filter(x=>x.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const l=i.find(g=>g.id===h),m=new Date().toISOString();return C(l?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),O=f.useCallback((r,i)=>{var g;const l=i.trim();if(!l)return;a(k=>C(k.map(x=>x.id===r?{...x,title:l}:x)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:l}).catch(()=>{})},[p]),M=f.useCallback(r=>{const i=p.find(m=>m.id===r),l=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:l}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:l}).catch(()=>{})},[p]),P=f.useCallback(()=>{v||y(L())},[v]),c=f.useCallback(r=>{v||y(r)},[v]),A=f.useCallback(r=>{var l;if(v)return;const i=(l=p.find(m=>m.id===r))==null?void 0:l.threadId;i&&(ke(i),R.deleteAgentThread(i).then(()=>U(i)).catch(()=>{})),a(m=>C(m.filter(g=>g.id!==r))),r===h&&y(L())},[h,p,v]),q=(r,i)=>{t({type:"OPEN_APP",appId:r,dashboardId:i})},z=(r,i)=>{t({type:"OPEN_GLOBAL_AI",audience:"stakeholder",context:{title:"Research",scopeHint:"Follow up on this research",selectedObject:{kind:"research",id:r,path:i}}})},I=f.useCallback(r=>{if(!e.activeFile||e.activeFile.type==="block"){s(r);return}const i=ve(r);i&&(t({type:"ADD_CELL",cell:i}),t({type:"SET_MAIN_VIEW",view:"notebook"}),le(i.id))},[t,s,e.activeFile]);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",overflow:"hidden",background:n.appBg},children:[o.jsx(De,{t:n,conversations:p,activeId:h,busy:v,loading:d,onNewChat:P,onSelect:c,onDelete:A,onRename:O,onToggleFavorite:M}),o.jsx("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:o.jsx(fe,{themeMode:e.themeMode,title:"Ask your data",askLayout:!0,scopeHint:u?`Scoped to ${u.domain}${u.modelAreaId?` · ${(V=u.modelAreaId.split("::").at(-1))==null?void 0:V.replace(/_/g," ")}`:""}${u.purpose?` for ${u.purpose}`:""}`:"Ask a question or request deep research",onClearScope:u?()=>{S(void 0),Ie(void 0)}:void 0,workspaceContext:u,audience:"stakeholder",initialMode:"auto",initialItems:T,onItemsChange:_,threadId:E,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,l)=>I({sql:r,title:i,question:l==null?void 0:l.question,sourceRunId:l==null?void 0:l.sourceRunId}),onInsertDql:I,insertDqlActionLabel:"Open in notebook"},h)})]})}function De({t:e,conversations:t,activeId:s,busy:n,loading:u,onNewChat:S,onSelect:p,onDelete:a,onRename:d,onToggleFavorite:w}){const j=n?"Finish the current question first":void 0,[h,y]=f.useState(null),[v,D]=f.useState(null),[T,E]=f.useState(""),_=t.filter(c=>c.favorite),$=t.filter(c=>!c.favorite),O=c=>{D(c.id),E(c.title)},M=()=>{v&&T.trim()&&d(v,T),D(null)},P=c=>{const A=c.id===s,q=h===c.id,z=v===c.id;return o.jsxs("div",{onMouseEnter:()=>y(c.id),onMouseLeave:()=>y(I=>I===c.id?null:I),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:I=>E(I.target.value),onBlur:M,onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),M()),I.key==="Escape"&&(I.preventDefault(),D(null))},"aria-label":"Conversation name",style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:7,border:`1px solid ${e.accent}`,background:e.appBg,color:e.textPrimary,fontSize:12.5,fontWeight:600}}):o.jsxs("button",{type:"button",onClick:()=>p(c.id),onDoubleClick:()=>O(c),disabled:n&&!A,title:n&&!A?j:`${c.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:A?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:A?e.accent:e.textSecondary,cursor:n&&!A?"not-allowed":"pointer",opacity:n&&!A?.5:1,textAlign:"left",fontSize:12.5,fontWeight:A?600:500,paddingRight:q?56:10},children:[A&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):c.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(me,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A&&n?"Working…":c.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:A&&n?e.accent:e.textMuted,fontWeight:A&&n?650:400},children:A&&n?"Live":je(c.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:c.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(c.id),children:o.jsx(G,{size:12,fill:c.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>O(c),children:o.jsx(pe,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(c.id),children:o.jsx(de,{size:12})})]}):null]},c.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick:S,disabled:n,title:j,style:{width:"100%",display:"inline-flex",alignItems:"center",gap:8,justifyContent:"center",padding:"9px 12px",borderRadius:8,border:`1px solid ${e.accent}`,background:e.accent,color:"var(--accent-on, #fff)",fontSize:13,fontWeight:650,cursor:n?"not-allowed":"pointer",opacity:n?.55:1},children:[o.jsx(se,{size:15,strokeWidth:2.4})," New chat"]})}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"0 8px 12px",display:"flex",flexDirection:"column",gap:2},children:u&&t.length===0?o.jsxs("div",{style:{padding:"10px 8px",display:"flex",alignItems:"center",gap:7,fontSize:11.5,color:e.textMuted},children:[o.jsx(J,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}),"Restoring project chats…"]}):t.length===0?o.jsx("div",{style:{padding:"10px 8px",fontSize:11.5,color:e.textMuted,lineHeight:1.5},children:"No past chats yet. Your conversations show up here so you can pick up where you left off."}):o.jsxs(o.Fragment,{children:[_.length>0?o.jsxs(o.Fragment,{children:[o.jsx(F,{t:e,children:"Favourites"}),_.map(c=>P(c)),o.jsx(F,{t:e,children:"Recent"})]}):o.jsx(F,{t:e,children:"Recent"}),$.map(c=>P(c))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(ae,{size:12,style:{flexShrink:0,color:e.success}}),o.jsx("span",{children:"Private project history · not committed to Git"})]})]})}function F({t:e,children:t}){return o.jsx("div",{style:{padding:"8px 8px 4px",fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:t})}function W({t:e,label:t,onClick:s,children:n}){return o.jsx("button",{type:"button","aria-label":t,title:t,onClick:u=>{u.stopPropagation(),s()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"none",background:e.cellBg,color:e.textMuted,cursor:"pointer"},children:n})}export{Ke as AnalyticsHome,ve as askNotebookCellFromPayload,we as mergePersistedAskConversations};