Skip to content

@makaio/ai-adapters-github-copilot-sdk

GitHub Copilot SDK adapter for the Makaio AI framework.

import {
createGitHubCopilotSDKAdapter,
GitHubCopilotAdapter,
} from '@makaio/ai-adapters-github-copilot-sdk';
import { MakaioBus } from '@makaio/bus-core';
import { AdapterSubjects } from '@makaio/contracts';
// Using the factory function (recommended)
const adapter = await createGitHubCopilotSDKAdapter();
const result = await MakaioBus.request(AdapterSubjects.startAgent, {
adapterId: adapter.adapterId,
role: 'lead',
initialMessage: 'Inspect this repository',
});
// Or using the class directly
const directAdapter = new GitHubCopilotAdapter();
await directAdapter.init();
const directResult = await MakaioBus.request(AdapterSubjects.startAgent, {
adapterId: directAdapter.adapterId,
role: 'lead',
initialMessage: 'Inspect this repository',
});

This adapter follows the three-layer architecture pattern:

GitHubCopilotAdapter extends AIAdapter
-> creates via agentFactory()
GitHubCopilotAgent extends AIAgent
-> receives connector via connectorFactory()
GitHubCopilotConnector extends AIAgentConnector

Layers:

LayerClassResponsibility
AdapterGitHubCopilotAdapterFactory for agents, handles adapter.startAgent RPC
AgentGitHubCopilotAgentWires events to global bus, manages lifecycle
ConnectorGitHubCopilotConnectorSDK-level bridge to GitHub Copilot

Session/Turn Management:

ClassPurpose
CopilotConnectorSessionSession lifecycle management
CopilotConnectorTurnIndividual turn handling
UserMessageQueueInternal connector queue from adapter core
  • tools - Tool/function calling support
  • systemPrompt:override - Replace/set the system prompt
  • systemPrompt:append - Append to the adapter’s default system prompt
  • Tool approval workflow via registerToolApprovalHandler
  • Replace and interrupt delivery modes
  • Model metadata from the model registry and canonical provider definitions

Note: Runtime model lists come from the canonical GitHub Copilot provider definition and model registry, not provider config. Registry generation can use provider.fetcher.ts, which asks the Copilot SDK for models using the SDK’s own authentication flow.

ExportDescription
GitHubCopilotAdapterMain adapter class
createGitHubCopilotSDKAdapterFactory function (creates and initializes)
GitHubCopilotSdkAdapterNameAdapter identifier constant
ExportDescription
GitHubCopilotAgentAgent class (middle layer)
GitHubCopilotConnectorConnector class (SDK bridge)
ExportDescription
CopilotConnectorSessionSession abstraction
CopilotConnectorTurnTurn abstraction
UserMessageQueueInternal connector queue from adapter core
ExportDescription
GitHubCopilotConnectorNamespaceBus namespace for connector events
GitHubCopilotConnectorSubjectsSubject constants for bus messaging
GitHubCopilotConnectorBusBus type for connector
CopilotSessionOptionsSession options type
ConsumptionCompleteResultConsumption result type
GitHubCopilotAgentConnectorConfigAgent connector config type
ExportDescription
registerToolApprovalHandlerRegister handler for tool approval requests
requestToolApprovalRequest tool approval
toGlobalToolApprovalConvert to global approval format
fromGlobalToolApprovalConvert from global approval format
mapPermissionRequestToCoreRequestMap Copilot permission to core request
mapCoreResponseToPermissionResultMap core response to Copilot permission
ExportDescription
GitHubCopilotSdkProviderConfigSchemaZod schema for provider config
GitHubCopilotSdkProviderSettingsProvider settings type
createTestConfigConformance test configuration factory

Runtime registration is contributed by @makaio/ai-adapters-github-copilot-sdk/server. That entrypoint default-exports the githubCopilotSdkPackage MakaioExtension descriptor, whose adapters[] entry wraps the internal definition from src/definition.ts.

ExportDescription
normalizeGitHubCopilotLogRecordMain dispatcher for all event types
normalizeAssistantTurnStartNormalize assistant.turn_start to agent.started
normalizeAssistantMessageNormalize assistant.message to agent.message
normalizeToolUserRequestedNormalize tool.user_requested to agent.tool.use
normalizeToolExecutionStartNormalize tool.execution_start
normalizeToolExecutionPartialResultNormalize tool.execution_partial_result
normalizeToolExecutionCompleteNormalize tool.execution_complete
normalizeSessionTruncationNormalize session.truncation to agent.usage
normalizeSessionErrorNormalize session.error to agent.error
normalizeUserMessageNormalize user.message (import-only)
normalizeAssistantTurnEndNormalize assistant.turn_end (import-only)
NormalizationContextContext for normalization
RawGitHubCopilotLogRecordRaw log record structure
NormalizeOptionsOptions for normalization

Runtime sessions require GitHub Copilot credentials. COPILOT_TOKEN is a runtime credential environment variable when credentials are provided through the environment. The canonical GitHub Copilot provider maps the stored token credential field to COPILOT_TOKEN; the connector also accepts a resolved token credential directly and passes it to the SDK as githubToken.

Model registry generation uses the Copilot SDK authentication flow (for example an authenticated GitHub CLI session or supported SDK token source), not provider config.

src/
├── index.ts # Package exports
├── adapter.ts # GitHubCopilotAdapter class
├── agent.ts # GitHubCopilotAgent class
├── connector.ts # GitHubCopilotConnector class
├── session.ts # Session management
├── turn.ts # Turn management
├── config.ts # Configuration utilities
├── constants.ts # Adapter constants
├── definition.ts # Internal adapter definition
├── package.ts # MakaioExtension package descriptor
├── provider.ts # Provider registration
├── provider.fetcher.ts # Registry model fetcher using Copilot SDK auth
├── server.ts # Server entrypoint exporting the package descriptor
├── schemas.ts # Zod schemas
├── tool-handling.ts # Tool approval utilities
├── event-normalizers.ts # Event normalization
├── namespaces/ # Bus namespace definitions
│ └── schemas/ # Message schemas
├── types/ # TypeScript types
└── utils/ # Utility functions
├── formatMessageHistoryAsTranscript.ts
└── normalizedMessageToPrompt.ts

Part of the Makaio AI framework