@assistant-ui/react 0.11.46 → 0.11.47

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.
Files changed (89) hide show
  1. package/dist/augmentations.d.ts.map +1 -1
  2. package/dist/client/ThreadMessageClient.js +2 -2
  3. package/dist/client/ThreadMessageClient.js.map +1 -1
  4. package/dist/client/types/ModelContext.d.ts.map +1 -1
  5. package/dist/context/react/AssistantApiContext.d.ts.map +1 -1
  6. package/dist/context/react/AssistantApiContext.js.map +1 -1
  7. package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -1
  8. package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -1
  9. package/dist/context/react/utils/ensureBinding.js.map +1 -1
  10. package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +3 -3
  11. package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
  12. package/dist/legacy-runtime/AssistantRuntimeProvider.js +3 -6
  13. package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
  14. package/dist/legacy-runtime/client/MessagePartRuntimeClient.js +1 -1
  15. package/dist/legacy-runtime/client/MessagePartRuntimeClient.js.map +1 -1
  16. package/dist/legacy-runtime/client/MessageRuntimeClient.js +1 -1
  17. package/dist/legacy-runtime/client/MessageRuntimeClient.js.map +1 -1
  18. package/dist/legacy-runtime/cloud/auiV0.js +1 -1
  19. package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
  20. package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts.map +1 -1
  21. package/dist/legacy-runtime/runtime/AssistantRuntime.js.map +1 -1
  22. package/dist/legacy-runtime/runtime/ComposerRuntime.js +2 -2
  23. package/dist/legacy-runtime/runtime/ComposerRuntime.js.map +1 -1
  24. package/dist/legacy-runtime/runtime/MessageRuntime.js +3 -3
  25. package/dist/legacy-runtime/runtime/MessageRuntime.js.map +1 -1
  26. package/dist/legacy-runtime/runtime/ThreadListRuntime.js +1 -1
  27. package/dist/legacy-runtime/runtime/ThreadListRuntime.js.map +1 -1
  28. package/dist/legacy-runtime/runtime/ThreadRuntime.js +2 -2
  29. package/dist/legacy-runtime/runtime/ThreadRuntime.js.map +1 -1
  30. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +1 -2
  31. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +1 -1
  32. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js.map +1 -1
  33. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.js +2 -2
  34. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
  35. package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts +1 -1
  36. package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts.map +1 -1
  37. package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts +1 -1
  38. package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts.map +1 -1
  39. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  40. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js +1 -1
  41. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js.map +1 -1
  42. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  43. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  44. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  45. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  46. package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
  47. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  48. package/dist/primitives/message/MessageError.js +1 -2
  49. package/dist/primitives/message/MessageError.js.map +1 -1
  50. package/dist/primitives/message/MessageParts.d.ts.map +1 -1
  51. package/dist/primitives/message/MessageParts.js.map +1 -1
  52. package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
  53. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  54. package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
  55. package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/utils/smooth/useSmooth.js +2 -2
  58. package/dist/utils/smooth/useSmooth.js.map +1 -1
  59. package/package.json +2 -5
  60. package/src/augmentations.ts +0 -2
  61. package/src/client/ThreadMessageClient.tsx +2 -2
  62. package/src/client/types/ModelContext.ts +0 -1
  63. package/src/context/react/AssistantApiContext.tsx +0 -2
  64. package/src/context/react/utils/createStateHookForRuntime.ts +0 -1
  65. package/src/context/react/utils/ensureBinding.ts +1 -1
  66. package/src/legacy-runtime/AssistantRuntimeProvider.tsx +5 -6
  67. package/src/legacy-runtime/client/MessagePartRuntimeClient.ts +1 -1
  68. package/src/legacy-runtime/client/MessageRuntimeClient.ts +1 -1
  69. package/src/legacy-runtime/cloud/auiV0.ts +1 -1
  70. package/src/legacy-runtime/runtime/AssistantRuntime.ts +3 -1
  71. package/src/legacy-runtime/runtime/ComposerRuntime.ts +2 -2
  72. package/src/legacy-runtime/runtime/MessageRuntime.ts +3 -3
  73. package/src/legacy-runtime/runtime/ThreadListRuntime.ts +1 -1
  74. package/src/legacy-runtime/runtime/ThreadRuntime.ts +2 -2
  75. package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +1 -1
  76. package/src/legacy-runtime/runtime-cores/adapters/attachment/CompositeAttachmentAdapter.ts +2 -2
  77. package/src/legacy-runtime/runtime-cores/adapters/feedback/index.ts +1 -1
  78. package/src/legacy-runtime/runtime-cores/adapters/suggestion/index.ts +1 -1
  79. package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.tsx +1 -1
  80. package/src/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.tsx +1 -1
  81. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +0 -2
  82. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +0 -2
  83. package/src/primitives/actionBar/ActionBarCopy.tsx +3 -1
  84. package/src/primitives/message/MessageError.tsx +1 -1
  85. package/src/primitives/message/MessageParts.tsx +0 -1
  86. package/src/primitives/message/MessagePartsGrouped.tsx +0 -1
  87. package/src/primitives/messagePart/useMessagePartData.tsx +1 -1
  88. package/src/types/index.ts +0 -1
  89. package/src/utils/smooth/useSmooth.tsx +2 -2
@@ -287,10 +287,8 @@ export function useAssistantApi(): AssistantApi;
287
287
  export function useAssistantApi(config: AssistantClientProps): AssistantApi;
288
288
  export function useAssistantApi(config?: AssistantClientProps): AssistantApi {
289
289
  if (config) {
290
- // eslint-disable-next-line react-hooks/rules-of-hooks
291
290
  return useExtendedAssistantApiImpl(config);
292
291
  } else {
293
- // eslint-disable-next-line react-hooks/rules-of-hooks
294
292
  return useAssistantApiImpl();
295
293
  }
296
294
  }
@@ -75,7 +75,6 @@ export function createStateHookForRuntime<TState>(
75
75
  if (!store) return null;
76
76
 
77
77
  // it is ok to call useRuntimeStateInternal conditionally because it will never become null if its available
78
- // eslint-disable-next-line react-hooks/rules-of-hooks
79
78
  return useRuntimeStateInternal(store, selector);
80
79
  }
81
80
 
@@ -24,7 +24,7 @@ const debugVerifyPrototype = (
24
24
 
25
25
  if (unboundMethods.length > 0) {
26
26
  throw new Error(
27
- "The following methods are not bound: " + JSON.stringify(unboundMethods),
27
+ `The following methods are not bound: ${JSON.stringify(unboundMethods)}`,
28
28
  );
29
29
  }
30
30
 
@@ -2,15 +2,15 @@
2
2
 
3
3
  import { FC, memo, PropsWithChildren } from "react";
4
4
  import {
5
- AssistantProvider,
6
5
  useAssistantApi,
6
+ AssistantProvider,
7
7
  } from "../context/react/AssistantApiContext";
8
8
  import { AssistantRuntime } from "./runtime/AssistantRuntime";
9
9
  import { AssistantRuntimeCore } from "./runtime-cores/core/AssistantRuntimeCore";
10
10
  import { RuntimeAdapter } from "./RuntimeAdapter";
11
11
  import { ThreadPrimitiveViewportProvider } from "../context/providers/ThreadViewportProvider";
12
12
 
13
- export namespace AssistantProvider {
13
+ export namespace AssistantRuntimeProvider {
14
14
  export type Props = PropsWithChildren<{
15
15
  /**
16
16
  * The runtime to provide to the rest of your app.
@@ -23,10 +23,9 @@ const getRenderComponent = (runtime: AssistantRuntime) => {
23
23
  return (runtime as { _core?: AssistantRuntimeCore })._core?.RenderComponent;
24
24
  };
25
25
 
26
- export const AssistantRuntimeProviderImpl: FC<AssistantProvider.Props> = ({
27
- children,
28
- runtime,
29
- }) => {
26
+ export const AssistantRuntimeProviderImpl: FC<
27
+ AssistantRuntimeProvider.Props
28
+ > = ({ children, runtime }) => {
30
29
  const api = useAssistantApi({
31
30
  threads: RuntimeAdapter(runtime),
32
31
  });
@@ -18,7 +18,7 @@ export const MessagePartClient = resource(
18
18
  return tapApi<MessagePartClientApi>(api, {
19
19
  key:
20
20
  runtimeState.type === "tool-call"
21
- ? "toolCallId-" + runtimeState.toolCallId
21
+ ? `toolCallId-${runtimeState.toolCallId}`
22
22
  : undefined,
23
23
  });
24
24
  },
@@ -116,7 +116,7 @@ export const MessageClient = resource(
116
116
  if ("index" in selector) {
117
117
  return parts.api({ index: selector.index });
118
118
  } else {
119
- return parts.api({ key: "toolCallId-" + selector.toolCallId });
119
+ return parts.api({ key: `toolCallId-${selector.toolCallId}` });
120
120
  }
121
121
  },
122
122
 
@@ -92,7 +92,7 @@ export const auiV0Encode = (message: ThreadMessage): AuiV0Message => {
92
92
  case "tool-call": {
93
93
  if (!isJSONValue(part.result)) {
94
94
  console.warn(
95
- "tool-call result is not JSON! " + JSON.stringify(part),
95
+ `tool-call result is not JSON! ${JSON.stringify(part)}`,
96
96
  );
97
97
  }
98
98
  return {
@@ -101,7 +101,9 @@ export class AssistantRuntimeImpl implements AssistantRuntime {
101
101
 
102
102
  public reset({
103
103
  initialMessages,
104
- }: { initialMessages?: ThreadMessageLike[] } = {}) {
104
+ }: {
105
+ initialMessages?: ThreadMessageLike[];
106
+ } = {}) {
105
107
  return this._core.threads
106
108
  .getMainThreadRuntimeCore()
107
109
  .import(ExportedMessageRepository.fromArray(initialMessages ?? []));
@@ -335,7 +335,7 @@ export class ThreadComposerRuntimeImpl
335
335
  ...this.path,
336
336
  attachmentSource: "thread-composer",
337
337
  attachmentSelector: { type: "index", index: idx },
338
- ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,
338
+ ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,
339
339
  },
340
340
  getState: () => {
341
341
  const attachments = this.getState().attachments;
@@ -423,7 +423,7 @@ export class EditComposerRuntimeImpl
423
423
  ...this.path,
424
424
  attachmentSource: "edit-composer",
425
425
  attachmentSelector: { type: "index", index: idx },
426
- ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,
426
+ ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,
427
427
  },
428
428
  getState: () => {
429
429
  const attachments = this.getState().attachments;
@@ -149,7 +149,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
149
149
  new NestedSubscriptionSubject({
150
150
  path: {
151
151
  ...this.path,
152
- ref: this.path.ref + `${this.path.ref}.composer`,
152
+ ref: `${this.path.ref}${this.path.ref}.composer`,
153
153
  composerSource: "edit",
154
154
  },
155
155
  getState: this._getEditComposerRuntimeCore,
@@ -270,7 +270,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
270
270
  new ShallowMemoizeSubject({
271
271
  path: {
272
272
  ...this.path,
273
- ref: this.path.ref + `${this.path.ref}.content[${idx}]`,
273
+ ref: `${this.path.ref}${this.path.ref}.content[${idx}]`,
274
274
  messagePartSelector: { type: "index", index: idx },
275
275
  },
276
276
  getState: () => {
@@ -314,7 +314,7 @@ export class MessageRuntimeImpl implements MessageRuntime {
314
314
  new ShallowMemoizeSubject({
315
315
  path: {
316
316
  ...this.path,
317
- ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,
317
+ ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,
318
318
  attachmentSource: "message",
319
319
  attachmentSelector: { type: "index", index: idx },
320
320
  },
@@ -163,7 +163,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
163
163
  return new this._runtimeFactory(
164
164
  new NestedSubscriptionSubject({
165
165
  path: {
166
- ref: "threads[threadId=" + JSON.stringify(threadId) + "]",
166
+ ref: `threads[threadId=${JSON.stringify(threadId)}]`,
167
167
  threadSelector: { type: "threadId", threadId },
168
168
  },
169
169
  getState: () => this._core.getThreadRuntimeCore(threadId),
@@ -338,7 +338,7 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
338
338
  new NestedSubscriptionSubject({
339
339
  path: {
340
340
  ...this.path,
341
- ref: this.path.ref + `${this.path.ref}.composer`,
341
+ ref: `${this.path.ref}${this.path.ref}.composer`,
342
342
  composerSource: "thread",
343
343
  },
344
344
  getState: () => this._threadBinding.getState().composer,
@@ -437,7 +437,7 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
437
437
  return this._getMessageRuntime(
438
438
  {
439
439
  ...this.path,
440
- ref: this.path.ref + `${this.path.ref}.messages[${idx}]`,
440
+ ref: `${this.path.ref}${this.path.ref}.messages[${idx}]`,
441
441
  messageSelector: { type: "index", index: idx },
442
442
  },
443
443
  () => {
@@ -13,7 +13,7 @@ export type RuntimeAdapters = {
13
13
 
14
14
  const RuntimeAdaptersContext = createContext<RuntimeAdapters | null>(null);
15
15
 
16
- namespace RuntimeAdapterProvider {
16
+ export namespace RuntimeAdapterProvider {
17
17
  export type Props = {
18
18
  adapters: RuntimeAdapters;
19
19
  children: ReactNode;
@@ -19,7 +19,7 @@ function fileMatchesAccept(
19
19
  .map((type) => type.trim().toLowerCase());
20
20
 
21
21
  // Get the file's extension and MIME type
22
- const fileExtension = "." + file.name.split(".").pop()!.toLowerCase();
22
+ const fileExtension = `.${file.name.split(".").pop()!.toLowerCase()}`;
23
23
  const fileMimeType = file.type.toLowerCase();
24
24
 
25
25
  for (const type of allowedTypes) {
@@ -37,7 +37,7 @@ function fileMatchesAccept(
37
37
  // Check for wildcard MIME type match
38
38
  if (type.endsWith("/*")) {
39
39
  const generalType = type.split("/")[0]!;
40
- if (fileMimeType.startsWith(generalType + "/")) {
40
+ if (fileMimeType.startsWith(`${generalType}/`)) {
41
41
  return true;
42
42
  }
43
43
  }
@@ -1 +1 @@
1
- export { type FeedbackAdapter } from "./FeedbackAdapter";
1
+ export type { FeedbackAdapter } from "./FeedbackAdapter";
@@ -1 +1 @@
1
- export { type SuggestionAdapter } from "./SuggestionAdapter";
1
+ export type { SuggestionAdapter } from "./SuggestionAdapter";
@@ -70,7 +70,7 @@ type ExternalStoreAdapterBase<T> = {
70
70
  onNew: (message: AppendMessage) => Promise<void>;
71
71
  onEdit?: ((message: AppendMessage) => Promise<void>) | undefined;
72
72
  onReload?: // TODO: remove parentId in 0.12.0
73
- | ((parentId: string | null, config: StartRunConfig) => Promise<void>)
73
+ | ((parentId: string | null, config: StartRunConfig) => Promise<void>)
74
74
  | undefined;
75
75
  onResume?: ((config: ResumeRunConfig) => Promise<void>) | undefined;
76
76
  onCancel?: (() => Promise<void>) | undefined;
@@ -132,7 +132,7 @@ export const fromThreadMessageLike = (
132
132
  const { parentId, messages, ...basePart } = part;
133
133
  const commonProps = {
134
134
  ...basePart,
135
- toolCallId: part.toolCallId ?? "tool-" + generateId(),
135
+ toolCallId: part.toolCallId ?? `tool-${generateId()}`,
136
136
  ...(parentId !== undefined && { parentId }),
137
137
  ...(messages !== undefined && { messages }),
138
138
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
1
  "use client";
3
2
 
4
3
  import {
@@ -128,7 +127,6 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
128
127
  private _OuterActiveThreadProvider: FC<{
129
128
  threadId: string;
130
129
  provider: ComponentType<PropsWithChildren>;
131
- // eslint-disable-next-line react/display-name
132
130
  }> = memo(({ threadId, provider: Provider }) => {
133
131
  // Runtime is provided by ThreadListItemByIdProvider
134
132
 
@@ -605,9 +605,7 @@ export class RemoteThreadListThreadListRuntimeCore
605
605
  private useBoundIds = create<string[]>(() => []);
606
606
 
607
607
  public __internal_RenderComponent: FC = () => {
608
- // eslint-disable-next-line react-hooks/rules-of-hooks
609
608
  const id = useId();
610
- // eslint-disable-next-line react-hooks/rules-of-hooks
611
609
  useEffect(() => {
612
610
  this.useBoundIds.setState((s) => [...s, id], true);
613
611
  return () => {
@@ -33,7 +33,9 @@ import { useAssistantState, useAssistantApi } from "../../context";
33
33
  */
34
34
  const useActionBarPrimitiveCopy = ({
35
35
  copiedDuration = 3000,
36
- }: { copiedDuration?: number | undefined } = {}) => {
36
+ }: {
37
+ copiedDuration?: number | undefined;
38
+ } = {}) => {
37
39
  const api = useAssistantApi();
38
40
  const hasCopyableContent = useAssistantState(({ message }) => {
39
41
  return (
@@ -9,7 +9,7 @@ export const MessagePrimitiveError: FC<PropsWithChildren> = ({ children }) => {
9
9
  message.status?.type === "incomplete" &&
10
10
  message.status.reason === "error",
11
11
  );
12
- return hasError ? <>{children}</> : null;
12
+ return hasError ? children : null;
13
13
  };
14
14
 
15
15
  MessagePrimitiveError.displayName = "MessagePrimitive.Error";
@@ -328,7 +328,6 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
328
328
  return <Source {...part} />;
329
329
 
330
330
  case "image":
331
- // eslint-disable-next-line jsx-a11y/alt-text
332
331
  return <Image {...part} />;
333
332
 
334
333
  case "file":
@@ -295,7 +295,6 @@ const MessagePartComponent: FC<MessagePartComponentProps> = ({
295
295
  return <Source {...part} />;
296
296
 
297
297
  case "image":
298
- // eslint-disable-next-line jsx-a11y/alt-text
299
298
  return <Image {...part} />;
300
299
 
301
300
  case "file":
@@ -3,7 +3,7 @@
3
3
  import { useAssistantState } from "../../context";
4
4
  import { DataMessagePart } from "../../types";
5
5
 
6
- export const useMessagePartData = <T = any,>(name?: string) => {
6
+ export const useMessagePartData = <T = any>(name?: string) => {
7
7
  const part = useAssistantState(({ part }) => {
8
8
  if (part.type !== "data") {
9
9
  return null;
@@ -18,7 +18,6 @@ export type {
18
18
  MessageStatus,
19
19
  MessagePartStatus,
20
20
  ToolCallMessagePartStatus,
21
-
22
21
  // thread message types
23
22
  ThreadUserMessagePart,
24
23
  ThreadAssistantMessagePart,
@@ -96,12 +96,12 @@ export const useSmooth = (
96
96
  useEffect(() => {
97
97
  if (smoothStatusStore) {
98
98
  const target =
99
- displayedText !== text || state.status.type === "running"
99
+ smooth && (displayedText !== text || state.status.type === "running")
100
100
  ? SMOOTH_STATUS
101
101
  : state.status;
102
102
  writableStore(smoothStatusStore).setState(target, true);
103
103
  }
104
- }, [smoothStatusStore, text, displayedText, state.status]);
104
+ }, [smoothStatusStore, smooth, text, displayedText, state.status]);
105
105
 
106
106
  const [animatorRef] = useState<TextStreamAnimator>(
107
107
  new TextStreamAnimator(text, setText),