@litert-lm/core 0.13.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +2 -2
  2. package/dist/conversation.d.ts +11 -3
  3. package/dist/conversation.d.ts.map +1 -1
  4. package/dist/conversation.js +68 -50
  5. package/dist/conversation.js.map +1 -1
  6. package/dist/conversation_config.d.ts +68 -22
  7. package/dist/conversation_config.d.ts.map +1 -1
  8. package/dist/engine.js +5 -2
  9. package/dist/engine.js.map +1 -1
  10. package/dist/engine_settings.d.ts +2 -1
  11. package/dist/engine_settings.d.ts.map +1 -1
  12. package/dist/engine_settings.js +4 -0
  13. package/dist/engine_settings.js.map +1 -1
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +4 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/litertlm_web.js +1 -1
  19. package/dist/load.d.ts.map +1 -1
  20. package/dist/load.js +9 -2
  21. package/dist/load.js.map +1 -1
  22. package/dist/load_litertlm.d.ts +1 -1
  23. package/dist/load_litertlm.d.ts.map +1 -1
  24. package/dist/load_litertlm.js +14 -2
  25. package/dist/load_litertlm.js.map +1 -1
  26. package/dist/orchestration/auto_tool_chat.d.ts +82 -0
  27. package/dist/orchestration/auto_tool_chat.d.ts.map +1 -0
  28. package/dist/orchestration/auto_tool_chat.js +304 -0
  29. package/dist/orchestration/auto_tool_chat.js.map +1 -0
  30. package/dist/orchestration/chat_interface.d.ts +30 -0
  31. package/dist/orchestration/chat_interface.d.ts.map +1 -0
  32. package/dist/orchestration/chat_interface.js +17 -0
  33. package/dist/orchestration/chat_interface.js.map +1 -0
  34. package/dist/orchestration/webmcp_tool.d.ts +41 -0
  35. package/dist/orchestration/webmcp_tool.d.ts.map +1 -0
  36. package/dist/orchestration/webmcp_tool.js +32 -0
  37. package/dist/orchestration/webmcp_tool.js.map +1 -0
  38. package/dist/session.d.ts +5 -0
  39. package/dist/session.d.ts.map +1 -1
  40. package/dist/session.js +19 -0
  41. package/dist/session.js.map +1 -1
  42. package/dist/testing/fakes.d.ts +67 -0
  43. package/dist/testing/fakes.d.ts.map +1 -0
  44. package/dist/testing/fakes.js +125 -0
  45. package/dist/testing/fakes.js.map +1 -0
  46. package/dist/testing/index.d.ts +17 -0
  47. package/dist/testing/index.d.ts.map +1 -0
  48. package/dist/testing/index.js +17 -0
  49. package/dist/testing/index.js.map +1 -0
  50. package/dist/wasm_binding_types.d.ts +17 -3
  51. package/dist/wasm_binding_types.d.ts.map +1 -1
  52. package/dist/wasm_binding_types.js.map +1 -1
  53. package/dist/wasm_feature_detect.d.ts +3 -0
  54. package/dist/wasm_feature_detect.d.ts.map +1 -1
  55. package/dist/wasm_feature_detect.js +22 -0
  56. package/dist/wasm_feature_detect.js.map +1 -1
  57. package/package.json +15 -1
  58. package/wasm/litertlm_wasm_asyncify_internal.js +8619 -0
  59. package/wasm/litertlm_wasm_asyncify_internal.wasm +0 -0
  60. package/wasm/litertlm_wasm_compat_asyncify_internal.js +8628 -0
  61. package/wasm/litertlm_wasm_compat_asyncify_internal.wasm +0 -0
  62. package/wasm/litertlm_wasm_compat_internal.js +83 -70
  63. package/wasm/litertlm_wasm_compat_internal.wasm +0 -0
  64. package/wasm/litertlm_wasm_internal.js +83 -70
  65. package/wasm/litertlm_wasm_internal.wasm +0 -0
@@ -17,6 +17,7 @@
17
17
  import { getGlobalLiteRtLm, getGlobalLiteRtLmPromise, hasGlobalLiteRtLm, hasGlobalLiteRtLmPromise, setGlobalLiteRtLm, setGlobalLiteRtLmPromise } from './global_litertlm.js';
18
18
  import { LiteRtLm } from './litertlm_web.js';
19
19
  import { load } from './load.js';
20
+ let globalLiteRtLmPath = undefined;
20
21
  /**
21
22
  * Load LiteRT-LM Wasm files from the given URL. This needs to be called before
22
23
  * calling any other LiteRT-LM functions.
@@ -63,13 +64,24 @@ export function unloadLiteRtLm() {
63
64
  if (hasGlobalLiteRtLm()) {
64
65
  getGlobalLiteRtLm().delete();
65
66
  setGlobalLiteRtLm(undefined);
67
+ globalLiteRtLmPath = undefined;
66
68
  }
67
69
  setGlobalLiteRtLmPromise(undefined);
68
70
  }
69
71
  /**
70
72
  * Get the global LiteRT-LM instance, or load it if it hasn't been loaded yet.
71
73
  */
72
- export function getOrLoadGlobalLiteRtLm() {
73
- return getGlobalLiteRtLmPromise() ?? loadLiteRtLm(LiteRtLm.DEFAULT_WASM_PATH);
74
+ export function getOrLoadGlobalLiteRtLm(path) {
75
+ const liteRtLmPromise = getGlobalLiteRtLmPromise();
76
+ if (liteRtLmPromise) {
77
+ if (path && globalLiteRtLmPath !== path) {
78
+ throw new Error(`LiteRT-LM is already loading / loaded with a different path ` +
79
+ `${globalLiteRtLmPath} but was requested to load ${path}. To ` +
80
+ `reload with a different path, call unloadLiteRtLm() first.`);
81
+ }
82
+ return liteRtLmPromise;
83
+ }
84
+ globalLiteRtLmPath = path ?? LiteRtLm.DEFAULT_WASM_PATH;
85
+ return liteRtLmPromise ?? loadLiteRtLm(globalLiteRtLmPath);
74
86
  }
75
87
  //# sourceMappingURL=load_litertlm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load_litertlm.js","sourceRoot":"","sources":["../src/load_litertlm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,mEAAmE;AAEnE,OAAO,EAAC,iBAAiB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,wBAAwB,EAAC,MAAM,sBAAsB,CAAC;AAC3K,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,IAAI,EAAc,MAAM,WAAW,CAAC;AAa5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CACxB,IAAe,EAAE,OAA6B;IAChD,IAAI,wBAAwB,EAAE,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CA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,4DAA4D,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,kBAAkB,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAAC;IACxD,OAAO,eAAe,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { ConversationConfig, Message, MessageLike, Tool } from '../conversation_config.js';
17
+ import { Engine } from '../engine.js';
18
+ import { JsonValue } from '../types.js';
19
+ import { BenchmarkInfo } from '../wasm_binding_types.js';
20
+ import { ChatInterface } from './chat_interface.js';
21
+ import { WebMcpTool } from './webmcp_tool.js';
22
+ type ToolExecute = (args: Record<string, JsonValue>) => JsonValue | Promise<JsonValue>;
23
+ /**
24
+ * A tool with an `execute` function implementation.
25
+ */
26
+ export type ToolWithImplementation = Tool & {
27
+ execute: ToolExecute;
28
+ };
29
+ /**
30
+ * Event detail representing the execution progress of a single tool.
31
+ */
32
+ export interface ToolProgressEvent {
33
+ id: number;
34
+ name: string;
35
+ arguments: Record<string, JsonValue>;
36
+ status: 'started' | 'completed' | 'error';
37
+ result?: unknown;
38
+ error?: string;
39
+ }
40
+ /**
41
+ * Options for configuring an AutoToolChat.
42
+ */
43
+ export interface AutoToolChatOptions {
44
+ engine: Engine;
45
+ config?: ConversationConfig;
46
+ tools?: Array<ToolWithImplementation | WebMcpTool>;
47
+ recurringToolCallLimit?: number;
48
+ onToolProgress?: (event: ToolProgressEvent) => void;
49
+ }
50
+ /**
51
+ * Wraps a conversation and automatically executes tools for the model.
52
+ *
53
+ * Tools are called in parallel, but the model waits for all of them to
54
+ * finish before being woken up again.
55
+ */
56
+ export declare class AutoToolChat implements ChatInterface {
57
+ private readonly options;
58
+ private baseConversation;
59
+ private isBusy;
60
+ private isCancelled;
61
+ private readonly tools;
62
+ private nextToolCallId;
63
+ private currentBatch;
64
+ constructor(options: AutoToolChatOptions);
65
+ private getConversation;
66
+ sendMessage(message: MessageLike | MessageLike[]): Promise<Message>;
67
+ sendMessageStreaming(message: MessageLike | MessageLike[]): ReadableStream<Message>;
68
+ /**
69
+ * Cancels the current generation.
70
+ * Note: This does not abort any in-progress tool calls natively. Tools that
71
+ * affect state may still complete in the background eventually, but their
72
+ * results will be discarded and not reported back to the model or the user.
73
+ */
74
+ cancel(): void;
75
+ getHistory(): Promise<Message[]>;
76
+ getTokenCount(): Promise<number>;
77
+ getBenchmarkInfo(): Promise<BenchmarkInfo>;
78
+ delete(): Promise<void>;
79
+ private executeToolCalls;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=auto_tool_chat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto_tool_chat.d.ts","sourceRoot":"","sources":["../../src/orchestration/auto_tool_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAc,kBAAkB,EAAgB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAW,MAAM,2BAA2B,CAAC;AAC9H,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAuB,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAMlE,KAAK,WAAW,GAAG,CAAC,IAAI,E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WAAW,EAAE,GACnD,cAAc,CAAC,OAAO,CAAC;IAmF3B;;;;;OAKG;IACH,MAAM;IAUA,UAAU,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAK1C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;YAOf,gBAAgB;CAU/B"}
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { isWebMcpTool, toTool } from './webmcp_tool.js';
17
+ const BUSY_MESSAGE = 'Conversation is busy. A generation is already in progress.';
18
+ /**
19
+ * Wraps a conversation and automatically executes tools for the model.
20
+ *
21
+ * Tools are called in parallel, but the model waits for all of them to
22
+ * finish before being woken up again.
23
+ */
24
+ export class AutoToolChat {
25
+ options;
26
+ baseConversation = null;
27
+ isBusy = false;
28
+ isCancelled = false;
29
+ tools = new Map();
30
+ nextToolCallId = 1;
31
+ currentBatch = null;
32
+ constructor(options) {
33
+ this.options = options;
34
+ if (options.config?.preface?.tools &&
35
+ options.config.preface.tools.length > 0) {
36
+ throw new Error('AutoToolChat handles tools itself. Do not provide tools via ConversationConfig.preface.tools.');
37
+ }
38
+ const activeTools = options.tools || [];
39
+ for (let t of activeTools) {
40
+ let tool;
41
+ if (isWebMcpTool(t)) {
42
+ tool = { ...toTool(t), execute: t.execute };
43
+ }
44
+ else if (!('function' in t)) {
45
+ const { execute, ...declaration } = t;
46
+ tool = { type: 'function', function: declaration, execute };
47
+ }
48
+ else {
49
+ tool = t;
50
+ }
51
+ const name = tool.function.name;
52
+ if (!name)
53
+ throw new Error('Tool must have a name.');
54
+ if (!tool.execute) {
55
+ throw new Error(`Tool ${name} must have an execute function.`);
56
+ }
57
+ if (this.tools.has(name)) {
58
+ throw new Error(`Duplicate tool name ${name} provided.`);
59
+ }
60
+ this.tools.set(name, tool);
61
+ }
62
+ }
63
+ async getConversation() {
64
+ if (!this.baseConversation) {
65
+ const config = this.options.config ? { ...this.options.config } : {};
66
+ if (this.tools.size > 0) {
67
+ if (!config.preface) {
68
+ config.preface = {};
69
+ }
70
+ // Extract the explicit tool definitions (e.g. name, description,
71
+ // parameters) to pass to createConversation without the execute
72
+ // implementation.
73
+ config.preface.tools = Array.from(this.tools.values()).map(t => {
74
+ const { execute, ...rest } = t;
75
+ return rest;
76
+ });
77
+ }
78
+ this.baseConversation =
79
+ await this.options.engine.createConversation(config);
80
+ }
81
+ return this.baseConversation;
82
+ }
83
+ async sendMessage(message) {
84
+ if (this.isBusy) {
85
+ throw new Error(BUSY_MESSAGE);
86
+ }
87
+ this.isBusy = true;
88
+ this.isCancelled = false;
89
+ try {
90
+ const conversation = await this.getConversation();
91
+ let currentMessage = message;
92
+ const recurringToolCallLimit = this.options.recurringToolCallLimit ?? 25;
93
+ let iteration = 0;
94
+ while (iteration < recurringToolCallLimit) {
95
+ iteration++;
96
+ const responseMsg = await conversation.sendMessage(currentMessage);
97
+ if (responseMsg.tool_calls && responseMsg.tool_calls.length > 0) {
98
+ const toolResponses = await this.executeToolCalls(responseMsg.tool_calls);
99
+ if (this.isCancelled) {
100
+ throw new Error('Conversation cancelled');
101
+ }
102
+ // Feed back as a tool message
103
+ currentMessage = { role: 'tool', content: toolResponses };
104
+ continue;
105
+ }
106
+ return responseMsg;
107
+ }
108
+ throw new Error('Tool calling exceeded the recurring limit');
109
+ }
110
+ finally {
111
+ this.isBusy = false;
112
+ }
113
+ }
114
+ sendMessageStreaming(message) {
115
+ if (this.isBusy) {
116
+ throw new Error(BUSY_MESSAGE);
117
+ }
118
+ this.isBusy = true;
119
+ this.isCancelled = false;
120
+ let isStreamCancelled = false;
121
+ return new ReadableStream({
122
+ start: (controller) => {
123
+ let currentMessage = message;
124
+ let iteration = 0;
125
+ const recurringToolCallLimit = this.options.recurringToolCallLimit ?? 25;
126
+ const executeIteration = async () => {
127
+ if (iteration >= recurringToolCallLimit) {
128
+ this.isBusy = false;
129
+ controller.error(new Error('Tool calling exceeded the recurring limit'));
130
+ return;
131
+ }
132
+ iteration++;
133
+ let toolCalls = [];
134
+ try {
135
+ const conversation = await this.getConversation();
136
+ const stream = conversation.sendMessageStreaming(currentMessage);
137
+ for await (const chunk of stream) {
138
+ if (isStreamCancelled || this.isCancelled) {
139
+ // Because we break out of the loop early, the underlying
140
+ // iterator automatically invokes stream.cancel()
141
+ break;
142
+ }
143
+ if (chunk.tool_calls && chunk.tool_calls.length > 0) {
144
+ toolCalls = toolCalls.concat(chunk.tool_calls);
145
+ // Omit the tool_calls property before enqueuing to the user
146
+ const cleanValue = { ...chunk };
147
+ delete cleanValue.tool_calls;
148
+ if (cleanValue.content) { // only enqueue if there's content
149
+ // besides tool_calls
150
+ controller.enqueue(cleanValue);
151
+ }
152
+ }
153
+ else {
154
+ controller.enqueue(chunk);
155
+ }
156
+ }
157
+ }
158
+ catch (e) {
159
+ this.isBusy = false;
160
+ controller.error(e);
161
+ return;
162
+ }
163
+ if (isStreamCancelled || this.isCancelled)
164
+ return;
165
+ if (toolCalls.length > 0) {
166
+ const toolResponses = await this.executeToolCalls(toolCalls);
167
+ if (isStreamCancelled || this.isCancelled)
168
+ return;
169
+ currentMessage = { role: 'tool', content: toolResponses };
170
+ await executeIteration();
171
+ return;
172
+ }
173
+ this.isBusy = false;
174
+ controller.close();
175
+ };
176
+ executeIteration().catch((e) => {
177
+ if (isStreamCancelled || this.isCancelled)
178
+ return;
179
+ this.isBusy = false;
180
+ controller.error(e);
181
+ });
182
+ },
183
+ cancel: () => {
184
+ isStreamCancelled = true;
185
+ this.cancel();
186
+ }
187
+ });
188
+ }
189
+ /**
190
+ * Cancels the current generation.
191
+ * Note: This does not abort any in-progress tool calls natively. Tools that
192
+ * affect state may still complete in the background eventually, but their
193
+ * results will be discarded and not reported back to the model or the user.
194
+ */
195
+ cancel() {
196
+ this.isCancelled = true;
197
+ if (this.currentBatch) {
198
+ this.currentBatch.cancel();
199
+ }
200
+ if (this.baseConversation) {
201
+ this.baseConversation.cancel();
202
+ }
203
+ }
204
+ async getHistory() {
205
+ const conversation = await this.getConversation();
206
+ return conversation.getHistory();
207
+ }
208
+ async getTokenCount() {
209
+ const conversation = await this.getConversation();
210
+ return conversation.getTokenCount();
211
+ }
212
+ async getBenchmarkInfo() {
213
+ const conversation = await this.getConversation();
214
+ return conversation.getBenchmarkInfo();
215
+ }
216
+ async delete() {
217
+ if (this.baseConversation) {
218
+ await this.baseConversation.delete();
219
+ this.baseConversation = null;
220
+ }
221
+ }
222
+ async executeToolCalls(toolCalls) {
223
+ this.currentBatch = new ToolCallBatch(this.tools, this.options.onToolProgress, () => this.nextToolCallId++);
224
+ try {
225
+ return await this.currentBatch.executeAll(toolCalls);
226
+ }
227
+ finally {
228
+ this.currentBatch = null;
229
+ }
230
+ }
231
+ }
232
+ class ToolCallBatch {
233
+ tools;
234
+ onToolProgress;
235
+ getNextId;
236
+ isCancelled = false;
237
+ constructor(tools, onToolProgress, getNextId) {
238
+ this.tools = tools;
239
+ this.onToolProgress = onToolProgress;
240
+ this.getNextId = getNextId;
241
+ }
242
+ cancel() {
243
+ this.isCancelled = true;
244
+ }
245
+ async executeAll(toolCalls) {
246
+ return Promise.all(toolCalls.map(async (tc) => {
247
+ const tool = this.tools.get(tc.function.name);
248
+ const callId = this.getNextId();
249
+ let result;
250
+ if (this.onToolProgress) {
251
+ this.onToolProgress({
252
+ id: callId,
253
+ name: tc.function.name,
254
+ arguments: tc.function.arguments,
255
+ status: 'started'
256
+ });
257
+ }
258
+ if (!tool) {
259
+ const errorMsg = `Tool ${tc.function.name} not found.`;
260
+ result = { error: errorMsg };
261
+ if (!this.isCancelled && this.onToolProgress) {
262
+ this.onToolProgress({
263
+ id: callId,
264
+ name: tc.function.name,
265
+ arguments: tc.function.arguments,
266
+ status: 'error',
267
+ error: errorMsg
268
+ });
269
+ }
270
+ }
271
+ else {
272
+ try {
273
+ result = await tool.execute(tc.function.arguments);
274
+ if (!this.isCancelled && this.onToolProgress) {
275
+ this.onToolProgress({
276
+ id: callId,
277
+ name: tc.function.name,
278
+ arguments: tc.function.arguments,
279
+ status: 'completed',
280
+ result
281
+ });
282
+ }
283
+ }
284
+ catch (e) {
285
+ const errorMsg = String(e);
286
+ result = {
287
+ error: `Error executing tool ${tc.function.name}: ${errorMsg}`
288
+ };
289
+ if (!this.isCancelled && this.onToolProgress) {
290
+ this.onToolProgress({
291
+ id: callId,
292
+ name: tc.function.name,
293
+ arguments: tc.function.arguments,
294
+ status: 'error',
295
+ error: errorMsg
296
+ });
297
+ }
298
+ }
299
+ }
300
+ return { type: 'tool_response', name: tc.function.name, response: result };
301
+ }));
302
+ }
303
+ }
304
+ //# sourceMappingURL=auto_tool_chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto_tool_chat.js","sourceRoot":"","sources":["../../src/orchestration/auto_tool_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAC,YAAY,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AAElE,MAAM,YAAY,GACd,4DAA4D,CAAC;AAkCjE;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAQM;IAPrB,gBAAgB,GAAsB,IAAI,CAAC;IAC3C,MAAM,GAAG,KAAK,CAAC;IACf,WAAW,GAAG,KAAK,CAAC;IACX,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,cAAc,GAAG,CAAC,CAAC;IACnB,YAAY,GAAuB,IAAI,CAAC;I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30 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Message, MessageLike } from '../conversation_config.js';
17
+ import { BenchmarkInfo } from '../wasm_binding_types.js';
18
+ /**
19
+ * Interface representing standard chat interaction methods.
20
+ */
21
+ export interface ChatInterface {
22
+ sendMessage(message: MessageLike | MessageLike[]): Promise<Message>;
23
+ sendMessageStreaming(message: MessageLike | MessageLike[]): ReadableStream<Message>;
24
+ cancel(): void;
25
+ getHistory(): Message[] | Promise<Message[]>;
26
+ getTokenCount(): Promise<number>;
27
+ getBenchmarkInfo(): Promise<BenchmarkInfo>;
28
+ delete(): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=chat_interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_interface.d.ts","sourceRoot":"","sources":["../../src/orchestration/chat_interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,OAAO,EAAE,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAC,WAAW,EAAE,GACnD,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,IAAI,IAAI,CAAC;IACf,UAAU,IAAI,OAAO,EAAE,GAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=chat_interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_interface.js","sourceRoot":"","sources":["../../src/orchestration/chat_interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { FunctionTool, Tool } from '../conversation_config.js';
17
+ import { JsonValue } from '../types.js';
18
+ /**
19
+ * A WebMCP tool declaration.
20
+ */
21
+ export interface WebMcpTool {
22
+ name: string;
23
+ description?: string;
24
+ inputSchema?: {
25
+ type?: string;
26
+ properties?: Record<string, JsonValue>;
27
+ required?: string[];
28
+ [key: string]: JsonValue | undefined;
29
+ };
30
+ execute?: (args: Record<string, JsonValue>) => JsonValue | Promise<JsonValue>;
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ * Type guard to check if a tool is a WebMcpTool.
35
+ */
36
+ export declare function isWebMcpTool(tool: Tool | WebMcpTool): tool is WebMcpTool;
37
+ /**
38
+ * Converts a WebMcpTool to a FunctionTool compatible with the C++ engine.
39
+ */
40
+ export declare function toTool(tool: WebMcpTool): FunctionTool;
41
+ //# sourceMappingURL=webmcp_tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webmcp_tool.d.ts","sourceRoot":"","sources":["../../src/orchestration/webmcp_tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,YAAY,EAAU,IAAI,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;KAC3D,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9E,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAC,UAAU,GAAG,IAAI,IAAI,UAAU,CAEtE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAMrD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright 2026 The ODML Authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Type guard to check if a tool is a WebMcpTool.
18
+ */
19
+ export function isWebMcpTool(tool) {
20
+ return 'inputSchema' in tool;
21
+ }
22
+ /**
23
+ * Converts a WebMcpTool to a FunctionTool compatible with the C++ engine.
24
+ */
25
+ export function toTool(tool) {
26
+ const { inputSchema, execute, ...rest } = tool;
27
+ return {
28
+ type: 'function',
29
+ function: { ...rest, parameters: inputSchema }
30
+ };
31
+ }
32
+ //# sourceMappingURL=webmcp_tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webmcp_tool.js","sourceRoot":"","sources":["../../src/orchestration/webmcp_tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoBH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAgB;IACrC,MAAM,EAAC,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,EAAC,GAAG,IAAI,CAAC;IAC7C,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAC,GAAG,IAAI,EAAE,UAAU,EAAE,WAAqB,EAAC;KACvD,CAAC;AACJ,CAAC"}
package/dist/session.d.ts CHANGED
@@ -34,6 +34,11 @@ export declare class Session {
34
34
  * Sends a signal to cancel any current generation.
35
35
  */
36
36
  cancel(): void;
37
+ /**
38
+ * Clones the session. The cloned session will have all the settings and
39
+ * context of the original session up to the point that clone is called.
40
+ */
41
+ clone(): Promise<Session>;
37
42
  delete(): Promise<void>;
38
43
  }
39
44
  declare class Responses {
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,aAAa,EAAmC,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,SAAS,IAAI,aAAa,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAK3F;;GAEG;AACH,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAe,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH3E,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,CAAS;gBAEM,OAAO,EAAE,WAAW,EAAmB,OAAO,EAAE;QAC3E,QAAQ,EAAE,KAAK,CAAC;KACjB;IAMK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3C,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;IAerC;;OAEG;IACH,MAAM;IAIA,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B;AAED,cAAM,SAAS;IACD,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAErD,QAAQ,IAAI,MAAM,EAAE;IAKpB,MAAM;CAGP"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,aAAa,EAAmC,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,SAAS,IAAI,aAAa,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAK3F;;GAEG;AACH,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAe,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH3E,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,CAAS;gBAEM,OAAO,EAAE,WAAW,EAAmB,OAAO,EAAE;QAC3E,QAAQ,EAAE,KAAK,CAAC;KACjB;IAMK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3C,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;IAerC;;OAEG;IACH,MAAM;IAIN;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAezB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B;AAED,cAAM,SAAS;IACD,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAErD,QAAQ,IAAI,MAAM,EAAE;IAKpB,MAAM;CAGP"}
package/dist/session.js CHANGED
@@ -66,6 +66,25 @@ export class Session {
66
66
  cancel() {
67
67
  this.session.cancelProcess();
68
68
  }
69
+ /**
70
+ * Clones the session. The cloned session will have all the settings and
71
+ * context of the original session up to the point that clone is called.
72
+ */
73
+ async clone() {
74
+ if (this.isBusy) {
75
+ throw new Error(BUSY_MESSAGE);
76
+ }
77
+ this.isBusy = true;
78
+ try {
79
+ return await this.mutexes.executor.acquireAndRun(() => {
80
+ const wasmClonedSession = this.session.clone();
81
+ return new Session(wasmClonedSession, this.mutexes);
82
+ });
83
+ }
84
+ finally {
85
+ this.isBusy = false;
86
+ }
87
+ }
69
88
  async delete() {
70
89
  await this.mutexes.executor.acquireAndRun(() => {
71
90
  this.session.delete();
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAgB,gCAAgC,EAAC,MAAM,qBAAqB,CAAC;AAGpF,OAAO,EAAC,8BAA8B,EAAC,MAAM,iBAAiB,CAAC;AAE/D,MAAM,YAAY,GAAG,uDAAuD,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,OAAO;IAIW;IAAuC;IAH3D,MAAM,CAAmC;IAC1C,MAAM,GAAG,KAAK,CAAC;IAEvB,YAA6B,OAAoB,EAAmB,OAEnE;QAF4B,YAAO,GAAP,OAAO,CAAa;QAAmB,YAAO,GAAP,OAAO,CAE1E;QACC,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,gCAAgC,CAAC,iBAAiB,CAAC,CAAC;QAClE,iBAAiB,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAgB;QAC/B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;gBACnD,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,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