Skip to content

Commit df4689f

Browse files
committed
Improve CLI templates: browser cleanup, env files, and rename advanced-sample
- Add kernel.browsers.deleteByID() to all templates to properly close live view on exit - Switch deploy instructions to use --env-file .env instead of inline --env flags - Add .env.example files for templates requiring API keys - Remove 'brew install' from Next steps (user already has CLI installed) - Rename advanced-sample template to captcha-solver (more descriptive) - Switch from playwright to playwright-core in TypeScript templates - Update all dependencies to latest versions - Fix devDependencies in package.json files - Add DuckDuckGo as starting URL for CUA templates (less captcha friction) - Clean up stale advanced-sample directory
1 parent 637dcef commit df4689f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+11920
-7438
lines changed

pkg/create/dependencies.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func getNextStepsWithToolInstall(appName string, language string, requiredTool s
6868
pnpm install
6969
7070
# Deploy your app:
71-
brew install onkernel/tap/kernel
7271
kernel login # or: export KERNEL_API_KEY=<YOUR_API_KEY>
7372
%s
7473
%s
@@ -85,7 +84,6 @@ func getNextStepsWithToolInstall(appName string, language string, requiredTool s
8584
uv venv && source .venv/bin/activate && uv sync
8685
8786
# Deploy your app:
88-
brew install onkernel/tap/kernel
8987
kernel login # or: export KERNEL_API_KEY=<YOUR_API_KEY>
9088
%s
9189
%s
@@ -100,7 +98,6 @@ func getNextStepsStandard(appName string, language string, template string) stri
10098
deployCommand := GetDeployCommand(language, template)
10199
invokeCommand := GetInvokeSample(language, template)
102100
return pterm.FgYellow.Sprintf(`Next steps:
103-
brew install onkernel/tap/kernel
104101
cd %s
105102
kernel login # or: export KERNEL_API_KEY=<YOUR_API_KEY>
106103
%s

pkg/create/templates.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88

99
// Template key constants
1010
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"
11+
TemplateSampleApp = "sample-app"
12+
TemplateCaptchaSolver = "captcha-solver"
13+
TemplateComputerUse = "computer-use"
14+
TemplateCUA = "cua"
15+
TemplateMagnitude = "magnitude"
16+
TemplateGeminiCUA = "gemini-cua"
17+
TemplateBrowserUse = "browser-use"
18+
TemplateStagehand = "stagehand"
1919
)
2020

2121
type TemplateInfo struct {
@@ -37,9 +37,9 @@ var Templates = map[string]TemplateInfo{
3737
Description: "Implements basic Kernel apps",
3838
Languages: []string{LanguageTypeScript, LanguagePython},
3939
},
40-
TemplateAdvancedSample: {
41-
Name: "Advanced Sample",
42-
Description: "Implements sample actions with advanced Kernel configs",
40+
TemplateCaptchaSolver: {
41+
Name: "CAPTCHA Solver",
42+
Description: "Demo of Kernel's auto-CAPTCHA solving capability",
4343
Languages: []string{LanguageTypeScript, LanguagePython},
4444
},
4545
TemplateComputerUse: {
@@ -124,72 +124,72 @@ func (tkv TemplateKeyValues) ContainsKey(key string) bool {
124124

125125
type DeployConfig struct {
126126
EntryPoint string
127-
EnvVars []string
127+
NeedsEnvFile bool
128128
InvokeCommand string
129129
}
130130

131131
var Commands = map[string]map[string]DeployConfig{
132132
LanguageTypeScript: {
133133
TemplateSampleApp: {
134134
EntryPoint: "index.ts",
135-
EnvVars: []string{},
135+
NeedsEnvFile: false,
136136
InvokeCommand: `kernel invoke ts-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
137137
},
138-
TemplateAdvancedSample: {
138+
TemplateCaptchaSolver: {
139139
EntryPoint: "index.ts",
140-
EnvVars: []string{},
141-
InvokeCommand: "kernel invoke ts-advanced test-captcha-solver",
140+
NeedsEnvFile: false,
141+
InvokeCommand: "kernel invoke ts-captcha-solver test-captcha-solver",
142142
},
143143
TemplateStagehand: {
144144
EntryPoint: "index.ts",
145-
EnvVars: []string{"OPENAI_API_KEY=XXX"},
145+
NeedsEnvFile: true,
146146
InvokeCommand: `kernel invoke ts-stagehand teamsize-task --payload '{"company": "Kernel"}'`,
147147
},
148148
TemplateComputerUse: {
149149
EntryPoint: "index.ts",
150-
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
150+
NeedsEnvFile: true,
151151
InvokeCommand: `kernel invoke ts-cu cu-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
152152
},
153153
TemplateMagnitude: {
154154
EntryPoint: "index.ts",
155-
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
155+
NeedsEnvFile: true,
156156
InvokeCommand: `kernel invoke ts-magnitude mag-url-extract --payload '{"url": "https://en.wikipedia.org/wiki/Special:Random"}'`,
157157
},
158158
TemplateCUA: {
159159
EntryPoint: "index.ts",
160-
EnvVars: []string{"OPENAI_API_KEY=XXX"},
160+
NeedsEnvFile: true,
161161
InvokeCommand: `kernel invoke ts-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
162162
},
163163
TemplateGeminiCUA: {
164164
EntryPoint: "index.ts",
165-
EnvVars: []string{"GOOGLE_API_KEY=XXX", "OPENAI_API_KEY=XXX"},
165+
NeedsEnvFile: true,
166166
InvokeCommand: "kernel invoke ts-gemini-cua gemini-cua-task",
167167
},
168168
},
169169
LanguagePython: {
170170
TemplateSampleApp: {
171171
EntryPoint: "main.py",
172-
EnvVars: []string{},
172+
NeedsEnvFile: false,
173173
InvokeCommand: `kernel invoke python-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
174174
},
175-
TemplateAdvancedSample: {
175+
TemplateCaptchaSolver: {
176176
EntryPoint: "main.py",
177-
EnvVars: []string{},
178-
InvokeCommand: "kernel invoke python-advanced test-captcha-solver",
177+
NeedsEnvFile: false,
178+
InvokeCommand: "kernel invoke python-captcha-solver test-captcha-solver",
179179
},
180180
TemplateBrowserUse: {
181181
EntryPoint: "main.py",
182-
EnvVars: []string{"OPENAI_API_KEY=XXX"},
182+
NeedsEnvFile: true,
183183
InvokeCommand: `kernel invoke python-bu bu-task --payload '{"task": "Compare the price of gpt-4o and DeepSeek-V3"}'`,
184184
},
185185
TemplateComputerUse: {
186186
EntryPoint: "main.py",
187-
EnvVars: []string{"ANTHROPIC_API_KEY=XXX"},
187+
NeedsEnvFile: true,
188188
InvokeCommand: `kernel invoke python-cu cu-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
189189
},
190190
TemplateCUA: {
191191
EntryPoint: "main.py",
192-
EnvVars: []string{"OPENAI_API_KEY=XXX"},
192+
NeedsEnvFile: true,
193193
InvokeCommand: `kernel invoke python-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
194194
},
195195
},
@@ -208,8 +208,8 @@ func GetDeployCommand(language, template string) string {
208208
}
209209

210210
cmd := "kernel deploy " + config.EntryPoint
211-
for _, env := range config.EnvVars {
212-
cmd += " --env " + env
211+
if config.NeedsEnvFile {
212+
cmd += " --env-file .env"
213213
}
214214

215215
return cmd

pkg/templates/python/advanced-sample/main.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)