@copilotkit/runtime 1.4.1-pre.1 → 1.4.1-pre.5

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 (54) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/__snapshots__/schema/schema.graphql +8 -0
  3. package/dist/{chunk-U3SBKRZR.mjs → chunk-IEBJELNR.mjs} +2 -2
  4. package/dist/{chunk-G5X7YZNG.mjs → chunk-KYP35WVS.mjs} +2 -2
  5. package/dist/{chunk-IJAXWREA.mjs → chunk-QM5B7BZG.mjs} +25 -5
  6. package/dist/chunk-QM5B7BZG.mjs.map +1 -0
  7. package/dist/{chunk-YLEXEC6R.mjs → chunk-WNQJ5JZV.mjs} +2 -2
  8. package/dist/{chunk-OKQVDDJ2.mjs → chunk-ZOC3UIQP.mjs} +30 -2
  9. package/dist/chunk-ZOC3UIQP.mjs.map +1 -0
  10. package/dist/{copilot-runtime-335a610d.d.ts → copilot-runtime-12e7ac40.d.ts} +2 -2
  11. package/dist/graphql/types/converted/index.d.ts +1 -1
  12. package/dist/{groq-adapter-b6c2b7ec.d.ts → groq-adapter-24abe931.d.ts} +1 -1
  13. package/dist/{index-83ee522f.d.ts → index-10b1c870.d.ts} +6 -1
  14. package/dist/index.d.ts +4 -4
  15. package/dist/index.js +52 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +5 -5
  18. package/dist/{langserve-cc06e76e.d.ts → langserve-f021ab9c.d.ts} +2 -1
  19. package/dist/lib/index.d.ts +4 -4
  20. package/dist/lib/index.js +52 -4
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/index.mjs +5 -5
  23. package/dist/lib/integrations/index.d.ts +4 -4
  24. package/dist/lib/integrations/index.js +19 -2
  25. package/dist/lib/integrations/index.js.map +1 -1
  26. package/dist/lib/integrations/index.mjs +5 -5
  27. package/dist/lib/integrations/nest/index.d.ts +3 -3
  28. package/dist/lib/integrations/nest/index.js +19 -2
  29. package/dist/lib/integrations/nest/index.js.map +1 -1
  30. package/dist/lib/integrations/nest/index.mjs +3 -3
  31. package/dist/lib/integrations/node-express/index.d.ts +3 -3
  32. package/dist/lib/integrations/node-express/index.js +19 -2
  33. package/dist/lib/integrations/node-express/index.js.map +1 -1
  34. package/dist/lib/integrations/node-express/index.mjs +3 -3
  35. package/dist/lib/integrations/node-http/index.d.ts +3 -3
  36. package/dist/lib/integrations/node-http/index.js +19 -2
  37. package/dist/lib/integrations/node-http/index.js.map +1 -1
  38. package/dist/lib/integrations/node-http/index.mjs +2 -2
  39. package/dist/service-adapters/index.d.ts +4 -4
  40. package/dist/service-adapters/index.js +29 -1
  41. package/dist/service-adapters/index.js.map +1 -1
  42. package/dist/service-adapters/index.mjs +1 -1
  43. package/package.json +4 -4
  44. package/src/graphql/inputs/action.input.ts +4 -1
  45. package/src/graphql/resolvers/copilot.resolver.ts +4 -2
  46. package/src/graphql/types/enums.ts +11 -0
  47. package/src/lib/runtime/copilot-runtime.ts +5 -1
  48. package/src/service-adapters/langchain/utils.test.ts +169 -0
  49. package/src/service-adapters/langchain/utils.ts +33 -1
  50. package/dist/chunk-IJAXWREA.mjs.map +0 -1
  51. package/dist/chunk-OKQVDDJ2.mjs.map +0 -1
  52. /package/dist/{chunk-U3SBKRZR.mjs.map → chunk-IEBJELNR.mjs.map} +0 -0
  53. /package/dist/{chunk-G5X7YZNG.mjs.map → chunk-KYP35WVS.mjs.map} +0 -0
  54. /package/dist/{chunk-YLEXEC6R.mjs.map → chunk-WNQJ5JZV.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  config,
4
4
  copilotRuntimeNextJSAppRouterEndpoint,
5
5
  copilotRuntimeNextJSPagesRouterEndpoint
6
- } from "./chunk-G5X7YZNG.mjs";
6
+ } from "./chunk-KYP35WVS.mjs";
7
7
  import {
8
8
  copilotRuntimeNestEndpoint
9
- } from "./chunk-U3SBKRZR.mjs";
9
+ } from "./chunk-IEBJELNR.mjs";
10
10
  import {
11
11
  copilotRuntimeNodeExpressEndpoint
12
- } from "./chunk-YLEXEC6R.mjs";
12
+ } from "./chunk-WNQJ5JZV.mjs";
13
13
  import {
14
14
  CopilotRuntime,
15
15
  buildSchema,
@@ -20,7 +20,7 @@ import {
20
20
  getCommonConfig,
21
21
  langGraphPlatformEndpoint,
22
22
  resolveEndpointType
23
- } from "./chunk-IJAXWREA.mjs";
23
+ } from "./chunk-QM5B7BZG.mjs";
24
24
  import {
25
25
  AnthropicAdapter,
26
26
  GoogleGenerativeAIAdapter,
@@ -30,7 +30,7 @@ import {
30
30
  OpenAIAssistantAdapter,
31
31
  RemoteChain,
32
32
  UnifyAdapter
33
- } from "./chunk-OKQVDDJ2.mjs";
33
+ } from "./chunk-ZOC3UIQP.mjs";
34
34
  import {
35
35
  GuardrailsValidationFailureResponse,
36
36
  MessageStreamInterruptedResponse,
@@ -1,4 +1,4 @@
1
- import { a as Message } from './index-83ee522f.js';
1
+ import { A as ActionInputAvailability, a as Message } from './index-10b1c870.js';
2
2
  import * as rxjs from 'rxjs';
3
3
  import { Subject, ReplaySubject } from 'rxjs';
4
4
  import { Action, Parameter } from '@copilotkit/shared';
@@ -16,6 +16,7 @@ declare class ActionInput {
16
16
  name: string;
17
17
  description: string;
18
18
  jsonSchema: string;
19
+ available?: ActionInputAvailability;
19
20
  }
20
21
 
21
22
  declare enum RuntimeEventTypes {
@@ -1,12 +1,12 @@
1
- export { h as CommonConfig, b as CopilotRequestContextProperties, a as CopilotRuntime, C as CopilotRuntimeConstructorParams, d as CreateCopilotRuntimeServerOptions, G as GraphQLContext, g as buildSchema, c as copilotKitEndpoint, e as createContext, f as flattenToolCallsNoDuplicates, i as getCommonConfig, l as langGraphPlatformEndpoint, r as resolveEndpointType } from '../copilot-runtime-335a610d.js';
2
- 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-b6c2b7ec.js';
1
+ export { h as CommonConfig, b as CopilotRequestContextProperties, a as CopilotRuntime, C as CopilotRuntimeConstructorParams, d as CreateCopilotRuntimeServerOptions, G as GraphQLContext, g as buildSchema, c as copilotKitEndpoint, e as createContext, f as flattenToolCallsNoDuplicates, i as getCommonConfig, l as langGraphPlatformEndpoint, r as resolveEndpointType } from '../copilot-runtime-12e7ac40.js';
2
+ 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';
3
3
  export { CopilotRuntimeServerInstance, config, copilotRuntimeNextJSAppRouterEndpoint, copilotRuntimeNextJSPagesRouterEndpoint } from './integrations/index.js';
4
4
  export { copilotRuntimeNodeHttpEndpoint } from './integrations/node-http/index.js';
5
5
  export { copilotRuntimeNodeExpressEndpoint } from './integrations/node-express/index.js';
6
6
  export { copilotRuntimeNestEndpoint } from './integrations/nest/index.js';
7
7
  import '@copilotkit/shared';
8
- import '../langserve-cc06e76e.js';
9
- import '../index-83ee522f.js';
8
+ import '../langserve-f021ab9c.js';
9
+ import '../index-10b1c870.js';
10
10
  import '../graphql/types/base/index.js';
11
11
  import 'rxjs';
12
12
  import 'graphql';
package/dist/lib/index.js CHANGED
@@ -44,7 +44,7 @@ var require_package = __commonJS({
44
44
  publishConfig: {
45
45
  access: "public"
46
46
  },
47
- version: "1.4.1-pre.1",
47
+ version: "1.4.1-pre.5",
48
48
  sideEffects: false,
49
49
  main: "./dist/index.js",
50
50
  module: "./dist/index.mjs",
@@ -469,6 +469,7 @@ __name(OpenAIAdapter, "OpenAIAdapter");
469
469
  // src/service-adapters/langchain/utils.ts
470
470
  var import_messages = require("@langchain/core/messages");
471
471
  var import_tools = require("@langchain/core/tools");
472
+ var import_zod = require("zod");
472
473
  var import_shared2 = require("@copilotkit/shared");
473
474
  function convertMessageToLangChainMessage(message) {
474
475
  if (message.isTextMessage()) {
@@ -498,11 +499,38 @@ function convertMessageToLangChainMessage(message) {
498
499
  }
499
500
  }
500
501
  __name(convertMessageToLangChainMessage, "convertMessageToLangChainMessage");
502
+ function convertJsonSchemaToZodSchema(jsonSchema, required) {
503
+ if (jsonSchema.type === "object") {
504
+ const spec = {};
505
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
506
+ return !required ? import_zod.z.object(spec).optional() : import_zod.z.object(spec);
507
+ }
508
+ for (const [key, value] of Object.entries(jsonSchema.properties)) {
509
+ spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
510
+ }
511
+ let schema = import_zod.z.object(spec).describe(jsonSchema.description);
512
+ return required ? schema : schema.optional();
513
+ } else if (jsonSchema.type === "string") {
514
+ let schema = import_zod.z.string().describe(jsonSchema.description);
515
+ return required ? schema : schema.optional();
516
+ } else if (jsonSchema.type === "number") {
517
+ let schema = import_zod.z.number().describe(jsonSchema.description);
518
+ return required ? schema : schema.optional();
519
+ } else if (jsonSchema.type === "boolean") {
520
+ let schema = import_zod.z.boolean().describe(jsonSchema.description);
521
+ return required ? schema : schema.optional();
522
+ } else if (jsonSchema.type === "array") {
523
+ let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
524
+ let schema = import_zod.z.array(itemSchema).describe(jsonSchema.description);
525
+ return required ? schema : schema.optional();
526
+ }
527
+ }
528
+ __name(convertJsonSchemaToZodSchema, "convertJsonSchemaToZodSchema");
501
529
  function convertActionInputToLangChainTool(actionInput) {
502
530
  return new import_tools.DynamicStructuredTool({
503
531
  name: actionInput.name,
504
532
  description: actionInput.description,
505
- schema: (0, import_shared2.convertJsonSchemaToZodSchema)(JSON.parse(actionInput.jsonSchema), true),
533
+ schema: convertJsonSchemaToZodSchema(JSON.parse(actionInput.jsonSchema), true),
506
534
  func: async () => {
507
535
  return "";
508
536
  }
@@ -1313,6 +1341,12 @@ var CopilotRequestType;
1313
1341
  CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
1314
1342
  CopilotRequestType2["Suggestion"] = "Suggestion";
1315
1343
  })(CopilotRequestType || (CopilotRequestType = {}));
1344
+ var ActionInputAvailability;
1345
+ (function(ActionInputAvailability2) {
1346
+ ActionInputAvailability2["disabled"] = "disabled";
1347
+ ActionInputAvailability2["enabled"] = "enabled";
1348
+ ActionInputAvailability2["remote"] = "remote";
1349
+ })(ActionInputAvailability || (ActionInputAvailability = {}));
1316
1350
  (0, import_type_graphql.registerEnumType)(MessageRole, {
1317
1351
  name: "MessageRole",
1318
1352
  description: "The role of the message"
@@ -1325,6 +1359,10 @@ var CopilotRequestType;
1325
1359
  name: "CopilotRequestType",
1326
1360
  description: "The type of Copilot request"
1327
1361
  });
1362
+ (0, import_type_graphql.registerEnumType)(ActionInputAvailability, {
1363
+ name: "ActionInputAvailability",
1364
+ description: "The availability of the frontend action"
1365
+ });
1328
1366
 
1329
1367
  // src/lib/runtime/remote-lg-action.ts
1330
1368
  async function execute(args) {
@@ -2502,7 +2540,10 @@ var CopilotRuntime = class {
2502
2540
  }));
2503
2541
  const actionInputs = flattenToolCallsNoDuplicates([
2504
2542
  ...serverSideActionsInput,
2505
- ...clientSideActionsInput
2543
+ ...clientSideActionsInput.filter(
2544
+ // Filter remote actions from CopilotKit core loop
2545
+ (action) => action.available !== ActionInputAvailability.remote
2546
+ )
2506
2547
  ]);
2507
2548
  await ((_a = this.onBeforeRequest) == null ? void 0 : _a.call(this, {
2508
2549
  threadId,
@@ -2881,6 +2922,7 @@ var ActionInput = class {
2881
2922
  name;
2882
2923
  description;
2883
2924
  jsonSchema;
2925
+ available;
2884
2926
  };
2885
2927
  __name(ActionInput, "ActionInput");
2886
2928
  _ts_decorate3([
@@ -2895,6 +2937,12 @@ _ts_decorate3([
2895
2937
  (0, import_type_graphql4.Field)(() => String),
2896
2938
  _ts_metadata3("design:type", String)
2897
2939
  ], ActionInput.prototype, "jsonSchema", void 0);
2940
+ _ts_decorate3([
2941
+ (0, import_type_graphql4.Field)(() => ActionInputAvailability, {
2942
+ nullable: true
2943
+ }),
2944
+ _ts_metadata3("design:type", typeof ActionInputAvailability === "undefined" ? Object : ActionInputAvailability)
2945
+ ], ActionInput.prototype, "available", void 0);
2898
2946
  ActionInput = _ts_decorate3([
2899
2947
  (0, import_type_graphql4.InputType)()
2900
2948
  ], ActionInput);
@@ -3821,7 +3869,7 @@ var CopilotResolver = class {
3821
3869
  const { eventSource, threadId = (0, import_shared10.randomId)(), runId, serverSideActions, actionInputsWithoutAgents } = await copilotRuntime.processRuntimeRequest({
3822
3870
  serviceAdapter,
3823
3871
  messages: data.messages,
3824
- actions: data.frontend.actions,
3872
+ actions: data.frontend.actions.filter((action) => action.available !== ActionInputAvailability.disabled),
3825
3873
  threadId: data.threadId,
3826
3874
  runId: data.runId,
3827
3875
  publicApiKey: void 0,