@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.js CHANGED
@@ -59799,6 +59799,15 @@ function turnsForRun(r) {
59799
59799
  stale: stale
59800
59800
  });
59801
59801
  }
59802
+ // Stopped before it answered (Stop in the chat, TEAM-015): say so, so the
59803
+ // question isn't left hanging.
59804
+ if (r.status === "stopped" && !r.output && !pending) {
59805
+ turns.push({
59806
+ kind: "system",
59807
+ text: "Stopped",
59808
+ at: r.endedAt || at
59809
+ });
59810
+ }
59802
59811
  if (r.outputUnavailable) {
59803
59812
  turns.push({
59804
59813
  kind: "bot",
@@ -59812,6 +59821,10 @@ function turnsForRun(r) {
59812
59821
  text: r.output || r.text || "",
59813
59822
  pending: pending,
59814
59823
  at: r.endedAt || at,
59824
+ // Shown beside the bot's name: "Sonnet · 2.1k tokens" (TEAM-015 AC8).
59825
+ model: r.model || null,
59826
+ usage: r.usage || null,
59827
+ cost: r.cost || null,
59815
59828
  // The run's window — a lead's drafts made in it are linked here (5b).
59816
59829
  startedAt: r.startedAt || null,
59817
59830
  endedAt: r.endedAt || null
@@ -69064,10 +69077,6 @@ var BotChat = function BotChat(_ref) {
69064
69077
  var strong = currentTheme["text-neutral-light"] || "text-gray-200";
69065
69078
  var statusTokens = DashReact.useStatusTokens();
69066
69079
  var hairline = currentTheme["border-neutral-dark"] || "border-gray-700";
69067
- var bubble = currentTheme["bg-primary-very-dark"] || "bg-gray-800";
69068
- var bubbleBorder = currentTheme["border-primary-dark"] || "border-gray-600";
69069
- // The bot's (or lead's) answers: a quieter, left-aligned bubble.
69070
- var answerBg = currentTheme["bg-neutral-very-dark"] || "bg-gray-900";
69071
69080
  var _useState = React.useState(null),
69072
69081
  _useState2 = _slicedToArray(_useState, 2),
69073
69082
  runs = _useState2[0],
@@ -69310,55 +69319,37 @@ var BotChat = function BotChat(_ref) {
69310
69319
  return _ref4.apply(this, arguments);
69311
69320
  };
69312
69321
  }();
69313
- var onKeyDown = function onKeyDown(e) {
69314
- if (e.key === "Enter" && !e.shiftKey) {
69315
- e.preventDefault();
69316
- send();
69317
- }
69322
+
69323
+ // Stop the run in progress (the composer's Send becomes Stop).
69324
+ var stop = function stop() {
69325
+ var bots = api$a();
69326
+ if (bots && bots.stop && bot) bots.stop(bot.id);
69318
69327
  };
69319
69328
  var renderTurn = function renderTurn(t, i) {
69320
69329
  switch (t.kind) {
69321
69330
  case "divider":
69322
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
69323
- className: "flex flex-row items-center gap-3 my-3 text-xs ".concat(muted),
69324
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
69325
- className: "flex-1 border-t ".concat(hairline)
69326
- }), t.text, /*#__PURE__*/jsxRuntime.jsx("div", {
69327
- className: "flex-1 border-t ".concat(hairline)
69328
- })]
69331
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.ChatMessage, {
69332
+ role: "note",
69333
+ children: t.text
69329
69334
  }, i);
69330
69335
  case "system":
69331
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
69332
- className: "text-xs ".concat(muted),
69336
+ return /*#__PURE__*/jsxRuntime.jsxs(DashReact.ChatMessage, {
69337
+ role: "note",
69333
69338
  children: [t.text, timeOf(t.at) ? " \xB7 ".concat(timeOf(t.at)) : ""]
69334
69339
  }, i);
69335
69340
  case "user":
69336
- return /*#__PURE__*/jsxRuntime.jsx("div", {
69337
- className: "flex flex-row justify-end",
69338
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
69339
- className: "max-w-xl rounded-xl border px-3 py-2 text-sm whitespace-pre-wrap ".concat(bubble, " ").concat(bubbleBorder),
69340
- children: t.text
69341
- })
69341
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.ChatMessage, {
69342
+ role: "you",
69343
+ children: t.text
69342
69344
  }, i);
69343
69345
  case "tools":
69344
69346
  return /*#__PURE__*/jsxRuntime.jsx("div", {
69345
69347
  className: "flex flex-col gap-1",
69346
69348
  children: t.calls.map(function (c, j) {
69347
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
69348
- className: "flex flex-row items-center gap-2 rounded-md border px-3 py-1.5 text-xs ".concat(hairline, " ").concat(muted),
69349
- children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
69350
- icon: c.ok === false ? "xmark" : c.ok ? "check" : t.live ? "circle-notch" : "minus",
69351
- className: "h-3 w-3"
69352
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
69353
- className: "font-mono",
69354
- children: c.tool
69355
- }), c.provider ? /*#__PURE__*/jsxRuntime.jsxs("span", {
69356
- children: ["\xB7 ", c.provider]
69357
- }) : null, c.ok === false ? /*#__PURE__*/jsxRuntime.jsx("span", {
69358
- children: "\xB7 failed"
69359
- }) : null, c.ok == null && !t.live ? /*#__PURE__*/jsxRuntime.jsx("span", {
69360
- children: "\xB7 didn't finish"
69361
- }) : null]
69349
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.ChatToolCall, {
69350
+ name: c.tool,
69351
+ status: c.ok === false ? "error" : c.ok ? "done" : t.live ? "running" : "error",
69352
+ source: [c.provider, c.ok === false ? "failed" : null, c.ok == null && !t.live ? "didn't finish" : null].filter(Boolean).join(" · ") || null
69362
69353
  }, j);
69363
69354
  })
69364
69355
  }, i);
@@ -69419,32 +69410,31 @@ var BotChat = function BotChat(_ref) {
69419
69410
  var to = t.endedAt ? Date.parse(t.endedAt) + 5000 : Infinity;
69420
69411
  return d.leadId === bot.id && c >= from && c <= to;
69421
69412
  }) : EMPTY$5;
69422
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
69423
- className: "flex flex-col gap-1 items-start",
69424
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
69425
- className: "text-xs ".concat(muted),
69426
- children: bot.name
69427
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
69428
- "data-testid": "answer-bubble",
69429
- className: "max-w-2xl rounded-xl border px-3 py-2 flex flex-col gap-2 ".concat(answerBg, " ").concat(hairline),
69430
- children: [t.unavailable ? /*#__PURE__*/jsxRuntime.jsx("span", {
69431
- className: "text-sm ".concat(muted),
69432
- children: "Answer unavailable \u2014 it was stored encrypted with a key this app can't read."
69433
- }) : /*#__PURE__*/jsxRuntime.jsx("span", {
69434
- className: "text-sm whitespace-pre-wrap leading-relaxed",
69435
- children: t.text ? toPlainText(t.text) : t.pending ? "Working…" : ""
69436
- }), madeHere.map(function (d) {
69437
- return /*#__PURE__*/jsxRuntime.jsx("div", {
69438
- children: /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
69439
- title: "Review draft: ".concat(d.definition && d.definition.name),
69440
- size: "sm",
69441
- onClick: function onClick() {
69442
- return onOpenDraft(d.id);
69443
- }
69444
- })
69413
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.ChatMessage, {
69414
+ role: "reply",
69415
+ label: bot.name,
69416
+ meta: t.pending ? null : runCostLabel(t) || null,
69417
+ streaming: !!t.pending,
69418
+ testId: "answer-bubble",
69419
+ footer: madeHere.length ? /*#__PURE__*/jsxRuntime.jsx("div", {
69420
+ className: "flex flex-row flex-wrap gap-2",
69421
+ children: madeHere.map(function (d) {
69422
+ return /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
69423
+ title: "Review draft: ".concat(d.definition && d.definition.name),
69424
+ size: "sm",
69425
+ onClick: function onClick() {
69426
+ return onOpenDraft(d.id);
69427
+ }
69445
69428
  }, d.id);
69446
- })]
69447
- })]
69429
+ })
69430
+ }) : null,
69431
+ children: t.unavailable ? /*#__PURE__*/jsxRuntime.jsx("span", {
69432
+ className: muted,
69433
+ children: "Answer unavailable \u2014 it was stored encrypted with a key this app can't read."
69434
+ }) : /*#__PURE__*/jsxRuntime.jsx("span", {
69435
+ className: "whitespace-pre-wrap",
69436
+ children: t.text ? toPlainText(t.text) : t.pending ? "Working…" : ""
69437
+ })
69448
69438
  }, i);
69449
69439
  }
69450
69440
  default:
@@ -69519,50 +69509,45 @@ var BotChat = function BotChat(_ref) {
69519
69509
  onClick: jumpToNewest
69520
69510
  })
69521
69511
  }) : null]
69522
- }), paused ? /*#__PURE__*/jsxRuntime.jsxs("div", {
69523
- 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),
69524
- "data-testid": "bot-chat-paused",
69525
- children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
69526
- icon: "pause",
69527
- className: "h-3 w-3 ".concat(muted)
69528
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
69529
- className: "flex-1",
69530
- children: "Paused \u2014 it won't answer until you resume it."
69531
- }), onResume ? /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
69532
- title: "Resume",
69533
- size: "sm",
69534
- onClick: function onClick() {
69535
- return onResume();
69536
- }
69537
- }) : null]
69538
- }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
69539
- className: "flex-shrink-0 border-t px-5 py-3 flex flex-col gap-2 ".concat(hairline),
69540
- children: [notice ? /*#__PURE__*/jsxRuntime.jsx("span", {
69541
- role: "status",
69542
- className: "text-xs ".concat(statusTokens.warning.text),
69543
- "data-testid": "bot-chat-notice",
69544
- children: notice
69545
- }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
69546
- className: "flex flex-row items-end gap-2",
69547
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
69548
- className: "flex-1",
69549
- children: /*#__PURE__*/jsxRuntime.jsx(DashReact.TextArea, {
69550
- value: draft,
69551
- onChange: setDraft,
69552
- rows: 2,
69553
- 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"),
69554
- disabled: paused,
69555
- "aria-label": "Message",
69556
- onKeyDown: onKeyDown
69557
- })
69558
- }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
69559
- title: isLead ? "Ask" : "Send",
69560
- size: "sm",
69561
- onClick: send,
69562
- disabled: !draft.trim() || !!live || paused
69563
- })]
69564
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
69565
- className: "flex flex-row items-center justify-between text-xs ".concat(muted),
69512
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.ChatComposer, {
69513
+ value: draft,
69514
+ onChange: function onChange(v) {
69515
+ return setDraft(v);
69516
+ },
69517
+ onSend: send,
69518
+ onStop: stop,
69519
+ busy: !!live,
69520
+ disabled: paused,
69521
+ ariaLabel: "Message",
69522
+ sendLabel: isLead ? "Ask" : "Send",
69523
+ 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"),
69524
+ above: paused || notice ? /*#__PURE__*/jsxRuntime.jsxs("div", {
69525
+ className: "flex flex-col gap-2",
69526
+ children: [paused ? /*#__PURE__*/jsxRuntime.jsxs("div", {
69527
+ className: "rounded-lg border px-3 py-2 flex flex-row items-center gap-3 text-xs ".concat(hairline),
69528
+ "data-testid": "bot-chat-paused",
69529
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
69530
+ icon: "pause",
69531
+ className: "h-3 w-3 ".concat(muted)
69532
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
69533
+ className: "flex-1",
69534
+ children: "Paused \u2014 it won't answer until you resume it."
69535
+ }), onResume ? /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
69536
+ title: "Resume",
69537
+ size: "sm",
69538
+ onClick: function onClick() {
69539
+ return onResume();
69540
+ }
69541
+ }) : null]
69542
+ }) : null, notice ? /*#__PURE__*/jsxRuntime.jsx("span", {
69543
+ role: "status",
69544
+ className: "text-xs ".concat(statusTokens.warning.text),
69545
+ "data-testid": "bot-chat-notice",
69546
+ children: notice
69547
+ }) : null]
69548
+ }) : null,
69549
+ hint: /*#__PURE__*/jsxRuntime.jsxs("span", {
69550
+ className: "flex flex-row items-center justify-between gap-2",
69566
69551
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
69567
69552
  children: "Enter to send \xB7 Shift+Enter for a new line"
69568
69553
  }), (runs || EMPTY$5).length ? /*#__PURE__*/jsxRuntime.jsx(DashReact.Button3, {
@@ -69572,7 +69557,7 @@ var BotChat = function BotChat(_ref) {
69572
69557
  return setFreshNext(true);
69573
69558
  }
69574
69559
  }) : null]
69575
- })]
69560
+ })
69576
69561
  })]
69577
69562
  });
69578
69563
  };