@copilotkit/runtime 1.5.1-next.1 → 1.5.1-next.3

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 (58) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/__snapshots__/schema/schema.graphql +9 -8
  3. package/dist/{chunk-RFF5IIZJ.mjs → chunk-B74M7FXG.mjs} +2 -3
  4. package/dist/chunk-B74M7FXG.mjs.map +1 -0
  5. package/dist/{chunk-L4VT7Z25.mjs → chunk-M4QD67S3.mjs} +2 -2
  6. package/dist/{chunk-CLGKEUOA.mjs → chunk-OKQVDDJ2.mjs} +63 -298
  7. package/dist/chunk-OKQVDDJ2.mjs.map +1 -0
  8. package/dist/{chunk-G2PTXSIW.mjs → chunk-U3AYI5XZ.mjs} +2 -2
  9. package/dist/{chunk-Z3MD5FQ4.mjs → chunk-U75F2RAQ.mjs} +2 -2
  10. package/dist/{chunk-6N4ZHRRC.mjs → chunk-ZSWCEADS.mjs} +331 -465
  11. package/dist/chunk-ZSWCEADS.mjs.map +1 -0
  12. package/dist/{copilot-runtime-6285d897.d.ts → copilot-runtime-12e7ac40.d.ts} +2 -2
  13. package/dist/graphql/types/converted/index.d.ts +1 -1
  14. package/dist/graphql/types/converted/index.js +1 -2
  15. package/dist/graphql/types/converted/index.js.map +1 -1
  16. package/dist/graphql/types/converted/index.mjs +1 -1
  17. package/dist/{groq-adapter-15d41154.d.ts → groq-adapter-24abe931.d.ts} +1 -1
  18. package/dist/{index-ff3fbc33.d.ts → index-10b1c870.d.ts} +8 -7
  19. package/dist/index.d.ts +5 -5
  20. package/dist/index.js +480 -852
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +11 -15
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/{langserve-48e976ac.d.ts → langserve-f021ab9c.d.ts} +14 -54
  25. package/dist/lib/index.d.ts +4 -4
  26. package/dist/lib/index.js +459 -754
  27. package/dist/lib/index.js.map +1 -1
  28. package/dist/lib/index.mjs +7 -7
  29. package/dist/lib/integrations/index.d.ts +4 -4
  30. package/dist/lib/integrations/index.js +30 -78
  31. package/dist/lib/integrations/index.js.map +1 -1
  32. package/dist/lib/integrations/index.mjs +6 -6
  33. package/dist/lib/integrations/nest/index.d.ts +3 -3
  34. package/dist/lib/integrations/nest/index.js +30 -78
  35. package/dist/lib/integrations/nest/index.js.map +1 -1
  36. package/dist/lib/integrations/nest/index.mjs +4 -4
  37. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  38. package/dist/lib/integrations/node-express/index.js +30 -78
  39. package/dist/lib/integrations/node-express/index.js.map +1 -1
  40. package/dist/lib/integrations/node-express/index.mjs +4 -4
  41. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  42. package/dist/lib/integrations/node-http/index.js +30 -78
  43. package/dist/lib/integrations/node-http/index.js.map +1 -1
  44. package/dist/lib/integrations/node-http/index.mjs +3 -3
  45. package/dist/service-adapters/index.d.ts +5 -36
  46. package/dist/service-adapters/index.js +61 -298
  47. package/dist/service-adapters/index.js.map +1 -1
  48. package/dist/service-adapters/index.mjs +1 -5
  49. package/package.json +4 -4
  50. package/src/graphql/resolvers/copilot.resolver.ts +16 -0
  51. package/src/graphql/types/agents-response.type.ts +22 -0
  52. package/src/lib/runtime/copilot-runtime.ts +50 -0
  53. package/dist/chunk-6N4ZHRRC.mjs.map +0 -1
  54. package/dist/chunk-CLGKEUOA.mjs.map +0 -1
  55. package/dist/chunk-RFF5IIZJ.mjs.map +0 -1
  56. /package/dist/{chunk-L4VT7Z25.mjs.map → chunk-M4QD67S3.mjs.map} +0 -0
  57. /package/dist/{chunk-G2PTXSIW.mjs.map → chunk-U3AYI5XZ.mjs.map} +0 -0
  58. /package/dist/{chunk-Z3MD5FQ4.mjs.map → chunk-U75F2RAQ.mjs.map} +0 -0
@@ -1,8 +1,8 @@
1
- import { b as CopilotServiceAdapter, C as CopilotRuntimeChatCompletionRequest, a as CopilotRuntimeChatCompletionResponse } from '../langserve-48e976ac.js';
2
- export { c as RemoteChain, R as RemoteChainParameters } from '../langserve-48e976ac.js';
3
- export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-15d41154.js';
1
+ import { C as CopilotServiceAdapter, c as CopilotRuntimeChatCompletionRequest, d as CopilotRuntimeChatCompletionResponse } from '../langserve-f021ab9c.js';
2
+ export { a as RemoteChain, R as RemoteChainParameters } from '../langserve-f021ab9c.js';
3
+ export { G as GoogleGenerativeAIAdapter, f as GroqAdapter, e as GroqAdapterParams, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams, d as UnifyAdapter, U as UnifyAdapterParams } from '../groq-adapter-24abe931.js';
4
4
  import Anthropic from '@anthropic-ai/sdk';
5
- import '../index-ff3fbc33.js';
5
+ import '../index-10b1c870.js';
6
6
  import '../graphql/types/base/index.js';
7
7
  import 'rxjs';
8
8
  import '@copilotkit/shared';
@@ -50,35 +50,4 @@ declare class AnthropicAdapter implements CopilotServiceAdapter {
50
50
  process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
51
51
  }
52
52
 
53
- interface OllamaAdapterOptions {
54
- model?: string;
55
- }
56
- declare class ExperimentalOllamaAdapter implements CopilotServiceAdapter {
57
- private model;
58
- constructor(options?: OllamaAdapterOptions);
59
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
60
- }
61
-
62
- /**
63
- * CopilotKit Empty Adapter
64
- *
65
- * This adapter is meant to preserve adherence to runtime requirements, while doing nothing
66
- * Ideal if you don't want to connect an LLM the to the runtime, and only use your LangGraph agent.
67
- * Be aware that Copilot Suggestions will not work if you use this adapter
68
- *
69
- * ## Example
70
- *
71
- * ```ts
72
- * import { CopilotRuntime, ExperimentalEmptyAdapter } from "@copilotkit/runtime";
73
- *
74
- * const copilotKit = new CopilotRuntime();
75
- *
76
- * return new ExperimentalEmptyAdapter();
77
- * ```
78
- */
79
-
80
- declare class ExperimentalEmptyAdapter implements CopilotServiceAdapter {
81
- process(request: CopilotRuntimeChatCompletionRequest): Promise<CopilotRuntimeChatCompletionResponse>;
82
- }
83
-
84
- export { AnthropicAdapter, AnthropicAdapterParams, CopilotRuntimeChatCompletionRequest, CopilotRuntimeChatCompletionResponse, CopilotServiceAdapter, ExperimentalEmptyAdapter, ExperimentalOllamaAdapter };
53
+ export { AnthropicAdapter, AnthropicAdapterParams, CopilotServiceAdapter };
@@ -31,8 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var service_adapters_exports = {};
32
32
  __export(service_adapters_exports, {
33
33
  AnthropicAdapter: () => AnthropicAdapter,
34
- ExperimentalEmptyAdapter: () => ExperimentalEmptyAdapter,
35
- ExperimentalOllamaAdapter: () => ExperimentalOllamaAdapter,
36
34
  GoogleGenerativeAIAdapter: () => GoogleGenerativeAIAdapter,
37
35
  GroqAdapter: () => GroqAdapter,
38
36
  LangChainAdapter: () => LangChainAdapter,
@@ -312,16 +310,11 @@ var OpenAIAdapter = class {
312
310
  },
313
311
  ...this.disableParallelToolCalls && {
314
312
  parallel_tool_calls: false
315
- },
316
- ...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
317
- temperature: forwardedParameters.temperature
318
313
  }
319
314
  });
320
315
  eventSource.stream(async (eventStream$) => {
321
316
  var _a, _b;
322
317
  let mode = null;
323
- let currentMessageId;
324
- let currentToolCallId;
325
318
  for await (const chunk of stream) {
326
319
  if (chunk.choices.length === 0) {
327
320
  continue;
@@ -330,52 +323,30 @@ var OpenAIAdapter = class {
330
323
  const content = chunk.choices[0].delta.content;
331
324
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
332
325
  mode = null;
333
- eventStream$.sendTextMessageEnd({
334
- messageId: currentMessageId
335
- });
326
+ eventStream$.sendTextMessageEnd();
336
327
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
337
328
  mode = null;
338
- eventStream$.sendActionExecutionEnd({
339
- actionExecutionId: currentToolCallId
340
- });
329
+ eventStream$.sendActionExecutionEnd();
341
330
  }
342
331
  if (mode === null) {
343
332
  if (toolCall == null ? void 0 : toolCall.id) {
344
333
  mode = "function";
345
- currentToolCallId = toolCall.id;
346
- eventStream$.sendActionExecutionStart({
347
- actionExecutionId: currentToolCallId,
348
- parentMessageId: chunk.id,
349
- actionName: toolCall.function.name
350
- });
334
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
351
335
  } else if (content) {
352
336
  mode = "message";
353
- currentMessageId = chunk.id;
354
- eventStream$.sendTextMessageStart({
355
- messageId: currentMessageId
356
- });
337
+ eventStream$.sendTextMessageStart(chunk.id);
357
338
  }
358
339
  }
359
340
  if (mode === "message" && content) {
360
- eventStream$.sendTextMessageContent({
361
- messageId: currentMessageId,
362
- content
363
- });
341
+ eventStream$.sendTextMessageContent(content);
364
342
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
365
- eventStream$.sendActionExecutionArgs({
366
- actionExecutionId: currentToolCallId,
367
- args: toolCall.function.arguments
368
- });
343
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
369
344
  }
370
345
  }
371
346
  if (mode === "message") {
372
- eventStream$.sendTextMessageEnd({
373
- messageId: currentMessageId
374
- });
347
+ eventStream$.sendTextMessageEnd();
375
348
  } else if (mode === "function") {
376
- eventStream$.sendActionExecutionEnd({
377
- actionExecutionId: currentToolCallId
378
- });
349
+ eventStream$.sendActionExecutionEnd();
379
350
  }
380
351
  eventStream$.complete();
381
352
  });
@@ -443,25 +414,17 @@ function isBaseMessageChunk(message) {
443
414
  __name(isBaseMessageChunk, "isBaseMessageChunk");
444
415
  function maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution) {
445
416
  if (actionExecution) {
446
- eventStream$.sendActionExecutionResult({
447
- actionExecutionId: actionExecution.id,
448
- actionName: actionExecution.name,
449
- result: "Sending a message"
450
- });
417
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, "Sending a message");
451
418
  }
452
419
  }
453
420
  __name(maybeSendActionExecutionResultIsMessage, "maybeSendActionExecutionResultIsMessage");
454
421
  async function streamLangChainResponse({ result, eventStream$, actionExecution }) {
455
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
422
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
456
423
  if (typeof result === "string") {
457
424
  if (!actionExecution) {
458
425
  eventStream$.sendTextMessage((0, import_shared2.randomId)(), result);
459
426
  } else {
460
- eventStream$.sendActionExecutionResult({
461
- actionExecutionId: actionExecution.id,
462
- actionName: actionExecution.name,
463
- result
464
- });
427
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, result);
465
428
  }
466
429
  } else if (isAIMessage(result)) {
467
430
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -469,11 +432,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
469
432
  eventStream$.sendTextMessage((0, import_shared2.randomId)(), result.content);
470
433
  }
471
434
  for (const toolCall of result.tool_calls) {
472
- eventStream$.sendActionExecution({
473
- actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
474
- actionName: toolCall.name,
475
- args: JSON.stringify(toolCall.args)
476
- });
435
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
477
436
  }
478
437
  } else if (isBaseMessageChunk(result)) {
479
438
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
@@ -482,18 +441,13 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
482
441
  }
483
442
  if ((_b = result.lc_kwargs) == null ? void 0 : _b.tool_calls) {
484
443
  for (const toolCall of (_c = result.lc_kwargs) == null ? void 0 : _c.tool_calls) {
485
- eventStream$.sendActionExecution({
486
- actionExecutionId: toolCall.id || (0, import_shared2.randomId)(),
487
- actionName: toolCall.name,
488
- args: JSON.stringify(toolCall.args)
489
- });
444
+ eventStream$.sendActionExecution(toolCall.id || (0, import_shared2.randomId)(), toolCall.name, JSON.stringify(toolCall.args));
490
445
  }
491
446
  }
492
447
  } else if (result && "getReader" in result) {
493
448
  maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
494
449
  let reader = result.getReader();
495
450
  let mode = null;
496
- let currentMessageId;
497
451
  const toolCallDetails = {
498
452
  name: null,
499
453
  id: null,
@@ -507,12 +461,9 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
507
461
  let toolCallId = void 0;
508
462
  let toolCallArgs = void 0;
509
463
  let hasToolCall = false;
510
- let content = "";
511
- if (value && value.content) {
512
- content = Array.isArray(value.content) ? ((_d = value.content[0]) == null ? void 0 : _d.text) ?? "" : value.content;
513
- }
464
+ let content = value == null ? void 0 : value.content;
514
465
  if (isAIMessageChunk(value)) {
515
- let chunk = (_e = value.tool_call_chunks) == null ? void 0 : _e[0];
466
+ let chunk = (_d = value.tool_call_chunks) == null ? void 0 : _d[0];
516
467
  toolCallArgs = chunk == null ? void 0 : chunk.args;
517
468
  hasToolCall = chunk != void 0;
518
469
  if (chunk == null ? void 0 : chunk.name)
@@ -527,22 +478,18 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
527
478
  toolCallName = toolCallDetails.name;
528
479
  toolCallId = toolCallDetails.id;
529
480
  } else if (isBaseMessageChunk(value)) {
530
- let chunk = (_g = (_f = value.additional_kwargs) == null ? void 0 : _f.tool_calls) == null ? void 0 : _g[0];
531
- toolCallName = (_h = chunk == null ? void 0 : chunk.function) == null ? void 0 : _h.name;
481
+ let chunk = (_f = (_e = value.additional_kwargs) == null ? void 0 : _e.tool_calls) == null ? void 0 : _f[0];
482
+ toolCallName = (_g = chunk == null ? void 0 : chunk.function) == null ? void 0 : _g.name;
532
483
  toolCallId = chunk == null ? void 0 : chunk.id;
533
- toolCallArgs = (_i = chunk == null ? void 0 : chunk.function) == null ? void 0 : _i.arguments;
484
+ toolCallArgs = (_h = chunk == null ? void 0 : chunk.function) == null ? void 0 : _h.arguments;
534
485
  hasToolCall = (chunk == null ? void 0 : chunk.function) != void 0;
535
486
  }
536
487
  if (mode === "message" && (toolCallId || done)) {
537
488
  mode = null;
538
- eventStream$.sendTextMessageEnd({
539
- messageId: currentMessageId
540
- });
489
+ eventStream$.sendTextMessageEnd();
541
490
  } else if (mode === "function" && (!hasToolCall || done)) {
542
491
  mode = null;
543
- eventStream$.sendActionExecutionEnd({
544
- actionExecutionId: toolCallId
545
- });
492
+ eventStream$.sendActionExecutionEnd();
546
493
  }
547
494
  if (done) {
548
495
  break;
@@ -550,40 +497,21 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
550
497
  if (mode === null) {
551
498
  if (hasToolCall && toolCallId && toolCallName) {
552
499
  mode = "function";
553
- eventStream$.sendActionExecutionStart({
554
- actionExecutionId: toolCallId,
555
- actionName: toolCallName,
556
- parentMessageId: (_j = value.lc_kwargs) == null ? void 0 : _j.id
557
- });
500
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
558
501
  } else if (content) {
559
502
  mode = "message";
560
- currentMessageId = ((_k = value.lc_kwargs) == null ? void 0 : _k.id) || (0, import_shared2.randomId)();
561
- eventStream$.sendTextMessageStart({
562
- messageId: currentMessageId
563
- });
503
+ eventStream$.sendTextMessageStart((0, import_shared2.randomId)());
564
504
  }
565
505
  }
566
506
  if (mode === "message" && content) {
567
- eventStream$.sendTextMessageContent({
568
- messageId: currentMessageId,
569
- content
570
- });
507
+ eventStream$.sendTextMessageContent(Array.isArray(content) ? ((_i = content[0]) == null ? void 0 : _i.text) ?? "" : content);
571
508
  } else if (mode === "function" && toolCallArgs) {
572
509
  if (toolCallDetails.index !== toolCallDetails.prevIndex) {
573
- eventStream$.sendActionExecutionEnd({
574
- actionExecutionId: toolCallId
575
- });
576
- eventStream$.sendActionExecutionStart({
577
- actionExecutionId: toolCallId,
578
- actionName: toolCallName,
579
- parentMessageId: (_l = value.lc_kwargs) == null ? void 0 : _l.id
580
- });
510
+ eventStream$.sendActionExecutionEnd();
511
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
581
512
  toolCallDetails.prevIndex = toolCallDetails.index;
582
513
  }
583
- eventStream$.sendActionExecutionArgs({
584
- actionExecutionId: toolCallId,
585
- args: toolCallArgs
586
- });
514
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
587
515
  }
588
516
  } catch (error) {
589
517
  console.error("Error reading from stream", error);
@@ -591,11 +519,7 @@ async function streamLangChainResponse({ result, eventStream$, actionExecution }
591
519
  }
592
520
  }
593
521
  } else if (actionExecution) {
594
- eventStream$.sendActionExecutionResult({
595
- actionExecutionId: actionExecution.id,
596
- actionName: actionExecution.name,
597
- result: encodeResult(result)
598
- });
522
+ eventStream$.sendActionExecutionResult(actionExecution.id, actionExecution.name, encodeResult(result));
599
523
  } else {
600
524
  throw new Error("Invalid return type from LangChain function.");
601
525
  }
@@ -775,33 +699,21 @@ var OpenAIAssistantAdapter = class {
775
699
  eventSource.stream(async (eventStream$) => {
776
700
  var _a, _b, _c, _d, _e, _f;
777
701
  let inFunctionCall = false;
778
- let currentMessageId;
779
- let currentToolCallId;
780
702
  for await (const chunk of stream) {
781
703
  switch (chunk.event) {
782
704
  case "thread.message.created":
783
705
  if (inFunctionCall) {
784
- eventStream$.sendActionExecutionEnd({
785
- actionExecutionId: currentToolCallId
786
- });
706
+ eventStream$.sendActionExecutionEnd();
787
707
  }
788
- currentMessageId = chunk.data.id;
789
- eventStream$.sendTextMessageStart({
790
- messageId: currentMessageId
791
- });
708
+ eventStream$.sendTextMessageStart(chunk.data.id);
792
709
  break;
793
710
  case "thread.message.delta":
794
711
  if (((_a = chunk.data.delta.content) == null ? void 0 : _a[0].type) === "text") {
795
- eventStream$.sendTextMessageContent({
796
- messageId: currentMessageId,
797
- content: (_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value
798
- });
712
+ eventStream$.sendTextMessageContent((_b = chunk.data.delta.content) == null ? void 0 : _b[0].text.value);
799
713
  }
800
714
  break;
801
715
  case "thread.message.completed":
802
- eventStream$.sendTextMessageEnd({
803
- messageId: currentMessageId
804
- });
716
+ eventStream$.sendTextMessageEnd();
805
717
  break;
806
718
  case "thread.run.step.delta":
807
719
  let toolCallId;
@@ -814,30 +726,18 @@ var OpenAIAssistantAdapter = class {
814
726
  }
815
727
  if (toolCallName && toolCallId) {
816
728
  if (inFunctionCall) {
817
- eventStream$.sendActionExecutionEnd({
818
- actionExecutionId: currentToolCallId
819
- });
729
+ eventStream$.sendActionExecutionEnd();
820
730
  }
821
731
  inFunctionCall = true;
822
- currentToolCallId = toolCallId;
823
- eventStream$.sendActionExecutionStart({
824
- actionExecutionId: currentToolCallId,
825
- parentMessageId: chunk.data.id,
826
- actionName: toolCallName
827
- });
732
+ eventStream$.sendActionExecutionStart(toolCallId, toolCallName);
828
733
  } else if (toolCallArgs) {
829
- eventStream$.sendActionExecutionArgs({
830
- actionExecutionId: currentToolCallId,
831
- args: toolCallArgs
832
- });
734
+ eventStream$.sendActionExecutionArgs(toolCallArgs);
833
735
  }
834
736
  break;
835
737
  }
836
738
  }
837
739
  if (inFunctionCall) {
838
- eventStream$.sendActionExecutionEnd({
839
- actionExecutionId: currentToolCallId
840
- });
740
+ eventStream$.sendActionExecutionEnd();
841
741
  }
842
742
  eventStream$.complete();
843
743
  });
@@ -880,7 +780,6 @@ var UnifyAdapter = class {
880
780
  apiKey: this.apiKey,
881
781
  baseURL: "https://api.unify.ai/v0/"
882
782
  });
883
- const forwardedParameters = request.forwardedParameters;
884
783
  const messages = request.messages.map(convertMessageToOpenAIMessage);
885
784
  const stream = await openai.chat.completions.create({
886
785
  model: this.model,
@@ -888,83 +787,49 @@ var UnifyAdapter = class {
888
787
  stream: true,
889
788
  ...tools.length > 0 && {
890
789
  tools
891
- },
892
- ...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
893
- temperature: forwardedParameters.temperature
894
790
  }
895
791
  });
896
792
  let model = null;
897
- let currentMessageId;
898
- let currentToolCallId;
899
793
  request.eventSource.stream(async (eventStream$) => {
900
794
  var _a, _b;
901
795
  let mode = null;
902
796
  for await (const chunk of stream) {
903
797
  if (this.start) {
904
798
  model = chunk.model;
905
- currentMessageId = (0, import_shared4.randomId)();
906
- eventStream$.sendTextMessageStart({
907
- messageId: currentMessageId
908
- });
909
- eventStream$.sendTextMessageContent({
910
- messageId: currentMessageId,
911
- content: `Model used: ${model}
912
- `
913
- });
914
- eventStream$.sendTextMessageEnd({
915
- messageId: currentMessageId
916
- });
799
+ eventStream$.sendTextMessageStart((0, import_shared4.randomId)());
800
+ eventStream$.sendTextMessageContent(`Model used: ${model}
801
+ `);
802
+ eventStream$.sendTextMessageEnd();
917
803
  this.start = false;
918
804
  }
919
805
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
920
806
  const content = chunk.choices[0].delta.content;
921
807
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
922
808
  mode = null;
923
- eventStream$.sendTextMessageEnd({
924
- messageId: currentMessageId
925
- });
809
+ eventStream$.sendTextMessageEnd();
926
810
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
927
811
  mode = null;
928
- eventStream$.sendActionExecutionEnd({
929
- actionExecutionId: currentToolCallId
930
- });
812
+ eventStream$.sendActionExecutionEnd();
931
813
  }
932
814
  if (mode === null) {
933
815
  if (toolCall == null ? void 0 : toolCall.id) {
934
816
  mode = "function";
935
- currentToolCallId = toolCall.id;
936
- eventStream$.sendActionExecutionStart({
937
- actionExecutionId: currentToolCallId,
938
- actionName: toolCall.function.name
939
- });
817
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
940
818
  } else if (content) {
941
819
  mode = "message";
942
- currentMessageId = chunk.id;
943
- eventStream$.sendTextMessageStart({
944
- messageId: currentMessageId
945
- });
820
+ eventStream$.sendTextMessageStart(chunk.id);
946
821
  }
947
822
  }
948
823
  if (mode === "message" && content) {
949
- eventStream$.sendTextMessageContent({
950
- messageId: currentMessageId,
951
- content
952
- });
824
+ eventStream$.sendTextMessageContent(content);
953
825
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
954
- eventStream$.sendActionExecutionArgs({
955
- actionExecutionId: currentToolCallId,
956
- args: toolCall.function.arguments
957
- });
826
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
958
827
  }
959
828
  }
960
829
  if (mode === "message") {
961
- eventStream$.sendTextMessageEnd({
962
- messageId: currentMessageId
963
- });
830
+ eventStream$.sendTextMessageEnd();
964
831
  } else if (mode === "function") {
965
- eventStream$.sendActionExecutionEnd({
966
- actionExecutionId: currentToolCallId
967
- });
832
+ eventStream$.sendActionExecutionEnd();
968
833
  }
969
834
  eventStream$.complete();
970
835
  });
@@ -1025,67 +890,40 @@ var GroqAdapter = class {
1025
890
  },
1026
891
  ...this.disableParallelToolCalls && {
1027
892
  parallel_tool_calls: false
1028
- },
1029
- ...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) && {
1030
- temperature: forwardedParameters.temperature
1031
893
  }
1032
894
  });
1033
895
  eventSource.stream(async (eventStream$) => {
1034
896
  var _a, _b;
1035
897
  let mode = null;
1036
- let currentMessageId;
1037
- let currentToolCallId;
1038
898
  for await (const chunk of stream) {
1039
899
  const toolCall = (_a = chunk.choices[0].delta.tool_calls) == null ? void 0 : _a[0];
1040
900
  const content = chunk.choices[0].delta.content;
1041
901
  if (mode === "message" && (toolCall == null ? void 0 : toolCall.id)) {
1042
902
  mode = null;
1043
- eventStream$.sendTextMessageEnd({
1044
- messageId: currentMessageId
1045
- });
903
+ eventStream$.sendTextMessageEnd();
1046
904
  } else if (mode === "function" && (toolCall === void 0 || (toolCall == null ? void 0 : toolCall.id))) {
1047
905
  mode = null;
1048
- eventStream$.sendActionExecutionEnd({
1049
- actionExecutionId: currentToolCallId
1050
- });
906
+ eventStream$.sendActionExecutionEnd();
1051
907
  }
1052
908
  if (mode === null) {
1053
909
  if (toolCall == null ? void 0 : toolCall.id) {
1054
910
  mode = "function";
1055
- currentToolCallId = toolCall.id;
1056
- eventStream$.sendActionExecutionStart({
1057
- actionExecutionId: currentToolCallId,
1058
- actionName: toolCall.function.name,
1059
- parentMessageId: chunk.id
1060
- });
911
+ eventStream$.sendActionExecutionStart(toolCall.id, toolCall.function.name);
1061
912
  } else if (content) {
1062
913
  mode = "message";
1063
- currentMessageId = chunk.id;
1064
- eventStream$.sendTextMessageStart({
1065
- messageId: currentMessageId
1066
- });
914
+ eventStream$.sendTextMessageStart(chunk.id);
1067
915
  }
1068
916
  }
1069
917
  if (mode === "message" && content) {
1070
- eventStream$.sendTextMessageContent({
1071
- messageId: currentMessageId,
1072
- content
1073
- });
918
+ eventStream$.sendTextMessageContent(content);
1074
919
  } else if (mode === "function" && ((_b = toolCall == null ? void 0 : toolCall.function) == null ? void 0 : _b.arguments)) {
1075
- eventStream$.sendActionExecutionArgs({
1076
- actionExecutionId: currentToolCallId,
1077
- args: toolCall.function.arguments
1078
- });
920
+ eventStream$.sendActionExecutionArgs(toolCall.function.arguments);
1079
921
  }
1080
922
  }
1081
923
  if (mode === "message") {
1082
- eventStream$.sendTextMessageEnd({
1083
- messageId: currentMessageId
1084
- });
924
+ eventStream$.sendTextMessageEnd();
1085
925
  } else if (mode === "function") {
1086
- eventStream$.sendActionExecutionEnd({
1087
- actionExecutionId: currentToolCallId
1088
- });
926
+ eventStream$.sendActionExecutionEnd();
1089
927
  }
1090
928
  eventStream$.complete();
1091
929
  });
@@ -1269,9 +1107,6 @@ var AnthropicAdapter = class {
1269
1107
  model: this.model,
1270
1108
  messages: anthropicMessages,
1271
1109
  max_tokens: (forwardedParameters == null ? void 0 : forwardedParameters.maxTokens) || 1024,
1272
- ...(forwardedParameters == null ? void 0 : forwardedParameters.temperature) ? {
1273
- temperature: forwardedParameters.temperature
1274
- } : {},
1275
1110
  ...tools.length > 0 && {
1276
1111
  tools
1277
1112
  },
@@ -1296,11 +1131,7 @@ var AnthropicAdapter = class {
1296
1131
  mode = "message";
1297
1132
  } else if (chunk.content_block.type === "tool_use") {
1298
1133
  currentToolCallId = chunk.content_block.id;
1299
- eventStream$.sendActionExecutionStart({
1300
- actionExecutionId: currentToolCallId,
1301
- actionName: chunk.content_block.name,
1302
- parentMessageId: currentMessageId
1303
- });
1134
+ eventStream$.sendActionExecutionStart(currentToolCallId, chunk.content_block.name);
1304
1135
  mode = "function";
1305
1136
  }
1306
1137
  } else if (chunk.type === "content_block_delta") {
@@ -1308,33 +1139,21 @@ var AnthropicAdapter = class {
1308
1139
  const text = filterThinkingTextBuffer.onTextChunk(chunk.delta.text);
1309
1140
  if (text.length > 0) {
1310
1141
  if (!didOutputText) {
1311
- eventStream$.sendTextMessageStart({
1312
- messageId: currentMessageId
1313
- });
1142
+ eventStream$.sendTextMessageStart(currentMessageId);
1314
1143
  didOutputText = true;
1315
1144
  }
1316
- eventStream$.sendTextMessageContent({
1317
- messageId: currentMessageId,
1318
- content: text
1319
- });
1145
+ eventStream$.sendTextMessageContent(text);
1320
1146
  }
1321
1147
  } else if (chunk.delta.type === "input_json_delta") {
1322
- eventStream$.sendActionExecutionArgs({
1323
- actionExecutionId: currentToolCallId,
1324
- args: chunk.delta.partial_json
1325
- });
1148
+ eventStream$.sendActionExecutionArgs(chunk.delta.partial_json);
1326
1149
  }
1327
1150
  } else if (chunk.type === "content_block_stop") {
1328
1151
  if (mode === "message") {
1329
1152
  if (didOutputText) {
1330
- eventStream$.sendTextMessageEnd({
1331
- messageId: currentMessageId
1332
- });
1153
+ eventStream$.sendTextMessageEnd();
1333
1154
  }
1334
1155
  } else if (mode === "function") {
1335
- eventStream$.sendActionExecutionEnd({
1336
- actionExecutionId: currentToolCallId
1337
- });
1156
+ eventStream$.sendActionExecutionEnd();
1338
1157
  }
1339
1158
  }
1340
1159
  }
@@ -1378,65 +1197,9 @@ var FilterThinkingTextBuffer = /* @__PURE__ */ __name(class FilterThinkingTextBu
1378
1197
  this.didFilterThinkingTag = false;
1379
1198
  }
1380
1199
  }, "FilterThinkingTextBuffer");
1381
-
1382
- // src/service-adapters/experimental/ollama/ollama-adapter.ts
1383
- var import_ollama = require("@langchain/community/llms/ollama");
1384
- var import_shared7 = require("@copilotkit/shared");
1385
- var DEFAULT_MODEL4 = "llama3:latest";
1386
- var ExperimentalOllamaAdapter = class {
1387
- model;
1388
- constructor(options) {
1389
- if (options == null ? void 0 : options.model) {
1390
- this.model = options.model;
1391
- } else {
1392
- this.model = DEFAULT_MODEL4;
1393
- }
1394
- }
1395
- async process(request) {
1396
- const { messages, actions, eventSource } = request;
1397
- const ollama = new import_ollama.Ollama({
1398
- model: this.model
1399
- });
1400
- const contents = messages.filter((m) => m.isTextMessage()).map((m) => m.content);
1401
- const _stream = await ollama.stream(contents);
1402
- eventSource.stream(async (eventStream$) => {
1403
- const currentMessageId = (0, import_shared7.randomId)();
1404
- eventStream$.sendTextMessageStart({
1405
- messageId: currentMessageId
1406
- });
1407
- for await (const chunkText of _stream) {
1408
- eventStream$.sendTextMessageContent({
1409
- messageId: currentMessageId,
1410
- content: chunkText
1411
- });
1412
- }
1413
- eventStream$.sendTextMessageEnd({
1414
- messageId: currentMessageId
1415
- });
1416
- eventStream$.complete();
1417
- });
1418
- return {
1419
- threadId: request.threadId || (0, import_shared7.randomId)()
1420
- };
1421
- }
1422
- };
1423
- __name(ExperimentalOllamaAdapter, "ExperimentalOllamaAdapter");
1424
-
1425
- // src/service-adapters/experimental/empty/empty-adapter.ts
1426
- var import_shared8 = require("@copilotkit/shared");
1427
- var ExperimentalEmptyAdapter = class {
1428
- async process(request) {
1429
- return {
1430
- threadId: request.threadId || (0, import_shared8.randomId)()
1431
- };
1432
- }
1433
- };
1434
- __name(ExperimentalEmptyAdapter, "ExperimentalEmptyAdapter");
1435
1200
  // Annotate the CommonJS export names for ESM import in node:
1436
1201
  0 && (module.exports = {
1437
1202
  AnthropicAdapter,
1438
- ExperimentalEmptyAdapter,
1439
- ExperimentalOllamaAdapter,
1440
1203
  GoogleGenerativeAIAdapter,
1441
1204
  GroqAdapter,
1442
1205
  LangChainAdapter,