@glodon-aiot/agent-cli-sdk 2.4.7

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.
Files changed (108) hide show
  1. package/README.md +70 -0
  2. package/dist/agent-cli-sdk.js +34975 -0
  3. package/dist/agent-cli-sdk.umd.cjs +150 -0
  4. package/dist/cdn/agent-cli-sdk.js +32945 -0
  5. package/dist/cdn/agent-cli-sdk.umd.cjs +140 -0
  6. package/dist/cdn/src/AgentPlugin.d.ts +17 -0
  7. package/dist/cdn/src/AgentSession.d.ts +8 -0
  8. package/dist/cdn/src/BotClient.d.ts +46 -0
  9. package/dist/cdn/src/Config.d.ts +32 -0
  10. package/dist/cdn/src/DialogSession.d.ts +21 -0
  11. package/dist/cdn/src/EventBus.d.ts +23 -0
  12. package/dist/cdn/src/Logger.d.ts +12 -0
  13. package/dist/cdn/src/PayloadTypes.d.ts +84 -0
  14. package/dist/cdn/src/Session.d.ts +156 -0
  15. package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +1 -0
  16. package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +1 -0
  17. package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +1 -0
  18. package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +44 -0
  19. package/dist/cdn/src/api/fetchEventSource/index.d.ts +1 -0
  20. package/dist/cdn/src/api/fetchEventSource/parse.d.ts +36 -0
  21. package/dist/cdn/src/api/index.d.ts +2 -0
  22. package/dist/cdn/src/index.d.ts +5 -0
  23. package/dist/cdn/src/utils.d.ts +4 -0
  24. package/dist/es/AgentPlugin.mjs +20 -0
  25. package/dist/es/AgentSession.mjs +243 -0
  26. package/dist/es/BotClient.mjs +242 -0
  27. package/dist/es/Config.mjs +34 -0
  28. package/dist/es/DialogSession.mjs +281 -0
  29. package/dist/es/EventBus.mjs +64 -0
  30. package/dist/es/Logger.mjs +31 -0
  31. package/dist/es/PayloadTypes.mjs +4 -0
  32. package/dist/es/Session.mjs +527 -0
  33. package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
  34. package/dist/es/_virtual/index.mjs +4 -0
  35. package/dist/es/_virtual/index2.mjs +4 -0
  36. package/dist/es/_virtual/index3.mjs +4 -0
  37. package/dist/es/_virtual/minio-zj.mjs +4 -0
  38. package/dist/es/api/fetchEventSource/fetch.mjs +112 -0
  39. package/dist/es/api/fetchEventSource/parse.mjs +97 -0
  40. package/dist/es/api/index.mjs +48 -0
  41. package/dist/es/index.mjs +11 -0
  42. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +26485 -0
  43. package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +54 -0
  44. package/dist/es/node_modules/base64-js/index.mjs +47 -0
  45. package/dist/es/node_modules/buffer/index.mjs +927 -0
  46. package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +9 -0
  47. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +18 -0
  48. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +24 -0
  49. package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +19 -0
  50. package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +4 -0
  51. package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +317 -0
  52. package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +113 -0
  53. package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +11 -0
  54. package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +273 -0
  55. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +8 -0
  56. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +87 -0
  57. package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +52 -0
  58. package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +21 -0
  59. package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +23 -0
  60. package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +21 -0
  61. package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +14 -0
  62. package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +39 -0
  63. package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +28 -0
  64. package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +105 -0
  65. package/dist/es/node_modules/ieee754/index.mjs +28 -0
  66. package/dist/es/node_modules/js-base64/base64.mjs +31 -0
  67. package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +26 -0
  68. package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +25 -0
  69. package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +242 -0
  70. package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +8 -0
  71. package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +608 -0
  72. package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +19 -0
  73. package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +52 -0
  74. package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +203 -0
  75. package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +26 -0
  76. package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
  77. package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
  78. package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
  79. package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
  80. package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +4 -0
  81. package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +8 -0
  82. package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +8 -0
  83. package/dist/es/packages/apis/dist/es/base/index.mjs +154 -0
  84. package/dist/es/packages/apis/dist/es/cvforce/index.mjs +431 -0
  85. package/dist/es/packages/apis/dist/es/cvforce/model.mjs +5 -0
  86. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +1 -0
  87. package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +3 -0
  88. package/dist/es/utils.mjs +11 -0
  89. package/dist/lib/index.js +126 -0
  90. package/dist/src/AgentPlugin.d.ts +17 -0
  91. package/dist/src/AgentSession.d.ts +8 -0
  92. package/dist/src/BotClient.d.ts +46 -0
  93. package/dist/src/Config.d.ts +32 -0
  94. package/dist/src/DialogSession.d.ts +21 -0
  95. package/dist/src/EventBus.d.ts +23 -0
  96. package/dist/src/Logger.d.ts +12 -0
  97. package/dist/src/PayloadTypes.d.ts +84 -0
  98. package/dist/src/Session.d.ts +155 -0
  99. package/dist/src/__ tests __/AgentClient.spec.d.ts +1 -0
  100. package/dist/src/__ tests __/AgentSession.spec.d.ts +1 -0
  101. package/dist/src/__ tests __/DialogClient.spec.d.ts +1 -0
  102. package/dist/src/api/fetchEventSource/fetch.d.ts +44 -0
  103. package/dist/src/api/fetchEventSource/index.d.ts +1 -0
  104. package/dist/src/api/fetchEventSource/parse.d.ts +36 -0
  105. package/dist/src/api/index.d.ts +2 -0
  106. package/dist/src/index.d.ts +5 -0
  107. package/dist/src/utils.d.ts +4 -0
  108. package/package.json +102 -0
@@ -0,0 +1,17 @@
1
+ import { AgentPluginRegistor } from '.';
2
+ /**
3
+ * Class AgentPlugin
4
+ * 提供获取插件数据、检测客户端插件等功能
5
+ */
6
+ interface AgentPluginDetails {
7
+ }
8
+ export default class AgentPlugin {
9
+ code: string;
10
+ description: string;
11
+ loaded: boolean;
12
+ functions: AgentPluginRegistor;
13
+ constructor(code: any, functions?: AgentPluginRegistor, initalData?: AgentPluginDetails);
14
+ fetchData(): void;
15
+ checkFunctions(): void;
16
+ }
17
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ISession } from '@glodon-aiot/apis';
2
+ import Session, { QuestionBody, QuestionConfig } from './Session';
3
+ export default class AgentSession extends Session {
4
+ constructor(token: string, _id?: string, _data?: Partial<ISession>, lazyload?: boolean);
5
+ prepareConnection(): Promise<boolean>;
6
+ sendQuestion(questionBody: QuestionBody, configs: QuestionConfig): Promise<false | undefined>;
7
+ stopAnswer(): void;
8
+ }
@@ -0,0 +1,46 @@
1
+ import Session from './Session';
2
+ import { BotClientConfig } from './Config';
3
+ import { IApplication, IPrompt, ISession, SessionQueryParams } from '@glodon-aiot/apis';
4
+ import EventBus from './EventBus';
5
+ export type ClientEventName = 'ready' | 'application:loaded';
6
+ export default class BotClient {
7
+ private _token;
8
+ private lazyload;
9
+ protected event: EventBus;
10
+ private cvforceApi;
11
+ private _applicationId;
12
+ private _application;
13
+ private _sessions;
14
+ private _activeSession?;
15
+ private _ready?;
16
+ private _questionContextMaxLength?;
17
+ private _promptVariables?;
18
+ constructor(_token: string, //AIoT resource token
19
+ configs: BotClientConfig, lazyload?: boolean);
20
+ private checkReady;
21
+ get ready(): boolean | undefined;
22
+ private set ready(value);
23
+ get questionContextMaxLength(): number | undefined;
24
+ get promptVariables(): IPrompt[] | undefined;
25
+ get knowledges(): any;
26
+ get sessions(): Session[];
27
+ set sessions(v: Session[]);
28
+ private loadApplication;
29
+ private getService;
30
+ get token(): string;
31
+ set token(v: string);
32
+ get applicationId(): string;
33
+ get application(): IApplication | null;
34
+ get activeSession(): string;
35
+ set activeSession(sessionId: string);
36
+ private createSession;
37
+ getSessions(queryParams?: SessionQueryParams): Promise<Session[]>;
38
+ loadSession(sessionId?: string, sessionParams?: Partial<ISession>): Promise<Session>;
39
+ reload(): Promise<void>;
40
+ reloadSession(sessionId?: string): Promise<Session | undefined>;
41
+ setTop(sessionId: string, top: boolean, order?: string): Promise<Session[] | undefined>;
42
+ addEventListener(eventName: ClientEventName, callback: any, once?: boolean): void;
43
+ removeEventListener(eventName: ClientEventName, callback: any): void;
44
+ removeSession(session: string | Session, deleteFromRemote?: boolean): Promise<void>;
45
+ clean(): void;
46
+ }
@@ -0,0 +1,32 @@
1
+ export interface BotClientConfig {
2
+ debug?: boolean;
3
+ env?: Env;
4
+ applicationId?: string;
5
+ plugins?: AgentPluginMap;
6
+ apiRoot?: string;
7
+ }
8
+ export interface AgentPluginRegistor {
9
+ [key: string]: Function;
10
+ }
11
+ export interface AgentPluginMap {
12
+ [pluginCode: string]: AgentPluginRegistor;
13
+ }
14
+ export type Env = 'dev' | 'test' | 'prod' | 'local';
15
+ export declare enum ApiUrl {
16
+ dev = "https://aiot-dev.glodon.com/api/cvforcepd",
17
+ test = "https://aiot-dev.glodon.com/api/cvforce",
18
+ prod = "https://copilot.glodon.com/api/cvforce",
19
+ local = "http://localhost:3000/api/cvforcepd"
20
+ }
21
+ export declare let configuration: {
22
+ debug: boolean;
23
+ env: string;
24
+ apiRoot: string;
25
+ applicationId: string;
26
+ plugins: AgentPluginMap;
27
+ };
28
+ /**
29
+ * 配置SDK,可以在SDK被使用前被调用,该方法被调用后将改变是否debug模式、是否测试环境等基本配置
30
+ * @param param {debug?: boolean; env?: 'dev' | 'test' | 'prod';}
31
+ */
32
+ export declare function configure(param?: BotClientConfig): void;
@@ -0,0 +1,21 @@
1
+ import { ISession } from '@glodon-aiot/apis';
2
+ import Session, { QuestionBody, QuestionConfig } from './Session';
3
+ export default class DialogSession extends Session {
4
+ private ctrl;
5
+ constructor(token: string, _id?: string, _data?: Partial<ISession>, lazyload?: boolean);
6
+ prepareConnection(): Promise<boolean>;
7
+ postChatV2EventSource(applicationId: string, sessionId: string, params: any, signal: AbortSignal, options: {
8
+ onopen?: any;
9
+ onmessage?: any;
10
+ onerror?: any;
11
+ onclose?: any;
12
+ }, onAppStatusError?: (error: any) => void): Promise<void>;
13
+ postChatV3EventSource(applicationId: string, sessionId: string, params: any, signal: AbortSignal, options: {
14
+ onopen?: any;
15
+ onmessage?: any;
16
+ onerror?: any;
17
+ onclose?: any;
18
+ }, onAppStatusError?: (error: any) => void): Promise<void>;
19
+ sendQuestion(questionBody: QuestionBody, configs: QuestionConfig): Promise<void>;
20
+ stopAnswer(): void;
21
+ }
@@ -0,0 +1,23 @@
1
+ type Topic = string;
2
+ export interface ViewerEvent {
3
+ topic: Topic;
4
+ payload?: any;
5
+ }
6
+ export type EventListener = (e: any) => void;
7
+ interface SingleEventListener {
8
+ fn: EventListener;
9
+ once: true;
10
+ }
11
+ export default class EventBus {
12
+ private eventListenerMap;
13
+ constructor(disableLog?: boolean);
14
+ getEventListenerMap(): {
15
+ [x: string]: (SingleEventListener | EventListener)[];
16
+ };
17
+ on(topic: Topic, listener: EventListener, once?: boolean): void;
18
+ once(topic: Topic, listener: EventListener): void;
19
+ off(topic: Topic, listener: EventListener): void;
20
+ emit(topic: Topic, payload?: any): void;
21
+ removeAllListeners(): void;
22
+ }
23
+ export {};
@@ -0,0 +1,12 @@
1
+ export default class Logger {
2
+ private prefix;
3
+ private open;
4
+ static debug: boolean;
5
+ constructor(prefix: string, open?: boolean);
6
+ disable(): void;
7
+ enable(): void;
8
+ log(...rest: any[]): void;
9
+ info(...rest: any[]): void;
10
+ error(...rest: any[]): void;
11
+ warn(...rest: any[]): void;
12
+ }
@@ -0,0 +1,84 @@
1
+ export declare enum UserMode {
2
+ Normal = 0,
3
+ Debug = 1
4
+ }
5
+ export interface ReadyEventPayload {
6
+ /**
7
+ * 错误码如下:
8
+ * 200: 成功
9
+ * 11903: 密钥失效
10
+ * 11904: 参数异常
11
+ * 11905: token解析异常
12
+ * 11907: 未知错误
13
+ * 11913: 获取应用编排数据失败
14
+ * 11914: 获取大模型服务失败, 请检查
15
+ * 11924: 用户无此应用权限
16
+ */
17
+ code: number;
18
+ message: string;
19
+ userMode: UserMode;
20
+ }
21
+ export interface PluginFunctionBasic {
22
+ pluginName: string;
23
+ pluginCode: string;
24
+ funcCode: string;
25
+ funcName: string;
26
+ parameters?: {
27
+ header: any;
28
+ query: any;
29
+ };
30
+ requestBody?: any;
31
+ runnerIsClient?: boolean;
32
+ result?: {
33
+ code: number;
34
+ message: string;
35
+ data: any;
36
+ };
37
+ }
38
+ export interface PluginFunctionBeforeCall extends PluginFunctionBasic {
39
+ parameters: {
40
+ header: any;
41
+ query: any;
42
+ };
43
+ requestBody: any;
44
+ }
45
+ export interface PluginFunctionCall extends PluginFunctionBasic {
46
+ parameters: {
47
+ header: any;
48
+ query: any;
49
+ };
50
+ requestBody: any;
51
+ runnerIsClient: boolean;
52
+ }
53
+ export interface PluginFunctionResult extends PluginFunctionBasic {
54
+ result: {
55
+ code: number;
56
+ message: string;
57
+ data: any;
58
+ };
59
+ }
60
+ export interface Thought {
61
+ step: number;
62
+ thought?: string;
63
+ observation?: string;
64
+ }
65
+ export interface BeforeCalldData extends Thought, PluginFunctionBeforeCall {
66
+ thought: string;
67
+ observation: undefined;
68
+ }
69
+ export interface FunctionCallData extends Thought, PluginFunctionCall {
70
+ thought: string;
71
+ observation: undefined;
72
+ }
73
+ export interface CallResultData extends Thought, PluginFunctionResult {
74
+ thought: undefined;
75
+ observation: undefined;
76
+ }
77
+ export interface AfterCallData extends Thought, PluginFunctionBasic {
78
+ thought: undefined;
79
+ observation: string;
80
+ }
81
+ export interface ActionPayload<T> {
82
+ type: 'BEFORE_CALL' | 'FUNCTION_CALL' | 'RESULT' | 'AFTER_CALL';
83
+ data: T;
84
+ }
@@ -0,0 +1,156 @@
1
+ import { ChatMessageRole, IChatMessage, ISession, ISessionPrompt } from '@glodon-aiot/apis';
2
+ import { Socket } from 'socket.io-client';
3
+ import EventBus from './EventBus';
4
+ import { ActionPayload, PluginFunctionBasic, Thought } from './PayloadTypes';
5
+ import { CVForceApi } from '@glodon-aiot/apis';
6
+ import { ChatHistoryParams, IKnowledge } from '@glodon-aiot/apis/dist/src/cvforce/model';
7
+ export interface QuestionBody {
8
+ content: string;
9
+ stream: boolean;
10
+ requestId?: string;
11
+ fileIds?: string[];
12
+ oldMessageId?: string;
13
+ referenceFirst?: boolean;
14
+ }
15
+ export interface QuestionConfig {
16
+ stream?: boolean;
17
+ referenceFirst?: boolean;
18
+ formatValues?: any;
19
+ oldMessageId?: string;
20
+ }
21
+ type ActionPayloadBasic = ActionPayload<PluginFunctionBasic & Thought>;
22
+ export type SessionEventName = 'init' | 'data:loading' | 'data:loaded' | 'data:updating' | 'data:updated' | 'data:creating' | 'data:created' | 'data:deleting' | 'data:deleted' | 'activated' | 'inactivated' | 'frozen' | 'history:loading' | 'history:loaded' | 'history:moreloading' | 'history:moreloaded' | 'history:add' | 'socket:connect' | 'socket:disconnect' | 'ready' | 'message:updated' | 'message:action' | 'message:content' | 'message:reference' | 'answer:finish' | 'error' | 'destroy';
23
+ export declare enum SessionErrors {
24
+ DataRequestFailed = "data request error",
25
+ SocketConnectionFailed = "socket error",
26
+ IdUndefined = "session id is not defined",
27
+ SendingEmptyContent = "failed at sending empty content",
28
+ Frozen = "session is frozen",
29
+ UserModeError = "failed at setting socket user mode",
30
+ Inactive = "session is inactive"
31
+ }
32
+ export declare const SESSION_ERROR_CAUSE: {
33
+ "session id is not defined": {
34
+ code: number;
35
+ message: string;
36
+ };
37
+ "failed at sending empty content": {
38
+ code: number;
39
+ message: string;
40
+ };
41
+ "session is frozen": {
42
+ code: number;
43
+ message: string;
44
+ };
45
+ };
46
+ export default abstract class Session {
47
+ protected token: string;
48
+ protected lazyload?: boolean | undefined;
49
+ protected _id?: string;
50
+ protected _frozen: boolean;
51
+ protected inactivating: boolean;
52
+ protected _ready: boolean;
53
+ protected event: EventBus;
54
+ _applicationId: string;
55
+ data: ISession | null;
56
+ messages: IChatMessage[];
57
+ protected _loadingMessages: boolean;
58
+ protected _loadingMessagesSize: number;
59
+ cvforceApi: CVForceApi;
60
+ socket: Socket | null;
61
+ protected _promptVariables: ISessionPrompt[];
62
+ protected active: boolean;
63
+ protected _stopAnswer: boolean;
64
+ private _dataLoading;
65
+ private _dataLoaded;
66
+ constructor(token: string, _id?: string, _data?: Partial<ISession>, lazyload?: boolean | undefined);
67
+ get id(): string | undefined;
68
+ get applicationId(): string;
69
+ get ready(): boolean;
70
+ get frozen(): boolean;
71
+ protected set frozen(v: boolean);
72
+ get knowledges(): IKnowledge[];
73
+ setKnowledges(knowledges?: IKnowledge[]): Promise<IKnowledge[] | undefined>;
74
+ get promptVariables(): ISessionPrompt[];
75
+ setPromptVariables(v: ISessionPrompt[]): Promise<boolean>;
76
+ private getService;
77
+ addEventListener(eventName: SessionEventName, callback: any, once?: boolean): void;
78
+ removeEventListener(eventName: SessionEventName, callback: any): void;
79
+ /**
80
+ * 获取对话记录
81
+ * @param params ChatHistoryParams
82
+ * @returns Promise<false|Message[]>
83
+ */
84
+ fetchMessages(params?: ChatHistoryParams): Promise<false | {
85
+ actions: ActionPayloadBasic[][];
86
+ relatedQuesion: string[] | undefined;
87
+ ts?: string | undefined;
88
+ messageId: string;
89
+ content: string;
90
+ role: ChatMessageRole;
91
+ userId?: string | undefined;
92
+ sessionId: string;
93
+ reference: import("@glodon-aiot/apis").IReference[];
94
+ searchReference: import("@glodon-aiot/apis").ISearchRefernce[];
95
+ comment?: import("@glodon-aiot/apis/dist/src/cvforce/model").ICommentParam | undefined;
96
+ knowledges?: IKnowledge[] | undefined;
97
+ isLoading?: boolean | undefined;
98
+ messageTime: string;
99
+ fileId?: string | undefined;
100
+ file?: import("@glodon-aiot/apis/dist/src/cvforce/model").KnowledgeFileMetadata | undefined;
101
+ chatMode?: import("@glodon-aiot/apis").ChatMode | undefined;
102
+ llmModel?: string | undefined;
103
+ isContext?: boolean | undefined;
104
+ index?: number | undefined;
105
+ agentHistoryList?: {
106
+ agentList: string;
107
+ createdAt: string;
108
+ creator: string;
109
+ deletedAt: string;
110
+ id: string;
111
+ updatedAt: string;
112
+ } | undefined;
113
+ finish?: boolean | undefined;
114
+ code?: number | undefined;
115
+ isSensitive?: boolean | undefined;
116
+ message?: string | undefined;
117
+ stream?: boolean | undefined;
118
+ fileIds?: string[] | undefined;
119
+ isReplying?: boolean | undefined;
120
+ files?: import("@glodon-aiot/apis").ChatMessageFile[] | undefined;
121
+ thinkingSecs?: number | undefined;
122
+ thinkingStatus?: "end" | "start" | undefined;
123
+ reasoningContent?: string | undefined;
124
+ }[]>;
125
+ rename(name: string): Promise<boolean>;
126
+ protected pushMessage(message: IChatMessage): Promise<void>;
127
+ reloadSessionInfo(): Promise<void>;
128
+ reload(): Promise<void>;
129
+ delete(): Promise<string | false>;
130
+ activate(): Promise<void>;
131
+ inactivate(immediately?: boolean): boolean;
132
+ abstract prepareConnection(): Promise<boolean>;
133
+ abstract sendQuestion(params: QuestionBody, configs: QuestionConfig): any;
134
+ abstract stopAnswer(): any;
135
+ send(params: {
136
+ text?: string;
137
+ uuid?: string;
138
+ fileIds?: string[];
139
+ }, configs?: QuestionConfig): Promise<false | {
140
+ sessionId: string;
141
+ role: number;
142
+ content: string;
143
+ messageId: string;
144
+ reference: never[];
145
+ searchReference: never[];
146
+ messageTime: string;
147
+ }>;
148
+ protected getRelatedQuesion(message: IChatMessage): Promise<IChatMessage>;
149
+ protected fillMessageReference(message: IChatMessage): Promise<IChatMessage>;
150
+ answerAgain(configs?: QuestionConfig): Promise<void>;
151
+ setTop(top: boolean): Promise<void>;
152
+ suspend(): this | undefined;
153
+ clear(): Promise<boolean>;
154
+ destroy(): string;
155
+ }
156
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ import { EventSourceMessage } from "./parse";
2
+ export declare const EventStreamContentType = "text/event-stream";
3
+ export interface FetchEventSourceInit extends RequestInit {
4
+ /**
5
+ * The request headers. FetchEventSource only supports the Record<string,string> format.
6
+ */
7
+ headers?: Record<string, string>;
8
+ /**
9
+ * Called when a response is received. Use this to validate that the response
10
+ * actually matches what you expect (and throw if it doesn't.) If not provided,
11
+ * will default to a basic validation to ensure the content-type is text/event-stream.
12
+ */
13
+ onopen?: (response: Response) => Promise<void>;
14
+ /**
15
+ * Called when a message is received. NOTE: Unlike the default browser
16
+ * EventSource.onmessage, this callback is called for _all_ events,
17
+ * even ones with a custom `event` field.
18
+ */
19
+ onmessage?: (ev: EventSourceMessage) => void;
20
+ /**
21
+ * Called when a response finishes. If you don't expect the server to kill
22
+ * the connection, you can throw an exception here and retry using onerror.
23
+ */
24
+ onclose?: () => void;
25
+ /**
26
+ * Called when there is any error making the request / processing messages /
27
+ * handling callbacks etc. Use this to control the retry strategy: if the
28
+ * error is fatal, rethrow the error inside the callback to stop the entire
29
+ * operation. Otherwise, you can return an interval (in milliseconds) after
30
+ * which the request will automatically retry (with the last-event-id).
31
+ * If this callback is not specified, or it returns undefined, fetchEventSource
32
+ * will treat every error as retriable and will try again after 1 second.
33
+ */
34
+ onerror?: (err: any) => number | null | undefined | void;
35
+ /**
36
+ * If true, will keep the request open even if the document is hidden.
37
+ * By default, fetchEventSource will close the request and reopen it
38
+ * automatically when the document becomes visible again.
39
+ */
40
+ openWhenHidden?: boolean;
41
+ /** The Fetch function to use. Defaults to window.fetch */
42
+ fetch?: typeof fetch;
43
+ }
44
+ export declare function fetchEventSource(input: RequestInfo, { signal: inputSignal, headers: inputHeaders, onopen: inputOnOpen, onmessage, onclose, onerror, openWhenHidden, fetch: inputFetch, ...rest }: FetchEventSourceInit): Promise<void>;
@@ -0,0 +1 @@
1
+ export * from "./fetch";
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Represents a message sent in an event stream
3
+ * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format
4
+ */
5
+ export interface EventSourceMessage {
6
+ /** The event ID to set the EventSource object's last event ID value. */
7
+ id: string;
8
+ /** A string identifying the type of event described. */
9
+ event: string;
10
+ /** The event data */
11
+ data: string;
12
+ /** The reconnection interval (in milliseconds) to wait before retrying the connection */
13
+ retry?: number;
14
+ }
15
+ /**
16
+ * Converts a ReadableStream into a callback pattern.
17
+ * @param stream The input ReadableStream.
18
+ * @param onChunk A function that will be called on each new byte chunk in the stream.
19
+ * @returns {Promise<void>} A promise that will be resolved when the stream closes.
20
+ */
21
+ export declare function getBytes(stream: ReadableStream<Uint8Array>, onChunk: (arr: Uint8Array) => void): Promise<void>;
22
+ /**
23
+ * Parses arbitary byte chunks into EventSource line buffers.
24
+ * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
25
+ * @param onLine A function that will be called on each new EventSource line.
26
+ * @returns A function that should be called for each incoming byte chunk.
27
+ */
28
+ export declare function getLines(onLine: (line: Uint8Array, fieldLength: number, isWrap: boolean) => void): (arr: Uint8Array) => void;
29
+ /**
30
+ * Parses line buffers into EventSourceMessages.
31
+ * @param onId A function that will be called on each `id` field.
32
+ * @param onRetry A function that will be called on each `retry` field.
33
+ * @param onMessage A function that will be called on each message.
34
+ * @returns A function that should be called for each incoming line buffer.
35
+ */
36
+ export declare function getMessages(onId: (id: string) => void, onRetry: (retry: number) => void, onMessage?: (msg: EventSourceMessage) => void): (line: Uint8Array, fieldLength: number, isWrap: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import { CVForceApi } from '@glodon-aiot/apis';
2
+ export declare function getCVForceService(apiBase: string, token: string, errorHandler: (status: number, message: string) => void): CVForceApi;
@@ -0,0 +1,5 @@
1
+ export type { AgentPluginRegistor, AgentPluginMap } from './Config';
2
+ export { configure, configuration } from './Config';
3
+ export { default as BotClient } from './BotClient';
4
+ export { default as Session } from './Session';
5
+ export { default as AgentPlugin } from './AgentPlugin';
@@ -0,0 +1,4 @@
1
+ export declare const parseJWT: (token: string) => any;
2
+ export declare const isExpired: (token: string) => boolean;
3
+ export declare const removeNewlines: (str: string) => string;
4
+ export declare const removeLeadingAndTrailingBackslashes: (str: string) => string;
@@ -0,0 +1,20 @@
1
+ var c = Object.defineProperty;
2
+ var a = (e, t, i) => t in e ? c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
+ var s = (e, t, i) => (a(e, typeof t != "symbol" ? t + "" : t, i), i);
4
+ class d {
5
+ constructor(t, i = {}, o) {
6
+ s(this, "code");
7
+ s(this, "description", "");
8
+ s(this, "loaded", !1);
9
+ s(this, "functions", {});
10
+ this.code = t, i && (this.functions = i);
11
+ }
12
+ fetchData() {
13
+ this.description = "描述", this.loaded = !0;
14
+ }
15
+ checkFunctions() {
16
+ }
17
+ }
18
+ export {
19
+ d as default
20
+ };