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

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