@assistant-ui/core 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/react/RuntimeAdapter.js +1 -1
- package/dist/react/RuntimeAdapter.js.map +1 -1
- package/dist/react/client/Interactables.js +1 -1
- package/dist/react/client/Interactables.js.map +1 -1
- package/dist/react/client/Tools.d.ts +1 -1
- package/dist/react/client/Tools.js +1 -1
- package/dist/react/client/Tools.js.map +1 -1
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +4 -4
- package/dist/react/model-context/interactableTool.d.ts +1 -1
- package/dist/react/model-context/useAssistantTool.d.ts +1 -1
- package/dist/react/runtimes/cloud/auiV0.d.ts +1 -0
- package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
- package/dist/react/runtimes/cloud/auiV0.js +2 -1
- package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
- package/dist/react/runtimes/createMessageConverter.d.ts +1 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts +4 -1
- package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
- package/dist/react/runtimes/createRuntimeExtras.js +6 -17
- package/dist/react/runtimes/createRuntimeExtras.js.map +1 -1
- package/dist/react/types/scopes/dataRenderers.d.ts +1 -1
- package/dist/react/types/scopes/interactables.d.ts +1 -1
- package/dist/react/types/scopes/tools.d.ts +1 -1
- package/dist/runtime/base/base-composer-runtime-core.d.ts +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +0 -2
- package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
- package/dist/runtime/base/default-edit-composer-runtime-core.js +18 -25
- package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
- package/dist/runtime/utils/runtime-extras-brand.d.ts +21 -0
- package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -0
- package/dist/runtime/utils/runtime-extras-brand.js +37 -0
- package/dist/runtime/utils/runtime-extras-brand.js.map +1 -0
- package/dist/runtime/utils/thread-message-like.js +3 -1
- package/dist/runtime/utils/thread-message-like.js.map +1 -1
- package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
- package/dist/store/clients/runtime-adapter.js +1 -1
- package/dist/store/clients/runtime-adapter.js.map +1 -1
- package/dist/store/clients/suggestions.js +1 -1
- package/dist/store/clients/suggestions.js.map +1 -1
- package/dist/store/clients/thread-message-client.js +1 -1
- package/dist/store/clients/thread-message-client.js.map +1 -1
- package/dist/store/index.d.ts +10 -1
- package/dist/store/index.js +7 -1
- package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js +1 -1
- package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js +1 -1
- package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js +1 -1
- package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
- package/dist/types/message.d.ts +1 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/package.json +3 -3
- package/src/react/RuntimeAdapter.test.ts +85 -0
- package/src/react/RuntimeAdapter.ts +1 -1
- package/src/react/client/Interactables.test.ts +3 -2
- package/src/react/client/Interactables.ts +4 -4
- package/src/react/client/Tools.ts +4 -4
- package/src/react/index.ts +1 -0
- package/src/react/runtimes/cloud/auiV0.ts +8 -1
- package/src/react/runtimes/createRuntimeExtras.test.ts +14 -1
- package/src/react/runtimes/createRuntimeExtras.ts +15 -26
- package/src/runtime/base/default-edit-composer-runtime-core.ts +32 -50
- package/src/runtime/utils/runtime-extras-brand.ts +47 -0
- package/src/runtime/utils/thread-message-like.ts +5 -1
- package/src/store/clients/runtime-adapter.ts +2 -5
- package/src/store/clients/suggestions.ts +1 -1
- package/src/store/clients/thread-message-client.ts +1 -1
- package/src/store/index.ts +31 -0
- package/src/store/runtime-clients/composer-runtime-client.ts +2 -5
- package/src/store/runtime-clients/lookup-domains.test.ts +109 -0
- package/src/store/runtime-clients/message-runtime-client.ts +2 -5
- package/src/store/runtime-clients/thread-list-item-runtime-client.ts +2 -1
- package/src/store/runtime-clients/thread-list-runtime-client.ts +2 -5
- package/src/store/runtime-clients/thread-runtime-client.ts +2 -2
- package/src/tests/auiV0Encode.test.ts +97 -0
- package/src/tests/default-edit-composer-runtime-core.test.ts +6 -2
- package/src/tests/framework-neutral-boundary.test.ts +60 -24
- package/src/tests/thread-message-like.test.ts +43 -0
- package/src/types/message.ts +1 -0
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { createRuntimeExtrasBrand } from "../../runtime/utils/runtime-extras-brand.js";
|
|
2
3
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
4
|
//#region src/react/runtimes/createRuntimeExtras.ts
|
|
4
5
|
/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const is = (extras) => typeof extras === "object" && extras !== null && brand in extras;
|
|
8
|
-
const assert = (extras) => {
|
|
9
|
-
if (!is(extras)) throw new Error(`The current thread is not backed by the ${runtimeName} runtime.`);
|
|
10
|
-
return extras;
|
|
11
|
-
};
|
|
12
|
-
const provide = (value) => {
|
|
13
|
-
Object.defineProperty(value, brand, {
|
|
14
|
-
value: true,
|
|
15
|
-
enumerable: false,
|
|
16
|
-
configurable: true
|
|
17
|
-
});
|
|
18
|
-
return value;
|
|
19
|
-
};
|
|
20
|
-
const tryGet = (extras) => is(extras) ? extras : void 0;
|
|
6
|
+
const unstable_createRuntimeExtrasFromBrand = (brand) => {
|
|
7
|
+
const { provide, is, tryGet, assert } = brand;
|
|
21
8
|
const get = (client) => assert(client.thread.getState().extras);
|
|
22
9
|
function use(select, ...rest) {
|
|
23
10
|
const hasFallback = rest.length > 0;
|
|
@@ -37,7 +24,9 @@ const createRuntimeExtras = (runtimeName) => {
|
|
|
37
24
|
use
|
|
38
25
|
};
|
|
39
26
|
};
|
|
27
|
+
/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */
|
|
28
|
+
const createRuntimeExtras = (runtimeName) => unstable_createRuntimeExtrasFromBrand(createRuntimeExtrasBrand(runtimeName));
|
|
40
29
|
//#endregion
|
|
41
|
-
export { createRuntimeExtras };
|
|
30
|
+
export { createRuntimeExtras, unstable_createRuntimeExtrasFromBrand };
|
|
42
31
|
|
|
43
32
|
//# sourceMappingURL=createRuntimeExtras.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRuntimeExtras.js","names":["useAuiState","AssistantClient","RuntimeExtras","provide","value","T","is","extras","tryGet","get","client","use","select","S","fallback","
|
|
1
|
+
{"version":3,"file":"createRuntimeExtras.js","names":["useAuiState","AssistantClient","createRuntimeExtrasBrand","RuntimeExtrasBrand","RuntimeExtras","provide","value","T","is","extras","tryGet","get","client","use","select","S","fallback","unstable_createRuntimeExtrasFromBrand","brand","assert","thread","getState","rest","hasFallback","length","s","createRuntimeExtras","runtimeName"],"sources":["../../../src/react/runtimes/createRuntimeExtras.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\nimport {\n createRuntimeExtrasBrand,\n type RuntimeExtrasBrand,\n} from \"../../runtime/utils/runtime-extras-brand\";\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport type RuntimeExtras<T extends object> = {\n provide: (value: T) => T;\n is: (extras: unknown) => extras is T;\n tryGet: (extras: unknown) => T | undefined;\n get: (client: AssistantClient) => T;\n use: {\n (): T;\n <S>(select: (extras: T) => S): S;\n <S>(select: (extras: T) => S, fallback: S): S;\n };\n};\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport const unstable_createRuntimeExtrasFromBrand = <T extends object>(\n brand: RuntimeExtrasBrand<T>,\n): RuntimeExtras<T> => {\n const { provide, is, tryGet, assert } = brand;\n\n const get = (client: AssistantClient): T =>\n assert(client.thread.getState().extras);\n\n function use<S>(\n select?: (extras: T) => S,\n ...rest: [fallback: S] | []\n ): S | T {\n // Detect a provided fallback by arity, not value: callers pass an explicit\n // `undefined` fallback, which must return `undefined` rather than throw.\n const hasFallback = rest.length > 0;\n const fallback = rest[0] as S;\n return useAuiState((s) => {\n const extras = s.thread.extras;\n if (is(extras)) return select ? select(extras) : extras;\n if (hasFallback) return fallback;\n return assert(extras);\n });\n }\n\n return { provide, is, tryGet, get, use: use as RuntimeExtras<T>[\"use\"] };\n};\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport const createRuntimeExtras = <T extends object>(\n runtimeName: string,\n): RuntimeExtras<T> =>\n unstable_createRuntimeExtrasFromBrand(\n createRuntimeExtrasBrand<T>(runtimeName),\n );\n"],"mappings":";;;;;AAuBA,MAAaiB,yCACXC,UACqB;CACrB,MAAM,EAAEb,SAASG,IAAIE,QAAQS,WAAWD;CAExC,MAAMP,OAAOC,WACXO,OAAOP,OAAOQ,OAAOC,SAAS,CAAC,CAACZ,MAAM;CAExC,SAASI,IACPC,QACA,GAAGQ,MACI;EAGP,MAAMC,cAAcD,KAAKE,SAAS;EAClC,MAAMR,WAAWM,KAAK;EACtB,OAAOtB,aAAayB,MAAM;GACxB,MAAMhB,SAASgB,EAAEL,OAAOX;GACxB,IAAID,GAAGC,MAAM,GAAG,OAAOK,SAASA,OAAOL,MAAM,IAAIA;GACjD,IAAIc,aAAa,OAAOP;GACxB,OAAOG,OAAOV,MAAM;EACtB,CAAC;CACH;CAEA,OAAO;EAAEJ;EAASG;EAAIE;EAAQC;EAAUE;CAA+B;AACzE;;AAGA,MAAaa,uBACXC,gBAEAV,sCACEf,yBAA4ByB,WAAW,CACzC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Unsubscribe } from "../../../types/unsubscribe.js";
|
|
2
|
-
import "../../../index.js";
|
|
3
2
|
import { DataMessagePartComponent } from "../MessagePartComponentTypes.js";
|
|
3
|
+
import "../../../index.js";
|
|
4
4
|
//#region src/react/types/scopes/dataRenderers.d.ts
|
|
5
5
|
type DataRenderersState = {
|
|
6
6
|
renderers: Record<string, DataMessagePartComponent[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Unsubscribe } from "../../../types/unsubscribe.js";
|
|
2
|
-
import "../../../index.js";
|
|
3
2
|
import { ToolCallMessagePartComponent } from "../MessagePartComponentTypes.js";
|
|
3
|
+
import "../../../index.js";
|
|
4
4
|
import { Tool } from "assistant-stream";
|
|
5
5
|
//#region src/react/types/scopes/interactables.d.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Unsubscribe } from "../../../types/unsubscribe.js";
|
|
2
|
-
import "../../../index.js";
|
|
3
2
|
import { ToolCallMessagePartComponent } from "../MessagePartComponentTypes.js";
|
|
3
|
+
import "../../../index.js";
|
|
4
4
|
//#region src/react/types/scopes/tools.d.ts
|
|
5
5
|
type McpAppResourceOutput = {
|
|
6
6
|
readonly render: ToolCallMessagePartComponent;
|
|
@@ -27,7 +27,7 @@ declare abstract class BaseComposerRuntimeCore extends BaseSubscribable implemen
|
|
|
27
27
|
private _text;
|
|
28
28
|
get text(): string;
|
|
29
29
|
private _role;
|
|
30
|
-
get role(): "
|
|
30
|
+
get role(): "assistant" | "system" | "user";
|
|
31
31
|
private _runConfig;
|
|
32
32
|
get runConfig(): RunConfig;
|
|
33
33
|
private _quote;
|
|
@@ -10,8 +10,6 @@ declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
|
|
|
10
10
|
get canSend(): boolean;
|
|
11
11
|
protected getAttachmentAdapter(): AttachmentAdapter | undefined;
|
|
12
12
|
protected getDictationAdapter(): DictationAdapter | undefined;
|
|
13
|
-
private _previousText;
|
|
14
|
-
private _previousAttachments;
|
|
15
13
|
private _nonTextPassthrough;
|
|
16
14
|
private _parentId;
|
|
17
15
|
private _sourceId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-edit-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"mappings":";;;;;;;cAWa,uCAAuC;MACvC;MAIA;YAID,wBAAoB;YAIpB,uBAAmB;UAIrB;UACA;UACA;UACA;
|
|
1
|
+
{"version":3,"file":"default-edit-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"mappings":";;;;;;;cAWa,uCAAuC;MACvC;MAIA;YAID,wBAAoB;YAIpB,uBAAmB;UAIrB;UACA;UACA;UACA;UAQA;EAGN,YAAA,SAAS;IACP;MAEM,cAAc;MACd,YAAY;;KAIpB,+BACE,UAAU;IAAa;IAAyB,SAAS;;MA6BlD;MAIA;EAIE,WACX,SAAS,KAAK,yCACd,UAAU,cAAW;EAkChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { gateInteractableComposerMetadata } from "../../model-context/interactable-composer-metadata.js";
|
|
2
|
-
import {
|
|
2
|
+
import { liftNonTextParts } from "../../adapters/attachment.js";
|
|
3
3
|
import { getThreadMessageText } from "../../utils/text.js";
|
|
4
4
|
import { BaseComposerRuntimeCore } from "./base-composer-runtime-core.js";
|
|
5
5
|
//#region src/runtime/base/default-edit-composer-runtime-core.ts
|
|
@@ -16,8 +16,6 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
16
16
|
getDictationAdapter() {
|
|
17
17
|
return this.runtime.adapters?.dictation;
|
|
18
18
|
}
|
|
19
|
-
_previousText;
|
|
20
|
-
_previousAttachments;
|
|
21
19
|
_nonTextPassthrough;
|
|
22
20
|
_parentId;
|
|
23
21
|
_sourceId;
|
|
@@ -29,17 +27,17 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
29
27
|
this.endEditCallback = endEditCallback;
|
|
30
28
|
this._parentId = parentId;
|
|
31
29
|
this._sourceId = message.id;
|
|
32
|
-
this.
|
|
33
|
-
this.setText(this._previousText);
|
|
30
|
+
this.setText(getThreadMessageText(message));
|
|
34
31
|
this.setRole(message.role);
|
|
32
|
+
let attachments;
|
|
35
33
|
if (message.role === "user") {
|
|
36
|
-
|
|
34
|
+
attachments = [...message.attachments ?? [], ...liftNonTextParts(message.content)];
|
|
37
35
|
this._nonTextPassthrough = [];
|
|
38
36
|
} else {
|
|
39
|
-
|
|
37
|
+
attachments = message.attachments ?? [];
|
|
40
38
|
this._nonTextPassthrough = message.content.filter((p) => p.type !== "text");
|
|
41
39
|
}
|
|
42
|
-
this.setAttachments(
|
|
40
|
+
this.setAttachments(attachments);
|
|
43
41
|
this.setRunConfig({ ...runtime.composer.runConfig });
|
|
44
42
|
}
|
|
45
43
|
get parentId() {
|
|
@@ -49,23 +47,18 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
|
49
47
|
return this._sourceId;
|
|
50
48
|
}
|
|
51
49
|
async handleSend(message, options) {
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
parentId: this._parentId,
|
|
65
|
-
sourceId: this._sourceId,
|
|
66
|
-
startRun: options?.startRun
|
|
67
|
-
});
|
|
68
|
-
}
|
|
50
|
+
const content = this._nonTextPassthrough.length > 0 ? [...message.content, ...this._nonTextPassthrough] : message.content;
|
|
51
|
+
const messages = this.runtime.messages;
|
|
52
|
+
const parentIndex = this._parentId === null ? -1 : messages.findIndex((m) => m.id === this._parentId);
|
|
53
|
+
const composerMetadata = gateInteractableComposerMetadata(this.runtime.getModelContext().unstable_composerMetadata, messages.slice(0, parentIndex + 1));
|
|
54
|
+
const enriched = this.enrichWithComposerMetadata(message, composerMetadata);
|
|
55
|
+
const appendTask = this.runtime.append({
|
|
56
|
+
...enriched,
|
|
57
|
+
content,
|
|
58
|
+
parentId: this._parentId,
|
|
59
|
+
sourceId: this._sourceId,
|
|
60
|
+
startRun: options?.startRun
|
|
61
|
+
});
|
|
69
62
|
this.handleCancel();
|
|
70
63
|
return appendTask;
|
|
71
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","
|
|
1
|
+
{"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","liftNonTextParts","AttachmentAdapter","DictationAdapter","SendOptions","ThreadRuntimeCore","BaseComposerRuntimeCore","gateInteractableComposerMetadata","DefaultEditComposerRuntimeCore","canCancel","canSend","isEmpty","_isSending","getAttachmentAdapter","runtime","adapters","attachments","getDictationAdapter","dictation","_nonTextPassthrough","_parentId","_sourceId","endEditCallback","constructor","parentId","message","id","setText","setRole","role","content","filter","p","type","setAttachments","setRunConfig","composer","runConfig","sourceId","handleSend","Omit","options","length","messages","parentIndex","findIndex","m","composerMetadata","getModelContext","unstable_composerMetadata","slice","enriched","enrichWithComposerMetadata","appendTask","append","startRun","handleCancel","_notifySubscribers"],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage, ThreadMessage } from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { liftNonTextParts } from \"../../adapters/attachment\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { SendOptions } from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\nimport { gateInteractableComposerMetadata } from \"../../model-context/interactable-composer-metadata\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n public get canSend() {\n return !this.isEmpty && !this._isSending;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n protected getDictationAdapter() {\n return this.runtime.adapters?.dictation;\n }\n\n private _nonTextPassthrough: readonly ThreadMessage[\"content\"][number][];\n private _parentId: string | null;\n private _sourceId: string | null;\n private runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n };\n private endEditCallback: () => void;\n\n constructor(\n runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n },\n endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this.runtime = runtime;\n this.endEditCallback = endEditCallback;\n this._parentId = parentId;\n this._sourceId = message.id;\n this.setText(getThreadMessageText(message));\n\n this.setRole(message.role);\n\n let attachments: readonly CompleteAttachment[];\n if (message.role === \"user\") {\n attachments = [\n ...(message.attachments ?? []),\n ...liftNonTextParts(message.content),\n ];\n this._nonTextPassthrough = [];\n } else {\n attachments = message.attachments ?? [];\n this._nonTextPassthrough = message.content.filter(\n (p) => p.type !== \"text\",\n );\n }\n this.setAttachments(attachments);\n\n this.setRunConfig({ ...runtime.composer.runConfig });\n }\n\n public get parentId() {\n return this._parentId;\n }\n\n public get sourceId() {\n return this._sourceId;\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ) {\n const content =\n this._nonTextPassthrough.length > 0\n ? ([\n ...message.content,\n ...this._nonTextPassthrough,\n ] as AppendMessage[\"content\"])\n : message.content;\n // Gate live state against the new branch's prefix (messages up to the\n // parent): an unchanged interactable re-stamps the prior baseline, an\n // interactable edited since the original message stamps its newest state.\n const messages = this.runtime.messages;\n const parentIndex =\n this._parentId === null\n ? -1\n : messages.findIndex((m) => m.id === this._parentId);\n const composerMetadata = gateInteractableComposerMetadata(\n this.runtime.getModelContext().unstable_composerMetadata,\n messages.slice(0, parentIndex + 1),\n );\n const enriched = this.enrichWithComposerMetadata(message, composerMetadata);\n const appendTask = this.runtime.append({\n ...enriched,\n content,\n parentId: this._parentId,\n sourceId: this._sourceId,\n startRun: options?.startRun,\n });\n\n this.handleCancel();\n return appendTask;\n }\n\n public handleCancel() {\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;;AAWA,IAAaW,iCAAb,cAAoDF,wBAAwB;CAC1E,IAAWG,YAAY;EACrB,OAAO;CACT;CAEA,IAAWC,UAAU;EACnB,OAAO,CAAC,KAAKC,WAAW,CAAC,KAAKC;CAChC;CAEA,uBAAiC;EAC/B,OAAO,KAAKE,QAAQC,UAAUC;CAChC;CAEA,sBAAgC;EAC9B,OAAO,KAAKF,QAAQC,UAAUG;CAChC;CAEA;CACA;CACA;CACA;CAQA;CAEAK,YACET,SAQAQ,iBACA,EAAEE,UAAUC,WACZ;EACA,MAAM;EACN,KAAKX,UAAUA;EACf,KAAKQ,kBAAkBA;EACvB,KAAKF,YAAYI;EACjB,KAAKH,YAAYI,QAAQC;EACzB,KAAKC,QAAQ3B,qBAAqByB,OAAO,CAAC;EAE1C,KAAKG,QAAQH,QAAQI,IAAI;EAEzB,IAAIb;EACJ,IAAIS,QAAQI,SAAS,QAAQ;GAC3Bb,cAAc,CACZ,GAAIS,QAAQT,eAAe,CAAA,GAC3B,GAAGf,iBAAiBwB,QAAQK,OAAO,CAAC;GAEtC,KAAKX,sBAAsB,CAAA;EAC7B,OAAO;GACLH,cAAcS,QAAQT,eAAe,CAAA;GACrC,KAAKG,sBAAsBM,QAAQK,QAAQC,QACxCC,MAAMA,EAAEC,SAAS,MACpB;EACF;EACA,KAAKC,eAAelB,WAAW;EAE/B,KAAKmB,aAAa,EAAE,GAAGrB,QAAQsB,SAASC,UAAU,CAAC;CACrD;CAEA,IAAWb,WAAW;EACpB,OAAO,KAAKJ;CACd;CAEA,IAAWkB,WAAW;EACpB,OAAO,KAAKjB;CACd;CAEA,MAAakB,WACXd,SACAgB,SACA;EACA,MAAMX,UACJ,KAAKX,oBAAoBuB,SAAS,IAC7B,CACC,GAAGjB,QAAQK,SACX,GAAG,KAAKX,mBAAmB,IAE7BM,QAAQK;EAId,MAAMa,WAAW,KAAK7B,QAAQ6B;EAC9B,MAAMC,cACJ,KAAKxB,cAAc,OACf,KACAuB,SAASE,WAAWC,MAAMA,EAAEpB,OAAO,KAAKN,SAAS;EACvD,MAAM2B,mBAAmBxC,iCACvB,KAAKO,QAAQkC,gBAAgB,CAAC,CAACC,2BAC/BN,SAASO,MAAM,GAAGN,cAAc,CAAC,CACnC;EACA,MAAMO,WAAW,KAAKC,2BAA2B3B,SAASsB,gBAAgB;EAC1E,MAAMM,aAAa,KAAKvC,QAAQwC,OAAO;GACrC,GAAGH;GACHrB;GACAN,UAAU,KAAKJ;GACfkB,UAAU,KAAKjB;GACfkC,UAAUd,SAASc;EACrB,CAAC;EAED,KAAKC,aAAa;EAClB,OAAOH;CACT;CAEA,eAAsB;EACpB,KAAK/B,gBAAgB;EACrB,KAAKmC,mBAAmB;CAC1B;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/runtime/utils/runtime-extras-brand.d.ts
|
|
2
|
+
/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */
|
|
3
|
+
type RuntimeExtrasBrand<T extends object> = {
|
|
4
|
+
provide: (value: T) => T;
|
|
5
|
+
is: (extras: unknown) => extras is T;
|
|
6
|
+
tryGet: (extras: unknown) => T | undefined;
|
|
7
|
+
assert: (extras: unknown) => T;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Creates the framework-neutral half of a runtime extras channel: the brand
|
|
11
|
+
* symbol with its provide/read primitives. A runtime factory provides extras
|
|
12
|
+
* through the brand on any framework; the React entry wraps the same brand
|
|
13
|
+
* with a `use()` hook. The symbol is per-instance, so the adapter package
|
|
14
|
+
* creates the brand once and every binding imports that instance.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice.
|
|
17
|
+
*/
|
|
18
|
+
declare const createRuntimeExtrasBrand: <T extends object>(runtimeName: string) => RuntimeExtrasBrand<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { RuntimeExtrasBrand, createRuntimeExtrasBrand };
|
|
21
|
+
//# sourceMappingURL=runtime-extras-brand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-extras-brand.d.ts","names":[],"sources":["../../../src/runtime/utils/runtime-extras-brand.ts"],"mappings":";;KACY,mBAAmB;EAC7B,UAAU,OAAO,MAAM;EACvB,KAAK,oBAAoB,UAAU;EACnC,SAAS,oBAAoB;EAC7B,SAAS,oBAAoB;;;;;;;;;;;cAYlB,2BAA4B,kBACvC,wBACC,mBAAmB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/runtime/utils/runtime-extras-brand.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates the framework-neutral half of a runtime extras channel: the brand
|
|
4
|
+
* symbol with its provide/read primitives. A runtime factory provides extras
|
|
5
|
+
* through the brand on any framework; the React entry wraps the same brand
|
|
6
|
+
* with a `use()` hook. The symbol is per-instance, so the adapter package
|
|
7
|
+
* creates the brand once and every binding imports that instance.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice.
|
|
10
|
+
*/
|
|
11
|
+
const createRuntimeExtrasBrand = (runtimeName) => {
|
|
12
|
+
const brand = Symbol(`${runtimeName} extras`);
|
|
13
|
+
const is = (extras) => typeof extras === "object" && extras !== null && brand in extras;
|
|
14
|
+
const assert = (extras) => {
|
|
15
|
+
if (!is(extras)) throw new Error(`The current thread is not backed by the ${runtimeName} runtime.`);
|
|
16
|
+
return extras;
|
|
17
|
+
};
|
|
18
|
+
const provide = (value) => {
|
|
19
|
+
Object.defineProperty(value, brand, {
|
|
20
|
+
value: true,
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
const tryGet = (extras) => is(extras) ? extras : void 0;
|
|
27
|
+
return {
|
|
28
|
+
provide,
|
|
29
|
+
is,
|
|
30
|
+
tryGet,
|
|
31
|
+
assert
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { createRuntimeExtrasBrand };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=runtime-extras-brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-extras-brand.js","names":["RuntimeExtrasBrand","provide","value","T","is","extras","tryGet","assert","createRuntimeExtrasBrand","runtimeName","brand","Symbol","Error","Object","defineProperty","enumerable","configurable","undefined"],"sources":["../../../src/runtime/utils/runtime-extras-brand.ts"],"sourcesContent":["/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport type RuntimeExtrasBrand<T extends object> = {\n provide: (value: T) => T;\n is: (extras: unknown) => extras is T;\n tryGet: (extras: unknown) => T | undefined;\n assert: (extras: unknown) => T;\n};\n\n/**\n * Creates the framework-neutral half of a runtime extras channel: the brand\n * symbol with its provide/read primitives. A runtime factory provides extras\n * through the brand on any framework; the React entry wraps the same brand\n * with a `use()` hook. The symbol is per-instance, so the adapter package\n * creates the brand once and every binding imports that instance.\n *\n * @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice.\n */\nexport const createRuntimeExtrasBrand = <T extends object>(\n runtimeName: string,\n): RuntimeExtrasBrand<T> => {\n const brand = Symbol(`${runtimeName} extras`);\n\n const is = (extras: unknown): extras is T =>\n typeof extras === \"object\" && extras !== null && brand in extras;\n\n const assert = (extras: unknown): T => {\n if (!is(extras))\n throw new Error(\n `The current thread is not backed by the ${runtimeName} runtime.`,\n );\n return extras;\n };\n\n const provide = (value: T): T => {\n Object.defineProperty(value, brand, {\n value: true,\n enumerable: false,\n configurable: true,\n });\n return value;\n };\n\n const tryGet = (extras: unknown): T | undefined =>\n is(extras) ? extras : undefined;\n\n return { provide, is, tryGet, assert };\n};\n"],"mappings":";;;;;;;;;;AAiBA,MAAaQ,4BACXC,gBAC0B;CAC1B,MAAMC,QAAQC,OAAO,GAAGF,YAAW,QAAS;CAE5C,MAAML,MAAMC,WACV,OAAOA,WAAW,YAAYA,WAAW,QAAQK,SAASL;CAE5D,MAAME,UAAUF,WAAuB;EACrC,IAAI,CAACD,GAAGC,MAAM,GACZ,MAAM,IAAIO,MACR,2CAA2CH,YAAW,UACxD;EACF,OAAOJ;CACT;CAEA,MAAMJ,WAAWC,UAAgB;EAC/BW,OAAOC,eAAeZ,OAAOQ,OAAO;GAClCR,OAAO;GACPa,YAAY;GACZC,cAAc;EAChB,CAAC;EACD,OAAOd;CACT;CAEA,MAAMI,UAAUD,WACdD,GAAGC,MAAM,IAAIA,SAASY,KAAAA;CAExB,OAAO;EAAEhB;EAASG;EAAIE;EAAQC;CAAO;AACvC"}
|
|
@@ -47,9 +47,11 @@ const fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
|
47
47
|
const type = part.type;
|
|
48
48
|
switch (type) {
|
|
49
49
|
case "text":
|
|
50
|
-
case "reasoning":
|
|
51
50
|
if (!part.text?.trim()) return null;
|
|
52
51
|
return part;
|
|
52
|
+
case "reasoning":
|
|
53
|
+
if (!part.text?.trim() && !part.unstable_summary?.trim()) return null;
|
|
54
|
+
return part;
|
|
53
55
|
case "file":
|
|
54
56
|
case "source": return part;
|
|
55
57
|
case "image": return sanitizeImageContent(part);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-like.js","names":["parsePartialJsonObject","generateId","parseDataUrl","ReasoningMessagePart","SourceMessagePart","ThreadStep","MessageStatus","ImageMessagePart","ThreadMessage","ThreadAssistantMessagePart","ThreadAssistantMessage","ThreadUserMessagePart","ThreadUserMessage","ThreadSystemMessage","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","Unstable_AudioMessagePart","CompleteAttachment","MessageTiming","PartProviderMetadata","TextMessagePart","ToolApprovalOption","ToolCallTiming","ReadonlyJSONObject","ReadonlyJSONValue","DataPrefixedPart","type","data","ThreadMessageLike","role","content","toolCallId","toolName","args","argsText","artifact","result","isError","parentId","messages","interrupt","payload","timing","providerMetadata","approval","id","approved","reason","isAutomatic","options","optionId","resolution","createdAt","Date","status","attachments","Omit","metadata","unstable_state","unstable_annotations","unstable_data","steps","submittedFeedback","isOptimistic","custom","Record","convertDataPrefixedPart","startsWith","undefined","name","substring","fromThreadMessageLike","like","fallbackId","fallbackStatus","common","const","text","sanitizeImageContent","image","rest","mimeType","test","console","warn","length","Error","map","part","trim","basePart","commonProps","JSON","stringify","converted","filter","c","att","unsupportedRole"],"sources":["../../../src/runtime/utils/thread-message-like.ts"],"sourcesContent":["import { parsePartialJsonObject } from \"assistant-stream/utils\";\nimport { generateId } from \"../../utils/id\";\nimport { parseDataUrl } from \"../../utils/data-url\";\nimport type {\n ReasoningMessagePart,\n SourceMessagePart,\n ThreadStep,\n MessageStatus,\n ImageMessagePart,\n ThreadMessage,\n ThreadAssistantMessagePart,\n ThreadAssistantMessage,\n ThreadUserMessagePart,\n ThreadUserMessage,\n ThreadSystemMessage,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n Unstable_AudioMessagePart,\n} from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport type {\n MessageTiming,\n PartProviderMetadata,\n TextMessagePart,\n ToolApprovalOption,\n ToolCallTiming,\n} from \"../../types/message\";\nimport type {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"assistant-stream/utils\";\n\ntype DataPrefixedPart = {\n readonly type: `data-${string}`;\n readonly data: any;\n};\n\nexport type ThreadMessageLike = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly content:\n | string\n | readonly (\n | TextMessagePart\n | ReasoningMessagePart\n | SourceMessagePart\n | ImageMessagePart\n | FileMessagePart\n | DataMessagePart\n | GenerativeUIMessagePart\n | Unstable_AudioMessagePart\n | DataPrefixedPart\n | {\n readonly type: \"tool-call\";\n readonly toolCallId?: string;\n readonly toolName: string;\n readonly args?: ReadonlyJSONObject;\n readonly argsText?: string;\n readonly artifact?: any;\n readonly result?: any | undefined;\n readonly isError?: boolean | undefined;\n readonly parentId?: string | undefined;\n readonly messages?: readonly ThreadMessage[] | undefined;\n readonly interrupt?: { type: \"human\"; payload: unknown };\n readonly timing?: ToolCallTiming;\n readonly providerMetadata?: PartProviderMetadata;\n readonly approval?: {\n readonly id: string;\n readonly approved?: boolean;\n readonly reason?: string;\n readonly isAutomatic?: boolean;\n readonly options?: readonly ToolApprovalOption[];\n readonly optionId?: string;\n readonly resolution?: \"cancelled\" | \"expired\";\n };\n }\n )[];\n readonly id?: string | undefined;\n readonly createdAt?: Date | undefined;\n readonly status?: MessageStatus | undefined;\n readonly attachments?:\n | readonly (Omit<CompleteAttachment, \"content\"> & {\n readonly content: readonly (ThreadUserMessagePart | DataPrefixedPart)[];\n })[]\n | undefined;\n readonly metadata?:\n | {\n readonly unstable_state?: ReadonlyJSONValue;\n readonly unstable_annotations?:\n | readonly ReadonlyJSONValue[]\n | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly timing?: MessageTiming | undefined;\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly isOptimistic?: boolean | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n }\n | undefined;\n};\n\nconst convertDataPrefixedPart = (\n type: string,\n data: unknown,\n): DataMessagePart | undefined => {\n if (!type.startsWith(\"data-\")) return undefined;\n return { type: \"data\", name: type.substring(5), data };\n};\n\n/**\n * @deprecated This API is experimental and may change without notice.\n */\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n const sanitizeImageContent = ({\n image,\n ...rest\n }: ImageMessagePart): ImageMessagePart | null => {\n if (typeof image !== \"string\") return null;\n if (parseDataUrl(image)?.mimeType.startsWith(\"image/\")) {\n return { ...rest, image };\n }\n if (/^(https:\\/\\/|blob:)/i.test(image)) {\n return { ...rest, image };\n }\n console.warn(`Invalid image data format detected`);\n return null;\n };\n\n if (role !== \"user\" && attachments?.length)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantMessagePart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"reasoning\":\n if (!part.text?.trim()) return null;\n return part;\n\n case \"file\":\n case \"source\":\n return part;\n\n case \"image\":\n return sanitizeImageContent(part);\n\n case \"data\":\n return part;\n\n case \"generative-ui\":\n return part;\n\n case \"tool-call\": {\n const { parentId, messages, ...basePart } = part;\n const commonProps = {\n ...basePart,\n toolCallId: part.toolCallId ?? `tool-${generateId()}`,\n ...(parentId !== undefined && { parentId }),\n ...(messages !== undefined && { messages }),\n };\n\n if (part.args) {\n return {\n ...commonProps,\n args: part.args,\n argsText: part.argsText ?? JSON.stringify(part.args),\n };\n }\n return {\n ...commonProps,\n args: parsePartialJsonObject(part.argsText ?? \"\") ?? {},\n argsText: part.argsText ?? \"\",\n };\n }\n\n default: {\n const converted = convertDataPrefixedPart(\n type,\n (part as DataPrefixedPart).data,\n );\n if (converted) return converted;\n throw new Error(\n `Unsupported assistant message part type: ${type}`,\n );\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n unstable_state: metadata?.unstable_state ?? null,\n unstable_annotations: metadata?.unstable_annotations ?? [],\n unstable_data: metadata?.unstable_data ?? [],\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n ...(metadata?.timing && { timing: metadata.timing }),\n ...(metadata?.submittedFeedback && {\n submittedFeedback: metadata.submittedFeedback,\n }),\n ...(metadata?.isOptimistic && { isOptimistic: true }),\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserMessagePart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"image\":\n case \"audio\":\n case \"file\":\n case \"data\":\n return part;\n\n default: {\n const converted = convertDataPrefixedPart(\n type,\n (part as DataPrefixedPart).data,\n );\n if (converted) return converted;\n throw new Error(`Unsupported user message part type: ${type}`);\n }\n }\n }),\n attachments: (attachments ?? []).map((att) => ({\n ...att,\n content: att.content.map((part): ThreadUserMessagePart => {\n const converted = convertDataPrefixedPart(\n part.type,\n (part as DataPrefixedPart).data,\n );\n return converted ?? (part as ThreadUserMessagePart);\n }),\n })),\n metadata: {\n custom: metadata?.custom ?? {},\n ...(metadata?.isOptimistic && { isOptimistic: true }),\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text message part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextMessagePart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";;;;AAqGA,MAAMmE,2BACJxC,MACAC,SACgC;CAChC,IAAI,CAACD,KAAKyC,WAAW,OAAO,GAAG,OAAOC,KAAAA;CACtC,OAAO;EAAE1C,MAAM;EAAQ2C,MAAM3C,KAAK4C,UAAU,CAAC;EAAG3C;CAAK;AACvD;;;;AAKA,MAAa4C,yBACXC,MACAC,YACAC,mBACkB;CAClB,MAAM,EAAE7C,MAAMgB,IAAIO,WAAWG,aAAaD,QAAQG,aAAae;CAC/D,MAAMG,SAAS;EACb9B,IAAIA,MAAM4B;EACVrB,WAAWA,6BAAa,IAAIC,KAAK;CACnC;CAEA,MAAMvB,UACJ,OAAO0C,KAAK1C,YAAY,WACpB,CAAC;EAAEJ,MAAM;EAAiBmD,MAAML,KAAK1C;CAAQ,CAAC,IAC9C0C,KAAK1C;CAEX,MAAMgD,wBAAwB,EAC5BC,OACA,GAAGC,WAC4C;EAC/C,IAAI,OAAOD,UAAU,UAAU,OAAO;EACtC,IAAI9E,aAAa8E,KAAK,CAAC,EAAEE,SAASd,WAAW,QAAQ,GACnD,OAAO;GAAE,GAAGa;GAAMD;EAAM;EAE1B,IAAI,uBAAuBG,KAAKH,KAAK,GACnC,OAAO;GAAE,GAAGC;GAAMD;EAAM;EAE1BI,QAAQC,KAAK,oCAAoC;EACjD,OAAO;CACT;CAEA,IAAIvD,SAAS,UAAU0B,aAAa8B,QAClC,MAAM,IAAIC,MAAM,kDAAkD;CAEpE,IAAIzD,SAAS,eAAeyB,QAC1B,MAAM,IAAIgC,MAAM,iDAAiD;CAEnE,IAAIzD,SAAS,eAAe4B,UAAUI,OACpC,MAAM,IAAIyB,MAAM,yDAAyD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UAAUO,UAAU,CAAC;IAC7BH,OAAOJ,UAAUI,SAAS,CAAA;IAC1B,GAAIJ,UAAUf,UAAU,EAAEA,QAAQe,SAASf,OAAO;IAClD,GAAIe,UAAUK,qBAAqB,EACjCA,mBAAmBL,SAASK,kBAC9B;IACA,GAAIL,UAAUM,gBAAgB,EAAEA,cAAc,KAAK;GACrD;EACF;EAEF,KAAK,QACH,OAAO;GACL,GAAGY;GACH9C;GACAC,SAASA,QAAQyD,KAAKC,SAAgC;IACpD,MAAM9D,OAAO8D,KAAK9D;IAClB,QAAQA,MAAR;KACE,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK,QACH,OAAO8D;KAET,SAAS;MACP,MAAMM,YAAY5B,wBAChBxC,MACC8D,KAA0B7D,IAC7B;MACA,IAAImE,WAAW,OAAOA;MACtB,MAAM,IAAIR,MAAM,uCAAuC5D,MAAM;KAC/D;IACF;GACF,CAAC;GACD6B,cAAcA,eAAe,CAAA,EAAA,CAAIgC,KAAKU,SAAS;IAC7C,GAAGA;IACHnE,SAASmE,IAAInE,QAAQyD,KAAKC,SAAgC;KAKxD,OAJkBtB,wBAChBsB,KAAK9D,MACJ8D,KAA0B7D,IAEtBmE,KAAcN;IACvB,CAAC;GACH,EAAE;GACF/B,UAAU;IACRO,QAAQP,UAAUO,UAAU,CAAC;IAC7B,GAAIP,UAAUM,gBAAgB,EAAEA,cAAc,KAAK;GACrD;EACF;EAEF,KAAK;GACH,IAAIjC,QAAQuD,WAAW,KAAKvD,QAAQ,EAAE,CAAEJ,SAAS,QAC/C,MAAM,IAAI4D,MACR,0DACF;GAEF,OAAO;IACL,GAAGX;IACH9C;IACSC;IACT2B,UAAU,EACRO,QAAQP,UAAUO,UAAU,CAAC,EAC/B;GACF;EAEF,SAEE,MAAM,IAAIsB,MAAM,yBAAyBY,MAAiB;CAE9D;AACF"}
|
|
1
|
+
{"version":3,"file":"thread-message-like.js","names":["parsePartialJsonObject","generateId","parseDataUrl","ReasoningMessagePart","SourceMessagePart","ThreadStep","MessageStatus","ImageMessagePart","ThreadMessage","ThreadAssistantMessagePart","ThreadAssistantMessage","ThreadUserMessagePart","ThreadUserMessage","ThreadSystemMessage","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","Unstable_AudioMessagePart","CompleteAttachment","MessageTiming","PartProviderMetadata","TextMessagePart","ToolApprovalOption","ToolCallTiming","ReadonlyJSONObject","ReadonlyJSONValue","DataPrefixedPart","type","data","ThreadMessageLike","role","content","toolCallId","toolName","args","argsText","artifact","result","isError","parentId","messages","interrupt","payload","timing","providerMetadata","approval","id","approved","reason","isAutomatic","options","optionId","resolution","createdAt","Date","status","attachments","Omit","metadata","unstable_state","unstable_annotations","unstable_data","steps","submittedFeedback","isOptimistic","custom","Record","convertDataPrefixedPart","startsWith","undefined","name","substring","fromThreadMessageLike","like","fallbackId","fallbackStatus","common","const","text","sanitizeImageContent","image","rest","mimeType","test","console","warn","length","Error","map","part","trim","unstable_summary","basePart","commonProps","JSON","stringify","converted","filter","c","att","unsupportedRole"],"sources":["../../../src/runtime/utils/thread-message-like.ts"],"sourcesContent":["import { parsePartialJsonObject } from \"assistant-stream/utils\";\nimport { generateId } from \"../../utils/id\";\nimport { parseDataUrl } from \"../../utils/data-url\";\nimport type {\n ReasoningMessagePart,\n SourceMessagePart,\n ThreadStep,\n MessageStatus,\n ImageMessagePart,\n ThreadMessage,\n ThreadAssistantMessagePart,\n ThreadAssistantMessage,\n ThreadUserMessagePart,\n ThreadUserMessage,\n ThreadSystemMessage,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n Unstable_AudioMessagePart,\n} from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport type {\n MessageTiming,\n PartProviderMetadata,\n TextMessagePart,\n ToolApprovalOption,\n ToolCallTiming,\n} from \"../../types/message\";\nimport type {\n ReadonlyJSONObject,\n ReadonlyJSONValue,\n} from \"assistant-stream/utils\";\n\ntype DataPrefixedPart = {\n readonly type: `data-${string}`;\n readonly data: any;\n};\n\nexport type ThreadMessageLike = {\n readonly role: \"assistant\" | \"user\" | \"system\";\n readonly content:\n | string\n | readonly (\n | TextMessagePart\n | ReasoningMessagePart\n | SourceMessagePart\n | ImageMessagePart\n | FileMessagePart\n | DataMessagePart\n | GenerativeUIMessagePart\n | Unstable_AudioMessagePart\n | DataPrefixedPart\n | {\n readonly type: \"tool-call\";\n readonly toolCallId?: string;\n readonly toolName: string;\n readonly args?: ReadonlyJSONObject;\n readonly argsText?: string;\n readonly artifact?: any;\n readonly result?: any | undefined;\n readonly isError?: boolean | undefined;\n readonly parentId?: string | undefined;\n readonly messages?: readonly ThreadMessage[] | undefined;\n readonly interrupt?: { type: \"human\"; payload: unknown };\n readonly timing?: ToolCallTiming;\n readonly providerMetadata?: PartProviderMetadata;\n readonly approval?: {\n readonly id: string;\n readonly approved?: boolean;\n readonly reason?: string;\n readonly isAutomatic?: boolean;\n readonly options?: readonly ToolApprovalOption[];\n readonly optionId?: string;\n readonly resolution?: \"cancelled\" | \"expired\";\n };\n }\n )[];\n readonly id?: string | undefined;\n readonly createdAt?: Date | undefined;\n readonly status?: MessageStatus | undefined;\n readonly attachments?:\n | readonly (Omit<CompleteAttachment, \"content\"> & {\n readonly content: readonly (ThreadUserMessagePart | DataPrefixedPart)[];\n })[]\n | undefined;\n readonly metadata?:\n | {\n readonly unstable_state?: ReadonlyJSONValue;\n readonly unstable_annotations?:\n | readonly ReadonlyJSONValue[]\n | undefined;\n readonly unstable_data?: readonly ReadonlyJSONValue[] | undefined;\n readonly steps?: readonly ThreadStep[] | undefined;\n readonly timing?: MessageTiming | undefined;\n readonly submittedFeedback?: { readonly type: \"positive\" | \"negative\" };\n readonly isOptimistic?: boolean | undefined;\n readonly custom?: Record<string, unknown> | undefined;\n }\n | undefined;\n};\n\nconst convertDataPrefixedPart = (\n type: string,\n data: unknown,\n): DataMessagePart | undefined => {\n if (!type.startsWith(\"data-\")) return undefined;\n return { type: \"data\", name: type.substring(5), data };\n};\n\n/**\n * @deprecated This API is experimental and may change without notice.\n */\nexport const fromThreadMessageLike = (\n like: ThreadMessageLike,\n fallbackId: string,\n fallbackStatus: MessageStatus,\n): ThreadMessage => {\n const { role, id, createdAt, attachments, status, metadata } = like;\n const common = {\n id: id ?? fallbackId,\n createdAt: createdAt ?? new Date(),\n };\n\n const content =\n typeof like.content === \"string\"\n ? [{ type: \"text\" as const, text: like.content }]\n : like.content;\n\n const sanitizeImageContent = ({\n image,\n ...rest\n }: ImageMessagePart): ImageMessagePart | null => {\n if (typeof image !== \"string\") return null;\n if (parseDataUrl(image)?.mimeType.startsWith(\"image/\")) {\n return { ...rest, image };\n }\n if (/^(https:\\/\\/|blob:)/i.test(image)) {\n return { ...rest, image };\n }\n console.warn(`Invalid image data format detected`);\n return null;\n };\n\n if (role !== \"user\" && attachments?.length)\n throw new Error(\"attachments are only supported for user messages\");\n\n if (role !== \"assistant\" && status)\n throw new Error(\"status is only supported for assistant messages\");\n\n if (role !== \"assistant\" && metadata?.steps)\n throw new Error(\"metadata.steps is only supported for assistant messages\");\n\n switch (role) {\n case \"assistant\":\n return {\n ...common,\n role,\n content: content\n .map((part): ThreadAssistantMessagePart | null => {\n const type = part.type;\n switch (type) {\n case \"text\":\n if (!part.text?.trim()) return null;\n return part;\n\n case \"reasoning\":\n if (!part.text?.trim() && !part.unstable_summary?.trim())\n return null;\n return part;\n\n case \"file\":\n case \"source\":\n return part;\n\n case \"image\":\n return sanitizeImageContent(part);\n\n case \"data\":\n return part;\n\n case \"generative-ui\":\n return part;\n\n case \"tool-call\": {\n const { parentId, messages, ...basePart } = part;\n const commonProps = {\n ...basePart,\n toolCallId: part.toolCallId ?? `tool-${generateId()}`,\n ...(parentId !== undefined && { parentId }),\n ...(messages !== undefined && { messages }),\n };\n\n if (part.args) {\n return {\n ...commonProps,\n args: part.args,\n argsText: part.argsText ?? JSON.stringify(part.args),\n };\n }\n return {\n ...commonProps,\n args: parsePartialJsonObject(part.argsText ?? \"\") ?? {},\n argsText: part.argsText ?? \"\",\n };\n }\n\n default: {\n const converted = convertDataPrefixedPart(\n type,\n (part as DataPrefixedPart).data,\n );\n if (converted) return converted;\n throw new Error(\n `Unsupported assistant message part type: ${type}`,\n );\n }\n }\n })\n .filter((c) => !!c),\n status: status ?? fallbackStatus,\n metadata: {\n unstable_state: metadata?.unstable_state ?? null,\n unstable_annotations: metadata?.unstable_annotations ?? [],\n unstable_data: metadata?.unstable_data ?? [],\n custom: metadata?.custom ?? {},\n steps: metadata?.steps ?? [],\n ...(metadata?.timing && { timing: metadata.timing }),\n ...(metadata?.submittedFeedback && {\n submittedFeedback: metadata.submittedFeedback,\n }),\n ...(metadata?.isOptimistic && { isOptimistic: true }),\n },\n } satisfies ThreadAssistantMessage;\n\n case \"user\":\n return {\n ...common,\n role,\n content: content.map((part): ThreadUserMessagePart => {\n const type = part.type;\n switch (type) {\n case \"text\":\n case \"image\":\n case \"audio\":\n case \"file\":\n case \"data\":\n return part;\n\n default: {\n const converted = convertDataPrefixedPart(\n type,\n (part as DataPrefixedPart).data,\n );\n if (converted) return converted;\n throw new Error(`Unsupported user message part type: ${type}`);\n }\n }\n }),\n attachments: (attachments ?? []).map((att) => ({\n ...att,\n content: att.content.map((part): ThreadUserMessagePart => {\n const converted = convertDataPrefixedPart(\n part.type,\n (part as DataPrefixedPart).data,\n );\n return converted ?? (part as ThreadUserMessagePart);\n }),\n })),\n metadata: {\n custom: metadata?.custom ?? {},\n ...(metadata?.isOptimistic && { isOptimistic: true }),\n },\n } satisfies ThreadUserMessage;\n\n case \"system\":\n if (content.length !== 1 || content[0]!.type !== \"text\")\n throw new Error(\n \"System messages must have exactly one text message part.\",\n );\n\n return {\n ...common,\n role,\n content: content as [TextMessagePart],\n metadata: {\n custom: metadata?.custom ?? {},\n },\n } satisfies ThreadSystemMessage;\n\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n};\n"],"mappings":";;;;AAqGA,MAAMmE,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AAqB,EACjCA,mBAAmBL,SAASK,kBAC9B;IACA,GAAIL,UAAUM,gBAAgB,EAAEA,cAAc,KAAK;GACrD;EACF;EAEF,KAAK,QACH,OAAO;GACL,GAAGY;GACH9C;GACAC,SAASA,QAAQyD,KAAKC,SAAgC;IACpD,MAAM9D,OAAO8D,KAAK9D;IAClB,QAAQA,MAAR;KACE,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK;KACL,KAAK,QACH,OAAO8D;KAET,SAAS;MACP,MAAMO,YAAY7B,wBAChBxC,MACC8D,KAA0B7D,IAC7B;MACA,IAAIoE,WAAW,OAAOA;MACtB,MAAM,IAAIT,MAAM,uCAAuC5D,MAAM;KAC/D;IACF;GACF,CAAC;GACD6B,cAAcA,eAAe,CAAA,EAAA,CAAIgC,KAAKW,SAAS;IAC7C,GAAGA;IACHpE,SAASoE,IAAIpE,QAAQyD,KAAKC,SAAgC;KAKxD,OAJkBtB,wBAChBsB,KAAK9D,MACJ8D,KAA0B7D,IAEtBoE,KAAcP;IACvB,CAAC;GACH,EAAE;GACF/B,UAAU;IACRO,QAAQP,UAAUO,UAAU,CAAC;IAC7B,GAAIP,UAAUM,gBAAgB,EAAEA,cAAc,KAAK;GACrD;EACF;EAEF,KAAK;GACH,IAAIjC,QAAQuD,WAAW,KAAKvD,QAAQ,EAAE,CAAEJ,SAAS,QAC/C,MAAM,IAAI4D,MACR,0DACF;GAEF,OAAO;IACL,GAAGX;IACH9C;IACSC;IACT2B,UAAU,EACRO,QAAQP,UAAUO,UAAU,CAAC,EAC/B;GACF;EAEF,SAEE,MAAM,IAAIsB,MAAM,yBAAyBa,MAAiB;CAE9D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-adapter.d.ts","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"runtime-adapter.d.ts","names":[],"sources":["../../../src/store/clients/runtime-adapter.ts"],"mappings":";;cAKa,oCACX,QAAQ,cACR,QAAQ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModelContext } from "./model-context-client.js";
|
|
2
2
|
import { Suggestions } from "./suggestions.js";
|
|
3
|
-
import { Derived } from "@assistant-ui/store";
|
|
3
|
+
import { Derived } from "@assistant-ui/store/client";
|
|
4
4
|
//#region src/store/clients/runtime-adapter.ts
|
|
5
5
|
const baseRuntimeAdapterTransformScopes = (scopes, parent) => {
|
|
6
6
|
scopes.thread ??= Derived({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-adapter.js","names":["
|
|
1
|
+
{"version":3,"file":"runtime-adapter.js","names":["AssistantClient","ScopesConfig","Derived","ModelContext","Suggestions","baseRuntimeAdapterTransformScopes","scopes","parent","thread","source","query","type","get","aui","threads","threadListItem","item","composer","modelContext","suggestions"],"sources":["../../../src/store/clients/runtime-adapter.ts"],"sourcesContent":["import type { AssistantClient, ScopesConfig } from \"@assistant-ui/store\";\nimport { Derived } from \"@assistant-ui/store/client\";\nimport { ModelContext } from \"./model-context-client\";\nimport { Suggestions } from \"./suggestions\";\n\nexport const baseRuntimeAdapterTransformScopes = (\n scopes: ScopesConfig,\n parent: AssistantClient,\n): void => {\n scopes.thread ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads.thread(\"main\"),\n });\n scopes.threadListItem ??= Derived({\n source: \"threads\",\n query: { type: \"main\" },\n get: (aui) => aui.threads.item(\"main\"),\n });\n scopes.composer ??= Derived({\n source: \"thread\",\n query: {},\n get: (aui) => aui.threads.thread(\"main\").composer(),\n });\n\n if (!scopes.modelContext && parent.modelContext.source === null) {\n scopes.modelContext = ModelContext();\n }\n if (!scopes.suggestions && parent.suggestions.source === null) {\n scopes.suggestions = Suggestions();\n }\n};\n"],"mappings":";;;;AAKA,MAAaK,qCACXC,QACAC,WACS;CACTD,OAAOE,WAAWN,QAAQ;EACxBO,QAAQ;EACRC,OAAO,EAAEC,MAAM,OAAO;EACtBC,MAAMC,QAAQA,IAAIC,QAAQN,OAAO,MAAM;CACzC,CAAC;CACDF,OAAOS,mBAAmBb,QAAQ;EAChCO,QAAQ;EACRC,OAAO,EAAEC,MAAM,OAAO;EACtBC,MAAMC,QAAQA,IAAIC,QAAQE,KAAK,MAAM;CACvC,CAAC;CACDV,OAAOW,aAAaf,QAAQ;EAC1BO,QAAQ;EACRC,OAAO,CAAC;EACRE,MAAMC,QAAQA,IAAIC,QAAQN,OAAO,MAAM,CAAC,CAACS,SAAS;CACpD,CAAC;CAED,IAAI,CAACX,OAAOY,gBAAgBX,OAAOW,aAAaT,WAAW,MACzDH,OAAOY,eAAef,aAAa;CAErC,IAAI,CAACG,OAAOa,eAAeZ,OAAOY,YAAYV,WAAW,MACvDH,OAAOa,cAAcf,YAAY;AAErC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
2
2
|
import { useState } from "@assistant-ui/tap/react-shim";
|
|
3
|
-
import { useClientLookup } from "@assistant-ui/store";
|
|
4
3
|
import { resource, withKey } from "@assistant-ui/tap";
|
|
4
|
+
import { useClientLookup } from "@assistant-ui/store/client";
|
|
5
5
|
//#region src/store/clients/suggestions.ts
|
|
6
6
|
const useSuggestionClient = (state) => {
|
|
7
7
|
return { getState: () => state };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.js","names":["useState","resource","withKey","ClientOutput","useClientLookup","SuggestionsState","SuggestionState","SuggestionConfig","title","label","prompt","useSuggestionClient","state","getState","SuggestionClient","useSuggestionsResource","suggestions","$","_c","t0","normalizedSuggestions","map","_temp","t1","_temp2","suggestionClients","t2","t3","t4","index","index_0","get","suggestion","Suggestions","s"],"sources":["../../../src/store/clients/suggestions.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { SuggestionsState } from \"../scopes/suggestions\";\nimport type { SuggestionState } from \"../scopes/suggestion\";\n\nexport type SuggestionConfig =\n | string\n | { title: string; label: string; prompt: string };\n\nconst useSuggestionClient = (\n state: SuggestionState,\n): ClientOutput<\"suggestion\"> => {\n return {\n getState: () => state,\n };\n};\n\nconst SuggestionClient = resource(useSuggestionClient);\n\nconst useSuggestionsResource = (\n suggestions?: SuggestionConfig[],\n): ClientOutput<\"suggestions\"> => {\n const [state] = useState<SuggestionsState>(() => {\n const normalizedSuggestions = (suggestions ?? []).map((s) => {\n if (typeof s === \"string\") {\n return {\n title: s,\n label: \"\",\n prompt: s,\n };\n }\n return {\n title: s.title,\n label: s.label,\n prompt: s.prompt,\n };\n });\n\n return {\n suggestions: normalizedSuggestions,\n };\n });\n\n const suggestionClients = useClientLookup(\n state.suggestions.map((suggestion, index) =>\n withKey(index, SuggestionClient(suggestion), [suggestion]),\n ),\n );\n\n return {\n getState: () => state,\n suggestion: ({ index }: { index: number }) => {\n return suggestionClients.get({ index });\n },\n };\n};\n\nexport const Suggestions = resource(useSuggestionsResource);\n"],"mappings":";;;;;AAWA,MAAMW,uBACJC,UAC+B;CAC/B,OAAO,EACLC,gBAAgBD,MAClB;AACF;AAEA,MAAME,mBAAmBb,SAASU,mBAAmB;AAErD,MAAMI,0BAAyBC,gBAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,aAAA;EAGcG,WAAA;GActC,OAEI,EAAAH,cAfwBA,eAAA,CAAA,EAAA,CAAiBK,IAAMC,KAgBvCF,EACf;EAAC;EACFH,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAnBD,MAAA,CAAAL,SAAgBZ,SAA2BmB,EAmB1C;CAAE,IAAAI;CAAA,IAAAN,EAAA,OAAAL,MAAAI,aAAA;EAGDO,KAAAX,MAAKI,YAAYK,IAAKG,MAEtB;EAACP,EAAA,KAAAL,MAAAI;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAHH,MAAAQ,oBAA0BrB,gBACxBmB,EAGF;CAAE,IAAAG;CAAA,IAAAT,EAAA,OAAAL,OAAA;EAGUc,WAAMd;EAAKK,EAAA,KAAAL;EAAAK,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,OAAAQ,mBAAA;EACTE,MAAAC,OAAA;GAAC,MAAA,EAAAC,OAAAC,YAAAF;GAA4B,OAChCH,kBAAiBM,IAAK,EAAAF,OAAEA,QAAM,CAAC;EAAC;EACxCZ,EAAA,KAAAQ;EAAAR,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,IAAAW;CAAA,IAAAX,EAAA,OAAAS,MAAAT,EAAA,OAAAU,IAAA;EAJIC,KAAA;GAAAf,UACKa;GAAWM,YACTL;EAGd;EAACV,EAAA,KAAAS;EAAAT,EAAA,KAAAU;EAAAV,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OALMW;AAKN;AAGH,MAAaK,cAAchC,SAASc,sBAAsB;AAtC3B,SAAAO,MAAAY,GAAA;CAKzB,IAAI,OAAOA,MAAM,UAAQ,OAChB;EAAA1B,OACE0B;EAACzB,OACD;EAAEC,QACDwB;CACV;CACD,OACM;EAAA1B,OACE0B,EAAC1B;EAAMC,OACPyB,EAACzB;EAAMC,QACNwB,EAACxB;CACX;AAAC;AAhBwB,SAAAc,OAAAQ,YAAAH,OAAA;CAAA,OA0BzB3B,QAAQ2B,OAAOf,iBAAiBkB,UAAU,GAAG,CAACA,UAAU,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"suggestions.js","names":["useState","resource","withKey","ClientOutput","useClientLookup","SuggestionsState","SuggestionState","SuggestionConfig","title","label","prompt","useSuggestionClient","state","getState","SuggestionClient","useSuggestionsResource","suggestions","$","_c","t0","normalizedSuggestions","map","_temp","t1","_temp2","suggestionClients","t2","t3","t4","index","index_0","get","suggestion","Suggestions","s"],"sources":["../../../src/store/clients/suggestions.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store/client\";\nimport type { SuggestionsState } from \"../scopes/suggestions\";\nimport type { SuggestionState } from \"../scopes/suggestion\";\n\nexport type SuggestionConfig =\n | string\n | { title: string; label: string; prompt: string };\n\nconst useSuggestionClient = (\n state: SuggestionState,\n): ClientOutput<\"suggestion\"> => {\n return {\n getState: () => state,\n };\n};\n\nconst SuggestionClient = resource(useSuggestionClient);\n\nconst useSuggestionsResource = (\n suggestions?: SuggestionConfig[],\n): ClientOutput<\"suggestions\"> => {\n const [state] = useState<SuggestionsState>(() => {\n const normalizedSuggestions = (suggestions ?? []).map((s) => {\n if (typeof s === \"string\") {\n return {\n title: s,\n label: \"\",\n prompt: s,\n };\n }\n return {\n title: s.title,\n label: s.label,\n prompt: s.prompt,\n };\n });\n\n return {\n suggestions: normalizedSuggestions,\n };\n });\n\n const suggestionClients = useClientLookup(\n state.suggestions.map((suggestion, index) =>\n withKey(index, SuggestionClient(suggestion), [suggestion]),\n ),\n );\n\n return {\n getState: () => state,\n suggestion: ({ index }: { index: number }) => {\n return suggestionClients.get({ index });\n },\n };\n};\n\nexport const Suggestions = resource(useSuggestionsResource);\n"],"mappings":";;;;;AAWA,MAAMW,uBACJC,UAC+B;CAC/B,OAAO,EACLC,gBAAgBD,MAClB;AACF;AAEA,MAAME,mBAAmBb,SAASU,mBAAmB;AAErD,MAAMI,0BAAyBC,gBAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,aAAA;EAGcG,WAAA;GActC,OAEI,EAAAH,cAfwBA,eAAA,CAAA,EAAA,CAAiBK,IAAMC,KAgBvCF,EACf;EAAC;EACFH,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,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,8 @@ import { COMPLETE_STATUS, normalizePartStatus } from "../../utils/normalizePartS
|
|
|
3
3
|
import { NoOpComposerClient } from "./no-op-composer-client.js";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
5
|
import { useState } from "@assistant-ui/tap/react-shim";
|
|
6
|
-
import { useClientLookup } from "@assistant-ui/store";
|
|
7
6
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
7
|
+
import { useClientLookup } from "@assistant-ui/store/client";
|
|
8
8
|
//#region src/store/clients/thread-message-client.ts
|
|
9
9
|
const useThreadMessagePartClient = (t0) => {
|
|
10
10
|
const $ = c(8);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-message-client.js","names":["ThreadAssistantMessagePart","ThreadUserMessagePart","ThreadMessage","Attachment","useMemo","useState","useResource","resource","withKey","ClientOutput","useClientLookup","MessageState","PartState","NoOpComposerClient","COMPLETE_STATUS","normalizePartStatus","getThreadMessageText","useThreadMessagePartClient","t0","$","_c","part","isMessageRunning","t1","t2","status","state","t3","getState","addToolResult","_temp","resumeToolCall","_temp2","respondToToolApproval","_temp3","ThreadMessagePartClient","useThreadMessageAttachmentClient","attachment","remove","Error","ThreadMessageAttachmentClient","ThreadMessageClientProps","message","index","isLast","branchNumber","branchCount","useThreadMessageClient","undefined","isCopiedState","setIsCopied","isHoveringState","setIsHovering","role","type","t4","content","t5","idx","toolCallId","map","parts","attachments","t6","_temp4","t7","Symbol","for","composer","t8","composerState","t9","parentId","speech","isCopied","isHovering","t10","t11","t12","selector","get","key","t13","selector_0","id","t14","t15","delete","_temp5","reload","_temp6","speak","_temp7","stopSpeaking","_temp8","submitFeedback","_temp9","switchToBranch","_temp0","getCopyText","ThreadMessageClient"],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\nimport {\n COMPLETE_STATUS,\n normalizePartStatus,\n} from \"../../utils/normalizePartStatus\";\nimport { getThreadMessageText } from \"../../utils/text\";\n\nconst useThreadMessagePartClient = ({\n part,\n isMessageRunning,\n}: {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n isMessageRunning: boolean;\n}): ClientOutput<\"part\"> => {\n const state = useMemo<PartState>(() => {\n return {\n ...part,\n status: isMessageRunning\n ? (normalizePartStatus(part) ?? COMPLETE_STATUS)\n : COMPLETE_STATUS,\n };\n }, [part, isMessageRunning]);\n\n return {\n getState: () => state,\n addToolResult: () => {\n throw new Error(\"Not supported\");\n },\n resumeToolCall: () => {\n throw new Error(\"Not supported\");\n },\n respondToToolApproval: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessagePartClient = resource(useThreadMessagePartClient);\n\nconst useThreadMessageAttachmentClient = ({\n attachment,\n}: {\n attachment: Attachment;\n}): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessageAttachmentClient = resource(\n useThreadMessageAttachmentClient,\n);\nexport type ThreadMessageClientProps = {\n message: ThreadMessage;\n index: number;\n isLast?: boolean;\n branchNumber?: number;\n branchCount?: number;\n};\n\nconst useThreadMessageClient = ({\n message,\n index,\n isLast = true,\n branchNumber = 1,\n branchCount = 1,\n}: ThreadMessageClientProps): ClientOutput<\"message\"> => {\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n const isMessageRunning =\n message.role === \"assistant\" && message.status.type === \"running\";\n\n const parts = useClientLookup(\n message.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n ThreadMessagePartClient({ part, isMessageRunning }),\n [part, isMessageRunning],\n ),\n ),\n );\n\n const attachments = useClientLookup(\n (message.attachments ?? []).map((attachment) =>\n withKey(attachment.id, ThreadMessageAttachmentClient({ attachment }), [\n attachment,\n ]),\n ),\n );\n\n const composer = useResource(NoOpComposerClient({ type: \"edit\" }));\n const composerState = composer.getState();\n\n const state = useMemo<MessageState>(() => {\n return {\n ...message,\n parts: parts.state,\n composer: composerState,\n parentId: null,\n index,\n isLast,\n branchNumber,\n branchCount,\n speech: undefined,\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n message,\n index,\n isCopiedState,\n isHoveringState,\n isLast,\n parts.state,\n composerState,\n branchNumber,\n branchCount,\n ]);\n\n return {\n getState: () => state,\n composer: () => composer,\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n delete: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n reload: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n speak: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n stopSpeaking: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n submitFeedback: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n switchToBranch: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n getCopyText: () => {\n return getThreadMessageText(message);\n },\n setIsCopied,\n setIsHovering,\n };\n};\n\nexport const ThreadMessageClient = resource(useThreadMessageClient);\n"],"mappings":";;;;;;;;AAmBA,MAAMiB,8BAA6BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EA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AAM,IAAIS,MAAM,eAAe;AAAE;AAnBJ,SAAAP,SAAA;CAsB7B,MAAM,IAAIO,MAAM,eAAe;AAAE;AAtBJ,SAAAL,SAAA;CAyB7B,MAAM,IAAIK,MAAM,eAAe;AAAE;AA+BR,SAAAyB,OAAA3B,YAAA;CAAA,OA0BzB7B,QAAQ6B,WAAU+C,IAAK5C,8BAA8B,EAAAH,WAAa,CAAC,GAAG,CACpEA,UAAU,CACX;AAAC;AA5BuB,SAAAmD,SAAA;CA+EzB,MAAM,IAAIjD,MAAM,wCAAwC;AAAE;AA/EjC,SAAAmD,SAAA;CAkFzB,MAAM,IAAInD,MAAM,wCAAwC;AAAE;AAlFjC,SAAAqD,SAAA;CAqFzB,MAAM,IAAIrD,MAAM,wCAAwC;AAAE;AArFjC,SAAAuD,SAAA;CAwFzB,MAAM,IAAIvD,MAAM,wCAAwC;AAAE;AAxFjC,SAAAyD,SAAA;CA2FzB,MAAM,IAAIzD,MAAM,wCAAwC;AAAE;AA3FjC,SAAA2D,SAAA;CA8FzB,MAAM,IAAI3D,MAAM,wCAAwC;AAAE"}
|
|
1
|
+
{"version":3,"file":"thread-message-client.js","names":["ThreadAssistantMessagePart","ThreadUserMessagePart","ThreadMessage","Attachment","useMemo","useState","useResource","resource","withKey","ClientOutput","useClientLookup","MessageState","PartState","NoOpComposerClient","COMPLETE_STATUS","normalizePartStatus","getThreadMessageText","useThreadMessagePartClient","t0","$","_c","part","isMessageRunning","t1","t2","status","state","t3","getState","addToolResult","_temp","resumeToolCall","_temp2","respondToToolApproval","_temp3","ThreadMessagePartClient","useThreadMessageAttachmentClient","attachment","remove","Error","ThreadMessageAttachmentClient","ThreadMessageClientProps","message","index","isLast","branchNumber","branchCount","useThreadMessageClient","undefined","isCopiedState","setIsCopied","isHoveringState","setIsHovering","role","type","t4","content","t5","idx","toolCallId","map","parts","attachments","t6","_temp4","t7","Symbol","for","composer","t8","composerState","t9","parentId","speech","isCopied","isHovering","t10","t11","t12","selector","get","key","t13","selector_0","id","t14","t15","delete","_temp5","reload","_temp6","speak","_temp7","stopSpeaking","_temp8","submitFeedback","_temp9","switchToBranch","_temp0","getCopyText","ThreadMessageClient"],"sources":["../../../src/store/clients/thread-message-client.ts"],"sourcesContent":["import type {\n ThreadAssistantMessagePart,\n ThreadUserMessagePart,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Attachment } from \"../../types/attachment\";\nimport { useMemo, useState } from \"react\";\nimport { useResource, resource, withKey } from \"@assistant-ui/tap\";\nimport type { ClientOutput } from \"@assistant-ui/store\";\nimport { useClientLookup } from \"@assistant-ui/store/client\";\nimport type { MessageState } from \"../scopes/message\";\nimport type { PartState } from \"../scopes/part\";\nimport { NoOpComposerClient } from \"./no-op-composer-client\";\nimport {\n COMPLETE_STATUS,\n normalizePartStatus,\n} from \"../../utils/normalizePartStatus\";\nimport { getThreadMessageText } from \"../../utils/text\";\n\nconst useThreadMessagePartClient = ({\n part,\n isMessageRunning,\n}: {\n part: ThreadAssistantMessagePart | ThreadUserMessagePart;\n isMessageRunning: boolean;\n}): ClientOutput<\"part\"> => {\n const state = useMemo<PartState>(() => {\n return {\n ...part,\n status: isMessageRunning\n ? (normalizePartStatus(part) ?? COMPLETE_STATUS)\n : COMPLETE_STATUS,\n };\n }, [part, isMessageRunning]);\n\n return {\n getState: () => state,\n addToolResult: () => {\n throw new Error(\"Not supported\");\n },\n resumeToolCall: () => {\n throw new Error(\"Not supported\");\n },\n respondToToolApproval: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessagePartClient = resource(useThreadMessagePartClient);\n\nconst useThreadMessageAttachmentClient = ({\n attachment,\n}: {\n attachment: Attachment;\n}): ClientOutput<\"attachment\"> => {\n return {\n getState: () => attachment,\n remove: () => {\n throw new Error(\"Not supported\");\n },\n };\n};\n\nconst ThreadMessageAttachmentClient = resource(\n useThreadMessageAttachmentClient,\n);\nexport type ThreadMessageClientProps = {\n message: ThreadMessage;\n index: number;\n isLast?: boolean;\n branchNumber?: number;\n branchCount?: number;\n};\n\nconst useThreadMessageClient = ({\n message,\n index,\n isLast = true,\n branchNumber = 1,\n branchCount = 1,\n}: ThreadMessageClientProps): ClientOutput<\"message\"> => {\n const [isCopiedState, setIsCopied] = useState(false);\n const [isHoveringState, setIsHovering] = useState(false);\n const isMessageRunning =\n message.role === \"assistant\" && message.status.type === \"running\";\n\n const parts = useClientLookup(\n message.content.map((part, idx) =>\n withKey(\n \"toolCallId\" in part && part.toolCallId != null\n ? `toolCallId-${part.toolCallId}`\n : `index-${idx}`,\n ThreadMessagePartClient({ part, isMessageRunning }),\n [part, isMessageRunning],\n ),\n ),\n );\n\n const attachments = useClientLookup(\n (message.attachments ?? []).map((attachment) =>\n withKey(attachment.id, ThreadMessageAttachmentClient({ attachment }), [\n attachment,\n ]),\n ),\n );\n\n const composer = useResource(NoOpComposerClient({ type: \"edit\" }));\n const composerState = composer.getState();\n\n const state = useMemo<MessageState>(() => {\n return {\n ...message,\n parts: parts.state,\n composer: composerState,\n parentId: null,\n index,\n isLast,\n branchNumber,\n branchCount,\n speech: undefined,\n isCopied: isCopiedState,\n isHovering: isHoveringState,\n };\n }, [\n message,\n index,\n isCopiedState,\n isHoveringState,\n isLast,\n parts.state,\n composerState,\n branchNumber,\n branchCount,\n ]);\n\n return {\n getState: () => state,\n composer: () => composer,\n part: (selector) => {\n if (\"index\" in selector) {\n return parts.get({ index: selector.index });\n } else {\n return parts.get({ key: `toolCallId-${selector.toolCallId}` });\n }\n },\n attachment: (selector) => {\n if (\"id\" in selector) {\n return attachments.get({ key: selector.id });\n } else {\n return attachments.get(selector);\n }\n },\n delete: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n reload: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n speak: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n stopSpeaking: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n submitFeedback: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n switchToBranch: () => {\n throw new Error(\"Not supported in ThreadMessageProvider\");\n },\n getCopyText: () => {\n return getThreadMessageText(message);\n },\n setIsCopied,\n setIsHovering,\n };\n};\n\nexport const ThreadMessageClient = resource(useThreadMessageClient);\n"],"mappings":";;;;;;;;AAmBA,MAAMiB,8BAA6BC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAC,MAAAC,qBAAAJ;CAMnC,IAAAK;CAAA,IAAAJ,EAAA,OAAAG,oBAAAH,EAAA,OAAAE,MAAA;EAIaE,KAAAD,mBACHP,oBAAoBM,IAAuB,KAA3CP,kBADGA;EAEWK,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAE,QAAAF,EAAA,OAAAI,IAAA;EAJdC,KAAA;GAAA,GACFH;GAAII,QACCF;EAGV;EAACJ,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CANH,MAAAO,QACEF;CAM2B,IAAAG;CAAA,IAAAR,EAAA,OAAAO,OAAA;EAEtBC,KAAA;GAAAC,gBACWF;GAAKG,eACNC;GAEdC,gBACeC;GAEfC,uBACsBC;EAGzB;EAACf,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAXMQ;AAWN;AAGH,MAAMQ,0BAA0B5B,SAASU,0BAA0B;AAEnE,MAAMmB,oCAAoC,EACxCC,iBAGgC;CAChC,OAAO;EACLT,gBAAgBS;EAChBC,cAAc;GACZ,MAAM,IAAIC,MAAM,eAAe;EACjC;CACF;AACF;AAEA,MAAMC,gCAAgCjC,SACpC6B,gCACF;AASA,MAAMW,0BAAyB7B,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAsB,SAAAC,OAAAC,QAAArB,IAA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jC,EAAA,MAAAyD;EAAAzD,EAAA,MAAA0D;EAAA1D,EAAA,MAAA2D;EAAA3D,EAAA,MAAA+D;EAAA/D,EAAA,MAAAkE;EAAAlE,EAAA,MAAAmE;CAAA,OAAAA,MAAAnE,EAAA;CAAA,OAxCMmE;AAwCN;AAGH,MAAac,sBAAsB7F,SAASwC,sBAAsB;AAhK/B,SAAAjB,QAAA;CAmB7B,MAAM,IAAIS,MAAM,eAAe;AAAE;AAnBJ,SAAAP,SAAA;CAsB7B,MAAM,IAAIO,MAAM,eAAe;AAAE;AAtBJ,SAAAL,SAAA;CAyB7B,MAAM,IAAIK,MAAM,eAAe;AAAE;AA+BR,SAAAyB,OAAA3B,YAAA;CAAA,OA0BzB7B,QAAQ6B,WAAU+C,IAAK5C,8BAA8B,EAAAH,WAAa,CAAC,GAAG,CACpEA,UAAU,CACX;AAAC;AA5BuB,SAAAmD,SAAA;CA+EzB,MAAM,IAAIjD,MAAM,wCAAwC;AAAE;AA/EjC,SAAAmD,SAAA;CAkFzB,MAAM,IAAInD,MAAM,wCAAwC;AAAE;AAlFjC,SAAAqD,SAAA;CAqFzB,MAAM,IAAIrD,MAAM,wCAAwC;AAAE;AArFjC,SAAAuD,SAAA;CAwFzB,MAAM,IAAIvD,MAAM,wCAAwC;AAAE;AAxFjC,SAAAyD,SAAA;CA2FzB,MAAM,IAAIzD,MAAM,wCAAwC;AAAE;AA3FjC,SAAA2D,SAAA;CA8FzB,MAAM,IAAI3D,MAAM,wCAAwC;AAAE"}
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference path="./scope-registration.d.ts" />
|
|
2
|
+
/// <reference path="../react/types/store-augmentation.d.ts" />
|
|
2
3
|
import { QueueItemClientSchema, QueueItemMeta, QueueItemMethods, QueueItemState } from "./scopes/queue-item.js";
|
|
3
4
|
import { ThreadListItemClientSchema, ThreadListItemEvents, ThreadListItemMeta, ThreadListItemMethods, ThreadListItemState } from "./scopes/thread-list-item.js";
|
|
4
5
|
import { AttachmentClientSchema, AttachmentMeta, AttachmentMethods, AttachmentState } from "./scopes/attachment.js";
|
|
@@ -11,9 +12,17 @@ import { SuggestionClientSchema, SuggestionMeta, SuggestionMethods, SuggestionSt
|
|
|
11
12
|
import { Suggestion, SuggestionsClientSchema, SuggestionsMethods, SuggestionsState } from "./scopes/suggestions.js";
|
|
12
13
|
import { ModelContextClientSchema, ModelContextMethods, ModelContextState } from "./scopes/model-context.js";
|
|
13
14
|
import { ChainOfThoughtClientSchema, ChainOfThoughtMeta, ChainOfThoughtMethods, ChainOfThoughtPart, ChainOfThoughtState } from "./scopes/chain-of-thought.js";
|
|
15
|
+
import { RuntimeAdapter } from "../react/RuntimeAdapter.js";
|
|
16
|
+
import { JoinStrategy, convertExternalMessages, useExternalMessageConverter } from "../react/runtimes/external-message-converter.js";
|
|
17
|
+
import { StreamingTimingAccessors, StreamingTimingOptions, StreamingTimingState } from "../runtime/utils/streaming-timing.js";
|
|
18
|
+
import { useStreamingTiming } from "../react/runtimes/useStreamingTiming.js";
|
|
19
|
+
import { RuntimeExtrasBrand, createRuntimeExtrasBrand } from "../runtime/utils/runtime-extras-brand.js";
|
|
20
|
+
import { Toolkit, ToolkitDefinition, ToolkitDefinitionEntry } from "../react/model-context/toolbox.js";
|
|
21
|
+
import { defineToolkit } from "../react/model-context/define-toolkit.js";
|
|
22
|
+
import { McpToolkitDefinition, McpToolkitEntry, McpToolkitToolConfig, defineMcpToolkit } from "../react/model-context/define-mcp-toolkit.js";
|
|
14
23
|
import { NoOpComposerClient } from "./clients/no-op-composer-client.js";
|
|
15
24
|
import { SuggestionConfig, Suggestions } from "./clients/suggestions.js";
|
|
16
25
|
import { ChainOfThoughtClient } from "./clients/chain-of-thought-client.js";
|
|
17
26
|
import { ThreadMessageClient, ThreadMessageClientProps } from "./clients/thread-message-client.js";
|
|
18
27
|
import { ModelContext } from "./clients/model-context-client.js";
|
|
19
|
-
export { type AttachmentClientSchema, type AttachmentMeta, type AttachmentMethods, type AttachmentState, ChainOfThoughtClient, type ChainOfThoughtClientSchema, type ChainOfThoughtMeta, type ChainOfThoughtMethods, type ChainOfThoughtPart, type ChainOfThoughtState, type ComposerClientSchema, type ComposerEvents, type ComposerMeta, type ComposerMethods, type ComposerSendOptions, type ComposerState, type MessageClientSchema, type MessageMeta, type MessageMethods, type MessageState, ModelContext, type ModelContextClientSchema, type ModelContextMethods, type ModelContextState, NoOpComposerClient, type PartClientSchema, type PartMeta, type PartMethods, type PartState, type QueueItemClientSchema, type QueueItemMeta, type QueueItemMethods, type QueueItemState, type Suggestion, type SuggestionClientSchema, type SuggestionConfig, type SuggestionMeta, type SuggestionMethods, type SuggestionState, Suggestions, type SuggestionsClientSchema, type SuggestionsMethods, type SuggestionsState, type ThreadClientSchema, type ThreadEvents, type ThreadListItemClientSchema, type ThreadListItemEvents, type ThreadListItemMeta, type ThreadListItemMethods, type ThreadListItemState, ThreadMessageClient, type ThreadMessageClientProps, type ThreadMeta, type ThreadMethods, type ThreadState, type ThreadsClientSchema, type ThreadsMethods, type ThreadsState };
|
|
28
|
+
export { type AttachmentClientSchema, type AttachmentMeta, type AttachmentMethods, type AttachmentState, ChainOfThoughtClient, type ChainOfThoughtClientSchema, type ChainOfThoughtMeta, type ChainOfThoughtMethods, type ChainOfThoughtPart, type ChainOfThoughtState, type ComposerClientSchema, type ComposerEvents, type ComposerMeta, type ComposerMethods, type ComposerSendOptions, type ComposerState, type JoinStrategy, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, type MessageClientSchema, type MessageMeta, type MessageMethods, type MessageState, ModelContext, type ModelContextClientSchema, type ModelContextMethods, type ModelContextState, NoOpComposerClient, type PartClientSchema, type PartMeta, type PartMethods, type PartState, type QueueItemClientSchema, type QueueItemMeta, type QueueItemMethods, type QueueItemState, RuntimeAdapter, type RuntimeExtrasBrand, type StreamingTimingAccessors, type StreamingTimingOptions, type StreamingTimingState, type Suggestion, type SuggestionClientSchema, type SuggestionConfig, type SuggestionMeta, type SuggestionMethods, type SuggestionState, Suggestions, type SuggestionsClientSchema, type SuggestionsMethods, type SuggestionsState, type ThreadClientSchema, type ThreadEvents, type ThreadListItemClientSchema, type ThreadListItemEvents, type ThreadListItemMeta, type ThreadListItemMethods, type ThreadListItemState, ThreadMessageClient, type ThreadMessageClientProps, type ThreadMeta, type ThreadMethods, type ThreadState, type ThreadsClientSchema, type ThreadsMethods, type ThreadsState, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, convertExternalMessages, createRuntimeExtrasBrand, defineMcpToolkit, defineToolkit, useExternalMessageConverter, useStreamingTiming };
|
package/dist/store/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ModelContext } from "./clients/model-context-client.js";
|
|
2
2
|
import { Suggestions } from "./clients/suggestions.js";
|
|
3
|
+
import { RuntimeAdapter } from "../react/RuntimeAdapter.js";
|
|
4
|
+
import { defineToolkit } from "../react/model-context/define-toolkit.js";
|
|
5
|
+
import { defineMcpToolkit } from "../react/model-context/define-mcp-toolkit.js";
|
|
6
|
+
import { convertExternalMessages, useExternalMessageConverter } from "../react/runtimes/external-message-converter.js";
|
|
7
|
+
import { useStreamingTiming } from "../react/runtimes/useStreamingTiming.js";
|
|
8
|
+
import { createRuntimeExtrasBrand } from "../runtime/utils/runtime-extras-brand.js";
|
|
3
9
|
import { NoOpComposerClient } from "./clients/no-op-composer-client.js";
|
|
4
10
|
import { ChainOfThoughtClient } from "./clients/chain-of-thought-client.js";
|
|
5
11
|
import { ThreadMessageClient } from "./clients/thread-message-client.js";
|
|
6
|
-
export { ChainOfThoughtClient, ModelContext, NoOpComposerClient, Suggestions, ThreadMessageClient };
|
|
12
|
+
export { ChainOfThoughtClient, ModelContext, NoOpComposerClient, RuntimeAdapter, Suggestions, ThreadMessageClient, convertExternalMessages, createRuntimeExtrasBrand, defineMcpToolkit, defineToolkit, useExternalMessageConverter, useStreamingTiming };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"composer-runtime-client.d.ts","names":[],"sources":["../../../src/store/runtime-clients/composer-runtime-client.ts"],"mappings":";;;cAuLa,4CAAc,SAAA;EAzHZ;IAAE;;EACA;IAAE;;EACR,SAAA"}
|
|
@@ -2,8 +2,8 @@ import { useSubscribable } from "./useSubscribable.js";
|
|
|
2
2
|
import { AttachmentRuntimeClient } from "./attachment-runtime-client.js";
|
|
3
3
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
4
|
import { useEffect } from "@assistant-ui/tap/react-shim";
|
|
5
|
-
import { useAssistantEmit, useClientLookup } from "@assistant-ui/store";
|
|
6
5
|
import { resource, useResource, withKey } from "@assistant-ui/tap";
|
|
6
|
+
import { useAssistantEmit, useClientLookup } from "@assistant-ui/store/client";
|
|
7
7
|
//#region src/store/runtime-clients/composer-runtime-client.ts
|
|
8
8
|
const useComposerAttachmentClientByIndex = (t0) => {
|
|
9
9
|
const $ = c(5);
|