Skip to content

Commit cb219c0

Browse files
committed
small changes to remove unused code
1 parent 398d7d0 commit cb219c0

File tree

2 files changed

+0
-76
lines changed

2 files changed

+0
-76
lines changed

stagehand/src/tools.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import { Stagehand } from "@browserbasehq/stagehand";
22
import { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
3-
import { AnyZodObject } from "zod";
4-
import { jsonSchemaToZod } from "./utils.js";
53
import { getServerInstance, operationLogs } from "./logging.js";
6-
import path from 'path';
7-
import fs from 'fs';
8-
import { fileURLToPath } from 'url';
94
import { screenshots } from "./resources.js";
105

11-
// Get the directory name for the current module
12-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
13-
146
// Define the Stagehand tools
157
export const TOOLS: Tool[] = [
168
{

stagehand/src/utils.ts

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,3 @@
1-
import { z, ZodTypeAny } from 'zod';
2-
3-
/**
4-
* Converts a JSON Schema object to a Zod schema
5-
* @param schema The JSON Schema object to convert
6-
* @returns A Zod schema equivalent to the input JSON Schema
7-
*/
8-
export function jsonSchemaToZod(schema: any): ZodTypeAny {
9-
switch (schema.type) {
10-
case 'object':
11-
if (schema.properties) {
12-
const shape: Record<string, ZodTypeAny> = {};
13-
for (const key in schema.properties) {
14-
shape[key] = jsonSchemaToZod(schema.properties[key]);
15-
}
16-
let zodObject = z.object(shape);
17-
if (schema.required && Array.isArray(schema.required)) {
18-
zodObject = zodObject.partial().required(schema.required);
19-
}
20-
if (schema.description) {
21-
zodObject = zodObject.describe(schema.description);
22-
}
23-
return zodObject;
24-
} else {
25-
return z.object({});
26-
}
27-
case 'array':
28-
if (schema.items) {
29-
let zodArray = z.array(jsonSchemaToZod(schema.items));
30-
if (schema.description) {
31-
zodArray = zodArray.describe(schema.description);
32-
}
33-
return zodArray;
34-
} else {
35-
return z.array(z.any());
36-
}
37-
case 'string':
38-
if (schema.enum) {
39-
return z.string().refine(val => schema.enum.includes(val));
40-
}
41-
let zodString = z.string();
42-
if (schema.description) {
43-
zodString = zodString.describe(schema.description);
44-
}
45-
return zodString;
46-
case 'number':
47-
let zodNumber = z.number();
48-
if (schema.minimum !== undefined) {
49-
zodNumber = zodNumber.min(schema.minimum);
50-
}
51-
if (schema.maximum !== undefined) {
52-
zodNumber = zodNumber.max(schema.maximum);
53-
}
54-
if (schema.description) {
55-
zodNumber = zodNumber.describe(schema.description);
56-
}
57-
return zodNumber;
58-
case 'boolean':
59-
let zodBoolean = z.boolean();
60-
if (schema.description) {
61-
zodBoolean = zodBoolean.describe(schema.description);
62-
}
63-
return zodBoolean;
64-
default:
65-
return z.any();
66-
}
67-
}
68-
691
/**
702
* Sanitizes a message to ensure it's properly formatted JSON
713
* @param message The message to sanitize

0 commit comments

Comments
 (0)