@glodon-aiot/agent-cli-ui 3.3.2-beta.1 → 3.3.2-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/es/AgentClientUI.mjs +34 -32
  2. package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +161 -147
  3. package/dist/es/Dialog/AgentChat/index.mjs +41 -39
  4. package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +354 -0
  5. package/dist/es/ReactTextGenerationUI/components/fetchEventSource/fetch.mjs +112 -0
  6. package/dist/es/ReactTextGenerationUI/components/fetchEventSource/parse.mjs +97 -0
  7. package/dist/es/ReactTextGenerationUI/index.mjs +90 -0
  8. package/dist/es/index.mjs +522 -251
  9. package/dist/es/node_modules/moment/dist/moment.mjs +2301 -0
  10. package/dist/es/packages/agent-cli-ui/package.json.mjs +162 -0
  11. package/dist/es/packages/react-components/dist/es/components/Markdown/ATag/index.mjs +27 -25
  12. package/dist/es/packages/react-components/dist/es/components/Markdown/Image/index.mjs +29 -27
  13. package/dist/es/packages/react-components/dist/es/components/Markdown/index.mjs +58 -48
  14. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  15. package/dist/es/src/style10.css +1 -1
  16. package/dist/es/src/style11.css +1 -1
  17. package/dist/es/src/style12.css +1 -1
  18. package/dist/es/src/style13.css +1 -1
  19. package/dist/es/src/style14.css +1 -1
  20. package/dist/es/src/style15.css +1 -1
  21. package/dist/es/src/style16.css +1 -1
  22. package/dist/es/src/style17.css +1 -1
  23. package/dist/es/src/style18.css +1 -1
  24. package/dist/es/src/style19.css +1 -1
  25. package/dist/es/src/style2.css +1 -1
  26. package/dist/es/src/style20.css +1 -1
  27. package/dist/es/src/style21.css +1 -1
  28. package/dist/es/src/style22.css +1 -1
  29. package/dist/es/src/style24.css +1 -1
  30. package/dist/es/src/style25.css +1 -1
  31. package/dist/es/src/style26.css +1 -1
  32. package/dist/es/src/style27.css +1 -1
  33. package/dist/es/src/style28.css +1 -1
  34. package/dist/es/src/style29.css +1 -1
  35. package/dist/es/src/style3.css +1 -1
  36. package/dist/es/src/style30.css +1 -0
  37. package/dist/es/src/style31.css +1 -0
  38. package/dist/es/src/style4.css +1 -1
  39. package/dist/es/src/style5.css +1 -1
  40. package/dist/es/src/style6.css +1 -1
  41. package/dist/es/src/style7.css +1 -1
  42. package/dist/es/src/style8.css +1 -1
  43. package/dist/es/src/style9.css +1 -1
  44. package/dist/lib/index.css +1 -1
  45. package/dist/lib/index.js +69 -58
  46. package/dist/src/Dialog/AgentChat/HistoryItem/index.d.ts +2 -0
  47. package/dist/src/ReactTextGenerationUI/components/TextSiders/index.d.ts +21 -0
  48. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/fetch.d.ts +44 -0
  49. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/index.d.ts +1 -0
  50. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/parse.d.ts +36 -0
  51. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/fetch.d.ts +44 -0
  52. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/index.d.ts +1 -0
  53. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/parse.d.ts +36 -0
  54. package/dist/src/ReactTextGenerationUI/index.d.ts +4 -0
  55. package/dist/src/index.d.ts +5 -1
  56. package/dist/src/types.d.ts +6 -2
  57. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { IHistory, IApplication } from '@glodon-aiot/apis';
3
3
  import { Session } from '@glodon-aiot/bot-client-sdk';
4
+ import { MarkdownProps } from '@glodon-aiot/react-components/dist/src/components/Markdown';
4
5
  interface HistoryItemProps {
5
6
  application: IApplication;
6
7
  currentSession?: Session;
@@ -12,6 +13,7 @@ interface HistoryItemProps {
12
13
  isLoading?: boolean;
13
14
  docViewerUrl?: string;
14
15
  actions?: boolean;
16
+ markdown?: Partial<MarkdownProps>;
15
17
  }
16
18
  export declare const isResultExec: (result?: string) => boolean;
17
19
  declare const HistoryItem: React.FC<HistoryItemProps>;
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ import { ChatMode, IApplication, KnowledgeFileMetadata } from '@glodon-aiot/apis';
3
+ export interface IChatParam {
4
+ content: string;
5
+ knowledgeId?: string;
6
+ knowledges?: string[];
7
+ enableChatHistory?: boolean;
8
+ saveHistory?: 'True' | 'False';
9
+ saveTokens?: boolean;
10
+ chatMode?: ChatMode;
11
+ fileId?: string;
12
+ file?: Partial<KnowledgeFileMetadata>;
13
+ promptVariables?: object;
14
+ resourceToken?: string;
15
+ }
16
+ interface TextSiderProps {
17
+ application: IApplication;
18
+ sessionId?: string;
19
+ }
20
+ declare const TextSiders: React.FC<TextSiderProps>;
21
+ export default TextSiders;
@@ -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,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,4 @@
1
+ import { FC } from 'react';
2
+ import { AgentClientProps } from '../types';
3
+ declare const ReactBotUI: FC<AgentClientProps>;
4
+ export default ReactBotUI;
@@ -1,5 +1,6 @@
1
1
  import { AgentClientUIConfig, AgentClientMode, InitalData, Env } from './types';
2
2
  import { BotClientApi, ISession } from '@glodon-aiot/apis';
3
+ import { BotClient } from '@glodon-aiot/bot-client-sdk';
3
4
  export default class AgentClientUI {
4
5
  private _token;
5
6
  private _activeSession;
@@ -10,6 +11,7 @@ export default class AgentClientUI {
10
11
  readonly apiUrl: string;
11
12
  readonly docViewerUrl: string;
12
13
  readonly env: Env;
14
+ readonly stream: boolean | undefined;
13
15
  service: BotClientApi;
14
16
  private rId;
15
17
  _mode: AgentClientMode;
@@ -18,6 +20,7 @@ export default class AgentClientUI {
18
20
  token?: (error: Error) => void;
19
21
  };
20
22
  wrapper: HTMLElement;
23
+ botClient: BotClient | null;
21
24
  constructor(config: InitalData);
22
25
  get token(): string;
23
26
  set token(v: string);
@@ -31,6 +34,7 @@ export default class AgentClientUI {
31
34
  input(message: string): void;
32
35
  disable(): void;
33
36
  enable(): void;
34
- render(): void;
37
+ createBotClientSDK(): Promise<BotClient>;
38
+ render(): Promise<void>;
35
39
  destroy(callback?: VoidFunction): void;
36
40
  }
@@ -1,7 +1,8 @@
1
1
  import { BotClient, AgentPluginMap, Session, MCPConfig } from '@glodon-aiot/bot-client-sdk';
2
- import { BotClientApi, ICommentParam, ISession, IChatMessage, IHistory, IKnowledge, ISessionPrompt, ISearchReference } from '@glodon-aiot/apis';
2
+ import { BotClientApi, ICommentParam, ISession, IChatMessage, IHistory, IKnowledge, ISessionPrompt, ISearchReference, IApplication } from '@glodon-aiot/apis';
3
3
  import { Theme } from 'antd/es/config-provider/context';
4
4
  import { CSSProperties } from 'react';
5
+ import { MarkdownProps } from '@glodon-aiot/react-components/dist/src/components/Markdown';
5
6
  export type Env = 'dev' | 'test' | 'prod' | 'local';
6
7
  export type AgentClientMode = 'float' | 'inlay';
7
8
  export declare enum ApiUrl {
@@ -87,6 +88,7 @@ export interface AgentFeaturesConfig {
87
88
  visible?: boolean;
88
89
  default?: ISessionPrompt[];
89
90
  };
91
+ markdown?: Partial<MarkdownProps>;
90
92
  }
91
93
  type CommentListener = (payload: {
92
94
  applicationId: string;
@@ -147,7 +149,6 @@ export interface AgentClientDefaultProps {
147
149
  service?: BotClientApi;
148
150
  popupContainer?: React.RefObject<HTMLDivElement>;
149
151
  token?: string;
150
- agentClient?: BotClient;
151
152
  debug?: boolean;
152
153
  plugins?: AgentPluginMap;
153
154
  mcp?: MCPConfig;
@@ -180,6 +181,8 @@ export interface AgentClientDefaultProps {
180
181
  visible?: boolean;
181
182
  }[];
182
183
  };
184
+ stream?: boolean;
185
+ agentClient?: BotClient;
183
186
  }
184
187
  interface DataEventListeners {
185
188
  comment: CommentListener;
@@ -224,5 +227,6 @@ export interface AgentClientProps extends AgentClientDefaultProps {
224
227
  apiUrl?: string;
225
228
  sessionId?: string;
226
229
  disabled?: boolean;
230
+ application: IApplication;
227
231
  }
228
232
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glodon-aiot/agent-cli-ui",
3
- "version": "3.3.2-beta.1",
3
+ "version": "3.3.2-beta.11",
4
4
  "module": "./dist/es/index.mjs",
5
5
  "main": "./dist/lib/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@ant-design/icons": "^5.3.4",
37
- "@glodon-aiot/apis": "^3.3.2-beta.1",
38
- "@glodon-aiot/bot-client-sdk": "^3.3.2-beta.1",
37
+ "@glodon-aiot/apis": "^3.3.2-beta.11",
38
+ "@glodon-aiot/bot-client-sdk": "^3.3.2-beta.11",
39
39
  "@matejmazur/react-mathjax": "^0.1.10",
40
40
  "@react-pdf-viewer/core": "^3.12.0",
41
41
  "@react-pdf-viewer/default-layout": "^3.12.0",