@trops/dash-core 0.1.765 → 0.1.766

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.
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import _typeof from '@babel/runtime/helpers/typeof';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import * as DashReact from '@trops/dash-react';
5
- import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, useStatusTokens, ButtonIcon3, DropdownPanel, MenuItem2, Caption2, StatusBadge as StatusBadge$1, ConfirmationModal, DropComponent, DragComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon2, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, ListRow, AlgoliaSearchBox, CodeEditorInline, Icon2, SectionLabel, SegmentedControl, ChatMessage, ChatComposer, useResizableWidth, ResizeHandle, PanelHeader, ChoiceMenu, CommandPalette, useSidebar, FilterMenu, Navbar, withRouter, Menu as Menu$1, ChatToolCall } from '@trops/dash-react';
5
+ import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, useStatusTokens, ButtonIcon3, DropdownPanel, MenuItem2, Caption2, StatusBadge as StatusBadge$1, ConfirmationModal, DropComponent, DragComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon2, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, ListRow, AlgoliaSearchBox, CodeEditorInline, Icon2, SectionLabel, SegmentedControl, ChatMessage, ChatComposer, useResizableWidth, ResizeHandle, PanelHeader, ChoiceMenu, CommandPalette, useSidebar, ChatToolCall, FilterMenu, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
6
6
  export * from '@trops/dash-react';
7
7
  export { FontAwesomeIcon, ThemeContext } from '@trops/dash-react';
8
8
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
@@ -59781,6 +59781,15 @@ function turnsForRun(r) {
59781
59781
  stale: stale
59782
59782
  });
59783
59783
  }
59784
+ // Stopped before it answered (Stop in the chat, TEAM-015): say so, so the
59785
+ // question isn't left hanging.
59786
+ if (r.status === "stopped" && !r.output && !pending) {
59787
+ turns.push({
59788
+ kind: "system",
59789
+ text: "Stopped",
59790
+ at: r.endedAt || at
59791
+ });
59792
+ }
59784
59793
  if (r.outputUnavailable) {
59785
59794
  turns.push({
59786
59795
  kind: "bot",
@@ -59794,6 +59803,10 @@ function turnsForRun(r) {
59794
59803
  text: r.output || r.text || "",
59795
59804
  pending: pending,
59796
59805
  at: r.endedAt || at,
59806
+ // Shown beside the bot's name: "Sonnet · 2.1k tokens" (TEAM-015 AC8).
59807
+ model: r.model || null,
59808
+ usage: r.usage || null,
59809
+ cost: r.cost || null,
59797
59810
  // The run's window — a lead's drafts made in it are linked here (5b).
59798
59811
  startedAt: r.startedAt || null,
59799
59812
  endedAt: r.endedAt || null
@@ -69046,10 +69059,6 @@ var BotChat = function BotChat(_ref) {
69046
69059
  var strong = currentTheme["text-neutral-light"] || "text-gray-200";
69047
69060
  var statusTokens = useStatusTokens();
69048
69061
  var hairline = currentTheme["border-neutral-dark"] || "border-gray-700";
69049
- var bubble = currentTheme["bg-primary-very-dark"] || "bg-gray-800";
69050
- var bubbleBorder = currentTheme["border-primary-dark"] || "border-gray-600";
69051
- // The bot's (or lead's) answers: a quieter, left-aligned bubble.
69052
- var answerBg = currentTheme["bg-neutral-very-dark"] || "bg-gray-900";
69053
69062
  var _useState = useState(null),
69054
69063
  _useState2 = _slicedToArray(_useState, 2),
69055
69064
  runs = _useState2[0],
@@ -69292,55 +69301,37 @@ var BotChat = function BotChat(_ref) {
69292
69301
  return _ref4.apply(this, arguments);
69293
69302
  };
69294
69303
  }();
69295
- var onKeyDown = function onKeyDown(e) {
69296
- if (e.key === "Enter" && !e.shiftKey) {
69297
- e.preventDefault();
69298
- send();
69299
- }
69304
+
69305
+ // Stop the run in progress (the composer's Send becomes Stop).
69306
+ var stop = function stop() {
69307
+ var bots = api$a();
69308
+ if (bots && bots.stop && bot) bots.stop(bot.id);
69300
69309
  };
69301
69310
  var renderTurn = function renderTurn(t, i) {
69302
69311
  switch (t.kind) {
69303
69312
  case "divider":
69304
- return /*#__PURE__*/jsxs("div", {
69305
- className: "flex flex-row items-center gap-3 my-3 text-xs ".concat(muted),
69306
- children: [/*#__PURE__*/jsx("div", {
69307
- className: "flex-1 border-t ".concat(hairline)
69308
- }), t.text, /*#__PURE__*/jsx("div", {
69309
- className: "flex-1 border-t ".concat(hairline)
69310
- })]
69313
+ return /*#__PURE__*/jsx(ChatMessage, {
69314
+ role: "note",
69315
+ children: t.text
69311
69316
  }, i);
69312
69317
  case "system":
69313
- return /*#__PURE__*/jsxs("div", {
69314
- className: "text-xs ".concat(muted),
69318
+ return /*#__PURE__*/jsxs(ChatMessage, {
69319
+ role: "note",
69315
69320
  children: [t.text, timeOf(t.at) ? " \xB7 ".concat(timeOf(t.at)) : ""]
69316
69321
  }, i);
69317
69322
  case "user":
69318
- return /*#__PURE__*/jsx("div", {
69319
- className: "flex flex-row justify-end",
69320
- children: /*#__PURE__*/jsx("div", {
69321
- className: "max-w-xl rounded-xl border px-3 py-2 text-sm whitespace-pre-wrap ".concat(bubble, " ").concat(bubbleBorder),
69322
- children: t.text
69323
- })
69323
+ return /*#__PURE__*/jsx(ChatMessage, {
69324
+ role: "you",
69325
+ children: t.text
69324
69326
  }, i);
69325
69327
  case "tools":
69326
69328
  return /*#__PURE__*/jsx("div", {
69327
69329
  className: "flex flex-col gap-1",
69328
69330
  children: t.calls.map(function (c, j) {
69329
- return /*#__PURE__*/jsxs("div", {
69330
- className: "flex flex-row items-center gap-2 rounded-md border px-3 py-1.5 text-xs ".concat(hairline, " ").concat(muted),
69331
- children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
69332
- icon: c.ok === false ? "xmark" : c.ok ? "check" : t.live ? "circle-notch" : "minus",
69333
- className: "h-3 w-3"
69334
- }), /*#__PURE__*/jsx("span", {
69335
- className: "font-mono",
69336
- children: c.tool
69337
- }), c.provider ? /*#__PURE__*/jsxs("span", {
69338
- children: ["\xB7 ", c.provider]
69339
- }) : null, c.ok === false ? /*#__PURE__*/jsx("span", {
69340
- children: "\xB7 failed"
69341
- }) : null, c.ok == null && !t.live ? /*#__PURE__*/jsx("span", {
69342
- children: "\xB7 didn't finish"
69343
- }) : null]
69331
+ return /*#__PURE__*/jsx(ChatToolCall, {
69332
+ name: c.tool,
69333
+ status: c.ok === false ? "error" : c.ok ? "done" : t.live ? "running" : "error",
69334
+ source: [c.provider, c.ok === false ? "failed" : null, c.ok == null && !t.live ? "didn't finish" : null].filter(Boolean).join(" · ") || null
69344
69335
  }, j);
69345
69336
  })
69346
69337
  }, i);
@@ -69401,32 +69392,31 @@ var BotChat = function BotChat(_ref) {
69401
69392
  var to = t.endedAt ? Date.parse(t.endedAt) + 5000 : Infinity;
69402
69393
  return d.leadId === bot.id && c >= from && c <= to;
69403
69394
  }) : EMPTY$5;
69404
- return /*#__PURE__*/jsxs("div", {
69405
- className: "flex flex-col gap-1 items-start",
69406
- children: [/*#__PURE__*/jsx("span", {
69407
- className: "text-xs ".concat(muted),
69408
- children: bot.name
69409
- }), /*#__PURE__*/jsxs("div", {
69410
- "data-testid": "answer-bubble",
69411
- className: "max-w-2xl rounded-xl border px-3 py-2 flex flex-col gap-2 ".concat(answerBg, " ").concat(hairline),
69412
- children: [t.unavailable ? /*#__PURE__*/jsx("span", {
69413
- className: "text-sm ".concat(muted),
69414
- children: "Answer unavailable \u2014 it was stored encrypted with a key this app can't read."
69415
- }) : /*#__PURE__*/jsx("span", {
69416
- className: "text-sm whitespace-pre-wrap leading-relaxed",
69417
- children: t.text ? toPlainText(t.text) : t.pending ? "Working…" : ""
69418
- }), madeHere.map(function (d) {
69419
- return /*#__PURE__*/jsx("div", {
69420
- children: /*#__PURE__*/jsx(Button3, {
69421
- title: "Review draft: ".concat(d.definition && d.definition.name),
69422
- size: "sm",
69423
- onClick: function onClick() {
69424
- return onOpenDraft(d.id);
69425
- }
69426
- })
69395
+ return /*#__PURE__*/jsx(ChatMessage, {
69396
+ role: "reply",
69397
+ label: bot.name,
69398
+ meta: t.pending ? null : runCostLabel(t) || null,
69399
+ streaming: !!t.pending,
69400
+ testId: "answer-bubble",
69401
+ footer: madeHere.length ? /*#__PURE__*/jsx("div", {
69402
+ className: "flex flex-row flex-wrap gap-2",
69403
+ children: madeHere.map(function (d) {
69404
+ return /*#__PURE__*/jsx(Button3, {
69405
+ title: "Review draft: ".concat(d.definition && d.definition.name),
69406
+ size: "sm",
69407
+ onClick: function onClick() {
69408
+ return onOpenDraft(d.id);
69409
+ }
69427
69410
  }, d.id);
69428
- })]
69429
- })]
69411
+ })
69412
+ }) : null,
69413
+ children: t.unavailable ? /*#__PURE__*/jsx("span", {
69414
+ className: muted,
69415
+ children: "Answer unavailable \u2014 it was stored encrypted with a key this app can't read."
69416
+ }) : /*#__PURE__*/jsx("span", {
69417
+ className: "whitespace-pre-wrap",
69418
+ children: t.text ? toPlainText(t.text) : t.pending ? "Working…" : ""
69419
+ })
69430
69420
  }, i);
69431
69421
  }
69432
69422
  default:
@@ -69501,50 +69491,45 @@ var BotChat = function BotChat(_ref) {
69501
69491
  onClick: jumpToNewest
69502
69492
  })
69503
69493
  }) : null]
69504
- }), paused ? /*#__PURE__*/jsxs("div", {
69505
- className: "flex-shrink-0 mx-5 mb-2 rounded-lg border px-3 py-2 flex flex-row items-center gap-3 text-xs ".concat(hairline),
69506
- "data-testid": "bot-chat-paused",
69507
- children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
69508
- icon: "pause",
69509
- className: "h-3 w-3 ".concat(muted)
69510
- }), /*#__PURE__*/jsx("span", {
69511
- className: "flex-1",
69512
- children: "Paused \u2014 it won't answer until you resume it."
69513
- }), onResume ? /*#__PURE__*/jsx(Button, {
69514
- title: "Resume",
69515
- size: "sm",
69516
- onClick: function onClick() {
69517
- return onResume();
69518
- }
69519
- }) : null]
69520
- }) : null, /*#__PURE__*/jsxs("div", {
69521
- className: "flex-shrink-0 border-t px-5 py-3 flex flex-col gap-2 ".concat(hairline),
69522
- children: [notice ? /*#__PURE__*/jsx("span", {
69523
- role: "status",
69524
- className: "text-xs ".concat(statusTokens.warning.text),
69525
- "data-testid": "bot-chat-notice",
69526
- children: notice
69527
- }) : null, /*#__PURE__*/jsxs("div", {
69528
- className: "flex flex-row items-end gap-2",
69529
- children: [/*#__PURE__*/jsx("div", {
69530
- className: "flex-1",
69531
- children: /*#__PURE__*/jsx(TextArea, {
69532
- value: draft,
69533
- onChange: setDraft,
69534
- rows: 2,
69535
- placeholder: paused ? "Resume ".concat(bot.name, " to message it") : isLead ? "Ask the lead about this team…" : (runs || EMPTY$5).length && !freshNext ? "Reply to ".concat(bot.name, "\u2026") : "Message ".concat(bot.name, "\u2026"),
69536
- disabled: paused,
69537
- "aria-label": "Message",
69538
- onKeyDown: onKeyDown
69539
- })
69540
- }), /*#__PURE__*/jsx(Button, {
69541
- title: isLead ? "Ask" : "Send",
69542
- size: "sm",
69543
- onClick: send,
69544
- disabled: !draft.trim() || !!live || paused
69545
- })]
69546
- }), /*#__PURE__*/jsxs("div", {
69547
- className: "flex flex-row items-center justify-between text-xs ".concat(muted),
69494
+ }), /*#__PURE__*/jsx(ChatComposer, {
69495
+ value: draft,
69496
+ onChange: function onChange(v) {
69497
+ return setDraft(v);
69498
+ },
69499
+ onSend: send,
69500
+ onStop: stop,
69501
+ busy: !!live,
69502
+ disabled: paused,
69503
+ ariaLabel: "Message",
69504
+ sendLabel: isLead ? "Ask" : "Send",
69505
+ placeholder: paused ? "Resume ".concat(bot.name, " to message it") : isLead ? "Ask the lead about this team…" : (runs || EMPTY$5).length && !freshNext ? "Reply to ".concat(bot.name, "\u2026") : "Message ".concat(bot.name, "\u2026"),
69506
+ above: paused || notice ? /*#__PURE__*/jsxs("div", {
69507
+ className: "flex flex-col gap-2",
69508
+ children: [paused ? /*#__PURE__*/jsxs("div", {
69509
+ className: "rounded-lg border px-3 py-2 flex flex-row items-center gap-3 text-xs ".concat(hairline),
69510
+ "data-testid": "bot-chat-paused",
69511
+ children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
69512
+ icon: "pause",
69513
+ className: "h-3 w-3 ".concat(muted)
69514
+ }), /*#__PURE__*/jsx("span", {
69515
+ className: "flex-1",
69516
+ children: "Paused \u2014 it won't answer until you resume it."
69517
+ }), onResume ? /*#__PURE__*/jsx(Button, {
69518
+ title: "Resume",
69519
+ size: "sm",
69520
+ onClick: function onClick() {
69521
+ return onResume();
69522
+ }
69523
+ }) : null]
69524
+ }) : null, notice ? /*#__PURE__*/jsx("span", {
69525
+ role: "status",
69526
+ className: "text-xs ".concat(statusTokens.warning.text),
69527
+ "data-testid": "bot-chat-notice",
69528
+ children: notice
69529
+ }) : null]
69530
+ }) : null,
69531
+ hint: /*#__PURE__*/jsxs("span", {
69532
+ className: "flex flex-row items-center justify-between gap-2",
69548
69533
  children: [/*#__PURE__*/jsx("span", {
69549
69534
  children: "Enter to send \xB7 Shift+Enter for a new line"
69550
69535
  }), (runs || EMPTY$5).length ? /*#__PURE__*/jsx(Button3, {
@@ -69554,7 +69539,7 @@ var BotChat = function BotChat(_ref) {
69554
69539
  return setFreshNext(true);
69555
69540
  }
69556
69541
  }) : null]
69557
- })]
69542
+ })
69558
69543
  })]
69559
69544
  });
69560
69545
  };