@ray-js/t-agent 0.1.1 → 0.2.0-beta-1

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.
@@ -2,6 +2,7 @@ import { Hookable } from 'hookable';
2
2
  import { AbortSignalObject, AddHookCallback, ChatAgentHooks, ChatAgentHooksWithOrder, ChatAgentPlugin, ChatMessageObject, ComposeHandler, InputBlock, StreamResponseInstance } from './types';
3
3
  import ChatSession from './ChatSession';
4
4
  import ChatMessage from './ChatMessage';
5
+ export declare const logger: import("./Logger").default;
5
6
  type AddHook<T extends keyof ChatAgentHooks> = AddHookCallback<ChatAgentHooks, T>;
6
7
  /**
7
8
  * ChatAgent
@@ -14,7 +14,7 @@ import ChatSession from './ChatSession';
14
14
  import ChatMessage from './ChatMessage';
15
15
  import { getLogger } from './Logger';
16
16
  import { isAbortError } from './utils';
17
- const logger = getLogger('TAgent/ChatAgent');
17
+ export const logger = getLogger('TAgent/ChatAgent');
18
18
  /**
19
19
  * ChatAgent
20
20
  *
@@ -89,6 +89,21 @@ export default class ChatBubbleTile extends ChatTile {
89
89
  src: block.video_url.url,
90
90
  thumbUrl: block.video_url.thumb_url
91
91
  });
92
+ } else if (block.type === 'image_path') {
93
+ this.message.addTile('file', {
94
+ mimeType: 'image',
95
+ path: block.image_path.path
96
+ });
97
+ } else if (block.type === 'video_path') {
98
+ this.message.addTile('file', {
99
+ mimeType: 'video',
100
+ path: block.video_path.path
101
+ });
102
+ } else if (block.type === 'file_path') {
103
+ this.message.addTile('file', {
104
+ mimeType: block.file_path.mime_pype || 'application/octet-stream',
105
+ path: block.file_path.path
106
+ });
92
107
  }
93
108
  }
94
109
  return this;
@@ -2,6 +2,7 @@ import { ChatMessageObject, ChatMessageObjectMeta, ChatMessageStatus } from './t
2
2
  import ChatTile from './ChatTile';
3
3
  import ChatBubbleTile from './ChatBubbleTile';
4
4
  import ChatAgent from './ChatAgent';
5
+ export declare const logger: import("./Logger").default;
5
6
  export default class ChatMessage implements ChatMessageObject {
6
7
  private agent;
7
8
  id: string;
@@ -9,6 +9,8 @@ import { ChatMessageStatus } from './types';
9
9
  import ChatTile from './ChatTile';
10
10
  import ChatBubbleTile from './ChatBubbleTile';
11
11
  import { deepCloneToPlainObject, deepMerge, generateId } from './utils';
12
+ import { getLogger } from './Logger';
13
+ export const logger = getLogger('TAgent/ChatAgent');
12
14
  export default class ChatMessage {
13
15
  get isShow() {
14
16
  return this._isShow;
@@ -105,6 +107,7 @@ export default class ChatMessage {
105
107
  await this.agent.hooks.callHook('onMessagePersist:before', payload, this);
106
108
  await this.agent.hooks.callHook('onMessagePersist', payload, this);
107
109
  await this.agent.hooks.callHook('onMessagePersist:after', payload, this);
110
+ logger.debug('%onMessagePersist', 'background: gray; color: white', payload, this);
108
111
  });
109
112
  }
110
113
  setTilesLocked(locked) {
@@ -3,6 +3,9 @@ import type ChatMessage from './ChatMessage';
3
3
  import type ChatAgent from './ChatAgent';
4
4
  import type { Hookable } from 'hookable';
5
5
  import type { EventCallback, EventOptions } from './Emitter';
6
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = T & {
7
+ [K in Keys]: Required<Pick<T, K>> & Partial<Omit<T, K>>;
8
+ }[Keys];
6
9
  export interface BubbleTileData {
7
10
  status: BubbleTileStatus;
8
11
  info?: string;
@@ -11,6 +14,12 @@ export interface TextTileData {
11
14
  text: string;
12
15
  markdown: boolean;
13
16
  }
17
+ export type FileTileData = RequireAtLeastOne<{
18
+ mimeType: string;
19
+ name?: string;
20
+ path?: string;
21
+ src?: string;
22
+ }, 'path' | 'src'>;
14
23
  export interface ImageTileData {
15
24
  src: string;
16
25
  }
@@ -178,3 +187,4 @@ export interface ComposeHandler {
178
187
  attachmentCompose?: (message: ChatMessage, attachment: AttachmentPart) => Promise<ChatMessage[]>;
179
188
  errorCompose?: (message: ChatMessage, text: string, error: any) => Promise<string>;
180
189
  }
190
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent",
3
- "version": "0.1.1",
3
+ "version": "0.2.0-beta-1",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -26,5 +26,5 @@
26
26
  "build": "ray build --type=component --output dist",
27
27
  "clean": "rimraf ./dist"
28
28
  },
29
- "gitHead": "e97f7ef72e4d5d366b5bf923525ca2e064248ab5"
29
+ "gitHead": "98229f8a9cb090a6fa0d9b47fa70b1f44ec2b34a"
30
30
  }