@copilotkit/runtime
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
1 lines • 2.42 kB
Source Map (JSON)
{"version":3,"file":"learning.mjs","names":[],"sources":["../../../../src/v2/runtime/core/learning.ts"],"sourcesContent":["import type { MaybePromise } from \"@copilotkit/shared\";\n\n/** Context for choosing one Learning Container for an Intelligence run. */\nexport type CopilotRuntimeLearningContext =\n | {\n readonly surface: \"web\";\n readonly request: Request;\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n }\n | {\n readonly surface: \"channel\";\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n readonly deliveryId: string;\n };\n\n/** Assigns each Intelligence Thread to one developer-created Learning Container. */\nexport interface CopilotRuntimeLearningConfig {\n readonly containerId:\n | string\n | ((\n input: CopilotRuntimeLearningContext,\n ) => MaybePromise<string | null | undefined>);\n}\n\nconst STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Validates and returns a stable Learning Container ID. */\nexport function assertStableLearningContainerId(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > 64 ||\n !STABLE_CONTAINER_ID.test(value)\n ) {\n throw new Error(\n \"Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens\",\n );\n }\n return value;\n}\n\n/** Resolves the configured Container once for one web or Channel run. */\nexport async function resolveLearningContainerId(\n config: CopilotRuntimeLearningConfig | undefined,\n input: CopilotRuntimeLearningContext,\n): Promise<string | undefined> {\n if (config === undefined) return undefined;\n const value =\n typeof config.containerId === \"function\"\n ? await config.containerId(input)\n : config.containerId;\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n"],"mappings":";;AA8BA,MAAM,sBAAsB;;AAG5B,SAAgB,gCAAgC,OAAwB;AACtE,KACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,SAAS,MACf,CAAC,oBAAoB,KAAK,MAAM,CAEhC,OAAM,IAAI,MACR,6GACD;AAEH,QAAO;;;AAIT,eAAsB,2BACpB,QACA,OAC6B;AAC7B,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QACJ,OAAO,OAAO,gBAAgB,aAC1B,MAAM,OAAO,YAAY,MAAM,GAC/B,OAAO;AACb,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM"}