@intelliweave/embedded 2.0.71 → 2.0.72-beta.10
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/component/chunk-FSRPMVAS.js +1 -0
- package/dist/component/component.d.ts +355 -130
- package/dist/component/component.js +466 -42
- package/dist/component/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/{script-tag/ort.bundle.min-IUPKB45H.js → component/ort.bundle.min-4BREXDX3.js} +3 -3
- package/dist/intelliweave-wordpress.zip +0 -0
- package/dist/node/node.d.ts +382 -216
- package/dist/node/node.js +48 -24
- package/dist/react/react.d.ts +343 -127
- package/dist/react/react.js +326 -30
- package/dist/script-tag/chunk-FSRPMVAS.js +1 -0
- package/dist/script-tag/ort.bundle.min-4BREXDX3.js +1834 -0
- package/dist/script-tag/script-tag.js +410 -3327
- package/dist/webpack/index.d.ts +423 -216
- package/dist/webpack/index.js +331 -31
- package/package.json +21 -21
- package/vitest.config.ts +12 -0
- package/dist/script-tag/chunk-AIYMQX7V.js +0 -1
package/dist/webpack/index.d.ts
CHANGED
|
@@ -1,10 +1,157 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
1
|
import { Optional } from 'utility-types';
|
|
2
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
3
|
import * as onnxruntime_web from 'onnxruntime-web';
|
|
4
4
|
import { InferenceSession, Tensor } from 'onnxruntime-web';
|
|
5
|
+
import OpenAI from 'openai';
|
|
5
6
|
import Anthropic from '@anthropic-ai/sdk';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
11
|
+
*/
|
|
12
|
+
declare class TokenWindow {
|
|
13
|
+
/** Token window size */
|
|
14
|
+
size: number;
|
|
15
|
+
/** Token groups */
|
|
16
|
+
groups: TokenWindowGroup<any>[];
|
|
17
|
+
/** Create a new group */
|
|
18
|
+
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
19
|
+
/** Get a group */
|
|
20
|
+
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
21
|
+
/** Counts tokens in the specified text */
|
|
22
|
+
static countTokensInText(text: string): number;
|
|
23
|
+
/** Calculate current tokens in all groups */
|
|
24
|
+
countTokens(): number;
|
|
25
|
+
/** Remove overflow from all groups. */
|
|
26
|
+
removeOverflow(): void;
|
|
27
|
+
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
28
|
+
private removeOneItem;
|
|
29
|
+
}
|
|
30
|
+
/** A token group. */
|
|
31
|
+
declare class TokenWindowGroup<DataType> {
|
|
32
|
+
/** Group ID */
|
|
33
|
+
id: string;
|
|
34
|
+
/** List of items */
|
|
35
|
+
items: TokenWindowGroupItem<DataType>[];
|
|
36
|
+
/**
|
|
37
|
+
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
38
|
+
* groups have a weight of 1, each group remove items equally if full. If one has a weight of 2 while the rest are 1,
|
|
39
|
+
* that group will be allowed to keep double the amount of items.
|
|
40
|
+
*/
|
|
41
|
+
weight: number;
|
|
42
|
+
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
43
|
+
tokenCount: number;
|
|
44
|
+
/** Group item separator. This text is added in between each item in the token window. */
|
|
45
|
+
separator: string;
|
|
46
|
+
/** Token count padding added to each item. */
|
|
47
|
+
private itemPadding;
|
|
48
|
+
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
49
|
+
setItemPadding(padding: number): this;
|
|
50
|
+
/** Sort function */
|
|
51
|
+
private sortFunction;
|
|
52
|
+
/** Set sort function */
|
|
53
|
+
sortBy(sortFunction: (a: TokenWindowGroupItem<DataType>, b: TokenWindowGroupItem<DataType>) => number): this;
|
|
54
|
+
/** Set separator. This text is added in between each item in the token window. */
|
|
55
|
+
setSeparator(separator: string): this;
|
|
56
|
+
/**
|
|
57
|
+
* Set weight. Weight controls how many items from this group should be kept
|
|
58
|
+
* in relation to the entire window. For example if all groups have a weight
|
|
59
|
+
* of 1, each group remove items equally if full. If one has a weight of 2
|
|
60
|
+
* while the rest are 1, that group will be allowed to keep double the
|
|
61
|
+
* amount of items.
|
|
62
|
+
*/
|
|
63
|
+
setWeight(weight: number): this;
|
|
64
|
+
/** Recalculate all tokens. Note this may take a while. */
|
|
65
|
+
recalculateTokens(): void;
|
|
66
|
+
/** Add an item to the group */
|
|
67
|
+
add(item: string | TokenWindowGroupItemParams<DataType>): TokenWindowGroupItem<DataType>;
|
|
68
|
+
/** Get all items as a string */
|
|
69
|
+
getAllAsString(): string;
|
|
70
|
+
/** Get all items. Doesn't return disabled items. */
|
|
71
|
+
getAll(): TokenWindowGroupItem<DataType>[];
|
|
72
|
+
/** Remove all items from this group */
|
|
73
|
+
empty(): void;
|
|
74
|
+
}
|
|
75
|
+
/** Token group item section types */
|
|
76
|
+
declare enum TokenWindowGroupItemSectionType {
|
|
77
|
+
/** Text items represent plain text. */
|
|
78
|
+
Text = "text",
|
|
79
|
+
/** Tool call items represent a tool call requested by the AI. */
|
|
80
|
+
ToolCall = "tool_call",
|
|
81
|
+
/** Tool result items represent the result of a tool call. */
|
|
82
|
+
ToolResult = "tool_result",
|
|
83
|
+
/** Thinking section */
|
|
84
|
+
Thinking = "thinking",
|
|
85
|
+
/** Other item types */
|
|
86
|
+
Other = "other"
|
|
87
|
+
}
|
|
88
|
+
/** Token group item */
|
|
89
|
+
interface TokenWindowGroupItem<DataType> {
|
|
90
|
+
/** Each item must have a unique ID. */
|
|
91
|
+
id: string;
|
|
92
|
+
/** True if this item should never be removed */
|
|
93
|
+
cannotRemove?: boolean;
|
|
94
|
+
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
95
|
+
sortOrder: number;
|
|
96
|
+
/** Date this item was added */
|
|
97
|
+
dateAdded: number;
|
|
98
|
+
/** Token count in the content */
|
|
99
|
+
tokenCount: number;
|
|
100
|
+
/** This is the actual item that gets sent to the APIs. It will be in whatever format is required for the associated API. */
|
|
101
|
+
data?: DataType;
|
|
102
|
+
/** If disabled, this item will not be included and will not add to the token count. */
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
/** Message source, ie was this message created by the user, or by the AI? */
|
|
105
|
+
source: 'user' | 'assistant';
|
|
106
|
+
/**
|
|
107
|
+
* The string content of the item, or a summary of it. This is an autogenerated field, updated when the item is added/updated in the token window group.
|
|
108
|
+
* If `data` is a string, this will be the same as `data`. If `data` is more complex, this will be a text representation of all items in the `sections` array.
|
|
109
|
+
*
|
|
110
|
+
* Note: When the response contains text and tool calls, this will add in a summary of what's happening. For better displaying, use the `sections` array.
|
|
111
|
+
*/
|
|
112
|
+
text?: string;
|
|
113
|
+
/** Message sections */
|
|
114
|
+
sections?: TokenWindowGroupItemSection[];
|
|
115
|
+
/** If this message was generated by the AI, this contains the token usage for this message. */
|
|
116
|
+
usage?: {
|
|
117
|
+
/** Number of tokens consumed from the data passed to the AI */
|
|
118
|
+
inputTokens: number;
|
|
119
|
+
/** Number of input tokens that were used in token caching */
|
|
120
|
+
cachedInputTokens: number;
|
|
121
|
+
/** Number of tokens consumed by the AI generating output */
|
|
122
|
+
outputTokens: number;
|
|
123
|
+
/** Total token usage */
|
|
124
|
+
totalTokens: number;
|
|
125
|
+
};
|
|
126
|
+
/** True if this item is still being streamed */
|
|
127
|
+
streamingInProgress?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/** A section of a message returned by the AI */
|
|
130
|
+
interface TokenWindowGroupItemSection {
|
|
131
|
+
/** Section type */
|
|
132
|
+
type: TokenWindowGroupItemSectionType;
|
|
133
|
+
/** Text content when this section represents text or thinking */
|
|
134
|
+
text?: string;
|
|
135
|
+
/** The raw tool name the AI requested to be called. */
|
|
136
|
+
toolName?: string;
|
|
137
|
+
/** The ID of the KB action this tool call maps to, if any */
|
|
138
|
+
toolKbID?: string;
|
|
139
|
+
/** The name of the KB action this tool call maps to, if any */
|
|
140
|
+
toolKbName?: string;
|
|
141
|
+
/** The parameters the AI requested to be sent to the tool. Only available if type == 'tool_call' */
|
|
142
|
+
toolParameters?: any;
|
|
143
|
+
/** Successful response of the tool call. Will be null if toolErrorResponse is set. */
|
|
144
|
+
toolSuccessResponse?: any;
|
|
145
|
+
/** Error response of the tool call. Will be null if toolSuccessResponse is set. */
|
|
146
|
+
toolErrorResponse?: string;
|
|
147
|
+
/** Tool call ID. This can be used to match a tool call request with it's result. */
|
|
148
|
+
toolCallInstanceID?: string;
|
|
149
|
+
/** True if this tool call should be hidden in the UI */
|
|
150
|
+
toolCallHiddenInUI?: 'always' | 'after-complete';
|
|
151
|
+
}
|
|
152
|
+
/** Token window group item input, without the autogenerated fields */
|
|
153
|
+
type TokenWindowGroupItemParams<DataType> = Omit<Optional<TokenWindowGroupItem<DataType>, 'id' | 'dateAdded' | 'sortOrder' | 'text' | 'source' | 'sections'>, 'tokenCount'>;
|
|
154
|
+
|
|
8
155
|
/**
|
|
9
156
|
* Allows an MCP server to be used as a knowledge source for IntelliWeave.
|
|
10
157
|
*/
|
|
@@ -34,6 +181,17 @@ declare class MCPKnowledgeClient {
|
|
|
34
181
|
searchToolName?: string;
|
|
35
182
|
/** Keep search function available for the AI to use. */
|
|
36
183
|
searchToolVisible?: boolean;
|
|
184
|
+
/** Use the IntelliWeave proxy */
|
|
185
|
+
proxy?: {
|
|
186
|
+
/** If true, will send requests via the IntelliWeave MCP proxy */
|
|
187
|
+
enabled?: boolean;
|
|
188
|
+
/** The URL of the proxy server, defaults to the standard IntelliWeave proxy */
|
|
189
|
+
url?: string;
|
|
190
|
+
/** IntelliWeave API key */
|
|
191
|
+
apiKey?: string;
|
|
192
|
+
};
|
|
193
|
+
/** Pass extra headers to the MCP server */
|
|
194
|
+
headers?: Record<string, string>;
|
|
37
195
|
};
|
|
38
196
|
/** Constructor */
|
|
39
197
|
constructor(config: MCPKnowledgeClient['config']);
|
|
@@ -44,16 +202,10 @@ declare class MCPKnowledgeClient {
|
|
|
44
202
|
method: string;
|
|
45
203
|
params?: {
|
|
46
204
|
[x: string]: unknown;
|
|
47
|
-
task?: {
|
|
48
|
-
[x: string]: unknown;
|
|
49
|
-
ttl?: number | null | undefined;
|
|
50
|
-
pollInterval?: number | undefined;
|
|
51
|
-
} | undefined;
|
|
52
205
|
_meta?: {
|
|
53
206
|
[x: string]: unknown;
|
|
54
207
|
progressToken?: string | number | undefined;
|
|
55
208
|
"io.modelcontextprotocol/related-task"?: {
|
|
56
|
-
[x: string]: unknown;
|
|
57
209
|
taskId: string;
|
|
58
210
|
} | undefined;
|
|
59
211
|
} | undefined;
|
|
@@ -64,8 +216,8 @@ declare class MCPKnowledgeClient {
|
|
|
64
216
|
[x: string]: unknown;
|
|
65
217
|
_meta?: {
|
|
66
218
|
[x: string]: unknown;
|
|
219
|
+
progressToken?: string | number | undefined;
|
|
67
220
|
"io.modelcontextprotocol/related-task"?: {
|
|
68
|
-
[x: string]: unknown;
|
|
69
221
|
taskId: string;
|
|
70
222
|
} | undefined;
|
|
71
223
|
} | undefined;
|
|
@@ -74,8 +226,8 @@ declare class MCPKnowledgeClient {
|
|
|
74
226
|
[x: string]: unknown;
|
|
75
227
|
_meta?: {
|
|
76
228
|
[x: string]: unknown;
|
|
229
|
+
progressToken?: string | number | undefined;
|
|
77
230
|
"io.modelcontextprotocol/related-task"?: {
|
|
78
|
-
[x: string]: unknown;
|
|
79
231
|
taskId: string;
|
|
80
232
|
} | undefined;
|
|
81
233
|
} | undefined;
|
|
@@ -84,16 +236,10 @@ declare class MCPKnowledgeClient {
|
|
|
84
236
|
method: string;
|
|
85
237
|
params?: {
|
|
86
238
|
[x: string]: unknown;
|
|
87
|
-
task?: {
|
|
88
|
-
[x: string]: unknown;
|
|
89
|
-
ttl?: number | null | undefined;
|
|
90
|
-
pollInterval?: number | undefined;
|
|
91
|
-
} | undefined;
|
|
92
239
|
_meta?: {
|
|
93
240
|
[x: string]: unknown;
|
|
94
241
|
progressToken?: string | number | undefined;
|
|
95
242
|
"io.modelcontextprotocol/related-task"?: {
|
|
96
|
-
[x: string]: unknown;
|
|
97
243
|
taskId: string;
|
|
98
244
|
} | undefined;
|
|
99
245
|
} | undefined;
|
|
@@ -104,8 +250,8 @@ declare class MCPKnowledgeClient {
|
|
|
104
250
|
[x: string]: unknown;
|
|
105
251
|
_meta?: {
|
|
106
252
|
[x: string]: unknown;
|
|
253
|
+
progressToken?: string | number | undefined;
|
|
107
254
|
"io.modelcontextprotocol/related-task"?: {
|
|
108
|
-
[x: string]: unknown;
|
|
109
255
|
taskId: string;
|
|
110
256
|
} | undefined;
|
|
111
257
|
} | undefined;
|
|
@@ -114,8 +260,8 @@ declare class MCPKnowledgeClient {
|
|
|
114
260
|
[x: string]: unknown;
|
|
115
261
|
_meta?: {
|
|
116
262
|
[x: string]: unknown;
|
|
263
|
+
progressToken?: string | number | undefined;
|
|
117
264
|
"io.modelcontextprotocol/related-task"?: {
|
|
118
|
-
[x: string]: unknown;
|
|
119
265
|
taskId: string;
|
|
120
266
|
} | undefined;
|
|
121
267
|
} | undefined;
|
|
@@ -316,8 +462,16 @@ declare class KnowledgeBase {
|
|
|
316
462
|
lastResults: KnowledgeBaseItem[];
|
|
317
463
|
/** Individual knowledge base entries added manually by the application */
|
|
318
464
|
manualEntries: KnowledgeBaseItem[];
|
|
465
|
+
/** If true, allows using globally defined sources from the browser window events */
|
|
466
|
+
allowWindowSources: boolean;
|
|
467
|
+
/** If true, allows using knowledge specified in the global configuration object */
|
|
468
|
+
allowGlobalConfigSources: boolean;
|
|
319
469
|
/** Constructor */
|
|
320
470
|
constructor(ai: IntelliWeave);
|
|
471
|
+
/** Ensures the internal knowledge is set correctly */
|
|
472
|
+
ensureInternalKnowledge(): void;
|
|
473
|
+
/** Clears all knowledge back to the default */
|
|
474
|
+
reset(): void;
|
|
321
475
|
/**
|
|
322
476
|
* Register a new knowledge base source. You can pass either just a query function, or an ID and a query function.
|
|
323
477
|
*
|
|
@@ -381,12 +535,12 @@ interface KnowledgeBaseItem {
|
|
|
381
535
|
name: string;
|
|
382
536
|
/** Item tags. Helps with search optimization. */
|
|
383
537
|
tags?: string;
|
|
384
|
-
/** Item content
|
|
385
|
-
content: string
|
|
538
|
+
/** Item content */
|
|
539
|
+
content: string;
|
|
386
540
|
/** If true, this item will always be returned from all search results. */
|
|
387
541
|
isContext?: boolean;
|
|
388
542
|
/** If true, this item will not be visible to the AI. */
|
|
389
|
-
disabled?: boolean;
|
|
543
|
+
disabled?: boolean | ((ai: IntelliWeave) => boolean);
|
|
390
544
|
/** List of parameters for an action function. Can either use IW's format, or a JSON Schema object. */
|
|
391
545
|
parameters?: KnowledgeBaseActionParameterSchema;
|
|
392
546
|
/**
|
|
@@ -395,8 +549,27 @@ interface KnowledgeBaseItem {
|
|
|
395
549
|
* that was performed. If an error is thrown, the AI will respond appropriately to the user.
|
|
396
550
|
*/
|
|
397
551
|
action?: (input: any, ai: IntelliWeave) => (any | Promise<any>);
|
|
398
|
-
/** If
|
|
399
|
-
|
|
552
|
+
/** If specified, will hide this action from the default UI after the AI finishes running it, or always hide it */
|
|
553
|
+
hideActionInUI?: 'always' | 'after-complete';
|
|
554
|
+
/** Attachments such as images, etc */
|
|
555
|
+
attachments?: KnowledgeBaseItemAttachment[];
|
|
556
|
+
}
|
|
557
|
+
/** Knowledge base item attachment, such as an image, file, etc. */
|
|
558
|
+
interface KnowledgeBaseItemAttachment {
|
|
559
|
+
/** UUID */
|
|
560
|
+
uuid: string;
|
|
561
|
+
/** Attachment mime type */
|
|
562
|
+
mimeType: string;
|
|
563
|
+
/** File name */
|
|
564
|
+
name: string;
|
|
565
|
+
/** Full URL to access the file. This is required for the AI to be able to see the attachment. */
|
|
566
|
+
url?: string;
|
|
567
|
+
/** UNIX timestamp (milliseconds since epoch) when the file was added */
|
|
568
|
+
dateAdded?: number;
|
|
569
|
+
/** Internal path to where the file is stored */
|
|
570
|
+
path?: string;
|
|
571
|
+
/** File size */
|
|
572
|
+
size?: number;
|
|
400
573
|
}
|
|
401
574
|
/** Parameter definition used by IntelliWeave */
|
|
402
575
|
interface IntelliWeaveParameterDefinition {
|
|
@@ -504,84 +677,6 @@ interface IntelliWeaveInstructConfig {
|
|
|
504
677
|
callback?: (txt: string) => void;
|
|
505
678
|
}
|
|
506
679
|
|
|
507
|
-
/**
|
|
508
|
-
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
509
|
-
*/
|
|
510
|
-
declare class TokenWindow {
|
|
511
|
-
/** Token window size */
|
|
512
|
-
size: number;
|
|
513
|
-
/** Token groups */
|
|
514
|
-
groups: TokenWindowGroup<any>[];
|
|
515
|
-
/** Create a new group */
|
|
516
|
-
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
517
|
-
/** Get a group */
|
|
518
|
-
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
519
|
-
/** Calculate current tokens in all groups */
|
|
520
|
-
countTokens(): number;
|
|
521
|
-
/** Remove overflow from all groups. */
|
|
522
|
-
removeOverflow(): void;
|
|
523
|
-
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
524
|
-
private removeOneItem;
|
|
525
|
-
}
|
|
526
|
-
/** A token group. */
|
|
527
|
-
declare class TokenWindowGroup<CustomDataType> {
|
|
528
|
-
/** Group ID */
|
|
529
|
-
id: string;
|
|
530
|
-
/** List of items */
|
|
531
|
-
items: TokenWindowGroupItem<CustomDataType>[];
|
|
532
|
-
/**
|
|
533
|
-
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
534
|
-
* groups have a weight of 1, each group remove items equally if full. If one has a weight of 2 while the rest are 1,
|
|
535
|
-
* that group will be allowed to keep double the amount of items.
|
|
536
|
-
*/
|
|
537
|
-
weight: number;
|
|
538
|
-
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
539
|
-
tokenCount: number;
|
|
540
|
-
/** Group item separator */
|
|
541
|
-
separator: string;
|
|
542
|
-
/** Token count padding added to each item. */
|
|
543
|
-
private itemPadding;
|
|
544
|
-
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
545
|
-
setItemPadding(padding: number): this;
|
|
546
|
-
/** Sort function */
|
|
547
|
-
private sortFunction;
|
|
548
|
-
/** Set sort function */
|
|
549
|
-
sortBy(sortFunction: (a: TokenWindowGroupItem<CustomDataType>, b: TokenWindowGroupItem<CustomDataType>) => number): this;
|
|
550
|
-
/** Set separator */
|
|
551
|
-
setSeparator(separator: string): this;
|
|
552
|
-
/** Set weight */
|
|
553
|
-
setWeight(weight: number): this;
|
|
554
|
-
/** Recalculate all tokens. Note this may take a while. */
|
|
555
|
-
recalculateTokens(): void;
|
|
556
|
-
/** Add an item to the group */
|
|
557
|
-
add(item: string | Omit<Optional<TokenWindowGroupItem<CustomDataType>, 'id' | 'dateAdded' | 'sortOrder'>, 'tokenCount'>): TokenWindowGroupItem<CustomDataType>;
|
|
558
|
-
/** Get all items as a string */
|
|
559
|
-
getAllAsString(): string;
|
|
560
|
-
/** Get all items. Doesn't return disabled items. */
|
|
561
|
-
getAll(): TokenWindowGroupItem<CustomDataType>[];
|
|
562
|
-
/** Remove all items from this group */
|
|
563
|
-
empty(): void;
|
|
564
|
-
}
|
|
565
|
-
/** Token group item */
|
|
566
|
-
interface TokenWindowGroupItem<CustomDataType> {
|
|
567
|
-
/** Each item must have a unique ID. */
|
|
568
|
-
id: string;
|
|
569
|
-
/** The string content of the item */
|
|
570
|
-
content: string;
|
|
571
|
-
/** True if this item should never be removed */
|
|
572
|
-
cannotRemove?: boolean;
|
|
573
|
-
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
574
|
-
sortOrder: number;
|
|
575
|
-
/** Date this item was added */
|
|
576
|
-
dateAdded: number;
|
|
577
|
-
/** Token count in the content */
|
|
578
|
-
tokenCount: number;
|
|
579
|
-
/** Anything to attach to this item */
|
|
580
|
-
customData?: CustomDataType;
|
|
581
|
-
/** If disabled, this item will not be included and will not add tot he token count. */
|
|
582
|
-
disabled?: boolean;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
680
|
/** Chat config options */
|
|
586
681
|
interface ChatBaseConfig {
|
|
587
682
|
/** API key */
|
|
@@ -602,8 +697,8 @@ interface ChatBaseConfig {
|
|
|
602
697
|
maxTokens: number;
|
|
603
698
|
/** Callback before the AI sends info to the LLM */
|
|
604
699
|
onBeforeMessageProcessing?: () => void;
|
|
605
|
-
/** Callback when a message from the AI is returned. If
|
|
606
|
-
onAIMessage?: (
|
|
700
|
+
/** Callback when a message from the AI is returned. If isPartial is true, it may be incomplete and be called again with more updates. */
|
|
701
|
+
onAIMessage?: (output: TokenWindowGroupItemParams<any>[], isPartial: boolean) => void;
|
|
607
702
|
/** Callback when the AI starts performing an action */
|
|
608
703
|
onAIToolStart?: (toolName: string, input: any) => void;
|
|
609
704
|
}
|
|
@@ -617,19 +712,17 @@ interface ChatBaseToolConfig {
|
|
|
617
712
|
params: JSONSchema7;
|
|
618
713
|
/** Callback function to process the tool */
|
|
619
714
|
callback: (params: any) => any;
|
|
620
|
-
/** If true, this tool call will be removed from the message history after it is executed. */
|
|
621
|
-
removeFromMessageHistory?: boolean;
|
|
622
715
|
/** If true, this item can be removed if there's not enough context available. */
|
|
623
716
|
canRemove?: boolean;
|
|
624
|
-
/**
|
|
625
|
-
|
|
717
|
+
/** Knowledge base item this tool use represents */
|
|
718
|
+
kbItem?: KnowledgeBaseItem;
|
|
626
719
|
}
|
|
627
720
|
/**
|
|
628
721
|
* API for interacting with chat APIs.
|
|
629
722
|
*/
|
|
630
723
|
declare class ChatBase<
|
|
631
724
|
/** Format for messages in the token window */
|
|
632
|
-
|
|
725
|
+
DataType = any,
|
|
633
726
|
/** Optional extended config */
|
|
634
727
|
ConfigFormat extends ChatBaseConfig = ChatBaseConfig> {
|
|
635
728
|
/** ID */
|
|
@@ -648,27 +741,95 @@ ConfigFormat extends ChatBaseConfig = ChatBaseConfig> {
|
|
|
648
741
|
/** Token window management */
|
|
649
742
|
tokenWindow: TokenWindow;
|
|
650
743
|
/** Token window group used for the context message */
|
|
651
|
-
get contextGroup(): TokenWindowGroup<
|
|
744
|
+
get contextGroup(): TokenWindowGroup<string>;
|
|
652
745
|
/** Token window group used for tools / actions */
|
|
653
746
|
get toolGroup(): TokenWindowGroup<ChatBaseToolConfig>;
|
|
654
747
|
/** Token window group used for messages */
|
|
655
|
-
get messageGroup(): TokenWindowGroup<
|
|
748
|
+
get messageGroup(): TokenWindowGroup<DataType>;
|
|
749
|
+
/** Get the API base after stripping out exact endpoints, or undefined for the default */
|
|
750
|
+
getBaseURL(): string | undefined;
|
|
656
751
|
/** Constructor */
|
|
657
752
|
constructor(config: ConfigFormat);
|
|
658
|
-
/** Send a message, and get the response */
|
|
659
|
-
sendMessage(message: string): Promise<
|
|
753
|
+
/** Send a message, and get the response as a string. */
|
|
754
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
660
755
|
/** Add a user message to the message history */
|
|
661
756
|
addUserMessage(message: string): void;
|
|
662
757
|
/** Add an assistant message to the message history */
|
|
663
758
|
addAssistantMessage(message: string): void;
|
|
759
|
+
/** Helper to add a plain text item */
|
|
760
|
+
protected addTextMessage(text: string, source: 'user' | 'assistant', data: DataType): void;
|
|
664
761
|
/** Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
665
|
-
onBeforeIncomingMessage(message:
|
|
762
|
+
onBeforeIncomingMessage(message: DataType): void;
|
|
666
763
|
/** Reset the conversation */
|
|
667
764
|
resetConversation(): void;
|
|
668
765
|
/** Trim message list */
|
|
669
766
|
trimMessages(): Promise<void>;
|
|
670
767
|
/** Register a tool. */
|
|
671
768
|
registerTool(tool: ChatBaseToolConfig): TokenWindowGroupItem<ChatBaseToolConfig>;
|
|
769
|
+
/** Find a tool based on the AI-safe name */
|
|
770
|
+
protected findToolBySafeName(toolSafeName: string): ChatBaseToolConfig | undefined;
|
|
771
|
+
/** Execute the specified tool. Throws an error if the tool is undefined. */
|
|
772
|
+
protected executeTool(tool: ChatBaseToolConfig | undefined, input: any): Promise<string>;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/** Parses the response from `IntelliWeave.sendMessage()` or a collection of message items. */
|
|
776
|
+
declare class IntelliWeaveMessageParser {
|
|
777
|
+
/** New messages produced after sendMessage() was called */
|
|
778
|
+
messages: TokenWindowGroupItemParams<unknown>[];
|
|
779
|
+
/** Constructor */
|
|
780
|
+
constructor(items: TokenWindowGroupItemParams<unknown>[]);
|
|
781
|
+
/** Plain text output from the AI */
|
|
782
|
+
text(): string;
|
|
783
|
+
/** Total token usage */
|
|
784
|
+
tokenUsage(): {
|
|
785
|
+
cachedInputTokens: number;
|
|
786
|
+
inputTokens: number;
|
|
787
|
+
outputTokens: number;
|
|
788
|
+
totalTokens: number;
|
|
789
|
+
};
|
|
790
|
+
/** Component sections for display */
|
|
791
|
+
sections(): TokenWindowGroupItemParams<unknown>['sections'];
|
|
792
|
+
/** List all tool calls that took place */
|
|
793
|
+
toolCalls(): TokenWindowGroupItemSection[];
|
|
794
|
+
/** Find the response for a tool call */
|
|
795
|
+
toolResult(toolCallInstanceID: string): TokenWindowGroupItemSection | null;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** Handles subagents. This allows your Persona to use other Personas as tools. */
|
|
799
|
+
declare class SubAgents {
|
|
800
|
+
/** Reference to the main IntelliWeave instance */
|
|
801
|
+
ai: IntelliWeave;
|
|
802
|
+
/** Constructor */
|
|
803
|
+
constructor(ai: IntelliWeave);
|
|
804
|
+
/** Subagents */
|
|
805
|
+
subagents: SubAgentConfig[];
|
|
806
|
+
/** Cached subagents */
|
|
807
|
+
cachedSubagents: Record<string, IntelliWeave>;
|
|
808
|
+
/** Register a sub-agent */
|
|
809
|
+
register(config: SubAgentConfig): void;
|
|
810
|
+
/** Unregister subagent */
|
|
811
|
+
remove(id: string): void;
|
|
812
|
+
/** Run the subagent */
|
|
813
|
+
runQuery(config: SubAgentConfig, query: string): Promise<string>;
|
|
814
|
+
}
|
|
815
|
+
/** Sub-agent config */
|
|
816
|
+
interface SubAgentConfig {
|
|
817
|
+
/** ID of the sub-agent */
|
|
818
|
+
id: string;
|
|
819
|
+
/** API key for the persona. If not specified, uses the same api key as the main agent. */
|
|
820
|
+
apiKey?: string;
|
|
821
|
+
/** Name of the sub-agent */
|
|
822
|
+
name?: string;
|
|
823
|
+
/** Instructions for the main agent to use this sub agent */
|
|
824
|
+
usageInstructions?: string;
|
|
825
|
+
/** If true, will remove all Persona knowledge entries */
|
|
826
|
+
clearExistingKnowledge?: boolean;
|
|
827
|
+
/** Extra knowledge base sources for the sub-agent */
|
|
828
|
+
knowledge?: KnowledgeFetcher;
|
|
829
|
+
/** Optional extra configuration for the subagent instance */
|
|
830
|
+
config?: Partial<WebWeaverGPTConfig>;
|
|
831
|
+
/** Called when the subagent is loaded */
|
|
832
|
+
onAgentLoaded?: (agent: IntelliWeave) => Promise<void> | void;
|
|
672
833
|
}
|
|
673
834
|
|
|
674
835
|
/** Built-in action flags for the persona */
|
|
@@ -708,6 +869,8 @@ interface WebWeaverGPTConfig {
|
|
|
708
869
|
textColor?: string;
|
|
709
870
|
/** Display mode: 'closed' (default - starts minimized) or 'open' (always open) */
|
|
710
871
|
displayMode?: 'closed' | 'open';
|
|
872
|
+
/** Layout preset: 'widget' (default) or 'fullscreen' */
|
|
873
|
+
layout?: 'widget' | 'fullscreen';
|
|
711
874
|
/** Positioning mode: 'fixed' (default - floats on page) or 'container' (fills parent container) */
|
|
712
875
|
positioningMode?: 'fixed' | 'container';
|
|
713
876
|
/** Horizontal position: 'left' or 'right' (default: 'right') - only used when positioningMode is 'fixed' */
|
|
@@ -718,6 +881,8 @@ interface WebWeaverGPTConfig {
|
|
|
718
881
|
offsetX?: number;
|
|
719
882
|
/** Vertical offset from edge in pixels (default: 20) - only used when positioningMode is 'fixed' */
|
|
720
883
|
offsetY?: number;
|
|
884
|
+
/** Identifier of an external app or service which manages this persona, if any. (eg. "chatterly") */
|
|
885
|
+
managedBy?: string;
|
|
721
886
|
/** Voice information */
|
|
722
887
|
voice?: {
|
|
723
888
|
/** Provider ID */
|
|
@@ -742,6 +907,10 @@ interface WebWeaverGPTConfig {
|
|
|
742
907
|
mcpServers?: MCPKnowledgeClient['config'][];
|
|
743
908
|
/** Built-in action flags that are currently enabled */
|
|
744
909
|
flags?: BuiltInActionFlags;
|
|
910
|
+
/** Allow custom chat provider */
|
|
911
|
+
onCreateProvider?: (config: ChatBaseConfig) => ChatBase;
|
|
912
|
+
/** Subagents */
|
|
913
|
+
subagents?: SubAgentConfig[];
|
|
745
914
|
}
|
|
746
915
|
/**
|
|
747
916
|
* IntelliWeave interface, loads a Persona from the hub and allows you to interact with it. This is the main entry point into the IntelliWeave
|
|
@@ -752,7 +921,7 @@ interface WebWeaverGPTConfig {
|
|
|
752
921
|
* - event `webweaver_loaded` - Fired when the AI is loaded with a new configuration. This is a global event that is fired on the window object.
|
|
753
922
|
* - event `webweaver_error` - Fired when an error occurs during loading. This is a global event that is fired on the window object.
|
|
754
923
|
* - event `input` - Fired when the user sends a message to the AI.
|
|
755
|
-
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.
|
|
924
|
+
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.isPartial` is true, the message is incomplete and will be followed by more events.
|
|
756
925
|
* - event `toolstart` - Fired when the AI starts performing an action.
|
|
757
926
|
* - event `tool` - Fired when the AI finishes performing an action.
|
|
758
927
|
*/
|
|
@@ -761,14 +930,16 @@ declare class IntelliWeave extends EventTarget {
|
|
|
761
930
|
static version: string;
|
|
762
931
|
/** Built-in actions version - increment this when adding new actions */
|
|
763
932
|
static builtInActionsVersion: string;
|
|
764
|
-
/** Callback when a message from the AI is returned. If
|
|
765
|
-
onAIMessage?: (
|
|
933
|
+
/** Callback when a message from the AI is returned. If isPartial is true, it may be incomplete and be called again with more updates. */
|
|
934
|
+
onAIMessage?: (messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean) => void;
|
|
766
935
|
/** Callback when the AI starts performing an action */
|
|
767
936
|
onAIToolStart?: ChatBaseConfig['onAIToolStart'];
|
|
768
937
|
/** Current conversation ID */
|
|
769
938
|
conversationID: string;
|
|
770
939
|
/** Knowledge database interface */
|
|
771
940
|
knowledgeBase: KnowledgeBase;
|
|
941
|
+
/** Subagent interface */
|
|
942
|
+
subAgents: SubAgents;
|
|
772
943
|
/** Last KB search that was performed */
|
|
773
944
|
private _lastKBsearch;
|
|
774
945
|
/** If set, the next time a request is made this is the KB result items that will be used, once-off. */
|
|
@@ -812,7 +983,7 @@ declare class IntelliWeave extends EventTarget {
|
|
|
812
983
|
/** URL of the IntelliWeave Hub API */
|
|
813
984
|
hubAPI: string;
|
|
814
985
|
/** Set model and load data from an API key */
|
|
815
|
-
load(apiKey: string): Promise<
|
|
986
|
+
load(apiKey: string, config?: Partial<WebWeaverGPTConfig>): Promise<IntelliWeave>;
|
|
816
987
|
/** Set the current model */
|
|
817
988
|
setModel(id: string): void;
|
|
818
989
|
private _lastSystemMsg;
|
|
@@ -820,18 +991,19 @@ declare class IntelliWeave extends EventTarget {
|
|
|
820
991
|
getContextPrefix(): Promise<string>;
|
|
821
992
|
/** Get system message to send to the AI */
|
|
822
993
|
onBeforeMessageProcessing(): Promise<void>;
|
|
823
|
-
/** @private Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
824
|
-
processIncomingMessage(
|
|
994
|
+
/** @private Process incoming message(s) from the AI. Can be used to respond to encoded actions in the text response. */
|
|
995
|
+
processIncomingMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial?: boolean): void;
|
|
825
996
|
/** True if currently processing a message */
|
|
826
997
|
isProcessing: boolean;
|
|
827
|
-
/** @private Last tracked token count for calculating per-message token usage */
|
|
828
|
-
private _lastTrackedTokens;
|
|
829
998
|
/** Send a message, and get the response */
|
|
830
|
-
sendMessage(message: string): Promise<
|
|
999
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<unknown>[]) => void): Promise<IntelliWeaveMessageParser>;
|
|
831
1000
|
/** @private Called when the AI wants to run a KB action */
|
|
832
1001
|
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
833
|
-
/** Submit an analytics event asynchronously */
|
|
1002
|
+
/** Submit an analytics event asynchronously. These events are for use in the Conversation Analytics code. For anonymous statistic analysis, use track() instead. */
|
|
1003
|
+
private activeAnalyticsPromises;
|
|
834
1004
|
submitAnalyticsEvent(data: any): void;
|
|
1005
|
+
/** Wait for all analytics events to finish */
|
|
1006
|
+
waitForAnalytics(): Promise<void>;
|
|
835
1007
|
/** Reset the conversation */
|
|
836
1008
|
resetConversation(): void;
|
|
837
1009
|
/** Insert a message as if the assistant has written it */
|
|
@@ -840,12 +1012,14 @@ declare class IntelliWeave extends EventTarget {
|
|
|
840
1012
|
exportState(): {
|
|
841
1013
|
type: string;
|
|
842
1014
|
conversationID: string;
|
|
843
|
-
messages: any[] | undefined;
|
|
1015
|
+
messages: TokenWindowGroupItem<any>[] | undefined;
|
|
844
1016
|
};
|
|
845
1017
|
/** Import conversation state from JSON */
|
|
846
1018
|
importState(state: any): void;
|
|
847
1019
|
/** Clone this instance without any message history */
|
|
848
1020
|
clone(): IntelliWeave;
|
|
1021
|
+
/** Get all messages in the conversation history */
|
|
1022
|
+
get messages(): TokenWindowGroupItem<any>[];
|
|
849
1023
|
}
|
|
850
1024
|
|
|
851
1025
|
/**
|
|
@@ -858,10 +1032,16 @@ declare class IntelliWeave extends EventTarget {
|
|
|
858
1032
|
declare class WebWeaverSpeechOutput extends EventTarget {
|
|
859
1033
|
/** Reference to the AI */
|
|
860
1034
|
private ai?;
|
|
1035
|
+
/** Automatically speak output from the AI */
|
|
1036
|
+
autoSpeak: boolean;
|
|
1037
|
+
/** If enabled, connections will be pre-emptively opened to speed up text-to-speech response times, if possible */
|
|
1038
|
+
preemptiveConnection: boolean;
|
|
861
1039
|
/** Constructor */
|
|
862
1040
|
constructor(ai: IntelliWeave);
|
|
863
|
-
/**
|
|
864
|
-
|
|
1041
|
+
/** Message IDs we've processed */
|
|
1042
|
+
private processedMessages;
|
|
1043
|
+
/** Called when the AI responds */
|
|
1044
|
+
onOutputFromAI(e: CustomEvent): void;
|
|
865
1045
|
/** Current player vars */
|
|
866
1046
|
private currentPlayerVolume?;
|
|
867
1047
|
private currentPlayer?;
|
|
@@ -873,8 +1053,15 @@ declare class WebWeaverSpeechOutput extends EventTarget {
|
|
|
873
1053
|
private maxVolumeHeard;
|
|
874
1054
|
/** Get current (realtime) audio output volume level, from 0 to 1 */
|
|
875
1055
|
get volumeLevel(): number;
|
|
1056
|
+
/** Queued messages to speak next */
|
|
1057
|
+
private _queuedText;
|
|
876
1058
|
/** Speak the text */
|
|
877
1059
|
speak(text: string): Promise<void>;
|
|
1060
|
+
private _queueActive;
|
|
1061
|
+
_runQueue(): Promise<void>;
|
|
1062
|
+
/** ElevenLabs connection pre-cache */
|
|
1063
|
+
private _elevenLabsPrecachedConnection?;
|
|
1064
|
+
private _getElevenLabsConnection;
|
|
878
1065
|
private _speakWithLock;
|
|
879
1066
|
/** True if currently playing audio */
|
|
880
1067
|
get isSpeaking(): boolean;
|
|
@@ -1017,7 +1204,7 @@ declare class IntelliWeaveTranscriptionNode extends VoiceChunkOutputNode {
|
|
|
1017
1204
|
static debugExportWav: boolean;
|
|
1018
1205
|
/** Server address for transcription */
|
|
1019
1206
|
apiAddress: string;
|
|
1020
|
-
/**
|
|
1207
|
+
/** IntelliWeave API key */
|
|
1021
1208
|
apiKey: string;
|
|
1022
1209
|
/** WebSocket connection */
|
|
1023
1210
|
private ws?;
|
|
@@ -1037,6 +1224,32 @@ declare class IntelliWeaveTranscriptionNode extends VoiceChunkOutputNode {
|
|
|
1037
1224
|
onSocketClose(): void;
|
|
1038
1225
|
}
|
|
1039
1226
|
|
|
1227
|
+
/**
|
|
1228
|
+
* This AudioNode uses ElevenLabs to transcribe spoken speech to text.
|
|
1229
|
+
*
|
|
1230
|
+
* - event `transcription` - Fired when a transcription is ready. `text` contains the transcribed text.
|
|
1231
|
+
*/
|
|
1232
|
+
declare class ElevenLabsTranscriptionNode extends VoiceChunkOutputNode {
|
|
1233
|
+
/** ElevenLabs API key */
|
|
1234
|
+
apiKey: string;
|
|
1235
|
+
/** ElevenLabs stream connection */
|
|
1236
|
+
private connection?;
|
|
1237
|
+
/** True if currently transcribing */
|
|
1238
|
+
isTranscribing: boolean;
|
|
1239
|
+
/** WebSocket shutdown timer */
|
|
1240
|
+
private shutdownTimer?;
|
|
1241
|
+
/** Constructor */
|
|
1242
|
+
constructor(audioContext: AudioContext, apiKey: string);
|
|
1243
|
+
/** Called when a voice chunk is received */
|
|
1244
|
+
onVoiceChunk(buffer: Float32Array): Promise<void>;
|
|
1245
|
+
/** Start reading the stream */
|
|
1246
|
+
private startReading;
|
|
1247
|
+
/** Called when the voice recording ends */
|
|
1248
|
+
onVoiceEnd(buffers: Float32Array[]): Promise<void>;
|
|
1249
|
+
/** Called when a transcription is ready */
|
|
1250
|
+
onVoiceTranscription(text: string): void;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1040
1253
|
/**
|
|
1041
1254
|
* Handles speech recognition from the microphone
|
|
1042
1255
|
*
|
|
@@ -1062,7 +1275,7 @@ declare class WebWeaverSpeechRecognition extends EventTarget {
|
|
|
1062
1275
|
/** Returns true if speech recognition is supported by this persona and browser */
|
|
1063
1276
|
get isSupported(): boolean;
|
|
1064
1277
|
/** Currently active voice detection node */
|
|
1065
|
-
voiceDetection?: IntelliWeaveTranscriptionNode | OpenAITranscriptionNode;
|
|
1278
|
+
voiceDetection?: IntelliWeaveTranscriptionNode | OpenAITranscriptionNode | ElevenLabsTranscriptionNode;
|
|
1066
1279
|
/** Constructor */
|
|
1067
1280
|
constructor(ai: IntelliWeave);
|
|
1068
1281
|
private _skipEvents;
|
|
@@ -1144,6 +1357,43 @@ declare class PCMPlayerNode extends AudioWorkletNode {
|
|
|
1144
1357
|
stop(): void;
|
|
1145
1358
|
}
|
|
1146
1359
|
|
|
1360
|
+
/** Return value of createElevenLabsTextToSpeechStream() */
|
|
1361
|
+
interface ElevenLabsTextToSpeechStream {
|
|
1362
|
+
/** Audio data output stream */
|
|
1363
|
+
stream: ReadableStream<Uint8Array>;
|
|
1364
|
+
/** Function to send text to be spoken */
|
|
1365
|
+
sendText: (text: string) => void;
|
|
1366
|
+
/** Function to signal there will be no more text */
|
|
1367
|
+
endText: () => void;
|
|
1368
|
+
/** True if this connection is closed */
|
|
1369
|
+
isClosed?: boolean;
|
|
1370
|
+
}
|
|
1371
|
+
/** This creates a two-way connection to ElevenLabs that allows for realtime text upload and realtime speech download. */
|
|
1372
|
+
declare function createElevenLabsTextToSpeechStream(apiKey: string, voiceID: string, format?: string): ElevenLabsTextToSpeechStream;
|
|
1373
|
+
/** Return value of createElevenLabsSpeechToTextStream() */
|
|
1374
|
+
interface ElevenLabsSpeechToTextStream {
|
|
1375
|
+
/** Audio data output stream */
|
|
1376
|
+
stream: ReadableStream<string>;
|
|
1377
|
+
/** Function to send audio to be processed */
|
|
1378
|
+
sendAudio: (audio: ArrayBuffer) => void;
|
|
1379
|
+
/** Function to signal speech has stopped. Only necessary if commitStrategy is 'manual' */
|
|
1380
|
+
commit: () => void;
|
|
1381
|
+
/** Function to close the connection */
|
|
1382
|
+
close: () => void;
|
|
1383
|
+
/** True if this connection is closed */
|
|
1384
|
+
isClosed?: boolean;
|
|
1385
|
+
}
|
|
1386
|
+
/** This creates a two-way connection to ElevenLabs that allows for realtime speech upload and text download. */
|
|
1387
|
+
declare function createElevenLabsSpeechToTextStream(
|
|
1388
|
+
/** ElevenLabs API key */
|
|
1389
|
+
apiKey: string,
|
|
1390
|
+
/** Format the audio data you're passing is in */
|
|
1391
|
+
inputAudioFormat?: string,
|
|
1392
|
+
/** Input audio sample rate */
|
|
1393
|
+
sampleRate?: number,
|
|
1394
|
+
/** Should ElevenLabs detect speech end, or will you call commit() manually */
|
|
1395
|
+
commitStrategy?: 'manual' | 'vad'): ElevenLabsSpeechToTextStream;
|
|
1396
|
+
|
|
1147
1397
|
/**
|
|
1148
1398
|
* This is a utility class for dealing with the ONNX runtime and model loading.
|
|
1149
1399
|
*/
|
|
@@ -1609,11 +1859,18 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1609
1859
|
private _lastBackground?;
|
|
1610
1860
|
private _lastTextColor?;
|
|
1611
1861
|
private _lastDisplayMode?;
|
|
1862
|
+
private _lastLayout?;
|
|
1863
|
+
private _lastPersonaName?;
|
|
1864
|
+
private _lastHeaderLogo?;
|
|
1612
1865
|
private _lastPositioningMode?;
|
|
1613
1866
|
private _lastPositionX?;
|
|
1614
1867
|
private _lastPositionY?;
|
|
1615
1868
|
private _lastOffsetX?;
|
|
1616
1869
|
private _lastOffsetY?;
|
|
1870
|
+
/** Apply persona-based color variants as CSS variables */
|
|
1871
|
+
private applyPersonaColorVariants;
|
|
1872
|
+
/** Parse a color string to RGB (supports hex and rgb/rgba) */
|
|
1873
|
+
private parseColorToRGB;
|
|
1617
1874
|
/** Apply UI styles from config and attributes, prioritizing attributes */
|
|
1618
1875
|
private applyConfigStylesAndAttributes;
|
|
1619
1876
|
/** Called on update */
|
|
@@ -1637,13 +1894,19 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1637
1894
|
/** Process input text from the user */
|
|
1638
1895
|
processInput(inputText: string): Promise<void>;
|
|
1639
1896
|
/** Called when the AI responds with some text */
|
|
1640
|
-
onAIMessage(
|
|
1641
|
-
/**
|
|
1642
|
-
|
|
1897
|
+
onAIMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean): Promise<void>;
|
|
1898
|
+
/** Updates a text element */
|
|
1899
|
+
updateTextElement(elementID: string, text: string): void;
|
|
1900
|
+
/** Updates an info block element */
|
|
1901
|
+
updateInfoElement(elementID: string, text: string, iconType: string): void;
|
|
1643
1902
|
/** Called when a suggestion button is clicked */
|
|
1644
1903
|
onSuggestionClick(e: Event, suggestion: string): void;
|
|
1645
1904
|
/** Called when an LLM model is selected */
|
|
1646
1905
|
onLLMModelSelect(e: CustomEvent): void;
|
|
1906
|
+
/** Called when the content area is scrolled */
|
|
1907
|
+
onContentScroll(e: Event): void;
|
|
1908
|
+
/** Displays whitelabeled branding for known apps */
|
|
1909
|
+
private updateBrandingFor;
|
|
1647
1910
|
}
|
|
1648
1911
|
|
|
1649
1912
|
/** Utility to trim whitespace from blocks of text */
|
|
@@ -1669,6 +1932,8 @@ interface IntelliWeaveGlobalConfig {
|
|
|
1669
1932
|
backgroundColor?: string;
|
|
1670
1933
|
/** Display mode: 'closed' (default - starts minimized) or 'open' (always open) */
|
|
1671
1934
|
displayMode?: 'closed' | 'open';
|
|
1935
|
+
/** Layout preset: 'widget' (default) or 'fullscreen' */
|
|
1936
|
+
layout?: 'widget' | 'fullscreen';
|
|
1672
1937
|
/** Positioning mode: 'fixed' (default - floats on page) or 'container' (fills parent container) */
|
|
1673
1938
|
positioningMode?: 'fixed' | 'container';
|
|
1674
1939
|
/** Horizontal position: 'left' or 'right' (default: 'right') - only used when positioningMode is 'fixed' */
|
|
@@ -1693,55 +1958,44 @@ declare function getDefaultUserID(): string;
|
|
|
1693
1958
|
/** Convert an IntelliWeave parameter list to JSON schema. Does not modify if it's already a JSON schema. */
|
|
1694
1959
|
declare function convertParamsToJSONSchema(params: KnowledgeBaseActionParameterSchema): JSONSchema7;
|
|
1695
1960
|
|
|
1696
|
-
/**
|
|
1697
|
-
interface
|
|
1698
|
-
|
|
1699
|
-
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
1700
|
-
/** Content of the message */
|
|
1701
|
-
content: string;
|
|
1702
|
-
/** Tool call ID */
|
|
1703
|
-
tool_call_id?: string;
|
|
1704
|
-
/** Tool calls made by the AI */
|
|
1705
|
-
tool_calls?: any[];
|
|
1961
|
+
/** OpenRouter message extensions */
|
|
1962
|
+
interface OpenRouterMessage extends OpenAI.Chat.ChatCompletionAssistantMessageParam {
|
|
1963
|
+
reasoning?: string;
|
|
1706
1964
|
}
|
|
1965
|
+
/** OpenAI message format */
|
|
1966
|
+
type DataType$1 = OpenRouterMessage | OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
|
1707
1967
|
/**
|
|
1708
|
-
* API for interacting with
|
|
1968
|
+
* API for interacting with Anthropic APIs.
|
|
1709
1969
|
*/
|
|
1710
|
-
declare class ChatGPT extends ChatBase<
|
|
1711
|
-
/**
|
|
1712
|
-
sendMessage(message: string): Promise<string>;
|
|
1713
|
-
/** Insert a message as if the assistant has written it */
|
|
1714
|
-
addAssistantMessage(message: string): void;
|
|
1715
|
-
/** Insert a message sent from a user. Note that doing this instead of using `sendMessage()` means you'll need to manually call `await processMessages()` and then `getLatestMessage()` to get the response. */
|
|
1970
|
+
declare class ChatGPT extends ChatBase<DataType$1> {
|
|
1971
|
+
/** Add a user message to the message history */
|
|
1716
1972
|
addUserMessage(message: string): void;
|
|
1717
|
-
/**
|
|
1718
|
-
|
|
1719
|
-
/**
|
|
1720
|
-
|
|
1721
|
-
/**
|
|
1722
|
-
|
|
1973
|
+
/** Add an assistant message to the message history */
|
|
1974
|
+
addAssistantMessage(message: string): void;
|
|
1975
|
+
/** Create the OpenAI client */
|
|
1976
|
+
protected createOpenAIClient(): OpenAI;
|
|
1977
|
+
/** Send a message, and get the response string. */
|
|
1978
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType$1>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1979
|
+
/** Parse a message block into our format */
|
|
1980
|
+
protected parseMessageBlock(messageID: string, message: OpenRouterMessage, usage: OpenAI.Completions.CompletionUsage | undefined, isPartial: boolean): TokenWindowGroupItemParams<DataType$1>;
|
|
1723
1981
|
/** Trim message list */
|
|
1724
1982
|
trimMessages(): Promise<void>;
|
|
1725
|
-
/** @private Send HTTP request to the API and return the response */
|
|
1726
|
-
sendRequest(payload: any): Promise<Response>;
|
|
1727
|
-
/** @private Send message list to the API and store the response */
|
|
1728
|
-
sendToAPI(generatePayloadOnly?: boolean): Promise<any>;
|
|
1729
|
-
/** @private Process a tool call request from the AI */
|
|
1730
|
-
processToolCall(toolCall: any): Promise<void>;
|
|
1731
1983
|
}
|
|
1732
1984
|
|
|
1985
|
+
/** Anthropic message format */
|
|
1986
|
+
type DataType = Anthropic.Messages.MessageParam;
|
|
1733
1987
|
/**
|
|
1734
1988
|
* API for interacting with Anthropic APIs.
|
|
1735
1989
|
*/
|
|
1736
|
-
declare class AnthropicChat extends ChatBase<
|
|
1990
|
+
declare class AnthropicChat extends ChatBase<DataType> {
|
|
1737
1991
|
/** Add a user message to the message history */
|
|
1738
1992
|
addUserMessage(message: string): void;
|
|
1739
1993
|
/** Add an assistant message to the message history */
|
|
1740
1994
|
addAssistantMessage(message: string): void;
|
|
1741
|
-
/** Send a message, and get the response */
|
|
1742
|
-
sendMessage(message: string): Promise<
|
|
1743
|
-
/**
|
|
1744
|
-
protected
|
|
1995
|
+
/** Send a message, and get the response string. */
|
|
1996
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1997
|
+
/** Parse a message block into our format */
|
|
1998
|
+
protected parseMessageBlock(message: Anthropic.Messages.Message, isPartial: boolean): TokenWindowGroupItemParams<DataType>;
|
|
1745
1999
|
/** Trim message list */
|
|
1746
2000
|
trimMessages(): Promise<void>;
|
|
1747
2001
|
}
|
|
@@ -1922,57 +2176,6 @@ interface VoiceSubmitEvent extends BaseStatisticsEvent {
|
|
|
1922
2176
|
/** Union type of all specific event types */
|
|
1923
2177
|
type StatisticsEvent = SessionStartEvent | MessageSendEvent | MessageReceiveEvent | ToolCallEvent | KnowledgeBaseSearchEvent | UIOpenEvent | UICloseEvent | VoiceStartEvent | VoiceEndEvent | VoiceSubmitEvent;
|
|
1924
2178
|
|
|
1925
|
-
/**
|
|
1926
|
-
* Handles a stream of input/output events with the specified AI model.
|
|
1927
|
-
*
|
|
1928
|
-
* @event event - Fired when an event is emitted, either by the AI or wrapper code etc.
|
|
1929
|
-
*/
|
|
1930
|
-
declare class IntelliWeaveStream extends IntelliWeave {
|
|
1931
|
-
/** Events that haven't been sent to the AI yet */
|
|
1932
|
-
pendingEvents: IntelliWeaveStreamEvent[];
|
|
1933
|
-
/** Get the system message prefix, before the KB entries are added */
|
|
1934
|
-
getContextPrefix(): Promise<string>;
|
|
1935
|
-
/** Get actions to be added to the context */
|
|
1936
|
-
/** Post an event to the AI */
|
|
1937
|
-
postEvent(event: Partial<IntelliWeaveStreamEvent>): void;
|
|
1938
|
-
/** @private Called when the AI wants to run a KB action */
|
|
1939
|
-
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
1940
|
-
/** Output an event to the event listener(s) */
|
|
1941
|
-
private emitEvent;
|
|
1942
|
-
private _isProcessingEvents;
|
|
1943
|
-
/** Process events */
|
|
1944
|
-
private processEvents;
|
|
1945
|
-
}
|
|
1946
|
-
/** Any event */
|
|
1947
|
-
interface IntelliWeaveStreamEvent {
|
|
1948
|
-
/** Event name */
|
|
1949
|
-
eventName: string;
|
|
1950
|
-
/** Event date, unix timestamp, number of milliseconds since Jan 1 1970 */
|
|
1951
|
-
timestamp: number;
|
|
1952
|
-
/** Human-readable event date */
|
|
1953
|
-
timestampDate: string;
|
|
1954
|
-
/** Direction of this event. Input events go into the AI for processing, output events come out of the AI system. */
|
|
1955
|
-
direction: 'input' | 'output';
|
|
1956
|
-
/** Assistant hint, added automatically if there's a KB entry with the same ID. */
|
|
1957
|
-
assistantHint?: string;
|
|
1958
|
-
/** Any extra data */
|
|
1959
|
-
[key: string]: any;
|
|
1960
|
-
}
|
|
1961
|
-
/** Error event schema */
|
|
1962
|
-
interface IntelliWeaveStreamErrorEvent extends IntelliWeaveStreamEvent {
|
|
1963
|
-
/** Event name */
|
|
1964
|
-
eventName: "error";
|
|
1965
|
-
/** Error details */
|
|
1966
|
-
errorMessage: string;
|
|
1967
|
-
}
|
|
1968
|
-
/** AI speaking event */
|
|
1969
|
-
interface IntelliWeaveStreamTextOutputEvent extends IntelliWeaveStreamEvent {
|
|
1970
|
-
/** Event name */
|
|
1971
|
-
eventName: "text";
|
|
1972
|
-
/** The text spoken */
|
|
1973
|
-
text: string;
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
2179
|
/**
|
|
1977
2180
|
* This is used when someone does `import "web-weaver-embedded"` and gives them a React Component (WebWeaverUI)
|
|
1978
2181
|
* that they can use in their React code.
|
|
@@ -2012,6 +2215,10 @@ declare const WebWeaverUI: (props: {
|
|
|
2012
2215
|
hubAPI?: string;
|
|
2013
2216
|
/** Display mode: 'closed' (default - starts minimized) or 'open' (always open) */
|
|
2014
2217
|
displayMode?: "closed" | "open";
|
|
2218
|
+
/** Layout preset: 'widget' (default) or 'fullscreen' */
|
|
2219
|
+
layout?: "widget" | "fullscreen";
|
|
2220
|
+
/** Fullscreen header: 'show' (default) or 'hidden' */
|
|
2221
|
+
header?: "show" | "hidden";
|
|
2015
2222
|
/** Positioning mode: 'fixed' (default - floats on page) or 'container' (fills parent container) */
|
|
2016
2223
|
positioningMode?: "fixed" | "container";
|
|
2017
2224
|
/** Horizontal position: 'left' or 'right' (default: 'right') - only used when positioningMode is 'fixed' */
|
|
@@ -2047,4 +2254,4 @@ declare function useIntelliWeave(): IntelliWeave | undefined;
|
|
|
2047
2254
|
/** React hook to add an external KB search hook. This can provide static KB entries, or perform an async search and return dynamic entries. */
|
|
2048
2255
|
declare function useIntelliWeaveKnowledge(query: KnowledgeBaseSource['query'], dependencies?: any[]): void;
|
|
2049
2256
|
|
|
2050
|
-
export { AILogic, AnthropicChat, AudioSystem, type BaseStatisticsEvent, type BufferType, BufferedWebSocket, type BuiltInActionFlags, ChatBase, type ChatBaseConfig, type ChatBaseToolConfig, ChatGPT, type
|
|
2257
|
+
export { AILogic, AnthropicChat, AudioSystem, type BaseStatisticsEvent, type BufferType, BufferedWebSocket, type BuiltInActionFlags, ChatBase, type ChatBaseConfig, type ChatBaseToolConfig, ChatGPT, type ElevenLabsSpeechToTextStream, type ElevenLabsTextToSpeechStream, ElevenLabsTranscriptionNode, FixedBufferStream, type InputStatisticsEvent, IntelliWeave, type IntelliWeaveGlobalConfig, type IntelliWeaveInstructConfig, IntelliWeaveMessageParser, type IntelliWeaveParameterDefinition, IntelliWeaveProvider, IntelliWeaveTranscriptionNode, KnowledgeBase, type KnowledgeBaseActionParameterSchema, type KnowledgeBaseItem, type KnowledgeBaseItemAttachment, type KnowledgeBaseSearchEvent, type KnowledgeBaseSource, type KnowledgeBaseWebhookActionResponse, type KnowledgeBaseWebhookRequest, type KnowledgeBaseWebhookSearchResponse, type KnowledgeFetcher, Logging, MCPKnowledgeClient, type MessageReceiveEvent, type MessageSendEvent, ONNXModel, type ONNXTensors, OpenAITranscriptionNode, PCMPlayerNode, PCMReceiverNode, Resampler, type SessionStartEvent, type StatisticsEvent, type StatisticsEventType, type SubAgentConfig, SubAgents, type SupportedArrayBuffers, TokenWindow, TokenWindowGroup, type TokenWindowGroupItem, type TokenWindowGroupItemParams, type TokenWindowGroupItemSection, TokenWindowGroupItemSectionType, type ToolCallEvent, type UICloseEvent, type UIOpenEvent, VoiceChunkOutputNode, VoiceDetectionNode, type VoiceEndEvent, type VoiceStartEvent, type VoiceSubmitEvent, WebWeaverEmbed, type WebWeaverGPTConfig, WebWeaverSpeechOutput, WebWeaverSpeechRecognition, WebWeaverUI, audioToWav, convertParamsToJSONSchema, createElevenLabsSpeechToTextStream, createElevenLabsTextToSpeechStream, floatTo16BitPCM, floatTo64BitPCM, getDefaultUserID, int16ToFloat32BitPCM, intelliweaveConfig, intelliweaveGlobalThis, sseEvents, track, trimWhitespaceInText, useIntelliWeave, useIntelliWeaveKnowledge };
|