@cloudbase/agent-server 0.0.3 → 0.0.7
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 +12 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +39 -29
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @cloudbase/agent-server
|
|
2
2
|
|
|
3
|
+
## 1.0.1-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- alpha release 0.1.2-alpha.1
|
|
8
|
+
- Update all public packages to version 0.1.2-alpha.1
|
|
9
|
+
- Trigger automated alpha release workflow
|
|
10
|
+
- Includes latest features and improvements
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @cloudbase/agent-shared@1.0.1-alpha.4
|
|
14
|
+
|
|
3
15
|
## 0.0.11-alpha.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -20,19 +20,19 @@ interface ICreateServer {
|
|
|
20
20
|
createAgent: AgentCreator;
|
|
21
21
|
basePath?: `/${string}/`;
|
|
22
22
|
cors?: boolean | cors.CorsOptions;
|
|
23
|
+
useAGUI?: boolean;
|
|
24
|
+
aguiOptions?: AGUIOptions;
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
interface IRun extends ICreateServer {
|
|
25
27
|
port?: number | string;
|
|
26
|
-
}
|
|
27
|
-
declare function createExpressServer(props: ICreateServer): Promise<Express>;
|
|
28
|
+
}
|
|
28
29
|
interface ICreateExpressRoutes extends ICreateServer {
|
|
29
30
|
express: Express;
|
|
30
|
-
useAGUI?: boolean;
|
|
31
|
-
aguiOptions?: AGUIOptions;
|
|
32
31
|
}
|
|
33
|
-
declare function
|
|
32
|
+
declare function run(props: IRun): void;
|
|
33
|
+
declare function createExpressServer(props: ICreateServer): Express;
|
|
34
|
+
declare function createExpressRoutes({ createAgent, basePath: _basePath, express, useAGUI: _useAGUI, aguiOptions, }: ICreateExpressRoutes): express.Express;
|
|
34
35
|
interface AGUIOptions {
|
|
35
|
-
agentId?: string;
|
|
36
36
|
runtimeOptions?: Partial<CopilotRuntimeOptions>;
|
|
37
37
|
endpointOptions?: Partial<CreateCopilotRuntimeServerOptions>;
|
|
38
38
|
}
|
package/dist/index.js
CHANGED
|
@@ -460,36 +460,37 @@ function createServerAdapter3(createAgent) {
|
|
|
460
460
|
var import_runtime = require("@copilotkit/runtime");
|
|
461
461
|
var import_express = __toESM(require("express"));
|
|
462
462
|
var import_cors = __toESM(require("cors"));
|
|
463
|
-
|
|
463
|
+
function run(props) {
|
|
464
464
|
const { port, ...rest } = props;
|
|
465
|
-
|
|
465
|
+
createExpressServer(rest).listen(
|
|
466
466
|
typeof port === "number" ? port : parseInt(port)
|
|
467
467
|
);
|
|
468
468
|
}
|
|
469
|
-
|
|
470
|
-
const { cors: corsOption = true } = props;
|
|
469
|
+
function createExpressServer(props) {
|
|
470
|
+
const { cors: corsOption = true, ...rest } = props;
|
|
471
471
|
const app = (0, import_express.default)();
|
|
472
472
|
if (corsOption) {
|
|
473
473
|
app.use(isCorsOptions(corsOption) ? (0, import_cors.default)(corsOption) : (0, import_cors.default)());
|
|
474
474
|
}
|
|
475
|
-
|
|
476
|
-
...
|
|
475
|
+
createExpressRoutes({
|
|
476
|
+
...rest,
|
|
477
477
|
express: app,
|
|
478
|
-
basePath: props.basePath ?? process.env.TENCENTCLOUD_RUNENV === "SCF" ? "/v1/aibot/bots/:agentId/" : void 0
|
|
478
|
+
basePath: props.basePath ?? (process.env.TENCENTCLOUD_RUNENV === "SCF" ? "/v1/aibot/bots/:agentId/" : void 0)
|
|
479
479
|
});
|
|
480
480
|
return app;
|
|
481
481
|
}
|
|
482
|
-
|
|
482
|
+
function createExpressRoutes({
|
|
483
483
|
createAgent,
|
|
484
484
|
basePath: _basePath,
|
|
485
485
|
express: express2,
|
|
486
|
-
useAGUI,
|
|
486
|
+
useAGUI: _useAGUI,
|
|
487
487
|
aguiOptions
|
|
488
488
|
}) {
|
|
489
|
+
const useAGUI = _useAGUI ?? true;
|
|
489
490
|
const basePath = _basePath ?? "/";
|
|
490
491
|
const sendMessageServerAdapter = useAGUI ? sendMessageAGUI_exports.createServerAdapter(createAgent) : sendMessage_exports.createServerAdapter(createAgent);
|
|
491
492
|
if (useAGUI) {
|
|
492
|
-
|
|
493
|
+
createAGUIRoute({
|
|
493
494
|
basePath,
|
|
494
495
|
express: express2,
|
|
495
496
|
createAgent,
|
|
@@ -503,32 +504,41 @@ async function createExpressRoutes({
|
|
|
503
504
|
express2.use(`${basePath}chat/completions`, openaiServerAdapter);
|
|
504
505
|
return express2;
|
|
505
506
|
}
|
|
506
|
-
|
|
507
|
+
var AGUIRpcHandlerPromise = null;
|
|
508
|
+
function getAGUIRpcHandler({
|
|
507
509
|
createAgent,
|
|
508
|
-
express: express2,
|
|
509
|
-
agentId,
|
|
510
|
-
basePath,
|
|
511
510
|
runtimeOptions,
|
|
511
|
+
basePath,
|
|
512
512
|
endpointOptions
|
|
513
513
|
}) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
514
|
+
if (AGUIRpcHandlerPromise) return AGUIRpcHandlerPromise;
|
|
515
|
+
AGUIRpcHandlerPromise = (async () => {
|
|
516
|
+
const agent = (await createAgent()).agent;
|
|
517
|
+
const aguiAgent = "toAGUIAgent" in agent ? agent.toAGUIAgent() : agent;
|
|
518
|
+
const runtime = new import_runtime.CopilotRuntime({
|
|
519
|
+
agents: {
|
|
520
|
+
default: aguiAgent
|
|
521
|
+
},
|
|
522
|
+
...runtimeOptions || {}
|
|
523
|
+
});
|
|
524
|
+
return (0, import_runtime.copilotRuntimeNodeExpressEndpoint)({
|
|
525
|
+
endpoint: `${basePath}agui`,
|
|
526
|
+
runtime,
|
|
527
|
+
serviceAdapter: new import_runtime.EmptyAdapter(),
|
|
528
|
+
...endpointOptions || {}
|
|
529
|
+
});
|
|
530
|
+
})();
|
|
531
|
+
return AGUIRpcHandlerPromise;
|
|
532
|
+
}
|
|
533
|
+
function createAGUIRoute(props) {
|
|
534
|
+
const { express: express2, basePath } = props;
|
|
535
|
+
express2.post(`${basePath}agui`, async (req, res) => {
|
|
536
|
+
const rpcHandler = await getAGUIRpcHandler(props);
|
|
537
|
+
rpcHandler(req, res);
|
|
527
538
|
});
|
|
528
|
-
express2.post(`${basePath}agui`, rpcHandler);
|
|
529
539
|
}
|
|
530
540
|
function isCorsOptions(cors2) {
|
|
531
|
-
return typeof cors2
|
|
541
|
+
return typeof cors2 !== "boolean";
|
|
532
542
|
}
|
|
533
543
|
// Annotate the CommonJS export names for ESM import in node:
|
|
534
544
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/agent-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"openai": "6.3.0",
|
|
21
21
|
"uuid": "^10.0.0",
|
|
22
22
|
"zod": "^4.1.12",
|
|
23
|
-
"@cloudbase/agent-shared": "^0.0.
|
|
23
|
+
"@cloudbase/agent-shared": "^0.0.7"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/cors": "^2.8.19",
|