Skip to content

Commit 2b00687

Browse files
committed
feat: add dynamic next steps commands
1 parent ae22440 commit 2b00687

File tree

1 file changed

+156
-8
lines changed

1 file changed

+156
-8
lines changed

pkg/create/templates.go

Lines changed: 156 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ import (
66
"sort"
77
)
88

9+
// Template key constants
10+
const (
11+
TemplateSampleApp = "sample-app"
12+
TemplateAdvancedSample = "advanced-sample"
13+
TemplateComputerUse = "computer-use"
14+
TemplateCUA = "cua"
15+
TemplateMagnitude = "magnitude"
16+
TemplateGeminiCUA = "gemini-cua"
17+
TemplateBrowserUse = "browser-use"
18+
TemplateStagehand = "stagehand"
19+
)
20+
921
type TemplateInfo struct {
1022
Name string
1123
Description string
@@ -20,42 +32,42 @@ type TemplateKeyValue struct {
2032
type TemplateKeyValues []TemplateKeyValue
2133

2234
var Templates = map[string]TemplateInfo{
23-
"sample-app": {
35+
TemplateSampleApp: {
2436
Name: "Sample App",
2537
Description: "Implements basic Kernel apps",
2638
Languages: []string{LanguageTypeScript, LanguagePython},
2739
},
28-
"advanced-sample": {
40+
TemplateAdvancedSample: {
2941
Name: "Advanced Sample",
3042
Description: "Implements sample actions with advanced Kernel configs",
3143
Languages: []string{LanguageTypeScript, LanguagePython},
3244
},
33-
"computer-use": {
45+
TemplateComputerUse: {
3446
Name: "Computer Use",
3547
Description: "Implements the Anthropic Computer Use SDK",
3648
Languages: []string{LanguageTypeScript, LanguagePython},
3749
},
38-
"cua": {
50+
TemplateCUA: {
3951
Name: "CUA Sample",
4052
Description: "Implements a Computer Use Agent (OpenAI CUA) sample",
4153
Languages: []string{LanguageTypeScript, LanguagePython},
4254
},
43-
"magnitude": {
55+
TemplateMagnitude: {
4456
Name: "Magnitude",
4557
Description: "Implements the Magnitude.run SDK",
4658
Languages: []string{LanguageTypeScript},
4759
},
48-
"gemini-cua": {
60+
TemplateGeminiCUA: {
4961
Name: "Gemini CUA",
5062
Description: "Implements Gemini 2.5 Computer Use Agent",
5163
Languages: []string{LanguageTypeScript},
5264
},
53-
"browser-use": {
65+
TemplateBrowserUse: {
5466
Name: "Browser Use",
5567
Description: "Implements Browser Use SDK",
5668
Languages: []string{LanguagePython},
5769
},
58-
"stagehand": {
70+
TemplateStagehand: {
5971
Name: "Stagehand",
6072
Description: "Implements the Stagehand v3 SDK",
6173
Languages: []string{LanguageTypeScript},
@@ -109,3 +121,139 @@ func (tkv TemplateKeyValues) ContainsKey(key string) bool {
109121
}
110122
return false
111123
}
124+
125+
type DeployConfig struct {
126+
EntryPoint string
127+
EnvVars []string
128+
InvokeCommand string
129+
RegisteredAppName string
130+
}
131+
132+
var Commands = map[string]map[string]DeployConfig{
133+
LanguageTypeScript: {
134+
TemplateSampleApp: {
135+
EntryPoint: "index.ts",
136+
EnvVars: []string{},
137+
InvokeCommand: `kernel invoke ts-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
138+
RegisteredAppName: "ts-basic",
139+
},
140+
TemplateAdvancedSample: {
141+
EntryPoint: "index.ts",
142+
EnvVars: []string{},
143+
InvokeCommand: "kernel invoke ts-advanced test-captcha-solver",
144+
RegisteredAppName: "ts-advanced",
145+
},
146+
TemplateStagehand: {
147+
EntryPoint: "index.ts",
148+
EnvVars: []string{"OPENAI_API_KEY=XXX"},
149+
InvokeCommand: `kernel invoke ts-stagehand teamsize-task --payload '{"company": "Kernel"}'`,
150+
RegisteredAppName: "ts-stagehand",
151+
},
152+
TemplateComputerUse: {
153+
EntryPoint: "index.ts",
154+
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
155+
InvokeCommand: `kernel invoke ts-cu cu-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
156+
RegisteredAppName: "ts-cu",
157+
},
158+
TemplateMagnitude: {
159+
EntryPoint: "index.ts",
160+
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
161+
InvokeCommand: `kernel invoke ts-magnitude mag-url-extract --payload '{"url": "https://en.wikipedia.org/wiki/Special:Random"}'`,
162+
RegisteredAppName: "ts-magnitude",
163+
},
164+
TemplateCUA: {
165+
EntryPoint: "index.ts",
166+
EnvVars: []string{"OPENAI_API_KEY=XXX"},
167+
InvokeCommand: `kernel invoke ts-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
168+
RegisteredAppName: "ts-cua",
169+
},
170+
TemplateGeminiCUA: {
171+
EntryPoint: "index.ts",
172+
EnvVars: []string{"GOOGLE_API_KEY=XXX", "OPENAI_API_KEY=XXX"},
173+
InvokeCommand: "kernel invoke ts-gemini-cua gemini-cua-task",
174+
RegisteredAppName: "ts-gemini-cua",
175+
},
176+
},
177+
LanguagePython: {
178+
TemplateSampleApp: {
179+
EntryPoint: "main.py",
180+
EnvVars: []string{},
181+
InvokeCommand: `kernel invoke python-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
182+
RegisteredAppName: "python-basic",
183+
},
184+
TemplateAdvancedSample: {
185+
EntryPoint: "main.py",
186+
EnvVars: []string{},
187+
InvokeCommand: "kernel invoke python-advanced test-captcha-solver",
188+
RegisteredAppName: "python-advanced",
189+
},
190+
TemplateBrowserUse: {
191+
EntryPoint: "main.py",
192+
EnvVars: []string{"OPENAI_API_KEY=XXX"},
193+
InvokeCommand: `kernel invoke python-bu bu-task --payload '{"task": "Compare the price of gpt-4o and DeepSeek-V3"}'`,
194+
RegisteredAppName: "python-bu",
195+
},
196+
TemplateComputerUse: {
197+
EntryPoint: "main.py",
198+
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
199+
InvokeCommand: `kernel invoke python-cu cu-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
200+
RegisteredAppName: "python-cu",
201+
},
202+
TemplateCUA: {
203+
EntryPoint: "main.py",
204+
EnvVars: []string{"OPENAI_API_KEY=XXX"},
205+
InvokeCommand: `kernel invoke python-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
206+
RegisteredAppName: "python-cua",
207+
},
208+
},
209+
}
210+
211+
// GetDeployCommand returns the full deploy command string for a given language and template
212+
func GetDeployCommand(language, template string) string {
213+
langCommands, ok := Commands[language]
214+
if !ok {
215+
return ""
216+
}
217+
218+
config, ok := langCommands[template]
219+
if !ok {
220+
return ""
221+
}
222+
223+
cmd := "kernel deploy " + config.EntryPoint
224+
for _, env := range config.EnvVars {
225+
cmd += " --env " + env
226+
}
227+
228+
return cmd
229+
}
230+
231+
// GetInvokeSample returns the sample invoke command for a given language and template
232+
func GetInvokeSample(language, template string) string {
233+
langSamples, ok := Commands[language]
234+
if !ok {
235+
return ""
236+
}
237+
238+
config, ok := langSamples[template]
239+
if !ok {
240+
return ""
241+
}
242+
243+
return config.InvokeCommand
244+
}
245+
246+
// GetRegisteredAppName returns the registered app name for a given language and template
247+
func GetRegisteredAppName(language, template string) string {
248+
langNames, ok := Commands[language]
249+
if !ok {
250+
return ""
251+
}
252+
253+
config, ok := langNames[template]
254+
if !ok {
255+
return ""
256+
}
257+
258+
return config.RegisteredAppName
259+
}

0 commit comments

Comments
 (0)