@hachej/boring-ui-cli 0.1.85 → 0.1.87

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 (71) hide show
  1. package/dist/server/modeApps.js +1 -0
  2. package/dist/server/pluginFrontRuntime.js +23 -0
  3. package/package.json +9 -9
  4. package/public/assets/{DebugDrawer-BF-awk9H.js → DebugDrawer-Crwr1-RI.js} +1 -1
  5. package/public/assets/{DiagramPane-CnEdIism.js → DiagramPane-BjMICSzV.js} +4 -4
  6. package/public/assets/{abnfDiagram-VRR7QNED-CLAKlr5l.js → abnfDiagram-VRR7QNED-DPWRLrCj.js} +1 -1
  7. package/public/assets/{architectureDiagram-ZJ3FMSHR-DEPw_oOi.js → architectureDiagram-ZJ3FMSHR-BznHt74F.js} +1 -1
  8. package/public/assets/{blockDiagram-677ZJIJ3-CExjLlYw.js → blockDiagram-677ZJIJ3-Bc-uMvZv.js} +1 -1
  9. package/public/assets/{c4Diagram-LMCZKHZV-D2dSJCeM.js → c4Diagram-LMCZKHZV-x9OWQMm3.js} +1 -1
  10. package/public/assets/channel-CAiNtULQ.js +1 -0
  11. package/public/assets/{chunk-32BRIVSS-CHD0tVUX.js → chunk-32BRIVSS-B-hpHl8F.js} +1 -1
  12. package/public/assets/{chunk-C7G6YPKG-BmisFQmp.js → chunk-C7G6YPKG-uFvWkH6u.js} +1 -1
  13. package/public/assets/{chunk-EX3LRPZG-eCmldOWJ.js → chunk-EX3LRPZG-BDeIDjs8.js} +1 -1
  14. package/public/assets/{chunk-HOUHSVGY-B_1yr7F3.js → chunk-HOUHSVGY-BcTh9Cy5.js} +1 -1
  15. package/public/assets/{chunk-ICXQ74PX-BTyIyjqc.js → chunk-ICXQ74PX-BDUDZE-Y.js} +1 -1
  16. package/public/assets/{chunk-MOJQB5TN-CT0SrQXT.js → chunk-MOJQB5TN-BJi3Jbh1.js} +1 -1
  17. package/public/assets/{chunk-OGEWGWER-v_5U_gzc.js → chunk-OGEWGWER-BMfvDdq8.js} +1 -1
  18. package/public/assets/{chunk-PUDLZKDR-CDwQspmm.js → chunk-PUDLZKDR-BP5Bjo1M.js} +1 -1
  19. package/public/assets/{chunk-Q4XR5HBZ-C4d7cEm8.js → chunk-Q4XR5HBZ-Yt9ETrQ4.js} +1 -1
  20. package/public/assets/{chunk-V7JOEXUC-pia1N70d.js → chunk-V7JOEXUC-CpiUOMHk.js} +1 -1
  21. package/public/assets/{chunk-VR4S4FIN-DZgoKNrb.js → chunk-VR4S4FIN-4OscHOKG.js} +1 -1
  22. package/public/assets/{chunk-WYO6CB5R-CrC2POLX.js → chunk-WYO6CB5R-CiUqhWtS.js} +2 -2
  23. package/public/assets/{chunk-ZGVPDNZ5-Bz6xfOza.js → chunk-ZGVPDNZ5-BP7ZwWUn.js} +1 -1
  24. package/public/assets/classDiagram-OUVF2IWQ-CA99TifN.js +1 -0
  25. package/public/assets/classDiagram-v2-EOCWNBFH-CA99TifN.js +1 -0
  26. package/public/assets/{cynefinDiagram-TSTJHNR4-BkRjvXUa.js → cynefinDiagram-TSTJHNR4-BxYBElDt.js} +1 -1
  27. package/public/assets/{dagre-VKFMJZFB-vz2bykmu.js → dagre-VKFMJZFB-CEzsJfj5.js} +1 -1
  28. package/public/assets/{diagram-FQU43EPY-B3ovUW12.js → diagram-FQU43EPY-Yoxoq2Ml.js} +1 -1
  29. package/public/assets/{diagram-G47NLZAW-CmpZj4fz.js → diagram-G47NLZAW-BeSzw0h-.js} +1 -1
  30. package/public/assets/{diagram-NH7WQ7WH-B9eq70uJ.js → diagram-NH7WQ7WH-Cqvt3rb_.js} +1 -1
  31. package/public/assets/{diagram-OA4YK3LP-DG1-0Ag3.js → diagram-OA4YK3LP-DJBSGsUs.js} +1 -1
  32. package/public/assets/{diagram-WEI45ONY-CN1V9bnE.js → diagram-WEI45ONY-D4b9C_A-.js} +1 -1
  33. package/public/assets/{dist-Dt60KW6m.js → dist-BcgWLSjc.js} +1 -1
  34. package/public/assets/{ebnfDiagram-CCIWWBDH-DkHgjHuu.js → ebnfDiagram-CCIWWBDH-WVuSMqSB.js} +1 -1
  35. package/public/assets/{erDiagram-Q63AITRT-CGT9TIdT.js → erDiagram-Q63AITRT-BuuyPJ_3.js} +1 -1
  36. package/public/assets/flowDiagram-23GEKE2U-CkTA-PWX.js +1 -0
  37. package/public/assets/{ganttDiagram-NO4QXBWP-Cf5x_CHZ.js → ganttDiagram-NO4QXBWP-CWXfDFIY.js} +1 -1
  38. package/public/assets/{gitGraphDiagram-IHSO6WYX-UxH6YhSw.js → gitGraphDiagram-IHSO6WYX-GAPjTonn.js} +1 -1
  39. package/public/assets/{highlighted-body-OFNGDK62-DK5KaerL.js → highlighted-body-OFNGDK62-BrD5dz2w.js} +1 -1
  40. package/public/assets/{index-UA_cHl90.css → index-BrpbLQBl.css} +1 -1
  41. package/public/assets/{index-DSCYbGhD.js → index-DAoG6NJz.js} +9 -9
  42. package/public/assets/{infoDiagram-FWYZ7A6U-CcX2Yt4c.js → infoDiagram-FWYZ7A6U-CJ09wWnx.js} +1 -1
  43. package/public/assets/{ishikawaDiagram-FXEZZL3T-CBmEPLhX.js → ishikawaDiagram-FXEZZL3T-CIehMp97.js} +1 -1
  44. package/public/assets/{journeyDiagram-5HDEW3XC-DQSRCV3t.js → journeyDiagram-5HDEW3XC-CTu1JZxZ.js} +1 -1
  45. package/public/assets/{kanban-definition-HUTT4EX6-Dw0Q6D-g.js → kanban-definition-HUTT4EX6-CpH17at_.js} +1 -1
  46. package/public/assets/{line-a6-xl0-l.js → line-DV0toWGN.js} +1 -1
  47. package/public/assets/mermaid-GHXKKRXX-D5LmLC_6.js +1 -0
  48. package/public/assets/{mindmap-definition-LN4V7U3C-upjXQ3oj.js → mindmap-definition-LN4V7U3C-DM59MH5G.js} +1 -1
  49. package/public/assets/{pegDiagram-2B236MQR-khcKyWeB.js → pegDiagram-2B236MQR-B3VbU3x1.js} +1 -1
  50. package/public/assets/{pieDiagram-ENE6RG2P-bJQBijMb.js → pieDiagram-ENE6RG2P-sO22u65R.js} +1 -1
  51. package/public/assets/{quadrantDiagram-ABIIQ3AL-BHPyVIsM.js → quadrantDiagram-ABIIQ3AL-Bmtq2B6v.js} +1 -1
  52. package/public/assets/{railroadDiagram-RFXS5EU6-D3f1Ta25.js → railroadDiagram-RFXS5EU6-DSZodXWg.js} +1 -1
  53. package/public/assets/{requirementDiagram-TGXJPOKE-CJut4R5D.js → requirementDiagram-TGXJPOKE-CfuCu5to.js} +1 -1
  54. package/public/assets/{sankeyDiagram-HTMAVEWB-t8gOrI-3.js → sankeyDiagram-HTMAVEWB-B20Fgpb7.js} +1 -1
  55. package/public/assets/{sequenceDiagram-DBY2YBRQ-Cq-V6lAC.js → sequenceDiagram-DBY2YBRQ-BuAxO00M.js} +1 -1
  56. package/public/assets/{stateDiagram-2N3HPSRC-CI-IeXsn.js → stateDiagram-2N3HPSRC-BwzG2dbk.js} +1 -1
  57. package/public/assets/stateDiagram-v2-6OUMAXLB-BZ6JVEuk.js +1 -0
  58. package/public/assets/{swimlanes-5IMT3BWC-Bx2VxwEC.js → swimlanes-5IMT3BWC-c3ksS3pT.js} +1 -1
  59. package/public/assets/swimlanesDiagram-G3AALYLV-PBt_14Mu.js +8 -0
  60. package/public/assets/{timeline-definition-FHXFAJF6-B4CMM1Dx.js → timeline-definition-FHXFAJF6-DMUcRUMQ.js} +1 -1
  61. package/public/assets/{vennDiagram-L72KCM5P-vetXq37w.js → vennDiagram-L72KCM5P-D4tetUdE.js} +1 -1
  62. package/public/assets/{wardleyDiagram-EHGQE667-ITDVqdiW.js → wardleyDiagram-EHGQE667-Cr5TS8on.js} +1 -1
  63. package/public/assets/{xychartDiagram-FW5EYKEG-BE-gt4-q.js → xychartDiagram-FW5EYKEG-BfGMZHbM.js} +1 -1
  64. package/public/index.html +10 -10
  65. package/public/assets/channel-DFNcJAbH.js +0 -1
  66. package/public/assets/classDiagram-OUVF2IWQ-OWcBOZiG.js +0 -1
  67. package/public/assets/classDiagram-v2-EOCWNBFH-OWcBOZiG.js +0 -1
  68. package/public/assets/flowDiagram-23GEKE2U-DQHgNKDB.js +0 -1
  69. package/public/assets/mermaid-GHXKKRXX-BCQmgWOt.js +0 -1
  70. package/public/assets/stateDiagram-v2-6OUMAXLB-CsniJ6Sc.js +0 -1
  71. package/public/assets/swimlanesDiagram-G3AALYLV-Bt_aLWJ1.js +0 -8
@@ -425,6 +425,7 @@ async function createWorkspacesModeApp(opts) {
425
425
  pluginPiSnapshots.set(pluginRuntimeKey(workspace), manager.inspectLoadedPiSnapshot());
426
426
  }
427
427
  function getOrCreatePluginRuntime(workspace) {
428
+ runtimeHost.activateWorkspace(workspace.id);
428
429
  const key = pluginRuntimeKey(workspace);
429
430
  let runtime = pluginRuntimes.get(key);
430
431
  if (!runtime) {
@@ -1105,6 +1105,8 @@ async function createPluginFrontRuntimeHost(options = {}) {
1105
1105
  const trackedWorkspaces = /* @__PURE__ */ new Map();
1106
1106
  const trackedPluginRevisions = /* @__PURE__ */ new Map();
1107
1107
  const transformCache = /* @__PURE__ */ new Map();
1108
+ const workspaceDisposalEpoch = /* @__PURE__ */ new Map();
1109
+ const disposedWorkspaces = /* @__PURE__ */ new Set();
1108
1110
  const mintedSupportPathsByCacheKey = /* @__PURE__ */ new Map();
1109
1111
  const mintedSupportPathRefCounts = /* @__PURE__ */ new Map();
1110
1112
  const limiter = new TransformLimiter(Math.max(1, options.maxTransformConcurrency ?? DEFAULT_MAX_TRANSFORM_CONCURRENCY));
@@ -1371,6 +1373,9 @@ async function createPluginFrontRuntimeHost(options = {}) {
1371
1373
  throw new PluginFrontRuntimeError(ErrorCode.enum.INTERNAL_ERROR, 503, "serve", "plugin front runtime host is closed");
1372
1374
  }
1373
1375
  const workspaceId = ensureSafeId("workspace", request.workspaceId);
1376
+ if (disposedWorkspaces.has(workspaceId)) {
1377
+ throw new PluginFrontRuntimeError(ErrorCode.enum.PATH_NOT_FOUND, 404, "validate", "plugin runtime workspace was evicted", { workspaceId });
1378
+ }
1374
1379
  const pluginId = ensureSafeId("plugin", request.pluginId);
1375
1380
  const revision = parseRevision(request.revision);
1376
1381
  const requestedPath = normalizeRequestSubpath(request.subpath);
@@ -1419,6 +1424,7 @@ async function createPluginFrontRuntimeHost(options = {}) {
1419
1424
  try {
1420
1425
  const resolved = await validateRequest(request);
1421
1426
  validated = resolved;
1427
+ const epochAtValidation = workspaceDisposalEpoch.get(resolved.workspaceId) ?? 0;
1422
1428
  const cached = transformCache.get(resolved.cacheKey);
1423
1429
  if (cached) {
1424
1430
  emit({
@@ -1512,6 +1518,14 @@ async function createPluginFrontRuntimeHost(options = {}) {
1512
1518
  );
1513
1519
  }
1514
1520
  });
1521
+ promise.catch(() => {
1522
+ });
1523
+ if ((workspaceDisposalEpoch.get(runtimeRequest.workspaceId) ?? 0) !== epochAtValidation) {
1524
+ throw new PluginFrontRuntimeError(ErrorCode.enum.PATH_NOT_FOUND, 404, "validate", "plugin runtime workspace was evicted while serving", {
1525
+ workspaceId: runtimeRequest.workspaceId,
1526
+ pluginId: runtimeRequest.pluginId
1527
+ });
1528
+ }
1515
1529
  transformCache.set(runtimeRequest.cacheKey, { runtimeId: runtimeRequest.runtimeId, promise });
1516
1530
  const response = await promise;
1517
1531
  emit({
@@ -1677,15 +1691,21 @@ async function createPluginFrontRuntimeHost(options = {}) {
1677
1691
  await invalidateMatching((entry) => entry.workspaceId === workspaceId && entry.pluginId === pluginId && (keepRevision === void 0 || entry.revision !== keepRevision));
1678
1692
  }
1679
1693
  async function disposeWorkspace(workspaceId) {
1694
+ workspaceDisposalEpoch.set(workspaceId, (workspaceDisposalEpoch.get(workspaceId) ?? 0) + 1);
1695
+ disposedWorkspaces.add(workspaceId);
1680
1696
  trackedWorkspaces.delete(workspaceId);
1681
1697
  trackedPluginRevisions.delete(workspaceId);
1682
1698
  await invalidateMatching((entry) => entry.workspaceId === workspaceId);
1683
1699
  }
1700
+ function activateWorkspace(workspaceId) {
1701
+ disposedWorkspaces.delete(ensureSafeId("workspace", workspaceId));
1702
+ }
1684
1703
  async function close() {
1685
1704
  if (closed) return;
1686
1705
  closed = true;
1687
1706
  trackedWorkspaces.clear();
1688
1707
  trackedPluginRevisions.clear();
1708
+ disposedWorkspaces.clear();
1689
1709
  transformCache.clear();
1690
1710
  mintedSupportPathsByCacheKey.clear();
1691
1711
  mintedSupportPathRefCounts.clear();
@@ -1720,7 +1740,9 @@ async function createPluginFrontRuntimeHost(options = {}) {
1720
1740
  return entryUrl;
1721
1741
  }
1722
1742
  function createFrontTargetResolver(workspaceId) {
1743
+ const disposalEpoch = workspaceDisposalEpoch.get(workspaceId) ?? 0;
1723
1744
  return (plugin, context) => {
1745
+ if ((workspaceDisposalEpoch.get(workspaceId) ?? 0) !== disposalEpoch) return void 0;
1724
1746
  if (!plugin.frontPath) return void 0;
1725
1747
  const frontEntrySubpath = normalizeRequestSubpath(context.frontEntrySubpath);
1726
1748
  if (!/(^|\/)front\//.test(frontEntrySubpath)) return void 0;
@@ -1791,6 +1813,7 @@ async function createPluginFrontRuntimeHost(options = {}) {
1791
1813
  basePath,
1792
1814
  singletonModules: HOST_SINGLETON_MODULES,
1793
1815
  createFrontTargetResolver,
1816
+ activateWorkspace,
1794
1817
  trackPlugin,
1795
1818
  untrackPlugin,
1796
1819
  invalidatePlugin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hachej/boring-ui-cli",
3
- "version": "0.1.85",
3
+ "version": "0.1.87",
4
4
  "description": "Turn an agent into an app",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,14 +21,14 @@
21
21
  "typescript": "^6.0.3",
22
22
  "vite": "^8.1.2",
23
23
  "yaml": "^2.9.0",
24
- "@hachej/boring-agent": "0.1.85",
25
- "@hachej/boring-ask-user": "0.1.85",
26
- "@hachej/boring-automation": "0.1.85",
27
- "@hachej/boring-tasks": "0.1.85",
28
- "@hachej/boring-ui-kit": "0.1.85",
29
- "@hachej/boring-diagram": "0.1.85",
30
- "@hachej/boring-workspace": "0.1.85",
31
- "@hachej/boring-ui-plugin-cli": "0.1.85"
24
+ "@hachej/boring-ask-user": "0.1.87",
25
+ "@hachej/boring-agent": "0.1.87",
26
+ "@hachej/boring-automation": "0.1.87",
27
+ "@hachej/boring-diagram": "0.1.87",
28
+ "@hachej/boring-tasks": "0.1.87",
29
+ "@hachej/boring-ui-kit": "0.1.87",
30
+ "@hachej/boring-ui-plugin-cli": "0.1.87",
31
+ "@hachej/boring-workspace": "0.1.87"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@tailwindcss/vite": "^4.3.1",
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{n as t,t as n}from"./jsx-runtime-CBD9r_Rc.js";import{Ct as r,G as i,St as a,Tt as o,d as s,wt as c}from"./createLucideIcon-Wu4zuv2w.js";import{A as l,E as u,M as d,N as f,T as p,j as m,k as h}from"./index-DSCYbGhD.js";var g=e(t(),1),_=e(n(),1);function v({value:e,label:t}){let[n,r]=(0,g.useState)(!1);return(0,_.jsx)(i,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:(0,g.useCallback)(()=>{p(e).then(e=>{e&&(r(!0),window.setTimeout(()=>r(!1),1200))})},[e]),className:`text-muted-foreground/60`,"aria-label":t,title:t,children:n?(0,_.jsx)(f,{className:`h-3 w-3`}):(0,_.jsx)(l,{className:`h-3 w-3`})})}function y({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-muted/20 p-2`,children:[(0,_.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,_.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,_.jsx)(v,{value:t,label:`Copy ${e}`})]}),(0,_.jsx)(`code`,{className:`block break-all font-mono text-[11px] leading-relaxed text-foreground dark:text-zinc-100`,children:t})]})}function b({sessionId:e}){return(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 overflow-auto p-3 text-[11px] text-muted-foreground dark:text-zinc-300`,children:[(0,_.jsx)(`p`,{className:`text-muted-foreground dark:text-zinc-300`,children:`This web chat is backed by a runtime session. Use the id below for support or debugging.`}),(0,_.jsx)(y,{label:`Runtime session id`,value:e})]})}var x=2500,S=20;function C({apiBaseUrl:e,fetch:t,sessionId:n,requestHeaders:r,storageScope:a}){let[o,s]=(0,g.useState)({kind:`loading`}),[c,l]=(0,g.useState)(0),u=(0,g.useRef)(0),d=(0,g.useCallback)(()=>{u.current=0,l(e=>e+1)},[]);return(0,g.useEffect)(()=>{let i=!1,o=null;return s({kind:`loading`}),(t??globalThis.fetch.bind(globalThis))(j(e,`/api/v1/agent/sessions/${encodeURIComponent(n)}/system-prompt`),{headers:M(r,a)}).then(async e=>{if(i)return;if(e.ok){let t=await e.json();if(typeof t.systemPrompt==`string`){u.current=0,s({kind:`ok`,text:t.systemPrompt});return}}let t=(await e.json().catch(()=>null))?.error?.message??`HTTP ${e.status}`;e.status===404&&u.current<S?(s({kind:`empty`,reason:t}),o=setTimeout(()=>{i||(u.current++,l(e=>e+1))},x)):s(e.status===404?{kind:`empty`,reason:t}:{kind:`error`,reason:t})}).catch(e=>{i||s({kind:`error`,reason:e instanceof Error?e.message:String(e)})}),()=>{i=!0,o&&clearTimeout(o)}},[e,t,n,r,c,a]),(0,_.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between px-3 pt-2 pb-1 border-b border-border/40`,children:[(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 font-mono`,children:o.kind===`ok`?`${o.text.length.toLocaleString()} chars`:o.kind===`loading`?`loading…`:o.kind===`empty`?`waiting for session · retry ${u.current}/${S}`:`error`}),o.kind!==`loading`&&(0,_.jsx)(i,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:d,className:`text-muted-foreground/60`,"aria-label":`Refresh system prompt`,children:(0,_.jsx)(h,{className:`h-3 w-3`})})]}),(o.kind===`loading`||o.kind===`empty`)&&(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground p-3`,children:o.kind===`loading`?`Loading…`:o.reason}),o.kind===`error`&&(0,_.jsx)(`p`,{className:`text-[11px] text-destructive p-3`,children:o.reason}),o.kind===`ok`&&(0,_.jsx)(`pre`,{className:`flex-1 overflow-auto px-3 py-2 font-mono text-[11px] leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:o.text})]})}function w(e){let t=e,n=t?.type??`?`;if(n===`text`){let e=String(t.text??``);return e.slice(0,80)+(e.length>80?`…`:``)}if(n===`tool-invocation`){let e=t.toolInvocation,n=String(e?.state??``);return`${e?.toolName??`?`}() · ${n}`}if(n===`reasoning`){let e=String(t.text??t.reasoning??``);return e.slice(0,80)+(e.length>80?`…`:``)}return n}function T(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=r,a=i.createdAt?new Date(i.createdAt).toISOString().slice(11,23):null;for(let e=0;e<r.parts.length;e++){let i=r.parts[e];t.push({msgId:r.id,msgIndex:n,role:r.role,time:a,partIndex:e,partType:i?.type??`unknown`,part:i})}}return t}function E({messages:e}){let t=T(e),[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(t.length);return(0,g.useEffect)(()=>{t.length!==a.current&&(i.current?.scrollIntoView({behavior:`smooth`}),a.current=t.length)},[t.length]),t.length===0?(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground p-3`,children:`No messages yet.`}):(0,_.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 px-3 pt-2 pb-1 text-[10px] text-muted-foreground/80 font-mono border-b border-border/40`,children:[e.length,` msg · `,t.length,` parts`]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[t.map(e=>{let t=`${e.msgId}:${e.partIndex}`,i=n===t;return(0,_.jsxs)(`div`,{className:`border-b border-border/30 last:border-0`,children:[(0,_.jsxs)(s,{type:`button`,variant:`ghost`,onClick:()=>r(i?null:t),className:`h-auto w-full justify-start gap-1.5 rounded-none px-2 py-1.5 text-left`,children:[(0,_.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground/40`,children:i?(0,_.jsx)(d,{className:`h-3 w-3`}):(0,_.jsx)(m,{className:`h-3 w-3`})}),(0,_.jsx)(`span`,{className:`font-mono text-[10px] shrink-0 w-20`,children:e.time?(0,_.jsx)(`span`,{className:`text-muted-foreground/60`,children:e.time}):(0,_.jsxs)(`span`,{className:`text-muted-foreground/30`,children:[`m`,e.msgIndex]})}),(0,_.jsx)(`span`,{className:u(`shrink-0 font-mono text-[10px] w-14`,e.role===`user`?`text-accent`:`text-muted-foreground`),children:e.role}),(0,_.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/60 w-24`,children:e.partType}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground truncate`,children:w(e.part)})]}),i&&(0,_.jsx)(`pre`,{className:`px-3 pb-2 font-mono text-[10px] leading-relaxed text-foreground/80 whitespace-pre-wrap break-words bg-muted/20`,children:JSON.stringify(e.part,null,2)})]},t)}),(0,_.jsx)(`div`,{ref:i})]})]})}var D=[{id:`session`,label:`Session`},{id:`prompt`,label:`System prompt`},{id:`messages`,label:`Messages`}],O=280,k=800;function A({apiBaseUrl:e,fetch:t,sessionId:n,messages:i,requestHeaders:s,storageScope:l,width:d,onWidthChange:f}){let[p,m]=(0,g.useState)(`session`);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{onMouseDown:(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=d,r=e=>{let r=t-e.clientX;f(Math.min(k,Math.max(O,n+r)))},i=()=>{window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)};window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},[d,f]),className:`w-1 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors`,"aria-hidden":!0}),(0,_.jsx)(`aside`,{style:{width:d},className:u(`flex h-full shrink-0 flex-col border-l border-border/60`,`bg-[oklch(from_var(--background)_calc(l-0.01)_c_h)]`),children:(0,_.jsxs)(a,{value:p,onValueChange:e=>m(e),className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,_.jsx)(`header`,{className:`flex shrink-0 items-center gap-0 border-b border-border/60 px-1`,children:(0,_.jsx)(c,{variant:`line`,className:`h-auto gap-0 p-0 w-full`,children:D.map(({id:e,label:t})=>(0,_.jsx)(o,{value:e,className:`h-8 flex-none px-3 py-2 text-[11px] font-medium data-[state=active]:after:bg-[color:var(--accent)]`,children:t},e))})}),(0,_.jsx)(r,{value:`session`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(b,{sessionId:n})}),(0,_.jsx)(r,{value:`prompt`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(C,{apiBaseUrl:e,fetch:t,sessionId:n,requestHeaders:s,storageScope:l})}),(0,_.jsx)(r,{value:`messages`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(E,{messages:i})})]})})]})}function j(e,t){return`${e?.replace(/\/$/,``)??``}${t}`}function M(e,t){if(!e&&!t)return;let n={...e??{}},r=Object.keys(n).some(e=>e.toLowerCase()===`x-boring-storage-scope`);return t&&!r&&(n[`x-boring-storage-scope`]=t),n}export{A as DebugDrawer};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{n as t,t as n}from"./jsx-runtime-CBD9r_Rc.js";import{Ct as r,G as i,St as a,Tt as o,d as s,wt as c}from"./createLucideIcon-Wu4zuv2w.js";import{A as l,E as u,M as d,N as f,T as p,j as m,k as h}from"./index-DAoG6NJz.js";var g=e(t(),1),_=e(n(),1);function v({value:e,label:t}){let[n,r]=(0,g.useState)(!1);return(0,_.jsx)(i,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:(0,g.useCallback)(()=>{p(e).then(e=>{e&&(r(!0),window.setTimeout(()=>r(!1),1200))})},[e]),className:`text-muted-foreground/60`,"aria-label":t,title:t,children:n?(0,_.jsx)(f,{className:`h-3 w-3`}):(0,_.jsx)(l,{className:`h-3 w-3`})})}function y({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-muted/20 p-2`,children:[(0,_.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,_.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,_.jsx)(v,{value:t,label:`Copy ${e}`})]}),(0,_.jsx)(`code`,{className:`block break-all font-mono text-[11px] leading-relaxed text-foreground dark:text-zinc-100`,children:t})]})}function b({sessionId:e}){return(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 overflow-auto p-3 text-[11px] text-muted-foreground dark:text-zinc-300`,children:[(0,_.jsx)(`p`,{className:`text-muted-foreground dark:text-zinc-300`,children:`This web chat is backed by a runtime session. Use the id below for support or debugging.`}),(0,_.jsx)(y,{label:`Runtime session id`,value:e})]})}var x=2500,S=20;function C({apiBaseUrl:e,fetch:t,sessionId:n,requestHeaders:r,storageScope:a}){let[o,s]=(0,g.useState)({kind:`loading`}),[c,l]=(0,g.useState)(0),u=(0,g.useRef)(0),d=(0,g.useCallback)(()=>{u.current=0,l(e=>e+1)},[]);return(0,g.useEffect)(()=>{let i=!1,o=null;return s({kind:`loading`}),(t??globalThis.fetch.bind(globalThis))(j(e,`/api/v1/agent/sessions/${encodeURIComponent(n)}/system-prompt`),{headers:M(r,a)}).then(async e=>{if(i)return;if(e.ok){let t=await e.json();if(typeof t.systemPrompt==`string`){u.current=0,s({kind:`ok`,text:t.systemPrompt});return}}let t=(await e.json().catch(()=>null))?.error?.message??`HTTP ${e.status}`;e.status===404&&u.current<S?(s({kind:`empty`,reason:t}),o=setTimeout(()=>{i||(u.current++,l(e=>e+1))},x)):s(e.status===404?{kind:`empty`,reason:t}:{kind:`error`,reason:t})}).catch(e=>{i||s({kind:`error`,reason:e instanceof Error?e.message:String(e)})}),()=>{i=!0,o&&clearTimeout(o)}},[e,t,n,r,c,a]),(0,_.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between px-3 pt-2 pb-1 border-b border-border/40`,children:[(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 font-mono`,children:o.kind===`ok`?`${o.text.length.toLocaleString()} chars`:o.kind===`loading`?`loading…`:o.kind===`empty`?`waiting for session · retry ${u.current}/${S}`:`error`}),o.kind!==`loading`&&(0,_.jsx)(i,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:d,className:`text-muted-foreground/60`,"aria-label":`Refresh system prompt`,children:(0,_.jsx)(h,{className:`h-3 w-3`})})]}),(o.kind===`loading`||o.kind===`empty`)&&(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground p-3`,children:o.kind===`loading`?`Loading…`:o.reason}),o.kind===`error`&&(0,_.jsx)(`p`,{className:`text-[11px] text-destructive p-3`,children:o.reason}),o.kind===`ok`&&(0,_.jsx)(`pre`,{className:`flex-1 overflow-auto px-3 py-2 font-mono text-[11px] leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:o.text})]})}function w(e){let t=e,n=t?.type??`?`;if(n===`text`){let e=String(t.text??``);return e.slice(0,80)+(e.length>80?`…`:``)}if(n===`tool-invocation`){let e=t.toolInvocation,n=String(e?.state??``);return`${e?.toolName??`?`}() · ${n}`}if(n===`reasoning`){let e=String(t.text??t.reasoning??``);return e.slice(0,80)+(e.length>80?`…`:``)}return n}function T(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=r,a=i.createdAt?new Date(i.createdAt).toISOString().slice(11,23):null;for(let e=0;e<r.parts.length;e++){let i=r.parts[e];t.push({msgId:r.id,msgIndex:n,role:r.role,time:a,partIndex:e,partType:i?.type??`unknown`,part:i})}}return t}function E({messages:e}){let t=T(e),[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(t.length);return(0,g.useEffect)(()=>{t.length!==a.current&&(i.current?.scrollIntoView({behavior:`smooth`}),a.current=t.length)},[t.length]),t.length===0?(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground p-3`,children:`No messages yet.`}):(0,_.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,_.jsxs)(`div`,{className:`shrink-0 px-3 pt-2 pb-1 text-[10px] text-muted-foreground/80 font-mono border-b border-border/40`,children:[e.length,` msg · `,t.length,` parts`]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[t.map(e=>{let t=`${e.msgId}:${e.partIndex}`,i=n===t;return(0,_.jsxs)(`div`,{className:`border-b border-border/30 last:border-0`,children:[(0,_.jsxs)(s,{type:`button`,variant:`ghost`,onClick:()=>r(i?null:t),className:`h-auto w-full justify-start gap-1.5 rounded-none px-2 py-1.5 text-left`,children:[(0,_.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground/40`,children:i?(0,_.jsx)(d,{className:`h-3 w-3`}):(0,_.jsx)(m,{className:`h-3 w-3`})}),(0,_.jsx)(`span`,{className:`font-mono text-[10px] shrink-0 w-20`,children:e.time?(0,_.jsx)(`span`,{className:`text-muted-foreground/60`,children:e.time}):(0,_.jsxs)(`span`,{className:`text-muted-foreground/30`,children:[`m`,e.msgIndex]})}),(0,_.jsx)(`span`,{className:u(`shrink-0 font-mono text-[10px] w-14`,e.role===`user`?`text-accent`:`text-muted-foreground`),children:e.role}),(0,_.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/60 w-24`,children:e.partType}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground truncate`,children:w(e.part)})]}),i&&(0,_.jsx)(`pre`,{className:`px-3 pb-2 font-mono text-[10px] leading-relaxed text-foreground/80 whitespace-pre-wrap break-words bg-muted/20`,children:JSON.stringify(e.part,null,2)})]},t)}),(0,_.jsx)(`div`,{ref:i})]})]})}var D=[{id:`session`,label:`Session`},{id:`prompt`,label:`System prompt`},{id:`messages`,label:`Messages`}],O=280,k=800;function A({apiBaseUrl:e,fetch:t,sessionId:n,messages:i,requestHeaders:s,storageScope:l,width:d,onWidthChange:f}){let[p,m]=(0,g.useState)(`session`);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{onMouseDown:(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=d,r=e=>{let r=t-e.clientX;f(Math.min(k,Math.max(O,n+r)))},i=()=>{window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)};window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},[d,f]),className:`w-1 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors`,"aria-hidden":!0}),(0,_.jsx)(`aside`,{style:{width:d},className:u(`flex h-full shrink-0 flex-col border-l border-border/60`,`bg-[oklch(from_var(--background)_calc(l-0.01)_c_h)]`),children:(0,_.jsxs)(a,{value:p,onValueChange:e=>m(e),className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,_.jsx)(`header`,{className:`flex shrink-0 items-center gap-0 border-b border-border/60 px-1`,children:(0,_.jsx)(c,{variant:`line`,className:`h-auto gap-0 p-0 w-full`,children:D.map(({id:e,label:t})=>(0,_.jsx)(o,{value:e,className:`h-8 flex-none px-3 py-2 text-[11px] font-medium data-[state=active]:after:bg-[color:var(--accent)]`,children:t},e))})}),(0,_.jsx)(r,{value:`session`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(b,{sessionId:n})}),(0,_.jsx)(r,{value:`prompt`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(C,{apiBaseUrl:e,fetch:t,sessionId:n,requestHeaders:s,storageScope:l})}),(0,_.jsx)(r,{value:`messages`,forceMount:!0,className:`flex flex-col flex-1 min-h-0 overflow-hidden data-[state=inactive]:hidden`,children:(0,_.jsx)(E,{messages:i})})]})})]})}function j(e,t){return`${e?.replace(/\/$/,``)??``}${t}`}function M(e,t){if(!e&&!t)return;let n={...e??{}},r=Object.keys(n).some(e=>e.toLowerCase()===`x-boring-storage-scope`);return t&&!r&&(n[`x-boring-storage-scope`]=t),n}export{A as DebugDrawer};