asgard-js-core-ink 0.1.19
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/README.md +415 -0
- package/dist/constants/enum.d.ts +31 -0
- package/dist/constants/enum.d.ts.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1828 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/channel.d.ts +23 -0
- package/dist/lib/channel.d.ts.map +1 -0
- package/dist/lib/client.d.ts +27 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/conversation.d.ts +20 -0
- package/dist/lib/conversation.d.ts.map +1 -0
- package/dist/lib/create-sse-observable.d.ts +13 -0
- package/dist/lib/create-sse-observable.d.ts.map +1 -0
- package/dist/lib/event-emitter.d.ts +8 -0
- package/dist/lib/event-emitter.d.ts.map +1 -0
- package/dist/types/auth.d.ts +2 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/blob.d.ts +22 -0
- package/dist/types/blob.d.ts.map +1 -0
- package/dist/types/channel.d.ts +62 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/client.d.ts +74 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/event-emitter.d.ts +5 -0
- package/dist/types/event-emitter.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sse-response.d.ts +142 -0
- package/dist/types/sse-response.d.ts.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,OAAO,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface BlobUploadResponse {
|
|
2
|
+
isSuccess: boolean;
|
|
3
|
+
data: BlobData[];
|
|
4
|
+
error: string | null;
|
|
5
|
+
errorCode: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface BlobData {
|
|
8
|
+
channelId: string;
|
|
9
|
+
blobId: string;
|
|
10
|
+
fileType: 'IMAGE' | 'DOCUMENT' | 'VIDEO' | 'AUDIO' | 'UNKNOWN';
|
|
11
|
+
fileName: string | null;
|
|
12
|
+
size: number;
|
|
13
|
+
mime: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FileAttachment {
|
|
16
|
+
blobId: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
mime: string;
|
|
19
|
+
size: number;
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/types/blob.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IAC/D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ErrorMessage, Message } from './sse-response';
|
|
2
|
+
import { IAsgardServiceClient } from './client';
|
|
3
|
+
import { default as Conversation } from '../lib/conversation';
|
|
4
|
+
import { EventType } from '../constants/enum';
|
|
5
|
+
import { Observer } from 'rxjs';
|
|
6
|
+
|
|
7
|
+
export type ObserverOrNext<T> = Partial<Observer<T>> | ((value: T) => void);
|
|
8
|
+
export interface ChannelStates {
|
|
9
|
+
isConnecting: boolean;
|
|
10
|
+
conversation: Conversation;
|
|
11
|
+
}
|
|
12
|
+
export interface ChannelConfig {
|
|
13
|
+
client: IAsgardServiceClient;
|
|
14
|
+
customChannelId: string;
|
|
15
|
+
customMessageId?: string;
|
|
16
|
+
conversation: Conversation;
|
|
17
|
+
statesObserver?: ObserverOrNext<ChannelStates>;
|
|
18
|
+
}
|
|
19
|
+
export type ConversationUserMessage = {
|
|
20
|
+
type: 'user';
|
|
21
|
+
messageId: string;
|
|
22
|
+
text: string;
|
|
23
|
+
blobIds?: string[];
|
|
24
|
+
filePreviewUrls?: string[];
|
|
25
|
+
documentNames?: string[];
|
|
26
|
+
time: Date;
|
|
27
|
+
traceId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type ConversationBotMessage = {
|
|
30
|
+
type: 'bot';
|
|
31
|
+
messageId: string;
|
|
32
|
+
eventType: EventType;
|
|
33
|
+
isTyping: boolean;
|
|
34
|
+
typingText: string | null;
|
|
35
|
+
message: Message;
|
|
36
|
+
time: Date;
|
|
37
|
+
traceId?: string;
|
|
38
|
+
};
|
|
39
|
+
export type ConversationErrorMessage = {
|
|
40
|
+
type: 'error';
|
|
41
|
+
messageId: string;
|
|
42
|
+
eventType: EventType;
|
|
43
|
+
error: ErrorMessage;
|
|
44
|
+
time: Date;
|
|
45
|
+
traceId?: string;
|
|
46
|
+
};
|
|
47
|
+
export type ConversationToolCallMessage = {
|
|
48
|
+
type: 'tool-call';
|
|
49
|
+
messageId: string;
|
|
50
|
+
eventType: EventType.TOOL_CALL_START | EventType.TOOL_CALL_COMPLETE;
|
|
51
|
+
processId: string;
|
|
52
|
+
callSeq: number;
|
|
53
|
+
toolName: string;
|
|
54
|
+
toolsetName: string;
|
|
55
|
+
parameter: Record<string, unknown>;
|
|
56
|
+
result?: Record<string, unknown>;
|
|
57
|
+
isComplete: boolean;
|
|
58
|
+
time: Date;
|
|
59
|
+
traceId?: string;
|
|
60
|
+
};
|
|
61
|
+
export type ConversationMessage = ConversationUserMessage | ConversationBotMessage | ConversationErrorMessage | ConversationToolCallMessage;
|
|
62
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/types/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,CAAC,EAAE,cAAc,CAAC,aA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,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,GACxB,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { BlobUploadResponse } from './blob';
|
|
2
|
+
import { EventHandler } from './event-emitter';
|
|
3
|
+
import { SseResponse } from './sse-response';
|
|
4
|
+
import { EventType, FetchSseAction } from '../constants/enum';
|
|
5
|
+
|
|
6
|
+
export interface IAsgardServiceClient {
|
|
7
|
+
fetchSse(payload: FetchSsePayload, options?: FetchSseOptions): void;
|
|
8
|
+
uploadFile?(file: File, customChannelId: string): Promise<BlobUploadResponse>;
|
|
9
|
+
}
|
|
10
|
+
export type InitEventHandler = EventHandler<SseResponse<EventType.INIT>>;
|
|
11
|
+
export type MessageEventHandler = EventHandler<SseResponse<EventType.MESSAGE_START | EventType.MESSAGE_DELTA | EventType.MESSAGE_COMPLETE>>;
|
|
12
|
+
export type ProcessEventHandler = EventHandler<SseResponse<EventType.PROCESS_START | EventType.PROCESS_COMPLETE>>;
|
|
13
|
+
export type DoneEventHandler = EventHandler<SseResponse<EventType.DONE>>;
|
|
14
|
+
export type ErrorEventHandler = EventHandler<SseResponse<EventType.ERROR>>;
|
|
15
|
+
export type ToolCallEventHandler = EventHandler<SseResponse<EventType.TOOL_CALL_START | EventType.TOOL_CALL_COMPLETE>>;
|
|
16
|
+
export interface SseHandlers {
|
|
17
|
+
onRunInit?: InitEventHandler;
|
|
18
|
+
onMessage?: MessageEventHandler;
|
|
19
|
+
onToolCall?: ToolCallEventHandler;
|
|
20
|
+
onProcess?: ProcessEventHandler;
|
|
21
|
+
onRunDone?: DoneEventHandler;
|
|
22
|
+
onRunError?: ErrorEventHandler;
|
|
23
|
+
}
|
|
24
|
+
export type ClientConfig = SseHandlers & {
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
debugMode?: boolean;
|
|
27
|
+
transformSsePayload?: (payload: FetchSsePayload) => FetchSsePayload;
|
|
28
|
+
} & ({
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use `botProviderEndpoint` instead. This will be removed in the next major version.
|
|
31
|
+
* If provided, it will be used. Otherwise, it will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
32
|
+
*/
|
|
33
|
+
endpoint: string;
|
|
34
|
+
/**
|
|
35
|
+
* Base URL for the bot provider service.
|
|
36
|
+
* The SSE endpoint will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
37
|
+
*/
|
|
38
|
+
botProviderEndpoint?: string;
|
|
39
|
+
} | {
|
|
40
|
+
/**
|
|
41
|
+
* Base URL for the bot provider service.
|
|
42
|
+
* The SSE endpoint will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
43
|
+
*/
|
|
44
|
+
botProviderEndpoint: string;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `botProviderEndpoint` instead. This will be removed in the next major version.
|
|
47
|
+
* If provided, it will be used. Otherwise, it will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
48
|
+
*/
|
|
49
|
+
endpoint?: string;
|
|
50
|
+
});
|
|
51
|
+
export interface FetchSsePayload {
|
|
52
|
+
customChannelId: string;
|
|
53
|
+
customMessageId?: string;
|
|
54
|
+
text: string;
|
|
55
|
+
payload?: Record<string, unknown>;
|
|
56
|
+
action: FetchSseAction;
|
|
57
|
+
blobIds?: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface FetchSseOptions {
|
|
60
|
+
delayTime?: number;
|
|
61
|
+
onSseStart?: () => void;
|
|
62
|
+
onSseMessage?: (response: SseResponse<EventType>) => void;
|
|
63
|
+
onSseError?: (error: unknown) => void;
|
|
64
|
+
onSseCompleted?: () => void;
|
|
65
|
+
}
|
|
66
|
+
export type SseEvents = {
|
|
67
|
+
[EventType.INIT]: InitEventHandler;
|
|
68
|
+
[EventType.PROCESS]: ProcessEventHandler;
|
|
69
|
+
[EventType.MESSAGE]: MessageEventHandler;
|
|
70
|
+
[EventType.TOOL_CALL]: ToolCallEventHandler;
|
|
71
|
+
[EventType.DONE]: DoneEventHandler;
|
|
72
|
+
[EventType.ERROR]: ErrorEventHandler;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/types/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACpE,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/E;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACzE,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAC5C,WAAW,CAAC,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAC5F,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAClH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,WAA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IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IAC1D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACnC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACzC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACzC,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IAC5C,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACnC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;CACtC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type EventHandler<Args, Return = void> = Args extends any[] ? (...args: Args) => Return : (arg: Args) => Return;
|
|
2
|
+
export type Listeners<Events extends Record<string, any>> = {
|
|
3
|
+
[K in keyof Events]?: Array<Events[K]>;
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=event-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../../src/types/event-emitter.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,IAAI,SAAS,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC;AAEvH,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;KACzD,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,QAAQ,CAAC;AAC5B,mBAAmB,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,QAAQ,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { EventType, MessageTemplateType } from '../constants/enum';
|
|
2
|
+
|
|
3
|
+
export interface MessageTemplate {
|
|
4
|
+
quickReplies: {
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
}
|
|
8
|
+
export interface TextMessageTemplate extends MessageTemplate {
|
|
9
|
+
type: MessageTemplateType.TEXT;
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
export interface HintMessageTemplate extends MessageTemplate {
|
|
13
|
+
type: MessageTemplateType.HINT;
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ImageMessageTemplate extends MessageTemplate {
|
|
17
|
+
type: MessageTemplateType.IMAGE;
|
|
18
|
+
originalContentUrl: string;
|
|
19
|
+
previewImageUrl: string;
|
|
20
|
+
}
|
|
21
|
+
export interface VideoMessageTemplate extends MessageTemplate {
|
|
22
|
+
type: MessageTemplateType.VIDEO;
|
|
23
|
+
originalContentUrl: string;
|
|
24
|
+
previewImageUrl: string;
|
|
25
|
+
duration: number;
|
|
26
|
+
}
|
|
27
|
+
export interface AudioMessageTemplate extends MessageTemplate {
|
|
28
|
+
type: MessageTemplateType.AUDIO;
|
|
29
|
+
originalContentUrl: string;
|
|
30
|
+
duration: number;
|
|
31
|
+
}
|
|
32
|
+
export interface LocationMessageTemplate extends MessageTemplate {
|
|
33
|
+
type: MessageTemplateType.LOCATION;
|
|
34
|
+
title: string;
|
|
35
|
+
text: string;
|
|
36
|
+
latitude: number;
|
|
37
|
+
longitude: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ChartMessageTemplate extends MessageTemplate {
|
|
40
|
+
type: MessageTemplateType.CHART;
|
|
41
|
+
title: string;
|
|
42
|
+
text: string;
|
|
43
|
+
chartOptions: {
|
|
44
|
+
type: string;
|
|
45
|
+
title: string;
|
|
46
|
+
spec: Record<string, unknown>;
|
|
47
|
+
}[];
|
|
48
|
+
defaultChart: string;
|
|
49
|
+
quickReplies: {
|
|
50
|
+
text: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
export type ButtonAction = {
|
|
54
|
+
type: 'message' | 'MESSAGE';
|
|
55
|
+
text: string;
|
|
56
|
+
uri?: null;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'uri' | 'URI';
|
|
59
|
+
text?: null;
|
|
60
|
+
uri: string;
|
|
61
|
+
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
62
|
+
} | {
|
|
63
|
+
type: 'emit' | 'EMIT';
|
|
64
|
+
payload: Record<string, unknown>;
|
|
65
|
+
};
|
|
66
|
+
export interface ButtonMessageTemplate extends MessageTemplate {
|
|
67
|
+
type: MessageTemplateType.BUTTON;
|
|
68
|
+
title: string;
|
|
69
|
+
text: string;
|
|
70
|
+
thumbnailImageUrl: string;
|
|
71
|
+
imageAspectRatio: 'rectangle' | 'square';
|
|
72
|
+
imageSize: 'cover' | 'contain';
|
|
73
|
+
imageBackgroundColor: string;
|
|
74
|
+
defaultAction: ButtonAction;
|
|
75
|
+
buttons: {
|
|
76
|
+
label: string;
|
|
77
|
+
action: ButtonAction;
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
export interface CarouselMessageTemplate extends MessageTemplate {
|
|
81
|
+
type: MessageTemplateType.CAROUSEL;
|
|
82
|
+
columns: Omit<ButtonMessageTemplate, 'type' | 'quickReplies'>[];
|
|
83
|
+
}
|
|
84
|
+
export interface Message<Payload = unknown> {
|
|
85
|
+
messageId: string;
|
|
86
|
+
replyToCustomMessageId: string;
|
|
87
|
+
text: string;
|
|
88
|
+
payload: Payload | null;
|
|
89
|
+
isDebug: boolean;
|
|
90
|
+
idx: number;
|
|
91
|
+
template: TextMessageTemplate | HintMessageTemplate | ButtonMessageTemplate | ImageMessageTemplate | VideoMessageTemplate | AudioMessageTemplate | LocationMessageTemplate | CarouselMessageTemplate | ChartMessageTemplate;
|
|
92
|
+
}
|
|
93
|
+
export type IsEqual<A, B, DataType> = A extends B ? (B extends A ? DataType : null) : null;
|
|
94
|
+
export interface MessageEventData {
|
|
95
|
+
message: Message;
|
|
96
|
+
}
|
|
97
|
+
export interface ErrorMessage {
|
|
98
|
+
message: string;
|
|
99
|
+
code: string;
|
|
100
|
+
inner: string;
|
|
101
|
+
location: {
|
|
102
|
+
namespace: string;
|
|
103
|
+
workflowName: string;
|
|
104
|
+
processorName: string;
|
|
105
|
+
processorType: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export interface ErrorEventData {
|
|
109
|
+
error: ErrorMessage;
|
|
110
|
+
}
|
|
111
|
+
export interface ToolCallBaseEventData {
|
|
112
|
+
processId: string;
|
|
113
|
+
callSeq: number;
|
|
114
|
+
toolCall: {
|
|
115
|
+
toolsetName: string;
|
|
116
|
+
toolName: string;
|
|
117
|
+
parameter: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export interface ToolCallCompleteEventData extends ToolCallBaseEventData {
|
|
121
|
+
toolCallResult: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface Fact<Type extends EventType> {
|
|
124
|
+
runInit: null;
|
|
125
|
+
runDone: null;
|
|
126
|
+
runError: IsEqual<Type, EventType.ERROR, ErrorEventData>;
|
|
127
|
+
messageStart: IsEqual<Type, EventType.MESSAGE_START, MessageEventData>;
|
|
128
|
+
messageDelta: IsEqual<Type, EventType.MESSAGE_DELTA, MessageEventData>;
|
|
129
|
+
messageComplete: IsEqual<Type, EventType.MESSAGE_COMPLETE, MessageEventData>;
|
|
130
|
+
toolCallStart: IsEqual<Type, EventType.TOOL_CALL_START, ToolCallBaseEventData>;
|
|
131
|
+
toolCallComplete: IsEqual<Type, EventType.TOOL_CALL_COMPLETE, ToolCallCompleteEventData>;
|
|
132
|
+
}
|
|
133
|
+
export interface SseResponse<Type extends EventType> {
|
|
134
|
+
eventType: Type;
|
|
135
|
+
requestId: string;
|
|
136
|
+
traceId?: string;
|
|
137
|
+
namespace: string;
|
|
138
|
+
botProviderName: string;
|
|
139
|
+
customChannelId: string;
|
|
140
|
+
fact: Fact<Type>;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=sse-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-response.d.ts","sourceRoot":"","sources":["../../src/types/sse-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,IAAI,EAAE,mBAAmB,CAAC,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,IAAI,EAAE,mBAAmB,CAAC,IAAI,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAChC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAqB,S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CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAC7E,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;IAC/E,gBAAgB,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,kBAAkB,EAAE,yBAAyB,CAAC,CAAC;CAC1F;AAED,MAAM,WAAW,WAAW,CAAC,IAAI,SAAS,SAAS;IACjD,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "asgard-js-core-ink",
|
|
3
|
+
"version": "0.1.19",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@microsoft/fetch-event-source": "^2.0.1",
|
|
6
|
+
"rxjs": "^7.8.1",
|
|
7
|
+
"uuid": "^13.0.0"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@nx/js": "^21.5.3",
|
|
11
|
+
"@nx/react": "^21.5.3",
|
|
12
|
+
"@nx/vite": "^21.5.3",
|
|
13
|
+
"@types/jsdom": "^21.1.6",
|
|
14
|
+
"@vitest/ui": "^1.6.0",
|
|
15
|
+
"jsdom": "^24.0.0",
|
|
16
|
+
"nx": "^21.5.3",
|
|
17
|
+
"vitest": "^1.6.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
22
|
+
"test:ui": "vitest --ui",
|
|
23
|
+
"test:coverage": "vitest run --coverage"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"typings": "./dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"!**/*.tsbuildinfo"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"nx": {
|
|
36
|
+
"name": "asgard-js-core-ink",
|
|
37
|
+
"sourceRoot": "packages/core/src",
|
|
38
|
+
"projectType": "library"
|
|
39
|
+
},
|
|
40
|
+
"exports": {
|
|
41
|
+
"./package.json": "./package.json",
|
|
42
|
+
".": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"default": "./dist/index.mjs"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"default": "./dist/index.cjs"
|
|
50
|
+
},
|
|
51
|
+
"default": "./dist/index.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"types": "./dist/index.d.ts",
|
|
55
|
+
"module": "./dist/index.mjs"
|
|
56
|
+
}
|