@assistant-ui/react 0.7.64 → 0.7.66
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/api/ThreadListItemRuntime.d.ts +2 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +5 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs +5 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/cloud/AssistantCloudThreads.d.ts +1 -1
- package/dist/cloud/AssistantCloudThreads.d.ts.map +1 -1
- package/dist/cloud/AssistantCloudThreads.js.map +1 -1
- package/dist/cloud/AssistantCloudThreads.mjs.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts +1 -1
- package/dist/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.js +8 -83
- package/dist/cloud/useCloudThreadListRuntime.js.map +1 -1
- package/dist/cloud/useCloudThreadListRuntime.mjs +8 -89
- package/dist/cloud/useCloudThreadListRuntime.mjs.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts +1 -2
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +4 -6
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.mjs +4 -6
- package/dist/primitives/thread/useThreadViewportAutoScroll.mjs.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.d.ts.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.d.ts +22 -3
- package/dist/runtimes/edge/EdgeChatAdapter.d.ts.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.js +44 -13
- package/dist/runtimes/edge/EdgeChatAdapter.js.map +1 -1
- package/dist/runtimes/edge/EdgeChatAdapter.mjs +34 -13
- package/dist/runtimes/edge/EdgeChatAdapter.mjs.map +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.d.ts +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +3 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +3 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.d.ts +1 -0
- package/dist/runtimes/local/ChatModelAdapter.d.ts.map +1 -1
- package/dist/runtimes/local/ChatModelAdapter.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts +4 -1
- package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.js +2 -0
- package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeOptions.mjs +2 -0
- package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +21 -31
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +43 -147
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +43 -147
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +4 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +4 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.d.ts +1 -1
- package/dist/runtimes/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +10 -1
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +10 -1
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +4 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +4 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +6 -6
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +25 -23
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +25 -23
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts +13 -0
- package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/cloud.js +96 -0
- package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/cloud.mjs +76 -0
- package/dist/runtimes/remote-thread-list/adapter/cloud.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +12 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js +58 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.mjs +35 -0
- package/dist/runtimes/remote-thread-list/adapter/in-memory.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/index.d.ts +2 -1
- package/dist/runtimes/remote-thread-list/index.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/index.js +3 -0
- package/dist/runtimes/remote-thread-list/index.js.map +1 -1
- package/dist/runtimes/remote-thread-list/index.mjs +2 -0
- package/dist/runtimes/remote-thread-list/index.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/types.d.ts +6 -6
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
- package/dist/runtimes/remote-thread-list/types.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts +2 -2
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +7 -7
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +7 -7
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.d.ts.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +7 -17
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.mjs +7 -17
- package/dist/utils/hooks/useOnResizeContent.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/ThreadListItemRuntime.ts +8 -0
- package/src/cloud/AssistantCloudThreads.tsx +1 -1
- package/src/cloud/useCloudThreadListRuntime.tsx +8 -110
- package/src/primitives/thread/useThreadViewportAutoScroll.tsx +3 -8
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +1 -0
- package/src/runtimes/edge/EdgeChatAdapter.ts +90 -19
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +4 -0
- package/src/runtimes/local/ChatModelAdapter.tsx +1 -0
- package/src/runtimes/local/LocalRuntimeOptions.tsx +4 -0
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +47 -190
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +3 -0
- package/src/runtimes/local/useLocalRuntime.tsx +15 -2
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +7 -0
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +27 -28
- package/src/runtimes/remote-thread-list/adapter/cloud.tsx +99 -0
- package/src/runtimes/remote-thread-list/adapter/in-memory.tsx +43 -0
- package/src/runtimes/remote-thread-list/index.ts +3 -4
- package/src/runtimes/remote-thread-list/types.tsx +10 -12
- package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +8 -8
- package/src/utils/hooks/useOnResizeContent.tsx +7 -21
|
@@ -1,42 +1,32 @@
|
|
|
1
|
-
import type { Unsubscribe } from "../../types";
|
|
2
1
|
import { ThreadListRuntimeCore } from "../core/ThreadListRuntimeCore";
|
|
2
|
+
import { BaseSubscribable } from "../remote-thread-list/BaseSubscribable";
|
|
3
3
|
import { LocalThreadRuntimeCore } from "./LocalThreadRuntimeCore";
|
|
4
|
-
export type ThreadListAdapter = {
|
|
5
|
-
subscribe(callback: () => void): Unsubscribe;
|
|
6
|
-
};
|
|
7
|
-
export type LocalThreadData = {
|
|
8
|
-
readonly runtime: LocalThreadRuntimeCore;
|
|
9
|
-
readonly status: "new" | "regular" | "archived";
|
|
10
|
-
readonly threadId: string;
|
|
11
|
-
readonly title?: string | undefined;
|
|
12
|
-
};
|
|
13
4
|
export type LocalThreadFactory = () => LocalThreadRuntimeCore;
|
|
14
|
-
export declare class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
private _newThreadId;
|
|
20
|
-
get newThreadId(): string | undefined;
|
|
5
|
+
export declare class LocalThreadListRuntimeCore extends BaseSubscribable implements ThreadListRuntimeCore {
|
|
6
|
+
private _mainThread;
|
|
7
|
+
constructor(_threadFactory: LocalThreadFactory);
|
|
8
|
+
getMainThreadRuntimeCore(): LocalThreadRuntimeCore;
|
|
9
|
+
get newThreadId(): string;
|
|
21
10
|
get threadIds(): readonly string[];
|
|
22
11
|
get archivedThreadIds(): readonly string[];
|
|
23
|
-
private _mainThreadId;
|
|
24
12
|
get mainThreadId(): string;
|
|
25
|
-
|
|
26
|
-
getMainThreadRuntimeCore(): LocalThreadRuntimeCore;
|
|
27
|
-
getThreadRuntimeCore(threadId: string): LocalThreadRuntimeCore;
|
|
13
|
+
getThreadRuntimeCore(): never;
|
|
28
14
|
getLoadThreadsPromise(): Promise<void>;
|
|
29
|
-
getItemById(threadId: string):
|
|
30
|
-
|
|
15
|
+
getItemById(threadId: string): {
|
|
16
|
+
status: "regular";
|
|
17
|
+
threadId: string;
|
|
18
|
+
remoteId: string;
|
|
19
|
+
externalId: undefined;
|
|
20
|
+
title: undefined;
|
|
21
|
+
isMain: boolean;
|
|
22
|
+
};
|
|
23
|
+
switchToThread(): Promise<void>;
|
|
31
24
|
switchToNewThread(): Promise<void>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
delete(threadId: string): Promise<void>;
|
|
25
|
+
rename(): Promise<void>;
|
|
26
|
+
archive(): Promise<void>;
|
|
27
|
+
unarchive(): Promise<void>;
|
|
28
|
+
delete(): Promise<void>;
|
|
37
29
|
initialize(): never;
|
|
38
|
-
|
|
39
|
-
subscribe(callback: () => void): Unsubscribe;
|
|
40
|
-
private _notifySubscribers;
|
|
30
|
+
generateTitle(): never;
|
|
41
31
|
}
|
|
42
32
|
//# sourceMappingURL=LocalThreadListRuntimeCore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LocalThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CAAC;AAG9D,qBAAa,0BACX,SAAQ,gBACR,YAAW,qBAAqB;IAEhC,OAAO,CAAC,WAAW,CAAyB;gBAChC,cAAc,EAAE,kBAAkB;IAMvC,wBAAwB;IAI/B,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAW,SAAS,IAAI,SAAS,MAAM,EAAE,CAExC;IAED,IAAW,iBAAiB,IAAI,SAAS,MAAM,EAAE,CAEhD;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;IAEM,oBAAoB,IAAI,KAAK;IAI7B,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,WAAW,CAAC,QAAQ,EAAE,MAAM;;;;;;;;IActB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,UAAU,IAAI,KAAK;IAInB,aAAa,IAAI,KAAK;CAG9B"}
|
|
@@ -23,175 +23,71 @@ __export(LocalThreadListRuntimeCore_exports, {
|
|
|
23
23
|
LocalThreadListRuntimeCore: () => LocalThreadListRuntimeCore
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(LocalThreadListRuntimeCore_exports);
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var LocalThreadListRuntimeCore = class {
|
|
26
|
+
var import_BaseSubscribable = require("../remote-thread-list/BaseSubscribable.js");
|
|
27
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
28
|
+
var LocalThreadListRuntimeCore = class extends import_BaseSubscribable.BaseSubscribable {
|
|
29
|
+
_mainThread;
|
|
29
30
|
constructor(_threadFactory) {
|
|
30
|
-
|
|
31
|
-
this.
|
|
31
|
+
super();
|
|
32
|
+
this._mainThread = _threadFactory();
|
|
33
|
+
}
|
|
34
|
+
getMainThreadRuntimeCore() {
|
|
35
|
+
return this._mainThread;
|
|
32
36
|
}
|
|
33
|
-
_threadData = /* @__PURE__ */ new Map();
|
|
34
|
-
_threadIds = [];
|
|
35
|
-
_archivedThreadIds = [];
|
|
36
|
-
_newThreadId;
|
|
37
37
|
get newThreadId() {
|
|
38
|
-
|
|
38
|
+
throw new Error("Method not implemented.");
|
|
39
39
|
}
|
|
40
40
|
get threadIds() {
|
|
41
|
-
|
|
41
|
+
throw EMPTY_ARRAY;
|
|
42
42
|
}
|
|
43
43
|
get archivedThreadIds() {
|
|
44
|
-
|
|
44
|
+
throw EMPTY_ARRAY;
|
|
45
45
|
}
|
|
46
|
-
_mainThreadId;
|
|
47
46
|
get mainThreadId() {
|
|
48
|
-
return
|
|
47
|
+
return "__DEFAULT_ID__";
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!result)
|
|
53
|
-
throw new Error("Main thread not found. This is a bug in assistant-ui.");
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
getThreadRuntimeCore(threadId) {
|
|
57
|
-
const result = this._threadData.get(threadId)?.runtime;
|
|
58
|
-
if (!result) throw new Error("Thread not found.");
|
|
59
|
-
return result;
|
|
49
|
+
getThreadRuntimeCore() {
|
|
50
|
+
throw new Error("Method not implemented.");
|
|
60
51
|
}
|
|
61
52
|
getLoadThreadsPromise() {
|
|
62
|
-
|
|
53
|
+
throw new Error("Method not implemented.");
|
|
63
54
|
}
|
|
64
55
|
getItemById(threadId) {
|
|
65
|
-
|
|
56
|
+
if (threadId === this.mainThreadId) {
|
|
57
|
+
return {
|
|
58
|
+
status: "regular",
|
|
59
|
+
threadId: this.mainThreadId,
|
|
60
|
+
remoteId: this.mainThreadId,
|
|
61
|
+
externalId: void 0,
|
|
62
|
+
title: void 0,
|
|
63
|
+
isMain: true
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Method not implemented");
|
|
66
67
|
}
|
|
67
|
-
async switchToThread(
|
|
68
|
-
|
|
69
|
-
const data = this._threadData.get(threadId);
|
|
70
|
-
if (!data) throw new Error("Thread not found");
|
|
71
|
-
if (data.status === "archived") await this.unarchive(threadId);
|
|
72
|
-
this._mainThreadId = data.threadId;
|
|
73
|
-
this._notifySubscribers();
|
|
68
|
+
async switchToThread() {
|
|
69
|
+
throw new Error("Method not implemented.");
|
|
74
70
|
}
|
|
75
71
|
switchToNewThread() {
|
|
76
|
-
|
|
77
|
-
let threadId;
|
|
78
|
-
do {
|
|
79
|
-
threadId = (0, import_idUtils.generateId)();
|
|
80
|
-
} while (this._threadData.has(threadId));
|
|
81
|
-
const runtime = this._threadFactory();
|
|
82
|
-
const dispose = runtime.unstable_on("initialize", () => {
|
|
83
|
-
dispose();
|
|
84
|
-
const data = this._threadData.get(threadId);
|
|
85
|
-
if (!data) throw new Error("Thread not found");
|
|
86
|
-
this._stateOp(threadId, "regular");
|
|
87
|
-
});
|
|
88
|
-
this._threadData.set(threadId, {
|
|
89
|
-
runtime,
|
|
90
|
-
status: "new",
|
|
91
|
-
threadId
|
|
92
|
-
});
|
|
93
|
-
this._newThreadId = threadId;
|
|
94
|
-
}
|
|
95
|
-
this.switchToThread(this._newThreadId);
|
|
96
|
-
return Promise.resolve();
|
|
97
|
-
}
|
|
98
|
-
async _stateOp(threadId, newState) {
|
|
99
|
-
const data = this._threadData.get(threadId);
|
|
100
|
-
if (!data) throw new Error("Thread not found");
|
|
101
|
-
const { status: lastState } = data;
|
|
102
|
-
if (lastState === newState) return;
|
|
103
|
-
switch (lastState) {
|
|
104
|
-
case "new":
|
|
105
|
-
this._newThreadId = void 0;
|
|
106
|
-
break;
|
|
107
|
-
case "regular":
|
|
108
|
-
this._threadIds = this._threadIds.filter((t) => t !== threadId);
|
|
109
|
-
break;
|
|
110
|
-
case "archived":
|
|
111
|
-
this._archivedThreadIds = this._archivedThreadIds.filter(
|
|
112
|
-
(t) => t !== threadId
|
|
113
|
-
);
|
|
114
|
-
break;
|
|
115
|
-
default: {
|
|
116
|
-
const _exhaustiveCheck = lastState;
|
|
117
|
-
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
switch (newState) {
|
|
121
|
-
case "regular":
|
|
122
|
-
this._threadIds = [data.threadId, ...this._threadIds];
|
|
123
|
-
break;
|
|
124
|
-
case "archived":
|
|
125
|
-
this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];
|
|
126
|
-
break;
|
|
127
|
-
case "deleted":
|
|
128
|
-
this._threadData.delete(threadId);
|
|
129
|
-
break;
|
|
130
|
-
default: {
|
|
131
|
-
const _exhaustiveCheck = newState;
|
|
132
|
-
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (newState !== "deleted") {
|
|
136
|
-
this._threadData.set(threadId, {
|
|
137
|
-
...data,
|
|
138
|
-
status: newState
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
if (threadId === this._mainThreadId && (newState === "archived" || newState === "deleted")) {
|
|
142
|
-
const lastThreadId = this._threadIds[0];
|
|
143
|
-
if (lastThreadId) {
|
|
144
|
-
await this.switchToThread(lastThreadId);
|
|
145
|
-
} else {
|
|
146
|
-
await this.switchToNewThread();
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
this._notifySubscribers();
|
|
150
|
-
}
|
|
72
|
+
throw new Error("Method not implemented.");
|
|
151
73
|
}
|
|
152
|
-
rename(
|
|
153
|
-
|
|
154
|
-
if (!data) throw new Error("Thread not found");
|
|
155
|
-
this._threadData.set(threadId, {
|
|
156
|
-
...data,
|
|
157
|
-
title: newTitle
|
|
158
|
-
});
|
|
159
|
-
this._notifySubscribers();
|
|
160
|
-
return Promise.resolve();
|
|
161
|
-
}
|
|
162
|
-
archive(threadId) {
|
|
163
|
-
const data = this._threadData.get(threadId);
|
|
164
|
-
if (!data) throw new Error("Thread not found");
|
|
165
|
-
if (data.status !== "regular")
|
|
166
|
-
throw new Error("Thread is not yet initialized or already archived");
|
|
167
|
-
this._stateOp(threadId, "archived");
|
|
168
|
-
return Promise.resolve();
|
|
169
|
-
}
|
|
170
|
-
unarchive(threadId) {
|
|
171
|
-
const data = this._threadData.get(threadId);
|
|
172
|
-
if (!data) throw new Error("Thread not found");
|
|
173
|
-
if (data.status !== "archived") throw new Error("Thread is not archived");
|
|
174
|
-
this._stateOp(threadId, "regular");
|
|
175
|
-
return Promise.resolve();
|
|
176
|
-
}
|
|
177
|
-
delete(threadId) {
|
|
178
|
-
const data = this._threadData.get(threadId);
|
|
179
|
-
if (!data) throw new Error("Thread not found");
|
|
180
|
-
if (data.status !== "regular" && data.status !== "archived")
|
|
181
|
-
throw new Error("Thread is not yet initialized");
|
|
182
|
-
this._stateOp(threadId, "deleted");
|
|
183
|
-
return Promise.resolve();
|
|
74
|
+
rename() {
|
|
75
|
+
throw new Error("Method not implemented.");
|
|
184
76
|
}
|
|
185
|
-
|
|
77
|
+
archive() {
|
|
78
|
+
throw new Error("Method not implemented.");
|
|
79
|
+
}
|
|
80
|
+
unarchive() {
|
|
81
|
+
throw new Error("Method not implemented.");
|
|
82
|
+
}
|
|
83
|
+
delete() {
|
|
186
84
|
throw new Error("Method not implemented.");
|
|
187
85
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this._subscriptions.add(callback);
|
|
191
|
-
return () => this._subscriptions.delete(callback);
|
|
86
|
+
initialize() {
|
|
87
|
+
throw new Error("Method not implemented.");
|
|
192
88
|
}
|
|
193
|
-
|
|
194
|
-
|
|
89
|
+
generateTitle() {
|
|
90
|
+
throw new Error("Method not implemented.");
|
|
195
91
|
}
|
|
196
92
|
};
|
|
197
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly status: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst RESOLVED_PROMISE = Promise.resolve();\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const result = this._threadData.get(threadId)?.runtime;\n if (!result) throw new Error(\"Thread not found.\");\n return result;\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return RESOLVED_PROMISE;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.status === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n status: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { status: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [data.threadId, ...this._threadIds];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n status: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\n }\n\n public initialize(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAA2B;AAgB3B,IAAM,mBAAmB,QAAQ,QAAQ;AAClC,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,aAAgC,CAAC;AAAA,EACjC,qBAAwC,CAAC;AAAA,EACzC;AAAA,EAER,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,eAAuB;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAMO,2BAA2B;AAChC,UAAM,SAAS,KAAK,YAAY,IAAI,KAAK,aAAa,GAAG;AACzD,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,uDAAuD;AACzE,WAAO;AAAA,EACT;AAAA,EAEO,qBAAqB,UAAkB;AAC5C,UAAM,SAAS,KAAK,YAAY,IAAI,QAAQ,GAAG;AAC/C,QAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,mBAAmB;AAChD,WAAO;AAAA,EACT;AAAA,EAEO,wBAAuC;AAC5C,WAAO;AAAA,EACT;AAAA,EAEO,YAAY,UAAkB;AACnC,WAAO,KAAK,YAAY,IAAI,QAAQ;AAAA,EACtC;AAAA,EAEA,MAAa,eAAe,UAAiC;AAC3D,QAAI,KAAK,kBAAkB,SAAU;AAErC,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ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U;AAClC,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,UAAU,UAAiC;AAChD,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAC7C,QAAI,KAAK,WAAW,WAAY,OAAM,IAAI,MAAM,wBAAwB;AAExE,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAC7C,QAAI,KAAK,WAAW,aAAa,KAAK,WAAW;AAC/C,YAAM,IAAI,MAAM,+BAA+B;AAEjD,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,aAAoB;AACzB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEQ,iBAAiB,oBAAI,IAAgB;AAAA,EAEtC,UAAU,UAAmC;AAClD,SAAK,eAAe,IAAI,QAAQ;AAChC,WAAO,MAAM,KAAK,eAAe,OAAO,QAAQ;AAAA,EAClD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,eAAgB,UAAS;AAAA,EACvD;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nexport class LocalThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _mainThread: LocalThreadRuntimeCore;\n constructor(_threadFactory: LocalThreadFactory) {\n super();\n\n this._mainThread = _threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public get newThreadId(): string {\n throw new Error(\"Method not implemented.\");\n }\n\n public get threadIds(): readonly string[] {\n throw EMPTY_ARRAY;\n }\n\n public get archivedThreadIds(): readonly string[] {\n throw EMPTY_ARRAY;\n }\n\n public get mainThreadId(): string {\n return \"__DEFAULT_ID__\";\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n if (threadId === this.mainThreadId) {\n return {\n status: \"regular\" as const,\n threadId: this.mainThreadId,\n remoteId: this.mainThreadId,\n externalId: undefined,\n title: undefined,\n isMain: true,\n };\n }\n throw new Error(\"Method not implemented\");\n }\n\n public async switchToThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public switchToNewThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public rename(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public archive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public unarchive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public delete(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public initialize(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public generateTitle(): never {\n throw new Error(\"Method not implemented.\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAAiC;AAKjC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAC7B,IAAM,6BAAN,cACG,yCAEV;AAAA,EACU;AAAA,EACR,YAAY,gBAAoC;AAC9C,UAAM;AAEN,SAAK,cAAc,eAAe;AAAA,EACpC;AAAA,EAEO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,cAAsB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|
4
|
-
var LocalThreadListRuntimeCore = class {
|
|
2
|
+
import { BaseSubscribable } from "../remote-thread-list/BaseSubscribable.mjs";
|
|
3
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
4
|
+
var LocalThreadListRuntimeCore = class extends BaseSubscribable {
|
|
5
|
+
_mainThread;
|
|
5
6
|
constructor(_threadFactory) {
|
|
6
|
-
|
|
7
|
-
this.
|
|
7
|
+
super();
|
|
8
|
+
this._mainThread = _threadFactory();
|
|
9
|
+
}
|
|
10
|
+
getMainThreadRuntimeCore() {
|
|
11
|
+
return this._mainThread;
|
|
8
12
|
}
|
|
9
|
-
_threadData = /* @__PURE__ */ new Map();
|
|
10
|
-
_threadIds = [];
|
|
11
|
-
_archivedThreadIds = [];
|
|
12
|
-
_newThreadId;
|
|
13
13
|
get newThreadId() {
|
|
14
|
-
|
|
14
|
+
throw new Error("Method not implemented.");
|
|
15
15
|
}
|
|
16
16
|
get threadIds() {
|
|
17
|
-
|
|
17
|
+
throw EMPTY_ARRAY;
|
|
18
18
|
}
|
|
19
19
|
get archivedThreadIds() {
|
|
20
|
-
|
|
20
|
+
throw EMPTY_ARRAY;
|
|
21
21
|
}
|
|
22
|
-
_mainThreadId;
|
|
23
22
|
get mainThreadId() {
|
|
24
|
-
return
|
|
23
|
+
return "__DEFAULT_ID__";
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!result)
|
|
29
|
-
throw new Error("Main thread not found. This is a bug in assistant-ui.");
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
getThreadRuntimeCore(threadId) {
|
|
33
|
-
const result = this._threadData.get(threadId)?.runtime;
|
|
34
|
-
if (!result) throw new Error("Thread not found.");
|
|
35
|
-
return result;
|
|
25
|
+
getThreadRuntimeCore() {
|
|
26
|
+
throw new Error("Method not implemented.");
|
|
36
27
|
}
|
|
37
28
|
getLoadThreadsPromise() {
|
|
38
|
-
|
|
29
|
+
throw new Error("Method not implemented.");
|
|
39
30
|
}
|
|
40
31
|
getItemById(threadId) {
|
|
41
|
-
|
|
32
|
+
if (threadId === this.mainThreadId) {
|
|
33
|
+
return {
|
|
34
|
+
status: "regular",
|
|
35
|
+
threadId: this.mainThreadId,
|
|
36
|
+
remoteId: this.mainThreadId,
|
|
37
|
+
externalId: void 0,
|
|
38
|
+
title: void 0,
|
|
39
|
+
isMain: true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
throw new Error("Method not implemented");
|
|
42
43
|
}
|
|
43
|
-
async switchToThread(
|
|
44
|
-
|
|
45
|
-
const data = this._threadData.get(threadId);
|
|
46
|
-
if (!data) throw new Error("Thread not found");
|
|
47
|
-
if (data.status === "archived") await this.unarchive(threadId);
|
|
48
|
-
this._mainThreadId = data.threadId;
|
|
49
|
-
this._notifySubscribers();
|
|
44
|
+
async switchToThread() {
|
|
45
|
+
throw new Error("Method not implemented.");
|
|
50
46
|
}
|
|
51
47
|
switchToNewThread() {
|
|
52
|
-
|
|
53
|
-
let threadId;
|
|
54
|
-
do {
|
|
55
|
-
threadId = generateId();
|
|
56
|
-
} while (this._threadData.has(threadId));
|
|
57
|
-
const runtime = this._threadFactory();
|
|
58
|
-
const dispose = runtime.unstable_on("initialize", () => {
|
|
59
|
-
dispose();
|
|
60
|
-
const data = this._threadData.get(threadId);
|
|
61
|
-
if (!data) throw new Error("Thread not found");
|
|
62
|
-
this._stateOp(threadId, "regular");
|
|
63
|
-
});
|
|
64
|
-
this._threadData.set(threadId, {
|
|
65
|
-
runtime,
|
|
66
|
-
status: "new",
|
|
67
|
-
threadId
|
|
68
|
-
});
|
|
69
|
-
this._newThreadId = threadId;
|
|
70
|
-
}
|
|
71
|
-
this.switchToThread(this._newThreadId);
|
|
72
|
-
return Promise.resolve();
|
|
73
|
-
}
|
|
74
|
-
async _stateOp(threadId, newState) {
|
|
75
|
-
const data = this._threadData.get(threadId);
|
|
76
|
-
if (!data) throw new Error("Thread not found");
|
|
77
|
-
const { status: lastState } = data;
|
|
78
|
-
if (lastState === newState) return;
|
|
79
|
-
switch (lastState) {
|
|
80
|
-
case "new":
|
|
81
|
-
this._newThreadId = void 0;
|
|
82
|
-
break;
|
|
83
|
-
case "regular":
|
|
84
|
-
this._threadIds = this._threadIds.filter((t) => t !== threadId);
|
|
85
|
-
break;
|
|
86
|
-
case "archived":
|
|
87
|
-
this._archivedThreadIds = this._archivedThreadIds.filter(
|
|
88
|
-
(t) => t !== threadId
|
|
89
|
-
);
|
|
90
|
-
break;
|
|
91
|
-
default: {
|
|
92
|
-
const _exhaustiveCheck = lastState;
|
|
93
|
-
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
switch (newState) {
|
|
97
|
-
case "regular":
|
|
98
|
-
this._threadIds = [data.threadId, ...this._threadIds];
|
|
99
|
-
break;
|
|
100
|
-
case "archived":
|
|
101
|
-
this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];
|
|
102
|
-
break;
|
|
103
|
-
case "deleted":
|
|
104
|
-
this._threadData.delete(threadId);
|
|
105
|
-
break;
|
|
106
|
-
default: {
|
|
107
|
-
const _exhaustiveCheck = newState;
|
|
108
|
-
throw new Error(`Unsupported state: ${_exhaustiveCheck}`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (newState !== "deleted") {
|
|
112
|
-
this._threadData.set(threadId, {
|
|
113
|
-
...data,
|
|
114
|
-
status: newState
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (threadId === this._mainThreadId && (newState === "archived" || newState === "deleted")) {
|
|
118
|
-
const lastThreadId = this._threadIds[0];
|
|
119
|
-
if (lastThreadId) {
|
|
120
|
-
await this.switchToThread(lastThreadId);
|
|
121
|
-
} else {
|
|
122
|
-
await this.switchToNewThread();
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
this._notifySubscribers();
|
|
126
|
-
}
|
|
48
|
+
throw new Error("Method not implemented.");
|
|
127
49
|
}
|
|
128
|
-
rename(
|
|
129
|
-
|
|
130
|
-
if (!data) throw new Error("Thread not found");
|
|
131
|
-
this._threadData.set(threadId, {
|
|
132
|
-
...data,
|
|
133
|
-
title: newTitle
|
|
134
|
-
});
|
|
135
|
-
this._notifySubscribers();
|
|
136
|
-
return Promise.resolve();
|
|
137
|
-
}
|
|
138
|
-
archive(threadId) {
|
|
139
|
-
const data = this._threadData.get(threadId);
|
|
140
|
-
if (!data) throw new Error("Thread not found");
|
|
141
|
-
if (data.status !== "regular")
|
|
142
|
-
throw new Error("Thread is not yet initialized or already archived");
|
|
143
|
-
this._stateOp(threadId, "archived");
|
|
144
|
-
return Promise.resolve();
|
|
145
|
-
}
|
|
146
|
-
unarchive(threadId) {
|
|
147
|
-
const data = this._threadData.get(threadId);
|
|
148
|
-
if (!data) throw new Error("Thread not found");
|
|
149
|
-
if (data.status !== "archived") throw new Error("Thread is not archived");
|
|
150
|
-
this._stateOp(threadId, "regular");
|
|
151
|
-
return Promise.resolve();
|
|
152
|
-
}
|
|
153
|
-
delete(threadId) {
|
|
154
|
-
const data = this._threadData.get(threadId);
|
|
155
|
-
if (!data) throw new Error("Thread not found");
|
|
156
|
-
if (data.status !== "regular" && data.status !== "archived")
|
|
157
|
-
throw new Error("Thread is not yet initialized");
|
|
158
|
-
this._stateOp(threadId, "deleted");
|
|
159
|
-
return Promise.resolve();
|
|
50
|
+
rename() {
|
|
51
|
+
throw new Error("Method not implemented.");
|
|
160
52
|
}
|
|
161
|
-
|
|
53
|
+
archive() {
|
|
54
|
+
throw new Error("Method not implemented.");
|
|
55
|
+
}
|
|
56
|
+
unarchive() {
|
|
57
|
+
throw new Error("Method not implemented.");
|
|
58
|
+
}
|
|
59
|
+
delete() {
|
|
162
60
|
throw new Error("Method not implemented.");
|
|
163
61
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this._subscriptions.add(callback);
|
|
167
|
-
return () => this._subscriptions.delete(callback);
|
|
62
|
+
initialize() {
|
|
63
|
+
throw new Error("Method not implemented.");
|
|
168
64
|
}
|
|
169
|
-
|
|
170
|
-
|
|
65
|
+
generateTitle() {
|
|
66
|
+
throw new Error("Method not implemented.");
|
|
171
67
|
}
|
|
172
68
|
};
|
|
173
69
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly status: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst RESOLVED_PROMISE = Promise.resolve();\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const result = this._threadData.get(threadId)?.runtime;\n if (!result) throw new Error(\"Thread not found.\");\n return result;\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return RESOLVED_PROMISE;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.status === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n status: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { status: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [data.threadId, ...this._threadIds];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [data.threadId, ...this._archivedThreadIds];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n status: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\n }\n\n public initialize(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";AAEA,SAAS,kBAAkB;AAgB3B,IAAM,mBAAmB,QAAQ,QAAQ;AAClC,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,aAA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AW,aAAa,KAAK,WAAW;AAC/C,YAAM,IAAI,MAAM,+BAA+B;AAEjD,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,aAAoB;AACzB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEQ,iBAAiB,oBAAI,IAAgB;AAAA,EAEtC,UAAU,UAAmC;AAClD,SAAK,eAAe,IAAI,QAAQ;AAChC,WAAO,MAAM,KAAK,eAAe,OAAO,QAAQ;AAAA,EAClD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,eAAgB,UAAS;AAAA,EACvD;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nexport class LocalThreadListRuntimeCore\n extends BaseSubscribable\n implements ThreadListRuntimeCore\n{\n private _mainThread: LocalThreadRuntimeCore;\n constructor(_threadFactory: LocalThreadFactory) {\n super();\n\n this._mainThread = _threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public get newThreadId(): string {\n throw new Error(\"Method not implemented.\");\n }\n\n public get threadIds(): readonly string[] {\n throw EMPTY_ARRAY;\n }\n\n public get archivedThreadIds(): readonly string[] {\n throw EMPTY_ARRAY;\n }\n\n public get mainThreadId(): string {\n return \"__DEFAULT_ID__\";\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n if (threadId === this.mainThreadId) {\n return {\n status: \"regular\" as const,\n threadId: this.mainThreadId,\n remoteId: this.mainThreadId,\n externalId: undefined,\n title: undefined,\n isMain: true,\n };\n }\n throw new Error(\"Method not implemented\");\n }\n\n public async switchToThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public switchToNewThread(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public rename(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public archive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public unarchive(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public delete(): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n public initialize(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public generateTitle(): never {\n throw new Error(\"Method not implemented.\");\n }\n}\n"],"mappings":";AACA,SAAS,wBAAwB;AAKjC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAC7B,IAAM,6BAAN,cACG,iBAEV;AAAA,EACU;AAAA,EACR,YAAY,gBAAoC;AAC9C,UAAM;AAEN,SAAK,cAAc,eAAe;AAAA,EACpC;AAAA,EAEO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,cAAsB;AAC/B,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEA,IAAW,YAA+B;AACxC,UAAM;AAAA,EACR;AAAA,EAEA,IAAW,oBAAuC;AAChD,UAAM;AAAA,EACR;AAAA,EAEA,IAAW,eAAuB;AAChC,WAAO;AAAA,EACT;AAAA,EAEO,uBAA8B;AACnC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,wBAAuC;AAC5C,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,YAAY,UAAkB;AACnC,QAAI,aAAa,KAAK,cAAc;AAClC,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,QACf,YAAY;AA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AE3C,OAAO,CAAC,cAAc,CAAiB;IAEvC,IAAW,MAAM,cAEhB;IAEM,qBAAqB,CAAC,OAAO,EAAE,uBAAuB;IA4B7D,OAAO,CAAC,YAAY,CAA4B;IACzC,eAAe;IAcT,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB7C,QAAQ,CAAC,EACpB,QAAQ,EACR,SAAS,GACV,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAqCnB,gBAAgB;IAgJvB,SAAS;IAKT,aAAa,CAAC,EACnB,SAAS,EACT,UAAU,EACV,MAAM,GACP,EAAE,oBAAoB;CAwCxB"}
|
|
@@ -200,7 +200,10 @@ var LocalThreadRuntimeCore = class extends import_BaseThreadRuntimeCore.BaseThre
|
|
|
200
200
|
abortSignal: this.abortController.signal,
|
|
201
201
|
context,
|
|
202
202
|
config: context,
|
|
203
|
-
unstable_assistantMessageId: message.id
|
|
203
|
+
unstable_assistantMessageId: message.id,
|
|
204
|
+
unstable_getMessage() {
|
|
205
|
+
return message;
|
|
206
|
+
}
|
|
204
207
|
});
|
|
205
208
|
if (Symbol.asyncIterator in promiseOrGenerator) {
|
|
206
209
|
for await (const r of promiseOrGenerator) {
|