@@ -13,7 +13,7 @@ const __dirname = path.dirname(__filename);
1313
1414// Types for better type safety
1515type LanguageKey = 'typescript' | 'python' ;
16- type TemplateKey = 'sample-app' | 'browser-use' ;
16+ type TemplateKey = 'sample-app' | 'browser-use' | 'stagehand' ;
1717type LanguageInfo = { name : string ; shorthand: string } ;
1818type TemplateInfo = { name : string ; description: string ; languages: LanguageKey [ ] } ;
1919
@@ -22,6 +22,7 @@ const LANGUAGE_TYPESCRIPT = 'typescript';
2222const LANGUAGE_PYTHON = 'python' ;
2323const TEMPLATE_SAMPLE_APP = 'sample-app' ;
2424const TEMPLATE_BROWSER_USE = 'browser-use' ;
25+ const TEMPLATE_STAGEHAND = 'stagehand' ;
2526const LANGUAGE_SHORTHAND_TS = 'ts' ;
2627const LANGUAGE_SHORTHAND_PY = 'py' ;
2728
@@ -41,13 +42,19 @@ const TEMPLATES: Record<TemplateKey, TemplateInfo> = {
4142 name : 'Browser Use' ,
4243 description : 'Implements Browser Use SDK' ,
4344 languages : [ LANGUAGE_PYTHON ]
44- }
45+ } ,
46+ [ TEMPLATE_STAGEHAND ] : {
47+ name : 'Stagehand' ,
48+ description : 'Implements the Stagehand SDK' ,
49+ languages : [ LANGUAGE_TYPESCRIPT ]
50+ } ,
4551} ;
4652
4753const INVOKE_SAMPLES : Record < string , string > = {
4854 'typescript-sample-app' : 'kernel invoke ts-basic get-page-title --payload \'{"url": "https://www.google.com"}\'' ,
4955 'python-sample-app' : 'kernel invoke python-basic get-page-title --payload \'{"url": "https://www.google.com"}\'' ,
50- 'python-browser-use' : 'kernel invoke python-bu bu-task --payload \'{"task": "Compare the price of gpt-4o and DeepSeek-V3"}\''
56+ 'python-browser-use' : 'kernel invoke python-bu bu-task --payload \'{"task": "Compare the price of gpt-4o and DeepSeek-V3"}\'' ,
57+ 'typescript-stagehand' : 'kernel invoke ts-stagehand stagehand-task --payload \'{"query": "Best wired earbuds"}\''
5158} ;
5259
5360const CONFIG = {
@@ -227,7 +234,8 @@ async function setupDependencies(appPath: string, language: LanguageKey): Promis
227234// Print success message with next steps
228235function printNextSteps ( appName : string , language : LanguageKey , template : TemplateKey ) : void {
229236 // Determine which sample command to show based on language and template
230- const deployCommand = language === LANGUAGE_TYPESCRIPT ? 'kernel deploy index.ts'
237+ const deployCommand = language === LANGUAGE_TYPESCRIPT && template === TEMPLATE_SAMPLE_APP ? 'kernel deploy index.ts'
238+ : language === LANGUAGE_TYPESCRIPT && template === TEMPLATE_STAGEHAND ? 'kernel deploy index.ts --env OPENAI_API_KEY=XXX'
231239 : language === LANGUAGE_PYTHON && template === TEMPLATE_SAMPLE_APP ? 'kernel deploy main.py'
232240 : language === LANGUAGE_PYTHON && template === TEMPLATE_BROWSER_USE ? 'kernel deploy main.py --env OPENAI_API_KEY=XXX'
233241 : '' ;
@@ -254,7 +262,7 @@ program
254262 . version ( '0.1.0' )
255263 . argument ( '[app-name]' , 'Name of your Kernel app' )
256264 . option ( '-l, --language <language>' , `Programming language (${ LANGUAGE_TYPESCRIPT } /${ LANGUAGE_SHORTHAND_TS } , ${ LANGUAGE_PYTHON } /${ LANGUAGE_SHORTHAND_PY } )` )
257- . option ( '-t, --template <template>' , `Template type (${ TEMPLATE_SAMPLE_APP } , ${ TEMPLATE_BROWSER_USE } )` )
265+ . option ( '-t, --template <template>' , `Template type (${ TEMPLATE_SAMPLE_APP } , ${ TEMPLATE_BROWSER_USE } , ${ TEMPLATE_STAGEHAND } )` )
258266 . action ( async ( appName : string , options : { language ?: string ; template ?: string } ) => {
259267 try {
260268 let normalizedLanguage : LanguageKey | null = null ;
0 commit comments