@fungi.computer/parakeet 0.14.9 → 0.15.0

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.
@@ -13,6 +13,11 @@ export type ParakeetVisitor = Readonly<{
13
13
  }>;
14
14
  /** Props for the standalone retained conversation surface. */
15
15
  export type ParakeetProps = Readonly<{
16
+ /**
17
+ * Show no author line on prompts while one human has written them all, so a
18
+ * solo chat carries no label; it appears once a second person writes.
19
+ */
20
+ hideSoleAuthor?: boolean | undefined;
16
21
  /** Show short identity suffixes for same-named authors; never in visitor mode. */
17
22
  disambiguateAuthors?: boolean | undefined;
18
23
  /**
@@ -51,6 +56,8 @@ export type ParakeetProps = Readonly<{
51
56
  }>;
52
57
  /** Props for the reusable retained conversation view. */
53
58
  export type ParakeetViewProps = Readonly<{
59
+ /** Hide the prompt author line while one human has written every prompt. */
60
+ hideSoleAuthor?: boolean | undefined;
54
61
  /** Show short identity suffixes for same-named authors; never in visitor mode. */
55
62
  disambiguateAuthors?: boolean | undefined;
56
63
  /** Visitor mode hides internal readouts and disables slash commands. */
@@ -83,6 +90,6 @@ export type ParakeetViewProps = Readonly<{
83
90
  commands?: ParakeetCommandRuntime | undefined;
84
91
  }>;
85
92
  /** Render the retained conversation surface within one Parakeet provider. */
86
- export declare function ParakeetView({ disambiguateAuthors, visitor, composerActionVariant, empty, hostFacts, autoFocus, commands, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, onLink, onOpen, }: ParakeetViewProps): ReactElement;
93
+ export declare function ParakeetView({ hideSoleAuthor, disambiguateAuthors, visitor, composerActionVariant, empty, hostFacts, autoFocus, commands, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, onLink, onOpen, }: ParakeetViewProps): ReactElement;
87
94
  /** Standalone typed composer and exact-message timeline. */
88
- export declare function Parakeet({ authorOf, disambiguateAuthors, visitor, markdownPolicy, composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, }: ParakeetProps): ReactElement;
95
+ export declare function Parakeet({ authorOf, hideSoleAuthor, disambiguateAuthors, visitor, markdownPolicy, composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, }: ParakeetProps): ReactElement;
package/dist/parakeet.js CHANGED
@@ -24,7 +24,7 @@ import { useSlashCommands, } from "./commands/use-slash-commands.js";
24
24
  import { TimelineItem } from "./components/TimelineItem.js";
25
25
  import { MarkdownPolicyContext } from "./components/MarkdownRenderer.js";
26
26
  /** Render the retained conversation surface within one Parakeet provider. */
27
- export function ParakeetView({ disambiguateAuthors, visitor, composerActionVariant, empty, hostFacts, autoFocus, commands, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, onLink, onOpen, }) {
27
+ export function ParakeetView({ hideSoleAuthor, disambiguateAuthors, visitor, composerActionVariant, empty, hostFacts, autoFocus, commands, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, onLink, onOpen, }) {
28
28
  const textareaRef = useRef(null);
29
29
  // Opening a conversation puts the caret in the composer; a click elsewhere keeps it.
30
30
  useEffect(() => {
@@ -56,7 +56,7 @@ export function ParakeetView({ disambiguateAuthors, visitor, composerActionVaria
56
56
  : null;
57
57
  if (anchor instanceof HTMLAnchorElement && onLink?.(anchor.href))
58
58
  event.preventDefault();
59
- }, children: [_jsxs("div", { className: "flex h-full w-full flex-col border-r border-base-300", children: [_jsx(ConversationTimeline, { disambiguateAuthors: visitor === undefined && disambiguateAuthors === true, clientActions: clientActions, onOpen: onOpen, focusAfterJump: textareaRef, empty: empty, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText }), contributions.some(({ entryId, value }) => value.panel.some((row) => JSON.stringify([entryId, row.id]) !== answering)) ? (_jsx("section", { "aria-label": "Session extension controls", className: "w-full shrink-0 border-t border-base-300 bg-base-100", children: contributions.map(({ entryId, value: contribution }) => {
59
+ }, children: [_jsxs("div", { className: "flex h-full w-full flex-col border-r border-base-300", children: [_jsx(ConversationTimeline, { hideSoleAuthor: hideSoleAuthor === true, disambiguateAuthors: visitor === undefined && disambiguateAuthors === true, clientActions: clientActions, onOpen: onOpen, focusAfterJump: textareaRef, empty: empty, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText }), contributions.some(({ entryId, value }) => value.panel.some((row) => JSON.stringify([entryId, row.id]) !== answering)) ? (_jsx("section", { "aria-label": "Session extension controls", className: "w-full shrink-0 border-t border-base-300 bg-base-100", children: contributions.map(({ entryId, value: contribution }) => {
60
60
  const value = {
61
61
  ...contribution,
62
62
  panel: contribution.panel.filter((row) => JSON.stringify([entryId, row.id]) !== answering),
@@ -110,7 +110,7 @@ function ConversationInteraction({ slash, }) {
110
110
  slash.store.close();
111
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)) }) }));
112
112
  }
113
- function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focusAfterJump, empty, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, }) {
113
+ function ConversationTimeline({ hideSoleAuthor, disambiguateAuthors, clientActions, onOpen, focusAfterJump, empty, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, }) {
114
114
  const { modelSetup } = useContext(ParakeetHostFactsContext);
115
115
  const dismissFailed = useDismissFailedPrompt();
116
116
  const composer = useComposer();
@@ -121,6 +121,21 @@ function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focu
121
121
  const authorNames = useMemo(() => authorDisplayNames(disambiguateAuthors
122
122
  ? [...timelineController.settled, ...timelineController.tail].flatMap((item) => ("author" in item && item.author ? [item.author] : []))
123
123
  : []), [disambiguateAuthors, timelineController.settled, timelineController.tail]);
124
+ // One human wrote every prompt: the label would only name the reader.
125
+ const soleAuthor = useMemo(() => {
126
+ if (!hideSoleAuthor)
127
+ return false;
128
+ const humans = new Set();
129
+ for (const item of [
130
+ ...timelineController.settled,
131
+ ...timelineController.tail,
132
+ ])
133
+ if (item.kind === "user_message" &&
134
+ item.author !== undefined &&
135
+ item.author.kind !== "agent")
136
+ humans.add(item.author.id);
137
+ return humans.size <= 1;
138
+ }, [hideSoleAuthor, timelineController.settled, timelineController.tail]);
124
139
  const contributions = useClientContributions();
125
140
  const placed = placeClientTimeline(contributions, timelineController.commandAnchors, timelineController.positionAnchors);
126
141
  const before = placed.before.map(({ entryId, cell }) => (_jsx(ClientRows, { entryId: entryId, rows: cell.rows, actions: clientActions, onOpen: onOpen }, `${entryId}:${cell.id}`)));
@@ -261,18 +276,22 @@ function ConversationTimeline({ disambiguateAuthors, clientActions, onOpen, focu
261
276
  top: 0,
262
277
  transform: `translateY(${String(virtualItem.start)}px)`,
263
278
  width: "100%",
264
- }, children: [virtualItem.index === 0 ? before : null, _jsx(TimelineItem, { item: "author" in item &&
265
- item.author &&
266
- authorNames.has(item.author.id)
267
- ? {
268
- ...item,
269
- author: {
270
- ...item.author,
271
- name: authorNames.get(item.author.id) ??
272
- item.author.name,
273
- },
274
- }
275
- : item, onDismissFailed: dismissFailed, onRetry: virtualItem.index === count - 1 &&
279
+ }, children: [virtualItem.index === 0 ? before : null, _jsx(TimelineItem, { item: soleAuthor &&
280
+ item.kind === "user_message" &&
281
+ item.author?.kind !== "agent"
282
+ ? { ...item, author: undefined }
283
+ : "author" in item &&
284
+ item.author &&
285
+ authorNames.has(item.author.id)
286
+ ? {
287
+ ...item,
288
+ author: {
289
+ ...item.author,
290
+ name: authorNames.get(item.author.id) ??
291
+ item.author.name,
292
+ },
293
+ }
294
+ : item, onDismissFailed: dismissFailed, onRetry: virtualItem.index === count - 1 &&
276
295
  (composer.failure === "failed" ||
277
296
  composer.failure === "admission")
278
297
  ? composer.retry
@@ -398,6 +417,6 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, sla
398
417
  return _jsx(ChatComposer, { ...composerProps });
399
418
  }
400
419
  /** Standalone typed composer and exact-message timeline. */
401
- export function Parakeet({ authorOf, disambiguateAuthors, visitor, markdownPolicy = "session", composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, }) {
402
- return (_jsx(MarkdownPolicyContext.Provider, { value: markdownPolicy, children: _jsx(ParakeetProvider, { session: session, clients: clients, authorOf: authorOf, children: _jsx(ParakeetView, { disambiguateAuthors: disambiguateAuthors, visitor: visitor, composerActionVariant: composerActionVariant, empty: empty, hostFacts: hostFacts, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText, commands: commands, onLink: onLink, onOpen: onOpen }) }) }));
420
+ export function Parakeet({ authorOf, hideSoleAuthor, disambiguateAuthors, visitor, markdownPolicy = "session", composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, }) {
421
+ return (_jsx(MarkdownPolicyContext.Provider, { value: markdownPolicy, children: _jsx(ParakeetProvider, { session: session, clients: clients, authorOf: authorOf, children: _jsx(ParakeetView, { hideSoleAuthor: hideSoleAuthor, disambiguateAuthors: disambiguateAuthors, visitor: visitor, composerActionVariant: composerActionVariant, empty: empty, hostFacts: hostFacts, renderToolActions: renderToolActions, claimsToolMedia: claimsToolMedia, renderAssistantAttachment: renderAssistantAttachment, formatAssistantText: formatAssistantText, commands: commands, onLink: onLink, onOpen: onOpen }) }) }));
403
422
  }
package/docs/api/index.md CHANGED
@@ -582,6 +582,7 @@ Public composer options for an anonymous visitor conversation.
582
582
 
583
583
  ```ts
584
584
  type ParakeetProps = Readonly<{
585
+ hideSoleAuthor?: boolean;
585
586
  disambiguateAuthors?: boolean;
586
587
  authorOf?: ParakeetAuthorOf;
587
588
  visitor?: ParakeetVisitor;
@@ -609,6 +610,7 @@ Props for the standalone retained conversation surface.
609
610
 
610
611
  ```ts
611
612
  type ParakeetViewProps = Readonly<{
613
+ hideSoleAuthor?: boolean;
612
614
  disambiguateAuthors?: boolean;
613
615
  visitor?: ParakeetVisitor;
614
616
  composerActionVariant?: "primary" | "outline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/parakeet",
3
- "version": "0.14.9",
3
+ "version": "0.15.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Standalone React composer for a typed Shiitake Session",