Skip to content

Commit a8b5265

Browse files
committed
Update input/output schemas and payloads
Add more descriptive and accurate input and output schemas and payloads for the stagehand sample app.
1 parent 6d96bca commit a8b5265

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const INVOKE_SAMPLES: Record<
103103
[TEMPLATE_SAMPLE_APP]:
104104
'kernel invoke ts-basic get-page-title --payload \'{"url": "https://www.google.com"}\'',
105105
[TEMPLATE_STAGEHAND]:
106-
'kernel invoke ts-stagehand headcount-task --payload \'{"query": "Kernel"}\'',
106+
'kernel invoke ts-stagehand teamsize-task --payload \'{"company": "Kernel"}\'',
107107
[TEMPLATE_ADVANCED_SAMPLE]: "kernel invoke ts-advanced test-captcha-solver",
108108
[TEMPLATE_COMPUTER_USE]:
109109
'kernel invoke ts-cu cu-task --payload \'{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}\'',

templates/typescript/stagehand/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ A Stagehand-powered browser automation app that extracts team size information f
44

55
## What it does
66

7-
The `headcount-task` searches for a startup on Y Combinator's company directory and extracts the team size (number of employees).
7+
The `teamsize-task` searches for a startup on Y Combinator's company directory and extracts the team size (number of employees).
88

99
## Input
1010

1111
```json
1212
{
13-
"query": "kernel" // Startup name to search (optional, defaults to "kernel")
13+
"company": "kernel" // Startup name to search (optional, defaults to "kernel")
1414
}
1515
```
1616

@@ -41,10 +41,10 @@ kernel deploy index.ts --env-file .env
4141

4242
Default query (searches for "kernel"):
4343
```bash
44-
kernel invoke ts-stagehand headcount-task
44+
kernel invoke ts-stagehand teamsize-task
4545
```
4646

4747
Custom query:
4848
```bash
49-
kernel invoke ts-stagehand headcount-task --payload '{"query": "Mixpanel"}'
49+
kernel invoke ts-stagehand teamsize-task --payload '{"company": "Mixpanel"}'
5050
```

templates/typescript/stagehand/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const kernel = new Kernel();
66

77
const app = kernel.app('ts-stagehand');
88

9-
interface SearchQueryInput {
10-
query: string;
9+
interface CompanyInput {
10+
company: string;
1111
}
1212

13-
interface SearchQueryOutput {
13+
interface TeamSizeOutput {
1414
teamSize: string;
1515
}
1616

@@ -23,9 +23,9 @@ if (!OPENAI_API_KEY) {
2323
throw new Error('OPENAI_API_KEY is not set');
2424
}
2525

26-
app.action<SearchQueryInput, SearchQueryOutput>(
27-
'headcount-task',
28-
async (ctx: KernelContext, payload?: SearchQueryInput): Promise<SearchQueryOutput> => {
26+
app.action<CompanyInput, TeamSizeOutput>(
27+
'teamsize-task',
28+
async (ctx: KernelContext, payload?: CompanyInput): Promise<TeamSizeOutput> => {
2929
// A function that returns the team size of a Y Combinator startup
3030

3131
// Args:
@@ -35,7 +35,7 @@ app.action<SearchQueryInput, SearchQueryOutput>(
3535
// Returns:
3636
// output: The team size (number of employees) of the startup
3737

38-
const query = payload?.query || 'kernel';
38+
const company = payload?.company || 'kernel';
3939

4040
const kernelBrowser = await kernel.browsers.create({
4141
invocation_id: ctx.invocation_id,
@@ -62,7 +62,7 @@ app.action<SearchQueryInput, SearchQueryOutput>(
6262
const page = stagehand.context.pages()[0];
6363
await page.goto("https://www.ycombinator.com/companies");
6464

65-
await stagehand.act(`Type in ${query} into the search box`);
65+
await stagehand.act(`Type in ${company} into the search box`);
6666
await stagehand.act("Click on the first search result");
6767

6868
// Schema definition

0 commit comments

Comments
 (0)