@fungi.computer/parakeet 0.17.0 → 0.17.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.
@@ -12,7 +12,6 @@ export declare function useClientActions(commands: ParakeetCommandRuntime): {
12
12
  readonly awaiting?: "question";
13
13
  }, Readonly<{
14
14
  pending: boolean;
15
- error?: string;
16
15
  }>>;
17
16
  /** Observation is live and this Session's action owner is attached. */
18
17
  enabled: boolean;
@@ -28,13 +28,13 @@ export function ClientRows({ entryId, rows, actions, onOpen, }) {
28
28
  : undefined;
29
29
  if (decision !== undefined) {
30
30
  const state = actions.state.get(decision);
31
- return (_jsxs("div", { "data-client-row": row.id, children: [_jsxs(Button, { size: "xs", variant: "ghost", className: "-mx-xs flex w-[calc(100%+2*var(--spacing-xs))] justify-start gap-2 px-xs font-normal", disabled: !actions.enabled || state?.pending === true, loading: state?.pending === true, onClick: () => {
32
- void actions.execute(entryId, decision);
33
- }, children: [_jsx("span", { "aria-hidden": "true", "data-client-row-dot": "", className: `w-3 shrink-0 text-center ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: row.tone === undefined ? "" : "●" }), _jsxs("span", { className: `min-w-0 flex-1 truncate text-start ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: [row.title, row.detail === undefined ? null : (_jsxs("span", { className: "text-dim", children: [" \u00B7 ", row.detail] }))] }), _jsx("span", { className: "shrink-0 text-dim", "data-client-row-action": "", children: decision.label })] }), state?.error === undefined ? null : (_jsx("p", { className: "text-error", role: "alert", children: state.error }))] }, row.id));
31
+ return (_jsx("div", { "data-client-row": row.id, children: _jsxs(Button, { size: "xs", variant: "ghost", className: "-mx-xs flex w-[calc(100%+2*var(--spacing-xs))] justify-start gap-2 px-xs font-normal", disabled: !actions.enabled || state?.pending === true, loading: state?.pending === true, onClick: () => {
32
+ void actions.execute(entryId, decision);
33
+ }, children: [_jsx("span", { "aria-hidden": "true", "data-client-row-dot": "", className: `w-3 shrink-0 text-center ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: row.tone === undefined ? "" : "●" }), _jsxs("span", { className: `min-w-0 flex-1 truncate text-start ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: [row.title, row.detail === undefined ? null : (_jsxs("span", { className: "text-dim", children: [" \u00B7 ", row.detail] }))] }), _jsx("span", { className: "shrink-0 text-dim", "data-client-row-action": "", children: decision.label })] }) }, row.id));
34
34
  }
35
- return (_jsxs("div", { "data-client-row": row.id, className: "py-1", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { "aria-hidden": "true", "data-client-row-dot": "", className: `w-3 shrink-0 text-center leading-4 ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: row.tone === undefined ? "" : "●" }), _jsxs("details", { className: "min-w-0 flex-1", children: [_jsxs("summary", { className: `cursor-pointer break-words leading-4 ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: [row.title, row.inspection === undefined || row.detail === undefined
35
+ return (_jsxs("div", { "data-client-row": row.id, className: "py-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { "aria-hidden": "true", "data-client-row-dot": "", className: `w-3 shrink-0 text-center leading-4 ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: row.tone === undefined ? "" : "●" }), _jsxs("details", { className: "min-w-0 flex-1", children: [_jsxs("summary", { title: row.title, className: `cursor-pointer truncate leading-4 ${row.tone === undefined ? "" : rowColors[row.tone]}`, children: [row.title, row.inspection === undefined || row.detail === undefined
36
36
  ? null
37
- : ` · ${row.detail}`] }), row.detail === undefined ? null : (_jsx("p", { className: "max-h-32 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words pb-2", children: row.detail }))] }), row.open === undefined ? null : (_jsx(Button, { size: "xs", variant: "outline", disabled: onOpen === undefined, onClick: () => {
37
+ : ` · ${row.detail}`] }), row.detail === undefined ? null : (_jsx("p", { className: "max-h-32 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words pb-2", children: row.detail }))] }), row.open === undefined ? null : (_jsx(Button, { size: "xs", variant: "outline", className: "shrink-0", disabled: onOpen === undefined, onClick: () => {
38
38
  if (row.open !== undefined)
39
39
  onOpen?.(row.open);
40
40
  }, children: "Open" })), row.actions?.map((action) => {
@@ -54,9 +54,6 @@ export function ClientRows({ entryId, rows, actions, onOpen, }) {
54
54
  ? "error"
55
55
  : child.tone === "attention"
56
56
  ? "warning"
57
- : "neutral", label: child.title }), child.detail === undefined ? null : (_jsx("span", { children: child.detail }))] }, child.id))) })] })) : null, row.actions?.map((action) => {
58
- const error = actions.state.get(action)?.error;
59
- return error === undefined ? null : (_jsx("p", { className: "text-error", role: "alert", children: error }, action.id));
60
- })] }, row.id));
57
+ : "neutral", label: child.title }), child.detail === undefined ? null : (_jsx("span", { children: child.detail }))] }, child.id))) })] })) : null] }, row.id));
61
58
  }) }));
62
59
  }
@@ -1,3 +1,4 @@
1
+ import { failureMessage } from "@fungi.computer/agar/errors";
1
2
  import { openAppAgent } from "@fungi.computer/agar/agents";
2
3
  import { seedSessionQuery } from "./headless.js";
3
4
  import { createShiitakeClient, } from "@fungi.computer/shiitake/client";
@@ -183,9 +184,13 @@ export function createConversationOpeningOwner(options) {
183
184
  if (isCurrent(opening)) {
184
185
  pending = null;
185
186
  options.onPending(null);
186
- options.onError(fromOpenRequest
187
- ? `That Session could not be opened. ${current ? "The current conversation remains open." : "Choose another Session from the list."}`
188
- : `Could not open this Session${cause instanceof Error ? `: ${cause.message}` : ""}. ${current ? "The previous conversation remains open." : "Try opening it again."}`);
187
+ options.onError(`${failureMessage("Could not open this Session", cause)} ${current
188
+ ? fromOpenRequest
189
+ ? "The current conversation remains open."
190
+ : "The previous conversation remains open."
191
+ : fromOpenRequest
192
+ ? "Choose another Session from the list."
193
+ : "Try opening it again."}`);
189
194
  }
190
195
  }
191
196
  })();
@@ -6,8 +6,6 @@ import type { ClientContribution } from "./client-contributions.js";
6
6
  export type ClientActionState = Readonly<{
7
7
  /** The same advertised intent is already in flight. */
8
8
  pending: boolean;
9
- /** Visible execution failure; cleared when this intent is retried. */
10
- error?: string;
11
9
  }>;
12
10
  /** Run admitted row intents through the ordinary advertised Whistle commands. */
13
11
  export declare function createClientActions(options: Readonly<{
@@ -26,8 +24,6 @@ export declare function createClientActions(options: Readonly<{
26
24
  }, Readonly<{
27
25
  /** The same advertised intent is already in flight. */
28
26
  pending: boolean;
29
- /** Visible execution failure; cleared when this intent is retried. */
30
- error?: string;
31
27
  }>>;
32
28
  refresh: () => void;
33
29
  subscribe: (listener: () => void) => () => void;
@@ -91,8 +91,11 @@ export function createClientActions(options) {
91
91
  const error = cause instanceof Error
92
92
  ? cause
93
93
  : new Error("Client row command failed", { cause });
94
- publish(intent, { pending: false, error: error.message });
95
- options.interactions.report({ tone: "error", message: error.message });
94
+ publish(intent, { pending: false });
95
+ options.interactions.toast({
96
+ variant: "error",
97
+ message: error.message,
98
+ });
96
99
  return;
97
100
  }
98
101
  if (retired())
@@ -104,9 +107,15 @@ export function createClientActions(options) {
104
107
  : outcome.status === "unavailable"
105
108
  ? outcome.reason
106
109
  : `Client row command ${outcome.status}`;
107
- publish(intent, error === undefined ? { pending: false } : { pending: false, error });
108
- if (error !== undefined)
109
- options.interactions.report({ tone: "error", message: error });
110
+ publish(intent, { pending: false });
111
+ if (error !== undefined) {
112
+ // Whistle may already have reported this command's failure. Move that
113
+ // notice to the toast surface without clearing another command's notice.
114
+ const notice = options.interactions.snapshot().notice;
115
+ if (notice?.tone === "error" && notice.message === error)
116
+ options.interactions.report(undefined);
117
+ options.interactions.toast({ variant: "error", message: error });
118
+ }
110
119
  },
111
120
  dispose: () => {
112
121
  controller.abort();
@@ -4,6 +4,7 @@ import { type ReactElement, type ReactNode } from "react";
4
4
  import { type ParakeetAuthorOf } from "./core/author-labels.js";
5
5
  import type { ToolItem } from "./store/types.js";
6
6
  import type { ParakeetSession } from "./session.js";
7
+ import type { ParakeetToast } from "./commands/interactions.js";
7
8
  import type { RowV1 } from "@fungi.computer/gills";
8
9
  import { type ParakeetCommandRuntime } from "./commands/use-slash-commands.js";
9
10
  /** Public composer options for an anonymous visitor conversation. */
@@ -45,6 +46,8 @@ export type ParakeetProps = Readonly<{
45
46
  formatAssistantText?: ((text: string) => string) | undefined;
46
47
  /** Host navigation for transcript links; true prevents browser navigation. */
47
48
  onLink?: ((href: string) => boolean) | undefined;
49
+ /** Send transient command information and failures to the host toast surface. */
50
+ onToast?: ((toast: ParakeetToast) => void) | undefined;
48
51
  /** Authorize and open a typed target through the host's navigation owner. */
49
52
  onOpen?: ((target: NonNullable<RowV1["open"]>) => void) | undefined;
50
53
  /** Optional caller-owned empty conversation state. */
@@ -97,4 +100,4 @@ export type ParakeetViewProps = Readonly<{
97
100
  /** Render the retained conversation surface within one Parakeet provider. */
98
101
  export declare function ParakeetView({ hideSoleAuthor, disambiguateAuthors, visitor, composerActionVariant, placeholder, empty, hostFacts, autoFocus, commands, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, onLink, onOpen, }: ParakeetViewProps): ReactElement;
99
102
  /** Standalone typed composer and exact-message timeline. */
100
- export declare function Parakeet({ authorOf, hideSoleAuthor, disambiguateAuthors, visitor, markdownPolicy, composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, }: ParakeetProps): ReactElement;
103
+ export declare function Parakeet({ authorOf, hideSoleAuthor, disambiguateAuthors, visitor, markdownPolicy, composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, onToast, }: ParakeetProps): ReactElement;
package/dist/parakeet.js CHANGED
@@ -417,6 +417,6 @@ function ConversationComposer({ visitor, textareaRef, composerActionVariant, pla
417
417
  return _jsx(ChatComposer, { ...composerProps });
418
418
  }
419
419
  /** Standalone typed composer and exact-message timeline. */
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 }) }) }));
420
+ export function Parakeet({ authorOf, hideSoleAuthor, disambiguateAuthors, visitor, markdownPolicy = "session", composerActionVariant, empty, hostFacts, session, clients, renderToolActions, claimsToolMedia, renderAssistantAttachment, formatAssistantText, commands, onLink, onOpen, onToast, }) {
421
+ return (_jsx(MarkdownPolicyContext.Provider, { value: markdownPolicy, children: _jsx(ParakeetProvider, { session: session, clients: clients, authorOf: authorOf, onToast: onToast, 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 }) }) }));
422
422
  }
@@ -8,7 +8,8 @@ function visibleState(held, snapshot) {
8
8
  ? {
9
9
  ...held,
10
10
  phase: "refused",
11
- refusal: snapshot.failure ?? "Something went wrong.",
11
+ refusal: snapshot.failure ??
12
+ "The host marked the answer failed and gave no reason.",
12
13
  }
13
14
  : { ...held, phase: "sending" };
14
15
  }
@@ -1361,11 +1361,11 @@ Ordinary advertised actions over the current admitted rows and observation.
1361
1361
 
1362
1362
  #### Returns
1363
1363
 
1364
- | Name | Type | Description |
1365
- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
1366
- | `state` | `ReadonlyMap`\<\{ `id`: `string`; `label`: `string`; `input?`: \{ \[`key`: `string`\]: `Json`; \}; `awaiting?`: `"question"`; \}, `Readonly`\<\{ `pending`: `boolean`; `error?`: `string`; \}\>\> | Current Session-owned state of admitted action intents. |
1367
- | `enabled` | `boolean` | Observation is live and this Session's action owner is attached. |
1368
- | `execute()` | (`entryId`, `action`, `waiting`) => `Promise`\<`void`\> | Execute an admitted intent through its owning advertised command. |
1364
+ | Name | Type | Description |
1365
+ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
1366
+ | `state` | `ReadonlyMap`\<\{ `id`: `string`; `label`: `string`; `input?`: \{ \[`key`: `string`\]: `Json`; \}; `awaiting?`: `"question"`; \}, `Readonly`\<\{ `pending`: `boolean`; \}\>\> | Current Session-owned state of admitted action intents. |
1367
+ | `enabled` | `boolean` | Observation is live and this Session's action owner is attached. |
1368
+ | `execute()` | (`entryId`, `action`, `waiting`) => `Promise`\<`void`\> | Execute an admitted intent through its owning advertised command. |
1369
1369
 
1370
1370
  ---
1371
1371
 
package/docs/api/index.md CHANGED
@@ -595,6 +595,7 @@ type ParakeetProps = Readonly<{
595
595
  renderAssistantAttachment?: (text) => ReactNode;
596
596
  formatAssistantText?: (text) => string;
597
597
  onLink?: (href) => boolean;
598
+ onToast?: (toast) => void;
598
599
  onOpen?: (target) => void;
599
600
  empty?: ReactNode;
600
601
  hostFacts?: ParakeetHostFacts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/parakeet",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Standalone React composer for a typed Shiitake Session",
@@ -68,14 +68,14 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@earendil-works/pi-ai": "1.5.2",
71
- "@fungi.computer/agar": "0.27.0",
71
+ "@fungi.computer/agar": "0.27.2",
72
72
  "@fungi.computer/bird-dog": "0.3.8",
73
73
  "@fungi.computer/cairn": "0.1.0",
74
- "@fungi.computer/caps": "0.12.8",
74
+ "@fungi.computer/caps": "0.12.9",
75
75
  "@fungi.computer/gills": "0.4.0",
76
- "@fungi.computer/knapsack": "0.4.26",
76
+ "@fungi.computer/knapsack": "0.4.27",
77
77
  "@fungi.computer/mule": "0.3.0",
78
- "@fungi.computer/shiitake": "0.22.2",
78
+ "@fungi.computer/shiitake": "0.22.4",
79
79
  "@fungi.computer/sigils": "0.3.2",
80
80
  "@fungi.computer/sprite": "0.2.2",
81
81
  "@fungi.computer/sprite-zdog": "0.3.2",