@asgard-js/core 0.0.30 → 0.0.32-canary.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/README.md +1 -9
- package/dist/constants/enum.d.ts +31 -0
- package/dist/constants/enum.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/channel.d.ts +19 -0
- package/dist/lib/channel.d.ts.map +1 -0
- package/dist/lib/client.d.ts +17 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/conversation.d.ts +18 -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/channel.d.ts +42 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/client.d.ts +71 -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 +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/sse-response.d.ts +141 -0
- package/dist/types/sse-response.d.ts.map +1 -0
- package/eslint.config.cjs +22 -0
- package/package.json +1 -1
- package/src/constants/enum.ts +32 -0
- package/src/index.ts +11 -0
- package/src/lib/channel.ts +152 -0
- package/src/lib/client.spec.ts +150 -0
- package/src/lib/client.ts +141 -0
- package/src/lib/conversation.ts +120 -0
- package/src/lib/create-sse-observable.ts +77 -0
- package/src/lib/event-emitter.ts +30 -0
- package/src/types/channel.ts +50 -0
- package/src/types/client.ts +89 -0
- package/src/types/event-emitter.ts +8 -0
- package/src/types/index.ts +4 -0
- package/src/types/sse-response.ts +176 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.spec.json +33 -0
- package/vite.config.ts +80 -0
package/README.md
CHANGED
|
@@ -220,23 +220,15 @@ The core package includes comprehensive tests using Vitest.
|
|
|
220
220
|
|
|
221
221
|
```sh
|
|
222
222
|
# Run tests once
|
|
223
|
-
npm test
|
|
224
|
-
# or
|
|
225
223
|
yarn test:core
|
|
226
224
|
|
|
227
225
|
# Run tests in watch mode
|
|
228
|
-
npm run test:watch
|
|
229
|
-
# or
|
|
230
226
|
yarn test:core:watch
|
|
231
227
|
|
|
232
228
|
# Run tests with UI
|
|
233
|
-
npm run test:ui
|
|
234
|
-
# or
|
|
235
229
|
yarn test:core:ui
|
|
236
230
|
|
|
237
231
|
# Run tests with coverage
|
|
238
|
-
npm run test:coverage
|
|
239
|
-
# or
|
|
240
232
|
yarn test:core:coverage
|
|
241
233
|
```
|
|
242
234
|
|
|
@@ -305,7 +297,7 @@ yarn build:core
|
|
|
305
297
|
yarn watch:core
|
|
306
298
|
```
|
|
307
299
|
|
|
308
|
-
Setup your npm
|
|
300
|
+
Setup your npm registry token for yarn publishing:
|
|
309
301
|
|
|
310
302
|
```sh
|
|
311
303
|
cd ~/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare enum FetchSseAction {
|
|
2
|
+
RESET_CHANNEL = "RESET_CHANNEL",
|
|
3
|
+
NONE = "NONE"
|
|
4
|
+
}
|
|
5
|
+
export declare enum EventType {
|
|
6
|
+
INIT = "asgard.run.init",
|
|
7
|
+
PROCESS = "asgard.process",
|
|
8
|
+
PROCESS_START = "asgard.process.start",
|
|
9
|
+
PROCESS_COMPLETE = "asgard.process.complete",
|
|
10
|
+
MESSAGE = "asgard.message",
|
|
11
|
+
MESSAGE_START = "asgard.message.start",
|
|
12
|
+
MESSAGE_DELTA = "asgard.message.delta",
|
|
13
|
+
MESSAGE_COMPLETE = "asgard.message.complete",
|
|
14
|
+
TOOL_CALL = "asgard.tool_call",
|
|
15
|
+
TOOL_CALL_START = "asgard.tool_call.start",
|
|
16
|
+
TOOL_CALL_COMPLETE = "asgard.tool_call.complete",
|
|
17
|
+
DONE = "asgard.run.done",
|
|
18
|
+
ERROR = "asgard.run.error"
|
|
19
|
+
}
|
|
20
|
+
export declare enum MessageTemplateType {
|
|
21
|
+
TEXT = "TEXT",
|
|
22
|
+
HINT = "HINT",
|
|
23
|
+
BUTTON = "BUTTON",
|
|
24
|
+
IMAGE = "IMAGE",
|
|
25
|
+
VIDEO = "VIDEO",
|
|
26
|
+
AUDIO = "AUDIO",
|
|
27
|
+
LOCATION = "LOCATION",
|
|
28
|
+
CAROUSEL = "CAROUSEL",
|
|
29
|
+
CHART = "CHART"
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/constants/enum.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,aAAa,kBAAkB;IAC/B,IAAI,SAAS;CACd;AAED,oBAAY,SAAS;IACnB,IAAI,oBAAoB;IACxB,OAAO,mBAAmB;IAC1B,aAAa,yBAAyB;IACtC,gBAAgB,4BAA4B;IAC5C,OAAO,mBAAmB;IAC1B,aAAa,yBAAyB;IACtC,aAAa,yBAAyB;IACtC,gBAAgB,4BAA4B;IAC5C,SAAS,qBAAqB;IAC9B,eAAe,2BAA2B;IAC1C,kBAAkB,8BAA8B;IAChD,IAAI,oBAAoB;IACxB,KAAK,qBAAqB;CAC3B;AAED,oBAAY,mBAAmB;IAC7B,IAAI,SAAS;IACb,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { Subscription } from 'rxjs';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export * from './constants/enum';
|
|
4
|
+
export { default as AsgardServiceClient } from './lib/client';
|
|
5
|
+
export { default as Channel } from './lib/channel';
|
|
6
|
+
export { default as Conversation } from './lib/conversation';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,mBAAmB,WAAW,CAAC;AAE/B,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChannelConfig, FetchSseOptions, FetchSsePayload } from '../types';
|
|
2
|
+
|
|
3
|
+
export default class Channel {
|
|
4
|
+
private client;
|
|
5
|
+
customChannelId: string;
|
|
6
|
+
customMessageId?: string;
|
|
7
|
+
private isConnecting$;
|
|
8
|
+
private conversation$;
|
|
9
|
+
private statesObserver?;
|
|
10
|
+
private statesSubscription?;
|
|
11
|
+
private constructor();
|
|
12
|
+
static reset(config: ChannelConfig, payload?: Pick<FetchSsePayload, 'text' | 'payload'>, options?: FetchSseOptions): Promise<Channel>;
|
|
13
|
+
private subscribe;
|
|
14
|
+
private fetchSse;
|
|
15
|
+
private resetChannel;
|
|
16
|
+
sendMessage(payload: Pick<FetchSsePayload, 'customMessageId' | 'text' | 'payload'>, options?: FetchSseOptions): Promise<void>;
|
|
17
|
+
close(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/lib/channel.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,eAAe,EACf,eAAe,EAGhB,MAAM,WAAW,CAAC;AAInB,MAAM,CAAC,OAAO,OAAO,OAAO;IAC1B,OAAO,CAAC,MAAM,CAAuB;IAE9B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEhC,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,CAAC,cAAc,CAAC,CAAgC;IACvD,OAAO,CAAC,kBAAkB,CAAC,CAAe;IAE1C,OAAO;WAkBa,KAAK,CACvB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC,EACnD,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC;IAgBnB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,QAAQ;IA2BhB,OAAO,CAAC,YAAY;IAgBb,WAAW,CAChB,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAAC,EACtE,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,IAAI,CAAC;IAyBT,KAAK,IAAI,IAAI;CAKrB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventType } from '../constants/enum';
|
|
2
|
+
import { ClientConfig, IAsgardServiceClient, FetchSsePayload, FetchSseOptions, SseResponse, SseEvents } from '../types';
|
|
3
|
+
|
|
4
|
+
export default class AsgardServiceClient implements IAsgardServiceClient {
|
|
5
|
+
private apiKey?;
|
|
6
|
+
private endpoint;
|
|
7
|
+
private debugMode?;
|
|
8
|
+
private destroy$;
|
|
9
|
+
private sseEmitter;
|
|
10
|
+
private transformSsePayload?;
|
|
11
|
+
constructor(config: ClientConfig);
|
|
12
|
+
on<K extends keyof SseEvents>(event: K, listener: SseEvents[K]): void;
|
|
13
|
+
handleEvent(response: SseResponse<EventType>): void;
|
|
14
|
+
fetchSse(payload: FetchSsePayload, options?: FetchSseOptions): void;
|
|
15
|
+
close(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,WAAW,EACX,SAAS,EACV,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,oBAAoB;IACtE,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAC,CAAU;IAC5B,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,mBAAmB,CAAC,CAAgD;gBAEhE,MAAM,EAAE,YAAY;IA6BhC,EAAE,CAAC,CAAC,SAAS,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI;IAKrE,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI;IAqDnD,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI;IA4BnE,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConversationMessage, SseResponse } from '../types';
|
|
2
|
+
import { EventType } from '../constants/enum';
|
|
3
|
+
|
|
4
|
+
interface IConversation {
|
|
5
|
+
messages: Map<string, ConversationMessage> | null;
|
|
6
|
+
}
|
|
7
|
+
export default class Conversation implements IConversation {
|
|
8
|
+
messages: Map<string, ConversationMessage> | null;
|
|
9
|
+
constructor({ messages }: IConversation);
|
|
10
|
+
pushMessage(message: ConversationMessage): Conversation;
|
|
11
|
+
onMessage(response: SseResponse<EventType>): Conversation;
|
|
12
|
+
onMessageStart(response: SseResponse<EventType.MESSAGE_START>): Conversation;
|
|
13
|
+
onMessageDelta(response: SseResponse<EventType.MESSAGE_DELTA>): Conversation;
|
|
14
|
+
onMessageComplete(response: SseResponse<EventType.MESSAGE_COMPLETE>): Conversation;
|
|
15
|
+
onMessageError(response: SseResponse<EventType.ERROR>): Conversation;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../src/lib/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7D,UAAU,aAAa;IACrB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAC;CACnD;AAED,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,aAAa;IACjD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI,CAAQ;gBAEpD,EAAE,QAAQ,EAAE,EAAE,aAAa;IAIvC,WAAW,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY;IAOvD,SAAS,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,YAAY;IAqBzD,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,YAAY;IAiB5E,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,YAAY;IAwB5E,iBAAiB,CACf,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAChD,YAAY;IAkBf,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,YAAY;CAgBrE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EventType } from '../constants/enum';
|
|
2
|
+
import { FetchSsePayload, SseResponse } from '../types';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
interface CreateSseObservableOptions {
|
|
6
|
+
endpoint: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
debugMode?: boolean;
|
|
9
|
+
payload: FetchSsePayload;
|
|
10
|
+
}
|
|
11
|
+
export declare function createSseObservable(options: CreateSseObservableOptions): Observable<SseResponse<EventType>>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=create-sse-observable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-sse-observable.d.ts","sourceRoot":"","sources":["../../src/lib/create-sse-observable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKlC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,UAAU,0BAA0B;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,eAAe,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,0BAA0B,GAClC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CA2DpC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class EventEmitter<Events extends Record<string, any>> {
|
|
2
|
+
private listeners;
|
|
3
|
+
on<K extends keyof Events>(event: K, listener: Events[K]): void;
|
|
4
|
+
off<K extends keyof Events>(event: K, listener: Events[K]): void;
|
|
5
|
+
remove<K extends keyof Events>(event: K): void;
|
|
6
|
+
emit<K extends keyof Events>(event: K, ...args: Parameters<Events[K]>): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=event-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../../src/lib/event-emitter.ts"],"names":[],"mappings":"AAGA,qBAAa,YAAY,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAE1C,EAAE,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAM/D,GAAG,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAQhE,MAAM,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAI9C,IAAI,CAAC,CAAC,SAAS,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAK7E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
time: Date;
|
|
24
|
+
};
|
|
25
|
+
export type ConversationBotMessage = {
|
|
26
|
+
type: 'bot';
|
|
27
|
+
messageId: string;
|
|
28
|
+
eventType: EventType;
|
|
29
|
+
isTyping: boolean;
|
|
30
|
+
typingText: string | null;
|
|
31
|
+
message: Message;
|
|
32
|
+
time: Date;
|
|
33
|
+
};
|
|
34
|
+
export type ConversationErrorMessage = {
|
|
35
|
+
type: 'error';
|
|
36
|
+
messageId: string;
|
|
37
|
+
eventType: EventType;
|
|
38
|
+
error: ErrorMessage;
|
|
39
|
+
time: Date;
|
|
40
|
+
};
|
|
41
|
+
export type ConversationMessage = ConversationUserMessage | ConversationBotMessage | ConversationErrorMessage;
|
|
42
|
+
//# 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,oBAAoB,CAAC;AAC/C,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,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,aAAa,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EventHandler } from './event-emitter';
|
|
2
|
+
import { SseResponse } from './sse-response';
|
|
3
|
+
import { EventType, FetchSseAction } from '../constants/enum';
|
|
4
|
+
|
|
5
|
+
export interface IAsgardServiceClient {
|
|
6
|
+
fetchSse(payload: FetchSsePayload, options?: FetchSseOptions): void;
|
|
7
|
+
}
|
|
8
|
+
export type InitEventHandler = EventHandler<SseResponse<EventType.INIT>>;
|
|
9
|
+
export type MessageEventHandler = EventHandler<SseResponse<EventType.MESSAGE_START | EventType.MESSAGE_DELTA | EventType.MESSAGE_COMPLETE>>;
|
|
10
|
+
export type ProcessEventHandler = EventHandler<SseResponse<EventType.PROCESS_START | EventType.PROCESS_COMPLETE>>;
|
|
11
|
+
export type DoneEventHandler = EventHandler<SseResponse<EventType.DONE>>;
|
|
12
|
+
export type ErrorEventHandler = EventHandler<SseResponse<EventType.ERROR>>;
|
|
13
|
+
export type ToolCallEventHandler = EventHandler<SseResponse<EventType.TOOL_CALL_START | EventType.TOOL_CALL_COMPLETE>>;
|
|
14
|
+
export interface SseHandlers {
|
|
15
|
+
onRunInit?: InitEventHandler;
|
|
16
|
+
onMessage?: MessageEventHandler;
|
|
17
|
+
onToolCall?: ToolCallEventHandler;
|
|
18
|
+
onProcess?: ProcessEventHandler;
|
|
19
|
+
onRunDone?: DoneEventHandler;
|
|
20
|
+
onRunError?: ErrorEventHandler;
|
|
21
|
+
}
|
|
22
|
+
export type ClientConfig = SseHandlers & {
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
debugMode?: boolean;
|
|
25
|
+
transformSsePayload?: (payload: FetchSsePayload) => FetchSsePayload;
|
|
26
|
+
} & ({
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `botProviderEndpoint` instead. This will be removed in the next major version.
|
|
29
|
+
* If provided, it will be used. Otherwise, it will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
30
|
+
*/
|
|
31
|
+
endpoint: string;
|
|
32
|
+
/**
|
|
33
|
+
* Base URL for the bot provider service.
|
|
34
|
+
* The SSE endpoint will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
35
|
+
*/
|
|
36
|
+
botProviderEndpoint?: string;
|
|
37
|
+
} | {
|
|
38
|
+
/**
|
|
39
|
+
* Base URL for the bot provider service.
|
|
40
|
+
* The SSE endpoint will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
41
|
+
*/
|
|
42
|
+
botProviderEndpoint: string;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use `botProviderEndpoint` instead. This will be removed in the next major version.
|
|
45
|
+
* If provided, it will be used. Otherwise, it will be automatically derived as `${botProviderEndpoint}/message/sse`
|
|
46
|
+
*/
|
|
47
|
+
endpoint?: string;
|
|
48
|
+
});
|
|
49
|
+
export interface FetchSsePayload {
|
|
50
|
+
customChannelId: string;
|
|
51
|
+
customMessageId?: string;
|
|
52
|
+
text: string;
|
|
53
|
+
payload?: Record<string, unknown>;
|
|
54
|
+
action: FetchSseAction;
|
|
55
|
+
}
|
|
56
|
+
export interface FetchSseOptions {
|
|
57
|
+
delayTime?: number;
|
|
58
|
+
onSseStart?: () => void;
|
|
59
|
+
onSseMessage?: (response: SseResponse<EventType>) => void;
|
|
60
|
+
onSseError?: (error: unknown) => void;
|
|
61
|
+
onSseCompleted?: () => void;
|
|
62
|
+
}
|
|
63
|
+
export interface SseEvents {
|
|
64
|
+
[EventType.INIT]: InitEventHandler;
|
|
65
|
+
[EventType.PROCESS]: ProcessEventHandler;
|
|
66
|
+
[EventType.MESSAGE]: MessageEventHandler;
|
|
67
|
+
[EventType.TOOL_CALL]: ToolCallEventHandler;
|
|
68
|
+
[EventType.DONE]: DoneEventHandler;
|
|
69
|
+
[EventType.ERROR]: ErrorEventHandler;
|
|
70
|
+
}
|
|
71
|
+
//# 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,oBAAoB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,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mB,CAAC,EAAE,MAAM,CAAC;CAC9B,GACD;IACE;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;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,WAAW,SAAS;IACxB,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"}
|
|
@@ -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,GAC9D,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GACzB,CAAC,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC;AAE1B,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,UAAU,CAAC;AAC9B,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
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: any;
|
|
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
|
+
namespace: string;
|
|
137
|
+
botProviderName: string;
|
|
138
|
+
customChannelId: string;
|
|
139
|
+
fact: Fact<Type>;
|
|
140
|
+
}
|
|
141
|
+
//# 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,oBAAoB,CAAC;AAEpE,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;AA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AAK,EAAE,cAAc,CAAC,CAAC;IACzD,YAAY,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IACvE,YAAY,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IACvE,eAAe,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IAC7E,aAAa,EAAE,OAAO,CACpB,IAAI,EACJ,SAAS,CAAC,eAAe,EACzB,qBAAqB,CACtB,CAAC;IACF,gBAAgB,EAAE,OAAO,CACvB,IAAI,EACJ,SAAS,CAAC,kBAAkB,EAC5B,yBAAyB,CAC1B,CAAC;CACH;AAED,MAAM,WAAW,WAAW,CAAC,IAAI,SAAS,SAAS;IACjD,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;CAClB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const baseConfig = require('../../eslint.config.cjs');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
...baseConfig,
|
|
5
|
+
{
|
|
6
|
+
files: ['**/*.json'],
|
|
7
|
+
rules: {
|
|
8
|
+
'@nx/dependency-checks': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
ignoredFiles: [
|
|
12
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
+
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parser: require('jsonc-eslint-parser'),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
];
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export enum FetchSseAction {
|
|
2
|
+
RESET_CHANNEL = 'RESET_CHANNEL',
|
|
3
|
+
NONE = 'NONE',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export enum EventType {
|
|
7
|
+
INIT = 'asgard.run.init',
|
|
8
|
+
PROCESS = 'asgard.process',
|
|
9
|
+
PROCESS_START = 'asgard.process.start',
|
|
10
|
+
PROCESS_COMPLETE = 'asgard.process.complete',
|
|
11
|
+
MESSAGE = 'asgard.message',
|
|
12
|
+
MESSAGE_START = 'asgard.message.start',
|
|
13
|
+
MESSAGE_DELTA = 'asgard.message.delta',
|
|
14
|
+
MESSAGE_COMPLETE = 'asgard.message.complete',
|
|
15
|
+
TOOL_CALL = 'asgard.tool_call',
|
|
16
|
+
TOOL_CALL_START = 'asgard.tool_call.start',
|
|
17
|
+
TOOL_CALL_COMPLETE = 'asgard.tool_call.complete',
|
|
18
|
+
DONE = 'asgard.run.done',
|
|
19
|
+
ERROR = 'asgard.run.error',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum MessageTemplateType {
|
|
23
|
+
TEXT = 'TEXT',
|
|
24
|
+
HINT = 'HINT',
|
|
25
|
+
BUTTON = 'BUTTON',
|
|
26
|
+
IMAGE = 'IMAGE',
|
|
27
|
+
VIDEO = 'VIDEO',
|
|
28
|
+
AUDIO = 'AUDIO',
|
|
29
|
+
LOCATION = 'LOCATION',
|
|
30
|
+
CAROUSEL = 'CAROUSEL',
|
|
31
|
+
CHART = 'CHART',
|
|
32
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { Subscription } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
export type * from 'src/types';
|
|
4
|
+
|
|
5
|
+
export * from 'src/constants/enum';
|
|
6
|
+
|
|
7
|
+
export { default as AsgardServiceClient } from 'src/lib/client';
|
|
8
|
+
|
|
9
|
+
export { default as Channel } from 'src/lib/channel';
|
|
10
|
+
|
|
11
|
+
export { default as Conversation } from 'src/lib/conversation';
|