@fungi.computer/parakeet 0.11.4 → 0.11.6

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,4 +1,3 @@
1
- import { type SetupNoticeFix } from "@fungi.computer/caps/blocks/setup-notice";
2
1
  import { type RefObject } from "react";
3
2
  import type { PromptDelivery, SessionContext } from "@fungi.computer/shiitake/client";
4
3
  import type { SlashCommandController } from "../commands/use-slash-commands.js";
@@ -16,10 +15,6 @@ export type ChatComposerProps = {
16
15
  queuedRecall: Pick<ComposerController, "recall" | "recallState" | "images"> | undefined;
17
16
  /** Caller-owned prompt hint; omitted for the ordinary Session composer. */
18
17
  placeholder?: string | undefined;
19
- /** Why typing cannot work yet, such as no model connected. It disables input and sending, and replaces the hint. */
20
- disabledReason?: string | undefined;
21
- /** No model is connected: the send path gives way to this one setup step. */
22
- setup?: SetupNoticeFix | undefined;
23
18
  /** Hide internal model, usage and status readouts for visitors. */
24
19
  showFooter?: boolean;
25
20
  /** Display-only status text supplied by the conversation's admitted entries. */
@@ -1,6 +1,5 @@
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";
4
3
  import { composerModelName } from "../core/composer-model-name.js";
5
4
  import { formatContextUsage } from "../core/format-context.js";
6
5
  import { isImeComposing } from "@fungi.computer/caps/lib/ime";
@@ -63,7 +62,7 @@ const presentations = {
63
62
  tone: "neutral",
64
63
  },
65
64
  };
66
- function HostComposerTextarea({ disabledReason, placeholder, onChange, onSend, onAbort, slash, slashListId, textareaId, textareaRef, value, queuedRecall, }) {
65
+ function HostComposerTextarea({ placeholder, onChange, onSend, onAbort, slash, slashListId, textareaId, textareaRef, value, queuedRecall, }) {
67
66
  const latestValue = useRef(value);
68
67
  const [history, setHistory] = useState([]);
69
68
  const [historyIndex, setHistoryIndex] = useState(-1);
@@ -197,7 +196,7 @@ function HostComposerTextarea({ disabledReason, placeholder, onChange, onSend, o
197
196
  : `${textareaId}-recall-guidance`,
198
197
  ]
199
198
  .filter((id) => id !== undefined)
200
- .join(" ") || undefined, "aria-busy": recalling, disabled: disabledReason !== undefined, readOnly: recalling, ...(slash === undefined
199
+ .join(" ") || undefined, "aria-busy": recalling, readOnly: recalling, ...(slash === undefined
201
200
  ? {}
202
201
  : completionFieldProps({
203
202
  open: listOpen,
@@ -206,8 +205,7 @@ function HostComposerTextarea({ disabledReason, placeholder, onChange, onSend, o
206
205
  })), className: "font-sans text-base-content", id: textareaId, onChange: (event) => {
207
206
  onChange(event.target.value);
208
207
  setHistoryIndex(-1);
209
- }, onKeyDown: onKeyDown, placeholder: disabledReason ??
210
- placeholder ??
208
+ }, onKeyDown: onKeyDown, placeholder: placeholder ??
211
209
  (slash === undefined ? "Ask agent..." : "Ask agent… (/ for commands)"), ref: textareaRef, rows: 1, value: value }), queuedRecall === undefined ? null : (_jsx("span", { id: `${textareaId}-recall-guidance`, className: "sr-only", children: "Press Up on an empty composer to recall your newest queued message." }))] }));
212
210
  }
213
211
  /** Full Session readout for announcements; the footer only draws attention states. */
@@ -319,7 +317,7 @@ function ComposerAttachments({ images, onRemove, }) {
319
317
  onRemove(index);
320
318
  }, size: "xs", variant: "outline" }))] }, index))) }));
321
319
  }
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, }) {
320
+ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesChange, placeholder, showFooter = true, statusChips, actionVariant = "primary", draft, admissionError, model, onAbort, onChange, onSend, status, viewState, textareaRef, usage, context, slash, }) {
323
321
  const textareaId = useId();
324
322
  const slashListId = `${textareaId}-commands`;
325
323
  const fileInput = useRef(null);
@@ -354,9 +352,8 @@ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesC
354
352
  blocked: recallBusy,
355
353
  });
356
354
  const sendLabel = busy ? "Queue follow-up" : "Send message";
357
- const sendAction = (_jsx(SendAction, { "aria-label": sendLabel, className: "composer-send-key", disabled: disabledReason !== undefined ||
358
- (sendState === "busy" &&
359
- (recallBusy || status === "queued" || status === "cancelling")), onClick: () => {
355
+ const sendAction = (_jsx(SendAction, { "aria-label": sendLabel, className: "composer-send-key", disabled: sendState === "busy" &&
356
+ (recallBusy || status === "queued" || status === "cancelling"), onClick: () => {
360
357
  onSend(busy ? "followUp" : "steer");
361
358
  }, onStop: onAbort, state: sendState, stopLabel: "Stop current turn", title: sendState === "busy"
362
359
  ? "Stop the current turn. Queued messages keep running in order."
@@ -384,8 +381,6 @@ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesC
384
381
  attach,
385
382
  send: sendAction,
386
383
  });
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" }) }));
389
384
  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"
390
385
  ? "One prompt is already queued; it sends when the service is back."
391
386
  : "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
@@ -396,7 +391,7 @@ export const ChatComposer = memo(function ChatComposer({ queuedRecall, onImagesC
396
391
  onImagesChange(images.filter((_image, at) => at !== index));
397
392
  } })) : undefined, input: _jsxs(_Fragment, { children: [takeover === undefined || slash === undefined ? null : (_jsx(DecisionComposer, { item: takeover, position: slash.awaiting.position, total: slash.awaiting.total, onLater: () => {
398
393
  slash.store.awaiting.later(takeover.key);
399
- }, takeFocus: hadFocus.current }, takeover.key)), _jsx("div", { hidden: takeover !== undefined, children: _jsx(HostComposerTextarea, { disabledReason: disabledReason, queuedRecall: queuedRecall, placeholder: placeholder, onChange: onChange, onAbort: onAbort, onSend: () => {
394
+ }, takeFocus: hadFocus.current }, takeover.key)), _jsx("div", { hidden: takeover !== undefined, children: _jsx(HostComposerTextarea, { queuedRecall: queuedRecall, placeholder: placeholder, onChange: onChange, onAbort: onAbort, onSend: () => {
400
395
  onSend(busy ? "followUp" : "steer");
401
396
  }, slash: slash, slashListId: slashListId, textareaId: textareaId, textareaRef: textareaRef, value: draft }) })] }), row:
402
397
  // A decision brings its own Later and Send row to the bottom edge.
@@ -53,7 +53,7 @@ export const TimelineItem = memo(function TimelineItem({ item, onDismissFailed,
53
53
  : undefined;
54
54
  if (modelFailure !== undefined) {
55
55
  // One line per run of identical failures, never the raw code.
56
- // With no model connected the composer already says so, with the fix.
56
+ // With no model connected the central setup panel already owns the fix.
57
57
  if ((modelFailure.unreachable || modelFailure.setup) &&
58
58
  facts.modelSetup?.state === "missing")
59
59
  return null;
package/dist/parakeet.js CHANGED
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Button } from "@fungi.computer/caps/components/button";
3
3
  import { boundedDiagnostic } from "@fungi.computer/bird-dog/effect";
4
4
  import { FailureLine } from "@fungi.computer/caps/components/failure-line";
5
+ import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
5
6
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
6
7
  import { ParakeetHostFactsContext, } from "./host-facts.js";
7
8
  import { Dialog, DialogContent } from "@fungi.computer/caps/components/dialog";
@@ -110,6 +111,7 @@ function ConversationInteraction({ slash, }) {
110
111
  }, children: _jsx(DialogContent, { className: "w-[min(32rem,calc(100vw-2rem))] rounded-box bg-base-100 p-md shadow-lg", keepMounted: false, children: open === undefined ? null : (_jsx(InteractionPanel, { host: open.host, onClose: slash.store.close }, open.key)) }) }));
111
112
  }
112
113
  function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focusAfterJump, empty, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, }) {
114
+ const { modelSetup } = useContext(ParakeetHostFactsContext);
113
115
  const dismissFailed = useDismissFailedPrompt();
114
116
  const composer = useComposer();
115
117
  const timelineController = useTimeline();
@@ -178,7 +180,7 @@ function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focu
178
180
  timelineController.jumpToLatest();
179
181
  timeline.scrollToEnd({ behavior: "smooth" });
180
182
  }, [timeline, timelineController]);
181
- return (_jsxs("div", { className: "prose relative min-h-0 flex-1", children: [_jsx("div", { "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: sessionReadout(sessionStatus.status, sessionStatus.viewState) }), sessionStatus.observation.status === "unavailable" ? (_jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-1 text-xs text-dim", role: "status", children: [_jsx("span", { children: sessionStatus.observation.reason }), _jsx(Button, { variant: "outline", size: "xs", onClick: () => void sessionStatus.reconnect(), type: "button", children: "Reconnect" })] })) : null, _jsx("div", { className: "h-full min-h-0 overflow-y-auto", "data-chat-scroller": true, ref: scrollerRef, onScroll: (event) => {
183
+ return (_jsxs("div", { className: "prose relative min-h-0 flex-1", children: [_jsx("div", { "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: sessionReadout(sessionStatus.status, sessionStatus.viewState) }), sessionStatus.observation.status === "unavailable" ? (_jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-1 text-xs text-dim", role: "status", children: [_jsx("span", { children: sessionStatus.observation.reason }), _jsx(Button, { variant: "outline", size: "xs", onClick: () => void sessionStatus.reconnect(), type: "button", children: "Reconnect" })] })) : null, _jsxs("div", { className: "h-full min-h-0 overflow-y-auto", "data-chat-scroller": true, ref: scrollerRef, onScroll: (event) => {
182
184
  const top = event.currentTarget.scrollTop;
183
185
  if (previousScrollTop.current !== undefined &&
184
186
  top < previousScrollTop.current)
@@ -197,44 +199,44 @@ function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focu
197
199
  scroller.scrollHeight - 1 &&
198
200
  hasNewerHistory)
199
201
  loadNewerHistory();
200
- }, style: { overscrollBehavior: "contain" }, children: count > 0 ? (_jsx("div", { className: "relative w-full", style: { height: `${String(timeline.getTotalSize())}px` }, children: virtualItems.map((virtualItem) => {
201
- const item = itemAt(virtualItem.index);
202
- if (item === undefined)
203
- return null;
204
- return (_jsxs("div", { "data-index": virtualItem.index, "data-parakeet-entry": item.kind === "user_message" ? "user" : item.kind, "data-parakeet-id": item.id, "data-status": item.kind === "assistant_message"
205
- ? item.isError
202
+ }, style: { overscrollBehavior: "contain" }, children: [count > 0 ? (_jsx("div", { className: "relative w-full", style: { height: `${String(timeline.getTotalSize())}px` }, children: virtualItems.map((virtualItem) => {
203
+ const item = itemAt(virtualItem.index);
204
+ if (item === undefined)
205
+ return null;
206
+ return (_jsxs("div", { "data-index": virtualItem.index, "data-parakeet-entry": item.kind === "user_message" ? "user" : item.kind, "data-parakeet-id": item.id, "data-status": item.kind === "assistant_message"
207
+ ? item.isError
208
+ ? "error"
209
+ : undefined
210
+ : item.kind === "compaction_divider" ||
211
+ item.kind === "compaction_notice"
212
+ ? undefined
213
+ : item.status, "data-tone": item.kind === "assistant_message" && item.isError
206
214
  ? "error"
207
- : undefined
208
- : item.kind === "compaction_divider" ||
209
- item.kind === "compaction_notice"
210
- ? undefined
211
- : item.status, "data-tone": item.kind === "assistant_message" && item.isError
212
- ? "error"
213
- : undefined, ref: timeline.measureElement, style: {
214
- left: 0,
215
- position: "absolute",
216
- top: 0,
217
- transform: `translateY(${String(virtualItem.start)}px)`,
218
- width: "100%",
219
- }, children: [virtualItem.index === 0 ? before : null, _jsx(TimelineItem, { item: "author" in item &&
220
- item.author &&
221
- authorNames.has(item.author.id)
222
- ? {
223
- ...item,
224
- author: {
225
- ...item.author,
226
- name: authorNames.get(item.author.id) ??
227
- item.author.name,
228
- },
229
- }
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));
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] }));
215
+ : undefined, ref: timeline.measureElement, style: {
216
+ left: 0,
217
+ position: "absolute",
218
+ top: 0,
219
+ transform: `translateY(${String(virtualItem.start)}px)`,
220
+ width: "100%",
221
+ }, children: [virtualItem.index === 0 ? before : null, _jsx(TimelineItem, { item: "author" in item &&
222
+ item.author &&
223
+ authorNames.has(item.author.id)
224
+ ? {
225
+ ...item,
226
+ author: {
227
+ ...item.author,
228
+ name: authorNames.get(item.author.id) ??
229
+ item.author.name,
230
+ },
231
+ }
232
+ : item, onDismissFailed: dismissFailed, onRetry: virtualItem.index === count - 1 &&
233
+ (composer.failure === "failed" ||
234
+ composer.failure === "admission")
235
+ ? composer.retry
236
+ : 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"
237
+ ? sessionStatus.viewState.cause
238
+ : 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));
239
+ }) })) : before.length > 0 ? (before) : hasMoreHistory || modelSetup?.state === "missing" ? null : ((empty ?? _jsx(ConversationStarters, {}))), modelSetup?.state === "missing" ? (_jsx("div", { className: `flex items-center justify-center p-6 ${count === 0 ? "h-full" : "min-h-64"}`, children: _jsx(SetupNotice, { need: "Connect a model to start", cause: "Agents answer with a model, and none is connected yet.", fix: modelSetup.fix, variant: "panel" }) })) : null] }), count > 0 ? (_jsx(ScrollToBottomBlob, { direction: "forward", unread: unread, focusAfterJump: focusAfterJump, onJump: jumpToBottom, scrollerRef: scrollerRef })) : null] }));
238
240
  }
239
241
  const stoppedMessages = {
240
242
  failed: "The run stopped. Your prompt is still here.",
@@ -275,11 +277,8 @@ function RunStopped({ failure, cause, lastItem, onRetry, }) {
275
277
  }
276
278
  /** The empty conversation: host starter chips when there are any, the quiet prompt otherwise. */
277
279
  function ConversationStarters() {
278
- const { modelSetup, starters } = useContext(ParakeetHostFactsContext);
280
+ const { starters } = useContext(ParakeetHostFactsContext);
279
281
  const composer = useComposer();
280
- // Known up front, before any run: the fix is the composer's one action below.
281
- if (modelSetup?.state === "missing")
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" }) }));
283
282
  if (starters === undefined || starters.length === 0)
284
283
  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?" })] }) }));
285
284
  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) => ({
@@ -319,6 +318,8 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, sla
319
318
  const abort = useCallback(() => {
320
319
  void composer.cancel();
321
320
  }, [composer.cancel]);
321
+ if (hostFacts.modelSetup?.state === "missing")
322
+ return null;
322
323
  const composerProps = {
323
324
  queuedRecall: visitor === undefined ? composer : undefined,
324
325
  onImagesChange: visitor === undefined ? composer.setImages : undefined,
@@ -334,14 +335,6 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, sla
334
335
  onSend: slash.submit,
335
336
  slash: visitor === undefined ? slash : undefined,
336
337
  placeholder: visitor === undefined ? undefined : `Ask ${visitor.agentName}…`,
337
- // No model means no reply: say why instead of taking a prompt that cannot work.
338
- disabledReason: hostFacts.modelSetup?.state === "missing"
339
- ? "Connect a model to start chatting"
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,
345
338
  showFooter: visitor === undefined,
346
339
  status: sessionStatus.status,
347
340
  viewState: sessionStatus.viewState,
package/dist/styles.css CHANGED
@@ -6430,6 +6430,9 @@
6430
6430
  .min-h-14 {
6431
6431
  min-height: calc(var(--spacing) * 14);
6432
6432
  }
6433
+ .min-h-64 {
6434
+ min-height: calc(var(--spacing) * 64);
6435
+ }
6433
6436
  .min-h-96 {
6434
6437
  min-height: calc(var(--spacing) * 96);
6435
6438
  }
@@ -6857,6 +6860,9 @@
6857
6860
  .p-0 {
6858
6861
  padding: calc(var(--spacing) * 0);
6859
6862
  }
6863
+ .p-6 {
6864
+ padding: calc(var(--spacing) * 6);
6865
+ }
6860
6866
  .p-lg {
6861
6867
  padding: var(--spacing-lg);
6862
6868
  }
@@ -15146,6 +15152,17 @@
15146
15152
  .caps-window-header:has(.caps-window-crumbs) {
15147
15153
  flex-wrap: wrap;
15148
15154
  }
15155
+ .caps-window-header:has( .caps-window-crumb-item[data-caps-crumb-position="parent"] ):has(.caps-window-commands)::after {
15156
+ content: "";
15157
+ flex-basis: 100%;
15158
+ order: 1;
15159
+ }
15160
+ .caps-window-header:has( .caps-window-crumb-item[data-caps-crumb-position="parent"] ) > :is(.caps-window-commands, .caps-window-actions) {
15161
+ order: 2;
15162
+ }
15163
+ .caps-window-header:has( .caps-window-crumb-item[data-caps-crumb-position="parent"] ) > .caps-window-commands {
15164
+ margin-inline-end: auto;
15165
+ }
15149
15166
  .caps-window-crumbs {
15150
15167
  min-width: min-content;
15151
15168
  flex-shrink: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/parakeet",
3
- "version": "0.11.4",
3
+ "version": "0.11.6",
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.1",
64
64
  "@fungi.computer/bird-dog": "0.3.6",
65
65
  "@fungi.computer/cairn": "0.1.0",
66
- "@fungi.computer/caps": "0.10.1",
66
+ "@fungi.computer/caps": "0.10.2",
67
67
  "@fungi.computer/gills": "0.3.0",
68
68
  "@fungi.computer/knapsack": "0.4.9",
69
69
  "@fungi.computer/shiitake": "0.12.4",