@intelliweave/embedded 2.0.72-beta.1 → 2.0.72-beta.11
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 +350 -130
- package/dist/component/component.js +344 -48
- 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 +375 -216
- package/dist/node/node.js +48 -24
- package/dist/react/react.d.ts +341 -127
- package/dist/react/react.js +204 -36
- 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 +288 -3333
- package/dist/webpack/index.d.ts +412 -216
- package/dist/webpack/index.js +209 -37
- 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,97 @@ 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
|
+
/** Disable RAG search for subagents. If true, only KB entries with isContext=true will be used. */
|
|
1338
|
+
disableRagSearch?: boolean;
|
|
1339
|
+
/** Extra knowledge base sources for the sub-agent */
|
|
1340
|
+
knowledge?: KnowledgeFetcher;
|
|
1341
|
+
/** Optional extra configuration for the subagent instance */
|
|
1342
|
+
config?: Partial<WebWeaverGPTConfig>;
|
|
1343
|
+
/** Called when the subagent is loaded */
|
|
1344
|
+
onAgentLoaded?: (agent: IntelliWeave) => Promise<void> | void;
|
|
1170
1345
|
}
|
|
1171
1346
|
|
|
1172
1347
|
/** Built-in action flags for the persona */
|
|
@@ -1218,6 +1393,8 @@ interface WebWeaverGPTConfig {
|
|
|
1218
1393
|
offsetX?: number;
|
|
1219
1394
|
/** Vertical offset from edge in pixels (default: 20) - only used when positioningMode is 'fixed' */
|
|
1220
1395
|
offsetY?: number;
|
|
1396
|
+
/** Identifier of an external app or service which manages this persona, if any. (eg. "chatterly") */
|
|
1397
|
+
managedBy?: string;
|
|
1221
1398
|
/** Voice information */
|
|
1222
1399
|
voice?: {
|
|
1223
1400
|
/** Provider ID */
|
|
@@ -1242,6 +1419,10 @@ interface WebWeaverGPTConfig {
|
|
|
1242
1419
|
mcpServers?: MCPKnowledgeClient['config'][];
|
|
1243
1420
|
/** Built-in action flags that are currently enabled */
|
|
1244
1421
|
flags?: BuiltInActionFlags;
|
|
1422
|
+
/** Allow custom chat provider */
|
|
1423
|
+
onCreateProvider?: (config: ChatBaseConfig) => ChatBase;
|
|
1424
|
+
/** Subagents */
|
|
1425
|
+
subagents?: SubAgentConfig[];
|
|
1245
1426
|
}
|
|
1246
1427
|
/**
|
|
1247
1428
|
* IntelliWeave interface, loads a Persona from the hub and allows you to interact with it. This is the main entry point into the IntelliWeave
|
|
@@ -1252,7 +1433,7 @@ interface WebWeaverGPTConfig {
|
|
|
1252
1433
|
* - 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.
|
|
1253
1434
|
* - event `webweaver_error` - Fired when an error occurs during loading. This is a global event that is fired on the window object.
|
|
1254
1435
|
* - event `input` - Fired when the user sends a message to the AI.
|
|
1255
|
-
* - event `output` - Fired when the AI sends a message back to the user. If `event.detail.
|
|
1436
|
+
* - 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.
|
|
1256
1437
|
* - event `toolstart` - Fired when the AI starts performing an action.
|
|
1257
1438
|
* - event `tool` - Fired when the AI finishes performing an action.
|
|
1258
1439
|
*/
|
|
@@ -1261,14 +1442,16 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1261
1442
|
static version: string;
|
|
1262
1443
|
/** Built-in actions version - increment this when adding new actions */
|
|
1263
1444
|
static builtInActionsVersion: string;
|
|
1264
|
-
/** Callback when a message from the AI is returned. If
|
|
1265
|
-
onAIMessage?: (
|
|
1445
|
+
/** Callback when a message from the AI is returned. If isPartial is true, it may be incomplete and be called again with more updates. */
|
|
1446
|
+
onAIMessage?: (messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean) => void;
|
|
1266
1447
|
/** Callback when the AI starts performing an action */
|
|
1267
1448
|
onAIToolStart?: ChatBaseConfig['onAIToolStart'];
|
|
1268
1449
|
/** Current conversation ID */
|
|
1269
1450
|
conversationID: string;
|
|
1270
1451
|
/** Knowledge database interface */
|
|
1271
1452
|
knowledgeBase: KnowledgeBase;
|
|
1453
|
+
/** Subagent interface */
|
|
1454
|
+
subAgents: SubAgents;
|
|
1272
1455
|
/** Last KB search that was performed */
|
|
1273
1456
|
private _lastKBsearch;
|
|
1274
1457
|
/** If set, the next time a request is made this is the KB result items that will be used, once-off. */
|
|
@@ -1312,7 +1495,7 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1312
1495
|
/** URL of the IntelliWeave Hub API */
|
|
1313
1496
|
hubAPI: string;
|
|
1314
1497
|
/** Set model and load data from an API key */
|
|
1315
|
-
load(apiKey: string): Promise<
|
|
1498
|
+
load(apiKey: string, config?: Partial<WebWeaverGPTConfig>): Promise<IntelliWeave>;
|
|
1316
1499
|
/** Set the current model */
|
|
1317
1500
|
setModel(id: string): void;
|
|
1318
1501
|
private _lastSystemMsg;
|
|
@@ -1320,18 +1503,19 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1320
1503
|
getContextPrefix(): Promise<string>;
|
|
1321
1504
|
/** Get system message to send to the AI */
|
|
1322
1505
|
onBeforeMessageProcessing(): Promise<void>;
|
|
1323
|
-
/** @private Process incoming message from the AI. Can be used to respond to encoded actions in the text response. */
|
|
1324
|
-
processIncomingMessage(
|
|
1506
|
+
/** @private Process incoming message(s) from the AI. Can be used to respond to encoded actions in the text response. */
|
|
1507
|
+
processIncomingMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial?: boolean): void;
|
|
1325
1508
|
/** True if currently processing a message */
|
|
1326
1509
|
isProcessing: boolean;
|
|
1327
|
-
/** @private Last tracked token count for calculating per-message token usage */
|
|
1328
|
-
private _lastTrackedTokens;
|
|
1329
1510
|
/** Send a message, and get the response */
|
|
1330
|
-
sendMessage(message: string): Promise<
|
|
1511
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<unknown>[]) => void): Promise<IntelliWeaveMessageParser>;
|
|
1331
1512
|
/** @private Called when the AI wants to run a KB action */
|
|
1332
1513
|
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
1333
|
-
/** Submit an analytics event asynchronously */
|
|
1514
|
+
/** Submit an analytics event asynchronously. These events are for use in the Conversation Analytics code. For anonymous statistic analysis, use track() instead. */
|
|
1515
|
+
private activeAnalyticsPromises;
|
|
1334
1516
|
submitAnalyticsEvent(data: any): void;
|
|
1517
|
+
/** Wait for all analytics events to finish */
|
|
1518
|
+
waitForAnalytics(): Promise<void>;
|
|
1335
1519
|
/** Reset the conversation */
|
|
1336
1520
|
resetConversation(): void;
|
|
1337
1521
|
/** Insert a message as if the assistant has written it */
|
|
@@ -1340,12 +1524,14 @@ declare class IntelliWeave extends EventTarget {
|
|
|
1340
1524
|
exportState(): {
|
|
1341
1525
|
type: string;
|
|
1342
1526
|
conversationID: string;
|
|
1343
|
-
messages: any[] | undefined;
|
|
1527
|
+
messages: TokenWindowGroupItem<any>[] | undefined;
|
|
1344
1528
|
};
|
|
1345
1529
|
/** Import conversation state from JSON */
|
|
1346
1530
|
importState(state: any): void;
|
|
1347
1531
|
/** Clone this instance without any message history */
|
|
1348
1532
|
clone(): IntelliWeave;
|
|
1533
|
+
/** Get all messages in the conversation history */
|
|
1534
|
+
get messages(): TokenWindowGroupItem<any>[];
|
|
1349
1535
|
}
|
|
1350
1536
|
|
|
1351
1537
|
/**
|
|
@@ -1362,8 +1548,18 @@ declare class KnowledgeBase {
|
|
|
1362
1548
|
lastResults: KnowledgeBaseItem[];
|
|
1363
1549
|
/** Individual knowledge base entries added manually by the application */
|
|
1364
1550
|
manualEntries: KnowledgeBaseItem[];
|
|
1551
|
+
/** If true, allows using globally defined sources from the browser window events */
|
|
1552
|
+
allowWindowSources: boolean;
|
|
1553
|
+
/** If true, allows using knowledge specified in the global configuration object */
|
|
1554
|
+
allowGlobalConfigSources: boolean;
|
|
1555
|
+
/** If true, allows the AI to search the knowledge base. If false, essentially disables RAG lookup. */
|
|
1556
|
+
allowRagSearch: boolean;
|
|
1365
1557
|
/** Constructor */
|
|
1366
1558
|
constructor(ai: IntelliWeave);
|
|
1559
|
+
/** Ensures the internal knowledge is set correctly */
|
|
1560
|
+
ensureInternalKnowledge(): void;
|
|
1561
|
+
/** Clears all knowledge back to the default */
|
|
1562
|
+
reset(): void;
|
|
1367
1563
|
/**
|
|
1368
1564
|
* Register a new knowledge base source. You can pass either just a query function, or an ID and a query function.
|
|
1369
1565
|
*
|
|
@@ -1386,7 +1582,7 @@ declare class KnowledgeBase {
|
|
|
1386
1582
|
/** Create and register an external knowledge base source from a URL */
|
|
1387
1583
|
registerSourceFromURL(url: string, id?: string): void;
|
|
1388
1584
|
/** Clone this instance */
|
|
1389
|
-
clone(): KnowledgeBase;
|
|
1585
|
+
clone(newIW: IntelliWeave): KnowledgeBase;
|
|
1390
1586
|
/** Registers an MCP server as a knowledge base source */
|
|
1391
1587
|
registerMCPSource(config: MCPKnowledgeClient['config']): MCPKnowledgeClient;
|
|
1392
1588
|
}
|
|
@@ -1427,8 +1623,8 @@ interface KnowledgeBaseItem {
|
|
|
1427
1623
|
name: string;
|
|
1428
1624
|
/** Item tags. Helps with search optimization. */
|
|
1429
1625
|
tags?: string;
|
|
1430
|
-
/** Item content
|
|
1431
|
-
content: string
|
|
1626
|
+
/** Item content */
|
|
1627
|
+
content: string;
|
|
1432
1628
|
/** If true, this item will always be returned from all search results. */
|
|
1433
1629
|
isContext?: boolean;
|
|
1434
1630
|
/** If true, this item will not be visible to the AI. */
|
|
@@ -1441,8 +1637,27 @@ interface KnowledgeBaseItem {
|
|
|
1441
1637
|
* that was performed. If an error is thrown, the AI will respond appropriately to the user.
|
|
1442
1638
|
*/
|
|
1443
1639
|
action?: (input: any, ai: IntelliWeave) => (any | Promise<any>);
|
|
1444
|
-
/** If
|
|
1445
|
-
|
|
1640
|
+
/** If specified, will hide this action from the default UI after the AI finishes running it, or always hide it */
|
|
1641
|
+
hideActionInUI?: 'always' | 'after-complete';
|
|
1642
|
+
/** Attachments such as images, etc */
|
|
1643
|
+
attachments?: KnowledgeBaseItemAttachment[];
|
|
1644
|
+
}
|
|
1645
|
+
/** Knowledge base item attachment, such as an image, file, etc. */
|
|
1646
|
+
interface KnowledgeBaseItemAttachment {
|
|
1647
|
+
/** UUID */
|
|
1648
|
+
uuid: string;
|
|
1649
|
+
/** Attachment mime type */
|
|
1650
|
+
mimeType: string;
|
|
1651
|
+
/** File name */
|
|
1652
|
+
name: string;
|
|
1653
|
+
/** Full URL to access the file. This is required for the AI to be able to see the attachment. */
|
|
1654
|
+
url?: string;
|
|
1655
|
+
/** UNIX timestamp (milliseconds since epoch) when the file was added */
|
|
1656
|
+
dateAdded?: number;
|
|
1657
|
+
/** Internal path to where the file is stored */
|
|
1658
|
+
path?: string;
|
|
1659
|
+
/** File size */
|
|
1660
|
+
size?: number;
|
|
1446
1661
|
}
|
|
1447
1662
|
/** Parameter definition used by IntelliWeave */
|
|
1448
1663
|
interface IntelliWeaveParameterDefinition {
|
|
@@ -1609,13 +1824,19 @@ declare class WebWeaverEmbed extends BaseComponent {
|
|
|
1609
1824
|
/** Process input text from the user */
|
|
1610
1825
|
processInput(inputText: string): Promise<void>;
|
|
1611
1826
|
/** Called when the AI responds with some text */
|
|
1612
|
-
onAIMessage(
|
|
1613
|
-
/**
|
|
1614
|
-
|
|
1827
|
+
onAIMessage(messages: TokenWindowGroupItemParams<unknown>[], isPartial: boolean): Promise<void>;
|
|
1828
|
+
/** Updates a text element */
|
|
1829
|
+
updateTextElement(elementID: string, text: string): void;
|
|
1830
|
+
/** Updates an info block element */
|
|
1831
|
+
updateInfoElement(elementID: string, text: string, iconType: string): void;
|
|
1615
1832
|
/** Called when a suggestion button is clicked */
|
|
1616
1833
|
onSuggestionClick(e: Event, suggestion: string): void;
|
|
1617
1834
|
/** Called when an LLM model is selected */
|
|
1618
1835
|
onLLMModelSelect(e: CustomEvent): void;
|
|
1836
|
+
/** Called when the content area is scrolled */
|
|
1837
|
+
onContentScroll(e: Event): void;
|
|
1838
|
+
/** Displays whitelabeled branding for known apps */
|
|
1839
|
+
private updateBrandingFor;
|
|
1619
1840
|
}
|
|
1620
1841
|
|
|
1621
1842
|
/** Utility to trim whitespace from blocks of text */
|
|
@@ -1667,55 +1888,44 @@ declare function getDefaultUserID(): string;
|
|
|
1667
1888
|
/** Convert an IntelliWeave parameter list to JSON schema. Does not modify if it's already a JSON schema. */
|
|
1668
1889
|
declare function convertParamsToJSONSchema(params: KnowledgeBaseActionParameterSchema): JSONSchema7;
|
|
1669
1890
|
|
|
1670
|
-
/**
|
|
1671
|
-
interface
|
|
1672
|
-
|
|
1673
|
-
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
1674
|
-
/** Content of the message */
|
|
1675
|
-
content: string;
|
|
1676
|
-
/** Tool call ID */
|
|
1677
|
-
tool_call_id?: string;
|
|
1678
|
-
/** Tool calls made by the AI */
|
|
1679
|
-
tool_calls?: any[];
|
|
1891
|
+
/** OpenRouter message extensions */
|
|
1892
|
+
interface OpenRouterMessage extends OpenAI.Chat.ChatCompletionAssistantMessageParam {
|
|
1893
|
+
reasoning?: string;
|
|
1680
1894
|
}
|
|
1895
|
+
/** OpenAI message format */
|
|
1896
|
+
type DataType$1 = OpenRouterMessage | OpenAI.Chat.Completions.ChatCompletionMessageParam;
|
|
1681
1897
|
/**
|
|
1682
|
-
* API for interacting with
|
|
1898
|
+
* API for interacting with Anthropic APIs.
|
|
1683
1899
|
*/
|
|
1684
|
-
declare class ChatGPT extends ChatBase<
|
|
1685
|
-
/**
|
|
1686
|
-
sendMessage(message: string): Promise<string>;
|
|
1687
|
-
/** Insert a message as if the assistant has written it */
|
|
1688
|
-
addAssistantMessage(message: string): void;
|
|
1689
|
-
/** 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. */
|
|
1900
|
+
declare class ChatGPT extends ChatBase<DataType$1> {
|
|
1901
|
+
/** Add a user message to the message history */
|
|
1690
1902
|
addUserMessage(message: string): void;
|
|
1691
|
-
/**
|
|
1692
|
-
|
|
1693
|
-
/**
|
|
1694
|
-
|
|
1695
|
-
/**
|
|
1696
|
-
|
|
1903
|
+
/** Add an assistant message to the message history */
|
|
1904
|
+
addAssistantMessage(message: string): void;
|
|
1905
|
+
/** Create the OpenAI client */
|
|
1906
|
+
protected createOpenAIClient(): OpenAI;
|
|
1907
|
+
/** Send a message, and get the response string. */
|
|
1908
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType$1>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1909
|
+
/** Parse a message block into our format */
|
|
1910
|
+
protected parseMessageBlock(messageID: string, message: OpenRouterMessage, usage: OpenAI.Completions.CompletionUsage | undefined, isPartial: boolean): TokenWindowGroupItemParams<DataType$1>;
|
|
1697
1911
|
/** Trim message list */
|
|
1698
1912
|
trimMessages(): Promise<void>;
|
|
1699
|
-
/** @private Send HTTP request to the API and return the response */
|
|
1700
|
-
sendRequest(payload: any): Promise<Response>;
|
|
1701
|
-
/** @private Send message list to the API and store the response */
|
|
1702
|
-
sendToAPI(generatePayloadOnly?: boolean): Promise<any>;
|
|
1703
|
-
/** @private Process a tool call request from the AI */
|
|
1704
|
-
processToolCall(toolCall: any): Promise<void>;
|
|
1705
1913
|
}
|
|
1706
1914
|
|
|
1915
|
+
/** Anthropic message format */
|
|
1916
|
+
type DataType = Anthropic.Messages.MessageParam;
|
|
1707
1917
|
/**
|
|
1708
1918
|
* API for interacting with Anthropic APIs.
|
|
1709
1919
|
*/
|
|
1710
|
-
declare class AnthropicChat extends ChatBase<
|
|
1920
|
+
declare class AnthropicChat extends ChatBase<DataType> {
|
|
1711
1921
|
/** Add a user message to the message history */
|
|
1712
1922
|
addUserMessage(message: string): void;
|
|
1713
1923
|
/** Add an assistant message to the message history */
|
|
1714
1924
|
addAssistantMessage(message: string): void;
|
|
1715
|
-
/** Send a message, and get the response */
|
|
1716
|
-
sendMessage(message: string): Promise<
|
|
1717
|
-
/**
|
|
1718
|
-
protected
|
|
1925
|
+
/** Send a message, and get the response string. */
|
|
1926
|
+
sendMessage(message: string, onPartial?: (items: TokenWindowGroupItemParams<DataType>[]) => void): Promise<TokenWindowGroupItemParams<any>[]>;
|
|
1927
|
+
/** Parse a message block into our format */
|
|
1928
|
+
protected parseMessageBlock(message: Anthropic.Messages.Message, isPartial: boolean): TokenWindowGroupItemParams<DataType>;
|
|
1719
1929
|
/** Trim message list */
|
|
1720
1930
|
trimMessages(): Promise<void>;
|
|
1721
1931
|
}
|
|
@@ -1744,55 +1954,4 @@ declare class Logging {
|
|
|
1744
1954
|
timer(name: string, ...args: any[]): (...args: any[]) => void;
|
|
1745
1955
|
}
|
|
1746
1956
|
|
|
1747
|
-
|
|
1748
|
-
* Handles a stream of input/output events with the specified AI model.
|
|
1749
|
-
*
|
|
1750
|
-
* @event event - Fired when an event is emitted, either by the AI or wrapper code etc.
|
|
1751
|
-
*/
|
|
1752
|
-
declare class IntelliWeaveStream extends IntelliWeave {
|
|
1753
|
-
/** Events that haven't been sent to the AI yet */
|
|
1754
|
-
pendingEvents: IntelliWeaveStreamEvent[];
|
|
1755
|
-
/** Get the system message prefix, before the KB entries are added */
|
|
1756
|
-
getContextPrefix(): Promise<string>;
|
|
1757
|
-
/** Get actions to be added to the context */
|
|
1758
|
-
/** Post an event to the AI */
|
|
1759
|
-
postEvent(event: Partial<IntelliWeaveStreamEvent>): void;
|
|
1760
|
-
/** @private Called when the AI wants to run a KB action */
|
|
1761
|
-
toolRunKBAction(kb: KnowledgeBaseItem, input: any): Promise<any>;
|
|
1762
|
-
/** Output an event to the event listener(s) */
|
|
1763
|
-
private emitEvent;
|
|
1764
|
-
private _isProcessingEvents;
|
|
1765
|
-
/** Process events */
|
|
1766
|
-
private processEvents;
|
|
1767
|
-
}
|
|
1768
|
-
/** Any event */
|
|
1769
|
-
interface IntelliWeaveStreamEvent {
|
|
1770
|
-
/** Event name */
|
|
1771
|
-
eventName: string;
|
|
1772
|
-
/** Event date, unix timestamp, number of milliseconds since Jan 1 1970 */
|
|
1773
|
-
timestamp: number;
|
|
1774
|
-
/** Human-readable event date */
|
|
1775
|
-
timestampDate: string;
|
|
1776
|
-
/** Direction of this event. Input events go into the AI for processing, output events come out of the AI system. */
|
|
1777
|
-
direction: 'input' | 'output';
|
|
1778
|
-
/** Assistant hint, added automatically if there's a KB entry with the same ID. */
|
|
1779
|
-
assistantHint?: string;
|
|
1780
|
-
/** Any extra data */
|
|
1781
|
-
[key: string]: any;
|
|
1782
|
-
}
|
|
1783
|
-
/** Error event schema */
|
|
1784
|
-
interface IntelliWeaveStreamErrorEvent extends IntelliWeaveStreamEvent {
|
|
1785
|
-
/** Event name */
|
|
1786
|
-
eventName: "error";
|
|
1787
|
-
/** Error details */
|
|
1788
|
-
errorMessage: string;
|
|
1789
|
-
}
|
|
1790
|
-
/** AI speaking event */
|
|
1791
|
-
interface IntelliWeaveStreamTextOutputEvent extends IntelliWeaveStreamEvent {
|
|
1792
|
-
/** Event name */
|
|
1793
|
-
eventName: "text";
|
|
1794
|
-
/** The text spoken */
|
|
1795
|
-
text: string;
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
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 };
|
|
1957
|
+
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 };
|