-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathsession_clear_defaults.ts
More file actions
37 lines (32 loc) · 1.11 KB
/
session_clear_defaults.ts
File metadata and controls
37 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { z } from 'zod';
import { sessionStore } from '../../../utils/session-store.ts';
import { createTypedTool } from '../../../utils/typed-tool-factory.ts';
import { getDefaultCommandExecutor } from '../../../utils/execution/index.ts';
import type { ToolResponse } from '../../../types/common.ts';
const keys = [
'projectPath',
'workspacePath',
'scheme',
'configuration',
'simulatorName',
'simulatorId',
'deviceId',
'useLatestOS',
'arch',
] as const;
const schemaObj = z.object({
keys: z.array(z.enum(keys)).optional(),
all: z.boolean().optional(),
});
type Params = z.infer<typeof schemaObj>;
export async function sessionClearDefaultsLogic(params: Params): Promise<ToolResponse> {
if (params.all || !params.keys) sessionStore.clear();
else sessionStore.clear(params.keys);
return { content: [{ type: 'text', text: 'Session defaults cleared' }], isError: false };
}
export default {
name: 'session-clear-defaults',
description: 'Clear selected or all session defaults.',
schema: schemaObj.shape,
handler: createTypedTool(schemaObj, sessionClearDefaultsLogic, getDefaultCommandExecutor),
};