@ray-js/t-agent-plugin-aistream 0.2.5 → 0.2.6-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.
@@ -614,7 +614,9 @@ export declare enum ConnectClientType {
614
614
  /** 作为设备代理 */
615
615
  DEVICE = 1,
616
616
  /** 作为 App */
617
- APP = 2
617
+ APP = 2,
618
+ /** 作为开发者(行业 APP) */
619
+ DEVELOPER = 3
618
620
  }
619
621
  export declare enum EventType {
620
622
  /** 事件开始 */
@@ -1101,13 +1103,13 @@ export type ConnectParams = {
1101
1103
  */
1102
1104
  export type QueryAgentTokenParams = {
1103
1105
  /** Owner ID: HomeID 或 设备id */
1104
- ownerId: string;
1106
+ ownerId?: string;
1105
1107
  /** 智能解决方案 code */
1106
1108
  solutionCode: string;
1107
1109
  /** 业务接口 */
1108
1110
  api: string;
1109
1111
  /** 接口版本 */
1110
- apiVersion: string;
1112
+ apiVersion?: string;
1111
1113
  /** 业务额外参数 */
1112
1114
  extParams: any;
1113
1115
  success?: (params: {
@@ -90,6 +90,7 @@ export let SessionState = /*#__PURE__*/function (SessionState) {
90
90
  export let ConnectClientType = /*#__PURE__*/function (ConnectClientType) {
91
91
  ConnectClientType[ConnectClientType["DEVICE"] = 1] = "DEVICE";
92
92
  ConnectClientType[ConnectClientType["APP"] = 2] = "APP";
93
+ ConnectClientType[ConnectClientType["DEVELOPER"] = 3] = "DEVELOPER";
93
94
  return ConnectClientType;
94
95
  }({});
95
96
  export let EventType = /*#__PURE__*/function (EventType) {
@@ -37,7 +37,7 @@ interface AIStreamSessionOptions {
37
37
  /** 业务接口 */
38
38
  api: string;
39
39
  /** 接口版本 */
40
- apiVersion: string;
40
+ apiVersion?: string;
41
41
  /** 业务额外参数 */
42
42
  extParams?: any;
43
43
  userData?: Attribute[];
@@ -221,7 +221,10 @@ export class AIStreamSession {
221
221
  throw e;
222
222
  }
223
223
  let ownerId = this.options.ownerId;
224
- if (!ownerId) {
224
+ if (this.connection.options.clientType === ConnectClientType.DEVELOPER) {
225
+ ownerId = undefined;
226
+ this.options.ownerId = undefined;
227
+ } else if (!ownerId) {
225
228
  if (this.connection.options.clientType === ConnectClientType.APP) {
226
229
  try {
227
230
  const {
@@ -3,7 +3,7 @@ import { TTTAction } from './utils';
3
3
  import { ConnectClientType, ReceivedTextSkillPacketBody } from './AIStreamTypes';
4
4
  import { ChatHistoryStore, StoredMessageObject } from './ChatHistoryStore';
5
5
  export interface AIStreamOptions {
6
- /** client 类型: 1-作为设备代理, 2-作为 App */
6
+ /** client 类型: 1-作为设备代理, 2-作为 App,3-作为开发者(行业 App) */
7
7
  clientType?: ConnectClientType;
8
8
  /** 代理的设备ID, clientType == 1 时必传 */
9
9
  deviceId?: string;
@@ -12,7 +12,8 @@ export interface AIStreamOptions {
12
12
  /** 获取 agent token 的参数 */
13
13
  tokenOptions?: {
14
14
  api: string;
15
- version: string;
15
+ /** 如果是 clientType == 3,则是 highway 接口,可以不传 */
16
+ version?: string;
16
17
  extParams?: Record<string, any>;
17
18
  };
18
19
  /** 历史消息数量,默认1000,为0的话,则已分页的方式取全部数据 */
@@ -47,7 +47,11 @@ export function withAIStream() {
47
47
  if (!agentId) {
48
48
  throw new Error('agentId is required');
49
49
  }
50
- if (!tokenOptions.api || !tokenOptions.version) {
50
+ if (clientType === ConnectClientType.DEVELOPER) {
51
+ if (!tokenOptions.api) {
52
+ throw new Error('tokenOptions.api is required');
53
+ }
54
+ } else if (!tokenOptions.api || !tokenOptions.version) {
51
55
  throw new Error('tokenOptions.api and tokenOptions.version are required');
52
56
  }
53
57
  if (clientType === ConnectClientType.DEVICE && !deviceId) {
@@ -57,6 +61,9 @@ export function withAIStream() {
57
61
  throw new Error('deviceId is not allowed when clientType is app');
58
62
  }
59
63
  let homeId = options.homeId;
64
+ if (clientType === ConnectClientType.DEVELOPER) {
65
+ homeId = 1;
66
+ }
60
67
  if (!homeId) {
61
68
  const info = await getCurrentHomeInfo();
62
69
  homeId = +info.homeId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-plugin-aistream",
3
- "version": "0.2.5",
3
+ "version": "0.2.6-beta-1",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@types/url-parse": "^1.4.11"
37
37
  },
38
- "gitHead": "5c2ee8c15695fa858e00d9f58147487479ca0121"
38
+ "gitHead": "7c5c58dfe2f598e502f3a9a09ed2439660336ce3"
39
39
  }