@copilotkit/runtime 1.71.2 → 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 (113) hide show
  1. package/dist/agent/index.cjs +35 -1
  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 +36 -3
  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 +15 -24
  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 +16 -25
  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/service-adapters/experimental/ollama/ollama-adapter.cjs +16 -0
  36. package/dist/service-adapters/experimental/ollama/ollama-adapter.cjs.map +1 -1
  37. package/dist/service-adapters/experimental/ollama/ollama-adapter.d.cts +14 -0
  38. package/dist/service-adapters/experimental/ollama/ollama-adapter.d.cts.map +1 -1
  39. package/dist/service-adapters/experimental/ollama/ollama-adapter.d.mts +14 -0
  40. package/dist/service-adapters/experimental/ollama/ollama-adapter.d.mts.map +1 -1
  41. package/dist/service-adapters/experimental/ollama/ollama-adapter.mjs +16 -0
  42. package/dist/service-adapters/experimental/ollama/ollama-adapter.mjs.map +1 -1
  43. package/dist/service-adapters/google/google-genai-adapter.cjs +17 -0
  44. package/dist/service-adapters/google/google-genai-adapter.cjs.map +1 -1
  45. package/dist/service-adapters/google/google-genai-adapter.d.cts +10 -0
  46. package/dist/service-adapters/google/google-genai-adapter.d.cts.map +1 -1
  47. package/dist/service-adapters/google/google-genai-adapter.d.mts +10 -0
  48. package/dist/service-adapters/google/google-genai-adapter.d.mts.map +1 -1
  49. package/dist/service-adapters/google/google-genai-adapter.mjs +16 -0
  50. package/dist/service-adapters/google/google-genai-adapter.mjs.map +1 -1
  51. package/dist/service-adapters/unify/unify-adapter.cjs +14 -2
  52. package/dist/service-adapters/unify/unify-adapter.cjs.map +1 -1
  53. package/dist/service-adapters/unify/unify-adapter.d.cts +9 -1
  54. package/dist/service-adapters/unify/unify-adapter.d.cts.map +1 -1
  55. package/dist/service-adapters/unify/unify-adapter.d.mts +9 -1
  56. package/dist/service-adapters/unify/unify-adapter.d.mts.map +1 -1
  57. package/dist/service-adapters/unify/unify-adapter.mjs +14 -2
  58. package/dist/service-adapters/unify/unify-adapter.mjs.map +1 -1
  59. package/dist/v2/index.cjs +1 -0
  60. package/dist/v2/index.d.cts +2 -2
  61. package/dist/v2/index.d.mts +2 -2
  62. package/dist/v2/index.mjs +2 -2
  63. package/dist/v2/runtime/core/channel-manager.d.mts +1 -0
  64. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  65. package/dist/v2/runtime/core/debug-event-bus.cjs +22 -0
  66. package/dist/v2/runtime/core/debug-event-bus.cjs.map +1 -1
  67. package/dist/v2/runtime/core/debug-event-bus.d.cts +1 -1
  68. package/dist/v2/runtime/core/debug-event-bus.d.mts +1 -1
  69. package/dist/v2/runtime/core/debug-event-bus.mjs +22 -1
  70. package/dist/v2/runtime/core/debug-event-bus.mjs.map +1 -1
  71. package/dist/v2/runtime/core/runtime.cjs +5 -5
  72. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  73. package/dist/v2/runtime/core/runtime.d.cts +11 -0
  74. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  75. package/dist/v2/runtime/core/runtime.d.mts +11 -0
  76. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  77. package/dist/v2/runtime/core/runtime.mjs +6 -6
  78. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  79. package/dist/v2/runtime/handlers/handle-connect.cjs +3 -2
  80. package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
  81. package/dist/v2/runtime/handlers/handle-connect.mjs +3 -2
  82. package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
  83. package/dist/v2/runtime/handlers/handle-debug-events.cjs +2 -1
  84. package/dist/v2/runtime/handlers/handle-debug-events.cjs.map +1 -1
  85. package/dist/v2/runtime/handlers/handle-debug-events.mjs +3 -1
  86. package/dist/v2/runtime/handlers/handle-debug-events.mjs.map +1 -1
  87. package/dist/v2/runtime/handlers/handle-run.cjs +5 -3
  88. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  89. package/dist/v2/runtime/handlers/handle-run.mjs +5 -3
  90. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  91. package/dist/v2/runtime/handlers/shared/cloud-telemetry.cjs +31 -0
  92. package/dist/v2/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  93. package/dist/v2/runtime/handlers/shared/cloud-telemetry.mjs +30 -0
  94. package/dist/v2/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  95. package/dist/v2/runtime/handlers/shared/sse-response.cjs +31 -3
  96. package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
  97. package/dist/v2/runtime/handlers/shared/sse-response.mjs +31 -3
  98. package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
  99. package/dist/v2/runtime/handlers/sse/run.cjs +1 -0
  100. package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
  101. package/dist/v2/runtime/handlers/sse/run.mjs +1 -0
  102. package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
  103. package/dist/v2/runtime/telemetry/events.d.cts +12 -0
  104. package/dist/v2/runtime/telemetry/events.d.cts.map +1 -1
  105. package/dist/v2/runtime/telemetry/events.d.mts +12 -0
  106. package/dist/v2/runtime/telemetry/events.d.mts.map +1 -1
  107. package/dist/v2/runtime/telemetry/telemetry-client.cjs +3 -2
  108. package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
  109. package/dist/v2/runtime/telemetry/telemetry-client.d.cts.map +1 -1
  110. package/dist/v2/runtime/telemetry/telemetry-client.d.mts.map +1 -1
  111. package/dist/v2/runtime/telemetry/telemetry-client.mjs +7 -6
  112. package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
  113. package/package.json +5 -5
@@ -1,15 +1,18 @@
1
1
  require("reflect-metadata");
2
2
  const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
+ let _ai_sdk_openai = require("@ai-sdk/openai");
3
4
  let _copilotkit_shared = require("@copilotkit/shared");
4
5
 
5
6
  //#region src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts
6
7
  const DEFAULT_MODEL = "llama3:latest";
8
+ const DEFAULT_BASE_URL = "http://127.0.0.1:11434";
7
9
  var ExperimentalOllamaAdapter = class {
8
10
  get name() {
9
11
  return "OllamaAdapter";
10
12
  }
11
13
  constructor(options) {
12
14
  this.provider = "ollama";
15
+ this.baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
13
16
  if (options?.model) this.model = options.model;
14
17
  else this.model = DEFAULT_MODEL;
15
18
  }
@@ -31,6 +34,19 @@ var ExperimentalOllamaAdapter = class {
31
34
  });
32
35
  return { threadId: request.threadId || (0, _copilotkit_shared.randomUUID)() };
33
36
  }
37
+ /**
38
+ * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built
39
+ * from the OpenAI provider pointed at the Ollama server. Without it the
40
+ * runtime rebuilds a bare "ollama/<model>" string and fails with
41
+ * `Unknown provider "ollama"`. Ollama ignores the key; a non-empty value is
42
+ * required only because the OpenAI client insists on one.
43
+ */
44
+ getLanguageModel() {
45
+ return (0, _ai_sdk_openai.createOpenAI)({
46
+ baseURL: `${this.baseUrl.replace(/\/$/, "")}/v1`,
47
+ apiKey: "ollama"
48
+ })(this.model);
49
+ }
34
50
  };
35
51
 
36
52
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ollama-adapter.cjs","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.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 — ExperimentalOllamaAdapter:\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\n/**\n * CopilotKit Adapter for Ollama\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OllamaAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new OllamaAdapter({ model: \"llama3-70b-8192\" }),\n * );\n * ```\n */\nimport type { TextMessage } from \"../../../graphql/types/converted\";\nimport type {\n CopilotServiceAdapter,\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n} from \"../../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\n\nconst DEFAULT_MODEL = \"llama3:latest\";\n\ninterface OllamaAdapterOptions {\n model?: string;\n}\n\nexport class ExperimentalOllamaAdapter implements CopilotServiceAdapter {\n public model: string;\n public provider = \"ollama\";\n public get name() {\n return \"OllamaAdapter\";\n }\n\n constructor(options?: OllamaAdapterOptions) {\n if (options?.model) {\n this.model = options.model;\n } else {\n this.model = DEFAULT_MODEL;\n }\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const { messages, actions, eventSource } = request;\n // const messages = this.transformMessages(forwardedProps.messages);\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { Ollama } = require(\"@langchain/community/llms/ollama\");\n const ollama = new Ollama({\n model: this.model,\n });\n const contents = (\n messages.filter((m) => m.isTextMessage()) as TextMessage[]\n ).map((m) => m.content);\n const _stream = await ollama.stream(contents); // [TODO] role info is dropped...\n\n eventSource.stream(async (eventStream$) => {\n const currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n for await (const chunkText of _stream) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: chunkText,\n });\n }\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n // we may need to add this later.. [nc]\n // let calls = (await result.response).functionCalls();\n\n eventStream$.complete();\n });\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n}\n"],"mappings":";;;;;AA8CA,MAAM,gBAAgB;AAMtB,IAAa,4BAAb,MAAwE;CAGtE,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAAgC;kBAL1B;AAMhB,MAAI,SAAS,MACX,MAAK,QAAQ,QAAQ;MAErB,MAAK,QAAQ;;CAIjB,MAAM,QACJ,SAC+C;EAC/C,MAAM,EAAE,UAAU,SAAS,gBAAgB;EAI3C,MAAM,EAAE,WAAW,QAAQ,mCAAmC;EAC9D,MAAM,SAAS,IAAI,OAAO,EACxB,OAAO,KAAK,OACb,CAAC;EACF,MAAM,WACJ,SAAS,QAAQ,MAAM,EAAE,eAAe,CAAC,CACzC,KAAK,MAAM,EAAE,QAAQ;EACvB,MAAM,UAAU,MAAM,OAAO,OAAO,SAAS;AAE7C,cAAY,OAAO,OAAO,iBAAiB;GACzC,MAAM,qDAA6B;AACnC,gBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,cAAW,MAAM,aAAa,QAC5B,cAAa,uBAAuB;IAClC,WAAW;IACX,SAAS;IACV,CAAC;AAEJ,gBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAIhE,gBAAa,UAAU;IACvB;AACF,SAAO,EACL,UAAU,QAAQ,gDAAwB,EAC3C"}
1
+ {"version":3,"file":"ollama-adapter.cjs","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.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 — ExperimentalOllamaAdapter:\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\n/**\n * CopilotKit Adapter for Ollama\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OllamaAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new OllamaAdapter({ model: \"llama3-70b-8192\" }),\n * );\n * ```\n */\nimport type { TextMessage } from \"../../../graphql/types/converted\";\nimport type {\n CopilotServiceAdapter,\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n} from \"../../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\nimport { createOpenAI } from \"@ai-sdk/openai\";\nimport type { LanguageModel } from \"ai\";\n\nconst DEFAULT_MODEL = \"llama3:latest\";\n\nconst DEFAULT_BASE_URL = \"http://127.0.0.1:11434\";\n\ninterface OllamaAdapterOptions {\n model?: string;\n /**\n * Base URL of the Ollama server. Defaults to `http://127.0.0.1:11434`.\n */\n baseUrl?: string;\n}\n\nexport class ExperimentalOllamaAdapter implements CopilotServiceAdapter {\n public model: string;\n public provider = \"ollama\";\n private baseUrl: string;\n public get name() {\n return \"OllamaAdapter\";\n }\n\n constructor(options?: OllamaAdapterOptions) {\n this.baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;\n if (options?.model) {\n this.model = options.model;\n } else {\n this.model = DEFAULT_MODEL;\n }\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const { messages, actions, eventSource } = request;\n // const messages = this.transformMessages(forwardedProps.messages);\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { Ollama } = require(\"@langchain/community/llms/ollama\");\n const ollama = new Ollama({\n model: this.model,\n });\n const contents = (\n messages.filter((m) => m.isTextMessage()) as TextMessage[]\n ).map((m) => m.content);\n const _stream = await ollama.stream(contents); // [TODO] role info is dropped...\n\n eventSource.stream(async (eventStream$) => {\n const currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n for await (const chunkText of _stream) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: chunkText,\n });\n }\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n // we may need to add this later.. [nc]\n // let calls = (await result.response).functionCalls();\n\n eventStream$.complete();\n });\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n\n /**\n * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built\n * from the OpenAI provider pointed at the Ollama server. Without it the\n * runtime rebuilds a bare \"ollama/<model>\" string and fails with\n * `Unknown provider \"ollama\"`. Ollama ignores the key; a non-empty value is\n * required only because the OpenAI client insists on one.\n */\n getLanguageModel(): LanguageModel {\n const provider = createOpenAI({\n baseURL: `${this.baseUrl.replace(/\\/$/, \"\")}/v1`,\n apiKey: \"ollama\",\n });\n return provider(this.model);\n }\n}\n"],"mappings":";;;;;;AAgDA,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB;AAUzB,IAAa,4BAAb,MAAwE;CAItE,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAAgC;kBAN1B;AAOhB,OAAK,UAAU,SAAS,WAAW;AACnC,MAAI,SAAS,MACX,MAAK,QAAQ,QAAQ;MAErB,MAAK,QAAQ;;CAIjB,MAAM,QACJ,SAC+C;EAC/C,MAAM,EAAE,UAAU,SAAS,gBAAgB;EAI3C,MAAM,EAAE,WAAW,QAAQ,mCAAmC;EAC9D,MAAM,SAAS,IAAI,OAAO,EACxB,OAAO,KAAK,OACb,CAAC;EACF,MAAM,WACJ,SAAS,QAAQ,MAAM,EAAE,eAAe,CAAC,CACzC,KAAK,MAAM,EAAE,QAAQ;EACvB,MAAM,UAAU,MAAM,OAAO,OAAO,SAAS;AAE7C,cAAY,OAAO,OAAO,iBAAiB;GACzC,MAAM,qDAA6B;AACnC,gBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,cAAW,MAAM,aAAa,QAC5B,cAAa,uBAAuB;IAClC,WAAW;IACX,SAAS;IACV,CAAC;AAEJ,gBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAIhE,gBAAa,UAAU;IACvB;AACF,SAAO,EACL,UAAU,QAAQ,gDAAwB,EAC3C;;;;;;;;;CAUH,mBAAkC;AAKhC,0CAJ8B;GAC5B,SAAS,GAAG,KAAK,QAAQ,QAAQ,OAAO,GAAG,CAAC;GAC5C,QAAQ;GACT,CAAC,CACc,KAAK,MAAM"}
@@ -1,16 +1,30 @@
1
1
 
2
2
  import { CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotServiceAdapter } from "../../service-adapter.cjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.d.ts
5
6
  interface OllamaAdapterOptions {
6
7
  model?: string;
8
+ /**
9
+ * Base URL of the Ollama server. Defaults to `http://127.0.0.1:11434`.
10
+ */
11
+ baseUrl?: string;
7
12
  }
8
13
  declare class ExperimentalOllamaAdapter implements CopilotServiceAdapter {
9
14
  model: string;
10
15
  provider: string;
16
+ private baseUrl;
11
17
  get name(): string;
12
18
  constructor(options?: OllamaAdapterOptions);
13
19
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
20
+ /**
21
+ * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built
22
+ * from the OpenAI provider pointed at the Ollama server. Without it the
23
+ * runtime rebuilds a bare "ollama/<model>" string and fails with
24
+ * `Unknown provider "ollama"`. Ollama ignores the key; a non-empty value is
25
+ * required only because the OpenAI client insists on one.
26
+ */
27
+ getLanguageModel(): LanguageModel;
14
28
  }
15
29
  //#endregion
16
30
  export { ExperimentalOllamaAdapter };
@@ -1 +1 @@
1
- {"version":3,"file":"ollama-adapter.d.cts","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts"],"mappings":";;;;UAgDU,oBAAA;EACR,KAAA;AAAA;AAAA,cAGW,yBAAA,YAAqC,qBAAA;EACzC,KAAA;EACA,QAAA;EAAA,IACI,IAAA,CAAA;cAIC,OAAA,GAAU,oBAAA;EAQhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;AAAA"}
1
+ {"version":3,"file":"ollama-adapter.d.cts","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts"],"mappings":";;;;;UAoDU,oBAAA;EACR,KAAA;EADQ;;;EAKR,OAAA;AAAA;AAAA,cAGW,yBAAA,YAAqC,qBAAA;EACzC,KAAA;EACA,QAAA;EAAA,QACC,OAAA;EAAA,IACG,IAAA,CAAA;cAIC,OAAA,GAAU,oBAAA;EAShB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;EAyCS;;;;;;;EAApB,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,16 +1,30 @@
1
1
 
2
2
  import { CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotServiceAdapter } from "../../service-adapter.mjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.d.ts
5
6
  interface OllamaAdapterOptions {
6
7
  model?: string;
8
+ /**
9
+ * Base URL of the Ollama server. Defaults to `http://127.0.0.1:11434`.
10
+ */
11
+ baseUrl?: string;
7
12
  }
8
13
  declare class ExperimentalOllamaAdapter implements CopilotServiceAdapter {
9
14
  model: string;
10
15
  provider: string;
16
+ private baseUrl;
11
17
  get name(): string;
12
18
  constructor(options?: OllamaAdapterOptions);
13
19
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
20
+ /**
21
+ * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built
22
+ * from the OpenAI provider pointed at the Ollama server. Without it the
23
+ * runtime rebuilds a bare "ollama/<model>" string and fails with
24
+ * `Unknown provider "ollama"`. Ollama ignores the key; a non-empty value is
25
+ * required only because the OpenAI client insists on one.
26
+ */
27
+ getLanguageModel(): LanguageModel;
14
28
  }
15
29
  //#endregion
16
30
  export { ExperimentalOllamaAdapter };
@@ -1 +1 @@
1
- {"version":3,"file":"ollama-adapter.d.mts","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts"],"mappings":";;;;UAgDU,oBAAA;EACR,KAAA;AAAA;AAAA,cAGW,yBAAA,YAAqC,qBAAA;EACzC,KAAA;EACA,QAAA;EAAA,IACI,IAAA,CAAA;cAIC,OAAA,GAAU,oBAAA;EAQhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;AAAA"}
1
+ {"version":3,"file":"ollama-adapter.d.mts","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts"],"mappings":";;;;;UAoDU,oBAAA;EACR,KAAA;EADQ;;;EAKR,OAAA;AAAA;AAAA,cAGW,yBAAA,YAAqC,qBAAA;EACzC,KAAA;EACA,QAAA;EAAA,QACC,OAAA;EAAA,IACG,IAAA,CAAA;cAIC,OAAA,GAAU,oBAAA;EAShB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;EAyCS;;;;;;;EAApB,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,15 +1,18 @@
1
1
  import "reflect-metadata";
2
2
  import { __require } from "../../../_virtual/_rolldown/runtime.mjs";
3
+ import { createOpenAI } from "@ai-sdk/openai";
3
4
  import { randomId, randomUUID } from "@copilotkit/shared";
4
5
 
5
6
  //#region src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.ts
6
7
  const DEFAULT_MODEL = "llama3:latest";
8
+ const DEFAULT_BASE_URL = "http://127.0.0.1:11434";
7
9
  var ExperimentalOllamaAdapter = class {
8
10
  get name() {
9
11
  return "OllamaAdapter";
10
12
  }
11
13
  constructor(options) {
12
14
  this.provider = "ollama";
15
+ this.baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;
13
16
  if (options?.model) this.model = options.model;
14
17
  else this.model = DEFAULT_MODEL;
15
18
  }
@@ -31,6 +34,19 @@ var ExperimentalOllamaAdapter = class {
31
34
  });
32
35
  return { threadId: request.threadId || randomUUID() };
33
36
  }
37
+ /**
38
+ * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built
39
+ * from the OpenAI provider pointed at the Ollama server. Without it the
40
+ * runtime rebuilds a bare "ollama/<model>" string and fails with
41
+ * `Unknown provider "ollama"`. Ollama ignores the key; a non-empty value is
42
+ * required only because the OpenAI client insists on one.
43
+ */
44
+ getLanguageModel() {
45
+ return createOpenAI({
46
+ baseURL: `${this.baseUrl.replace(/\/$/, "")}/v1`,
47
+ apiKey: "ollama"
48
+ })(this.model);
49
+ }
34
50
  };
35
51
 
36
52
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ollama-adapter.mjs","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.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 — ExperimentalOllamaAdapter:\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\n/**\n * CopilotKit Adapter for Ollama\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OllamaAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new OllamaAdapter({ model: \"llama3-70b-8192\" }),\n * );\n * ```\n */\nimport type { TextMessage } from \"../../../graphql/types/converted\";\nimport type {\n CopilotServiceAdapter,\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n} from \"../../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\n\nconst DEFAULT_MODEL = \"llama3:latest\";\n\ninterface OllamaAdapterOptions {\n model?: string;\n}\n\nexport class ExperimentalOllamaAdapter implements CopilotServiceAdapter {\n public model: string;\n public provider = \"ollama\";\n public get name() {\n return \"OllamaAdapter\";\n }\n\n constructor(options?: OllamaAdapterOptions) {\n if (options?.model) {\n this.model = options.model;\n } else {\n this.model = DEFAULT_MODEL;\n }\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const { messages, actions, eventSource } = request;\n // const messages = this.transformMessages(forwardedProps.messages);\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { Ollama } = require(\"@langchain/community/llms/ollama\");\n const ollama = new Ollama({\n model: this.model,\n });\n const contents = (\n messages.filter((m) => m.isTextMessage()) as TextMessage[]\n ).map((m) => m.content);\n const _stream = await ollama.stream(contents); // [TODO] role info is dropped...\n\n eventSource.stream(async (eventStream$) => {\n const currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n for await (const chunkText of _stream) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: chunkText,\n });\n }\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n // we may need to add this later.. [nc]\n // let calls = (await result.response).functionCalls();\n\n eventStream$.complete();\n });\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n}\n"],"mappings":";;;;;AA8CA,MAAM,gBAAgB;AAMtB,IAAa,4BAAb,MAAwE;CAGtE,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAAgC;kBAL1B;AAMhB,MAAI,SAAS,MACX,MAAK,QAAQ,QAAQ;MAErB,MAAK,QAAQ;;CAIjB,MAAM,QACJ,SAC+C;EAC/C,MAAM,EAAE,UAAU,SAAS,gBAAgB;EAI3C,MAAM,EAAE,qBAAmB,mCAAmC;EAC9D,MAAM,SAAS,IAAI,OAAO,EACxB,OAAO,KAAK,OACb,CAAC;EACF,MAAM,WACJ,SAAS,QAAQ,MAAM,EAAE,eAAe,CAAC,CACzC,KAAK,MAAM,EAAE,QAAQ;EACvB,MAAM,UAAU,MAAM,OAAO,OAAO,SAAS;AAE7C,cAAY,OAAO,OAAO,iBAAiB;GACzC,MAAM,mBAAmB,UAAU;AACnC,gBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,cAAW,MAAM,aAAa,QAC5B,cAAa,uBAAuB;IAClC,WAAW;IACX,SAAS;IACV,CAAC;AAEJ,gBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAIhE,gBAAa,UAAU;IACvB;AACF,SAAO,EACL,UAAU,QAAQ,YAAY,YAAY,EAC3C"}
1
+ {"version":3,"file":"ollama-adapter.mjs","names":[],"sources":["../../../../../src/v1-deprecated/service-adapters/experimental/ollama/ollama-adapter.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 — ExperimentalOllamaAdapter:\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\n/**\n * CopilotKit Adapter for Ollama\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OllamaAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new OllamaAdapter({ model: \"llama3-70b-8192\" }),\n * );\n * ```\n */\nimport type { TextMessage } from \"../../../graphql/types/converted\";\nimport type {\n CopilotServiceAdapter,\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n} from \"../../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\nimport { createOpenAI } from \"@ai-sdk/openai\";\nimport type { LanguageModel } from \"ai\";\n\nconst DEFAULT_MODEL = \"llama3:latest\";\n\nconst DEFAULT_BASE_URL = \"http://127.0.0.1:11434\";\n\ninterface OllamaAdapterOptions {\n model?: string;\n /**\n * Base URL of the Ollama server. Defaults to `http://127.0.0.1:11434`.\n */\n baseUrl?: string;\n}\n\nexport class ExperimentalOllamaAdapter implements CopilotServiceAdapter {\n public model: string;\n public provider = \"ollama\";\n private baseUrl: string;\n public get name() {\n return \"OllamaAdapter\";\n }\n\n constructor(options?: OllamaAdapterOptions) {\n this.baseUrl = options?.baseUrl ?? DEFAULT_BASE_URL;\n if (options?.model) {\n this.model = options.model;\n } else {\n this.model = DEFAULT_MODEL;\n }\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const { messages, actions, eventSource } = request;\n // const messages = this.transformMessages(forwardedProps.messages);\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { Ollama } = require(\"@langchain/community/llms/ollama\");\n const ollama = new Ollama({\n model: this.model,\n });\n const contents = (\n messages.filter((m) => m.isTextMessage()) as TextMessage[]\n ).map((m) => m.content);\n const _stream = await ollama.stream(contents); // [TODO] role info is dropped...\n\n eventSource.stream(async (eventStream$) => {\n const currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n for await (const chunkText of _stream) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: chunkText,\n });\n }\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n // we may need to add this later.. [nc]\n // let calls = (await result.response).functionCalls();\n\n eventStream$.complete();\n });\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n\n /**\n * Ollama exposes an OpenAI-compatible API at `/v1`, so the model is built\n * from the OpenAI provider pointed at the Ollama server. Without it the\n * runtime rebuilds a bare \"ollama/<model>\" string and fails with\n * `Unknown provider \"ollama\"`. Ollama ignores the key; a non-empty value is\n * required only because the OpenAI client insists on one.\n */\n getLanguageModel(): LanguageModel {\n const provider = createOpenAI({\n baseURL: `${this.baseUrl.replace(/\\/$/, \"\")}/v1`,\n apiKey: \"ollama\",\n });\n return provider(this.model);\n }\n}\n"],"mappings":";;;;;;AAgDA,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB;AAUzB,IAAa,4BAAb,MAAwE;CAItE,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAAgC;kBAN1B;AAOhB,OAAK,UAAU,SAAS,WAAW;AACnC,MAAI,SAAS,MACX,MAAK,QAAQ,QAAQ;MAErB,MAAK,QAAQ;;CAIjB,MAAM,QACJ,SAC+C;EAC/C,MAAM,EAAE,UAAU,SAAS,gBAAgB;EAI3C,MAAM,EAAE,qBAAmB,mCAAmC;EAC9D,MAAM,SAAS,IAAI,OAAO,EACxB,OAAO,KAAK,OACb,CAAC;EACF,MAAM,WACJ,SAAS,QAAQ,MAAM,EAAE,eAAe,CAAC,CACzC,KAAK,MAAM,EAAE,QAAQ;EACvB,MAAM,UAAU,MAAM,OAAO,OAAO,SAAS;AAE7C,cAAY,OAAO,OAAO,iBAAiB;GACzC,MAAM,mBAAmB,UAAU;AACnC,gBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,cAAW,MAAM,aAAa,QAC5B,cAAa,uBAAuB;IAClC,WAAW;IACX,SAAS;IACV,CAAC;AAEJ,gBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAIhE,gBAAa,UAAU;IACvB;AACF,SAAO,EACL,UAAU,QAAQ,YAAY,YAAY,EAC3C;;;;;;;;;CAUH,mBAAkC;AAKhC,SAJiB,aAAa;GAC5B,SAAS,GAAG,KAAK,QAAQ,QAAQ,OAAO,GAAG,CAAC;GAC5C,QAAQ;GACT,CAAC,CACc,KAAK,MAAM"}
@@ -1,5 +1,7 @@
1
1
  require("reflect-metadata");
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
3
  const require_langchain_adapter = require('../langchain/langchain-adapter.cjs');
4
+ let _ai_sdk_google = require("@ai-sdk/google");
3
5
 
4
6
  //#region src/v1-deprecated/service-adapters/google/google-genai-adapter.ts
5
7
  /**
@@ -44,6 +46,21 @@ var GoogleGenerativeAIAdapter = class extends require_langchain_adapter.LangChai
44
46
  } });
45
47
  this.provider = "google";
46
48
  this.model = DEFAULT_MODEL;
49
+ this._apiKey = options?.apiKey;
50
+ this._apiVersion = options?.apiVersion;
51
+ this.model = options?.model ?? DEFAULT_MODEL;
52
+ }
53
+ /**
54
+ * Hands `BuiltInAgent` a model built from this adapter's own credentials.
55
+ * Without it the runtime rebuilds a bare "google/<model>" string and the
56
+ * provider falls back to environment variables, dropping the `apiKey`
57
+ * passed to this constructor.
58
+ */
59
+ getLanguageModel() {
60
+ return (0, _ai_sdk_google.createGoogleGenerativeAI)({
61
+ apiKey: this._apiKey ?? process.env.GOOGLE_API_KEY,
62
+ ...this._apiVersion && { baseURL: `https://generativelanguage.googleapis.com/${this._apiVersion}` }
63
+ })(this.model);
47
64
  }
48
65
  };
49
66
 
@@ -1 +1 @@
1
- {"version":3,"file":"google-genai-adapter.cjs","names":["LangChainAdapter"],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.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 — GoogleGenerativeAIAdapter:\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\n/**\n * Copilot Runtime adapter for Google Generative AI (e.g. Gemini).\n *\n * ## Example\n *\n * ```ts\n * import { CopilotRuntime, GoogleGenerativeAIAdapter } from \"@copilotkit/runtime\";\n * const { GoogleGenerativeAI } = require(\"@google/generative-ai\");\n *\n * const genAI = new GoogleGenerativeAI(process.env[\"GOOGLE_API_KEY\"]);\n *\n * const copilotKit = new CopilotRuntime();\n *\n * return new GoogleGenerativeAIAdapter({ model: \"gemini-2.5-flash\", apiVersion: \"v1\" });\n * ```\n */\nimport { LangChainAdapter } from \"../langchain/langchain-adapter\";\n\ninterface GoogleGenerativeAIAdapterOptions {\n /**\n * A custom Google Generative AI model to use.\n */\n model?: string;\n /**\n * The API version to use (e.g. \"v1\" or \"v1beta\"). Defaults to \"v1\".\n */\n apiVersion?: \"v1\" | \"v1beta\";\n /**\n * The API key to use.\n */\n apiKey?: string;\n}\n\nconst DEFAULT_MODEL = \"gemini-2.5-flash\";\nconst DEFAULT_API_VERSION: GoogleGenerativeAIAdapterOptions[\"apiVersion\"] =\n \"v1\";\nlet hasWarnedDefaultGoogleModel = false;\n\nexport class GoogleGenerativeAIAdapter extends LangChainAdapter {\n public provider = \"google\";\n public model: string = DEFAULT_MODEL;\n\n constructor(options?: GoogleGenerativeAIAdapterOptions) {\n if (\n !hasWarnedDefaultGoogleModel &&\n !options?.model &&\n !options?.apiVersion\n ) {\n console.warn(\n `You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. ` +\n `CopilotKit will default to apiVersion=\"v1\" and model=\"${DEFAULT_MODEL}\". ` +\n `To silence this warning, pass model and apiVersion when constructing the adapter.`,\n );\n hasWarnedDefaultGoogleModel = true;\n }\n\n super({\n chainFn: async ({ messages, tools, threadId }) => {\n // Lazy require for optional peer dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { ChatGoogle } = require(\"@langchain/google-gauth\");\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { AIMessage } = require(\"@langchain/core/messages\");\n\n // Filter out empty assistant messages to prevent Gemini validation errors\n // Gemini specifically rejects conversations containing AIMessages with empty content\n const filteredMessages = messages.filter((message) => {\n // Keep all non-AI messages (HumanMessage, SystemMessage, ToolMessage, etc.)\n if (!(message instanceof AIMessage)) {\n return true;\n }\n\n // For AIMessages, only keep those with non-empty content\n // Also keep AIMessages with tool_calls even if content is empty\n const aiMsg = message as any;\n return (\n (aiMsg.content && String(aiMsg.content).trim().length > 0) ||\n (aiMsg.tool_calls && aiMsg.tool_calls.length > 0)\n );\n });\n\n this.model = options?.model ?? DEFAULT_MODEL;\n const model = new ChatGoogle({\n apiKey: options?.apiKey ?? process.env.GOOGLE_API_KEY,\n modelName: this.model,\n apiVersion: options?.apiVersion ?? DEFAULT_API_VERSION,\n }).bindTools(tools);\n\n return model.stream(filteredMessages, {\n metadata: { conversation_id: threadId },\n });\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,gBAAgB;AACtB,MAAM,sBACJ;AACF,IAAI,8BAA8B;AAElC,IAAa,4BAAb,cAA+CA,2CAAiB;CAI9D,YAAY,SAA4C;AACtD,MACE,CAAC,+BACD,CAAC,SAAS,SACV,CAAC,SAAS,YACV;AACA,WAAQ,KACN,uJAC2D,cAAc,sFAE1E;AACD,iCAA8B;;AAGhC,QAAM,EACJ,SAAS,OAAO,EAAE,UAAU,OAAO,eAAe;GAGhD,MAAM,EAAE,eAAe,QAAQ,0BAA0B;GAEzD,MAAM,EAAE,cAAc,QAAQ,2BAA2B;GAIzD,MAAM,mBAAmB,SAAS,QAAQ,YAAY;AAEpD,QAAI,EAAE,mBAAmB,WACvB,QAAO;IAKT,MAAM,QAAQ;AACd,WACG,MAAM,WAAW,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,KACvD,MAAM,cAAc,MAAM,WAAW,SAAS;KAEjD;AAEF,QAAK,QAAQ,SAAS,SAAS;AAO/B,UANc,IAAI,WAAW;IAC3B,QAAQ,SAAS,UAAU,QAAQ,IAAI;IACvC,WAAW,KAAK;IAChB,YAAY,SAAS,cAAc;IACpC,CAAC,CAAC,UAAU,MAAM,CAEN,OAAO,kBAAkB,EACpC,UAAU,EAAE,iBAAiB,UAAU,EACxC,CAAC;KAEL,CAAC;kBArDc;eACK"}
1
+ {"version":3,"file":"google-genai-adapter.cjs","names":["LangChainAdapter"],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.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 — GoogleGenerativeAIAdapter:\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\n/**\n * Copilot Runtime adapter for Google Generative AI (e.g. Gemini).\n *\n * ## Example\n *\n * ```ts\n * import { CopilotRuntime, GoogleGenerativeAIAdapter } from \"@copilotkit/runtime\";\n * const { GoogleGenerativeAI } = require(\"@google/generative-ai\");\n *\n * const genAI = new GoogleGenerativeAI(process.env[\"GOOGLE_API_KEY\"]);\n *\n * const copilotKit = new CopilotRuntime();\n *\n * return new GoogleGenerativeAIAdapter({ model: \"gemini-2.5-flash\", apiVersion: \"v1\" });\n * ```\n */\nimport { LangChainAdapter } from \"../langchain/langchain-adapter\";\nimport { createGoogleGenerativeAI } from \"@ai-sdk/google\";\nimport type { LanguageModel } from \"ai\";\n\ninterface GoogleGenerativeAIAdapterOptions {\n /**\n * A custom Google Generative AI model to use.\n */\n model?: string;\n /**\n * The API version to use (e.g. \"v1\" or \"v1beta\"). Defaults to \"v1\".\n */\n apiVersion?: \"v1\" | \"v1beta\";\n /**\n * The API key to use.\n */\n apiKey?: string;\n}\n\nconst DEFAULT_MODEL = \"gemini-2.5-flash\";\nconst DEFAULT_API_VERSION: GoogleGenerativeAIAdapterOptions[\"apiVersion\"] =\n \"v1\";\nlet hasWarnedDefaultGoogleModel = false;\n\nexport class GoogleGenerativeAIAdapter extends LangChainAdapter {\n public provider = \"google\";\n private _apiKey?: string;\n private _apiVersion?: GoogleGenerativeAIAdapterOptions[\"apiVersion\"];\n public model: string = DEFAULT_MODEL;\n\n constructor(options?: GoogleGenerativeAIAdapterOptions) {\n if (\n !hasWarnedDefaultGoogleModel &&\n !options?.model &&\n !options?.apiVersion\n ) {\n console.warn(\n `You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. ` +\n `CopilotKit will default to apiVersion=\"v1\" and model=\"${DEFAULT_MODEL}\". ` +\n `To silence this warning, pass model and apiVersion when constructing the adapter.`,\n );\n hasWarnedDefaultGoogleModel = true;\n }\n\n super({\n chainFn: async ({ messages, tools, threadId }) => {\n // Lazy require for optional peer dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { ChatGoogle } = require(\"@langchain/google-gauth\");\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { AIMessage } = require(\"@langchain/core/messages\");\n\n // Filter out empty assistant messages to prevent Gemini validation errors\n // Gemini specifically rejects conversations containing AIMessages with empty content\n const filteredMessages = messages.filter((message) => {\n // Keep all non-AI messages (HumanMessage, SystemMessage, ToolMessage, etc.)\n if (!(message instanceof AIMessage)) {\n return true;\n }\n\n // For AIMessages, only keep those with non-empty content\n // Also keep AIMessages with tool_calls even if content is empty\n const aiMsg = message as any;\n return (\n (aiMsg.content && String(aiMsg.content).trim().length > 0) ||\n (aiMsg.tool_calls && aiMsg.tool_calls.length > 0)\n );\n });\n\n this.model = options?.model ?? DEFAULT_MODEL;\n const model = new ChatGoogle({\n apiKey: options?.apiKey ?? process.env.GOOGLE_API_KEY,\n modelName: this.model,\n apiVersion: options?.apiVersion ?? DEFAULT_API_VERSION,\n }).bindTools(tools);\n\n return model.stream(filteredMessages, {\n metadata: { conversation_id: threadId },\n });\n },\n });\n\n // `this.model` is otherwise only assigned inside the chain closure, which\n // does not run until a request arrives — so `getLanguageModel()` would\n // report the default model instead of the configured one.\n this._apiKey = options?.apiKey;\n this._apiVersion = options?.apiVersion;\n this.model = options?.model ?? DEFAULT_MODEL;\n }\n\n /**\n * Hands `BuiltInAgent` a model built from this adapter's own credentials.\n * Without it the runtime rebuilds a bare \"google/<model>\" string and the\n * provider falls back to environment variables, dropping the `apiKey`\n * passed to this constructor.\n */\n getLanguageModel(): LanguageModel {\n // `createGoogleGenerativeAI` has no `apiVersion` option, so the version is\n // carried on the base URL. Only when the caller asked for one: the\n // provider's own default is v1beta, and that has been the live default\n // ever since this method started routing around `process()`. Forcing the\n // adapter's documented \"v1\" here would strand models v1 does not serve.\n const provider = createGoogleGenerativeAI({\n apiKey: this._apiKey ?? process.env.GOOGLE_API_KEY,\n ...(this._apiVersion && {\n baseURL: `https://generativelanguage.googleapis.com/${this._apiVersion}`,\n }),\n });\n return provider(this.model);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,gBAAgB;AACtB,MAAM,sBACJ;AACF,IAAI,8BAA8B;AAElC,IAAa,4BAAb,cAA+CA,2CAAiB;CAM9D,YAAY,SAA4C;AACtD,MACE,CAAC,+BACD,CAAC,SAAS,SACV,CAAC,SAAS,YACV;AACA,WAAQ,KACN,uJAC2D,cAAc,sFAE1E;AACD,iCAA8B;;AAGhC,QAAM,EACJ,SAAS,OAAO,EAAE,UAAU,OAAO,eAAe;GAGhD,MAAM,EAAE,eAAe,QAAQ,0BAA0B;GAEzD,MAAM,EAAE,cAAc,QAAQ,2BAA2B;GAIzD,MAAM,mBAAmB,SAAS,QAAQ,YAAY;AAEpD,QAAI,EAAE,mBAAmB,WACvB,QAAO;IAKT,MAAM,QAAQ;AACd,WACG,MAAM,WAAW,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,KACvD,MAAM,cAAc,MAAM,WAAW,SAAS;KAEjD;AAEF,QAAK,QAAQ,SAAS,SAAS;AAO/B,UANc,IAAI,WAAW;IAC3B,QAAQ,SAAS,UAAU,QAAQ,IAAI;IACvC,WAAW,KAAK;IAChB,YAAY,SAAS,cAAc;IACpC,CAAC,CAAC,UAAU,MAAM,CAEN,OAAO,kBAAkB,EACpC,UAAU,EAAE,iBAAiB,UAAU,EACxC,CAAC;KAEL,CAAC;kBAvDc;eAGK;AAyDrB,OAAK,UAAU,SAAS;AACxB,OAAK,cAAc,SAAS;AAC5B,OAAK,QAAQ,SAAS,SAAS;;;;;;;;CASjC,mBAAkC;AAYhC,sDAN0C;GACxC,QAAQ,KAAK,WAAW,QAAQ,IAAI;GACpC,GAAI,KAAK,eAAe,EACtB,SAAS,6CAA6C,KAAK,eAC5D;GACF,CAAC,CACc,KAAK,MAAM"}
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { LangChainAdapter } from "../langchain/langchain-adapter.cjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/google/google-genai-adapter.d.ts
5
6
  interface GoogleGenerativeAIAdapterOptions {
@@ -18,8 +19,17 @@ interface GoogleGenerativeAIAdapterOptions {
18
19
  }
19
20
  declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
20
21
  provider: string;
22
+ private _apiKey?;
23
+ private _apiVersion?;
21
24
  model: string;
22
25
  constructor(options?: GoogleGenerativeAIAdapterOptions);
26
+ /**
27
+ * Hands `BuiltInAgent` a model built from this adapter's own credentials.
28
+ * Without it the runtime rebuilds a bare "google/<model>" string and the
29
+ * provider falls back to environment variables, dropping the `apiKey`
30
+ * passed to this constructor.
31
+ */
32
+ getLanguageModel(): LanguageModel;
23
33
  }
24
34
  //#endregion
25
35
  export { GoogleGenerativeAIAdapter };
@@ -1 +1 @@
1
- {"version":3,"file":"google-genai-adapter.d.cts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.ts"],"mappings":";;;;UAqCU,gCAAA;EAsBD;;;EAlBP,KAAA;EAoBsD;;;EAhBtD,UAAA;;;;EAIA,MAAA;AAAA;AAAA,cAQW,yBAAA,SAAkC,gBAAA;EACtC,QAAA;EACA,KAAA;cAEK,OAAA,GAAU,gCAAA;AAAA"}
1
+ {"version":3,"file":"google-genai-adapter.d.cts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.ts"],"mappings":";;;;;UAuCU,gCAAA;EAoBqD;;;EAhB7D,KAAA;EAkBQ;;;EAdR,UAAA;EAkBsB;;;EAdtB,MAAA;AAAA;AAAA,cAQW,yBAAA,SAAkC,gBAAA;EACtC,QAAA;EAAA,QACC,OAAA;EAAA,QACA,WAAA;EACD,KAAA;cAEK,OAAA,GAAU,gCAAA;;;;;;;EAkEtB,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { LangChainAdapter } from "../langchain/langchain-adapter.mjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/google/google-genai-adapter.d.ts
5
6
  interface GoogleGenerativeAIAdapterOptions {
@@ -18,8 +19,17 @@ interface GoogleGenerativeAIAdapterOptions {
18
19
  }
19
20
  declare class GoogleGenerativeAIAdapter extends LangChainAdapter {
20
21
  provider: string;
22
+ private _apiKey?;
23
+ private _apiVersion?;
21
24
  model: string;
22
25
  constructor(options?: GoogleGenerativeAIAdapterOptions);
26
+ /**
27
+ * Hands `BuiltInAgent` a model built from this adapter's own credentials.
28
+ * Without it the runtime rebuilds a bare "google/<model>" string and the
29
+ * provider falls back to environment variables, dropping the `apiKey`
30
+ * passed to this constructor.
31
+ */
32
+ getLanguageModel(): LanguageModel;
23
33
  }
24
34
  //#endregion
25
35
  export { GoogleGenerativeAIAdapter };
@@ -1 +1 @@
1
- {"version":3,"file":"google-genai-adapter.d.mts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.ts"],"mappings":";;;;UAqCU,gCAAA;EAsBD;;;EAlBP,KAAA;EAoBsD;;;EAhBtD,UAAA;;;;EAIA,MAAA;AAAA;AAAA,cAQW,yBAAA,SAAkC,gBAAA;EACtC,QAAA;EACA,KAAA;cAEK,OAAA,GAAU,gCAAA;AAAA"}
1
+ {"version":3,"file":"google-genai-adapter.d.mts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.ts"],"mappings":";;;;;UAuCU,gCAAA;EAoBqD;;;EAhB7D,KAAA;EAkBQ;;;EAdR,UAAA;EAkBsB;;;EAdtB,MAAA;AAAA;AAAA,cAQW,yBAAA,SAAkC,gBAAA;EACtC,QAAA;EAAA,QACC,OAAA;EAAA,QACA,WAAA;EACD,KAAA;cAEK,OAAA,GAAU,gCAAA;;;;;;;EAkEtB,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,6 +1,7 @@
1
1
  import "reflect-metadata";
2
2
  import { __require } from "../../_virtual/_rolldown/runtime.mjs";
3
3
  import { LangChainAdapter } from "../langchain/langchain-adapter.mjs";
4
+ import { createGoogleGenerativeAI } from "@ai-sdk/google";
4
5
 
5
6
  //#region src/v1-deprecated/service-adapters/google/google-genai-adapter.ts
6
7
  /**
@@ -45,6 +46,21 @@ var GoogleGenerativeAIAdapter = class extends LangChainAdapter {
45
46
  } });
46
47
  this.provider = "google";
47
48
  this.model = DEFAULT_MODEL;
49
+ this._apiKey = options?.apiKey;
50
+ this._apiVersion = options?.apiVersion;
51
+ this.model = options?.model ?? DEFAULT_MODEL;
52
+ }
53
+ /**
54
+ * Hands `BuiltInAgent` a model built from this adapter's own credentials.
55
+ * Without it the runtime rebuilds a bare "google/<model>" string and the
56
+ * provider falls back to environment variables, dropping the `apiKey`
57
+ * passed to this constructor.
58
+ */
59
+ getLanguageModel() {
60
+ return createGoogleGenerativeAI({
61
+ apiKey: this._apiKey ?? process.env.GOOGLE_API_KEY,
62
+ ...this._apiVersion && { baseURL: `https://generativelanguage.googleapis.com/${this._apiVersion}` }
63
+ })(this.model);
48
64
  }
49
65
  };
50
66
 
@@ -1 +1 @@
1
- {"version":3,"file":"google-genai-adapter.mjs","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.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 — GoogleGenerativeAIAdapter:\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\n/**\n * Copilot Runtime adapter for Google Generative AI (e.g. Gemini).\n *\n * ## Example\n *\n * ```ts\n * import { CopilotRuntime, GoogleGenerativeAIAdapter } from \"@copilotkit/runtime\";\n * const { GoogleGenerativeAI } = require(\"@google/generative-ai\");\n *\n * const genAI = new GoogleGenerativeAI(process.env[\"GOOGLE_API_KEY\"]);\n *\n * const copilotKit = new CopilotRuntime();\n *\n * return new GoogleGenerativeAIAdapter({ model: \"gemini-2.5-flash\", apiVersion: \"v1\" });\n * ```\n */\nimport { LangChainAdapter } from \"../langchain/langchain-adapter\";\n\ninterface GoogleGenerativeAIAdapterOptions {\n /**\n * A custom Google Generative AI model to use.\n */\n model?: string;\n /**\n * The API version to use (e.g. \"v1\" or \"v1beta\"). Defaults to \"v1\".\n */\n apiVersion?: \"v1\" | \"v1beta\";\n /**\n * The API key to use.\n */\n apiKey?: string;\n}\n\nconst DEFAULT_MODEL = \"gemini-2.5-flash\";\nconst DEFAULT_API_VERSION: GoogleGenerativeAIAdapterOptions[\"apiVersion\"] =\n \"v1\";\nlet hasWarnedDefaultGoogleModel = false;\n\nexport class GoogleGenerativeAIAdapter extends LangChainAdapter {\n public provider = \"google\";\n public model: string = DEFAULT_MODEL;\n\n constructor(options?: GoogleGenerativeAIAdapterOptions) {\n if (\n !hasWarnedDefaultGoogleModel &&\n !options?.model &&\n !options?.apiVersion\n ) {\n console.warn(\n `You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. ` +\n `CopilotKit will default to apiVersion=\"v1\" and model=\"${DEFAULT_MODEL}\". ` +\n `To silence this warning, pass model and apiVersion when constructing the adapter.`,\n );\n hasWarnedDefaultGoogleModel = true;\n }\n\n super({\n chainFn: async ({ messages, tools, threadId }) => {\n // Lazy require for optional peer dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { ChatGoogle } = require(\"@langchain/google-gauth\");\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { AIMessage } = require(\"@langchain/core/messages\");\n\n // Filter out empty assistant messages to prevent Gemini validation errors\n // Gemini specifically rejects conversations containing AIMessages with empty content\n const filteredMessages = messages.filter((message) => {\n // Keep all non-AI messages (HumanMessage, SystemMessage, ToolMessage, etc.)\n if (!(message instanceof AIMessage)) {\n return true;\n }\n\n // For AIMessages, only keep those with non-empty content\n // Also keep AIMessages with tool_calls even if content is empty\n const aiMsg = message as any;\n return (\n (aiMsg.content && String(aiMsg.content).trim().length > 0) ||\n (aiMsg.tool_calls && aiMsg.tool_calls.length > 0)\n );\n });\n\n this.model = options?.model ?? DEFAULT_MODEL;\n const model = new ChatGoogle({\n apiKey: options?.apiKey ?? process.env.GOOGLE_API_KEY,\n modelName: this.model,\n apiVersion: options?.apiVersion ?? DEFAULT_API_VERSION,\n }).bindTools(tools);\n\n return model.stream(filteredMessages, {\n metadata: { conversation_id: threadId },\n });\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,gBAAgB;AACtB,MAAM,sBACJ;AACF,IAAI,8BAA8B;AAElC,IAAa,4BAAb,cAA+C,iBAAiB;CAI9D,YAAY,SAA4C;AACtD,MACE,CAAC,+BACD,CAAC,SAAS,SACV,CAAC,SAAS,YACV;AACA,WAAQ,KACN,uJAC2D,cAAc,sFAE1E;AACD,iCAA8B;;AAGhC,QAAM,EACJ,SAAS,OAAO,EAAE,UAAU,OAAO,eAAe;GAGhD,MAAM,EAAE,yBAAuB,0BAA0B;GAEzD,MAAM,EAAE,wBAAsB,2BAA2B;GAIzD,MAAM,mBAAmB,SAAS,QAAQ,YAAY;AAEpD,QAAI,EAAE,mBAAmB,WACvB,QAAO;IAKT,MAAM,QAAQ;AACd,WACG,MAAM,WAAW,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,KACvD,MAAM,cAAc,MAAM,WAAW,SAAS;KAEjD;AAEF,QAAK,QAAQ,SAAS,SAAS;AAO/B,UANc,IAAI,WAAW;IAC3B,QAAQ,SAAS,UAAU,QAAQ,IAAI;IACvC,WAAW,KAAK;IAChB,YAAY,SAAS,cAAc;IACpC,CAAC,CAAC,UAAU,MAAM,CAEN,OAAO,kBAAkB,EACpC,UAAU,EAAE,iBAAiB,UAAU,EACxC,CAAC;KAEL,CAAC;kBArDc;eACK"}
1
+ {"version":3,"file":"google-genai-adapter.mjs","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/google/google-genai-adapter.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 — GoogleGenerativeAIAdapter:\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\n/**\n * Copilot Runtime adapter for Google Generative AI (e.g. Gemini).\n *\n * ## Example\n *\n * ```ts\n * import { CopilotRuntime, GoogleGenerativeAIAdapter } from \"@copilotkit/runtime\";\n * const { GoogleGenerativeAI } = require(\"@google/generative-ai\");\n *\n * const genAI = new GoogleGenerativeAI(process.env[\"GOOGLE_API_KEY\"]);\n *\n * const copilotKit = new CopilotRuntime();\n *\n * return new GoogleGenerativeAIAdapter({ model: \"gemini-2.5-flash\", apiVersion: \"v1\" });\n * ```\n */\nimport { LangChainAdapter } from \"../langchain/langchain-adapter\";\nimport { createGoogleGenerativeAI } from \"@ai-sdk/google\";\nimport type { LanguageModel } from \"ai\";\n\ninterface GoogleGenerativeAIAdapterOptions {\n /**\n * A custom Google Generative AI model to use.\n */\n model?: string;\n /**\n * The API version to use (e.g. \"v1\" or \"v1beta\"). Defaults to \"v1\".\n */\n apiVersion?: \"v1\" | \"v1beta\";\n /**\n * The API key to use.\n */\n apiKey?: string;\n}\n\nconst DEFAULT_MODEL = \"gemini-2.5-flash\";\nconst DEFAULT_API_VERSION: GoogleGenerativeAIAdapterOptions[\"apiVersion\"] =\n \"v1\";\nlet hasWarnedDefaultGoogleModel = false;\n\nexport class GoogleGenerativeAIAdapter extends LangChainAdapter {\n public provider = \"google\";\n private _apiKey?: string;\n private _apiVersion?: GoogleGenerativeAIAdapterOptions[\"apiVersion\"];\n public model: string = DEFAULT_MODEL;\n\n constructor(options?: GoogleGenerativeAIAdapterOptions) {\n if (\n !hasWarnedDefaultGoogleModel &&\n !options?.model &&\n !options?.apiVersion\n ) {\n console.warn(\n `You are using the GoogleGenerativeAIAdapter without explicitly setting a model or apiVersion. ` +\n `CopilotKit will default to apiVersion=\"v1\" and model=\"${DEFAULT_MODEL}\". ` +\n `To silence this warning, pass model and apiVersion when constructing the adapter.`,\n );\n hasWarnedDefaultGoogleModel = true;\n }\n\n super({\n chainFn: async ({ messages, tools, threadId }) => {\n // Lazy require for optional peer dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { ChatGoogle } = require(\"@langchain/google-gauth\");\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { AIMessage } = require(\"@langchain/core/messages\");\n\n // Filter out empty assistant messages to prevent Gemini validation errors\n // Gemini specifically rejects conversations containing AIMessages with empty content\n const filteredMessages = messages.filter((message) => {\n // Keep all non-AI messages (HumanMessage, SystemMessage, ToolMessage, etc.)\n if (!(message instanceof AIMessage)) {\n return true;\n }\n\n // For AIMessages, only keep those with non-empty content\n // Also keep AIMessages with tool_calls even if content is empty\n const aiMsg = message as any;\n return (\n (aiMsg.content && String(aiMsg.content).trim().length > 0) ||\n (aiMsg.tool_calls && aiMsg.tool_calls.length > 0)\n );\n });\n\n this.model = options?.model ?? DEFAULT_MODEL;\n const model = new ChatGoogle({\n apiKey: options?.apiKey ?? process.env.GOOGLE_API_KEY,\n modelName: this.model,\n apiVersion: options?.apiVersion ?? DEFAULT_API_VERSION,\n }).bindTools(tools);\n\n return model.stream(filteredMessages, {\n metadata: { conversation_id: threadId },\n });\n },\n });\n\n // `this.model` is otherwise only assigned inside the chain closure, which\n // does not run until a request arrives — so `getLanguageModel()` would\n // report the default model instead of the configured one.\n this._apiKey = options?.apiKey;\n this._apiVersion = options?.apiVersion;\n this.model = options?.model ?? DEFAULT_MODEL;\n }\n\n /**\n * Hands `BuiltInAgent` a model built from this adapter's own credentials.\n * Without it the runtime rebuilds a bare \"google/<model>\" string and the\n * provider falls back to environment variables, dropping the `apiKey`\n * passed to this constructor.\n */\n getLanguageModel(): LanguageModel {\n // `createGoogleGenerativeAI` has no `apiVersion` option, so the version is\n // carried on the base URL. Only when the caller asked for one: the\n // provider's own default is v1beta, and that has been the live default\n // ever since this method started routing around `process()`. Forcing the\n // adapter's documented \"v1\" here would strand models v1 does not serve.\n const provider = createGoogleGenerativeAI({\n apiKey: this._apiKey ?? process.env.GOOGLE_API_KEY,\n ...(this._apiVersion && {\n baseURL: `https://generativelanguage.googleapis.com/${this._apiVersion}`,\n }),\n });\n return provider(this.model);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,gBAAgB;AACtB,MAAM,sBACJ;AACF,IAAI,8BAA8B;AAElC,IAAa,4BAAb,cAA+C,iBAAiB;CAM9D,YAAY,SAA4C;AACtD,MACE,CAAC,+BACD,CAAC,SAAS,SACV,CAAC,SAAS,YACV;AACA,WAAQ,KACN,uJAC2D,cAAc,sFAE1E;AACD,iCAA8B;;AAGhC,QAAM,EACJ,SAAS,OAAO,EAAE,UAAU,OAAO,eAAe;GAGhD,MAAM,EAAE,yBAAuB,0BAA0B;GAEzD,MAAM,EAAE,wBAAsB,2BAA2B;GAIzD,MAAM,mBAAmB,SAAS,QAAQ,YAAY;AAEpD,QAAI,EAAE,mBAAmB,WACvB,QAAO;IAKT,MAAM,QAAQ;AACd,WACG,MAAM,WAAW,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,KACvD,MAAM,cAAc,MAAM,WAAW,SAAS;KAEjD;AAEF,QAAK,QAAQ,SAAS,SAAS;AAO/B,UANc,IAAI,WAAW;IAC3B,QAAQ,SAAS,UAAU,QAAQ,IAAI;IACvC,WAAW,KAAK;IAChB,YAAY,SAAS,cAAc;IACpC,CAAC,CAAC,UAAU,MAAM,CAEN,OAAO,kBAAkB,EACpC,UAAU,EAAE,iBAAiB,UAAU,EACxC,CAAC;KAEL,CAAC;kBAvDc;eAGK;AAyDrB,OAAK,UAAU,SAAS;AACxB,OAAK,cAAc,SAAS;AAC5B,OAAK,QAAQ,SAAS,SAAS;;;;;;;;CASjC,mBAAkC;AAYhC,SANiB,yBAAyB;GACxC,QAAQ,KAAK,WAAW,QAAQ,IAAI;GACpC,GAAI,KAAK,eAAe,EACtB,SAAS,6CAA6C,KAAK,eAC5D;GACF,CAAC,CACc,KAAK,MAAM"}
@@ -1,6 +1,7 @@
1
1
  require("reflect-metadata");
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
3
  const require_utils = require('../openai/utils.cjs');
4
+ let _ai_sdk_openai = require("@ai-sdk/openai");
4
5
  let _copilotkit_shared = require("@copilotkit/shared");
5
6
 
6
7
  //#region src/v1-deprecated/service-adapters/unify/unify-adapter.ts
@@ -10,8 +11,7 @@ var UnifyAdapter = class {
10
11
  }
11
12
  constructor(options) {
12
13
  this.provider = "unify";
13
- if (options?.apiKey) this.apiKey = options.apiKey;
14
- else this.apiKey = "UNIFY_API_KEY";
14
+ this.apiKey = options?.apiKey ?? process.env.UNIFY_API_KEY;
15
15
  this.model = options?.model;
16
16
  this.start = true;
17
17
  }
@@ -86,6 +86,18 @@ var UnifyAdapter = class {
86
86
  });
87
87
  return { threadId: request.threadId || (0, _copilotkit_shared.randomUUID)() };
88
88
  }
89
+ /**
90
+ * Unify's API is OpenAI-compatible, so the model is built from the OpenAI
91
+ * provider pointed at Unify's base URL with this adapter's own key. Without
92
+ * it the runtime rebuilds a bare "unify/<model>" string, which is not a
93
+ * provider it can resolve.
94
+ */
95
+ getLanguageModel() {
96
+ return (0, _ai_sdk_openai.createOpenAI)({
97
+ baseURL: "https://api.unify.ai/v0/",
98
+ apiKey: this.apiKey
99
+ })(this.model);
100
+ }
89
101
  };
90
102
 
91
103
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"unify-adapter.cjs","names":["convertActionInputToOpenAITool","convertMessageToOpenAIMessage"],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.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 — UnifyAdapter:\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 * @copilotkit/runtime — UnifyAdapterParams:\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\n/**\n * CopilotKit Adapter for Unify\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new UnifyAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new UnifyAdapter({ model: \"llama-3-8b-chat@fireworks-ai\" }),\n * );\n * ```\n */\nimport type {\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n CopilotServiceAdapter,\n} from \"../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\nimport {\n convertActionInputToOpenAITool,\n convertMessageToOpenAIMessage,\n} from \"../openai/utils\";\n\nexport interface UnifyAdapterParams {\n apiKey?: string;\n model: string;\n}\n\nexport class UnifyAdapter implements CopilotServiceAdapter {\n private apiKey: string;\n public model: string;\n private start: boolean;\n public provider = \"unify\";\n\n public get name() {\n return \"UnifyAdapter\";\n }\n\n constructor(options?: UnifyAdapterParams) {\n if (options?.apiKey) {\n this.apiKey = options.apiKey;\n } else {\n this.apiKey = \"UNIFY_API_KEY\";\n }\n this.model = options?.model;\n this.start = true;\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const tools = request.actions.map(convertActionInputToOpenAITool);\n // Lazy require for optional peer dependency\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const OpenAI = require(\"openai\").default;\n const openai = new OpenAI({\n apiKey: this.apiKey,\n baseURL: \"https://api.unify.ai/v0/\",\n });\n const forwardedParameters = request.forwardedParameters;\n\n const messages = request.messages.map((m) =>\n convertMessageToOpenAIMessage(m),\n );\n\n const stream = await openai.chat.completions.create({\n model: this.model,\n messages: messages,\n stream: true,\n ...(tools.length > 0 && { tools }),\n ...(forwardedParameters?.temperature && {\n temperature: forwardedParameters.temperature,\n }),\n });\n\n let model = null;\n let currentMessageId: string;\n let currentToolCallId: string;\n request.eventSource.stream(async (eventStream$) => {\n let mode: \"function\" | \"message\" | null = null;\n for await (const chunk of stream) {\n if (this.start) {\n model = chunk.model;\n currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: `Model used: ${model}\\n`,\n });\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n this.start = false;\n }\n const toolCall = chunk.choices[0].delta.tool_calls?.[0];\n const content = chunk.choices[0].delta.content;\n\n // When switching from message to function or vice versa,\n // send the respective end event.\n // If toolCall?.id is defined, it means a new tool call starts.\n if (mode === \"message\" && toolCall?.id) {\n mode = null;\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n } else if (\n mode === \"function\" &&\n (toolCall === undefined || toolCall?.id)\n ) {\n mode = null;\n eventStream$.sendActionExecutionEnd({\n actionExecutionId: currentToolCallId,\n });\n }\n\n // If we send a new message type, send the appropriate start event.\n if (mode === null) {\n if (toolCall?.id) {\n mode = \"function\";\n currentToolCallId = toolCall!.id;\n eventStream$.sendActionExecutionStart({\n actionExecutionId: currentToolCallId,\n actionName: toolCall!.function!.name,\n });\n } else if (content) {\n mode = \"message\";\n currentMessageId = chunk.id;\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n }\n }\n\n // send the content events\n if (mode === \"message\" && content) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: content,\n });\n } else if (mode === \"function\" && toolCall?.function?.arguments) {\n eventStream$.sendActionExecutionArgs({\n actionExecutionId: currentToolCallId,\n args: toolCall.function.arguments,\n });\n }\n }\n\n // send the end events\n if (mode === \"message\") {\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n } else if (mode === \"function\") {\n eventStream$.sendActionExecutionEnd({\n actionExecutionId: currentToolCallId,\n });\n }\n\n eventStream$.complete();\n });\n\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n}\n"],"mappings":";;;;;;AA6DA,IAAa,eAAb,MAA2D;CAMzD,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAA8B;kBANxB;AAOhB,MAAI,SAAS,OACX,MAAK,SAAS,QAAQ;MAEtB,MAAK,SAAS;AAEhB,OAAK,QAAQ,SAAS;AACtB,OAAK,QAAQ;;CAGf,MAAM,QACJ,SAC+C;EAC/C,MAAM,QAAQ,QAAQ,QAAQ,IAAIA,6CAA+B;EAGjE,MAAM,SAAS,QAAQ,SAAS,CAAC;EACjC,MAAM,SAAS,IAAI,OAAO;GACxB,QAAQ,KAAK;GACb,SAAS;GACV,CAAC;EACF,MAAM,sBAAsB,QAAQ;EAEpC,MAAM,WAAW,QAAQ,SAAS,KAAK,MACrCC,4CAA8B,EAAE,CACjC;EAED,MAAM,SAAS,MAAM,OAAO,KAAK,YAAY,OAAO;GAClD,OAAO,KAAK;GACF;GACV,QAAQ;GACR,GAAI,MAAM,SAAS,KAAK,EAAE,OAAO;GACjC,GAAI,qBAAqB,eAAe,EACtC,aAAa,oBAAoB,aAClC;GACF,CAAC;EAEF,IAAI,QAAQ;EACZ,IAAI;EACJ,IAAI;AACJ,UAAQ,YAAY,OAAO,OAAO,iBAAiB;GACjD,IAAI,OAAsC;AAC1C,cAAW,MAAM,SAAS,QAAQ;AAChC,QAAI,KAAK,OAAO;AACd,aAAQ,MAAM;AACd,0DAA6B;AAC7B,kBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,kBAAa,uBAAuB;MAClC,WAAW;MACX,SAAS,eAAe,MAAM;MAC/B,CAAC;AACF,kBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAChE,UAAK,QAAQ;;IAEf,MAAM,WAAW,MAAM,QAAQ,GAAG,MAAM,aAAa;IACrD,MAAM,UAAU,MAAM,QAAQ,GAAG,MAAM;AAKvC,QAAI,SAAS,aAAa,UAAU,IAAI;AACtC,YAAO;AACP,kBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;eAEhE,SAAS,eACR,aAAa,UAAa,UAAU,KACrC;AACA,YAAO;AACP,kBAAa,uBAAuB,EAClC,mBAAmB,mBACpB,CAAC;;AAIJ,QAAI,SAAS,MACX;SAAI,UAAU,IAAI;AAChB,aAAO;AACP,0BAAoB,SAAU;AAC9B,mBAAa,yBAAyB;OACpC,mBAAmB;OACnB,YAAY,SAAU,SAAU;OACjC,CAAC;gBACO,SAAS;AAClB,aAAO;AACP,yBAAmB,MAAM;AACzB,mBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;;;AAKtE,QAAI,SAAS,aAAa,QACxB,cAAa,uBAAuB;KAClC,WAAW;KACF;KACV,CAAC;aACO,SAAS,cAAc,UAAU,UAAU,UACpD,cAAa,wBAAwB;KACnC,mBAAmB;KACnB,MAAM,SAAS,SAAS;KACzB,CAAC;;AAKN,OAAI,SAAS,UACX,cAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;YACvD,SAAS,WAClB,cAAa,uBAAuB,EAClC,mBAAmB,mBACpB,CAAC;AAGJ,gBAAa,UAAU;IACvB;AAEF,SAAO,EACL,UAAU,QAAQ,gDAAwB,EAC3C"}
1
+ {"version":3,"file":"unify-adapter.cjs","names":["convertActionInputToOpenAITool","convertMessageToOpenAIMessage"],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.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 — UnifyAdapter:\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 * @copilotkit/runtime — UnifyAdapterParams:\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\n/**\n * CopilotKit Adapter for Unify\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new UnifyAdapter());\n * ```\n * </RequestExample>\n *\n * You can easily set the model to use by passing it to the constructor.\n * ```jsx\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(\n * req,\n * new UnifyAdapter({ model: \"llama-3-8b-chat@fireworks-ai\" }),\n * );\n * ```\n */\nimport type {\n CopilotRuntimeChatCompletionRequest,\n CopilotRuntimeChatCompletionResponse,\n CopilotServiceAdapter,\n} from \"../service-adapter\";\nimport { randomId, randomUUID } from \"@copilotkit/shared\";\nimport { createOpenAI } from \"@ai-sdk/openai\";\nimport type { LanguageModel } from \"ai\";\nimport {\n convertActionInputToOpenAITool,\n convertMessageToOpenAIMessage,\n} from \"../openai/utils\";\n\nexport interface UnifyAdapterParams {\n apiKey?: string;\n model: string;\n}\n\nexport class UnifyAdapter implements CopilotServiceAdapter {\n private apiKey?: string;\n public model: string;\n private start: boolean;\n public provider = \"unify\";\n\n public get name() {\n return \"UnifyAdapter\";\n }\n\n constructor(options?: UnifyAdapterParams) {\n // Was `this.apiKey = \"UNIFY_API_KEY\"` — the *name* of the variable, stored\n // as the key. Every request that relied on the default authenticated with\n // the literal placeholder and came back 401. Read the variable instead,\n // matching how the Google adapter falls back to GOOGLE_API_KEY.\n this.apiKey = options?.apiKey ?? process.env.UNIFY_API_KEY;\n this.model = options?.model;\n this.start = true;\n }\n\n async process(\n request: CopilotRuntimeChatCompletionRequest,\n ): Promise<CopilotRuntimeChatCompletionResponse> {\n const tools = request.actions.map(convertActionInputToOpenAITool);\n // Lazy require for optional peer dependency\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const OpenAI = require(\"openai\").default;\n const openai = new OpenAI({\n apiKey: this.apiKey,\n baseURL: \"https://api.unify.ai/v0/\",\n });\n const forwardedParameters = request.forwardedParameters;\n\n const messages = request.messages.map((m) =>\n convertMessageToOpenAIMessage(m),\n );\n\n const stream = await openai.chat.completions.create({\n model: this.model,\n messages: messages,\n stream: true,\n ...(tools.length > 0 && { tools }),\n ...(forwardedParameters?.temperature && {\n temperature: forwardedParameters.temperature,\n }),\n });\n\n let model = null;\n let currentMessageId: string;\n let currentToolCallId: string;\n request.eventSource.stream(async (eventStream$) => {\n let mode: \"function\" | \"message\" | null = null;\n for await (const chunk of stream) {\n if (this.start) {\n model = chunk.model;\n currentMessageId = randomId();\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: `Model used: ${model}\\n`,\n });\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n this.start = false;\n }\n const toolCall = chunk.choices[0].delta.tool_calls?.[0];\n const content = chunk.choices[0].delta.content;\n\n // When switching from message to function or vice versa,\n // send the respective end event.\n // If toolCall?.id is defined, it means a new tool call starts.\n if (mode === \"message\" && toolCall?.id) {\n mode = null;\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n } else if (\n mode === \"function\" &&\n (toolCall === undefined || toolCall?.id)\n ) {\n mode = null;\n eventStream$.sendActionExecutionEnd({\n actionExecutionId: currentToolCallId,\n });\n }\n\n // If we send a new message type, send the appropriate start event.\n if (mode === null) {\n if (toolCall?.id) {\n mode = \"function\";\n currentToolCallId = toolCall!.id;\n eventStream$.sendActionExecutionStart({\n actionExecutionId: currentToolCallId,\n actionName: toolCall!.function!.name,\n });\n } else if (content) {\n mode = \"message\";\n currentMessageId = chunk.id;\n eventStream$.sendTextMessageStart({ messageId: currentMessageId });\n }\n }\n\n // send the content events\n if (mode === \"message\" && content) {\n eventStream$.sendTextMessageContent({\n messageId: currentMessageId,\n content: content,\n });\n } else if (mode === \"function\" && toolCall?.function?.arguments) {\n eventStream$.sendActionExecutionArgs({\n actionExecutionId: currentToolCallId,\n args: toolCall.function.arguments,\n });\n }\n }\n\n // send the end events\n if (mode === \"message\") {\n eventStream$.sendTextMessageEnd({ messageId: currentMessageId });\n } else if (mode === \"function\") {\n eventStream$.sendActionExecutionEnd({\n actionExecutionId: currentToolCallId,\n });\n }\n\n eventStream$.complete();\n });\n\n return {\n threadId: request.threadId || randomUUID(),\n };\n }\n\n /**\n * Unify's API is OpenAI-compatible, so the model is built from the OpenAI\n * provider pointed at Unify's base URL with this adapter's own key. Without\n * it the runtime rebuilds a bare \"unify/<model>\" string, which is not a\n * provider it can resolve.\n */\n getLanguageModel(): LanguageModel {\n const provider = createOpenAI({\n baseURL: \"https://api.unify.ai/v0/\",\n apiKey: this.apiKey,\n });\n return provider(this.model);\n }\n}\n"],"mappings":";;;;;;;AA+DA,IAAa,eAAb,MAA2D;CAMzD,IAAW,OAAO;AAChB,SAAO;;CAGT,YAAY,SAA8B;kBANxB;AAWhB,OAAK,SAAS,SAAS,UAAU,QAAQ,IAAI;AAC7C,OAAK,QAAQ,SAAS;AACtB,OAAK,QAAQ;;CAGf,MAAM,QACJ,SAC+C;EAC/C,MAAM,QAAQ,QAAQ,QAAQ,IAAIA,6CAA+B;EAGjE,MAAM,SAAS,QAAQ,SAAS,CAAC;EACjC,MAAM,SAAS,IAAI,OAAO;GACxB,QAAQ,KAAK;GACb,SAAS;GACV,CAAC;EACF,MAAM,sBAAsB,QAAQ;EAEpC,MAAM,WAAW,QAAQ,SAAS,KAAK,MACrCC,4CAA8B,EAAE,CACjC;EAED,MAAM,SAAS,MAAM,OAAO,KAAK,YAAY,OAAO;GAClD,OAAO,KAAK;GACF;GACV,QAAQ;GACR,GAAI,MAAM,SAAS,KAAK,EAAE,OAAO;GACjC,GAAI,qBAAqB,eAAe,EACtC,aAAa,oBAAoB,aAClC;GACF,CAAC;EAEF,IAAI,QAAQ;EACZ,IAAI;EACJ,IAAI;AACJ,UAAQ,YAAY,OAAO,OAAO,iBAAiB;GACjD,IAAI,OAAsC;AAC1C,cAAW,MAAM,SAAS,QAAQ;AAChC,QAAI,KAAK,OAAO;AACd,aAAQ,MAAM;AACd,0DAA6B;AAC7B,kBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;AAClE,kBAAa,uBAAuB;MAClC,WAAW;MACX,SAAS,eAAe,MAAM;MAC/B,CAAC;AACF,kBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;AAChE,UAAK,QAAQ;;IAEf,MAAM,WAAW,MAAM,QAAQ,GAAG,MAAM,aAAa;IACrD,MAAM,UAAU,MAAM,QAAQ,GAAG,MAAM;AAKvC,QAAI,SAAS,aAAa,UAAU,IAAI;AACtC,YAAO;AACP,kBAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;eAEhE,SAAS,eACR,aAAa,UAAa,UAAU,KACrC;AACA,YAAO;AACP,kBAAa,uBAAuB,EAClC,mBAAmB,mBACpB,CAAC;;AAIJ,QAAI,SAAS,MACX;SAAI,UAAU,IAAI;AAChB,aAAO;AACP,0BAAoB,SAAU;AAC9B,mBAAa,yBAAyB;OACpC,mBAAmB;OACnB,YAAY,SAAU,SAAU;OACjC,CAAC;gBACO,SAAS;AAClB,aAAO;AACP,yBAAmB,MAAM;AACzB,mBAAa,qBAAqB,EAAE,WAAW,kBAAkB,CAAC;;;AAKtE,QAAI,SAAS,aAAa,QACxB,cAAa,uBAAuB;KAClC,WAAW;KACF;KACV,CAAC;aACO,SAAS,cAAc,UAAU,UAAU,UACpD,cAAa,wBAAwB;KACnC,mBAAmB;KACnB,MAAM,SAAS,SAAS;KACzB,CAAC;;AAKN,OAAI,SAAS,UACX,cAAa,mBAAmB,EAAE,WAAW,kBAAkB,CAAC;YACvD,SAAS,WAClB,cAAa,uBAAuB,EAClC,mBAAmB,mBACpB,CAAC;AAGJ,gBAAa,UAAU;IACvB;AAEF,SAAO,EACL,UAAU,QAAQ,gDAAwB,EAC3C;;;;;;;;CASH,mBAAkC;AAKhC,0CAJ8B;GAC5B,SAAS;GACT,QAAQ,KAAK;GACd,CAAC,CACc,KAAK,MAAM"}
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotServiceAdapter } from "../service-adapter.cjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/unify/unify-adapter.d.ts
5
6
  interface UnifyAdapterParams {
@@ -7,13 +8,20 @@ interface UnifyAdapterParams {
7
8
  model: string;
8
9
  }
9
10
  declare class UnifyAdapter implements CopilotServiceAdapter {
10
- private apiKey;
11
+ private apiKey?;
11
12
  model: string;
12
13
  private start;
13
14
  provider: string;
14
15
  get name(): string;
15
16
  constructor(options?: UnifyAdapterParams);
16
17
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
18
+ /**
19
+ * Unify's API is OpenAI-compatible, so the model is built from the OpenAI
20
+ * provider pointed at Unify's base URL with this adapter's own key. Without
21
+ * it the runtime rebuilds a bare "unify/<model>" string, which is not a
22
+ * provider it can resolve.
23
+ */
24
+ getLanguageModel(): LanguageModel;
17
25
  }
18
26
  //#endregion
19
27
  export { UnifyAdapter, UnifyAdapterParams };
@@ -1 +1 @@
1
- {"version":3,"file":"unify-adapter.d.cts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.ts"],"mappings":";;;;UAwDiB,kBAAA;EACf,MAAA;EACA,KAAA;AAAA;AAAA,cAGW,YAAA,YAAwB,qBAAA;EAAA,QAC3B,MAAA;EACD,KAAA;EAAA,QACC,KAAA;EACD,QAAA;EAAA,IAEI,IAAA,CAAA;cAIC,OAAA,GAAU,kBAAA;EAUhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;AAAA"}
1
+ {"version":3,"file":"unify-adapter.d.cts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.ts"],"mappings":";;;;;UA0DiB,kBAAA;EACf,MAAA;EACA,KAAA;AAAA;AAAA,cAGW,YAAA,YAAwB,qBAAA;EAAA,QAC3B,MAAA;EACD,KAAA;EAAA,QACC,KAAA;EACD,QAAA;EAAA,IAEI,IAAA,CAAA;cAIC,OAAA,GAAU,kBAAA;EAUhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;EAAA;;;;;;EAkHX,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,5 +1,6 @@
1
1
 
2
2
  import { CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotServiceAdapter } from "../service-adapter.mjs";
3
+ import { LanguageModel } from "ai";
3
4
 
4
5
  //#region src/v1-deprecated/service-adapters/unify/unify-adapter.d.ts
5
6
  interface UnifyAdapterParams {
@@ -7,13 +8,20 @@ interface UnifyAdapterParams {
7
8
  model: string;
8
9
  }
9
10
  declare class UnifyAdapter implements CopilotServiceAdapter {
10
- private apiKey;
11
+ private apiKey?;
11
12
  model: string;
12
13
  private start;
13
14
  provider: string;
14
15
  get name(): string;
15
16
  constructor(options?: UnifyAdapterParams);
16
17
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
18
+ /**
19
+ * Unify's API is OpenAI-compatible, so the model is built from the OpenAI
20
+ * provider pointed at Unify's base URL with this adapter's own key. Without
21
+ * it the runtime rebuilds a bare "unify/<model>" string, which is not a
22
+ * provider it can resolve.
23
+ */
24
+ getLanguageModel(): LanguageModel;
17
25
  }
18
26
  //#endregion
19
27
  export { UnifyAdapter, UnifyAdapterParams };
@@ -1 +1 @@
1
- {"version":3,"file":"unify-adapter.d.mts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.ts"],"mappings":";;;;UAwDiB,kBAAA;EACf,MAAA;EACA,KAAA;AAAA;AAAA,cAGW,YAAA,YAAwB,qBAAA;EAAA,QAC3B,MAAA;EACD,KAAA;EAAA,QACC,KAAA;EACD,QAAA;EAAA,IAEI,IAAA,CAAA;cAIC,OAAA,GAAU,kBAAA;EAUhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;AAAA"}
1
+ {"version":3,"file":"unify-adapter.d.mts","names":[],"sources":["../../../../src/v1-deprecated/service-adapters/unify/unify-adapter.ts"],"mappings":";;;;;UA0DiB,kBAAA;EACf,MAAA;EACA,KAAA;AAAA;AAAA,cAGW,YAAA,YAAwB,qBAAA;EAAA,QAC3B,MAAA;EACD,KAAA;EAAA,QACC,KAAA;EACD,QAAA;EAAA,IAEI,IAAA,CAAA;cAIC,OAAA,GAAU,kBAAA;EAUhB,OAAA,CACJ,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,oCAAA;EAAA;;;;;;EAkHX,gBAAA,CAAA,GAAoB,aAAA;AAAA"}
@@ -1,6 +1,7 @@
1
1
  import "reflect-metadata";
2
2
  import { __require } from "../../_virtual/_rolldown/runtime.mjs";
3
3
  import { convertActionInputToOpenAITool, convertMessageToOpenAIMessage } from "../openai/utils.mjs";
4
+ import { createOpenAI } from "@ai-sdk/openai";
4
5
  import { randomId, randomUUID } from "@copilotkit/shared";
5
6
 
6
7
  //#region src/v1-deprecated/service-adapters/unify/unify-adapter.ts
@@ -10,8 +11,7 @@ var UnifyAdapter = class {
10
11
  }
11
12
  constructor(options) {
12
13
  this.provider = "unify";
13
- if (options?.apiKey) this.apiKey = options.apiKey;
14
- else this.apiKey = "UNIFY_API_KEY";
14
+ this.apiKey = options?.apiKey ?? process.env.UNIFY_API_KEY;
15
15
  this.model = options?.model;
16
16
  this.start = true;
17
17
  }
@@ -86,6 +86,18 @@ var UnifyAdapter = class {
86
86
  });
87
87
  return { threadId: request.threadId || randomUUID() };
88
88
  }
89
+ /**
90
+ * Unify's API is OpenAI-compatible, so the model is built from the OpenAI
91
+ * provider pointed at Unify's base URL with this adapter's own key. Without
92
+ * it the runtime rebuilds a bare "unify/<model>" string, which is not a
93
+ * provider it can resolve.
94
+ */
95
+ getLanguageModel() {
96
+ return createOpenAI({
97
+ baseURL: "https://api.unify.ai/v0/",
98
+ apiKey: this.apiKey
99
+ })(this.model);
100
+ }
89
101
  };
90
102
 
91
103
  //#endregion