@assistant-ui/react 0.7.38 → 0.7.39

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 (179) hide show
  1. package/dist/primitives/actionBar/ActionBarRoot.d.ts +2 -2
  2. package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
  3. package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
  4. package/dist/primitives/actionBar/ActionBarRoot.mjs.map +1 -1
  5. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +2 -2
  6. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
  7. package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
  8. package/dist/primitives/assistantModal/AssistantModalAnchor.mjs.map +1 -1
  9. package/dist/primitives/assistantModal/AssistantModalContent.d.ts +2 -2
  10. package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
  11. package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
  12. package/dist/primitives/assistantModal/AssistantModalContent.mjs.map +1 -1
  13. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +2 -2
  14. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
  15. package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
  16. package/dist/primitives/assistantModal/AssistantModalTrigger.mjs.map +1 -1
  17. package/dist/primitives/assistantModal/scope.d.ts +3 -3
  18. package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
  19. package/dist/primitives/assistantModal/scope.js.map +1 -1
  20. package/dist/primitives/assistantModal/scope.mjs.map +1 -1
  21. package/dist/primitives/attachment/AttachmentRoot.d.ts +2 -2
  22. package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
  23. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  24. package/dist/primitives/attachment/AttachmentRoot.mjs.map +1 -1
  25. package/dist/primitives/attachment/AttachmentThumb.d.ts +2 -2
  26. package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
  27. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  28. package/dist/primitives/attachment/AttachmentThumb.mjs.map +1 -1
  29. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +2 -2
  30. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
  31. package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
  32. package/dist/primitives/branchPicker/BranchPickerRoot.mjs.map +1 -1
  33. package/dist/primitives/composer/ComposerRoot.d.ts +2 -2
  34. package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
  35. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  36. package/dist/primitives/composer/ComposerRoot.mjs.map +1 -1
  37. package/dist/primitives/contentPart/ContentPartImage.d.ts +2 -2
  38. package/dist/primitives/contentPart/ContentPartImage.d.ts.map +1 -1
  39. package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
  40. package/dist/primitives/contentPart/ContentPartImage.mjs.map +1 -1
  41. package/dist/primitives/contentPart/ContentPartText.d.ts +2 -2
  42. package/dist/primitives/contentPart/ContentPartText.d.ts.map +1 -1
  43. package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
  44. package/dist/primitives/contentPart/ContentPartText.mjs.map +1 -1
  45. package/dist/primitives/message/MessageRoot.d.ts +2 -2
  46. package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
  47. package/dist/primitives/message/MessageRoot.js.map +1 -1
  48. package/dist/primitives/message/MessageRoot.mjs.map +1 -1
  49. package/dist/primitives/thread/ThreadRoot.d.ts +2 -2
  50. package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
  51. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  52. package/dist/primitives/thread/ThreadRoot.mjs.map +1 -1
  53. package/dist/primitives/thread/ThreadViewport.d.ts +2 -2
  54. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  55. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  56. package/dist/primitives/thread/ThreadViewport.mjs.map +1 -1
  57. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +2 -2
  58. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
  59. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  60. package/dist/primitives/threadListItem/ThreadListItemRoot.mjs.map +1 -1
  61. package/dist/runtimes/local/LocalThreadListRuntimeCore.js +2 -2
  62. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
  63. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +2 -2
  64. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
  65. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +4 -2
  66. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  67. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +17 -14
  68. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  69. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +24 -15
  70. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
  71. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +3 -2
  72. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  73. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +94 -64
  74. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  75. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +95 -65
  76. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
  77. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts +2 -0
  78. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts.map +1 -1
  79. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js +3 -0
  80. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js.map +1 -1
  81. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs +3 -0
  82. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs.map +1 -1
  83. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +10 -6
  84. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -1
  85. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +25 -8
  86. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -1
  87. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +25 -8
  88. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -1
  89. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +2 -2
  90. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -1
  91. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +7 -8
  92. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -1
  93. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +7 -8
  94. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -1
  95. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts +15 -0
  96. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.d.ts.map +1 -0
  97. package/dist/runtimes/remote-thread-list/cloud/{CloudContext.js → AssistantCloudRuns.js} +23 -9
  98. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.js.map +1 -0
  99. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs +21 -0
  100. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudRuns.mjs.map +1 -0
  101. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts +22 -0
  102. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts.map +1 -0
  103. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js +85 -0
  104. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js.map +1 -0
  105. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs +60 -0
  106. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs.map +1 -0
  107. package/dist/runtimes/remote-thread-list/cloud/index.d.ts +1 -1
  108. package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -1
  109. package/dist/runtimes/remote-thread-list/cloud/index.js +3 -3
  110. package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -1
  111. package/dist/runtimes/remote-thread-list/cloud/index.mjs +2 -2
  112. package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -1
  113. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  114. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +47 -19
  115. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -1
  116. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +54 -20
  117. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -1
  118. package/dist/runtimes/remote-thread-list/types.d.ts +10 -2
  119. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  120. package/dist/runtimes/remote-thread-list/types.js.map +1 -1
  121. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
  122. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +1 -0
  123. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  124. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +1 -0
  125. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
  126. package/dist/styles/index.css.map +1 -1
  127. package/dist/ui/base/button.d.ts.map +1 -1
  128. package/dist/ui/base/button.js.map +1 -1
  129. package/dist/ui/base/button.mjs.map +1 -1
  130. package/dist/ui/base/dialog.js.map +1 -1
  131. package/dist/ui/base/dialog.mjs.map +1 -1
  132. package/dist/utils/createActionButton.d.ts +2 -2
  133. package/dist/utils/createActionButton.d.ts.map +1 -1
  134. package/dist/utils/createActionButton.js.map +1 -1
  135. package/dist/utils/createActionButton.mjs.map +1 -1
  136. package/package.json +7 -10
  137. package/src/primitives/actionBar/ActionBarRoot.tsx +2 -2
  138. package/src/primitives/assistantModal/AssistantModalAnchor.tsx +2 -2
  139. package/src/primitives/assistantModal/AssistantModalContent.tsx +2 -2
  140. package/src/primitives/assistantModal/AssistantModalTrigger.tsx +2 -2
  141. package/src/primitives/assistantModal/scope.tsx +1 -1
  142. package/src/primitives/attachment/AttachmentRoot.tsx +2 -2
  143. package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
  144. package/src/primitives/branchPicker/BranchPickerRoot.tsx +2 -2
  145. package/src/primitives/composer/ComposerRoot.tsx +2 -2
  146. package/src/primitives/contentPart/ContentPartImage.tsx +2 -2
  147. package/src/primitives/contentPart/ContentPartText.tsx +2 -2
  148. package/src/primitives/message/MessageRoot.tsx +2 -2
  149. package/src/primitives/thread/ThreadRoot.tsx +2 -2
  150. package/src/primitives/thread/ThreadViewport.tsx +2 -2
  151. package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -2
  152. package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +2 -2
  153. package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +40 -24
  154. package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +119 -80
  155. package/src/runtimes/remote-thread-list/cloud/AssistantCloud.tsx +3 -0
  156. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +36 -16
  157. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +5 -6
  158. package/src/runtimes/remote-thread-list/cloud/AssistantCloudRuns.tsx +26 -0
  159. package/src/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.tsx +89 -0
  160. package/src/runtimes/remote-thread-list/cloud/index.ts +1 -1
  161. package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +63 -28
  162. package/src/runtimes/remote-thread-list/types.tsx +18 -4
  163. package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +1 -0
  164. package/src/ui/base/button.tsx +2 -2
  165. package/src/ui/base/dialog.tsx +5 -5
  166. package/src/utils/createActionButton.tsx +2 -2
  167. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts +0 -10
  168. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts.map +0 -1
  169. package/dist/runtimes/remote-thread-list/cloud/CloudContext.js.map +0 -1
  170. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs +0 -7
  171. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs.map +0 -1
  172. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts +0 -4
  173. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts.map +0 -1
  174. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js +0 -46
  175. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js.map +0 -1
  176. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs +0 -22
  177. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs.map +0 -1
  178. package/src/runtimes/remote-thread-list/cloud/CloudContext.tsx +0 -12
  179. package/src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx +0 -19
@@ -7,15 +7,28 @@ import {
7
7
  export type AssistantCloudConfig =
8
8
  | {
9
9
  baseUrl: string;
10
- // TODO use baseUrl to construct the projectId
11
- unstable_projectId: string;
12
10
  authToken(): Promise<string>;
13
11
  }
14
12
  | {
15
13
  apiKey: string;
14
+ userId: string;
16
15
  workspaceId: string;
17
16
  };
18
17
 
18
+ class CloudAPIError extends Error {
19
+ constructor(message: string) {
20
+ super(message);
21
+ this.name = "APIError";
22
+ }
23
+ }
24
+
25
+ type MakeRequestOptions = {
26
+ method?: "POST" | "PUT" | "DELETE" | undefined;
27
+ headers?: Record<string, string> | undefined;
28
+ query?: Record<string, string | number | boolean> | undefined;
29
+ body?: object | undefined;
30
+ };
31
+
19
32
  export class AssistantCloudAPI {
20
33
  private _tokenManager: AssistantCloudAuthStrategy;
21
34
  private _baseUrl;
@@ -23,30 +36,25 @@ export class AssistantCloudAPI {
23
36
  constructor(config: AssistantCloudConfig) {
24
37
  if ("authToken" in config) {
25
38
  this._baseUrl = config.baseUrl;
26
- this._tokenManager = new AssistantCloudJWTAuthStrategy(
27
- config.unstable_projectId,
28
- config.authToken,
29
- );
39
+ this._tokenManager = new AssistantCloudJWTAuthStrategy(config.authToken);
30
40
  } else {
31
- this._baseUrl = "https://api.assistant-ui.com";
41
+ this._baseUrl = "https://backend.assistant-api.com";
32
42
  this._tokenManager = new AssistantCloudAPIKeyAuthStrategy(
33
43
  config.apiKey,
44
+ config.userId,
34
45
  config.workspaceId,
35
46
  );
36
47
  }
37
48
  }
38
49
 
39
- public async makeRequest(
50
+ public async makeRawRequest(
40
51
  endpoint: string,
41
- options: {
42
- method?: "POST" | "PUT" | "DELETE" | undefined;
43
- query?: Record<string, string | number | boolean> | undefined;
44
- body?: object | undefined;
45
- } = {},
52
+ options: MakeRequestOptions = {},
46
53
  ) {
47
54
  const authHeaders = await this._tokenManager.getAuthHeaders();
48
55
  const headers = {
49
56
  ...authHeaders,
57
+ ...options.headers,
50
58
  "Content-Type": "application/json",
51
59
  };
52
60
 
@@ -62,7 +70,7 @@ export class AssistantCloudAPI {
62
70
  }
63
71
  }
64
72
 
65
- const url = new URL(`${this._baseUrl}${endpoint}`);
73
+ const url = new URL(`${this._baseUrl}/v1${endpoint}`);
66
74
  url.search = queryParams.toString();
67
75
 
68
76
  const response = await fetch(url, {
@@ -72,10 +80,22 @@ export class AssistantCloudAPI {
72
80
  });
73
81
 
74
82
  if (!response.ok) {
75
- // TODO better error handling
76
- throw new Error(`Request failed with status ${response.status}`);
83
+ const text = await response.text();
84
+ try {
85
+ const body = JSON.parse(text);
86
+ throw new CloudAPIError(body.message);
87
+ } catch {
88
+ throw new Error(
89
+ `Request failed with status ${response.status}, ${text}`,
90
+ );
91
+ }
77
92
  }
78
93
 
94
+ return response;
95
+ }
96
+
97
+ public async makeRequest(endpoint: string, options: MakeRequestOptions = {}) {
98
+ const response = await this.makeRawRequest(endpoint, options);
79
99
  return response.json();
80
100
  }
81
101
  }
@@ -11,11 +11,9 @@ export class AssistantCloudJWTAuthStrategy
11
11
  private cachedToken: string | null = null;
12
12
  private tokenExpiry: number | null = null;
13
13
 
14
- #projectId;
15
14
  #authTokenCallback;
16
15
 
17
- constructor(projectId: string, authTokenCallback: () => Promise<string>) {
18
- this.#projectId = projectId;
16
+ constructor(authTokenCallback: () => Promise<string>) {
19
17
  this.#authTokenCallback = authTokenCallback;
20
18
  }
21
19
 
@@ -56,7 +54,6 @@ export class AssistantCloudJWTAuthStrategy
56
54
  ) {
57
55
  return {
58
56
  Authorization: `Bearer ${this.cachedToken}`,
59
- "Aui-Project-Id": this.#projectId,
60
57
  };
61
58
  }
62
59
 
@@ -69,7 +66,6 @@ export class AssistantCloudJWTAuthStrategy
69
66
 
70
67
  return {
71
68
  Authorization: `Bearer ${newToken}`,
72
- "Aui-Project-Id": this.#projectId,
73
69
  };
74
70
  }
75
71
  }
@@ -79,16 +75,19 @@ export class AssistantCloudAPIKeyAuthStrategy
79
75
  public readonly strategy = "api-key";
80
76
 
81
77
  #apiKey;
78
+ #userId;
82
79
  #workspaceId;
83
80
 
84
- constructor(apiKey: string, workspaceId: string) {
81
+ constructor(apiKey: string, userId: string, workspaceId: string) {
85
82
  this.#apiKey = apiKey;
83
+ this.#userId = userId;
86
84
  this.#workspaceId = workspaceId;
87
85
  }
88
86
 
89
87
  public async getAuthHeaders(): Promise<Record<string, string>> {
90
88
  return {
91
89
  Authorization: `Bearer ${this.#apiKey}`,
90
+ "Aui-User-Id": this.#userId,
92
91
  "Aui-Workspace-Id": this.#workspaceId,
93
92
  };
94
93
  }
@@ -0,0 +1,26 @@
1
+ import { CoreMessage } from "../../../types";
2
+ import { AssistantCloudAPI } from "./AssistantCloudAPI";
3
+ import { AssistantStream, PlainTextDecoder } from "assistant-stream";
4
+
5
+ type AssistantCloudRunsStreamBody = {
6
+ thread_id: string;
7
+ assistant_id: "system/thread_title";
8
+ messages: CoreMessage[];
9
+ };
10
+
11
+ export class AssistantCloudRuns {
12
+ constructor(private cloud: AssistantCloudAPI) {}
13
+
14
+ public async stream(
15
+ body: AssistantCloudRunsStreamBody,
16
+ ): Promise<AssistantStream> {
17
+ const response = await this.cloud.makeRawRequest("/runs/stream", {
18
+ method: "POST",
19
+ headers: {
20
+ Accept: "text/plain",
21
+ },
22
+ body,
23
+ });
24
+ return AssistantStream.fromResponse(response, new PlainTextDecoder());
25
+ }
26
+ }
@@ -0,0 +1,89 @@
1
+ "use client";
2
+
3
+ import { createContext, FC, useContext, useEffect, useState } from "react";
4
+ import { useThreadListItemRuntime } from "../../../context";
5
+ import { RemoteThreadInitializeResponse } from "../types";
6
+ import { ThreadListItemRuntime } from "../../../api";
7
+
8
+ type CloudInitializeResponse = {
9
+ remoteId: string;
10
+ externalId: string | undefined;
11
+ };
12
+
13
+ type CloudThreadListItemRuntime = {
14
+ getOrCreateThread: () => Promise<CloudInitializeResponse>;
15
+ generateThreadTitle: () => Promise<void>;
16
+ };
17
+
18
+ export const useCloudThreadListItemRuntime = () => {
19
+ const cloudThreadListItemRuntime = useContext(
20
+ CloudThreadListItemRuntimeContext,
21
+ );
22
+ if (!cloudThreadListItemRuntime)
23
+ throw new Error(
24
+ "This component can only be used inside a useCloudThreadListRuntime's runtimeHook.",
25
+ );
26
+ return cloudThreadListItemRuntime;
27
+ };
28
+
29
+ type CloudThreadListItemRuntimeAdapter = {
30
+ initialize: (threadId: string) => Promise<RemoteThreadInitializeResponse>;
31
+ generateTitle: (remoteId: string) => Promise<void>;
32
+ };
33
+
34
+ class CloudThreadListItemRuntimeImpl implements CloudThreadListItemRuntime {
35
+ public constructor(
36
+ private adapter: CloudThreadListItemRuntimeAdapter,
37
+ private threadListItemRuntime: ThreadListItemRuntime,
38
+ ) {}
39
+
40
+ public __internal_setThreadListItemRuntime(
41
+ threadListItemRuntime: ThreadListItemRuntime,
42
+ ) {
43
+ this.threadListItemRuntime = threadListItemRuntime;
44
+ }
45
+
46
+ public async getOrCreateThread(): Promise<CloudInitializeResponse> {
47
+ const threadData = this.threadListItemRuntime.getState();
48
+ if (threadData.remoteId)
49
+ return threadData as RemoteThreadInitializeResponse;
50
+ return this.adapter.initialize(threadData.id);
51
+ }
52
+
53
+ public generateThreadTitle() {
54
+ const remoteId = this.threadListItemRuntime.getState().remoteId;
55
+ if (!remoteId) throw new Error("Thread not initialized yet");
56
+ return this.adapter.generateTitle(remoteId);
57
+ }
58
+ }
59
+
60
+ type CloudThreadListItemRuntimeContextAdapterProps = {
61
+ adapter: CloudThreadListItemRuntimeAdapter;
62
+ children: React.ReactNode;
63
+ };
64
+
65
+ export const CloudThreadListItemRuntimeProvider: FC<
66
+ CloudThreadListItemRuntimeContextAdapterProps
67
+ > = ({ adapter, children }) => {
68
+ const threadListItemRuntime = useThreadListItemRuntime();
69
+ const [cloudThreadListItemRuntime] = useState(
70
+ () => new CloudThreadListItemRuntimeImpl(adapter, threadListItemRuntime),
71
+ );
72
+
73
+ useEffect(() => {
74
+ cloudThreadListItemRuntime.__internal_setThreadListItemRuntime(
75
+ threadListItemRuntime,
76
+ );
77
+ }, [cloudThreadListItemRuntime, threadListItemRuntime]);
78
+
79
+ return (
80
+ <CloudThreadListItemRuntimeContext.Provider
81
+ value={cloudThreadListItemRuntime}
82
+ >
83
+ {children}
84
+ </CloudThreadListItemRuntimeContext.Provider>
85
+ );
86
+ };
87
+
88
+ const CloudThreadListItemRuntimeContext =
89
+ createContext<CloudThreadListItemRuntime | null>(null);
@@ -1,3 +1,3 @@
1
1
  export { useCloudThreadListRuntime } from "./useCloudThreadListRuntime";
2
- export { useCloudGetOrCreateThread } from "./useCloudGetOrCreateThread";
2
+ export { useCloudThreadListItemRuntime } from "./CloudThreadListItemRuntime";
3
3
  export { AssistantCloud } from "./AssistantCloud";
@@ -1,10 +1,19 @@
1
1
  "use client";
2
2
 
3
- import { PropsWithChildren, useEffect, useMemo, useRef } from "react";
3
+ import {
4
+ PropsWithChildren,
5
+ useCallback,
6
+ useEffect,
7
+ useMemo,
8
+ useRef,
9
+ useState,
10
+ } from "react";
4
11
  import { useRemoteThreadListRuntime } from "../useRemoteThreadListRuntime";
5
12
  import { AssistantCloud } from "./AssistantCloud";
6
- import { CloudContext, CloudInitializeResponse } from "./CloudContext";
7
13
  import { AssistantRuntime } from "../../../api";
14
+ import { RemoteThreadListSubscriber } from "../types";
15
+ import { CloudThreadListItemRuntimeProvider } from "./CloudThreadListItemRuntime";
16
+ import { toCoreMessages } from "../../edge";
8
17
 
9
18
  type ThreadData = {
10
19
  externalId: string;
@@ -19,20 +28,29 @@ type CloudThreadListAdapter = {
19
28
  delete?(threadId: string): Promise<void>;
20
29
  };
21
30
 
31
+ const beginnable = <T,>(callback: () => Promise<T>) => {
32
+ let task: Promise<T> | undefined = undefined;
33
+
34
+ return () => {
35
+ if (task === undefined) task = callback();
36
+ return task;
37
+ };
38
+ };
39
+
22
40
  export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
23
41
  const adapterRef = useRef(adapter);
24
42
  useEffect(() => {
25
43
  adapterRef.current = adapter;
26
44
  }, [adapter]);
27
45
 
28
- const cloudContextValue = useMemo(() => {
29
- const subscribers = new Set<
30
- (result: Promise<CloudInitializeResponse>) => void
31
- >();
46
+ const [subscribers] = useState(() => new Set<RemoteThreadListSubscriber>());
47
+
48
+ const cloudThreadListItemRuntimeAdapter = useMemo(() => {
32
49
  return {
33
- initialize: async () => {
34
- const createTask = adapterRef.current.create?.() ?? Promise.resolve();
35
- const task = createTask.then(async (t) => {
50
+ initialize: async (threadId: string) => {
51
+ const begin = beginnable(async () => {
52
+ const createTask = adapterRef.current.create?.() ?? Promise.resolve();
53
+ const t = await createTask;
36
54
  const external_id = t ? t.externalId : undefined;
37
55
  const { thread_id } = await adapterRef.current.cloud.threads.create({
38
56
  title: "New Thread",
@@ -41,21 +59,30 @@ export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
41
59
  });
42
60
  return { externalId: external_id, remoteId: thread_id };
43
61
  });
62
+
44
63
  for (const subscriber of subscribers) {
45
- subscriber(task);
64
+ subscriber.onInitialize(threadId, begin);
46
65
  }
47
- return task;
66
+
67
+ // note: onInitialize immediately throws if there are any issues
68
+ // therefore begin is safe to call here
69
+ return begin();
48
70
  },
49
- subscribe: (
50
- callback: (result: Promise<CloudInitializeResponse>) => void,
51
- ) => {
52
- subscribers.add(callback);
53
- return () => {
54
- subscribers.delete(callback);
55
- };
71
+ generateTitle: async (remoteId: string) => {
72
+ const messages = runtime.thread.getState().messages;
73
+ const begin = beginnable(() => {
74
+ return adapterRef.current.cloud.runs.stream({
75
+ thread_id: remoteId,
76
+ assistant_id: "system/thread_title",
77
+ messages: toCoreMessages(messages),
78
+ });
79
+ });
80
+ for (const subscriber of subscribers) {
81
+ subscriber.onGenerateTitle(remoteId, begin);
82
+ }
56
83
  },
57
84
  };
58
- }, []);
85
+ }, [subscribers]);
59
86
 
60
87
  const runtime = useRemoteThreadListRuntime({
61
88
  runtimeHook: adapter.runtimeHook,
@@ -83,16 +110,24 @@ export const useCloudThreadListRuntime = (adapter: CloudThreadListAdapter) => {
83
110
  await adapter.delete?.(threadId);
84
111
  return adapter.cloud.threads.delete(threadId);
85
112
  },
86
- onInitialize: (callback) => {
87
- return cloudContextValue.subscribe(callback);
88
- },
89
- unstable_Provider: ({ children }: PropsWithChildren) => {
90
- return (
91
- <CloudContext.Provider value={cloudContextValue}>
92
- {children}
93
- </CloudContext.Provider>
94
- );
113
+ subscribe: (callback) => {
114
+ subscribers.add(callback);
115
+ return () => {
116
+ subscribers.delete(callback);
117
+ };
95
118
  },
119
+ unstable_Provider: useCallback(
120
+ ({ children }: PropsWithChildren) => {
121
+ return (
122
+ <CloudThreadListItemRuntimeProvider
123
+ adapter={cloudThreadListItemRuntimeAdapter}
124
+ >
125
+ {children}
126
+ </CloudThreadListItemRuntimeProvider>
127
+ );
128
+ },
129
+ [cloudThreadListItemRuntimeAdapter],
130
+ ),
96
131
  });
97
132
 
98
133
  return runtime;
@@ -1,7 +1,12 @@
1
1
  import { ComponentType, PropsWithChildren } from "react";
2
2
  import { AssistantRuntime } from "../../api";
3
3
  import { Unsubscribe } from "../../types";
4
- import { CloudInitializeResponse } from "./cloud/CloudContext";
4
+ import { AssistantStream } from "assistant-stream";
5
+
6
+ export type RemoteThreadInitializeResponse = {
7
+ remoteId: string;
8
+ externalId: string | undefined;
9
+ };
5
10
 
6
11
  export type RemoteThreadMetadata = {
7
12
  readonly status: "regular" | "archived";
@@ -16,6 +21,17 @@ export type RemoteThreadListResponse = {
16
21
 
17
22
  export type RemoteThreadListHook = () => AssistantRuntime;
18
23
 
24
+ export type RemoteThreadListSubscriber = {
25
+ onInitialize: (
26
+ threadId: string,
27
+ begin: () => Promise<RemoteThreadInitializeResponse>,
28
+ ) => void;
29
+ onGenerateTitle: (
30
+ threadId: string,
31
+ begin: () => Promise<AssistantStream>,
32
+ ) => void;
33
+ };
34
+
19
35
  export type RemoteThreadListAdapter = {
20
36
  runtimeHook: RemoteThreadListHook;
21
37
 
@@ -26,9 +42,7 @@ export type RemoteThreadListAdapter = {
26
42
  unarchive(remoteId: string): Promise<void>;
27
43
  delete(remoteId: string): Promise<void>;
28
44
 
29
- onInitialize(
30
- callback: (task: Promise<CloudInitializeResponse>) => Promise<void>,
31
- ): Unsubscribe;
45
+ subscribe(subscriber: RemoteThreadListSubscriber): Unsubscribe;
32
46
 
33
47
  unstable_Provider?: ComponentType<PropsWithChildren>;
34
48
  };
@@ -29,6 +29,7 @@ export const useRemoteThreadListRuntime = (
29
29
  const [runtime] = useState(() => new RemoteThreadListRuntimeCore(adapter));
30
30
  useEffect(() => {
31
31
  runtime.threadList.__internal_setAdapter(adapter);
32
+ return runtime.threadList.__internal_bindAdapter();
32
33
  }, [runtime, adapter]);
33
34
  return useMemo(() => AssistantRuntimeImpl.create(runtime), [runtime]);
34
35
  };
@@ -1,6 +1,6 @@
1
1
  import { cva, type VariantProps } from "class-variance-authority";
2
2
  import { Primitive } from "@radix-ui/react-primitive";
3
- import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
3
+ import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
4
4
 
5
5
  const buttonVariants = cva("aui-button", {
6
6
  variants: {
@@ -20,7 +20,7 @@ const buttonVariants = cva("aui-button", {
20
20
  },
21
21
  });
22
22
 
23
- type ButtonElement = ElementRef<typeof Primitive.button>;
23
+ type ButtonElement = ComponentRef<typeof Primitive.button>;
24
24
 
25
25
  export type ButtonProps = ComponentPropsWithoutRef<typeof Primitive.button> &
26
26
  VariantProps<typeof buttonVariants>;
@@ -1,7 +1,7 @@
1
1
  import * as DialogPrimitive from "@radix-ui/react-dialog";
2
2
 
3
3
  import classNames from "classnames";
4
- import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
4
+ import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
5
5
 
6
6
  const Dialog = DialogPrimitive.Root;
7
7
 
@@ -12,7 +12,7 @@ const DialogPortal = DialogPrimitive.Portal;
12
12
  const DialogClose = DialogPrimitive.Close;
13
13
 
14
14
  const DialogOverlay = forwardRef<
15
- ElementRef<typeof DialogPrimitive.Overlay>,
15
+ ComponentRef<typeof DialogPrimitive.Overlay>,
16
16
  ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
17
17
  >(({ className, ...props }, ref) => (
18
18
  <DialogPrimitive.Overlay
@@ -24,7 +24,7 @@ const DialogOverlay = forwardRef<
24
24
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
25
25
 
26
26
  const DialogContent = forwardRef<
27
- ElementRef<typeof DialogPrimitive.Content>,
27
+ ComponentRef<typeof DialogPrimitive.Content>,
28
28
  ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
29
29
  >(({ className, children, ...props }, ref) => (
30
30
  <DialogPortal>
@@ -73,7 +73,7 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
73
73
  // DialogFooter.displayName = "DialogFooter";
74
74
 
75
75
  // const DialogTitle = forwardRef<
76
- // ElementRef<typeof DialogPrimitive.Title>,
76
+ // ComponentRef<typeof DialogPrimitive.Title>,
77
77
  // ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
78
78
  // >(({ className, ...props }, ref) => (
79
79
  // <DialogPrimitive.Title
@@ -88,7 +88,7 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
88
88
  // DialogTitle.displayName = DialogPrimitive.Title.displayName;
89
89
 
90
90
  // const DialogDescription = forwardRef<
91
- // ElementRef<typeof DialogPrimitive.Description>,
91
+ // ComponentRef<typeof DialogPrimitive.Description>,
92
92
  // ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
93
93
  // >(({ className, ...props }, ref) => (
94
94
  // <DialogPrimitive.Description
@@ -1,5 +1,5 @@
1
1
  import {
2
- ElementRef,
2
+ ComponentRef,
3
3
  forwardRef,
4
4
  ComponentPropsWithoutRef,
5
5
  MouseEventHandler,
@@ -16,7 +16,7 @@ type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;
16
16
  export type ActionButtonProps<THook> = PrimitiveButtonProps &
17
17
  (THook extends (props: infer TProps) => unknown ? TProps : never);
18
18
 
19
- export type ActionButtonElement = ElementRef<typeof Primitive.button>;
19
+ export type ActionButtonElement = ComponentRef<typeof Primitive.button>;
20
20
 
21
21
  export const createActionButton = <TProps,>(
22
22
  displayName: string,
@@ -1,10 +0,0 @@
1
- export type CloudInitializeResponse = {
2
- remoteId: string;
3
- externalId: string | undefined;
4
- };
5
- type CloudContextValue = {
6
- initialize: () => Promise<CloudInitializeResponse>;
7
- };
8
- export declare const CloudContext: import("react").Context<CloudContextValue | null>;
9
- export {};
10
- //# sourceMappingURL=CloudContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CloudContext.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/remote-thread-list/cloud/CloudContext.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,YAAY,mDAAgD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/cloud/CloudContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type CloudInitializeResponse = {\n remoteId: string;\n externalId: string | undefined;\n};\n\ntype CloudContextValue = {\n initialize: () => Promise<CloudInitializeResponse>;\n};\n\nexport const CloudContext = createContext<CloudContextValue | null>(null);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8B;AAWvB,IAAM,mBAAe,4BAAwC,IAAI;","names":[]}
@@ -1,7 +0,0 @@
1
- // src/runtimes/remote-thread-list/cloud/CloudContext.tsx
2
- import { createContext } from "react";
3
- var CloudContext = createContext(null);
4
- export {
5
- CloudContext
6
- };
7
- //# sourceMappingURL=CloudContext.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/cloud/CloudContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type CloudInitializeResponse = {\n remoteId: string;\n externalId: string | undefined;\n};\n\ntype CloudContextValue = {\n initialize: () => Promise<CloudInitializeResponse>;\n};\n\nexport const CloudContext = createContext<CloudContextValue | null>(null);\n"],"mappings":";AAAA,SAAS,qBAAqB;AAWvB,IAAM,eAAe,cAAwC,IAAI;","names":[]}
@@ -1,4 +0,0 @@
1
- export declare const useCloudGetOrCreateThread: () => () => Promise<{
2
- externalId: string | undefined;
3
- }>;
4
- //# sourceMappingURL=useCloudGetOrCreateThread.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCloudGetOrCreateThread.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB;;EAYrC,CAAC"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
-
21
- // src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx
22
- var useCloudGetOrCreateThread_exports = {};
23
- __export(useCloudGetOrCreateThread_exports, {
24
- useCloudGetOrCreateThread: () => useCloudGetOrCreateThread
25
- });
26
- module.exports = __toCommonJS(useCloudGetOrCreateThread_exports);
27
- var import_react = require("react");
28
- var import_ThreadListItemContext = require("../../../context/react/ThreadListItemContext.js");
29
- var import_CloudContext = require("./CloudContext.js");
30
- var useCloudGetOrCreateThread = () => {
31
- const currentId = (0, import_ThreadListItemContext.useThreadListItem)((i) => i.externalId);
32
- const cloudContextValue = (0, import_react.useContext)(import_CloudContext.CloudContext);
33
- if (!cloudContextValue) throw new Error("CloudContext not available");
34
- return async () => {
35
- let externalId = currentId;
36
- if (!externalId) {
37
- externalId = (await cloudContextValue.initialize()).externalId;
38
- }
39
- return { externalId };
40
- };
41
- };
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- useCloudGetOrCreateThread
45
- });
46
- //# sourceMappingURL=useCloudGetOrCreateThread.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx"],"sourcesContent":["\"use client\";\n\nimport { useContext } from \"react\";\nimport { useThreadListItem } from \"../../../context/react/ThreadListItemContext\";\nimport { CloudContext } from \"./CloudContext\";\n\nexport const useCloudGetOrCreateThread = () => {\n const currentId = useThreadListItem((i) => i.externalId);\n const cloudContextValue = useContext(CloudContext);\n if (!cloudContextValue) throw new Error(\"CloudContext not available\");\n\n return async () => {\n let externalId = currentId;\n if (!externalId) {\n externalId = (await cloudContextValue.initialize()).externalId;\n }\n return { externalId };\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2B;AAC3B,mCAAkC;AAClC,0BAA6B;AAEtB,IAAM,4BAA4B,MAAM;AAC7C,QAAM,gBAAY,gDAAkB,CAAC,MAAM,EAAE,UAAU;AACvD,QAAM,wBAAoB,yBAAW,gCAAY;AACjD,MAAI,CAAC,kBAAmB,OAAM,IAAI,MAAM,4BAA4B;AAEpE,SAAO,YAAY;AACjB,QAAI,aAAa;AACjB,QAAI,CAAC,YAAY;AACf,oBAAc,MAAM,kBAAkB,WAAW,GAAG;AAAA,IACtD;AACA,WAAO,EAAE,WAAW;AAAA,EACtB;AACF;","names":[]}
@@ -1,22 +0,0 @@
1
- "use client";
2
-
3
- // src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx
4
- import { useContext } from "react";
5
- import { useThreadListItem } from "../../../context/react/ThreadListItemContext.mjs";
6
- import { CloudContext } from "./CloudContext.mjs";
7
- var useCloudGetOrCreateThread = () => {
8
- const currentId = useThreadListItem((i) => i.externalId);
9
- const cloudContextValue = useContext(CloudContext);
10
- if (!cloudContextValue) throw new Error("CloudContext not available");
11
- return async () => {
12
- let externalId = currentId;
13
- if (!externalId) {
14
- externalId = (await cloudContextValue.initialize()).externalId;
15
- }
16
- return { externalId };
17
- };
18
- };
19
- export {
20
- useCloudGetOrCreateThread
21
- };
22
- //# sourceMappingURL=useCloudGetOrCreateThread.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx"],"sourcesContent":["\"use client\";\n\nimport { useContext } from \"react\";\nimport { useThreadListItem } from \"../../../context/react/ThreadListItemContext\";\nimport { CloudContext } from \"./CloudContext\";\n\nexport const useCloudGetOrCreateThread = () => {\n const currentId = useThreadListItem((i) => i.externalId);\n const cloudContextValue = useContext(CloudContext);\n if (!cloudContextValue) throw new Error(\"CloudContext not available\");\n\n return async () => {\n let externalId = currentId;\n if (!externalId) {\n externalId = (await cloudContextValue.initialize()).externalId;\n }\n return { externalId };\n };\n};\n"],"mappings":";;;AAEA,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAEtB,IAAM,4BAA4B,MAAM;AAC7C,QAAM,YAAY,kBAAkB,CAAC,MAAM,EAAE,UAAU;AACvD,QAAM,oBAAoB,WAAW,YAAY;AACjD,MAAI,CAAC,kBAAmB,OAAM,IAAI,MAAM,4BAA4B;AAEpE,SAAO,YAAY;AACjB,QAAI,aAAa;AACjB,QAAI,CAAC,YAAY;AACf,oBAAc,MAAM,kBAAkB,WAAW,GAAG;AAAA,IACtD;AACA,WAAO,EAAE,WAAW;AAAA,EACtB;AACF;","names":[]}