@assistant-ui/react 0.10.43 → 0.10.45
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/model-context/frame/AssistantFrameHost.d.ts +37 -0
- package/dist/model-context/frame/AssistantFrameHost.d.ts.map +1 -0
- package/dist/model-context/frame/AssistantFrameHost.js +151 -0
- package/dist/model-context/frame/AssistantFrameHost.js.map +1 -0
- package/dist/model-context/frame/AssistantFrameProvider.d.ts +41 -0
- package/dist/model-context/frame/AssistantFrameProvider.d.ts.map +1 -0
- package/dist/model-context/frame/AssistantFrameProvider.js +142 -0
- package/dist/model-context/frame/AssistantFrameProvider.js.map +1 -0
- package/dist/model-context/frame/AssistantFrameTypes.d.ts +29 -0
- package/dist/model-context/frame/AssistantFrameTypes.d.ts.map +1 -0
- package/dist/model-context/frame/AssistantFrameTypes.js +6 -0
- package/dist/model-context/frame/AssistantFrameTypes.js.map +1 -0
- package/dist/model-context/frame/index.d.ts +5 -0
- package/dist/model-context/frame/index.d.ts.map +1 -0
- package/dist/model-context/frame/index.js +6 -0
- package/dist/model-context/frame/index.js.map +1 -0
- package/dist/model-context/frame/useAssistantFrameHost.d.ts +28 -0
- package/dist/model-context/frame/useAssistantFrameHost.d.ts.map +1 -0
- package/dist/model-context/frame/useAssistantFrameHost.js +25 -0
- package/dist/model-context/frame/useAssistantFrameHost.js.map +1 -0
- package/dist/model-context/index.d.ts +2 -0
- package/dist/model-context/index.d.ts.map +1 -1
- package/dist/model-context/index.js +2 -0
- package/dist/model-context/index.js.map +1 -1
- package/dist/model-context/registry/ModelContextRegistry.d.ts +19 -0
- package/dist/model-context/registry/ModelContextRegistry.d.ts.map +1 -0
- package/dist/model-context/registry/ModelContextRegistry.js +117 -0
- package/dist/model-context/registry/ModelContextRegistry.js.map +1 -0
- package/dist/model-context/registry/ModelContextRegistryHandles.d.ts +14 -0
- package/dist/model-context/registry/ModelContextRegistryHandles.d.ts.map +1 -0
- package/dist/model-context/registry/ModelContextRegistryHandles.js +1 -0
- package/dist/model-context/registry/ModelContextRegistryHandles.js.map +1 -0
- package/dist/model-context/registry/index.d.ts +3 -0
- package/dist/model-context/registry/index.d.ts.map +1 -0
- package/dist/model-context/registry/index.js +4 -0
- package/dist/model-context/registry/index.js.map +1 -0
- package/dist/model-context/useAssistantInstructions.d.ts +1 -2
- package/dist/model-context/useAssistantInstructions.d.ts.map +1 -1
- package/dist/model-context/useAssistantInstructions.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +5 -4
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +4 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +25 -10
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/types/MessagePartTypes.d.ts +2 -0
- package/dist/types/MessagePartTypes.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/model-context/frame/AssistantFrame.test.ts +353 -0
- package/src/model-context/frame/AssistantFrameHost.ts +218 -0
- package/src/model-context/frame/AssistantFrameProvider.ts +225 -0
- package/src/model-context/frame/AssistantFrameTypes.ts +40 -0
- package/src/model-context/frame/SPEC_AssistantFrame.md +104 -0
- package/src/model-context/frame/index.ts +4 -0
- package/src/model-context/frame/useAssistantFrameHost.ts +48 -0
- package/src/model-context/index.ts +3 -0
- package/src/model-context/registry/ModelContextRegistry.ts +165 -0
- package/src/model-context/registry/ModelContextRegistryHandles.ts +19 -0
- package/src/model-context/registry/SPEC_ModelContextRegistry.md +40 -0
- package/src/model-context/registry/index.ts +2 -0
- package/src/model-context/useAssistantInstructions.tsx +1 -1
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +5 -4
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +29 -11
- package/src/types/MessagePartTypes.ts +2 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
// src/model-context/registry/ModelContextRegistry.ts
|
2
|
+
import {
|
3
|
+
mergeModelContexts
|
4
|
+
} from "../../model-context/ModelContextTypes.js";
|
5
|
+
var ModelContextRegistry = class {
|
6
|
+
_tools = /* @__PURE__ */ new Map();
|
7
|
+
_instructions = /* @__PURE__ */ new Map();
|
8
|
+
_providers = /* @__PURE__ */ new Map();
|
9
|
+
_subscribers = /* @__PURE__ */ new Set();
|
10
|
+
_providerUnsubscribes = /* @__PURE__ */ new Map();
|
11
|
+
getModelContext() {
|
12
|
+
const instructions = Array.from(this._instructions.values()).filter(
|
13
|
+
Boolean
|
14
|
+
);
|
15
|
+
const system = instructions.length > 0 ? instructions.join("\n\n") : void 0;
|
16
|
+
const tools = {};
|
17
|
+
for (const toolProps of this._tools.values()) {
|
18
|
+
const { toolName, render, ...tool } = toolProps;
|
19
|
+
tools[toolName] = tool;
|
20
|
+
}
|
21
|
+
const providerContexts = mergeModelContexts(
|
22
|
+
new Set(this._providers.values())
|
23
|
+
);
|
24
|
+
const context = {
|
25
|
+
system,
|
26
|
+
tools: Object.keys(tools).length > 0 ? tools : void 0
|
27
|
+
};
|
28
|
+
if (providerContexts.system) {
|
29
|
+
context.system = context.system ? `${context.system}
|
30
|
+
|
31
|
+
${providerContexts.system}` : providerContexts.system;
|
32
|
+
}
|
33
|
+
if (providerContexts.tools) {
|
34
|
+
context.tools = { ...context.tools || {}, ...providerContexts.tools };
|
35
|
+
}
|
36
|
+
if (providerContexts.callSettings) {
|
37
|
+
context.callSettings = providerContexts.callSettings;
|
38
|
+
}
|
39
|
+
if (providerContexts.config) {
|
40
|
+
context.config = providerContexts.config;
|
41
|
+
}
|
42
|
+
return context;
|
43
|
+
}
|
44
|
+
subscribe(callback) {
|
45
|
+
this._subscribers.add(callback);
|
46
|
+
return () => this._subscribers.delete(callback);
|
47
|
+
}
|
48
|
+
notifySubscribers() {
|
49
|
+
for (const callback of this._subscribers) {
|
50
|
+
callback();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
addTool(tool) {
|
54
|
+
const id = Symbol();
|
55
|
+
this._tools.set(id, tool);
|
56
|
+
this.notifySubscribers();
|
57
|
+
return {
|
58
|
+
update: (newTool) => {
|
59
|
+
if (this._tools.has(id)) {
|
60
|
+
this._tools.set(id, newTool);
|
61
|
+
this.notifySubscribers();
|
62
|
+
}
|
63
|
+
},
|
64
|
+
remove: () => {
|
65
|
+
this._tools.delete(id);
|
66
|
+
this.notifySubscribers();
|
67
|
+
}
|
68
|
+
};
|
69
|
+
}
|
70
|
+
addInstruction(config) {
|
71
|
+
const id = Symbol();
|
72
|
+
const instruction = typeof config === "string" ? config : config.instruction;
|
73
|
+
const disabled = typeof config === "object" ? config.disabled : false;
|
74
|
+
if (!disabled) {
|
75
|
+
this._instructions.set(id, instruction);
|
76
|
+
this.notifySubscribers();
|
77
|
+
}
|
78
|
+
return {
|
79
|
+
update: (newConfig) => {
|
80
|
+
const newInstruction = typeof newConfig === "string" ? newConfig : newConfig.instruction;
|
81
|
+
const newDisabled = typeof newConfig === "object" ? newConfig.disabled : false;
|
82
|
+
if (newDisabled) {
|
83
|
+
this._instructions.delete(id);
|
84
|
+
} else {
|
85
|
+
this._instructions.set(id, newInstruction);
|
86
|
+
}
|
87
|
+
this.notifySubscribers();
|
88
|
+
},
|
89
|
+
remove: () => {
|
90
|
+
this._instructions.delete(id);
|
91
|
+
this.notifySubscribers();
|
92
|
+
}
|
93
|
+
};
|
94
|
+
}
|
95
|
+
addProvider(provider) {
|
96
|
+
const id = Symbol();
|
97
|
+
this._providers.set(id, provider);
|
98
|
+
const unsubscribe = provider.subscribe?.(() => {
|
99
|
+
this.notifySubscribers();
|
100
|
+
});
|
101
|
+
this._providerUnsubscribes.set(id, unsubscribe);
|
102
|
+
this.notifySubscribers();
|
103
|
+
return {
|
104
|
+
remove: () => {
|
105
|
+
this._providers.delete(id);
|
106
|
+
const unsubscribe2 = this._providerUnsubscribes.get(id);
|
107
|
+
unsubscribe2?.();
|
108
|
+
this._providerUnsubscribes.delete(id);
|
109
|
+
this.notifySubscribers();
|
110
|
+
}
|
111
|
+
};
|
112
|
+
}
|
113
|
+
};
|
114
|
+
export {
|
115
|
+
ModelContextRegistry
|
116
|
+
};
|
117
|
+
//# sourceMappingURL=ModelContextRegistry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/model-context/registry/ModelContextRegistry.ts"],"sourcesContent":["import { Tool } from \"assistant-stream\";\nimport {\n ModelContext,\n ModelContextProvider,\n mergeModelContexts,\n} from \"../../model-context/ModelContextTypes\";\nimport { Unsubscribe } from \"../../types/Unsubscribe\";\nimport {\n ModelContextRegistryToolHandle,\n ModelContextRegistryInstructionHandle,\n ModelContextRegistryProviderHandle,\n} from \"./ModelContextRegistryHandles\";\nimport type { AssistantToolProps } from \"../../model-context/useAssistantTool\";\nimport type { AssistantInstructionsConfig } from \"../../model-context/useAssistantInstructions\";\n\nexport class ModelContextRegistry implements ModelContextProvider {\n private _tools = new Map<symbol, AssistantToolProps<any, any>>();\n private _instructions = new Map<symbol, string>();\n private _providers = new Map<symbol, ModelContextProvider>();\n private _subscribers = new Set<() => void>();\n private _providerUnsubscribes = new Map<symbol, Unsubscribe | undefined>();\n\n getModelContext(): ModelContext {\n // Merge instructions\n const instructions = Array.from(this._instructions.values()).filter(\n Boolean,\n );\n\n const system =\n instructions.length > 0 ? instructions.join(\"\\n\\n\") : undefined;\n\n // Collect tools\n const tools: Record<string, Tool<any, any>> = {};\n for (const toolProps of this._tools.values()) {\n const { toolName, render, ...tool } = toolProps;\n tools[toolName] = tool;\n }\n\n // Merge provider contexts\n const providerContexts = mergeModelContexts(\n new Set(this._providers.values()),\n );\n\n // Combine everything\n const context: ModelContext = {\n system,\n tools: Object.keys(tools).length > 0 ? tools : undefined,\n };\n\n // Merge with provider contexts\n if (providerContexts.system) {\n context.system = context.system\n ? `${context.system}\\n\\n${providerContexts.system}`\n : providerContexts.system;\n }\n\n if (providerContexts.tools) {\n context.tools = { ...(context.tools || {}), ...providerContexts.tools };\n }\n\n if (providerContexts.callSettings) {\n context.callSettings = providerContexts.callSettings;\n }\n\n if (providerContexts.config) {\n context.config = providerContexts.config;\n }\n\n return context;\n }\n\n subscribe(callback: () => void): Unsubscribe {\n this._subscribers.add(callback);\n return () => this._subscribers.delete(callback);\n }\n\n private notifySubscribers(): void {\n for (const callback of this._subscribers) {\n callback();\n }\n }\n\n addTool<TArgs extends Record<string, unknown>, TResult>(\n tool: AssistantToolProps<TArgs, TResult>,\n ): ModelContextRegistryToolHandle<TArgs, TResult> {\n const id = Symbol();\n\n this._tools.set(id, tool);\n this.notifySubscribers();\n\n return {\n update: (newTool: AssistantToolProps<TArgs, TResult>) => {\n if (this._tools.has(id)) {\n this._tools.set(id, newTool);\n this.notifySubscribers();\n }\n },\n remove: () => {\n this._tools.delete(id);\n this.notifySubscribers();\n },\n };\n }\n\n addInstruction(\n config: string | AssistantInstructionsConfig,\n ): ModelContextRegistryInstructionHandle {\n const id = Symbol();\n\n const instruction =\n typeof config === \"string\" ? config : config.instruction;\n const disabled = typeof config === \"object\" ? config.disabled : false;\n\n if (!disabled) {\n this._instructions.set(id, instruction);\n this.notifySubscribers();\n }\n\n return {\n update: (newConfig: string | AssistantInstructionsConfig) => {\n const newInstruction =\n typeof newConfig === \"string\" ? newConfig : newConfig.instruction;\n const newDisabled =\n typeof newConfig === \"object\" ? newConfig.disabled : false;\n\n if (newDisabled) {\n this._instructions.delete(id);\n } else {\n this._instructions.set(id, newInstruction);\n }\n this.notifySubscribers();\n },\n remove: () => {\n this._instructions.delete(id);\n this.notifySubscribers();\n },\n };\n }\n\n addProvider(\n provider: ModelContextProvider,\n ): ModelContextRegistryProviderHandle {\n const id = Symbol();\n\n this._providers.set(id, provider);\n\n // Subscribe to provider changes\n const unsubscribe = provider.subscribe?.(() => {\n this.notifySubscribers();\n });\n this._providerUnsubscribes.set(id, unsubscribe);\n\n this.notifySubscribers();\n\n return {\n remove: () => {\n this._providers.delete(id);\n const unsubscribe = this._providerUnsubscribes.get(id);\n unsubscribe?.();\n this._providerUnsubscribes.delete(id);\n this.notifySubscribers();\n },\n };\n }\n}\n"],"mappings":";AACA;AAAA,EAGE;AAAA,OACK;AAUA,IAAM,uBAAN,MAA2D;AAAA,EACxD,SAAS,oBAAI,IAA0C;AAAA,EACvD,gBAAgB,oBAAI,IAAoB;AAAA,EACxC,aAAa,oBAAI,IAAkC;AAAA,EACnD,eAAe,oBAAI,IAAgB;AAAA,EACnC,wBAAwB,oBAAI,IAAqC;AAAA,EAEzE,kBAAgC;AAE9B,UAAM,eAAe,MAAM,KAAK,KAAK,cAAc,OAAO,CAAC,EAAE;AAAA,MAC3D;AAAA,IACF;AAEA,UAAM,SACJ,aAAa,SAAS,IAAI,aAAa,KAAK,MAAM,IAAI;AAGxD,UAAM,QAAwC,CAAC;AAC/C,eAAW,aAAa,KAAK,OAAO,OAAO,GAAG;AAC5C,YAAM,EAAE,UAAU,QAAQ,GAAG,KAAK,IAAI;AACtC,YAAM,QAAQ,IAAI;AAAA,IACpB;AAGA,UAAM,mBAAmB;AAAA,MACvB,IAAI,IAAI,KAAK,WAAW,OAAO,CAAC;AAAA,IAClC;AAGA,UAAM,UAAwB;AAAA,MAC5B;AAAA,MACA,OAAO,OAAO,KAAK,KAAK,EAAE,SAAS,IAAI,QAAQ;AAAA,IACjD;AAGA,QAAI,iBAAiB,QAAQ;AAC3B,cAAQ,SAAS,QAAQ,SACrB,GAAG,QAAQ,MAAM;AAAA;AAAA,EAAO,iBAAiB,MAAM,KAC/C,iBAAiB;AAAA,IACvB;AAEA,QAAI,iBAAiB,OAAO;AAC1B,cAAQ,QAAQ,EAAE,GAAI,QAAQ,SAAS,CAAC,GAAI,GAAG,iBAAiB,MAAM;AAAA,IACxE;AAEA,QAAI,iBAAiB,cAAc;AACjC,cAAQ,eAAe,iBAAiB;AA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ACZ,aAAK,cAAc,OAAO,EAAE;AAC5B,aAAK,kBAAkB;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YACE,UACoC;AACpC,UAAM,KAAK,OAAO;AAElB,SAAK,WAAW,IAAI,IAAI,QAAQ;AAGhC,UAAM,cAAc,SAAS,YAAY,MAAM;AAC7C,WAAK,kBAAkB;AAAA,IACzB,CAAC;AACD,SAAK,sBAAsB,IAAI,IAAI,WAAW;AAE9C,SAAK,kBAAkB;AAEvB,WAAO;AAAA,MACL,QAAQ,MAAM;AACZ,aAAK,WAAW,OAAO,EAAE;AACzB,cAAMA,eAAc,KAAK,sBAAsB,IAAI,EAAE;AACrD,QAAAA,eAAc;AACd,aAAK,sBAAsB,OAAO,EAAE;AACpC,aAAK,kBAAkB;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;","names":["unsubscribe"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { AssistantToolProps } from "../../model-context/useAssistantTool";
|
2
|
+
import type { AssistantInstructionsConfig } from "../../model-context/useAssistantInstructions";
|
3
|
+
export interface ModelContextRegistryToolHandle<TArgs extends Record<string, unknown> = any, TResult = any> {
|
4
|
+
update(tool: AssistantToolProps<TArgs, TResult>): void;
|
5
|
+
remove(): void;
|
6
|
+
}
|
7
|
+
export interface ModelContextRegistryInstructionHandle {
|
8
|
+
update(config: string | AssistantInstructionsConfig): void;
|
9
|
+
remove(): void;
|
10
|
+
}
|
11
|
+
export interface ModelContextRegistryProviderHandle {
|
12
|
+
remove(): void;
|
13
|
+
}
|
14
|
+
//# sourceMappingURL=ModelContextRegistryHandles.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ModelContextRegistryHandles.d.ts","sourceRoot":"","sources":["../../../src/model-context/registry/ModelContextRegistryHandles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,MAAM,WAAW,8BAA8B,CAC7C,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,EAC3C,OAAO,GAAG,GAAG;IAEb,MAAM,CAAC,IAAI,EAAE,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,qCAAqC;IACpD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,2BAA2B,GAAG,IAAI,CAAC;IAC3D,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,kCAAkC;IACjD,MAAM,IAAI,IAAI,CAAC;CAChB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=ModelContextRegistryHandles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/model-context/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/model-context/registry/index.ts"],"sourcesContent":["export * from \"./ModelContextRegistry\";\nexport * from \"./ModelContextRegistryHandles\";\n"],"mappings":";AAAA,cAAc;AACd,cAAc;","names":[]}
|
@@ -1,7 +1,6 @@
|
|
1
|
-
type AssistantInstructionsConfig = {
|
1
|
+
export type AssistantInstructionsConfig = {
|
2
2
|
disabled?: boolean | undefined;
|
3
3
|
instruction: string;
|
4
4
|
};
|
5
5
|
export declare const useAssistantInstructions: (config: string | AssistantInstructionsConfig) => void;
|
6
|
-
export {};
|
7
6
|
//# sourceMappingURL=useAssistantInstructions.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAssistantInstructions.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantInstructions.tsx"],"names":[],"mappings":"AAKA,
|
1
|
+
{"version":3,"file":"useAssistantInstructions.d.ts","sourceRoot":"","sources":["../../src/model-context/useAssistantInstructions.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AASF,eAAO,MAAM,wBAAwB,GACnC,QAAQ,MAAM,GAAG,2BAA2B,SAe7C,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/model-context/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\
|
1
|
+
{"version":3,"sources":["../../src/model-context/useAssistantInstructions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useAssistantRuntime } from \"../context\";\n\nexport type AssistantInstructionsConfig = {\n disabled?: boolean | undefined;\n instruction: string;\n};\n\nconst getInstructions = (\n instruction: string | AssistantInstructionsConfig,\n): AssistantInstructionsConfig => {\n if (typeof instruction === \"string\") return { instruction };\n return instruction;\n};\n\nexport const useAssistantInstructions = (\n config: string | AssistantInstructionsConfig,\n) => {\n const { instruction, disabled = false } = getInstructions(config);\n const assistantRuntime = useAssistantRuntime();\n\n useEffect(() => {\n if (disabled) return;\n\n const config = {\n system: instruction,\n };\n return assistantRuntime.registerModelContextProvider({\n getModelContext: () => config,\n });\n }, [assistantRuntime, instruction, disabled]);\n};\n"],"mappings":";;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAOpC,IAAM,kBAAkB,CACtB,gBACgC;AAChC,MAAI,OAAO,gBAAgB,SAAU,QAAO,EAAE,YAAY;AAC1D,SAAO;AACT;AAEO,IAAM,2BAA2B,CACtC,WACG;AACH,QAAM,EAAE,aAAa,WAAW,MAAM,IAAI,gBAAgB,MAAM;AAChE,QAAM,mBAAmB,oBAAoB;AAE7C,YAAU,MAAM;AACd,QAAI,SAAU;AAEd,UAAMA,UAAS;AAAA,MACb,QAAQ;AAAA,IACV;AACA,WAAO,iBAAiB,6BAA6B;AAAA,MACnD,iBAAiB,MAAMA;AAAA,IACzB,CAAC;AAAA,EACH,GAAG,CAAC,kBAAkB,aAAa,QAAQ,CAAC;AAC9C;","names":["config"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BaseComposerRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAGX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAK1E,8BAAsB,uBACpB,SAAQ,gBACR,YAAW,mBAAmB;IAE9B,SAAgB,SAAS,QAAQ;IAEjC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,iBAAiB,GAAG,SAAS;IAEjE,mBAAmB,IAAI,MAAM;IAIpC,OAAO,CAAC,YAAY,CAA6B;IACjD,IAAW,WAAW,0BAErB;IAED,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE;IAKrD,aAAoB,SAAS,IAAI,OAAO,CAAC;IAEzC,IAAW,OAAO,YAEjB;IAED,OAAO,CAAC,KAAK,CAAM;IAEnB,IAAI,IAAI,WAEP;IAED,OAAO,CAAC,KAAK,CAAuB;IAEpC,IAAI,IAAI,oCAEP;IAED,OAAO,CAAC,UAAU,CA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;IAOrB,OAAO,CAAC,IAAI,EAAE,WAAW;IAOzB,YAAY,CAAC,SAAS,EAAE,SAAS;IAOxC,OAAO,CAAC,wBAAwB;YAMlB,mBAAmB;IAOpB,KAAK;IAkBL,gBAAgB;IAOhB,IAAI;IA4BV,MAAM;IAIb,SAAS,CAAC,QAAQ,CAAC,UAAU,CAC3B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC,GACpD,IAAI;IACP,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAEjC,aAAa,CAAC,IAAI,EAAE,IAAI;IAmCxB,gBAAgB,CAAC,YAAY,EAAE,MAAM;IAkB3C,OAAO,CAAC,iBAAiB,CAGrB;IAEJ,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,wBAAwB;IAO1D,WAAW,CAAC,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,IAAI;CAczE"}
|
@@ -72,22 +72,23 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
|
|
72
72
|
}
|
73
73
|
async send() {
|
74
74
|
const adapter = this.getAttachmentAdapter();
|
75
|
-
const attachments = adapter && this.attachments.length > 0 ?
|
75
|
+
const attachments = adapter && this.attachments.length > 0 ? Promise.all(
|
76
76
|
this.attachments.map(async (a) => {
|
77
77
|
if (isAttachmentComplete(a)) return a;
|
78
78
|
const result = await adapter.send(a);
|
79
79
|
return result;
|
80
80
|
})
|
81
81
|
) : [];
|
82
|
+
const text = this.text;
|
83
|
+
this._emptyTextAndAttachments();
|
82
84
|
const message = {
|
83
85
|
createdAt: /* @__PURE__ */ new Date(),
|
84
86
|
role: this.role,
|
85
|
-
content:
|
86
|
-
attachments,
|
87
|
+
content: text ? [{ type: "text", text }] : [],
|
88
|
+
attachments: await attachments,
|
87
89
|
runConfig: this.runConfig,
|
88
90
|
metadata: { custom: {} }
|
89
91
|
};
|
90
|
-
this._emptyTextAndAttachments();
|
91
92
|
this.handleSend(message);
|
92
93
|
this._notifyEventSubscribers("send");
|
93
94
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? await Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n createdAt: new Date(),\n role: this.role,\n content: this.text ? [{ type: \"text\", text: this.text }] : [],\n attachments,\n runConfig: this.runConfig,\n metadata: { custom: {} },\n };\n this._emptyTextAndAttachments();\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const upsertAttachment = (a: PendingAttachment) => {\n const idx = this._attachments.findIndex(\n (attachment) => attachment.id === a.id,\n );\n if (idx !== -1)\n this._attachments = [\n ...this._attachments.slice(0, idx),\n a,\n ...this._attachments.slice(idx + 1),\n ];\n else {\n this._attachments = [...this._attachments, a];\n this._notifyEventSubscribers(\"attachment_add\");\n }\n\n this._notifySubscribers();\n };\n\n const promiseOrGenerator = adapter.add({ file });\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n upsertAttachment(r);\n }\n } else {\n upsertAttachment(await promiseOrGenerator);\n }\n\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n // this._attachments.toSpliced(index, 1); - not yet widely supported\n this._attachments = [\n ...this._attachments.slice(0, index),\n ...this._attachments.slice(index + 1),\n ];\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<() => void>\n >();\n\n protected _notifyEventSubscribers(event: ComposerRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n this._eventSubscribers.set(event, new Set([callback]));\n } else {\n subscribers.add(callback);\n }\n\n return () => {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";AAYA,SAAS,wBAAwB;AAEjC,IAAM,uBAAuB,CAAC,MAC5B,EAAE,OAAO,SAAS;AAEb,IAAe,0BAAf,cACG,iBAEV;AAAA,EACkB,YAAY;AAAA,EAIrB,sBAA8B;AACnC,WAAO,KAAK,qBAAqB,GAAG,UAAU;AAAA,EAChD;AAAA,EAEQ,eAAsC,CAAC;AAAA,EAC/C,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEU,eAAe,OAA8B;AACrD,SAAK,eAAe;AACpB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAIA,IAAW,UAAU;AACnB,WAAO,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,KAAK,YAAY;AAAA,EAChD;AAAA,EAEQ,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AAA,EACF;AACF;","names":["subscribers"]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/composer/BaseComposerRuntimeCore.tsx"],"sourcesContent":["import {\n Attachment,\n CompleteAttachment,\n PendingAttachment,\n} from \"../../types/AttachmentTypes\";\nimport { AppendMessage } from \"../../types\";\nimport { AttachmentAdapter } from \"../adapters/attachment\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n} from \"../core/ComposerRuntimeCore\";\nimport { MessageRole, RunConfig } from \"../../types/AssistantTypes\";\nimport { BaseSubscribable } from \"../remote-thread-list/BaseSubscribable\";\n\nconst isAttachmentComplete = (a: Attachment): a is CompleteAttachment =>\n a.status.type === \"complete\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n\n public getAttachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._notifySubscribers();\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n await Promise.all(this._attachments.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send() {\n const adapter = this.getAttachmentAdapter();\n const attachments =\n adapter && this.attachments.length > 0\n ? Promise.all(\n this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n }),\n )\n : [];\n\n const text = this.text;\n this._emptyTextAndAttachments();\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n createdAt: new Date(),\n role: this.role,\n content: text ? [{ type: \"text\", text }] : [],\n attachments: await attachments,\n runConfig: this.runConfig,\n metadata: { custom: {} },\n };\n\n this.handleSend(message);\n this._notifyEventSubscribers(\"send\");\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n ): void;\n protected abstract handleCancel(): void;\n\n async addAttachment(file: File) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const upsertAttachment = (a: PendingAttachment) => {\n const idx = this._attachments.findIndex(\n (attachment) => attachment.id === a.id,\n );\n if (idx !== -1)\n this._attachments = [\n ...this._attachments.slice(0, idx),\n a,\n ...this._attachments.slice(idx + 1),\n ];\n else {\n this._attachments = [...this._attachments, a];\n this._notifyEventSubscribers(\"attachment_add\");\n }\n\n this._notifySubscribers();\n };\n\n const promiseOrGenerator = adapter.add({ file });\n if (Symbol.asyncIterator in promiseOrGenerator) {\n for await (const r of promiseOrGenerator) {\n upsertAttachment(r);\n }\n } else {\n upsertAttachment(await promiseOrGenerator);\n }\n\n this._notifyEventSubscribers(\"attachment_add\");\n this._notifySubscribers();\n }\n\n async removeAttachment(attachmentId: string) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n await adapter.remove(attachment);\n\n // this._attachments.toSpliced(index, 1); - not yet widely supported\n this._attachments = [\n ...this._attachments.slice(0, index),\n ...this._attachments.slice(index + 1),\n ];\n this._notifySubscribers();\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<() => void>\n >();\n\n protected _notifyEventSubscribers(event: ComposerRuntimeEventType) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n for (const callback of subscribers) callback();\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n this._eventSubscribers.set(event, new Set([callback]));\n } else {\n subscribers.add(callback);\n }\n\n return () => {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n subscribers.delete(callback);\n };\n }\n}\n"],"mappings":";AAYA,SAAS,wBAAwB;AAEjC,IAAM,uBAAuB,CAAC,MAC5B,EAAE,OAAO,SAAS;AAEb,IAAe,0BAAf,cACG,iBAEV;AAAA,EACkB,YAAY;AAAA,EAIrB,sBAA8B;AACnC,WAAO,KAAK,qBAAqB,GAAG,UAAU;AAAA,EAChD;AAAA,EAEQ,eAAsC,CAAC;AAAA,EAC/C,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEU,eAAe,OAA8B;AACrD,SAAK,eAAe;AACpB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAIA,IAAW,UAAU;AACnB,WAAO,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,KAAK,YAAY;AAAA,EAChD;AAAA,EAEQ,QAAQ;AAAA,EAE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,EACF;AACF;","names":["subscribers"]}
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { AddToolResultOptions, StartRunConfig, ThreadSuggestion } from "../core/ThreadRuntimeCore";
|
2
2
|
import { AppendMessage, ThreadMessage } from "../../types";
|
3
3
|
import { ExternalStoreAdapter } from "./ExternalStoreAdapter";
|
4
|
+
import { ThreadMessageLike } from "./ThreadMessageLike";
|
4
5
|
import { RuntimeCapabilities, ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
|
5
6
|
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore";
|
6
7
|
import { ModelContextProvider } from "../../model-context";
|
7
8
|
export declare const hasUpcomingMessage: (isRunning: boolean, messages: readonly ThreadMessage[]) => boolean;
|
8
9
|
export declare class ExternalStoreThreadRuntimeCore extends BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
9
|
-
private
|
10
|
+
private _resetScheduled;
|
11
|
+
private _assistantOptimisticId;
|
10
12
|
private _capabilities;
|
11
13
|
get capabilities(): RuntimeCapabilities;
|
12
14
|
private _messages;
|
@@ -32,6 +34,7 @@ export declare class ExternalStoreThreadRuntimeCore extends BaseThreadRuntimeCor
|
|
32
34
|
resumeRun(): Promise<void>;
|
33
35
|
cancelRun(): void;
|
34
36
|
addToolResult(options: AddToolResultOptions): void;
|
37
|
+
reset(initialMessages?: readonly ThreadMessageLike[]): void;
|
35
38
|
private updateMessages;
|
36
39
|
}
|
37
40
|
//# sourceMappingURL=ExternalStoreThreadRuntimeCore.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
1
|
+
{"version":3,"file":"ExternalStoreThreadRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO9D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAQ3D,eAAO,MAAM,kBAAkB,GAC7B,WAAW,OAAO,EAClB,UAAU,SAAS,aAAa,EAAE,YAGnC,CAAC;AAEF,qBAAa,8BACX,SAAQ,qBACR,YAAW,iBAAiB;IAE5B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,sBAAsB,CAAuB;IAErD,OAAO,CAAC,aAAa,CASnB;IAEF,IAAW,YAAY,wBAEtB;IAED,OAAO,CAAC,SAAS,CAA4B;IACtC,UAAU,EAAG,OAAO,CAAC;IAC5B,IAAW,SAAS,YAEnB;IAED,IAAoB,QAAQ,6BAE3B;IAED,IAAW,QAAQ;;;;;kBAElB;IAEM,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAM;IAC9C,MAAM,EAAE,OAAO,CAAa;IAEnC,OAAO,CAAC,UAAU,CAAgC;IAElD,OAAO,CAAC,MAAM,CAA6B;IAE3B,SAAS,CAAC,SAAS,EAAE,MAAM;gBAQzC,eAAe,EAAE,oBAAoB,EACrC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAM3B,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAsI7C,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAQzC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC,SAAS,IAAI,IAAI;IAiCjB,aAAa,CAAC,OAAO,EAAE,oBAAoB;IAMlC,KAAK,CAAC,eAAe,CAAC,EAAE,SAAS,iBAAiB,EAAE;IAOpE,OAAO,CAAC,cAAc,CAUpB;CACH"}
|
@@ -8,12 +8,17 @@ import { getAutoStatus, isAutoStatus } from "./auto-status.js";
|
|
8
8
|
import { fromThreadMessageLike } from "./ThreadMessageLike.js";
|
9
9
|
import { getThreadMessageText } from "../../utils/getThreadMessageText.js";
|
10
10
|
import { BaseThreadRuntimeCore } from "../core/BaseThreadRuntimeCore.js";
|
11
|
+
import {
|
12
|
+
ExportedMessageRepository,
|
13
|
+
MessageRepository
|
14
|
+
} from "../utils/MessageRepository.js";
|
11
15
|
var EMPTY_ARRAY = Object.freeze([]);
|
12
16
|
var hasUpcomingMessage = (isRunning, messages) => {
|
13
17
|
return isRunning && messages[messages.length - 1]?.role !== "assistant";
|
14
18
|
};
|
15
19
|
var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
16
|
-
|
20
|
+
_resetScheduled = false;
|
21
|
+
_assistantOptimisticId = null;
|
17
22
|
_capabilities = {
|
18
23
|
switchToBranch: false,
|
19
24
|
edit: false,
|
@@ -77,7 +82,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
77
82
|
return;
|
78
83
|
}
|
79
84
|
this.repository.clear();
|
80
|
-
this.
|
85
|
+
this._assistantOptimisticId = null;
|
81
86
|
this.repository.import(store.messageRepository);
|
82
87
|
messages = this.repository.getMessages();
|
83
88
|
} else if (store.messages) {
|
@@ -104,6 +109,10 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
104
109
|
newMessage[symbolInnerMessage] = m;
|
105
110
|
return newMessage;
|
106
111
|
});
|
112
|
+
if (this._resetScheduled || messages.length === 0) {
|
113
|
+
this._resetScheduled = false;
|
114
|
+
this.repository.clear();
|
115
|
+
}
|
107
116
|
for (let i = 0; i < messages.length; i++) {
|
108
117
|
const message = messages[i];
|
109
118
|
const parent = messages[i - 1];
|
@@ -122,12 +131,12 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
122
131
|
this._notifyEventSubscribers("run-end");
|
123
132
|
}
|
124
133
|
}
|
125
|
-
if (this.
|
126
|
-
this.repository.deleteMessage(this.
|
127
|
-
this.
|
134
|
+
if (this._assistantOptimisticId) {
|
135
|
+
this.repository.deleteMessage(this._assistantOptimisticId);
|
136
|
+
this._assistantOptimisticId = null;
|
128
137
|
}
|
129
138
|
if (hasUpcomingMessage(isRunning, messages)) {
|
130
|
-
this.
|
139
|
+
this._assistantOptimisticId = this.repository.appendOptimisticMessage(
|
131
140
|
messages.at(-1)?.id ?? null,
|
132
141
|
{
|
133
142
|
role: "assistant",
|
@@ -136,7 +145,7 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
136
145
|
);
|
137
146
|
}
|
138
147
|
this.repository.resetHead(
|
139
|
-
this.
|
148
|
+
this._assistantOptimisticId ?? messages.at(-1)?.id ?? null
|
140
149
|
);
|
141
150
|
this._messages = this.repository.getMessages();
|
142
151
|
this._notifySubscribers();
|
@@ -168,9 +177,9 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
168
177
|
if (!this._store.onCancel)
|
169
178
|
throw new Error("Runtime does not support cancelling runs.");
|
170
179
|
this._store.onCancel();
|
171
|
-
if (this.
|
172
|
-
this.repository.deleteMessage(this.
|
173
|
-
this.
|
180
|
+
if (this._assistantOptimisticId) {
|
181
|
+
this.repository.deleteMessage(this._assistantOptimisticId);
|
182
|
+
this._assistantOptimisticId = null;
|
174
183
|
}
|
175
184
|
let messages = this.repository.getMessages();
|
176
185
|
const previousMessage = messages[messages.length - 1];
|
@@ -192,6 +201,12 @@ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
192
201
|
throw new Error("Runtime does not support tool results.");
|
193
202
|
this._store.onAddToolResult?.(options);
|
194
203
|
}
|
204
|
+
reset(initialMessages) {
|
205
|
+
const repo = new MessageRepository();
|
206
|
+
repo.import(ExportedMessageRepository.fromArray(initialMessages ?? []));
|
207
|
+
this._resetScheduled = true;
|
208
|
+
this.updateMessages(repo.getMessages());
|
209
|
+
}
|
195
210
|
updateMessages = (messages) => {
|
196
211
|
const hasConverter = this._store.convertMessage !== void 0;
|
197
212
|
if (hasConverter) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n StartRunConfig,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { ModelContextProvider } from \"../../model-context\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: readonly ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n private _messages!: readonly ThreadMessage[];\n public isDisabled!: boolean;\n public get isLoading() {\n return this._store.isLoading ?? false;\n }\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n store: ExternalStoreAdapter<any>,\n ) {\n super(contextProvider);\n this.__internal_setAdapter(store);\n }\n\n public __internal_setAdapter(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n let messages: readonly ThreadMessage[];\n\n if (store.messageRepository) {\n // Handle messageRepository\n if (\n oldStore &&\n oldStore.isRunning === store.isRunning &&\n oldStore.messageRepository === store.messageRepository\n ) {\n this._notifySubscribers();\n return;\n }\n\n // Clear and import the message repository\n this.repository.clear();\n this.assistantOptimisticId = null;\n this.repository.import(store.messageRepository);\n\n messages = this.repository.getMessages();\n } else if (store.messages) {\n // Handle messages array\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages!.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning, false);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const messageLike = store.convertMessage(m, idx);\n const newMessage = fromThreadMessageLike(\n messageLike,\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n } else {\n throw new Error(\n \"ExternalStoreAdapter must provide either 'messages' or 'messageRepository'\",\n );\n }\n\n // Common logic for both paths\n if (messages.length > 0) this.ensureInitialized();\n\n if ((oldStore?.isRunning ?? false) !== (store.isRunning ?? false)) {\n if (store.isRunning) {\n this._notifyEventSubscribers(\"run-start\");\n } else {\n this._notifyEventSubscribers(\"run-end\");\n }\n }\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this.assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this.assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(config: StartRunConfig): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(config.parentId, config);\n }\n\n public async resumeRun(): Promise<void> {\n throw new Error(\"Runtime does not support resuming runs.\");\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this.assistantOptimisticId) {\n this.repository.deleteMessage(this.assistantOptimisticId);\n this.assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult && !this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult?.(options);\n }\n\n private updateMessages = (messages: readonly ThreadMessage[]) => {\n const hasConverter = this._store.convertMessage !== undefined;\n if (hasConverter) {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n } else {\n // TODO mark this as readonly in v0.8.0\n this._store.setMessages?.(messages as ThreadMessage[]);\n }\n };\n}\n"],"mappings":";AAQA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAA6B;AACtC,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAGtC,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,sBAEV;AAAA,EACU,wBAAuC;AAAA,EAEvC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EACD;AAAA,EACP,IAAW,YAAY;AACrB,WAAO,KAAK,OAAO,aAAa;AAAA,EAClC;AAAA,EAEA,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW;AACpB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEO,cAA2C,CAAC;AAAA,EAC5C,SAAkB;AAAA,EAEjB,aAAa,IAAI,uBAAuB;AAAA,EAExC;AAAA,EAEQ,UAAU,WAAmB;AAC3C,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,mCAAmC;AAErD,UAAM,UAAU,SAAS;AAAA,EAC3B;AAAA,EAEA,YACE,iBACA,OACA;AACA,UAAM,eAAe;AACrB,SAAK,sBAAsB,KAAK;AAAA,EAClC;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AEA,iBAAW,KAAK,WAAW,YAAY;AAAA,IACzC,OAAO;AACL,WAAK,mBAAmB;AAAA,IAC1B;AAGA,eAAW,MAAM;AACf,WAAK,eAAe,QAAQ;AAAA,IAC9B,GAAG,CAAC;AAAA,EACN;AAAA,EAEO,cAAc,SAA+B;AAClD,QAAI,CAAC,KAAK,OAAO,mBAAmB,CAAC,KAAK,OAAO;AAC/C,YAAM,IAAI,MAAM,wCAAwC;AAC1D,SAAK,OAAO,kBAAkB,OAAO;AAAA,EACvC;AAAA,EAEQ,iBAAiB,CAAC,aAAuC;AAC/D,UAAM,eAAe,KAAK,OAAO,mBAAmB;AACpD,QAAI,cAAc;AAChB,WAAK,OAAO;AAAA,QACV,SAAS,QAAQ,uBAAuB,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI;AAAA,MACnE;AAAA,IACF,OAAO;AAEL,WAAK,OAAO,cAAc,QAA2B;AAAA,IACvD;AAAA,EACF;AACF;","names":[]}
|
1
|
+
{"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx"],"sourcesContent":["import {\n AddToolResultOptions,\n StartRunConfig,\n ThreadSuggestion,\n} from \"../core/ThreadRuntimeCore\";\n\nimport { AppendMessage, ThreadMessage } from \"../../types\";\nimport { ExternalStoreAdapter } from \"./ExternalStoreAdapter\";\nimport {\n getExternalStoreMessage,\n symbolInnerMessage,\n} from \"./getExternalStoreMessage\";\nimport { ThreadMessageConverter } from \"./ThreadMessageConverter\";\nimport { getAutoStatus, isAutoStatus } from \"./auto-status\";\nimport { fromThreadMessageLike, ThreadMessageLike } from \"./ThreadMessageLike\";\nimport { getThreadMessageText } from \"../../utils/getThreadMessageText\";\nimport {\n RuntimeCapabilities,\n ThreadRuntimeCore,\n} from \"../core/ThreadRuntimeCore\";\nimport { BaseThreadRuntimeCore } from \"../core/BaseThreadRuntimeCore\";\nimport { ModelContextProvider } from \"../../model-context\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/MessageRepository\";\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\nexport const hasUpcomingMessage = (\n isRunning: boolean,\n messages: readonly ThreadMessage[],\n) => {\n return isRunning && messages[messages.length - 1]?.role !== \"assistant\";\n};\n\nexport class ExternalStoreThreadRuntimeCore\n extends BaseThreadRuntimeCore\n implements ThreadRuntimeCore\n{\n private _resetScheduled = false;\n private _assistantOptimisticId: string | null = null;\n\n private _capabilities: RuntimeCapabilities = {\n switchToBranch: false,\n edit: false,\n reload: false,\n cancel: false,\n unstable_copy: false,\n speech: false,\n attachments: false,\n feedback: false,\n };\n\n public get capabilities() {\n return this._capabilities;\n }\n\n private _messages!: readonly ThreadMessage[];\n public isDisabled!: boolean;\n public get isLoading() {\n return this._store.isLoading ?? false;\n }\n\n public override get messages() {\n return this._messages;\n }\n\n public get adapters() {\n return this._store.adapters;\n }\n\n public suggestions: readonly ThreadSuggestion[] = [];\n public extras: unknown = undefined;\n\n private _converter = new ThreadMessageConverter();\n\n private _store!: ExternalStoreAdapter<any>;\n\n public override beginEdit(messageId: string) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing.\");\n\n super.beginEdit(messageId);\n }\n\n constructor(\n contextProvider: ModelContextProvider,\n store: ExternalStoreAdapter<any>,\n ) {\n super(contextProvider);\n this.__internal_setAdapter(store);\n }\n\n public __internal_setAdapter(store: ExternalStoreAdapter<any>) {\n if (this._store === store) return;\n\n const isRunning = store.isRunning ?? false;\n this.isDisabled = store.isDisabled ?? false;\n\n const oldStore = this._store as ExternalStoreAdapter<any> | undefined;\n this._store = store;\n this.extras = store.extras;\n this.suggestions = store.suggestions ?? EMPTY_ARRAY;\n this._capabilities = {\n switchToBranch: this._store.setMessages !== undefined,\n edit: this._store.onEdit !== undefined,\n reload: this._store.onReload !== undefined,\n cancel: this._store.onCancel !== undefined,\n speech: this._store.adapters?.speech !== undefined,\n unstable_copy: this._store.unstable_capabilities?.copy !== false, // default true\n attachments: !!this._store.adapters?.attachments,\n feedback: !!this._store.adapters?.feedback,\n };\n\n let messages: readonly ThreadMessage[];\n\n if (store.messageRepository) {\n // Handle messageRepository\n if (\n oldStore &&\n oldStore.isRunning === store.isRunning &&\n oldStore.messageRepository === store.messageRepository\n ) {\n this._notifySubscribers();\n return;\n }\n\n // Clear and import the message repository\n this.repository.clear();\n this._assistantOptimisticId = null;\n this.repository.import(store.messageRepository);\n\n messages = this.repository.getMessages();\n } else if (store.messages) {\n // Handle messages array\n\n if (oldStore) {\n // flush the converter cache when the convertMessage prop changes\n if (oldStore.convertMessage !== store.convertMessage) {\n this._converter = new ThreadMessageConverter();\n } else if (\n oldStore.isRunning === store.isRunning &&\n oldStore.messages === store.messages\n ) {\n this._notifySubscribers();\n // no conversion update\n return;\n }\n }\n\n messages = !store.convertMessage\n ? store.messages\n : this._converter.convertMessages(store.messages, (cache, m, idx) => {\n if (!store.convertMessage) return m;\n\n const isLast = idx === store.messages!.length - 1;\n const autoStatus = getAutoStatus(isLast, isRunning, false);\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n )\n return cache;\n\n const messageLike = store.convertMessage(m, idx);\n const newMessage = fromThreadMessageLike(\n messageLike,\n idx.toString(),\n autoStatus,\n );\n (newMessage as any)[symbolInnerMessage] = m;\n return newMessage;\n });\n\n // special case: branches should be reset if an empty array is provided\n if (this._resetScheduled || messages.length === 0) {\n this._resetScheduled = false;\n this.repository.clear();\n }\n\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i]!;\n const parent = messages[i - 1];\n this.repository.addOrUpdateMessage(parent?.id ?? null, message);\n }\n } else {\n throw new Error(\n \"ExternalStoreAdapter must provide either 'messages' or 'messageRepository'\",\n );\n }\n\n // Common logic for both paths\n if (messages.length > 0) this.ensureInitialized();\n\n if ((oldStore?.isRunning ?? false) !== (store.isRunning ?? false)) {\n if (store.isRunning) {\n this._notifyEventSubscribers(\"run-start\");\n } else {\n this._notifyEventSubscribers(\"run-end\");\n }\n }\n\n if (this._assistantOptimisticId) {\n this.repository.deleteMessage(this._assistantOptimisticId);\n this._assistantOptimisticId = null;\n }\n\n if (hasUpcomingMessage(isRunning, messages)) {\n this._assistantOptimisticId = this.repository.appendOptimisticMessage(\n messages.at(-1)?.id ?? null,\n {\n role: \"assistant\",\n content: [],\n },\n );\n }\n\n this.repository.resetHead(\n this._assistantOptimisticId ?? messages.at(-1)?.id ?? null,\n );\n\n this._messages = this.repository.getMessages();\n this._notifySubscribers();\n }\n\n public override switchToBranch(branchId: string): void {\n if (!this._store.setMessages)\n throw new Error(\"Runtime does not support switching branches.\");\n\n this.repository.switchToBranch(branchId);\n this.updateMessages(this.repository.getMessages());\n }\n\n public async append(message: AppendMessage): Promise<void> {\n if (message.parentId !== (this.messages.at(-1)?.id ?? null)) {\n if (!this._store.onEdit)\n throw new Error(\"Runtime does not support editing messages.\");\n await this._store.onEdit(message);\n } else {\n await this._store.onNew(message);\n }\n }\n\n public async startRun(config: StartRunConfig): Promise<void> {\n if (!this._store.onReload)\n throw new Error(\"Runtime does not support reloading messages.\");\n\n await this._store.onReload(config.parentId, config);\n }\n\n public async resumeRun(): Promise<void> {\n throw new Error(\"Runtime does not support resuming runs.\");\n }\n\n public cancelRun(): void {\n if (!this._store.onCancel)\n throw new Error(\"Runtime does not support cancelling runs.\");\n\n this._store.onCancel();\n\n if (this._assistantOptimisticId) {\n this.repository.deleteMessage(this._assistantOptimisticId);\n this._assistantOptimisticId = null;\n }\n\n let messages = this.repository.getMessages();\n const previousMessage = messages[messages.length - 1];\n if (\n previousMessage?.role === \"user\" &&\n previousMessage.id === messages.at(-1)?.id // ensure the previous message is a leaf node\n ) {\n this.repository.deleteMessage(previousMessage.id);\n if (!this.composer.text.trim()) {\n this.composer.setText(getThreadMessageText(previousMessage));\n }\n\n messages = this.repository.getMessages();\n } else {\n this._notifySubscribers();\n }\n\n // resync messages (for reloading, to restore the previous branch)\n setTimeout(() => {\n this.updateMessages(messages);\n }, 0);\n }\n\n public addToolResult(options: AddToolResultOptions) {\n if (!this._store.onAddToolResult && !this._store.onAddToolResult)\n throw new Error(\"Runtime does not support tool results.\");\n this._store.onAddToolResult?.(options);\n }\n\n public override reset(initialMessages?: readonly ThreadMessageLike[]) {\n const repo = new MessageRepository();\n repo.import(ExportedMessageRepository.fromArray(initialMessages ?? []));\n this._resetScheduled = true;\n this.updateMessages(repo.getMessages());\n }\n\n private updateMessages = (messages: readonly ThreadMessage[]) => {\n const hasConverter = this._store.convertMessage !== undefined;\n if (hasConverter) {\n this._store.setMessages?.(\n messages.flatMap(getExternalStoreMessage).filter((m) => m != null),\n );\n } else {\n // TODO mark this as readonly in v0.8.0\n this._store.setMessages?.(messages as ThreadMessage[]);\n }\n };\n}\n"],"mappings":";AAQA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,6BAAgD;AACzD,SAAS,4BAA4B;AAKrC,SAAS,6BAA6B;AAEtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AAE7B,IAAM,qBAAqB,CAChC,WACA,aACG;AACH,SAAO,aAAa,SAAS,SAAS,SAAS,CAAC,GAAG,SAAS;AAC9D;AAEO,IAAM,iCAAN,cACG,sBAEV;AAAA,EACU,kBAAkB;AAAA,EAClB,yBAAwC;AAAA,EAExC,gBAAqC;AAAA,IAC3C,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,UAAU;AAAA,EACZ;AAAA,EAEA,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EACD;AAAA,EACP,IAAW,YAAY;AACrB,WAAO,KAAK,OAAO,aAAa;AAAA,EAClC;AAAA,EAEA,IAAoB,WAAW;AAC7B,WAAO,KAAK;AAAA,EAC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AACF;","names":[]}
|
@@ -20,9 +20,11 @@ export type SourceMessagePart = {
|
|
20
20
|
export type ImageMessagePart = {
|
21
21
|
readonly type: "image";
|
22
22
|
readonly image: string;
|
23
|
+
readonly filename?: string;
|
23
24
|
};
|
24
25
|
export type FileMessagePart = {
|
25
26
|
readonly type: "file";
|
27
|
+
readonly filename?: string;
|
26
28
|
readonly data: string;
|
27
29
|
readonly mimeType: string;
|
28
30
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MessagePartTypes.d.ts","sourceRoot":"","sources":["../../src/types/MessagePartTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,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MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAC7B,KAAK,GAAG,kBAAkB,EAC1B,OAAO,GAAG,OAAO,IACf;IACF,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,yBAAyB,CAAC;AAE9B,MAAM,MAAM,0BAA0B,GAClC,eAAe,GACf,oBAAoB,GACpB,mBAAmB,GACnB,iBAAiB,GACjB,eAAe,GACf,gBAAgB,CAAC"}
|
package/package.json
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
"conversational-ui",
|
29
29
|
"conversational-ai"
|
30
30
|
],
|
31
|
-
"version": "0.10.
|
31
|
+
"version": "0.10.45",
|
32
32
|
"license": "MIT",
|
33
33
|
"type": "module",
|
34
34
|
"exports": {
|
@@ -48,6 +48,7 @@
|
|
48
48
|
],
|
49
49
|
"sideEffects": false,
|
50
50
|
"dependencies": {
|
51
|
+
"assistant-cloud": "^0.1.1",
|
51
52
|
"@radix-ui/primitive": "^1.1.3",
|
52
53
|
"@radix-ui/react-compose-refs": "^1.1.2",
|
53
54
|
"@radix-ui/react-context": "^1.1.2",
|
@@ -62,8 +63,7 @@
|
|
62
63
|
"nanoid": "5.1.5",
|
63
64
|
"react-textarea-autosize": "^8.5.9",
|
64
65
|
"zod": "^4.0.17",
|
65
|
-
"zustand": "^5.0.7"
|
66
|
-
"assistant-cloud": "0.1.1"
|
66
|
+
"zustand": "^5.0.7"
|
67
67
|
},
|
68
68
|
"peerDependencies": {
|
69
69
|
"@types/react": "*",
|