@teaflask/assistant 0.11.1 → 0.11.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.
|
@@ -18,6 +18,7 @@ import { useCell } from "./use-store-cell.js";
|
|
|
18
18
|
const NO_POLICY = new ObservableCell(null);
|
|
19
19
|
const NO_GATE_CELL = new ObservableCell(NO_GATE);
|
|
20
20
|
const COMPOSER_MAX_HEIGHT_PX = 200;
|
|
21
|
+
const WELCOME_ROOM_SHARE = 0.5;
|
|
21
22
|
export function Composer({ compact = false, surface = "page", }) {
|
|
22
23
|
const { busy, pendingSend, sendMessage, composerRefocusPending, markComposerRefocusHandled, stopping, stopTurn, composerInput, setDraft, setAttachments, addFiles, noteComposerFocus, takeComposerCaretReturn, } = useConversation();
|
|
23
24
|
const { draft, attachments } = useCell(composerInput);
|
|
@@ -41,6 +42,7 @@ export function Composer({ compact = false, surface = "page", }) {
|
|
|
41
42
|
});
|
|
42
43
|
const { textareaRef, onTextareaFocus, onTextareaBlur } = useComposerFocus({
|
|
43
44
|
surface,
|
|
45
|
+
compact,
|
|
44
46
|
draft,
|
|
45
47
|
busy,
|
|
46
48
|
composerRefocusPending,
|
|
@@ -110,7 +112,7 @@ function useComposerAttachments({ session, policy, addFiles, setAttachments, })
|
|
|
110
112
|
const attachmentRoom = policy === null ? 0 : attachmentRoomOf(policy);
|
|
111
113
|
return { attachmentRoom, addFiles: pickFiles, removeAttachment };
|
|
112
114
|
}
|
|
113
|
-
function useComposerFocus({ surface, draft, busy, composerRefocusPending, markComposerRefocusHandled, noteComposerFocus, takeComposerCaretReturn, }) {
|
|
115
|
+
function useComposerFocus({ surface, compact, draft, busy, composerRefocusPending, markComposerRefocusHandled, noteComposerFocus, takeComposerCaretReturn, }) {
|
|
114
116
|
const textareaRef = useRef(null);
|
|
115
117
|
const ownsFocusRef = useRef(false);
|
|
116
118
|
useEffect(() => {
|
|
@@ -137,16 +139,23 @@ function useComposerFocus({ surface, draft, busy, composerRefocusPending, markCo
|
|
|
137
139
|
}
|
|
138
140
|
}, [takeComposerCaretReturn, surface]);
|
|
139
141
|
useLayoutEffect(() => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
_fitTheBoxToItsDraft(textareaRef.current, compact);
|
|
143
|
+
}, [draft, compact]);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
const room = compact
|
|
146
|
+
? (textareaRef.current?.closest("[data-tf-welcome-room]") ?? null)
|
|
147
|
+
: null;
|
|
148
|
+
if (room === null || typeof ResizeObserver === "undefined") {
|
|
146
149
|
return;
|
|
147
150
|
}
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
const observer = new ResizeObserver(() => {
|
|
152
|
+
_fitTheBoxToItsDraft(textareaRef.current, compact);
|
|
153
|
+
});
|
|
154
|
+
observer.observe(room);
|
|
155
|
+
return () => {
|
|
156
|
+
observer.disconnect();
|
|
157
|
+
};
|
|
158
|
+
}, [compact]);
|
|
150
159
|
return {
|
|
151
160
|
textareaRef,
|
|
152
161
|
onTextareaFocus: () => {
|
|
@@ -187,6 +196,22 @@ function ComposerControlsRow({ attachments, policy, busy, pendingSend, stopping,
|
|
|
187
196
|
void send.submitDraft();
|
|
188
197
|
}, disabled: send.sendDisabled, "aria-label": send.sending ? "Sending message" : "Send message", children: _jsx(ArrowUpIcon, {}) }))] })] }));
|
|
189
198
|
}
|
|
199
|
+
function _fitTheBoxToItsDraft(textarea, compact) {
|
|
200
|
+
if (textarea === null) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
textarea.style.height = "auto";
|
|
204
|
+
if (textarea.scrollHeight === 0) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
textarea.style.height = `${String(Math.min(textarea.scrollHeight, _heightCapOf(textarea, compact)))}px`;
|
|
208
|
+
}
|
|
209
|
+
function _heightCapOf(textarea, compact) {
|
|
210
|
+
const room = compact ? textarea.closest("[data-tf-welcome-room]") : null;
|
|
211
|
+
return room === null
|
|
212
|
+
? COMPOSER_MAX_HEIGHT_PX
|
|
213
|
+
: Math.max(COMPOSER_MAX_HEIGHT_PX, room.clientHeight * WELCOME_ROOM_SHARE);
|
|
214
|
+
}
|
|
190
215
|
function _focusWasDroppedByTheRemount(textarea) {
|
|
191
216
|
const active = document.activeElement;
|
|
192
217
|
return (active === null ||
|
|
@@ -39,7 +39,7 @@ function EmptyConversation({ surface, suggestions, welcomeTitle = "Where should
|
|
|
39
39
|
if (surface === "companion") {
|
|
40
40
|
return (_jsx(CompanionWelcome, { suggestions: suggestions, welcomeTitle: welcomeTitle, welcomeMark: welcomeMark, pendingRows: pendingRows }));
|
|
41
41
|
}
|
|
42
|
-
return (_jsx("div", { className: "tf:flex tf:min-h-0 tf:flex-1 tf:flex-col " +
|
|
42
|
+
return (_jsx("div", { "data-tf-welcome-room": "", className: "tf:flex tf:min-h-0 tf:flex-1 tf:flex-col " +
|
|
43
43
|
(pendingEcho === null ? "tf:overflow-y-auto" : ""), children: _jsxs("div", { className: pendingEcho === null
|
|
44
44
|
? "tf:my-auto tf:flex tf:w-full tf:flex-col tf:pt-4 tf:pb-16"
|
|
45
45
|
: "tf:contents", children: [pendingEcho !== null ? (_jsx(SurfaceBoundary, { surface: "message-list", children: _jsx(MessageList, { rows: pendingRows, cards: [], live: true }) })) : (_jsxs("div", { "data-tf-welcome": "", className: "tf:flex tf:items-center tf:justify-center tf:gap-2 tf:px-6 tf:pb-5 tf:text-center", children: [_jsx("span", { "data-tf-host-view": "", className: "tf:contents", children: welcomeMark }), _jsx("h2", { className: "tf:text-3xl tf:font-semibold tf:tracking-[-0.04em] tf:text-balance", children: welcomeTitle })] })), _jsx(SurfaceBoundary, { surface: "composer", children: _jsx(Composer, { compact: pendingEcho === null, surface: surface }) }), pendingEcho === null &&
|
|
@@ -57,6 +57,12 @@ export declare const ApiErrorCode: {
|
|
|
57
57
|
readonly AGENT_DEFINITION_REVISION_NOT_PUBLISHABLE: "AGENT_DEFINITION_REVISION_NOT_PUBLISHABLE";
|
|
58
58
|
readonly SLACK_AGENTS_UNAVAILABLE: "SLACK_AGENTS_UNAVAILABLE";
|
|
59
59
|
readonly OPENROUTER_MODELS_UNAVAILABLE: "OPENROUTER_MODELS_UNAVAILABLE";
|
|
60
|
+
readonly EVAL_TESTS_UNAVAILABLE: "EVAL_TESTS_UNAVAILABLE";
|
|
61
|
+
readonly EVAL_CONVERSATION_NOT_ELIGIBLE: "EVAL_CONVERSATION_NOT_ELIGIBLE";
|
|
62
|
+
readonly EVAL_CONVERSATION_IN_PROGRESS: "EVAL_CONVERSATION_IN_PROGRESS";
|
|
63
|
+
readonly EVAL_CASE_BUSY: "EVAL_CASE_BUSY";
|
|
64
|
+
readonly EVAL_CASE_STALE: "EVAL_CASE_STALE";
|
|
65
|
+
readonly EVAL_CASE_EDIT_INVALID: "EVAL_CASE_EDIT_INVALID";
|
|
60
66
|
readonly SKILL_INVALID: "SKILL_INVALID";
|
|
61
67
|
readonly SKILL_SLUG_TAKEN: "SKILL_SLUG_TAKEN";
|
|
62
68
|
readonly SKILL_REVISION_NOT_PUBLISHABLE: "SKILL_REVISION_NOT_PUBLISHABLE";
|
|
@@ -175,7 +181,6 @@ export declare const ApiErrorCode: {
|
|
|
175
181
|
readonly STEEP_KEY_INVALID: "STEEP_KEY_INVALID";
|
|
176
182
|
readonly STEEP_TOKEN_EXPIRED: "STEEP_TOKEN_EXPIRED";
|
|
177
183
|
readonly STEEP_DISABLED: "STEEP_DISABLED";
|
|
178
|
-
readonly STEEP_LEARNING_DISABLED: "STEEP_LEARNING_DISABLED";
|
|
179
184
|
readonly STEEP_LEARNING_OFF: "STEEP_LEARNING_OFF";
|
|
180
185
|
readonly STEEP_LEARNING_RUN_IN_PROGRESS: "STEEP_LEARNING_RUN_IN_PROGRESS";
|
|
181
186
|
readonly STEEP_BATCH_INVALID: "STEEP_BATCH_INVALID";
|
|
@@ -56,6 +56,12 @@ export const ApiErrorCode = {
|
|
|
56
56
|
AGENT_DEFINITION_REVISION_NOT_PUBLISHABLE: "AGENT_DEFINITION_REVISION_NOT_PUBLISHABLE",
|
|
57
57
|
SLACK_AGENTS_UNAVAILABLE: "SLACK_AGENTS_UNAVAILABLE",
|
|
58
58
|
OPENROUTER_MODELS_UNAVAILABLE: "OPENROUTER_MODELS_UNAVAILABLE",
|
|
59
|
+
EVAL_TESTS_UNAVAILABLE: "EVAL_TESTS_UNAVAILABLE",
|
|
60
|
+
EVAL_CONVERSATION_NOT_ELIGIBLE: "EVAL_CONVERSATION_NOT_ELIGIBLE",
|
|
61
|
+
EVAL_CONVERSATION_IN_PROGRESS: "EVAL_CONVERSATION_IN_PROGRESS",
|
|
62
|
+
EVAL_CASE_BUSY: "EVAL_CASE_BUSY",
|
|
63
|
+
EVAL_CASE_STALE: "EVAL_CASE_STALE",
|
|
64
|
+
EVAL_CASE_EDIT_INVALID: "EVAL_CASE_EDIT_INVALID",
|
|
59
65
|
SKILL_INVALID: "SKILL_INVALID",
|
|
60
66
|
SKILL_SLUG_TAKEN: "SKILL_SLUG_TAKEN",
|
|
61
67
|
SKILL_REVISION_NOT_PUBLISHABLE: "SKILL_REVISION_NOT_PUBLISHABLE",
|
|
@@ -174,7 +180,6 @@ export const ApiErrorCode = {
|
|
|
174
180
|
STEEP_KEY_INVALID: "STEEP_KEY_INVALID",
|
|
175
181
|
STEEP_TOKEN_EXPIRED: "STEEP_TOKEN_EXPIRED",
|
|
176
182
|
STEEP_DISABLED: "STEEP_DISABLED",
|
|
177
|
-
STEEP_LEARNING_DISABLED: "STEEP_LEARNING_DISABLED",
|
|
178
183
|
STEEP_LEARNING_OFF: "STEEP_LEARNING_OFF",
|
|
179
184
|
STEEP_LEARNING_RUN_IN_PROGRESS: "STEEP_LEARNING_RUN_IN_PROGRESS",
|
|
180
185
|
STEEP_BATCH_INVALID: "STEEP_BATCH_INVALID",
|
package/package.json
CHANGED