@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.
- package/.eslintrc.js +7 -0
- package/.turbo/turbo-build.log +70 -0
- package/CHANGELOG.md +1 -0
- package/__snapshots__/schema/schema.graphql +178 -0
- package/dist/chunk-2CCVVJDU.mjs +56 -0
- package/dist/chunk-2CCVVJDU.mjs.map +1 -0
- package/dist/chunk-4UA4RB4C.mjs +185 -0
- package/dist/chunk-4UA4RB4C.mjs.map +1 -0
- package/dist/chunk-5HGYI6EG.mjs +678 -0
- package/dist/chunk-5HGYI6EG.mjs.map +1 -0
- package/dist/chunk-7IFP53C6.mjs +169 -0
- package/dist/chunk-7IFP53C6.mjs.map +1 -0
- package/dist/chunk-BLTAUVRP.mjs +30 -0
- package/dist/chunk-BLTAUVRP.mjs.map +1 -0
- package/dist/chunk-NFCPM5AM.mjs +43 -0
- package/dist/chunk-NFCPM5AM.mjs.map +1 -0
- package/dist/chunk-XPAUPJMW.mjs +1051 -0
- package/dist/chunk-XPAUPJMW.mjs.map +1 -0
- package/dist/graphql/types/base/index.d.ts +6 -0
- package/dist/graphql/types/base/index.js +63 -0
- package/dist/graphql/types/base/index.js.map +1 -0
- package/dist/graphql/types/base/index.mjs +7 -0
- package/dist/graphql/types/base/index.mjs.map +1 -0
- package/dist/graphql/types/converted/index.d.ts +2 -0
- package/dist/graphql/types/converted/index.js +88 -0
- package/dist/graphql/types/converted/index.js.map +1 -0
- package/dist/graphql/types/converted/index.mjs +12 -0
- package/dist/graphql/types/converted/index.mjs.map +1 -0
- package/dist/index-aa091e3c.d.ts +49 -0
- package/dist/index-f0875df3.d.ts +197 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2171 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +49 -0
- package/dist/index.mjs.map +1 -0
- package/dist/langchain-adapter-9ce103f3.d.ts +200 -0
- package/dist/langserve-fd5066ee.d.ts +96 -0
- package/dist/lib/index.d.ts +15 -0
- package/dist/lib/index.js +2170 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +46 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/integrations/index.d.ts +9 -0
- package/dist/lib/integrations/index.js +1024 -0
- package/dist/lib/integrations/index.js.map +1 -0
- package/dist/lib/integrations/index.mjs +24 -0
- package/dist/lib/integrations/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +8 -0
- package/dist/lib/integrations/node-http/index.js +969 -0
- package/dist/lib/integrations/node-http/index.js.map +1 -0
- package/dist/lib/integrations/node-http/index.mjs +10 -0
- package/dist/lib/integrations/node-http/index.mjs.map +1 -0
- package/dist/pages-router-b6bc6c60.d.ts +30 -0
- package/dist/service-adapters/index.d.ts +11 -0
- package/dist/service-adapters/index.js +912 -0
- package/dist/service-adapters/index.js.map +1 -0
- package/dist/service-adapters/index.mjs +18 -0
- package/dist/service-adapters/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +63 -0
- package/scripts/generate-gql-schema.ts +13 -0
- package/src/graphql/inputs/action.input.ts +13 -0
- package/src/graphql/inputs/cloud-guardrails.input.ts +19 -0
- package/src/graphql/inputs/cloud.input.ts +8 -0
- package/src/graphql/inputs/context-property.input.ts +10 -0
- package/src/graphql/inputs/custom-property.input.ts +15 -0
- package/src/graphql/inputs/frontend.input.ts +11 -0
- package/src/graphql/inputs/generate-copilot-response.input.ts +22 -0
- package/src/graphql/inputs/message.input.ts +50 -0
- package/src/graphql/resolvers/copilot.resolver.ts +147 -0
- package/src/graphql/types/base/index.ts +10 -0
- package/src/graphql/types/converted/index.ts +29 -0
- package/src/graphql/types/copilot-response.type.ts +75 -0
- package/src/graphql/types/enums.ts +22 -0
- package/src/graphql/types/guardrails-result.type.ts +20 -0
- package/src/graphql/types/message-status.type.ts +40 -0
- package/src/graphql/types/response-status.type.ts +52 -0
- package/src/index.ts +2 -0
- package/src/lib/copilot-cloud.ts +63 -0
- package/src/lib/copilot-runtime.ts +261 -0
- package/src/lib/guardrails.ts +3 -0
- package/src/lib/index.ts +7 -0
- package/src/lib/integrations/index.ts +4 -0
- package/src/lib/integrations/nextjs/app-router.ts +29 -0
- package/src/lib/integrations/nextjs/pages-router.ts +36 -0
- package/src/lib/integrations/node-http/index.ts +23 -0
- package/src/lib/integrations/shared.ts +68 -0
- package/src/service-adapters/conversion.ts +47 -0
- package/src/service-adapters/events.ts +197 -0
- package/src/service-adapters/experimental/groq/groq-adapter.ts +124 -0
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +75 -0
- package/src/service-adapters/google/google-genai-adapter.ts +149 -0
- package/src/service-adapters/google/utils.ts +94 -0
- package/src/service-adapters/index.ts +6 -0
- package/src/service-adapters/langchain/langchain-adapter.ts +82 -0
- package/src/service-adapters/langchain/langserve.ts +81 -0
- package/src/service-adapters/langchain/types.ts +14 -0
- package/src/service-adapters/langchain/utils.ts +235 -0
- package/src/service-adapters/openai/openai-adapter.ts +142 -0
- package/src/service-adapters/openai/openai-assistant-adapter.ts +260 -0
- package/src/service-adapters/openai/utils.ts +164 -0
- package/src/service-adapters/service-adapter.ts +29 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +17 -0
- package/typedoc.json +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/integrations/node-http/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/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"],"sourcesContent":["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","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\";\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"],"mappings":";;;;;;;;;AAAA,SAASA,kBAAkB;;;ACE3B,SAASC,uBAAuB;;;ACFhC,SAASC,KAAKC,KAAKC,UAAUC,OAAOC,gBAAgB;AACpD,SAASC,SAASC,gBAAgBC,aAAaC,WAAWC,iBAAiB;;;ACD3E,SAASC,SAAAA,QAAOC,aAAAA,kBAAiB;;;ACAjC,SAASC,OAAOC,iBAAiB;;;ACAjC,SAASC,wBAAwB;;UAErBC,cAAAA;;;;GAAAA,gBAAAA,cAAAA,CAAAA,EAAAA;;UAMAC,uBAAAA;;;GAAAA,yBAAAA,uBAAAA,CAAAA,EAAAA;AAKZF,iBAAiBC,aAAa;EAC5BE,MAAM;EACNC,aAAa;AACf,CAAA;AAEAJ,iBAAiBE,sBAAsB;EACrCC,MAAM;EACNC,aAAa;AACf,CAAA;;;;;;;;;;;;;;;;;;;ADdO,IAAMC,eAAN,cAA2BC,YAAAA;EAEhCC;EAGAC;EAGAC;AACF;AATaJ;;EACVK,MAAM,MAAMC,kBAAkB;IAAEC,UAAU;EAAK,CAAA;qCAClC,qBAAA,cAAA,SAAA,gBAAA;GAFHP,aAAAA,WAAAA,eAAAA,MAAAA;;EAIVK,MAAM,MAAMG,6BAA6B;IAAED,UAAU;EAAK,CAAA;qCAClC,gCAAA,cAAA,SAAA,2BAAA;GALdP,aAAAA,WAAAA,0BAAAA,MAAAA;;EAOVK,MAAM,MAAMI,oBAAoB;IAAEF,UAAU;EAAK,CAAA;qCAClC,uBAAA,cAAA,SAAA,kBAAA;GARLP,aAAAA,WAAAA,iBAAAA,MAAAA;AAAAA,eAAAA,aAAAA;EADZU,UAAAA;GACYV,YAAAA;AAYN,IAAMM,mBAAN,MAAMA;EAEXK;EAGAC;AACF;AANaN;;EACVD,MAAM,MAAMQ,MAAAA;;GADFP,iBAAAA,WAAAA,WAAAA,MAAAA;;EAIVD,MAAM,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C,eAAeC,gBAAgB;IAAEJ;IAASE;EAAe,CAAA;AAE/D,QAAMG,OAAOC,WAAW;IACtB,GAAGH;IACHI,iBAAiBN;EACnB,CAAA;AAEA,SAAOI;AACT;AAjBgBN;","names":["createYoga","buildSchemaSync","Arg","Ctx","Mutation","Query","Resolver","Subject","firstValueFrom","shareReplay","skipWhile","takeWhile","Field","InputType","Field","InputType","registerEnumType","MessageRole","ActionExecutionScope","name","description","MessageInput","BaseMessage","textMessage","actionExecutionMessage","resultMessage","Field","TextMessageInput","nullable","ActionExecutionMessageInput","ResultMessageInput","InputType","content","role","String","MessageRole","name","arguments","scope","ActionExecutionScope","actionExecutionId","actionName","result","Field","InputType","Field","InputType","ActionInput","name","description","jsonSchema","Field","String","InputType","FrontendInput","toDeprecate_fullContext","actions","Field","String","nullable","ActionInput","InputType","Field","InputType","Field","InputType","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","Field","InterfaceType","ObjectType","Field","ObjectType","createUnionType","registerEnumType","MessageStatusCode","registerEnumType","name","BaseMessageStatus","code","Field","ObjectType","PendingMessageStatus","SuccessMessageStatus","FailedMessageStatus","reason","String","MessageStatusUnion","createUnionType","types","Field","InterfaceType","ObjectType","createUnionType","registerEnumType","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","Repeater","nanoid","of","concat","map","scan","concatMap","ReplaySubject","RuntimeEventTypes","RuntimeEventSubject","ReplaySubject","constructor","sendTextMessageStart","messageId","next","type","sendTextMessageContent","content","sendTextMessageEnd","sendTextMessage","sendActionExecutionStart","actionExecutionId","actionName","sendActionExecutionArgs","args","sendActionExecutionEnd","sendActionExecution","toolName","sendActionExecutionResult","result","RuntimeEventSource","eventStream$","callback","stream","process","serversideActions","catch","error","console","pipe","map","event","scope","find","action","name","scan","acc","callActionServerSide","concatMap","eventWithState","toolCallEventStream$","executeAction","concat","of","actionArguments","JSON","parse","handler","streamLangChainResponse","actionExecution","id","GraphQLJSONObject","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","useDeferStream","createContext","initialContext","copilotKitContext","ctx","_copilotkit","buildSchema","options","schema","buildSchemaSync","resolvers","CopilotResolver","emitSchemaFile","getCommonConfig","plugins","useDeferStream","context","runtime","serviceAdapter","properties","copilotRuntimeNodeHttpEndpoint","runtime","endpoint","serviceAdapter","commonConfig","getCommonConfig","yoga","createYoga","graphqlEndpoint"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/graphql/types/base/index.ts
|
|
21
|
+
var base_exports = {};
|
|
22
|
+
__export(base_exports, {
|
|
23
|
+
BaseMessage: () => BaseMessage
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(base_exports);
|
|
26
|
+
var import_type_graphql = require("type-graphql");
|
|
27
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
28
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
30
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
+
else
|
|
32
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
33
|
+
if (d = decorators[i])
|
|
34
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36
|
+
}
|
|
37
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
38
|
+
function _ts_metadata(k, v) {
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
40
|
+
return Reflect.metadata(k, v);
|
|
41
|
+
}
|
|
42
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
43
|
+
var BaseMessage = class {
|
|
44
|
+
id;
|
|
45
|
+
createdAt;
|
|
46
|
+
};
|
|
47
|
+
__name(BaseMessage, "BaseMessage");
|
|
48
|
+
_ts_decorate([
|
|
49
|
+
(0, import_type_graphql.Field)(() => String),
|
|
50
|
+
_ts_metadata("design:type", String)
|
|
51
|
+
], BaseMessage.prototype, "id", void 0);
|
|
52
|
+
_ts_decorate([
|
|
53
|
+
(0, import_type_graphql.Field)(() => Date),
|
|
54
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
55
|
+
], BaseMessage.prototype, "createdAt", void 0);
|
|
56
|
+
BaseMessage = _ts_decorate([
|
|
57
|
+
(0, import_type_graphql.InputType)()
|
|
58
|
+
], BaseMessage);
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
BaseMessage
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/graphql/types/base/index.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0BAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMA,cAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,2BAAM,MAAMC,MAAAA;;GADFJ,YAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,2BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,YAAAA,WAAAA,aAAAA,MAAAA;AAAAA,cAAAA,aAAAA;MADZM,+BAAAA;GACYN,WAAAA;","names":["BaseMessage","id","createdAt","Field","String","Date","InputType"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/graphql/types/converted/index.ts
|
|
21
|
+
var converted_exports = {};
|
|
22
|
+
__export(converted_exports, {
|
|
23
|
+
ActionExecutionMessage: () => ActionExecutionMessage,
|
|
24
|
+
ResultMessage: () => ResultMessage,
|
|
25
|
+
TextMessage: () => TextMessage
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(converted_exports);
|
|
28
|
+
|
|
29
|
+
// src/graphql/types/base/index.ts
|
|
30
|
+
var import_type_graphql = require("type-graphql");
|
|
31
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
32
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
34
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
35
|
+
else
|
|
36
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
37
|
+
if (d = decorators[i])
|
|
38
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
39
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
|
+
}
|
|
41
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
42
|
+
function _ts_metadata(k, v) {
|
|
43
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
44
|
+
return Reflect.metadata(k, v);
|
|
45
|
+
}
|
|
46
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
47
|
+
var BaseMessage = class {
|
|
48
|
+
id;
|
|
49
|
+
createdAt;
|
|
50
|
+
};
|
|
51
|
+
__name(BaseMessage, "BaseMessage");
|
|
52
|
+
_ts_decorate([
|
|
53
|
+
(0, import_type_graphql.Field)(() => String),
|
|
54
|
+
_ts_metadata("design:type", String)
|
|
55
|
+
], BaseMessage.prototype, "id", void 0);
|
|
56
|
+
_ts_decorate([
|
|
57
|
+
(0, import_type_graphql.Field)(() => Date),
|
|
58
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
59
|
+
], BaseMessage.prototype, "createdAt", void 0);
|
|
60
|
+
BaseMessage = _ts_decorate([
|
|
61
|
+
(0, import_type_graphql.InputType)()
|
|
62
|
+
], BaseMessage);
|
|
63
|
+
|
|
64
|
+
// src/graphql/types/converted/index.ts
|
|
65
|
+
var TextMessage = class extends BaseMessage {
|
|
66
|
+
content;
|
|
67
|
+
role;
|
|
68
|
+
};
|
|
69
|
+
__name(TextMessage, "TextMessage");
|
|
70
|
+
var ActionExecutionMessage = class extends BaseMessage {
|
|
71
|
+
name;
|
|
72
|
+
arguments;
|
|
73
|
+
scope;
|
|
74
|
+
};
|
|
75
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
76
|
+
var ResultMessage = class extends BaseMessage {
|
|
77
|
+
actionExecutionId;
|
|
78
|
+
actionName;
|
|
79
|
+
result;
|
|
80
|
+
};
|
|
81
|
+
__name(ResultMessage, "ResultMessage");
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
ActionExecutionMessage,
|
|
85
|
+
ResultMessage,
|
|
86
|
+
TextMessage
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/graphql/types/converted/index.ts","../../../../src/graphql/types/base/index.ts"],"sourcesContent":["import {\n ActionExecutionMessageInput,\n ResultMessageInput,\n TextMessageInput,\n} from \"../../inputs/message.input\";\nimport { BaseMessage } from \"../base\";\nimport { ActionExecutionScope, MessageRole } from \"../enums\";\n\nexport class TextMessage extends BaseMessage implements TextMessageInput {\n content: string;\n role: MessageRole;\n}\n\nexport type Message = BaseMessage;\n\nexport class ActionExecutionMessage\n extends BaseMessage\n implements Omit<ActionExecutionMessageInput, \"arguments\">\n{\n name: string;\n arguments: Record<string, any>;\n scope: ActionExecutionScope;\n}\n\nexport class ResultMessage extends BaseMessage implements ResultMessageInput {\n actionExecutionId: string;\n actionName: string;\n result: string;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA;;;;;;;;;ACLA,0BAAiC;;;;;;;;;;;;;;;;;AAG1B,IAAMA,cAAN,MAAMA;EAEXC;EAGAC;AACF;AANaF;;MACVG,2BAAM,MAAMC,MAAAA;;GADFJ,YAAAA,WAAAA,MAAAA,MAAAA;;MAIVG,2BAAM,MAAME,IAAAA;qCACF,SAAA,cAAA,SAAA,IAAA;GALAL,YAAAA,WAAAA,aAAAA,MAAAA;AAAAA,cAAAA,aAAAA;MADZM,+BAAAA;GACYN,WAAAA;;;ADKN,IAAMO,cAAN,cAA0BC,YAAAA;EAC/BC;EACAC;AACF;AAHaH;AAON,IAAMI,yBAAN,cACGH,YAAAA;EAGRI;EACAC;EACAC;AACF;AAPaH;AASN,IAAMI,gBAAN,cAA4BP,YAAAA;EACjCQ;EACAC;EACAC;AACF;AAJaH;","names":["BaseMessage","id","createdAt","Field","String","Date","InputType","TextMessage","BaseMessage","content","role","ActionExecutionMessage","name","arguments","scope","ResultMessage","actionExecutionId","actionName","result"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionExecutionMessage,
|
|
3
|
+
ResultMessage,
|
|
4
|
+
TextMessage
|
|
5
|
+
} from "../../../chunk-BLTAUVRP.mjs";
|
|
6
|
+
import "../../../chunk-NFCPM5AM.mjs";
|
|
7
|
+
export {
|
|
8
|
+
ActionExecutionMessage,
|
|
9
|
+
ResultMessage,
|
|
10
|
+
TextMessage
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseMessage } from './graphql/types/base/index.js';
|
|
2
|
+
|
|
3
|
+
declare enum MessageRole {
|
|
4
|
+
user = "user",
|
|
5
|
+
assistant = "assistant",
|
|
6
|
+
system = "system"
|
|
7
|
+
}
|
|
8
|
+
declare enum ActionExecutionScope {
|
|
9
|
+
server = "server",
|
|
10
|
+
client = "client"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class MessageInput extends BaseMessage {
|
|
14
|
+
textMessage?: TextMessageInput;
|
|
15
|
+
actionExecutionMessage?: ActionExecutionMessageInput;
|
|
16
|
+
resultMessage?: ResultMessageInput;
|
|
17
|
+
}
|
|
18
|
+
declare class TextMessageInput {
|
|
19
|
+
content: string;
|
|
20
|
+
role: MessageRole;
|
|
21
|
+
}
|
|
22
|
+
declare class ActionExecutionMessageInput {
|
|
23
|
+
name: string;
|
|
24
|
+
arguments: string;
|
|
25
|
+
scope: ActionExecutionScope;
|
|
26
|
+
}
|
|
27
|
+
declare class ResultMessageInput {
|
|
28
|
+
actionExecutionId: string;
|
|
29
|
+
actionName: string;
|
|
30
|
+
result: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class TextMessage extends BaseMessage implements TextMessageInput {
|
|
34
|
+
content: string;
|
|
35
|
+
role: MessageRole;
|
|
36
|
+
}
|
|
37
|
+
type Message = BaseMessage;
|
|
38
|
+
declare class ActionExecutionMessage extends BaseMessage implements Omit<ActionExecutionMessageInput, "arguments"> {
|
|
39
|
+
name: string;
|
|
40
|
+
arguments: Record<string, any>;
|
|
41
|
+
scope: ActionExecutionScope;
|
|
42
|
+
}
|
|
43
|
+
declare class ResultMessage extends BaseMessage implements ResultMessageInput {
|
|
44
|
+
actionExecutionId: string;
|
|
45
|
+
actionName: string;
|
|
46
|
+
result: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { ActionExecutionMessage as A, MessageInput as M, ResultMessage as R, TextMessage as T, Message as a };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as graphql_yoga from 'graphql-yoga';
|
|
2
|
+
import { YogaInitialContext } from 'graphql-yoga';
|
|
3
|
+
import * as graphql from 'graphql';
|
|
4
|
+
import { CopilotCloudConfig, Parameter, Action } from '@copilotkit/shared';
|
|
5
|
+
import { R as RemoteChain, A as ActionInput, C as CopilotServiceAdapter, a as RuntimeEventSource } from './langserve-fd5066ee.js';
|
|
6
|
+
import { M as MessageInput } from './index-aa091e3c.js';
|
|
7
|
+
|
|
8
|
+
interface CloudCheckGuardrailsInputParams {
|
|
9
|
+
cloud: CopilotCloudConfig;
|
|
10
|
+
publicApiKey: string;
|
|
11
|
+
messages: any[];
|
|
12
|
+
}
|
|
13
|
+
interface CloudCheckGuardrailsInputResponse {
|
|
14
|
+
status: "allowed" | "denied";
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
declare abstract class CopilotCloud {
|
|
18
|
+
abstract checkGuardrailsInput(params: CloudCheckGuardrailsInputParams): Promise<CloudCheckGuardrailsInputResponse>;
|
|
19
|
+
}
|
|
20
|
+
declare class RemoteCopilotCloud extends CopilotCloud {
|
|
21
|
+
private readonly cloudApiUrl;
|
|
22
|
+
constructor(cloudApiUrl?: string);
|
|
23
|
+
checkGuardrailsInput({ cloud, publicApiKey, messages, }: CloudCheckGuardrailsInputParams): Promise<CloudCheckGuardrailsInputResponse>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Handles requests from frontend, provides function calling and various LLM backends.
|
|
28
|
+
*
|
|
29
|
+
* <img
|
|
30
|
+
* referrerPolicy="no-referrer-when-downgrade"
|
|
31
|
+
* src="https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be"
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* <RequestExample>
|
|
35
|
+
* ```jsx CopilotRuntime Example
|
|
36
|
+
* import {
|
|
37
|
+
* CopilotRuntime,
|
|
38
|
+
* OpenAIAdapter
|
|
39
|
+
* } from "@copilotkit/runtime";
|
|
40
|
+
*
|
|
41
|
+
* export async function POST(req: Request) {
|
|
42
|
+
* const copilotKit = new CopilotRuntime();
|
|
43
|
+
* return copilotKit.response(req, new OpenAIAdapter());
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* ```
|
|
47
|
+
* </RequestExample>
|
|
48
|
+
*
|
|
49
|
+
* This class is the main entry point for the runtime. It handles requests from the frontend, provides function calling and various LLM backends.
|
|
50
|
+
*
|
|
51
|
+
* For example, to use OpenAI as a backend (check the [OpenAI Adapter](./OpenAIAdapter) docs for more info):
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const copilotKit = new CopilotRuntime();
|
|
54
|
+
* return copilotKit.response(req, new OpenAIAdapter());
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Currently we support:
|
|
58
|
+
*
|
|
59
|
+
* - [OpenAI](./OpenAIAdapter)
|
|
60
|
+
* - [LangChain](./LangChainAdapter)
|
|
61
|
+
* - [OpenAI Assistant API](./OpenAIAssistantAdapter)
|
|
62
|
+
* - [Google Gemini](./GoogleGenerativeAIAdapter)
|
|
63
|
+
*
|
|
64
|
+
* ## Server Side Actions
|
|
65
|
+
*
|
|
66
|
+
* CopilotKit supports actions that can be executed on the server side. You can define server side actions by passing the `actions` parameter:
|
|
67
|
+
*
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const copilotKit = new CopilotRuntime({
|
|
70
|
+
* actions: [
|
|
71
|
+
* {
|
|
72
|
+
* name: "sayHello",
|
|
73
|
+
* description: "Says hello to someone.",
|
|
74
|
+
* argumentAnnotations: [
|
|
75
|
+
* {
|
|
76
|
+
* name: "arg",
|
|
77
|
+
* type: "string",
|
|
78
|
+
* description: "The name of the person to say hello to.",
|
|
79
|
+
* required: true,
|
|
80
|
+
* },
|
|
81
|
+
* ],
|
|
82
|
+
* implementation: async (arg) => {
|
|
83
|
+
* console.log("Hello from the server", arg, "!");
|
|
84
|
+
* },
|
|
85
|
+
* },
|
|
86
|
+
* ],
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* Server side actions can also return a result which becomes part of the message history.
|
|
91
|
+
*
|
|
92
|
+
* This is useful because it gives the LLM context about what happened on the server side. In addition,
|
|
93
|
+
* it can be used to look up information from a vector or relational database and other sources.
|
|
94
|
+
*
|
|
95
|
+
* In addition to that, server side actions can also come from LangChain, including support for streaming responses.
|
|
96
|
+
*
|
|
97
|
+
* Returned results can be of the following type:
|
|
98
|
+
*
|
|
99
|
+
* - anything serializable to JSON
|
|
100
|
+
* - `string`
|
|
101
|
+
* - LangChain types:
|
|
102
|
+
* - `IterableReadableStream`
|
|
103
|
+
* - `BaseMessageChunk`
|
|
104
|
+
* - `AIMessage`
|
|
105
|
+
*
|
|
106
|
+
* ## LangServe
|
|
107
|
+
*
|
|
108
|
+
* The backend also supports LangServe, enabling you to connect to existing chains, for example python based chains.
|
|
109
|
+
* Use the `langserve` parameter to specify URLs for LangServe.
|
|
110
|
+
*
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const copilotKit = new CopilotRuntime({
|
|
113
|
+
* langserve: [
|
|
114
|
+
* {
|
|
115
|
+
* chainUrl: "http://my-langserve.chain",
|
|
116
|
+
* name: "performResearch",
|
|
117
|
+
* description: "Performs research on a given topic.",
|
|
118
|
+
* },
|
|
119
|
+
* ],
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* When left out, arguments are automatically inferred from the schema provided by LangServe.
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
interface CopilotRuntimeRequest {
|
|
127
|
+
serviceAdapter: CopilotServiceAdapter;
|
|
128
|
+
messages: MessageInput[];
|
|
129
|
+
actions: ActionInput[];
|
|
130
|
+
threadId?: string;
|
|
131
|
+
runId?: string;
|
|
132
|
+
publicApiKey?: string;
|
|
133
|
+
}
|
|
134
|
+
interface CopilotRuntimeResponse {
|
|
135
|
+
threadId?: string;
|
|
136
|
+
runId?: string;
|
|
137
|
+
eventSource: RuntimeEventSource;
|
|
138
|
+
}
|
|
139
|
+
interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
140
|
+
actions?: Action<T>[];
|
|
141
|
+
langserve?: RemoteChain[];
|
|
142
|
+
debug?: boolean;
|
|
143
|
+
copilotCloud?: CopilotCloud;
|
|
144
|
+
}
|
|
145
|
+
declare class CopilotRuntime<const T extends Parameter[] | [] = []> {
|
|
146
|
+
actions: Action<any>[];
|
|
147
|
+
private langserve;
|
|
148
|
+
private debug;
|
|
149
|
+
private copilotCloud;
|
|
150
|
+
constructor(params?: CopilotRuntimeConstructorParams<T>);
|
|
151
|
+
addAction<const T extends Parameter[] | [] = []>(action: Action<T>): void;
|
|
152
|
+
removeAction(actionName: string): void;
|
|
153
|
+
process({ serviceAdapter, messages, actions: clientSideActionsInput, threadId, runId, publicApiKey, }: CopilotRuntimeRequest): Promise<CopilotRuntimeResponse>;
|
|
154
|
+
}
|
|
155
|
+
declare function flattenToolCallsNoDuplicates(toolsByPriority: ActionInput[]): ActionInput[];
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated use CopilotRuntime instead
|
|
158
|
+
*/
|
|
159
|
+
declare class CopilotBackend extends CopilotRuntime {
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface GuardrailsOptions {
|
|
163
|
+
baseUrl: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
type AnyPrimitive = string | boolean | number | null;
|
|
167
|
+
type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
|
|
168
|
+
type CopilotKitContext = {
|
|
169
|
+
runtime: CopilotRuntime;
|
|
170
|
+
serviceAdapter: CopilotServiceAdapter;
|
|
171
|
+
properties: CopilotRequestContextProperties;
|
|
172
|
+
};
|
|
173
|
+
type GraphQLContext = YogaInitialContext & {
|
|
174
|
+
_copilotkit: CopilotKitContext;
|
|
175
|
+
};
|
|
176
|
+
interface CreateCopilotRuntimeServerOptions {
|
|
177
|
+
runtime: CopilotRuntime;
|
|
178
|
+
serviceAdapter: CopilotServiceAdapter;
|
|
179
|
+
guardrails?: GuardrailsOptions;
|
|
180
|
+
}
|
|
181
|
+
declare function createContext(initialContext: YogaInitialContext, copilotKitContext: CopilotKitContext): Promise<Partial<GraphQLContext>>;
|
|
182
|
+
declare function buildSchema(options?: {
|
|
183
|
+
emitSchemaFile?: string;
|
|
184
|
+
}): graphql.GraphQLSchema;
|
|
185
|
+
declare function getCommonConfig(options?: CreateCopilotRuntimeServerOptions): {
|
|
186
|
+
schema: graphql.GraphQLSchema;
|
|
187
|
+
plugins: graphql_yoga.Plugin<Record<string, unknown>>[];
|
|
188
|
+
context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
declare function copilotRuntimeNodeHttpEndpoint({ runtime, endpoint, serviceAdapter, }: {
|
|
192
|
+
runtime: CopilotRuntime;
|
|
193
|
+
serviceAdapter: CopilotServiceAdapter;
|
|
194
|
+
endpoint: string;
|
|
195
|
+
}): graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
196
|
+
|
|
197
|
+
export { CopilotRuntimeConstructorParams as C, GraphQLContext as G, RemoteCopilotCloud as R, CopilotRuntime as a, CopilotBackend as b, CloudCheckGuardrailsInputParams as c, CloudCheckGuardrailsInputResponse as d, CopilotCloud as e, flattenToolCallsNoDuplicates as f, CopilotRequestContextProperties as g, CreateCopilotRuntimeServerOptions as h, createContext as i, buildSchema as j, getCommonConfig as k, copilotRuntimeNodeHttpEndpoint as l };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { c as CloudCheckGuardrailsInputParams, d as CloudCheckGuardrailsInputResponse, b as CopilotBackend, e as CopilotCloud, g as CopilotRequestContextProperties, a as CopilotRuntime, C as CopilotRuntimeConstructorParams, h as CreateCopilotRuntimeServerOptions, G as GraphQLContext, R as RemoteCopilotCloud, j as buildSchema, l as copilotRuntimeNodeHttpEndpoint, i as createContext, f as flattenToolCallsNoDuplicates, k as getCommonConfig } from './index-f0875df3.js';
|
|
2
|
+
export { G as GoogleGenerativeAIAdapter, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams } from './langchain-adapter-9ce103f3.js';
|
|
3
|
+
export { C as CopilotRuntimeServerInstance, a as config, c as copilotRuntimeNextJSAppRouterEndpoint, b as copilotRuntimeNextJSPagesRouterEndpoint } from './pages-router-b6bc6c60.js';
|
|
4
|
+
import 'graphql-yoga';
|
|
5
|
+
import 'graphql';
|
|
6
|
+
import '@copilotkit/shared';
|
|
7
|
+
import './langserve-fd5066ee.js';
|
|
8
|
+
import './index-aa091e3c.js';
|
|
9
|
+
import './graphql/types/base/index.js';
|
|
10
|
+
import 'rxjs';
|
|
11
|
+
import 'openai';
|
|
12
|
+
import '@google/generative-ai';
|
|
13
|
+
import '@langchain/core/messages';
|
|
14
|
+
import '@langchain/core/tools';
|
|
15
|
+
import '@langchain/core/utils/stream';
|