-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathconstants.ts
More file actions
185 lines (161 loc) · 6.41 KB
/
constants.ts
File metadata and controls
185 lines (161 loc) · 6.41 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import { z } from 'zod';
// ============================================================================
// Feature Constants (shared across all schemas)
// ============================================================================
export const SDKFrameworkSchema = z.enum(['Strands', 'LangChain_LangGraph', 'GoogleADK', 'OpenAIAgents']);
export type SDKFramework = z.infer<typeof SDKFrameworkSchema>;
export const TargetLanguageSchema = z.enum(['Python', 'TypeScript', 'Other']);
export type TargetLanguage = z.infer<typeof TargetLanguageSchema>;
export const ModelProviderSchema = z.enum(['Bedrock', 'Gemini', 'OpenAI', 'Anthropic']);
export type ModelProvider = z.infer<typeof ModelProviderSchema>;
/** Providers that use credentials (Bedrock uses IAM, no credential needed). */
export const CREDENTIAL_PROVIDERS = ['Gemini', 'OpenAI', 'Anthropic'] as const;
/**
* Case-insensitively match a user-provided value against a Zod enum's options.
* Returns the canonical (correctly-cased) value, or undefined if no match.
*/
export function matchEnumValue(schema: { options: readonly string[] }, input: string): string | undefined {
const lower = input.toLowerCase();
return schema.options.find(v => v.toLowerCase() === lower);
}
/**
* Default model IDs used for each provider.
* These are the models generated in agent templates.
*/
export const DEFAULT_MODEL_IDS: Record<ModelProvider, string> = {
Bedrock: 'us.anthropic.claude-sonnet-4-5-20250514-v1:0',
Anthropic: 'claude-sonnet-4-5-20250514',
OpenAI: 'gpt-4.1',
Gemini: 'gemini-2.5-flash',
};
/**
* Matrix defining which model providers are supported for each SDK framework.
* - Most SDKs support all 4 providers (Bedrock, Anthropic, OpenAI, Gemini)
* - GoogleADK only supports Gemini (uses Google's native API)
* - OpenAIAgents only supports OpenAI (uses OpenAI's native API)
*/
export const SDK_MODEL_PROVIDER_MATRIX: Record<SDKFramework, readonly ModelProvider[]> = {
Strands: ['Bedrock', 'Anthropic', 'OpenAI', 'Gemini'] as const,
LangChain_LangGraph: ['Bedrock', 'Anthropic', 'OpenAI', 'Gemini'] as const,
GoogleADK: ['Gemini'] as const,
OpenAIAgents: ['OpenAI'] as const,
};
/**
* Returns the supported model providers for a given SDK framework.
*/
export function getSupportedModelProviders(sdk: SDKFramework): readonly ModelProvider[] {
return SDK_MODEL_PROVIDER_MATRIX[sdk];
}
/**
* Checks if a model provider is supported for a given SDK framework.
*/
export function isModelProviderSupported(sdk: SDKFramework, provider: ModelProvider): boolean {
return SDK_MODEL_PROVIDER_MATRIX[sdk].includes(provider);
}
// ============================================================================
// Reserved Project Names (Python package conflicts)
// ============================================================================
/**
* Project/agent names that would conflict with Python package names when
* creating a virtual environment. If the project directory name matches
* a dependency name, uv/pip will fail to resolve dependencies correctly.
*
* This list includes all dependencies used across SDK templates, normalized
* to valid project name format (lowercase, underscores replaced with nothing
* since project names are alphanumeric only).
*/
export const RESERVED_PROJECT_NAMES: readonly string[] = [
// Core SDK packages
'anthropic',
'autogen',
'autogenagentchat',
'autogenext',
'bedrock',
'bedrockagentcore',
'googleadk',
'googlegenerativeai',
'langchain',
'langchainanthropic',
'langchainaws',
'langchaingooglegenai',
'langchainmcpadapters',
'langchainopenai',
'langgraph',
'mcp',
'openai',
'openaiagents',
'strands',
'strandsagents',
'strandsagentstools',
// Common utilities
'httpx',
'pytest',
'pytestasyncio',
'pythondotenv',
// Build tools
'hatchling',
'setuptools',
'wheel',
// AWS packages
'awsopentelemetrydistro',
'boto3',
'botocore',
// Common Python stdlib/package names that could cause issues
'test',
'tests',
'src',
'lib',
'dist',
'build',
'env',
'venv',
'site',
'pip',
'uv',
] as const;
/**
* Check if a project name is reserved (case-insensitive).
*/
export function isReservedProjectName(name: string): boolean {
return RESERVED_PROJECT_NAMES.includes(name.toLowerCase());
}
// ============================================================================
// Infrastructure Constants (shared between agent-env and mcp schemas)
// ============================================================================
export const PythonRuntimeSchema = z.enum(['PYTHON_3_10', 'PYTHON_3_11', 'PYTHON_3_12', 'PYTHON_3_13', 'PYTHON_3_14']);
export type PythonRuntime = z.infer<typeof PythonRuntimeSchema>;
/** Default Python runtime version for new agents and MCP tools */
export const DEFAULT_PYTHON_VERSION: PythonRuntime = 'PYTHON_3_14';
export const NodeRuntimeSchema = z.enum(['NODE_18', 'NODE_20', 'NODE_22']);
export type NodeRuntime = z.infer<typeof NodeRuntimeSchema>;
/** Combined runtime version schema supporting both Python and Node/TypeScript runtimes */
export const RuntimeVersionSchema = z.union([PythonRuntimeSchema, NodeRuntimeSchema]);
export type RuntimeVersion = z.infer<typeof RuntimeVersionSchema>;
export const NetworkModeSchema = z.enum(['PUBLIC', 'VPC']);
export type NetworkMode = z.infer<typeof NetworkModeSchema>;
// ============================================================================
// Protocol Mode
// ============================================================================
export const ProtocolModeSchema = z.enum(['HTTP', 'MCP', 'A2A']);
export type ProtocolMode = z.infer<typeof ProtocolModeSchema>;
/**
* Matrix defining which SDK frameworks are supported for each protocol mode.
* MCP is a standalone tool server with no framework.
*/
export const PROTOCOL_FRAMEWORK_MATRIX: Record<ProtocolMode, readonly SDKFramework[]> = {
HTTP: ['Strands', 'LangChain_LangGraph', 'GoogleADK', 'OpenAIAgents'] as const,
MCP: [] as const,
A2A: ['Strands', 'GoogleADK', 'LangChain_LangGraph'] as const,
};
/**
* Returns the supported SDK frameworks for a given protocol mode.
*/
export function getSupportedFrameworksForProtocol(protocol: ProtocolMode): readonly SDKFramework[] {
return PROTOCOL_FRAMEWORK_MATRIX[protocol];
}
/**
* Checks if a framework is supported for a given protocol mode.
*/
export function isFrameworkSupportedForProtocol(protocol: ProtocolMode, framework: SDKFramework): boolean {
return PROTOCOL_FRAMEWORK_MATRIX[protocol].includes(framework);
}