@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/node/node.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as onnxruntime_web from 'onnxruntime-web';
|
|
2
2
|
import { InferenceSession, Tensor } from 'onnxruntime-web';
|
|
3
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
3
|
import { Optional } from 'utility-types';
|
|
4
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
5
|
+
import OpenAI from 'openai';
|
|
5
6
|
import Anthropic from '@anthropic-ai/sdk';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -387,6 +388,152 @@ function int16ToFloat32BitPCM(input) {
|
|
|
387
388
|
return output;
|
|
388
389
|
}
|
|
389
390
|
|
|
391
|
+
/**
|
|
392
|
+
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
393
|
+
*/
|
|
394
|
+
declare class TokenWindow {
|
|
395
|
+
/** Token window size */
|
|
396
|
+
size: number;
|
|
397
|
+
/** Token groups */
|
|
398
|
+
groups: TokenWindowGroup<any>[];
|
|
399
|
+
/** Create a new group */
|
|
400
|
+
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
401
|
+
/** Get a group */
|
|
402
|
+
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
403
|
+
/** Counts tokens in the specified text */
|
|
404
|
+
static countTokensInText(text: string): number;
|
|
405
|
+
/** Calculate current tokens in all groups */
|
|
406
|
+
countTokens(): number;
|
|
407
|
+
/** Remove overflow from all groups. */
|
|
408
|
+
removeOverflow(): void;
|
|
409
|
+
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
410
|
+
private removeOneItem;
|
|
411
|
+
}
|
|
412
|
+
/** A token group. */
|
|
413
|
+
declare class TokenWindowGroup<DataType> {
|
|
414
|
+
/** Group ID */
|
|
415
|
+
id: string;
|
|
416
|
+
/** List of items */
|
|
417
|
+
items: TokenWindowGroupItem<DataType>[];
|
|
418
|
+
/**
|
|
419
|
+
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
420
|
+
* 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,
|
|
421
|
+
* that group will be allowed to keep double the amount of items.
|
|
422
|
+
*/
|
|
423
|
+
weight: number;
|
|
424
|
+
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
425
|
+
tokenCount: number;
|
|
426
|
+
/** Group item separator. This text is added in between each item in the token window. */
|
|
427
|
+
separator: string;
|
|
428
|
+
/** Token count padding added to each item. */
|
|
429
|
+
private itemPadding;
|
|
430
|
+
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
431
|
+
setItemPadding(padding: number): this;
|
|
432
|
+
/** Sort function */
|
|
433
|
+
private sortFunction;
|
|
434
|
+
/** Set sort function */
|
|
435
|
+
sortBy(sortFunction: (a: TokenWindowGroupItem<DataType>, b: TokenWindowGroupItem<DataType>) => number): this;
|
|
436
|
+
/** Set separator. This text is added in between each item in the token window. */
|
|
437
|
+
setSeparator(separator: string): this;
|
|
438
|
+
/**
|
|
439
|
+
* Set weight. Weight controls how many items from this group should be kept
|
|
440
|
+
* in relation to the entire window. For example if all groups have a weight
|
|
441
|
+
* of 1, each group remove items equally if full. If one has a weight of 2
|
|
442
|
+
* while the rest are 1, that group will be allowed to keep double the
|
|
443
|
+
* amount of items.
|
|
444
|
+
*/
|
|
445
|
+
setWeight(weight: number): this;
|
|
446
|
+
/** Recalculate all tokens. Note this may take a while. */
|
|
447
|
+
recalculateTokens(): void;
|
|
448
|
+
/** Add an item to the group */
|
|
449
|
+
add(item: string | TokenWindowGroupItemParams<DataType>): TokenWindowGroupItem<DataType>;
|
|
450
|
+
/** Get all items as a string */
|
|
451
|
+
getAllAsString(): string;
|
|
452
|
+
/** Get all items. Doesn't return disabled items. */
|
|
453
|
+
getAll(): TokenWindowGroupItem<DataType>[];
|
|
454
|
+
/** Remove all items from this group */
|
|
455
|
+
empty(): void;
|
|
456
|
+
}
|
|
457
|
+
/** Token group item section types */
|
|
458
|
+
declare enum TokenWindowGroupItemSectionType {
|
|
459
|
+
/** Text items represent plain text. */
|
|
460
|
+
Text = "text",
|
|
461
|
+
/** Tool call items represent a tool call requested by the AI. */
|
|
462
|
+
ToolCall = "tool_call",
|
|
463
|
+
/** Tool result items represent the result of a tool call. */
|
|
464
|
+
ToolResult = "tool_result",
|
|
465
|
+
/** Thinking section */
|
|
466
|
+
Thinking = "thinking",
|
|
467
|
+
/** Other item types */
|
|
468
|
+
Other = "other"
|
|
469
|
+
}
|
|
470
|
+
/** Token group item */
|
|
471
|
+
interface TokenWindowGroupItem<DataType> {
|
|
472
|
+
/** Each item must have a unique ID. */
|
|
473
|
+
id: string;
|
|
474
|
+
/** True if this item should never be removed */
|
|
475
|
+
cannotRemove?: boolean;
|
|
476
|
+
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
477
|
+
sortOrder: number;
|
|
478
|
+
/** Date this item was added */
|
|
479
|
+
dateAdded: number;
|
|
480
|
+
/** Token count in the content */
|
|
481
|
+
tokenCount: number;
|
|
482
|
+
/** This is the actual item that gets sent to the APIs. It will be in whatever format is required for the associated API. */
|
|
483
|
+
data?: DataType;
|
|
484
|
+
/** If disabled, this item will not be included and will not add to the token count. */
|
|
485
|
+
disabled?: boolean;
|
|
486
|
+
/** Message source, ie was this message created by the user, or by the AI? */
|
|
487
|
+
source: 'user' | 'assistant';
|
|
488
|
+
/**
|
|
489
|
+
* 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.
|
|
490
|
+
* 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.
|
|
491
|
+
*
|
|
492
|
+
* 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.
|
|
493
|
+
*/
|
|
494
|
+
text?: string;
|
|
495
|
+
/** Message sections */
|
|
496
|
+
sections?: TokenWindowGroupItemSection[];
|
|
497
|
+
/** If this message was generated by the AI, this contains the token usage for this message. */
|
|
498
|
+
usage?: {
|
|
499
|
+
/** Number of tokens consumed from the data passed to the AI */
|
|
500
|
+
inputTokens: number;
|
|
501
|
+
/** Number of input tokens that were used in token caching */
|
|
502
|
+
cachedInputTokens: number;
|
|
503
|
+
/** Number of tokens consumed by the AI generating output */
|
|
504
|
+
outputTokens: number;
|
|
505
|
+
/** Total token usage */
|
|
506
|
+
totalTokens: number;
|
|
507
|
+
};
|
|
508
|
+
/** True if this item is still being streamed */
|
|
509
|
+
streamingInProgress?: boolean;
|
|
510
|
+
}
|
|
511
|
+
/** A section of a message returned by the AI */
|
|
512
|
+
interface TokenWindowGroupItemSection {
|
|
513
|
+
/** Section type */
|
|
514
|
+
type: TokenWindowGroupItemSectionType;
|
|
515
|
+
/** Text content when this section represents text or thinking */
|
|
516
|
+
text?: string;
|
|
517
|
+
/** The raw tool name the AI requested to be called. */
|
|
518
|
+
toolName?: string;
|
|
519
|
+
/** The ID of the KB action this tool call maps to, if any */
|
|
520
|
+
toolKbID?: string;
|
|
521
|
+
/** The name of the KB action this tool call maps to, if any */
|
|
522
|
+
toolKbName?: string;
|
|
523
|
+
/** The parameters the AI requested to be sent to the tool. Only available if type == 'tool_call' */
|
|
524
|
+
toolParameters?: any;
|
|
525
|
+
/** Successful response of the tool call. Will be null if toolErrorResponse is set. */
|
|
526
|
+
toolSuccessResponse?: any;
|
|
527
|
+
/** Error response of the tool call. Will be null if toolSuccessResponse is set. */
|
|
528
|
+
toolErrorResponse?: string;
|
|
529
|
+
/** Tool call ID. This can be used to match a tool call request with it's result. */
|
|
530
|
+
toolCallInstanceID?: string;
|
|
531
|
+
/** True if this tool call should be hidden in the UI */
|
|
532
|
+
toolCallHiddenInUI?: 'always' | 'after-complete';
|
|
533
|
+
}
|
|
534
|
+
/** Token window group item input, without the autogenerated fields */
|
|
535
|
+
type TokenWindowGroupItemParams<DataType> = Omit<Optional<TokenWindowGroupItem<DataType>, 'id' | 'dateAdded' | 'sortOrder' | 'text' | 'source' | 'sections'>, 'tokenCount'>;
|
|
536
|
+
|
|
390
537
|
/**
|
|
391
538
|
* Speech output
|
|
392
539
|
*
|
|
@@ -397,10 +544,16 @@ function int16ToFloat32BitPCM(input) {
|
|
|
397
544
|
declare class WebWeaverSpeechOutput extends EventTarget {
|
|
398
545
|
/** Reference to the AI */
|
|
399
546
|
private ai?;
|
|
547
|
+
/** Automatically speak output from the AI */
|
|
548
|
+
autoSpeak: boolean;
|
|
549
|
+
/** If enabled, connections will be pre-emptively opened to speed up text-to-speech response times, if possible */
|
|
550
|
+
preemptiveConnection: boolean;
|
|
400
551
|
/** Constructor */
|
|
401
552
|
constructor(ai: IntelliWeave);
|
|
402
|
-
/**
|
|
403
|
-
|
|
553
|
+
/** Message IDs we've processed */
|
|
554
|
+
private processedMessages;
|
|
555
|
+
/** Called when the AI responds */
|
|
556
|
+
onOutputFromAI(e: CustomEvent): void;
|
|
404
557
|
/** Current player vars */
|
|
405
558
|
private currentPlayerVolume?;
|
|
406
559
|
private currentPlayer?;
|
|
@@ -412,8 +565,15 @@ declare class WebWeaverSpeechOutput extends EventTarget {
|
|
|
412
565
|
private maxVolumeHeard;
|
|
413
566
|
/** Get current (realtime) audio output volume level, from 0 to 1 */
|
|
414
567
|
get volumeLevel(): number;
|
|
568
|
+
/** Queued messages to speak next */
|
|
569
|
+
private _queuedText;
|
|
415
570
|
/** Speak the text */
|
|
416
571
|
speak(text: string): Promise<void>;
|
|
572
|
+
private _queueActive;
|
|
573
|
+
_runQueue(): Promise<void>;
|
|
574
|
+
/** ElevenLabs connection pre-cache */
|
|
575
|
+
private _elevenLabsPrecachedConnection?;
|
|
576
|
+
private _getElevenLabsConnection;
|
|
417
577
|
private _speakWithLock;
|
|
418
578
|
/** True if currently playing audio */
|
|
419
579
|
get isSpeaking(): boolean;
|
|
@@ -556,7 +716,7 @@ declare class IntelliWeaveTranscriptionNode extends VoiceChunkOutputNode {
|
|
|
556
716
|
static debugExportWav: boolean;
|
|
557
717
|
/** Server address for transcription */
|
|
558
718
|
apiAddress: string;
|
|
559
|
-
/**
|
|
719
|
+
/** IntelliWeave API key */
|
|
560
720
|
apiKey: string;
|
|
561
721
|
/** WebSocket connection */
|
|
562
722
|
private ws?;
|
|
@@ -576,6 +736,32 @@ declare class IntelliWeaveTranscriptionNode extends VoiceChunkOutputNode {
|
|
|
576
736
|
onSocketClose(): void;
|
|
577
737
|
}
|
|
578
738
|
|
|
739
|
+
/**
|
|
740
|
+
* This AudioNode uses ElevenLabs to transcribe spoken speech to text.
|
|
741
|
+
*
|
|
742
|
+
* - event `transcription` - Fired when a transcription is ready. `text` contains the transcribed text.
|
|
743
|
+
*/
|
|
744
|
+
declare class ElevenLabsTranscriptionNode extends VoiceChunkOutputNode {
|
|
745
|
+
/** ElevenLabs API key */
|
|
746
|
+
apiKey: string;
|
|
747
|
+
/** ElevenLabs stream connection */
|
|
748
|
+
private connection?;
|
|
749
|
+
/** True if currently transcribing */
|
|
750
|
+
isTranscribing: boolean;
|
|
751
|
+
/** WebSocket shutdown timer */
|
|
752
|
+
private shutdownTimer?;
|
|
753
|
+
/** Constructor */
|
|
754
|
+
constructor(audioContext: AudioContext, apiKey: string);
|
|
755
|
+
/** Called when a voice chunk is received */
|
|
756
|
+
onVoiceChunk(buffer: Float32Array): Promise<void>;
|
|
757
|
+
/** Start reading the stream */
|
|
758
|
+
private startReading;
|
|
759
|
+
/** Called when the voice recording ends */
|
|
760
|
+
onVoiceEnd(buffers: Float32Array[]): Promise<void>;
|
|
761
|
+
/** Called when a transcription is ready */
|
|
762
|
+
onVoiceTranscription(text: string): void;
|
|
763
|
+
}
|
|
764
|
+
|
|
579
765
|
/**
|
|
580
766
|
* Handles speech recognition from the microphone
|
|
581
767
|
*
|
|
@@ -601,7 +787,7 @@ declare class WebWeaverSpeechRecognition extends EventTarget {
|
|
|
601
787
|
/** Returns true if speech recognition is supported by this persona and browser */
|
|
602
788
|
get isSupported(): boolean;
|
|
603
789
|
/** Currently active voice detection node */
|
|
604
|
-
voiceDetection?: IntelliWeaveTranscriptionNode | OpenAITranscriptionNode;
|
|
790
|
+
voiceDetection?: IntelliWeaveTranscriptionNode | OpenAITranscriptionNode | ElevenLabsTranscriptionNode;
|
|
605
791
|
/** Constructor */
|
|
606
792
|
constructor(ai: IntelliWeave);
|
|
607
793
|
private _skipEvents;
|
|
@@ -734,6 +920,17 @@ declare class MCPKnowledgeClient {
|
|
|
734
920
|
searchToolName?: string;
|
|
735
921
|
/** Keep search function available for the AI to use. */
|
|
736
922
|
searchToolVisible?: boolean;
|
|
923
|
+
/** Use the IntelliWeave proxy */
|
|
924
|
+
proxy?: {
|
|
925
|
+
/** If true, will send requests via the IntelliWeave MCP proxy */
|
|
926
|
+
enabled?: boolean;
|
|
927
|
+
/** The URL of the proxy server, defaults to the standard IntelliWeave proxy */
|
|
928
|
+
url?: string;
|
|
929
|
+
/** IntelliWeave API key */
|
|
930
|
+
apiKey?: string;
|
|
931
|
+
};
|
|
932
|
+
/** Pass extra headers to the MCP server */
|
|
933
|
+
headers?: Record<string, string>;
|
|
737
934
|
};
|
|
738
935
|
/** Constructor */
|
|
739
936
|
constructor(config: MCPKnowledgeClient['config']);
|
|
@@ -744,16 +941,10 @@ declare class MCPKnowledgeClient {
|
|
|
744
941
|
method: string;
|
|
745
942
|
params?: {
|
|
746
943
|
[x: string]: unknown;
|
|
747
|
-
task?: {
|
|
748
|
-
[x: string]: unknown;
|
|
749
|
-
ttl?: number | null | undefined;
|
|
750
|
-
pollInterval?: number | undefined;
|
|
751
|
-
} | undefined;
|
|
752
944
|
_meta?: {
|
|
753
945
|
[x: string]: unknown;
|
|
754
946
|
progressToken?: string | number | undefined;
|
|
755
947
|
"io.modelcontextprotocol/related-task"?: {
|
|
756
|
-
[x: string]: unknown;
|
|
757
948
|
taskId: string;
|
|
758
949
|
} | undefined;
|
|
759
950
|
} | undefined;
|
|
@@ -764,8 +955,8 @@ declare class MCPKnowledgeClient {
|
|
|
764
955
|
[x: string]: unknown;
|
|
765
956
|
_meta?: {
|
|
766
957
|
[x: string]: unknown;
|
|
958
|
+
progressToken?: string | number | undefined;
|
|
767
959
|
"io.modelcontextprotocol/related-task"?: {
|
|
768
|
-
[x: string]: unknown;
|
|
769
960
|
taskId: string;
|
|
770
961
|
} | undefined;
|
|
771
962
|
} | undefined;
|
|
@@ -774,8 +965,8 @@ declare class MCPKnowledgeClient {
|
|
|
774
965
|
[x: string]: unknown;
|
|
775
966
|
_meta?: {
|
|
776
967
|
[x: string]: unknown;
|
|
968
|
+
progressToken?: string | number | undefined;
|
|
777
969
|
"io.modelcontextprotocol/related-task"?: {
|
|
778
|
-
[x: string]: unknown;
|
|
779
970
|
taskId: string;
|
|
780
971
|
} | undefined;
|
|
781
972
|
} | undefined;
|
|
@@ -784,16 +975,10 @@ declare class MCPKnowledgeClient {
|
|
|
784
975
|
method: string;
|
|
785
976
|
params?: {
|
|
786
977
|
[x: string]: unknown;
|
|
787
|
-
task?: {
|
|
788
|
-
[x: string]: unknown;
|
|
789
|
-
ttl?: number | null | undefined;
|
|
790
|
-
pollInterval?: number | undefined;
|
|
791
|
-
} | undefined;
|
|
792
978
|
_meta?: {
|
|
793
979
|
[x: string]: unknown;
|
|
794
980
|
progressToken?: string | number | undefined;
|
|
795
981
|
"io.modelcontextprotocol/related-task"?: {
|
|
796
|
-
[x: string]: unknown;
|
|
797
982
|
taskId: string;
|
|
798
983
|
} | undefined;
|
|
799
984
|
} | undefined;
|
|
@@ -804,8 +989,8 @@ declare class MCPKnowledgeClient {
|
|
|
804
989
|
[x: string]: unknown;
|
|
805
990
|
_meta?: {
|
|
806
991
|
[x: string]: unknown;
|
|
992
|
+
progressToken?: string | number | undefined;
|
|
807
993
|
"io.modelcontextprotocol/related-task"?: {
|
|
808
|
-
[x: string]: unknown;
|
|
809
994
|
taskId: string;
|
|
810
995
|
} | undefined;
|
|
811
996
|
} | undefined;
|
|
@@ -814,8 +999,8 @@ declare class MCPKnowledgeClient {
|
|
|
814
999
|
[x: string]: unknown;
|
|
815
1000
|
_meta?: {
|
|
816
1001
|
[x: string]: unknown;
|
|
1002
|
+
progressToken?: string | number | undefined;
|
|
817
1003
|
"io.modelcontextprotocol/related-task"?: {
|
|
818
|
-
[x: string]: unknown;
|
|
819
1004
|
taskId: string;
|
|
820
1005
|
} | undefined;
|
|
821
1006
|
} | undefined;
|
|
@@ -835,84 +1020,6 @@ declare class MCPKnowledgeClient {
|
|
|
835
1020
|
private performToolCall;
|
|
836
1021
|
}
|
|
837
1022
|
|
|
838
|
-
/**
|
|
839
|
-
* This class helps organize groups of tokenized text along with removing items when the window is full.
|
|
840
|
-
*/
|
|
841
|
-
declare class TokenWindow {
|
|
842
|
-
/** Token window size */
|
|
843
|
-
size: number;
|
|
844
|
-
/** Token groups */
|
|
845
|
-
groups: TokenWindowGroup<any>[];
|
|
846
|
-
/** Create a new group */
|
|
847
|
-
createGroup(id: string): TokenWindowGroup<unknown>;
|
|
848
|
-
/** Get a group */
|
|
849
|
-
group<CustomDataType>(id: string): TokenWindowGroup<CustomDataType> | undefined;
|
|
850
|
-
/** Calculate current tokens in all groups */
|
|
851
|
-
countTokens(): number;
|
|
852
|
-
/** Remove overflow from all groups. */
|
|
853
|
-
removeOverflow(): void;
|
|
854
|
-
/** Remove one overflow item. Returns null if no items were able to be removed. */
|
|
855
|
-
private removeOneItem;
|
|
856
|
-
}
|
|
857
|
-
/** A token group. */
|
|
858
|
-
declare class TokenWindowGroup<CustomDataType> {
|
|
859
|
-
/** Group ID */
|
|
860
|
-
id: string;
|
|
861
|
-
/** List of items */
|
|
862
|
-
items: TokenWindowGroupItem<CustomDataType>[];
|
|
863
|
-
/**
|
|
864
|
-
* Weight controls how many items from this group should be kept in relation to the entire window. For example if all
|
|
865
|
-
* 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,
|
|
866
|
-
* that group will be allowed to keep double the amount of items.
|
|
867
|
-
*/
|
|
868
|
-
weight: number;
|
|
869
|
-
/** Current total token count, computed automatically. Don't update this value manually. */
|
|
870
|
-
tokenCount: number;
|
|
871
|
-
/** Group item separator */
|
|
872
|
-
separator: string;
|
|
873
|
-
/** Token count padding added to each item. */
|
|
874
|
-
private itemPadding;
|
|
875
|
-
/** Sets the token count padding added to each item. Useful if you don't know exactly what will be added by the LLM host. */
|
|
876
|
-
setItemPadding(padding: number): this;
|
|
877
|
-
/** Sort function */
|
|
878
|
-
private sortFunction;
|
|
879
|
-
/** Set sort function */
|
|
880
|
-
sortBy(sortFunction: (a: TokenWindowGroupItem<CustomDataType>, b: TokenWindowGroupItem<CustomDataType>) => number): this;
|
|
881
|
-
/** Set separator */
|
|
882
|
-
setSeparator(separator: string): this;
|
|
883
|
-
/** Set weight */
|
|
884
|
-
setWeight(weight: number): this;
|
|
885
|
-
/** Recalculate all tokens. Note this may take a while. */
|
|
886
|
-
recalculateTokens(): void;
|
|
887
|
-
/** Add an item to the group */
|
|
888
|
-
add(item: string | Omit<Optional<TokenWindowGroupItem<CustomDataType>, 'id' | 'dateAdded' | 'sortOrder'>, 'tokenCount'>): TokenWindowGroupItem<CustomDataType>;
|
|
889
|
-
/** Get all items as a string */
|
|
890
|
-
getAllAsString(): string;
|
|
891
|
-
/** Get all items. Doesn't return disabled items. */
|
|
892
|
-
getAll(): TokenWindowGroupItem<CustomDataType>[];
|
|
893
|
-
/** Remove all items from this group */
|
|
894
|
-
empty(): void;
|
|
895
|
-
}
|
|
896
|
-
/** Token group item */
|
|
897
|
-
interface TokenWindowGroupItem<CustomDataType> {
|
|
898
|
-
/** Each item must have a unique ID. */
|
|
899
|
-
id: string;
|
|
900
|
-
/** The string content of the item */
|
|
901
|
-
content: string;
|
|
902
|
-
/** True if this item should never be removed */
|
|
903
|
-
cannotRemove?: boolean;
|
|
904
|
-
/** Sorting order. If not specified, uses dateAdded instead. */
|
|
905
|
-
sortOrder: number;
|
|
906
|
-
/** Date this item was added */
|
|
907
|
-
dateAdded: number;
|
|
908
|
-
/** Token count in the content */
|
|
909
|
-
tokenCount: number;
|
|
910
|
-
/** Anything to attach to this item */
|
|
911
|
-
customData?: CustomDataType;
|
|
912
|
-
/** If disabled, this item will not be included and will not add tot he token count. */
|
|
913
|
-
disabled?: boolean;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
1023
|
// ==================================================================================================
|
|
917
1024
|
// JSON Schema Draft 07
|
|
918
1025
|
// ==================================================================================================
|
|
@@ -1100,8 +1207,8 @@ interface ChatBaseConfig {
|
|
|
1100
1207
|
maxTokens: number;
|
|
1101
1208
|
/** Callback before the AI sends info to the LLM */
|
|
1102
1209
|
onBeforeMessageProcessing?: () => void;
|
|
1103
|
-
/** Callback when a message from the AI is returned. If
|
|
1104
|
-
onAIMessage?: (
|
|
1210
|
+
/** Callback when a message from the AI is returned. If isPartial is true, it may be incomplete and be called again with more updates. */
|
|
1211
|
+
onAIMessage?: (output: TokenWindowGroupItemParams<any>[], isPartial: boolean) => void;
|
|
1105
1212
|
/** Callback when the AI starts performing an action */
|
|
1106
1213
|
onAIToolStart?: (toolName: string, input: any) => void;
|
|
1107
1214
|
}
|
|
@@ -1115,19 +1222,17 @@ interface ChatBaseToolConfig {
|
|
|
1115
1222
|
params: JSONSchema7;
|
|
1116
1223
|
/** Callback function to process the tool */
|
|
1117
1224
|
callback: (params: any) => any;
|
|
1118
|
-
/** If true, this tool call will be removed from the message history after it is executed. */
|
|
1119
|
-
removeFromMessageHistory?: boolean;
|
|
1120
1225
|
/** If true, this item can be removed if there's not enough context available. */
|
|
1121
1226
|
canRemove?: boolean;
|
|
1122
|
-
/**
|
|
1123
|
-
|
|
1227
|
+
/** Knowledge base item this tool use represents */
|
|
1228
|
+
kbItem?: KnowledgeBaseItem;
|
|
1124
1229
|
}
|
|
1125
1230
|
/**
|
|
1126
1231
|
* API for interacting with chat APIs.
|
|
1127
1232
|
*/
|
|
1128
1233
|
declare class ChatBase<
|
|
1129
1234
|
/** Format for messages in the token window */
|
|
1130
|
-
|
|
1235
|
+
DataType = any,
|
|
1131
1236
|
/** Optional extended config */
|
|
1132
1237
|
ConfigFormat extends ChatBaseConfig = ChatBaseConfig> {
|
|
1133
1238
|
/** ID */
|
|
@@ -1146,27 +1251,95 @@ ConfigFormat extends ChatBaseConfig = ChatBaseConfig> {
|
|
|
1146
1251
|
/** Token window management */
|
|
1147
1252
|
tokenWindow: TokenWindow;
|
|
1148
1253
|
/** Token window group used for the context message */
|
|
1149
|
-
get contextGroup(): TokenWindowGroup<
|
|
1254
|
+
get contextGroup(): TokenWindowGroup<string>;
|
|
1150
1255
|
/** Token window group used for tools / actions */
|
|
1151
1256
|
get toolGroup(): TokenWindowGroup<ChatBaseToolConfig>;
|
|
1152
1257
|
/** Token window group used for messages */
|
|
1153
|
-
get messageGroup(): TokenWindowGroup<
|
|
1258
|
+
get messageGroup(): TokenWindowGroup<DataType>;
|
|
1259
|
+
/** Get the API base after stripping out exact endpoints, or undefined for the default */
|
|
1260
|
+
getBaseURL(): string | undefined;
|
|
1154
1261
|
/** Constructor */
|
|
1155
1262
|
constructor(config: ConfigFormat);
|
|
1156
|
-
/** Send a message, and get the response */
|
|
1157
|
-
sendMessage(message: string): Promise<
|
|
1263
|
+
/** Send a message, and get the response as a string. */
|
|
1264
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1158
1265
|
/** Add a user message to the message history */
|
|
1159
1266
|
addUserMessage(message: string): void;
|
|
1160
1267
|
/** Add an assistant message to the message history */
|
|
1161
1268
|
addAssistantMessage(message: string): void;
|
|
1269
|
+
/** Helper to add a plain text item */
|
|
1270
|
+
protected addTextMessage(text: string, source: 'user' | 'assistant', data: DataType): void;
|
|
1162
1271
|
/** Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
1163
|
-
onBeforeIncomingMessage(message:
|
|
1272
|
+
onBeforeIncomingMessage(message: DataType): void;
|
|
1164
1273
|
/** Reset the conversation */
|
|
1165
1274
|
resetConversation(): void;
|
|
1166
1275
|
/** Trim message list */
|
|
1167
1276
|
trimMessages(): Promise<void>;
|
|
1168
1277
|
/** Register a tool. */
|
|
1169
1278
|
registerTool(tool: ChatBaseToolConfig): TokenWindowGroupItem<ChatBaseToolConfig>;
|
|
1279
|
+
/** Find a tool based on the AI-safe name */
|
|
1280
|
+
protected findToolBySafeName(toolSafeName: string): ChatBaseToolConfig | undefined;
|
|
1281
|
+
/** Execute the specified tool. Throws an error if the tool is undefined. */
|
|
1282
|
+
protected executeTool(tool: ChatBaseToolConfig | undefined, input: any): Promise<string>;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
/** Parses the response from `IntelliWeave.sendMessage()` or a collection of message items. */
|
|
1286
|
+
declare class IntelliWeaveMessageParser {
|
|
1287
|
+
/** New messages produced after sendMessage() was called */
|
|
1288
|
+
messages: TokenWindowGroupItemParams<unknown>[];
|
|
1289
|
+
/** Constructor */
|
|
1290
|
+
constructor(items: TokenWindowGroupItemParams<unknown>[]);
|
|
1291
|
+
/** Plain text output from the AI */
|
|
1292
|
+
text(): string;
|
|
1293
|
+
/** Total token usage */
|
|
1294
|
+
tokenUsage(): {
|
|
1295
|
+
cachedInputTokens: number;
|
|
1296
|
+
inputTokens: number;
|
|
1297
|
+
outputTokens: number;
|
|
1298
|
+
totalTokens: number;
|
|
1299
|
+
};
|
|
1300
|
+
/** Component sections for display */
|
|
1301
|
+
sections(): TokenWindowGroupItemParams<unknown>['sections'];
|
|
1302
|
+
/** List all tool calls that took place */
|
|
1303
|
+
toolCalls(): TokenWindowGroupItemSection[];
|
|
1304
|
+
/** Find the response for a tool call */
|
|
1305
|
+
toolResult(toolCallInstanceID: string): TokenWindowGroupItemSection | null;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/** Handles subagents. This allows your Persona to use other Personas as tools. */
|
|
1309
|
+
declare class SubAgents {
|
|
1310
|
+
/** Reference to the main IntelliWeave instance */
|
|
1311
|
+
ai: IntelliWeave;
|
|
1312
|
+
/** Constructor */
|
|
1313
|
+
constructor(ai: IntelliWeave);
|
|
1314
|
+
/** Subagents */
|
|
1315
|
+
subagents: SubAgentConfig[];
|
|
1316
|
+
/** Cached subagents */
|
|
1317
|
+
cachedSubagents: Record<string, IntelliWeave>;
|
|
1318
|
+
/** Register a sub-agent */
|
|
1319
|
+
register(config: SubAgentConfig): void;
|
|
1320
|
+
/** Unregister subagent */
|
|
1321
|
+
remove(id: string): void;
|
|
1322
|
+
/** Run the subagent */
|
|
1323
|
+
runQuery(config: SubAgentConfig, query: string): Promise<string>;
|
|
1324
|
+
}
|
|
1325
|
+
/** Sub-agent config */
|
|
1326
|
+
interface SubAgentConfig {
|
|
1327
|
+
/** ID of the sub-agent */
|
|
1328
|
+
id: string;
|
|
1329
|
+
/** API key for the persona. If not specified, uses the same api key as the main agent. */
|
|
1330
|
+
apiKey?: string;
|
|
1331
|
+
/** Name of the sub-agent */
|
|
1332
|
+
name?: string;
|
|
1333
|
+
/** Instructions for the main agent to use this sub agent */
|
|
1334
|
+
usageInstructions?: string;
|
|
1335
|
+
/** If true, will remove all Persona knowledge entries */
|
|
1336
|
+
clearExistingKnowledge?: boolean;
|
|
1337
|
+
/** Extra knowledge base sources for the sub-agent */
|
|
1338
|
+
knowledge?: KnowledgeFetcher;
|
|
1339
|
+
/** Optional extra configuration for the subagent instance */
|
|
1340
|
+
config?: Partial<WebWeaverGPTConfig>;
|
|
1341
|
+
/** Called when the subagent is loaded */
|
|
1342
|
+
onAgentLoaded?: (agent: IntelliWeave) => Promise<void> | void;
|
|
1170
1343
|
}
|
|
1171
1344
|
|
|
1172
1345
|
/** Built-in action flags for the persona */
|
|
@@ -1206,6 +1379,8 @@ interface WebWeaverGPTConfig {
|
|
|
1206
1379
|
textColor?: string;
|
|
1207
1380
|
/** Display mode: 'closed' (default - starts minimized) or 'open' (always open) */
|
|
1208
1381
|
displayMode?: 'closed' | 'open';
|
|
1382
|
+
/** Layout preset: 'widget' (default) or 'fullscreen' */
|
|
1383
|
+
layout?: 'widget' | 'fullscreen';
|
|
1209
1384
|
/** Positioning mode: 'fixed' (default - floats on page) or 'container' (fills parent container) */
|
|
1210
1385
|
positioningMode?: 'fixed' | 'container';
|
|
1211
1386
|
/** Horizontal position: 'left' or 'right' (default: 'right') - only used when positioningMode is 'fixed' */
|
|
@@ -1216,6 +1391,8 @@ interface WebWeaverGPTConfig {
|
|
|
1216
1391
|
offsetX?: number;
|
|
1217
1392
|
/** Vertical offset from edge in pixels (default: 20) - only used when positioningMode is 'fixed' */
|
|
1218
1393
|
offsetY?: number;
|
|
1394
|
+
/** Identifier of an external app or service which manages this persona, if any. (eg. "chatterly") */
|
|
1395
|
+
managedBy?: string;
|
|
1219
1396
|
/** Voice information */
|
|
1220
1397
|
voice?: {
|
|
1221
1398
|
/** Provider ID */
|
|
@@ -1240,6 +1417,10 @@ interface WebWeaverGPTConfig {
|
|
|
1240
1417
|
mcpServers?: MCPKnowledgeClient['config'][];
|
|
1241
1418
|
/** Built-in action flags that are currently enabled */
|
|
1242
1419
|
flags?: BuiltInActionFlags;
|
|
1420
|
+
/** Allow custom chat provider */
|
|
1421
|
+
onCreateProvider?: (config: ChatBaseConfig) => ChatBase;
|
|
1422
|
+
/** Subagents */
|
|
1423
|
+
subagents?: SubAgentConfig[];
|
|
1243
1424
|
}
|
|
1244
1425
|
/**
|
|
1245
1426
|
* IntelliWeave interface, loads a Persona from the hub and allows you to interact with it. This is the main entry point into the IntelliWeave
|
|
@@ -1250,7 +1431,7 @@ interface WebWeaverGPTConfig {
|
|
|
1250
1431
|
* - 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.
|
|
1251
1432
|
* - event `webweaver_error` - Fired when an error occurs during loading. This is a global event that is fired on the window object.
|
|
1252
1433
|
* - event `input` - Fired when the user sends a message to the AI.
|
|
1253
|
-
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.
|
|
1434
|
+
* - 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.
|
|
1254
1435
|
* - event `toolstart` - Fired when the AI starts performing an action.
|
|
1255
1436
|
* - event `tool` - Fired when the AI finishes performing an action.
|
|
1256
1437
|
*/
|
|
@@ -1259,14 +1440,16 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1259
1440
|
static version: string;
|
|
1260
1441
|
/** Built-in actions version - increment this when adding new actions */
|
|
1261
1442
|
static builtInActionsVersion: string;
|
|
1262
|
-
/** Callback when a message from the AI is returned. If
|
|
1263
|
-
onAIMessage?: (
|
|
1443
|
+
/** Callback when a message from the AI is returned. If isPartial is true, it may be incomplete and be called again with more updates. */
|
|
1444
|
+
onAIMessage?: (messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean) => void;
|
|
1264
1445
|
/** Callback when the AI starts performing an action */
|
|
1265
1446
|
onAIToolStart?: ChatBaseConfig['onAIToolStart'];
|
|
1266
1447
|
/** Current conversation ID */
|
|
1267
1448
|
conversationID: string;
|
|
1268
1449
|
/** Knowledge database interface */
|
|
1269
1450
|
knowledgeBase: KnowledgeBase;
|
|
1451
|
+
/** Subagent interface */
|
|
1452
|
+
subAgents: SubAgents;
|
|
1270
1453
|
/** Last KB search that was performed */
|
|
1271
1454
|
private _lastKBsearch;
|
|
1272
1455
|
/** If set, the next time a request is made this is the KB result items that will be used, once-off. */
|
|
@@ -1310,7 +1493,7 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1310
1493
|
/** URL of the IntelliWeave Hub API */
|
|
1311
1494
|
hubAPI: string;
|
|
1312
1495
|
/** Set model and load data from an API key */
|
|
1313
|
-
load(apiKey: string): Promise<
|
|
1496
|
+
load(apiKey: string, config?: Partial<WebWeaverGPTConfig>): Promise<IntelliWeave>;
|
|
1314
1497
|
/** Set the current model */
|
|
1315
1498
|
setModel(id: string): void;
|
|
1316
1499
|
private _lastSystemMsg;
|
|
@@ -1318,18 +1501,19 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1318
1501
|
getContextPrefix(): Promise<string>;
|
|
1319
1502
|
/** Get system message to send to the AI */
|
|
1320
1503
|
onBeforeMessageProcessing(): Promise<void>;
|
|
1321
|
-
/** @private Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
1322
|
-
processIncomingMessage(
|
|
1504
|
+
/** @private Process incoming message(s) from the AI. Can be used to respond to encoded actions in the text response. */
|
|
1505
|
+
processIncomingMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial?: boolean): void;
|
|
1323
1506
|
/** True if currently processing a message */
|
|
1324
1507
|
isProcessing: boolean;
|
|
1325
|
-
/** @private Last tracked token count for calculating per-message token usage */
|
|
1326
|
-
private _lastTrackedTokens;
|
|
1327
1508
|
/** Send a message, and get the response */
|
|
1328
|
-
sendMessage(message: string): Promise<
|
|
1509
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<unknown>[]) => void): Promise<IntelliWeaveMessageParser>;
|
|
1329
1510
|
/** @private Called when the AI wants to run a KB action */
|
|
1330
1511
|
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
1331
|
-
/** Submit an analytics event asynchronously */
|
|
1512
|
+
/** Submit an analytics event asynchronously. These events are for use in the Conversation Analytics code. For anonymous statistic analysis, use track() instead. */
|
|
1513
|
+
private activeAnalyticsPromises;
|
|
1332
1514
|
submitAnalyticsEvent(data: any): void;
|
|
1515
|
+
/** Wait for all analytics events to finish */
|
|
1516
|
+
waitForAnalytics(): Promise<void>;
|
|
1333
1517
|
/** Reset the conversation */
|
|
1334
1518
|
resetConversation(): void;
|
|
1335
1519
|
/** Insert a message as if the assistant has written it */
|
|
@@ -1338,12 +1522,14 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1338
1522
|
exportState(): {
|
|
1339
1523
|
type: string;
|
|
1340
1524
|
conversationID: string;
|
|
1341
|
-
messages: any[] | undefined;
|
|
1525
|
+
messages: TokenWindowGroupItem<any>[] | undefined;
|
|
1342
1526
|
};
|
|
1343
1527
|
/** Import conversation state from JSON */
|
|
1344
1528
|
importState(state: any): void;
|
|
1345
1529
|
/** Clone this instance without any message history */
|
|
1346
1530
|
clone(): IntelliWeave;
|
|
1531
|
+
/** Get all messages in the conversation history */
|
|
1532
|
+
get messages(): TokenWindowGroupItem<any>[];
|
|
1347
1533
|
}
|
|
1348
1534
|
|
|
1349
1535
|
/**
|
|
@@ -1360,8 +1546,16 @@ declare class KnowledgeBase {
|
|
|
1360
1546
|
lastResults: KnowledgeBaseItem[];
|
|
1361
1547
|
/** Individual knowledge base entries added manually by the application */
|
|
1362
1548
|
manualEntries: KnowledgeBaseItem[];
|
|
1549
|
+
/** If true, allows using globally defined sources from the browser window events */
|
|
1550
|
+
allowWindowSources: boolean;
|
|
1551
|
+
/** If true, allows using knowledge specified in the global configuration object */
|
|
1552
|
+
allowGlobalConfigSources: boolean;
|
|
1363
1553
|
/** Constructor */
|
|
1364
1554
|
constructor(ai: IntelliWeave);
|
|
1555
|
+
/** Ensures the internal knowledge is set correctly */
|
|
1556
|
+
ensureInternalKnowledge(): void;
|
|
1557
|
+
/** Clears all knowledge back to the default */
|
|
1558
|
+
reset(): void;
|
|
1365
1559
|
/**
|
|
1366
1560
|
* Register a new knowledge base source. You can pass either just a query function, or an ID and a query function.
|
|
1367
1561
|
*
|
|
@@ -1425,12 +1619,12 @@ interface KnowledgeBaseItem {
|
|
|
1425
1619
|
name: string;
|
|
1426
1620
|
/** Item tags. Helps with search optimization. */
|
|
1427
1621
|
tags?: string;
|
|
1428
|
-
/** Item content
|
|
1429
|
-
content: string
|
|
1622
|
+
/** Item content */
|
|
1623
|
+
content: string;
|
|
1430
1624
|
/** If true, this item will always be returned from all search results. */
|
|
1431
1625
|
isContext?: boolean;
|
|
1432
1626
|
/** If true, this item will not be visible to the AI. */
|
|
1433
|
-
disabled?: boolean;
|
|
1627
|
+
disabled?: boolean | ((ai: IntelliWeave) => boolean);
|
|
1434
1628
|
/** List of parameters for an action function. Can either use IW's format, or a JSON Schema object. */
|
|
1435
1629
|
parameters?: KnowledgeBaseActionParameterSchema;
|
|
1436
1630
|
/**
|
|
@@ -1439,8 +1633,27 @@ interface KnowledgeBaseItem {
|
|
|
1439
1633
|
* that was performed. If an error is thrown, the AI will respond appropriately to the user.
|
|
1440
1634
|
*/
|
|
1441
1635
|
action?: (input: any, ai: IntelliWeave) => (any | Promise<any>);
|
|
1442
|
-
/** If
|
|
1443
|
-
|
|
1636
|
+
/** If specified, will hide this action from the default UI after the AI finishes running it, or always hide it */
|
|
1637
|
+
hideActionInUI?: 'always' | 'after-complete';
|
|
1638
|
+
/** Attachments such as images, etc */
|
|
1639
|
+
attachments?: KnowledgeBaseItemAttachment[];
|
|
1640
|
+
}
|
|
1641
|
+
/** Knowledge base item attachment, such as an image, file, etc. */
|
|
1642
|
+
interface KnowledgeBaseItemAttachment {
|
|
1643
|
+
/** UUID */
|
|
1644
|
+
uuid: string;
|
|
1645
|
+
/** Attachment mime type */
|
|
1646
|
+
mimeType: string;
|
|
1647
|
+
/** File name */
|
|
1648
|
+
name: string;
|
|
1649
|
+
/** Full URL to access the file. This is required for the AI to be able to see the attachment. */
|
|
1650
|
+
url?: string;
|
|
1651
|
+
/** UNIX timestamp (milliseconds since epoch) when the file was added */
|
|
1652
|
+
dateAdded?: number;
|
|
1653
|
+
/** Internal path to where the file is stored */
|
|
1654
|
+
path?: string;
|
|
1655
|
+
/** File size */
|
|
1656
|
+
size?: number;
|
|
1444
1657
|
}
|
|
1445
1658
|
/** Parameter definition used by IntelliWeave */
|
|
1446
1659
|
interface IntelliWeaveParameterDefinition {
|
|
@@ -1572,11 +1785,18 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1572
1785
|
private _lastBackground?;
|
|
1573
1786
|
private _lastTextColor?;
|
|
1574
1787
|
private _lastDisplayMode?;
|
|
1788
|
+
private _lastLayout?;
|
|
1789
|
+
private _lastPersonaName?;
|
|
1790
|
+
private _lastHeaderLogo?;
|
|
1575
1791
|
private _lastPositioningMode?;
|
|
1576
1792
|
private _lastPositionX?;
|
|
1577
1793
|
private _lastPositionY?;
|
|
1578
1794
|
private _lastOffsetX?;
|
|
1579
1795
|
private _lastOffsetY?;
|
|
1796
|
+
/** Apply persona-based color variants as CSS variables */
|
|
1797
|
+
private applyPersonaColorVariants;
|
|
1798
|
+
/** Parse a color string to RGB (supports hex and rgb/rgba) */
|
|
1799
|
+
private parseColorToRGB;
|
|
1580
1800
|
/** Apply UI styles from config and attributes, prioritizing attributes */
|
|
1581
1801
|
private applyConfigStylesAndAttributes;
|
|
1582
1802
|
/** Called on update */
|
|
@@ -1600,13 +1820,19 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1600
1820
|
/** Process input text from the user */
|
|
1601
1821
|
processInput(inputText: string): Promise<void>;
|
|
1602
1822
|
/** Called when the AI responds with some text */
|
|
1603
|
-
onAIMessage(
|
|
1604
|
-
/**
|
|
1605
|
-
|
|
1823
|
+
onAIMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean): Promise<void>;
|
|
1824
|
+
/** Updates a text element */
|
|
1825
|
+
updateTextElement(elementID: string, text: string): void;
|
|
1826
|
+
/** Updates an info block element */
|
|
1827
|
+
updateInfoElement(elementID: string, text: string, iconType: string): void;
|
|
1606
1828
|
/** Called when a suggestion button is clicked */
|
|
1607
1829
|
onSuggestionClick(e: Event, suggestion: string): void;
|
|
1608
1830
|
/** Called when an LLM model is selected */
|
|
1609
1831
|
onLLMModelSelect(e: CustomEvent): void;
|
|
1832
|
+
/** Called when the content area is scrolled */
|
|
1833
|
+
onContentScroll(e: Event): void;
|
|
1834
|
+
/** Displays whitelabeled branding for known apps */
|
|
1835
|
+
private updateBrandingFor;
|
|
1610
1836
|
}
|
|
1611
1837
|
|
|
1612
1838
|
/** Utility to trim whitespace from blocks of text */
|
|
@@ -1632,6 +1858,8 @@ interface IntelliWeaveGlobalConfig {
|
|
|
1632
1858
|
backgroundColor?: string;
|
|
1633
1859
|
/** Display mode: 'closed' (default - starts minimized) or 'open' (always open) */
|
|
1634
1860
|
displayMode?: 'closed' | 'open';
|
|
1861
|
+
/** Layout preset: 'widget' (default) or 'fullscreen' */
|
|
1862
|
+
layout?: 'widget' | 'fullscreen';
|
|
1635
1863
|
/** Positioning mode: 'fixed' (default - floats on page) or 'container' (fills parent container) */
|
|
1636
1864
|
positioningMode?: 'fixed' | 'container';
|
|
1637
1865
|
/** Horizontal position: 'left' or 'right' (default: 'right') - only used when positioningMode is 'fixed' */
|
|
@@ -1656,55 +1884,44 @@ declare function getDefaultUserID(): string;
|
|
|
1656
1884
|
/** Convert an IntelliWeave parameter list to JSON schema. Does not modify if it's already a JSON schema. */
|
|
1657
1885
|
declare function convertParamsToJSONSchema(params: KnowledgeBaseActionParameterSchema): JSONSchema7;
|
|
1658
1886
|
|
|
1659
|
-
/**
|
|
1660
|
-
interface
|
|
1661
|
-
|
|
1662
|
-
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
1663
|
-
/** Content of the message */
|
|
1664
|
-
content: string;
|
|
1665
|
-
/** Tool call ID */
|
|
1666
|
-
tool_call_id?: string;
|
|
1667
|
-
/** Tool calls made by the AI */
|
|
1668
|
-
tool_calls?: any[];
|
|
1887
|
+
/** OpenRouter message extensions */
|
|
1888
|
+
interface OpenRouterMessage extends OpenAI.Chat.ChatCompletionAssistantMessageParam {
|
|
1889
|
+
reasoning?: string;
|
|
1669
1890
|
}
|
|
1891
|
+
/** OpenAI message format */
|
|
1892
|
+
type DataType$1 = OpenRouterMessage | OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
|
1670
1893
|
/**
|
|
1671
|
-
* API for interacting with
|
|
1894
|
+
* API for interacting with Anthropic APIs.
|
|
1672
1895
|
*/
|
|
1673
|
-
declare class ChatGPT extends ChatBase<
|
|
1674
|
-
/**
|
|
1675
|
-
sendMessage(message: string): Promise<string>;
|
|
1676
|
-
/** Insert a message as if the assistant has written it */
|
|
1677
|
-
addAssistantMessage(message: string): void;
|
|
1678
|
-
/** 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. */
|
|
1896
|
+
declare class ChatGPT extends ChatBase<DataType$1> {
|
|
1897
|
+
/** Add a user message to the message history */
|
|
1679
1898
|
addUserMessage(message: string): void;
|
|
1680
|
-
/**
|
|
1681
|
-
|
|
1682
|
-
/**
|
|
1683
|
-
|
|
1684
|
-
/**
|
|
1685
|
-
|
|
1899
|
+
/** Add an assistant message to the message history */
|
|
1900
|
+
addAssistantMessage(message: string): void;
|
|
1901
|
+
/** Create the OpenAI client */
|
|
1902
|
+
protected createOpenAIClient(): OpenAI;
|
|
1903
|
+
/** Send a message, and get the response string. */
|
|
1904
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType$1>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1905
|
+
/** Parse a message block into our format */
|
|
1906
|
+
protected parseMessageBlock(messageID: string, message: OpenRouterMessage, usage: OpenAI.Completions.CompletionUsage | undefined, isPartial: boolean): TokenWindowGroupItemParams<DataType$1>;
|
|
1686
1907
|
/** Trim message list */
|
|
1687
1908
|
trimMessages(): Promise<void>;
|
|
1688
|
-
/** @private Send HTTP request to the API and return the response */
|
|
1689
|
-
sendRequest(payload: any): Promise<Response>;
|
|
1690
|
-
/** @private Send message list to the API and store the response */
|
|
1691
|
-
sendToAPI(generatePayloadOnly?: boolean): Promise<any>;
|
|
1692
|
-
/** @private Process a tool call request from the AI */
|
|
1693
|
-
processToolCall(toolCall: any): Promise<void>;
|
|
1694
1909
|
}
|
|
1695
1910
|
|
|
1911
|
+
/** Anthropic message format */
|
|
1912
|
+
type DataType = Anthropic.Messages.MessageParam;
|
|
1696
1913
|
/**
|
|
1697
1914
|
* API for interacting with Anthropic APIs.
|
|
1698
1915
|
*/
|
|
1699
|
-
declare class AnthropicChat extends ChatBase<
|
|
1916
|
+
declare class AnthropicChat extends ChatBase<DataType> {
|
|
1700
1917
|
/** Add a user message to the message history */
|
|
1701
1918
|
addUserMessage(message: string): void;
|
|
1702
1919
|
/** Add an assistant message to the message history */
|
|
1703
1920
|
addAssistantMessage(message: string): void;
|
|
1704
|
-
/** Send a message, and get the response */
|
|
1705
|
-
sendMessage(message: string): Promise<
|
|
1706
|
-
/**
|
|
1707
|
-
protected
|
|
1921
|
+
/** Send a message, and get the response string. */
|
|
1922
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1923
|
+
/** Parse a message block into our format */
|
|
1924
|
+
protected parseMessageBlock(message: Anthropic.Messages.Message, isPartial: boolean): TokenWindowGroupItemParams<DataType>;
|
|
1708
1925
|
/** Trim message list */
|
|
1709
1926
|
trimMessages(): Promise<void>;
|
|
1710
1927
|
}
|
|
@@ -1733,55 +1950,4 @@ declare class Logging {
|
|
|
1733
1950
|
timer(name: string, ...args: any[]): (...args: any[]) => void;
|
|
1734
1951
|
}
|
|
1735
1952
|
|
|
1736
|
-
|
|
1737
|
-
* Handles a stream of input/output events with the specified AI model.
|
|
1738
|
-
*
|
|
1739
|
-
* @event event - Fired when an event is emitted, either by the AI or wrapper code etc.
|
|
1740
|
-
*/
|
|
1741
|
-
declare class IntelliWeaveStream extends IntelliWeave {
|
|
1742
|
-
/** Events that haven't been sent to the AI yet */
|
|
1743
|
-
pendingEvents: IntelliWeaveStreamEvent[];
|
|
1744
|
-
/** Get the system message prefix, before the KB entries are added */
|
|
1745
|
-
getContextPrefix(): Promise<string>;
|
|
1746
|
-
/** Get actions to be added to the context */
|
|
1747
|
-
/** Post an event to the AI */
|
|
1748
|
-
postEvent(event: Partial<IntelliWeaveStreamEvent>): void;
|
|
1749
|
-
/** @private Called when the AI wants to run a KB action */
|
|
1750
|
-
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
1751
|
-
/** Output an event to the event listener(s) */
|
|
1752
|
-
private emitEvent;
|
|
1753
|
-
private _isProcessingEvents;
|
|
1754
|
-
/** Process events */
|
|
1755
|
-
private processEvents;
|
|
1756
|
-
}
|
|
1757
|
-
/** Any event */
|
|
1758
|
-
interface IntelliWeaveStreamEvent {
|
|
1759
|
-
/** Event name */
|
|
1760
|
-
eventName: string;
|
|
1761
|
-
/** Event date, unix timestamp, number of milliseconds since Jan 1 1970 */
|
|
1762
|
-
timestamp: number;
|
|
1763
|
-
/** Human-readable event date */
|
|
1764
|
-
timestampDate: string;
|
|
1765
|
-
/** Direction of this event. Input events go into the AI for processing, output events come out of the AI system. */
|
|
1766
|
-
direction: 'input' | 'output';
|
|
1767
|
-
/** Assistant hint, added automatically if there's a KB entry with the same ID. */
|
|
1768
|
-
assistantHint?: string;
|
|
1769
|
-
/** Any extra data */
|
|
1770
|
-
[key: string]: any;
|
|
1771
|
-
}
|
|
1772
|
-
/** Error event schema */
|
|
1773
|
-
interface IntelliWeaveStreamErrorEvent extends IntelliWeaveStreamEvent {
|
|
1774
|
-
/** Event name */
|
|
1775
|
-
eventName: "error";
|
|
1776
|
-
/** Error details */
|
|
1777
|
-
errorMessage: string;
|
|
1778
|
-
}
|
|
1779
|
-
/** AI speaking event */
|
|
1780
|
-
interface IntelliWeaveStreamTextOutputEvent extends IntelliWeaveStreamEvent {
|
|
1781
|
-
/** Event name */
|
|
1782
|
-
eventName: "text";
|
|
1783
|
-
/** The text spoken */
|
|
1784
|
-
text: string;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
export { AnthropicChat, type BufferType, BufferedWebSocket, type BuiltInActionFlags, ChatBase, type ChatBaseConfig, type ChatBaseToolConfig, ChatGPT, type ChatGPTMessage, FixedBufferStream, IntelliWeave, type IntelliWeaveGlobalConfig, type IntelliWeaveParameterDefinition, IntelliWeaveStream, type IntelliWeaveStreamErrorEvent, type IntelliWeaveStreamEvent, type IntelliWeaveStreamTextOutputEvent, KnowledgeBase, type KnowledgeBaseActionParameterSchema, type KnowledgeBaseItem, type KnowledgeBaseSource, type KnowledgeBaseWebhookActionResponse, type KnowledgeBaseWebhookRequest, type KnowledgeBaseWebhookSearchResponse, type KnowledgeFetcher, Logging, MCPKnowledgeClient, ONNXModel, type ONNXTensors, Resampler, type SupportedArrayBuffers, TokenWindow, TokenWindowGroup, type TokenWindowGroupItem, type WebWeaverGPTConfig, audioToWav, convertParamsToJSONSchema, floatTo16BitPCM, floatTo64BitPCM, getDefaultUserID, int16ToFloat32BitPCM, intelliweaveConfig, intelliweaveGlobalThis, sseEvents, trimWhitespaceInText };
|
|
1953
|
+
export { AnthropicChat, type BufferType, BufferedWebSocket, type BuiltInActionFlags, ChatBase, type ChatBaseConfig, type ChatBaseToolConfig, ChatGPT, FixedBufferStream, IntelliWeave, type IntelliWeaveGlobalConfig, IntelliWeaveMessageParser, type IntelliWeaveParameterDefinition, KnowledgeBase, type KnowledgeBaseActionParameterSchema, type KnowledgeBaseItem, type KnowledgeBaseItemAttachment, type KnowledgeBaseSource, type KnowledgeBaseWebhookActionResponse, type KnowledgeBaseWebhookRequest, type KnowledgeBaseWebhookSearchResponse, type KnowledgeFetcher, Logging, MCPKnowledgeClient, ONNXModel, type ONNXTensors, Resampler, type SupportedArrayBuffers, TokenWindow, TokenWindowGroup, type TokenWindowGroupItem, type TokenWindowGroupItemParams, type TokenWindowGroupItemSection, TokenWindowGroupItemSectionType, type WebWeaverGPTConfig, audioToWav, convertParamsToJSONSchema, floatTo16BitPCM, floatTo64BitPCM, getDefaultUserID, int16ToFloat32BitPCM, intelliweaveConfig, intelliweaveGlobalThis, sseEvents, trimWhitespaceInText };
|