2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { spawn } from 'child_process';
7
>
import type { CustomAgentConfig, MCPServerConfig, SessionConfig } from '@github/copilot-sdk';
8
>
import { Schemas } from '../../../../base/common/network.js';
9
>
import { OperatingSystem, OS } from '../../../../base/common/platform.js';
10
>
import { URI } from '../../../../base/common/uri.js';
11
>
import { parseFrontMatter } from '../../../../base/common/yaml.js';
12
>
import { IFileService } from '../../../files/common/files.js';
13
>
import { McpServerType, type IMcpServerConfiguration } from '../../../mcp/common/mcpPlatformTypes.js';
14
>
import type { IMcpServerDefinition, INamedPluginResource, IParsedAgent, IParsedHookCommand, IParsedHookGroup, IParsedPlugin } from '../../../agentPlugins/common/pluginParsers.js';
15
>
import { type AgentCustomization, type ChildCustomization } from '../../common/state/protocol/state.js';
16
>
import { dirname } from '../../../../base/common/path.js';
17
>
18
>
type SessionHooks = NonNullable<SessionConfig['hooks']>;
19
>
type PreToolUseHookInput = Parameters<NonNullable<SessionHooks['onPreToolUse']>>[0];
20
>
type PostToolUseHookInput = Parameters<NonNullable<SessionHooks['onPostToolUse']>>[0];
21
>
type UserPromptSubmittedHookInput = Parameters<NonNullable<SessionHooks['onUserPromptSubmitted']>>[0];
22
>
type SessionStartHookInput = Parameters<NonNullable<SessionHooks['onSessionStart']>>[0];
23
>
type SessionEndHookInput = Parameters<NonNullable<SessionHooks['onSessionEnd']>>[0];
24
>
type ErrorOccurredHookInput = Parameters<NonNullable<SessionHooks['onErrorOccurred']>>[0];
25
>
26
>
// ---------------------------------------------------------------------------
27
>
// MCP servers
28
>
// ---------------------------------------------------------------------------
29
>
30
>
/**
31
>
* Converts parsed MCP server definitions into the SDK's `mcpServers` config.
32
>
*/
33
>
export function toSdkMcpServers(defs: readonly IMcpServerDefinition[]): Record<string, MCPServerConfig> {
34
const result: Record<string, MCPServerConfig> = {};
35
for (const def of defs) {