@cloudbase/agent-server 0.0.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,587 @@
1
+ # @cloudbase/agent-server
2
+
3
+ ## 0.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - stable release 0.0.10
8
+ - Update all public packages to version 0.0.10
9
+ - Trigger automated stable release workflow
10
+ - Includes latest features and improvements
11
+
12
+ - Updated dependencies
13
+ - @cloudbase/agent-agents@0.0.10
14
+ - @cloudbase/agent-shared@0.0.10
15
+
16
+ ## 0.0.10-alpha.1
17
+
18
+ ### Patch Changes
19
+
20
+ - alpha release 0.0.9-alpha.3
21
+ - Update all public packages to version 0.0.9-alpha.3
22
+ - Trigger automated alpha release workflow
23
+ - Includes latest features and improvements
24
+
25
+ - Updated dependencies
26
+ - @cloudbase/agent-agents@0.0.10-alpha.1
27
+ - @cloudbase/agent-shared@0.0.10-alpha.1
28
+
29
+ ## 0.0.10-alpha.0
30
+
31
+ ### Patch Changes
32
+
33
+ - alpha release 0.0.9-alpha.3
34
+ - Update all public packages to version 0.0.9-alpha.3
35
+ - Trigger automated alpha release workflow
36
+ - Includes latest features and improvements
37
+
38
+ - Updated dependencies
39
+ - @cloudbase/agent-agents@0.0.10-alpha.0
40
+ - @cloudbase/agent-shared@0.0.10-alpha.0
41
+
42
+ ## 0.0.9
43
+
44
+ ### Patch Changes
45
+
46
+ - stable release 0.0.9
47
+ - Update all public packages to version 0.0.9
48
+ - Trigger automated stable release workflow
49
+ - Includes latest features and improvements
50
+
51
+ - Updated dependencies
52
+ - @cloudbase/agent-agents@0.0.9
53
+ - @cloudbase/agent-shared@0.0.9
54
+
55
+ ## 0.0.9-alpha.2
56
+
57
+ ### Patch Changes
58
+
59
+ - alpha release 0.0.8-alpha.1
60
+ - Update all public packages to version 0.0.8-alpha.1
61
+ - Trigger automated alpha release workflow
62
+ - Includes latest features and improvements
63
+
64
+ - Updated dependencies
65
+ - @cloudbase/agent-agents@0.0.9-alpha.2
66
+ - @cloudbase/agent-shared@0.0.9-alpha.2
67
+
68
+ ## 0.0.9-alpha.1
69
+
70
+ ### Patch Changes
71
+
72
+ - alpha release 0.0.8-alpha.1
73
+ - Update all public packages to version 0.0.8-alpha.1
74
+ - Trigger automated alpha release workflow
75
+ - Includes latest features and improvements
76
+
77
+ - Updated dependencies
78
+ - @cloudbase/agent-agents@0.0.9-alpha.1
79
+ - @cloudbase/agent-shared@0.0.9-alpha.1
80
+
81
+ ## 0.0.9-alpha.0
82
+
83
+ ### Patch Changes
84
+
85
+ - alpha release 0.0.8-alpha.1
86
+ - Update all public packages to version 0.0.8-alpha.1
87
+ - Trigger automated alpha release workflow
88
+ - Includes latest features and improvements
89
+
90
+ - Updated dependencies
91
+ - @cloudbase/agent-agents@0.0.9-alpha.0
92
+ - @cloudbase/agent-shared@0.0.9-alpha.0
93
+
94
+ ## 0.0.8
95
+
96
+ ### Patch Changes
97
+
98
+ - stable release 0.0.8
99
+ - Update all public packages to version 0.0.8
100
+ - Trigger automated stable release workflow
101
+ - Includes latest features and improvements
102
+
103
+ - Updated dependencies
104
+ - @cloudbase/agent-agents@0.0.8
105
+ - @cloudbase/agent-shared@0.0.8
106
+
107
+ ## 0.0.4-alpha.0
108
+
109
+ ### Patch Changes
110
+
111
+ - alpha release 0.0.7-alpha.1
112
+ - Update all public packages to version 0.0.7-alpha.1
113
+ - Trigger automated alpha release workflow
114
+ - Includes latest features and improvements
115
+
116
+ - Updated dependencies
117
+ - @cloudbase/agent-agents@0.0.4-alpha.0
118
+ - @cloudbase/agent-shared@0.0.4-alpha.0
119
+
120
+ ## 0.0.0-alpha-20251103123845
121
+
122
+ ### Patch Changes
123
+
124
+ - alpha release 0.0.7-alpha.1
125
+ - Update all public packages to version 0.0.7-alpha.1
126
+ - Trigger automated alpha release workflow
127
+ - Includes latest features and improvements
128
+
129
+ - Updated dependencies
130
+ - @cloudbase/agent-agents@0.0.0-alpha-20251103123845
131
+ - @cloudbase/agent-shared@0.0.0-alpha-20251103123845
132
+
133
+ ## 0.0.5
134
+
135
+ ### Patch Changes
136
+
137
+ - stable release 0.0.7
138
+ - Update all public packages to version 0.0.7
139
+ - Trigger automated stable release workflow
140
+ - Includes latest features and improvements
141
+
142
+ - Updated dependencies
143
+ - @cloudbase/agent-agents@0.0.5
144
+ - @cloudbase/agent-shared@0.0.5
145
+
146
+ ## 0.0.4
147
+
148
+ ### Patch Changes
149
+
150
+ - stable release 0.0.6
151
+ - Update all public packages to version 0.0.6
152
+ - Trigger automated stable release workflow
153
+ - Includes latest features and improvements
154
+
155
+ - Updated dependencies
156
+ - @cloudbase/agent-agents@0.0.4
157
+ - @cloudbase/agent-shared@0.0.4
158
+
159
+ ## 0.0.0-alpha-20251030080320
160
+
161
+ ### Patch Changes
162
+
163
+ - alpha release 0.0.5-alpha.7
164
+ - Update all public packages to version 0.0.5-alpha.7
165
+ - Trigger automated alpha release workflow
166
+ - Includes latest features and improvements
167
+
168
+ - Updated dependencies
169
+ - @cloudbase/agent-agents@0.0.0-alpha-20251030080320
170
+ - @cloudbase/agent-shared@0.0.0-alpha-20251030080320
171
+
172
+ ## 0.0.0-alpha-20251028115618
173
+
174
+ ### Patch Changes
175
+
176
+ - alpha release 0.0.5-alpha.6
177
+ - Update all public packages to version 0.0.5-alpha.6
178
+ - Trigger automated alpha release workflow
179
+ - Includes latest features and improvements
180
+
181
+ - Updated dependencies
182
+ - @cloudbase/agent-agents@0.0.0-alpha-20251028115618
183
+ - @cloudbase/agent-shared@0.0.0-alpha-20251028115618
184
+
185
+ ## 0.0.0-alpha-20251028114708
186
+
187
+ ### Patch Changes
188
+
189
+ - alpha release 0.0.5-alpha.5
190
+ - Update all public packages to version 0.0.5-alpha.5
191
+ - Trigger automated alpha release workflow
192
+ - Includes latest features and improvements
193
+
194
+ - Updated dependencies
195
+ - @cloudbase/agent-agents@0.0.0-alpha-20251028114708
196
+ - @cloudbase/agent-shared@0.0.0-alpha-20251028114708
197
+
198
+ ## 0.0.0-alpha-20251027092338
199
+
200
+ ### Patch Changes
201
+
202
+ - alpha release 0.0.5-alpha.4
203
+ - Update all public packages to version 0.0.5-alpha.4
204
+ - Trigger automated alpha release workflow
205
+ - Includes latest features and improvements
206
+
207
+ - Updated dependencies
208
+ - @cloudbase/agent-agents@0.0.0-alpha-20251027092338
209
+ - @cloudbase/agent-shared@0.0.0-alpha-20251027092338
210
+
211
+ ## 0.0.0-alpha-20251027092045
212
+
213
+ ### Patch Changes
214
+
215
+ - alpha release 0.0.5-alpha.3
216
+ - Update all public packages to version 0.0.5-alpha.3
217
+ - Trigger automated alpha release workflow
218
+ - Includes latest features and improvements
219
+
220
+ - Updated dependencies
221
+ - @cloudbase/agent-agents@0.0.0-alpha-20251027092045
222
+ - @cloudbase/agent-shared@0.0.0-alpha-20251027092045
223
+
224
+ ## 0.0.0-alpha-20251024113345
225
+
226
+ ### Patch Changes
227
+
228
+ - alpha release 0.0.5-alpha.2
229
+ - Update all public packages to version 0.0.5-alpha.2
230
+ - Trigger automated alpha release workflow
231
+ - Includes latest features and improvements
232
+
233
+ - Updated dependencies
234
+ - @cloudbase/agent-agents@0.0.0-alpha-20251024113345
235
+ - @cloudbase/agent-shared@0.0.0-alpha-20251024113345
236
+
237
+ ## 0.0.0-alpha-20251024090137
238
+
239
+ ### Patch Changes
240
+
241
+ - alpha release 0.0.5-alpha.1
242
+ - Update all public packages to version 0.0.5-alpha.1
243
+ - Trigger automated alpha release workflow
244
+ - Includes latest features and improvements
245
+
246
+ - Updated dependencies
247
+ - @cloudbase/agent-agents@0.0.0-alpha-20251024090137
248
+ - @cloudbase/agent-shared@0.0.0-alpha-20251024090137
249
+
250
+ ## 0.0.0-alpha-20251024085927
251
+
252
+ ### Patch Changes
253
+
254
+ - alpha release 0.0.1-alpha.18
255
+ - Update all public packages to version 0.0.1-alpha.18
256
+ - Trigger automated alpha release workflow
257
+ - Includes latest features and improvements
258
+
259
+ - Updated dependencies
260
+ - @cloudbase/agent-agents@0.0.0-alpha-20251024085927
261
+ - @cloudbase/agent-shared@0.0.0-alpha-20251024085927
262
+
263
+ ## 0.0.0-alpha-20251023135253
264
+
265
+ ### Patch Changes
266
+
267
+ - Alpha release with latest features and improvements
268
+ - Update all public packages to alpha version
269
+ - Include playground preview enhancements
270
+ - Add Python Server deployment support
271
+ - Include Mastra framework examples
272
+ - Trigger automated alpha release workflow
273
+
274
+ - Updated dependencies
275
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023135253
276
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023135253
277
+
278
+ ## 0.0.0-alpha-20251023135056
279
+
280
+ ### Patch Changes
281
+
282
+ - Alpha release with latest features and improvements
283
+ - Update all public packages to alpha version
284
+ - Include playground preview enhancements
285
+ - Add Python Server deployment support
286
+ - Trigger automated alpha release workflow
287
+
288
+ - 579f801: Stable release with latest features and improvements
289
+ - Update all public packages to stable version
290
+ - Include playground preview enhancements
291
+ - Add new playground examples
292
+ - Trigger automated stable release workflow
293
+
294
+ - Updated dependencies
295
+ - Updated dependencies [579f801]
296
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023135056
297
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023135056
298
+
299
+ ## 0.0.4
300
+
301
+ ### Patch Changes
302
+
303
+ - Stable release with latest features and improvements
304
+ - Update all public packages to stable version
305
+ - Include playground preview enhancements
306
+ - Add new playground examples
307
+ - Trigger automated stable release workflow
308
+
309
+ - Updated dependencies
310
+ - @cloudbase/agent-agents@0.0.4
311
+ - @cloudbase/agent-shared@0.0.4
312
+
313
+ ## 0.0.0-alpha-20251023125455
314
+
315
+ ### Patch Changes
316
+
317
+ - Alpha release with latest features and improvements
318
+ - Update all public packages to alpha version
319
+ - Include playground preview enhancements
320
+ - Add new playground examples
321
+ - Trigger automated alpha release workflow
322
+
323
+ - Updated dependencies
324
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023125455
325
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023125455
326
+
327
+ ## 0.0.0-alpha-20251023125311
328
+
329
+ ### Patch Changes
330
+
331
+ - Alpha release with latest features and improvements
332
+ - Update all public packages to alpha version
333
+ - Include playground preview enhancements
334
+ - Add new playground examples (LlamaIndex, Mastra)
335
+ - Fix workspace configuration for new packages
336
+ - Trigger automated alpha release workflow
337
+
338
+ - Updated dependencies
339
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023125311
340
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023125311
341
+
342
+ ## 0.0.4
343
+
344
+ ### Patch Changes
345
+
346
+ - @cloudbase/agent-agents@0.0.4
347
+
348
+ ## 0.0.2
349
+
350
+ ### Patch Changes
351
+
352
+ - stable release 0.0.3
353
+ - Update all public packages to version 0.0.3
354
+ - Trigger automated stable release workflow
355
+ - Includes latest features and improvements
356
+
357
+ - Updated dependencies
358
+ - @cloudbase/agent-agents@0.0.2
359
+ - @cloudbase/agent-shared@0.0.2
360
+
361
+ ## 0.0.0-alpha-20251023094104
362
+
363
+ ### Patch Changes
364
+
365
+ - alpha release 0.0.1-alpha.14
366
+ - Update all public packages to version 0.0.1-alpha.14
367
+ - Trigger automated alpha release workflow
368
+ - Includes latest features and improvements
369
+
370
+ - Updated dependencies
371
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023094104
372
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023094104
373
+
374
+ ## 0.0.0-alpha-20251023093942
375
+
376
+ ### Patch Changes
377
+
378
+ - alpha release 0.0.1-alpha.13
379
+ - Update all public packages to version 0.0.1-alpha.13
380
+ - Trigger automated alpha release workflow
381
+ - Includes latest features and improvements
382
+
383
+ - Updated dependencies
384
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023093942
385
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023093942
386
+
387
+ ## 0.0.2
388
+
389
+ ### Patch Changes
390
+
391
+ - stable release 0.0.2
392
+ - Update all public packages to version 0.0.2
393
+ - Trigger automated stable release workflow
394
+ - Includes latest features and improvements
395
+
396
+ - Updated dependencies
397
+ - @cloudbase/agent-agents@0.0.2
398
+ - @cloudbase/agent-shared@0.0.2
399
+
400
+ ## 0.0.0-alpha-20251023054807
401
+
402
+ ### Patch Changes
403
+
404
+ - alpha release 0.0.1-alpha.12
405
+ - Update all public packages to version 0.0.1-alpha.12
406
+ - Trigger automated alpha release workflow
407
+ - Includes latest features and improvements
408
+
409
+ - Updated dependencies
410
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023054807
411
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023054807
412
+
413
+ ## 0.0.0-alpha-20251023054737
414
+
415
+ ### Patch Changes
416
+
417
+ - Alpha release with latest features and improvements including MCP knowledge retrieval examples and configuration validation fixes.
418
+ - Updated dependencies
419
+ - @cloudbase/agent-agents@0.0.0-alpha-20251023054737
420
+ - @cloudbase/agent-shared@0.0.0-alpha-20251023054737
421
+
422
+ ## 0.0.2
423
+
424
+ ### Patch Changes
425
+
426
+ - stable release 0.0.1
427
+ - Update all public packages to version 0.0.1
428
+ - Trigger automated stable release workflow
429
+ - Includes latest features and improvements
430
+
431
+ - Updated dependencies
432
+ - @cloudbase/agent-agents@0.0.2
433
+ - @cloudbase/agent-shared@0.0.2
434
+
435
+ ## 0.0.0-alpha-20251022083933
436
+
437
+ ### Patch Changes
438
+
439
+ - alpha release 0.0.1-alpha.11
440
+ - Update all public packages to version 0.0.1-alpha.11
441
+ - Trigger automated alpha release workflow
442
+ - Includes latest features and improvements
443
+
444
+ - Updated dependencies
445
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022083933
446
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022083933
447
+
448
+ ## 0.0.0-alpha-20251022080712
449
+
450
+ ### Patch Changes
451
+
452
+ - Alpha release 0.0.1-alpha.10
453
+ - Update all public packages to version 0.0.1-alpha.10
454
+ - Trigger automated alpha release workflow
455
+ - Includes latest features and improvements
456
+
457
+ - Updated dependencies
458
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022080712
459
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022080712
460
+
461
+ ## 0.0.0-alpha-20251022072016
462
+
463
+ ### Patch Changes
464
+
465
+ - Alpha release with latest features and improvements
466
+ - Make @cloudbase/agent-example-ui-web-shared package public
467
+ - Update all public packages to alpha version
468
+ - Include shared UI components in public release
469
+
470
+ - Updated dependencies
471
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022072016
472
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022072016
473
+
474
+ ## 0.0.0-alpha-20251022071917
475
+
476
+ ### Patch Changes
477
+
478
+ - Alpha release with latest features and improvements
479
+ - Make @cloudbase/agent-example-ui-web-shared package public
480
+ - Update all public packages to alpha version
481
+ - Include shared UI components in public release
482
+
483
+ - Updated dependencies
484
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022071917
485
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022071917
486
+
487
+ ## 0.0.0-alpha-20251022064104
488
+
489
+ ### Patch Changes
490
+
491
+ - Fix alpha release versioning format
492
+ - Fix Changesets configuration for proper alpha versioning
493
+ - Reset to correct v0.0.1-alpha.X format
494
+ - Include recent improvements and bug fixes
495
+
496
+ - Updated dependencies
497
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022064104
498
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022064104
499
+
500
+ ## 0.0.0-alpha-20251022043017
501
+
502
+ ### Patch Changes
503
+
504
+ - Alpha release with CI improvements and quickstart enhancements
505
+ - Remove CloudBase docs deployment from CI workflow
506
+ - Update quickstart guide with modern ES modules setup
507
+ - Add support for multiple LLM providers (OpenAI, Zhipu, Qwen, DeepSeek, Ollama)
508
+ - Simplify configuration and improve code examples
509
+ - Remove UUID validation from conversationId for flexibility
510
+ - Update dependencies and build scripts for better DX
511
+
512
+ - Updated dependencies
513
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022043017
514
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022043017
515
+
516
+ ## 0.0.0-alpha-20251022031106
517
+
518
+ ### Patch Changes
519
+
520
+ - Alpha release with dependency updates and improvements
521
+ - Updated dependencies and package configurations
522
+ - Enhanced example configurations
523
+ - Bug fixes and performance improvements
524
+ - Improved stability and reliability
525
+
526
+ - Updated dependencies
527
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022031106
528
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022031106
529
+
530
+ ## 0.0.0-alpha-20251022025955
531
+
532
+ ### Patch Changes
533
+
534
+ - Alpha release with latest features and improvements
535
+ - Enhanced documentation and hero section
536
+ - Improved framework logo integration
537
+ - Updated documentation standards
538
+ - Bug fixes and performance improvements
539
+
540
+ - Updated dependencies
541
+ - @cloudbase/agent-agents@0.0.0-alpha-20251022025955
542
+ - @cloudbase/agent-shared@0.0.0-alpha-20251022025955
543
+
544
+ ## 0.0.0-alpha-20251017101436
545
+
546
+ ### Patch Changes
547
+
548
+ - Fix GitHub permissions and test deployment pipeline
549
+ - Updated dependencies
550
+ - @cloudbase/agent-agents@0.0.0-alpha-20251017101436
551
+ - @cloudbase/agent-shared@0.0.0-alpha-20251017101436
552
+
553
+ ## 0.0.0-alpha-20251017100216
554
+
555
+ ### Patch Changes
556
+
557
+ - Fix GitHub Actions workflow issues and test deployment
558
+ - Updated dependencies
559
+ - @cloudbase/agent-agents@0.0.0-alpha-20251017100216
560
+ - @cloudbase/agent-shared@0.0.0-alpha-20251017100216
561
+
562
+ ## 0.0.0-alpha-20251017094344
563
+
564
+ ### Patch Changes
565
+
566
+ - Alpha release with latest features and improvements
567
+ - Updated dependencies
568
+ - @cloudbase/agent-agents@0.0.0-alpha-20251017094344
569
+ - @cloudbase/agent-shared@0.0.0-alpha-20251017094344
570
+
571
+ ## 0.0.0-alpha-20251017093946
572
+
573
+ ### Patch Changes
574
+
575
+ - 54e476e: Initial alpha release for testing purposes. This release includes all core AG-Kit packages and example implementations for community testing and feedback.
576
+ - Updated dependencies [54e476e]
577
+ - @cloudbase/agent-agents@0.0.0-alpha-20251017093946
578
+ - @cloudbase/agent-shared@0.0.0-alpha-20251017093946
579
+
580
+ ## 0.0.0-alpha-20251017081242
581
+
582
+ ### Patch Changes
583
+
584
+ - Initial alpha release for testing purposes. This release includes all core AG-Kit packages and example implementations for community testing and feedback.
585
+ - Updated dependencies
586
+ - @cloudbase/agent-agents@0.0.0-alpha-20251017081242
587
+ - @cloudbase/agent-shared@0.0.0-alpha-20251017081242
@@ -0,0 +1,89 @@
1
+ import express, { Express } from 'express';
2
+ import { AbstractAgent } from '@cloudbase/agent-agents/abstract';
3
+ import cors from 'cors';
4
+ import { AbstractAgent as AbstractAgent$1 } from '@ag-ui/client';
5
+ import { SendMessageInput } from '@cloudbase/agent-shared';
6
+ import { Repeater } from '@repeaterjs/repeater';
7
+ import * as _whatwg_node_server from '@whatwg-node/server';
8
+ import { OpenAI } from 'openai';
9
+
10
+ type AgentCreatorRet = {
11
+ agent: AbstractAgent | {
12
+ toAGUIAgent(): AbstractAgent;
13
+ };
14
+ cleanup?: () => void;
15
+ };
16
+ type AgentCreator = () => AgentCreatorRet | Promise<AgentCreatorRet>;
17
+ interface ICreateServer {
18
+ createAgent: AgentCreator;
19
+ basePath?: `/${string}/`;
20
+ cors?: boolean | cors.CorsOptions;
21
+ }
22
+ declare function run(props: ICreateServer & {
23
+ port?: number | string;
24
+ }): void;
25
+ declare function createExpressServer(props: ICreateServer): Express;
26
+ interface ICreateExpressRoutes extends ICreateServer {
27
+ express: Express;
28
+ }
29
+ declare function createExpressRoutes({ createAgent, basePath: _basePath, express, }: ICreateExpressRoutes): express.Express;
30
+
31
+ declare function handler$1(input: SendMessageInput, agent: AbstractAgent$1): Repeater<{
32
+ type: "text";
33
+ content: string;
34
+ } | {
35
+ type: "tool-call-start";
36
+ toolCallId: string;
37
+ toolCallName: string;
38
+ } | {
39
+ type: "tool-call-args";
40
+ toolCallId: string;
41
+ delta: string;
42
+ } | {
43
+ type: "tool-call-end";
44
+ toolCallId: string;
45
+ } | {
46
+ type: "tool-result";
47
+ toolCallId: string;
48
+ result: string;
49
+ } | {
50
+ type: "interrupt";
51
+ id: string;
52
+ reason: string;
53
+ payload: any;
54
+ }, any, unknown>;
55
+
56
+ declare function createServerAdapter$1(createAgent: AgentCreator): _whatwg_node_server.ServerAdapter<{}, _whatwg_node_server.ServerAdapterBaseObject<{}, (request: Request) => Promise<Response>>>;
57
+
58
+ declare namespace index$3 {
59
+ export { createServerAdapter$1 as createServerAdapter, handler$1 as handler };
60
+ }
61
+
62
+ declare const serverAdapter: _whatwg_node_server.ServerAdapter<{}, _whatwg_node_server.ServerAdapterBaseObject<{}, () => Response>>;
63
+
64
+ declare const index$2_serverAdapter: typeof serverAdapter;
65
+ declare namespace index$2 {
66
+ export { index$2_serverAdapter as serverAdapter };
67
+ }
68
+
69
+ type OpenAIMessage = OpenAI.Chat.Completions.ChatCompletionMessageParam;
70
+ type OpenAITool = OpenAI.Chat.Completions.ChatCompletionTool;
71
+ type ChatCompletionsInput = {
72
+ messages: Array<OpenAIMessage>;
73
+ tools?: Array<OpenAITool>;
74
+ };
75
+ declare function handler(input: ChatCompletionsInput, agent: AbstractAgent$1): Repeater<OpenAI.Chat.Completions.ChatCompletionChunk, any, unknown>;
76
+
77
+ declare function createServerAdapter(createAgent: AgentCreator): _whatwg_node_server.ServerAdapter<{}, _whatwg_node_server.ServerAdapterBaseObject<{}, (request: Request) => Promise<Response>>>;
78
+
79
+ declare const index$1_createServerAdapter: typeof createServerAdapter;
80
+ declare const index$1_handler: typeof handler;
81
+ declare namespace index$1 {
82
+ export { index$1_createServerAdapter as createServerAdapter, index$1_handler as handler };
83
+ }
84
+
85
+ declare namespace index {
86
+ export { index$2 as healthz, index$1 as openai, index$3 as sendMessage };
87
+ }
88
+
89
+ export { type AgentCreator, index as agui, createExpressRoutes, createExpressServer, run };
package/dist/index.js ADDED
@@ -0,0 +1,430 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ agui: () => agui_exports,
33
+ createExpressRoutes: () => createExpressRoutes,
34
+ createExpressServer: () => createExpressServer,
35
+ run: () => run
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
39
+ // src/agui/index.ts
40
+ var agui_exports = {};
41
+ __export(agui_exports, {
42
+ healthz: () => healthz_exports,
43
+ openai: () => openai_exports,
44
+ sendMessage: () => sendMessage_exports
45
+ });
46
+
47
+ // src/agui/sendMessage/index.ts
48
+ var sendMessage_exports = {};
49
+ __export(sendMessage_exports, {
50
+ createServerAdapter: () => createServerAdapter,
51
+ handler: () => handler
52
+ });
53
+
54
+ // src/agui/sendMessage/handler.ts
55
+ var import_client = require("@ag-ui/client");
56
+ var import_uuid = require("uuid");
57
+ var import_repeater = require("@repeaterjs/repeater");
58
+ function handler(input, agent) {
59
+ agent.threadId = input.conversationId;
60
+ if (input.messages) {
61
+ const aguiMessages = input.messages.map(messageToAGUIMessage);
62
+ agent.setMessages(aguiMessages);
63
+ }
64
+ return new import_repeater.Repeater(async (push, stop) => {
65
+ agent.runAgent(
66
+ {
67
+ tools: input.tools,
68
+ forwardedProps: {
69
+ resume: input.resume
70
+ }
71
+ },
72
+ {
73
+ onTextMessageContentEvent: ({ event }) => {
74
+ push({
75
+ type: "text",
76
+ content: event.delta
77
+ });
78
+ },
79
+ onRunFinishedEvent: () => {
80
+ stop();
81
+ },
82
+ onToolCallStartEvent: ({ event }) => {
83
+ push({
84
+ type: "tool-call-start",
85
+ toolCallId: event.toolCallId,
86
+ toolCallName: event.toolCallName
87
+ });
88
+ },
89
+ onToolCallArgsEvent: ({ event }) => {
90
+ push({
91
+ type: "tool-call-args",
92
+ toolCallId: event.toolCallId,
93
+ delta: event.delta
94
+ });
95
+ },
96
+ onToolCallEndEvent: ({ event }) => {
97
+ push({
98
+ type: "tool-call-end",
99
+ toolCallId: event.toolCallId
100
+ });
101
+ },
102
+ onToolCallResultEvent: ({ event }) => {
103
+ push({
104
+ type: "tool-result",
105
+ result: event.content,
106
+ toolCallId: event.toolCallId
107
+ });
108
+ },
109
+ onEvent: ({ event }) => {
110
+ if (event.type !== import_client.EventType.RUN_FINISHED) {
111
+ return;
112
+ }
113
+ if (event["outcome"] !== "interrupt") {
114
+ return;
115
+ }
116
+ const interrupt = event["interrupt"];
117
+ push({
118
+ type: "interrupt",
119
+ id: interrupt.id,
120
+ reason: interrupt.reason,
121
+ payload: interrupt.payload
122
+ });
123
+ }
124
+ }
125
+ );
126
+ });
127
+ }
128
+ function messageToAGUIMessage(message) {
129
+ if (message.role === "system" || message.role === "user") {
130
+ return {
131
+ id: (0, import_uuid.v4)(),
132
+ role: message.role,
133
+ content: message.content
134
+ };
135
+ }
136
+ if (message.role === "tool") {
137
+ return {
138
+ role: "tool",
139
+ toolCallId: message.toolCallId,
140
+ content: message.content,
141
+ id: (0, import_uuid.v4)()
142
+ };
143
+ }
144
+ if (message.role === "assistant") {
145
+ return {
146
+ role: "assistant",
147
+ content: message.content,
148
+ id: (0, import_uuid.v4)(),
149
+ toolCalls: message.toolCalls
150
+ };
151
+ }
152
+ }
153
+
154
+ // src/agui/sendMessage/server.ts
155
+ var import_server = require("@whatwg-node/server");
156
+ var import_agent_shared = require("@cloudbase/agent-shared");
157
+ function createServerAdapter(createAgent) {
158
+ return (0, import_server.createServerAdapter)(async (request) => {
159
+ const input = import_agent_shared.sendMessageInputSchema.parse(await request.json());
160
+ const { agent: unknownAgent, cleanup } = await Promise.resolve(createAgent());
161
+ const agent = "toAGUIAgent" in unknownAgent ? unknownAgent.toAGUIAgent() : unknownAgent;
162
+ const events = handler(input, agent);
163
+ let heartbeat;
164
+ const stream = new ReadableStream({
165
+ async start(controller) {
166
+ const encoder = new TextEncoder();
167
+ heartbeat = setInterval(() => {
168
+ controller.enqueue(encoder.encode(":ping\n\n"));
169
+ }, 15 * 1e3);
170
+ try {
171
+ for await (const event of events) {
172
+ const sseChunk = `data: ${JSON.stringify(event)}
173
+
174
+ `;
175
+ controller.enqueue(encoder.encode(sseChunk));
176
+ }
177
+ controller.enqueue(encoder.encode("data: [DONE]\n\n"));
178
+ } finally {
179
+ if (heartbeat) clearInterval(heartbeat);
180
+ controller.close();
181
+ cleanup == null ? void 0 : cleanup();
182
+ }
183
+ },
184
+ cancel() {
185
+ if (heartbeat) clearInterval(heartbeat);
186
+ }
187
+ });
188
+ const headers = new Headers({
189
+ "Content-Type": "text/event-stream",
190
+ "Cache-Control": "no-cache, no-transform",
191
+ Connection: "keep-alive"
192
+ });
193
+ return new Response(stream, { status: 200, headers });
194
+ });
195
+ }
196
+
197
+ // src/agui/healthz/index.ts
198
+ var healthz_exports = {};
199
+ __export(healthz_exports, {
200
+ serverAdapter: () => serverAdapter
201
+ });
202
+ var import_server3 = require("@whatwg-node/server");
203
+ var serverAdapter = (0, import_server3.createServerAdapter)(() => new Response("OK"));
204
+
205
+ // src/agui/openai/index.ts
206
+ var openai_exports = {};
207
+ __export(openai_exports, {
208
+ createServerAdapter: () => createServerAdapter2,
209
+ handler: () => handler2
210
+ });
211
+
212
+ // src/agui/openai/handler.ts
213
+ var import_uuid2 = require("uuid");
214
+ var import_repeater2 = require("@repeaterjs/repeater");
215
+ function handler2(input, agent) {
216
+ var _a;
217
+ const res = handler(
218
+ {
219
+ messages: input.messages.map(openAIMessageToClientMessage),
220
+ tools: (_a = input.tools) == null ? void 0 : _a.filter((tool) => tool.type === "function").map((tool) => ({
221
+ name: tool.function.name,
222
+ description: tool.function.description,
223
+ parameters: tool.function.parameters
224
+ })),
225
+ conversationId: (0, import_uuid2.v4)()
226
+ },
227
+ agent
228
+ );
229
+ return new import_repeater2.Repeater(async (push, stop) => {
230
+ const id = (0, import_uuid2.v4)();
231
+ let tools = [];
232
+ let lastWithToolCall = false;
233
+ let maxIndex = 0;
234
+ const toolIdToIndex = {};
235
+ for await (let x of res) {
236
+ if (x.type === "text") {
237
+ lastWithToolCall = false;
238
+ push({
239
+ id,
240
+ object: "chat.completion.chunk",
241
+ model: "",
242
+ choices: [
243
+ {
244
+ delta: {
245
+ role: "assistant",
246
+ content: x.content
247
+ },
248
+ index: 0,
249
+ finish_reason: null
250
+ }
251
+ ],
252
+ created: Date.now()
253
+ });
254
+ }
255
+ if (x.type === "tool-call-start") {
256
+ toolIdToIndex[x.toolCallId] = maxIndex;
257
+ maxIndex++;
258
+ tools.push({
259
+ name: x.toolCallName,
260
+ id: x.toolCallId,
261
+ args: ""
262
+ });
263
+ }
264
+ if (x.type === "tool-call-args") {
265
+ tools.find((t) => t.id === x.toolCallId).args += x.delta;
266
+ }
267
+ if (x.type === "tool-call-end") {
268
+ const index = tools.findIndex((t) => t.id === x.toolCallId);
269
+ const [tool] = tools.splice(index, 1);
270
+ lastWithToolCall = true;
271
+ push({
272
+ id,
273
+ created: Date.now(),
274
+ model: "",
275
+ object: "chat.completion.chunk",
276
+ choices: [
277
+ {
278
+ index: 0,
279
+ finish_reason: null,
280
+ delta: {
281
+ tool_calls: [
282
+ {
283
+ index: toolIdToIndex[tool.id],
284
+ type: "function",
285
+ id: tool.id,
286
+ function: {
287
+ name: tool.name,
288
+ arguments: tool.args
289
+ }
290
+ }
291
+ ]
292
+ }
293
+ }
294
+ ]
295
+ });
296
+ }
297
+ }
298
+ push({
299
+ id,
300
+ object: "chat.completion.chunk",
301
+ model: "",
302
+ created: Date.now(),
303
+ choices: [
304
+ {
305
+ finish_reason: lastWithToolCall ? "tool_calls" : "stop",
306
+ index: 0,
307
+ delta: {}
308
+ }
309
+ ]
310
+ });
311
+ stop();
312
+ });
313
+ }
314
+ function openAIMessageToClientMessage(message) {
315
+ var _a;
316
+ if (message.role === "developer" || message.role === "system") {
317
+ return {
318
+ role: "system",
319
+ content: typeof message.content === "string" ? message.content : message.content.map((p) => p.text).join("")
320
+ };
321
+ }
322
+ if (message.role === "user") {
323
+ return {
324
+ role: "user",
325
+ content: typeof message.content === "string" ? message.content : message.content.filter((p) => p.type === "text").map((p) => p.text).join("")
326
+ };
327
+ }
328
+ if (message.role === "assistant") {
329
+ return {
330
+ role: "assistant",
331
+ content: typeof message.content === "string" ? message.content : message.content.filter((p) => p.type === "text").map((p) => p.text).join(""),
332
+ toolCalls: (_a = message.tool_calls) == null ? void 0 : _a.filter((t) => t.type === "function").map((toolCall) => ({
333
+ id: toolCall.id,
334
+ type: "function",
335
+ function: {
336
+ name: toolCall.function.name,
337
+ arguments: toolCall.function.arguments
338
+ }
339
+ }))
340
+ };
341
+ }
342
+ if (message.role === "tool") {
343
+ return {
344
+ role: "tool",
345
+ content: typeof message.content === "string" ? message.content : message.content.map((c) => c.text).join(""),
346
+ toolCallId: message.tool_call_id
347
+ };
348
+ }
349
+ if (message.role === "function") {
350
+ throw new Error("unreachable: function message is deprecated");
351
+ }
352
+ }
353
+
354
+ // src/agui/openai/server.ts
355
+ var import_server4 = require("@whatwg-node/server");
356
+ function createServerAdapter2(createAgent) {
357
+ return (0, import_server4.createServerAdapter)(async (request) => {
358
+ const input = await request.json();
359
+ const { agent: unknownAgent, cleanup } = await Promise.resolve(createAgent());
360
+ const agent = "toAGUIAgent" in unknownAgent ? unknownAgent.toAGUIAgent() : unknownAgent;
361
+ const events = handler2(input, agent);
362
+ const stream = new ReadableStream({
363
+ async start(controller) {
364
+ const encoder = new TextEncoder();
365
+ for await (const event of events) {
366
+ const sseChunk = `data: ${JSON.stringify(event)}
367
+
368
+ `;
369
+ controller.enqueue(encoder.encode(sseChunk));
370
+ }
371
+ controller.enqueue(encoder.encode("data: [DONE]\n\n"));
372
+ controller.close();
373
+ cleanup == null ? void 0 : cleanup();
374
+ }
375
+ });
376
+ const headers = new Headers({
377
+ "Content-Type": "text/event-stream",
378
+ "Cache-Control": "no-cache, no-transform",
379
+ Connection: "keep-alive"
380
+ });
381
+ return new Response(stream, { status: 200, headers });
382
+ });
383
+ }
384
+
385
+ // src/express.ts
386
+ var import_express = __toESM(require("express"));
387
+ var import_cors = __toESM(require("cors"));
388
+ function run(props) {
389
+ const { port, ...rest } = props;
390
+ createExpressServer(rest).listen(
391
+ typeof port === "number" ? port : parseInt(port)
392
+ );
393
+ }
394
+ function createExpressServer(props) {
395
+ const { cors: corsOption = true } = props;
396
+ const app = (0, import_express.default)();
397
+ if (corsOption) {
398
+ app.use(isCorsOptions(corsOption) ? (0, import_cors.default)(corsOption) : (0, import_cors.default)());
399
+ }
400
+ createExpressRoutes({
401
+ ...props,
402
+ express: app,
403
+ basePath: props.basePath ?? process.env.TENCENTCLOUD_RUNENV === "SCF" ? "/v1/aibot/bots/:agentId/" : void 0
404
+ });
405
+ return app;
406
+ }
407
+ function createExpressRoutes({
408
+ createAgent,
409
+ basePath: _basePath,
410
+ express: express2
411
+ }) {
412
+ const basePath = _basePath ?? "/";
413
+ const sendMessageServerAdapter = sendMessage_exports.createServerAdapter(createAgent);
414
+ const openaiServerAdapter = openai_exports.createServerAdapter(createAgent);
415
+ const healthzServerAdapter = healthz_exports.serverAdapter;
416
+ express2.use(`${basePath}send-message`, sendMessageServerAdapter);
417
+ express2.use(`${basePath}healthz`, healthzServerAdapter);
418
+ express2.use(`${basePath}chat/completions`, openaiServerAdapter);
419
+ return express2;
420
+ }
421
+ function isCorsOptions(cors2) {
422
+ return typeof cors2 === "boolean";
423
+ }
424
+ // Annotate the CommonJS export names for ESM import in node:
425
+ 0 && (module.exports = {
426
+ agui,
427
+ createExpressRoutes,
428
+ createExpressServer,
429
+ run
430
+ });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@cloudbase/agent-server",
3
+ "version": "0.0.2",
4
+ "main": "dist/index.js",
5
+ "files": [
6
+ "dist/",
7
+ "README.md",
8
+ "CHANGELOG.md"
9
+ ],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "@ag-ui/client": "^0.0.38",
15
+ "@repeaterjs/repeater": "^3.0.6",
16
+ "@whatwg-node/server": "^0.10.12",
17
+ "cors": "^2.8.5",
18
+ "express": "^5.1.0",
19
+ "openai": "6.3.0",
20
+ "uuid": "^10.0.0",
21
+ "zod": "^4.1.12",
22
+ "@cloudbase/agent-agents": "0.0.2",
23
+ "@cloudbase/agent-shared": "^0.0.2"
24
+ },
25
+ "devDependencies": {
26
+ "@types/cors": "^2.8.19",
27
+ "@types/express": "^5.0.3",
28
+ "tsup": "^8.5.0"
29
+ },
30
+ "scripts": {
31
+ "test": "echo \"Error: no test specified\" && exit 1",
32
+ "build": "tsup --config tsup.config.ts"
33
+ }
34
+ }