@assistant-ui/react 0.7.64 → 0.7.66
Sign up to get free protection for your applications and to get access to all the features.
- 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,5 +1,5 @@
|
|
1
1
|
import { LocalRuntimeOptions } from "..";
|
2
2
|
import { DangerousInBrowserAdapterOptions } from "./DangerousInBrowserAdapter";
|
3
3
|
export type DangerousInBrowserRuntimeOptions = DangerousInBrowserAdapterOptions & LocalRuntimeOptions;
|
4
|
-
export declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => import("
|
4
|
+
export declare const useDangerousInBrowserRuntime: (options: DangerousInBrowserRuntimeOptions) => import("../..").AssistantRuntime;
|
5
5
|
//# sourceMappingURL=useDangerousInBrowserRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDangerousInBrowserRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAE1D,OAAO,EAEL,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,gCAAgC,GAC1C,gCAAgC,GAAG,mBAAmB,CAAC;AAEzD,eAAO,MAAM,4BAA4B,YAC9B,gCAAgC,
|
1
|
+
{"version":3,"file":"useDangerousInBrowserRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAE1D,OAAO,EAEL,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,gCAAgC,GAC1C,gCAAgC,GAAG,mBAAmB,CAAC;AAEzD,eAAO,MAAM,4BAA4B,YAC9B,gCAAgC,qCAM1C,CAAC"}
|
@@ -1,24 +1,43 @@
|
|
1
1
|
import { ChatModelAdapter, ChatModelRunOptions } from "../local/ChatModelAdapter";
|
2
2
|
import { ChatModelRunResult } from "../local/ChatModelAdapter";
|
3
|
+
import { ThreadMessage } from "../../types";
|
3
4
|
export declare function asAsyncIterable<T>(source: ReadableStream<T>): AsyncIterable<T>;
|
4
5
|
export type EdgeChatAdapterOptions = {
|
5
6
|
api: string;
|
7
|
+
/**
|
8
|
+
* Callback function to be called when the API response is received.
|
9
|
+
*/
|
10
|
+
onResponse?: (response: Response) => void | Promise<void>;
|
11
|
+
/**
|
12
|
+
* Optional callback function that is called when the assistant message is finished streaming.
|
13
|
+
*/
|
14
|
+
onFinish?: (message: ThreadMessage) => void;
|
15
|
+
/**
|
16
|
+
* Callback function to be called when an error is encountered.
|
17
|
+
*/
|
18
|
+
onError?: (error: Error) => void;
|
6
19
|
credentials?: RequestCredentials;
|
7
20
|
headers?: Record<string, string> | Headers;
|
8
21
|
body?: object;
|
9
22
|
/**
|
10
|
-
*
|
23
|
+
* @deprecated Renamed to `sendExtraMessageFields`.
|
11
24
|
*/
|
12
25
|
unstable_sendMessageIds?: boolean;
|
26
|
+
/**
|
27
|
+
* When enabled, the adapter will not strip `id` from messages in the messages array.
|
28
|
+
*/
|
29
|
+
sendExtraMessageFields?: boolean;
|
13
30
|
/**
|
14
31
|
* When enabled, the adapter will send messages in the format expected by the Vercel AI SDK Core.
|
15
32
|
* This feature will be removed in the future in favor of a better solution.
|
33
|
+
*
|
34
|
+
* `v2` sends frontend tools in a format that can be directly passed to `stremaText`
|
16
35
|
*/
|
17
|
-
unstable_AISDKInterop?: boolean | undefined;
|
36
|
+
unstable_AISDKInterop?: boolean | "v2" | undefined;
|
18
37
|
};
|
19
38
|
export declare class EdgeChatAdapter implements ChatModelAdapter {
|
20
39
|
private options;
|
21
40
|
constructor(options: EdgeChatAdapterOptions);
|
22
|
-
run({ messages, runConfig, abortSignal, context, unstable_assistantMessageId, }: ChatModelRunOptions): AsyncGenerator<ChatModelRunResult, void, unknown>;
|
41
|
+
run({ messages, runConfig, abortSignal, context, unstable_assistantMessageId, unstable_getMessage, }: ChatModelRunOptions): AsyncGenerator<ChatModelRunResult, void, unknown>;
|
23
42
|
}
|
24
43
|
//# sourceMappingURL=EdgeChatAdapter.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"EdgeChatAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
1
|
+
{"version":3,"file":"EdgeChatAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,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getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
8
|
var __export = (target, all) => {
|
7
9
|
for (var name in all)
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
17
|
}
|
16
18
|
return to;
|
17
19
|
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
29
|
|
20
30
|
// src/runtimes/edge/EdgeChatAdapter.ts
|
@@ -31,6 +41,8 @@ var import_streamPartDecoderStream = require("./streams/utils/streamPartDecoderS
|
|
31
41
|
var import_runResultStream = require("./streams/runResultStream.js");
|
32
42
|
var import_toolResultStream = require("./streams/toolResultStream.js");
|
33
43
|
var import_converters = require("./converters/index.js");
|
44
|
+
var import_zod = require("zod");
|
45
|
+
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
|
34
46
|
function asAsyncIterable(source) {
|
35
47
|
return {
|
36
48
|
[Symbol.asyncIterator]: () => {
|
@@ -44,6 +56,17 @@ function asAsyncIterable(source) {
|
|
44
56
|
}
|
45
57
|
};
|
46
58
|
}
|
59
|
+
var toAISDKTools = (tools) => {
|
60
|
+
return Object.fromEntries(
|
61
|
+
Object.entries(tools).map(([name, tool]) => [
|
62
|
+
name,
|
63
|
+
{
|
64
|
+
...tool.description ? { description: tool.description } : void 0,
|
65
|
+
parameters: tool.parameters instanceof import_zod.z.ZodType ? (0, import_zod_to_json_schema.default)(tool.parameters) : tool.parameters
|
66
|
+
}
|
67
|
+
])
|
68
|
+
);
|
69
|
+
};
|
47
70
|
var EdgeChatAdapter = class {
|
48
71
|
constructor(options) {
|
49
72
|
this.options = options;
|
@@ -53,7 +76,8 @@ var EdgeChatAdapter = class {
|
|
53
76
|
runConfig,
|
54
77
|
abortSignal,
|
55
78
|
context,
|
56
|
-
unstable_assistantMessageId
|
79
|
+
unstable_assistantMessageId,
|
80
|
+
unstable_getMessage
|
57
81
|
}) {
|
58
82
|
const headers = new Headers(this.options.headers);
|
59
83
|
headers.set("Content-Type", "application/json");
|
@@ -64,11 +88,11 @@ var EdgeChatAdapter = class {
|
|
64
88
|
body: JSON.stringify({
|
65
89
|
system: context.system,
|
66
90
|
messages: this.options.unstable_AISDKInterop ? (0, import_converters.toLanguageModelMessages)(messages, {
|
67
|
-
unstable_includeId: this.options.unstable_sendMessageIds
|
91
|
+
unstable_includeId: this.options.unstable_sendMessageIds || this.options.sendExtraMessageFields
|
68
92
|
}) : (0, import_toCoreMessages.toCoreMessages)(messages, {
|
69
|
-
unstable_includeId: this.options.unstable_sendMessageIds
|
93
|
+
unstable_includeId: this.options.unstable_sendMessageIds || this.options.sendExtraMessageFields
|
70
94
|
}),
|
71
|
-
tools: context.tools ? (0, import_toLanguageModelTools.toLanguageModelTools)(context.tools) : [],
|
95
|
+
tools: context.tools ? this.options.unstable_AISDKInterop === "v2" ? toAISDKTools(context.tools) : (0, import_toLanguageModelTools.toLanguageModelTools)(context.tools) : [],
|
72
96
|
unstable_assistantMessageId,
|
73
97
|
runConfig,
|
74
98
|
...context.callSettings,
|
@@ -77,16 +101,23 @@ var EdgeChatAdapter = class {
|
|
77
101
|
}),
|
78
102
|
signal: abortSignal
|
79
103
|
});
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
104
|
+
await this.options.onResponse?.(result);
|
105
|
+
try {
|
106
|
+
if (!result.ok) {
|
107
|
+
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
108
|
+
}
|
109
|
+
const stream = result.body.pipeThrough((0, import_streamPartDecoderStream.streamPartDecoderStream)()).pipeThrough((0, import_assistantDecoderStream.assistantDecoderStream)()).pipeThrough((0, import_toolResultStream.toolResultStream)(context.tools, abortSignal)).pipeThrough((0, import_runResultStream.runResultStream)());
|
110
|
+
let update;
|
111
|
+
for await (update of asAsyncIterable(stream)) {
|
112
|
+
yield update;
|
113
|
+
}
|
114
|
+
if (update === void 0)
|
115
|
+
throw new Error("No data received from Edge Runtime");
|
116
|
+
this.options.onFinish?.(unstable_getMessage());
|
117
|
+
} catch (error) {
|
118
|
+
this.options.onError?.(error);
|
119
|
+
throw error;
|
87
120
|
}
|
88
|
-
if (update === void 0)
|
89
|
-
throw new Error("No data received from Edge Runtime");
|
90
121
|
}
|
91
122
|
};
|
92
123
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"sourcesContent":["import {\n ChatModelAdapter,\n ChatModelRunOptions,\n} from \"../local/ChatModelAdapter\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { streamPartDecoderStream } from \"./streams/utils/streamPartDecoderStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\nimport { toLanguageModelMessages } from \"./converters\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\nexport type EdgeChatAdapterOptions = {\n api: string;\n\n credentials?: RequestCredentials;\n headers?: Record<string, string> | Headers;\n body?: object;\n\n /**\n * When enabled, the adapter will not strip `id` from messages in the messages array.\n */\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"sourcesContent":["import {\n ChatModelAdapter,\n ChatModelRunOptions,\n} from \"../local/ChatModelAdapter\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { streamPartDecoderStream } from \"./streams/utils/streamPartDecoderStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\nimport { toLanguageModelMessages } from \"./converters\";\nimport { ThreadMessage } from \"../../types\";\nimport { Tool } from \"../../model-context\";\nimport { z } from \"zod\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { JSONSchema7 } from \"json-schema\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\n\nexport type EdgeChatAdapterOptions = {\n api: string;\n\n // experimental_prepareRequestBody?: (options: {\n // id: string;\n // messages: UIMessage[];\n // requestData?: JSONValue;\n // requestBody?: object;\n // }) => unknown;\n\n // onToolCall?: ({\n // toolCall,\n // }: {\n // toolCall: UIMessageToolInvocation;\n // }) => void | Promise<unknown> | unknown;\n\n /**\n * Callback function to be called when the API response is received.\n */\n onResponse?: (response: Response) => void | Promise<void>;\n /**\n * Optional callback function that is called when the assistant message is finished streaming.\n */\n onFinish?: (message: ThreadMessage) => void;\n /**\n * Callback function to be called when an error is encountered.\n */\n onError?: (error: Error) => void;\n\n credentials?: RequestCredentials;\n headers?: Record<string, string> | Headers;\n body?: object;\n\n /**\n * @deprecated Renamed to `sendExtraMessageFields`.\n */\n unstable_sendMessageIds?: boolean;\n\n /**\n * When enabled, the adapter will not strip `id` from messages in the messages array.\n */\n sendExtraMessageFields?: boolean;\n\n /**\n * When enabled, the adapter will send messages in the format expected by the Vercel AI SDK Core.\n * This feature will be removed in the future in favor of a better solution.\n *\n * `v2` sends frontend tools in a format that can be directly passed to `stremaText`\n */\n unstable_AISDKInterop?: boolean | \"v2\" | undefined;\n};\n\nconst toAISDKTools = (tools: Record<string, Tool<any, any>>) => {\n return Object.fromEntries(\n Object.entries(tools).map(([name, tool]) => [\n name,\n {\n ...(tool.description ? { description: tool.description } : undefined),\n parameters: (tool.parameters instanceof z.ZodType\n ? zodToJsonSchema(tool.parameters)\n : tool.parameters) as JSONSchema7,\n },\n ]),\n );\n};\n\nexport class EdgeChatAdapter implements ChatModelAdapter {\n constructor(private options: EdgeChatAdapterOptions) {}\n\n async *run({\n messages,\n runConfig,\n abortSignal,\n context,\n unstable_assistantMessageId,\n unstable_getMessage,\n }: ChatModelRunOptions) {\n const headers = new Headers(this.options.headers);\n headers.set(\"Content-Type\", \"application/json\");\n\n const result = await fetch(this.options.api, {\n method: \"POST\",\n headers,\n credentials: this.options.credentials ?? \"same-origin\",\n body: JSON.stringify({\n system: context.system,\n messages: this.options.unstable_AISDKInterop\n ? (toLanguageModelMessages(messages, {\n unstable_includeId:\n this.options.unstable_sendMessageIds ||\n this.options.sendExtraMessageFields,\n }) as EdgeRuntimeRequestOptions[\"messages\"]) // TODO figure out a better way to do this\n : toCoreMessages(messages, {\n unstable_includeId:\n this.options.unstable_sendMessageIds ||\n this.options.sendExtraMessageFields,\n }),\n tools: context.tools\n ? this.options.unstable_AISDKInterop === \"v2\"\n ? (toAISDKTools(context.tools) as any)\n : toLanguageModelTools(context.tools)\n : [],\n unstable_assistantMessageId,\n runConfig,\n ...context.callSettings,\n ...context.config,\n\n ...this.options.body,\n } satisfies EdgeRuntimeRequestOptions),\n signal: abortSignal,\n });\n\n await this.options.onResponse?.(result);\n\n try {\n if (!result.ok) {\n throw new Error(`Status ${result.status}: ${await result.text()}`);\n }\n\n const stream = result\n .body!.pipeThrough(streamPartDecoderStream())\n .pipeThrough(assistantDecoderStream())\n .pipeThrough(toolResultStream(context.tools, abortSignal))\n .pipeThrough(runResultStream());\n\n let update: ChatModelRunResult | undefined;\n for await (update of asAsyncIterable(stream)) {\n yield update;\n }\n\n if (update === undefined)\n throw new Error(\"No data received from Edge Runtime\");\n\n this.options.onFinish?.(unstable_getMessage());\n } catch (error: unknown) {\n this.options.onError?.(error as Error);\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,4BAA+B;AAC/B,kCAAqC;AAErC,oCAAuC;AACvC,qCAAwC;AACxC,6BAAgC;AAChC,8BAAiC;AACjC,wBAAwC;AAGxC,iBAAkB;AAClB,gCAA4B;AAGrB,SAAS,gBACd,QACkB;AAClB,SAAO;AAAA,IACL,CAAC,OAAO,aAAa,GAAG,MAAM;AAC5B,YAAM,SAAS,OAAO,UAAU;AAChC,aAAO;AAAA,QACL,MAAM,OAA8C;AAClD,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,iBAAO,OACH,EAAE,MAAM,MAAM,OAAO,OAAU,IAC/B,EAAE,MAAM,OAAO,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAsDA,IAAM,eAAe,CAAC,UAA0C;AAC9D,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,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IAAI,MAAM,UAAU,OAAO,MAAM,KAAK,MAAM,OAAO,KAAK,CAAC,EAAE;AAAA,MACnE;AAEA,YAAM,SAAS,OACZ,KAAM,gBAAY,wDAAwB,CAAC,EAC3C,gBAAY,sDAAuB,CAAC,EACpC,gBAAY,0CAAiB,QAAQ,OAAO,WAAW,CAAC,EACxD,gBAAY,wCAAgB,CAAC;AAEhC,UAAI;AACJ,iBAAW,UAAU,gBAAgB,MAAM,GAAG;AAC5C,cAAM;AAAA,MACR;AAEA,UAAI,WAAW;AACb,cAAM,IAAI,MAAM,oCAAoC;AAEtD,WAAK,QAAQ,WAAW,oBAAoB,CAAC;AAAA,IAC/C,SAAS,OAAgB;AACvB,WAAK,QAAQ,UAAU,KAAc;AACrC,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["zodToJsonSchema"]}
|
@@ -6,6 +6,8 @@ import { streamPartDecoderStream } from "./streams/utils/streamPartDecoderStream
|
|
6
6
|
import { runResultStream } from "./streams/runResultStream.mjs";
|
7
7
|
import { toolResultStream } from "./streams/toolResultStream.mjs";
|
8
8
|
import { toLanguageModelMessages } from "./converters/index.mjs";
|
9
|
+
import { z } from "zod";
|
10
|
+
import zodToJsonSchema from "zod-to-json-schema";
|
9
11
|
function asAsyncIterable(source) {
|
10
12
|
return {
|
11
13
|
[Symbol.asyncIterator]: () => {
|
@@ -19,6 +21,17 @@ function asAsyncIterable(source) {
|
|
19
21
|
}
|
20
22
|
};
|
21
23
|
}
|
24
|
+
var toAISDKTools = (tools) => {
|
25
|
+
return Object.fromEntries(
|
26
|
+
Object.entries(tools).map(([name, tool]) => [
|
27
|
+
name,
|
28
|
+
{
|
29
|
+
...tool.description ? { description: tool.description } : void 0,
|
30
|
+
parameters: tool.parameters instanceof z.ZodType ? zodToJsonSchema(tool.parameters) : tool.parameters
|
31
|
+
}
|
32
|
+
])
|
33
|
+
);
|
34
|
+
};
|
22
35
|
var EdgeChatAdapter = class {
|
23
36
|
constructor(options) {
|
24
37
|
this.options = options;
|
@@ -28,7 +41,8 @@ var EdgeChatAdapter = class {
|
|
28
41
|
runConfig,
|
29
42
|
abortSignal,
|
30
43
|
context,
|
31
|
-
unstable_assistantMessageId
|
44
|
+
unstable_assistantMessageId,
|
45
|
+
unstable_getMessage
|
32
46
|
}) {
|
33
47
|
const headers = new Headers(this.options.headers);
|
34
48
|
headers.set("Content-Type", "application/json");
|
@@ -39,11 +53,11 @@ var EdgeChatAdapter = class {
|
|
39
53
|
body: JSON.stringify({
|
40
54
|
system: context.system,
|
41
55
|
messages: this.options.unstable_AISDKInterop ? toLanguageModelMessages(messages, {
|
42
|
-
unstable_includeId: this.options.unstable_sendMessageIds
|
56
|
+
unstable_includeId: this.options.unstable_sendMessageIds || this.options.sendExtraMessageFields
|
43
57
|
}) : toCoreMessages(messages, {
|
44
|
-
unstable_includeId: this.options.unstable_sendMessageIds
|
58
|
+
unstable_includeId: this.options.unstable_sendMessageIds || this.options.sendExtraMessageFields
|
45
59
|
}),
|
46
|
-
tools: context.tools ? toLanguageModelTools(context.tools) : [],
|
60
|
+
tools: context.tools ? this.options.unstable_AISDKInterop === "v2" ? toAISDKTools(context.tools) : toLanguageModelTools(context.tools) : [],
|
47
61
|
unstable_assistantMessageId,
|
48
62
|
runConfig,
|
49
63
|
...context.callSettings,
|
@@ -52,16 +66,23 @@ var EdgeChatAdapter = class {
|
|
52
66
|
}),
|
53
67
|
signal: abortSignal
|
54
68
|
});
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
69
|
+
await this.options.onResponse?.(result);
|
70
|
+
try {
|
71
|
+
if (!result.ok) {
|
72
|
+
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
73
|
+
}
|
74
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(context.tools, abortSignal)).pipeThrough(runResultStream());
|
75
|
+
let update;
|
76
|
+
for await (update of asAsyncIterable(stream)) {
|
77
|
+
yield update;
|
78
|
+
}
|
79
|
+
if (update === void 0)
|
80
|
+
throw new Error("No data received from Edge Runtime");
|
81
|
+
this.options.onFinish?.(unstable_getMessage());
|
82
|
+
} catch (error) {
|
83
|
+
this.options.onError?.(error);
|
84
|
+
throw error;
|
62
85
|
}
|
63
|
-
if (update === void 0)
|
64
|
-
throw new Error("No data received from Edge Runtime");
|
65
86
|
}
|
66
87
|
};
|
67
88
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"sourcesContent":["import {\n ChatModelAdapter,\n ChatModelRunOptions,\n} from \"../local/ChatModelAdapter\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { streamPartDecoderStream } from \"./streams/utils/streamPartDecoderStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\nimport { toLanguageModelMessages } from \"./converters\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\nexport type EdgeChatAdapterOptions = {\n api: string;\n\n credentials?: RequestCredentials;\n headers?: Record<string, string> | Headers;\n body?: object;\n\n /**\n * When enabled, the adapter will not strip `id` from messages in the messages array.\n */\n
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/edge/EdgeChatAdapter.ts"],"sourcesContent":["import {\n ChatModelAdapter,\n ChatModelRunOptions,\n} from \"../local/ChatModelAdapter\";\nimport { ChatModelRunResult } from \"../local/ChatModelAdapter\";\nimport { toCoreMessages } from \"./converters/toCoreMessages\";\nimport { toLanguageModelTools } from \"./converters/toLanguageModelTools\";\nimport { EdgeRuntimeRequestOptions } from \"./EdgeRuntimeRequestOptions\";\nimport { assistantDecoderStream } from \"./streams/assistantDecoderStream\";\nimport { streamPartDecoderStream } from \"./streams/utils/streamPartDecoderStream\";\nimport { runResultStream } from \"./streams/runResultStream\";\nimport { toolResultStream } from \"./streams/toolResultStream\";\nimport { toLanguageModelMessages } from \"./converters\";\nimport { ThreadMessage } from \"../../types\";\nimport { Tool } from \"../../model-context\";\nimport { z } from \"zod\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport { JSONSchema7 } from \"json-schema\";\n\nexport function asAsyncIterable<T>(\n source: ReadableStream<T>,\n): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]: () => {\n const reader = source.getReader();\n return {\n async next(): Promise<IteratorResult<T, undefined>> {\n const { done, value } = await reader.read();\n return done\n ? { done: true, value: undefined }\n : { done: false, value };\n },\n };\n },\n };\n}\n\nexport type EdgeChatAdapterOptions = {\n api: string;\n\n // experimental_prepareRequestBody?: (options: {\n // id: string;\n // messages: UIMessage[];\n // requestData?: JSONValue;\n // requestBody?: object;\n // }) => unknown;\n\n // onToolCall?: ({\n // toolCall,\n // }: {\n // toolCall: UIMessageToolInvocation;\n // }) => void | Promise<unknown> | unknown;\n\n /**\n * Callback function to be called when the API response is received.\n */\n onResponse?: (response: Response) => void | Promise<void>;\n /**\n * Optional callback function that is called when the assistant message is finished streaming.\n */\n onFinish?: (message: ThreadMessage) => void;\n /**\n * Callback function to be called when an error is encountered.\n */\n onError?: (error: Error) => void;\n\n credentials?: RequestCredentials;\n headers?: Record<string, string> | Headers;\n body?: object;\n\n /**\n * @deprecated Renamed to `sendExtraMessageFields`.\n */\n unstable_sendMessageIds?: boolean;\n\n /**\n * When enabled, the adapter will not strip `id` from messages in the messages array.\n */\n sendExtraMessageFields?: boolean;\n\n /**\n * When enabled, the adapter will send messages in the format expected by the Vercel AI SDK Core.\n * This feature will be removed in the future in favor of a better solution.\n *\n * `v2` sends frontend tools in a format that can be directly passed to `stremaText`\n */\n unstable_AISDKInterop?: boolean | \"v2\" | undefined;\n};\n\nconst toAISDKTools = (tools: Record<string, Tool<any, any>>) => {\n return Object.fromEntries(\n Object.entries(tools).map(([name, tool]) => [\n name,\n {\n ...(tool.description ? { description: tool.description } : undefined),\n parameters: (tool.parameters instanceof z.ZodType\n ? zodToJsonSchema(tool.parameters)\n : tool.parameters) as JSONSchema7,\n },\n ]),\n );\n};\n\nexport class EdgeChatAdapter implements ChatModelAdapter {\n constructor(private options: EdgeChatAdapterOptions) {}\n\n async *run({\n messages,\n runConfig,\n abortSignal,\n context,\n unstable_assistantMessageId,\n unstable_getMessage,\n }: ChatModelRunOptions) {\n const headers = new Headers(this.options.headers);\n headers.set(\"Content-Type\", \"application/json\");\n\n const result = await fetch(this.options.api, {\n method: \"POST\",\n headers,\n credentials: this.options.credentials ?? \"same-origin\",\n body: JSON.stringify({\n system: context.system,\n messages: this.options.unstable_AISDKInterop\n ? (toLanguageModelMessages(messages, {\n unstable_includeId:\n this.options.unstable_sendMessageIds ||\n this.options.sendExtraMessageFields,\n }) as EdgeRuntimeRequestOptions[\"messages\"]) // TODO figure out a better way to do this\n : toCoreMessages(messages, {\n unstable_includeId:\n this.options.unstable_sendMessageIds ||\n this.options.sendExtraMessageFields,\n }),\n tools: context.tools\n ? this.options.unstable_AISDKInterop === \"v2\"\n ? (toAISDKTools(context.tools) as any)\n : toLanguageModelTools(context.tools)\n : [],\n unstable_assistantMessageId,\n runConfig,\n ...context.callSettings,\n ...context.config,\n\n ...this.options.body,\n } satisfies EdgeRuntimeRequestOptions),\n signal: abortSignal,\n });\n\n await this.options.onResponse?.(result);\n\n try {\n if (!result.ok) {\n throw new Error(`Status ${result.status}: ${await result.text()}`);\n }\n\n const stream = result\n .body!.pipeThrough(streamPartDecoderStream())\n .pipeThrough(assistantDecoderStream())\n .pipeThrough(toolResultStream(context.tools, abortSignal))\n .pipeThrough(runResultStream());\n\n let update: ChatModelRunResult | undefined;\n for await (update of asAsyncIterable(stream)) {\n yield update;\n }\n\n if (update === undefined)\n throw new Error(\"No data received from Edge Runtime\");\n\n this.options.onFinish?.(unstable_getMessage());\n } catch (error: unknown) {\n this.options.onError?.(error as Error);\n throw error;\n }\n }\n}\n"],"mappings":";AAKA,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAErC,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AACxC,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAGxC,SAAS,SAAS;AAClB,OAAO,qBAAqB;AAGrB,SAAS,gBACd,QACkB;AAClB,SAAO;AAAA,IACL,CAAC,OAAO,aAAa,GAAG,MAAM;AAC5B,YAAM,SAAS,OAAO,UAAU;AAChC,aAAO;AAAA,QACL,MAAM,OAA8C;AAClD,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,iBAAO,OACH,EAAE,MAAM,MAAM,OAAO,OAAU,IAC/B,EAAE,MAAM,OAAO,MAAM;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAsDA,IAAM,eAAe,CAAC,UAA0C;AAC9D,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM;AAAA,MAC1C;AAAA,MACA;AAAA,QACE,GAAI,KAAK,cAAc,EAAE,aAAa,KAAK,YAAY,IAAI;AAAA,QAC3D,YAAa,KAAK,sBAAsB,EAAE,UACtC,gBAAgB,KAAK,UAAU,IAC/B,KAAK;AAAA,MACX;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,kBAAN,MAAkD;AAAA,EACvD,YAAoB,SAAiC;AAAjC;AAAA,EAAkC;AAAA,EAEtD,OAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA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AoC;AAEtD,WAAK,QAAQ,WAAW,oBAAoB,CAAC;AAAA,IAC/C,SAAS,OAAgB;AACvB,WAAK,QAAQ,UAAU,KAAc;AACrC,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { LocalRuntimeOptions } from "..";
|
2
2
|
import { EdgeChatAdapterOptions } from "./EdgeChatAdapter";
|
3
3
|
export type EdgeRuntimeOptions = EdgeChatAdapterOptions & LocalRuntimeOptions;
|
4
|
-
export declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => import("
|
4
|
+
export declare const useEdgeRuntime: (options: EdgeRuntimeOptions) => import("../..").AssistantRuntime;
|
5
5
|
//# sourceMappingURL=useEdgeRuntime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useEdgeRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/useEdgeRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAmB,MAAM,mBAAmB,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;AAE9E,eAAO,MAAM,cAAc,YAAa,kBAAkB,
|
1
|
+
{"version":3,"file":"useEdgeRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtimes/edge/useEdgeRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAmB,MAAM,mBAAmB,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;AAE9E,eAAO,MAAM,cAAc,YAAa,kBAAkB,qCAQzD,CAAC"}
|
@@ -27,6 +27,7 @@ export declare class ExternalStoreThreadListRuntimeCore implements ThreadListRun
|
|
27
27
|
unarchive(threadId: string): Promise<void>;
|
28
28
|
delete(threadId: string): Promise<void>;
|
29
29
|
initialize(): never;
|
30
|
+
generateTitle(): never;
|
30
31
|
private _subscriptions;
|
31
32
|
subscribe(callback: () => void): Unsubscribe;
|
32
33
|
private _notifySubscribers;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalStoreThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,0BAA0B,GAAG,MAAM,8BAA8B,CAAC;AAW9E,qBAAa,kCACX,YAAW,qBAAqB;IA6B9B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,aAAa;IA5BvB,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,gBAAgB,CAAkC;IAE1D,IAAW,WAAW,cAErB;IAED,IAAW,SAAS,sBAEnB;IAED,IAAW,iBAAiB,sBAE3B;IAEM,qBAAqB;IAI5B,OAAO,CAAC,WAAW,CAAiC;IAEpD,IAAW,YAAY,WAEtB;gBAGS,OAAO,EAAE,8BAA8B,YAAK,EAC5C,aAAa,EAAE,0BAA0B;IAK5C,wBAAwB;IAIxB,oBAAoB,IAAI,KAAK;IAI7B,WAAW,CAAC,QAAQ,EAAE,MAAM;IAW5B,qBAAqB,CAAC,OAAO,EAAE,8BAA8B;IAuCvD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC,MAAM,CAAC,QAAQ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IAuCvD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,UAAU,IAAI,KAAK;IAInB,aAAa,IAAI,KAAK;IAI7B,OAAO,CAAC,cAAc,CAAyB;IAExC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnD,OAAO,CAAC,kBAAkB;CAG3B"}
|
@@ -140,6 +140,9 @@ var ExternalStoreThreadListRuntimeCore = class {
|
|
140
140
|
initialize() {
|
141
141
|
throw new Error("Method not implemented.");
|
142
142
|
}
|
143
|
+
generateTitle() {
|
144
|
+
throw new Error("Method not implemented.");
|
145
|
+
}
|
143
146
|
_subscriptions = /* @__PURE__ */ new Set();
|
144
147
|
subscribe(callback) {
|
145
148
|
this._subscriptions.add(callback);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public async switchToNewThread(): Promise<void> {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\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;AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AACD,IAAM,mBAAmB,QAAQ,QAAQ;AAElC,IAAM,qCAAN,MAEP;AAAA,EA2BE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA/BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,wBAAwB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAER,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,uBAA8B;AACnC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,YAAY,UAAkB;AACnC,eAAW,UAAU,KAAK,QAAQ,WAAW,CAAC,GAAG;AAC/C,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,eAAW,UAAU,KAAK,QAAQ,mBAAmB,CAAC,GAAG;AACvD,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,QAAI,aAAa,kBAAmB,QAAO;AAC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AAa,QAAQ,UAAiC;AACpD,UAAM,YAAY,KAAK,QAAQ;AAC/B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,mDAAmD;AAErE,cAAU,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,UAAM,cAAc,KAAK,QAAQ;AACjC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,qDAAqD;AAEvE,gBAAY,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,QAAQ;AAAA,EACnB;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/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public async switchToNewThread(): Promise<void> {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\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 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._subscript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mD;AAErE,cAAU,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,UAAM,cAAc,KAAK,QAAQ;AACjC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,qDAAqD;AAEvE,gBAAY,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,QAAQ;AAAA,EACnB;AAAA,EAEO,aAAoB;AACzB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,gBAAuB;AAC5B,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":[]}
|
@@ -116,6 +116,9 @@ var ExternalStoreThreadListRuntimeCore = class {
|
|
116
116
|
initialize() {
|
117
117
|
throw new Error("Method not implemented.");
|
118
118
|
}
|
119
|
+
generateTitle() {
|
120
|
+
throw new Error("Method not implemented.");
|
121
|
+
}
|
119
122
|
_subscriptions = /* @__PURE__ */ new Set();
|
120
123
|
subscribe(callback) {
|
121
124
|
this._subscriptions.add(callback);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public async switchToNewThread(): Promise<void> {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\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":";AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AACD,IAAM,mBAAmB,QAAQ,QAAQ;AAElC,IAAM,qCAAN,MAEP;AAAA,EA2BE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA/BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,wBAAwB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAER,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,uBAA8B;AACnC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,YAAY,UAAkB;AACnC,eAAW,UAAU,KAAK,QAAQ,WAAW,CAAC,GAAG;AAC/C,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,eAAW,UAAU,KAAK,QAAQ,mBAAmB,CAAC,GAAG;AACvD,UAAI,OAAO,aAAa,SAAU,QAAO;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E,aAAS,UAAU,QAAQ;AAAA,EAC7B;AAAA,EAEA,MAAa,QAAQ,UAAiC;AACpD,UAAM,YAAY,KAAK,QAAQ;AAC/B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,mDAAmD;AAErE,cAAU,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,UAAM,cAAc,KAAK,QAAQ;AACjC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,qDAAqD;AAEvE,gBAAY,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,QAAQ;AAAA,EACnB;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/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getThreadRuntimeCore(): never {\n throw new Error(\"Method not implemented.\");\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public async switchToNewThread(): Promise<void> {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\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 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":";AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AACD,IAAM,mBAAmB,QAAQ,QAAQ;AAElC,IAAM,qCAAN,MAEP;AAAA,EA2BE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA/BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,wBAAwB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAER,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,uBAA8B;AACnC,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,YAAY,UAAkB;AACnC,eAAW,UAAU,KAAK,QAAQ,WAAW,CAAC,GAAG;AAC/C,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,eAAW,UAAU,KAAK,QAAQ,mBAAmB,CAAC,GAAG;AACvD,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,QAAI,aAAa,kBAAmB,QAAO;AAC3C,WAAO;AAAA,EACT;AAAA,EAEO,sBAAsB,SAAyC;AACpE,UAAM,kBAAkB,KAAK;AAC7B,SAAK,UAAU;AAEf,UA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AErE,cAAU,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,UAAM,cAAc,KAAK,QAAQ;AACjC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,qDAAqD;AAEvE,gBAAY,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,QAAQ;AAAA,EACnB;AAAA,EAEO,aAAoB;AACzB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AAAA,EAEO,gBAAuB;AAC5B,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":[]}
|
@@ -28,6 +28,7 @@ export type ChatModelRunOptions = {
|
|
28
28
|
*/
|
29
29
|
readonly config: ModelContext;
|
30
30
|
readonly unstable_assistantMessageId?: string;
|
31
|
+
unstable_getMessage(): ThreadMessage;
|
31
32
|
};
|
32
33
|
export type ChatModelAdapter = {
|
33
34
|
run(options: ChatModelRunOptions): Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatModelAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACb,UAAU,EACV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAA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AG;IACzE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,eAAe,GAAG,mBAAmB,CAAC,EAAE,CAAC;CACtE,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAC9C,mBAAmB,IAAI,aAAa,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CACD,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;CAC3E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["import type {\n MessageStatus,\n RunConfig,\n TextContentPart,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n ToolCallContentPart,\n} from \"../../types/AssistantTypes\";\nimport type { ModelContext } from \"../../model-context/ModelContextTypes\";\nimport { ReadonlyJSONValue } from \"../../utils/json/json-value\";\n\nexport type ChatModelRunUpdate = {\n readonly content: readonly ThreadAssistantContentPart[];\n readonly metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n readonly content?: readonly ThreadAssistantContentPart[] | undefined;\n readonly status?: MessageStatus | undefined;\n readonly metadata?: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[] | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport type CoreChatModelRunResult = Omit<ChatModelRunResult, \"content\"> & {\n readonly content: readonly (TextContentPart | ToolCallContentPart)[];\n};\n\nexport type ChatModelRunOptions = {\n readonly messages: readonly ThreadMessage[];\n readonly runConfig: RunConfig;\n readonly abortSignal: AbortSignal;\n readonly context: ModelContext;\n\n /**\n * @deprecated This field was renamed to `context`.\n */\n readonly config: ModelContext;\n\n readonly unstable_assistantMessageId?: string;\n};\n\nexport type ChatModelAdapter = {\n run(\n options: ChatModelRunOptions,\n ): Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/ChatModelAdapter.tsx"],"sourcesContent":["import type {\n MessageStatus,\n RunConfig,\n TextContentPart,\n ThreadAssistantContentPart,\n ThreadMessage,\n ThreadStep,\n ToolCallContentPart,\n} from \"../../types/AssistantTypes\";\nimport type { ModelContext } from \"../../model-context/ModelContextTypes\";\nimport { ReadonlyJSONValue } from \"../../utils/json/json-value\";\n\nexport type ChatModelRunUpdate = {\n readonly content: readonly ThreadAssistantContentPart[];\n readonly metadata?: Record<string, unknown>;\n};\n\nexport type ChatModelRunResult = {\n readonly content?: readonly ThreadAssistantContentPart[] | undefined;\n readonly status?: MessageStatus | undefined;\n readonly metadata?: {\n readonly unstable_annotations?: readonly ReadonlyJSONValue[] | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n };\n};\n\nexport type CoreChatModelRunResult = Omit<ChatModelRunResult, \"content\"> & {\n readonly content: readonly (TextContentPart | ToolCallContentPart)[];\n};\n\nexport type ChatModelRunOptions = {\n readonly messages: readonly ThreadMessage[];\n readonly runConfig: RunConfig;\n readonly abortSignal: AbortSignal;\n readonly context: ModelContext;\n\n /**\n * @deprecated This field was renamed to `context`.\n */\n readonly config: ModelContext;\n\n readonly unstable_assistantMessageId?: string;\n unstable_getMessage(): ThreadMessage;\n};\n\nexport type ChatModelAdapter = {\n run(\n options: ChatModelRunOptions,\n ): Promise<ChatModelRunResult> | AsyncGenerator<ChatModelRunResult, void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
@@ -4,6 +4,7 @@ import { ThreadMessageLike } from "../external-store";
|
|
4
4
|
import { FeedbackAdapter } from "../adapters/feedback/FeedbackAdapter";
|
5
5
|
import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
|
6
6
|
import { ChatModelAdapter } from "./ChatModelAdapter";
|
7
|
+
import { AssistantCloud } from "../../cloud";
|
7
8
|
export type LocalRuntimeOptionsBase = {
|
8
9
|
maxSteps?: number | undefined;
|
9
10
|
adapters: {
|
@@ -20,11 +21,13 @@ export type LocalRuntimeOptionsBase = {
|
|
20
21
|
unstable_shouldContinueIgnoreToolNames?: string[] | undefined;
|
21
22
|
};
|
22
23
|
export type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, "adapters"> & {
|
24
|
+
cloud?: AssistantCloud | undefined;
|
23
25
|
initialMessages?: readonly ThreadMessageLike[] | undefined;
|
24
26
|
adapters?: Omit<LocalRuntimeOptionsBase["adapters"], "chatModel"> | undefined;
|
25
27
|
};
|
26
28
|
export declare const splitLocalRuntimeOptions: <T extends LocalRuntimeOptions>(options: T) => {
|
27
29
|
localRuntimeOptions: {
|
30
|
+
cloud: AssistantCloud | undefined;
|
28
31
|
initialMessages: readonly ThreadMessageLike[] | undefined;
|
29
32
|
maxSteps: number | undefined;
|
30
33
|
adapters: Omit<{
|
@@ -36,6 +39,6 @@ export declare const splitLocalRuntimeOptions: <T extends LocalRuntimeOptions>(o
|
|
36
39
|
}, "chatModel"> | undefined;
|
37
40
|
unstable_shouldContinueIgnoreToolNames: string[] | undefined;
|
38
41
|
};
|
39
|
-
otherOptions: Omit<T, "adapters" | "maxSteps" | "unstable_shouldContinueIgnoreToolNames" | "initialMessages">;
|
42
|
+
otherOptions: Omit<T, "adapters" | "maxSteps" | "unstable_shouldContinueIgnoreToolNames" | "cloud" | "initialMessages">;
|
40
43
|
};
|
41
44
|
//# sourceMappingURL=LocalRuntimeOptions.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocalRuntimeOptions.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"LocalRuntimeOptions.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE;QACR,SAAS,EAAE,gBAAgB,CAAC;QAC5B,OAAO,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;QAC3C,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;QAC5C,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;QAC5C,QAAQ,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KACxC,CAAC;IAEF;;;OAGG;IACH,sCAAsC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/D,CAAC;AAGF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,GAAG;IAC5E,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,eAAe,CAAC,EAAE,SAAS,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,EAAE,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC;CAC/E,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,mBAAmB,WAC3D,CAAC;;;;;;uBAtBG,gBAAgB;sBACjB,oBAAoB,GAAG,SAAS;0BAC5B,iBAAiB,GAAG,SAAS;qBAClC,sBAAsB,GAAG,SAAS;uBAChC,eAAe,GAAG,SAAS;;;;;CAuCzC,CAAC"}
|
@@ -25,6 +25,7 @@ __export(LocalRuntimeOptions_exports, {
|
|
25
25
|
module.exports = __toCommonJS(LocalRuntimeOptions_exports);
|
26
26
|
var splitLocalRuntimeOptions = (options) => {
|
27
27
|
const {
|
28
|
+
cloud,
|
28
29
|
initialMessages,
|
29
30
|
maxSteps,
|
30
31
|
adapters,
|
@@ -33,6 +34,7 @@ var splitLocalRuntimeOptions = (options) => {
|
|
33
34
|
} = options;
|
34
35
|
return {
|
35
36
|
localRuntimeOptions: {
|
37
|
+
cloud,
|
36
38
|
initialMessages,
|
37
39
|
maxSteps,
|
38
40
|
adapters,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"sourcesContent":["import { ThreadHistoryAdapter } from \"../adapters/thread-history/ThreadHistoryAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment/AttachmentAdapter\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { ChatModelAdapter } from \"./ChatModelAdapter\";\n\nexport type LocalRuntimeOptionsBase = {\n maxSteps?: number | undefined;\n adapters: {\n chatModel: ChatModelAdapter;\n history?: ThreadHistoryAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n };\n\n /**\n * @deprecated This is a temporary workaround for subgraph frontend function calls.\n * This feature will be removed in a future version without notice. DO NOT USE.\n */\n unstable_shouldContinueIgnoreToolNames?: string[] | undefined;\n};\n\n// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n },\n otherOptions: rest,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"sourcesContent":["import { ThreadHistoryAdapter } from \"../adapters/thread-history/ThreadHistoryAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment/AttachmentAdapter\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { AssistantCloud } from \"../../cloud\";\n\nexport type LocalRuntimeOptionsBase = {\n maxSteps?: number | undefined;\n adapters: {\n chatModel: ChatModelAdapter;\n history?: ThreadHistoryAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n };\n\n /**\n * @deprecated This is a temporary workaround for subgraph frontend function calls.\n * This feature will be removed in a future version without notice. DO NOT USE.\n */\n unstable_shouldContinueIgnoreToolNames?: string[] | undefined;\n};\n\n// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n },\n otherOptions: rest,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,IAAM,2BAA2B,CACtC,YACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,SAAO;AAAA,IACL,qBAAqB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,cAAc;AAAA,EAChB;AACF;","names":[]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// src/runtimes/local/LocalRuntimeOptions.tsx
|
2
2
|
var splitLocalRuntimeOptions = (options) => {
|
3
3
|
const {
|
4
|
+
cloud,
|
4
5
|
initialMessages,
|
5
6
|
maxSteps,
|
6
7
|
adapters,
|
@@ -9,6 +10,7 @@ var splitLocalRuntimeOptions = (options) => {
|
|
9
10
|
} = options;
|
10
11
|
return {
|
11
12
|
localRuntimeOptions: {
|
13
|
+
cloud,
|
12
14
|
initialMessages,
|
13
15
|
maxSteps,
|
14
16
|
adapters,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"sourcesContent":["import { ThreadHistoryAdapter } from \"../adapters/thread-history/ThreadHistoryAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment/AttachmentAdapter\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { ChatModelAdapter } from \"./ChatModelAdapter\";\n\nexport type LocalRuntimeOptionsBase = {\n maxSteps?: number | undefined;\n adapters: {\n chatModel: ChatModelAdapter;\n history?: ThreadHistoryAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n };\n\n /**\n * @deprecated This is a temporary workaround for subgraph frontend function calls.\n * This feature will be removed in a future version without notice. DO NOT USE.\n */\n unstable_shouldContinueIgnoreToolNames?: string[] | undefined;\n};\n\n// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n },\n otherOptions: rest,\n };\n};\n"],"mappings":";
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/local/LocalRuntimeOptions.tsx"],"sourcesContent":["import { ThreadHistoryAdapter } from \"../adapters/thread-history/ThreadHistoryAdapter\";\nimport { AttachmentAdapter } from \"../adapters/attachment/AttachmentAdapter\";\nimport { ThreadMessageLike } from \"../external-store\";\nimport { FeedbackAdapter } from \"../adapters/feedback/FeedbackAdapter\";\nimport { SpeechSynthesisAdapter } from \"../adapters/speech/SpeechAdapterTypes\";\nimport { ChatModelAdapter } from \"./ChatModelAdapter\";\nimport { AssistantCloud } from \"../../cloud\";\n\nexport type LocalRuntimeOptionsBase = {\n maxSteps?: number | undefined;\n adapters: {\n chatModel: ChatModelAdapter;\n history?: ThreadHistoryAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n };\n\n /**\n * @deprecated This is a temporary workaround for subgraph frontend function calls.\n * This feature will be removed in a future version without notice. DO NOT USE.\n */\n unstable_shouldContinueIgnoreToolNames?: string[] | undefined;\n};\n\n// TODO align LocalRuntimeOptions with LocalRuntimeOptionsBase\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_shouldContinueIgnoreToolNames,\n },\n otherOptions: rest,\n };\n};\n"],"mappings":";AAgCO,IAAM,2BAA2B,CACtC,YACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,SAAO;AAAA,IACL,qBAAqB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,cAAc;AAAA,EAChB;AACF;","names":[]}
|