@agentxjs/types 0.0.9 → 0.2.0
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/Agent-BXUYGlWZ.d.cts +510 -0
- package/dist/Agent-CaSxMF_E.d.ts +510 -0
- package/dist/CommandEvent-CbXzPolX.d.ts +495 -0
- package/dist/CommandEvent-DCdk7lzX.d.cts +495 -0
- package/dist/Container-DR-1g44i.d.ts +641 -0
- package/dist/Container-dBDOcjhk.d.cts +641 -0
- package/dist/ContentPart-CqOh-rI1.d.ts +19 -0
- package/dist/ContentPart-DEFnYXCU.d.cts +19 -0
- package/dist/DriveableEvent-Bj7nn-Uk.d.ts +161 -0
- package/dist/DriveableEvent-CCMC1h_C.d.cts +161 -0
- package/dist/ErrorMessage-BoIh3MIO.d.cts +24 -0
- package/dist/ErrorMessage-BoIh3MIO.d.ts +24 -0
- package/dist/ImageRecord-Cn0VcJWk.d.cts +71 -0
- package/dist/ImageRecord-Cn0VcJWk.d.ts +71 -0
- package/dist/LoggerFactory-DZtw0M7U.d.cts +129 -0
- package/dist/LoggerFactory-DZtw0M7U.d.ts +129 -0
- package/dist/Message-Crh81uLL.d.cts +45 -0
- package/dist/Message-DWQUt647.d.ts +45 -0
- package/dist/Persistence-BQkdKomV.d.ts +230 -0
- package/dist/Persistence-Dr70FEBh.d.cts +230 -0
- package/dist/StopReason-D4DthB1h.d.cts +39 -0
- package/dist/StopReason-D4DthB1h.d.ts +39 -0
- package/dist/SystemEvent-CPvvxdMQ.d.cts +159 -0
- package/dist/SystemEvent-CPvvxdMQ.d.ts +159 -0
- package/dist/ToolResultMessage-CDG2L7Zv.d.ts +332 -0
- package/dist/ToolResultMessage-CRKMSf5d.d.cts +332 -0
- package/dist/agent-internal.cjs +19 -0
- package/dist/agent-internal.cjs.map +1 -0
- package/dist/agent-internal.d.cts +52 -0
- package/dist/agent-internal.d.ts +52 -0
- package/dist/agent-internal.js +1 -0
- package/dist/agent-internal.js.map +1 -0
- package/dist/agent.cjs +70 -0
- package/dist/agent.cjs.map +1 -0
- package/dist/agent.d.cts +229 -0
- package/dist/agent.d.ts +229 -0
- package/dist/agent.js +41 -0
- package/dist/agent.js.map +1 -0
- package/dist/agentx.cjs +38 -0
- package/dist/agentx.cjs.map +1 -0
- package/dist/agentx.d.cts +311 -0
- package/dist/agentx.d.ts +311 -0
- package/dist/agentx.js +12 -0
- package/dist/agentx.js.map +1 -0
- package/dist/chunk-2QHAIM3V.js +1 -0
- package/dist/chunk-2QHAIM3V.js.map +1 -0
- package/dist/common.cjs +19 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +43 -0
- package/dist/common.d.ts +43 -0
- package/dist/common.js +2 -0
- package/dist/common.js.map +1 -0
- package/dist/event.cjs +184 -0
- package/dist/event.cjs.map +1 -0
- package/dist/event.d.cts +769 -0
- package/dist/event.d.ts +769 -0
- package/dist/event.js +134 -0
- package/dist/event.js.map +1 -0
- package/dist/index-CjFNcCxR.d.cts +299 -0
- package/dist/index-usKuk41S.d.ts +299 -0
- package/dist/index.cjs +2 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5267
- package/dist/index.d.ts +8 -5267
- package/dist/index.js +1 -150
- package/dist/index.js.map +1 -1
- package/dist/network.cjs +19 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.d.cts +168 -0
- package/dist/network.d.ts +168 -0
- package/dist/network.js +1 -0
- package/dist/network.js.map +1 -0
- package/dist/runtime-internal.cjs +19 -0
- package/dist/runtime-internal.cjs.map +1 -0
- package/dist/runtime-internal.d.cts +943 -0
- package/dist/runtime-internal.d.ts +943 -0
- package/dist/runtime-internal.js +1 -0
- package/dist/runtime-internal.js.map +1 -0
- package/dist/runtime.cjs +19 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +217 -0
- package/dist/runtime.d.ts +217 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +82 -10
- package/LICENSE +0 -21
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { S as SystemEvent } from './SystemEvent-CPvvxdMQ.cjs';
|
|
2
|
+
import { I as ImageRecord } from './ImageRecord-Cn0VcJWk.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CommandEvent - Request/Response events for Runtime operations
|
|
6
|
+
*
|
|
7
|
+
* These events enable unified operation API for both local and remote modes:
|
|
8
|
+
* - Local mode: RuntimeImpl listens to requests, emits responses
|
|
9
|
+
* - Remote mode: WebSocket/SSE forwards requests/responses
|
|
10
|
+
*
|
|
11
|
+
* Pattern:
|
|
12
|
+
* ```
|
|
13
|
+
* Caller Handler (Runtime)
|
|
14
|
+
* ─────────────────────────────────────────────────────────
|
|
15
|
+
* container_create_request ────────► handle & execute
|
|
16
|
+
* ◄──────── container_create_response
|
|
17
|
+
*
|
|
18
|
+
* agent_run_request ────────► handle & execute
|
|
19
|
+
* ◄──────── agent_run_response
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* All CommandEvents have:
|
|
23
|
+
* - source: "command"
|
|
24
|
+
* - category: "request" | "response"
|
|
25
|
+
* - intent: "request" | "result"
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Base interface for Command request events
|
|
30
|
+
*/
|
|
31
|
+
interface BaseCommandRequest<T extends string, D = unknown> extends SystemEvent<T, D, "command", "request", "request"> {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base interface for Command response events
|
|
35
|
+
*/
|
|
36
|
+
interface BaseCommandResponse<T extends string, D = unknown> extends SystemEvent<T, D, "command", "response", "result"> {
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Request to create a container
|
|
40
|
+
*/
|
|
41
|
+
interface ContainerCreateRequest extends BaseCommandRequest<"container_create_request", {
|
|
42
|
+
requestId: string;
|
|
43
|
+
containerId: string;
|
|
44
|
+
}> {
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Response to container creation
|
|
48
|
+
*/
|
|
49
|
+
interface ContainerCreateResponse extends BaseCommandResponse<"container_create_response", {
|
|
50
|
+
requestId: string;
|
|
51
|
+
containerId: string;
|
|
52
|
+
error?: string;
|
|
53
|
+
}> {
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request to get a container
|
|
57
|
+
*/
|
|
58
|
+
interface ContainerGetRequest extends BaseCommandRequest<"container_get_request", {
|
|
59
|
+
requestId: string;
|
|
60
|
+
containerId: string;
|
|
61
|
+
}> {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Response to container get
|
|
65
|
+
*/
|
|
66
|
+
interface ContainerGetResponse extends BaseCommandResponse<"container_get_response", {
|
|
67
|
+
requestId: string;
|
|
68
|
+
containerId?: string;
|
|
69
|
+
exists: boolean;
|
|
70
|
+
error?: string;
|
|
71
|
+
}> {
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Request to list containers
|
|
75
|
+
*/
|
|
76
|
+
interface ContainerListRequest extends BaseCommandRequest<"container_list_request", {
|
|
77
|
+
requestId: string;
|
|
78
|
+
}> {
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Response to container list
|
|
82
|
+
*/
|
|
83
|
+
interface ContainerListResponse extends BaseCommandResponse<"container_list_response", {
|
|
84
|
+
requestId: string;
|
|
85
|
+
containerIds: string[];
|
|
86
|
+
error?: string;
|
|
87
|
+
}> {
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Request to get an agent
|
|
91
|
+
*/
|
|
92
|
+
interface AgentGetRequest extends BaseCommandRequest<"agent_get_request", {
|
|
93
|
+
requestId: string;
|
|
94
|
+
agentId: string;
|
|
95
|
+
}> {
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Response to agent get
|
|
99
|
+
*/
|
|
100
|
+
interface AgentGetResponse extends BaseCommandResponse<"agent_get_response", {
|
|
101
|
+
requestId: string;
|
|
102
|
+
agentId?: string;
|
|
103
|
+
containerId?: string;
|
|
104
|
+
exists: boolean;
|
|
105
|
+
error?: string;
|
|
106
|
+
}> {
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Request to list agents
|
|
110
|
+
*/
|
|
111
|
+
interface AgentListRequest extends BaseCommandRequest<"agent_list_request", {
|
|
112
|
+
requestId: string;
|
|
113
|
+
containerId: string;
|
|
114
|
+
}> {
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Response to agent list
|
|
118
|
+
*/
|
|
119
|
+
interface AgentListResponse extends BaseCommandResponse<"agent_list_response", {
|
|
120
|
+
requestId: string;
|
|
121
|
+
agents: Array<{
|
|
122
|
+
agentId: string;
|
|
123
|
+
containerId: string;
|
|
124
|
+
imageId: string;
|
|
125
|
+
}>;
|
|
126
|
+
error?: string;
|
|
127
|
+
}> {
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Request to destroy an agent
|
|
131
|
+
*/
|
|
132
|
+
interface AgentDestroyRequest extends BaseCommandRequest<"agent_destroy_request", {
|
|
133
|
+
requestId: string;
|
|
134
|
+
agentId: string;
|
|
135
|
+
}> {
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Response to agent destroy
|
|
139
|
+
*/
|
|
140
|
+
interface AgentDestroyResponse extends BaseCommandResponse<"agent_destroy_response", {
|
|
141
|
+
requestId: string;
|
|
142
|
+
agentId: string;
|
|
143
|
+
success: boolean;
|
|
144
|
+
error?: string;
|
|
145
|
+
}> {
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Request to destroy all agents in a container
|
|
149
|
+
*/
|
|
150
|
+
interface AgentDestroyAllRequest extends BaseCommandRequest<"agent_destroy_all_request", {
|
|
151
|
+
requestId: string;
|
|
152
|
+
containerId: string;
|
|
153
|
+
}> {
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Response to destroy all agents
|
|
157
|
+
*/
|
|
158
|
+
interface AgentDestroyAllResponse extends BaseCommandResponse<"agent_destroy_all_response", {
|
|
159
|
+
requestId: string;
|
|
160
|
+
containerId: string;
|
|
161
|
+
error?: string;
|
|
162
|
+
}> {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Request to send a message
|
|
166
|
+
* Can use either imageId (preferred) or agentId
|
|
167
|
+
* If using imageId and agent is not running, it will be auto-activated
|
|
168
|
+
*/
|
|
169
|
+
interface MessageSendRequest extends BaseCommandRequest<"message_send_request", {
|
|
170
|
+
requestId: string;
|
|
171
|
+
/** Image ID (preferred) - will auto-activate if offline */
|
|
172
|
+
imageId?: string;
|
|
173
|
+
/** Agent ID (legacy) - must be already running */
|
|
174
|
+
agentId?: string;
|
|
175
|
+
content: string;
|
|
176
|
+
}> {
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Response to message send (acknowledges message received, not completion)
|
|
180
|
+
*/
|
|
181
|
+
interface MessageSendResponse extends BaseCommandResponse<"message_send_response", {
|
|
182
|
+
requestId: string;
|
|
183
|
+
imageId?: string;
|
|
184
|
+
agentId: string;
|
|
185
|
+
error?: string;
|
|
186
|
+
}> {
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Request to interrupt an agent
|
|
190
|
+
* Can use either imageId or agentId
|
|
191
|
+
*/
|
|
192
|
+
interface AgentInterruptRequest extends BaseCommandRequest<"agent_interrupt_request", {
|
|
193
|
+
requestId: string;
|
|
194
|
+
/** Image ID (preferred) */
|
|
195
|
+
imageId?: string;
|
|
196
|
+
/** Agent ID (legacy) */
|
|
197
|
+
agentId?: string;
|
|
198
|
+
}> {
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Response to agent interrupt
|
|
202
|
+
*/
|
|
203
|
+
interface AgentInterruptResponse extends BaseCommandResponse<"agent_interrupt_response", {
|
|
204
|
+
requestId: string;
|
|
205
|
+
imageId?: string;
|
|
206
|
+
agentId?: string;
|
|
207
|
+
error?: string;
|
|
208
|
+
}> {
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Request to create a new image (conversation)
|
|
212
|
+
*/
|
|
213
|
+
interface ImageCreateRequest extends BaseCommandRequest<"image_create_request", {
|
|
214
|
+
requestId: string;
|
|
215
|
+
containerId: string;
|
|
216
|
+
config: {
|
|
217
|
+
name?: string;
|
|
218
|
+
description?: string;
|
|
219
|
+
systemPrompt?: string;
|
|
220
|
+
};
|
|
221
|
+
}> {
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Response to image creation
|
|
225
|
+
*/
|
|
226
|
+
interface ImageCreateResponse extends BaseCommandResponse<"image_create_response", {
|
|
227
|
+
requestId: string;
|
|
228
|
+
record: ImageRecord;
|
|
229
|
+
error?: string;
|
|
230
|
+
}> {
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Request to run an image (create or reuse agent)
|
|
234
|
+
*/
|
|
235
|
+
interface ImageRunRequest extends BaseCommandRequest<"image_run_request", {
|
|
236
|
+
requestId: string;
|
|
237
|
+
imageId: string;
|
|
238
|
+
}> {
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Response to image run
|
|
242
|
+
*/
|
|
243
|
+
interface ImageRunResponse extends BaseCommandResponse<"image_run_response", {
|
|
244
|
+
requestId: string;
|
|
245
|
+
imageId: string;
|
|
246
|
+
agentId: string;
|
|
247
|
+
/** true if reusing existing agent, false if newly created */
|
|
248
|
+
reused: boolean;
|
|
249
|
+
error?: string;
|
|
250
|
+
}> {
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Request to stop an image (destroy agent, keep image)
|
|
254
|
+
*/
|
|
255
|
+
interface ImageStopRequest extends BaseCommandRequest<"image_stop_request", {
|
|
256
|
+
requestId: string;
|
|
257
|
+
imageId: string;
|
|
258
|
+
}> {
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Response to image stop
|
|
262
|
+
*/
|
|
263
|
+
interface ImageStopResponse extends BaseCommandResponse<"image_stop_response", {
|
|
264
|
+
requestId: string;
|
|
265
|
+
imageId: string;
|
|
266
|
+
error?: string;
|
|
267
|
+
}> {
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Request to update an image (name, description, etc.)
|
|
271
|
+
*/
|
|
272
|
+
interface ImageUpdateRequest extends BaseCommandRequest<"image_update_request", {
|
|
273
|
+
requestId: string;
|
|
274
|
+
imageId: string;
|
|
275
|
+
updates: {
|
|
276
|
+
name?: string;
|
|
277
|
+
description?: string;
|
|
278
|
+
};
|
|
279
|
+
}> {
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Response to image update
|
|
283
|
+
*/
|
|
284
|
+
interface ImageUpdateResponse extends BaseCommandResponse<"image_update_response", {
|
|
285
|
+
requestId: string;
|
|
286
|
+
record: ImageRecord;
|
|
287
|
+
error?: string;
|
|
288
|
+
}> {
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Request to list all images
|
|
292
|
+
*/
|
|
293
|
+
interface ImageListRequest extends BaseCommandRequest<"image_list_request", {
|
|
294
|
+
requestId: string;
|
|
295
|
+
containerId?: string;
|
|
296
|
+
}> {
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Image list item with online status
|
|
300
|
+
*/
|
|
301
|
+
interface ImageListItem extends ImageRecord {
|
|
302
|
+
/** Whether an agent is currently running for this image */
|
|
303
|
+
online: boolean;
|
|
304
|
+
/** Current agent ID if online */
|
|
305
|
+
agentId?: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Response to image list
|
|
309
|
+
*/
|
|
310
|
+
interface ImageListResponse extends BaseCommandResponse<"image_list_response", {
|
|
311
|
+
requestId: string;
|
|
312
|
+
records: ImageListItem[];
|
|
313
|
+
error?: string;
|
|
314
|
+
}> {
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Request to get an image by ID
|
|
318
|
+
*/
|
|
319
|
+
interface ImageGetRequest extends BaseCommandRequest<"image_get_request", {
|
|
320
|
+
requestId: string;
|
|
321
|
+
imageId: string;
|
|
322
|
+
}> {
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Response to image get
|
|
326
|
+
*/
|
|
327
|
+
interface ImageGetResponse extends BaseCommandResponse<"image_get_response", {
|
|
328
|
+
requestId: string;
|
|
329
|
+
record?: ImageListItem | null;
|
|
330
|
+
error?: string;
|
|
331
|
+
}> {
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Request to delete an image
|
|
335
|
+
*/
|
|
336
|
+
interface ImageDeleteRequest extends BaseCommandRequest<"image_delete_request", {
|
|
337
|
+
requestId: string;
|
|
338
|
+
imageId: string;
|
|
339
|
+
}> {
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Response to image delete
|
|
343
|
+
*/
|
|
344
|
+
interface ImageDeleteResponse extends BaseCommandResponse<"image_delete_response", {
|
|
345
|
+
requestId: string;
|
|
346
|
+
imageId: string;
|
|
347
|
+
error?: string;
|
|
348
|
+
}> {
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Request to get messages for an image
|
|
352
|
+
*/
|
|
353
|
+
interface ImageMessagesRequest extends BaseCommandRequest<"image_messages_request", {
|
|
354
|
+
requestId: string;
|
|
355
|
+
imageId: string;
|
|
356
|
+
}> {
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Response to image messages request
|
|
360
|
+
*/
|
|
361
|
+
interface ImageMessagesResponse extends BaseCommandResponse<"image_messages_response", {
|
|
362
|
+
requestId: string;
|
|
363
|
+
imageId: string;
|
|
364
|
+
messages: Array<{
|
|
365
|
+
id: string;
|
|
366
|
+
role: "user" | "assistant" | "tool_call" | "tool_result";
|
|
367
|
+
content: unknown;
|
|
368
|
+
timestamp: number;
|
|
369
|
+
}>;
|
|
370
|
+
error?: string;
|
|
371
|
+
}> {
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* All Command request events
|
|
375
|
+
*/
|
|
376
|
+
type CommandRequest = ContainerCreateRequest | ContainerGetRequest | ContainerListRequest | AgentGetRequest | AgentListRequest | AgentDestroyRequest | AgentDestroyAllRequest | MessageSendRequest | AgentInterruptRequest | ImageCreateRequest | ImageRunRequest | ImageStopRequest | ImageUpdateRequest | ImageListRequest | ImageGetRequest | ImageDeleteRequest | ImageMessagesRequest;
|
|
377
|
+
/**
|
|
378
|
+
* All Command response events
|
|
379
|
+
*/
|
|
380
|
+
type CommandResponse = ContainerCreateResponse | ContainerGetResponse | ContainerListResponse | AgentGetResponse | AgentListResponse | AgentDestroyResponse | AgentDestroyAllResponse | MessageSendResponse | AgentInterruptResponse | ImageCreateResponse | ImageRunResponse | ImageStopResponse | ImageUpdateResponse | ImageListResponse | ImageGetResponse | ImageDeleteResponse | ImageMessagesResponse;
|
|
381
|
+
/**
|
|
382
|
+
* All Command events (requests + responses)
|
|
383
|
+
*/
|
|
384
|
+
type CommandEvent = CommandRequest | CommandResponse;
|
|
385
|
+
/**
|
|
386
|
+
* Command event type strings
|
|
387
|
+
*/
|
|
388
|
+
type CommandEventType = CommandEvent["type"];
|
|
389
|
+
/**
|
|
390
|
+
* Type guard: is this a CommandEvent?
|
|
391
|
+
*/
|
|
392
|
+
declare function isCommandEvent(event: {
|
|
393
|
+
source?: string;
|
|
394
|
+
}): event is CommandEvent;
|
|
395
|
+
/**
|
|
396
|
+
* Type guard: is this a Command request event?
|
|
397
|
+
*/
|
|
398
|
+
declare function isCommandRequest(event: {
|
|
399
|
+
source?: string;
|
|
400
|
+
category?: string;
|
|
401
|
+
}): event is CommandRequest;
|
|
402
|
+
/**
|
|
403
|
+
* Type guard: is this a Command response event?
|
|
404
|
+
*/
|
|
405
|
+
declare function isCommandResponse(event: {
|
|
406
|
+
source?: string;
|
|
407
|
+
category?: string;
|
|
408
|
+
}): event is CommandResponse;
|
|
409
|
+
/**
|
|
410
|
+
* CommandEventMap - Maps event type string to event interface
|
|
411
|
+
*
|
|
412
|
+
* Enables type-safe event handling:
|
|
413
|
+
* ```typescript
|
|
414
|
+
* bus.onCommand("container_create_request", (event) => {
|
|
415
|
+
* event.data.requestId; // ✓ string
|
|
416
|
+
* event.data.containerId; // ✓ string
|
|
417
|
+
* });
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
interface CommandEventMap {
|
|
421
|
+
container_create_request: ContainerCreateRequest;
|
|
422
|
+
container_create_response: ContainerCreateResponse;
|
|
423
|
+
container_get_request: ContainerGetRequest;
|
|
424
|
+
container_get_response: ContainerGetResponse;
|
|
425
|
+
container_list_request: ContainerListRequest;
|
|
426
|
+
container_list_response: ContainerListResponse;
|
|
427
|
+
agent_get_request: AgentGetRequest;
|
|
428
|
+
agent_get_response: AgentGetResponse;
|
|
429
|
+
agent_list_request: AgentListRequest;
|
|
430
|
+
agent_list_response: AgentListResponse;
|
|
431
|
+
agent_destroy_request: AgentDestroyRequest;
|
|
432
|
+
agent_destroy_response: AgentDestroyResponse;
|
|
433
|
+
agent_destroy_all_request: AgentDestroyAllRequest;
|
|
434
|
+
agent_destroy_all_response: AgentDestroyAllResponse;
|
|
435
|
+
message_send_request: MessageSendRequest;
|
|
436
|
+
message_send_response: MessageSendResponse;
|
|
437
|
+
agent_interrupt_request: AgentInterruptRequest;
|
|
438
|
+
agent_interrupt_response: AgentInterruptResponse;
|
|
439
|
+
image_create_request: ImageCreateRequest;
|
|
440
|
+
image_create_response: ImageCreateResponse;
|
|
441
|
+
image_run_request: ImageRunRequest;
|
|
442
|
+
image_run_response: ImageRunResponse;
|
|
443
|
+
image_stop_request: ImageStopRequest;
|
|
444
|
+
image_stop_response: ImageStopResponse;
|
|
445
|
+
image_update_request: ImageUpdateRequest;
|
|
446
|
+
image_update_response: ImageUpdateResponse;
|
|
447
|
+
image_list_request: ImageListRequest;
|
|
448
|
+
image_list_response: ImageListResponse;
|
|
449
|
+
image_get_request: ImageGetRequest;
|
|
450
|
+
image_get_response: ImageGetResponse;
|
|
451
|
+
image_delete_request: ImageDeleteRequest;
|
|
452
|
+
image_delete_response: ImageDeleteResponse;
|
|
453
|
+
image_messages_request: ImageMessagesRequest;
|
|
454
|
+
image_messages_response: ImageMessagesResponse;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Maps request event type to its corresponding response event type
|
|
458
|
+
*/
|
|
459
|
+
interface CommandRequestResponseMap {
|
|
460
|
+
container_create_request: "container_create_response";
|
|
461
|
+
container_get_request: "container_get_response";
|
|
462
|
+
container_list_request: "container_list_response";
|
|
463
|
+
agent_get_request: "agent_get_response";
|
|
464
|
+
agent_list_request: "agent_list_response";
|
|
465
|
+
agent_destroy_request: "agent_destroy_response";
|
|
466
|
+
agent_destroy_all_request: "agent_destroy_all_response";
|
|
467
|
+
message_send_request: "message_send_response";
|
|
468
|
+
agent_interrupt_request: "agent_interrupt_response";
|
|
469
|
+
image_create_request: "image_create_response";
|
|
470
|
+
image_run_request: "image_run_response";
|
|
471
|
+
image_stop_request: "image_stop_response";
|
|
472
|
+
image_update_request: "image_update_response";
|
|
473
|
+
image_list_request: "image_list_response";
|
|
474
|
+
image_get_request: "image_get_response";
|
|
475
|
+
image_delete_request: "image_delete_response";
|
|
476
|
+
image_messages_request: "image_messages_response";
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* All command request types
|
|
480
|
+
*/
|
|
481
|
+
type CommandRequestType = keyof CommandRequestResponseMap;
|
|
482
|
+
/**
|
|
483
|
+
* Get response type for a request type
|
|
484
|
+
*/
|
|
485
|
+
type ResponseTypeFor<T extends CommandRequestType> = CommandRequestResponseMap[T];
|
|
486
|
+
/**
|
|
487
|
+
* Get response event for a request type
|
|
488
|
+
*/
|
|
489
|
+
type ResponseEventFor<T extends CommandRequestType> = CommandEventMap[ResponseTypeFor<T>];
|
|
490
|
+
/**
|
|
491
|
+
* Get request data type (without requestId, as it's auto-generated)
|
|
492
|
+
*/
|
|
493
|
+
type RequestDataFor<T extends CommandRequestType> = Omit<CommandEventMap[T]["data"], "requestId">;
|
|
494
|
+
|
|
495
|
+
export { type AgentGetRequest as A, type ImageListResponse as B, type CommandRequestType as C, type ImageListItem as D, type ImageGetRequest as E, type ImageGetResponse as F, type ImageDeleteRequest as G, type ImageDeleteResponse as H, type ImageCreateRequest as I, type CommandRequest as J, type CommandResponse as K, type CommandEvent as L, type MessageSendRequest as M, type CommandEventType as N, type CommandRequestResponseMap as O, type ResponseTypeFor as P, isCommandEvent as Q, type RequestDataFor as R, isCommandRequest as S, isCommandResponse as T, type ResponseEventFor as a, type CommandEventMap as b, type ContainerCreateRequest as c, type ContainerCreateResponse as d, type ContainerGetRequest as e, type ContainerGetResponse as f, type ContainerListRequest as g, type ContainerListResponse as h, type AgentGetResponse as i, type AgentListRequest as j, type AgentListResponse as k, type AgentDestroyRequest as l, type AgentDestroyResponse as m, type AgentDestroyAllRequest as n, type AgentDestroyAllResponse as o, type MessageSendResponse as p, type AgentInterruptRequest as q, type AgentInterruptResponse as r, type ImageCreateResponse as s, type ImageRunRequest as t, type ImageRunResponse as u, type ImageStopRequest as v, type ImageStopResponse as w, type ImageUpdateRequest as x, type ImageUpdateResponse as y, type ImageListRequest as z };
|