-
-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathcommon.ts
More file actions
143 lines (131 loc) · 4.01 KB
/
Copy pathcommon.ts
File metadata and controls
143 lines (131 loc) · 4.01 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Common type definitions used across the server
*
* This module provides core type definitions and interfaces used throughout the codebase.
* It establishes a consistent type system for platform identification, tool responses,
* and other shared concepts.
*
* Responsibilities:
* - Defining the XcodePlatform enum for platform identification
* - Establishing the ToolResponse interface for standardized tool outputs
* - Providing ToolResponseContent types for different response formats
* - Supporting error handling with standardized error response types
*/
/**
* Represents a suggested next step that can be rendered for CLI or MCP.
*/
export interface NextStep {
/** Optional MCP tool name (e.g., "boot_sim") */
tool?: string;
/** CLI tool name (kebab-case, disambiguated) */
cliTool?: string;
/** Workflow name for CLI grouping (e.g., "simulator") */
workflow?: string;
/** Human-readable description of the action (optional when manifest template provides it) */
label?: string;
/** Optional parameters to pass to the tool */
params?: Record<string, string | number | boolean>;
/** Optional ordering hint for merged steps */
priority?: number;
}
export type NextStepParams = Record<string, string | number | boolean>;
export type NextStepParamsMap = Record<string, NextStepParams | NextStepParams[]>;
/**
* Output style controls verbosity of tool responses.
* - 'normal': Full output including next steps
* - 'minimal': Essential result only, no next steps
*/
export type OutputStyle = 'normal' | 'minimal';
/**
* Enum representing Xcode build platforms.
*/
export enum XcodePlatform {
macOS = 'macOS',
iOS = 'iOS',
iOSSimulator = 'iOS Simulator',
watchOS = 'watchOS',
watchOSSimulator = 'watchOS Simulator',
tvOS = 'tvOS',
tvOSSimulator = 'tvOS Simulator',
visionOS = 'visionOS',
visionOSSimulator = 'visionOS Simulator',
}
/**
* ToolResponse - Standard response format for tools
* Compatible with MCP CallToolResult interface from the SDK
*/
export interface ToolResponse {
content: ToolResponseContent[];
isError?: boolean;
_meta?: Record<string, unknown>;
/** Structured next steps that get rendered differently for CLI vs MCP */
nextSteps?: NextStep[];
/** Dynamic params for manifest nextSteps keyed by toolId */
nextStepParams?: NextStepParamsMap;
[key: string]: unknown; // Index signature to match CallToolResult
}
/**
* Contents that can be included in a tool response
*/
export type ToolResponseContent =
| {
type: 'text';
text: string;
[key: string]: unknown; // Index signature to match ContentItem
}
| {
type: 'image';
data: string; // Base64-encoded image data (without URI scheme prefix)
mimeType: string; // e.g., 'image/png', 'image/jpeg'
[key: string]: unknown; // Index signature to match ContentItem
};
export function createTextContent(text: string): { type: 'text'; text: string } {
return { type: 'text', text };
}
export function createImageContent(
data: string,
mimeType: string,
): { type: 'image'; data: string; mimeType: string } {
return { type: 'image', data, mimeType };
}
/**
* ValidationResult - Result of parameter validation operations
*/
export interface ValidationResult {
isValid: boolean;
errorResponse?: ToolResponse;
warningResponse?: ToolResponse;
}
/**
* CommandResponse - Generic result of command execution
*/
export interface CommandResponse {
success: boolean;
output: string;
error?: string;
process?: unknown; // ChildProcess from node:child_process
}
/**
* Interface for shared build parameters
*/
export interface SharedBuildParams {
workspacePath?: string;
projectPath?: string;
scheme: string;
configuration: string;
derivedDataPath?: string;
extraArgs?: string[];
}
/**
* Interface for platform-specific build options
*/
export interface PlatformBuildOptions {
platform: XcodePlatform;
simulatorName?: string;
simulatorId?: string;
deviceId?: string;
useLatestOS?: boolean;
packageCachePath?: string;
arch?: string;
logPrefix: string;
}