@copilotkit/runtime 0.38.0-mme-alpha.1 → 1.0.0-beta.1
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/.turbo/turbo-build.log +81 -67
- package/CHANGELOG.md +13 -10
- package/__snapshots__/schema/schema.graphql +15 -1
- package/dist/chunk-44O2JGUY.mjs +12 -0
- package/dist/chunk-5U6S5EGT.mjs +24 -0
- package/dist/chunk-5U6S5EGT.mjs.map +1 -0
- package/dist/{chunk-XI3HBDMA.mjs → chunk-7QCEK4DP.mjs} +25 -14
- package/dist/chunk-7QCEK4DP.mjs.map +1 -0
- package/dist/{chunk-DX2KAJBF.mjs → chunk-DL2QQEOR.mjs} +204 -19
- package/dist/chunk-DL2QQEOR.mjs.map +1 -0
- package/dist/{chunk-FRK6BXXV.mjs → chunk-DVDKD6F5.mjs} +3 -3
- package/dist/{chunk-NXFMYCNF.mjs → chunk-F5K2JKGM.mjs} +38 -23
- package/dist/chunk-F5K2JKGM.mjs.map +1 -0
- package/dist/{chunk-OZMCHYYR.mjs → chunk-GEIBJJQ4.mjs} +3 -3
- package/dist/{chunk-4RGXTUS4.mjs → chunk-R25IOQB5.mjs} +17 -4
- package/dist/chunk-R25IOQB5.mjs.map +1 -0
- package/dist/{chunk-6NZ4UMOD.mjs → chunk-RMZWGQ46.mjs} +2 -2
- package/dist/{chunk-BYB2LNMK.mjs → chunk-U3V2BCGI.mjs} +2 -2
- package/dist/chunk-ZTEJCDMJ.mjs +24 -0
- package/dist/chunk-ZTEJCDMJ.mjs.map +1 -0
- package/dist/graphql/types/base/index.mjs +2 -2
- package/dist/graphql/types/converted/index.mjs +3 -3
- package/dist/index.d.ts +8 -5
- package/dist/index.js +297 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{langchain-adapter-54784d29.d.ts → langchain-adapter-a02d1d38.d.ts} +4 -4
- package/dist/{langserve-63794237.d.ts → langserve-75ebbc38.d.ts} +1 -2
- package/dist/lib/index.d.ts +8 -5
- package/dist/lib/index.js +297 -53
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +17 -11
- package/dist/lib/integrations/index.d.ts +7 -4
- package/dist/lib/integrations/index.js +254 -14
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +15 -7
- package/dist/lib/integrations/nest/index.d.ts +14 -0
- package/dist/lib/integrations/nest/index.js +1481 -0
- package/dist/lib/integrations/nest/index.js.map +1 -0
- package/dist/lib/integrations/nest/index.mjs +13 -0
- package/dist/lib/integrations/nest/index.mjs.map +1 -0
- package/dist/lib/integrations/node-express/index.d.ts +14 -0
- package/dist/lib/integrations/node-express/index.js +1481 -0
- package/dist/lib/integrations/node-express/index.js.map +1 -0
- package/dist/lib/integrations/node-express/index.mjs +13 -0
- package/dist/lib/integrations/node-express/index.mjs.map +1 -0
- package/dist/lib/integrations/node-http/index.d.ts +7 -3
- package/dist/lib/integrations/node-http/index.js +214 -14
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +6 -6
- package/dist/{pages-router-b88114e9.d.ts → pages-router-24897543.d.ts} +1 -1
- package/dist/service-adapters/index.d.ts +2 -2
- package/dist/service-adapters/index.js +28 -17
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +5 -5
- package/dist/{index-1eb2e9b1.d.ts → shared-48c0f7b8.d.ts} +64 -21
- package/dist/utils/index.mjs +2 -2
- package/package.json +4 -4
- package/src/graphql/inputs/cloud-guardrails.input.ts +2 -2
- package/src/graphql/inputs/generate-copilot-response.input.ts +10 -0
- package/src/graphql/resolvers/copilot.resolver.ts +79 -3
- package/src/graphql/types/enums.ts +13 -0
- package/src/lib/copilot-runtime.ts +106 -32
- package/src/lib/integrations/index.ts +2 -0
- package/src/lib/integrations/nest/index.ts +14 -0
- package/src/lib/integrations/nextjs/app-router.ts +10 -0
- package/src/lib/integrations/nextjs/pages-router.ts +10 -0
- package/src/lib/integrations/node-express/index.ts +14 -0
- package/src/lib/integrations/node-http/index.ts +10 -0
- package/src/lib/integrations/shared.ts +15 -2
- package/src/lib/telemetry-client.ts +9 -0
- package/src/service-adapters/experimental/groq/groq-adapter.ts +3 -1
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +3 -1
- package/src/service-adapters/google/google-genai-adapter.ts +3 -1
- package/src/service-adapters/langchain/langchain-adapter.ts +8 -9
- package/src/service-adapters/openai/openai-adapter.ts +8 -7
- package/src/service-adapters/openai/openai-assistant-adapter.ts +6 -8
- package/src/service-adapters/service-adapter.ts +1 -2
- package/dist/chunk-4RGXTUS4.mjs.map +0 -1
- package/dist/chunk-DX2KAJBF.mjs.map +0 -1
- package/dist/chunk-NXFMYCNF.mjs.map +0 -1
- package/dist/chunk-RHQLCJGG.mjs +0 -7
- package/dist/chunk-XI3HBDMA.mjs.map +0 -1
- /package/dist/{chunk-RHQLCJGG.mjs.map → chunk-44O2JGUY.mjs.map} +0 -0
- /package/dist/{chunk-FRK6BXXV.mjs.map → chunk-DVDKD6F5.mjs.map} +0 -0
- /package/dist/{chunk-OZMCHYYR.mjs.map → chunk-GEIBJJQ4.mjs.map} +0 -0
- /package/dist/{chunk-6NZ4UMOD.mjs.map → chunk-RMZWGQ46.mjs.map} +0 -0
- /package/dist/{chunk-BYB2LNMK.mjs.map → chunk-U3V2BCGI.mjs.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../package.json","../../../../src/lib/integrations/node-express/index.ts","../../../../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/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/graphql/types/converted/index.ts","../../../../src/utils/failed-response-status-reasons.ts","../../../../src/lib/telemetry-client.ts","../../../../src/lib/logger.ts"],"sourcesContent":["{\n \"name\": \"@copilotkit/runtime\",\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"version\": \"1.0.0-beta.1\",\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"exports\": {\n \".\": \"./dist/index.js\"\n },\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"dev\": \"tsup --watch --onSuccess \\\"pnpm run generate-graphql-schema\\\"\",\n \"test\": \"jest --passWithNoTests\",\n \"check-types\": \"tsc --noEmit\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next\",\n \"generate-graphql-schema\": \"rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts\"\n },\n \"devDependencies\": {\n \"@swc/core\": \"1.5.28\",\n \"@types/express\": \"^4.17.21\",\n \"@types/jest\": \"^29.5.4\",\n \"@types/node\": \"^18.11.17\",\n \"@whatwg-node/server\": \"^0.9.34\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-custom\": \"workspace:*\",\n \"jest\": \"^29.6.4\",\n \"nodemon\": \"^3.1.3\",\n \"ts-jest\": \"^29.1.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"^6.7.0\",\n \"typescript\": \"^5.2.3\"\n },\n \"dependencies\": {\n \"@copilotkit/shared\": \"workspace:*\",\n \"@google/generative-ai\": \"^0.11.2\",\n \"@graphql-yoga/plugin-defer-stream\": \"^3.3.1\",\n \"@langchain/community\": \"^0.0.53\",\n \"@langchain/core\": \"^0.1.61\",\n \"@langchain/openai\": \"^0.0.28\",\n \"class-transformer\": \"^0.5.1\",\n \"express\": \"^4.19.2\",\n \"graphql\": \"^16.8.1\",\n \"graphql-scalars\": \"^1.23.0\",\n \"graphql-yoga\": \"^5.3.1\",\n \"groq-sdk\": \"^0.5.0\",\n \"js-tiktoken\": \"^1.0.8\",\n \"langchain\": \"^0.1.36\",\n \"nanoid\": \"3.3.4\",\n \"openai\": \"^4.50.0\",\n \"pino\": \"^9.2.0\",\n \"pino-pretty\": \"^11.2.1\",\n \"reflect-metadata\": \"^0.2.2\",\n \"rxjs\": \"^7.8.1\",\n \"tiktoken\": \"^1.0.15\",\n \"type-graphql\": \"2.0.0-rc.1\",\n \"zod\": \"^3.23.3\"\n }\n}\n","import { CreateCopilotRuntimeServerOptions } from \"../shared\";\nimport { copilotRuntimeNodeHttpEndpoint } from \"../node-http\";\nimport telemetry from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeExpressEndpoint(options: CreateCopilotRuntimeServerOptions) {\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-express\",\n },\n });\n\n telemetry.capture(\"oss.runtime.instance_created\", {});\n return copilotRuntimeNodeHttpEndpoint(options);\n}\n","import { createYoga } from \"graphql-yoga\";\nimport { CreateCopilotRuntimeServerOptions, getCommonConfig } from \"../shared\";\nimport telemetry from \"../../telemetry-client\";\n\nexport function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions) {\n const commonConfig = getCommonConfig(options);\n\n telemetry.setGlobalProperties({\n runtime: {\n framework: \"node-http\",\n },\n });\n\n telemetry.capture(\"oss.runtime.instance_created\", {});\n\n const logger = commonConfig.logging;\n logger.debug(\"Creating Node HTTP endpoint\");\n\n const yoga = createYoga({\n ...commonConfig,\n graphqlEndpoint: options.endpoint,\n });\n\n return yoga;\n}\n","import { YogaInitialContext } from \"graphql-yoga\";\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\";\nimport { CopilotCloudOptions } from \"../cloud\";\nimport { LogLevel, createLogger } from \"../../lib/logger\";\nimport { createYoga } from \"graphql-yoga\";\nimport telemetry from \"../telemetry-client\";\n\nconst logger = createLogger();\n\ntype AnyPrimitive = string | boolean | number | null;\nexport type CopilotRequestContextProperties = Record<\n string,\n AnyPrimitive | Record<string, AnyPrimitive>\n>;\n\nexport type GraphQLContext = YogaInitialContext & {\n _copilotkit: CreateCopilotRuntimeServerOptions;\n properties: CopilotRequestContextProperties;\n logger: typeof logger;\n};\n\nexport interface CreateCopilotRuntimeServerOptions {\n runtime: CopilotRuntime<any>;\n serviceAdapter: CopilotServiceAdapter;\n endpoint: string;\n baseUrl?: string;\n cloud?: CopilotCloudOptions;\n properties?: CopilotRequestContextProperties;\n logLevel?: LogLevel;\n}\n\nexport async function createContext(\n initialContext: YogaInitialContext,\n copilotKitContext: CreateCopilotRuntimeServerOptions,\n contextLogger: typeof logger,\n properties: CopilotRequestContextProperties = {},\n): Promise<Partial<GraphQLContext>> {\n logger.debug({ copilotKitContext }, \"Creating GraphQL context\");\n const ctx: GraphQLContext = {\n ...initialContext,\n _copilotkit: {\n ...copilotKitContext,\n },\n properties: { ...properties },\n logger: contextLogger,\n };\n return ctx;\n}\n\nexport function buildSchema(\n options: {\n emitSchemaFile?: string;\n } = {},\n) {\n logger.debug(\"Building GraphQL schema...\");\n const schema = buildSchemaSync({\n resolvers: [CopilotResolver],\n emitSchemaFile: options.emitSchemaFile,\n });\n logger.debug(\"GraphQL schema built successfully\");\n return schema;\n}\n\nexport type CommonConfig = {\n logging: typeof logger;\n schema: ReturnType<typeof buildSchema>;\n plugins: Parameters<typeof createYoga>[0][\"plugins\"];\n context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;\n};\n\nexport function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig {\n const logLevel = (process.env.LOG_LEVEL as LogLevel) || (options.logLevel as LogLevel) || \"error\";\n const logger = createLogger({ level: logLevel, component: \"getCommonConfig\" });\n\n const contextLogger = createLogger({ level: logLevel });\n\n if (options.cloud) {\n telemetry.setCloudConfiguration({\n publicApiKey: options.cloud.publicApiKey,\n baseUrl: options.cloud.baseUrl,\n });\n }\n\n telemetry.setGlobalProperties({\n runtime: {\n serviceAdapter: options.serviceAdapter.constructor.name,\n },\n });\n\n return {\n logging: createLogger({ component: \"Yoga GraphQL\", level: logLevel }),\n schema: buildSchema(),\n plugins: [useDeferStream()],\n context: (ctx: YogaInitialContext): Promise<Partial<GraphQLContext>> =>\n createContext(ctx, options, contextLogger, options.properties),\n };\n}\n","import { Arg, Ctx, Mutation, Query, Resolver } from \"type-graphql\";\nimport {\n ReplaySubject,\n Subject,\n Subscription,\n finalize,\n firstValueFrom,\n shareReplay,\n skipWhile,\n take,\n takeWhile,\n tap,\n} 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 {\n FailedMessageStatus,\n MessageStatusUnion,\n SuccessMessageStatus,\n} from \"../types/message-status.type\";\nimport { ResponseStatusUnion, SuccessResponseStatus } from \"../types/response-status.type\";\nimport { GraphQLJSONObject } from \"graphql-scalars\";\nimport { plainToInstance } from \"class-transformer\";\nimport { GuardrailsResult } from \"../types/guardrails-result.type\";\nimport { GraphQLError } from \"graphql\";\nimport {\n GuardrailsValidationFailureResponse,\n MessageStreamInterruptedResponse,\n UnknownErrorResponse,\n} from \"../../utils\";\nimport { ActionExecutionMessage, Message, ResultMessage, TextMessage } from \"../types/converted\";\nimport telemetry from \"../../lib/telemetry-client\";\n\nconst invokeGuardrails = async ({\n baseUrl,\n copilotCloudPublicApiKey,\n data,\n onResult,\n onError,\n}: {\n baseUrl: string;\n copilotCloudPublicApiKey: string;\n data: GenerateCopilotResponseInput;\n onResult: (result: GuardrailsResult) => void;\n onError: (err: Error) => void;\n}) => {\n console.log(\"invokeGuardrails.baseUrl\", baseUrl);\n\n if (\n data.messages.length &&\n data.messages[data.messages.length - 1].textMessage?.role === MessageRole.user\n ) {\n const messages = data.messages\n .filter(\n (m) =>\n m.textMessage !== undefined &&\n (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant),\n )\n .map((m) => ({\n role: m.textMessage!.role,\n content: m.textMessage.content,\n }));\n\n const lastMessage = messages[messages.length - 1];\n const restOfMessages = messages.slice(0, -1);\n\n const body = {\n input: lastMessage.content,\n validTopics: data.cloud.guardrails.inputValidationRules.allowList,\n invalidTopics: data.cloud.guardrails.inputValidationRules.denyList,\n messages: restOfMessages,\n };\n\n const guardrailsResult = await fetch(`${baseUrl}/guardrails/validate`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-CopilotCloud-Public-API-Key\": copilotCloudPublicApiKey,\n },\n body: JSON.stringify(body),\n });\n\n if (guardrailsResult.ok) {\n const resultJson: GuardrailsResult = await guardrailsResult.json();\n onResult(resultJson);\n } else {\n onError(await guardrailsResult.json());\n }\n }\n};\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 telemetry.capture(\"oss.runtime.copilot_request_created\", {\n \"cloud.guardrails.enabled\": data.cloud?.guardrails !== undefined,\n requestType: data.metadata.requestType,\n });\n\n let logger = ctx.logger.child({ component: \"CopilotResolver.generateCopilotResponse\" });\n logger.debug({ data }, \"Generating Copilot response\");\n\n const copilotRuntime = ctx._copilotkit.runtime;\n const serviceAdapter = ctx._copilotkit.serviceAdapter;\n\n if (properties) {\n logger.debug(\"Properties provided, merging with context properties\");\n ctx.properties = { ...ctx.properties, ...properties };\n }\n\n let copilotCloudPublicApiKey: string | null = null;\n let copilotCloudBaseUrl: string;\n\n if (data.cloud) {\n logger = logger.child({ cloud: true });\n logger.debug(\"Cloud configuration provided, checking for public API key in headers\");\n const key = ctx.request.headers.get(\"x-copilotcloud-public-api-key\");\n if (key) {\n logger.debug(\"Public API key found in headers\");\n copilotCloudPublicApiKey = key;\n } else {\n logger.error(\"Public API key not found in headers\");\n throw new GraphQLError(\"X-CopilotCloud-Public-API-Key header is required\");\n }\n\n if (process.env.COPILOT_CLOUD_BASE_URL) {\n copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;\n } else if (ctx._copilotkit.cloud?.baseUrl) {\n copilotCloudBaseUrl = ctx._copilotkit.cloud?.baseUrl;\n } else {\n copilotCloudBaseUrl = \"https://api.cloud.copilotkit.ai\";\n }\n\n logger = logger.child({ copilotCloudBaseUrl });\n }\n\n logger.debug(\"Setting up subjects\");\n const responseStatus$ = new ReplaySubject<typeof ResponseStatusUnion>();\n const interruptStreaming$ = new ReplaySubject<{ reason: string; messageId?: string }>();\n const guardrailsResult$ = new ReplaySubject<GuardrailsResult>();\n\n let outputMessages: Message[] = [];\n let resolveOutputMessagesPromise: (messages: Message[]) => void;\n let rejectOutputMessagesPromise: (err: Error) => void;\n\n const outputMessagesPromise = new Promise<Message[]>((resolve, reject) => {\n resolveOutputMessagesPromise = resolve;\n rejectOutputMessagesPromise = reject;\n });\n\n logger.debug(\"Processing\");\n const {\n eventSource,\n threadId = nanoid(),\n runId,\n actions,\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 properties: ctx.properties || {},\n outputMessagesPromise,\n });\n\n logger.debug(\"Event source created, creating response\");\n\n const response = {\n threadId,\n runId,\n status: firstValueFrom(responseStatus$),\n messages: new Repeater(async (pushMessage, stopStreamingMessages) => {\n logger.debug(\"Messages repeater created\");\n\n if (data.cloud?.guardrails) {\n logger = logger.child({ guardrails: true });\n logger.debug(\"Guardrails is enabled, validating input\");\n\n invokeGuardrails({\n baseUrl: copilotCloudBaseUrl,\n copilotCloudPublicApiKey,\n data,\n onResult: (result) => {\n logger.debug({ status: result.status }, \"Guardrails validation done\");\n guardrailsResult$.next(result);\n\n // Guardrails validation failed\n if (result.status === \"denied\") {\n // send the reason to the client and interrupt streaming\n responseStatus$.next(\n new GuardrailsValidationFailureResponse({ guardrailsReason: result.reason }),\n );\n interruptStreaming$.next({\n reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`,\n });\n\n // resolve messages promise to the middleware\n outputMessages = [\n plainToInstance(TextMessage, {\n id: nanoid(),\n createdAt: new Date(),\n content: result.reason,\n role: MessageRole.assistant,\n }),\n ];\n resolveOutputMessagesPromise(outputMessages);\n }\n },\n onError: (err) => {\n logger.error({ err }, \"Error in guardrails validation\");\n responseStatus$.next(\n new UnknownErrorResponse({\n description: `An unknown error has occurred in the guardrails validation`,\n }),\n );\n interruptStreaming$.next({\n reason: `Interrupted due to unknown error in guardrails validation`,\n });\n\n // reject the middleware promise\n rejectOutputMessagesPromise(err);\n },\n });\n }\n\n let eventStreamSubscription: Subscription;\n\n // run and process the event stream\n const eventStream = eventSource\n .process({\n serversideActions: actions,\n guardrailsResult$: data.cloud?.guardrails ? guardrailsResult$ : null,\n })\n .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 finalize(() => {\n logger.debug(\"Event stream finalized\");\n }),\n );\n\n logger.debug(\"Event stream created, subscribing to event stream\");\n\n eventStreamSubscription = 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 const messageId = nanoid();\n\n // push the new message\n pushMessage({\n id: messageId,\n status: firstValueFrom(streamingTextStatus),\n createdAt: new Date(),\n role: MessageRole.assistant,\n content: new Repeater(async (pushTextChunk, stopStreamingText) => {\n logger.debug(\"Text message content repeater created\");\n\n const textChunks: string[] = [];\n let textSubscription: Subscription;\n\n interruptStreaming$\n .pipe(\n shareReplay(),\n take(1),\n tap(({ reason, messageId }) => {\n logger.debug({ reason, messageId }, \"Text streaming interrupted\");\n\n streamingTextStatus.next(\n plainToInstance(FailedMessageStatus, { reason }),\n );\n\n responseStatus$.next(new MessageStreamInterruptedResponse({ messageId }));\n stopStreamingText();\n textSubscription?.unsubscribe();\n }),\n )\n .subscribe();\n\n logger.debug(\"Subscribing to text message content stream\");\n\n textSubscription = textMessageContentStream.subscribe({\n next: async (e: RuntimeEvent) => {\n if (e.type == RuntimeEventTypes.TextMessageContent) {\n await pushTextChunk(e.content);\n textChunks.push(e.content);\n }\n },\n error: (err) => {\n logger.error({ err }, \"Error in text message content stream\");\n interruptStreaming$.next({\n reason: \"Error streaming message content\",\n messageId,\n });\n stopStreamingText();\n textSubscription?.unsubscribe();\n },\n complete: () => {\n logger.debug(\"Text message content stream completed\");\n streamingTextStatus.next(new SuccessMessageStatus());\n stopStreamingText();\n textSubscription?.unsubscribe();\n\n outputMessages.push(\n plainToInstance(TextMessage, {\n id: messageId,\n createdAt: new Date(),\n content: textChunks.join(\"\"),\n role: MessageRole.assistant,\n }),\n );\n },\n });\n }),\n });\n break;\n ////////////////////////////////\n // ActionExecutionStart\n ////////////////////////////////\n case RuntimeEventTypes.ActionExecutionStart:\n logger.debug(\"Action execution start event received\");\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 logger.debug(\"Action execution argument stream created\");\n\n const argumentChunks: string[] = [];\n let actionExecutionArgumentSubscription: Subscription;\n\n actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({\n next: async (e: RuntimeEvent) => {\n if (e.type == RuntimeEventTypes.ActionExecutionArgs) {\n await pushArgumentsChunk(e.args);\n argumentChunks.push(e.args);\n }\n },\n error: (err) => {\n logger.error({ err }, \"Error in action execution argument stream\");\n streamingArgumentsStatus.next(\n plainToInstance(FailedMessageStatus, {\n reason:\n \"An unknown error has occurred in the action execution argument stream\",\n }),\n );\n stopStreamingArguments();\n actionExecutionArgumentSubscription?.unsubscribe();\n },\n complete: () => {\n logger.debug(\"Action execution argument stream completed\");\n streamingArgumentsStatus.next(new SuccessMessageStatus());\n stopStreamingArguments();\n actionExecutionArgumentSubscription?.unsubscribe();\n\n outputMessages.push(\n plainToInstance(ActionExecutionMessage, {\n id: event.actionExecutionId,\n createdAt: new Date(),\n name: event.actionName,\n scope: event.scope!,\n arguments: argumentChunks.join(\"\"),\n }),\n );\n },\n });\n }),\n });\n break;\n ////////////////////////////////\n // ActionExecutionResult\n ////////////////////////////////\n case RuntimeEventTypes.ActionExecutionResult:\n logger.debug({ result: event.result }, \"Action execution result event received\");\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\n outputMessages.push(\n plainToInstance(ResultMessage, {\n id: nanoid(),\n createdAt: new Date(),\n actionExecutionId: event.actionExecutionId,\n actionName: event.actionName,\n result: event.result,\n }),\n );\n break;\n }\n },\n error: (err) => {\n logger.error({ err }, \"Error in event stream\");\n responseStatus$.next(\n new UnknownErrorResponse({\n description: `An unknown error has occurred in the event stream`,\n }),\n );\n eventStreamSubscription?.unsubscribe();\n stopStreamingMessages();\n\n rejectOutputMessagesPromise(err);\n },\n complete: async () => {\n logger.debug(\"Event stream completed\");\n if (data.cloud?.guardrails) {\n logger.debug(\"Guardrails is enabled, waiting for guardrails result\");\n await firstValueFrom(guardrailsResult$);\n }\n responseStatus$.next(new SuccessResponseStatus());\n eventStreamSubscription?.unsubscribe();\n stopStreamingMessages();\n\n resolveOutputMessagesPromise(outputMessages);\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\";\nimport { CopilotRequestType } from \"../types/enums\";\n\n@InputType()\nexport class GenerateCopilotResponseMetadataInput {\n @Field(() => CopilotRequestType, { nullable: true })\n requestType: CopilotRequestType;\n}\n\n@InputType()\nexport class GenerateCopilotResponseInput {\n @Field(() => GenerateCopilotResponseMetadataInput, { nullable: false })\n metadata: GenerateCopilotResponseMetadataInput;\n\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\nexport enum CopilotRequestType {\n Chat = \"Chat\",\n Task = \"Task\",\n TextareaCompletion = \"TextareaCompletion\",\n TextareaPopover = \"TextareaPopover\",\n Suggestion = \"Suggestion\",\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\nregisterEnumType(CopilotRequestType, {\n name: \"CopilotRequestType\",\n description: \"The type of Copilot request\",\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, { nullable: true })\n guardrails?: GuardrailsInput;\n}\n","import { Field, InputType } from \"type-graphql\";\n\n@InputType()\nexport class GuardrailsRuleInput {\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: false })\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 { GraphQLJSON } from \"graphql-scalars\";\nimport { 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\nexport enum FailedResponseStatusReason {\n GUARDRAILS_VALIDATION_FAILED = \"GUARDRAILS_VALIDATION_FAILED\",\n MESSAGE_STREAM_INTERRUPTED = \"MESSAGE_STREAM_INTERRUPTED\",\n UNKNOWN_ERROR = \"UNKNOWN_ERROR\",\n}\n\nregisterEnumType(FailedResponseStatusReason, {\n name: \"FailedResponseStatusReason\",\n});\n\n@ObjectType({ implements: BaseResponseStatus })\nexport class FailedResponseStatus extends BaseResponseStatus {\n code: ResponseStatusCode = ResponseStatusCode.Failed;\n\n @Field(() => FailedResponseStatusReason)\n reason: FailedResponseStatusReason;\n\n @Field(() => GraphQLJSON, { nullable: true })\n details?: Record<string, any> = null;\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, Subject, firstValueFrom } from \"rxjs\";\nimport { streamLangChainResponse } from \"./langchain/utils\";\nimport { GuardrailsResult } from \"../graphql/types/guardrails-result.type\";\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({\n serversideActions,\n guardrailsResult$,\n }: {\n serversideActions: Action<any>[];\n guardrailsResult$?: Subject<GuardrailsResult>;\n }) {\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 guardrailsResult$ ? guardrailsResult$ : null,\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 guardrailsResult$: Subject<GuardrailsResult> | null,\n action: Action<any>,\n actionArguments: string,\n actionExecutionId: string,\n) {\n if (guardrailsResult$) {\n const { status } = await firstValueFrom(guardrailsResult$);\n\n if (status === \"denied\") {\n eventStream$.complete();\n return;\n }\n }\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 {\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 {\n FailedResponseStatus,\n FailedResponseStatusReason,\n} from \"../graphql/types/response-status.type\";\n\nexport class GuardrailsValidationFailureResponse extends FailedResponseStatus {\n reason = FailedResponseStatusReason.GUARDRAILS_VALIDATION_FAILED;\n declare details: {\n guardrailsReason: string;\n };\n\n constructor({ guardrailsReason }) {\n super();\n this.details = {\n guardrailsReason,\n };\n }\n}\n\nexport class MessageStreamInterruptedResponse extends FailedResponseStatus {\n reason = FailedResponseStatusReason.MESSAGE_STREAM_INTERRUPTED;\n declare details: {\n messageId: string;\n description: string;\n };\n\n constructor({ messageId }: { messageId: string }) {\n super();\n this.details = {\n messageId,\n description: \"Check the message for mode details\",\n };\n }\n}\n\nexport class UnknownErrorResponse extends FailedResponseStatus {\n reason = FailedResponseStatusReason.UNKNOWN_ERROR;\n declare details: {\n description?: string;\n };\n\n constructor({ description }: { description?: string }) {\n super();\n this.details = {\n description,\n };\n }\n}\n","import { TelemetryClient } from \"@copilotkit/shared\";\nconst packageJson = require(\"../../package.json\");\n\nconst telemetryClient = new TelemetryClient({\n packageName: packageJson.name,\n packageVersion: packageJson.version,\n});\n\nexport default telemetryClient;\n","import createPinoLogger from \"pino\";\nimport pretty from \"pino-pretty\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type CopilotRuntimeLogger = ReturnType<typeof createLogger>;\n\nexport function createLogger(options?: { level?: LogLevel; component?: string }) {\n const { level, component } = options || {};\n const stream = pretty({ colorize: true });\n\n const logger = createPinoLogger(\n {\n level: process.env.LOG_LEVEL || level || \"error\",\n redact: {\n paths: [\"pid\", \"hostname\"],\n remove: true,\n },\n },\n stream,\n );\n\n if (component) {\n return logger.child({ component });\n } else {\n return logger;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,0BAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,eAAiB;AAAA,QACf,QAAU;AAAA,MACZ;AAAA,MACA,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,QAAU;AAAA,MACV,SAAW;AAAA,QACT,KAAK;AAAA,MACP;AAAA,MACA,OAAS;AAAA,MACT,SAAW;AAAA,MACX,SAAW;AAAA,QACT,OAAS;AAAA,QACT,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,eAAe;AAAA,QACf,OAAS;AAAA,QACT,2BAA2B;AAAA,MAC7B;AAAA,MACA,iBAAmB;AAAA,QACjB,aAAa;AAAA,QACb,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,eAAe;AAAA,QACf,uBAAuB;AAAA,QACvB,QAAU;AAAA,QACV,wBAAwB;AAAA,QACxB,MAAQ;AAAA,QACR,SAAW;AAAA,QACX,WAAW;AAAA,QACX,WAAW;AAAA,QACX,UAAY;AAAA,QACZ,MAAQ;AAAA,QACR,YAAc;AAAA,MAChB;AAAA,MACA,cAAgB;AAAA,QACd,sBAAsB;AAAA,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gBAAgBpB,QAAQoB,eAAeC,YAAYC;IACrD;EACF,CAAA;AAEA,SAAO;IACLC,SAASjC,aAAa;MAAEsB,WAAW;MAAgBD,OAAOJ;IAAS,CAAA;IACnEN,QAAQF,YAAAA;IACRyB,SAAS;UAACC,2CAAAA;;IACVC,SAAS,CAAC7B,QACRN,cAAcM,KAAKG,SAASN,eAAeM,QAAQL,UAAU;EACjE;AACF;AA1BgBW;;;ADtET,SAASqB,+BAA+BC,SAA0C;AACvF,QAAMC,eAAeC,gBAAgBF,OAAAA;AAErCG,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QAAQ,gCAAgC,CAAC,CAAA;AAEnD,QAAMC,UAASP,aAAaQ;AAC5BD,EAAAA,QAAOE,MAAM,6BAAA;AAEb,QAAMC,WAAOC,iCAAW;IACtB,GAAGX;IACHY,iBAAiBb,QAAQc;EAC3B,CAAA;AAEA,SAAOH;AACT;AApBgBZ;;;ADAT,SAASgB,kCAAkCC,SAA0C;AAC1FC,2BAAUC,oBAAoB;IAC5BC,SAAS;MACPC,WAAW;IACb;EACF,CAAA;AAEAH,2BAAUI,QAAQ,gCAAgC,CAAC,CAAA;AACnD,SAAOC,+BAA+BN,OAAAA;AACxC;AATgBD;","names":["module","import_graphql_yoga","import_type_graphql","import_type_graphql","import_rxjs","import_type_graphql","import_type_graphql","MessageRole","ActionExecutionScope","CopilotRequestType","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","allowList","denyList","Field","String","nullable","InputType","GuardrailsInput","inputValidationRules","CloudInput","guardrails","Field","GuardrailsInput","nullable","InputType","GenerateCopilotResponseMetadataInput","requestType","Field","CopilotRequestType","nullable","InputType","GenerateCopilotResponseInput","metadata","threadId","runId","messages","frontend","cloud","String","MessageInput","FrontendInput","CloudInput","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","FailedResponseStatusReason","reason","details","GraphQLJSON","nullable","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","TextMessage","BaseMessage","content","role","ActionExecutionMessage","name","arguments","scope","ResultMessage","actionExecutionId","actionName","result","RuntimeEventTypes","import_graphql_scalars","GuardrailsValidationFailureResponse","FailedResponseStatus","reason","FailedResponseStatusReason","GUARDRAILS_VALIDATION_FAILED","constructor","guardrailsReason","details","MessageStreamInterruptedResponse","MESSAGE_STREAM_INTERRUPTED","messageId","description","UnknownErrorResponse","UNKNOWN_ERROR","packageJson","require","telemetryClient","TelemetryClient","packageName","name","packageVersion","version","invokeGuardrails","baseUrl","copilotCloudPublicApiKey","data","onResult","onError","console","log","messages","length","textMessage","role","MessageRole","user","filter","m","undefined","assistant","map","content","lastMessage","restOfMessages","slice","body","input","validTopics","cloud","guardrails","inputValidationRules","allowList","invalidTopics","denyList","guardrailsResult","fetch","method","headers","JSON","stringify","ok","resultJson","json","CopilotResolver","hello","generateCopilotResponse","ctx","properties","telemetry","capture","requestType","metadata","logger","child","component","debug","copilotRuntime","_copilotkit","runtime","serviceAdapter","copilotCloudBaseUrl","key","request","get","error","GraphQLError","process","env","COPILOT_CLOUD_BASE_URL","responseStatus$","ReplaySubject","interruptStreaming$","guardrailsResult$","outputMessages","resolveOutputMessagesPromise","rejectOutputMessagesPromise","outputMessagesPromise","Promise","resolve","reject","eventSource","threadId","nanoid","runId","actions","frontend","publicApiKey","response","status","firstValueFrom","Repeater","pushMessage","stopStreamingMessages","result","next","GuardrailsValidationFailureResponse","guardrailsReason","reason","plainToInstance","TextMessage","id","createdAt","Date","err","UnknownErrorResponse","description","eventStreamSubscription","eventStream","serversideActions","pipe","shareReplay","finalize","subscribe","event","type","RuntimeEventTypes","TextMessageStart","textMessageContentStream","skipWhile","e","takeWhile","TextMessageEnd","streamingTextStatus","Subject","messageId","pushTextChunk","stopStreamingText","textChunks","textSubscription","take","tap","FailedMessageStatus","MessageStreamInterruptedResponse","unsubscribe","TextMessageContent","push","complete","SuccessMessageStatus","join","ActionExecutionStart","actionExecutionArgumentStream","ActionExecutionEnd","streamingArgumentsStatus","actionExecutionId","name","actionName","scope","arguments","pushArgumentsChunk","stopStreamingArguments","argumentChunks","actionExecutionArgumentSubscription","ActionExecutionArgs","args","ActionExecutionMessage","ActionExecutionResult","ResultMessage","SuccessResponseStatus","Query","String","Mutation","CopilotResponse","Ctx","Arg","GraphQLJSONObject","nullable","Resolver","createLogger","options","level","component","stream","pretty","colorize","logger","createPinoLogger","process","env","LOG_LEVEL","redact","paths","remove","child","logger","createLogger","createContext","initialContext","copilotKitContext","contextLogger","properties","debug","ctx","_copilotkit","buildSchema","options","schema","buildSchemaSync","resolvers","CopilotResolver","emitSchemaFile","getCommonConfig","logLevel","process","env","LOG_LEVEL","level","component","cloud","telemetry","setCloudConfiguration","publicApiKey","baseUrl","setGlobalProperties","runtime","serviceAdapter","constructor","name","logging","plugins","useDeferStream","context","copilotRuntimeNodeHttpEndpoint","options","commonConfig","getCommonConfig","telemetry","setGlobalProperties","runtime","framework","capture","logger","logging","debug","yoga","createYoga","graphqlEndpoint","endpoint","copilotRuntimeNodeExpressEndpoint","options","telemetry","setGlobalProperties","runtime","framework","capture","copilotRuntimeNodeHttpEndpoint"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
copilotRuntimeNodeExpressEndpoint
|
|
3
|
+
} from "../../../chunk-5U6S5EGT.mjs";
|
|
4
|
+
import "../../../chunk-DL2QQEOR.mjs";
|
|
5
|
+
import "../../../chunk-DVDKD6F5.mjs";
|
|
6
|
+
import "../../../chunk-U3V2BCGI.mjs";
|
|
7
|
+
import "../../../chunk-GEIBJJQ4.mjs";
|
|
8
|
+
import "../../../chunk-RMZWGQ46.mjs";
|
|
9
|
+
import "../../../chunk-44O2JGUY.mjs";
|
|
10
|
+
export {
|
|
11
|
+
copilotRuntimeNodeExpressEndpoint
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import 'graphql-yoga';
|
|
2
|
-
|
|
1
|
+
import * as graphql_yoga from 'graphql-yoga';
|
|
2
|
+
import { c as CreateCopilotRuntimeServerOptions, G as GraphQLContext } from '../../../shared-48c0f7b8.js';
|
|
3
3
|
import 'graphql';
|
|
4
4
|
import 'pino';
|
|
5
5
|
import '@copilotkit/shared';
|
|
6
|
-
import '../../../langserve-
|
|
6
|
+
import '../../../langserve-75ebbc38.js';
|
|
7
7
|
import '../../../index-aa091e3c.js';
|
|
8
8
|
import '../../../graphql/types/base/index.js';
|
|
9
9
|
import 'rxjs';
|
|
10
10
|
import '../../cloud/index.js';
|
|
11
|
+
|
|
12
|
+
declare function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions): graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
13
|
+
|
|
14
|
+
export { copilotRuntimeNodeHttpEndpoint };
|
|
@@ -5,6 +5,9 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,77 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// package.json
|
|
34
|
+
var require_package = __commonJS({
|
|
35
|
+
"package.json"(exports, module2) {
|
|
36
|
+
module2.exports = {
|
|
37
|
+
name: "@copilotkit/runtime",
|
|
38
|
+
private: false,
|
|
39
|
+
publishConfig: {
|
|
40
|
+
access: "public"
|
|
41
|
+
},
|
|
42
|
+
version: "1.0.0-beta.1",
|
|
43
|
+
sideEffects: false,
|
|
44
|
+
main: "./dist/index.js",
|
|
45
|
+
module: "./dist/index.mjs",
|
|
46
|
+
exports: {
|
|
47
|
+
".": "./dist/index.js"
|
|
48
|
+
},
|
|
49
|
+
types: "./dist/index.d.ts",
|
|
50
|
+
license: "MIT",
|
|
51
|
+
scripts: {
|
|
52
|
+
build: "tsup --clean",
|
|
53
|
+
dev: 'tsup --watch --onSuccess "pnpm run generate-graphql-schema"',
|
|
54
|
+
test: "jest --passWithNoTests",
|
|
55
|
+
"check-types": "tsc --noEmit",
|
|
56
|
+
clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
57
|
+
"generate-graphql-schema": "rm -rf __snapshots__ && ts-node ./scripts/generate-gql-schema.ts"
|
|
58
|
+
},
|
|
59
|
+
devDependencies: {
|
|
60
|
+
"@swc/core": "1.5.28",
|
|
61
|
+
"@types/express": "^4.17.21",
|
|
62
|
+
"@types/jest": "^29.5.4",
|
|
63
|
+
"@types/node": "^18.11.17",
|
|
64
|
+
"@whatwg-node/server": "^0.9.34",
|
|
65
|
+
eslint: "^8.56.0",
|
|
66
|
+
"eslint-config-custom": "workspace:*",
|
|
67
|
+
jest: "^29.6.4",
|
|
68
|
+
nodemon: "^3.1.3",
|
|
69
|
+
"ts-jest": "^29.1.1",
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
71
|
+
tsconfig: "workspace:*",
|
|
72
|
+
tsup: "^6.7.0",
|
|
73
|
+
typescript: "^5.2.3"
|
|
74
|
+
},
|
|
75
|
+
dependencies: {
|
|
76
|
+
"@copilotkit/shared": "workspace:*",
|
|
77
|
+
"@google/generative-ai": "^0.11.2",
|
|
78
|
+
"@graphql-yoga/plugin-defer-stream": "^3.3.1",
|
|
79
|
+
"@langchain/community": "^0.0.53",
|
|
80
|
+
"@langchain/core": "^0.1.61",
|
|
81
|
+
"@langchain/openai": "^0.0.28",
|
|
82
|
+
"class-transformer": "^0.5.1",
|
|
83
|
+
express: "^4.19.2",
|
|
84
|
+
graphql: "^16.8.1",
|
|
85
|
+
"graphql-scalars": "^1.23.0",
|
|
86
|
+
"graphql-yoga": "^5.3.1",
|
|
87
|
+
"groq-sdk": "^0.5.0",
|
|
88
|
+
"js-tiktoken": "^1.0.8",
|
|
89
|
+
langchain: "^0.1.36",
|
|
90
|
+
nanoid: "3.3.4",
|
|
91
|
+
openai: "^4.50.0",
|
|
92
|
+
pino: "^9.2.0",
|
|
93
|
+
"pino-pretty": "^11.2.1",
|
|
94
|
+
"reflect-metadata": "^0.2.2",
|
|
95
|
+
rxjs: "^7.8.1",
|
|
96
|
+
tiktoken: "^1.0.15",
|
|
97
|
+
"type-graphql": "2.0.0-rc.1",
|
|
98
|
+
zod: "^3.23.3"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
30
104
|
// src/lib/integrations/node-http/index.ts
|
|
31
105
|
var node_http_exports = {};
|
|
32
106
|
__export(node_http_exports, {
|
|
@@ -61,6 +135,14 @@ var ActionExecutionScope;
|
|
|
61
135
|
ActionExecutionScope2["server"] = "server";
|
|
62
136
|
ActionExecutionScope2["client"] = "client";
|
|
63
137
|
})(ActionExecutionScope || (ActionExecutionScope = {}));
|
|
138
|
+
var CopilotRequestType;
|
|
139
|
+
(function(CopilotRequestType2) {
|
|
140
|
+
CopilotRequestType2["Chat"] = "Chat";
|
|
141
|
+
CopilotRequestType2["Task"] = "Task";
|
|
142
|
+
CopilotRequestType2["TextareaCompletion"] = "TextareaCompletion";
|
|
143
|
+
CopilotRequestType2["TextareaPopover"] = "TextareaPopover";
|
|
144
|
+
CopilotRequestType2["Suggestion"] = "Suggestion";
|
|
145
|
+
})(CopilotRequestType || (CopilotRequestType = {}));
|
|
64
146
|
(0, import_type_graphql.registerEnumType)(MessageRole, {
|
|
65
147
|
name: "MessageRole",
|
|
66
148
|
description: "The role of the message"
|
|
@@ -69,6 +151,10 @@ var ActionExecutionScope;
|
|
|
69
151
|
name: "ActionExecutionScope",
|
|
70
152
|
description: "The scope of the action"
|
|
71
153
|
});
|
|
154
|
+
(0, import_type_graphql.registerEnumType)(CopilotRequestType, {
|
|
155
|
+
name: "CopilotRequestType",
|
|
156
|
+
description: "The type of Copilot request"
|
|
157
|
+
});
|
|
72
158
|
|
|
73
159
|
// src/graphql/types/base/index.ts
|
|
74
160
|
var import_type_graphql2 = require("type-graphql");
|
|
@@ -335,15 +421,12 @@ GuardrailsRuleInput = _ts_decorate5([
|
|
|
335
421
|
(0, import_type_graphql6.InputType)()
|
|
336
422
|
], GuardrailsRuleInput);
|
|
337
423
|
var GuardrailsInput = class {
|
|
338
|
-
inputValidationRules
|
|
339
|
-
allowList: [],
|
|
340
|
-
denyList: []
|
|
341
|
-
};
|
|
424
|
+
inputValidationRules;
|
|
342
425
|
};
|
|
343
426
|
__name(GuardrailsInput, "GuardrailsInput");
|
|
344
427
|
_ts_decorate5([
|
|
345
428
|
(0, import_type_graphql6.Field)(() => GuardrailsRuleInput, {
|
|
346
|
-
nullable:
|
|
429
|
+
nullable: false
|
|
347
430
|
}),
|
|
348
431
|
_ts_metadata5("design:type", typeof GuardrailsRuleInput === "undefined" ? Object : GuardrailsRuleInput)
|
|
349
432
|
], GuardrailsInput.prototype, "inputValidationRules", void 0);
|
|
@@ -399,7 +482,21 @@ function _ts_metadata7(k, v) {
|
|
|
399
482
|
return Reflect.metadata(k, v);
|
|
400
483
|
}
|
|
401
484
|
__name(_ts_metadata7, "_ts_metadata");
|
|
485
|
+
var GenerateCopilotResponseMetadataInput = class {
|
|
486
|
+
requestType;
|
|
487
|
+
};
|
|
488
|
+
__name(GenerateCopilotResponseMetadataInput, "GenerateCopilotResponseMetadataInput");
|
|
489
|
+
_ts_decorate7([
|
|
490
|
+
(0, import_type_graphql8.Field)(() => CopilotRequestType, {
|
|
491
|
+
nullable: true
|
|
492
|
+
}),
|
|
493
|
+
_ts_metadata7("design:type", typeof CopilotRequestType === "undefined" ? Object : CopilotRequestType)
|
|
494
|
+
], GenerateCopilotResponseMetadataInput.prototype, "requestType", void 0);
|
|
495
|
+
GenerateCopilotResponseMetadataInput = _ts_decorate7([
|
|
496
|
+
(0, import_type_graphql8.InputType)()
|
|
497
|
+
], GenerateCopilotResponseMetadataInput);
|
|
402
498
|
var GenerateCopilotResponseInput = class {
|
|
499
|
+
metadata;
|
|
403
500
|
threadId;
|
|
404
501
|
runId;
|
|
405
502
|
messages;
|
|
@@ -407,6 +504,12 @@ var GenerateCopilotResponseInput = class {
|
|
|
407
504
|
cloud;
|
|
408
505
|
};
|
|
409
506
|
__name(GenerateCopilotResponseInput, "GenerateCopilotResponseInput");
|
|
507
|
+
_ts_decorate7([
|
|
508
|
+
(0, import_type_graphql8.Field)(() => GenerateCopilotResponseMetadataInput, {
|
|
509
|
+
nullable: false
|
|
510
|
+
}),
|
|
511
|
+
_ts_metadata7("design:type", typeof GenerateCopilotResponseMetadataInput === "undefined" ? Object : GenerateCopilotResponseMetadataInput)
|
|
512
|
+
], GenerateCopilotResponseInput.prototype, "metadata", void 0);
|
|
410
513
|
_ts_decorate7([
|
|
411
514
|
(0, import_type_graphql8.Field)(() => String, {
|
|
412
515
|
nullable: true
|
|
@@ -774,6 +877,27 @@ var import_nanoid = require("nanoid");
|
|
|
774
877
|
|
|
775
878
|
// src/service-adapters/events.ts
|
|
776
879
|
var import_rxjs = require("rxjs");
|
|
880
|
+
|
|
881
|
+
// src/graphql/types/converted/index.ts
|
|
882
|
+
var TextMessage = class extends BaseMessage {
|
|
883
|
+
content;
|
|
884
|
+
role;
|
|
885
|
+
};
|
|
886
|
+
__name(TextMessage, "TextMessage");
|
|
887
|
+
var ActionExecutionMessage = class extends BaseMessage {
|
|
888
|
+
name;
|
|
889
|
+
arguments;
|
|
890
|
+
scope;
|
|
891
|
+
};
|
|
892
|
+
__name(ActionExecutionMessage, "ActionExecutionMessage");
|
|
893
|
+
var ResultMessage = class extends BaseMessage {
|
|
894
|
+
actionExecutionId;
|
|
895
|
+
actionName;
|
|
896
|
+
result;
|
|
897
|
+
};
|
|
898
|
+
__name(ResultMessage, "ResultMessage");
|
|
899
|
+
|
|
900
|
+
// src/service-adapters/events.ts
|
|
777
901
|
var RuntimeEventTypes;
|
|
778
902
|
(function(RuntimeEventTypes2) {
|
|
779
903
|
RuntimeEventTypes2["TextMessageStart"] = "TextMessageStart";
|
|
@@ -823,6 +947,15 @@ var UnknownErrorResponse = class extends FailedResponseStatus {
|
|
|
823
947
|
};
|
|
824
948
|
__name(UnknownErrorResponse, "UnknownErrorResponse");
|
|
825
949
|
|
|
950
|
+
// src/lib/telemetry-client.ts
|
|
951
|
+
var import_shared = require("@copilotkit/shared");
|
|
952
|
+
var packageJson = require_package();
|
|
953
|
+
var telemetryClient = new import_shared.TelemetryClient({
|
|
954
|
+
packageName: packageJson.name,
|
|
955
|
+
packageVersion: packageJson.version
|
|
956
|
+
});
|
|
957
|
+
var telemetry_client_default = telemetryClient;
|
|
958
|
+
|
|
826
959
|
// src/graphql/resolvers/copilot.resolver.ts
|
|
827
960
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
828
961
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -848,6 +981,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
848
981
|
__name(_ts_param, "_ts_param");
|
|
849
982
|
var invokeGuardrails = /* @__PURE__ */ __name(async ({ baseUrl, copilotCloudPublicApiKey, data, onResult, onError }) => {
|
|
850
983
|
var _a;
|
|
984
|
+
console.log("invokeGuardrails.baseUrl", baseUrl);
|
|
851
985
|
if (data.messages.length && ((_a = data.messages[data.messages.length - 1].textMessage) == null ? void 0 : _a.role) === MessageRole.user) {
|
|
852
986
|
const messages = data.messages.filter((m) => m.textMessage !== void 0 && (m.textMessage.role === MessageRole.user || m.textMessage.role === MessageRole.assistant)).map((m) => ({
|
|
853
987
|
role: m.textMessage.role,
|
|
@@ -882,6 +1016,11 @@ var CopilotResolver = class {
|
|
|
882
1016
|
return "Hello World";
|
|
883
1017
|
}
|
|
884
1018
|
async generateCopilotResponse(ctx, data, properties) {
|
|
1019
|
+
var _a, _b, _c;
|
|
1020
|
+
telemetry_client_default.capture("oss.runtime.copilot_request_created", {
|
|
1021
|
+
"cloud.guardrails.enabled": ((_a = data.cloud) == null ? void 0 : _a.guardrails) !== void 0,
|
|
1022
|
+
requestType: data.metadata.requestType
|
|
1023
|
+
});
|
|
885
1024
|
let logger2 = ctx.logger.child({
|
|
886
1025
|
component: "CopilotResolver.generateCopilotResponse"
|
|
887
1026
|
});
|
|
@@ -914,8 +1053,8 @@ var CopilotResolver = class {
|
|
|
914
1053
|
}
|
|
915
1054
|
if (process.env.COPILOT_CLOUD_BASE_URL) {
|
|
916
1055
|
copilotCloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL;
|
|
917
|
-
} else if (ctx._copilotkit.baseUrl) {
|
|
918
|
-
copilotCloudBaseUrl = ctx._copilotkit.baseUrl;
|
|
1056
|
+
} else if ((_b = ctx._copilotkit.cloud) == null ? void 0 : _b.baseUrl) {
|
|
1057
|
+
copilotCloudBaseUrl = (_c = ctx._copilotkit.cloud) == null ? void 0 : _c.baseUrl;
|
|
919
1058
|
} else {
|
|
920
1059
|
copilotCloudBaseUrl = "https://api.cloud.copilotkit.ai";
|
|
921
1060
|
}
|
|
@@ -927,6 +1066,13 @@ var CopilotResolver = class {
|
|
|
927
1066
|
const responseStatus$ = new import_rxjs2.ReplaySubject();
|
|
928
1067
|
const interruptStreaming$ = new import_rxjs2.ReplaySubject();
|
|
929
1068
|
const guardrailsResult$ = new import_rxjs2.ReplaySubject();
|
|
1069
|
+
let outputMessages = [];
|
|
1070
|
+
let resolveOutputMessagesPromise;
|
|
1071
|
+
let rejectOutputMessagesPromise;
|
|
1072
|
+
const outputMessagesPromise = new Promise((resolve, reject) => {
|
|
1073
|
+
resolveOutputMessagesPromise = resolve;
|
|
1074
|
+
rejectOutputMessagesPromise = reject;
|
|
1075
|
+
});
|
|
930
1076
|
logger2.debug("Processing");
|
|
931
1077
|
const { eventSource, threadId = (0, import_nanoid.nanoid)(), runId, actions } = await copilotRuntime.process({
|
|
932
1078
|
serviceAdapter,
|
|
@@ -934,7 +1080,9 @@ var CopilotResolver = class {
|
|
|
934
1080
|
actions: data.frontend.actions,
|
|
935
1081
|
threadId: data.threadId,
|
|
936
1082
|
runId: data.runId,
|
|
937
|
-
publicApiKey: void 0
|
|
1083
|
+
publicApiKey: void 0,
|
|
1084
|
+
properties: ctx.properties || {},
|
|
1085
|
+
outputMessagesPromise
|
|
938
1086
|
});
|
|
939
1087
|
logger2.debug("Event source created, creating response");
|
|
940
1088
|
const response = {
|
|
@@ -942,9 +1090,9 @@ var CopilotResolver = class {
|
|
|
942
1090
|
runId,
|
|
943
1091
|
status: (0, import_rxjs2.firstValueFrom)(responseStatus$),
|
|
944
1092
|
messages: new import_graphql_yoga.Repeater(async (pushMessage, stopStreamingMessages) => {
|
|
945
|
-
var
|
|
1093
|
+
var _a2, _b2;
|
|
946
1094
|
logger2.debug("Messages repeater created");
|
|
947
|
-
if ((
|
|
1095
|
+
if ((_a2 = data.cloud) == null ? void 0 : _a2.guardrails) {
|
|
948
1096
|
logger2 = logger2.child({
|
|
949
1097
|
guardrails: true
|
|
950
1098
|
});
|
|
@@ -965,6 +1113,15 @@ var CopilotResolver = class {
|
|
|
965
1113
|
interruptStreaming$.next({
|
|
966
1114
|
reason: `Interrupted due to Guardrails validation failure. Reason: ${result.reason}`
|
|
967
1115
|
});
|
|
1116
|
+
outputMessages = [
|
|
1117
|
+
(0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
1118
|
+
id: (0, import_nanoid.nanoid)(),
|
|
1119
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1120
|
+
content: result.reason,
|
|
1121
|
+
role: MessageRole.assistant
|
|
1122
|
+
})
|
|
1123
|
+
];
|
|
1124
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
968
1125
|
}
|
|
969
1126
|
},
|
|
970
1127
|
onError: (err) => {
|
|
@@ -977,13 +1134,14 @@ var CopilotResolver = class {
|
|
|
977
1134
|
interruptStreaming$.next({
|
|
978
1135
|
reason: `Interrupted due to unknown error in guardrails validation`
|
|
979
1136
|
});
|
|
1137
|
+
rejectOutputMessagesPromise(err);
|
|
980
1138
|
}
|
|
981
1139
|
});
|
|
982
1140
|
}
|
|
983
1141
|
let eventStreamSubscription;
|
|
984
1142
|
const eventStream = eventSource.process({
|
|
985
1143
|
serversideActions: actions,
|
|
986
|
-
guardrailsResult$: ((
|
|
1144
|
+
guardrailsResult$: ((_b2 = data.cloud) == null ? void 0 : _b2.guardrails) ? guardrailsResult$ : null
|
|
987
1145
|
}).pipe(
|
|
988
1146
|
// shareReplay() ensures that later subscribers will see the whole stream instead of
|
|
989
1147
|
// just the events that were emitted after the subscriber was added.
|
|
@@ -1012,6 +1170,7 @@ var CopilotResolver = class {
|
|
|
1012
1170
|
role: MessageRole.assistant,
|
|
1013
1171
|
content: new import_graphql_yoga.Repeater(async (pushTextChunk, stopStreamingText) => {
|
|
1014
1172
|
logger2.debug("Text message content repeater created");
|
|
1173
|
+
const textChunks = [];
|
|
1015
1174
|
let textSubscription;
|
|
1016
1175
|
interruptStreaming$.pipe((0, import_rxjs2.shareReplay)(), (0, import_rxjs2.take)(1), (0, import_rxjs2.tap)(({ reason, messageId: messageId2 }) => {
|
|
1017
1176
|
logger2.debug({
|
|
@@ -1032,6 +1191,7 @@ var CopilotResolver = class {
|
|
|
1032
1191
|
next: async (e) => {
|
|
1033
1192
|
if (e.type == RuntimeEventTypes.TextMessageContent) {
|
|
1034
1193
|
await pushTextChunk(e.content);
|
|
1194
|
+
textChunks.push(e.content);
|
|
1035
1195
|
}
|
|
1036
1196
|
},
|
|
1037
1197
|
error: (err) => {
|
|
@@ -1050,6 +1210,12 @@ var CopilotResolver = class {
|
|
|
1050
1210
|
streamingTextStatus.next(new SuccessMessageStatus());
|
|
1051
1211
|
stopStreamingText();
|
|
1052
1212
|
textSubscription == null ? void 0 : textSubscription.unsubscribe();
|
|
1213
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(TextMessage, {
|
|
1214
|
+
id: messageId,
|
|
1215
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1216
|
+
content: textChunks.join(""),
|
|
1217
|
+
role: MessageRole.assistant
|
|
1218
|
+
}));
|
|
1053
1219
|
}
|
|
1054
1220
|
});
|
|
1055
1221
|
})
|
|
@@ -1067,11 +1233,13 @@ var CopilotResolver = class {
|
|
|
1067
1233
|
scope: event.scope,
|
|
1068
1234
|
arguments: new import_graphql_yoga.Repeater(async (pushArgumentsChunk, stopStreamingArguments) => {
|
|
1069
1235
|
logger2.debug("Action execution argument stream created");
|
|
1236
|
+
const argumentChunks = [];
|
|
1070
1237
|
let actionExecutionArgumentSubscription;
|
|
1071
1238
|
actionExecutionArgumentSubscription = actionExecutionArgumentStream.subscribe({
|
|
1072
1239
|
next: async (e) => {
|
|
1073
1240
|
if (e.type == RuntimeEventTypes.ActionExecutionArgs) {
|
|
1074
1241
|
await pushArgumentsChunk(e.args);
|
|
1242
|
+
argumentChunks.push(e.args);
|
|
1075
1243
|
}
|
|
1076
1244
|
},
|
|
1077
1245
|
error: (err) => {
|
|
@@ -1089,6 +1257,13 @@ var CopilotResolver = class {
|
|
|
1089
1257
|
streamingArgumentsStatus.next(new SuccessMessageStatus());
|
|
1090
1258
|
stopStreamingArguments();
|
|
1091
1259
|
actionExecutionArgumentSubscription == null ? void 0 : actionExecutionArgumentSubscription.unsubscribe();
|
|
1260
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(ActionExecutionMessage, {
|
|
1261
|
+
id: event.actionExecutionId,
|
|
1262
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1263
|
+
name: event.actionName,
|
|
1264
|
+
scope: event.scope,
|
|
1265
|
+
arguments: argumentChunks.join("")
|
|
1266
|
+
}));
|
|
1092
1267
|
}
|
|
1093
1268
|
});
|
|
1094
1269
|
})
|
|
@@ -1106,6 +1281,13 @@ var CopilotResolver = class {
|
|
|
1106
1281
|
actionName: event.actionName,
|
|
1107
1282
|
result: event.result
|
|
1108
1283
|
});
|
|
1284
|
+
outputMessages.push((0, import_class_transformer.plainToInstance)(ResultMessage, {
|
|
1285
|
+
id: (0, import_nanoid.nanoid)(),
|
|
1286
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1287
|
+
actionExecutionId: event.actionExecutionId,
|
|
1288
|
+
actionName: event.actionName,
|
|
1289
|
+
result: event.result
|
|
1290
|
+
}));
|
|
1109
1291
|
break;
|
|
1110
1292
|
}
|
|
1111
1293
|
},
|
|
@@ -1118,17 +1300,19 @@ var CopilotResolver = class {
|
|
|
1118
1300
|
}));
|
|
1119
1301
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
1120
1302
|
stopStreamingMessages();
|
|
1303
|
+
rejectOutputMessagesPromise(err);
|
|
1121
1304
|
},
|
|
1122
1305
|
complete: async () => {
|
|
1123
|
-
var
|
|
1306
|
+
var _a3;
|
|
1124
1307
|
logger2.debug("Event stream completed");
|
|
1125
|
-
if ((
|
|
1308
|
+
if ((_a3 = data.cloud) == null ? void 0 : _a3.guardrails) {
|
|
1126
1309
|
logger2.debug("Guardrails is enabled, waiting for guardrails result");
|
|
1127
1310
|
await (0, import_rxjs2.firstValueFrom)(guardrailsResult$);
|
|
1128
1311
|
}
|
|
1129
1312
|
responseStatus$.next(new SuccessResponseStatus());
|
|
1130
1313
|
eventStreamSubscription == null ? void 0 : eventStreamSubscription.unsubscribe();
|
|
1131
1314
|
stopStreamingMessages();
|
|
1315
|
+
resolveOutputMessagesPromise(outputMessages);
|
|
1132
1316
|
}
|
|
1133
1317
|
});
|
|
1134
1318
|
})
|
|
@@ -1230,10 +1414,20 @@ function getCommonConfig(options) {
|
|
|
1230
1414
|
level: logLevel,
|
|
1231
1415
|
component: "getCommonConfig"
|
|
1232
1416
|
});
|
|
1233
|
-
logger2.debug("Getting common config");
|
|
1234
1417
|
const contextLogger = createLogger({
|
|
1235
1418
|
level: logLevel
|
|
1236
1419
|
});
|
|
1420
|
+
if (options.cloud) {
|
|
1421
|
+
telemetry_client_default.setCloudConfiguration({
|
|
1422
|
+
publicApiKey: options.cloud.publicApiKey,
|
|
1423
|
+
baseUrl: options.cloud.baseUrl
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
telemetry_client_default.setGlobalProperties({
|
|
1427
|
+
runtime: {
|
|
1428
|
+
serviceAdapter: options.serviceAdapter.constructor.name
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1237
1431
|
return {
|
|
1238
1432
|
logging: createLogger({
|
|
1239
1433
|
component: "Yoga GraphQL",
|
|
@@ -1251,6 +1445,12 @@ __name(getCommonConfig, "getCommonConfig");
|
|
|
1251
1445
|
// src/lib/integrations/node-http/index.ts
|
|
1252
1446
|
function copilotRuntimeNodeHttpEndpoint(options) {
|
|
1253
1447
|
const commonConfig = getCommonConfig(options);
|
|
1448
|
+
telemetry_client_default.setGlobalProperties({
|
|
1449
|
+
runtime: {
|
|
1450
|
+
framework: "node-http"
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
telemetry_client_default.capture("oss.runtime.instance_created", {});
|
|
1254
1454
|
const logger2 = commonConfig.logging;
|
|
1255
1455
|
logger2.debug("Creating Node HTTP endpoint");
|
|
1256
1456
|
const yoga = (0, import_graphql_yoga2.createYoga)({
|