@copilotkit/runtime 0.37.0 → 0.38.0-mme-alpha.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/.turbo/turbo-build.log +69 -54
- package/CHANGELOG.md +11 -0
- package/__snapshots__/schema/schema.graphql +15 -4
- package/dist/{chunk-NFCPM5AM.mjs → chunk-6NZ4UMOD.mjs} +4 -4
- package/dist/chunk-6NZ4UMOD.mjs.map +1 -0
- package/dist/{chunk-2CCVVJDU.mjs → chunk-6OJ47NCG.mjs} +13 -15
- package/dist/chunk-6OJ47NCG.mjs.map +1 -0
- package/dist/chunk-BYB2LNMK.mjs +152 -0
- package/dist/chunk-BYB2LNMK.mjs.map +1 -0
- package/dist/{chunk-XPAUPJMW.mjs → chunk-EWS5TMDA.mjs} +411 -206
- package/dist/chunk-EWS5TMDA.mjs.map +1 -0
- package/dist/{chunk-7IFP53C6.mjs → chunk-FRK6BXXV.mjs} +49 -11
- package/dist/chunk-FRK6BXXV.mjs.map +1 -0
- package/dist/{chunk-BLTAUVRP.mjs → chunk-OZMCHYYR.mjs} +5 -3
- package/dist/{chunk-BLTAUVRP.mjs.map → chunk-OZMCHYYR.mjs.map} +1 -1
- package/dist/chunk-RHQLCJGG.mjs +7 -0
- package/dist/chunk-RHQLCJGG.mjs.map +1 -0
- package/dist/{chunk-5HGYI6EG.mjs → chunk-XI3HBDMA.mjs} +13 -5
- package/dist/chunk-XI3HBDMA.mjs.map +1 -0
- package/dist/{chunk-4UA4RB4C.mjs → chunk-XXYCNRFT.mjs} +12 -10
- package/dist/chunk-XXYCNRFT.mjs.map +1 -0
- package/dist/failed-response-status-reasons-0ab19e06.d.ts +49 -0
- package/dist/graphql/types/base/index.mjs +2 -1
- package/dist/graphql/types/converted/index.mjs +3 -2
- package/dist/{index-f0875df3.d.ts → index-d5ba24be.d.ts} +24 -23
- package/dist/index.d.ts +7 -4
- package/dist/index.js +486 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{langchain-adapter-9ce103f3.d.ts → langchain-adapter-54784d29.d.ts} +1 -1
- package/dist/{langserve-fd5066ee.d.ts → langserve-63794237.d.ts} +24 -7
- package/dist/lib/cloud/index.d.ts +6 -0
- package/dist/lib/cloud/index.js +18 -0
- package/dist/lib/cloud/index.js.map +1 -0
- package/dist/lib/cloud/index.mjs +1 -0
- package/dist/lib/cloud/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +6 -4
- package/dist/lib/index.js +480 -96
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +9 -7
- package/dist/lib/integrations/index.d.ts +5 -3
- package/dist/lib/integrations/index.js +419 -80
- package/dist/lib/integrations/index.js.map +1 -1
- package/dist/lib/integrations/index.mjs +7 -5
- package/dist/lib/integrations/node-http/index.d.ts +4 -2
- package/dist/lib/integrations/node-http/index.js +409 -68
- package/dist/lib/integrations/node-http/index.js.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +6 -4
- package/dist/pages-router-d94f01da.d.ts +21 -0
- package/dist/service-adapters/index.d.ts +2 -2
- package/dist/service-adapters/index.js +54 -8
- package/dist/service-adapters/index.js.map +1 -1
- package/dist/service-adapters/index.mjs +5 -4
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +174 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +6 -4
- package/src/graphql/inputs/cloud-guardrails.input.ts +2 -5
- package/src/graphql/inputs/cloud.input.ts +2 -2
- package/src/graphql/resolvers/copilot.resolver.ts +269 -30
- package/src/graphql/types/response-status.type.ts +16 -2
- package/src/index.ts +1 -0
- package/src/lib/cloud/index.ts +4 -0
- package/src/lib/copilot-runtime.ts +13 -37
- package/src/lib/integrations/nextjs/app-router.ts +9 -17
- package/src/lib/integrations/nextjs/pages-router.ts +9 -15
- package/src/lib/integrations/node-http/index.ts +6 -14
- package/src/lib/integrations/shared.ts +37 -17
- package/src/lib/logger.ts +28 -0
- package/src/service-adapters/events.ts +20 -2
- package/src/service-adapters/google/google-genai-adapter.ts +3 -0
- package/src/service-adapters/google/utils.ts +1 -1
- package/src/service-adapters/index.ts +1 -1
- package/src/service-adapters/langchain/langserve.ts +10 -4
- package/src/service-adapters/langchain/utils.ts +58 -9
- package/src/utils/failed-response-status-reasons.ts +48 -0
- package/src/utils/index.ts +1 -0
- package/dist/chunk-2CCVVJDU.mjs.map +0 -1
- package/dist/chunk-4UA4RB4C.mjs.map +0 -1
- package/dist/chunk-5HGYI6EG.mjs.map +0 -1
- package/dist/chunk-7IFP53C6.mjs.map +0 -1
- package/dist/chunk-NFCPM5AM.mjs.map +0 -1
- package/dist/chunk-XPAUPJMW.mjs.map +0 -1
- package/dist/pages-router-b6bc6c60.d.ts +0 -30
- package/src/lib/guardrails.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/copilot-runtime.ts","../src/lib/copilot-cloud.ts","../src/service-adapters/conversion.ts"],"sourcesContent":["/**\n * Handles requests from frontend, provides function calling and various LLM backends.\n *\n * <img\n * referrerPolicy=\"no-referrer-when-downgrade\"\n * src=\"https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be\"\n * />\n *\n * <RequestExample>\n * ```jsx CopilotRuntime Example\n * import {\n * CopilotRuntime,\n * OpenAIAdapter\n * } from \"@copilotkit/runtime\";\n *\n * export async function POST(req: Request) {\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OpenAIAdapter());\n * }\n *\n * ```\n * </RequestExample>\n *\n * This class is the main entry point for the runtime. It handles requests from the frontend, provides function calling and various LLM backends.\n *\n * For example, to use OpenAI as a backend (check the [OpenAI Adapter](./OpenAIAdapter) docs for more info):\n * ```typescript\n * const copilotKit = new CopilotRuntime();\n * return copilotKit.response(req, new OpenAIAdapter());\n * ```\n *\n * Currently we support:\n *\n * - [OpenAI](./OpenAIAdapter)\n * - [LangChain](./LangChainAdapter)\n * - [OpenAI Assistant API](./OpenAIAssistantAdapter)\n * - [Google Gemini](./GoogleGenerativeAIAdapter)\n *\n * ## Server Side Actions\n *\n * CopilotKit supports actions that can be executed on the server side. You can define server side actions by passing the `actions` parameter:\n *\n * ```typescript\n * const copilotKit = new CopilotRuntime({\n * actions: [\n * {\n * name: \"sayHello\",\n * description: \"Says hello to someone.\",\n * argumentAnnotations: [\n * {\n * name: \"arg\",\n * type: \"string\",\n * description: \"The name of the person to say hello to.\",\n * required: true,\n * },\n * ],\n * implementation: async (arg) => {\n * console.log(\"Hello from the server\", arg, \"!\");\n * },\n * },\n * ],\n * });\n * ```\n *\n * Server side actions can also return a result which becomes part of the message history.\n *\n * This is useful because it gives the LLM context about what happened on the server side. In addition,\n * it can be used to look up information from a vector or relational database and other sources.\n *\n * In addition to that, server side actions can also come from LangChain, including support for streaming responses.\n *\n * Returned results can be of the following type:\n *\n * - anything serializable to JSON\n * - `string`\n * - LangChain types:\n * - `IterableReadableStream`\n * - `BaseMessageChunk`\n * - `AIMessage`\n *\n * ## LangServe\n *\n * The backend also supports LangServe, enabling you to connect to existing chains, for example python based chains.\n * Use the `langserve` parameter to specify URLs for LangServe.\n *\n * ```typescript\n * const copilotKit = new CopilotRuntime({\n * langserve: [\n * {\n * chainUrl: \"http://my-langserve.chain\",\n * name: \"performResearch\",\n * description: \"Performs research on a given topic.\",\n * },\n * ],\n * });\n * ```\n *\n * When left out, arguments are automatically inferred from the schema provided by LangServe.\n */\n\nimport { Action, actionParametersToJsonSchema, Parameter } from \"@copilotkit/shared\";\nimport { RemoteChain, RemoteChainParameters, CopilotServiceAdapter } from \"../service-adapters\";\nimport { CopilotCloud, RemoteCopilotCloud } from \"./copilot-cloud\";\nimport { MessageInput } from \"../graphql/inputs/message.input\";\nimport { ActionInput } from \"../graphql/inputs/action.input\";\nimport { RuntimeEventSource } from \"../service-adapters/events\";\nimport { convertGqlInputToMessages } from \"../service-adapters/conversion\";\n\ninterface CopilotRuntimeRequest {\n serviceAdapter: CopilotServiceAdapter;\n messages: MessageInput[];\n actions: ActionInput[];\n threadId?: string;\n runId?: string;\n publicApiKey?: string;\n}\n\ninterface CopilotRuntimeResponse {\n threadId?: string;\n runId?: string;\n eventSource: RuntimeEventSource;\n actions: Action<any>[];\n}\n\nexport interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {\n /*\n * A list of server side actions that can be executed.\n */\n actions?: Action<T>[];\n\n /*\n * An array of LangServer URLs.\n */\n langserve?: RemoteChainParameters[];\n\n debug?: boolean;\n copilotCloud?: CopilotCloud;\n}\n\nexport class CopilotRuntime<const T extends Parameter[] | [] = []> {\n public actions: Action<any>[] = [];\n private langserve: Promise<Action<any>>[] = [];\n private debug: boolean = false;\n private copilotCloud: CopilotCloud;\n\n constructor(params?: CopilotRuntimeConstructorParams<T>) {\n this.actions = params?.actions || [];\n\n for (const chain of params?.langserve || []) {\n const remoteChain = new RemoteChain(chain);\n this.langserve.push(remoteChain.toAction());\n }\n this.debug = params?.debug || false;\n this.copilotCloud = params?.copilotCloud || new RemoteCopilotCloud();\n }\n\n addAction<const T extends Parameter[] | [] = []>(action: Action<T>): void {\n this.removeAction(action.name);\n this.actions.push(action);\n }\n\n removeAction(actionName: string): void {\n this.actions = this.actions.filter((f) => f.name !== actionName);\n }\n\n async process({\n serviceAdapter,\n messages,\n actions: clientSideActionsInput,\n threadId,\n runId,\n publicApiKey,\n }: CopilotRuntimeRequest): Promise<CopilotRuntimeResponse> {\n const langserveFunctions: Action<any>[] = [];\n\n for (const chainPromise of this.langserve) {\n try {\n const chain = await chainPromise;\n langserveFunctions.push(chain);\n } catch (error) {\n console.error(\"Error loading langserve chain:\", error);\n }\n }\n\n const actions = [...this.actions, ...langserveFunctions];\n\n const serverSideActionsInput: ActionInput[] = actions.map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n }));\n\n const actionInputs = flattenToolCallsNoDuplicates([\n ...serverSideActionsInput,\n ...clientSideActionsInput,\n ]);\n\n try {\n const eventSource = new RuntimeEventSource();\n // TODO-PROTOCOL: type this and support function calls\n const result = await serviceAdapter.process({\n messages: convertGqlInputToMessages(messages),\n actions: actionInputs,\n threadId,\n runId,\n eventSource,\n });\n\n return {\n threadId: result.threadId,\n runId: result.runId,\n eventSource,\n actions,\n };\n } catch (error) {\n console.error(\"Error getting response:\", error);\n throw error;\n }\n }\n}\n\nexport function flattenToolCallsNoDuplicates(toolsByPriority: ActionInput[]): ActionInput[] {\n let allTools: ActionInput[] = [];\n const allToolNames: string[] = [];\n for (const tool of toolsByPriority) {\n if (!allToolNames.includes(tool.name)) {\n allTools.push(tool);\n allToolNames.push(tool.name);\n }\n }\n return allTools;\n}\n\n/**\n * @deprecated use CopilotRuntime instead\n */\nexport class CopilotBackend extends CopilotRuntime {}\n","import {\n COPILOT_CLOUD_API_URL,\n COPILOT_CLOUD_VERSION,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n CopilotCloudConfig,\n} from \"@copilotkit/shared\";\n\nexport interface CloudCheckGuardrailsInputParams {\n cloud: CopilotCloudConfig;\n publicApiKey: string;\n // TODO-PROTOCOL: switch to graphql\n messages: any[];\n}\n\nexport interface CloudCheckGuardrailsInputResponse {\n status: \"allowed\" | \"denied\";\n reason: string;\n}\n\nexport abstract class CopilotCloud {\n abstract checkGuardrailsInput(\n params: CloudCheckGuardrailsInputParams,\n ): Promise<CloudCheckGuardrailsInputResponse>;\n}\n\nexport class RemoteCopilotCloud extends CopilotCloud {\n constructor(private readonly cloudApiUrl: string = COPILOT_CLOUD_API_URL) {\n super();\n }\n\n async checkGuardrailsInput({\n cloud,\n publicApiKey,\n messages,\n }: CloudCheckGuardrailsInputParams): Promise<CloudCheckGuardrailsInputResponse> {\n const url = `${this.cloudApiUrl}/${COPILOT_CLOUD_VERSION}/copilotkit/guardrails/input`;\n\n const response = await fetch(url, {\n method: \"PUT\",\n headers: {\n \"Content-Type\": \"application/json\",\n [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey,\n },\n body: JSON.stringify({ messages, cloud }),\n });\n\n if (!response.ok) {\n let message = response.statusText;\n\n // try to parse the response body for a more detailed error message\n try {\n const json = await response.json();\n if (json.message) {\n message = json.message;\n }\n } catch (error) {}\n\n throw new Error(\"Failed to check input guardrails: \" + message);\n }\n const json = await response.json();\n return { status: json.status, reason: json.reason };\n }\n}\n","import {\n ActionExecutionMessage,\n Message,\n ResultMessage,\n TextMessage,\n} from \"../graphql/types/converted\";\nimport { MessageInput } from \"../graphql/inputs/message.input\";\nimport { plainToInstance } from \"class-transformer\";\n\nexport function convertGqlInputToMessages(inputMessages: MessageInput[]): Message[] {\n const messages: Message[] = [];\n\n for (const message of inputMessages) {\n if (message.textMessage) {\n messages.push(\n plainToInstance(TextMessage, {\n id: message.id,\n createdAt: message.createdAt,\n role: message.textMessage.role,\n content: message.textMessage.content,\n }),\n );\n } else if (message.actionExecutionMessage) {\n messages.push(\n plainToInstance(ActionExecutionMessage, {\n id: message.id,\n createdAt: message.createdAt,\n name: message.actionExecutionMessage.name,\n arguments: JSON.parse(message.actionExecutionMessage.arguments),\n scope: message.actionExecutionMessage.scope,\n }),\n );\n } else if (message.resultMessage) {\n messages.push(\n plainToInstance(ResultMessage, {\n id: message.id,\n createdAt: message.createdAt,\n actionExecutionId: message.resultMessage.actionExecutionId,\n actionName: message.resultMessage.actionName,\n result: message.resultMessage.result,\n }),\n );\n }\n }\n\n return messages;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoGA,SAAiBA,oCAA+C;;;ACpGhE,SACEC,uBACAC,uBACAC,2CAEK;AAcA,IAAeC,eAAf,MAAeA;AAItB;AAJsBA;AAMf,IAAMC,qBAAN,cAAiCD,aAAAA;;EACtCE,YAA6BC,cAAsBC,uBAAuB;AACxE,UAAK;SADsBD,cAAAA;EAE7B;EAEA,MAAME,qBAAqB,EACzBC,OACAC,cACA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AU,CAAA;IAC3E,EAAA;AAEA,UAAMC,eAAeC,6BAA6B;SAC7CT;SACAR;KACJ;AAED,QAAI;AACF,YAAMkB,cAAc,IAAIC,mBAAAA;AAExB,YAAMC,SAAS,MAAMtB,eAAeD,QAAQ;QAC1CE,UAAUsB,0BAA0BtB,QAAAA;QACpCrB,SAASsC;QACTf;QACAC;QACAgB;MACF,CAAA;AAEA,aAAO;QACLjB,UAAUmB,OAAOnB;QACjBC,OAAOkB,OAAOlB;QACdgB;QACAxC;MACF;IACF,SAAS4B,OAAP;AACAC,cAAQD,MAAM,2BAA2BA,KAAAA;AACzC,YAAMA;IACR;EACF;AACF;AAhFa7B;AAkFN,SAASwC,6BAA6BK,iBAA8B;AACzE,MAAIC,WAA0B,CAAA;AAC9B,QAAMC,eAAyB,CAAA;AAC/B,aAAWC,QAAQH,iBAAiB;AAClC,QAAI,CAACE,aAAaE,SAASD,KAAKhC,IAAI,GAAG;AACrC8B,eAASpC,KAAKsC,IAAAA;AACdD,mBAAarC,KAAKsC,KAAKhC,IAAI;IAC7B;EACF;AACA,SAAO8B;AACT;AAVgBN;AAeT,IAAMU,iBAAN,cAA6BlD,eAAAA;AAAgB;AAAvCkD;","names":["actionParametersToJsonSchema","COPILOT_CLOUD_API_URL","COPILOT_CLOUD_VERSION","COPILOT_CLOUD_PUBLIC_API_KEY_HEADER","CopilotCloud","RemoteCopilotCloud","constructor","cloudApiUrl","COPILOT_CLOUD_API_URL","checkGuardrailsInput","cloud","publicApiKey","messages","url","COPILOT_CLOUD_VERSION","response","fetch","method","headers","COPILOT_CLOUD_PUBLIC_API_KEY_HEADER","body","JSON","stringify","ok","message","statusText","json","error","Error","status","reason","plainToInstance","convertGqlInputToMessages","inputMessages","messages","message","textMessage","push","plainToInstance","TextMessage","id","createdAt","role","content","actionExecutionMessage","ActionExecutionMessage","name","arguments","JSON","parse","scope","resultMessage","ResultMessage","actionExecutionId","actionName","result","CopilotRuntime","actions","langserve","debug","copilotCloud","constructor","params","chain","remoteChain","RemoteChain","push","toAction","RemoteCopilotCloud","addAction","action","removeAction","name","actionName","filter","f","process","serviceAdapter","messages","clientSideActionsInput","threadId","runId","publicApiKey","langserveFunctions","chainPromise","error","console","serverSideActionsInput","map","description","jsonSchema","JSON","stringify","actionParametersToJsonSchema","parameters","actionInputs","flattenToolCallsNoDuplicates","eventSource","RuntimeEventSource","result","convertGqlInputToMessages","toolsByPriority","allTools","allToolNames","tool","includes","CopilotBackend"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
declare enum ResponseStatusCode {
|
|
2
|
+
Pending = "pending",
|
|
3
|
+
Success = "success",
|
|
4
|
+
Failed = "failed"
|
|
5
|
+
}
|
|
6
|
+
declare abstract class BaseResponseStatus {
|
|
7
|
+
code: ResponseStatusCode;
|
|
8
|
+
}
|
|
9
|
+
declare enum FailedResponseStatusReason {
|
|
10
|
+
GUARDRAILS_VALIDATION_FAILED = "GUARDRAILS_VALIDATION_FAILED",
|
|
11
|
+
MESSAGE_STREAM_INTERRUPTED = "MESSAGE_STREAM_INTERRUPTED",
|
|
12
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
13
|
+
}
|
|
14
|
+
declare class FailedResponseStatus extends BaseResponseStatus {
|
|
15
|
+
code: ResponseStatusCode;
|
|
16
|
+
reason: FailedResponseStatusReason;
|
|
17
|
+
details?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class GuardrailsValidationFailureResponse extends FailedResponseStatus {
|
|
21
|
+
reason: FailedResponseStatusReason;
|
|
22
|
+
details: {
|
|
23
|
+
guardrailsReason: string;
|
|
24
|
+
};
|
|
25
|
+
constructor({ guardrailsReason }: {
|
|
26
|
+
guardrailsReason: any;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
declare class MessageStreamInterruptedResponse extends FailedResponseStatus {
|
|
30
|
+
reason: FailedResponseStatusReason;
|
|
31
|
+
details: {
|
|
32
|
+
messageId: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
constructor({ messageId }: {
|
|
36
|
+
messageId: string;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
declare class UnknownErrorResponse extends FailedResponseStatus {
|
|
40
|
+
reason: FailedResponseStatusReason;
|
|
41
|
+
details: {
|
|
42
|
+
description?: string;
|
|
43
|
+
};
|
|
44
|
+
constructor({ description }: {
|
|
45
|
+
description?: string;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { GuardrailsValidationFailureResponse as G, MessageStreamInterruptedResponse as M, UnknownErrorResponse as U };
|
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
ActionExecutionMessage,
|
|
3
3
|
ResultMessage,
|
|
4
4
|
TextMessage
|
|
5
|
-
} from "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
5
|
+
} from "../../../chunk-OZMCHYYR.mjs";
|
|
6
|
+
import "../../../chunk-6NZ4UMOD.mjs";
|
|
7
|
+
import "../../../chunk-RHQLCJGG.mjs";
|
|
7
8
|
export {
|
|
8
9
|
ActionExecutionMessage,
|
|
9
10
|
ResultMessage,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as graphql_yoga from 'graphql-yoga';
|
|
2
|
-
import { YogaInitialContext } from 'graphql-yoga';
|
|
2
|
+
import { YogaInitialContext, createYoga } from 'graphql-yoga';
|
|
3
3
|
import * as graphql from 'graphql';
|
|
4
|
+
import * as pino from 'pino';
|
|
4
5
|
import { CopilotCloudConfig, Parameter, Action } from '@copilotkit/shared';
|
|
5
|
-
import { R as
|
|
6
|
+
import { R as RemoteChainParameters, A as ActionInput, C as CopilotServiceAdapter, a as RuntimeEventSource } from './langserve-63794237.js';
|
|
6
7
|
import { M as MessageInput } from './index-aa091e3c.js';
|
|
8
|
+
import { CopilotCloudOptions } from './lib/cloud/index.js';
|
|
7
9
|
|
|
8
10
|
interface CloudCheckGuardrailsInputParams {
|
|
9
11
|
cloud: CopilotCloudConfig;
|
|
@@ -135,10 +137,11 @@ interface CopilotRuntimeResponse {
|
|
|
135
137
|
threadId?: string;
|
|
136
138
|
runId?: string;
|
|
137
139
|
eventSource: RuntimeEventSource;
|
|
140
|
+
actions: Action<any>[];
|
|
138
141
|
}
|
|
139
142
|
interface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []> {
|
|
140
143
|
actions?: Action<T>[];
|
|
141
|
-
langserve?:
|
|
144
|
+
langserve?: RemoteChainParameters[];
|
|
142
145
|
debug?: boolean;
|
|
143
146
|
copilotCloud?: CopilotCloud;
|
|
144
147
|
}
|
|
@@ -159,39 +162,37 @@ declare function flattenToolCallsNoDuplicates(toolsByPriority: ActionInput[]): A
|
|
|
159
162
|
declare class CopilotBackend extends CopilotRuntime {
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
baseUrl: string;
|
|
164
|
-
}
|
|
165
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
165
166
|
|
|
167
|
+
declare const logger: pino.Logger<never>;
|
|
166
168
|
type AnyPrimitive = string | boolean | number | null;
|
|
167
169
|
type CopilotRequestContextProperties = Record<string, AnyPrimitive | Record<string, AnyPrimitive>>;
|
|
168
|
-
type CopilotKitContext = {
|
|
169
|
-
runtime: CopilotRuntime;
|
|
170
|
-
serviceAdapter: CopilotServiceAdapter;
|
|
171
|
-
properties: CopilotRequestContextProperties;
|
|
172
|
-
};
|
|
173
170
|
type GraphQLContext = YogaInitialContext & {
|
|
174
|
-
_copilotkit:
|
|
171
|
+
_copilotkit: CreateCopilotRuntimeServerOptions;
|
|
172
|
+
properties: CopilotRequestContextProperties;
|
|
173
|
+
logger: typeof logger;
|
|
175
174
|
};
|
|
176
175
|
interface CreateCopilotRuntimeServerOptions {
|
|
177
176
|
runtime: CopilotRuntime;
|
|
178
177
|
serviceAdapter: CopilotServiceAdapter;
|
|
179
|
-
|
|
178
|
+
endpoint: string;
|
|
179
|
+
baseUrl?: string;
|
|
180
|
+
cloud?: CopilotCloudOptions;
|
|
181
|
+
properties?: CopilotRequestContextProperties;
|
|
182
|
+
logLevel?: LogLevel;
|
|
180
183
|
}
|
|
181
|
-
declare function createContext(initialContext: YogaInitialContext, copilotKitContext:
|
|
184
|
+
declare function createContext(initialContext: YogaInitialContext, copilotKitContext: CreateCopilotRuntimeServerOptions, contextLogger: typeof logger, properties?: CopilotRequestContextProperties): Promise<Partial<GraphQLContext>>;
|
|
182
185
|
declare function buildSchema(options?: {
|
|
183
186
|
emitSchemaFile?: string;
|
|
184
187
|
}): graphql.GraphQLSchema;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
type CommonConfig = {
|
|
189
|
+
logging: typeof logger;
|
|
190
|
+
schema: ReturnType<typeof buildSchema>;
|
|
191
|
+
plugins: Parameters<typeof createYoga>[0]["plugins"];
|
|
188
192
|
context: (ctx: YogaInitialContext) => Promise<Partial<GraphQLContext>>;
|
|
189
193
|
};
|
|
194
|
+
declare function getCommonConfig(options: CreateCopilotRuntimeServerOptions): CommonConfig;
|
|
190
195
|
|
|
191
|
-
declare function copilotRuntimeNodeHttpEndpoint(
|
|
192
|
-
runtime: CopilotRuntime;
|
|
193
|
-
serviceAdapter: CopilotServiceAdapter;
|
|
194
|
-
endpoint: string;
|
|
195
|
-
}): graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
196
|
+
declare function copilotRuntimeNodeHttpEndpoint(options: CreateCopilotRuntimeServerOptions): graphql_yoga.YogaServerInstance<{}, Partial<GraphQLContext>>;
|
|
196
197
|
|
|
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,
|
|
198
|
+
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, CommonConfig as k, getCommonConfig as l, copilotRuntimeNodeHttpEndpoint as m };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
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,
|
|
2
|
-
export { G as GoogleGenerativeAIAdapter, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams } from './langchain-adapter-
|
|
3
|
-
export { C as CopilotRuntimeServerInstance, a as config, c as copilotRuntimeNextJSAppRouterEndpoint, b as copilotRuntimeNextJSPagesRouterEndpoint } from './pages-router-
|
|
1
|
+
export { c as CloudCheckGuardrailsInputParams, d as CloudCheckGuardrailsInputResponse, k as CommonConfig, 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, m as copilotRuntimeNodeHttpEndpoint, i as createContext, f as flattenToolCallsNoDuplicates, l as getCommonConfig } from './index-d5ba24be.js';
|
|
2
|
+
export { G as GoogleGenerativeAIAdapter, L as LangChainAdapter, a as OpenAIAdapter, O as OpenAIAdapterParams, c as OpenAIAssistantAdapter, b as OpenAIAssistantAdapterParams } from './langchain-adapter-54784d29.js';
|
|
3
|
+
export { C as CopilotRuntimeServerInstance, a as config, c as copilotRuntimeNextJSAppRouterEndpoint, b as copilotRuntimeNextJSPagesRouterEndpoint } from './pages-router-d94f01da.js';
|
|
4
|
+
export { G as GuardrailsValidationFailureResponse, M as MessageStreamInterruptedResponse, U as UnknownErrorResponse } from './failed-response-status-reasons-0ab19e06.js';
|
|
4
5
|
import 'graphql-yoga';
|
|
5
6
|
import 'graphql';
|
|
7
|
+
import 'pino';
|
|
6
8
|
import '@copilotkit/shared';
|
|
7
|
-
import './langserve-
|
|
9
|
+
import './langserve-63794237.js';
|
|
8
10
|
import './index-aa091e3c.js';
|
|
9
11
|
import './graphql/types/base/index.js';
|
|
10
12
|
import 'rxjs';
|
|
13
|
+
import './lib/cloud/index.js';
|
|
11
14
|
import 'openai';
|
|
12
15
|
import '@google/generative-ai';
|
|
13
16
|
import '@langchain/core/messages';
|