@robota-sdk/agent-transport-ws 3.0.0-beta.63 → 3.0.0-beta.76

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.
@@ -1,160 +1,151 @@
1
- import { IToolState, IExecutionResult, ICommandResult, InteractiveSession, IExecutionWorkspaceSnapshot, TBackgroundTaskEvent, TBackgroundJobGroupEvent, IBackgroundTaskState, IBackgroundJobGroupState, IBackgroundTaskLogPage, IBackgroundTaskListFilter, IBackgroundTaskInput, IBackgroundTaskLogCursor } from '@robota-sdk/agent-sdk';
2
- export { IExecutionWorkspaceEntry, IExecutionWorkspaceSnapshot, TExecutionAttention, TExecutionWorkspaceStatus } from '@robota-sdk/agent-sdk';
3
- import { ITransportAdapter, IConfigurableTransport } from '@robota-sdk/agent-interface-transport';
4
- import { ISession, TUniversalValue } from '@robota-sdk/agent-core';
1
+ import { IBackgroundTaskInput, IBackgroundTaskListFilter, IBackgroundTaskLogCursor, IBackgroundTaskLogPage, IBackgroundTaskState, IExecutionWorkspaceEntry, IExecutionWorkspaceSnapshot, InteractiveSession, TBackgroundTaskEvent, TExecutionAttention, TExecutionWorkspaceStatus } from "@robota-sdk/agent-framework";
2
+ import { IBackgroundJobGroupState, ICommandResult, IConfigurableTransport, IExecutionResult, IExecutionWorkspaceSnapshot as IExecutionWorkspaceSnapshot$1, IInteractiveSession, IToolState, ITransportAdapter, TBackgroundJobGroupEvent } from "@robota-sdk/agent-interface-transport";
3
+ import { TUniversalValue } from "@robota-sdk/agent-core";
5
4
 
5
+ //#region src/ws-protocol.d.ts
6
6
  type TBackgroundControlAction = 'cancel' | 'close' | 'send';
7
7
  /** Inbound message from client to server. */
8
8
  type TClientMessage = {
9
- type: 'submit';
10
- prompt: string;
9
+ type: 'submit';
10
+ prompt: string;
11
11
  } | {
12
- type: 'command';
13
- name: string;
14
- args?: string;
12
+ type: 'command';
13
+ name: string;
14
+ args?: string;
15
15
  } | {
16
- type: 'abort';
16
+ type: 'abort';
17
17
  } | {
18
- type: 'cancel-queue';
18
+ type: 'cancel-queue';
19
19
  } | {
20
- type: 'get-messages';
20
+ type: 'get-messages';
21
21
  } | {
22
- type: 'get-context';
22
+ type: 'get-context';
23
23
  } | {
24
- type: 'get-executing';
24
+ type: 'get-executing';
25
25
  } | {
26
- type: 'get-pending';
26
+ type: 'get-pending';
27
27
  } | {
28
- type: 'get-execution-workspace';
28
+ type: 'get-execution-workspace';
29
29
  } | {
30
- type: 'get-background-tasks';
31
- filter?: IBackgroundTaskListFilter;
30
+ type: 'get-background-tasks';
31
+ filter?: IBackgroundTaskListFilter;
32
32
  } | {
33
- type: 'get-background-task';
34
- taskId: string;
33
+ type: 'get-background-task';
34
+ taskId: string;
35
35
  } | {
36
- type: 'get-background-job-groups';
36
+ type: 'get-background-job-groups';
37
37
  } | {
38
- type: 'get-background-job-group';
39
- groupId: string;
38
+ type: 'get-background-job-group';
39
+ groupId: string;
40
40
  } | {
41
- type: 'wait-background-job-group';
42
- groupId: string;
41
+ type: 'wait-background-job-group';
42
+ groupId: string;
43
43
  } | {
44
- type: 'cancel-background-task';
45
- taskId: string;
46
- reason?: string;
44
+ type: 'cancel-background-task';
45
+ taskId: string;
46
+ reason?: string;
47
47
  } | {
48
- type: 'close-background-task';
49
- taskId: string;
48
+ type: 'close-background-task';
49
+ taskId: string;
50
50
  } | {
51
- type: 'send-background-task';
52
- taskId: string;
53
- input: IBackgroundTaskInput;
51
+ type: 'send-background-task';
52
+ taskId: string;
53
+ input: IBackgroundTaskInput;
54
54
  } | {
55
- type: 'read-background-task-log';
56
- taskId: string;
57
- cursor?: IBackgroundTaskLogCursor;
55
+ type: 'read-background-task-log';
56
+ taskId: string;
57
+ cursor?: IBackgroundTaskLogCursor;
58
58
  };
59
59
  /** Outbound message from server to client. */
60
60
  type TServerMessage = {
61
- type: 'text_delta';
62
- delta: string;
61
+ type: 'text_delta';
62
+ delta: string;
63
63
  } | {
64
- type: 'user_message';
65
- content: string;
64
+ type: 'user_message';
65
+ content: string;
66
66
  } | {
67
- type: 'tool_start';
68
- state: IToolState;
67
+ type: 'tool_start';
68
+ state: IToolState;
69
69
  } | {
70
- type: 'tool_end';
71
- state: IToolState;
70
+ type: 'tool_end';
71
+ state: IToolState;
72
72
  } | {
73
- type: 'thinking';
74
- isThinking: boolean;
73
+ type: 'thinking';
74
+ isThinking: boolean;
75
75
  } | {
76
- type: 'complete';
77
- result: IExecutionResult;
76
+ type: 'complete';
77
+ result: IExecutionResult;
78
78
  } | {
79
- type: 'interrupted';
80
- result: IExecutionResult;
79
+ type: 'interrupted';
80
+ result: IExecutionResult;
81
81
  } | {
82
- type: 'error';
83
- message: string;
82
+ type: 'error';
83
+ message: string;
84
84
  } | {
85
- type: 'command_result';
86
- name: string;
87
- message: string;
88
- success: boolean;
89
- data?: ICommandResult['data'];
85
+ type: 'command_result';
86
+ name: string;
87
+ message: string;
88
+ success: boolean;
89
+ data?: ICommandResult['data'];
90
90
  } | {
91
- type: 'messages';
92
- messages: ReturnType<InteractiveSession['getMessages']>;
91
+ type: 'messages';
92
+ messages: ReturnType<InteractiveSession['getMessages']>;
93
93
  } | {
94
- type: 'context';
95
- state: ReturnType<InteractiveSession['getContextState']>;
94
+ type: 'context';
95
+ state: ReturnType<InteractiveSession['getContextState']>;
96
96
  } | {
97
- type: 'executing';
98
- executing: boolean;
97
+ type: 'executing';
98
+ executing: boolean;
99
99
  } | {
100
- type: 'pending';
101
- pending: string | null;
100
+ type: 'pending';
101
+ pending: string | null;
102
102
  } | {
103
- type: 'execution_workspace_event';
104
- snapshot: IExecutionWorkspaceSnapshot;
103
+ type: 'execution_workspace_event';
104
+ snapshot: IExecutionWorkspaceSnapshot$1;
105
105
  } | {
106
- type: 'background_task_event';
107
- event: TBackgroundTaskEvent;
106
+ type: 'background_task_event';
107
+ event: TBackgroundTaskEvent;
108
108
  } | {
109
- type: 'background_job_group_event';
110
- event: TBackgroundJobGroupEvent;
109
+ type: 'background_job_group_event';
110
+ event: TBackgroundJobGroupEvent;
111
111
  } | {
112
- type: 'background_tasks';
113
- tasks: IBackgroundTaskState[];
112
+ type: 'background_tasks';
113
+ tasks: IBackgroundTaskState[];
114
114
  } | {
115
- type: 'background_task';
116
- taskId: string;
117
- task: IBackgroundTaskState | null;
115
+ type: 'background_task';
116
+ taskId: string;
117
+ task: IBackgroundTaskState | null;
118
118
  } | {
119
- type: 'background_job_groups';
120
- groups: IBackgroundJobGroupState[];
119
+ type: 'background_job_groups';
120
+ groups: IBackgroundJobGroupState[];
121
121
  } | {
122
- type: 'background_job_group';
123
- groupId: string;
124
- group: IBackgroundJobGroupState | null;
122
+ type: 'background_job_group';
123
+ groupId: string;
124
+ group: IBackgroundJobGroupState | null;
125
125
  } | {
126
- type: 'background_task_log';
127
- taskId: string;
128
- page: IBackgroundTaskLogPage;
126
+ type: 'background_task_log';
127
+ taskId: string;
128
+ page: IBackgroundTaskLogPage;
129
129
  } | {
130
- type: 'background_task_control_result';
131
- action: TBackgroundControlAction;
132
- taskId: string;
133
- success: boolean;
134
- message?: string;
130
+ type: 'background_task_control_result';
131
+ action: TBackgroundControlAction;
132
+ taskId: string;
133
+ success: boolean;
134
+ message?: string;
135
135
  } | {
136
- type: 'protocol_error';
137
- message: string;
136
+ type: 'protocol_error';
137
+ message: string;
138
138
  };
139
-
140
- /**
141
- * WebSocket transport adapter — exposes InteractiveSession over WebSocket.
142
- *
143
- * Framework-agnostic: works with any WebSocket implementation via
144
- * send/onMessage callbacks. No dependency on ws, uWebSockets, etc.
145
- *
146
- * Protocol: JSON messages with { type, ...payload } structure.
147
- * Server pushes InteractiveSession events to client in real-time.
148
- */
149
-
139
+ //#endregion
140
+ //#region src/ws-handler.d.ts
150
141
  interface IWsHandlerOptions {
151
- /** InteractiveSession to expose. */
152
- session: InteractiveSession;
153
- /** Send a JSON message to the client. */
154
- send: (message: TServerMessage) => void;
142
+ /** IInteractiveSession to expose. */
143
+ session: IInteractiveSession;
144
+ /** Send a JSON message to the client. */
145
+ send: (message: TServerMessage) => void;
155
146
  }
156
147
  /**
157
- * Create a WebSocket message handler for an InteractiveSession.
148
+ * Create a WebSocket message handler for an IInteractiveSession.
158
149
  *
159
150
  * Returns:
160
151
  * - `onMessage(data)`: call this when the WebSocket receives a message
@@ -172,60 +163,51 @@ interface IWsHandlerOptions {
172
163
  * ```
173
164
  */
174
165
  declare function createWsHandler(options: IWsHandlerOptions): {
175
- onMessage: (data: string) => void;
176
- cleanup: () => void;
166
+ onMessage: (data: string) => void;
167
+ cleanup: () => void;
177
168
  };
178
-
179
- /**
180
- * ITransportAdapter implementation for WebSocket transport.
181
- *
182
- * Wraps createWsHandler into the unified ITransportAdapter interface.
183
- * After start(), the consumer must wire onMessage to their WebSocket.
184
- */
185
-
169
+ //#endregion
170
+ //#region src/ws-transport.d.ts
186
171
  interface IWsTransportOptions {
187
- /** Send a JSON message to the connected WebSocket client. */
188
- send: (message: TServerMessage) => void;
172
+ /** Send a JSON message to the connected WebSocket client. */
173
+ send: (message: TServerMessage) => void;
189
174
  }
190
- declare function createWsTransport(options: IWsTransportOptions): ITransportAdapter & {
191
- onMessage: ((data: string) => void) | null;
175
+ declare function createWsTransport(options: IWsTransportOptions): ITransportAdapter<IInteractiveSession> & {
176
+ onMessage: ((data: string) => void) | null;
192
177
  };
193
-
194
- /**
195
- * Self-contained WS transport implementing IConfigurableTransport.
196
- * Owns the WebSocket server lifecycle (ws package), started/stopped via the transport registry.
197
- */
198
-
178
+ //#endregion
179
+ //#region src/ws-transport-configurable.d.ts
199
180
  interface IWsTransportConfig {
200
- port?: number;
201
- maxRetries?: number;
181
+ port?: number;
182
+ maxRetries?: number;
202
183
  }
203
- declare class WsTransport implements IConfigurableTransport {
204
- readonly name = "ws";
205
- readonly defaultEnabled = true;
206
- readonly optionsSchema: {
207
- port: {
208
- type: string;
209
- description: string;
210
- default: number;
211
- };
212
- maxRetries: {
213
- type: string;
214
- description: string;
215
- default: number;
216
- };
184
+ declare class WsTransport implements IConfigurableTransport<IInteractiveSession> {
185
+ readonly name = "ws";
186
+ readonly defaultEnabled = true;
187
+ readonly optionsSchema: {
188
+ port: {
189
+ type: string;
190
+ description: string;
191
+ default: number;
217
192
  };
218
- private session;
219
- private stopFn;
220
- private readonly port;
221
- private readonly maxRetries;
222
- constructor(config?: IWsTransportConfig);
223
- attach(session: ISession): void;
224
- start(): Promise<void>;
225
- stop(): Promise<void>;
226
- validateOptions(options: Record<string, TUniversalValue>): boolean;
227
- private bindWithRetry;
228
- private tryBind;
193
+ maxRetries: {
194
+ type: string;
195
+ description: string;
196
+ default: number;
197
+ };
198
+ };
199
+ private session;
200
+ private stopFn;
201
+ private readonly port;
202
+ private readonly maxRetries;
203
+ constructor(config?: IWsTransportConfig);
204
+ attach(session: IInteractiveSession): void;
205
+ start(): Promise<void>;
206
+ stop(): Promise<void>;
207
+ validateOptions(options: Record<string, TUniversalValue>): boolean;
208
+ private bindWithRetry;
209
+ private tryBind;
229
210
  }
230
-
231
- export { type IWsHandlerOptions, type IWsTransportConfig, type IWsTransportOptions, type TClientMessage, type TServerMessage, WsTransport, createWsHandler, createWsTransport };
211
+ //#endregion
212
+ export { type IExecutionWorkspaceEntry, type IExecutionWorkspaceSnapshot, type IWsHandlerOptions, type IWsTransportConfig, type IWsTransportOptions, type TClientMessage, type TExecutionAttention, type TExecutionWorkspaceStatus, type TServerMessage, WsTransport, createWsHandler, createWsTransport };
213
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ws-protocol.ts","../../src/ws-handler.ts","../../src/ws-transport.ts","../../src/ws-transport-configurable.ts"],"mappings":";;;;;KAkBY,wBAAA;;KAGA,cAAA;EACN,IAAA;EAAgB,MAAA;AAAA;EAChB,IAAA;EAAiB,IAAA;EAAc,IAAA;AAAA;EAC/B,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IA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