Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/chatSessions/copilotcli/vscode-node/tools/updateSessionName.ts
13406 views
1
/*---------------------------------------------------------------------------------------------
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 type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
import { z } from 'zod';
8
import { ILogger } from '../../../../../platform/log/common/logService';
9
import { ICopilotCLISessionTracker } from '../copilotCLISessionTracker';
10
import { makeTextResult } from './utils';
11
12
export function registerUpdateSessionNameTool(server: McpServer, logger: ILogger, sessionTracker: ICopilotCLISessionTracker, sessionId: string): void {
13
const schema = {
14
name: z.string().describe('The new session name'),
15
};
16
server.registerTool(
17
'update_session_name',
18
{
19
description: 'Update the display name for the current CLI session',
20
inputSchema: schema,
21
},
22
// @ts-ignore - TS2589: zod type instantiation too deep for server.tool() generics
23
async (args: { name: string }) => {
24
const { name } = args;
25
logger.debug(`Updating session name for ${sessionId} to "${name}"`);
26
sessionTracker.setSessionName(sessionId, name);
27
return makeTextResult({ success: true });
28
}
29
);
30
}
31
32