@fungi.computer/parakeet 0.11.0 → 0.11.2

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.
@@ -1,3 +1,4 @@
1
+ import { type SetupNoticeFix } from "@fungi.computer/caps/blocks/setup-notice";
1
2
  import { type RefObject } from "react";
2
3
  import type { PromptDelivery, SessionContext } from "@fungi.computer/shiitake/client";
3
4
  import type { SlashCommandController } from "../commands/use-slash-commands.js";
@@ -17,18 +18,17 @@ export type ChatComposerProps = {
17
18
  placeholder?: string | undefined;
18
19
  /** Why typing cannot work yet, such as no model connected. It disables input and sending, and replaces the hint. */
19
20
  disabledReason?: string | undefined;
21
+ /** No model is connected: the send path gives way to this one setup step. */
22
+ setup?: SetupNoticeFix | undefined;
20
23
  /** Hide internal model, usage and status readouts for visitors. */
21
24
  showFooter?: boolean;
22
25
  /** Display-only status text supplied by the conversation's admitted entries. */
23
26
  statusChips?: readonly string[] | undefined;
24
27
  actionVariant?: "primary" | "outline" | undefined;
25
28
  draft: string;
26
- failure: ComposerController["failure"];
27
- failureCause?: string | undefined;
28
29
  model?: ChatComposerModel | undefined;
29
30
  onAbort: () => void;
30
31
  onChange: (value: string) => void;
31
- onRetry: () => void;
32
32
  /** Submit the draft; `followUp` while a run is active, otherwise `steer`. */
33
33
  onSend: (delivery: PromptDelivery) => void;
34
34
  admissionError?: ComposerController["admissionError"];
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { formatTokens } from "../core/format-tokens.js";
3
+ import { SetupNotice, } from "@fungi.computer/caps/blocks/setup-notice";
3
4
  import { composerModelName } from "../core/composer-model-name.js";
4
5
  import { formatContextUsage } from "../core/format-context.js";
5
6
  import { isImeComposing } from "@fungi.computer/caps/lib/ime";
6
- import { RunFailureNotice } from "./RunFailureNotice.js";
7
7
  import { SendAction } from "@fungi.computer/caps/components/send-action";
8
8
  import { formatMoney } from "@fungi.computer/caps/lib/format-money";
9
9
  import { Status } from "@fungi.computer/caps/components/status";
@@ -319,7 +319,7 @@ function ComposerAttachments({ images, onRemove, }) {
319
319
  onRemove(index);
320
320
  }, size: "xs", variant: "outline" }))] }, index))) }));
321
321
  }
322
- export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesChange, placeholder, disabledReason, showFooter = true, statusChips, actionVariant = "primary", draft, failure, failureCause, admissionError, model, onAbort, onChange, onRetry, onSend, status, viewState, textareaRef, usage, context, slash, }) {
322
+ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesChange, placeholder, disabledReason, setup, showFooter = true, statusChips, actionVariant = "primary", draft, admissionError, model, onAbort, onChange, onSend, status, viewState, textareaRef, usage, context, slash, }) {
323
323
  const textareaId = useId();
324
324
  const slashListId = `${textareaId}-commands`;
325
325
  const fileInput = useRef(null);
@@ -384,9 +384,11 @@ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesC
384
384
  attach,
385
385
  send: sendAction,
386
386
  });
387
+ if (setup !== undefined)
388
+ return (_jsx("div", { className: "chat-composer not-prose flex-shrink-0", children: _jsx(SetupNotice, { cause: "Agents answer with a model, and none is connected yet.", fix: setup, need: "Connect a model", variant: "banner" }) }));
387
389
  return (_jsxs("div", { className: "chat-composer not-prose flex-shrink-0", children: [admissionError !== undefined ? (_jsx("div", { className: "px-3 py-1.5 text-xs text-error", role: "alert", children: admissionError === "offline_queue_full"
388
390
  ? "One prompt is already queued; it sends when the service is back."
389
- : "Too many prompts are still awaiting admission. Try again shortly." })) : null, failure !== undefined ? (_jsx(RunFailureNotice, { failure: failure, cause: failureCause, onRetry: onRetry })) : null, slash?.interactions.notice === undefined ? null : (_jsx("div", { className: "parakeet-command-notice px-3 py-1.5 text-xs", "data-tone": slash.interactions.notice.tone, role: slash.interactions.notice.tone === "error" ? "alert" : "status", children: slash.interactions.notice.message })), _jsx("div", { "aria-live": "polite", className: "sr-only", children: takeover === undefined || slash === undefined
391
+ : "Too many prompts are still awaiting admission. Try again shortly." })) : null, slash?.interactions.notice === undefined ? null : (_jsx("div", { className: "parakeet-command-notice px-3 py-1.5 text-xs", "data-tone": slash.interactions.notice.tone, role: slash.interactions.notice.tone === "error" ? "alert" : "status", children: slash.interactions.notice.message })), _jsx("div", { "aria-live": "polite", className: "sr-only", children: takeover === undefined || slash === undefined
390
392
  ? ""
391
393
  : `Agent ${takeover.kind} ${String(slash.awaiting.position)} of ${String(slash.awaiting.total)} needs your answer` }), _jsx(ComposerShell, { "aria-label": "Message composer", action: takeover === undefined && row === undefined ? sendAction : undefined, menu: slash === undefined ? undefined : (_jsx(SlashMenu, { slash: slash, listId: slashListId })), attachments: takeover === undefined && images.length > 0 ? (_jsx(ComposerAttachments, { images: images, onRemove: onImagesChange === undefined
392
394
  ? undefined
@@ -5,6 +5,8 @@ import { type ToggleToolDisclosure } from "./ToolGroup.js";
5
5
  export declare const TimelineItem: import("react").NamedExoticComponent<Readonly<{
6
6
  item: TimelineRow;
7
7
  onDismissFailed?: ((requestId: string) => void) | undefined;
8
+ /** Run the failed prompt again; given only to the row the failure belongs to. */
9
+ onRetry?: (() => void) | undefined;
8
10
  onCancelQueued?: ((commandId: string) => void) | undefined;
9
11
  cancellingQueued?: boolean | undefined;
10
12
  renderToolActions?: ((item: ToolItem) => ReactNode) | undefined;
@@ -5,7 +5,6 @@ import { memo, useContext } from "react";
5
5
  import { disclosureOpen, initialToolDisclosure, } from "../core/tool-groups.js";
6
6
  import { assistantMessageVisible } from "../core/assistant-visibility.js";
7
7
  import { formatTokenCount } from "../core/format-context.js";
8
- import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
9
8
  import { FailureLine } from "@fungi.computer/caps/components/failure-line";
10
9
  import { ParakeetHostFactsContext, plainModelFailure } from "../host-facts.js";
11
10
  import { ChatMessage, PendingMessageStatus } from "./ChatMessage.js";
@@ -17,7 +16,7 @@ const compactionNoticeLabel = {
17
16
  stale: "compaction skipped: the context moved on",
18
17
  insufficient: "compaction skipped: the summary would not fit",
19
18
  };
20
- export const TimelineItem = memo(function TimelineItem({ item, onDismissFailed, onCancelQueued, cancellingQueued = false, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, toolDisclosure = initialToolDisclosure, onToggleTool = ignoreToggle, }) {
19
+ export const TimelineItem = memo(function TimelineItem({ item, onDismissFailed, onRetry, onCancelQueued, cancellingQueued = false, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, toolDisclosure = initialToolDisclosure, onToggleTool = ignoreToggle, }) {
21
20
  const facts = useContext(ParakeetHostFactsContext);
22
21
  switch (item.kind) {
23
22
  case "user_message": {
@@ -34,7 +33,7 @@ export const TimelineItem = memo(function TimelineItem({ item, onDismissFailed,
34
33
  }, type: "button", children: "Dismiss" }));
35
34
  const failed = item.status === "failed" ? (_jsxs("div", { className: "flex items-center gap-2 px-3 text-xs text-error", role: "alert", children: [_jsx("span", { children: item.author?.kind === "agent"
36
35
  ? "That Agent message didn’t make it through."
37
- : "Your prompt didn’t make it through." }), dismissAction] })) : null;
36
+ : "Your prompt didn’t make it through." }), onRetry === undefined ? null : (_jsx(Button, { "aria-label": "Retry prompt", variant: "outline", size: "xs", onClick: onRetry, type: "button", children: "Retry" })), dismissAction] })) : null;
38
37
  if (item.author?.kind === "agent") {
39
38
  const open = disclosureOpen(toolDisclosure, item.id, false);
40
39
  return (_jsxs(_Fragment, { children: [_jsxs("div", { className: item.status === "confirmed"
@@ -53,10 +52,19 @@ export const TimelineItem = memo(function TimelineItem({ item, onDismissFailed,
53
52
  : undefined;
54
53
  if (modelFailure !== undefined) {
55
54
  // One line per run of identical failures, never the raw code.
56
- return modelFailure.unreachable &&
57
- facts.modelSetup?.state === "missing" ? (_jsx(SetupNotice, { cause: "No model is connected to this workspace.", fix: facts.modelSetup.fix, need: "No model could answer", variant: "inline" })) : (_jsx(FailureLine, { count: item.repeatCount ?? 1, message: modelFailure.message }));
55
+ // With no model connected the composer already says so, with the fix.
56
+ if (modelFailure.unreachable && facts.modelSetup?.state === "missing")
57
+ return null;
58
+ const tries = item.repeatCount ?? 1;
59
+ return (_jsxs("div", { "data-failure": item.id, children: [_jsx(FailureLine, { message: tries > 1
60
+ ? `${modelFailure.message} · ${String(tries)} tries`
61
+ : modelFailure.message, ...(onRetry === undefined
62
+ ? {}
63
+ : { onRetry, retryAriaLabel: "Retry prompt" }) }), _jsx("div", { className: "px-3 text-xs text-dim", ...(item.providerError === undefined
64
+ ? {}
65
+ : { "data-provider-error": item.id }), children: _jsxs("details", { children: [_jsx("summary", { children: "Details" }), _jsx("div", { children: modelFailure.detail }), item.providerError === undefined ? null : (_jsx("pre", { className: "whitespace-pre-wrap", children: item.providerError }))] }) })] }));
58
66
  }
59
- return (_jsxs(_Fragment, { children: [item.author ? (_jsx("div", { className: "px-3 text-xs text-dim", "data-author": item.author.id, children: item.author.name })) : null, _jsx(ChatMessage, { isError: item.isError === true, pending: item.pending, speaker: "agent", ...(item.thinking ? { thinking: item.thinking } : {}), children: formatAssistantText?.(item.text) ?? item.text }), item.isError && item.repeatCount !== undefined ? (_jsxs("span", { className: "px-3 text-error", children: ["x", item.repeatCount] })) : null, item.isError && item.errorDetail ? (_jsx("p", { className: "px-3 text-dim", children: item.errorDetail })) : null, item.isError && item.providerError !== undefined ? (_jsx("div", { className: "px-3 text-error", "data-provider-error": item.id, children: _jsxs("details", { children: [_jsx("summary", { children: "Provider details (latest response)" }), _jsx("pre", { className: "whitespace-pre-wrap", children: item.providerError })] }) })) : null, !item.pending && !item.isError
67
+ return (_jsxs(_Fragment, { children: [item.author ? (_jsx("div", { className: "px-3 text-xs text-dim", "data-author": item.author.id, children: item.author.name })) : null, _jsx(ChatMessage, { isError: item.isError === true, pending: item.pending, speaker: "agent", ...(item.thinking ? { thinking: item.thinking } : {}), children: formatAssistantText?.(item.text) ?? item.text }), item.isError && item.errorDetail ? (_jsx("p", { className: "px-3 text-dim", children: item.errorDetail })) : null, item.isError && item.providerError !== undefined ? (_jsx("div", { className: "px-3 text-error", "data-provider-error": item.id, children: _jsxs("details", { children: [_jsx("summary", { children: "Provider details (latest response)" }), _jsx("pre", { className: "whitespace-pre-wrap", children: item.providerError })] }) })) : null, !item.pending && !item.isError
60
68
  ? renderAssistantAttachment?.(item.text)
61
69
  : null] }));
62
70
  }
@@ -89,7 +89,7 @@ function assistantMessageItem(id, value, blocks) {
89
89
  at: value.timestamp,
90
90
  text: blocks.text.length === 0
91
91
  ? value.stopReason === "error"
92
- ? "This run couldn’t finish."
92
+ ? (value.errorMessage ?? "This run couldn’t finish.")
93
93
  : value.stopReason === "aborted"
94
94
  ? "The run was cancelled."
95
95
  : ""
@@ -28,8 +28,11 @@ export declare const ParakeetHostFactsContext: import("react").Context<Readonly<
28
28
  /** One-click prompts the empty conversation offers; each sends as written. */
29
29
  starters?: readonly string[] | undefined;
30
30
  }>>;
31
- /** A model run that failed, with the plain sentence for its cause; undefined for any other text. */
32
- export declare function plainModelFailure(text: string): Readonly<{
31
+ /** A failed model run in plain words; `detail` is the stored text, kept for a details disclosure. */
32
+ export type PlainModelFailure = Readonly<{
33
33
  unreachable: boolean;
34
34
  message: string;
35
- }> | undefined;
35
+ detail: string;
36
+ }>;
37
+ /** A run that failed, with the plain sentence for its cause; undefined for any other text. */
38
+ export declare function plainModelFailure(text: string): PlainModelFailure | undefined;
@@ -2,15 +2,19 @@ import { createContext } from "react";
2
2
  /** Provided by the conversation view; read by the failure and empty states. */
3
3
  export const ParakeetHostFactsContext = createContext({});
4
4
  const modelFailure = /^Model request failed \(([a-z_]+)\)\./u;
5
- /** A model run that failed, with the plain sentence for its cause; undefined for any other text. */
5
+ const unfinishedRun = "This run couldn’t finish.";
6
+ /** A run that failed, with the plain sentence for its cause; undefined for any other text. */
6
7
  export function plainModelFailure(text) {
8
+ if (text === unfinishedRun)
9
+ return {
10
+ unreachable: false,
11
+ message: "The run couldn’t finish",
12
+ detail: text,
13
+ };
7
14
  const code = modelFailure.exec(text)?.[1];
8
15
  if (code === undefined)
9
16
  return undefined;
10
17
  return code === "provider_unavailable" || code === "setup_required"
11
- ? {
12
- unreachable: true,
13
- message: "The model provider couldn't be reached. Try again.",
14
- }
15
- : { unreachable: false, message: "The model request failed. Try again." };
18
+ ? { unreachable: true, message: "Couldn’t reach the model", detail: text }
19
+ : { unreachable: false, message: "The model request failed", detail: text };
16
20
  }
package/dist/parakeet.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Button } from "@fungi.computer/caps/components/button";
3
- import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
3
+ import { boundedDiagnostic } from "@fungi.computer/bird-dog/effect";
4
+ import { FailureLine } from "@fungi.computer/caps/components/failure-line";
4
5
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
5
6
  import { ParakeetHostFactsContext, } from "./host-facts.js";
6
7
  import { Dialog, DialogContent } from "@fungi.computer/caps/components/dialog";
@@ -110,6 +111,7 @@ function ConversationInteraction({ slash, }) {
110
111
  }
111
112
  function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focusAfterJump, empty, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, }) {
112
113
  const dismissFailed = useDismissFailedPrompt();
114
+ const composer = useComposer();
113
115
  const timelineController = useTimeline();
114
116
  const cancelQueued = useCallback((commandId) => {
115
117
  void timelineController.cancelQueued(commandId);
@@ -225,16 +227,59 @@ function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focu
225
227
  item.author.name,
226
228
  },
227
229
  }
228
- : item, onDismissFailed: dismissFailed, onCancelQueued: cancelQueued, cancellingQueued: timelineController.cancellingQueued, onToggleTool: toggleTool, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText, toolDisclosure: toolDisclosure }), placed.after.get(item.id)?.map(({ entryId, cell }) => (_jsx(ClientRows, { entryId: entryId, rows: cell.rows, actions: clientActions, onOpen: onOpen }, `${entryId}:${cell.id}`)))] }, virtualItem.key));
230
+ : item, onDismissFailed: dismissFailed, onRetry: virtualItem.index === count - 1 &&
231
+ (composer.failure === "failed" ||
232
+ composer.failure === "admission")
233
+ ? composer.retry
234
+ : undefined, onCancelQueued: cancelQueued, cancellingQueued: timelineController.cancellingQueued, onToggleTool: toggleTool, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText, toolDisclosure: toolDisclosure }), virtualItem.index === count - 1 ? (_jsx(RunStopped, { failure: composer.failure, cause: sessionStatus.viewState.kind === "error"
235
+ ? sessionStatus.viewState.cause
236
+ : undefined, lastItem: item, onRetry: composer.retry })) : null, placed.after.get(item.id)?.map(({ entryId, cell }) => (_jsx(ClientRows, { entryId: entryId, rows: cell.rows, actions: clientActions, onOpen: onOpen }, `${entryId}:${cell.id}`)))] }, virtualItem.key));
229
237
  }) })) : before.length > 0 ? (before) : hasMoreHistory ? null : ((empty ?? _jsx(ConversationStarters, {}))) }), count > 0 ? (_jsx(ScrollToBottomBlob, { direction: "forward", unread: unread, focusAfterJump: focusAfterJump, onJump: jumpToBottom, scrollerRef: scrollerRef })) : null] }));
230
238
  }
239
+ const stoppedMessages = {
240
+ failed: "The run stopped. Your prompt is still here.",
241
+ interrupted: "The worker stopped before this run finished. Your prompt is still here.",
242
+ cancelled: "The run was cancelled. Send a new prompt when you’re ready.",
243
+ };
244
+ /**
245
+ * A run that ended with no failed row of its own to show it, said once, in the
246
+ * thread where it stopped. A failed row or prompt already carries its own line.
247
+ */
248
+ function RunStopped({ failure, cause, lastItem, onRetry, }) {
249
+ if (failure === undefined || failure === "admission")
250
+ return null;
251
+ if (failure === "failed" &&
252
+ lastItem.kind === "assistant_message" &&
253
+ lastItem.isError)
254
+ return null;
255
+ // A cancelled run's assistant row already says so.
256
+ if (failure === "cancelled" &&
257
+ lastItem.kind === "assistant_message" &&
258
+ lastItem.isError)
259
+ return null;
260
+ const bounded = cause === undefined ? undefined : boundedDiagnostic(cause);
261
+ // Diagnostic metadata is useful to the owner, not a public explanation.
262
+ const publicCause = bounded !== undefined &&
263
+ !bounded.startsWith("reason_unavailable:") &&
264
+ !/\b(?:run|session)=/iu.test(bounded)
265
+ ? bounded
266
+ : undefined;
267
+ const message = publicCause === undefined || failure === "cancelled"
268
+ ? stoppedMessages[failure]
269
+ : failure === "interrupted"
270
+ ? `This turn stopped before it finished: ${publicCause}. Your prompt is still here.`
271
+ : `The run stopped: ${publicCause}. Your prompt is still here.`;
272
+ return (_jsx(FailureLine, { message: message, role: "alert", ...(failure === "cancelled"
273
+ ? {}
274
+ : { onRetry, retryAriaLabel: "Retry prompt" }) }));
275
+ }
231
276
  /** The empty conversation: host starter chips when there are any, the quiet prompt otherwise. */
232
277
  function ConversationStarters() {
233
278
  const { modelSetup, starters } = useContext(ParakeetHostFactsContext);
234
279
  const composer = useComposer();
235
- // Known up front, before any run: say so once, with the fix as the one action.
280
+ // Known up front, before any run: the fix is the composer's one action below.
236
281
  if (modelSetup?.state === "missing")
237
- return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx(SetupNotice, { cause: "No model is connected to this workspace yet.", fix: modelSetup.fix, need: "Connect a model to start", variant: "panel" }) }));
282
+ return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx(EmptyState, { description: "Agents answer with a model, and none is connected yet.", title: "Connect a model to start", variant: "quiet" }) }));
238
283
  if (starters === undefined || starters.length === 0)
239
284
  return (_jsx("div", { className: "flex h-full items-center justify-center text-center", children: _jsxs("div", { children: [_jsx("p", { className: "mb-1 text-xs text-base-content", children: "Ready" }), _jsx("p", { className: "text-[10px] text-dim", children: "What would you like to build?" })] }) }));
240
285
  return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx(EmptyState, { description: "Pick one to start, or type your own below.", suggestions: starters.map((prompt) => ({
@@ -283,14 +328,9 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, sla
283
328
  .map(({ row }) => row.title),
284
329
  actionVariant: composerActionVariant,
285
330
  draft: composer.draft,
286
- failure: composer.failure,
287
- failureCause: sessionStatus.viewState.kind === "error"
288
- ? sessionStatus.viewState.cause
289
- : undefined,
290
331
  admissionError: composer.admissionError,
291
332
  onAbort: abort,
292
333
  onChange: composer.setDraft,
293
- onRetry: composer.retry,
294
334
  onSend: slash.submit,
295
335
  slash: visitor === undefined ? slash : undefined,
296
336
  placeholder: visitor === undefined ? undefined : `Ask ${visitor.agentName}…`,
@@ -298,6 +338,10 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, sla
298
338
  disabledReason: hostFacts.modelSetup?.state === "missing"
299
339
  ? "Connect a model to start chatting"
300
340
  : undefined,
341
+ // No model: the composer's send path gives way to the one setup step.
342
+ setup: hostFacts.modelSetup?.state === "missing"
343
+ ? hostFacts.modelSetup.fix
344
+ : undefined,
301
345
  showFooter: visitor === undefined,
302
346
  status: sessionStatus.status,
303
347
  viewState: sessionStatus.viewState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/parakeet",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Standalone React composer for a typed Shiitake Session",
@@ -63,7 +63,7 @@
63
63
  "@fungi.computer/agar": "0.9.0",
64
64
  "@fungi.computer/bird-dog": "0.3.6",
65
65
  "@fungi.computer/cairn": "0.1.0",
66
- "@fungi.computer/caps": "0.10.0",
66
+ "@fungi.computer/caps": "0.10.1",
67
67
  "@fungi.computer/gills": "0.3.0",
68
68
  "@fungi.computer/knapsack": "0.4.9",
69
69
  "@fungi.computer/shiitake": "0.12.3",
@@ -1,7 +0,0 @@
1
- import type { ComposerController } from "../conversation.js";
2
- /** Session failures do not carry a billing receipt; never promise a refund. */
3
- export declare function RunFailureNotice({ failure, cause, onRetry, }: Readonly<{
4
- failure: NonNullable<ComposerController["failure"]>;
5
- cause?: string | undefined;
6
- onRetry: () => void;
7
- }>): import("react/jsx-runtime").JSX.Element | null;
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
3
- import { FailureLine } from "@fungi.computer/caps/components/failure-line";
4
- import { boundedDiagnostic } from "@fungi.computer/bird-dog/effect";
5
- import { useContext } from "react";
6
- import { ParakeetHostFactsContext } from "../host-facts.js";
7
- const messages = {
8
- admission: "Your prompt didn’t make it through. Let’s give it another go.",
9
- failed: "The run stopped. Check the message above before trying again.",
10
- interrupted: "The worker stopped before this run finished. Your prompt is still here.",
11
- cancelled: "The run was cancelled. Send a new prompt when you’re ready.",
12
- };
13
- /** Session failures do not carry a billing receipt; never promise a refund. */
14
- export function RunFailureNotice({ failure, cause, onRetry, }) {
15
- const { billing = true, modelSetup } = useContext(ParakeetHostFactsContext);
16
- // With no model connected the timeline already says so, once, with the fix.
17
- if (failure === "failed" && modelSetup?.state === "missing")
18
- return null;
19
- if (failure === "admission" && modelSetup?.state === "missing")
20
- return (_jsx(SetupNotice, { cause: "No model is connected to this workspace.", fix: modelSetup.fix, need: "No model could answer", variant: "inline" }));
21
- const bounded = cause === undefined ? undefined : boundedDiagnostic(cause);
22
- // Diagnostic metadata is useful to the owner, not a public explanation.
23
- const publicCause = bounded !== undefined &&
24
- !bounded.startsWith("reason_unavailable:") &&
25
- !/\b(?:run|session)=/iu.test(bounded)
26
- ? bounded
27
- : undefined;
28
- const interruptedWithReason = failure === "interrupted" && publicCause !== undefined;
29
- const credits = billing
30
- ? " If the model didn’t start, there’s no charge. Model work already done can still use credits."
31
- : "";
32
- const message = interruptedWithReason
33
- ? `This turn stopped before it finished: ${publicCause}. Your prompt is still here.`
34
- : `${messages[failure]}${credits}${publicCause ? ` ${publicCause}` : ""}`;
35
- return (_jsx(FailureLine, { message: message, role: "alert", ...(failure === "cancelled"
36
- ? {}
37
- : { onRetry, retryAriaLabel: "Retry prompt" }) }));
38
- }