@copilotkit/runtime 0.37.0

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 (105) hide show
  1. package/.eslintrc.js +7 -0
  2. package/.turbo/turbo-build.log +70 -0
  3. package/CHANGELOG.md +1 -0
  4. package/__snapshots__/schema/schema.graphql +178 -0
  5. package/dist/chunk-2CCVVJDU.mjs +56 -0
  6. package/dist/chunk-2CCVVJDU.mjs.map +1 -0
  7. package/dist/chunk-4UA4RB4C.mjs +185 -0
  8. package/dist/chunk-4UA4RB4C.mjs.map +1 -0
  9. package/dist/chunk-5HGYI6EG.mjs +678 -0
  10. package/dist/chunk-5HGYI6EG.mjs.map +1 -0
  11. package/dist/chunk-7IFP53C6.mjs +169 -0
  12. package/dist/chunk-7IFP53C6.mjs.map +1 -0
  13. package/dist/chunk-BLTAUVRP.mjs +30 -0
  14. package/dist/chunk-BLTAUVRP.mjs.map +1 -0
  15. package/dist/chunk-NFCPM5AM.mjs +43 -0
  16. package/dist/chunk-NFCPM5AM.mjs.map +1 -0
  17. package/dist/chunk-XPAUPJMW.mjs +1051 -0
  18. package/dist/chunk-XPAUPJMW.mjs.map +1 -0
  19. package/dist/graphql/types/base/index.d.ts +6 -0
  20. package/dist/graphql/types/base/index.js +63 -0
  21. package/dist/graphql/types/base/index.js.map +1 -0
  22. package/dist/graphql/types/base/index.mjs +7 -0
  23. package/dist/graphql/types/base/index.mjs.map +1 -0
  24. package/dist/graphql/types/converted/index.d.ts +2 -0
  25. package/dist/graphql/types/converted/index.js +88 -0
  26. package/dist/graphql/types/converted/index.js.map +1 -0
  27. package/dist/graphql/types/converted/index.mjs +12 -0
  28. package/dist/graphql/types/converted/index.mjs.map +1 -0
  29. package/dist/index-aa091e3c.d.ts +49 -0
  30. package/dist/index-f0875df3.d.ts +197 -0
  31. package/dist/index.d.ts +15 -0
  32. package/dist/index.js +2171 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/index.mjs +49 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/langchain-adapter-9ce103f3.d.ts +200 -0
  37. package/dist/langserve-fd5066ee.d.ts +96 -0
  38. package/dist/lib/index.d.ts +15 -0
  39. package/dist/lib/index.js +2170 -0
  40. package/dist/lib/index.js.map +1 -0
  41. package/dist/lib/index.mjs +46 -0
  42. package/dist/lib/index.mjs.map +1 -0
  43. package/dist/lib/integrations/index.d.ts +9 -0
  44. package/dist/lib/integrations/index.js +1024 -0
  45. package/dist/lib/integrations/index.js.map +1 -0
  46. package/dist/lib/integrations/index.mjs +24 -0
  47. package/dist/lib/integrations/index.mjs.map +1 -0
  48. package/dist/lib/integrations/node-http/index.d.ts +8 -0
  49. package/dist/lib/integrations/node-http/index.js +969 -0
  50. package/dist/lib/integrations/node-http/index.js.map +1 -0
  51. package/dist/lib/integrations/node-http/index.mjs +10 -0
  52. package/dist/lib/integrations/node-http/index.mjs.map +1 -0
  53. package/dist/pages-router-b6bc6c60.d.ts +30 -0
  54. package/dist/service-adapters/index.d.ts +11 -0
  55. package/dist/service-adapters/index.js +912 -0
  56. package/dist/service-adapters/index.js.map +1 -0
  57. package/dist/service-adapters/index.mjs +18 -0
  58. package/dist/service-adapters/index.mjs.map +1 -0
  59. package/jest.config.js +5 -0
  60. package/package.json +63 -0
  61. package/scripts/generate-gql-schema.ts +13 -0
  62. package/src/graphql/inputs/action.input.ts +13 -0
  63. package/src/graphql/inputs/cloud-guardrails.input.ts +19 -0
  64. package/src/graphql/inputs/cloud.input.ts +8 -0
  65. package/src/graphql/inputs/context-property.input.ts +10 -0
  66. package/src/graphql/inputs/custom-property.input.ts +15 -0
  67. package/src/graphql/inputs/frontend.input.ts +11 -0
  68. package/src/graphql/inputs/generate-copilot-response.input.ts +22 -0
  69. package/src/graphql/inputs/message.input.ts +50 -0
  70. package/src/graphql/resolvers/copilot.resolver.ts +147 -0
  71. package/src/graphql/types/base/index.ts +10 -0
  72. package/src/graphql/types/converted/index.ts +29 -0
  73. package/src/graphql/types/copilot-response.type.ts +75 -0
  74. package/src/graphql/types/enums.ts +22 -0
  75. package/src/graphql/types/guardrails-result.type.ts +20 -0
  76. package/src/graphql/types/message-status.type.ts +40 -0
  77. package/src/graphql/types/response-status.type.ts +52 -0
  78. package/src/index.ts +2 -0
  79. package/src/lib/copilot-cloud.ts +63 -0
  80. package/src/lib/copilot-runtime.ts +261 -0
  81. package/src/lib/guardrails.ts +3 -0
  82. package/src/lib/index.ts +7 -0
  83. package/src/lib/integrations/index.ts +4 -0
  84. package/src/lib/integrations/nextjs/app-router.ts +29 -0
  85. package/src/lib/integrations/nextjs/pages-router.ts +36 -0
  86. package/src/lib/integrations/node-http/index.ts +23 -0
  87. package/src/lib/integrations/shared.ts +68 -0
  88. package/src/service-adapters/conversion.ts +47 -0
  89. package/src/service-adapters/events.ts +197 -0
  90. package/src/service-adapters/experimental/groq/groq-adapter.ts +124 -0
  91. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +75 -0
  92. package/src/service-adapters/google/google-genai-adapter.ts +149 -0
  93. package/src/service-adapters/google/utils.ts +94 -0
  94. package/src/service-adapters/index.ts +6 -0
  95. package/src/service-adapters/langchain/langchain-adapter.ts +82 -0
  96. package/src/service-adapters/langchain/langserve.ts +81 -0
  97. package/src/service-adapters/langchain/types.ts +14 -0
  98. package/src/service-adapters/langchain/utils.ts +235 -0
  99. package/src/service-adapters/openai/openai-adapter.ts +142 -0
  100. package/src/service-adapters/openai/openai-assistant-adapter.ts +260 -0
  101. package/src/service-adapters/openai/utils.ts +164 -0
  102. package/src/service-adapters/service-adapter.ts +29 -0
  103. package/tsconfig.json +11 -0
  104. package/tsup.config.ts +17 -0
  105. package/typedoc.json +4 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/integrations/index.ts","../../../src/lib/integrations/shared.ts","../../../src/graphql/resolvers/copilot.resolver.ts","../../../src/graphql/inputs/generate-copilot-response.input.ts","../../../src/graphql/inputs/message.input.ts","../../../src/graphql/types/enums.ts","../../../src/graphql/types/base/index.ts","../../../src/graphql/inputs/frontend.input.ts","../../../src/graphql/inputs/action.input.ts","../../../src/graphql/inputs/cloud.input.ts","../../../src/graphql/inputs/cloud-guardrails.input.ts","../../../src/graphql/types/copilot-response.type.ts","../../../src/graphql/types/message-status.type.ts","../../../src/graphql/types/response-status.type.ts","../../../src/service-adapters/events.ts","../../../src/lib/integrations/nextjs/app-router.ts","../../../src/lib/integrations/nextjs/pages-router.ts","../../../src/lib/integrations/node-http/index.ts"],"sourcesContent":["export * from \"./shared\";\nexport * from \"./nextjs/app-router\";\nexport * from \"./nextjs/pages-router\";\nexport * from \"./node-http\";\n","import { YogaInitialContext } from \"graphql-yoga\";\nimport { GuardrailsOptions } from \"../guardrails\";\nimport { buildSchemaSync } from \"type-graphql\";\nimport { CopilotResolver } from \"../../graphql/resolvers/copilot.resolver\";\nimport { useDeferStream } from \"@graphql-yoga/plugin-defer-stream\";\nimport { CopilotRuntime } from \"../copilot-runtime\";\nimport { CopilotServiceAdapter } from \"../../service-adapters\";\n\ntype AnyPrimitive = string | boolean | number | null;\nexport type CopilotRequestContextProperties = Record<\n string,\n AnyPrimitive | Record<string, AnyPrimitive>\n>;\n\ntype CopilotKitContext = {\n runtime: CopilotRuntime;\n serviceAdapter: CopilotServiceAdapter;\n properties: CopilotRequestContextProperties;\n};\n\nexport type GraphQLContext = YogaInitialContext & {\n _copilotkit: CopilotKitContext;\n};\n\nexport interface CreateCopilotRuntimeServerOptions {\n runtime: CopilotRuntime;\n serviceAdapter: CopilotServiceAdapter;\n guardrails?: GuardrailsOptions;\n}\n\nexport async function createContext(\n initialContext: YogaInitialContext,\n copilotKitContext: CopilotKitContext,\n): Promise<Partial<GraphQLContext>> {\n const ctx: GraphQLContext = {\n ...initialContext,\n _copilotkit: {\n ...copilotKitContext,\n },\n };\n\n return ctx;\n}\n\nexport function buildSchema(\n options: {\n emitSchemaFile?: string;\n } = {},\n) {\n const schema = buildSchemaSync({\n resolvers: [CopilotResolver],\n emitSchemaFile: options.emitSchemaFile,\n });\n return schema;\n}\n\nexport function getCommonConfig(options?: CreateCopilotRuntimeServerOptions) {\n return {\n schema: buildSchema(),\n plugins: [useDeferStream()],\n context: (ctx: YogaInitialContext): Promise<Partial<GraphQLContext>> =>\n createContext(ctx, {\n runtime: options.runtime,\n serviceAdapter: options.serviceAdapter,\n properties: {},\n }),\n };\n}\n","import { Arg, Ctx, Mutation, Query, Resolver } from \"type-graphql\";\nimport { Subject, firstValueFrom, shareReplay, skipWhile, takeWhile } from \"rxjs\";\nimport { GenerateCopilotResponseInput } from \"../inputs/generate-copilot-response.input\";\nimport { CopilotResponse } from \"../types/copilot-response.type\";\nimport { MessageRole } from \"../types/enums\";\nimport { Repeater } from \"graphql-yoga\";\nimport type { CopilotRequestContextProperties, GraphQLContext } from \"../../lib/integrations\";\nimport { nanoid } from \"nanoid\";\nimport { RuntimeEvent, RuntimeEventTypes } from \"../../service-adapters/events\";\nimport { MessageStatusUnion, SuccessMessageStatus } from \"../types/message-status.type\";\nimport { ResponseStatusUnion, SuccessResponseStatus } from \"../types/response-status.type\";\nimport { GraphQLJSONObject } from \"graphql-scalars\";\n\n@Resolver(() => CopilotResponse)\nexport class CopilotResolver {\n @Query(() => String)\n async hello() {\n return \"Hello World\";\n }\n\n @Mutation(() => CopilotResponse)\n async generateCopilotResponse(\n @Ctx() ctx: GraphQLContext,\n @Arg(\"data\") data: GenerateCopilotResponseInput,\n @Arg(\"properties\", () => GraphQLJSONObject, { nullable: true })\n properties?: CopilotRequestContextProperties,\n ) {\n if (properties) {\n ctx._copilotkit.properties = { ...ctx._copilotkit.properties, ...properties };\n }\n const copilotRuntime = ctx._copilotkit.runtime;\n const serviceAdapter = ctx._copilotkit.serviceAdapter;\n const responseStatus = new Subject<typeof ResponseStatusUnion>();\n\n const {\n eventSource,\n threadId = nanoid(),\n runId,\n } = await copilotRuntime.process({\n serviceAdapter,\n messages: data.messages,\n actions: data.frontend.actions,\n threadId: data.threadId,\n runId: data.runId,\n publicApiKey: undefined,\n });\n\n const response = {\n threadId,\n runId,\n status: firstValueFrom(responseStatus),\n messages: new Repeater(async (pushMessage, stopStreamingMessages) => {\n // run and process the event stream\n const eventStream = eventSource.process(copilotRuntime.actions).pipe(\n // shareReplay() ensures that later subscribers will see the whole stream instead of\n // just the events that were emitted after the subscriber was added.\n shareReplay(),\n );\n eventStream.subscribe({\n next: async (event) => {\n switch (event.type) {\n ////////////////////////////////\n // TextMessageStart\n ////////////////////////////////\n case RuntimeEventTypes.TextMessageStart:\n // create a sub stream that contains the message content\n const textMessageContentStream = eventStream.pipe(\n // skip until this message start event\n skipWhile((e) => e !== event),\n // take until the message end event\n takeWhile((e) => e.type != RuntimeEventTypes.TextMessageEnd),\n );\n\n // signal when we are done streaming\n const streamingTextStatus = new Subject<typeof MessageStatusUnion>();\n\n // push the new message\n pushMessage({\n id: nanoid(),\n status: firstValueFrom(streamingTextStatus),\n createdAt: new Date(),\n role: MessageRole.assistant,\n content: new Repeater(async (pushTextChunk, stopStreamingText) => {\n // push the message content\n await textMessageContentStream.forEach(async (e: RuntimeEvent) => {\n if (e.type == RuntimeEventTypes.TextMessageContent) {\n await pushTextChunk(e.content);\n }\n });\n stopStreamingText();\n streamingTextStatus.next(new SuccessMessageStatus());\n }),\n });\n break;\n ////////////////////////////////\n // ActionExecutionStart\n ////////////////////////////////\n case RuntimeEventTypes.ActionExecutionStart:\n const actionExecutionArgumentStream = eventStream.pipe(\n skipWhile((e) => e !== event),\n takeWhile((e) => e.type != RuntimeEventTypes.ActionExecutionEnd),\n );\n const streamingArgumentsStatus = new Subject<typeof MessageStatusUnion>();\n pushMessage({\n id: event.actionExecutionId,\n status: firstValueFrom(streamingArgumentsStatus),\n createdAt: new Date(),\n name: event.actionName,\n scope: event.scope!,\n arguments: new Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {\n await actionExecutionArgumentStream.forEach(async (e: RuntimeEvent) => {\n if (e.type == RuntimeEventTypes.ActionExecutionArgs) {\n await pushArgumentsChunk(e.args);\n }\n });\n stopStreamingArguments();\n streamingArgumentsStatus.next(new SuccessMessageStatus());\n }),\n });\n break;\n ////////////////////////////////\n // ActionExecutionResult\n ////////////////////////////////\n case RuntimeEventTypes.ActionExecutionResult:\n pushMessage({\n id: nanoid(),\n status: new SuccessMessageStatus(),\n createdAt: new Date(),\n actionExecutionId: event.actionExecutionId,\n actionName: event.actionName,\n result: event.result,\n });\n break;\n }\n },\n error: (err) => console.error(\"Error in event source\", err),\n complete: () => {\n responseStatus.next(new SuccessResponseStatus());\n stopStreamingMessages();\n },\n });\n }),\n };\n\n return response;\n }\n}\n","import { Field, InputType } from \"type-graphql\";\nimport { MessageInput } from \"./message.input\";\nimport { FrontendInput } from \"./frontend.input\";\nimport { CloudInput } from \"./cloud.input\";\n\n@InputType()\nexport class GenerateCopilotResponseInput {\n @Field(() => String, { nullable: true })\n threadId?: string;\n\n @Field(() => String, { nullable: true })\n runId?: string;\n\n @Field(() => [MessageInput])\n messages: MessageInput[];\n\n @Field(() => FrontendInput)\n frontend: FrontendInput;\n\n @Field(() => CloudInput, { nullable: true })\n cloud?: CloudInput;\n}\n","import { Field, InputType } from \"type-graphql\";\nimport { MessageRole, ActionExecutionScope } from \"../types/enums\";\nimport { BaseMessage } from \"../types/base\";\n\n// GraphQL does not support union types in inputs, so we need to use\n// optional fields for the different subtypes.\n@InputType()\nexport class MessageInput extends BaseMessage {\n @Field(() => TextMessageInput, { nullable: true })\n textMessage?: TextMessageInput;\n\n @Field(() => ActionExecutionMessageInput, { nullable: true })\n actionExecutionMessage?: ActionExecutionMessageInput;\n\n @Field(() => ResultMessageInput, { nullable: true })\n resultMessage?: ResultMessageInput;\n}\n\n@InputType()\nexport class TextMessageInput {\n @Field(() => String)\n content: string;\n\n @Field(() => MessageRole)\n role: MessageRole;\n}\n\n@InputType()\nexport class ActionExecutionMessageInput {\n @Field(() => String)\n name: string;\n\n @Field(() => String)\n arguments: string;\n\n @Field(() => ActionExecutionScope)\n scope: ActionExecutionScope;\n}\n\n@InputType()\nexport class ResultMessageInput {\n @Field(() => String)\n actionExecutionId: string;\n\n @Field(() => String)\n actionName: string;\n\n @Field(() => String)\n result: string;\n}\n","import { registerEnumType } from \"type-graphql\";\n\nexport enum MessageRole {\n user = \"user\",\n assistant = \"assistant\",\n system = \"system\",\n}\n\nexport enum ActionExecutionScope {\n server = \"server\",\n client = \"client\",\n}\n\nregisterEnumType(MessageRole, {\n name: \"MessageRole\",\n description: \"The role of the message\",\n});\n\nregisterEnumType(ActionExecutionScope, {\n name: \"ActionExecutionScope\",\n description: \"The scope of the action\",\n});\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class BaseMessage {\n @Field(() => String)\n id: string;\n\n @Field(() => Date)\n createdAt: Date;\n}\n","import { Field, InputType } from \"type-graphql\";\nimport { ActionInput } from \"./action.input\";\n\n@InputType()\nexport class FrontendInput {\n @Field(() => String, { nullable: true })\n toDeprecate_fullContext?: string;\n\n @Field(() => [ActionInput])\n actions: ActionInput[];\n}\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class ActionInput {\n @Field(() => String)\n name: string;\n\n @Field(() => String)\n description: string;\n\n @Field(() => String)\n jsonSchema: string;\n}\n","import { Field, InputType } from \"type-graphql\";\nimport { GuardrailsInput } from \"./cloud-guardrails.input\";\n\n@InputType()\nexport class CloudInput {\n @Field(() => GuardrailsInput)\n guardrails: GuardrailsInput;\n}\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class GuardrailsRuleInput {\n @Field(() => String)\n id: string;\n\n @Field(() => [String], { nullable: true })\n allowList?: string[] = [];\n\n @Field(() => [String], { nullable: true })\n denyList?: string[] = [];\n}\n\n@InputType()\nexport class GuardrailsInput {\n @Field(() => [GuardrailsRuleInput], { nullable: true })\n inputValidationRules?: GuardrailsRuleInput[] = [];\n}\n","import { Field, InterfaceType, ObjectType } from \"type-graphql\";\nimport { MessageRole, ActionExecutionScope } from \"./enums\";\nimport { MessageStatusUnion } from \"./message-status.type\";\nimport { ResponseStatusUnion } from \"./response-status.type\";\n\n@InterfaceType({\n resolveType(value) {\n if (value.hasOwnProperty(\"content\")) {\n return TextMessageOutput;\n } else if (value.hasOwnProperty(\"name\")) {\n return ActionExecutionMessageOutput;\n } else if (value.hasOwnProperty(\"result\")) {\n return ResultMessageOutput;\n }\n return undefined;\n },\n})\nabstract class BaseMessageOutput {\n @Field(() => String)\n id: string;\n\n @Field(() => Date)\n createdAt: Date;\n\n @Field(() => MessageStatusUnion)\n status: typeof MessageStatusUnion;\n}\n\n@ObjectType({ implements: BaseMessageOutput })\nexport class TextMessageOutput {\n @Field(() => MessageRole)\n role: MessageRole;\n\n @Field(() => [String])\n content: string[];\n}\n\n@ObjectType({ implements: BaseMessageOutput })\nexport class ActionExecutionMessageOutput {\n @Field(() => String)\n name: string;\n\n @Field(() => ActionExecutionScope)\n scope: ActionExecutionScope;\n\n @Field(() => [String])\n arguments: string[];\n}\n\n@ObjectType({ implements: BaseMessageOutput })\nexport class ResultMessageOutput {\n @Field(() => String)\n actionExecutionId: string;\n\n @Field(() => String)\n actionName: string;\n\n @Field(() => String)\n result: string;\n}\n\n@ObjectType()\nexport class CopilotResponse {\n @Field(() => String)\n threadId!: string;\n\n @Field(() => ResponseStatusUnion)\n status: typeof ResponseStatusUnion;\n\n @Field({ nullable: true })\n runId?: string;\n\n @Field(() => [BaseMessageOutput])\n messages: (typeof BaseMessageOutput)[];\n}\n","import { Field, ObjectType, createUnionType, registerEnumType } from \"type-graphql\";\n\nexport enum MessageStatusCode {\n Pending = \"pending\",\n Success = \"success\",\n Failed = \"failed\",\n}\n\nregisterEnumType(MessageStatusCode, {\n name: \"MessageStatusCode\",\n});\n\n@ObjectType()\nclass BaseMessageStatus {\n @Field(() => MessageStatusCode)\n code: MessageStatusCode;\n}\n\n@ObjectType()\nexport class PendingMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Pending;\n}\n\n@ObjectType()\nexport class SuccessMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Success;\n}\n\n@ObjectType()\nexport class FailedMessageStatus extends BaseMessageStatus {\n code: MessageStatusCode = MessageStatusCode.Failed;\n\n @Field(() => String)\n reason: string;\n}\n\nexport const MessageStatusUnion = createUnionType({\n name: \"MessageStatus\",\n types: () => [PendingMessageStatus, SuccessMessageStatus, FailedMessageStatus] as const,\n});\n","import { Field, InterfaceType, ObjectType, createUnionType, registerEnumType } from \"type-graphql\";\n\nexport enum ResponseStatusCode {\n Pending = \"pending\",\n Success = \"success\",\n Failed = \"failed\",\n}\n\nregisterEnumType(ResponseStatusCode, {\n name: \"ResponseStatusCode\",\n});\n\n@InterfaceType({\n resolveType(value) {\n if (value.code === ResponseStatusCode.Success) {\n return SuccessResponseStatus;\n } else if (value.code === ResponseStatusCode.Failed) {\n return FailedResponseStatus;\n } else if (value.code === ResponseStatusCode.Pending) {\n return PendingResponseStatus;\n }\n return undefined;\n },\n})\n@ObjectType()\nabstract class BaseResponseStatus {\n @Field(() => ResponseStatusCode)\n code: ResponseStatusCode;\n}\n\n@ObjectType({ implements: BaseResponseStatus })\nexport class PendingResponseStatus extends BaseResponseStatus {\n code: ResponseStatusCode = ResponseStatusCode.Pending;\n}\n\n@ObjectType({ implements: BaseResponseStatus })\nexport class SuccessResponseStatus extends BaseResponseStatus {\n code: ResponseStatusCode = ResponseStatusCode.Success;\n}\n\n@ObjectType({ implements: BaseResponseStatus })\nexport class FailedResponseStatus extends BaseResponseStatus {\n code: ResponseStatusCode = ResponseStatusCode.Failed;\n\n @Field(() => String)\n reason: string;\n}\n\nexport const ResponseStatusUnion = createUnionType({\n name: \"ResponseStatus\",\n types: () => [PendingResponseStatus, SuccessResponseStatus, FailedResponseStatus] as const,\n});\n","import { Action } from \"@copilotkit/shared\";\nimport { of, concat, map, scan, concatMap, ReplaySubject } from \"rxjs\";\nimport { streamLangChainResponse } from \"./langchain/utils\";\n\nexport enum RuntimeEventTypes {\n TextMessageStart = \"TextMessageStart\",\n TextMessageContent = \"TextMessageContent\",\n TextMessageEnd = \"TextMessageEnd\",\n ActionExecutionStart = \"ActionExecutionStart\",\n ActionExecutionArgs = \"ActionExecutionArgs\",\n ActionExecutionEnd = \"ActionExecutionEnd\",\n ActionExecutionResult = \"ActionExecutionResult\",\n}\n\ntype FunctionCallScope = \"client\" | \"server\";\n\nexport type RuntimeEvent =\n | { type: RuntimeEventTypes.TextMessageStart; messageId: string }\n | {\n type: RuntimeEventTypes.TextMessageContent;\n content: string;\n }\n | { type: RuntimeEventTypes.TextMessageEnd }\n | {\n type: RuntimeEventTypes.ActionExecutionStart;\n actionExecutionId: string;\n actionName: string;\n scope?: FunctionCallScope;\n }\n | { type: RuntimeEventTypes.ActionExecutionArgs; args: string }\n | { type: RuntimeEventTypes.ActionExecutionEnd }\n | {\n type: RuntimeEventTypes.ActionExecutionResult;\n actionName: string;\n actionExecutionId: string;\n result: string;\n };\n\ninterface RuntimeEventWithState {\n event: RuntimeEvent | null;\n callActionServerSide: boolean;\n action: Action<any> | null;\n actionExecutionId: string | null;\n args: string;\n}\n\ntype EventSourceCallback = (eventStream$: RuntimeEventSubject) => Promise<void>;\n\nexport class RuntimeEventSubject extends ReplaySubject<RuntimeEvent> {\n constructor() {\n super();\n }\n\n sendTextMessageStart(messageId: string) {\n this.next({ type: RuntimeEventTypes.TextMessageStart, messageId });\n }\n\n sendTextMessageContent(content: string) {\n this.next({ type: RuntimeEventTypes.TextMessageContent, content });\n }\n\n sendTextMessageEnd() {\n this.next({ type: RuntimeEventTypes.TextMessageEnd });\n }\n\n sendTextMessage(messageId: string, content: string) {\n this.sendTextMessageStart(messageId);\n this.sendTextMessageContent(content);\n this.sendTextMessageEnd();\n }\n\n sendActionExecutionStart(actionExecutionId: string, actionName: string) {\n this.next({\n type: RuntimeEventTypes.ActionExecutionStart,\n actionExecutionId,\n actionName,\n });\n }\n\n sendActionExecutionArgs(args: string) {\n this.next({ type: RuntimeEventTypes.ActionExecutionArgs, args });\n }\n\n sendActionExecutionEnd() {\n this.next({ type: RuntimeEventTypes.ActionExecutionEnd });\n }\n\n sendActionExecution(actionExecutionId: string, toolName: string, args: string) {\n this.sendActionExecutionStart(actionExecutionId, toolName);\n this.sendActionExecutionArgs(args);\n this.sendActionExecutionEnd();\n }\n\n sendActionExecutionResult(actionExecutionId: string, actionName: string, result: string) {\n this.next({\n type: RuntimeEventTypes.ActionExecutionResult,\n actionName,\n actionExecutionId,\n result,\n });\n }\n}\n\nexport class RuntimeEventSource {\n private eventStream$ = new RuntimeEventSubject();\n private callback!: EventSourceCallback;\n\n async stream(callback: EventSourceCallback): Promise<void> {\n this.callback = callback;\n }\n\n process(serversideActions: Action<any>[]) {\n this.callback(this.eventStream$).catch((error) => {\n console.error(\"Error in event source callback\", error);\n });\n return this.eventStream$.pipe(\n // mark tools for server side execution\n map((event) => {\n if (event.type === RuntimeEventTypes.ActionExecutionStart) {\n event.scope = serversideActions.find((action) => action.name === event.actionName)\n ? \"server\"\n : \"client\";\n }\n return event;\n }),\n // track state\n scan(\n (acc, event) => {\n if (event.type === RuntimeEventTypes.ActionExecutionStart) {\n acc.callActionServerSide = event.scope === \"server\";\n acc.args = \"\";\n acc.actionExecutionId = event.actionExecutionId;\n if (acc.callActionServerSide) {\n acc.action = serversideActions.find((action) => action.name === event.actionName);\n }\n } else if (event.type === RuntimeEventTypes.ActionExecutionArgs) {\n acc.args += event.args;\n }\n\n acc.event = event;\n return acc;\n },\n {\n event: null,\n callActionServerSide: false,\n args: \"\",\n actionExecutionId: null,\n action: null,\n } as RuntimeEventWithState,\n ),\n concatMap((eventWithState) => {\n if (\n eventWithState.event!.type === RuntimeEventTypes.ActionExecutionEnd &&\n eventWithState.callActionServerSide\n ) {\n const toolCallEventStream$ = new RuntimeEventSubject();\n executeAction(\n toolCallEventStream$,\n eventWithState.action!,\n eventWithState.args,\n eventWithState.actionExecutionId,\n ).catch((error) => {\n console.error(error);\n });\n return concat(of(eventWithState.event!), toolCallEventStream$);\n } else {\n return of(eventWithState.event!);\n }\n }),\n );\n }\n}\n\nasync function executeAction(\n eventStream$: RuntimeEventSubject,\n action: Action<any>,\n actionArguments: string,\n actionExecutionId: string,\n) {\n // Prepare arguments for function calling\n let args: Record<string, any>[] = [];\n if (actionArguments) {\n args = JSON.parse(actionArguments);\n }\n\n // call the function\n const result = await action.handler(args);\n\n await streamLangChainResponse({\n result,\n eventStream$,\n actionExecution: {\n name: action.name,\n id: actionExecutionId,\n },\n });\n}\n","import { createYoga } from \"graphql-yoga\";\nimport { getCommonConfig } from \"../shared\";\nimport { CopilotRuntime } from \"../../copilot-runtime\";\nimport { CopilotServiceAdapter } from \"../../../service-adapters\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint({\n runtime,\n endpoint,\n serviceAdapter,\n}: {\n runtime: CopilotRuntime;\n serviceAdapter: CopilotServiceAdapter;\n endpoint: string;\n}) {\n const commonConfig = getCommonConfig({ runtime, serviceAdapter });\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: endpoint,\n fetchAPI: { Response: globalThis.Response },\n });\n\n return {\n handleRequest: yoga,\n GET: yoga,\n POST: yoga,\n OPTIONS: yoga,\n };\n}\n","import { YogaServerInstance, createYoga } from \"graphql-yoga\";\nimport { GraphQLContext, getCommonConfig } from \"../shared\";\nimport { CopilotRuntime } from \"../../copilot-runtime\";\nimport { CopilotServiceAdapter } from \"../../../service-adapters\";\n\nexport const config = {\n api: {\n bodyParser: false,\n },\n};\n\nexport type CopilotRuntimeServerInstance<T> = YogaServerInstance<T, Partial<GraphQLContext>>;\n\n// Theis import is needed to fix the type error\n// Fix is currently in TypeScript 5.5 beta, waiting for stable version\n// https://github.com/microsoft/TypeScript/issues/42873#issuecomment-2066874644\nexport type {} from \"@whatwg-node/server\";\n\nexport function copilotRuntimeNextJSPagesRouterEndpoint({\n runtime,\n endpoint,\n serviceAdapter,\n}: {\n runtime: CopilotRuntime;\n serviceAdapter: CopilotServiceAdapter;\n endpoint: string;\n}): CopilotRuntimeServerInstance<GraphQLContext> {\n const commonConfig = getCommonConfig({ runtime, serviceAdapter });\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: endpoint,\n });\n\n return yoga;\n}\n","import { createYoga } from \"graphql-yoga\";\nimport { getCommonConfig } from \"../shared\";\nimport { CopilotRuntime } from \"../../copilot-runtime\";\nimport { CopilotServiceAdapter } from \"../../../service-adapters\";\n\nexport function copilotRuntimeNodeHttpEndpoint({\n runtime,\n endpoint,\n serviceAdapter,\n}: {\n runtime: CopilotRuntime;\n serviceAdapter: CopilotServiceAdapter;\n endpoint: string;\n}) {\n const commonConfig = getCommonConfig({ runtime, serviceAdapter });\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: endpoint,\n });\n\n return yoga;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACEA,IAAAA,wBAAgC;;;ACFhC,IAAAC,wBAAoD;AACpD,IAAAC,eAA2E;;;ACD3E,IAAAC,uBAAiC;;;ACAjC,IAAAC,uBAAiC;;;ACAjC,0BAAiC;;UAErBC,cAAAA;;;;GAAAA,gBAAAA,cAAAA,CAAAA,EAAAA;;UAMAC,uBAAAA;;;GAAAA,yBAAAA,uBAAAA,CAAAA,EAAAA;IAKZC,sCAAiBF,aAAa;EAC5BG,MAAM;EACNC,aAAa;AACf,CAAA;IAEAF,sCAAiBD,sBAAsB;EACrCE,MAAM;EACNC,aAAa;AACf,CAAA;;;ACrBA,IAAAC,uBAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMC,cAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,4BAAM,MAAMC,MAAAA;;GADFJ,YAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,4BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,YAAAA,WAAAA,aAAAA,MAAAA;AAAAA,cAAAA,aAAAA;MADZM,gCAAAA;GACYN,WAAAA;;;;;;;;;;;;;;;;;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A,SAAOJ;AACT;AAVgBF;AAYT,SAASO,gBAAgBN,SAA2C;AACzE,SAAO;IACLC,QAAQF,YAAAA;IACRQ,SAAS;UAACC,2CAAAA;;IACVC,SAAS,CAACZ,QACRH,cAAcG,KAAK;MACjBa,SAASV,QAAQU;MACjBC,gBAAgBX,QAAQW;MACxBC,YAAY,CAAC;IACf,CAAA;EACJ;AACF;AAXgBN;;;AcxDhB,IAAAO,uBAA2B;AAKpB,SAASC,sCAAsC,EACpDC,SACAC,UACAC,eAAc,GAKf;AACC,QAAMC,eAAeC,gBAAgB;IAAEJ;IAASE;EAAe,CAAA;AAE/D,QAAMG,WAAOC,iCAAW;IACtB,GAAGH;IACHI,iBAAiBN;IACjBO,UAAU;MAAEC,UAAUC,WAAWD;IAAS;EAC5C,CAAA;AAEA,SAAO;IACLE,eAAeN;IACfO,KAAKP;IACLQ,MAAMR;IACNS,SAAST;EACX;AACF;AAvBgBN;;;ACLhB,IAAAgB,uBAA+C;AAKxC,IAAMC,SAAS;EACpBC,KAAK;IACHC,YAAY;EACd;AACF;AASO,SAASC,wCAAwC,EACtDC,SACAC,UACAC,eAAc,GAKf;AACC,QAAMC,eAAeC,gBAAgB;IAAEJ;IAASE;EAAe,CAAA;AAE/D,QAAMG,WAAOC,iCAAW;IACtB,GAAGH;IACHI,iBAAiBN;EACnB,CAAA;AAEA,SAAOI;AACT;AAjBgBN;;;AClBhB,IAAAS,uBAA2B;AAKpB,SAASC,+BAA+B,EAC7CC,SACAC,UACAC,eAAc,GAKf;AACC,QAAMC,eAAeC,gBAAgB;IAAEJ;IAASE;EAAe,CAAA;AAE/D,QAAMG,WAAOC,iCAAW;IACtB,GAAGH;IACHI,iBAAiBN;EACnB,CAAA;AAEA,SAAOI;AACT;AAjBgBN;","names":["import_type_graphql","import_type_graphql","import_rxjs","import_type_graphql","import_type_graphql","MessageRole","ActionExecutionScope","registerEnumType","name","description","import_type_graphql","BaseMessage","id","createdAt","Field","String","Date","InputType","MessageInput","BaseMessage","textMessage","actionExecutionMessage","resultMessage","Field","TextMessageInput","nullable","ActionExecutionMessageInput","ResultMessageInput","InputType","content","role","String","MessageRole","name","arguments","scope","ActionExecutionScope","actionExecutionId","actionName","result","import_type_graphql","import_type_graphql","ActionInput","name","description","jsonSchema","Field","String","InputType","FrontendInput","toDeprecate_fullContext","actions","Field","String","nullable","ActionInput","InputType","import_type_graphql","import_type_graphql","GuardrailsRuleInput","id","allowList","denyList","Field","String","nullable","InputType","GuardrailsInput","inputValidationRules","CloudInput","guardrails","Field","GuardrailsInput","InputType","GenerateCopilotResponseInput","threadId","runId","messages","frontend","cloud","Field","String","nullable","MessageInput","FrontendInput","CloudInput","InputType","import_type_graphql","import_type_graphql","MessageStatusCode","registerEnumType","name","BaseMessageStatus","code","Field","ObjectType","PendingMessageStatus","SuccessMessageStatus","FailedMessageStatus","reason","String","MessageStatusUnion","createUnionType","types","import_type_graphql","ResponseStatusCode","registerEnumType","name","BaseResponseStatus","code","Field","InterfaceType","resolveType","value","SuccessResponseStatus","FailedResponseStatus","PendingResponseStatus","undefined","ObjectType","implements","reason","String","ResponseStatusUnion","createUnionType","types","BaseMessageOutput","id","createdAt","status","Field","String","Date","MessageStatusUnion","InterfaceType","resolveType","value","hasOwnProperty","TextMessageOutput","ActionExecutionMessageOutput","ResultMessageOutput","undefined","role","content","MessageRole","ObjectType","implements","name","scope","arguments","ActionExecutionScope","actionExecutionId","actionName","result","CopilotResponse","threadId","runId","messages","ResponseStatusUnion","nullable","RuntimeEventTypes","CopilotResolver","hello","generateCopilotResponse","ctx","data","properties","_copilotkit","copilotRuntime","runtime","serviceAdapter","responseStatus","Subject","eventSource","threadId","nanoid","runId","process","messages","actions","frontend","publicApiKey","undefined","response","status","firstValueFrom","Repeater","pushMessage","stopStreamingMessages","eventStream","pipe","shareReplay","subscribe","next","event","type","RuntimeEventTypes","TextMessageStart","textMessageContentStream","skipWhile","e","takeWhile","TextMessageEnd","streamingTextStatus","id","createdAt","Date","role","MessageRole","assistant","content","pushTextChunk","stopStreamingText","forEach","TextMessageContent","SuccessMessageStatus","ActionExecutionStart","actionExecutionArgumentStream","ActionExecutionEnd","streamingArgumentsStatus","actionExecutionId","name","actionName","scope","arguments","pushArgumentsChunk","stopStreamingArguments","ActionExecutionArgs","args","ActionExecutionResult","result","error","err","console","complete","SuccessResponseStatus","Query","String","Mutation","CopilotResponse","Ctx","Arg","GraphQLJSONObject","nullable","Resolver","createContext","initialContext","copilotKitContext","ctx","_copilotkit","buildSchema","options","schema","buildSchemaSync","resolvers","CopilotResolver","emitSchemaFile","getCommonConfig","plugins","useDeferStream","context","runtime","serviceAdapter","properties","import_graphql_yoga","copilotRuntimeNextJSAppRouterEndpoint","runtime","endpoint","serviceAdapter","commonConfig","getCommonConfig","yoga","createYoga","graphqlEndpoint","fetchAPI","Response","globalThis","handleRequest","GET","POST","OPTIONS","import_graphql_yoga","config","api","bodyParser","copilotRuntimeNextJSPagesRouterEndpoint","runtime","endpoint","serviceAdapter","commonConfig","getCommonConfig","yoga","createYoga","graphqlEndpoint","import_graphql_yoga","copilotRuntimeNodeHttpEndpoint","runtime","endpoint","serviceAdapter","commonConfig","getCommonConfig","yoga","createYoga","graphqlEndpoint"]}
@@ -0,0 +1,24 @@
1
+ import {
2
+ config,
3
+ copilotRuntimeNextJSAppRouterEndpoint,
4
+ copilotRuntimeNextJSPagesRouterEndpoint
5
+ } from "../../chunk-2CCVVJDU.mjs";
6
+ import {
7
+ buildSchema,
8
+ copilotRuntimeNodeHttpEndpoint,
9
+ createContext,
10
+ getCommonConfig
11
+ } from "../../chunk-XPAUPJMW.mjs";
12
+ import "../../chunk-7IFP53C6.mjs";
13
+ import "../../chunk-BLTAUVRP.mjs";
14
+ import "../../chunk-NFCPM5AM.mjs";
15
+ export {
16
+ buildSchema,
17
+ config,
18
+ copilotRuntimeNextJSAppRouterEndpoint,
19
+ copilotRuntimeNextJSPagesRouterEndpoint,
20
+ copilotRuntimeNodeHttpEndpoint,
21
+ createContext,
22
+ getCommonConfig
23
+ };
24
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ import 'graphql-yoga';
2
+ export { l as copilotRuntimeNodeHttpEndpoint } from '../../../index-f0875df3.js';
3
+ import '../../../langserve-fd5066ee.js';
4
+ import 'graphql';
5
+ import '@copilotkit/shared';
6
+ import '../../../index-aa091e3c.js';
7
+ import '../../../graphql/types/base/index.js';
8
+ import 'rxjs';