@lcap/wave-sandbox-sdk 0.0.2 → 0.0.3

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/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export { FileSystemModule } from './modules/file-system.js';
6
6
  export { PortModule } from './modules/port.js';
7
7
  export { ProjectModule } from './modules/project.js';
8
8
  export { AgentModule } from './modules/agent.js';
9
- export type { Attachment, SendMessageOptions, ProcessQueueItem, MessageQueueChangedEvent, MessageSendEvent, MessageRunningEvent, MessageFinishedEvent, InitializingEvent, InitializedEvent, MessageBlockAddedEvent, MessageBlockUpdatedEvent, MessageToolBlockUpdatedEvent, MessageSubagentBlockAddEvent, MessageSubagentBlockStatusUpdatedEvent, MessageSubagentBlockContentUpdatedEvent, MessageSubagentToolBlockUpdatedEvent, MessageErrorBlockAddedEvent, MessageCommandOutputMessageAddedEvent, MessageCommandOutputMessageUpdatedEvent, MessageCommandOutputMessageCompletedEvent, McpServersChangeEvent, DocumentParseStartEvent, DocumentParseCompleteEvent, DocumentParseErrorEvent, AgentEventMap, AgentEventName, } from './modules/agent.js';
9
+ export type { Attachment, SendMessageOptions, ProcessQueueItem, MessageQueueChangedEvent, MessageSendEvent, MessageRunningEvent, MessageFinishedEvent, InitializingEvent, InitializedEvent, MessageBlockAddedEvent, MessageBlockUpdatedEvent, MessageToolBlockUpdatedEvent, MessageSubagentBlockAddEvent, MessageSubagentBlockStatusUpdatedEvent, MessageSubagentBlockContentUpdatedEvent, MessageSubagentToolBlockUpdatedEvent, MessageErrorBlockAddedEvent, MessageCommandOutputMessageAddedEvent, MessageCommandOutputMessageUpdatedEvent, MessageCommandOutputMessageCompletedEvent, McpServersChangeEvent, DocumentParseStartEvent, DocumentParseCompleteEvent, DocumentParseErrorEvent, AskUserQuestionEvent, ClientCallBackOptions, AgentEventMap, AgentEventName, } from './modules/agent.js';
@@ -242,6 +242,32 @@ export interface DocumentParseErrorEvent {
242
242
  mimeType: string;
243
243
  error: string;
244
244
  }
245
+ export interface AskUserQuestionOption {
246
+ label: string;
247
+ description?: string;
248
+ isRecommended?: boolean;
249
+ }
250
+ export interface AskUserQuestion {
251
+ question: string;
252
+ header: string;
253
+ options: AskUserQuestionOption[];
254
+ multiSelect?: boolean;
255
+ }
256
+ /**
257
+ * 询问用户问题事件数据
258
+ */
259
+ export interface AskUserQuestionEvent {
260
+ questionId: string;
261
+ questions?: AskUserQuestion[];
262
+ }
263
+ /**
264
+ * 客户端回调选项
265
+ */
266
+ export interface ClientCallBackOptions<T> {
267
+ event: string;
268
+ id: string;
269
+ data: T;
270
+ }
245
271
  /**
246
272
  * Agent 事件名称映射
247
273
  */
@@ -267,6 +293,7 @@ export type AgentEventMap = {
267
293
  'agent:document-parse-start': DocumentParseStartEvent;
268
294
  'agent:document-parse-complete': DocumentParseCompleteEvent;
269
295
  'agent:document-parse-error': DocumentParseErrorEvent;
296
+ 'agent:ask-user-question': AskUserQuestionEvent;
270
297
  };
271
298
  /**
272
299
  * Agent 事件名称类型
@@ -438,6 +465,17 @@ export declare class AgentModule {
438
465
  * @returns 取消监听的函数
439
466
  */
440
467
  onDocumentParseError(callback: (event: DocumentParseErrorEvent) => void): () => void;
468
+ /**
469
+ * 监听询问用户问题事件
470
+ * @param callback 回调函数
471
+ * @returns 取消监听的函数
472
+ */
473
+ onAskUserQuestion(callback: (event: AskUserQuestionEvent) => void): () => void;
474
+ /**
475
+ * 发送客户端回调
476
+ * @param options 客户端回调选项
477
+ */
478
+ clientCallBack<T = unknown>(options: ClientCallBackOptions<T>): Promise<void>;
441
479
  /**
442
480
  * 通用事件监听方法,用于监听自定义事件
443
481
  * @param eventName 事件名称(必须以 'agent:' 开头)
@@ -236,6 +236,21 @@ export class AgentModule {
236
236
  onDocumentParseError(callback) {
237
237
  return onSocketEvent(this.socket, 'agent:document-parse-error', callback);
238
238
  }
239
+ /**
240
+ * 监听询问用户问题事件
241
+ * @param callback 回调函数
242
+ * @returns 取消监听的函数
243
+ */
244
+ onAskUserQuestion(callback) {
245
+ return onSocketEvent(this.socket, 'agent:ask-user-question', callback);
246
+ }
247
+ /**
248
+ * 发送客户端回调
249
+ * @param options 客户端回调选项
250
+ */
251
+ async clientCallBack(options) {
252
+ return createSocketHandler(this.socket, 'agent:clientCallBack', () => options);
253
+ }
239
254
  /**
240
255
  * 通用事件监听方法,用于监听自定义事件
241
256
  * @param eventName 事件名称(必须以 'agent:' 开头)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lcap/wave-sandbox-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "SDK for Wave Sandbox Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,15 +10,6 @@
10
10
  "src",
11
11
  "README.md"
12
12
  ],
13
- "scripts": {
14
- "build": "rimraf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
15
- "type-check": "tsc --noEmit",
16
- "dev": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
17
- "test": "vitest run",
18
- "lint": "eslint --cache",
19
- "format": "prettier --write .",
20
- "prepublishOnly": "pnpm run build"
21
- },
22
13
  "dependencies": {
23
14
  "socket.io-client": "^4.8.3"
24
15
  },
@@ -31,5 +22,13 @@
31
22
  "engines": {
32
23
  "node": ">=16.0.0"
33
24
  },
34
- "license": "MIT"
35
- }
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "build": "rimraf dist && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
28
+ "type-check": "tsc --noEmit",
29
+ "dev": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
30
+ "test": "vitest run",
31
+ "lint": "eslint --cache",
32
+ "format": "prettier --write ."
33
+ }
34
+ }
package/src/index.ts CHANGED
@@ -55,6 +55,8 @@ export type {
55
55
  DocumentParseStartEvent,
56
56
  DocumentParseCompleteEvent,
57
57
  DocumentParseErrorEvent,
58
+ AskUserQuestionEvent,
59
+ ClientCallBackOptions,
58
60
  AgentEventMap,
59
61
  AgentEventName,
60
62
  } from './modules/agent.js';
@@ -276,6 +276,36 @@ export interface DocumentParseErrorEvent {
276
276
  error: string;
277
277
  }
278
278
 
279
+ export interface AskUserQuestionOption {
280
+ label: string;
281
+ description?: string;
282
+ isRecommended?: boolean;
283
+ }
284
+
285
+ export interface AskUserQuestion {
286
+ question: string;
287
+ header: string;
288
+ options: AskUserQuestionOption[];
289
+ multiSelect?: boolean;
290
+ }
291
+
292
+ /**
293
+ * 询问用户问题事件数据
294
+ */
295
+ export interface AskUserQuestionEvent {
296
+ questionId: string;
297
+ questions?: AskUserQuestion[];
298
+ }
299
+
300
+ /**
301
+ * 客户端回调选项
302
+ */
303
+ export interface ClientCallBackOptions<T> {
304
+ event: string;
305
+ id: string;
306
+ data: T;
307
+ }
308
+
279
309
  /**
280
310
  * Agent 事件名称映射
281
311
  */
@@ -301,6 +331,7 @@ export type AgentEventMap = {
301
331
  'agent:document-parse-start': DocumentParseStartEvent;
302
332
  'agent:document-parse-complete': DocumentParseCompleteEvent;
303
333
  'agent:document-parse-error': DocumentParseErrorEvent;
334
+ 'agent:ask-user-question': AskUserQuestionEvent;
304
335
  };
305
336
 
306
337
  /**
@@ -609,6 +640,23 @@ export class AgentModule {
609
640
  return onSocketEvent<DocumentParseErrorEvent>(this.socket, 'agent:document-parse-error', callback);
610
641
  }
611
642
 
643
+ /**
644
+ * 监听询问用户问题事件
645
+ * @param callback 回调函数
646
+ * @returns 取消监听的函数
647
+ */
648
+ onAskUserQuestion(callback: (event: AskUserQuestionEvent) => void): () => void {
649
+ return onSocketEvent<AskUserQuestionEvent>(this.socket, 'agent:ask-user-question', callback);
650
+ }
651
+
652
+ /**
653
+ * 发送客户端回调
654
+ * @param options 客户端回调选项
655
+ */
656
+ async clientCallBack<T = unknown>(options: ClientCallBackOptions<T>): Promise<void> {
657
+ return createSocketHandler<ClientCallBackOptions<T>, void>(this.socket, 'agent:clientCallBack', () => options);
658
+ }
659
+
612
660
  /**
613
661
  * 通用事件监听方法,用于监听自定义事件
614
662
  * @param eventName 事件名称(必须以 'agent:' 开头)