Protected ReadonlycliProtectedloadedProtectedloadedProtected ReadonlyloggerProtecteddoProtecteddynamicDynamic import through a constructed function, so that a bundler leaves it alone: what is imported here is resolved on the machine running the backend, not at build time.
ProtectedimportImports an installed @github/copilot-sdk, for an application that depends on the package.
ProtectedimportImports the copy of the SDK that ships with the CLI. It is an ES module, hence the import by URL.
Loads the SDK, and remembers it for as long as the CLI it belongs to stays the same.
ProtectedtoChecks that what was loaded provides what is used, so that an incompatible CLI is reported as such instead of failing somewhere in the middle of a request.
ProtectedtryImports an installed SDK if there is one, so that a missing package is reported as the CLI not providing what is needed rather than as a module that cannot be found.
Provides the Copilot SDK that belongs to the Copilot CLI in use.
The SDK is not a dependency of this extension. It is published as
@github/copilot-sdk, but that package depends on the CLI, which is a large proprietary binary that an application must not have to ship, see CopilotCliLocator. The CLI carries its own copy of the SDK, so the one belonging to the CLI that is actually going to serve the requests is loaded from there. What is used of its API is mirrored incopilot-sdk-types.tsrather than taken from the package.An installed
@github/copilot-sdkis used when the CLI does not carry one, so that an application which does depend on the package keeps working.