{"version":3,"file":"app-router.mjs","names":[],"sources":["../../../../src/lib/integrations/nextjs/app-router.ts"],"sourcesContent":["import { createCopilotEndpointSingleRoute } from \"../../../v2/runtime\";\nimport { CreateCopilotRuntimeServerOptions, getCommonConfig } from \"../shared\";\nimport telemetry, {\n  getRuntimeInstanceTelemetryInfo,\n} from \"../../telemetry-client\";\nimport { handle } from \"hono/vercel\";\n\nexport function copilotRuntimeNextJSAppRouterEndpoint(\n  options: CreateCopilotRuntimeServerOptions,\n) {\n  const commonConfig = getCommonConfig(options);\n\n  telemetry.setGlobalProperties({\n    runtime: {\n      framework: \"nextjs-app-router\",\n    },\n  });\n\n  if (options.properties?._copilotkit) {\n    telemetry.setGlobalProperties({\n      _copilotkit: options.properties._copilotkit,\n    });\n  }\n\n  telemetry.capture(\n    \"oss.runtime.instance_created\",\n    getRuntimeInstanceTelemetryInfo(options),\n  );\n\n  const logger = commonConfig.logging;\n  logger.debug(\"Creating NextJS App Router endpoint\");\n\n  const serviceAdapter = options.serviceAdapter;\n  if (serviceAdapter) {\n    options.runtime.handleServiceAdapter(serviceAdapter);\n  }\n\n  // Note: cors option requires @copilotkit/runtime with credentials support\n  const copilotRoute = createCopilotEndpointSingleRoute({\n    runtime: options.runtime.instance,\n    basePath: options.baseUrl ?? options.endpoint,\n    ...(options.cors && { cors: options.cors }),\n  } as any);\n\n  const handleRequest = handle(copilotRoute as any);\n  return { handleRequest };\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,sCACd,SACA;CACA,MAAM,eAAe,gBAAgB,QAAQ;AAE7C,iBAAU,oBAAoB,EAC5B,SAAS,EACP,WAAW,qBACZ,EACF,CAAC;AAEF,KAAI,QAAQ,YAAY,YACtB,iBAAU,oBAAoB,EAC5B,aAAa,QAAQ,WAAW,aACjC,CAAC;AAGJ,iBAAU,QACR,gCACA,gCAAgC,QAAQ,CACzC;AAGD,CADe,aAAa,QACrB,MAAM,sCAAsC;CAEnD,MAAM,iBAAiB,QAAQ;AAC/B,KAAI,eACF,SAAQ,QAAQ,qBAAqB,eAAe;AAWtD,QAAO,EAAE,eADa,OAND,iCAAiC;EACpD,SAAS,QAAQ,QAAQ;EACzB,UAAU,QAAQ,WAAW,QAAQ;EACrC,GAAI,QAAQ,QAAQ,EAAE,MAAM,QAAQ,MAAM;EAC3C,CAAQ,CAEwC,EACzB"}