@copilotkitnext/runtime 1.51.2-next.1 → 1.51.3-next.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/index.d.mts CHANGED
@@ -1,21 +1,46 @@
1
- import { C as CopilotRuntime, A as AgentRunner, a as AgentRunnerRunRequest, b as AgentRunnerConnectRequest, c as AgentRunnerIsRunningRequest, d as AgentRunnerStopRequest } from './runtime-BEcxV64L.mjs';
2
- export { e as CopilotRuntimeOptions, V as VERSION } from './runtime-BEcxV64L.mjs';
1
+ import { C as CopilotRuntime, A as AgentRunner, a as AgentRunnerRunRequest, b as AgentRunnerConnectRequest, c as AgentRunnerIsRunningRequest, d as AgentRunnerStopRequest } from './runtime-biMoHc-z.mjs';
2
+ export { e as CopilotRuntimeOptions, T as TranscribeFileOptions, f as TranscriptionService, V as VERSION } from './runtime-biMoHc-z.mjs';
3
3
  import * as hono_hono_base from 'hono/hono-base';
4
4
  import * as hono_utils_http_status from 'hono/utils/http-status';
5
5
  import { Observable } from 'rxjs';
6
6
  import { BaseEvent } from '@ag-ui/client';
7
7
  export { finalizeRunEvents } from '@copilotkitnext/shared';
8
8
 
9
+ /**
10
+ * CORS configuration for CopilotKit endpoints.
11
+ * When using credentials (e.g., HTTP-only cookies), you must specify an explicit origin.
12
+ */
13
+ interface CopilotEndpointCorsConfig {
14
+ /**
15
+ * Allowed origin(s) for CORS. Can be:
16
+ * - A string: exact origin (e.g., "https://myapp.com")
17
+ * - An array: list of allowed origins
18
+ * - A function: dynamic origin resolution
19
+ *
20
+ * Note: When credentials is true, origin cannot be "*"
21
+ */
22
+ origin: string | string[] | ((origin: string, c: any) => string | undefined | null);
23
+ /**
24
+ * Whether to allow credentials (cookies, HTTP authentication).
25
+ * When true, origin must be explicitly specified (not "*").
26
+ */
27
+ credentials?: boolean;
28
+ }
9
29
  interface CopilotEndpointParams {
10
30
  runtime: CopilotRuntime;
11
31
  basePath: string;
32
+ /**
33
+ * Optional CORS configuration. When not provided, defaults to allowing all origins without credentials.
34
+ * To support HTTP-only cookies, provide cors config with credentials: true and explicit origin.
35
+ */
36
+ cors?: CopilotEndpointCorsConfig;
12
37
  }
13
38
  type CopilotEndpointContext$1 = {
14
39
  Variables: {
15
40
  modifiedRequest?: Request;
16
41
  };
17
42
  };
18
- declare function createCopilotEndpoint({ runtime, basePath }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext$1, {
43
+ declare function createCopilotEndpoint({ runtime, basePath, cors: corsConfig }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext$1, {
19
44
  [x: `${string}/agent/:agentId/run`]: {
20
45
  $post: {
21
46
  input: {
@@ -82,13 +107,18 @@ interface CopilotSingleEndpointParams {
82
107
  * Absolute path at which to mount the single-route endpoint (e.g. "/api/copilotkit").
83
108
  */
84
109
  basePath: string;
110
+ /**
111
+ * Optional CORS configuration. When not provided, defaults to allowing all origins without credentials.
112
+ * To support HTTP-only cookies, provide cors config with credentials: true and explicit origin.
113
+ */
114
+ cors?: CopilotEndpointCorsConfig;
85
115
  }
86
116
  type CopilotEndpointContext = {
87
117
  Variables: {
88
118
  modifiedRequest?: Request;
89
119
  };
90
120
  };
91
- declare function createCopilotEndpointSingleRoute({ runtime, basePath }: CopilotSingleEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
121
+ declare function createCopilotEndpointSingleRoute({ runtime, basePath, cors: corsConfig }: CopilotSingleEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
92
122
  [x: string]: {
93
123
  $post: {
94
124
  input: {};
@@ -106,4 +136,4 @@ declare class InMemoryAgentRunner extends AgentRunner {
106
136
  stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
107
137
  }
108
138
 
109
- export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, CopilotRuntime, InMemoryAgentRunner, createCopilotEndpoint, createCopilotEndpointSingleRoute };
139
+ export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, type CopilotEndpointCorsConfig, CopilotRuntime, InMemoryAgentRunner, createCopilotEndpoint, createCopilotEndpointSingleRoute };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,46 @@
1
- import { C as CopilotRuntime, A as AgentRunner, a as AgentRunnerRunRequest, b as AgentRunnerConnectRequest, c as AgentRunnerIsRunningRequest, d as AgentRunnerStopRequest } from './runtime-BEcxV64L.js';
2
- export { e as CopilotRuntimeOptions, V as VERSION } from './runtime-BEcxV64L.js';
1
+ import { C as CopilotRuntime, A as AgentRunner, a as AgentRunnerRunRequest, b as AgentRunnerConnectRequest, c as AgentRunnerIsRunningRequest, d as AgentRunnerStopRequest } from './runtime-biMoHc-z.js';
2
+ export { e as CopilotRuntimeOptions, T as TranscribeFileOptions, f as TranscriptionService, V as VERSION } from './runtime-biMoHc-z.js';
3
3
  import * as hono_hono_base from 'hono/hono-base';
4
4
  import * as hono_utils_http_status from 'hono/utils/http-status';
5
5
  import { Observable } from 'rxjs';
6
6
  import { BaseEvent } from '@ag-ui/client';
7
7
  export { finalizeRunEvents } from '@copilotkitnext/shared';
8
8
 
9
+ /**
10
+ * CORS configuration for CopilotKit endpoints.
11
+ * When using credentials (e.g., HTTP-only cookies), you must specify an explicit origin.
12
+ */
13
+ interface CopilotEndpointCorsConfig {
14
+ /**
15
+ * Allowed origin(s) for CORS. Can be:
16
+ * - A string: exact origin (e.g., "https://myapp.com")
17
+ * - An array: list of allowed origins
18
+ * - A function: dynamic origin resolution
19
+ *
20
+ * Note: When credentials is true, origin cannot be "*"
21
+ */
22
+ origin: string | string[] | ((origin: string, c: any) => string | undefined | null);
23
+ /**
24
+ * Whether to allow credentials (cookies, HTTP authentication).
25
+ * When true, origin must be explicitly specified (not "*").
26
+ */
27
+ credentials?: boolean;
28
+ }
9
29
  interface CopilotEndpointParams {
10
30
  runtime: CopilotRuntime;
11
31
  basePath: string;
32
+ /**
33
+ * Optional CORS configuration. When not provided, defaults to allowing all origins without credentials.
34
+ * To support HTTP-only cookies, provide cors config with credentials: true and explicit origin.
35
+ */
36
+ cors?: CopilotEndpointCorsConfig;
12
37
  }
13
38
  type CopilotEndpointContext$1 = {
14
39
  Variables: {
15
40
  modifiedRequest?: Request;
16
41
  };
17
42
  };
18
- declare function createCopilotEndpoint({ runtime, basePath }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext$1, {
43
+ declare function createCopilotEndpoint({ runtime, basePath, cors: corsConfig }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext$1, {
19
44
  [x: `${string}/agent/:agentId/run`]: {
20
45
  $post: {
21
46
  input: {
@@ -82,13 +107,18 @@ interface CopilotSingleEndpointParams {
82
107
  * Absolute path at which to mount the single-route endpoint (e.g. "/api/copilotkit").
83
108
  */
84
109
  basePath: string;
110
+ /**
111
+ * Optional CORS configuration. When not provided, defaults to allowing all origins without credentials.
112
+ * To support HTTP-only cookies, provide cors config with credentials: true and explicit origin.
113
+ */
114
+ cors?: CopilotEndpointCorsConfig;
85
115
  }
86
116
  type CopilotEndpointContext = {
87
117
  Variables: {
88
118
  modifiedRequest?: Request;
89
119
  };
90
120
  };
91
- declare function createCopilotEndpointSingleRoute({ runtime, basePath }: CopilotSingleEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
121
+ declare function createCopilotEndpointSingleRoute({ runtime, basePath, cors: corsConfig }: CopilotSingleEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
92
122
  [x: string]: {
93
123
  $post: {
94
124
  input: {};
@@ -106,4 +136,4 @@ declare class InMemoryAgentRunner extends AgentRunner {
106
136
  stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
107
137
  }
108
138
 
109
- export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, CopilotRuntime, InMemoryAgentRunner, createCopilotEndpoint, createCopilotEndpointSingleRoute };
139
+ export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, type CopilotEndpointCorsConfig, CopilotRuntime, InMemoryAgentRunner, createCopilotEndpoint, createCopilotEndpointSingleRoute };
package/dist/index.js CHANGED
@@ -23,17 +23,18 @@ __export(index_exports, {
23
23
  AgentRunner: () => AgentRunner,
24
24
  CopilotRuntime: () => CopilotRuntime,
25
25
  InMemoryAgentRunner: () => InMemoryAgentRunner,
26
+ TranscriptionService: () => TranscriptionService,
26
27
  VERSION: () => VERSION,
27
28
  createCopilotEndpoint: () => createCopilotEndpoint,
28
29
  createCopilotEndpointSingleRoute: () => createCopilotEndpointSingleRoute,
29
- finalizeRunEvents: () => import_shared5.finalizeRunEvents
30
+ finalizeRunEvents: () => import_shared6.finalizeRunEvents
30
31
  });
31
32
  module.exports = __toCommonJS(index_exports);
32
33
 
33
34
  // package.json
34
35
  var package_default = {
35
36
  name: "@copilotkitnext/runtime",
36
- version: "1.51.2-next.1",
37
+ version: "1.51.3-next.0",
37
38
  description: "Server-side runtime package for CopilotKit2",
38
39
  main: "dist/index.js",
39
40
  types: "dist/index.d.ts",
@@ -69,7 +70,6 @@ var package_default = {
69
70
  "@types/express": "^4.17.21",
70
71
  "@types/node": "^22.15.3",
71
72
  eslint: "^9.30.0",
72
- openai: "^5.9.0",
73
73
  supertest: "^7.1.1",
74
74
  tsup: "^8.5.0",
75
75
  typescript: "5.8.2",
@@ -82,11 +82,14 @@ var package_default = {
82
82
  "@copilotkitnext/shared": "workspace:*",
83
83
  cors: "^2.8.5",
84
84
  express: "^4.21.2",
85
- hono: "^4.6.13",
85
+ hono: "^4.11.4",
86
86
  rxjs: "7.8.1"
87
87
  },
88
88
  peerDependencies: {
89
- openai: "^5.9.0"
89
+ "@ag-ui/client": "0.0.42",
90
+ "@ag-ui/core": "0.0.42",
91
+ "@ag-ui/encoder": "0.0.42",
92
+ "@copilotkitnext/shared": "workspace:*"
90
93
  },
91
94
  peerDependenciesMeta: {},
92
95
  engines: {
@@ -577,73 +580,135 @@ async function handleGetRuntimeInfo({
577
580
  }
578
581
 
579
582
  // src/handlers/handle-transcribe.ts
583
+ var import_shared2 = require("@copilotkitnext/shared");
584
+ var ERROR_STATUS_CODES = {
585
+ [import_shared2.TranscriptionErrorCode.SERVICE_NOT_CONFIGURED]: 503,
586
+ [import_shared2.TranscriptionErrorCode.INVALID_AUDIO_FORMAT]: 400,
587
+ [import_shared2.TranscriptionErrorCode.AUDIO_TOO_LONG]: 400,
588
+ [import_shared2.TranscriptionErrorCode.AUDIO_TOO_SHORT]: 400,
589
+ [import_shared2.TranscriptionErrorCode.RATE_LIMITED]: 429,
590
+ [import_shared2.TranscriptionErrorCode.AUTH_FAILED]: 401,
591
+ [import_shared2.TranscriptionErrorCode.PROVIDER_ERROR]: 500,
592
+ [import_shared2.TranscriptionErrorCode.NETWORK_ERROR]: 502,
593
+ [import_shared2.TranscriptionErrorCode.INVALID_REQUEST]: 400
594
+ };
595
+ var VALID_AUDIO_TYPES = [
596
+ "audio/mpeg",
597
+ "audio/mp3",
598
+ "audio/mp4",
599
+ "audio/wav",
600
+ "audio/webm",
601
+ "audio/ogg",
602
+ "audio/flac",
603
+ "audio/aac"
604
+ ];
605
+ function isValidAudioType(type) {
606
+ const baseType = type.split(";")[0]?.trim() ?? "";
607
+ return VALID_AUDIO_TYPES.includes(baseType) || baseType === "" || baseType === "application/octet-stream";
608
+ }
609
+ function createErrorResponse(errorResponse) {
610
+ const status = ERROR_STATUS_CODES[errorResponse.error] ?? 500;
611
+ return new Response(JSON.stringify(errorResponse), {
612
+ status,
613
+ headers: { "Content-Type": "application/json" }
614
+ });
615
+ }
616
+ function base64ToFile(base64, mimeType, filename) {
617
+ const base64Data = base64.includes(",") ? base64.split(",")[1] ?? base64 : base64;
618
+ const binaryString = atob(base64Data);
619
+ const bytes = new Uint8Array(binaryString.length);
620
+ for (let i = 0; i < binaryString.length; i++) {
621
+ bytes[i] = binaryString.charCodeAt(i);
622
+ }
623
+ return new File([bytes], filename, { type: mimeType });
624
+ }
625
+ async function extractAudioFromFormData(request) {
626
+ const formData = await request.formData();
627
+ const audioFile = formData.get("audio");
628
+ if (!audioFile || !(audioFile instanceof File)) {
629
+ const err = import_shared2.TranscriptionErrors.invalidRequest(
630
+ "No audio file found in form data. Please include an 'audio' field."
631
+ );
632
+ return { error: createErrorResponse(err) };
633
+ }
634
+ if (!isValidAudioType(audioFile.type)) {
635
+ const err = import_shared2.TranscriptionErrors.invalidAudioFormat(audioFile.type, VALID_AUDIO_TYPES);
636
+ return { error: createErrorResponse(err) };
637
+ }
638
+ return { file: audioFile };
639
+ }
640
+ async function extractAudioFromJson(request) {
641
+ let body;
642
+ try {
643
+ body = await request.json();
644
+ } catch {
645
+ const err = import_shared2.TranscriptionErrors.invalidRequest("Request body must be valid JSON");
646
+ return { error: createErrorResponse(err) };
647
+ }
648
+ if (!body.audio || typeof body.audio !== "string") {
649
+ const err = import_shared2.TranscriptionErrors.invalidRequest(
650
+ "Request must include 'audio' field with base64-encoded audio data"
651
+ );
652
+ return { error: createErrorResponse(err) };
653
+ }
654
+ if (!body.mimeType || typeof body.mimeType !== "string") {
655
+ const err = import_shared2.TranscriptionErrors.invalidRequest(
656
+ "Request must include 'mimeType' field (e.g., 'audio/webm')"
657
+ );
658
+ return { error: createErrorResponse(err) };
659
+ }
660
+ if (!isValidAudioType(body.mimeType)) {
661
+ const err = import_shared2.TranscriptionErrors.invalidAudioFormat(body.mimeType, VALID_AUDIO_TYPES);
662
+ return { error: createErrorResponse(err) };
663
+ }
664
+ try {
665
+ const filename = body.filename || "recording.webm";
666
+ const file = base64ToFile(body.audio, body.mimeType, filename);
667
+ return { file };
668
+ } catch {
669
+ const err = import_shared2.TranscriptionErrors.invalidRequest("Failed to decode base64 audio data");
670
+ return { error: createErrorResponse(err) };
671
+ }
672
+ }
673
+ function categorizeProviderError(error) {
674
+ const message = error instanceof Error ? error.message : "Unknown error occurred";
675
+ const errorStr = String(error).toLowerCase();
676
+ if (errorStr.includes("rate") || errorStr.includes("429") || errorStr.includes("too many")) {
677
+ return import_shared2.TranscriptionErrors.rateLimited();
678
+ }
679
+ if (errorStr.includes("auth") || errorStr.includes("401") || errorStr.includes("api key") || errorStr.includes("unauthorized")) {
680
+ return import_shared2.TranscriptionErrors.authFailed();
681
+ }
682
+ if (errorStr.includes("too long") || errorStr.includes("duration") || errorStr.includes("length")) {
683
+ return import_shared2.TranscriptionErrors.audioTooLong();
684
+ }
685
+ return import_shared2.TranscriptionErrors.providerError(message);
686
+ }
580
687
  async function handleTranscribe({
581
688
  runtime,
582
689
  request
583
690
  }) {
584
691
  try {
585
692
  if (!runtime.transcriptionService) {
586
- return new Response(
587
- JSON.stringify({
588
- error: "Transcription service not configured",
589
- message: "No transcription service has been configured in the runtime"
590
- }),
591
- {
592
- status: 503,
593
- headers: { "Content-Type": "application/json" }
594
- }
595
- );
596
- }
597
- const contentType = request.headers.get("content-type");
598
- if (!contentType || !contentType.includes("multipart/form-data")) {
599
- return new Response(
600
- JSON.stringify({
601
- error: "Invalid content type",
602
- message: "Request must contain multipart/form-data with an audio file"
603
- }),
604
- {
605
- status: 400,
606
- headers: { "Content-Type": "application/json" }
607
- }
608
- );
693
+ const err = import_shared2.TranscriptionErrors.serviceNotConfigured();
694
+ return createErrorResponse(err);
609
695
  }
610
- const formData = await request.formData();
611
- const audioFile = formData.get("audio");
612
- if (!audioFile || !(audioFile instanceof File)) {
613
- return new Response(
614
- JSON.stringify({
615
- error: "Missing audio file",
616
- message: "No audio file found in form data. Please include an 'audio' field."
617
- }),
618
- {
619
- status: 400,
620
- headers: { "Content-Type": "application/json" }
621
- }
696
+ const contentType = request.headers.get("content-type") || "";
697
+ let extractResult;
698
+ if (contentType.includes("multipart/form-data")) {
699
+ extractResult = await extractAudioFromFormData(request);
700
+ } else if (contentType.includes("application/json")) {
701
+ extractResult = await extractAudioFromJson(request);
702
+ } else {
703
+ const err = import_shared2.TranscriptionErrors.invalidRequest(
704
+ "Request must be multipart/form-data or application/json with base64 audio"
622
705
  );
706
+ return createErrorResponse(err);
623
707
  }
624
- const validAudioTypes = [
625
- "audio/mpeg",
626
- "audio/mp3",
627
- "audio/mp4",
628
- "audio/wav",
629
- "audio/webm",
630
- "audio/ogg",
631
- "audio/flac",
632
- "audio/aac"
633
- ];
634
- const isValidType = validAudioTypes.includes(audioFile.type) || audioFile.type === "" || audioFile.type === "application/octet-stream";
635
- if (!isValidType) {
636
- return new Response(
637
- JSON.stringify({
638
- error: "Invalid file type",
639
- message: `Unsupported audio file type: ${audioFile.type}. Supported types: ${validAudioTypes.join(", ")}, or files with unknown/empty types`
640
- }),
641
- {
642
- status: 400,
643
- headers: { "Content-Type": "application/json" }
644
- }
645
- );
708
+ if ("error" in extractResult) {
709
+ return extractResult.error;
646
710
  }
711
+ const audioFile = extractResult.file;
647
712
  const transcription = await runtime.transcriptionService.transcribeFile({
648
713
  audioFile,
649
714
  mimeType: audioFile.type,
@@ -661,24 +726,15 @@ async function handleTranscribe({
661
726
  }
662
727
  );
663
728
  } catch (error) {
664
- return new Response(
665
- JSON.stringify({
666
- error: "Transcription failed",
667
- message: error instanceof Error ? error.message : "Unknown error occurred during transcription"
668
- }),
669
- {
670
- status: 500,
671
- headers: { "Content-Type": "application/json" }
672
- }
673
- );
729
+ return createErrorResponse(categorizeProviderError(error));
674
730
  }
675
731
  }
676
732
 
677
733
  // src/endpoints/hono.ts
678
- var import_shared3 = require("@copilotkitnext/shared");
734
+ var import_shared4 = require("@copilotkitnext/shared");
679
735
 
680
736
  // src/middleware.ts
681
- var import_shared2 = require("@copilotkitnext/shared");
737
+ var import_shared3 = require("@copilotkitnext/shared");
682
738
  async function callBeforeRequestMiddleware({
683
739
  runtime,
684
740
  request,
@@ -689,7 +745,7 @@ async function callBeforeRequestMiddleware({
689
745
  if (typeof mw === "function") {
690
746
  return mw({ runtime, request, path });
691
747
  }
692
- import_shared2.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
748
+ import_shared3.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
693
749
  return;
694
750
  }
695
751
  async function callAfterRequestMiddleware({
@@ -702,7 +758,7 @@ async function callAfterRequestMiddleware({
702
758
  if (typeof mw === "function") {
703
759
  return mw({ runtime, response, path });
704
760
  }
705
- import_shared2.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
761
+ import_shared3.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
706
762
  }
707
763
 
708
764
  // src/handlers/handle-connect.ts
@@ -894,14 +950,15 @@ async function handleStopAgent({
894
950
  }
895
951
 
896
952
  // src/endpoints/hono.ts
897
- function createCopilotEndpoint({ runtime, basePath }) {
953
+ function createCopilotEndpoint({ runtime, basePath, cors: corsConfig }) {
898
954
  const app = new import_hono.Hono();
899
955
  return app.basePath(basePath).use(
900
956
  "*",
901
957
  (0, import_cors.cors)({
902
- origin: "*",
958
+ origin: corsConfig?.origin ?? "*",
903
959
  allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
904
- allowHeaders: ["*"]
960
+ allowHeaders: ["*"],
961
+ credentials: corsConfig?.credentials ?? false
905
962
  })
906
963
  ).use("*", async (c, next) => {
907
964
  const request = c.req.raw;
@@ -916,7 +973,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
916
973
  c.set("modifiedRequest", maybeModifiedRequest);
917
974
  }
918
975
  } catch (error) {
919
- import_shared3.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
976
+ import_shared4.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
920
977
  if (error instanceof Response) {
921
978
  return error;
922
979
  }
@@ -932,7 +989,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
932
989
  response,
933
990
  path
934
991
  }).catch((error) => {
935
- import_shared3.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
992
+ import_shared4.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
936
993
  });
937
994
  }).post("/agent/:agentId/run", async (c) => {
938
995
  const agentId = c.req.param("agentId");
@@ -944,7 +1001,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
944
1001
  agentId
945
1002
  });
946
1003
  } catch (error) {
947
- import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
1004
+ import_shared4.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
948
1005
  throw error;
949
1006
  }
950
1007
  }).post("/agent/:agentId/connect", async (c) => {
@@ -957,7 +1014,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
957
1014
  agentId
958
1015
  });
959
1016
  } catch (error) {
960
- import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
1017
+ import_shared4.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
961
1018
  throw error;
962
1019
  }
963
1020
  }).post("/agent/:agentId/stop/:threadId", async (c) => {
@@ -972,7 +1029,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
972
1029
  threadId
973
1030
  });
974
1031
  } catch (error) {
975
- import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
1032
+ import_shared4.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
976
1033
  throw error;
977
1034
  }
978
1035
  }).get("/info", async (c) => {
@@ -983,7 +1040,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
983
1040
  request
984
1041
  });
985
1042
  } catch (error) {
986
- import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
1043
+ import_shared4.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
987
1044
  throw error;
988
1045
  }
989
1046
  }).post("/transcribe", async (c) => {
@@ -994,7 +1051,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
994
1051
  request
995
1052
  });
996
1053
  } catch (error) {
997
- import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
1054
+ import_shared4.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
998
1055
  throw error;
999
1056
  }
1000
1057
  }).notFound((c) => {
@@ -1005,7 +1062,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
1005
1062
  // src/endpoints/hono-single.ts
1006
1063
  var import_hono2 = require("hono");
1007
1064
  var import_cors2 = require("hono/cors");
1008
- var import_shared4 = require("@copilotkitnext/shared");
1065
+ var import_shared5 = require("@copilotkitnext/shared");
1009
1066
 
1010
1067
  // src/endpoints/single-route-helpers.ts
1011
1068
  var METHOD_NAMES = [
@@ -1092,15 +1149,16 @@ function serializeJsonBody(body) {
1092
1149
  }
1093
1150
 
1094
1151
  // src/endpoints/hono-single.ts
1095
- function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1152
+ function createCopilotEndpointSingleRoute({ runtime, basePath, cors: corsConfig }) {
1096
1153
  const app = new import_hono2.Hono();
1097
1154
  const routePath = normalizePath(basePath);
1098
1155
  return app.basePath(routePath).use(
1099
1156
  "*",
1100
1157
  (0, import_cors2.cors)({
1101
- origin: "*",
1158
+ origin: corsConfig?.origin ?? "*",
1102
1159
  allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
1103
- allowHeaders: ["*"]
1160
+ allowHeaders: ["*"],
1161
+ credentials: corsConfig?.credentials ?? false
1104
1162
  })
1105
1163
  ).use("*", async (c, next) => {
1106
1164
  const request = c.req.raw;
@@ -1115,7 +1173,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1115
1173
  c.set("modifiedRequest", maybeModifiedRequest);
1116
1174
  }
1117
1175
  } catch (error) {
1118
- import_shared4.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
1176
+ import_shared5.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
1119
1177
  if (error instanceof Response) {
1120
1178
  return error;
1121
1179
  }
@@ -1131,7 +1189,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1131
1189
  response,
1132
1190
  path
1133
1191
  }).catch((error) => {
1134
- import_shared4.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
1192
+ import_shared5.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
1135
1193
  });
1136
1194
  }).post("/", async (c) => {
1137
1195
  const request = c.get("modifiedRequest") || c.req.raw;
@@ -1140,10 +1198,10 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1140
1198
  methodCall = await parseMethodCall(request);
1141
1199
  } catch (error) {
1142
1200
  if (error instanceof Response) {
1143
- import_shared4.logger.warn({ url: request.url }, "Invalid single-route payload");
1201
+ import_shared5.logger.warn({ url: request.url }, "Invalid single-route payload");
1144
1202
  return error;
1145
1203
  }
1146
- import_shared4.logger.warn({ err: error, url: request.url }, "Invalid single-route payload");
1204
+ import_shared5.logger.warn({ err: error, url: request.url }, "Invalid single-route payload");
1147
1205
  return c.json(
1148
1206
  {
1149
1207
  error: "invalid_request",
@@ -1173,7 +1231,8 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1173
1231
  return await handleGetRuntimeInfo({ runtime, request });
1174
1232
  }
1175
1233
  case "transcribe": {
1176
- return await handleTranscribe({ runtime, request });
1234
+ const handlerRequest = createJsonRequest(request, methodCall.body);
1235
+ return await handleTranscribe({ runtime, request: handlerRequest });
1177
1236
  }
1178
1237
  default: {
1179
1238
  const exhaustiveCheck = methodCall.method;
@@ -1184,7 +1243,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
1184
1243
  if (error instanceof Response) {
1185
1244
  return error;
1186
1245
  }
1187
- import_shared4.logger.error({ err: error, url: request.url, method: methodCall.method }, "Error running single-route handler");
1246
+ import_shared5.logger.error({ err: error, url: request.url, method: methodCall.method }, "Error running single-route handler");
1188
1247
  throw error;
1189
1248
  }
1190
1249
  }).notFound((c) => {
@@ -1205,12 +1264,17 @@ function normalizePath(path) {
1205
1264
  }
1206
1265
 
1207
1266
  // src/runner/index.ts
1208
- var import_shared5 = require("@copilotkitnext/shared");
1267
+ var import_shared6 = require("@copilotkitnext/shared");
1268
+
1269
+ // src/transcription-service/transcription-service.ts
1270
+ var TranscriptionService = class {
1271
+ };
1209
1272
  // Annotate the CommonJS export names for ESM import in node:
1210
1273
  0 && (module.exports = {
1211
1274
  AgentRunner,
1212
1275
  CopilotRuntime,
1213
1276
  InMemoryAgentRunner,
1277
+ TranscriptionService,
1214
1278
  VERSION,
1215
1279
  createCopilotEndpoint,
1216
1280
  createCopilotEndpointSingleRoute,