@copilotkit/runtime 1.50.1 → 2.0.0-next.1

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.mjs CHANGED
@@ -65,7 +65,7 @@ var require_package = __commonJS({
65
65
  publishConfig: {
66
66
  access: "public"
67
67
  },
68
- version: "1.50.1",
68
+ version: "2.0.0-next.1",
69
69
  sideEffects: false,
70
70
  main: "./dist/index.js",
71
71
  module: "./dist/index.mjs",
@@ -4748,9 +4748,27 @@ function readableStreamToNodeStream(webStream) {
4748
4748
  });
4749
4749
  }
4750
4750
  __name(readableStreamToNodeStream, "readableStreamToNodeStream");
4751
+ function nodeStreamToReadableStream(nodeStream) {
4752
+ return new ReadableStream({
4753
+ start(controller) {
4754
+ nodeStream.on("data", (chunk) => {
4755
+ controller.enqueue(chunk instanceof Buffer ? new Uint8Array(chunk) : chunk);
4756
+ });
4757
+ nodeStream.on("end", () => {
4758
+ controller.close();
4759
+ });
4760
+ nodeStream.on("error", (err) => {
4761
+ controller.error(err);
4762
+ });
4763
+ },
4764
+ cancel() {
4765
+ nodeStream.destroy();
4766
+ }
4767
+ });
4768
+ }
4769
+ __name(nodeStreamToReadableStream, "nodeStreamToReadableStream");
4751
4770
  function getFullUrl(req) {
4752
- const expressPath = req.originalUrl ?? (req.baseUrl ? `${req.baseUrl}${req.url ?? ""}` : void 0);
4753
- const path = expressPath || req.url || "/";
4771
+ const path = req.url || "/";
4754
4772
  const host = req.headers["x-forwarded-host"] || req.headers.host || "localhost";
4755
4773
  const proto = req.headers["x-forwarded-proto"] || (req.socket.encrypted ? "https" : "http");
4756
4774
  return `${proto}://${host}${path}`;
@@ -4802,6 +4820,8 @@ function isDisturbedOrLockedError(error) {
4802
4820
  return error instanceof TypeError && typeof error.message === "string" && (error.message.includes("disturbed") || error.message.includes("locked"));
4803
4821
  }
4804
4822
  __name(isDisturbedOrLockedError, "isDisturbedOrLockedError");
4823
+
4824
+ // src/lib/integrations/node-http/index.ts
4805
4825
  function copilotRuntimeNodeHttpEndpoint(options) {
4806
4826
  var _a;
4807
4827
  const commonConfig = getCommonConfig(options);
@@ -4826,7 +4846,7 @@ function copilotRuntimeNodeHttpEndpoint(options) {
4826
4846
  runtime: options.runtime.instance,
4827
4847
  basePath: options.baseUrl ?? options.endpoint
4828
4848
  });
4829
- return /* @__PURE__ */ __name(async function handler(req, res) {
4849
+ const handle2 = /* @__PURE__ */ __name(async function handler(req, res) {
4830
4850
  const url = getFullUrl(req);
4831
4851
  const hasBody = req.method !== "GET" && req.method !== "HEAD";
4832
4852
  const baseHeaders = toHeaders(req.headers);
@@ -4836,7 +4856,7 @@ function copilotRuntimeNodeHttpEndpoint(options) {
4836
4856
  let requestBody = void 0;
4837
4857
  let useDuplex = false;
4838
4858
  if (hasBody && canStream) {
4839
- requestBody = req;
4859
+ requestBody = nodeStreamToReadableStream(req);
4840
4860
  useDuplex = true;
4841
4861
  }
4842
4862
  if (hasBody && streamConsumed) {
@@ -4892,6 +4912,15 @@ function copilotRuntimeNodeHttpEndpoint(options) {
4892
4912
  res.end();
4893
4913
  }
4894
4914
  }, "handler");
4915
+ return function(reqOrRequest, res) {
4916
+ if (reqOrRequest instanceof Request) {
4917
+ return honoApp.fetch(reqOrRequest);
4918
+ }
4919
+ if (!res) {
4920
+ throw new TypeError("ServerResponse is required for Node HTTP requests");
4921
+ }
4922
+ return handle2(reqOrRequest, res);
4923
+ };
4895
4924
  }
4896
4925
  __name(copilotRuntimeNodeHttpEndpoint, "copilotRuntimeNodeHttpEndpoint");
4897
4926
 
@@ -5564,6 +5593,6 @@ var EmptyAdapter = class {
5564
5593
  __name(EmptyAdapter, "EmptyAdapter");
5565
5594
  var ExperimentalEmptyAdapter = EmptyAdapter;
5566
5595
 
5567
- export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, TelemetryAgentRunner, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, readableStreamToNodeStream, resolveEndpointType };
5596
+ export { AnthropicAdapter, BedrockAdapter, CopilotRuntime, EmptyAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter, GoogleGenerativeAIAdapter, GroqAdapter, GuardrailsValidationFailureResponse, LangChainAdapter, LangGraphAgent, LangGraphHttpAgent, MessageStreamInterruptedResponse, OpenAIAdapter, OpenAIAssistantAdapter, RemoteChain, TelemetryAgentRunner, UnifyAdapter, UnknownErrorResponse, addCustomHeaderPlugin, buildSchema, config, convertMCPToolsToActions, convertServiceAdapterError, copilotKitEndpoint, copilotRuntimeNestEndpoint, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint, copilotRuntimeNodeExpressEndpoint, copilotRuntimeNodeHttpEndpoint, createContext, createLogger, extractParametersFromSchema, generateMcpToolInstructions, getCommonConfig, langGraphPlatformEndpoint, resolveEndpointType };
5568
5597
  //# sourceMappingURL=out.js.map
5569
5598
  //# sourceMappingURL=index.mjs.map