@cloudbase/agent-server 0.0.6 → 0.0.8

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 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
- declare function run(props: ICreateServer & {
26
+ interface IRun extends ICreateServer {
25
27
  port?: number | string;
26
- }): Promise<void>;
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 createExpressRoutes({ createAgent, basePath: _basePath, express, useAGUI, aguiOptions, }: ICreateExpressRoutes): Promise<express.Express>;
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,36 @@ 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
- async function run(props) {
463
+ function run(props) {
464
464
  const { port, ...rest } = props;
465
- (await createExpressServer(rest)).listen(
465
+ createExpressServer(rest).listen(
466
466
  typeof port === "number" ? port : parseInt(port)
467
467
  );
468
468
  }
469
- async function createExpressServer(props) {
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
- await createExpressRoutes({
476
- ...props,
477
- express: app,
478
- basePath: props.basePath ?? process.env.TENCENTCLOUD_RUNENV === "SCF" ? "/v1/aibot/bots/:agentId/" : void 0
475
+ createExpressRoutes({
476
+ ...rest,
477
+ express: app
479
478
  });
480
479
  return app;
481
480
  }
482
- async function createExpressRoutes({
481
+ function createExpressRoutes({
483
482
  createAgent,
484
483
  basePath: _basePath,
485
484
  express: express2,
486
- useAGUI,
485
+ useAGUI: _useAGUI,
487
486
  aguiOptions
488
487
  }) {
489
- const basePath = _basePath ?? "/";
488
+ const useAGUI = _useAGUI ?? true;
489
+ const basePath = _basePath ?? (process.env.TENCENTCLOUD_RUNENV === "SCF" ? "/v1/aibot/bots/:agentId/" : void 0);
490
490
  const sendMessageServerAdapter = useAGUI ? sendMessageAGUI_exports.createServerAdapter(createAgent) : sendMessage_exports.createServerAdapter(createAgent);
491
491
  if (useAGUI) {
492
- await createAGUIRoute({
492
+ createAGUIRoute({
493
493
  basePath,
494
494
  express: express2,
495
495
  createAgent,
@@ -503,32 +503,41 @@ async function createExpressRoutes({
503
503
  express2.use(`${basePath}chat/completions`, openaiServerAdapter);
504
504
  return express2;
505
505
  }
506
- async function createAGUIRoute({
506
+ var AGUIRpcHandlerPromise = null;
507
+ function getAGUIRpcHandler({
507
508
  createAgent,
508
- express: express2,
509
- agentId,
510
- basePath,
511
509
  runtimeOptions,
510
+ basePath,
512
511
  endpointOptions
513
512
  }) {
514
- const agent = (await createAgent()).agent;
515
- const aguiAgent = "toAGUIAgent" in agent ? agent.toAGUIAgent() : agent;
516
- const runtime = new import_runtime.CopilotRuntime({
517
- agents: {
518
- [agentId || "default"]: aguiAgent
519
- },
520
- ...runtimeOptions || {}
521
- });
522
- const rpcHandler = (0, import_runtime.copilotRuntimeNodeExpressEndpoint)({
523
- endpoint: `${basePath}agui`,
524
- runtime,
525
- serviceAdapter: new import_runtime.EmptyAdapter(),
526
- ...endpointOptions || {}
513
+ if (AGUIRpcHandlerPromise) return AGUIRpcHandlerPromise;
514
+ AGUIRpcHandlerPromise = (async () => {
515
+ const agent = (await createAgent()).agent;
516
+ const aguiAgent = "toAGUIAgent" in agent ? agent.toAGUIAgent() : agent;
517
+ const runtime = new import_runtime.CopilotRuntime({
518
+ agents: {
519
+ default: aguiAgent
520
+ },
521
+ ...runtimeOptions || {}
522
+ });
523
+ return (0, import_runtime.copilotRuntimeNodeExpressEndpoint)({
524
+ endpoint: `${basePath}agui`,
525
+ runtime,
526
+ serviceAdapter: new import_runtime.EmptyAdapter(),
527
+ ...endpointOptions || {}
528
+ });
529
+ })();
530
+ return AGUIRpcHandlerPromise;
531
+ }
532
+ function createAGUIRoute(props) {
533
+ const { express: express2, basePath } = props;
534
+ express2.post(`${basePath}agui`, async (req, res) => {
535
+ const rpcHandler = await getAGUIRpcHandler(props);
536
+ rpcHandler(req, res);
527
537
  });
528
- express2.post(`${basePath}agui`, rpcHandler);
529
538
  }
530
539
  function isCorsOptions(cors2) {
531
- return typeof cors2 === "boolean";
540
+ return typeof cors2 !== "boolean";
532
541
  }
533
542
  // Annotate the CommonJS export names for ESM import in node:
534
543
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/agent-server",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
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.6"
23
+ "@cloudbase/agent-shared": "^0.0.8"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/cors": "^2.8.19",