@teaflask/assistant 0.11.2 → 0.11.4

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
- const textarea = textareaRef.current;
141
- if (textarea === null) {
142
- return;
143
- }
144
- textarea.style.height = "auto";
145
- if (textarea.scrollHeight === 0) {
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
- textarea.style.height = `${String(Math.min(textarea.scrollHeight, COMPOSER_MAX_HEIGHT_PX))}px`;
149
- }, [draft]);
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 &&
@@ -63,6 +63,17 @@ export declare const ApiErrorCode: {
63
63
  readonly EVAL_CASE_BUSY: "EVAL_CASE_BUSY";
64
64
  readonly EVAL_CASE_STALE: "EVAL_CASE_STALE";
65
65
  readonly EVAL_CASE_EDIT_INVALID: "EVAL_CASE_EDIT_INVALID";
66
+ readonly EVAL_CASE_NOT_CHECKABLE: "EVAL_CASE_NOT_CHECKABLE";
67
+ readonly EVAL_RUN_NOTHING_TO_RUN: "EVAL_RUN_NOTHING_TO_RUN";
68
+ readonly EVAL_RUN_REVISION_NOT_OF_AGENT: "EVAL_RUN_REVISION_NOT_OF_AGENT";
69
+ readonly EVAL_RUN_REVISION_CANNOT_RUN: "EVAL_RUN_REVISION_CANNOT_RUN";
70
+ readonly EVAL_RUN_SAME_REVISION: "EVAL_RUN_SAME_REVISION";
71
+ readonly EVAL_RUN_NO_JUDGE: "EVAL_RUN_NO_JUDGE";
72
+ readonly EVAL_RUN_ESTIMATE_STALE: "EVAL_RUN_ESTIMATE_STALE";
73
+ readonly EVAL_RUN_UNFUNDED: "EVAL_RUN_UNFUNDED";
74
+ readonly EVAL_RUN_OVER_MONTHLY_CAP: "EVAL_RUN_OVER_MONTHLY_CAP";
75
+ readonly EVAL_RUN_SETTLED: "EVAL_RUN_SETTLED";
76
+ readonly EVAL_AGENT_TRASHED: "EVAL_AGENT_TRASHED";
66
77
  readonly SKILL_INVALID: "SKILL_INVALID";
67
78
  readonly SKILL_SLUG_TAKEN: "SKILL_SLUG_TAKEN";
68
79
  readonly SKILL_REVISION_NOT_PUBLISHABLE: "SKILL_REVISION_NOT_PUBLISHABLE";
@@ -181,7 +192,6 @@ export declare const ApiErrorCode: {
181
192
  readonly STEEP_KEY_INVALID: "STEEP_KEY_INVALID";
182
193
  readonly STEEP_TOKEN_EXPIRED: "STEEP_TOKEN_EXPIRED";
183
194
  readonly STEEP_DISABLED: "STEEP_DISABLED";
184
- readonly STEEP_LEARNING_DISABLED: "STEEP_LEARNING_DISABLED";
185
195
  readonly STEEP_LEARNING_OFF: "STEEP_LEARNING_OFF";
186
196
  readonly STEEP_LEARNING_RUN_IN_PROGRESS: "STEEP_LEARNING_RUN_IN_PROGRESS";
187
197
  readonly STEEP_BATCH_INVALID: "STEEP_BATCH_INVALID";
@@ -62,6 +62,17 @@ export const ApiErrorCode = {
62
62
  EVAL_CASE_BUSY: "EVAL_CASE_BUSY",
63
63
  EVAL_CASE_STALE: "EVAL_CASE_STALE",
64
64
  EVAL_CASE_EDIT_INVALID: "EVAL_CASE_EDIT_INVALID",
65
+ EVAL_CASE_NOT_CHECKABLE: "EVAL_CASE_NOT_CHECKABLE",
66
+ EVAL_RUN_NOTHING_TO_RUN: "EVAL_RUN_NOTHING_TO_RUN",
67
+ EVAL_RUN_REVISION_NOT_OF_AGENT: "EVAL_RUN_REVISION_NOT_OF_AGENT",
68
+ EVAL_RUN_REVISION_CANNOT_RUN: "EVAL_RUN_REVISION_CANNOT_RUN",
69
+ EVAL_RUN_SAME_REVISION: "EVAL_RUN_SAME_REVISION",
70
+ EVAL_RUN_NO_JUDGE: "EVAL_RUN_NO_JUDGE",
71
+ EVAL_RUN_ESTIMATE_STALE: "EVAL_RUN_ESTIMATE_STALE",
72
+ EVAL_RUN_UNFUNDED: "EVAL_RUN_UNFUNDED",
73
+ EVAL_RUN_OVER_MONTHLY_CAP: "EVAL_RUN_OVER_MONTHLY_CAP",
74
+ EVAL_RUN_SETTLED: "EVAL_RUN_SETTLED",
75
+ EVAL_AGENT_TRASHED: "EVAL_AGENT_TRASHED",
65
76
  SKILL_INVALID: "SKILL_INVALID",
66
77
  SKILL_SLUG_TAKEN: "SKILL_SLUG_TAKEN",
67
78
  SKILL_REVISION_NOT_PUBLISHABLE: "SKILL_REVISION_NOT_PUBLISHABLE",
@@ -180,7 +191,6 @@ export const ApiErrorCode = {
180
191
  STEEP_KEY_INVALID: "STEEP_KEY_INVALID",
181
192
  STEEP_TOKEN_EXPIRED: "STEEP_TOKEN_EXPIRED",
182
193
  STEEP_DISABLED: "STEEP_DISABLED",
183
- STEEP_LEARNING_DISABLED: "STEEP_LEARNING_DISABLED",
184
194
  STEEP_LEARNING_OFF: "STEEP_LEARNING_OFF",
185
195
  STEEP_LEARNING_RUN_IN_PROGRESS: "STEEP_LEARNING_RUN_IN_PROGRESS",
186
196
  STEEP_BATCH_INVALID: "STEEP_BATCH_INVALID",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teaflask/assistant",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "The AI assistant for your product: drop it into your React app or any page with a script tag.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "author": "Teaflask",