Skip to content

Commit 8adf546

Browse files
committed
Refactor V3 class for improved code clarity and consistency
# what changed - Added spaces in catch blocks for consistency. - Introduced optional chaining for the manual option in LLMProvider initialization. - Minor formatting adjustments to enhance readability. # test plan - Ensure that the V3 class functions correctly with the updated formatting and optional chaining.
1 parent 52f24b2 commit 8adf546

File tree

1 file changed

+6
-5
lines changed
  • packages/core/lib/v3

1 file changed

+6
-5
lines changed

packages/core/lib/v3/v3.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class V3 {
136136
}
137137
private _onCdpClosed = (why: string) => {
138138
// Single place to react to the transport closing
139-
this._immediateShutdown(`CDP transport closed: ${why}`).catch(() => {});
139+
this._immediateShutdown(`CDP transport closed: ${why}`).catch(() => { });
140140
};
141141
public readonly experimental: boolean = false;
142142
public readonly logInferenceToFile: boolean = false;
@@ -173,6 +173,7 @@ export class V3 {
173173

174174
constructor(opts: V3Options) {
175175
V3._installProcessGuards();
176+
176177
this.externalLogger = opts.logger;
177178
this.verbose = opts.verbose ?? 1;
178179
this.instanceId =
@@ -213,7 +214,7 @@ export class V3 {
213214
this.modelName = modelName;
214215
this.experimental = opts.experimental ?? false;
215216
this.logInferenceToFile = opts.logInferenceToFile ?? false;
216-
this.llmProvider = new LLMProvider(this.logger, this.opts.manual);
217+
this.llmProvider = new LLMProvider(this.logger, this.opts?.manual ?? false);
217218
this.domSettleTimeoutMs = opts.domSettleTimeout;
218219
this.disableAPI = opts.disableAPI ?? false;
219220
const baseClientOptions: ClientOptions = clientOptions
@@ -611,7 +612,7 @@ export class V3 {
611612
kind: "LOCAL",
612613
// no LaunchedChrome when attaching externally; create a stub kill
613614
chrome: {
614-
kill: async () => {},
615+
kill: async () => { },
615616
} as unknown as import("chrome-launcher").LaunchedChrome,
616617
ws: lbo.cdpUrl,
617618
};
@@ -840,7 +841,7 @@ export class V3 {
840841
downloadPath: lbo.downloadsPath,
841842
eventsEnabled: true,
842843
})
843-
.catch(() => {});
844+
.catch(() => { });
844845
}
845846
} catch {
846847
// best-effort only
@@ -1418,7 +1419,7 @@ export class V3 {
14181419
if (!isCua) {
14191420
throw new Error(
14201421
"To use the computer use agent, please provide a CUA model in the agent constructor or stagehand config. Try one of our supported CUA models: " +
1421-
AVAILABLE_CUA_MODELS.join(", "),
1422+
AVAILABLE_CUA_MODELS.join(", "),
14221423
);
14231424
}
14241425

0 commit comments

Comments
 (0)