@uipath/uipath-typescript 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -0
- package/dist/assets/index.cjs +199 -221
- package/dist/assets/index.mjs +199 -221
- package/dist/buckets/index.cjs +199 -221
- package/dist/buckets/index.mjs +199 -221
- package/dist/cases/index.cjs +220 -238
- package/dist/cases/index.mjs +220 -238
- package/dist/conversational-agent/index.cjs +6622 -0
- package/dist/conversational-agent/index.d.ts +6579 -0
- package/dist/conversational-agent/index.mjs +6575 -0
- package/dist/core/index.cjs +1196 -1158
- package/dist/core/index.d.ts +2 -10
- package/dist/core/index.mjs +1196 -1158
- package/dist/entities/index.cjs +199 -221
- package/dist/entities/index.mjs +199 -221
- package/dist/index.cjs +744 -418
- package/dist/index.d.ts +4342 -13
- package/dist/index.mjs +738 -419
- package/dist/index.umd.js +744 -418
- package/dist/maestro-processes/index.cjs +199 -221
- package/dist/maestro-processes/index.mjs +199 -221
- package/dist/processes/index.cjs +246 -232
- package/dist/processes/index.d.ts +1 -1
- package/dist/processes/index.mjs +246 -232
- package/dist/queues/index.cjs +199 -221
- package/dist/queues/index.mjs +199 -221
- package/dist/tasks/index.cjs +199 -221
- package/dist/tasks/index.mjs +199 -221
- package/package.json +22 -4
package/dist/index.d.ts
CHANGED
|
@@ -5585,6 +5585,4343 @@ declare class UiPath extends UiPath$1 {
|
|
|
5585
5585
|
get assets(): AssetService;
|
|
5586
5586
|
}
|
|
5587
5587
|
|
|
5588
|
+
/**
|
|
5589
|
+
* Constants for Conversational Agent
|
|
5590
|
+
*/
|
|
5591
|
+
/**
|
|
5592
|
+
* Maps API response fields to SDK field names (API → SDK)
|
|
5593
|
+
* Used when transforming API responses for SDK consumers.
|
|
5594
|
+
* For request transformation (SDK → API), use `transformRequest(data, ConversationMap)`.
|
|
5595
|
+
*/
|
|
5596
|
+
declare const ConversationMap: {
|
|
5597
|
+
[key: string]: string;
|
|
5598
|
+
};
|
|
5599
|
+
/**
|
|
5600
|
+
* Maps fields for Exchange entity to ensure consistent SDK naming
|
|
5601
|
+
*/
|
|
5602
|
+
declare const ExchangeMap: {
|
|
5603
|
+
[key: string]: string;
|
|
5604
|
+
};
|
|
5605
|
+
/**
|
|
5606
|
+
* Maps fields for Message entity to ensure consistent SDK naming
|
|
5607
|
+
*/
|
|
5608
|
+
declare const MessageMap: {
|
|
5609
|
+
[key: string]: string;
|
|
5610
|
+
};
|
|
5611
|
+
|
|
5612
|
+
/**
|
|
5613
|
+
* Common types for Conversational Agent
|
|
5614
|
+
* Contains IDs, primitives, and utility types used across conversation types.
|
|
5615
|
+
*/
|
|
5616
|
+
/**
|
|
5617
|
+
* Identifies the origin of a message in the conversation.
|
|
5618
|
+
*/
|
|
5619
|
+
declare enum MessageRole {
|
|
5620
|
+
System = "system",
|
|
5621
|
+
User = "user",
|
|
5622
|
+
Assistant = "assistant"
|
|
5623
|
+
}
|
|
5624
|
+
/**
|
|
5625
|
+
* Identifies the type of an interrupt.
|
|
5626
|
+
*/
|
|
5627
|
+
declare enum InterruptType {
|
|
5628
|
+
ToolCallConfirmation = "uipath_cas_tool_call_confirmation"
|
|
5629
|
+
}
|
|
5630
|
+
/**
|
|
5631
|
+
* Base interface for citation sources.
|
|
5632
|
+
*/
|
|
5633
|
+
interface CitationSourceBase {
|
|
5634
|
+
/**
|
|
5635
|
+
* Title for the citation source, suitable for display to users.
|
|
5636
|
+
*/
|
|
5637
|
+
title: string;
|
|
5638
|
+
/**
|
|
5639
|
+
* Label number for the citation source, suitable for display to users
|
|
5640
|
+
* (e.g. [1] for the first unique source, [2] for the second, etc.).
|
|
5641
|
+
*/
|
|
5642
|
+
number: number;
|
|
5643
|
+
}
|
|
5644
|
+
/**
|
|
5645
|
+
* Used when the citation can be rendered as a link.
|
|
5646
|
+
*/
|
|
5647
|
+
interface CitationSourceUrl extends CitationSourceBase {
|
|
5648
|
+
/**
|
|
5649
|
+
* Citation url.
|
|
5650
|
+
*/
|
|
5651
|
+
url: string;
|
|
5652
|
+
}
|
|
5653
|
+
/**
|
|
5654
|
+
* Used when the citation references media, such as a PDF document.
|
|
5655
|
+
*/
|
|
5656
|
+
interface CitationSourceMedia extends CitationSourceBase {
|
|
5657
|
+
/** The mime type of the media. If non-specified, should be discovered through the downloadUrl. */
|
|
5658
|
+
mimeType?: string;
|
|
5659
|
+
/** Download URL for the media */
|
|
5660
|
+
downloadUrl?: string;
|
|
5661
|
+
/** The page number for the media, if applicable (e.g. for application/pdf documents) */
|
|
5662
|
+
pageNumber?: string;
|
|
5663
|
+
}
|
|
5664
|
+
/**
|
|
5665
|
+
* Citation sources can target either an Url or a media (e.g. a pdf document).
|
|
5666
|
+
* Repeated citation sources within a content part are identified by the same title and number.
|
|
5667
|
+
*/
|
|
5668
|
+
type CitationSource = CitationSourceUrl | CitationSourceMedia;
|
|
5669
|
+
/**
|
|
5670
|
+
* JSON compatible primitive type.
|
|
5671
|
+
*/
|
|
5672
|
+
type JSONPrimitive = string | number | boolean | null;
|
|
5673
|
+
/**
|
|
5674
|
+
* JSON compatible value type.
|
|
5675
|
+
*/
|
|
5676
|
+
type JSONValue = JSONPrimitive | Record<string, any> | any[];
|
|
5677
|
+
/**
|
|
5678
|
+
* JSON compatible object type.
|
|
5679
|
+
*/
|
|
5680
|
+
type JSONObject = Record<string, JSONValue>;
|
|
5681
|
+
/**
|
|
5682
|
+
* JSON compatible array type.
|
|
5683
|
+
*/
|
|
5684
|
+
type JSONArray = JSONValue[];
|
|
5685
|
+
/**
|
|
5686
|
+
* An arbitrary JSON serializable object.
|
|
5687
|
+
*/
|
|
5688
|
+
type MetaData = JSONObject;
|
|
5689
|
+
/**
|
|
5690
|
+
* Produces the provided object type with specified properties changed to optional.
|
|
5691
|
+
*/
|
|
5692
|
+
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5693
|
+
/**
|
|
5694
|
+
* Produces the provided object type with specified properties changed to required.
|
|
5695
|
+
*/
|
|
5696
|
+
type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
5697
|
+
/**
|
|
5698
|
+
* Causes typescript to simplify the display of object types created using MakeOptional, MakeRequired, and other utility
|
|
5699
|
+
* types. This doesn't change the effective type, but makes popups in the ide and compile error messages cleaner.
|
|
5700
|
+
*/
|
|
5701
|
+
type Simplify<T> = T extends any[] | Date ? T : {
|
|
5702
|
+
[K in keyof T]: T[K];
|
|
5703
|
+
} & {};
|
|
5704
|
+
/**
|
|
5705
|
+
* Inline value - used when a value is small enough to be returned inline with an API result.
|
|
5706
|
+
*/
|
|
5707
|
+
interface InlineValue<T> {
|
|
5708
|
+
inline: T;
|
|
5709
|
+
}
|
|
5710
|
+
/**
|
|
5711
|
+
* External value - used when a value is too large to be returned inline with an API result.
|
|
5712
|
+
*/
|
|
5713
|
+
interface ExternalValue {
|
|
5714
|
+
uri: string;
|
|
5715
|
+
byteCount?: number;
|
|
5716
|
+
}
|
|
5717
|
+
/**
|
|
5718
|
+
* Inline or external value - used when a value can be too large to include inline in input or output data.
|
|
5719
|
+
* If the inline property is set, it contains the full value, otherwise the uri property is set and it contains an uri
|
|
5720
|
+
* from which the data can be downloaded.
|
|
5721
|
+
*/
|
|
5722
|
+
type InlineOrExternalValue<T> = InlineValue<T> | ExternalValue;
|
|
5723
|
+
/**
|
|
5724
|
+
* Tool call input value type.
|
|
5725
|
+
*/
|
|
5726
|
+
type ToolCallInputValue = JSONObject;
|
|
5727
|
+
/**
|
|
5728
|
+
* Tool call output value type.
|
|
5729
|
+
*/
|
|
5730
|
+
type ToolCallOutputValue = JSONValue;
|
|
5731
|
+
|
|
5732
|
+
/**
|
|
5733
|
+
* Core data model types for Conversational Agent REST endpoints
|
|
5734
|
+
* Contains: Conversation, Exchange, Message, ContentPart, ToolCall, etc.
|
|
5735
|
+
*/
|
|
5736
|
+
|
|
5737
|
+
/**
|
|
5738
|
+
* Represents the order in which items should be sorted.
|
|
5739
|
+
*/
|
|
5740
|
+
declare enum SortOrder {
|
|
5741
|
+
Ascending = "ascending",
|
|
5742
|
+
Descending = "descending"
|
|
5743
|
+
}
|
|
5744
|
+
/**
|
|
5745
|
+
* Represents a citation or reference to an external source within a content part.
|
|
5746
|
+
*/
|
|
5747
|
+
interface Citation {
|
|
5748
|
+
/**
|
|
5749
|
+
* Unique identifier for the citation.
|
|
5750
|
+
*/
|
|
5751
|
+
id: string;
|
|
5752
|
+
/**
|
|
5753
|
+
* Unique identifier for the citation within its content part.
|
|
5754
|
+
*/
|
|
5755
|
+
citationId: string;
|
|
5756
|
+
/**
|
|
5757
|
+
* The offset of the start of the citation target in the content part data.
|
|
5758
|
+
*/
|
|
5759
|
+
offset: number;
|
|
5760
|
+
/**
|
|
5761
|
+
* The length of the citation target in the content part data.
|
|
5762
|
+
*/
|
|
5763
|
+
length: number;
|
|
5764
|
+
/**
|
|
5765
|
+
* The source being referenced by this citation.
|
|
5766
|
+
*/
|
|
5767
|
+
sources: CitationSource[];
|
|
5768
|
+
/**
|
|
5769
|
+
* Timestamp indicating when the citation was created.
|
|
5770
|
+
*/
|
|
5771
|
+
createdTime: string;
|
|
5772
|
+
/**
|
|
5773
|
+
* Timestamp indicating when the citation was last updated.
|
|
5774
|
+
*/
|
|
5775
|
+
updatedTime: string;
|
|
5776
|
+
}
|
|
5777
|
+
/**
|
|
5778
|
+
* Citation options for input operations (without timestamps).
|
|
5779
|
+
*/
|
|
5780
|
+
interface CitationOptions {
|
|
5781
|
+
citationId: string;
|
|
5782
|
+
offset: number;
|
|
5783
|
+
length: number;
|
|
5784
|
+
sources: CitationSource[];
|
|
5785
|
+
}
|
|
5786
|
+
/**
|
|
5787
|
+
* Content part data type - can be inline or external.
|
|
5788
|
+
*/
|
|
5789
|
+
type ContentPartData = Simplify<InlineOrExternalValue<string>>;
|
|
5790
|
+
/**
|
|
5791
|
+
* Represents a single part of message content.
|
|
5792
|
+
*/
|
|
5793
|
+
interface ContentPart {
|
|
5794
|
+
/**
|
|
5795
|
+
* Unique identifier for the content part.
|
|
5796
|
+
*/
|
|
5797
|
+
id: string;
|
|
5798
|
+
/**
|
|
5799
|
+
* Unique identifier for the content part within the message.
|
|
5800
|
+
*/
|
|
5801
|
+
contentPartId: string;
|
|
5802
|
+
/**
|
|
5803
|
+
* The MIME type of the content.
|
|
5804
|
+
*/
|
|
5805
|
+
mimeType: string;
|
|
5806
|
+
/**
|
|
5807
|
+
* The actual content data.
|
|
5808
|
+
*/
|
|
5809
|
+
data: ContentPartData;
|
|
5810
|
+
/**
|
|
5811
|
+
* Array of citations referenced in this content part.
|
|
5812
|
+
*/
|
|
5813
|
+
citations: Citation[];
|
|
5814
|
+
/**
|
|
5815
|
+
* Indicates whether this content part is a transcript produced by the LLM.
|
|
5816
|
+
*/
|
|
5817
|
+
isTranscript?: boolean;
|
|
5818
|
+
/**
|
|
5819
|
+
* Indicates whether this content part may be incomplete.
|
|
5820
|
+
*/
|
|
5821
|
+
isIncomplete?: boolean;
|
|
5822
|
+
/**
|
|
5823
|
+
* Optional name for the content part.
|
|
5824
|
+
*/
|
|
5825
|
+
name?: string;
|
|
5826
|
+
/**
|
|
5827
|
+
* Timestamp indicating when the content part was created.
|
|
5828
|
+
*/
|
|
5829
|
+
createdTime: string;
|
|
5830
|
+
/**
|
|
5831
|
+
* Timestamp indicating when the content part was last updated.
|
|
5832
|
+
*/
|
|
5833
|
+
updatedTime: string;
|
|
5834
|
+
}
|
|
5835
|
+
/**
|
|
5836
|
+
* Represents the result of a tool call execution.
|
|
5837
|
+
*/
|
|
5838
|
+
interface ToolCallResult {
|
|
5839
|
+
/**
|
|
5840
|
+
* Timestamp indicating when the result was generated.
|
|
5841
|
+
*/
|
|
5842
|
+
timestamp?: string;
|
|
5843
|
+
/**
|
|
5844
|
+
* The value returned by the tool.
|
|
5845
|
+
*/
|
|
5846
|
+
output?: ToolCallOutputValue;
|
|
5847
|
+
/**
|
|
5848
|
+
* field for the tool call output value.
|
|
5849
|
+
*/
|
|
5850
|
+
value?: InlineOrExternalValue<ToolCallOutputValue>;
|
|
5851
|
+
/**
|
|
5852
|
+
* Indicates whether the tool call resulted in an error.
|
|
5853
|
+
*/
|
|
5854
|
+
isError?: boolean;
|
|
5855
|
+
/**
|
|
5856
|
+
* Indicates whether the tool call was cancelled.
|
|
5857
|
+
*/
|
|
5858
|
+
cancelled?: boolean;
|
|
5859
|
+
}
|
|
5860
|
+
/**
|
|
5861
|
+
* Represents a call to an external tool or function within a message.
|
|
5862
|
+
*/
|
|
5863
|
+
interface ToolCall {
|
|
5864
|
+
/**
|
|
5865
|
+
* Unique identifier for the tool call.
|
|
5866
|
+
*/
|
|
5867
|
+
id: string;
|
|
5868
|
+
/**
|
|
5869
|
+
* Unique identifier for the tool call within the message.
|
|
5870
|
+
*/
|
|
5871
|
+
toolCallId: string;
|
|
5872
|
+
/**
|
|
5873
|
+
* The name of the tool being called.
|
|
5874
|
+
*/
|
|
5875
|
+
name: string;
|
|
5876
|
+
/**
|
|
5877
|
+
* Optional input value provided to the tool.
|
|
5878
|
+
*/
|
|
5879
|
+
input?: ToolCallInputValue;
|
|
5880
|
+
/**
|
|
5881
|
+
* Legacy field for tool call input arguments.
|
|
5882
|
+
*/
|
|
5883
|
+
arguments?: InlineOrExternalValue<ToolCallInputValue>;
|
|
5884
|
+
/**
|
|
5885
|
+
* Timestamp indicating when the tool call was initiated.
|
|
5886
|
+
*/
|
|
5887
|
+
timestamp?: string;
|
|
5888
|
+
/**
|
|
5889
|
+
* Optional output value returned by the tool's execution.
|
|
5890
|
+
*/
|
|
5891
|
+
result?: ToolCallResult;
|
|
5892
|
+
/**
|
|
5893
|
+
* Timestamp indicating when the tool call was created.
|
|
5894
|
+
*/
|
|
5895
|
+
createdTime: string;
|
|
5896
|
+
/**
|
|
5897
|
+
* Timestamp indicating when the tool call was last updated.
|
|
5898
|
+
*/
|
|
5899
|
+
updatedTime: string;
|
|
5900
|
+
}
|
|
5901
|
+
/**
|
|
5902
|
+
* Represents an interrupt within a message.
|
|
5903
|
+
*/
|
|
5904
|
+
interface Interrupt {
|
|
5905
|
+
/**
|
|
5906
|
+
* Unique identifier for the interrupt.
|
|
5907
|
+
*/
|
|
5908
|
+
id: string;
|
|
5909
|
+
/**
|
|
5910
|
+
* Unique identifier for the interrupt within the message.
|
|
5911
|
+
*/
|
|
5912
|
+
interruptId: string;
|
|
5913
|
+
/**
|
|
5914
|
+
* The type of interrupt.
|
|
5915
|
+
*/
|
|
5916
|
+
type: InterruptType;
|
|
5917
|
+
/**
|
|
5918
|
+
* The value associated with the interrupt start event.
|
|
5919
|
+
*/
|
|
5920
|
+
interruptValue: unknown;
|
|
5921
|
+
/**
|
|
5922
|
+
* The value provided to end/resolve the interrupt.
|
|
5923
|
+
*/
|
|
5924
|
+
endValue?: unknown;
|
|
5925
|
+
/**
|
|
5926
|
+
* Timestamp indicating when the interrupt was created.
|
|
5927
|
+
*/
|
|
5928
|
+
createdTime: string;
|
|
5929
|
+
/**
|
|
5930
|
+
* Timestamp indicating when the interrupt was last updated.
|
|
5931
|
+
*/
|
|
5932
|
+
updatedTime: string;
|
|
5933
|
+
}
|
|
5934
|
+
/**
|
|
5935
|
+
* Represents a single message within a conversation exchange.
|
|
5936
|
+
*/
|
|
5937
|
+
interface Message {
|
|
5938
|
+
/**
|
|
5939
|
+
* Unique identifier for the message.
|
|
5940
|
+
*/
|
|
5941
|
+
id: string;
|
|
5942
|
+
/**
|
|
5943
|
+
* Unique identifier for the message within its exchange.
|
|
5944
|
+
*/
|
|
5945
|
+
messageId: string;
|
|
5946
|
+
/**
|
|
5947
|
+
* The role of the message sender.
|
|
5948
|
+
*/
|
|
5949
|
+
role: MessageRole;
|
|
5950
|
+
/**
|
|
5951
|
+
* Contains the message's content parts.
|
|
5952
|
+
*/
|
|
5953
|
+
contentParts: ContentPart[];
|
|
5954
|
+
/**
|
|
5955
|
+
* Array of tool calls made within this message.
|
|
5956
|
+
*/
|
|
5957
|
+
toolCalls: ToolCall[];
|
|
5958
|
+
/**
|
|
5959
|
+
* Array of interrupts within this message.
|
|
5960
|
+
*/
|
|
5961
|
+
interrupts: Interrupt[];
|
|
5962
|
+
/**
|
|
5963
|
+
* Timestamp indicating when the message was created.
|
|
5964
|
+
*/
|
|
5965
|
+
createdTime: string;
|
|
5966
|
+
/**
|
|
5967
|
+
* Timestamp indicating when the message was last updated.
|
|
5968
|
+
*/
|
|
5969
|
+
updatedTime: string;
|
|
5970
|
+
/**
|
|
5971
|
+
* Span identifier for distributed tracing.
|
|
5972
|
+
*/
|
|
5973
|
+
spanId?: string;
|
|
5974
|
+
}
|
|
5975
|
+
/**
|
|
5976
|
+
* Feedback rating type.
|
|
5977
|
+
*/
|
|
5978
|
+
declare enum FeedbackRating {
|
|
5979
|
+
Positive = "positive",
|
|
5980
|
+
Negative = "negative"
|
|
5981
|
+
}
|
|
5982
|
+
/**
|
|
5983
|
+
* Represents a group of related messages (exchange).
|
|
5984
|
+
*/
|
|
5985
|
+
interface Exchange {
|
|
5986
|
+
/**
|
|
5987
|
+
* Unique identifier for the exchange.
|
|
5988
|
+
*/
|
|
5989
|
+
id: string;
|
|
5990
|
+
/**
|
|
5991
|
+
* Identifies the exchange.
|
|
5992
|
+
*/
|
|
5993
|
+
exchangeId: string;
|
|
5994
|
+
/**
|
|
5995
|
+
* Messages in the exchange.
|
|
5996
|
+
*/
|
|
5997
|
+
messages: Message[];
|
|
5998
|
+
/**
|
|
5999
|
+
* Timestamp indicating when the exchange was created.
|
|
6000
|
+
*/
|
|
6001
|
+
createdTime: string;
|
|
6002
|
+
/**
|
|
6003
|
+
* Timestamp indicating when the exchange was last updated.
|
|
6004
|
+
*/
|
|
6005
|
+
updatedTime: string;
|
|
6006
|
+
/**
|
|
6007
|
+
* Span identifier for distributed tracing.
|
|
6008
|
+
*/
|
|
6009
|
+
spanId?: string;
|
|
6010
|
+
/**
|
|
6011
|
+
* The optional feedback rating given by the user.
|
|
6012
|
+
*/
|
|
6013
|
+
feedbackRating?: FeedbackRating;
|
|
6014
|
+
}
|
|
6015
|
+
/**
|
|
6016
|
+
* Optional configuration options for when the service automatically starts agent job(s) to serve the conversation.
|
|
6017
|
+
* When not provided, service uses default configuration with RunAsMe set to false.
|
|
6018
|
+
*/
|
|
6019
|
+
interface ConversationJobStartOverrides {
|
|
6020
|
+
/**
|
|
6021
|
+
* Whether the job(s) should run with the user's identity (RunAsMe). Defaults to false when not provided.
|
|
6022
|
+
*/
|
|
6023
|
+
runAsMe?: boolean;
|
|
6024
|
+
}
|
|
6025
|
+
/**
|
|
6026
|
+
* Raw response type for conversation operations (without methods).
|
|
6027
|
+
* Represents a conversation between users and AI agents.
|
|
6028
|
+
*/
|
|
6029
|
+
interface RawConversationGetResponse {
|
|
6030
|
+
/**
|
|
6031
|
+
* A globally unique identifier for the conversation.
|
|
6032
|
+
*/
|
|
6033
|
+
id: string;
|
|
6034
|
+
/**
|
|
6035
|
+
* Timestamp indicating when the conversation was created.
|
|
6036
|
+
*/
|
|
6037
|
+
createdTime: string;
|
|
6038
|
+
/**
|
|
6039
|
+
* Timestamp indicating when any conversation field(s) are updated.
|
|
6040
|
+
*/
|
|
6041
|
+
updatedTime: string;
|
|
6042
|
+
/**
|
|
6043
|
+
* Timestamp indicating when the conversation last had activity.
|
|
6044
|
+
*/
|
|
6045
|
+
lastActivityTime: string;
|
|
6046
|
+
/**
|
|
6047
|
+
* The human-readable label or title for the conversation.
|
|
6048
|
+
*/
|
|
6049
|
+
label: string;
|
|
6050
|
+
/**
|
|
6051
|
+
* Whether the conversation label was automatically generated.
|
|
6052
|
+
*/
|
|
6053
|
+
autogenerateLabel: boolean;
|
|
6054
|
+
/**
|
|
6055
|
+
* Identifier of the user who owns or initiated the conversation.
|
|
6056
|
+
*/
|
|
6057
|
+
userId: string;
|
|
6058
|
+
/**
|
|
6059
|
+
* Identifier of the organization.
|
|
6060
|
+
*/
|
|
6061
|
+
orgId: string;
|
|
6062
|
+
/**
|
|
6063
|
+
* Identifier of the tenant within the organization.
|
|
6064
|
+
*/
|
|
6065
|
+
tenantId: string;
|
|
6066
|
+
/**
|
|
6067
|
+
* Identifier of the folder where the conversation is stored.
|
|
6068
|
+
*/
|
|
6069
|
+
folderId: number;
|
|
6070
|
+
/**
|
|
6071
|
+
* Identifier of the agent used for this conversation
|
|
6072
|
+
*/
|
|
6073
|
+
agentId?: number;
|
|
6074
|
+
/**
|
|
6075
|
+
* Trace identifier for distributed tracing.
|
|
6076
|
+
*/
|
|
6077
|
+
traceId: string;
|
|
6078
|
+
/**
|
|
6079
|
+
* Span identifier for distributed tracing.
|
|
6080
|
+
*/
|
|
6081
|
+
spanId?: string;
|
|
6082
|
+
/**
|
|
6083
|
+
* Optional configuration options for when the service automatically starts agent job(s).
|
|
6084
|
+
*/
|
|
6085
|
+
jobStartOverrides?: ConversationJobStartOverrides;
|
|
6086
|
+
/**
|
|
6087
|
+
* Optional job key for conversations that are part of a larger job.
|
|
6088
|
+
*/
|
|
6089
|
+
jobKey?: string;
|
|
6090
|
+
/**
|
|
6091
|
+
* Whether the conversation's job is running locally.
|
|
6092
|
+
*/
|
|
6093
|
+
isLocalJobExecution?: boolean;
|
|
6094
|
+
}
|
|
6095
|
+
|
|
6096
|
+
/**
|
|
6097
|
+
* Event types for Conversational Agent WebSocket protocol
|
|
6098
|
+
*/
|
|
6099
|
+
|
|
6100
|
+
/**
|
|
6101
|
+
* Identifies how sensitive the LLM should be when detecting the start or end of speech.
|
|
6102
|
+
*
|
|
6103
|
+
* * UNSPECIFIED - the default is HIGH
|
|
6104
|
+
* * HIGH - Will detect the start/end of speech more often.
|
|
6105
|
+
* * LOW - Will detect the start/end of speech less often.
|
|
6106
|
+
*/
|
|
6107
|
+
declare enum InputStreamSpeechSensitivity {
|
|
6108
|
+
Unspecified = "UNSPECIFIED",
|
|
6109
|
+
High = "HIGH",
|
|
6110
|
+
Low = "LOW"
|
|
6111
|
+
}
|
|
6112
|
+
/**
|
|
6113
|
+
* Signals that a content stream was interrupted.
|
|
6114
|
+
*/
|
|
6115
|
+
interface ContentPartInterrupted {
|
|
6116
|
+
}
|
|
6117
|
+
/**
|
|
6118
|
+
* Describes the capabilities of the sender. This type allows custom properties, in addition to the ones defined.
|
|
6119
|
+
*/
|
|
6120
|
+
interface SessionCapabilities {
|
|
6121
|
+
/**
|
|
6122
|
+
* Indicates the sender may produce a cross exchange input stream events if the receiver indicates they can be handled.
|
|
6123
|
+
*/
|
|
6124
|
+
asyncInputStreamEmitter?: boolean;
|
|
6125
|
+
/**
|
|
6126
|
+
* Indicates the sender can handle cross exchange input stream events.
|
|
6127
|
+
*/
|
|
6128
|
+
asyncInputStreamHandler?: boolean;
|
|
6129
|
+
/**
|
|
6130
|
+
* Indicates the sender may produce cross exchange tool calls if the receiver indicates they can be handled.
|
|
6131
|
+
*/
|
|
6132
|
+
asyncToolCallEmitter?: boolean;
|
|
6133
|
+
/**
|
|
6134
|
+
* Indicates the sender can handle cross exchange tool calls.
|
|
6135
|
+
*/
|
|
6136
|
+
asyncToolCallHandler?: boolean;
|
|
6137
|
+
/**
|
|
6138
|
+
* Indicates the mime types which the sender can send in input streams and as message content, provided the receiver
|
|
6139
|
+
* indicates they can handle the mime type.
|
|
6140
|
+
*/
|
|
6141
|
+
mimeTypesEmitted?: string[];
|
|
6142
|
+
/**
|
|
6143
|
+
* Indicates the mime types the sender can handle. Wildcards such as "*\/*" and "text/*" are allowed.
|
|
6144
|
+
*/
|
|
6145
|
+
mimeTypesHandled?: string[];
|
|
6146
|
+
/** Allow custom properties */
|
|
6147
|
+
[key: string]: unknown;
|
|
6148
|
+
}
|
|
6149
|
+
/**
|
|
6150
|
+
* Signals the start of a session.
|
|
6151
|
+
*/
|
|
6152
|
+
interface SessionStartEvent {
|
|
6153
|
+
/**
|
|
6154
|
+
* Indicates the capabilities of the end point that sent the session start event.
|
|
6155
|
+
*/
|
|
6156
|
+
capabilities?: SessionCapabilities;
|
|
6157
|
+
/**
|
|
6158
|
+
* Optional metadata that can be used for any data pertaining to the starting event stream.
|
|
6159
|
+
*/
|
|
6160
|
+
metaData?: MetaData;
|
|
6161
|
+
}
|
|
6162
|
+
/**
|
|
6163
|
+
* Signals the acceptance of the start of a session.
|
|
6164
|
+
*/
|
|
6165
|
+
interface SessionStartedEvent {
|
|
6166
|
+
/**
|
|
6167
|
+
* Indicates the capabilities of the end point that received the session start event.
|
|
6168
|
+
*/
|
|
6169
|
+
capabilities?: SessionCapabilities;
|
|
6170
|
+
}
|
|
6171
|
+
/**
|
|
6172
|
+
* Indicates the end of a session.
|
|
6173
|
+
*/
|
|
6174
|
+
interface SessionEndEvent {
|
|
6175
|
+
/**
|
|
6176
|
+
* Optional metadata that can be used for any data having to do with the completion of the session.
|
|
6177
|
+
*/
|
|
6178
|
+
metaData?: MetaData;
|
|
6179
|
+
}
|
|
6180
|
+
/**
|
|
6181
|
+
* Indicates the service wants the client to end the current session.
|
|
6182
|
+
*/
|
|
6183
|
+
interface SessionEndingEvent {
|
|
6184
|
+
/**
|
|
6185
|
+
* Number of milliseconds before the websocket is closed by the service to force the session to end.
|
|
6186
|
+
*/
|
|
6187
|
+
timeToLiveMS: number;
|
|
6188
|
+
}
|
|
6189
|
+
/**
|
|
6190
|
+
* Signals the start of an exchange of messages within a conversation.
|
|
6191
|
+
*/
|
|
6192
|
+
interface ExchangeStartEvent {
|
|
6193
|
+
/**
|
|
6194
|
+
* Optional value specifying the sequence number of the exchange within the conversation.
|
|
6195
|
+
*/
|
|
6196
|
+
conversationSequence?: number;
|
|
6197
|
+
/**
|
|
6198
|
+
* Optional metadata that can be used for any data pertaining to the starting event stream.
|
|
6199
|
+
*/
|
|
6200
|
+
metadata?: MetaData;
|
|
6201
|
+
/**
|
|
6202
|
+
* The time the exchange started.
|
|
6203
|
+
*/
|
|
6204
|
+
timestamp?: string;
|
|
6205
|
+
}
|
|
6206
|
+
/**
|
|
6207
|
+
* Signals the end of an exchange of messages within a conversation.
|
|
6208
|
+
*/
|
|
6209
|
+
interface ExchangeEndEvent {
|
|
6210
|
+
/**
|
|
6211
|
+
* Optional metadata that can be used for any data having to do with the completion of the event stream.
|
|
6212
|
+
*/
|
|
6213
|
+
metaData?: MetaData;
|
|
6214
|
+
}
|
|
6215
|
+
/**
|
|
6216
|
+
* Signals the start of a message.
|
|
6217
|
+
*/
|
|
6218
|
+
interface MessageStartEvent {
|
|
6219
|
+
/**
|
|
6220
|
+
* Optional value that provides the sequence of the message within the exchange.
|
|
6221
|
+
*/
|
|
6222
|
+
exchangeSequence?: number;
|
|
6223
|
+
/**
|
|
6224
|
+
* Message timestamp.
|
|
6225
|
+
*/
|
|
6226
|
+
timestamp?: string;
|
|
6227
|
+
/**
|
|
6228
|
+
* Required value that identifies the origin of the message (system, user, or agent).
|
|
6229
|
+
*/
|
|
6230
|
+
role: MessageRole;
|
|
6231
|
+
/**
|
|
6232
|
+
* Optional metadata that can be used for any data pertaining to the starting event stream.
|
|
6233
|
+
*/
|
|
6234
|
+
metaData?: MetaData;
|
|
6235
|
+
}
|
|
6236
|
+
/**
|
|
6237
|
+
* Signals the end of a message.
|
|
6238
|
+
*/
|
|
6239
|
+
interface MessageEndEvent {
|
|
6240
|
+
/**
|
|
6241
|
+
* Optional metadata that can be used for any data having to do with the completion of the event stream.
|
|
6242
|
+
*/
|
|
6243
|
+
metaData?: MetaData;
|
|
6244
|
+
}
|
|
6245
|
+
/**
|
|
6246
|
+
* Content part start event metadata with transcript indicator.
|
|
6247
|
+
*/
|
|
6248
|
+
type ContentPartStartMetaData = MetaData & {
|
|
6249
|
+
/**
|
|
6250
|
+
* Indicates that the content part is transcript produced by the LLM from user voice input.
|
|
6251
|
+
*/
|
|
6252
|
+
isTranscript?: boolean;
|
|
6253
|
+
};
|
|
6254
|
+
/**
|
|
6255
|
+
* Signals the start of a message content part.
|
|
6256
|
+
*/
|
|
6257
|
+
interface ContentPartStartEvent {
|
|
6258
|
+
/**
|
|
6259
|
+
* Describes the type and format of a content part.
|
|
6260
|
+
*/
|
|
6261
|
+
mimeType: string;
|
|
6262
|
+
/**
|
|
6263
|
+
* Optional metadata that can be used for any data pertaining to the starting event stream.
|
|
6264
|
+
*/
|
|
6265
|
+
metaData?: ContentPartStartMetaData;
|
|
6266
|
+
/**
|
|
6267
|
+
* If present, indicates that the content part's data is stored externally.
|
|
6268
|
+
*/
|
|
6269
|
+
externalValue?: ExternalValue;
|
|
6270
|
+
/**
|
|
6271
|
+
* Optional name for the content part. Typically used for file attachment names.
|
|
6272
|
+
*/
|
|
6273
|
+
name?: string;
|
|
6274
|
+
/**
|
|
6275
|
+
* The time the content part was created.
|
|
6276
|
+
*/
|
|
6277
|
+
timestamp?: string;
|
|
6278
|
+
}
|
|
6279
|
+
/**
|
|
6280
|
+
* Signals the end of a message content part.
|
|
6281
|
+
*/
|
|
6282
|
+
interface ContentPartEndEvent {
|
|
6283
|
+
/**
|
|
6284
|
+
* Optional value that provides the contentPartSequence sent in the last content part chunk sent.
|
|
6285
|
+
*/
|
|
6286
|
+
lastChunkContentPartSequence?: number;
|
|
6287
|
+
/**
|
|
6288
|
+
* Indicates if the content part stream was interrupted.
|
|
6289
|
+
*/
|
|
6290
|
+
interrupted?: ContentPartInterrupted;
|
|
6291
|
+
/**
|
|
6292
|
+
* Optional metadata that can be used for any data having to do with the completion of the event stream.
|
|
6293
|
+
*/
|
|
6294
|
+
metaData?: MetaData;
|
|
6295
|
+
}
|
|
6296
|
+
/**
|
|
6297
|
+
* Represents the start of an error condition.
|
|
6298
|
+
*/
|
|
6299
|
+
interface ErrorStartEvent {
|
|
6300
|
+
/**
|
|
6301
|
+
* A message that can be displayed to the user.
|
|
6302
|
+
*/
|
|
6303
|
+
message: string;
|
|
6304
|
+
/**
|
|
6305
|
+
* An optional property that contains error related details.
|
|
6306
|
+
*/
|
|
6307
|
+
details?: JSONValue;
|
|
6308
|
+
}
|
|
6309
|
+
/**
|
|
6310
|
+
* Represents the end of an error condition.
|
|
6311
|
+
*/
|
|
6312
|
+
interface ErrorEndEvent {
|
|
6313
|
+
}
|
|
6314
|
+
/**
|
|
6315
|
+
* Encapsulates sub-events that represent the start and end of an error condition.
|
|
6316
|
+
*/
|
|
6317
|
+
interface ErrorEvent {
|
|
6318
|
+
/**
|
|
6319
|
+
* An identifier for the error.
|
|
6320
|
+
*/
|
|
6321
|
+
errorId: string;
|
|
6322
|
+
/**
|
|
6323
|
+
* If present, indicates the start of an error condition.
|
|
6324
|
+
*/
|
|
6325
|
+
startError?: ErrorStartEvent;
|
|
6326
|
+
/**
|
|
6327
|
+
* If present, indicates the end of an error condition.
|
|
6328
|
+
*/
|
|
6329
|
+
endError?: ErrorEndEvent;
|
|
6330
|
+
}
|
|
6331
|
+
/**
|
|
6332
|
+
* Indicates the start of a citation target in the stream of content part chunks.
|
|
6333
|
+
*/
|
|
6334
|
+
interface CitationStartEvent {
|
|
6335
|
+
}
|
|
6336
|
+
/**
|
|
6337
|
+
* Indicates the end of a citation target in the stream of content part chunks.
|
|
6338
|
+
*/
|
|
6339
|
+
interface CitationEndEvent {
|
|
6340
|
+
/**
|
|
6341
|
+
* Provides data concerning the citation sources.
|
|
6342
|
+
*/
|
|
6343
|
+
sources: CitationSource[];
|
|
6344
|
+
}
|
|
6345
|
+
/**
|
|
6346
|
+
* Encapsulates sub-events related to citations.
|
|
6347
|
+
*/
|
|
6348
|
+
interface CitationEvent {
|
|
6349
|
+
/**
|
|
6350
|
+
* Identifies a set of citation sources.
|
|
6351
|
+
*/
|
|
6352
|
+
citationId: string;
|
|
6353
|
+
/**
|
|
6354
|
+
* Indicates the start of a citation target.
|
|
6355
|
+
*/
|
|
6356
|
+
startCitation?: CitationStartEvent;
|
|
6357
|
+
/**
|
|
6358
|
+
* Indicates the end of a citation target.
|
|
6359
|
+
*/
|
|
6360
|
+
endCitation?: CitationEndEvent;
|
|
6361
|
+
/**
|
|
6362
|
+
* Sent by the service to indicate an error condition impacting a citation.
|
|
6363
|
+
*/
|
|
6364
|
+
citationError?: ErrorEvent;
|
|
6365
|
+
}
|
|
6366
|
+
/**
|
|
6367
|
+
* Contains a chunk of a message content part.
|
|
6368
|
+
*/
|
|
6369
|
+
interface ContentPartChunkEvent {
|
|
6370
|
+
/**
|
|
6371
|
+
* Content part data.
|
|
6372
|
+
*/
|
|
6373
|
+
data?: string;
|
|
6374
|
+
/**
|
|
6375
|
+
* Sub-event for attaching citations to content chunks.
|
|
6376
|
+
*/
|
|
6377
|
+
citation?: CitationEvent;
|
|
6378
|
+
}
|
|
6379
|
+
/**
|
|
6380
|
+
* Signals the start of an input stream.
|
|
6381
|
+
*/
|
|
6382
|
+
interface AsyncInputStreamStartEvent {
|
|
6383
|
+
/**
|
|
6384
|
+
* Describes the type of data sent over the input stream.
|
|
6385
|
+
*/
|
|
6386
|
+
mimeType: string;
|
|
6387
|
+
/**
|
|
6388
|
+
* Determines how sensitive the LLM should be in detecting the start of speech.
|
|
6389
|
+
*/
|
|
6390
|
+
startOfSpeechSensitivity?: InputStreamSpeechSensitivity;
|
|
6391
|
+
/**
|
|
6392
|
+
* Determines how sensitive the LLM should be in detecting the end of speech.
|
|
6393
|
+
*/
|
|
6394
|
+
endOfSpeechSensitivity?: InputStreamSpeechSensitivity;
|
|
6395
|
+
/**
|
|
6396
|
+
* The required duration of detected speech before start-of-speech is committed.
|
|
6397
|
+
*/
|
|
6398
|
+
prefixPaddingMs?: number;
|
|
6399
|
+
/**
|
|
6400
|
+
* The required duration of detected non-speech before end-of-speech is committed.
|
|
6401
|
+
*/
|
|
6402
|
+
silenceDurationMs?: number;
|
|
6403
|
+
/**
|
|
6404
|
+
* Optional metadata that can be used for any data pertaining to the starting event stream.
|
|
6405
|
+
*/
|
|
6406
|
+
metaData?: MetaData;
|
|
6407
|
+
}
|
|
6408
|
+
/**
|
|
6409
|
+
* Signals the end of a cross exchange input stream.
|
|
6410
|
+
*/
|
|
6411
|
+
interface AsyncInputStreamEndEvent {
|
|
6412
|
+
/**
|
|
6413
|
+
* Optional metadata that can be used for any data having to do with the completion of the event stream.
|
|
6414
|
+
*/
|
|
6415
|
+
metaData?: MetaData;
|
|
6416
|
+
/**
|
|
6417
|
+
* Optional value that provides the contentPartSequence value in the last content part chunk sent.
|
|
6418
|
+
*/
|
|
6419
|
+
lastChunkContentPartSequence?: number;
|
|
6420
|
+
}
|
|
6421
|
+
/**
|
|
6422
|
+
* Async input stream chunk event.
|
|
6423
|
+
*/
|
|
6424
|
+
interface AsyncInputStreamChunkEvent {
|
|
6425
|
+
data: string;
|
|
6426
|
+
}
|
|
6427
|
+
/**
|
|
6428
|
+
* Signals the start of a tool call.
|
|
6429
|
+
*/
|
|
6430
|
+
interface ToolCallStartEvent {
|
|
6431
|
+
/**
|
|
6432
|
+
* Identifies the tool that is to be called.
|
|
6433
|
+
*/
|
|
6434
|
+
toolName: string;
|
|
6435
|
+
/**
|
|
6436
|
+
* The time the tool call was made.
|
|
6437
|
+
*/
|
|
6438
|
+
timestamp?: string;
|
|
6439
|
+
/**
|
|
6440
|
+
* Optional input value provided to the tool when executed.
|
|
6441
|
+
*/
|
|
6442
|
+
input?: ToolCallInputValue;
|
|
6443
|
+
/**
|
|
6444
|
+
* Optional metadata pertaining to the tool call.
|
|
6445
|
+
*/
|
|
6446
|
+
metaData?: MetaData;
|
|
6447
|
+
}
|
|
6448
|
+
/**
|
|
6449
|
+
* Signals the end of a tool call.
|
|
6450
|
+
*/
|
|
6451
|
+
interface ToolCallEndEvent {
|
|
6452
|
+
/**
|
|
6453
|
+
* The time the result was generated.
|
|
6454
|
+
*/
|
|
6455
|
+
timestamp?: string;
|
|
6456
|
+
/**
|
|
6457
|
+
* Optional output value returned by the tool's execution.
|
|
6458
|
+
*/
|
|
6459
|
+
output?: ToolCallOutputValue;
|
|
6460
|
+
/**
|
|
6461
|
+
* Indicates if the tool call resulted in an error.
|
|
6462
|
+
*/
|
|
6463
|
+
isError?: boolean;
|
|
6464
|
+
/**
|
|
6465
|
+
* Indicates if the tool call was canceled before the result was generated.
|
|
6466
|
+
*/
|
|
6467
|
+
cancelled?: boolean;
|
|
6468
|
+
/**
|
|
6469
|
+
* Metadata pertaining to the tool call's execution or result.
|
|
6470
|
+
*/
|
|
6471
|
+
metaData?: MetaData;
|
|
6472
|
+
}
|
|
6473
|
+
/**
|
|
6474
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6475
|
+
*/
|
|
6476
|
+
interface MetaEvent {
|
|
6477
|
+
[key: string]: unknown;
|
|
6478
|
+
}
|
|
6479
|
+
/**
|
|
6480
|
+
* Indicates the update of the conversation label.
|
|
6481
|
+
*/
|
|
6482
|
+
interface LabelUpdatedEvent {
|
|
6483
|
+
/**
|
|
6484
|
+
* The new label for the conversation.
|
|
6485
|
+
*/
|
|
6486
|
+
label: string;
|
|
6487
|
+
/**
|
|
6488
|
+
* Whether the label was autogenerated by the system, or manually updated through the API.
|
|
6489
|
+
*/
|
|
6490
|
+
autogenerated: boolean;
|
|
6491
|
+
}
|
|
6492
|
+
/**
|
|
6493
|
+
* Encapsulates the data related to a tool call event.
|
|
6494
|
+
*/
|
|
6495
|
+
interface ToolCallEvent {
|
|
6496
|
+
/**
|
|
6497
|
+
* Identifies the tool call.
|
|
6498
|
+
*/
|
|
6499
|
+
toolCallId: string;
|
|
6500
|
+
/**
|
|
6501
|
+
* Signals the start of a tool call.
|
|
6502
|
+
*/
|
|
6503
|
+
startToolCall?: ToolCallStartEvent;
|
|
6504
|
+
/**
|
|
6505
|
+
* Signals the end of a tool call.
|
|
6506
|
+
*/
|
|
6507
|
+
endToolCall?: ToolCallEndEvent;
|
|
6508
|
+
/**
|
|
6509
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6510
|
+
*/
|
|
6511
|
+
metaEvent?: MetaEvent;
|
|
6512
|
+
/**
|
|
6513
|
+
* Sent by the service to indicate an error condition impacting a tool call.
|
|
6514
|
+
*/
|
|
6515
|
+
toolCallError?: ErrorEvent;
|
|
6516
|
+
}
|
|
6517
|
+
/**
|
|
6518
|
+
* Schema for tool call confirmation interrupt value.
|
|
6519
|
+
*/
|
|
6520
|
+
interface ToolCallConfirmationValue {
|
|
6521
|
+
/**
|
|
6522
|
+
* The ID of the tool call being confirmed.
|
|
6523
|
+
*/
|
|
6524
|
+
toolCallId: string;
|
|
6525
|
+
/**
|
|
6526
|
+
* The name of the tool to be called.
|
|
6527
|
+
*/
|
|
6528
|
+
toolName: string;
|
|
6529
|
+
/**
|
|
6530
|
+
* The input schema for the tool call.
|
|
6531
|
+
*/
|
|
6532
|
+
inputSchema: JSONValue;
|
|
6533
|
+
/**
|
|
6534
|
+
* The input value for the tool call.
|
|
6535
|
+
*/
|
|
6536
|
+
inputValue?: JSONValue;
|
|
6537
|
+
}
|
|
6538
|
+
/**
|
|
6539
|
+
* Schema for tool call confirmation end value.
|
|
6540
|
+
*/
|
|
6541
|
+
interface ToolCallConfirmationEndValue {
|
|
6542
|
+
/**
|
|
6543
|
+
* Whether the tool call was approved.
|
|
6544
|
+
*/
|
|
6545
|
+
approved: boolean;
|
|
6546
|
+
/**
|
|
6547
|
+
* Modified input parameters for the tool call.
|
|
6548
|
+
*/
|
|
6549
|
+
input?: JSONValue;
|
|
6550
|
+
}
|
|
6551
|
+
/**
|
|
6552
|
+
* Known interrupt start event for tool call confirmation.
|
|
6553
|
+
*/
|
|
6554
|
+
interface ToolCallConfirmationInterruptStartEvent {
|
|
6555
|
+
/**
|
|
6556
|
+
* Tool call confirmation interrupt type.
|
|
6557
|
+
*/
|
|
6558
|
+
type: typeof InterruptType.ToolCallConfirmation;
|
|
6559
|
+
/**
|
|
6560
|
+
* The tool call confirmation data.
|
|
6561
|
+
*/
|
|
6562
|
+
value: ToolCallConfirmationValue;
|
|
6563
|
+
}
|
|
6564
|
+
/**
|
|
6565
|
+
* Generic interrupt start event for custom interrupts.
|
|
6566
|
+
*/
|
|
6567
|
+
interface GenericInterruptStartEvent {
|
|
6568
|
+
/**
|
|
6569
|
+
* The type of the interrupt.
|
|
6570
|
+
*/
|
|
6571
|
+
type: string;
|
|
6572
|
+
/**
|
|
6573
|
+
* The value of the interrupt.
|
|
6574
|
+
*/
|
|
6575
|
+
value: unknown;
|
|
6576
|
+
}
|
|
6577
|
+
/**
|
|
6578
|
+
* Signals the start of an interrupt - a pause point where the agent needs external input.
|
|
6579
|
+
*/
|
|
6580
|
+
type InterruptStartEvent = ToolCallConfirmationInterruptStartEvent | GenericInterruptStartEvent;
|
|
6581
|
+
/**
|
|
6582
|
+
* Signals the interrupt end event with the provided value.
|
|
6583
|
+
*/
|
|
6584
|
+
type InterruptEndEvent = Record<string, unknown>;
|
|
6585
|
+
/**
|
|
6586
|
+
* Encapsulates interrupt-related events within a message.
|
|
6587
|
+
*/
|
|
6588
|
+
interface InterruptEvent {
|
|
6589
|
+
/**
|
|
6590
|
+
* Identifies the interrupt.
|
|
6591
|
+
*/
|
|
6592
|
+
interruptId: string;
|
|
6593
|
+
/**
|
|
6594
|
+
* Signals the start of an interrupt.
|
|
6595
|
+
*/
|
|
6596
|
+
startInterrupt?: InterruptStartEvent;
|
|
6597
|
+
/**
|
|
6598
|
+
* Signals the end of an interrupt.
|
|
6599
|
+
*/
|
|
6600
|
+
endInterrupt?: InterruptEndEvent;
|
|
6601
|
+
}
|
|
6602
|
+
/**
|
|
6603
|
+
* Encapsulates sub-events related to message content parts.
|
|
6604
|
+
*/
|
|
6605
|
+
interface ContentPartEvent {
|
|
6606
|
+
/**
|
|
6607
|
+
* Identifies the content part.
|
|
6608
|
+
*/
|
|
6609
|
+
contentPartId: string;
|
|
6610
|
+
/**
|
|
6611
|
+
* Optional value that signals the start of message content.
|
|
6612
|
+
*/
|
|
6613
|
+
startContentPart?: ContentPartStartEvent;
|
|
6614
|
+
/**
|
|
6615
|
+
* Optional value that signals the end of message content.
|
|
6616
|
+
*/
|
|
6617
|
+
endContentPart?: ContentPartEndEvent;
|
|
6618
|
+
/**
|
|
6619
|
+
* Optional content part chunk sub-event.
|
|
6620
|
+
*/
|
|
6621
|
+
chunk?: ContentPartChunkEvent;
|
|
6622
|
+
/**
|
|
6623
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6624
|
+
*/
|
|
6625
|
+
metaEvent?: MetaEvent;
|
|
6626
|
+
/**
|
|
6627
|
+
* Sent by the service to indicate an error condition impacting a content part.
|
|
6628
|
+
*/
|
|
6629
|
+
contentPartError?: ErrorEvent;
|
|
6630
|
+
}
|
|
6631
|
+
/**
|
|
6632
|
+
* Encapsulates sub-events related to a message within an exchange.
|
|
6633
|
+
*/
|
|
6634
|
+
interface MessageEvent {
|
|
6635
|
+
/**
|
|
6636
|
+
* Identifies a message.
|
|
6637
|
+
*/
|
|
6638
|
+
messageId: string;
|
|
6639
|
+
/**
|
|
6640
|
+
* Optional value that signals that start of a message.
|
|
6641
|
+
*/
|
|
6642
|
+
startMessage?: MessageStartEvent;
|
|
6643
|
+
/**
|
|
6644
|
+
* Optional value that signals the end of a message.
|
|
6645
|
+
*/
|
|
6646
|
+
endMessage?: MessageEndEvent;
|
|
6647
|
+
/**
|
|
6648
|
+
* Optional content part sub-event.
|
|
6649
|
+
*/
|
|
6650
|
+
contentPart?: ContentPartEvent;
|
|
6651
|
+
/**
|
|
6652
|
+
* Optional tool call sub-event.
|
|
6653
|
+
*/
|
|
6654
|
+
toolCall?: ToolCallEvent;
|
|
6655
|
+
/**
|
|
6656
|
+
* Optional interrupt sub-event for human-in-the-loop patterns.
|
|
6657
|
+
*/
|
|
6658
|
+
interrupt?: InterruptEvent;
|
|
6659
|
+
/**
|
|
6660
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6661
|
+
*/
|
|
6662
|
+
metaEvent?: MetaEvent;
|
|
6663
|
+
/**
|
|
6664
|
+
* Sent by the service to indicate an error condition impacting a message.
|
|
6665
|
+
*/
|
|
6666
|
+
messageError?: ErrorEvent;
|
|
6667
|
+
}
|
|
6668
|
+
/**
|
|
6669
|
+
* Encapsulates events related to a cross exchange input stream for the conversation.
|
|
6670
|
+
*/
|
|
6671
|
+
interface AsyncInputStreamEvent {
|
|
6672
|
+
/**
|
|
6673
|
+
* Identifies the input stream.
|
|
6674
|
+
*/
|
|
6675
|
+
streamId: string;
|
|
6676
|
+
/**
|
|
6677
|
+
* Optional value that signals the start of an input stream.
|
|
6678
|
+
*/
|
|
6679
|
+
startAsyncInputStream?: AsyncInputStreamStartEvent;
|
|
6680
|
+
/**
|
|
6681
|
+
* Optional value that signals the end of an input stream.
|
|
6682
|
+
*/
|
|
6683
|
+
endAsyncInputStream?: AsyncInputStreamEndEvent;
|
|
6684
|
+
/**
|
|
6685
|
+
* Optional input stream chunk sub-event.
|
|
6686
|
+
*/
|
|
6687
|
+
chunk?: AsyncInputStreamChunkEvent;
|
|
6688
|
+
/**
|
|
6689
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6690
|
+
*/
|
|
6691
|
+
metaEvent?: MetaEvent;
|
|
6692
|
+
/**
|
|
6693
|
+
* Sent by the service to indicate an error condition impacting an async input stream.
|
|
6694
|
+
*/
|
|
6695
|
+
asyncInputStreamError?: ErrorEvent;
|
|
6696
|
+
}
|
|
6697
|
+
/**
|
|
6698
|
+
* An event that applies to a single exchange of messages within a conversation.
|
|
6699
|
+
*/
|
|
6700
|
+
interface ExchangeEvent {
|
|
6701
|
+
/**
|
|
6702
|
+
* Identifies the exchange.
|
|
6703
|
+
*/
|
|
6704
|
+
exchangeId: string;
|
|
6705
|
+
/**
|
|
6706
|
+
* Optional value that signals the start of an exchange.
|
|
6707
|
+
*/
|
|
6708
|
+
startExchange?: ExchangeStartEvent;
|
|
6709
|
+
/**
|
|
6710
|
+
* Optional value that signals the end of an exchange.
|
|
6711
|
+
*/
|
|
6712
|
+
endExchange?: ExchangeEndEvent;
|
|
6713
|
+
/**
|
|
6714
|
+
* Optional message sub-events related to the exchange.
|
|
6715
|
+
*/
|
|
6716
|
+
message?: MessageEvent;
|
|
6717
|
+
/**
|
|
6718
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6719
|
+
*/
|
|
6720
|
+
metaEvent?: MetaEvent;
|
|
6721
|
+
/**
|
|
6722
|
+
* Sent by the service to indicate an error condition impacting an exchange.
|
|
6723
|
+
*/
|
|
6724
|
+
exchangeError?: ErrorEvent;
|
|
6725
|
+
}
|
|
6726
|
+
/**
|
|
6727
|
+
* The ConversationEvent type represents an event in a conversation with an LLM.
|
|
6728
|
+
*/
|
|
6729
|
+
interface ConversationEvent {
|
|
6730
|
+
/**
|
|
6731
|
+
* A globally unique identifier for conversation to which the other sub-event and data properties apply.
|
|
6732
|
+
*/
|
|
6733
|
+
conversationId: string;
|
|
6734
|
+
/**
|
|
6735
|
+
* Signals the start of session for a conversation.
|
|
6736
|
+
*/
|
|
6737
|
+
startSession?: SessionStartEvent;
|
|
6738
|
+
/**
|
|
6739
|
+
* Sent in response to a SessionStartEvent to signal the acceptance of the session.
|
|
6740
|
+
*/
|
|
6741
|
+
sessionStarted?: SessionStartedEvent;
|
|
6742
|
+
/**
|
|
6743
|
+
* Sent by the service when the client needs to end the current session.
|
|
6744
|
+
*/
|
|
6745
|
+
sessionEnding?: SessionEndingEvent;
|
|
6746
|
+
/**
|
|
6747
|
+
* Signals the end of a session for a conversation.
|
|
6748
|
+
*/
|
|
6749
|
+
endSession?: SessionEndEvent;
|
|
6750
|
+
/**
|
|
6751
|
+
* Optional exchange sub-event.
|
|
6752
|
+
*/
|
|
6753
|
+
exchange?: ExchangeEvent;
|
|
6754
|
+
/**
|
|
6755
|
+
* Optional input stream sub-events.
|
|
6756
|
+
*/
|
|
6757
|
+
asyncInputStream?: AsyncInputStreamEvent;
|
|
6758
|
+
/**
|
|
6759
|
+
* Optional async tool call sub-event.
|
|
6760
|
+
*/
|
|
6761
|
+
asyncToolCall?: ToolCallEvent;
|
|
6762
|
+
/**
|
|
6763
|
+
* Indicates that the conversation's label has been updated.
|
|
6764
|
+
*/
|
|
6765
|
+
labelUpdated?: LabelUpdatedEvent;
|
|
6766
|
+
/**
|
|
6767
|
+
* Allows additional events to be sent in the context of the enclosing event stream.
|
|
6768
|
+
*/
|
|
6769
|
+
metaEvent?: MetaEvent;
|
|
6770
|
+
/**
|
|
6771
|
+
* Sent by the service to indicate an error condition impacting a conversation.
|
|
6772
|
+
*/
|
|
6773
|
+
conversationError?: ErrorEvent;
|
|
6774
|
+
}
|
|
6775
|
+
|
|
6776
|
+
/**
|
|
6777
|
+
* Content Part Stream Types
|
|
6778
|
+
*
|
|
6779
|
+
* Defines the public API for interacting with streaming content parts
|
|
6780
|
+
* within a message. Content parts represent text, audio, images, etc.
|
|
6781
|
+
*/
|
|
6782
|
+
|
|
6783
|
+
/**
|
|
6784
|
+
* Error encountered during citation processing
|
|
6785
|
+
*/
|
|
6786
|
+
type CitationError = {
|
|
6787
|
+
citationId: string;
|
|
6788
|
+
errorType: CitationErrorType;
|
|
6789
|
+
};
|
|
6790
|
+
/**
|
|
6791
|
+
* Types of citation processing errors
|
|
6792
|
+
*/
|
|
6793
|
+
declare enum CitationErrorType {
|
|
6794
|
+
CitationNotEnded = "CitationNotEnded",
|
|
6795
|
+
CitationNotStarted = "CitationNotStarted"
|
|
6796
|
+
}
|
|
6797
|
+
/**
|
|
6798
|
+
* Aggregated data for a completed content part
|
|
6799
|
+
*
|
|
6800
|
+
* Contains the full buffered text, citations, and metadata
|
|
6801
|
+
* available after a content part stream has ended.
|
|
6802
|
+
*/
|
|
6803
|
+
type CompletedContentPart = ContentPartStartEvent & ContentPartEndEvent & {
|
|
6804
|
+
contentPartId: string;
|
|
6805
|
+
data: string;
|
|
6806
|
+
citations: CitationOptions[];
|
|
6807
|
+
citationErrors: CitationError[];
|
|
6808
|
+
};
|
|
6809
|
+
/**
|
|
6810
|
+
* Model for content part event helpers.
|
|
6811
|
+
*
|
|
6812
|
+
* A content part is a single piece of content within a message — text,
|
|
6813
|
+
* audio, an image, or a transcript. Use the type-check properties
|
|
6814
|
+
* (`isText`, `isMarkdown`, `isHtml`, `isAudio`, `isImage`, `isTranscript`)
|
|
6815
|
+
* to determine the content type and handle it accordingly.
|
|
6816
|
+
*
|
|
6817
|
+
* @example Streaming markdown content
|
|
6818
|
+
* ```typescript
|
|
6819
|
+
* message.onContentPartStart((part) => {
|
|
6820
|
+
* if (part.isMarkdown) {
|
|
6821
|
+
* part.onChunk((chunk) => {
|
|
6822
|
+
* process.stdout.write(chunk.data ?? '');
|
|
6823
|
+
* });
|
|
6824
|
+
* }
|
|
6825
|
+
* });
|
|
6826
|
+
* ```
|
|
6827
|
+
*
|
|
6828
|
+
* @example Handling different content types
|
|
6829
|
+
* ```typescript
|
|
6830
|
+
* message.onContentPartStart((part) => {
|
|
6831
|
+
* if (part.isText) {
|
|
6832
|
+
* part.onChunk((chunk) => showPlainText(chunk.data ?? ''));
|
|
6833
|
+
* } else if (part.isMarkdown) {
|
|
6834
|
+
* part.onChunk((chunk) => renderMarkdown(chunk.data ?? ''));
|
|
6835
|
+
* } else if (part.isHtml) {
|
|
6836
|
+
* part.onChunk((chunk) => renderHtml(chunk.data ?? ''));
|
|
6837
|
+
* } else if (part.isAudio) {
|
|
6838
|
+
* part.onChunk((chunk) => audioPlayer.enqueue(chunk.data ?? ''));
|
|
6839
|
+
* } else if (part.isImage) {
|
|
6840
|
+
* part.onChunk((chunk) => imageBuffer.append(chunk.data ?? ''));
|
|
6841
|
+
* } else if (part.isTranscript) {
|
|
6842
|
+
* part.onChunk((chunk) => showTranscript(chunk.data ?? ''));
|
|
6843
|
+
* }
|
|
6844
|
+
* });
|
|
6845
|
+
* ```
|
|
6846
|
+
*
|
|
6847
|
+
* @example Getting complete content with citations (buffered)
|
|
6848
|
+
* ```typescript
|
|
6849
|
+
* message.onContentPartStart((part) => {
|
|
6850
|
+
* part.onCompleted((completed) => {
|
|
6851
|
+
* console.log(`Full text: ${completed.data}`);
|
|
6852
|
+
*
|
|
6853
|
+
* // Access citations — each has offset, length, and sources
|
|
6854
|
+
* for (const citation of completed.citations) {
|
|
6855
|
+
* const citedText = completed.data.substring(
|
|
6856
|
+
* citation.offset,
|
|
6857
|
+
* citation.offset + citation.length
|
|
6858
|
+
* );
|
|
6859
|
+
* console.log(`"${citedText}" cited from:`, citation.sources);
|
|
6860
|
+
* }
|
|
6861
|
+
* });
|
|
6862
|
+
* });
|
|
6863
|
+
* ```
|
|
6864
|
+
*
|
|
6865
|
+
* @example Using the content part completed handler at the message level
|
|
6866
|
+
* ```typescript
|
|
6867
|
+
* message.onContentPartCompleted((completed) => {
|
|
6868
|
+
* console.log(`[${completed.mimeType}] ${completed.data}`);
|
|
6869
|
+
* });
|
|
6870
|
+
* ```
|
|
6871
|
+
*/
|
|
6872
|
+
interface ContentPartStream {
|
|
6873
|
+
/** Unique identifier for this content part */
|
|
6874
|
+
readonly contentPartId: string;
|
|
6875
|
+
/** The MIME type of this content part, or undefined if start event not yet received */
|
|
6876
|
+
readonly mimeType: string | undefined;
|
|
6877
|
+
/** Whether this content part is plain text. Matches `text/plain`. */
|
|
6878
|
+
readonly isText: boolean;
|
|
6879
|
+
/** Whether this content part is markdown. Matches `text/markdown`. */
|
|
6880
|
+
readonly isMarkdown: boolean;
|
|
6881
|
+
/** Whether this content part is HTML. Matches `text/html`. */
|
|
6882
|
+
readonly isHtml: boolean;
|
|
6883
|
+
/** Whether this content part is audio content */
|
|
6884
|
+
readonly isAudio: boolean;
|
|
6885
|
+
/** Whether this content part is an image */
|
|
6886
|
+
readonly isImage: boolean;
|
|
6887
|
+
/** Whether this content part is a transcript (from speech-to-text) */
|
|
6888
|
+
readonly isTranscript: boolean;
|
|
6889
|
+
/**
|
|
6890
|
+
* The start event, or undefined if not yet received
|
|
6891
|
+
* @internal
|
|
6892
|
+
*/
|
|
6893
|
+
readonly startEventMaybe: ContentPartStartEvent | undefined;
|
|
6894
|
+
/**
|
|
6895
|
+
* The start event (throws if not yet received)
|
|
6896
|
+
* @internal
|
|
6897
|
+
*/
|
|
6898
|
+
readonly startEvent: MakeRequired<ContentPartStartEvent, 'timestamp'>;
|
|
6899
|
+
/** Whether this content part has ended */
|
|
6900
|
+
readonly ended: boolean;
|
|
6901
|
+
/**
|
|
6902
|
+
* Registers a handler for error start events
|
|
6903
|
+
*
|
|
6904
|
+
* @param cb - Callback receiving the error event
|
|
6905
|
+
* @returns Cleanup function to remove the handler
|
|
6906
|
+
*
|
|
6907
|
+
* @example Content part error handling
|
|
6908
|
+
* ```typescript
|
|
6909
|
+
* part.onErrorStart((error) => {
|
|
6910
|
+
* console.error(`Content part error: ${error.message}`);
|
|
6911
|
+
* });
|
|
6912
|
+
* ```
|
|
6913
|
+
*/
|
|
6914
|
+
onErrorStart(cb: (error: {
|
|
6915
|
+
errorId: string;
|
|
6916
|
+
} & ErrorStartEvent) => void): () => void;
|
|
6917
|
+
/**
|
|
6918
|
+
* Registers a handler for error end events
|
|
6919
|
+
* @param cb - Callback receiving the error end event
|
|
6920
|
+
* @returns Cleanup function to remove the handler
|
|
6921
|
+
*/
|
|
6922
|
+
onErrorEnd(cb: (error: {
|
|
6923
|
+
errorId: string;
|
|
6924
|
+
} & ErrorEndEvent) => void): () => void;
|
|
6925
|
+
/**
|
|
6926
|
+
* Registers a handler for content part chunks
|
|
6927
|
+
*
|
|
6928
|
+
* Chunks are the fundamental unit of streaming data. Each chunk
|
|
6929
|
+
* contains a piece of the content (text, audio data, etc.).
|
|
6930
|
+
*
|
|
6931
|
+
* @param cb - Callback receiving each chunk
|
|
6932
|
+
* @returns Cleanup function to remove the handler
|
|
6933
|
+
*
|
|
6934
|
+
* @example Streaming text output
|
|
6935
|
+
* ```typescript
|
|
6936
|
+
* part.onChunk((chunk) => {
|
|
6937
|
+
* process.stdout.write(chunk.data ?? '');
|
|
6938
|
+
* });
|
|
6939
|
+
* ```
|
|
6940
|
+
*/
|
|
6941
|
+
onChunk(cb: (chunk: ContentPartChunkEvent) => void): () => void;
|
|
6942
|
+
/**
|
|
6943
|
+
* Registers a handler for content part end events
|
|
6944
|
+
*
|
|
6945
|
+
* @param cb - Callback receiving the end event
|
|
6946
|
+
* @returns Cleanup function to remove the handler
|
|
6947
|
+
*
|
|
6948
|
+
* @example Tracking content part lifecycle
|
|
6949
|
+
* ```typescript
|
|
6950
|
+
* part.onContentPartEnd((endEvent) => {
|
|
6951
|
+
* console.log('Content part finished');
|
|
6952
|
+
* });
|
|
6953
|
+
* ```
|
|
6954
|
+
*/
|
|
6955
|
+
onContentPartEnd(cb: (endContentPart: ContentPartEndEvent) => void): () => void;
|
|
6956
|
+
/**
|
|
6957
|
+
* Registers a handler called when this content part finishes
|
|
6958
|
+
*
|
|
6959
|
+
* The handler receives the aggregated content part data including
|
|
6960
|
+
* all buffered text, citations, and any citation errors.
|
|
6961
|
+
*
|
|
6962
|
+
* @param cb - Callback receiving the completed content part data
|
|
6963
|
+
*
|
|
6964
|
+
* @example Getting buffered content with citation data
|
|
6965
|
+
* ```typescript
|
|
6966
|
+
* part.onCompleted((completed) => {
|
|
6967
|
+
* console.log(`Content type: ${completed.mimeType}`);
|
|
6968
|
+
* console.log(`Full text: ${completed.data}`);
|
|
6969
|
+
*
|
|
6970
|
+
* // Citations provide offset/length into the text and source references
|
|
6971
|
+
* for (const citation of completed.citations) {
|
|
6972
|
+
* const citedText = completed.data.substring(
|
|
6973
|
+
* citation.offset,
|
|
6974
|
+
* citation.offset + citation.length
|
|
6975
|
+
* );
|
|
6976
|
+
* console.log(`"${citedText}" — sources:`, citation.sources);
|
|
6977
|
+
* }
|
|
6978
|
+
*
|
|
6979
|
+
* // Citation errors indicate malformed citation ranges
|
|
6980
|
+
* if (completed.citationErrors.length > 0) {
|
|
6981
|
+
* console.warn('Citation errors:', completed.citationErrors);
|
|
6982
|
+
* }
|
|
6983
|
+
* });
|
|
6984
|
+
* ```
|
|
6985
|
+
*/
|
|
6986
|
+
onCompleted(cb: (completedContentPart: CompletedContentPart) => void): void;
|
|
6987
|
+
/**
|
|
6988
|
+
* Sends a content part chunk
|
|
6989
|
+
*
|
|
6990
|
+
* @param chunk - Chunk data to send
|
|
6991
|
+
*
|
|
6992
|
+
* @example Sending text chunks
|
|
6993
|
+
* ```typescript
|
|
6994
|
+
* part.sendChunk({ data: 'Hello ' });
|
|
6995
|
+
* part.sendChunk({ data: 'world!' });
|
|
6996
|
+
* ```
|
|
6997
|
+
*/
|
|
6998
|
+
sendChunk(chunk: ContentPartChunkEvent): void;
|
|
6999
|
+
/**
|
|
7000
|
+
* Ends the content part stream
|
|
7001
|
+
*
|
|
7002
|
+
* @param endContentPart - Optional end event data
|
|
7003
|
+
*
|
|
7004
|
+
* @example Ending a content part
|
|
7005
|
+
* ```typescript
|
|
7006
|
+
* part.sendContentPartEnd();
|
|
7007
|
+
* ```
|
|
7008
|
+
*/
|
|
7009
|
+
sendContentPartEnd(endContentPart?: ContentPartEndEvent): void;
|
|
7010
|
+
/**
|
|
7011
|
+
* Sends an error start event for this content part
|
|
7012
|
+
* @param args - Error details including optional error ID and message
|
|
7013
|
+
* @internal
|
|
7014
|
+
*/
|
|
7015
|
+
sendErrorStart(args: {
|
|
7016
|
+
errorId?: string;
|
|
7017
|
+
} & ErrorStartEvent): void;
|
|
7018
|
+
/**
|
|
7019
|
+
* Sends an error end event for this content part
|
|
7020
|
+
* @param args - Error end details including the error ID
|
|
7021
|
+
* @internal
|
|
7022
|
+
*/
|
|
7023
|
+
sendErrorEnd(args: {
|
|
7024
|
+
errorId: string;
|
|
7025
|
+
} & ErrorEndEvent): void;
|
|
7026
|
+
/**
|
|
7027
|
+
* Sends a metadata event for this content part
|
|
7028
|
+
* @param metaEvent - Metadata to send
|
|
7029
|
+
* @internal
|
|
7030
|
+
*/
|
|
7031
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
7032
|
+
/**
|
|
7033
|
+
* Sends a chunk that starts a citation range
|
|
7034
|
+
*
|
|
7035
|
+
* Marks the beginning of a cited passage. All subsequent chunks
|
|
7036
|
+
* until `sendChunkWithCitationEnd` are considered part of this citation.
|
|
7037
|
+
*
|
|
7038
|
+
* @param chunk - Chunk data with citation ID
|
|
7039
|
+
* @internal
|
|
7040
|
+
*/
|
|
7041
|
+
sendChunkWithCitationStart(chunk: Omit<ContentPartChunkEvent, 'citation'> & {
|
|
7042
|
+
citationId: string;
|
|
7043
|
+
}): void;
|
|
7044
|
+
/**
|
|
7045
|
+
* Sends a chunk that ends a citation range
|
|
7046
|
+
*
|
|
7047
|
+
* Marks the end of a cited passage and provides the citation sources.
|
|
7048
|
+
*
|
|
7049
|
+
* @param chunk - Chunk data with citation ID and sources
|
|
7050
|
+
* @internal
|
|
7051
|
+
*/
|
|
7052
|
+
sendChunkWithCitationEnd(chunk: Omit<ContentPartChunkEvent, 'citation'> & {
|
|
7053
|
+
citationId: string;
|
|
7054
|
+
sources: CitationSource[];
|
|
7055
|
+
}): void;
|
|
7056
|
+
/**
|
|
7057
|
+
* Sends a chunk that is a complete citation (start and end in one)
|
|
7058
|
+
*
|
|
7059
|
+
* Use this for inline citations where the entire cited text is in a single chunk.
|
|
7060
|
+
*
|
|
7061
|
+
* @param chunk - Chunk data with citation ID and sources
|
|
7062
|
+
* @internal
|
|
7063
|
+
*/
|
|
7064
|
+
sendChunkWithCitation(chunk: Omit<ContentPartChunkEvent, 'citation'> & {
|
|
7065
|
+
citationId: string;
|
|
7066
|
+
sources: CitationSource[];
|
|
7067
|
+
}): void;
|
|
7068
|
+
/**
|
|
7069
|
+
* Emits a raw content part event
|
|
7070
|
+
* @param contentPartEvent - The event to emit (contentPartId is added automatically)
|
|
7071
|
+
* @internal
|
|
7072
|
+
*/
|
|
7073
|
+
emit(contentPartEvent: Omit<ContentPartEvent, 'contentPartId'>): void;
|
|
7074
|
+
/**
|
|
7075
|
+
* Returns a string representation of this content part
|
|
7076
|
+
* @internal
|
|
7077
|
+
*/
|
|
7078
|
+
toString(): string;
|
|
7079
|
+
}
|
|
7080
|
+
|
|
7081
|
+
/**
|
|
7082
|
+
* Consumer-facing interface for ToolCallEventHelper
|
|
7083
|
+
*
|
|
7084
|
+
* Defines the public API for interacting with tool call events
|
|
7085
|
+
* within a message. Tool calls represent external tool invocations
|
|
7086
|
+
* made by the assistant during a conversation.
|
|
7087
|
+
*/
|
|
7088
|
+
|
|
7089
|
+
/**
|
|
7090
|
+
* Aggregated data for a completed tool call
|
|
7091
|
+
*
|
|
7092
|
+
* Contains the merged start and end event data
|
|
7093
|
+
* available after a tool call has ended.
|
|
7094
|
+
*/
|
|
7095
|
+
type CompletedToolCall = ToolCallStartEvent & ToolCallEndEvent & {
|
|
7096
|
+
toolCallId: string;
|
|
7097
|
+
};
|
|
7098
|
+
/**
|
|
7099
|
+
* Consumer-facing model for tool call event helpers.
|
|
7100
|
+
*
|
|
7101
|
+
* A tool call represents the agent invoking an external tool (API call,
|
|
7102
|
+
* database query, etc.) during a conversation. Tool calls live within
|
|
7103
|
+
* a message and have a start event (with tool name and input) and an
|
|
7104
|
+
* end event (with the output/result).
|
|
7105
|
+
*
|
|
7106
|
+
* @example Listening for tool call results
|
|
7107
|
+
* ```typescript
|
|
7108
|
+
* message.onToolCallStart((toolCall) => {
|
|
7109
|
+
* console.log(`Tool: ${toolCall.startEvent.toolName}`);
|
|
7110
|
+
* toolCall.onToolCallEnd((endEvent) => {
|
|
7111
|
+
* console.log('Tool call completed:', endEvent.output);
|
|
7112
|
+
* });
|
|
7113
|
+
* });
|
|
7114
|
+
* ```
|
|
7115
|
+
*
|
|
7116
|
+
* @example Parsing tool call input and output
|
|
7117
|
+
* ```typescript
|
|
7118
|
+
* message.onToolCallStart((toolCall) => {
|
|
7119
|
+
* const { toolName, input } = toolCall.startEvent;
|
|
7120
|
+
* const parsedInput = JSON.parse(input ?? '{}');
|
|
7121
|
+
* console.log(`Calling ${toolName} with:`, parsedInput);
|
|
7122
|
+
*
|
|
7123
|
+
* toolCall.onToolCallEnd((endEvent) => {
|
|
7124
|
+
* const result = JSON.parse(endEvent.output ?? '{}');
|
|
7125
|
+
* console.log(`${toolName} returned:`, result);
|
|
7126
|
+
* });
|
|
7127
|
+
* });
|
|
7128
|
+
* ```
|
|
7129
|
+
*
|
|
7130
|
+
* @example Responding to a tool call (agent-side)
|
|
7131
|
+
* ```typescript
|
|
7132
|
+
* message.onToolCallStart(async (toolCall) => {
|
|
7133
|
+
* const { toolName, input } = toolCall.startEvent;
|
|
7134
|
+
*
|
|
7135
|
+
* // Execute the tool and return the result
|
|
7136
|
+
* const result = await executeTool(toolName, input);
|
|
7137
|
+
* toolCall.sendToolCallEnd({
|
|
7138
|
+
* output: JSON.stringify(result)
|
|
7139
|
+
* });
|
|
7140
|
+
* });
|
|
7141
|
+
* ```
|
|
7142
|
+
*/
|
|
7143
|
+
interface ToolCallStream {
|
|
7144
|
+
/** Unique identifier for this tool call */
|
|
7145
|
+
readonly toolCallId: string;
|
|
7146
|
+
/**
|
|
7147
|
+
* The start event, or undefined if not yet received
|
|
7148
|
+
* @internal
|
|
7149
|
+
*/
|
|
7150
|
+
readonly startEventMaybe: ToolCallStartEvent | undefined;
|
|
7151
|
+
/**
|
|
7152
|
+
* The start event (throws if not yet received)
|
|
7153
|
+
* @internal
|
|
7154
|
+
*/
|
|
7155
|
+
readonly startEvent: MakeRequired<ToolCallStartEvent, 'timestamp'>;
|
|
7156
|
+
/** Whether this tool call has ended */
|
|
7157
|
+
readonly ended: boolean;
|
|
7158
|
+
/**
|
|
7159
|
+
* Registers a handler for error start events
|
|
7160
|
+
*
|
|
7161
|
+
* @param cb - Callback receiving the error event
|
|
7162
|
+
* @returns Cleanup function to remove the handler
|
|
7163
|
+
*
|
|
7164
|
+
* @example Tool call error handling
|
|
7165
|
+
* ```typescript
|
|
7166
|
+
* toolCall.onErrorStart((error) => {
|
|
7167
|
+
* console.error(`Tool call error: ${error.message}`);
|
|
7168
|
+
* });
|
|
7169
|
+
* ```
|
|
7170
|
+
*/
|
|
7171
|
+
onErrorStart(cb: (error: {
|
|
7172
|
+
errorId: string;
|
|
7173
|
+
} & ErrorStartEvent) => void): () => void;
|
|
7174
|
+
/**
|
|
7175
|
+
* Registers a handler for error end events
|
|
7176
|
+
* @param cb - Callback receiving the error end event
|
|
7177
|
+
* @returns Cleanup function to remove the handler
|
|
7178
|
+
*/
|
|
7179
|
+
onErrorEnd(cb: (error: {
|
|
7180
|
+
errorId: string;
|
|
7181
|
+
} & ErrorEndEvent) => void): () => void;
|
|
7182
|
+
/**
|
|
7183
|
+
* Registers a handler for tool call end events
|
|
7184
|
+
*
|
|
7185
|
+
* @param cb - Callback receiving the end event
|
|
7186
|
+
* @returns Cleanup function to remove the handler
|
|
7187
|
+
*
|
|
7188
|
+
* @example Handling tool call completion
|
|
7189
|
+
* ```typescript
|
|
7190
|
+
* toolCall.onToolCallEnd((endEvent) => {
|
|
7191
|
+
* console.log('Output:', endEvent.output);
|
|
7192
|
+
* });
|
|
7193
|
+
* ```
|
|
7194
|
+
*/
|
|
7195
|
+
onToolCallEnd(cb: (endToolCall: ToolCallEndEvent) => void): () => void;
|
|
7196
|
+
/**
|
|
7197
|
+
* Ends the tool call
|
|
7198
|
+
*
|
|
7199
|
+
* @param endToolCall - Optional end event data
|
|
7200
|
+
*
|
|
7201
|
+
* @example Completing a tool call with output
|
|
7202
|
+
* ```typescript
|
|
7203
|
+
* toolCall.sendToolCallEnd({
|
|
7204
|
+
* output: JSON.stringify({ temperature: 18, condition: 'cloudy' })
|
|
7205
|
+
* });
|
|
7206
|
+
* ```
|
|
7207
|
+
*/
|
|
7208
|
+
sendToolCallEnd(endToolCall?: ToolCallEndEvent): void;
|
|
7209
|
+
/**
|
|
7210
|
+
* Sends an error start event for this tool call
|
|
7211
|
+
* @param args - Error details including optional error ID and message
|
|
7212
|
+
* @internal
|
|
7213
|
+
*/
|
|
7214
|
+
sendErrorStart(args: {
|
|
7215
|
+
errorId?: string;
|
|
7216
|
+
} & ErrorStartEvent): void;
|
|
7217
|
+
/**
|
|
7218
|
+
* Sends an error end event for this tool call
|
|
7219
|
+
* @param args - Error end details including the error ID
|
|
7220
|
+
* @internal
|
|
7221
|
+
*/
|
|
7222
|
+
sendErrorEnd(args: {
|
|
7223
|
+
errorId: string;
|
|
7224
|
+
} & ErrorEndEvent): void;
|
|
7225
|
+
/**
|
|
7226
|
+
* Sends a metadata event for this tool call
|
|
7227
|
+
* @param metaEvent - Metadata to send
|
|
7228
|
+
* @internal
|
|
7229
|
+
*/
|
|
7230
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
7231
|
+
/**
|
|
7232
|
+
* Emits a raw tool call event
|
|
7233
|
+
* @param toolCallEvent - The event to emit (toolCallId is added automatically)
|
|
7234
|
+
* @internal
|
|
7235
|
+
*/
|
|
7236
|
+
emit(toolCallEvent: Omit<ToolCallEvent, 'toolCallId'>): void;
|
|
7237
|
+
/**
|
|
7238
|
+
* Returns a string representation of this tool call
|
|
7239
|
+
* @internal
|
|
7240
|
+
*/
|
|
7241
|
+
toString(): string;
|
|
7242
|
+
}
|
|
7243
|
+
/**
|
|
7244
|
+
* Consumer-facing model for async tool call event helpers.
|
|
7245
|
+
*
|
|
7246
|
+
* Async tool calls operate at the session level (not within a single message)
|
|
7247
|
+
* and can span across multiple exchanges. They are used for long-running
|
|
7248
|
+
* tool invocations that need to persist beyond a single request-response cycle.
|
|
7249
|
+
*
|
|
7250
|
+
* Unlike regular {@link ToolCallStream} which live inside a message,
|
|
7251
|
+
* async tool calls are managed directly on the {@link SessionStream}.
|
|
7252
|
+
*
|
|
7253
|
+
* @example Listening for async tool call completion
|
|
7254
|
+
* ```typescript
|
|
7255
|
+
* session.onAsyncToolCallStart((toolCall) => {
|
|
7256
|
+
* console.log(`Async tool started: ${toolCall.startEvent.toolName}`);
|
|
7257
|
+
* toolCall.onToolCallEnd((endEvent) => {
|
|
7258
|
+
* console.log('Async tool completed:', endEvent.output);
|
|
7259
|
+
* });
|
|
7260
|
+
* });
|
|
7261
|
+
* ```
|
|
7262
|
+
*
|
|
7263
|
+
* @example Starting and completing an async tool call
|
|
7264
|
+
* ```typescript
|
|
7265
|
+
* // Start a long-running analysis
|
|
7266
|
+
* const toolCall = session.startAsyncToolCall({
|
|
7267
|
+
* toolName: 'document-analysis',
|
|
7268
|
+
* input: JSON.stringify({ documentId: 'doc-123' })
|
|
7269
|
+
* });
|
|
7270
|
+
*
|
|
7271
|
+
* // ... perform the analysis across multiple exchanges ...
|
|
7272
|
+
*
|
|
7273
|
+
* // Complete when done
|
|
7274
|
+
* toolCall.sendToolCallEnd({
|
|
7275
|
+
* output: JSON.stringify({ summary: 'Analysis complete', pages: 42 })
|
|
7276
|
+
* });
|
|
7277
|
+
* ```
|
|
7278
|
+
*
|
|
7279
|
+
* @example Handling errors on async tool calls
|
|
7280
|
+
* ```typescript
|
|
7281
|
+
* session.onAsyncToolCallStart((toolCall) => {
|
|
7282
|
+
* toolCall.onErrorStart((error) => {
|
|
7283
|
+
* console.error(`Async tool error: ${error.message}`);
|
|
7284
|
+
* });
|
|
7285
|
+
* });
|
|
7286
|
+
* ```
|
|
7287
|
+
*/
|
|
7288
|
+
interface AsyncToolCallStream {
|
|
7289
|
+
/** Unique identifier for this async tool call */
|
|
7290
|
+
readonly toolCallId: string;
|
|
7291
|
+
/**
|
|
7292
|
+
* The start event, or undefined if not yet received
|
|
7293
|
+
* @internal
|
|
7294
|
+
*/
|
|
7295
|
+
readonly startEventMaybe: ToolCallStartEvent | undefined;
|
|
7296
|
+
/**
|
|
7297
|
+
* The start event (throws if not yet received)
|
|
7298
|
+
* @internal
|
|
7299
|
+
*/
|
|
7300
|
+
readonly startEvent: MakeRequired<ToolCallStartEvent, 'timestamp'>;
|
|
7301
|
+
/** Whether this async tool call has ended */
|
|
7302
|
+
readonly ended: boolean;
|
|
7303
|
+
/**
|
|
7304
|
+
* Registers a handler for error start events
|
|
7305
|
+
* @param cb - Callback receiving the error event
|
|
7306
|
+
* @returns Cleanup function to remove the handler
|
|
7307
|
+
*/
|
|
7308
|
+
onErrorStart(cb: (error: {
|
|
7309
|
+
errorId: string;
|
|
7310
|
+
} & ErrorStartEvent) => void): () => void;
|
|
7311
|
+
/**
|
|
7312
|
+
* Registers a handler for error end events
|
|
7313
|
+
* @param cb - Callback receiving the error end event
|
|
7314
|
+
* @returns Cleanup function to remove the handler
|
|
7315
|
+
*/
|
|
7316
|
+
onErrorEnd(cb: (error: {
|
|
7317
|
+
errorId: string;
|
|
7318
|
+
} & ErrorEndEvent) => void): () => void;
|
|
7319
|
+
/**
|
|
7320
|
+
* Registers a handler for tool call end events
|
|
7321
|
+
* @param cb - Callback receiving the end event
|
|
7322
|
+
* @returns Cleanup function to remove the handler
|
|
7323
|
+
*/
|
|
7324
|
+
onToolCallEnd(cb: (endToolCall: ToolCallEndEvent) => void): () => void;
|
|
7325
|
+
/**
|
|
7326
|
+
* Ends the async tool call
|
|
7327
|
+
* @param endToolCall - Optional end event data including output
|
|
7328
|
+
*/
|
|
7329
|
+
sendToolCallEnd(endToolCall?: ToolCallEndEvent): void;
|
|
7330
|
+
/**
|
|
7331
|
+
* Sends an error start event for this async tool call
|
|
7332
|
+
* @param args - Error details including optional error ID and message
|
|
7333
|
+
* @internal
|
|
7334
|
+
*/
|
|
7335
|
+
sendErrorStart(args: {
|
|
7336
|
+
errorId?: string;
|
|
7337
|
+
} & ErrorStartEvent): void;
|
|
7338
|
+
/**
|
|
7339
|
+
* Sends an error end event for this async tool call
|
|
7340
|
+
* @param args - Error end details including the error ID
|
|
7341
|
+
* @internal
|
|
7342
|
+
*/
|
|
7343
|
+
sendErrorEnd(args: {
|
|
7344
|
+
errorId: string;
|
|
7345
|
+
} & ErrorEndEvent): void;
|
|
7346
|
+
/**
|
|
7347
|
+
* Sends a metadata event for this async tool call
|
|
7348
|
+
* @param metaEvent - Metadata to send
|
|
7349
|
+
* @internal
|
|
7350
|
+
*/
|
|
7351
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
7352
|
+
/**
|
|
7353
|
+
* Emits a raw tool call event
|
|
7354
|
+
* @param toolCallEvent - The event to emit (toolCallId is added automatically)
|
|
7355
|
+
* @internal
|
|
7356
|
+
*/
|
|
7357
|
+
emit(toolCallEvent: Omit<ToolCallEvent, 'toolCallId'>): void;
|
|
7358
|
+
/**
|
|
7359
|
+
* Returns a string representation of this async tool call
|
|
7360
|
+
* @internal
|
|
7361
|
+
*/
|
|
7362
|
+
toString(): string;
|
|
7363
|
+
}
|
|
7364
|
+
|
|
7365
|
+
/**
|
|
7366
|
+
* Consumer-facing interface for AsyncInputStreamEventHelper
|
|
7367
|
+
*
|
|
7368
|
+
* Defines the public API for interacting with async input streams
|
|
7369
|
+
* at the session level. Async input streams are used for streaming
|
|
7370
|
+
* audio or other media data to the agent.
|
|
7371
|
+
*/
|
|
7372
|
+
|
|
7373
|
+
/**
|
|
7374
|
+
* Consumer-facing model for async input stream event helpers.
|
|
7375
|
+
*
|
|
7376
|
+
* Async input streams operate at the session level and are used for
|
|
7377
|
+
* streaming audio or other media data to the agent in real-time.
|
|
7378
|
+
* They persist across exchanges, making them ideal for continuous
|
|
7379
|
+
* audio input from a microphone.
|
|
7380
|
+
*
|
|
7381
|
+
* Unlike content parts (which carry agent output), async input streams
|
|
7382
|
+
* carry user input to the agent via the {@link SessionStream}.
|
|
7383
|
+
*
|
|
7384
|
+
* @example Streaming microphone audio
|
|
7385
|
+
* ```typescript
|
|
7386
|
+
* const stream = session.startAsyncInputStream({
|
|
7387
|
+
* mimeType: 'audio/pcm;rate=24000'
|
|
7388
|
+
* });
|
|
7389
|
+
*
|
|
7390
|
+
* // Stream microphone PCM data
|
|
7391
|
+
* microphone.on('data', (pcmData: string) => {
|
|
7392
|
+
* stream.sendChunk({ data: pcmData });
|
|
7393
|
+
* });
|
|
7394
|
+
*
|
|
7395
|
+
* // End when user stops speaking
|
|
7396
|
+
* microphone.on('end', () => {
|
|
7397
|
+
* stream.sendAsyncInputStreamEnd();
|
|
7398
|
+
* });
|
|
7399
|
+
* ```
|
|
7400
|
+
*
|
|
7401
|
+
* @example Receiving audio input (agent-side)
|
|
7402
|
+
* ```typescript
|
|
7403
|
+
* session.onInputStreamStart((inputStream) => {
|
|
7404
|
+
* console.log(`Receiving audio: ${inputStream.startEvent.mimeType}`);
|
|
7405
|
+
*
|
|
7406
|
+
* inputStream.onChunk((chunk) => {
|
|
7407
|
+
* // Process incoming audio data
|
|
7408
|
+
* audioProcessor.process(chunk.data);
|
|
7409
|
+
* });
|
|
7410
|
+
*
|
|
7411
|
+
* inputStream.onAsyncInputStreamEnd(() => {
|
|
7412
|
+
* console.log('Audio stream ended');
|
|
7413
|
+
* });
|
|
7414
|
+
* });
|
|
7415
|
+
* ```
|
|
7416
|
+
*
|
|
7417
|
+
* @example Handling stream errors
|
|
7418
|
+
* ```typescript
|
|
7419
|
+
* const stream = session.startAsyncInputStream({
|
|
7420
|
+
* mimeType: 'audio/pcm;rate=24000'
|
|
7421
|
+
* });
|
|
7422
|
+
*
|
|
7423
|
+
* stream.onErrorStart((error) => {
|
|
7424
|
+
* console.error(`Stream error: ${error.message}`);
|
|
7425
|
+
* // Clean up microphone resources
|
|
7426
|
+
* microphone.stop();
|
|
7427
|
+
* });
|
|
7428
|
+
* ```
|
|
7429
|
+
*/
|
|
7430
|
+
interface AsyncInputStream {
|
|
7431
|
+
/** Unique identifier for this input stream */
|
|
7432
|
+
readonly streamId: string;
|
|
7433
|
+
/**
|
|
7434
|
+
* The start event, or undefined if not yet received
|
|
7435
|
+
* @internal
|
|
7436
|
+
*/
|
|
7437
|
+
readonly startEventMaybe: AsyncInputStreamStartEvent | undefined;
|
|
7438
|
+
/**
|
|
7439
|
+
* The start event (throws if not yet received)
|
|
7440
|
+
* @internal
|
|
7441
|
+
*/
|
|
7442
|
+
readonly startEvent: AsyncInputStreamStartEvent;
|
|
7443
|
+
/** Whether this input stream has ended */
|
|
7444
|
+
readonly ended: boolean;
|
|
7445
|
+
/**
|
|
7446
|
+
* Registers a handler for error start events
|
|
7447
|
+
* @param cb - Callback receiving the error event
|
|
7448
|
+
* @returns Cleanup function to remove the handler
|
|
7449
|
+
*/
|
|
7450
|
+
onErrorStart(cb: (error: {
|
|
7451
|
+
errorId: string;
|
|
7452
|
+
} & ErrorStartEvent) => void): () => void;
|
|
7453
|
+
/**
|
|
7454
|
+
* Registers a handler for error end events
|
|
7455
|
+
* @param cb - Callback receiving the error end event
|
|
7456
|
+
* @returns Cleanup function to remove the handler
|
|
7457
|
+
*/
|
|
7458
|
+
onErrorEnd(cb: (error: {
|
|
7459
|
+
errorId: string;
|
|
7460
|
+
} & ErrorEndEvent) => void): () => void;
|
|
7461
|
+
/**
|
|
7462
|
+
* Sends a stream chunk
|
|
7463
|
+
* @param chunk - Chunk data to send (e.g., audio data)
|
|
7464
|
+
*/
|
|
7465
|
+
sendChunk(chunk: AsyncInputStreamChunkEvent): void;
|
|
7466
|
+
/**
|
|
7467
|
+
* Registers a handler for stream chunks
|
|
7468
|
+
* @param cb - Callback receiving each chunk
|
|
7469
|
+
* @returns Cleanup function to remove the handler
|
|
7470
|
+
*/
|
|
7471
|
+
onChunk(cb: (chunk: AsyncInputStreamChunkEvent) => void): () => void;
|
|
7472
|
+
/**
|
|
7473
|
+
* Ends the input stream
|
|
7474
|
+
* @param endAsyncInputStream - Optional end event data
|
|
7475
|
+
*/
|
|
7476
|
+
sendAsyncInputStreamEnd(endAsyncInputStream?: AsyncInputStreamEndEvent): void;
|
|
7477
|
+
/**
|
|
7478
|
+
* Registers a handler for stream end events
|
|
7479
|
+
* @param cb - Callback receiving the end event
|
|
7480
|
+
* @returns Cleanup function to remove the handler
|
|
7481
|
+
*/
|
|
7482
|
+
onAsyncInputStreamEnd(cb: (endAsyncInputStream: AsyncInputStreamEndEvent) => void): () => void;
|
|
7483
|
+
/**
|
|
7484
|
+
* Sends an error start event for this stream
|
|
7485
|
+
* @param args - Error details including optional error ID and message
|
|
7486
|
+
* @internal
|
|
7487
|
+
*/
|
|
7488
|
+
sendErrorStart(args: {
|
|
7489
|
+
errorId?: string;
|
|
7490
|
+
} & ErrorStartEvent): void;
|
|
7491
|
+
/**
|
|
7492
|
+
* Sends an error end event for this stream
|
|
7493
|
+
* @param args - Error end details including the error ID
|
|
7494
|
+
* @internal
|
|
7495
|
+
*/
|
|
7496
|
+
sendErrorEnd(args: {
|
|
7497
|
+
errorId: string;
|
|
7498
|
+
} & ErrorEndEvent): void;
|
|
7499
|
+
/**
|
|
7500
|
+
* Sends a metadata event for this stream
|
|
7501
|
+
* @param metaEvent - Metadata to send
|
|
7502
|
+
* @internal
|
|
7503
|
+
*/
|
|
7504
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
7505
|
+
/**
|
|
7506
|
+
* Emits a raw async input stream event
|
|
7507
|
+
* @param streamEvent - The event to emit (streamId is added automatically)
|
|
7508
|
+
* @internal
|
|
7509
|
+
*/
|
|
7510
|
+
emit(streamEvent: Omit<AsyncInputStreamEvent, 'streamId'>): void;
|
|
7511
|
+
/**
|
|
7512
|
+
* Returns a string representation of this input stream
|
|
7513
|
+
* @internal
|
|
7514
|
+
*/
|
|
7515
|
+
toString(): string;
|
|
7516
|
+
}
|
|
7517
|
+
|
|
7518
|
+
/**
|
|
7519
|
+
* Consumer-facing interface for MessageEventHelper
|
|
7520
|
+
*
|
|
7521
|
+
* Defines the public API for interacting with message events
|
|
7522
|
+
* within an exchange. Messages represent individual turns from
|
|
7523
|
+
* users, assistants, or the system.
|
|
7524
|
+
*/
|
|
7525
|
+
|
|
7526
|
+
/**
|
|
7527
|
+
* Aggregated data for a completed message
|
|
7528
|
+
*
|
|
7529
|
+
* Contains all content parts, tool calls, and metadata
|
|
7530
|
+
* available after a message stream has ended.
|
|
7531
|
+
*/
|
|
7532
|
+
type CompletedMessage = Simplify<{
|
|
7533
|
+
messageId: string;
|
|
7534
|
+
contentParts: Array<CompletedContentPart>;
|
|
7535
|
+
toolCalls: Array<CompletedToolCall>;
|
|
7536
|
+
} & Partial<MessageStartEvent> & MessageEndEvent>;
|
|
7537
|
+
/**
|
|
7538
|
+
* Consumer-facing model for message event helpers.
|
|
7539
|
+
*
|
|
7540
|
+
* A message represents a single turn from a user, assistant, or system.
|
|
7541
|
+
* Messages contain content parts (text, audio, images) and tool calls.
|
|
7542
|
+
* The `role` property and convenience booleans (`isUser`, `isAssistant`,
|
|
7543
|
+
* `isSystem`) let you filter by sender.
|
|
7544
|
+
*
|
|
7545
|
+
* @example Streaming text with real-time output
|
|
7546
|
+
* ```typescript
|
|
7547
|
+
* exchange.onMessageStart((message) => {
|
|
7548
|
+
* if (message.isAssistant) {
|
|
7549
|
+
* message.onContentPartStart((part) => {
|
|
7550
|
+
* if (part.isMarkdown) {
|
|
7551
|
+
* part.onChunk((chunk) => {
|
|
7552
|
+
* process.stdout.write(chunk.data ?? '');
|
|
7553
|
+
* });
|
|
7554
|
+
* }
|
|
7555
|
+
* });
|
|
7556
|
+
* }
|
|
7557
|
+
* });
|
|
7558
|
+
* ```
|
|
7559
|
+
*
|
|
7560
|
+
* @example Handling tool calls with confirmation interrupts
|
|
7561
|
+
* ```typescript
|
|
7562
|
+
* exchange.onMessageStart((message) => {
|
|
7563
|
+
* if (message.isAssistant) {
|
|
7564
|
+
* message.onToolCallStart((toolCall) => {
|
|
7565
|
+
* console.log(`Tool: ${toolCall.startEvent.toolName}`);
|
|
7566
|
+
* });
|
|
7567
|
+
*
|
|
7568
|
+
* message.onInterruptStart(({ interruptId, startEvent }) => {
|
|
7569
|
+
* if (startEvent.type === 'uipath_cas_tool_call_confirmation') {
|
|
7570
|
+
* message.sendInterruptEnd(interruptId, { approved: true });
|
|
7571
|
+
* }
|
|
7572
|
+
* });
|
|
7573
|
+
* }
|
|
7574
|
+
* });
|
|
7575
|
+
* ```
|
|
7576
|
+
*
|
|
7577
|
+
* @example Getting the complete message at once (buffered)
|
|
7578
|
+
* ```typescript
|
|
7579
|
+
* exchange.onMessageStart((message) => {
|
|
7580
|
+
* if (message.isAssistant) {
|
|
7581
|
+
* message.onCompleted((completed) => {
|
|
7582
|
+
* console.log(`Message ${completed.messageId} finished`);
|
|
7583
|
+
* for (const part of completed.contentParts) {
|
|
7584
|
+
* console.log(part.data);
|
|
7585
|
+
* }
|
|
7586
|
+
* for (const tool of completed.toolCalls) {
|
|
7587
|
+
* console.log(`${tool.toolName} → ${tool.output}`);
|
|
7588
|
+
* }
|
|
7589
|
+
* });
|
|
7590
|
+
* }
|
|
7591
|
+
* });
|
|
7592
|
+
* ```
|
|
7593
|
+
*
|
|
7594
|
+
* @example Sending a content part with convenience method
|
|
7595
|
+
* ```typescript
|
|
7596
|
+
* const message = exchange.startMessage({ role: MessageRole.User });
|
|
7597
|
+
* await message.sendContentPart({ data: 'Hello!', mimeType: 'text/plain' });
|
|
7598
|
+
* message.sendMessageEnd();
|
|
7599
|
+
* ```
|
|
7600
|
+
*/
|
|
7601
|
+
interface MessageStream {
|
|
7602
|
+
/** Unique identifier for this message */
|
|
7603
|
+
readonly messageId: string;
|
|
7604
|
+
/** The role of this message sender, or undefined if start event not yet received */
|
|
7605
|
+
readonly role: MessageRole | undefined;
|
|
7606
|
+
/** Whether this message is from the user */
|
|
7607
|
+
readonly isUser: boolean;
|
|
7608
|
+
/** Whether this message is from the assistant */
|
|
7609
|
+
readonly isAssistant: boolean;
|
|
7610
|
+
/** Whether this message is a system message */
|
|
7611
|
+
readonly isSystem: boolean;
|
|
7612
|
+
/**
|
|
7613
|
+
* The start event, or undefined if not yet received
|
|
7614
|
+
* @internal
|
|
7615
|
+
*/
|
|
7616
|
+
readonly startEventMaybe: MessageStartEvent | undefined;
|
|
7617
|
+
/**
|
|
7618
|
+
* The start event (throws if not yet received)
|
|
7619
|
+
* @internal
|
|
7620
|
+
*/
|
|
7621
|
+
readonly startEvent: MakeRequired<MessageStartEvent, 'timestamp'>;
|
|
7622
|
+
/** Whether this message has ended */
|
|
7623
|
+
readonly ended: boolean;
|
|
7624
|
+
/**
|
|
7625
|
+
* Registers a handler for error start events
|
|
7626
|
+
*
|
|
7627
|
+
* @param cb - Callback receiving the error event
|
|
7628
|
+
* @returns Cleanup function to remove the handler
|
|
7629
|
+
*
|
|
7630
|
+
* @example Message-level error handling
|
|
7631
|
+
* ```typescript
|
|
7632
|
+
* message.onErrorStart((error) => {
|
|
7633
|
+
* console.error(`Message error [${error.errorId}]: ${error.message}`);
|
|
7634
|
+
* });
|
|
7635
|
+
* ```
|
|
7636
|
+
*/
|
|
7637
|
+
onErrorStart(cb: (error: {
|
|
7638
|
+
errorId: string;
|
|
7639
|
+
} & ErrorStartEvent) => void): () => void;
|
|
7640
|
+
/**
|
|
7641
|
+
* Registers a handler for error end events
|
|
7642
|
+
* @param cb - Callback receiving the error end event
|
|
7643
|
+
* @returns Cleanup function to remove the handler
|
|
7644
|
+
*/
|
|
7645
|
+
onErrorEnd(cb: (error: {
|
|
7646
|
+
errorId: string;
|
|
7647
|
+
} & ErrorEndEvent) => void): () => void;
|
|
7648
|
+
/**
|
|
7649
|
+
* Registers a handler for content part start events
|
|
7650
|
+
*
|
|
7651
|
+
* Content parts are streamed pieces of content (text, audio, images,
|
|
7652
|
+
* transcripts). Use `part.isMarkdown`, `part.isAudio`, etc. to determine type.
|
|
7653
|
+
*
|
|
7654
|
+
* @param cb - Callback receiving each new content part
|
|
7655
|
+
* @returns Cleanup function to remove the handler
|
|
7656
|
+
*
|
|
7657
|
+
* @example Streaming text and handling different content types
|
|
7658
|
+
* ```typescript
|
|
7659
|
+
* message.onContentPartStart((part) => {
|
|
7660
|
+
* if (part.isMarkdown) {
|
|
7661
|
+
* part.onChunk((chunk) => renderMarkdown(chunk.data ?? ''));
|
|
7662
|
+
* } else if (part.isAudio) {
|
|
7663
|
+
* part.onChunk((chunk) => audioPlayer.enqueue(chunk.data ?? ''));
|
|
7664
|
+
* } else if (part.isImage) {
|
|
7665
|
+
* part.onChunk((chunk) => imageBuffer.append(chunk.data ?? ''));
|
|
7666
|
+
* } else if (part.isTranscript) {
|
|
7667
|
+
* part.onChunk((chunk) => showTranscript(chunk.data ?? ''));
|
|
7668
|
+
* }
|
|
7669
|
+
* });
|
|
7670
|
+
* ```
|
|
7671
|
+
*/
|
|
7672
|
+
onContentPartStart(cb: (contentPart: ContentPartStream) => void): () => void;
|
|
7673
|
+
/**
|
|
7674
|
+
* Registers a handler for tool call start events
|
|
7675
|
+
*
|
|
7676
|
+
* Tool calls represent the agent invoking external tools. Each tool call
|
|
7677
|
+
* has a name, input, and eventually an output when it completes.
|
|
7678
|
+
*
|
|
7679
|
+
* @param cb - Callback receiving each new tool call
|
|
7680
|
+
* @returns Cleanup function to remove the handler
|
|
7681
|
+
*
|
|
7682
|
+
* @example Streaming tool call events
|
|
7683
|
+
* ```typescript
|
|
7684
|
+
* message.onToolCallStart((toolCall) => {
|
|
7685
|
+
* const { toolName, input } = toolCall.startEvent;
|
|
7686
|
+
* console.log(`Calling ${toolName}:`, JSON.parse(input ?? '{}'));
|
|
7687
|
+
*
|
|
7688
|
+
* toolCall.onToolCallEnd((end) => {
|
|
7689
|
+
* console.log(`Result:`, JSON.parse(end.output ?? '{}'));
|
|
7690
|
+
* });
|
|
7691
|
+
* });
|
|
7692
|
+
* ```
|
|
7693
|
+
*/
|
|
7694
|
+
onToolCallStart(cb: (toolCall: ToolCallStream) => void): () => void;
|
|
7695
|
+
/**
|
|
7696
|
+
* Registers a handler for message end events
|
|
7697
|
+
*
|
|
7698
|
+
* @param cb - Callback receiving the end event
|
|
7699
|
+
* @returns Cleanup function to remove the handler
|
|
7700
|
+
*
|
|
7701
|
+
* @example Tracking message lifecycle
|
|
7702
|
+
* ```typescript
|
|
7703
|
+
* message.onMessageEnd((endEvent) => {
|
|
7704
|
+
* console.log('Message ended');
|
|
7705
|
+
* });
|
|
7706
|
+
* ```
|
|
7707
|
+
*/
|
|
7708
|
+
onMessageEnd(cb: (endMessage: MessageEndEvent) => void): () => void;
|
|
7709
|
+
/**
|
|
7710
|
+
* Registers a handler called when a content part finishes
|
|
7711
|
+
*
|
|
7712
|
+
* Convenience method that combines onContentPartStart + onContentPartEnd.
|
|
7713
|
+
* The handler receives the full buffered content part data including
|
|
7714
|
+
* text, citations, and any citation errors.
|
|
7715
|
+
*
|
|
7716
|
+
* @param cb - Callback receiving the completed content part data
|
|
7717
|
+
*
|
|
7718
|
+
* @example Getting completed content parts with citations
|
|
7719
|
+
* ```typescript
|
|
7720
|
+
* message.onContentPartCompleted((completed) => {
|
|
7721
|
+
* console.log(`[${completed.mimeType}] ${completed.data}`);
|
|
7722
|
+
*
|
|
7723
|
+
* // Access citations if present
|
|
7724
|
+
* for (const citation of completed.citations) {
|
|
7725
|
+
* const citedText = completed.data.substring(citation.offset, citation.offset + citation.length);
|
|
7726
|
+
* console.log(`Citation "${citedText}" from:`, citation.sources);
|
|
7727
|
+
* }
|
|
7728
|
+
*
|
|
7729
|
+
* // Check for citation errors
|
|
7730
|
+
* for (const error of completed.citationErrors) {
|
|
7731
|
+
* console.warn(`Citation error [${error.citationId}]: ${error.errorType}`);
|
|
7732
|
+
* }
|
|
7733
|
+
* });
|
|
7734
|
+
* ```
|
|
7735
|
+
*/
|
|
7736
|
+
onContentPartCompleted(cb: (completedContentPart: CompletedContentPart) => void): void;
|
|
7737
|
+
/**
|
|
7738
|
+
* Registers a handler called when a tool call finishes
|
|
7739
|
+
*
|
|
7740
|
+
* Convenience method that combines onToolCallStart + onToolCallEnd.
|
|
7741
|
+
* The handler receives the merged start and end event data.
|
|
7742
|
+
*
|
|
7743
|
+
* @param cb - Callback receiving the completed tool call data
|
|
7744
|
+
*
|
|
7745
|
+
* @example Getting completed tool calls
|
|
7746
|
+
* ```typescript
|
|
7747
|
+
* message.onToolCallCompleted((toolCall) => {
|
|
7748
|
+
* console.log(`Tool: ${toolCall.toolName}`);
|
|
7749
|
+
* console.log(`Input: ${toolCall.input}`);
|
|
7750
|
+
* console.log(`Output: ${toolCall.output}`);
|
|
7751
|
+
* });
|
|
7752
|
+
* ```
|
|
7753
|
+
*/
|
|
7754
|
+
onToolCallCompleted(cb: (completedToolCall: CompletedToolCall) => void): void;
|
|
7755
|
+
/**
|
|
7756
|
+
* Registers a handler called when the entire message finishes
|
|
7757
|
+
*
|
|
7758
|
+
* The handler receives the aggregated message data including
|
|
7759
|
+
* all completed content parts and tool calls.
|
|
7760
|
+
*
|
|
7761
|
+
* @param cb - Callback receiving the completed message data
|
|
7762
|
+
*
|
|
7763
|
+
* @example Getting the full buffered message
|
|
7764
|
+
* ```typescript
|
|
7765
|
+
* message.onCompleted((completed) => {
|
|
7766
|
+
* console.log(`Message ${completed.messageId} (role: ${completed.role})`);
|
|
7767
|
+
* console.log('Text:', completed.contentParts.map(p => p.data).join(''));
|
|
7768
|
+
* console.log('Tool calls:', completed.toolCalls.length);
|
|
7769
|
+
* });
|
|
7770
|
+
* ```
|
|
7771
|
+
*/
|
|
7772
|
+
onCompleted(cb: (completedMessage: CompletedMessage) => void): void;
|
|
7773
|
+
/**
|
|
7774
|
+
* Registers a handler for interrupt start events
|
|
7775
|
+
*
|
|
7776
|
+
* Interrupts represent pause points where the agent needs external input,
|
|
7777
|
+
* such as tool call confirmation requests.
|
|
7778
|
+
*
|
|
7779
|
+
* @param cb - Callback receiving the interrupt ID and start event
|
|
7780
|
+
* @returns Cleanup function to remove the handler
|
|
7781
|
+
*
|
|
7782
|
+
* @example Handling tool call confirmation
|
|
7783
|
+
* ```typescript
|
|
7784
|
+
* message.onInterruptStart(({ interruptId, startEvent }) => {
|
|
7785
|
+
* if (startEvent.type === 'uipath_cas_tool_call_confirmation') {
|
|
7786
|
+
* // Show confirmation UI, then respond
|
|
7787
|
+
* message.sendInterruptEnd(interruptId, { approved: true });
|
|
7788
|
+
* }
|
|
7789
|
+
* });
|
|
7790
|
+
* ```
|
|
7791
|
+
*/
|
|
7792
|
+
onInterruptStart(cb: (interrupt: {
|
|
7793
|
+
interruptId: string;
|
|
7794
|
+
startEvent: InterruptStartEvent;
|
|
7795
|
+
}) => void): () => void;
|
|
7796
|
+
/**
|
|
7797
|
+
* Registers a handler for interrupt end events
|
|
7798
|
+
*
|
|
7799
|
+
* @param cb - Callback receiving the interrupt ID and end event
|
|
7800
|
+
* @returns Cleanup function to remove the handler
|
|
7801
|
+
*
|
|
7802
|
+
* @example Tracking interrupt resolution
|
|
7803
|
+
* ```typescript
|
|
7804
|
+
* message.onInterruptEnd(({ interruptId, endEvent }) => {
|
|
7805
|
+
* console.log(`Interrupt ${interruptId} resolved`);
|
|
7806
|
+
* });
|
|
7807
|
+
* ```
|
|
7808
|
+
*/
|
|
7809
|
+
onInterruptEnd(cb: (interrupt: {
|
|
7810
|
+
interruptId: string;
|
|
7811
|
+
endEvent: InterruptEndEvent;
|
|
7812
|
+
}) => void): () => void;
|
|
7813
|
+
/**
|
|
7814
|
+
* Sends an interrupt end event to resolve a pending interrupt
|
|
7815
|
+
*
|
|
7816
|
+
* Call this to respond to an interrupt received via onInterruptStart.
|
|
7817
|
+
*
|
|
7818
|
+
* @param interruptId - The interrupt ID to respond to
|
|
7819
|
+
* @param endInterrupt - The response data (e.g., approval for tool call confirmation)
|
|
7820
|
+
*
|
|
7821
|
+
* @example Approving a tool call confirmation
|
|
7822
|
+
* ```typescript
|
|
7823
|
+
* message.sendInterruptEnd(interruptId, { approved: true });
|
|
7824
|
+
* ```
|
|
7825
|
+
*/
|
|
7826
|
+
sendInterruptEnd(interruptId: string, endInterrupt: InterruptEndEvent): void;
|
|
7827
|
+
/**
|
|
7828
|
+
* Starts a new content part stream in this message
|
|
7829
|
+
*
|
|
7830
|
+
* Use this for streaming content in chunks. For sending
|
|
7831
|
+
* complete content in one call, prefer {@link sendContentPart}.
|
|
7832
|
+
*
|
|
7833
|
+
* @param args - Content part start options including mime type
|
|
7834
|
+
* @returns The content part stream for sending chunks
|
|
7835
|
+
*
|
|
7836
|
+
* @example Streaming text content in chunks
|
|
7837
|
+
* ```typescript
|
|
7838
|
+
* const part = message.startContentPart({ mimeType: 'text/markdown' });
|
|
7839
|
+
* part.sendChunk({ data: '# Hello\n' });
|
|
7840
|
+
* part.sendChunk({ data: 'This is **markdown** content.' });
|
|
7841
|
+
* part.sendContentPartEnd();
|
|
7842
|
+
* ```
|
|
7843
|
+
*/
|
|
7844
|
+
startContentPart(args: {
|
|
7845
|
+
contentPartId?: string;
|
|
7846
|
+
} & ContentPartStartEvent): ContentPartStream;
|
|
7847
|
+
/**
|
|
7848
|
+
* Sends a complete content part with data in one step
|
|
7849
|
+
*
|
|
7850
|
+
* Convenience method that creates a content part, sends the data as a chunk,
|
|
7851
|
+
* and ends the content part. Defaults to mimeType "text/markdown".
|
|
7852
|
+
*
|
|
7853
|
+
* @param args - Content part data and optional mime type
|
|
7854
|
+
*
|
|
7855
|
+
* @example Sending a text content part
|
|
7856
|
+
* ```typescript
|
|
7857
|
+
* await message.sendContentPart({ data: 'Hello world!' });
|
|
7858
|
+
* ```
|
|
7859
|
+
*
|
|
7860
|
+
* @example Sending with explicit mime type
|
|
7861
|
+
* ```typescript
|
|
7862
|
+
* await message.sendContentPart({
|
|
7863
|
+
* data: 'Plain text content',
|
|
7864
|
+
* mimeType: 'text/plain'
|
|
7865
|
+
* });
|
|
7866
|
+
* ```
|
|
7867
|
+
*/
|
|
7868
|
+
sendContentPart(args: {
|
|
7869
|
+
data?: string;
|
|
7870
|
+
mimeType?: string;
|
|
7871
|
+
}): Promise<void>;
|
|
7872
|
+
/**
|
|
7873
|
+
* Iterator over all active content parts in this message
|
|
7874
|
+
*/
|
|
7875
|
+
readonly contentParts: Iterable<ContentPartStream>;
|
|
7876
|
+
/**
|
|
7877
|
+
* Retrieves a content part by ID
|
|
7878
|
+
* @param contentPartId - The content part ID to look up
|
|
7879
|
+
* @returns The content part stream, or undefined if not found
|
|
7880
|
+
*/
|
|
7881
|
+
getContentPart(contentPartId: string): ContentPartStream | undefined;
|
|
7882
|
+
/**
|
|
7883
|
+
* Starts a new tool call in this message
|
|
7884
|
+
*
|
|
7885
|
+
* @param args - Tool call start options including tool name
|
|
7886
|
+
* @returns The tool call stream for managing the tool call lifecycle
|
|
7887
|
+
*
|
|
7888
|
+
* @example Creating and completing a tool call
|
|
7889
|
+
* ```typescript
|
|
7890
|
+
* const toolCall = message.startToolCall({
|
|
7891
|
+
* toolName: 'get-weather',
|
|
7892
|
+
* input: JSON.stringify({ city: 'London' })
|
|
7893
|
+
* });
|
|
7894
|
+
* toolCall.sendToolCallEnd({
|
|
7895
|
+
* output: JSON.stringify({ temperature: 18, condition: 'cloudy' })
|
|
7896
|
+
* });
|
|
7897
|
+
* ```
|
|
7898
|
+
*/
|
|
7899
|
+
startToolCall(args: {
|
|
7900
|
+
toolCallId?: string;
|
|
7901
|
+
} & ToolCallStartEvent): ToolCallStream;
|
|
7902
|
+
/**
|
|
7903
|
+
* Iterator over all active tool calls in this message
|
|
7904
|
+
*/
|
|
7905
|
+
readonly toolCalls: Iterable<ToolCallStream>;
|
|
7906
|
+
/**
|
|
7907
|
+
* Retrieves a tool call by ID
|
|
7908
|
+
* @param toolCallId - The tool call ID to look up
|
|
7909
|
+
* @returns The tool call stream, or undefined if not found
|
|
7910
|
+
*/
|
|
7911
|
+
getToolCall(toolCallId: string): ToolCallStream | undefined;
|
|
7912
|
+
/**
|
|
7913
|
+
* Ends the message
|
|
7914
|
+
*
|
|
7915
|
+
* @param endMessage - Optional end event data
|
|
7916
|
+
*
|
|
7917
|
+
* @example Ending a message
|
|
7918
|
+
* ```typescript
|
|
7919
|
+
* message.sendMessageEnd();
|
|
7920
|
+
* ```
|
|
7921
|
+
*/
|
|
7922
|
+
sendMessageEnd(endMessage?: MessageEndEvent): void;
|
|
7923
|
+
/**
|
|
7924
|
+
* Sends an error start event for this message
|
|
7925
|
+
* @param args - Error details including optional error ID and message
|
|
7926
|
+
* @internal
|
|
7927
|
+
*/
|
|
7928
|
+
sendErrorStart(args: {
|
|
7929
|
+
errorId?: string;
|
|
7930
|
+
} & ErrorStartEvent): void;
|
|
7931
|
+
/**
|
|
7932
|
+
* Sends an error end event for this message
|
|
7933
|
+
* @param args - Error end details including the error ID
|
|
7934
|
+
* @internal
|
|
7935
|
+
*/
|
|
7936
|
+
sendErrorEnd(args: {
|
|
7937
|
+
errorId: string;
|
|
7938
|
+
} & ErrorEndEvent): void;
|
|
7939
|
+
/**
|
|
7940
|
+
* Sends a metadata event for this message
|
|
7941
|
+
* @param metaEvent - Metadata to send
|
|
7942
|
+
* @internal
|
|
7943
|
+
*/
|
|
7944
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
7945
|
+
/**
|
|
7946
|
+
* Emits a raw message event
|
|
7947
|
+
* @param messageEvent - The event to emit (messageId is added automatically)
|
|
7948
|
+
* @internal
|
|
7949
|
+
*/
|
|
7950
|
+
emit(messageEvent: Omit<MessageEvent, 'messageId'>): void;
|
|
7951
|
+
/**
|
|
7952
|
+
* Sends an interrupt start event
|
|
7953
|
+
* @param interruptId - The interrupt ID
|
|
7954
|
+
* @param startInterrupt - The interrupt start event data
|
|
7955
|
+
* @internal
|
|
7956
|
+
*/
|
|
7957
|
+
sendInterrupt(interruptId: string, startInterrupt: InterruptStartEvent): void;
|
|
7958
|
+
/**
|
|
7959
|
+
* Returns a string representation of this message
|
|
7960
|
+
* @internal
|
|
7961
|
+
*/
|
|
7962
|
+
toString(): string;
|
|
7963
|
+
}
|
|
7964
|
+
|
|
7965
|
+
/**
|
|
7966
|
+
* Consumer-facing interface for ExchangeEventHelper
|
|
7967
|
+
*
|
|
7968
|
+
* Defines the public API for interacting with exchange events
|
|
7969
|
+
* within a session. Exchanges represent request-response pairs
|
|
7970
|
+
* containing user and assistant messages.
|
|
7971
|
+
*/
|
|
7972
|
+
|
|
7973
|
+
/**
|
|
7974
|
+
* Consumer-facing model for exchange event helpers.
|
|
7975
|
+
*
|
|
7976
|
+
* An exchange represents a single request-response cycle within a session.
|
|
7977
|
+
* Each exchange contains one or more messages (typically a user message
|
|
7978
|
+
* followed by an assistant response). Use exchanges to group related
|
|
7979
|
+
* turns in a multi-turn conversation.
|
|
7980
|
+
*
|
|
7981
|
+
* @example Streaming assistant response
|
|
7982
|
+
* ```typescript
|
|
7983
|
+
* session.onExchangeStart((exchange) => {
|
|
7984
|
+
* exchange.onMessageStart((message) => {
|
|
7985
|
+
* if (message.isAssistant) {
|
|
7986
|
+
* message.onContentPartStart((part) => {
|
|
7987
|
+
* if (part.isMarkdown) {
|
|
7988
|
+
* part.onChunk((chunk) => {
|
|
7989
|
+
* process.stdout.write(chunk.data ?? '');
|
|
7990
|
+
* });
|
|
7991
|
+
* }
|
|
7992
|
+
* });
|
|
7993
|
+
* }
|
|
7994
|
+
* });
|
|
7995
|
+
* });
|
|
7996
|
+
* ```
|
|
7997
|
+
*
|
|
7998
|
+
* @example Getting the completed message at once (no streaming)
|
|
7999
|
+
* ```typescript
|
|
8000
|
+
* session.onExchangeStart((exchange) => {
|
|
8001
|
+
* exchange.onMessageCompleted((completed) => {
|
|
8002
|
+
* for (const part of completed.contentParts) {
|
|
8003
|
+
* console.log(part.data);
|
|
8004
|
+
* }
|
|
8005
|
+
* for (const tool of completed.toolCalls) {
|
|
8006
|
+
* console.log(`${tool.toolName}: ${tool.output}`);
|
|
8007
|
+
* }
|
|
8008
|
+
* });
|
|
8009
|
+
* });
|
|
8010
|
+
* ```
|
|
8011
|
+
*
|
|
8012
|
+
* @example Sending a user message with convenience method
|
|
8013
|
+
* ```typescript
|
|
8014
|
+
* // Call startExchange inside onSessionStarted to ensure the session is ready
|
|
8015
|
+
* session.onSessionStarted(() => {
|
|
8016
|
+
* const exchange = session.startExchange();
|
|
8017
|
+
* exchange.sendMessageWithContentPart({
|
|
8018
|
+
* data: 'Hello, how can you help me?',
|
|
8019
|
+
* role: MessageRole.User
|
|
8020
|
+
* });
|
|
8021
|
+
* });
|
|
8022
|
+
* ```
|
|
8023
|
+
*
|
|
8024
|
+
* @example Sending a user message with streaming parts
|
|
8025
|
+
* ```typescript
|
|
8026
|
+
* // Call startExchange inside onSessionStarted to ensure the session is ready
|
|
8027
|
+
* session.onSessionStarted(() => {
|
|
8028
|
+
* const exchange = session.startExchange();
|
|
8029
|
+
* const message = exchange.startMessage({ role: MessageRole.User });
|
|
8030
|
+
* const part = message.startContentPart({ mimeType: 'text/plain' });
|
|
8031
|
+
* part.sendChunk({ data: 'Hello, ' });
|
|
8032
|
+
* part.sendChunk({ data: 'how can you help me?' });
|
|
8033
|
+
* part.sendContentPartEnd();
|
|
8034
|
+
* message.sendMessageEnd();
|
|
8035
|
+
* });
|
|
8036
|
+
* ```
|
|
8037
|
+
*/
|
|
8038
|
+
interface ExchangeStream {
|
|
8039
|
+
/** Unique identifier for this exchange */
|
|
8040
|
+
readonly exchangeId: string;
|
|
8041
|
+
/**
|
|
8042
|
+
* The start event, or undefined if not yet received
|
|
8043
|
+
* @internal
|
|
8044
|
+
*/
|
|
8045
|
+
readonly startEventMaybe: ExchangeStartEvent | undefined;
|
|
8046
|
+
/**
|
|
8047
|
+
* The start event (throws if not yet received)
|
|
8048
|
+
* @internal
|
|
8049
|
+
*/
|
|
8050
|
+
readonly startEvent: MakeRequired<ExchangeStartEvent, 'timestamp'>;
|
|
8051
|
+
/** Whether this exchange has ended */
|
|
8052
|
+
readonly ended: boolean;
|
|
8053
|
+
/**
|
|
8054
|
+
* Registers a handler for error start events
|
|
8055
|
+
*
|
|
8056
|
+
* @param cb - Callback receiving the error event
|
|
8057
|
+
* @returns Cleanup function to remove the handler
|
|
8058
|
+
*
|
|
8059
|
+
* @example Exchange-level error handling
|
|
8060
|
+
* ```typescript
|
|
8061
|
+
* exchange.onErrorStart((error) => {
|
|
8062
|
+
* console.error(`Exchange error [${error.errorId}]: ${error.message}`);
|
|
8063
|
+
* });
|
|
8064
|
+
* ```
|
|
8065
|
+
*/
|
|
8066
|
+
onErrorStart(cb: (error: {
|
|
8067
|
+
errorId: string;
|
|
8068
|
+
} & ErrorStartEvent) => void): () => void;
|
|
8069
|
+
/**
|
|
8070
|
+
* Registers a handler for error end events
|
|
8071
|
+
* @param cb - Callback receiving the error end event
|
|
8072
|
+
* @returns Cleanup function to remove the handler
|
|
8073
|
+
*/
|
|
8074
|
+
onErrorEnd(cb: (error: {
|
|
8075
|
+
errorId: string;
|
|
8076
|
+
} & ErrorEndEvent) => void): () => void;
|
|
8077
|
+
/**
|
|
8078
|
+
* Registers a handler for message start events
|
|
8079
|
+
*
|
|
8080
|
+
* Each exchange typically contains a user message and an assistant
|
|
8081
|
+
* response. Use `message.isAssistant` or `message.isUser` to filter.
|
|
8082
|
+
*
|
|
8083
|
+
* @param cb - Callback receiving each new message
|
|
8084
|
+
* @returns Cleanup function to remove the handler
|
|
8085
|
+
*
|
|
8086
|
+
* @example Filtering by message role
|
|
8087
|
+
* ```typescript
|
|
8088
|
+
* exchange.onMessageStart((message) => {
|
|
8089
|
+
* if (message.isAssistant) {
|
|
8090
|
+
* message.onContentPartStart((part) => {
|
|
8091
|
+
* if (part.isMarkdown) {
|
|
8092
|
+
* part.onChunk((chunk) => process.stdout.write(chunk.data ?? ''));
|
|
8093
|
+
* }
|
|
8094
|
+
* });
|
|
8095
|
+
* }
|
|
8096
|
+
* });
|
|
8097
|
+
* ```
|
|
8098
|
+
*/
|
|
8099
|
+
onMessageStart(cb: (message: MessageStream) => void): () => void;
|
|
8100
|
+
/**
|
|
8101
|
+
* Registers a handler for exchange end events
|
|
8102
|
+
*
|
|
8103
|
+
* @param cb - Callback receiving the end event
|
|
8104
|
+
* @returns Cleanup function to remove the handler
|
|
8105
|
+
*
|
|
8106
|
+
* @example Tracking exchange lifecycle
|
|
8107
|
+
* ```typescript
|
|
8108
|
+
* exchange.onExchangeEnd((endEvent) => {
|
|
8109
|
+
* console.log('Exchange completed');
|
|
8110
|
+
* });
|
|
8111
|
+
* ```
|
|
8112
|
+
*/
|
|
8113
|
+
onExchangeEnd(cb: (endExchange: ExchangeEndEvent) => void): () => void;
|
|
8114
|
+
/**
|
|
8115
|
+
* Registers a handler called when a message finishes
|
|
8116
|
+
*
|
|
8117
|
+
* Convenience method that combines onMessageStart + message.onCompleted.
|
|
8118
|
+
* The handler receives the aggregated message data including all
|
|
8119
|
+
* content parts and tool calls.
|
|
8120
|
+
*
|
|
8121
|
+
* @param cb - Callback receiving the completed message data
|
|
8122
|
+
*
|
|
8123
|
+
* @example Getting buffered message with all content and tool calls
|
|
8124
|
+
* ```typescript
|
|
8125
|
+
* exchange.onMessageCompleted((message) => {
|
|
8126
|
+
* console.log(`Message ${message.messageId} (role: ${message.role})`);
|
|
8127
|
+
* console.log(`Content parts: ${message.contentParts.length}`);
|
|
8128
|
+
* console.log(`Tool calls: ${message.toolCalls.length}`);
|
|
8129
|
+
* });
|
|
8130
|
+
* ```
|
|
8131
|
+
*/
|
|
8132
|
+
onMessageCompleted(cb: (completedMessage: CompletedMessage) => void): void;
|
|
8133
|
+
/**
|
|
8134
|
+
* Starts a new message in this exchange
|
|
8135
|
+
*
|
|
8136
|
+
* Use this for fine-grained control over message construction.
|
|
8137
|
+
* For simple text messages, prefer {@link sendMessageWithContentPart}.
|
|
8138
|
+
*
|
|
8139
|
+
* @param args - Optional message start options including role
|
|
8140
|
+
* @returns The message stream for sending content
|
|
8141
|
+
*
|
|
8142
|
+
* @example Building a message with multiple content parts
|
|
8143
|
+
* ```typescript
|
|
8144
|
+
* const message = exchange.startMessage({ role: MessageRole.User });
|
|
8145
|
+
* const part = message.startContentPart({ mimeType: 'text/plain' });
|
|
8146
|
+
* part.sendChunk({ data: 'Analyze this image: ' });
|
|
8147
|
+
* part.sendContentPartEnd();
|
|
8148
|
+
* message.sendMessageEnd();
|
|
8149
|
+
* ```
|
|
8150
|
+
*/
|
|
8151
|
+
startMessage(args?: {
|
|
8152
|
+
messageId?: string;
|
|
8153
|
+
} & Partial<MessageStartEvent>): MessageStream;
|
|
8154
|
+
/**
|
|
8155
|
+
* Sends a complete message with a content part in one step
|
|
8156
|
+
*
|
|
8157
|
+
* Convenience method that creates a message, adds a content part with the given data,
|
|
8158
|
+
* and ends both the content part and message.
|
|
8159
|
+
*
|
|
8160
|
+
* @param options - Message content options
|
|
8161
|
+
*
|
|
8162
|
+
* @example Sending a user message
|
|
8163
|
+
* ```typescript
|
|
8164
|
+
* await exchange.sendMessageWithContentPart({
|
|
8165
|
+
* data: 'What is the weather today?',
|
|
8166
|
+
* role: MessageRole.User
|
|
8167
|
+
* });
|
|
8168
|
+
* ```
|
|
8169
|
+
*/
|
|
8170
|
+
sendMessageWithContentPart(options: {
|
|
8171
|
+
data: string;
|
|
8172
|
+
role?: MessageRole;
|
|
8173
|
+
mimeType?: string;
|
|
8174
|
+
}): Promise<void>;
|
|
8175
|
+
/**
|
|
8176
|
+
* Iterator over all active messages in this exchange
|
|
8177
|
+
*/
|
|
8178
|
+
readonly messages: Iterable<MessageStream>;
|
|
8179
|
+
/**
|
|
8180
|
+
* Retrieves a message by ID
|
|
8181
|
+
* @param messageId - The message ID to look up
|
|
8182
|
+
* @returns The message stream, or undefined if not found
|
|
8183
|
+
*/
|
|
8184
|
+
getMessage(messageId: string): MessageStream | undefined;
|
|
8185
|
+
/**
|
|
8186
|
+
* Ends the exchange
|
|
8187
|
+
*
|
|
8188
|
+
* @param endExchange - Optional end event data
|
|
8189
|
+
*
|
|
8190
|
+
* @example Manually ending an exchange
|
|
8191
|
+
* ```typescript
|
|
8192
|
+
* exchange.sendExchangeEnd();
|
|
8193
|
+
* ```
|
|
8194
|
+
*/
|
|
8195
|
+
sendExchangeEnd(endExchange?: ExchangeEndEvent): void;
|
|
8196
|
+
/**
|
|
8197
|
+
* Sends an error start event for this exchange
|
|
8198
|
+
* @param args - Error details including optional error ID and message
|
|
8199
|
+
* @internal
|
|
8200
|
+
*/
|
|
8201
|
+
sendErrorStart(args: {
|
|
8202
|
+
errorId?: string;
|
|
8203
|
+
} & ErrorStartEvent): void;
|
|
8204
|
+
/**
|
|
8205
|
+
* Sends an error end event for this exchange
|
|
8206
|
+
* @param args - Error end details including the error ID
|
|
8207
|
+
* @internal
|
|
8208
|
+
*/
|
|
8209
|
+
sendErrorEnd(args: {
|
|
8210
|
+
errorId: string;
|
|
8211
|
+
} & ErrorEndEvent): void;
|
|
8212
|
+
/**
|
|
8213
|
+
* Sends a metadata event for this exchange
|
|
8214
|
+
* @param metaEvent - Metadata to send
|
|
8215
|
+
* @internal
|
|
8216
|
+
*/
|
|
8217
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
8218
|
+
/**
|
|
8219
|
+
* Emits a raw exchange event
|
|
8220
|
+
* @param exchangeEvent - The event to emit (exchangeId is added automatically)
|
|
8221
|
+
* @internal
|
|
8222
|
+
*/
|
|
8223
|
+
emit(exchangeEvent: Omit<ExchangeEvent, 'exchangeId'>): void;
|
|
8224
|
+
/**
|
|
8225
|
+
* Returns a string representation of this exchange
|
|
8226
|
+
* @internal
|
|
8227
|
+
*/
|
|
8228
|
+
toString(): string;
|
|
8229
|
+
}
|
|
8230
|
+
|
|
8231
|
+
/**
|
|
8232
|
+
* Consumer-facing interface for SessionEventHelper
|
|
8233
|
+
*
|
|
8234
|
+
* Defines the public API for interacting with a real-time
|
|
8235
|
+
* conversation session. Sessions are the top-level container
|
|
8236
|
+
* for exchanges, messages, and streaming content.
|
|
8237
|
+
*/
|
|
8238
|
+
|
|
8239
|
+
/**
|
|
8240
|
+
* Real-time WebSocket session for two-way communication within a {@link ConversationServiceModel | Conversation}.
|
|
8241
|
+
*
|
|
8242
|
+
* Send messages and receive agent responses through a nested stream hierarchy.
|
|
8243
|
+
* The `SessionStream` is the top-level entry point — events flow down through
|
|
8244
|
+
* exchanges, messages, content parts, and tool calls.
|
|
8245
|
+
*
|
|
8246
|
+
* ### Usage
|
|
8247
|
+
*
|
|
8248
|
+
* **Important:** Always wait for `onSessionStarted` before calling
|
|
8249
|
+
* `startExchange`. The session must be fully connected via WebSocket
|
|
8250
|
+
* before exchanges can be sent — calling `startExchange` earlier may
|
|
8251
|
+
* lose events or cause errors.
|
|
8252
|
+
*
|
|
8253
|
+
* ```typescript
|
|
8254
|
+
* const session = conversation.startSession();
|
|
8255
|
+
*
|
|
8256
|
+
* // Set up handlers for incoming assistant responses
|
|
8257
|
+
* session.onExchangeStart((exchange) => {
|
|
8258
|
+
* exchange.onMessageStart((message) => {
|
|
8259
|
+
* if (message.isAssistant) {
|
|
8260
|
+
* message.onContentPartStart((part) => {
|
|
8261
|
+
* if (part.isMarkdown) {
|
|
8262
|
+
* part.onChunk((chunk) => {
|
|
8263
|
+
* process.stdout.write(chunk.data ?? '');
|
|
8264
|
+
* });
|
|
8265
|
+
* }
|
|
8266
|
+
* });
|
|
8267
|
+
* }
|
|
8268
|
+
* });
|
|
8269
|
+
* });
|
|
8270
|
+
*
|
|
8271
|
+
* // Wait for the session to be ready, then send a message
|
|
8272
|
+
* session.onSessionStarted(() => {
|
|
8273
|
+
* const exchange = session.startExchange();
|
|
8274
|
+
* exchange.sendMessageWithContentPart({
|
|
8275
|
+
* data: 'Hello!',
|
|
8276
|
+
* role: MessageRole.User
|
|
8277
|
+
* });
|
|
8278
|
+
* });
|
|
8279
|
+
*
|
|
8280
|
+
* // End the session when done
|
|
8281
|
+
* conversation.endSession();
|
|
8282
|
+
* ```
|
|
8283
|
+
*
|
|
8284
|
+
* ### Related Streams
|
|
8285
|
+
*
|
|
8286
|
+
* | Stream | Description |
|
|
8287
|
+
* | --- | --- |
|
|
8288
|
+
* | {@link ExchangeStream} | A single request-response cycle within a session. Contains user and assistant messages. |
|
|
8289
|
+
* | {@link MessageStream} | A single message (user, assistant, or system). Contains content parts and tool calls. |
|
|
8290
|
+
* | {@link ContentPartStream} | A piece of streamed content (text, audio, image, transcript). Delivers data via `onChunk`. |
|
|
8291
|
+
* | {@link ToolCallStream} | An external tool invocation by the assistant. Has a start event (name, input) and end event (output). |
|
|
8292
|
+
*/
|
|
8293
|
+
interface SessionStream {
|
|
8294
|
+
/** The conversation ID this session belongs to */
|
|
8295
|
+
readonly conversationId: string;
|
|
8296
|
+
/**
|
|
8297
|
+
* Whether echo mode is enabled (emitted events are also dispatched to handlers)
|
|
8298
|
+
* @internal
|
|
8299
|
+
*/
|
|
8300
|
+
readonly echo: boolean;
|
|
8301
|
+
/**
|
|
8302
|
+
* The start event, or undefined if not yet received
|
|
8303
|
+
* @internal
|
|
8304
|
+
*/
|
|
8305
|
+
readonly startEventMaybe: SessionStartEvent | undefined;
|
|
8306
|
+
/**
|
|
8307
|
+
* The start event (throws if not yet received)
|
|
8308
|
+
* @internal
|
|
8309
|
+
*/
|
|
8310
|
+
readonly startEvent: SessionStartEvent;
|
|
8311
|
+
/** Whether this session has ended */
|
|
8312
|
+
readonly ended: boolean;
|
|
8313
|
+
/**
|
|
8314
|
+
* Whether event emitting is currently paused
|
|
8315
|
+
* @internal
|
|
8316
|
+
*/
|
|
8317
|
+
readonly isEmitPaused: boolean;
|
|
8318
|
+
/**
|
|
8319
|
+
* Pauses emitting events to the WebSocket
|
|
8320
|
+
*
|
|
8321
|
+
* Events are buffered internally and sent when `resumeEmits` is called.
|
|
8322
|
+
* Useful when you need to set up event handlers before events start flowing
|
|
8323
|
+
* (e.g., between starting a session and receiving the session started event).
|
|
8324
|
+
* @internal
|
|
8325
|
+
*/
|
|
8326
|
+
pauseEmits(): void;
|
|
8327
|
+
/**
|
|
8328
|
+
* Resumes emitting events and flushes any buffered events
|
|
8329
|
+
*
|
|
8330
|
+
* All events that were buffered while paused are sent in order.
|
|
8331
|
+
* @internal
|
|
8332
|
+
*/
|
|
8333
|
+
resumeEmits(): void;
|
|
8334
|
+
/**
|
|
8335
|
+
* Registers a handler for error start events at the session level
|
|
8336
|
+
*
|
|
8337
|
+
* @param cb - Callback receiving the error event
|
|
8338
|
+
* @returns Cleanup function to remove the handler
|
|
8339
|
+
*
|
|
8340
|
+
* @example
|
|
8341
|
+
* ```typescript
|
|
8342
|
+
* session.onErrorStart((error) => {
|
|
8343
|
+
* console.error(`Session error [${error.errorId}]: ${error.message}`);
|
|
8344
|
+
* });
|
|
8345
|
+
* ```
|
|
8346
|
+
*/
|
|
8347
|
+
onErrorStart(cb: (error: {
|
|
8348
|
+
errorId: string;
|
|
8349
|
+
} & ErrorStartEvent) => void): () => void;
|
|
8350
|
+
/**
|
|
8351
|
+
* Registers a handler for error end events at the session level
|
|
8352
|
+
*
|
|
8353
|
+
* @param cb - Callback receiving the error end event
|
|
8354
|
+
* @returns Cleanup function to remove the handler
|
|
8355
|
+
*
|
|
8356
|
+
* @example
|
|
8357
|
+
* ```typescript
|
|
8358
|
+
* session.onErrorEnd((error) => {
|
|
8359
|
+
* console.log(`Error ${error.errorId} resolved`);
|
|
8360
|
+
* });
|
|
8361
|
+
* ```
|
|
8362
|
+
*/
|
|
8363
|
+
onErrorEnd(cb: (error: {
|
|
8364
|
+
errorId: string;
|
|
8365
|
+
} & ErrorEndEvent) => void): () => void;
|
|
8366
|
+
/**
|
|
8367
|
+
* Registers a handler for exchange start events
|
|
8368
|
+
*
|
|
8369
|
+
* This is the primary entry point for handling agent responses.
|
|
8370
|
+
* Each exchange represents a request-response cycle containing
|
|
8371
|
+
* user and assistant messages.
|
|
8372
|
+
*
|
|
8373
|
+
* @param cb - Callback receiving each new exchange
|
|
8374
|
+
* @returns Cleanup function to remove the handler
|
|
8375
|
+
*
|
|
8376
|
+
* @example Streaming text with content type handling
|
|
8377
|
+
* ```typescript
|
|
8378
|
+
* session.onExchangeStart((exchange) => {
|
|
8379
|
+
* exchange.onMessageStart((message) => {
|
|
8380
|
+
* if (message.isAssistant) {
|
|
8381
|
+
* message.onContentPartStart((part) => {
|
|
8382
|
+
* if (part.isMarkdown) {
|
|
8383
|
+
* part.onChunk((chunk) => renderMarkdown(chunk.data ?? ''));
|
|
8384
|
+
* } else if (part.isAudio) {
|
|
8385
|
+
* part.onChunk((chunk) => audioPlayer.enqueue(chunk.data ?? ''));
|
|
8386
|
+
* } else if (part.isImage) {
|
|
8387
|
+
* part.onChunk((chunk) => imageBuffer.append(chunk.data ?? ''));
|
|
8388
|
+
* } else if (part.isTranscript) {
|
|
8389
|
+
* part.onChunk((chunk) => showTranscript(chunk.data ?? ''));
|
|
8390
|
+
* }
|
|
8391
|
+
* });
|
|
8392
|
+
* }
|
|
8393
|
+
* });
|
|
8394
|
+
* });
|
|
8395
|
+
* ```
|
|
8396
|
+
*
|
|
8397
|
+
* @example Getting the complete response at once (no streaming)
|
|
8398
|
+
* ```typescript
|
|
8399
|
+
* session.onExchangeStart((exchange) => {
|
|
8400
|
+
* exchange.onMessageCompleted((completed) => {
|
|
8401
|
+
* console.log(`Message ${completed.messageId} (role: ${completed.role})`);
|
|
8402
|
+
* for (const part of completed.contentParts) {
|
|
8403
|
+
* console.log(part.data);
|
|
8404
|
+
* }
|
|
8405
|
+
* for (const tool of completed.toolCalls) {
|
|
8406
|
+
* console.log(`${tool.toolName} → ${tool.output}`);
|
|
8407
|
+
* }
|
|
8408
|
+
* });
|
|
8409
|
+
* });
|
|
8410
|
+
* ```
|
|
8411
|
+
*
|
|
8412
|
+
* @example Handling tool calls and confirmation interrupts
|
|
8413
|
+
* ```typescript
|
|
8414
|
+
* session.onExchangeStart((exchange) => {
|
|
8415
|
+
* exchange.onMessageStart((message) => {
|
|
8416
|
+
* if (message.isAssistant) {
|
|
8417
|
+
* // Stream tool call events
|
|
8418
|
+
* message.onToolCallStart((toolCall) => {
|
|
8419
|
+
* const { toolName, input } = toolCall.startEvent;
|
|
8420
|
+
* console.log(`Calling ${toolName}:`, JSON.parse(input ?? '{}'));
|
|
8421
|
+
* toolCall.onToolCallEnd((end) => {
|
|
8422
|
+
* console.log(`Result:`, JSON.parse(end.output ?? '{}'));
|
|
8423
|
+
* });
|
|
8424
|
+
* });
|
|
8425
|
+
*
|
|
8426
|
+
* // Handle confirmation interrupts
|
|
8427
|
+
* message.onInterruptStart(({ interruptId, startEvent }) => {
|
|
8428
|
+
* if (startEvent.type === 'uipath_cas_tool_call_confirmation') {
|
|
8429
|
+
* message.sendInterruptEnd(interruptId, { approved: true });
|
|
8430
|
+
* }
|
|
8431
|
+
* });
|
|
8432
|
+
* }
|
|
8433
|
+
* });
|
|
8434
|
+
* });
|
|
8435
|
+
* ```
|
|
8436
|
+
*/
|
|
8437
|
+
onExchangeStart(cb: (exchange: ExchangeStream) => void): () => void;
|
|
8438
|
+
/**
|
|
8439
|
+
* Registers a handler for session started events
|
|
8440
|
+
*
|
|
8441
|
+
* Fired when the WebSocket connection is established and the
|
|
8442
|
+
* session is ready to send and receive events.
|
|
8443
|
+
*
|
|
8444
|
+
* @param cb - Callback receiving the started event
|
|
8445
|
+
* @returns Cleanup function to remove the handler
|
|
8446
|
+
*
|
|
8447
|
+
* @example
|
|
8448
|
+
* ```typescript
|
|
8449
|
+
* session.onSessionStarted(() => {
|
|
8450
|
+
* console.log('Session is ready — now safe to start exchanges');
|
|
8451
|
+
*
|
|
8452
|
+
* const exchange = session.startExchange();
|
|
8453
|
+
* exchange.sendMessageWithContentPart({
|
|
8454
|
+
* data: 'Hello!',
|
|
8455
|
+
* role: MessageRole.User
|
|
8456
|
+
* });
|
|
8457
|
+
* });
|
|
8458
|
+
* ```
|
|
8459
|
+
*/
|
|
8460
|
+
onSessionStarted(cb: (event: SessionStartedEvent) => void): () => void;
|
|
8461
|
+
/**
|
|
8462
|
+
* Registers a handler for session ending events
|
|
8463
|
+
*
|
|
8464
|
+
* Fired when the session is about to end. Use this for cleanup
|
|
8465
|
+
* before the session fully closes.
|
|
8466
|
+
*
|
|
8467
|
+
* @param cb - Callback receiving the ending event
|
|
8468
|
+
* @returns Cleanup function to remove the handler
|
|
8469
|
+
*
|
|
8470
|
+
* @example
|
|
8471
|
+
* ```typescript
|
|
8472
|
+
* session.onSessionEnding((event) => {
|
|
8473
|
+
* console.log('Session is ending, performing cleanup...');
|
|
8474
|
+
* });
|
|
8475
|
+
* ```
|
|
8476
|
+
*/
|
|
8477
|
+
onSessionEnding(cb: (event: SessionEndingEvent) => void): () => void;
|
|
8478
|
+
/**
|
|
8479
|
+
* Registers a handler for session end events
|
|
8480
|
+
*
|
|
8481
|
+
* Fired when the session has fully closed.
|
|
8482
|
+
*
|
|
8483
|
+
* @param cb - Callback receiving the end event
|
|
8484
|
+
* @returns Cleanup function to remove the handler
|
|
8485
|
+
*
|
|
8486
|
+
* @example
|
|
8487
|
+
* ```typescript
|
|
8488
|
+
* session.onSessionEnd((event) => {
|
|
8489
|
+
* console.log('Session ended');
|
|
8490
|
+
* });
|
|
8491
|
+
* ```
|
|
8492
|
+
*/
|
|
8493
|
+
onSessionEnd(cb: (event: SessionEndEvent) => void): () => void;
|
|
8494
|
+
/**
|
|
8495
|
+
* Registers a handler for conversation label updates
|
|
8496
|
+
*
|
|
8497
|
+
* Fired when the conversation label changes, typically when the server
|
|
8498
|
+
* auto-generates a title based on the first message.
|
|
8499
|
+
*
|
|
8500
|
+
* @param cb - Callback receiving the {@link LabelUpdatedEvent} with the new label
|
|
8501
|
+
* @returns Cleanup function to remove the handler
|
|
8502
|
+
*
|
|
8503
|
+
* @example
|
|
8504
|
+
* ```typescript
|
|
8505
|
+
* session.onLabelUpdated((event) => {
|
|
8506
|
+
* console.log(`New label: ${event.label} (auto: ${event.autogenerated})`);
|
|
8507
|
+
* updateConversationTitle(event.label);
|
|
8508
|
+
* });
|
|
8509
|
+
* ```
|
|
8510
|
+
*/
|
|
8511
|
+
onLabelUpdated(cb: (event: LabelUpdatedEvent) => void): () => void;
|
|
8512
|
+
/**
|
|
8513
|
+
* Sends a session started event
|
|
8514
|
+
* @param sessionStarted - Optional started event data
|
|
8515
|
+
* @internal
|
|
8516
|
+
*/
|
|
8517
|
+
sendSessionStarted(sessionStarted?: SessionStartedEvent): void;
|
|
8518
|
+
/**
|
|
8519
|
+
* Sends a session end event and closes the session
|
|
8520
|
+
*
|
|
8521
|
+
* Prefer using `conversation.endSession()` instead of calling this directly.
|
|
8522
|
+
*
|
|
8523
|
+
* @param endSession - Optional end event data
|
|
8524
|
+
* @internal
|
|
8525
|
+
*/
|
|
8526
|
+
sendSessionEnd(endSession?: SessionEndEvent): void;
|
|
8527
|
+
/**
|
|
8528
|
+
* Sends an error start event for this session
|
|
8529
|
+
* @param args - Error details including optional error ID and message
|
|
8530
|
+
* @internal
|
|
8531
|
+
*/
|
|
8532
|
+
sendErrorStart(args: {
|
|
8533
|
+
errorId?: string;
|
|
8534
|
+
} & ErrorStartEvent): void;
|
|
8535
|
+
/**
|
|
8536
|
+
* Sends an error end event for this session
|
|
8537
|
+
* @param args - Error end details including the error ID
|
|
8538
|
+
* @internal
|
|
8539
|
+
*/
|
|
8540
|
+
sendErrorEnd(args: {
|
|
8541
|
+
errorId: string;
|
|
8542
|
+
} & ErrorEndEvent): void;
|
|
8543
|
+
/**
|
|
8544
|
+
* Sends a metadata event for this session
|
|
8545
|
+
* @param metaEvent - Metadata to send
|
|
8546
|
+
* @internal
|
|
8547
|
+
*/
|
|
8548
|
+
sendMetaEvent(metaEvent: MetaEvent): void;
|
|
8549
|
+
/**
|
|
8550
|
+
* Starts a new exchange in this session
|
|
8551
|
+
*
|
|
8552
|
+
* Each exchange is a request-response cycle. Use `sendMessageWithContentPart`
|
|
8553
|
+
* on the returned {@link ExchangeStream} to send a user message, or
|
|
8554
|
+
* `startMessage` for fine-grained control.
|
|
8555
|
+
*
|
|
8556
|
+
* @param args - Optional exchange start options
|
|
8557
|
+
* @returns The exchange stream for sending messages
|
|
8558
|
+
*
|
|
8559
|
+
* @example Multi-exchange conversation
|
|
8560
|
+
* ```typescript
|
|
8561
|
+
* const session = conversation.startSession();
|
|
8562
|
+
*
|
|
8563
|
+
* // Listen for all assistant responses
|
|
8564
|
+
* session.onExchangeStart((exchange) => {
|
|
8565
|
+
* exchange.onMessageCompleted((completed) => {
|
|
8566
|
+
* if (completed.role === MessageRole.Assistant) {
|
|
8567
|
+
* for (const part of completed.contentParts) {
|
|
8568
|
+
* console.log('Assistant:', part.data);
|
|
8569
|
+
* }
|
|
8570
|
+
* }
|
|
8571
|
+
* });
|
|
8572
|
+
* });
|
|
8573
|
+
*
|
|
8574
|
+
* // Wait for session to be ready before starting exchanges
|
|
8575
|
+
* session.onSessionStarted(async () => {
|
|
8576
|
+
* // Send first user message
|
|
8577
|
+
* const exchange1 = session.startExchange();
|
|
8578
|
+
* await exchange1.sendMessageWithContentPart({
|
|
8579
|
+
* data: 'What is the weather today?',
|
|
8580
|
+
* role: MessageRole.User
|
|
8581
|
+
* });
|
|
8582
|
+
*
|
|
8583
|
+
* // Send follow-up in a new exchange
|
|
8584
|
+
* const exchange2 = session.startExchange();
|
|
8585
|
+
* await exchange2.sendMessageWithContentPart({
|
|
8586
|
+
* data: 'And tomorrow?',
|
|
8587
|
+
* role: MessageRole.User
|
|
8588
|
+
* });
|
|
8589
|
+
* });
|
|
8590
|
+
* ```
|
|
8591
|
+
*/
|
|
8592
|
+
startExchange(args?: {
|
|
8593
|
+
exchangeId?: string;
|
|
8594
|
+
} & ExchangeStartEvent): ExchangeStream;
|
|
8595
|
+
/**
|
|
8596
|
+
* Iterator over all active exchanges in this session
|
|
8597
|
+
*/
|
|
8598
|
+
readonly exchanges: Iterable<ExchangeStream>;
|
|
8599
|
+
/**
|
|
8600
|
+
* Retrieves an exchange by ID
|
|
8601
|
+
* @param exchangeId - The exchange ID to look up
|
|
8602
|
+
* @returns The exchange stream, or undefined if not found
|
|
8603
|
+
*/
|
|
8604
|
+
getExchange(exchangeId: string): ExchangeStream | undefined;
|
|
8605
|
+
/**
|
|
8606
|
+
* Starts an async tool call at the session level
|
|
8607
|
+
* @param args - Tool call start options including tool name
|
|
8608
|
+
* @returns The async tool call stream for managing the lifecycle
|
|
8609
|
+
* @internal
|
|
8610
|
+
*/
|
|
8611
|
+
startAsyncToolCall(args: {
|
|
8612
|
+
toolCallId?: string;
|
|
8613
|
+
} & ToolCallStartEvent): AsyncToolCallStream;
|
|
8614
|
+
/**
|
|
8615
|
+
* Registers a handler for async tool call start events
|
|
8616
|
+
* @param cb - Callback receiving each new async tool call
|
|
8617
|
+
* @returns Cleanup function to remove the handler
|
|
8618
|
+
* @internal
|
|
8619
|
+
*/
|
|
8620
|
+
onAsyncToolCallStart(cb: (asyncToolCall: AsyncToolCallStream) => void): () => void;
|
|
8621
|
+
/**
|
|
8622
|
+
* Iterator over all active async tool calls in this session
|
|
8623
|
+
* @internal
|
|
8624
|
+
*/
|
|
8625
|
+
readonly asyncToolCalls: Iterable<AsyncToolCallStream>;
|
|
8626
|
+
/**
|
|
8627
|
+
* Retrieves an async tool call by ID
|
|
8628
|
+
* @param toolCallId - The tool call ID to look up
|
|
8629
|
+
* @returns The async tool call stream, or undefined if not found
|
|
8630
|
+
* @internal
|
|
8631
|
+
*/
|
|
8632
|
+
getAsyncToolCall(toolCallId: string): AsyncToolCallStream | undefined;
|
|
8633
|
+
/**
|
|
8634
|
+
* Starts an async input stream at the session level
|
|
8635
|
+
* @param args - Stream start options including MIME type
|
|
8636
|
+
* @returns The async input stream for sending data
|
|
8637
|
+
* @internal
|
|
8638
|
+
*/
|
|
8639
|
+
startAsyncInputStream(args: {
|
|
8640
|
+
streamId?: string;
|
|
8641
|
+
} & AsyncInputStreamStartEvent): AsyncInputStream;
|
|
8642
|
+
/**
|
|
8643
|
+
* Registers a handler for async input stream start events
|
|
8644
|
+
* @param cb - Callback receiving each new input stream
|
|
8645
|
+
* @returns Cleanup function to remove the handler
|
|
8646
|
+
* @internal
|
|
8647
|
+
*/
|
|
8648
|
+
onInputStreamStart(cb: (inputStream: AsyncInputStream) => void): () => void;
|
|
8649
|
+
/**
|
|
8650
|
+
* Iterator over all active async input streams in this session
|
|
8651
|
+
* @internal
|
|
8652
|
+
*/
|
|
8653
|
+
readonly asyncInputStreams: Iterable<AsyncInputStream>;
|
|
8654
|
+
/**
|
|
8655
|
+
* Retrieves an async input stream by ID
|
|
8656
|
+
* @param streamId - The stream ID to look up
|
|
8657
|
+
* @returns The async input stream, or undefined if not found
|
|
8658
|
+
* @internal
|
|
8659
|
+
*/
|
|
8660
|
+
getAsyncInputStream(streamId: string): AsyncInputStream | undefined;
|
|
8661
|
+
/**
|
|
8662
|
+
* Emits a raw conversation event
|
|
8663
|
+
* @param conversationEvent - The event to emit (conversationId is added automatically)
|
|
8664
|
+
* @internal
|
|
8665
|
+
*/
|
|
8666
|
+
emit(conversationEvent: Omit<ConversationEvent, 'conversationId'>): void;
|
|
8667
|
+
/**
|
|
8668
|
+
* Registers a handler for error start events from any nested helper
|
|
8669
|
+
*
|
|
8670
|
+
* Unlike `onErrorStart` which only catches errors at the session level,
|
|
8671
|
+
* this handler receives errors from all nested helpers (exchanges, messages,
|
|
8672
|
+
* content parts, tool calls, etc.).
|
|
8673
|
+
*
|
|
8674
|
+
* @param cb - Callback receiving the error event with its source
|
|
8675
|
+
* @returns Cleanup function to remove the handler
|
|
8676
|
+
* @internal
|
|
8677
|
+
*/
|
|
8678
|
+
onAnyErrorStart(cb: (errorStart: {
|
|
8679
|
+
source: unknown;
|
|
8680
|
+
errorId: string;
|
|
8681
|
+
} & ErrorStartEvent) => void): () => void;
|
|
8682
|
+
/**
|
|
8683
|
+
* Registers a handler for error end events from any nested helper
|
|
8684
|
+
*
|
|
8685
|
+
* Unlike `onErrorEnd` which only catches errors at the session level,
|
|
8686
|
+
* this handler receives error end events from all nested helpers.
|
|
8687
|
+
*
|
|
8688
|
+
* @param cb - Callback receiving the error end event with its source
|
|
8689
|
+
* @returns Cleanup function to remove the handler
|
|
8690
|
+
* @internal
|
|
8691
|
+
*/
|
|
8692
|
+
onAnyErrorEnd(cb: (errorEnd: {
|
|
8693
|
+
source: unknown;
|
|
8694
|
+
errorId: string;
|
|
8695
|
+
} & ErrorEndEvent) => void): () => void;
|
|
8696
|
+
/**
|
|
8697
|
+
* Replays persisted exchanges into this session
|
|
8698
|
+
*
|
|
8699
|
+
* Used to restore session state from previously saved exchange data.
|
|
8700
|
+
*
|
|
8701
|
+
* @param exchanges - The exchange data to replay
|
|
8702
|
+
* @internal
|
|
8703
|
+
*/
|
|
8704
|
+
replay(exchanges: Exchange[]): void;
|
|
8705
|
+
/**
|
|
8706
|
+
* Returns a string representation of this session
|
|
8707
|
+
* @internal
|
|
8708
|
+
*/
|
|
8709
|
+
toString(): string;
|
|
8710
|
+
}
|
|
8711
|
+
|
|
8712
|
+
/**
|
|
8713
|
+
* Types for Exchange Service
|
|
8714
|
+
*/
|
|
8715
|
+
|
|
8716
|
+
/**
|
|
8717
|
+
* Response type for Exchange with MessageGetResponse instead of raw Message
|
|
8718
|
+
*/
|
|
8719
|
+
interface ExchangeGetResponse extends Omit<Exchange, 'messages'> {
|
|
8720
|
+
messages: MessageGetResponse[];
|
|
8721
|
+
}
|
|
8722
|
+
/**
|
|
8723
|
+
* Response type for Message with ContentPartGetResponse
|
|
8724
|
+
*/
|
|
8725
|
+
interface MessageGetResponse extends Omit<Message, 'contentParts'> {
|
|
8726
|
+
contentParts?: ContentPartGetResponse[];
|
|
8727
|
+
}
|
|
8728
|
+
/**
|
|
8729
|
+
* Response interface for ContentPart with convenience methods for accessing data.
|
|
8730
|
+
*
|
|
8731
|
+
* Provides helper properties and methods to determine if content is stored
|
|
8732
|
+
* inline or externally, and to retrieve the data accordingly.
|
|
8733
|
+
*
|
|
8734
|
+
* @example
|
|
8735
|
+
* ```typescript
|
|
8736
|
+
* const contentPart = message.contentParts[0];
|
|
8737
|
+
*
|
|
8738
|
+
* // Check storage type
|
|
8739
|
+
* if (contentPart.isDataInline) {
|
|
8740
|
+
* const data = await contentPart.getData(); // Returns string
|
|
8741
|
+
* } else if (contentPart.isDataExternal) {
|
|
8742
|
+
* const response = await contentPart.getData(); // Returns fetch Response
|
|
8743
|
+
* }
|
|
8744
|
+
* ```
|
|
8745
|
+
*/
|
|
8746
|
+
interface ContentPartGetResponse extends ContentPart {
|
|
8747
|
+
/** Returns true if data is stored inline (as a string value) */
|
|
8748
|
+
readonly isDataInline: boolean;
|
|
8749
|
+
/** Returns true if data is stored externally (as a URI reference) */
|
|
8750
|
+
readonly isDataExternal: boolean;
|
|
8751
|
+
/**
|
|
8752
|
+
* Retrieves the content data.
|
|
8753
|
+
* @returns For inline data: the string content. For external data: a fetch Response.
|
|
8754
|
+
*/
|
|
8755
|
+
getData(): Promise<string | Response>;
|
|
8756
|
+
}
|
|
8757
|
+
type ExchangeGetAllOptions = PaginationOptions & {
|
|
8758
|
+
/** Sort order for exchanges */
|
|
8759
|
+
exchangeSort?: SortOrder;
|
|
8760
|
+
/** Sort order for messages within each exchange */
|
|
8761
|
+
messageSort?: SortOrder;
|
|
8762
|
+
};
|
|
8763
|
+
interface ExchangeGetByIdOptions {
|
|
8764
|
+
/** Sort order for messages within the exchange */
|
|
8765
|
+
messageSort?: SortOrder;
|
|
8766
|
+
}
|
|
8767
|
+
interface CreateFeedbackOptions {
|
|
8768
|
+
/** Rating for the exchange ('positive' or 'negative') */
|
|
8769
|
+
rating: FeedbackRating;
|
|
8770
|
+
/** Optional text comment for the feedback */
|
|
8771
|
+
comment?: string;
|
|
8772
|
+
}
|
|
8773
|
+
interface FeedbackCreateResponse {
|
|
8774
|
+
}
|
|
8775
|
+
|
|
8776
|
+
/**
|
|
8777
|
+
* Exchange Service Model
|
|
8778
|
+
*/
|
|
8779
|
+
|
|
8780
|
+
/**
|
|
8781
|
+
* Service for retrieving exchanges and managing feedback within a {@link ConversationServiceModel | Conversation}
|
|
8782
|
+
*
|
|
8783
|
+
* An exchange represents a single request-response cycle — typically one user
|
|
8784
|
+
* question and the agent's reply. Each exchange response includes its
|
|
8785
|
+
* {@link MessageServiceModel | Messages}, making this the primary way to retrieve
|
|
8786
|
+
* conversation history. For real-time streaming of exchanges, see {@link ExchangeStream}.
|
|
8787
|
+
*
|
|
8788
|
+
* ### Usage
|
|
8789
|
+
*
|
|
8790
|
+
* Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize)
|
|
8791
|
+
*
|
|
8792
|
+
* ```typescript
|
|
8793
|
+
* import { Exchanges } from '@uipath/uipath-typescript/conversational-agent';
|
|
8794
|
+
*
|
|
8795
|
+
* const exchanges = new Exchanges(sdk);
|
|
8796
|
+
* const conversationExchanges = await exchanges.getAll(conversationId);
|
|
8797
|
+
* ```
|
|
8798
|
+
*/
|
|
8799
|
+
interface ExchangeServiceModel {
|
|
8800
|
+
/**
|
|
8801
|
+
* Gets all exchanges for a conversation with optional filtering and pagination
|
|
8802
|
+
*
|
|
8803
|
+
* @param conversationId - The conversation ID to get exchanges for
|
|
8804
|
+
* @param options - Options for querying exchanges including optional pagination parameters
|
|
8805
|
+
* @returns Promise resolving to either an array of exchanges {@link NonPaginatedResponse}<{@link ExchangeGetResponse}> or a {@link PaginatedResponse}<{@link ExchangeGetResponse}> when pagination options are used
|
|
8806
|
+
* @example
|
|
8807
|
+
* ```typescript
|
|
8808
|
+
* // Get all exchanges (non-paginated)
|
|
8809
|
+
* const conversationExchanges = await exchanges.getAll(conversationId);
|
|
8810
|
+
*
|
|
8811
|
+
* // First page with pagination
|
|
8812
|
+
* const firstPageOfExchanges = await exchanges.getAll(conversationId, { pageSize: 10 });
|
|
8813
|
+
*
|
|
8814
|
+
* // Navigate using cursor
|
|
8815
|
+
* if (firstPageOfExchanges.hasNextPage) {
|
|
8816
|
+
* const nextPageOfExchanges = await exchanges.getAll(conversationId, {
|
|
8817
|
+
* cursor: firstPageOfExchanges.nextCursor
|
|
8818
|
+
* });
|
|
8819
|
+
* }
|
|
8820
|
+
* ```
|
|
8821
|
+
*/
|
|
8822
|
+
getAll<T extends ExchangeGetAllOptions = ExchangeGetAllOptions>(conversationId: string, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<ExchangeGetResponse> : NonPaginatedResponse<ExchangeGetResponse>>;
|
|
8823
|
+
/**
|
|
8824
|
+
* Gets an exchange by ID with its messages
|
|
8825
|
+
*
|
|
8826
|
+
* @param conversationId - The conversation containing the exchange
|
|
8827
|
+
* @param exchangeId - The exchange ID to retrieve
|
|
8828
|
+
* @param options - Optional parameters for message sorting
|
|
8829
|
+
* @returns Promise resolving to {@link ExchangeGetResponse}
|
|
8830
|
+
* @example
|
|
8831
|
+
* ```typescript
|
|
8832
|
+
* const exchange = await exchanges.getById(conversationId, exchangeId);
|
|
8833
|
+
*
|
|
8834
|
+
* // Access messages
|
|
8835
|
+
* for (const message of exchange.messages) {
|
|
8836
|
+
* console.log(message.role, message.contentParts);
|
|
8837
|
+
* }
|
|
8838
|
+
* ```
|
|
8839
|
+
*/
|
|
8840
|
+
getById(conversationId: string, exchangeId: string, options?: ExchangeGetByIdOptions): Promise<ExchangeGetResponse>;
|
|
8841
|
+
/**
|
|
8842
|
+
* Creates feedback for an exchange
|
|
8843
|
+
*
|
|
8844
|
+
* @param conversationId - The conversation containing the exchange
|
|
8845
|
+
* @param exchangeId - The exchange to provide feedback for
|
|
8846
|
+
* @param options - Feedback data including rating and optional comment
|
|
8847
|
+
* @returns Promise resolving to the feedback creation response
|
|
8848
|
+
* {@link FeedbackCreateResponse}
|
|
8849
|
+
* @example
|
|
8850
|
+
* ```typescript
|
|
8851
|
+
* await exchanges.createFeedback(
|
|
8852
|
+
* conversationId,
|
|
8853
|
+
* exchangeId,
|
|
8854
|
+
* { rating: FeedbackRating.Positive, comment: 'Very helpful!' }
|
|
8855
|
+
* );
|
|
8856
|
+
* ```
|
|
8857
|
+
*/
|
|
8858
|
+
createFeedback(conversationId: string, exchangeId: string, options: CreateFeedbackOptions): Promise<FeedbackCreateResponse>;
|
|
8859
|
+
}
|
|
8860
|
+
/**
|
|
8861
|
+
* Scoped exchange service for a specific conversation.
|
|
8862
|
+
* Auto-fills conversationId from the conversation.
|
|
8863
|
+
*/
|
|
8864
|
+
interface ConversationExchangeServiceModel {
|
|
8865
|
+
/**
|
|
8866
|
+
* Gets all exchanges for this conversation with optional filtering and pagination
|
|
8867
|
+
*
|
|
8868
|
+
* @param options - Options for querying exchanges including optional pagination parameters
|
|
8869
|
+
* @returns Promise resolving to either an array of exchanges or a paginated response
|
|
8870
|
+
*
|
|
8871
|
+
* @example
|
|
8872
|
+
* ```typescript
|
|
8873
|
+
* const conversation = await conversationalAgent.conversations.getById(conversationId);
|
|
8874
|
+
*
|
|
8875
|
+
* // Get all exchanges
|
|
8876
|
+
* const allExchanges = await conversation.exchanges.getAll();
|
|
8877
|
+
*
|
|
8878
|
+
* // With pagination
|
|
8879
|
+
* const firstPage = await conversation.exchanges.getAll({ pageSize: 10 });
|
|
8880
|
+
* if (firstPage.hasNextPage) {
|
|
8881
|
+
* const nextPage = await conversation.exchanges.getAll({ cursor: firstPage.nextCursor });
|
|
8882
|
+
* }
|
|
8883
|
+
* ```
|
|
8884
|
+
*/
|
|
8885
|
+
getAll<T extends ExchangeGetAllOptions = ExchangeGetAllOptions>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<ExchangeGetResponse> : NonPaginatedResponse<ExchangeGetResponse>>;
|
|
8886
|
+
/**
|
|
8887
|
+
* Gets an exchange by ID with its messages
|
|
8888
|
+
*
|
|
8889
|
+
* @param exchangeId - The exchange ID to retrieve
|
|
8890
|
+
* @param options - Optional parameters for message sorting
|
|
8891
|
+
* @returns Promise resolving to the exchange with messages
|
|
8892
|
+
*
|
|
8893
|
+
* @example
|
|
8894
|
+
* ```typescript
|
|
8895
|
+
* const exchange = await conversation.exchanges.getById(exchangeId);
|
|
8896
|
+
* for (const message of exchange.messages) {
|
|
8897
|
+
* console.log(message.role, message.contentParts);
|
|
8898
|
+
* }
|
|
8899
|
+
* ```
|
|
8900
|
+
*/
|
|
8901
|
+
getById(exchangeId: string, options?: ExchangeGetByIdOptions): Promise<ExchangeGetResponse>;
|
|
8902
|
+
/**
|
|
8903
|
+
* Creates feedback for an exchange
|
|
8904
|
+
*
|
|
8905
|
+
* @param exchangeId - The exchange to provide feedback for
|
|
8906
|
+
* @param options - Feedback data including rating and optional comment
|
|
8907
|
+
* @returns Promise resolving to the feedback creation response
|
|
8908
|
+
*
|
|
8909
|
+
* @example
|
|
8910
|
+
* ```typescript
|
|
8911
|
+
* await conversation.exchanges.createFeedback(exchangeId, {
|
|
8912
|
+
* rating: FeedbackRating.Positive,
|
|
8913
|
+
* comment: 'Very helpful!'
|
|
8914
|
+
* });
|
|
8915
|
+
* ```
|
|
8916
|
+
*/
|
|
8917
|
+
createFeedback(exchangeId: string, options: CreateFeedbackOptions): Promise<FeedbackCreateResponse>;
|
|
8918
|
+
}
|
|
8919
|
+
|
|
8920
|
+
/**
|
|
8921
|
+
* WebSocket Types - Common types for WebSocket infrastructure
|
|
8922
|
+
*/
|
|
8923
|
+
/**
|
|
8924
|
+
* Connection status for WebSocket clients
|
|
8925
|
+
*/
|
|
8926
|
+
declare enum ConnectionStatus {
|
|
8927
|
+
Disconnected = "Disconnected",
|
|
8928
|
+
Connecting = "Connecting",
|
|
8929
|
+
Connected = "Connected"
|
|
8930
|
+
}
|
|
8931
|
+
/**
|
|
8932
|
+
* Handler for connection status changes
|
|
8933
|
+
*/
|
|
8934
|
+
type ConnectionStatusChangedHandler = (status: ConnectionStatus, error: Error | null) => void;
|
|
8935
|
+
/**
|
|
8936
|
+
* Log levels for WebSocket debugging
|
|
8937
|
+
*/
|
|
8938
|
+
declare enum LogLevel {
|
|
8939
|
+
Debug = "debug",
|
|
8940
|
+
Info = "info",
|
|
8941
|
+
Warn = "warn",
|
|
8942
|
+
Error = "error"
|
|
8943
|
+
}
|
|
8944
|
+
|
|
8945
|
+
/**
|
|
8946
|
+
* Conversation Service Model
|
|
8947
|
+
*
|
|
8948
|
+
* This interface defines the HTTP CRUD operations for conversations
|
|
8949
|
+
* and real-time WebSocket session management.
|
|
8950
|
+
*/
|
|
8951
|
+
|
|
8952
|
+
/**
|
|
8953
|
+
* Methods interface for session operations.
|
|
8954
|
+
* This allows the conversation object to access session methods without
|
|
8955
|
+
* depending on the full ConversationService implementation.
|
|
8956
|
+
*/
|
|
8957
|
+
interface ConversationSessionMethods {
|
|
8958
|
+
/**
|
|
8959
|
+
* Starts a real-time chat session for a conversation
|
|
8960
|
+
*/
|
|
8961
|
+
startSession(conversationId: string, options?: ConversationSessionOptions): SessionStream;
|
|
8962
|
+
/**
|
|
8963
|
+
* Gets an active session for a conversation
|
|
8964
|
+
*/
|
|
8965
|
+
getSession(conversationId: string): SessionStream | undefined;
|
|
8966
|
+
/**
|
|
8967
|
+
* Ends an active session for a conversation
|
|
8968
|
+
*/
|
|
8969
|
+
endSession(conversationId: string): void;
|
|
8970
|
+
}
|
|
8971
|
+
/**
|
|
8972
|
+
* Service for creating and managing conversations with UiPath Conversational Agents
|
|
8973
|
+
*
|
|
8974
|
+
* A conversation is a long-lived interaction with a specific agent with shared context.
|
|
8975
|
+
* It persists across sessions and can be resumed at any time. To retrieve the
|
|
8976
|
+
* conversation history, use the {@link ExchangeServiceModel | Exchanges} service.
|
|
8977
|
+
* For real-time chat, see {@link SessionStream | Session}.
|
|
8978
|
+
*
|
|
8979
|
+
* ### Usage
|
|
8980
|
+
*
|
|
8981
|
+
* Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize)
|
|
8982
|
+
*
|
|
8983
|
+
* ```typescript
|
|
8984
|
+
* import { ConversationalAgent } from '@uipath/uipath-typescript/conversational-agent';
|
|
8985
|
+
*
|
|
8986
|
+
* const conversationalAgent = new ConversationalAgent(sdk);
|
|
8987
|
+
*
|
|
8988
|
+
* // Access conversations through the main service
|
|
8989
|
+
* const conversation = await conversationalAgent.conversations.create(agentId, folderId);
|
|
8990
|
+
*
|
|
8991
|
+
* // Or through agent objects (agentId/folderId auto-filled)
|
|
8992
|
+
* const agents = await conversationalAgent.getAll();
|
|
8993
|
+
* const agentConversation = await agents[0].conversations.create({ label: 'My Chat' });
|
|
8994
|
+
* ```
|
|
8995
|
+
*/
|
|
8996
|
+
interface ConversationServiceModel {
|
|
8997
|
+
/**
|
|
8998
|
+
* Creates a new conversation
|
|
8999
|
+
*
|
|
9000
|
+
* The returned conversation has bound methods for lifecycle management:
|
|
9001
|
+
* `update()`, `delete()`, and `startSession()`.
|
|
9002
|
+
*
|
|
9003
|
+
* @param agentId - The agent ID to create the conversation for
|
|
9004
|
+
* @param folderId - The folder ID containing the agent
|
|
9005
|
+
* @param options - Optional settings for the conversation
|
|
9006
|
+
* @returns Promise resolving to {@link ConversationCreateResponse} with bound methods
|
|
9007
|
+
*
|
|
9008
|
+
* @example
|
|
9009
|
+
* ```typescript
|
|
9010
|
+
* const conversation = await conversationalAgent.conversations.create(
|
|
9011
|
+
* agentId,
|
|
9012
|
+
* folderId,
|
|
9013
|
+
* { label: 'Customer Support Session' }
|
|
9014
|
+
* );
|
|
9015
|
+
*
|
|
9016
|
+
* // Update the conversation
|
|
9017
|
+
* await conversation.update({ label: 'Renamed Chat' });
|
|
9018
|
+
*
|
|
9019
|
+
* // Start a real-time session
|
|
9020
|
+
* const session = conversation.startSession();
|
|
9021
|
+
*
|
|
9022
|
+
* // Delete the conversation
|
|
9023
|
+
* await conversation.delete();
|
|
9024
|
+
* ```
|
|
9025
|
+
*/
|
|
9026
|
+
create(agentId: number, folderId: number, options?: ConversationCreateOptions): Promise<ConversationCreateResponse>;
|
|
9027
|
+
/**
|
|
9028
|
+
* Gets all conversations with optional filtering and pagination
|
|
9029
|
+
*
|
|
9030
|
+
* @param options - Options for querying conversations including optional pagination parameters
|
|
9031
|
+
* @returns Promise resolving to either an array of conversations NonPaginatedResponse<ConversationGetResponse> or a PaginatedResponse<ConversationGetResponse> when pagination options are used
|
|
9032
|
+
*
|
|
9033
|
+
* @example Basic usage - get all conversations
|
|
9034
|
+
* ```typescript
|
|
9035
|
+
* const allConversations = await conversationalAgent.conversations.getAll();
|
|
9036
|
+
*
|
|
9037
|
+
* for (const conversation of allConversations.items) {
|
|
9038
|
+
* console.log(`${conversation.label} - created: ${conversation.createdTime}`);
|
|
9039
|
+
* }
|
|
9040
|
+
* ```
|
|
9041
|
+
*
|
|
9042
|
+
* @example With pagination
|
|
9043
|
+
* ```typescript
|
|
9044
|
+
* // First page
|
|
9045
|
+
* const firstPage = await conversationalAgent.conversations.getAll({ pageSize: 10 });
|
|
9046
|
+
*
|
|
9047
|
+
* // Navigate using cursor
|
|
9048
|
+
* if (firstPage.hasNextPage) {
|
|
9049
|
+
* const nextPage = await conversationalAgent.conversations.getAll({
|
|
9050
|
+
* cursor: firstPage.nextCursor
|
|
9051
|
+
* });
|
|
9052
|
+
* }
|
|
9053
|
+
* ```
|
|
9054
|
+
*
|
|
9055
|
+
* @example Sorted with limit
|
|
9056
|
+
* ```typescript
|
|
9057
|
+
* const result = await conversationalAgent.conversations.getAll({
|
|
9058
|
+
* sort: SortOrder.Descending,
|
|
9059
|
+
* pageSize: 20
|
|
9060
|
+
* });
|
|
9061
|
+
* ```
|
|
9062
|
+
*/
|
|
9063
|
+
getAll<T extends ConversationGetAllOptions = ConversationGetAllOptions>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<ConversationGetResponse> : NonPaginatedResponse<ConversationGetResponse>>;
|
|
9064
|
+
/**
|
|
9065
|
+
* Gets a conversation by ID
|
|
9066
|
+
*
|
|
9067
|
+
* The returned conversation has bound methods for lifecycle management:
|
|
9068
|
+
* `update()`, `delete()`, and `startSession()`.
|
|
9069
|
+
*
|
|
9070
|
+
* @param id - The conversation ID to retrieve
|
|
9071
|
+
* @returns Promise resolving to {@link ConversationGetResponse} with bound methods
|
|
9072
|
+
*
|
|
9073
|
+
* @example Resume with a real-time session
|
|
9074
|
+
* ```typescript
|
|
9075
|
+
* const conversation = await conversationalAgent.conversations.getById(conversationId);
|
|
9076
|
+
* const session = conversation.startSession();
|
|
9077
|
+
* ```
|
|
9078
|
+
*
|
|
9079
|
+
* @example
|
|
9080
|
+
* ```typescript
|
|
9081
|
+
* //Retrieve conversation history
|
|
9082
|
+
* const conversation = await conversationalAgent.conversations.getById(conversationId);
|
|
9083
|
+
* const allExchanges = await conversation.exchanges.getAll();
|
|
9084
|
+
* for (const exchange of allExchanges.items) {
|
|
9085
|
+
* for (const message of exchange.messages) {
|
|
9086
|
+
* console.log(`${message.role}: ${message.contentParts.map(p => p.data).join('')}`);
|
|
9087
|
+
* }
|
|
9088
|
+
* }
|
|
9089
|
+
* ```
|
|
9090
|
+
*/
|
|
9091
|
+
getById(id: string): Promise<ConversationGetResponse>;
|
|
9092
|
+
/**
|
|
9093
|
+
* Updates a conversation by ID
|
|
9094
|
+
*
|
|
9095
|
+
* @param id - The conversation ID to update
|
|
9096
|
+
* @param options - Fields to update
|
|
9097
|
+
* @returns Promise resolving to {@link ConversationGetResponse} with bound methods
|
|
9098
|
+
* @example
|
|
9099
|
+
* ```typescript
|
|
9100
|
+
* const updatedConversation = await conversationalAgent.conversations.updateById(conversationId, {
|
|
9101
|
+
* label: 'Updated Name'
|
|
9102
|
+
* });
|
|
9103
|
+
* ```
|
|
9104
|
+
*/
|
|
9105
|
+
updateById(id: string, options: ConversationUpdateOptions): Promise<ConversationUpdateResponse>;
|
|
9106
|
+
/**
|
|
9107
|
+
* Deletes a conversation by ID
|
|
9108
|
+
*
|
|
9109
|
+
* @param id - The conversation ID to delete
|
|
9110
|
+
* @returns Promise resolving to {@link ConversationDeleteResponse}
|
|
9111
|
+
* @example
|
|
9112
|
+
* ```typescript
|
|
9113
|
+
* await conversationalAgent.conversations.deleteById(conversationId);
|
|
9114
|
+
* ```
|
|
9115
|
+
*/
|
|
9116
|
+
deleteById(id: string): Promise<ConversationDeleteResponse>;
|
|
9117
|
+
/**
|
|
9118
|
+
* Uploads a file attachment to a conversation
|
|
9119
|
+
*
|
|
9120
|
+
* @param id - The ID of the conversation to attach the file to
|
|
9121
|
+
* @param file - The file to upload
|
|
9122
|
+
* @returns Promise resolving to attachment metadata with URI
|
|
9123
|
+
* {@link ConversationAttachmentUploadResponse}
|
|
9124
|
+
*
|
|
9125
|
+
* @example
|
|
9126
|
+
* ```typescript
|
|
9127
|
+
* const attachment = await conversationalAgent.conversations.uploadAttachment(conversationId, file);
|
|
9128
|
+
* console.log(`Uploaded: ${attachment.uri}`);
|
|
9129
|
+
* ```
|
|
9130
|
+
*/
|
|
9131
|
+
uploadAttachment(id: string, file: File): Promise<ConversationAttachmentUploadResponse>;
|
|
9132
|
+
/**
|
|
9133
|
+
* Starts a real-time chat session for a conversation
|
|
9134
|
+
*
|
|
9135
|
+
* Creates a WebSocket session and returns a SessionStream for sending
|
|
9136
|
+
* and receiving messages in real-time.
|
|
9137
|
+
*
|
|
9138
|
+
* @param conversationId - The conversation ID to start the session for
|
|
9139
|
+
* @param options - Optional session configuration
|
|
9140
|
+
* @returns SessionStream for managing the session
|
|
9141
|
+
*
|
|
9142
|
+
* @example
|
|
9143
|
+
* ```typescript
|
|
9144
|
+
* const session = conversationalAgent.conversations.startSession(conversation.id);
|
|
9145
|
+
*
|
|
9146
|
+
* // Listen for responses using helper methods
|
|
9147
|
+
* session.onExchangeStart((exchange) => {
|
|
9148
|
+
* exchange.onMessageStart((message) => {
|
|
9149
|
+
* // Use message.isAssistant to filter AI responses
|
|
9150
|
+
* if (message.isAssistant) {
|
|
9151
|
+
* message.onContentPartStart((part) => {
|
|
9152
|
+
* // Use part.isMarkdown to handle text content
|
|
9153
|
+
* if (part.isMarkdown) {
|
|
9154
|
+
* part.onChunk((chunk) => console.log(chunk.data));
|
|
9155
|
+
* }
|
|
9156
|
+
* });
|
|
9157
|
+
* }
|
|
9158
|
+
* });
|
|
9159
|
+
* });
|
|
9160
|
+
*
|
|
9161
|
+
* // Wait for session to be ready, then send a message
|
|
9162
|
+
* session.onSessionStarted(() => {
|
|
9163
|
+
* const exchange = session.startExchange();
|
|
9164
|
+
* exchange.sendMessageWithContentPart({ data: 'Hello!' });
|
|
9165
|
+
* });
|
|
9166
|
+
*
|
|
9167
|
+
* // End the session when done
|
|
9168
|
+
* conversationalAgent.conversations.endSession(conversation.id);
|
|
9169
|
+
* ```
|
|
9170
|
+
*/
|
|
9171
|
+
startSession(conversationId: string, options?: ConversationSessionOptions): SessionStream;
|
|
9172
|
+
/**
|
|
9173
|
+
* Retrieves an active session by conversation ID
|
|
9174
|
+
*
|
|
9175
|
+
* @param conversationId - The conversation ID to get the session for
|
|
9176
|
+
* @returns The session helper if active, undefined otherwise
|
|
9177
|
+
*
|
|
9178
|
+
* @example
|
|
9179
|
+
* ```typescript
|
|
9180
|
+
* const session = conversationalAgent.conversations.getSession(conversationId);
|
|
9181
|
+
* if (session) {
|
|
9182
|
+
* // Session already started — safe to send exchanges directly
|
|
9183
|
+
* const exchange = session.startExchange();
|
|
9184
|
+
* exchange.sendMessageWithContentPart({ data: 'Hello!' });
|
|
9185
|
+
* }
|
|
9186
|
+
* ```
|
|
9187
|
+
*/
|
|
9188
|
+
getSession(conversationId: string): SessionStream | undefined;
|
|
9189
|
+
/**
|
|
9190
|
+
* Ends an active session for a conversation
|
|
9191
|
+
*
|
|
9192
|
+
* Sends a session end event and releases the socket for the conversation.
|
|
9193
|
+
* If no active session exists for the given conversation, this is a no-op.
|
|
9194
|
+
*
|
|
9195
|
+
* @param conversationId - The conversation ID to end the session for
|
|
9196
|
+
*
|
|
9197
|
+
* @example
|
|
9198
|
+
* ```typescript
|
|
9199
|
+
* // End session for a specific conversation
|
|
9200
|
+
* conversationalAgent.conversations.endSession(conversationId);
|
|
9201
|
+
* ```
|
|
9202
|
+
*/
|
|
9203
|
+
endSession(conversationId: string): void;
|
|
9204
|
+
/**
|
|
9205
|
+
* Iterator over all active sessions
|
|
9206
|
+
* @internal
|
|
9207
|
+
*/
|
|
9208
|
+
readonly sessions: Iterable<SessionStream>;
|
|
9209
|
+
/**
|
|
9210
|
+
* Current connection status
|
|
9211
|
+
* @internal
|
|
9212
|
+
*/
|
|
9213
|
+
readonly connectionStatus: ConnectionStatus;
|
|
9214
|
+
/**
|
|
9215
|
+
* Whether WebSocket is connected
|
|
9216
|
+
* @internal
|
|
9217
|
+
*/
|
|
9218
|
+
readonly isConnected: boolean;
|
|
9219
|
+
/**
|
|
9220
|
+
* Current connection error, if any
|
|
9221
|
+
* @internal
|
|
9222
|
+
*/
|
|
9223
|
+
readonly connectionError: Error | null;
|
|
9224
|
+
/**
|
|
9225
|
+
* Registers a handler for connection status changes
|
|
9226
|
+
* @internal
|
|
9227
|
+
*/
|
|
9228
|
+
onConnectionStatusChanged(handler: ConnectionStatusChangedHandler): () => void;
|
|
9229
|
+
}
|
|
9230
|
+
/**
|
|
9231
|
+
* Methods interface that will be added to conversation objects
|
|
9232
|
+
*/
|
|
9233
|
+
interface ConversationMethods {
|
|
9234
|
+
/** Scoped exchange operations for this conversation */
|
|
9235
|
+
readonly exchanges: ConversationExchangeServiceModel;
|
|
9236
|
+
/**
|
|
9237
|
+
* Updates this conversation
|
|
9238
|
+
*
|
|
9239
|
+
* @param options - Fields to update
|
|
9240
|
+
* @returns Promise resolving to the updated conversation
|
|
9241
|
+
*/
|
|
9242
|
+
update(options: ConversationUpdateOptions): Promise<ConversationUpdateResponse>;
|
|
9243
|
+
/**
|
|
9244
|
+
* Deletes this conversation
|
|
9245
|
+
*
|
|
9246
|
+
* @returns Promise resolving to the deletion response
|
|
9247
|
+
*/
|
|
9248
|
+
delete(): Promise<ConversationDeleteResponse>;
|
|
9249
|
+
/**
|
|
9250
|
+
* Starts a real-time chat session for this conversation
|
|
9251
|
+
*
|
|
9252
|
+
* Creates a WebSocket session and returns a SessionStream for sending
|
|
9253
|
+
* and receiving messages in real-time.
|
|
9254
|
+
*
|
|
9255
|
+
* @param options - Optional session options
|
|
9256
|
+
* @returns SessionStream for managing the session
|
|
9257
|
+
*
|
|
9258
|
+
* @example
|
|
9259
|
+
* ```typescript
|
|
9260
|
+
* const conversation = await conversationalAgent.conversations.create(agentId, folderId);
|
|
9261
|
+
*
|
|
9262
|
+
* // Start a real-time session
|
|
9263
|
+
* const session = conversation.startSession();
|
|
9264
|
+
*
|
|
9265
|
+
* // Listen for responses using helper methods
|
|
9266
|
+
* session.onExchangeStart((exchange) => {
|
|
9267
|
+
* exchange.onMessageStart((message) => {
|
|
9268
|
+
* // Filter for assistant messages
|
|
9269
|
+
* if (message.isAssistant) {
|
|
9270
|
+
* message.onContentPartStart((part) => {
|
|
9271
|
+
* // Handle text content
|
|
9272
|
+
* if (part.isMarkdown) {
|
|
9273
|
+
* part.onChunk((chunk) => console.log(chunk.data));
|
|
9274
|
+
* }
|
|
9275
|
+
* });
|
|
9276
|
+
* }
|
|
9277
|
+
* });
|
|
9278
|
+
* });
|
|
9279
|
+
*
|
|
9280
|
+
* // Wait for session to be ready, then send a message
|
|
9281
|
+
* session.onSessionStarted(() => {
|
|
9282
|
+
* const exchange = session.startExchange();
|
|
9283
|
+
* exchange.sendMessageWithContentPart({ data: 'Hello!' });
|
|
9284
|
+
* });
|
|
9285
|
+
* ```
|
|
9286
|
+
*/
|
|
9287
|
+
startSession(options?: ConversationSessionOptions): SessionStream;
|
|
9288
|
+
/**
|
|
9289
|
+
* Gets the active session for this conversation
|
|
9290
|
+
*
|
|
9291
|
+
* @returns The session helper if active, undefined otherwise
|
|
9292
|
+
*
|
|
9293
|
+
* @example
|
|
9294
|
+
* ```typescript
|
|
9295
|
+
* const session = conversation.getSession();
|
|
9296
|
+
* if (session) {
|
|
9297
|
+
* // Session already started — safe to send exchanges directly
|
|
9298
|
+
* const exchange = session.startExchange();
|
|
9299
|
+
* exchange.sendMessageWithContentPart({ data: 'Hello!' });
|
|
9300
|
+
* }
|
|
9301
|
+
* ```
|
|
9302
|
+
*/
|
|
9303
|
+
getSession(): SessionStream | undefined;
|
|
9304
|
+
/**
|
|
9305
|
+
* Ends the active session for this conversation
|
|
9306
|
+
*
|
|
9307
|
+
* Sends a session end event and cleans up the session resources.
|
|
9308
|
+
*
|
|
9309
|
+
* @example
|
|
9310
|
+
* ```typescript
|
|
9311
|
+
* // End the session when done
|
|
9312
|
+
* conversation.endSession();
|
|
9313
|
+
* ```
|
|
9314
|
+
*/
|
|
9315
|
+
endSession(): void;
|
|
9316
|
+
/**
|
|
9317
|
+
* Uploads a file attachment to this conversation
|
|
9318
|
+
*
|
|
9319
|
+
* @param file - The file to upload
|
|
9320
|
+
* @returns Promise resolving to attachment metadata with URI
|
|
9321
|
+
* {@link ConversationAttachmentUploadResponse}
|
|
9322
|
+
*
|
|
9323
|
+
* @example
|
|
9324
|
+
* ```typescript
|
|
9325
|
+
* const attachment = await conversation.uploadAttachment(file);
|
|
9326
|
+
* console.log(`Uploaded: ${attachment.uri}`);
|
|
9327
|
+
* ```
|
|
9328
|
+
*/
|
|
9329
|
+
uploadAttachment(file: File): Promise<ConversationAttachmentUploadResponse>;
|
|
9330
|
+
}
|
|
9331
|
+
/**
|
|
9332
|
+
* Conversation combining {@link RawConversationGetResponse} metadata with {@link ConversationMethods} for lifecycle management
|
|
9333
|
+
*/
|
|
9334
|
+
type ConversationGetResponse = RawConversationGetResponse & ConversationMethods;
|
|
9335
|
+
/**
|
|
9336
|
+
* Creates an actionable conversation by combining API conversation data with operational methods.
|
|
9337
|
+
*
|
|
9338
|
+
* @param conversationData - The conversation data from API
|
|
9339
|
+
* @param service - The conversation service instance
|
|
9340
|
+
* @param sessionMethods - Optional session methods for WebSocket session operations
|
|
9341
|
+
* @param exchangeService - Optional exchange service for scoped exchange methods
|
|
9342
|
+
* @returns A conversation object with added methods
|
|
9343
|
+
*/
|
|
9344
|
+
declare function createConversationWithMethods(conversationData: RawConversationGetResponse, service: ConversationServiceModel, sessionMethods?: ConversationSessionMethods, exchangeService?: ExchangeServiceModel): ConversationGetResponse;
|
|
9345
|
+
|
|
9346
|
+
/**
|
|
9347
|
+
* Types for Conversation Service
|
|
9348
|
+
*/
|
|
9349
|
+
|
|
9350
|
+
/**
|
|
9351
|
+
* Options for starting a session on a conversation object.
|
|
9352
|
+
* Unlike SessionStartEventOptions, conversationId is not needed since it's implicit from the conversation.
|
|
9353
|
+
*/
|
|
9354
|
+
interface ConversationSessionOptions {
|
|
9355
|
+
/**
|
|
9356
|
+
* When set, causes events emitted to also be dispatched to event handlers.
|
|
9357
|
+
* This option is useful when the event helper objects are bound to UI components
|
|
9358
|
+
* as it allows a single code path for rendering both user and assistant messages.
|
|
9359
|
+
*/
|
|
9360
|
+
echo?: boolean;
|
|
9361
|
+
/**
|
|
9362
|
+
* Sets the log level for WebSocket session debugging.
|
|
9363
|
+
* When set, enables logging at the specified level for the underlying WebSocket connection.
|
|
9364
|
+
*
|
|
9365
|
+
* @example
|
|
9366
|
+
* ```typescript
|
|
9367
|
+
* import { LogLevel } from '@uipath/uipath-typescript/conversational-agent';
|
|
9368
|
+
*
|
|
9369
|
+
* const session = conversation.startSession({ logLevel: LogLevel.Debug });
|
|
9370
|
+
* ```
|
|
9371
|
+
*/
|
|
9372
|
+
logLevel?: LogLevel;
|
|
9373
|
+
}
|
|
9374
|
+
/** Response for creating a conversation (includes methods) */
|
|
9375
|
+
type ConversationCreateResponse = ConversationGetResponse;
|
|
9376
|
+
/** Response for updating a conversation (includes methods) */
|
|
9377
|
+
type ConversationUpdateResponse = ConversationGetResponse;
|
|
9378
|
+
/** Response for deleting a conversation (raw data, no methods needed) */
|
|
9379
|
+
type ConversationDeleteResponse = RawConversationGetResponse;
|
|
9380
|
+
interface ConversationCreateOptions {
|
|
9381
|
+
/** Human-readable label for the conversation (max 100 chars) */
|
|
9382
|
+
label?: string;
|
|
9383
|
+
/** Whether the label should be auto-generated and updated after exchanges */
|
|
9384
|
+
autogenerateLabel?: boolean;
|
|
9385
|
+
/** Trace identifier for distributed tracing */
|
|
9386
|
+
traceId?: string;
|
|
9387
|
+
/** Optional configuration for job start behavior */
|
|
9388
|
+
jobStartOverrides?: ConversationJobStartOverrides;
|
|
9389
|
+
}
|
|
9390
|
+
interface ConversationUpdateOptions {
|
|
9391
|
+
/** Human-readable label for the conversation */
|
|
9392
|
+
label?: string;
|
|
9393
|
+
/** Whether the label should be auto-generated and updated after exchanges */
|
|
9394
|
+
autogenerateLabel?: boolean;
|
|
9395
|
+
/** The key of the current/latest job serving the conversation */
|
|
9396
|
+
jobKey?: string;
|
|
9397
|
+
/** Whether the conversation's job is running locally */
|
|
9398
|
+
isLocalJobExecution?: boolean;
|
|
9399
|
+
}
|
|
9400
|
+
type ConversationGetAllOptions = PaginationOptions & {
|
|
9401
|
+
/** Sort order for conversations */
|
|
9402
|
+
sort?: SortOrder;
|
|
9403
|
+
};
|
|
9404
|
+
/**
|
|
9405
|
+
* File upload access details for uploading file content to blob storage
|
|
9406
|
+
*/
|
|
9407
|
+
interface FileUploadAccess {
|
|
9408
|
+
/** URL to upload the file to */
|
|
9409
|
+
url: string;
|
|
9410
|
+
/** HTTP verb to use (e.g., 'PUT') */
|
|
9411
|
+
verb: string;
|
|
9412
|
+
/** Headers to include in the upload request */
|
|
9413
|
+
headers: {
|
|
9414
|
+
keys: string[];
|
|
9415
|
+
values: string[];
|
|
9416
|
+
};
|
|
9417
|
+
/** Whether authentication is required for the upload */
|
|
9418
|
+
requiresAuth?: boolean;
|
|
9419
|
+
}
|
|
9420
|
+
/**
|
|
9421
|
+
* Response for creating a file attachment entry
|
|
9422
|
+
*
|
|
9423
|
+
* Contains the attachment URI and upload access details for uploading
|
|
9424
|
+
* the file content to blob storage.
|
|
9425
|
+
*/
|
|
9426
|
+
interface ConversationAttachmentCreateResponse {
|
|
9427
|
+
/** URI to reference this attachment in messages */
|
|
9428
|
+
uri: string;
|
|
9429
|
+
/** File name */
|
|
9430
|
+
name: string;
|
|
9431
|
+
/** Details for uploading the file content */
|
|
9432
|
+
fileUploadAccess: FileUploadAccess;
|
|
9433
|
+
}
|
|
9434
|
+
/**
|
|
9435
|
+
* Response for uploading an attachment (after file content is uploaded)
|
|
9436
|
+
*/
|
|
9437
|
+
interface ConversationAttachmentUploadResponse {
|
|
9438
|
+
/** URI to reference this attachment in messages */
|
|
9439
|
+
uri: string;
|
|
9440
|
+
/** File name */
|
|
9441
|
+
name: string;
|
|
9442
|
+
/** MIME type of the uploaded file */
|
|
9443
|
+
mimeType: string;
|
|
9444
|
+
}
|
|
9445
|
+
|
|
9446
|
+
/**
|
|
9447
|
+
* Message Service Model
|
|
9448
|
+
*/
|
|
9449
|
+
|
|
9450
|
+
/**
|
|
9451
|
+
* Service for retrieving individual messages within an {@link ExchangeServiceModel | Exchange}
|
|
9452
|
+
*
|
|
9453
|
+
* A message is a single turn from a user, assistant, or system. Each message includes
|
|
9454
|
+
* a role, contentParts (text, audio, images), toolCalls, and interrupts.
|
|
9455
|
+
* Messages are also returned as part of exchange responses — use this service
|
|
9456
|
+
* when you need to fetch a specific message by ID or retrieve external content parts.
|
|
9457
|
+
* For real-time streaming of messages, see {@link MessageStream}.
|
|
9458
|
+
*
|
|
9459
|
+
* ### Usage
|
|
9460
|
+
*
|
|
9461
|
+
* Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize)
|
|
9462
|
+
*
|
|
9463
|
+
* ```typescript
|
|
9464
|
+
* import { Messages } from '@uipath/uipath-typescript/conversational-agent';
|
|
9465
|
+
*
|
|
9466
|
+
* const message = new Messages(sdk);
|
|
9467
|
+
* const messageDetails = await message.getById(conversationId, exchangeId, messageId);
|
|
9468
|
+
* ```
|
|
9469
|
+
*/
|
|
9470
|
+
interface MessageServiceModel {
|
|
9471
|
+
/**
|
|
9472
|
+
* Gets a message by ID
|
|
9473
|
+
*
|
|
9474
|
+
* Returns the message including its content parts, tool calls, and interrupts.
|
|
9475
|
+
*
|
|
9476
|
+
* @param conversationId - The conversation containing the message
|
|
9477
|
+
* @param exchangeId - The exchange containing the message
|
|
9478
|
+
* @param messageId - The message ID to retrieve
|
|
9479
|
+
* @returns Promise resolving to {@link MessageGetResponse}
|
|
9480
|
+
* @example
|
|
9481
|
+
* ```typescript
|
|
9482
|
+
* const message = await messages.getById(conversationId, exchangeId, messageId);
|
|
9483
|
+
*
|
|
9484
|
+
* console.log(message.role);
|
|
9485
|
+
* console.log(message.contentParts);
|
|
9486
|
+
* console.log(message.toolCalls);
|
|
9487
|
+
* ```
|
|
9488
|
+
*/
|
|
9489
|
+
getById(conversationId: string, exchangeId: string, messageId: string): Promise<MessageGetResponse>;
|
|
9490
|
+
/**
|
|
9491
|
+
* Gets an external content part by ID
|
|
9492
|
+
*
|
|
9493
|
+
* @param conversationId - The conversation containing the content
|
|
9494
|
+
* @param exchangeId - The exchange containing the content
|
|
9495
|
+
* @param messageId - The message containing the content part
|
|
9496
|
+
* @param contentPartId - The content part ID to retrieve
|
|
9497
|
+
* @returns Promise resolving to {@link ContentPartGetResponse}
|
|
9498
|
+
* @example
|
|
9499
|
+
* ```typescript
|
|
9500
|
+
* const contentPart = await messages.getContentPartById(
|
|
9501
|
+
* conversationId,
|
|
9502
|
+
* exchangeId,
|
|
9503
|
+
* messageId,
|
|
9504
|
+
* contentPartId
|
|
9505
|
+
* );
|
|
9506
|
+
* ```
|
|
9507
|
+
*/
|
|
9508
|
+
getContentPartById(conversationId: string, exchangeId: string, messageId: string, contentPartId: string): Promise<ContentPartGetResponse>;
|
|
9509
|
+
}
|
|
9510
|
+
|
|
9511
|
+
/**
|
|
9512
|
+
* Types for Agent Service
|
|
9513
|
+
*/
|
|
9514
|
+
/**
|
|
9515
|
+
* Starting prompt configuration for an agent
|
|
9516
|
+
*/
|
|
9517
|
+
interface AgentStartingPrompt {
|
|
9518
|
+
/** The prompt text displayed to the user */
|
|
9519
|
+
displayPrompt: string;
|
|
9520
|
+
/** The actual prompt sent when selected */
|
|
9521
|
+
actualPrompt: string;
|
|
9522
|
+
/** Unique identifier for the prompt */
|
|
9523
|
+
id: string;
|
|
9524
|
+
}
|
|
9525
|
+
/**
|
|
9526
|
+
* Agent appearance configuration
|
|
9527
|
+
*/
|
|
9528
|
+
interface AgentAppearance {
|
|
9529
|
+
/** Welcome title displayed to users */
|
|
9530
|
+
welcomeTitle?: string;
|
|
9531
|
+
/** Welcome description displayed to users */
|
|
9532
|
+
welcomeDescription?: string;
|
|
9533
|
+
/** Starting prompts for users to choose from */
|
|
9534
|
+
startingPrompts?: AgentStartingPrompt[];
|
|
9535
|
+
}
|
|
9536
|
+
/**
|
|
9537
|
+
* Raw API response for getting all agents
|
|
9538
|
+
*/
|
|
9539
|
+
interface RawAgentGetResponse {
|
|
9540
|
+
/** Unique ID of the agent */
|
|
9541
|
+
id: number;
|
|
9542
|
+
/** Display name of the agent */
|
|
9543
|
+
name: string;
|
|
9544
|
+
/** Agent description */
|
|
9545
|
+
description: string;
|
|
9546
|
+
/** Process version */
|
|
9547
|
+
processVersion: string;
|
|
9548
|
+
/** Process key identifier */
|
|
9549
|
+
processKey: string;
|
|
9550
|
+
/** Folder ID */
|
|
9551
|
+
folderId: number;
|
|
9552
|
+
/** Feed ID */
|
|
9553
|
+
feedId: string;
|
|
9554
|
+
/** Creation timestamp */
|
|
9555
|
+
createdTime?: string;
|
|
9556
|
+
}
|
|
9557
|
+
/**
|
|
9558
|
+
* Raw API response for getting a single agent by ID - includes appearance configuration
|
|
9559
|
+
*/
|
|
9560
|
+
interface RawAgentGetByIdResponse extends RawAgentGetResponse {
|
|
9561
|
+
/** Agent appearance configuration */
|
|
9562
|
+
appearance?: AgentAppearance;
|
|
9563
|
+
}
|
|
9564
|
+
|
|
9565
|
+
/**
|
|
9566
|
+
* Agent Service Models
|
|
9567
|
+
*
|
|
9568
|
+
* Provides fluent API for agent objects returned from getAll() and getById().
|
|
9569
|
+
*/
|
|
9570
|
+
|
|
9571
|
+
/**
|
|
9572
|
+
* Options for creating a conversation from an agent
|
|
9573
|
+
*/
|
|
9574
|
+
type AgentCreateConversationOptions = ConversationCreateOptions;
|
|
9575
|
+
/**
|
|
9576
|
+
* Scoped conversation service for a specific agent.
|
|
9577
|
+
* Auto-fills agentId and folderId from the agent.
|
|
9578
|
+
*/
|
|
9579
|
+
interface AgentConversationServiceModel {
|
|
9580
|
+
/**
|
|
9581
|
+
* Creates a conversation for this agent
|
|
9582
|
+
*
|
|
9583
|
+
* @param options - Optional conversation options (label, etc.)
|
|
9584
|
+
* @returns Promise resolving to the created conversation with methods
|
|
9585
|
+
*
|
|
9586
|
+
* @example
|
|
9587
|
+
* ```typescript
|
|
9588
|
+
* const agent = (await conversationalAgent.getAll())[0];
|
|
9589
|
+
* const conversation = await agent.conversations.create({ label: 'My Chat' });
|
|
9590
|
+
* const session = conversation.startSession();
|
|
9591
|
+
* ```
|
|
9592
|
+
*/
|
|
9593
|
+
create(options?: AgentCreateConversationOptions): Promise<ConversationCreateResponse>;
|
|
9594
|
+
}
|
|
9595
|
+
/**
|
|
9596
|
+
* Methods added to agent objects
|
|
9597
|
+
*/
|
|
9598
|
+
interface AgentMethods {
|
|
9599
|
+
/** Scoped conversation operations for this agent */
|
|
9600
|
+
readonly conversations: AgentConversationServiceModel;
|
|
9601
|
+
/** Current WebSocket connection status */
|
|
9602
|
+
get connectionStatus(): ConnectionStatus;
|
|
9603
|
+
/** Whether the WebSocket connection is currently active */
|
|
9604
|
+
get isConnected(): boolean;
|
|
9605
|
+
/** Current connection error, or `null` if none */
|
|
9606
|
+
get connectionError(): Error | null;
|
|
9607
|
+
}
|
|
9608
|
+
/**
|
|
9609
|
+
* Agent combining {@link RawAgentGetResponse} metadata with {@link AgentMethods} for conversation and connection management
|
|
9610
|
+
*/
|
|
9611
|
+
type AgentGetResponse = RawAgentGetResponse & AgentMethods;
|
|
9612
|
+
/**
|
|
9613
|
+
* Agent combining {@link RawAgentGetByIdResponse} metadata with {@link AgentMethods} for conversation and connection management
|
|
9614
|
+
*/
|
|
9615
|
+
type AgentGetByIdResponse = RawAgentGetByIdResponse & AgentMethods;
|
|
9616
|
+
declare function createAgentWithMethods<T extends RawAgentGetResponse>(agentData: T, conversationService: ConversationServiceModel): T & AgentMethods;
|
|
9617
|
+
|
|
9618
|
+
/**
|
|
9619
|
+
* Constants for Agent Service
|
|
9620
|
+
*/
|
|
9621
|
+
/**
|
|
9622
|
+
* Maps fields for Agent entities to ensure consistent SDK naming
|
|
9623
|
+
*/
|
|
9624
|
+
declare const AgentMap: {
|
|
9625
|
+
[key: string]: string;
|
|
9626
|
+
};
|
|
9627
|
+
|
|
9628
|
+
/**
|
|
9629
|
+
* Types for User Service
|
|
9630
|
+
*/
|
|
9631
|
+
/**
|
|
9632
|
+
* Response for getting user settings
|
|
9633
|
+
*
|
|
9634
|
+
* Contains profile and context information that is passed to the agent
|
|
9635
|
+
* for all conversations to provide user context.
|
|
9636
|
+
*
|
|
9637
|
+
* @example
|
|
9638
|
+
* ```typescript
|
|
9639
|
+
* const userSettings = await conversationalAgentService.user.getSettings();
|
|
9640
|
+
* console.log(userSettings.name, userSettings.email);
|
|
9641
|
+
* ```
|
|
9642
|
+
*/
|
|
9643
|
+
interface UserSettingsGetResponse {
|
|
9644
|
+
/** Unique identifier of the user (UUID) */
|
|
9645
|
+
userId: string;
|
|
9646
|
+
/** Name of the user (max 100 chars) */
|
|
9647
|
+
name: string | null;
|
|
9648
|
+
/** Email address (max 255 chars, must be valid email) */
|
|
9649
|
+
email: string | null;
|
|
9650
|
+
/** Role of the user (max 100 chars) */
|
|
9651
|
+
role: string | null;
|
|
9652
|
+
/** Department (max 100 chars) */
|
|
9653
|
+
department: string | null;
|
|
9654
|
+
/** Company (max 100 chars) */
|
|
9655
|
+
company: string | null;
|
|
9656
|
+
/** Country (max 100 chars) */
|
|
9657
|
+
country: string | null;
|
|
9658
|
+
/** Timezone (max 50 chars) */
|
|
9659
|
+
timezone: string | null;
|
|
9660
|
+
/** UTC timestamp of creation */
|
|
9661
|
+
createdTime: string;
|
|
9662
|
+
/** UTC timestamp of last update */
|
|
9663
|
+
updatedTime: string;
|
|
9664
|
+
}
|
|
9665
|
+
/** Response for updating user settings */
|
|
9666
|
+
type UserSettingsUpdateResponse = UserSettingsGetResponse;
|
|
9667
|
+
/**
|
|
9668
|
+
* Options for updating user settings
|
|
9669
|
+
*
|
|
9670
|
+
* All fields are optional - only send the fields you want to change.
|
|
9671
|
+
* Set fields to `null` to explicitly clear them.
|
|
9672
|
+
* Omitting fields means no change.
|
|
9673
|
+
*
|
|
9674
|
+
* @example
|
|
9675
|
+
* ```typescript
|
|
9676
|
+
* // Update specific fields
|
|
9677
|
+
* await conversationalAgentService.user.updateSettings({
|
|
9678
|
+
* name: 'John Doe',
|
|
9679
|
+
* timezone: 'America/New_York'
|
|
9680
|
+
* });
|
|
9681
|
+
*
|
|
9682
|
+
* // Clear a field by setting to null
|
|
9683
|
+
* await conversationalAgentService.user.updateSettings({
|
|
9684
|
+
* department: null
|
|
9685
|
+
* });
|
|
9686
|
+
* ```
|
|
9687
|
+
*/
|
|
9688
|
+
interface UserSettingsUpdateOptions {
|
|
9689
|
+
/** Name of the user (max 100 chars) */
|
|
9690
|
+
name?: string | null;
|
|
9691
|
+
/** Email address (max 255 chars, must be valid email) */
|
|
9692
|
+
email?: string | null;
|
|
9693
|
+
/** Role of the user (max 100 chars) */
|
|
9694
|
+
role?: string | null;
|
|
9695
|
+
/** Department (max 100 chars) */
|
|
9696
|
+
department?: string | null;
|
|
9697
|
+
/** Company (max 100 chars) */
|
|
9698
|
+
company?: string | null;
|
|
9699
|
+
/** Country (max 100 chars) */
|
|
9700
|
+
country?: string | null;
|
|
9701
|
+
/** Timezone (max 50 chars) */
|
|
9702
|
+
timezone?: string | null;
|
|
9703
|
+
}
|
|
9704
|
+
|
|
9705
|
+
/**
|
|
9706
|
+
* Service for managing UiPath User Settings
|
|
9707
|
+
*
|
|
9708
|
+
* User settings are passed to the agent for all conversations
|
|
9709
|
+
* to provide user context (name, email, role, timezone, etc.).
|
|
9710
|
+
*
|
|
9711
|
+
* @internal
|
|
9712
|
+
*/
|
|
9713
|
+
interface UserServiceModel {
|
|
9714
|
+
/**
|
|
9715
|
+
* Gets the current user's profile and context settings
|
|
9716
|
+
*
|
|
9717
|
+
* @returns Promise resolving to user settings object
|
|
9718
|
+
* {@link UserSettingsGetResponse}
|
|
9719
|
+
* @example
|
|
9720
|
+
* ```typescript
|
|
9721
|
+
* const userSettings = await userService.getSettings();
|
|
9722
|
+
* console.log(userSettings.name);
|
|
9723
|
+
* console.log(userSettings.email);
|
|
9724
|
+
* ```
|
|
9725
|
+
*/
|
|
9726
|
+
getSettings(): Promise<UserSettingsGetResponse>;
|
|
9727
|
+
/**
|
|
9728
|
+
* Updates the current user's profile and context settings
|
|
9729
|
+
*
|
|
9730
|
+
* @param options - Fields to update
|
|
9731
|
+
* @returns Promise resolving to updated user settings
|
|
9732
|
+
* {@link UserSettingsUpdateResponse}
|
|
9733
|
+
* @example
|
|
9734
|
+
* ```typescript
|
|
9735
|
+
* const updatedUserSettings = await userService.updateSettings({
|
|
9736
|
+
* name: 'John Doe',
|
|
9737
|
+
* timezone: 'America/New_York'
|
|
9738
|
+
* });
|
|
9739
|
+
* ```
|
|
9740
|
+
*/
|
|
9741
|
+
updateSettings(options: UserSettingsUpdateOptions): Promise<UserSettingsUpdateResponse>;
|
|
9742
|
+
}
|
|
9743
|
+
|
|
9744
|
+
/**
|
|
9745
|
+
* Constants for User Service
|
|
9746
|
+
*/
|
|
9747
|
+
/**
|
|
9748
|
+
* Maps fields for User Settings entities to ensure consistent SDK naming
|
|
9749
|
+
*/
|
|
9750
|
+
declare const UserSettingsMap: {
|
|
9751
|
+
[key: string]: string;
|
|
9752
|
+
};
|
|
9753
|
+
|
|
9754
|
+
/**
|
|
9755
|
+
* Types for Feature Flags
|
|
9756
|
+
*/
|
|
9757
|
+
/**
|
|
9758
|
+
* Feature flags for conversational agent capabilities
|
|
9759
|
+
*
|
|
9760
|
+
* @internal
|
|
9761
|
+
*/
|
|
9762
|
+
type FeatureFlags = Record<string, unknown>;
|
|
9763
|
+
|
|
9764
|
+
/**
|
|
9765
|
+
* Service for managing UiPath Conversational Agents — AI-powered chat interfaces that enable
|
|
9766
|
+
* natural language interactions with UiPath automation. Discover agents, create conversations,
|
|
9767
|
+
* and stream real-time responses over WebSocket. [UiPath Conversational Agents Guide](https://docs.uipath.com/agents/automation-cloud/latest/user-guide/conversational-agents)
|
|
9768
|
+
*
|
|
9769
|
+
* Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize)
|
|
9770
|
+
*
|
|
9771
|
+
* ## How It Works
|
|
9772
|
+
*
|
|
9773
|
+
* ### Lifecycle
|
|
9774
|
+
*
|
|
9775
|
+
* ```mermaid
|
|
9776
|
+
* graph TD
|
|
9777
|
+
* A["Agent"] -->|conversations.create| B["Conversation"]
|
|
9778
|
+
* B -->|startSession| C["Session"]
|
|
9779
|
+
* B -->|exchanges.getAll| F(["History"])
|
|
9780
|
+
* C -->|onSessionStarted| D["Ready"]
|
|
9781
|
+
* D -->|startExchange| E["Exchange"]
|
|
9782
|
+
* E -->|sendMessage| G["Message"]
|
|
9783
|
+
* ```
|
|
9784
|
+
*
|
|
9785
|
+
* ### Real-Time Event Flow
|
|
9786
|
+
*
|
|
9787
|
+
* Once a session is started, events flow through a nested stream hierarchy:
|
|
9788
|
+
*
|
|
9789
|
+
* ```mermaid
|
|
9790
|
+
* graph TD
|
|
9791
|
+
* S["SessionStream"]
|
|
9792
|
+
* S -->|onExchangeStart| E["ExchangeStream"]
|
|
9793
|
+
* S -->|onSessionEnd| SE(["session closed"])
|
|
9794
|
+
* E -->|onMessageStart| M["MessageStream"]
|
|
9795
|
+
* E -->|onExchangeEnd| EE(["exchange complete"])
|
|
9796
|
+
* M -->|onContentPartStart| CP["ContentPartStream"]
|
|
9797
|
+
* M -->|onToolCallStart| TC["ToolCallStream"]
|
|
9798
|
+
* M -->|onInterruptStart| IR(["awaiting approval"])
|
|
9799
|
+
* CP -->|onChunk| CH(["streaming data"])
|
|
9800
|
+
* TC -->|onToolCallEnd| TCE(["tool result"])
|
|
9801
|
+
* ```
|
|
9802
|
+
*
|
|
9803
|
+
* ## Usage
|
|
9804
|
+
*
|
|
9805
|
+
* ```typescript
|
|
9806
|
+
* import { ConversationalAgent } from '@uipath/uipath-typescript/conversational-agent';
|
|
9807
|
+
*
|
|
9808
|
+
* const conversationalAgent = new ConversationalAgent(sdk);
|
|
9809
|
+
*
|
|
9810
|
+
* // 1. Discover agents
|
|
9811
|
+
* const agents = await conversationalAgent.getAll();
|
|
9812
|
+
* const agent = agents[0];
|
|
9813
|
+
*
|
|
9814
|
+
* // 2. Create a conversation
|
|
9815
|
+
* const conversation = await agent.conversations.create({ label: 'My Chat' });
|
|
9816
|
+
*
|
|
9817
|
+
* // 3. Start real-time session and listen for responses
|
|
9818
|
+
* const session = conversation.startSession();
|
|
9819
|
+
*
|
|
9820
|
+
* session.onExchangeStart((exchange) => {
|
|
9821
|
+
* exchange.onMessageStart((message) => {
|
|
9822
|
+
* if (message.isAssistant) {
|
|
9823
|
+
* message.onContentPartStart((part) => {
|
|
9824
|
+
* if (part.isMarkdown) {
|
|
9825
|
+
* part.onChunk((chunk) => process.stdout.write(chunk.data ?? ''));
|
|
9826
|
+
* }
|
|
9827
|
+
* });
|
|
9828
|
+
* }
|
|
9829
|
+
* });
|
|
9830
|
+
* });
|
|
9831
|
+
*
|
|
9832
|
+
* // 4. Wait for session to be ready, then send a message
|
|
9833
|
+
* session.onSessionStarted(() => {
|
|
9834
|
+
* const exchange = session.startExchange();
|
|
9835
|
+
* exchange.sendMessageWithContentPart({ data: 'Hello!' });
|
|
9836
|
+
* });
|
|
9837
|
+
*
|
|
9838
|
+
* // 5. End session when done
|
|
9839
|
+
* conversation.endSession();
|
|
9840
|
+
*
|
|
9841
|
+
* // 6. Retrieve conversation history (offline)
|
|
9842
|
+
* const exchanges = await conversation.exchanges.getAll();
|
|
9843
|
+
* ```
|
|
9844
|
+
*/
|
|
9845
|
+
interface ConversationalAgentServiceModel {
|
|
9846
|
+
/**
|
|
9847
|
+
* Gets all available conversational agents
|
|
9848
|
+
*
|
|
9849
|
+
* @param folderId - Optional folder ID to filter agents
|
|
9850
|
+
* @returns Promise resolving to an array of agents
|
|
9851
|
+
* {@link AgentGetResponse}
|
|
9852
|
+
*
|
|
9853
|
+
* @example Basic usage
|
|
9854
|
+
* ```typescript
|
|
9855
|
+
* const agents = await conversationalAgent.getAll();
|
|
9856
|
+
* const agent = agents[0];
|
|
9857
|
+
*
|
|
9858
|
+
* // Create conversation directly from agent (agentId and folderId are auto-filled)
|
|
9859
|
+
* const conversation = await agent.conversations.create({ label: 'My Chat' });
|
|
9860
|
+
* ```
|
|
9861
|
+
*
|
|
9862
|
+
* @example Filter agents by folder
|
|
9863
|
+
* ```typescript
|
|
9864
|
+
* const agents = await conversationalAgent.getAll(folderId);
|
|
9865
|
+
* ```
|
|
9866
|
+
*/
|
|
9867
|
+
getAll(folderId?: number): Promise<AgentGetResponse[]>;
|
|
9868
|
+
/**
|
|
9869
|
+
* Gets a specific agent by ID
|
|
9870
|
+
*
|
|
9871
|
+
* @param id - ID of the agent release
|
|
9872
|
+
* @param folderId - ID of the folder containing the agent
|
|
9873
|
+
* @returns Promise resolving to the agent
|
|
9874
|
+
* {@link AgentGetByIdResponse}
|
|
9875
|
+
*
|
|
9876
|
+
* @example Basic usage
|
|
9877
|
+
* ```typescript
|
|
9878
|
+
* const agent = await conversationalAgent.getById(agentId, folderId);
|
|
9879
|
+
*
|
|
9880
|
+
* // Create conversation directly from agent (agentId and folderId are auto-filled)
|
|
9881
|
+
* const conversation = await agent.conversations.create({ label: 'My Chat' });
|
|
9882
|
+
* ```
|
|
9883
|
+
*/
|
|
9884
|
+
getById(id: number, folderId: number): Promise<AgentGetByIdResponse>;
|
|
9885
|
+
/**
|
|
9886
|
+
* Registers a handler that is called whenever the WebSocket connection status changes.
|
|
9887
|
+
*
|
|
9888
|
+
* @param handler - Callback receiving a {@link ConnectionStatus} (`'Disconnected'` | `'Connecting'` | `'Connected'`) and an optional `Error`
|
|
9889
|
+
* @returns Cleanup function to remove the handler
|
|
9890
|
+
*
|
|
9891
|
+
* @example
|
|
9892
|
+
* ```typescript
|
|
9893
|
+
* const cleanup = conversationalAgent.onConnectionStatusChanged((status, error) => {
|
|
9894
|
+
* console.log('Connection status:', status);
|
|
9895
|
+
* if (error) {
|
|
9896
|
+
* console.error('Connection error:', error.message);
|
|
9897
|
+
* }
|
|
9898
|
+
* });
|
|
9899
|
+
*
|
|
9900
|
+
* // Later, remove the handler
|
|
9901
|
+
* cleanup();
|
|
9902
|
+
* ```
|
|
9903
|
+
*/
|
|
9904
|
+
onConnectionStatusChanged(handler: (status: ConnectionStatus, error: Error | null) => void): () => void;
|
|
9905
|
+
/** Service for creating and managing conversations. See {@link ConversationServiceModel}. */
|
|
9906
|
+
readonly conversations: ConversationServiceModel;
|
|
9907
|
+
/**
|
|
9908
|
+
* Gets feature flags for the current tenant
|
|
9909
|
+
*
|
|
9910
|
+
* @internal
|
|
9911
|
+
*/
|
|
9912
|
+
getFeatureFlags(): Promise<FeatureFlags>;
|
|
9913
|
+
}
|
|
9914
|
+
|
|
9915
|
+
/**
|
|
9916
|
+
* Options for ConversationalAgentService constructor
|
|
9917
|
+
*/
|
|
9918
|
+
interface ConversationalAgentOptions {
|
|
9919
|
+
/** External User ID (optional) */
|
|
9920
|
+
externalUserId?: string;
|
|
9921
|
+
/** Log level for debugging */
|
|
9922
|
+
logLevel?: LogLevel;
|
|
9923
|
+
}
|
|
9924
|
+
|
|
5588
9925
|
/**
|
|
5589
9926
|
* Error thrown when authorization fails (403 errors)
|
|
5590
9927
|
* Common scenarios:
|
|
@@ -5654,17 +9991,13 @@ interface ErrorParams {
|
|
|
5654
9991
|
|
|
5655
9992
|
/**
|
|
5656
9993
|
* Base error class for all UiPath SDK errors
|
|
5657
|
-
*
|
|
9994
|
+
* Extends Error for standard error handling compatibility
|
|
5658
9995
|
*/
|
|
5659
|
-
declare abstract class UiPathError {
|
|
9996
|
+
declare abstract class UiPathError extends Error {
|
|
5660
9997
|
/**
|
|
5661
9998
|
* Error type identifier (e.g., "AuthenticationError", "ValidationError")
|
|
5662
9999
|
*/
|
|
5663
10000
|
readonly type: string;
|
|
5664
|
-
/**
|
|
5665
|
-
* Error message describing what went wrong
|
|
5666
|
-
*/
|
|
5667
|
-
readonly message: string;
|
|
5668
10001
|
/**
|
|
5669
10002
|
* HTTP status code (400, 401, 403, 404, 500, etc.)
|
|
5670
10003
|
*/
|
|
@@ -5677,10 +10010,6 @@ declare abstract class UiPathError {
|
|
|
5677
10010
|
* Timestamp when the error occurred
|
|
5678
10011
|
*/
|
|
5679
10012
|
readonly timestamp: Date;
|
|
5680
|
-
/**
|
|
5681
|
-
* Stack trace for debugging
|
|
5682
|
-
*/
|
|
5683
|
-
readonly stack?: string;
|
|
5684
10013
|
protected constructor(type: string, params: ErrorParams);
|
|
5685
10014
|
/**
|
|
5686
10015
|
* Returns a clean JSON representation of the error
|
|
@@ -5866,7 +10195,7 @@ declare const telemetryClient: TelemetryClient;
|
|
|
5866
10195
|
* SDK Telemetry constants
|
|
5867
10196
|
*/
|
|
5868
10197
|
declare const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
|
|
5869
|
-
declare const SDK_VERSION = "1.
|
|
10198
|
+
declare const SDK_VERSION = "1.1.0";
|
|
5870
10199
|
declare const VERSION = "Version";
|
|
5871
10200
|
declare const SERVICE = "Service";
|
|
5872
10201
|
declare const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -5881,5 +10210,5 @@ declare const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
|
5881
10210
|
declare const SDK_RUN_EVENT = "Sdk.Run";
|
|
5882
10211
|
declare const UNKNOWN = "";
|
|
5883
10212
|
|
|
5884
|
-
export { APP_NAME, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, FieldDisplayType, HttpStatus, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN, UiPath, UiPathError, VERSION, ValidationError, createCaseInstanceWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };
|
|
5885
|
-
export type { ArgumentMetadata, AssetGetAllOptions, AssetGetByIdOptions, AssetGetResponse, AssetServiceModel, BaseConfig, BaseOptions, BlobItem, BodyOptions, BpmnXmlString, BucketGetAllOptions, BucketGetByIdOptions, BucketGetFileMetaDataOptions, BucketGetFileMetaDataResponse, BucketGetFileMetaDataWithPaginationOptions, BucketGetReadUriOptions, BucketGetResponse, BucketGetUriOptions, BucketGetUriResponse, BucketServiceModel, BucketUploadFileOptions, BucketUploadResponse, CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetStageResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstancesServiceModel, CasesServiceModel, ChoiceSetGetAllResponse, ChoiceSetGetByIdOptions, ChoiceSetGetResponse, ChoiceSetServiceModel, CollectionResponse, CustomKeyValuePair, ElementExecutionMetadata, ElementMetaData, ElementRunMetadata, EntityBatchInsertOptions, EntityBatchInsertResponse, EntityDeleteOptions, EntityDeleteRecordsOptions, EntityDeleteResponse, EntityDownloadAttachmentOptions, EntityGetAllRecordsOptions, EntityGetRecordByIdOptions, EntityGetRecordsByIdOptions, EntityGetResponse, EntityInsertOptions, EntityInsertRecordOptions, EntityInsertRecordsOptions, EntityInsertResponse, EntityMethods, EntityOperationOptions, EntityOperationResponse, EntityRecord, EntityServiceModel, EntityUpdateOptions, EntityUpdateRecordsOptions, EntityUpdateResponse, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, ExternalConnection, ExternalField, ExternalFieldMapping, ExternalObject, ExternalSourceFields, FailureRecord, Field, FieldDataType, FieldMetaData, FolderProperties, GlobalVariableMetaData, HasPaginationOptions, Headers, HttpMethod, JobAttachment, JobError, Machine, MaestroProcessGetAllResponse, MaestroProcessesServiceModel, NonPaginatedResponse, OAuthFields, OperationResponse, PaginatedResponse, PaginationCursor, PaginationMetadata, PaginationMethodUnion, PaginationOptions, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, ProcessProperties, ProcessServiceModel, ProcessStartRequest, ProcessStartResponse, QueryParams, QueueGetAllOptions, QueueGetByIdOptions, QueueGetResponse, QueueServiceModel, RawCaseInstanceGetResponse, RawEntityGetResponse, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, RawTaskCreateResponse, RawTaskGetResponse, RequestOptions, RequestSpec, ResponseDictionary, ResponseType, RetryOptions, RobotMetadata, SourceJoinCriteria, StageSLA, StageTask, Tag, TaskActivity, TaskAssignOptions, TaskAssignment, TaskAssignmentOptions, TaskAssignmentResponse, TaskBaseResponse, TaskCompleteOptions, TaskCompletionOptions, TaskCreateOptions, TaskCreateResponse, TaskGetAllOptions, TaskGetByIdOptions, TaskGetResponse, TaskGetUsersOptions, TaskMethods, TaskServiceModel, TaskSlaDetail, TaskSource, TasksUnassignOptions, TimeoutOptions, UiPathSDKConfig, UserLoginInfo };
|
|
10213
|
+
export { APP_NAME, AgentMap, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, CitationErrorType, ConversationMap, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, ExchangeMap, FeedbackRating, FieldDisplayType, HttpStatus, InputStreamSpeechSensitivity, InterruptType, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, MessageMap, MessageRole, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, SortOrder, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN, UiPath, UiPathError, UserSettingsMap, VERSION, ValidationError, createAgentWithMethods, createCaseInstanceWithMethods, createConversationWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };
|
|
10214
|
+
export type { AgentAppearance, AgentConversationServiceModel, AgentCreateConversationOptions, AgentGetByIdResponse, AgentGetResponse, AgentMethods, AgentStartingPrompt, ArgumentMetadata, AssetGetAllOptions, AssetGetByIdOptions, AssetGetResponse, AssetServiceModel, AsyncInputStream, AsyncInputStreamChunkEvent, AsyncInputStreamEndEvent, AsyncInputStreamEvent, AsyncInputStreamStartEvent, AsyncToolCallStream, BaseConfig, BaseOptions, BaseProcessStartRequest, BlobItem, BodyOptions, BpmnXmlString, BucketGetAllOptions, BucketGetByIdOptions, BucketGetFileMetaDataOptions, BucketGetFileMetaDataResponse, BucketGetFileMetaDataWithPaginationOptions, BucketGetReadUriOptions, BucketGetResponse, BucketGetUriOptions, BucketGetUriResponse, BucketServiceModel, BucketUploadFileOptions, BucketUploadResponse, CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetStageResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstancesServiceModel, CasesServiceModel, ChoiceSetGetAllResponse, ChoiceSetGetByIdOptions, ChoiceSetGetResponse, ChoiceSetServiceModel, Citation, CitationEndEvent, CitationError, CitationEvent, CitationOptions, CitationSource, CitationSourceBase, CitationSourceMedia, CitationSourceUrl, CitationStartEvent, CollectionResponse, CompletedContentPart, CompletedMessage, CompletedToolCall, ContentPart, ContentPartChunkEvent, ContentPartData, ContentPartEndEvent, ContentPartEvent, ContentPartGetResponse, ContentPartInterrupted, ContentPartStartEvent, ContentPartStartMetaData, ContentPartStream, ConversationAttachmentCreateResponse, ConversationAttachmentUploadResponse, ConversationCreateOptions, ConversationCreateResponse, ConversationDeleteResponse, ConversationEvent, ConversationExchangeServiceModel, ConversationGetAllOptions, ConversationGetResponse, ConversationJobStartOverrides, ConversationMethods, ConversationServiceModel, ConversationSessionMethods, ConversationSessionOptions, ConversationUpdateOptions, ConversationUpdateResponse, ConversationalAgentOptions, ConversationalAgentServiceModel, CreateFeedbackOptions, CustomKeyValuePair, ElementExecutionMetadata, ElementMetaData, ElementRunMetadata, EntityBatchInsertOptions, EntityBatchInsertResponse, EntityDeleteOptions, EntityDeleteRecordsOptions, EntityDeleteResponse, EntityDownloadAttachmentOptions, EntityGetAllRecordsOptions, EntityGetRecordByIdOptions, EntityGetRecordsByIdOptions, EntityGetResponse, EntityInsertOptions, EntityInsertRecordOptions, EntityInsertRecordsOptions, EntityInsertResponse, EntityMethods, EntityOperationOptions, EntityOperationResponse, EntityRecord, EntityServiceModel, EntityUpdateOptions, EntityUpdateRecordsOptions, EntityUpdateResponse, ErrorEndEvent, ErrorEvent, ErrorStartEvent, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, Exchange, ExchangeEndEvent, ExchangeEvent, ExchangeGetAllOptions, ExchangeGetByIdOptions, ExchangeGetResponse, ExchangeServiceModel, ExchangeStartEvent, ExchangeStream, ExternalConnection, ExternalField, ExternalFieldMapping, ExternalObject, ExternalSourceFields, ExternalValue, FailureRecord, FeatureFlags, FeedbackCreateResponse, Field, FieldDataType, FieldMetaData, FileUploadAccess, FolderProperties, GenericInterruptStartEvent, GlobalVariableMetaData, HasPaginationOptions, Headers, HttpMethod, InlineOrExternalValue, InlineValue, Interrupt, InterruptEndEvent, InterruptEvent, InterruptStartEvent, JSONArray, JSONObject, JSONPrimitive, JSONValue, JobAttachment, JobError, LabelUpdatedEvent, Machine, MaestroProcessGetAllResponse, MaestroProcessesServiceModel, MakeOptional, MakeRequired, Message, MessageEndEvent, MessageEvent, MessageGetResponse, MessageServiceModel, MessageStartEvent, MessageStream, MetaData, MetaEvent, NonPaginatedResponse, OAuthFields, OperationResponse, PaginatedResponse, PaginationCursor, PaginationMetadata, PaginationMethodUnion, PaginationOptions, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, ProcessProperties, ProcessServiceModel, ProcessStartRequest, ProcessStartRequestWithKey, ProcessStartRequestWithName, ProcessStartResponse, QueryParams, QueueGetAllOptions, QueueGetByIdOptions, QueueGetResponse, QueueServiceModel, RawAgentGetByIdResponse, RawAgentGetResponse, RawCaseInstanceGetResponse, RawConversationGetResponse, RawEntityGetResponse, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, RawTaskCreateResponse, RawTaskGetResponse, RequestOptions, RequestSpec, ResponseDictionary, ResponseType, RetryOptions, RobotMetadata, SessionCapabilities, SessionEndEvent, SessionEndingEvent, SessionStartEvent, SessionStartedEvent, SessionStream, Simplify, SourceJoinCriteria, StageSLA, StageTask, Tag, TaskActivity, TaskAssignOptions, TaskAssignment, TaskAssignmentOptions, TaskAssignmentResponse, TaskBaseResponse, TaskCompleteOptions, TaskCompletionOptions, TaskCreateOptions, TaskCreateResponse, TaskGetAllOptions, TaskGetByIdOptions, TaskGetResponse, TaskGetUsersOptions, TaskMethods, TaskServiceModel, TaskSlaDetail, TaskSource, TasksUnassignOptions, TimeoutOptions, ToolCall, ToolCallConfirmationEndValue, ToolCallConfirmationInterruptStartEvent, ToolCallConfirmationValue, ToolCallEndEvent, ToolCallEvent, ToolCallInputValue, ToolCallOutputValue, ToolCallResult, ToolCallStartEvent, ToolCallStream, UiPathSDKConfig, UserLoginInfo, UserServiceModel, UserSettingsGetResponse, UserSettingsUpdateOptions, UserSettingsUpdateResponse };
|