@fungi.computer/parakeet 0.17.1 → 0.17.3
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/client-contributions.d.ts +0 -1
- package/dist/components/ChatComposer.js +1 -1
- package/dist/components/ClientRows.js +6 -9
- package/dist/core/awaiting-answer.d.ts +13 -1
- package/dist/core/awaiting-answer.js +66 -1
- package/dist/core/client-actions.d.ts +0 -4
- package/dist/core/client-actions.js +14 -5
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/parakeet.d.ts +4 -1
- package/dist/parakeet.js +2 -2
- package/dist/styles.css +32 -4
- package/dist/use-approval-awaiting.js +9 -1
- package/dist/use-decision.js +21 -5
- package/docs/api/headless.md +76 -14
- package/docs/api/index.md +1 -0
- package/package.json +5 -5
- package/src/composer-shell.css +31 -0
|
@@ -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;
|
|
@@ -285,7 +285,7 @@ function useComposerRow({ showFooter, statusChips, model, status, viewState, wai
|
|
|
285
285
|
: [
|
|
286
286
|
{
|
|
287
287
|
id: "settings",
|
|
288
|
-
label: (_jsxs("span", { className: "composer-settings-chip", children: [_jsx(SlidersHorizontal, { "aria-hidden": "true" }), "Settings"] })),
|
|
288
|
+
label: (_jsxs("span", { className: "composer-settings-chip", children: [_jsx(SlidersHorizontal, { "aria-hidden": "true" }), _jsx("span", { className: "composer-settings-label", children: "Settings" })] })),
|
|
289
289
|
accessibleLabel: "Session settings",
|
|
290
290
|
title: "Settings",
|
|
291
291
|
content: (_jsxs(StatusTrayList, { className: "composer-settings", children: [modelName === undefined ? null : (_jsx(StatusTrayRow, { primary: "Model", secondary: modelName, actions: canPickModel ? (_jsx(Button, { size: "xs", variant: "ghost", onClick: () => {
|
|
@@ -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 (
|
|
32
|
-
|
|
33
|
-
|
|
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-
|
|
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 ? "" : `list-none [&::-webkit-details-marker]:hidden ${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.
|
|
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
|
}
|
|
@@ -16,6 +16,8 @@ export type AwaitingItem = Readonly<{
|
|
|
16
16
|
arrivedAt: number;
|
|
17
17
|
/** The conversation to draw and answer. */
|
|
18
18
|
host: WhistleInteractionHost;
|
|
19
|
+
/** A draft owned by the pending record, retained while its host reconnects. */
|
|
20
|
+
draft?: DecisionDraft;
|
|
19
21
|
}>;
|
|
20
22
|
/** Which item the composer shows and where it stands among all of them. */
|
|
21
23
|
export type AwaitingQueue = Readonly<{
|
|
@@ -46,7 +48,7 @@ export type DecisionPrompt = WhistlePromptOf<"decision">;
|
|
|
46
48
|
export type DecisionPhase = "choose" | "other" | "confirm" | "sending" | "refused";
|
|
47
49
|
/** Everything the reducer remembers about one decision prompt. */
|
|
48
50
|
export type DecisionState = Readonly<{
|
|
49
|
-
/** Highlighted row
|
|
51
|
+
/** Highlighted row, or -1 when a retained choice is no longer available. */
|
|
50
52
|
highlight: number;
|
|
51
53
|
/** Option values toggled so far (multiple decisions only). */
|
|
52
54
|
toggled: ReadonlySet<string>;
|
|
@@ -122,6 +124,16 @@ export type DecisionOutcome = Readonly<{
|
|
|
122
124
|
}>;
|
|
123
125
|
/** The state a decision starts in. */
|
|
124
126
|
export declare function initialDecisionState(): DecisionState;
|
|
127
|
+
/** One pending choice, retaining no display metadata or answering authority. */
|
|
128
|
+
export declare class DecisionDraft {
|
|
129
|
+
#private;
|
|
130
|
+
/** Start without a remembered choice. */
|
|
131
|
+
constructor();
|
|
132
|
+
/** Remember option values, which policy rows may move, and unfinished text. */
|
|
133
|
+
remember(state: DecisionState, prompt: DecisionPrompt): void;
|
|
134
|
+
/** Redraw a compatible choice without replaying any submitted answer. */
|
|
135
|
+
restore(prompt: DecisionPrompt): DecisionState;
|
|
136
|
+
}
|
|
125
137
|
/**
|
|
126
138
|
* The one set of rules both renderers follow. Number keys only move the
|
|
127
139
|
* highlight, Enter is the only way to answer, and Esc steps back one level
|
|
@@ -32,6 +32,63 @@ export function initialDecisionState() {
|
|
|
32
32
|
details: false,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
/** One pending choice, retaining no display metadata or answering authority. */
|
|
36
|
+
export class DecisionDraft {
|
|
37
|
+
#current;
|
|
38
|
+
/** Start without a remembered choice. */
|
|
39
|
+
constructor() {
|
|
40
|
+
this.#current = undefined;
|
|
41
|
+
}
|
|
42
|
+
/** Remember option values, which policy rows may move, and unfinished text. */
|
|
43
|
+
remember(state, prompt) {
|
|
44
|
+
const option = prompt.options[state.highlight];
|
|
45
|
+
if (option === undefined &&
|
|
46
|
+
(state.highlight !== prompt.options.length || prompt.other === undefined))
|
|
47
|
+
return;
|
|
48
|
+
this.#current = {
|
|
49
|
+
multiple: prompt.multiple === true,
|
|
50
|
+
escape: prompt.escape,
|
|
51
|
+
other: prompt.other === undefined ? undefined : { blank: prompt.other.blank },
|
|
52
|
+
choice: option === undefined
|
|
53
|
+
? { kind: "other" }
|
|
54
|
+
: { kind: "option", value: option.value },
|
|
55
|
+
toggled: [...state.toggled],
|
|
56
|
+
text: state.other,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Redraw a compatible choice without replaying any submitted answer. */
|
|
60
|
+
restore(prompt) {
|
|
61
|
+
const initial = initialDecisionState();
|
|
62
|
+
const draft = this.#current;
|
|
63
|
+
if (draft === undefined)
|
|
64
|
+
return initial;
|
|
65
|
+
const choice = draft.choice;
|
|
66
|
+
const highlight = choice.kind === "other"
|
|
67
|
+
? prompt.other === undefined
|
|
68
|
+
? -1
|
|
69
|
+
: prompt.options.length
|
|
70
|
+
: prompt.options.findIndex((option) => option.value === choice.value);
|
|
71
|
+
if (draft.multiple !== (prompt.multiple === true) ||
|
|
72
|
+
draft.escape !== prompt.escape ||
|
|
73
|
+
(draft.other === undefined) !== (prompt.other === undefined) ||
|
|
74
|
+
draft.other?.blank !== prompt.other?.blank ||
|
|
75
|
+
highlight < 0 ||
|
|
76
|
+
draft.toggled.some((value) => !prompt.options.some((option) => option.value === value)))
|
|
77
|
+
return {
|
|
78
|
+
...initial,
|
|
79
|
+
highlight: -1,
|
|
80
|
+
phase: "refused",
|
|
81
|
+
refusal: "This choice changed. Choose again before sending.",
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
...initial,
|
|
85
|
+
highlight,
|
|
86
|
+
phase: highlight === prompt.options.length ? "other" : "choose",
|
|
87
|
+
toggled: new Set(draft.toggled),
|
|
88
|
+
other: draft.text,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
35
92
|
const unchanged = (state) => ({ state });
|
|
36
93
|
function onRow(state, prompt, highlight) {
|
|
37
94
|
return {
|
|
@@ -61,7 +118,11 @@ export function reduceDecision(state, intent, prompt) {
|
|
|
61
118
|
switch (intent.type) {
|
|
62
119
|
case "move":
|
|
63
120
|
return {
|
|
64
|
-
state: onRow(state, prompt,
|
|
121
|
+
state: onRow(state, prompt, state.highlight < 0
|
|
122
|
+
? intent.delta === 1
|
|
123
|
+
? 0
|
|
124
|
+
: rows - 1
|
|
125
|
+
: (state.highlight + intent.delta + rows) % rows),
|
|
65
126
|
};
|
|
66
127
|
case "pick":
|
|
67
128
|
return intent.number >= 1 && intent.number <= rows
|
|
@@ -96,6 +157,8 @@ export function reduceDecision(state, intent, prompt) {
|
|
|
96
157
|
case "details":
|
|
97
158
|
return { state: { ...state, details: !state.details } };
|
|
98
159
|
case "enter": {
|
|
160
|
+
if (state.highlight < 0 || state.highlight >= rows)
|
|
161
|
+
return unchanged(state);
|
|
99
162
|
const text = state.other.trim();
|
|
100
163
|
const answerText = text === "" ? {} : { text };
|
|
101
164
|
if (prompt.multiple === true) {
|
|
@@ -269,6 +332,8 @@ export function decisionView(state, prompt, context) {
|
|
|
269
332
|
phase: state.phase,
|
|
270
333
|
canSend: !sending &&
|
|
271
334
|
!state.details &&
|
|
335
|
+
state.highlight >= 0 &&
|
|
336
|
+
state.highlight < rows.length &&
|
|
272
337
|
(multiple
|
|
273
338
|
? state.toggled.size > 0 || otherText !== ""
|
|
274
339
|
: state.highlight < optionCount ||
|
|
@@ -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
|
|
95
|
-
options.interactions.
|
|
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,
|
|
108
|
-
if (error !== undefined)
|
|
109
|
-
|
|
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();
|
package/dist/headless.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { formatToolDuration, toolCallView, toolKindSigils, toolLiveLines, toolSt
|
|
|
28
28
|
export { assistantMessageVisible } from "./core/assistant-visibility.js";
|
|
29
29
|
export { disclosureOpen, initialToolDisclosure, toggleAllDisclosure, toggleDisclosure, toolCallDefaultOpen, toolGroupDefaultOpen, visibleToolCalls, type ToolDisclosureState, } from "./core/tool-groups.js";
|
|
30
30
|
export { useClientActions } from "./client-contributions.js";
|
|
31
|
-
export { awaitingQueue, awaitingTakeover, decisionView, decisionViewText, initialDecisionState, reduceDecision, type AwaitingItem, type AwaitingKind, type AwaitingQueue, type DecisionEffect, type DecisionIntent, type DecisionOutcome, type DecisionPhase, type DecisionPrompt, type DecisionRowView, type DecisionState, type DecisionView, } from "./core/awaiting-answer.js";
|
|
31
|
+
export { awaitingQueue, awaitingTakeover, decisionView, decisionViewText, initialDecisionState, reduceDecision, type AwaitingItem, type AwaitingKind, type AwaitingQueue, type DecisionEffect, type DecisionIntent, type DecisionOutcome, type DecisionPhase, type DecisionPrompt, type DecisionRowView, type DecisionState, DecisionDraft, type DecisionView, } from "./core/awaiting-answer.js";
|
|
32
32
|
export { useDecision, type DecisionController } from "./use-decision.js";
|
|
33
33
|
export { useApprovalAwaiting } from "./use-approval-awaiting.js";
|
|
34
34
|
export { approvalCardCopy, approvalRefusal, askApproval, type ApprovalAbandoned, type ApprovalAnswered, type ApprovalAnswerInput, type ApprovalAnswerResult, type ApprovalCard, type ApprovalContent, type ApprovalDecision, type ApprovalEntry, type ApprovalFacts, type ApprovalOutcome, type ApprovalRefused, type ApprovalReview, type ApprovalSource, } from "./core/approval-decision.js";
|
package/dist/headless.js
CHANGED
|
@@ -23,7 +23,7 @@ export { formatToolDuration, toolCallView, toolKindSigils, toolLiveLines, toolSt
|
|
|
23
23
|
export { assistantMessageVisible } from "./core/assistant-visibility.js";
|
|
24
24
|
export { disclosureOpen, initialToolDisclosure, toggleAllDisclosure, toggleDisclosure, toolCallDefaultOpen, toolGroupDefaultOpen, visibleToolCalls, } from "./core/tool-groups.js";
|
|
25
25
|
export { useClientActions } from "./client-contributions.js";
|
|
26
|
-
export { awaitingQueue, awaitingTakeover, decisionView, decisionViewText, initialDecisionState, reduceDecision, } from "./core/awaiting-answer.js";
|
|
26
|
+
export { awaitingQueue, awaitingTakeover, decisionView, decisionViewText, initialDecisionState, reduceDecision, DecisionDraft, } from "./core/awaiting-answer.js";
|
|
27
27
|
export { useDecision } from "./use-decision.js";
|
|
28
28
|
export { useApprovalAwaiting } from "./use-approval-awaiting.js";
|
|
29
29
|
export { approvalCardCopy, approvalRefusal, askApproval, } from "./core/approval-decision.js";
|
package/dist/parakeet.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/styles.css
CHANGED
|
@@ -6599,6 +6599,9 @@
|
|
|
6599
6599
|
.resize {
|
|
6600
6600
|
resize: both;
|
|
6601
6601
|
}
|
|
6602
|
+
.list-none {
|
|
6603
|
+
list-style-type: none;
|
|
6604
|
+
}
|
|
6602
6605
|
.grid-cols-2 {
|
|
6603
6606
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
6604
6607
|
}
|
|
@@ -7859,6 +7862,11 @@
|
|
|
7859
7862
|
height: calc(var(--spacing) * 7);
|
|
7860
7863
|
}
|
|
7861
7864
|
}
|
|
7865
|
+
.\[\&\:\:-webkit-details-marker\]\:hidden {
|
|
7866
|
+
&::-webkit-details-marker {
|
|
7867
|
+
display: none;
|
|
7868
|
+
}
|
|
7869
|
+
}
|
|
7862
7870
|
.\[\&\>\*\]\:join-item {
|
|
7863
7871
|
&>* {
|
|
7864
7872
|
@layer daisyui.l1.l2.l3.l4 {
|
|
@@ -14599,7 +14607,8 @@
|
|
|
14599
14607
|
position: relative;
|
|
14600
14608
|
display: inline-grid;
|
|
14601
14609
|
justify-self: start;
|
|
14602
|
-
|
|
14610
|
+
--caps-code-slot: calc(var(--size-field, 0.25rem) * 10);
|
|
14611
|
+
width: min( 100%, calc( var(--caps-code-length) * var(--caps-code-slot) + (var(--caps-code-length) - 1) * var(--spacing-xs) ) );
|
|
14603
14612
|
}
|
|
14604
14613
|
.caps-code-field {
|
|
14605
14614
|
position: absolute;
|
|
@@ -14617,13 +14626,13 @@
|
|
|
14617
14626
|
}
|
|
14618
14627
|
.caps-code-slots {
|
|
14619
14628
|
display: grid;
|
|
14620
|
-
grid-
|
|
14621
|
-
grid-auto-flow: column;
|
|
14629
|
+
grid-template-columns: repeat(var(--caps-code-length), minmax(0, 1fr));
|
|
14622
14630
|
gap: var(--spacing-xs);
|
|
14623
14631
|
}
|
|
14624
14632
|
.caps-code-slot {
|
|
14625
14633
|
position: relative;
|
|
14626
|
-
width:
|
|
14634
|
+
width: 100%;
|
|
14635
|
+
min-width: 0;
|
|
14627
14636
|
justify-content: center;
|
|
14628
14637
|
padding-inline: 0;
|
|
14629
14638
|
font-family: var(--font-numeric, var(--font-mono));
|
|
@@ -19630,6 +19639,25 @@
|
|
|
19630
19639
|
max-width: none;
|
|
19631
19640
|
}
|
|
19632
19641
|
}
|
|
19642
|
+
@container (max-width: 16rem) {
|
|
19643
|
+
.parakeet-composer-row:has(.composer-settings-chip) .parakeet-composer-model-key {
|
|
19644
|
+
--caps-keycap-justify: center;
|
|
19645
|
+
--caps-keycap-padding: var(--spacing-xs);
|
|
19646
|
+
flex: none;
|
|
19647
|
+
width: var(--caps-status-tray-key-height);
|
|
19648
|
+
min-width: var(--caps-status-tray-key-height);
|
|
19649
|
+
}
|
|
19650
|
+
.parakeet-composer-row:has(.composer-settings-chip) .parakeet-composer-model-key .caps-keycap-button-label, .parakeet-composer-row .composer-settings-label {
|
|
19651
|
+
display: none;
|
|
19652
|
+
}
|
|
19653
|
+
}
|
|
19654
|
+
@media (pointer: coarse) {
|
|
19655
|
+
@container (max-width: 16rem) {
|
|
19656
|
+
.parakeet-composer-row:has(.composer-settings-chip) .parakeet-composer-model-key {
|
|
19657
|
+
display: none;
|
|
19658
|
+
}
|
|
19659
|
+
}
|
|
19660
|
+
}
|
|
19633
19661
|
.boot-curtain {
|
|
19634
19662
|
position: fixed;
|
|
19635
19663
|
inset: 0;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createWhistleInteractionHost } from "@fungi.computer/whistle/interaction";
|
|
2
2
|
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
3
3
|
import { askApproval } from "./core/approval-decision.js";
|
|
4
|
+
import { DecisionDraft } from "./core/awaiting-answer.js";
|
|
4
5
|
const noApproval = () => undefined;
|
|
5
6
|
const noSubscription = () => () => undefined;
|
|
6
7
|
/**
|
|
@@ -31,11 +32,17 @@ export function useApprovalAwaiting(options) {
|
|
|
31
32
|
view.record.revision,
|
|
32
33
|
view.canAnswer,
|
|
33
34
|
]);
|
|
35
|
+
// One record owns its draft through a temporary loss of capability metadata.
|
|
36
|
+
// A different record or revision starts a new choice; rights stay live in source.
|
|
37
|
+
const draft = useRef();
|
|
38
|
+
if (key !== undefined && draft.current?.key !== key)
|
|
39
|
+
draft.current = { key, memory: new DecisionDraft() };
|
|
34
40
|
useEffect(() => {
|
|
35
41
|
const view = shown.current;
|
|
36
42
|
if (!enabled || source === undefined || view === undefined)
|
|
37
43
|
return;
|
|
38
|
-
|
|
44
|
+
const retained = draft.current;
|
|
45
|
+
if (!view.canAnswer || key === undefined || retained?.key !== key)
|
|
39
46
|
return;
|
|
40
47
|
const { home, width, noteLimit } = layout.current;
|
|
41
48
|
const host = createWhistleInteractionHost({ title: "Approval" });
|
|
@@ -52,6 +59,7 @@ export function useApprovalAwaiting(options) {
|
|
|
52
59
|
kind: "approval",
|
|
53
60
|
arrivedAt: Date.now(),
|
|
54
61
|
host,
|
|
62
|
+
draft: retained.memory,
|
|
55
63
|
});
|
|
56
64
|
void askApproval(session.interaction, {
|
|
57
65
|
view,
|
package/dist/use-decision.js
CHANGED
|
@@ -22,20 +22,36 @@ export function useDecision(item, context) {
|
|
|
22
22
|
const { host } = item;
|
|
23
23
|
const snapshot = useSyncExternalStore(host.subscribe, host.snapshot);
|
|
24
24
|
const shown = useRef();
|
|
25
|
+
if (shown.current?.host !== host)
|
|
26
|
+
shown.current = undefined;
|
|
25
27
|
const pending = snapshot.prompt;
|
|
26
28
|
if (pending?.request.type === "decision")
|
|
27
|
-
shown.current = {
|
|
29
|
+
shown.current = {
|
|
30
|
+
host,
|
|
31
|
+
sequence: pending.sequence,
|
|
32
|
+
prompt: pending.request,
|
|
33
|
+
};
|
|
28
34
|
const [, setHeld] = useState();
|
|
29
35
|
// Several keys can arrive before React renders; each must see the last one.
|
|
30
36
|
const latest = useRef();
|
|
31
37
|
const prompt = shown.current;
|
|
32
|
-
const held = () =>
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
const held = () => {
|
|
39
|
+
if (prompt === undefined)
|
|
40
|
+
return initialDecisionState();
|
|
41
|
+
if (latest.current?.host !== host ||
|
|
42
|
+
latest.current.sequence !== prompt.sequence) {
|
|
43
|
+
const state = latest.current?.host === host
|
|
44
|
+
? initialDecisionState()
|
|
45
|
+
: (item.draft?.restore(prompt.prompt) ?? initialDecisionState());
|
|
46
|
+
latest.current = { host, sequence: prompt.sequence, state };
|
|
47
|
+
}
|
|
48
|
+
return latest.current.state;
|
|
49
|
+
};
|
|
35
50
|
const remember = (next) => {
|
|
36
51
|
if (prompt === undefined)
|
|
37
52
|
return;
|
|
38
|
-
latest.current = { sequence: prompt.sequence, state: next };
|
|
53
|
+
latest.current = { host, sequence: prompt.sequence, state: next };
|
|
54
|
+
item.draft?.remember(next, prompt.prompt);
|
|
39
55
|
setHeld(latest.current);
|
|
40
56
|
};
|
|
41
57
|
return {
|
package/docs/api/headless.md
CHANGED
|
@@ -8,6 +8,65 @@
|
|
|
8
8
|
|
|
9
9
|
# headless
|
|
10
10
|
|
|
11
|
+
## Classes
|
|
12
|
+
|
|
13
|
+
### DecisionDraft
|
|
14
|
+
|
|
15
|
+
One pending choice, retaining no display metadata or answering authority.
|
|
16
|
+
|
|
17
|
+
#### Constructors
|
|
18
|
+
|
|
19
|
+
##### Constructor
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
new DecisionDraft(): DecisionDraft;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Start without a remembered choice.
|
|
26
|
+
|
|
27
|
+
###### Returns
|
|
28
|
+
|
|
29
|
+
[`DecisionDraft`](#decisiondraft)
|
|
30
|
+
|
|
31
|
+
#### Methods
|
|
32
|
+
|
|
33
|
+
##### remember()
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
remember(state, prompt): void;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Remember option values, which policy rows may move, and unfinished text.
|
|
40
|
+
|
|
41
|
+
###### Parameters
|
|
42
|
+
|
|
43
|
+
| Parameter | Type |
|
|
44
|
+
| --------- | --------------------------------- |
|
|
45
|
+
| `state` | [`DecisionState`](#decisionstate) |
|
|
46
|
+
| `prompt` | `object` & `object` |
|
|
47
|
+
|
|
48
|
+
###### Returns
|
|
49
|
+
|
|
50
|
+
`void`
|
|
51
|
+
|
|
52
|
+
##### restore()
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
restore(prompt): DecisionState;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Redraw a compatible choice without replaying any submitted answer.
|
|
59
|
+
|
|
60
|
+
###### Parameters
|
|
61
|
+
|
|
62
|
+
| Parameter | Type |
|
|
63
|
+
| --------- | ------------------- |
|
|
64
|
+
| `prompt` | `object` & `object` |
|
|
65
|
+
|
|
66
|
+
###### Returns
|
|
67
|
+
|
|
68
|
+
[`DecisionState`](#decisionstate)
|
|
69
|
+
|
|
11
70
|
## Type Aliases
|
|
12
71
|
|
|
13
72
|
### LoginMethodKind
|
|
@@ -699,6 +758,7 @@ type AwaitingItem = Readonly<{
|
|
|
699
758
|
kind: AwaitingKind;
|
|
700
759
|
arrivedAt: number;
|
|
701
760
|
host: WhistleInteractionHost;
|
|
761
|
+
draft?: DecisionDraft;
|
|
702
762
|
}>;
|
|
703
763
|
```
|
|
704
764
|
|
|
@@ -1361,11 +1421,11 @@ Ordinary advertised actions over the current admitted rows and observation.
|
|
|
1361
1421
|
|
|
1362
1422
|
#### Returns
|
|
1363
1423
|
|
|
1364
|
-
| Name | Type
|
|
1365
|
-
| ----------- |
|
|
1366
|
-
| `state` | `ReadonlyMap`\<\{ `id`: `string`; `label`: `string`; `input?`: \{ \[`key`: `string`\]: `Json`; \}; `awaiting?`: `"question"`; \}, `Readonly`\<\{ `pending`: `boolean`;
|
|
1367
|
-
| `enabled` | `boolean`
|
|
1368
|
-
| `execute()` | (`entryId`, `action`, `waiting`) => `Promise`\<`void`\>
|
|
1424
|
+
| Name | Type | Description |
|
|
1425
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
1426
|
+
| `state` | `ReadonlyMap`\<\{ `id`: `string`; `label`: `string`; `input?`: \{ \[`key`: `string`\]: `Json`; \}; `awaiting?`: `"question"`; \}, `Readonly`\<\{ `pending`: `boolean`; \}\>\> | Current Session-owned state of admitted action intents. |
|
|
1427
|
+
| `enabled` | `boolean` | Observation is live and this Session's action owner is attached. |
|
|
1428
|
+
| `execute()` | (`entryId`, `action`, `waiting`) => `Promise`\<`void`\> | Execute an admitted intent through its owning advertised command. |
|
|
1369
1429
|
|
|
1370
1430
|
---
|
|
1371
1431
|
|
|
@@ -1952,10 +2012,10 @@ leaves the composer but stays counted: it is the footer row.
|
|
|
1952
2012
|
|
|
1953
2013
|
#### Parameters
|
|
1954
2014
|
|
|
1955
|
-
| Parameter | Type
|
|
1956
|
-
| --------- |
|
|
1957
|
-
| `items` | readonly `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; \}\>[] |
|
|
1958
|
-
| `later` | `ReadonlySet`\<`string`\>
|
|
2015
|
+
| Parameter | Type |
|
|
2016
|
+
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2017
|
+
| `items` | readonly `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; `draft?`: [`DecisionDraft`](#decisiondraft); \}\>[] |
|
|
2018
|
+
| `later` | `ReadonlySet`\<`string`\> |
|
|
1959
2019
|
|
|
1960
2020
|
#### Returns
|
|
1961
2021
|
|
|
@@ -1975,6 +2035,7 @@ function awaitingTakeover(
|
|
|
1975
2035
|
kind: AwaitingKind;
|
|
1976
2036
|
arrivedAt: number;
|
|
1977
2037
|
host: WhistleInteractionHost;
|
|
2038
|
+
draft?: DecisionDraft;
|
|
1978
2039
|
}>
|
|
1979
2040
|
| undefined;
|
|
1980
2041
|
```
|
|
@@ -1984,15 +2045,16 @@ with text is never, unless the person asked for the decision.
|
|
|
1984
2045
|
|
|
1985
2046
|
#### Parameters
|
|
1986
2047
|
|
|
1987
|
-
| Parameter | Type
|
|
1988
|
-
| ---------- |
|
|
1989
|
-
| `awaiting` | `Readonly`\<\{ `items`: readonly `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; \}\>[]; `current?`: `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; \}\>; `position`: `number`; `total`: `number`; \}\> & `Readonly`\<\{ `forced`: `boolean`; \}\> |
|
|
1990
|
-
| `draft` | `string`
|
|
2048
|
+
| Parameter | Type |
|
|
2049
|
+
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2050
|
+
| `awaiting` | `Readonly`\<\{ `items`: readonly `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; `draft?`: [`DecisionDraft`](#decisiondraft); \}\>[]; `current?`: `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind); `arrivedAt`: `number`; `host`: `WhistleInteractionHost`; `draft?`: [`DecisionDraft`](#decisiondraft); \}\>; `position`: `number`; `total`: `number`; \}\> & `Readonly`\<\{ `forced`: `boolean`; \}\> |
|
|
2051
|
+
| `draft` | `string` |
|
|
1991
2052
|
|
|
1992
2053
|
#### Returns
|
|
1993
2054
|
|
|
1994
2055
|
\| `Readonly`\<\{ `key`: `string`; `kind`: [`AwaitingKind`](#awaitingkind);
|
|
1995
|
-
`arrivedAt`: `number`; `host`: `WhistleInteractionHost`;
|
|
2056
|
+
`arrivedAt`: `number`; `host`: `WhistleInteractionHost`; `draft?`:
|
|
2057
|
+
[`DecisionDraft`](#decisiondraft); \}\> \| `undefined`
|
|
1996
2058
|
|
|
1997
2059
|
---
|
|
1998
2060
|
|
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.
|
|
3
|
+
"version": "0.17.3",
|
|
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.
|
|
71
|
+
"@fungi.computer/agar": "0.28.0",
|
|
72
72
|
"@fungi.computer/bird-dog": "0.3.8",
|
|
73
73
|
"@fungi.computer/cairn": "0.1.0",
|
|
74
|
-
"@fungi.computer/caps": "0.
|
|
74
|
+
"@fungi.computer/caps": "0.13.0",
|
|
75
75
|
"@fungi.computer/gills": "0.4.0",
|
|
76
|
-
"@fungi.computer/knapsack": "0.4.
|
|
76
|
+
"@fungi.computer/knapsack": "0.4.27",
|
|
77
77
|
"@fungi.computer/mule": "0.3.0",
|
|
78
|
-
"@fungi.computer/shiitake": "0.22.
|
|
78
|
+
"@fungi.computer/shiitake": "0.22.5",
|
|
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",
|
package/src/composer-shell.css
CHANGED
|
@@ -132,3 +132,34 @@
|
|
|
132
132
|
max-width: none;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
/* A split phone pane has room for the model menu key, not a partial name.
|
|
137
|
+
Keep its accessible model label and the ordinary picker action. */
|
|
138
|
+
@container (max-width: 16rem) {
|
|
139
|
+
.parakeet-composer-row:has(.composer-settings-chip)
|
|
140
|
+
.parakeet-composer-model-key {
|
|
141
|
+
--caps-keycap-justify: center;
|
|
142
|
+
--caps-keycap-padding: var(--spacing-xs);
|
|
143
|
+
flex: none;
|
|
144
|
+
width: var(--caps-status-tray-key-height);
|
|
145
|
+
min-width: var(--caps-status-tray-key-height);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.parakeet-composer-row:has(.composer-settings-chip)
|
|
149
|
+
.parakeet-composer-model-key
|
|
150
|
+
.caps-keycap-button-label,
|
|
151
|
+
.parakeet-composer-row .composer-settings-label {
|
|
152
|
+
display: none;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* Touch keys need more room in a phone's beside pane. Settings already
|
|
157
|
+
contains the same model picker, so keep that route instead of a fourth key. */
|
|
158
|
+
@media (pointer: coarse) {
|
|
159
|
+
@container (max-width: 16rem) {
|
|
160
|
+
.parakeet-composer-row:has(.composer-settings-chip)
|
|
161
|
+
.parakeet-composer-model-key {
|
|
162
|
+
display: none;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|