@copilotkit/runtime 1.72.0 → 1.72.1-canary.sp-longthread-perf

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.
Files changed (89) hide show
  1. package/dist/agent/index.cjs +34 -0
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +36 -2
  4. package/dist/agent/index.d.cts.map +1 -1
  5. package/dist/agent/index.d.mts +36 -2
  6. package/dist/agent/index.d.mts.map +1 -1
  7. package/dist/agent/index.mjs +35 -2
  8. package/dist/agent/index.mjs.map +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +23 -16
  11. package/dist/index.d.mts +23 -16
  12. package/dist/index.mjs +1 -1
  13. package/dist/langgraph.d.cts +3 -1
  14. package/dist/langgraph.d.mts +3 -1
  15. package/dist/lib/index.cjs +1 -1
  16. package/dist/lib/index.cjs.map +1 -1
  17. package/dist/lib/index.d.cts.map +1 -1
  18. package/dist/lib/index.d.mts.map +1 -1
  19. package/dist/lib/index.mjs +1 -1
  20. package/dist/lib/index.mjs.map +1 -1
  21. package/dist/lib/integrations/nextjs/app-router.cjs.map +1 -1
  22. package/dist/lib/integrations/nextjs/app-router.mjs.map +1 -1
  23. package/dist/lib/integrations/node-express/index.cjs.map +1 -1
  24. package/dist/lib/integrations/node-express/index.mjs.map +1 -1
  25. package/dist/lib/integrations/node-http/index.cjs.map +1 -1
  26. package/dist/lib/integrations/node-http/index.mjs.map +1 -1
  27. package/dist/lib/runtime/copilot-runtime.cjs +2 -16
  28. package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
  29. package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
  30. package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
  31. package/dist/lib/runtime/copilot-runtime.mjs +3 -17
  32. package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
  33. package/dist/package.cjs +1 -1
  34. package/dist/package.mjs +1 -1
  35. package/dist/v2/index.cjs +1 -0
  36. package/dist/v2/index.d.cts +2 -2
  37. package/dist/v2/index.d.mts +2 -2
  38. package/dist/v2/index.mjs +2 -2
  39. package/dist/v2/runtime/core/channel-manager.d.mts +1 -0
  40. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  41. package/dist/v2/runtime/core/debug-event-bus.cjs +22 -0
  42. package/dist/v2/runtime/core/debug-event-bus.cjs.map +1 -1
  43. package/dist/v2/runtime/core/debug-event-bus.d.cts +1 -1
  44. package/dist/v2/runtime/core/debug-event-bus.d.mts +1 -1
  45. package/dist/v2/runtime/core/debug-event-bus.mjs +22 -1
  46. package/dist/v2/runtime/core/debug-event-bus.mjs.map +1 -1
  47. package/dist/v2/runtime/core/runtime.cjs +5 -5
  48. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  49. package/dist/v2/runtime/core/runtime.d.cts +11 -0
  50. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  51. package/dist/v2/runtime/core/runtime.d.mts +11 -0
  52. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  53. package/dist/v2/runtime/core/runtime.mjs +6 -6
  54. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  55. package/dist/v2/runtime/handlers/handle-connect.cjs +3 -2
  56. package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
  57. package/dist/v2/runtime/handlers/handle-connect.mjs +3 -2
  58. package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
  59. package/dist/v2/runtime/handlers/handle-debug-events.cjs +2 -1
  60. package/dist/v2/runtime/handlers/handle-debug-events.cjs.map +1 -1
  61. package/dist/v2/runtime/handlers/handle-debug-events.mjs +3 -1
  62. package/dist/v2/runtime/handlers/handle-debug-events.mjs.map +1 -1
  63. package/dist/v2/runtime/handlers/handle-run.cjs +5 -3
  64. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  65. package/dist/v2/runtime/handlers/handle-run.mjs +5 -3
  66. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  67. package/dist/v2/runtime/handlers/shared/cloud-telemetry.cjs +31 -0
  68. package/dist/v2/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  69. package/dist/v2/runtime/handlers/shared/cloud-telemetry.mjs +30 -0
  70. package/dist/v2/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  71. package/dist/v2/runtime/handlers/shared/sse-response.cjs +31 -3
  72. package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
  73. package/dist/v2/runtime/handlers/shared/sse-response.mjs +31 -3
  74. package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
  75. package/dist/v2/runtime/handlers/sse/run.cjs +1 -0
  76. package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
  77. package/dist/v2/runtime/handlers/sse/run.mjs +1 -0
  78. package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
  79. package/dist/v2/runtime/telemetry/events.d.cts +12 -0
  80. package/dist/v2/runtime/telemetry/events.d.cts.map +1 -1
  81. package/dist/v2/runtime/telemetry/events.d.mts +12 -0
  82. package/dist/v2/runtime/telemetry/events.d.mts.map +1 -1
  83. package/dist/v2/runtime/telemetry/telemetry-client.cjs +3 -2
  84. package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
  85. package/dist/v2/runtime/telemetry/telemetry-client.d.cts.map +1 -1
  86. package/dist/v2/runtime/telemetry/telemetry-client.d.mts.map +1 -1
  87. package/dist/v2/runtime/telemetry/telemetry-client.mjs +7 -6
  88. package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
  89. package/package.json +2 -2
package/dist/index.d.mts CHANGED
@@ -314,7 +314,8 @@ LangChainAdapter, /**
314
314
  */
315
315
  LangGraphAgent, /**
316
316
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
317
- * No 1:1 v2 replacement is available.
317
+ * Use `HttpAgent` from `@ag-ui/client`, passed to the v2 `CopilotRuntime`.
318
+ * Exception: a v1 client still resuming interrupts through `forwardedProps.command.resume` — `LangGraphHttpAgent` keeps a back-compat bridge for that channel.
318
319
  * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
319
320
  * Start with `@copilotkit/runtime/v2`.
320
321
  * V2 docs: https://docs.copilotkit.ai/
@@ -553,11 +554,13 @@ copilotKitEndpoint, /**
553
554
  */
554
555
  copilotRuntimeNestEndpoint, /**
555
556
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
556
- * No 1:1 v2 replacement is available.
557
- * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter
558
- * Start with `@copilotkit/runtime/v2`.
559
- * V2 docs: https://docs.copilotkit.ai/
560
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
557
+ * Use `createCopilotRuntimeHandler` from `@copilotkit/runtime/v2` instead.
558
+ * Import and usage example:
559
+ * ```ts
560
+ * import { createCopilotRuntimeHandler } from "@copilotkit/runtime/v2";
561
+ * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;
562
+ * ```
563
+ * See https://docs.copilotkit.ai/runtime-server-adapter
561
564
  * Migration guide: https://docs.copilotkit.ai/migrate/v2
562
565
  */
563
566
  copilotRuntimeNextJSAppRouterEndpoint, /**
@@ -571,20 +574,24 @@ copilotRuntimeNextJSAppRouterEndpoint, /**
571
574
  */
572
575
  copilotRuntimeNextJSPagesRouterEndpoint, /**
573
576
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
574
- * No 1:1 v2 replacement is available.
575
- * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter
576
- * Start with `@copilotkit/runtime/v2`.
577
- * V2 docs: https://docs.copilotkit.ai/
578
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
577
+ * Use `createCopilotExpressHandler` from `@copilotkit/runtime/v2/express` instead.
578
+ * Import and usage example:
579
+ * ```ts
580
+ * import { createCopilotExpressHandler } from "@copilotkit/runtime/v2/express";
581
+ * const v2CreateCopilotExpressHandler = createCopilotExpressHandler;
582
+ * ```
583
+ * See https://docs.copilotkit.ai/runtime-server-adapter
579
584
  * Migration guide: https://docs.copilotkit.ai/migrate/v2
580
585
  */
581
586
  copilotRuntimeNodeExpressEndpoint, /**
582
587
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
583
- * No 1:1 v2 replacement is available.
584
- * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter
585
- * Start with `@copilotkit/runtime/v2`.
586
- * V2 docs: https://docs.copilotkit.ai/
587
- * V2 reference docs: https://docs.copilotkit.ai/reference/v2
588
+ * Use `createCopilotRuntimeHandler` from `@copilotkit/runtime/v2` instead.
589
+ * Import and usage example:
590
+ * ```ts
591
+ * import { createCopilotRuntimeHandler } from "@copilotkit/runtime/v2";
592
+ * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;
593
+ * ```
594
+ * See https://docs.copilotkit.ai/runtime-server-adapter
588
595
  * Migration guide: https://docs.copilotkit.ai/migrate/v2
589
596
  */
590
597
  copilotRuntimeNodeHttpEndpoint, /**
package/dist/index.mjs CHANGED
@@ -9,7 +9,6 @@ import { UnifyAdapter } from "./service-adapters/unify/unify-adapter.mjs";
9
9
  import { GroqAdapter } from "./service-adapters/groq/groq-adapter.mjs";
10
10
  import { GuardrailsValidationFailureResponse, MessageStreamInterruptedResponse, UnknownErrorResponse } from "./utils/failed-response-status-reasons.mjs";
11
11
  import { createLogger } from "./lib/logger.mjs";
12
- import { TelemetryAgentRunner } from "./lib/runtime/telemetry-agent-runner.mjs";
13
12
  import { convertMCPToolsToActions, extractParametersFromSchema, generateMcpToolInstructions } from "./lib/runtime/mcp-tools-utils.mjs";
14
13
  import { CopilotRuntime, copilotKitEndpoint, langGraphPlatformEndpoint, resolveEndpointType } from "./lib/runtime/copilot-runtime.mjs";
15
14
  import { buildSchema, getCommonConfig } from "./lib/integrations/shared.mjs";
@@ -18,6 +17,7 @@ import { copilotRuntimeNodeHttpEndpoint } from "./lib/integrations/node-http/ind
18
17
  import { config, copilotRuntimeNextJSPagesRouterEndpoint } from "./lib/integrations/nextjs/pages-router.mjs";
19
18
  import { copilotRuntimeNodeExpressEndpoint } from "./lib/integrations/node-express/index.mjs";
20
19
  import { copilotRuntimeNestEndpoint } from "./lib/integrations/nest/index.mjs";
20
+ import { TelemetryAgentRunner } from "./lib/runtime/telemetry-agent-runner.mjs";
21
21
  import { LangGraphAgent, LangGraphHttpAgent } from "./lib/index.mjs";
22
22
  import { RemoteChain } from "./service-adapters/langchain/langserve.mjs";
23
23
  import { AnthropicAdapter, FilterThinkingTextBuffer } from "./service-adapters/anthropic/anthropic-adapter.mjs";
@@ -22,7 +22,9 @@ CustomEventNames, /**
22
22
  */
23
23
  LangGraphAgent, /**
24
24
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
25
- * No 1:1 v2 replacement is available.
25
+ * Use `HttpAgent` from `@ag-ui/client`, passed to the v2 `CopilotRuntime`.
26
+ * Exception: a v1 client still resuming interrupts through `forwardedProps.command.resume` — `LangGraphHttpAgent` keeps a back-compat bridge for that channel.
27
+ * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
26
28
  * Start with `@copilotkit/runtime/v2`.
27
29
  * V2 docs: https://docs.copilotkit.ai/
28
30
  * V2 reference docs: https://docs.copilotkit.ai/reference/v2
@@ -22,7 +22,9 @@ CustomEventNames, /**
22
22
  */
23
23
  LangGraphAgent, /**
24
24
  * @deprecated Since 1.68.2. The v1 SDK is deprecated. Use v2 instead.
25
- * No 1:1 v2 replacement is available.
25
+ * Use `HttpAgent` from `@ag-ui/client`, passed to the v2 `CopilotRuntime`.
26
+ * Exception: a v1 client still resuming interrupts through `forwardedProps.command.resume` — `LangGraphHttpAgent` keeps a back-compat bridge for that channel.
27
+ * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph
26
28
  * Start with `@copilotkit/runtime/v2`.
27
29
  * V2 docs: https://docs.copilotkit.ai/
28
30
  * V2 reference docs: https://docs.copilotkit.ai/reference/v2
@@ -6,7 +6,6 @@ const require_openai_assistant_adapter = require('../service-adapters/openai/ope
6
6
  const require_unify_adapter = require('../service-adapters/unify/unify-adapter.cjs');
7
7
  const require_groq_adapter = require('../service-adapters/groq/groq-adapter.cjs');
8
8
  const require_logger = require('./logger.cjs');
9
- const require_telemetry_agent_runner = require('./runtime/telemetry-agent-runner.cjs');
10
9
  const require_mcp_tools_utils = require('./runtime/mcp-tools-utils.cjs');
11
10
  const require_copilot_runtime = require('./runtime/copilot-runtime.cjs');
12
11
  const require_shared = require('./integrations/shared.cjs');
@@ -15,6 +14,7 @@ const require_index = require('./integrations/node-http/index.cjs');
15
14
  const require_pages_router = require('./integrations/nextjs/pages-router.cjs');
16
15
  const require_index$1 = require('./integrations/node-express/index.cjs');
17
16
  const require_index$2 = require('./integrations/nest/index.cjs');
17
+ const require_telemetry_agent_runner = require('./runtime/telemetry-agent-runner.cjs');
18
18
 
19
19
  //#region src/v1-deprecated/lib/index.ts
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CustomEventNames:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphHttpAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — PredictStateTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TextMessageEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — ToolCallEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nexport * from \"../service-adapters/openai/openai-adapter\";\nexport * from \"../service-adapters/langchain/langchain-adapter\";\nexport * from \"../service-adapters/google/google-genai-adapter\";\nexport * from \"../service-adapters/openai/openai-assistant-adapter\";\nexport * from \"../service-adapters/unify/unify-adapter\";\nexport * from \"../service-adapters/groq/groq-adapter\";\nexport * from \"./integrations\";\nexport * from \"./logger\";\nexport * from \"./runtime/copilot-runtime\";\nexport * from \"./runtime/mcp-tools-utils\";\nexport * from \"./runtime/telemetry-agent-runner\";\n\n// The below re-exports \"dummy\" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route\n\n/**\n * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphAgent {\n constructor() {\n throw new Error(\n \"LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphHttpAgent {\n constructor() {\n throw new Error(\n \"LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type TextMessageEvents = any;\n/**\n * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type ToolCallEvents = any;\n/**\n * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type CustomEventNames = any;\n/**\n * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type PredictStateTool = any;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,IAAa,iBAAb,MAA4B;CAC1B,cAAc;AACZ,QAAM,IAAI,MACR,4HACD;;;;;;AAOL,IAAa,qBAAb,MAAgC;CAC9B,cAAc;AACZ,QAAM,IAAI,MACR,gIACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CustomEventNames:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphHttpAgent:\n * Use `HttpAgent` from `@ag-ui/client`, passed to the v2 `CopilotRuntime`.\n * Exception: a v1 client still resuming interrupts through `forwardedProps.command.resume` — `LangGraphHttpAgent` keeps a back-compat bridge for that channel.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — PredictStateTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TextMessageEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — ToolCallEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nexport * from \"../service-adapters/openai/openai-adapter\";\nexport * from \"../service-adapters/langchain/langchain-adapter\";\nexport * from \"../service-adapters/google/google-genai-adapter\";\nexport * from \"../service-adapters/openai/openai-assistant-adapter\";\nexport * from \"../service-adapters/unify/unify-adapter\";\nexport * from \"../service-adapters/groq/groq-adapter\";\nexport * from \"./integrations\";\nexport * from \"./logger\";\nexport * from \"./runtime/copilot-runtime\";\nexport * from \"./runtime/mcp-tools-utils\";\nexport * from \"./runtime/telemetry-agent-runner\";\n\n// The below re-exports \"dummy\" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route\n\n/**\n * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphAgent {\n constructor() {\n throw new Error(\n \"LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphHttpAgent {\n constructor() {\n throw new Error(\n \"LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type TextMessageEvents = any;\n/**\n * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type ToolCallEvents = any;\n/**\n * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type CustomEventNames = any;\n/**\n * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type PredictStateTool = any;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAa,iBAAb,MAA4B;CAC1B,cAAc;AACZ,QAAM,IAAI,MACR,4HACD;;;;;;AAOL,IAAa,qBAAb,MAAgC;CAC9B,cAAc;AACZ,QAAM,IAAI,MACR,gIACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;cAuEa,cAAA;EAAc,WAAA,CAAA;AAAA;;;;cAWd,kBAAA;EAAkB,WAAA,CAAA;AAAA;;;AAA/B;KAWY,iBAAA;;;;KAIA,cAAA;;;;KAIA,gBAAA;AAJZ;;;AAAA,KAQY,gBAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;cAwEa,cAAA;EAAc,WAAA,CAAA;AAAA;;;;cAWd,kBAAA;EAAkB,WAAA,CAAA;AAAA;;;AAA/B;KAWY,iBAAA;;;;KAIA,cAAA;;;;KAIA,gBAAA;AAJZ;;;AAAA,KAQY,gBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;cAuEa,cAAA;EAAc,WAAA,CAAA;AAAA;;;;cAWd,kBAAA;EAAkB,WAAA,CAAA;AAAA;;;AAA/B;KAWY,iBAAA;;;;KAIA,cAAA;;;;KAIA,gBAAA;AAJZ;;;AAAA,KAQY,gBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;cAwEa,cAAA;EAAc,WAAA,CAAA;AAAA;;;;cAWd,kBAAA;EAAkB,WAAA,CAAA;AAAA;;;AAA/B;KAWY,iBAAA;;;;KAIA,cAAA;;;;KAIA,gBAAA;AAJZ;;;AAAA,KAQY,gBAAA"}
@@ -6,7 +6,6 @@ import { OpenAIAssistantAdapter } from "../service-adapters/openai/openai-assist
6
6
  import { UnifyAdapter } from "../service-adapters/unify/unify-adapter.mjs";
7
7
  import { GroqAdapter } from "../service-adapters/groq/groq-adapter.mjs";
8
8
  import { createLogger } from "./logger.mjs";
9
- import { TelemetryAgentRunner } from "./runtime/telemetry-agent-runner.mjs";
10
9
  import { convertMCPToolsToActions, extractParametersFromSchema, generateMcpToolInstructions } from "./runtime/mcp-tools-utils.mjs";
11
10
  import { CopilotRuntime, copilotKitEndpoint, langGraphPlatformEndpoint, resolveEndpointType } from "./runtime/copilot-runtime.mjs";
12
11
  import { buildSchema, getCommonConfig } from "./integrations/shared.mjs";
@@ -15,6 +14,7 @@ import { copilotRuntimeNodeHttpEndpoint } from "./integrations/node-http/index.m
15
14
  import { config, copilotRuntimeNextJSPagesRouterEndpoint } from "./integrations/nextjs/pages-router.mjs";
16
15
  import { copilotRuntimeNodeExpressEndpoint } from "./integrations/node-express/index.mjs";
17
16
  import { copilotRuntimeNestEndpoint } from "./integrations/nest/index.mjs";
17
+ import { TelemetryAgentRunner } from "./runtime/telemetry-agent-runner.mjs";
18
18
 
19
19
  //#region src/v1-deprecated/lib/index.ts
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CustomEventNames:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphHttpAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — PredictStateTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TextMessageEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — ToolCallEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nexport * from \"../service-adapters/openai/openai-adapter\";\nexport * from \"../service-adapters/langchain/langchain-adapter\";\nexport * from \"../service-adapters/google/google-genai-adapter\";\nexport * from \"../service-adapters/openai/openai-assistant-adapter\";\nexport * from \"../service-adapters/unify/unify-adapter\";\nexport * from \"../service-adapters/groq/groq-adapter\";\nexport * from \"./integrations\";\nexport * from \"./logger\";\nexport * from \"./runtime/copilot-runtime\";\nexport * from \"./runtime/mcp-tools-utils\";\nexport * from \"./runtime/telemetry-agent-runner\";\n\n// The below re-exports \"dummy\" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route\n\n/**\n * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphAgent {\n constructor() {\n throw new Error(\n \"LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphHttpAgent {\n constructor() {\n throw new Error(\n \"LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type TextMessageEvents = any;\n/**\n * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type ToolCallEvents = any;\n/**\n * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type CustomEventNames = any;\n/**\n * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type PredictStateTool = any;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,IAAa,iBAAb,MAA4B;CAC1B,cAAc;AACZ,QAAM,IAAI,MACR,4HACD;;;;;;AAOL,IAAa,qBAAb,MAAgC;CAC9B,cAAc;AACZ,QAAM,IAAI,MACR,gIACD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/v1-deprecated/lib/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CustomEventNames:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphAgent:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LangGraphHttpAgent:\n * Use `HttpAgent` from `@ag-ui/client`, passed to the v2 `CopilotRuntime`.\n * Exception: a v1 client still resuming interrupts through `forwardedProps.command.resume` — `LangGraphHttpAgent` keeps a back-compat bridge for that channel.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — PredictStateTool:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TextMessageEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — ToolCallEvents:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nexport * from \"../service-adapters/openai/openai-adapter\";\nexport * from \"../service-adapters/langchain/langchain-adapter\";\nexport * from \"../service-adapters/google/google-genai-adapter\";\nexport * from \"../service-adapters/openai/openai-assistant-adapter\";\nexport * from \"../service-adapters/unify/unify-adapter\";\nexport * from \"../service-adapters/groq/groq-adapter\";\nexport * from \"./integrations\";\nexport * from \"./logger\";\nexport * from \"./runtime/copilot-runtime\";\nexport * from \"./runtime/mcp-tools-utils\";\nexport * from \"./runtime/telemetry-agent-runner\";\n\n// The below re-exports \"dummy\" classes and types, to get a deprecation warning redirecting the users to import these from the correct, new route\n\n/**\n * @deprecated LangGraphAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphAgent {\n constructor() {\n throw new Error(\n \"LangGraphAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated LangGraphHttpAgent import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport class LangGraphHttpAgent {\n constructor() {\n throw new Error(\n \"LangGraphHttpAgent import from @copilotkit/runtime is deprecated. Please import it from @copilotkit/runtime/langgraph instead\",\n );\n }\n}\n\n/**\n * @deprecated TextMessageEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type TextMessageEvents = any;\n/**\n * @deprecated ToolCallEvents import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type ToolCallEvents = any;\n/**\n * @deprecated CustomEventNames import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type CustomEventNames = any;\n/**\n * @deprecated PredictStateTool import from `@copilotkit/runtime` is deprecated. Please import it from `@copilotkit/runtime/langgraph` instead\n */\nexport type PredictStateTool = any;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAa,iBAAb,MAA4B;CAC1B,cAAc;AACZ,QAAM,IAAI,MACR,4HACD;;;;;;AAOL,IAAa,qBAAb,MAAgC;CAC9B,cAAc;AACZ,QAAM,IAAI,MACR,gIACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.cjs","names":["getCommonConfig","getRuntimeInstanceTelemetryInfo","createCopilotEndpointSingleRoute"],"sources":["../../../../../src/v1-deprecated/lib/integrations/nextjs/app-router.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNextJSAppRouterEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { handle } from \"hono/vercel\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-app-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS App Router endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const copilotRoute = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handleRequest = handle(copilotRoute as any);\n return { handleRequest };\n}\n"],"mappings":";;;;;;;;AA2BA,SAAgB,sCACd,SACA;CACA,MAAM,eAAeA,+BAAgB,QAAQ;AAE7C,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,qBACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,kCAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACAC,yDAAgC,QAAQ,CACzC;AAGD,CADe,aAAa,QACrB,MAAM,sCAAsC;CAEnD,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;AAWtD,QAAO,EAAE,uCAPYC,qDAAiC;EACpD,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ,CAEwC,EACzB"}
1
+ {"version":3,"file":"app-router.cjs","names":["getCommonConfig","getRuntimeInstanceTelemetryInfo","createCopilotEndpointSingleRoute"],"sources":["../../../../../src/v1-deprecated/lib/integrations/nextjs/app-router.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNextJSAppRouterEndpoint:\n * V2 import and usage:\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime/v2\";\n * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/core/fetch-handler.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { handle } from \"hono/vercel\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-app-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS App Router endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const copilotRoute = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handleRequest = handle(copilotRoute as any);\n return { handleRequest };\n}\n"],"mappings":";;;;;;;;AA2BA,SAAgB,sCACd,SACA;CACA,MAAM,eAAeA,+BAAgB,QAAQ;AAE7C,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,qBACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,kCAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACAC,yDAAgC,QAAQ,CACzC;AAGD,CADe,aAAa,QACrB,MAAM,sCAAsC;CAEnD,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;AAWtD,QAAO,EAAE,uCAPYC,qDAAiC;EACpD,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ,CAEwC,EACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-router.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/nextjs/app-router.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNextJSAppRouterEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { handle } from \"hono/vercel\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-app-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS App Router endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const copilotRoute = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handleRequest = handle(copilotRoute as any);\n return { handleRequest };\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,sCACd,SACA;CACA,MAAM,eAAe,gBAAgB,QAAQ;AAE7C,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,qBACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,iBAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;AAGD,CADe,aAAa,QACrB,MAAM,sCAAsC;CAEnD,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;AAWtD,QAAO,EAAE,eADa,OAND,iCAAiC;EACpD,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ,CAEwC,EACzB"}
1
+ {"version":3,"file":"app-router.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/nextjs/app-router.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNextJSAppRouterEndpoint:\n * V2 import and usage:\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime/v2\";\n * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/core/fetch-handler.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { handle } from \"hono/vercel\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"nextjs-app-router\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating NextJS App Router endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const copilotRoute = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handleRequest = handle(copilotRoute as any);\n return { handleRequest };\n}\n"],"mappings":";;;;;;;AA2BA,SAAgB,sCACd,SACA;CACA,MAAM,eAAe,gBAAgB,QAAQ;AAE7C,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,qBACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,iBAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;AAGD,CADe,aAAa,QACrB,MAAM,sCAAsC;CAEnD,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;AAWtD,QAAO,EAAE,eADa,OAND,iCAAiC;EACpD,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ,CAEwC,EACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-express/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeExpressEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;AAyBA,SAAgB,kCACd,SACA;AACA,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,gBACZ,EACF,CAAC;AAEF,SAAQ,QAAQ,UAAU,QACxB,gCACAA,yDAAgC,QAAQ,CACzC;AACD,QAAOC,6CAA+B,QAAQ"}
1
+ {"version":3,"file":"index.cjs","names":["getRuntimeInstanceTelemetryInfo","copilotRuntimeNodeHttpEndpoint"],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-express/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeExpressEndpoint:\n * V2 import and usage:\n * import { createCopilotExpressHandler } from \"@copilotkit/runtime/v2/express\";\n * const v2CreateCopilotExpressHandler = createCopilotExpressHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/endpoints/express.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;AAyBA,SAAgB,kCACd,SACA;AACA,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,gBACZ,EACF,CAAC;AAEF,SAAQ,QAAQ,UAAU,QACxB,gCACAA,yDAAgC,QAAQ,CACzC;AACD,QAAOC,6CAA+B,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-express/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeExpressEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;AAyBA,SAAgB,kCACd,SACA;AACA,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,gBACZ,EACF,CAAC;AAEF,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;AACD,QAAO,+BAA+B,QAAQ"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-express/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeExpressEndpoint:\n * V2 import and usage:\n * import { createCopilotExpressHandler } from \"@copilotkit/runtime/v2/express\";\n * const v2CreateCopilotExpressHandler = createCopilotExpressHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/endpoints/express.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n"],"mappings":";;;;;AAyBA,SAAgB,kCACd,SACA;AACA,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,gBACZ,EACF,CAAC;AAEF,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;AACD,QAAO,+BAA+B,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["getCommonConfig","getRuntimeInstanceTelemetryInfo","createCopilotEndpointSingleRoute","getFullUrl","toHeaders","isStreamConsumed","nodeStreamToReadableStream","synthesizeBodyFromParsedBody","isDisturbedOrLockedError"],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-http/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeHttpEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { IncomingWithBody } from \"./request-handler\";\nimport {\n getFullUrl,\n isDisturbedOrLockedError,\n isStreamConsumed,\n nodeStreamToReadableStream,\n readableStreamToNodeStream,\n synthesizeBodyFromParsedBody,\n toHeaders,\n} from \"./request-handler\";\n\nexport function copilotRuntimeNodeHttpEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-http\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating Node HTTP endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const honoApp = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handle = async function handler(\n req: IncomingWithBody,\n res: ServerResponse,\n ) {\n const url = getFullUrl(req);\n const hasBody = req.method !== \"GET\" && req.method !== \"HEAD\";\n\n const baseHeaders = toHeaders(req.headers);\n const parsedBody = req.body;\n\n const streamConsumed = isStreamConsumed(req) || parsedBody !== undefined;\n const canStream = hasBody && !streamConsumed;\n\n let requestBody: BodyInit | null | undefined = undefined;\n let useDuplex = false;\n\n if (hasBody && canStream) {\n requestBody = nodeStreamToReadableStream(req);\n useDuplex = true;\n }\n\n if (hasBody && streamConsumed) {\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n baseHeaders,\n );\n requestBody = synthesized.body ?? undefined;\n baseHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n baseHeaders.set(\"content-type\", synthesized.contentType);\n }\n\n logger.debug(\n \"Request stream already consumed; using parsed req.body to rebuild request.\",\n );\n } else {\n logger.warn(\n \"Request stream consumed with no available body; sending empty payload.\",\n );\n requestBody = undefined;\n }\n }\n\n const buildRequest = (\n body: BodyInit | null | undefined,\n headers: Headers,\n duplex: boolean,\n ) =>\n new Request(url, {\n method: req.method,\n headers,\n body,\n duplex: duplex ? \"half\" : undefined,\n } as RequestInit);\n\n let response: Response;\n try {\n response = await honoApp.fetch(\n buildRequest(requestBody, baseHeaders, useDuplex),\n );\n } catch (error) {\n if (isDisturbedOrLockedError(error) && hasBody) {\n logger.warn(\n \"Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.\",\n );\n\n const fallbackHeaders = new Headers(baseHeaders);\n let fallbackBody: BodyInit | null | undefined;\n\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n fallbackHeaders,\n );\n fallbackBody = synthesized.body ?? undefined;\n fallbackHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n fallbackHeaders.set(\"content-type\", synthesized.contentType);\n }\n } else {\n fallbackBody = undefined;\n }\n\n response = await honoApp.fetch(\n buildRequest(fallbackBody, fallbackHeaders, false),\n );\n } else {\n throw error;\n }\n }\n\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n\n if (response.body) {\n readableStreamToNodeStream(response.body).pipe(res);\n } else {\n res.end();\n }\n };\n\n // Duck-type check for Request-like objects (handles polyfilled Request from @hono/node-server)\n function isRequestLike(obj: unknown): obj is Request {\n return (\n obj instanceof Request ||\n (typeof obj === \"object\" &&\n obj !== null &&\n \"url\" in obj &&\n \"method\" in obj &&\n \"headers\" in obj &&\n typeof (obj as any).url === \"string\" &&\n typeof (obj as any).method === \"string\")\n );\n }\n\n return function (\n reqOrRequest: IncomingMessage | Request,\n res?: ServerResponse,\n ): Promise<void> | Promise<Response> | Response {\n if (isRequestLike(reqOrRequest) && !res) {\n return honoApp.fetch(reqOrRequest as Request);\n }\n if (!res) {\n throw new TypeError(\"ServerResponse is required for Node HTTP requests\");\n }\n return handle(reqOrRequest as IncomingMessage, res);\n };\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,+BACd,SACA;CACA,MAAM,eAAeA,+BAAgB,QAAQ;AAE7C,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,aACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,kCAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACAC,yDAAgC,QAAQ,CACzC;CAED,MAAM,SAAS,aAAa;AAC5B,QAAO,MAAM,8BAA8B;CAE3C,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;CAItD,MAAM,UAAUC,qDAAiC;EAC/C,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ;CAET,MAAM,SAAS,eAAe,QAC5B,KACA,KACA;EACA,MAAM,MAAMC,mCAAW,IAAI;EAC3B,MAAM,UAAU,IAAI,WAAW,SAAS,IAAI,WAAW;EAEvD,MAAM,cAAcC,kCAAU,IAAI,QAAQ;EAC1C,MAAM,aAAa,IAAI;EAEvB,MAAM,iBAAiBC,yCAAiB,IAAI,IAAI,eAAe;EAC/D,MAAM,YAAY,WAAW,CAAC;EAE9B,IAAI,cAA2C;EAC/C,IAAI,YAAY;AAEhB,MAAI,WAAW,WAAW;AACxB,iBAAcC,mDAA2B,IAAI;AAC7C,eAAY;;AAGd,MAAI,WAAW,eACb,KAAI,eAAe,QAAW;GAC5B,MAAM,cAAcC,qDAClB,YACA,YACD;AACD,iBAAc,YAAY,QAAQ;AAClC,eAAY,OAAO,iBAAiB;AAEpC,OAAI,YAAY,YACd,aAAY,IAAI,gBAAgB,YAAY,YAAY;AAG1D,UAAO,MACL,6EACD;SACI;AACL,UAAO,KACL,yEACD;AACD,iBAAc;;EAIlB,MAAM,gBACJ,MACA,SACA,WAEA,IAAI,QAAQ,KAAK;GACf,QAAQ,IAAI;GACZ;GACA;GACA,QAAQ,SAAS,SAAS;GAC3B,CAAgB;EAEnB,IAAI;AACJ,MAAI;AACF,cAAW,MAAM,QAAQ,MACvB,aAAa,aAAa,aAAa,UAAU,CAClD;WACM,OAAO;AACd,OAAIC,iDAAyB,MAAM,IAAI,SAAS;AAC9C,WAAO,KACL,oGACD;IAED,MAAM,kBAAkB,IAAI,QAAQ,YAAY;IAChD,IAAI;AAEJ,QAAI,eAAe,QAAW;KAC5B,MAAM,cAAcD,qDAClB,YACA,gBACD;AACD,oBAAe,YAAY,QAAQ;AACnC,qBAAgB,OAAO,iBAAiB;AAExC,SAAI,YAAY,YACd,iBAAgB,IAAI,gBAAgB,YAAY,YAAY;UAG9D,gBAAe;AAGjB,eAAW,MAAM,QAAQ,MACvB,aAAa,cAAc,iBAAiB,MAAM,CACnD;SAED,OAAM;;AAIV,MAAI,aAAa,SAAS;AAC1B,WAAS,QAAQ,SAAS,OAAO,QAAQ;AACvC,OAAI,UAAU,KAAK,MAAM;IACzB;AAEF,MAAI,SAAS,KACX,oDAA2B,SAAS,KAAK,CAAC,KAAK,IAAI;MAEnD,KAAI,KAAK;;CAKb,SAAS,cAAc,KAA8B;AACnD,SACE,eAAe,WACd,OAAO,QAAQ,YACd,QAAQ,QACR,SAAS,OACT,YAAY,OACZ,aAAa,OACb,OAAQ,IAAY,QAAQ,YAC5B,OAAQ,IAAY,WAAW;;AAIrC,QAAO,SACL,cACA,KAC8C;AAC9C,MAAI,cAAc,aAAa,IAAI,CAAC,IAClC,QAAO,QAAQ,MAAM,aAAwB;AAE/C,MAAI,CAAC,IACH,OAAM,IAAI,UAAU,oDAAoD;AAE1E,SAAO,OAAO,cAAiC,IAAI"}
1
+ {"version":3,"file":"index.cjs","names":["getCommonConfig","getRuntimeInstanceTelemetryInfo","createCopilotEndpointSingleRoute","getFullUrl","toHeaders","isStreamConsumed","nodeStreamToReadableStream","synthesizeBodyFromParsedBody","isDisturbedOrLockedError"],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-http/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeHttpEndpoint:\n * V2 import and usage:\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime/v2\";\n * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/core/fetch-handler.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { IncomingWithBody } from \"./request-handler\";\nimport {\n getFullUrl,\n isDisturbedOrLockedError,\n isStreamConsumed,\n nodeStreamToReadableStream,\n readableStreamToNodeStream,\n synthesizeBodyFromParsedBody,\n toHeaders,\n} from \"./request-handler\";\n\nexport function copilotRuntimeNodeHttpEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-http\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating Node HTTP endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const honoApp = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handle = async function handler(\n req: IncomingWithBody,\n res: ServerResponse,\n ) {\n const url = getFullUrl(req);\n const hasBody = req.method !== \"GET\" && req.method !== \"HEAD\";\n\n const baseHeaders = toHeaders(req.headers);\n const parsedBody = req.body;\n\n const streamConsumed = isStreamConsumed(req) || parsedBody !== undefined;\n const canStream = hasBody && !streamConsumed;\n\n let requestBody: BodyInit | null | undefined = undefined;\n let useDuplex = false;\n\n if (hasBody && canStream) {\n requestBody = nodeStreamToReadableStream(req);\n useDuplex = true;\n }\n\n if (hasBody && streamConsumed) {\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n baseHeaders,\n );\n requestBody = synthesized.body ?? undefined;\n baseHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n baseHeaders.set(\"content-type\", synthesized.contentType);\n }\n\n logger.debug(\n \"Request stream already consumed; using parsed req.body to rebuild request.\",\n );\n } else {\n logger.warn(\n \"Request stream consumed with no available body; sending empty payload.\",\n );\n requestBody = undefined;\n }\n }\n\n const buildRequest = (\n body: BodyInit | null | undefined,\n headers: Headers,\n duplex: boolean,\n ) =>\n new Request(url, {\n method: req.method,\n headers,\n body,\n duplex: duplex ? \"half\" : undefined,\n } as RequestInit);\n\n let response: Response;\n try {\n response = await honoApp.fetch(\n buildRequest(requestBody, baseHeaders, useDuplex),\n );\n } catch (error) {\n if (isDisturbedOrLockedError(error) && hasBody) {\n logger.warn(\n \"Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.\",\n );\n\n const fallbackHeaders = new Headers(baseHeaders);\n let fallbackBody: BodyInit | null | undefined;\n\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n fallbackHeaders,\n );\n fallbackBody = synthesized.body ?? undefined;\n fallbackHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n fallbackHeaders.set(\"content-type\", synthesized.contentType);\n }\n } else {\n fallbackBody = undefined;\n }\n\n response = await honoApp.fetch(\n buildRequest(fallbackBody, fallbackHeaders, false),\n );\n } else {\n throw error;\n }\n }\n\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n\n if (response.body) {\n readableStreamToNodeStream(response.body).pipe(res);\n } else {\n res.end();\n }\n };\n\n // Duck-type check for Request-like objects (handles polyfilled Request from @hono/node-server)\n function isRequestLike(obj: unknown): obj is Request {\n return (\n obj instanceof Request ||\n (typeof obj === \"object\" &&\n obj !== null &&\n \"url\" in obj &&\n \"method\" in obj &&\n \"headers\" in obj &&\n typeof (obj as any).url === \"string\" &&\n typeof (obj as any).method === \"string\")\n );\n }\n\n return function (\n reqOrRequest: IncomingMessage | Request,\n res?: ServerResponse,\n ): Promise<void> | Promise<Response> | Response {\n if (isRequestLike(reqOrRequest) && !res) {\n return honoApp.fetch(reqOrRequest as Request);\n }\n if (!res) {\n throw new TypeError(\"ServerResponse is required for Node HTTP requests\");\n }\n return handle(reqOrRequest as IncomingMessage, res);\n };\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,+BACd,SACA;CACA,MAAM,eAAeA,+BAAgB,QAAQ;AAE7C,kCAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,aACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,kCAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACAC,yDAAgC,QAAQ,CACzC;CAED,MAAM,SAAS,aAAa;AAC5B,QAAO,MAAM,8BAA8B;CAE3C,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;CAItD,MAAM,UAAUC,qDAAiC;EAC/C,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ;CAET,MAAM,SAAS,eAAe,QAC5B,KACA,KACA;EACA,MAAM,MAAMC,mCAAW,IAAI;EAC3B,MAAM,UAAU,IAAI,WAAW,SAAS,IAAI,WAAW;EAEvD,MAAM,cAAcC,kCAAU,IAAI,QAAQ;EAC1C,MAAM,aAAa,IAAI;EAEvB,MAAM,iBAAiBC,yCAAiB,IAAI,IAAI,eAAe;EAC/D,MAAM,YAAY,WAAW,CAAC;EAE9B,IAAI,cAA2C;EAC/C,IAAI,YAAY;AAEhB,MAAI,WAAW,WAAW;AACxB,iBAAcC,mDAA2B,IAAI;AAC7C,eAAY;;AAGd,MAAI,WAAW,eACb,KAAI,eAAe,QAAW;GAC5B,MAAM,cAAcC,qDAClB,YACA,YACD;AACD,iBAAc,YAAY,QAAQ;AAClC,eAAY,OAAO,iBAAiB;AAEpC,OAAI,YAAY,YACd,aAAY,IAAI,gBAAgB,YAAY,YAAY;AAG1D,UAAO,MACL,6EACD;SACI;AACL,UAAO,KACL,yEACD;AACD,iBAAc;;EAIlB,MAAM,gBACJ,MACA,SACA,WAEA,IAAI,QAAQ,KAAK;GACf,QAAQ,IAAI;GACZ;GACA;GACA,QAAQ,SAAS,SAAS;GAC3B,CAAgB;EAEnB,IAAI;AACJ,MAAI;AACF,cAAW,MAAM,QAAQ,MACvB,aAAa,aAAa,aAAa,UAAU,CAClD;WACM,OAAO;AACd,OAAIC,iDAAyB,MAAM,IAAI,SAAS;AAC9C,WAAO,KACL,oGACD;IAED,MAAM,kBAAkB,IAAI,QAAQ,YAAY;IAChD,IAAI;AAEJ,QAAI,eAAe,QAAW;KAC5B,MAAM,cAAcD,qDAClB,YACA,gBACD;AACD,oBAAe,YAAY,QAAQ;AACnC,qBAAgB,OAAO,iBAAiB;AAExC,SAAI,YAAY,YACd,iBAAgB,IAAI,gBAAgB,YAAY,YAAY;UAG9D,gBAAe;AAGjB,eAAW,MAAM,QAAQ,MACvB,aAAa,cAAc,iBAAiB,MAAM,CACnD;SAED,OAAM;;AAIV,MAAI,aAAa,SAAS;AAC1B,WAAS,QAAQ,SAAS,OAAO,QAAQ;AACvC,OAAI,UAAU,KAAK,MAAM;IACzB;AAEF,MAAI,SAAS,KACX,oDAA2B,SAAS,KAAK,CAAC,KAAK,IAAI;MAEnD,KAAI,KAAK;;CAKb,SAAS,cAAc,KAA8B;AACnD,SACE,eAAe,WACd,OAAO,QAAQ,YACd,QAAQ,QACR,SAAS,OACT,YAAY,OACZ,aAAa,OACb,OAAQ,IAAY,QAAQ,YAC5B,OAAQ,IAAY,WAAW;;AAIrC,QAAO,SACL,cACA,KAC8C;AAC9C,MAAI,cAAc,aAAa,IAAI,CAAC,IAClC,QAAO,QAAQ,MAAM,aAAwB;AAE/C,MAAI,CAAC,IACH,OAAM,IAAI,UAAU,oDAAoD;AAE1E,SAAO,OAAO,cAAiC,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-http/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeHttpEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { IncomingWithBody } from \"./request-handler\";\nimport {\n getFullUrl,\n isDisturbedOrLockedError,\n isStreamConsumed,\n nodeStreamToReadableStream,\n readableStreamToNodeStream,\n synthesizeBodyFromParsedBody,\n toHeaders,\n} from \"./request-handler\";\n\nexport function copilotRuntimeNodeHttpEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-http\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating Node HTTP endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const honoApp = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handle = async function handler(\n req: IncomingWithBody,\n res: ServerResponse,\n ) {\n const url = getFullUrl(req);\n const hasBody = req.method !== \"GET\" && req.method !== \"HEAD\";\n\n const baseHeaders = toHeaders(req.headers);\n const parsedBody = req.body;\n\n const streamConsumed = isStreamConsumed(req) || parsedBody !== undefined;\n const canStream = hasBody && !streamConsumed;\n\n let requestBody: BodyInit | null | undefined = undefined;\n let useDuplex = false;\n\n if (hasBody && canStream) {\n requestBody = nodeStreamToReadableStream(req);\n useDuplex = true;\n }\n\n if (hasBody && streamConsumed) {\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n baseHeaders,\n );\n requestBody = synthesized.body ?? undefined;\n baseHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n baseHeaders.set(\"content-type\", synthesized.contentType);\n }\n\n logger.debug(\n \"Request stream already consumed; using parsed req.body to rebuild request.\",\n );\n } else {\n logger.warn(\n \"Request stream consumed with no available body; sending empty payload.\",\n );\n requestBody = undefined;\n }\n }\n\n const buildRequest = (\n body: BodyInit | null | undefined,\n headers: Headers,\n duplex: boolean,\n ) =>\n new Request(url, {\n method: req.method,\n headers,\n body,\n duplex: duplex ? \"half\" : undefined,\n } as RequestInit);\n\n let response: Response;\n try {\n response = await honoApp.fetch(\n buildRequest(requestBody, baseHeaders, useDuplex),\n );\n } catch (error) {\n if (isDisturbedOrLockedError(error) && hasBody) {\n logger.warn(\n \"Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.\",\n );\n\n const fallbackHeaders = new Headers(baseHeaders);\n let fallbackBody: BodyInit | null | undefined;\n\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n fallbackHeaders,\n );\n fallbackBody = synthesized.body ?? undefined;\n fallbackHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n fallbackHeaders.set(\"content-type\", synthesized.contentType);\n }\n } else {\n fallbackBody = undefined;\n }\n\n response = await honoApp.fetch(\n buildRequest(fallbackBody, fallbackHeaders, false),\n );\n } else {\n throw error;\n }\n }\n\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n\n if (response.body) {\n readableStreamToNodeStream(response.body).pipe(res);\n } else {\n res.end();\n }\n };\n\n // Duck-type check for Request-like objects (handles polyfilled Request from @hono/node-server)\n function isRequestLike(obj: unknown): obj is Request {\n return (\n obj instanceof Request ||\n (typeof obj === \"object\" &&\n obj !== null &&\n \"url\" in obj &&\n \"method\" in obj &&\n \"headers\" in obj &&\n typeof (obj as any).url === \"string\" &&\n typeof (obj as any).method === \"string\")\n );\n }\n\n return function (\n reqOrRequest: IncomingMessage | Request,\n res?: ServerResponse,\n ): Promise<void> | Promise<Response> | Response {\n if (isRequestLike(reqOrRequest) && !res) {\n return honoApp.fetch(reqOrRequest as Request);\n }\n if (!res) {\n throw new TypeError(\"ServerResponse is required for Node HTTP requests\");\n }\n return handle(reqOrRequest as IncomingMessage, res);\n };\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,+BACd,SACA;CACA,MAAM,eAAe,gBAAgB,QAAQ;AAE7C,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,aACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,iBAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;CAED,MAAM,SAAS,aAAa;AAC5B,QAAO,MAAM,8BAA8B;CAE3C,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;CAItD,MAAM,UAAU,iCAAiC;EAC/C,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ;CAET,MAAM,SAAS,eAAe,QAC5B,KACA,KACA;EACA,MAAM,MAAM,WAAW,IAAI;EAC3B,MAAM,UAAU,IAAI,WAAW,SAAS,IAAI,WAAW;EAEvD,MAAM,cAAc,UAAU,IAAI,QAAQ;EAC1C,MAAM,aAAa,IAAI;EAEvB,MAAM,iBAAiB,iBAAiB,IAAI,IAAI,eAAe;EAC/D,MAAM,YAAY,WAAW,CAAC;EAE9B,IAAI,cAA2C;EAC/C,IAAI,YAAY;AAEhB,MAAI,WAAW,WAAW;AACxB,iBAAc,2BAA2B,IAAI;AAC7C,eAAY;;AAGd,MAAI,WAAW,eACb,KAAI,eAAe,QAAW;GAC5B,MAAM,cAAc,6BAClB,YACA,YACD;AACD,iBAAc,YAAY,QAAQ;AAClC,eAAY,OAAO,iBAAiB;AAEpC,OAAI,YAAY,YACd,aAAY,IAAI,gBAAgB,YAAY,YAAY;AAG1D,UAAO,MACL,6EACD;SACI;AACL,UAAO,KACL,yEACD;AACD,iBAAc;;EAIlB,MAAM,gBACJ,MACA,SACA,WAEA,IAAI,QAAQ,KAAK;GACf,QAAQ,IAAI;GACZ;GACA;GACA,QAAQ,SAAS,SAAS;GAC3B,CAAgB;EAEnB,IAAI;AACJ,MAAI;AACF,cAAW,MAAM,QAAQ,MACvB,aAAa,aAAa,aAAa,UAAU,CAClD;WACM,OAAO;AACd,OAAI,yBAAyB,MAAM,IAAI,SAAS;AAC9C,WAAO,KACL,oGACD;IAED,MAAM,kBAAkB,IAAI,QAAQ,YAAY;IAChD,IAAI;AAEJ,QAAI,eAAe,QAAW;KAC5B,MAAM,cAAc,6BAClB,YACA,gBACD;AACD,oBAAe,YAAY,QAAQ;AACnC,qBAAgB,OAAO,iBAAiB;AAExC,SAAI,YAAY,YACd,iBAAgB,IAAI,gBAAgB,YAAY,YAAY;UAG9D,gBAAe;AAGjB,eAAW,MAAM,QAAQ,MACvB,aAAa,cAAc,iBAAiB,MAAM,CACnD;SAED,OAAM;;AAIV,MAAI,aAAa,SAAS;AAC1B,WAAS,QAAQ,SAAS,OAAO,QAAQ;AACvC,OAAI,UAAU,KAAK,MAAM;IACzB;AAEF,MAAI,SAAS,KACX,4BAA2B,SAAS,KAAK,CAAC,KAAK,IAAI;MAEnD,KAAI,KAAK;;CAKb,SAAS,cAAc,KAA8B;AACnD,SACE,eAAe,WACd,OAAO,QAAQ,YACd,QAAQ,QACR,SAAS,OACT,YAAY,OACZ,aAAa,OACb,OAAQ,IAAY,QAAQ,YAC5B,OAAQ,IAAY,WAAW;;AAIrC,QAAO,SACL,cACA,KAC8C;AAC9C,MAAI,cAAc,aAAa,IAAI,CAAC,IAClC,QAAO,QAAQ,MAAM,aAAwB;AAE/C,MAAI,CAAC,IACH,OAAM,IAAI,UAAU,oDAAoD;AAE1E,SAAO,OAAO,cAAiC,IAAI"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../src/v1-deprecated/lib/integrations/node-http/index.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotRuntimeNodeHttpEndpoint:\n * V2 import and usage:\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime/v2\";\n * const v2CreateCopilotRuntimeHandler = createCopilotRuntimeHandler;\n * V2 replacement source: packages/runtime/src/v2/runtime/core/fetch-handler.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\nimport type { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { getCommonConfig } from \"../shared\";\nimport telemetry, {\n getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { createCopilotEndpointSingleRoute } from \"../../../../v2/runtime\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { IncomingWithBody } from \"./request-handler\";\nimport {\n getFullUrl,\n isDisturbedOrLockedError,\n isStreamConsumed,\n nodeStreamToReadableStream,\n readableStreamToNodeStream,\n synthesizeBodyFromParsedBody,\n toHeaders,\n} from \"./request-handler\";\n\nexport function copilotRuntimeNodeHttpEndpoint(\n options: CreateCopilotRuntimeServerOptions,\n) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-http\",\n },\n });\n\n if (options.properties?._copilotkit) {\n telemetry.setGlobalProperties({\n _copilotkit: options.properties._copilotkit,\n });\n }\n\n options.runtime.telemetry.capture(\n \"oss.runtime.instance_created\",\n getRuntimeInstanceTelemetryInfo(options),\n );\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating Node HTTP endpoint\");\n\n const serviceAdapter = options.serviceAdapter;\n if (serviceAdapter) {\n options.runtime.handleServiceAdapter(serviceAdapter);\n }\n\n // Note: cors option requires @copilotkit/runtime with credentials support\n const honoApp = createCopilotEndpointSingleRoute({\n runtime: options.runtime.instance,\n basePath: options.baseUrl ?? options.endpoint,\n ...(options.cors && { cors: options.cors }),\n } as any);\n\n const handle = async function handler(\n req: IncomingWithBody,\n res: ServerResponse,\n ) {\n const url = getFullUrl(req);\n const hasBody = req.method !== \"GET\" && req.method !== \"HEAD\";\n\n const baseHeaders = toHeaders(req.headers);\n const parsedBody = req.body;\n\n const streamConsumed = isStreamConsumed(req) || parsedBody !== undefined;\n const canStream = hasBody && !streamConsumed;\n\n let requestBody: BodyInit | null | undefined = undefined;\n let useDuplex = false;\n\n if (hasBody && canStream) {\n requestBody = nodeStreamToReadableStream(req);\n useDuplex = true;\n }\n\n if (hasBody && streamConsumed) {\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n baseHeaders,\n );\n requestBody = synthesized.body ?? undefined;\n baseHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n baseHeaders.set(\"content-type\", synthesized.contentType);\n }\n\n logger.debug(\n \"Request stream already consumed; using parsed req.body to rebuild request.\",\n );\n } else {\n logger.warn(\n \"Request stream consumed with no available body; sending empty payload.\",\n );\n requestBody = undefined;\n }\n }\n\n const buildRequest = (\n body: BodyInit | null | undefined,\n headers: Headers,\n duplex: boolean,\n ) =>\n new Request(url, {\n method: req.method,\n headers,\n body,\n duplex: duplex ? \"half\" : undefined,\n } as RequestInit);\n\n let response: Response;\n try {\n response = await honoApp.fetch(\n buildRequest(requestBody, baseHeaders, useDuplex),\n );\n } catch (error) {\n if (isDisturbedOrLockedError(error) && hasBody) {\n logger.warn(\n \"Encountered disturbed/locked request body; rebuilding request using parsed body or empty payload.\",\n );\n\n const fallbackHeaders = new Headers(baseHeaders);\n let fallbackBody: BodyInit | null | undefined;\n\n if (parsedBody !== undefined) {\n const synthesized = synthesizeBodyFromParsedBody(\n parsedBody,\n fallbackHeaders,\n );\n fallbackBody = synthesized.body ?? undefined;\n fallbackHeaders.delete(\"content-length\");\n\n if (synthesized.contentType) {\n fallbackHeaders.set(\"content-type\", synthesized.contentType);\n }\n } else {\n fallbackBody = undefined;\n }\n\n response = await honoApp.fetch(\n buildRequest(fallbackBody, fallbackHeaders, false),\n );\n } else {\n throw error;\n }\n }\n\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n res.setHeader(key, value);\n });\n\n if (response.body) {\n readableStreamToNodeStream(response.body).pipe(res);\n } else {\n res.end();\n }\n };\n\n // Duck-type check for Request-like objects (handles polyfilled Request from @hono/node-server)\n function isRequestLike(obj: unknown): obj is Request {\n return (\n obj instanceof Request ||\n (typeof obj === \"object\" &&\n obj !== null &&\n \"url\" in obj &&\n \"method\" in obj &&\n \"headers\" in obj &&\n typeof (obj as any).url === \"string\" &&\n typeof (obj as any).method === \"string\")\n );\n }\n\n return function (\n reqOrRequest: IncomingMessage | Request,\n res?: ServerResponse,\n ): Promise<void> | Promise<Response> | Response {\n if (isRequestLike(reqOrRequest) && !res) {\n return honoApp.fetch(reqOrRequest as Request);\n }\n if (!res) {\n throw new TypeError(\"ServerResponse is required for Node HTTP requests\");\n }\n return handle(reqOrRequest as IncomingMessage, res);\n };\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,+BACd,SACA;CACA,MAAM,eAAe,gBAAgB,QAAQ;AAE7C,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,aACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,iBAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,SAAQ,QAAQ,UAAU,QACxB,gCACA,gCAAgC,QAAQ,CACzC;CAED,MAAM,SAAS,aAAa;AAC5B,QAAO,MAAM,8BAA8B;CAE3C,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;CAItD,MAAM,UAAU,iCAAiC;EAC/C,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ;CAET,MAAM,SAAS,eAAe,QAC5B,KACA,KACA;EACA,MAAM,MAAM,WAAW,IAAI;EAC3B,MAAM,UAAU,IAAI,WAAW,SAAS,IAAI,WAAW;EAEvD,MAAM,cAAc,UAAU,IAAI,QAAQ;EAC1C,MAAM,aAAa,IAAI;EAEvB,MAAM,iBAAiB,iBAAiB,IAAI,IAAI,eAAe;EAC/D,MAAM,YAAY,WAAW,CAAC;EAE9B,IAAI,cAA2C;EAC/C,IAAI,YAAY;AAEhB,MAAI,WAAW,WAAW;AACxB,iBAAc,2BAA2B,IAAI;AAC7C,eAAY;;AAGd,MAAI,WAAW,eACb,KAAI,eAAe,QAAW;GAC5B,MAAM,cAAc,6BAClB,YACA,YACD;AACD,iBAAc,YAAY,QAAQ;AAClC,eAAY,OAAO,iBAAiB;AAEpC,OAAI,YAAY,YACd,aAAY,IAAI,gBAAgB,YAAY,YAAY;AAG1D,UAAO,MACL,6EACD;SACI;AACL,UAAO,KACL,yEACD;AACD,iBAAc;;EAIlB,MAAM,gBACJ,MACA,SACA,WAEA,IAAI,QAAQ,KAAK;GACf,QAAQ,IAAI;GACZ;GACA;GACA,QAAQ,SAAS,SAAS;GAC3B,CAAgB;EAEnB,IAAI;AACJ,MAAI;AACF,cAAW,MAAM,QAAQ,MACvB,aAAa,aAAa,aAAa,UAAU,CAClD;WACM,OAAO;AACd,OAAI,yBAAyB,MAAM,IAAI,SAAS;AAC9C,WAAO,KACL,oGACD;IAED,MAAM,kBAAkB,IAAI,QAAQ,YAAY;IAChD,IAAI;AAEJ,QAAI,eAAe,QAAW;KAC5B,MAAM,cAAc,6BAClB,YACA,gBACD;AACD,oBAAe,YAAY,QAAQ;AACnC,qBAAgB,OAAO,iBAAiB;AAExC,SAAI,YAAY,YACd,iBAAgB,IAAI,gBAAgB,YAAY,YAAY;UAG9D,gBAAe;AAGjB,eAAW,MAAM,QAAQ,MACvB,aAAa,cAAc,iBAAiB,MAAM,CACnD;SAED,OAAM;;AAIV,MAAI,aAAa,SAAS;AAC1B,WAAS,QAAQ,SAAS,OAAO,QAAQ;AACvC,OAAI,UAAU,KAAK,MAAM;IACzB;AAEF,MAAI,SAAS,KACX,4BAA2B,SAAS,KAAK,CAAC,KAAK,IAAI;MAEnD,KAAI,KAAK;;CAKb,SAAS,cAAc,KAA8B;AACnD,SACE,eAAe,WACd,OAAO,QAAQ,YACd,QAAQ,QACR,SAAS,OACT,YAAY,OACZ,aAAa,OACb,OAAQ,IAAY,QAAQ,YAC5B,OAAQ,IAAY,WAAW;;AAIrC,QAAO,SACL,cACA,KAC8C;AAC9C,MAAI,cAAc,aAAa,IAAI,CAAC,IAClC,QAAO,QAAQ,MAAM,aAAwB;AAE/C,MAAI,CAAC,IACH,OAAM,IAAI,UAAU,oDAAoD;AAE1E,SAAO,OAAO,cAAiC,IAAI"}
@@ -6,7 +6,6 @@ const require_in_memory = require('../../v2/runtime/runner/in-memory.cjs');
6
6
  const require_telemetry_identity = require('../../v2/runtime/telemetry/telemetry-identity.cjs');
7
7
  const require_runtime_error_reporter = require('../../v2/runtime/core/runtime-error-reporter.cjs');
8
8
  const require_runtime$1 = require('../../v2/runtime/core/runtime.cjs');
9
- const require_telemetry_agent_runner = require('./telemetry-agent-runner.cjs');
10
9
  const require_types = require('./types.cjs');
11
10
  const require_mcp_tools_utils = require('./mcp-tools-utils.cjs');
12
11
  const require_index = require('../../agent/index.cjs');
@@ -60,15 +59,12 @@ var CopilotRuntime = class {
60
59
  const resolvedTelemetryId = (0, _copilotkit_shared.firstNonBlankTelemetryId)(params?.telemetryId, process.env.CPK_TELEMETRY_ID);
61
60
  const resolvedTelemetryIdentity = resolvedTelemetryId !== void 0 ? { telemetryId: resolvedTelemetryId } : resolvedLicenseToken !== void 0 ? { licenseToken: resolvedLicenseToken } : {};
62
61
  this.telemetry = require_telemetry_client.default.createScope(resolvedTelemetryIdentity);
63
- const baseRunner = params?.runner ?? new require_in_memory.InMemoryAgentRunner();
64
- const runner = (0, _copilotkit_shared.isTelemetryDisabled)() ? baseRunner : new require_telemetry_agent_runner.TelemetryAgentRunner({
65
- runner: baseRunner,
66
- telemetry: this.telemetry
67
- });
62
+ const runner = params?.runner ?? new require_in_memory.InMemoryAgentRunner();
68
63
  const sharedRuntimeArgs = {
69
64
  agents: mergedAgents,
70
65
  telemetryId: resolvedTelemetryId,
71
66
  licenseToken: resolvedLicenseToken,
67
+ ɵtelemetry: this.telemetry,
72
68
  telemetryProperties: params?.telemetryProperties,
73
69
  debug: params?.debug,
74
70
  beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
@@ -171,17 +167,7 @@ var CopilotRuntime = class {
171
167
  createOnBeforeRequestHandler(params) {
172
168
  return async (hookParams) => {
173
169
  const { request } = hookParams;
174
- const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
175
170
  const body = await (0, _copilotkit_shared.readBody)(request);
176
- const forwardedProps = body?.forwardedProps;
177
- const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
178
- this.telemetry.capture("oss.runtime.copilot_request_created", {
179
- "cloud.guardrails.enabled": forwardedProps?.cloud?.guardrails !== void 0,
180
- requestType: forwardedProps?.metadata?.requestType ?? "unknown",
181
- "cloud.api_key_provided": !!publicApiKey,
182
- ...publicApiKey ? { "cloud.public_api_key": publicApiKey } : {},
183
- "cloud.base_url": cloudBaseUrl
184
- });
185
171
  if (request.method === "GET" || !body) return;
186
172
  const middlewareResult = await params?.beforeRequestMiddleware?.(hookParams);
187
173
  if (params?.middleware?.onBeforeRequest) {