@assistant-ui/core 0.1.17 → 0.2.0
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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +5 -0
- package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -0
- package/dist/react/primitive-hooks/useThreadListLoadMore.js +11 -0
- package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -0
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +0 -2
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +4 -3
- package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +6 -4
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +86 -38
- package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/react/runtimes/useLocalRuntime.d.ts +1 -1
- package/dist/runtime/api/assistant-runtime.d.ts +0 -33
- package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
- package/dist/runtime/api/assistant-runtime.js +0 -23
- package/dist/runtime/api/assistant-runtime.js.map +1 -1
- package/dist/runtime/api/bindings.d.ts +1 -3
- package/dist/runtime/api/bindings.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.d.ts +1 -6
- package/dist/runtime/api/message-runtime.d.ts.map +1 -1
- package/dist/runtime/api/message-runtime.js.map +1 -1
- package/dist/runtime/api/thread-list-runtime.d.ts +4 -0
- package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-list-runtime.js +6 -0
- package/dist/runtime/api/thread-list-runtime.js.map +1 -1
- package/dist/runtime/api/thread-runtime.d.ts +1 -24
- package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
- package/dist/runtime/api/thread-runtime.js +1 -20
- package/dist/runtime/api/thread-runtime.js.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts +0 -1
- package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +3 -0
- package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
- package/dist/runtime/interfaces/thread-runtime-core.d.ts +0 -4
- package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
- package/dist/runtime/utils/chat-model-adapter.d.ts +0 -4
- package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.d.ts +0 -4
- package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
- package/dist/runtime/utils/external-store-message.js +0 -7
- package/dist/runtime/utils/external-store-message.js.map +1 -1
- package/dist/runtimes/assistant-transport/utils.d.ts +0 -9
- package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
- package/dist/runtimes/assistant-transport/utils.js +0 -13
- package/dist/runtimes/assistant-transport/utils.js.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +0 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js +0 -3
- package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts +0 -1
- package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
- package/dist/runtimes/local/local-thread-runtime-core.js +0 -4
- package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +0 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +0 -3
- package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/empty-thread-core.js +0 -3
- package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +12 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/remote-thread-state.js +34 -0
- package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +5 -1
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.d.ts.map +1 -1
- package/dist/store/clients/thread-message-client.js +0 -1
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +3 -0
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +0 -1
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/store/scopes/message.d.ts +1 -3
- package/dist/store/scopes/message.d.ts.map +1 -1
- package/dist/store/scopes/thread.d.ts +0 -4
- package/dist/store/scopes/thread.d.ts.map +1 -1
- package/dist/store/scopes/threads.d.ts +3 -0
- package/dist/store/scopes/threads.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +2 -6
- package/src/react/index.ts +1 -0
- package/src/react/primitive-hooks/useThreadListLoadMore.ts +15 -0
- package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +7 -6
- package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +96 -43
- package/src/runtime/api/assistant-runtime.ts +0 -62
- package/src/runtime/api/bindings.ts +1 -6
- package/src/runtime/api/message-runtime.ts +1 -8
- package/src/runtime/api/thread-list-runtime.ts +10 -0
- package/src/runtime/api/thread-runtime.ts +1 -46
- package/src/runtime/base/base-thread-runtime-core.ts +0 -1
- package/src/runtime/interfaces/thread-list-runtime-core.ts +3 -0
- package/src/runtime/interfaces/thread-runtime-core.ts +0 -5
- package/src/runtime/utils/chat-model-adapter.ts +0 -5
- package/src/runtime/utils/external-store-message.ts +0 -8
- package/src/runtimes/assistant-transport/utils.ts +0 -28
- package/src/runtimes/external-store/external-store-thread-runtime-core.ts +0 -4
- package/src/runtimes/local/local-thread-runtime-core.ts +0 -5
- package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +0 -4
- package/src/runtimes/remote-thread-list/empty-thread-core.ts +0 -4
- package/src/runtimes/remote-thread-list/remote-thread-state.ts +54 -1
- package/src/runtimes/remote-thread-list/types.ts +6 -1
- package/src/store/clients/thread-message-client.ts +0 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +3 -0
- package/src/store/runtime-clients/thread-runtime-client.ts +0 -1
- package/src/store/scopes/message.ts +1 -6
- package/src/store/scopes/thread.ts +0 -5
- package/src/store/scopes/threads.ts +3 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-loadMore.test.ts +448 -0
- package/src/tests/RemoteThreadListThreadListRuntimeCore-reload.test.ts +6 -1
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SpeechState,
|
|
3
|
-
SubmittedFeedback,
|
|
4
|
-
} from "../interfaces/thread-runtime-core";
|
|
1
|
+
import type { SpeechState } from "../interfaces/thread-runtime-core";
|
|
5
2
|
import { symbolInnerMessage } from "../utils/external-store-message";
|
|
6
3
|
import type {
|
|
7
4
|
ToolCallMessagePartStatus,
|
|
@@ -90,10 +87,6 @@ export type MessageState = ThreadMessage & {
|
|
|
90
87
|
* @deprecated This API is still under active development and might change without notice.
|
|
91
88
|
*/
|
|
92
89
|
readonly speech: SpeechState | undefined;
|
|
93
|
-
/**
|
|
94
|
-
* @deprecated Use `message.metadata.submittedFeedback` instead. This will be removed in 0.12.0.
|
|
95
|
-
*/
|
|
96
|
-
readonly submittedFeedback: SubmittedFeedback | undefined;
|
|
97
90
|
};
|
|
98
91
|
|
|
99
92
|
export type { MessageStateBinding } from "./bindings";
|
|
@@ -28,6 +28,8 @@ export type ThreadListState = {
|
|
|
28
28
|
readonly threadIds: readonly string[];
|
|
29
29
|
readonly archivedThreadIds: readonly string[];
|
|
30
30
|
readonly isLoading: boolean;
|
|
31
|
+
readonly isLoadingMore: boolean;
|
|
32
|
+
readonly hasMore: boolean;
|
|
31
33
|
readonly threadItems: Readonly<
|
|
32
34
|
Record<string, Omit<ThreadListItemState, "isMain" | "threadId">>
|
|
33
35
|
>;
|
|
@@ -51,6 +53,7 @@ export type ThreadListRuntime = {
|
|
|
51
53
|
|
|
52
54
|
getLoadThreadsPromise(): Promise<void>;
|
|
53
55
|
reload(): Promise<void>;
|
|
56
|
+
loadMore(): Promise<void>;
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
const getThreadListState = (
|
|
@@ -62,6 +65,8 @@ const getThreadListState = (
|
|
|
62
65
|
threadIds: threadList.threadIds,
|
|
63
66
|
archivedThreadIds: threadList.archivedThreadIds,
|
|
64
67
|
isLoading: threadList.isLoading,
|
|
68
|
+
isLoadingMore: threadList.isLoadingMore ?? false,
|
|
69
|
+
hasMore: threadList.hasMore ?? false,
|
|
65
70
|
threadItems: threadList.threadItems,
|
|
66
71
|
};
|
|
67
72
|
};
|
|
@@ -138,6 +143,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
138
143
|
this.switchToNewThread = this.switchToNewThread.bind(this);
|
|
139
144
|
this.getLoadThreadsPromise = this.getLoadThreadsPromise.bind(this);
|
|
140
145
|
this.reload = this.reload.bind(this);
|
|
146
|
+
this.loadMore = this.loadMore.bind(this);
|
|
141
147
|
this.getState = this.getState.bind(this);
|
|
142
148
|
this.subscribe = this.subscribe.bind(this);
|
|
143
149
|
this.getById = this.getById.bind(this);
|
|
@@ -162,6 +168,10 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
162
168
|
return this._core.reload?.() ?? RESOLVED_PROMISE;
|
|
163
169
|
}
|
|
164
170
|
|
|
171
|
+
public loadMore(): Promise<void> {
|
|
172
|
+
return this._core.loadMore?.() ?? RESOLVED_PROMISE;
|
|
173
|
+
}
|
|
174
|
+
|
|
165
175
|
public getState(): ThreadListState {
|
|
166
176
|
return this._getState();
|
|
167
177
|
}
|
|
@@ -252,10 +252,6 @@ export type ThreadRuntime = {
|
|
|
252
252
|
*/
|
|
253
253
|
append(message: CreateAppendMessage): void;
|
|
254
254
|
|
|
255
|
-
/**
|
|
256
|
-
* @deprecated pass an object with `parentId` instead. This will be removed in 0.12.0.
|
|
257
|
-
*/
|
|
258
|
-
startRun(parentId: string | null): void;
|
|
259
255
|
/**
|
|
260
256
|
* Start a new run with the given configuration.
|
|
261
257
|
* @param config The configuration for starting the run
|
|
@@ -268,11 +264,6 @@ export type ThreadRuntime = {
|
|
|
268
264
|
**/
|
|
269
265
|
resumeRun(config: CreateResumeRunConfig): void;
|
|
270
266
|
|
|
271
|
-
/**
|
|
272
|
-
* @deprecated Use `resumeRun` instead.
|
|
273
|
-
*/
|
|
274
|
-
unstable_resumeRun(config: CreateResumeRunConfig): void;
|
|
275
|
-
|
|
276
267
|
/**
|
|
277
268
|
* Export the thread state in the external store format.
|
|
278
269
|
* For AI SDK runtimes, this returns the AI SDK message format.
|
|
@@ -289,22 +280,10 @@ export type ThreadRuntime = {
|
|
|
289
280
|
*/
|
|
290
281
|
importExternalState(state: any): void;
|
|
291
282
|
|
|
292
|
-
/**
|
|
293
|
-
* Load external state into the thread.
|
|
294
|
-
* @deprecated Use importExternalState instead. This method will be removed in 0.12.0.
|
|
295
|
-
* @param state The state to load into the thread
|
|
296
|
-
*/
|
|
297
|
-
unstable_loadExternalState(state: any): void;
|
|
298
|
-
|
|
299
283
|
subscribe(callback: () => void): Unsubscribe;
|
|
300
284
|
cancelRun(): void;
|
|
301
285
|
getModelContext(): ModelContext;
|
|
302
286
|
|
|
303
|
-
/**
|
|
304
|
-
* @deprecated This method was renamed to `getModelContext`.
|
|
305
|
-
*/
|
|
306
|
-
getModelConfig(): ModelContext;
|
|
307
|
-
|
|
308
287
|
export(): ExportedMessageRepository;
|
|
309
288
|
import(repository: ExportedMessageRepository): void;
|
|
310
289
|
|
|
@@ -396,9 +375,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
396
375
|
protected __internal_bindMethods() {
|
|
397
376
|
this.append = this.append.bind(this);
|
|
398
377
|
this.resumeRun = this.resumeRun.bind(this);
|
|
399
|
-
this.unstable_resumeRun = this.unstable_resumeRun.bind(this);
|
|
400
|
-
this.unstable_loadExternalState =
|
|
401
|
-
this.unstable_loadExternalState.bind(this);
|
|
402
378
|
this.importExternalState = this.importExternalState.bind(this);
|
|
403
379
|
this.exportExternalState = this.exportExternalState.bind(this);
|
|
404
380
|
this.startRun = this.startRun.bind(this);
|
|
@@ -418,7 +394,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
418
394
|
this.subscribe = this.subscribe.bind(this);
|
|
419
395
|
this.unstable_on = this.unstable_on.bind(this);
|
|
420
396
|
this.getModelContext = this.getModelContext.bind(this);
|
|
421
|
-
this.getModelConfig = this.getModelConfig.bind(this);
|
|
422
397
|
this.getState = this.getState.bind(this);
|
|
423
398
|
}
|
|
424
399
|
|
|
@@ -444,15 +419,7 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
444
419
|
return this._threadBinding.getState().getModelContext();
|
|
445
420
|
}
|
|
446
421
|
|
|
447
|
-
public
|
|
448
|
-
return this.getModelContext();
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
public startRun(configOrParentId: string | null | CreateStartRunConfig) {
|
|
452
|
-
const config =
|
|
453
|
-
configOrParentId === null || typeof configOrParentId === "string"
|
|
454
|
-
? { parentId: configOrParentId }
|
|
455
|
-
: configOrParentId;
|
|
422
|
+
public startRun(config: CreateStartRunConfig) {
|
|
456
423
|
return this._threadBinding.getState().startRun(toStartRunConfig(config));
|
|
457
424
|
}
|
|
458
425
|
|
|
@@ -460,11 +427,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
460
427
|
return this._threadBinding.getState().resumeRun(toResumeRunConfig(config));
|
|
461
428
|
}
|
|
462
429
|
|
|
463
|
-
/** @deprecated Use `resumeRun` instead. */
|
|
464
|
-
public unstable_resumeRun(config: CreateResumeRunConfig) {
|
|
465
|
-
return this.resumeRun(config);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
430
|
public exportExternalState() {
|
|
469
431
|
return this._threadBinding.getState().exportExternalState();
|
|
470
432
|
}
|
|
@@ -473,10 +435,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
473
435
|
this._threadBinding.getState().importExternalState(state);
|
|
474
436
|
}
|
|
475
437
|
|
|
476
|
-
public unstable_loadExternalState(state: any) {
|
|
477
|
-
this._threadBinding.getState().unstable_loadExternalState(state);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
438
|
public cancelRun() {
|
|
481
439
|
this._threadBinding.getState().cancelRun();
|
|
482
440
|
}
|
|
@@ -575,7 +533,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
575
533
|
const thread = this._threadBinding.getState();
|
|
576
534
|
|
|
577
535
|
const branches = thread.getBranches(message.id);
|
|
578
|
-
const submittedFeedback = message.metadata.submittedFeedback;
|
|
579
536
|
|
|
580
537
|
return {
|
|
581
538
|
...message,
|
|
@@ -590,8 +547,6 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
590
547
|
|
|
591
548
|
speech:
|
|
592
549
|
speechState?.messageId === message.id ? speechState : undefined,
|
|
593
|
-
|
|
594
|
-
submittedFeedback,
|
|
595
550
|
} satisfies MessageState;
|
|
596
551
|
},
|
|
597
552
|
subscribe: (callback) => this._threadBinding.subscribe(callback),
|
|
@@ -61,7 +61,6 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
|
|
61
61
|
public abstract cancelRun(): void;
|
|
62
62
|
public abstract exportExternalState(): any;
|
|
63
63
|
public abstract importExternalState(state: any): void;
|
|
64
|
-
public abstract unstable_loadExternalState(state: any): void;
|
|
65
64
|
|
|
66
65
|
protected _voiceMessages: ThreadMessage[] = [];
|
|
67
66
|
protected _voiceGeneration = 0;
|
|
@@ -17,6 +17,8 @@ export type ThreadListItemCoreState = {
|
|
|
17
17
|
|
|
18
18
|
export type ThreadListRuntimeCore = {
|
|
19
19
|
readonly isLoading: boolean;
|
|
20
|
+
readonly isLoadingMore?: boolean;
|
|
21
|
+
readonly hasMore?: boolean;
|
|
20
22
|
mainThreadId: string;
|
|
21
23
|
newThreadId: string | undefined;
|
|
22
24
|
|
|
@@ -35,6 +37,7 @@ export type ThreadListRuntimeCore = {
|
|
|
35
37
|
|
|
36
38
|
getLoadThreadsPromise(): Promise<void>;
|
|
37
39
|
reload?(): Promise<void>;
|
|
40
|
+
loadMore?(): Promise<void>;
|
|
38
41
|
|
|
39
42
|
detach(threadId: string): Promise<void>;
|
|
40
43
|
rename(threadId: string, newTitle: string): Promise<void>;
|
|
@@ -194,9 +194,4 @@ export type ThreadRuntimeCore = Readonly<{
|
|
|
194
194
|
event: E,
|
|
195
195
|
callback: ThreadRuntimeEventCallback<E>,
|
|
196
196
|
): Unsubscribe;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* @deprecated Use importExternalState instead. This method will be removed in 0.12.0.
|
|
200
|
-
*/
|
|
201
|
-
unstable_loadExternalState: (state: any) => void;
|
|
202
197
|
}>;
|
|
@@ -50,11 +50,6 @@ export type ChatModelRunOptions = {
|
|
|
50
50
|
readonly abortSignal: AbortSignal;
|
|
51
51
|
readonly context: ModelContext;
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated This field was renamed to `context`.
|
|
55
|
-
*/
|
|
56
|
-
readonly config: ModelContext;
|
|
57
|
-
|
|
58
53
|
readonly unstable_assistantMessageId?: string | undefined;
|
|
59
54
|
readonly unstable_threadId?: string | undefined;
|
|
60
55
|
readonly unstable_parentId?: string | null | undefined;
|
|
@@ -8,14 +8,6 @@ type WithInnerMessages<T> = {
|
|
|
8
8
|
[symbolInnerMessages]?: T[];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use `getExternalStoreMessages` (plural) instead. This function will be removed in 0.12.0.
|
|
13
|
-
*/
|
|
14
|
-
export const getExternalStoreMessage = <T>(input: ThreadMessage) => {
|
|
15
|
-
const withInnerMessages = input as WithInnerMessages<T>;
|
|
16
|
-
return withInnerMessages[symbolInnerMessage];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
11
|
const EMPTY_ARRAY: never[] = [];
|
|
20
12
|
|
|
21
13
|
/**
|
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Tool,
|
|
3
|
-
toToolsJSONSchema,
|
|
4
|
-
type ToolJSONSchema,
|
|
5
|
-
} from "assistant-stream";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Use `toToolsJSONSchema` from `assistant-stream` instead.
|
|
9
|
-
*/
|
|
10
|
-
export function toAISDKTools(
|
|
11
|
-
tools: Record<string, Tool>,
|
|
12
|
-
): Record<string, ToolJSONSchema> {
|
|
13
|
-
return toToolsJSONSchema(tools, { filter: () => true });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Use `toToolsJSONSchema` from `assistant-stream` instead, which includes filtering by default.
|
|
18
|
-
*/
|
|
19
|
-
export function getEnabledTools(
|
|
20
|
-
tools: Record<string, Tool>,
|
|
21
|
-
): Record<string, Tool> {
|
|
22
|
-
return Object.fromEntries(
|
|
23
|
-
Object.entries(tools).filter(
|
|
24
|
-
([, tool]) => !tool.disabled && tool.type !== "backend",
|
|
25
|
-
),
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
1
|
export async function createRequestHeaders(
|
|
30
2
|
headersValue:
|
|
31
3
|
| Record<string, string>
|
|
@@ -316,10 +316,6 @@ export class ExternalStoreThreadRuntimeCore
|
|
|
316
316
|
this._store.onLoadExternalState(state);
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
public unstable_loadExternalState(state: any): void {
|
|
320
|
-
this.importExternalState(state);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
319
|
public cancelRun(): void {
|
|
324
320
|
if (!this._store.onCancel)
|
|
325
321
|
throw new Error("Runtime does not support cancelling runs.");
|
|
@@ -226,10 +226,6 @@ export class LocalThreadRuntimeCore
|
|
|
226
226
|
throw new Error("Runtime does not support importing external states.");
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
public unstable_loadExternalState(): void {
|
|
230
|
-
throw new Error("Runtime does not support importing external states.");
|
|
231
|
-
}
|
|
232
|
-
|
|
233
229
|
public async startRun(
|
|
234
230
|
{ parentId, runConfig }: StartRunConfig,
|
|
235
231
|
runCallback?: ChatModelAdapter["run"],
|
|
@@ -405,7 +401,6 @@ export class LocalThreadRuntimeCore
|
|
|
405
401
|
runConfig: this._lastRunConfig,
|
|
406
402
|
abortSignal,
|
|
407
403
|
context,
|
|
408
|
-
config: context,
|
|
409
404
|
unstable_assistantMessageId: message.id,
|
|
410
405
|
unstable_threadId: threadId,
|
|
411
406
|
unstable_parentId: parentId,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
RemoteThreadInitializeResponse,
|
|
3
|
+
RemoteThreadMetadata,
|
|
4
|
+
} from "./types";
|
|
2
5
|
|
|
3
6
|
export type RemoteThreadData =
|
|
4
7
|
| {
|
|
@@ -34,8 +37,58 @@ export function createThreadMappingId(id: string): THREAD_MAPPING_ID {
|
|
|
34
37
|
return id as THREAD_MAPPING_ID;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
export const normalizeCursor = (c: string | undefined): string | undefined =>
|
|
41
|
+
c || undefined;
|
|
42
|
+
|
|
43
|
+
type ClassifyAccumulator = {
|
|
44
|
+
threadIds: string[];
|
|
45
|
+
archivedThreadIds: string[];
|
|
46
|
+
threadIdMap: Record<string, THREAD_MAPPING_ID>;
|
|
47
|
+
threadData: Record<THREAD_MAPPING_ID, RemoteThreadData>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const classifyThreads = (
|
|
51
|
+
threads: readonly RemoteThreadMetadata[],
|
|
52
|
+
acc: ClassifyAccumulator,
|
|
53
|
+
): ClassifyAccumulator => {
|
|
54
|
+
for (const thread of threads) {
|
|
55
|
+
if (acc.threadIdMap[thread.remoteId] !== undefined) continue;
|
|
56
|
+
|
|
57
|
+
switch (thread.status) {
|
|
58
|
+
case "regular":
|
|
59
|
+
acc.threadIds.push(thread.remoteId);
|
|
60
|
+
break;
|
|
61
|
+
case "archived":
|
|
62
|
+
acc.archivedThreadIds.push(thread.remoteId);
|
|
63
|
+
break;
|
|
64
|
+
default: {
|
|
65
|
+
const _exhaustiveCheck: never = thread.status;
|
|
66
|
+
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const mappingId = createThreadMappingId(thread.remoteId);
|
|
71
|
+
acc.threadIdMap[thread.remoteId] = mappingId;
|
|
72
|
+
acc.threadData[mappingId] = {
|
|
73
|
+
id: thread.remoteId,
|
|
74
|
+
remoteId: thread.remoteId,
|
|
75
|
+
externalId: thread.externalId,
|
|
76
|
+
status: thread.status,
|
|
77
|
+
title: thread.title,
|
|
78
|
+
custom: thread.custom,
|
|
79
|
+
initializeTask: Promise.resolve({
|
|
80
|
+
remoteId: thread.remoteId,
|
|
81
|
+
externalId: thread.externalId,
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return acc;
|
|
86
|
+
};
|
|
87
|
+
|
|
37
88
|
export type RemoteThreadState = {
|
|
38
89
|
readonly isLoading: boolean;
|
|
90
|
+
readonly isLoadingMore: boolean;
|
|
91
|
+
readonly cursor: string | undefined;
|
|
39
92
|
readonly newThreadId: string | undefined;
|
|
40
93
|
readonly threadIds: readonly string[];
|
|
41
94
|
readonly archivedThreadIds: readonly string[];
|
|
@@ -18,10 +18,15 @@ export type RemoteThreadMetadata = {
|
|
|
18
18
|
|
|
19
19
|
export type RemoteThreadListResponse = {
|
|
20
20
|
threads: RemoteThreadMetadata[];
|
|
21
|
+
nextCursor?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type RemoteThreadListPageOptions = {
|
|
25
|
+
after?: string | undefined;
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
export type RemoteThreadListAdapter = {
|
|
24
|
-
list(): Promise<RemoteThreadListResponse>;
|
|
29
|
+
list(params?: RemoteThreadListPageOptions): Promise<RemoteThreadListResponse>;
|
|
25
30
|
|
|
26
31
|
rename(remoteId: string, newTitle: string): Promise<void>;
|
|
27
32
|
archive(remoteId: string): Promise<void>;
|
|
@@ -53,6 +53,8 @@ export const ThreadListClient = resource(
|
|
|
53
53
|
mainThreadId: runtimeState.mainThreadId,
|
|
54
54
|
newThreadId: runtimeState.newThreadId ?? null,
|
|
55
55
|
isLoading: runtimeState.isLoading,
|
|
56
|
+
isLoadingMore: runtimeState.isLoadingMore,
|
|
57
|
+
hasMore: runtimeState.hasMore,
|
|
56
58
|
threadIds: runtimeState.threadIds,
|
|
57
59
|
archivedThreadIds: runtimeState.archivedThreadIds,
|
|
58
60
|
threadItems: threadItems.state,
|
|
@@ -87,6 +89,7 @@ export const ThreadListClient = resource(
|
|
|
87
89
|
},
|
|
88
90
|
getLoadThreadsPromise: () => runtime.getLoadThreadsPromise(),
|
|
89
91
|
reload: () => runtime.reload(),
|
|
92
|
+
loadMore: () => runtime.loadMore(),
|
|
90
93
|
__internal_getAssistantRuntime: () => __internal_assistantRuntime,
|
|
91
94
|
};
|
|
92
95
|
},
|
|
@@ -116,7 +116,6 @@ export const ThreadClient = resource(
|
|
|
116
116
|
append: runtime.append,
|
|
117
117
|
startRun: runtime.startRun,
|
|
118
118
|
resumeRun: runtime.resumeRun,
|
|
119
|
-
unstable_resumeRun: runtime.resumeRun,
|
|
120
119
|
cancelRun: runtime.cancelRun,
|
|
121
120
|
getModelContext: runtime.getModelContext,
|
|
122
121
|
export: runtime.export,
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ThreadMessage } from "../../types/message";
|
|
2
2
|
import type { RunConfig } from "../../types/message";
|
|
3
|
-
import type {
|
|
4
|
-
SpeechState,
|
|
5
|
-
SubmittedFeedback,
|
|
6
|
-
} from "../../runtime/interfaces/thread-runtime-core";
|
|
3
|
+
import type { SpeechState } from "../../runtime/interfaces/thread-runtime-core";
|
|
7
4
|
import type { MessageRuntime } from "../../runtime/api/message-runtime";
|
|
8
5
|
import type { ComposerMethods, ComposerState } from "./composer";
|
|
9
6
|
import type { PartMethods, PartState } from "./part";
|
|
@@ -31,8 +28,6 @@ export type MessageState = ThreadMessage & {
|
|
|
31
28
|
* });
|
|
32
29
|
*/
|
|
33
30
|
readonly speech: SpeechState | undefined;
|
|
34
|
-
/** @deprecated Use `message.metadata.submittedFeedback` instead. This will be removed in 0.12.0. */
|
|
35
|
-
readonly submittedFeedback: SubmittedFeedback | undefined;
|
|
36
31
|
readonly composer: ComposerState;
|
|
37
32
|
readonly parts: readonly PartState[];
|
|
38
33
|
readonly isCopied: boolean;
|
|
@@ -98,11 +98,6 @@ export type ThreadMethods = {
|
|
|
98
98
|
* @param config The configuration for resuming the run
|
|
99
99
|
*/
|
|
100
100
|
resumeRun(config: CreateResumeRunConfig): void;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated Use `resumeRun` instead.
|
|
104
|
-
*/
|
|
105
|
-
unstable_resumeRun(config: CreateResumeRunConfig): void;
|
|
106
101
|
cancelRun(): void;
|
|
107
102
|
getModelContext(): ModelContext;
|
|
108
103
|
export(): ExportedMessageRepository;
|
|
@@ -9,6 +9,8 @@ export type ThreadsState = {
|
|
|
9
9
|
readonly mainThreadId: string;
|
|
10
10
|
readonly newThreadId: string | null;
|
|
11
11
|
readonly isLoading: boolean;
|
|
12
|
+
readonly isLoadingMore: boolean;
|
|
13
|
+
readonly hasMore: boolean;
|
|
12
14
|
readonly threadIds: readonly string[];
|
|
13
15
|
readonly archivedThreadIds: readonly string[];
|
|
14
16
|
readonly threadItems: readonly ThreadListItemState[];
|
|
@@ -28,6 +30,7 @@ export type ThreadsMethods = {
|
|
|
28
30
|
thread(selector: "main"): ThreadMethods;
|
|
29
31
|
getLoadThreadsPromise(): Promise<void>;
|
|
30
32
|
reload(): Promise<void>;
|
|
33
|
+
loadMore(): Promise<void>;
|
|
31
34
|
__internal_getAssistantRuntime?(): AssistantRuntime;
|
|
32
35
|
};
|
|
33
36
|
|