@btraut/browser-bridge 0.4.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -36,6 +36,9 @@ var ErrorCodeSchema = import_zod.z.enum([
36
36
  "FAILED_PRECONDITION",
37
37
  "UNAUTHORIZED",
38
38
  "FORBIDDEN",
39
+ "PERMISSION_REQUIRED",
40
+ "PERMISSION_DENIED",
41
+ "PERMISSION_PROMPT_TIMEOUT",
39
42
  "CONFLICT",
40
43
  "TIMEOUT",
41
44
  "CANCELLED",
@@ -584,89 +587,21 @@ var DiagnosticsDoctorOutputSchema = DiagnosticReportSchema;
584
587
 
585
588
  // packages/cli/src/cli-output.ts
586
589
  var import_zod3 = require("zod");
587
- var CliError = class extends Error {
588
- constructor(info) {
589
- super(info.message);
590
- this.info = info;
591
- }
592
- };
593
- var parseInput = (schema, payload) => {
594
- const result = schema.safeParse(payload);
595
- if (result.success) {
596
- return result.data;
597
- }
598
- const [issue] = result.error.issues;
599
- throw new CliError({
600
- code: "INVALID_ARGUMENT",
601
- message: issue?.message ?? "Invalid input.",
602
- retryable: false,
603
- details: { issues: result.error.issues }
604
- });
605
- };
606
- var outputEnvelope = (envelope2, options) => {
607
- if (options.json) {
608
- console.log(JSON.stringify(envelope2, null, 2));
609
- return;
610
- }
611
- if (envelope2.ok) {
612
- if (typeof envelope2.result === "string") {
613
- console.log(envelope2.result);
614
- return;
615
- }
616
- console.log(JSON.stringify(envelope2.result, null, 2));
617
- return;
618
- }
619
- console.error(`${envelope2.error.code}: ${envelope2.error.message}`);
620
- if (envelope2.error.details) {
621
- console.error(JSON.stringify(envelope2.error.details, null, 2));
622
- }
623
- };
624
- var toErrorInfo = (error) => {
625
- if (error instanceof CliError) {
626
- return error.info;
627
- }
628
- if (error instanceof import_zod3.ZodError) {
629
- const [issue] = error.issues;
630
- return {
631
- code: "INVALID_ARGUMENT",
632
- message: issue?.message ?? "Invalid input.",
633
- retryable: false,
634
- details: { issues: error.issues }
635
- };
636
- }
637
- if (error instanceof Error) {
638
- return {
639
- code: "INTERNAL",
640
- message: error.message,
641
- retryable: false
642
- };
643
- }
644
- return {
645
- code: "INTERNAL",
646
- message: "Unknown error.",
647
- retryable: false
648
- };
649
- };
650
- var outputError = (error, options) => {
651
- const info = toErrorInfo(error);
652
- const envelope2 = { ok: false, error: info };
653
- if (options.json) {
654
- console.log(JSON.stringify(envelope2, null, 2));
655
- return;
656
- }
657
- console.error(`${info.code}: ${info.message}`);
658
- if (info.details) {
659
- console.error(JSON.stringify(info.details, null, 2));
660
- }
661
- };
662
590
 
663
591
  // packages/cli/src/core-client.ts
664
592
  var import_node_child_process = require("node:child_process");
665
593
  var import_node_path = require("node:path");
666
594
  var import_promises = require("node:timers/promises");
595
+ var CoreClientError = class extends Error {
596
+ constructor(info) {
597
+ super(info.message);
598
+ this.name = "CoreClientError";
599
+ this.info = info;
600
+ }
601
+ };
667
602
  var DEFAULT_HOST = "127.0.0.1";
668
603
  var DEFAULT_PORT = 3210;
669
- var DEFAULT_TIMEOUT_MS = 4e3;
604
+ var DEFAULT_TIMEOUT_MS = 3e4;
670
605
  var HEALTH_RETRY_MS = 250;
671
606
  var HEALTH_ATTEMPTS = 20;
672
607
  var resolveHost = (host) => {
@@ -711,14 +646,31 @@ var createCoreClient = (options = {}) => {
711
646
  const controller = new AbortController();
712
647
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
713
648
  try {
714
- const response = await fetchImpl(`${baseUrl}${normalizePath(path9)}`, {
715
- method,
716
- headers: {
717
- "content-type": "application/json"
718
- },
719
- body: body === void 0 ? void 0 : JSON.stringify(body),
720
- signal: controller.signal
721
- });
649
+ let response;
650
+ try {
651
+ response = await fetchImpl(`${baseUrl}${normalizePath(path9)}`, {
652
+ method,
653
+ headers: {
654
+ "content-type": "application/json"
655
+ },
656
+ body: body === void 0 ? void 0 : JSON.stringify(body),
657
+ signal: controller.signal
658
+ });
659
+ } catch (error) {
660
+ if (controller.signal.aborted || error instanceof Error && error.name === "AbortError") {
661
+ throw new CoreClientError({
662
+ code: "TIMEOUT",
663
+ message: `Core request timed out after ${timeoutMs}ms.`,
664
+ retryable: true,
665
+ details: {
666
+ timeout_ms: timeoutMs,
667
+ base_url: baseUrl,
668
+ path: normalizePath(path9)
669
+ }
670
+ });
671
+ }
672
+ throw error;
673
+ }
722
674
  const raw = await response.text();
723
675
  if (!raw) {
724
676
  throw new Error(`Empty response from Core (${response.status}).`);
@@ -738,10 +690,18 @@ var createCoreClient = (options = {}) => {
738
690
  const controller = new AbortController();
739
691
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
740
692
  try {
741
- const response = await fetchImpl(`${baseUrl}/health`, {
742
- method: "GET",
743
- signal: controller.signal
744
- });
693
+ let response;
694
+ try {
695
+ response = await fetchImpl(`${baseUrl}/health`, {
696
+ method: "GET",
697
+ signal: controller.signal
698
+ });
699
+ } catch (error) {
700
+ if (controller.signal.aborted || error instanceof Error && error.name === "AbortError") {
701
+ return false;
702
+ }
703
+ throw error;
704
+ }
745
705
  if (!response.ok) {
746
706
  return false;
747
707
  }
@@ -806,6 +766,86 @@ startCoreServer({ host: ${JSON.stringify(
806
766
  return { baseUrl, ensureReady, post };
807
767
  };
808
768
 
769
+ // packages/cli/src/cli-output.ts
770
+ var CliError = class extends Error {
771
+ constructor(info) {
772
+ super(info.message);
773
+ this.info = info;
774
+ }
775
+ };
776
+ var parseInput = (schema, payload) => {
777
+ const result = schema.safeParse(payload);
778
+ if (result.success) {
779
+ return result.data;
780
+ }
781
+ const [issue] = result.error.issues;
782
+ throw new CliError({
783
+ code: "INVALID_ARGUMENT",
784
+ message: issue?.message ?? "Invalid input.",
785
+ retryable: false,
786
+ details: { issues: result.error.issues }
787
+ });
788
+ };
789
+ var outputEnvelope = (envelope2, options) => {
790
+ if (options.json) {
791
+ console.log(JSON.stringify(envelope2, null, 2));
792
+ return;
793
+ }
794
+ if (envelope2.ok) {
795
+ if (typeof envelope2.result === "string") {
796
+ console.log(envelope2.result);
797
+ return;
798
+ }
799
+ console.log(JSON.stringify(envelope2.result, null, 2));
800
+ return;
801
+ }
802
+ console.error(`${envelope2.error.code}: ${envelope2.error.message}`);
803
+ if (envelope2.error.details) {
804
+ console.error(JSON.stringify(envelope2.error.details, null, 2));
805
+ }
806
+ };
807
+ var toErrorInfo = (error) => {
808
+ if (error instanceof CliError) {
809
+ return error.info;
810
+ }
811
+ if (error instanceof CoreClientError) {
812
+ return error.info;
813
+ }
814
+ if (error instanceof import_zod3.ZodError) {
815
+ const [issue] = error.issues;
816
+ return {
817
+ code: "INVALID_ARGUMENT",
818
+ message: issue?.message ?? "Invalid input.",
819
+ retryable: false,
820
+ details: { issues: error.issues }
821
+ };
822
+ }
823
+ if (error instanceof Error) {
824
+ return {
825
+ code: "INTERNAL",
826
+ message: error.message,
827
+ retryable: false
828
+ };
829
+ }
830
+ return {
831
+ code: "INTERNAL",
832
+ message: "Unknown error.",
833
+ retryable: false
834
+ };
835
+ };
836
+ var outputError = (error, options) => {
837
+ const info = toErrorInfo(error);
838
+ const envelope2 = { ok: false, error: info };
839
+ if (options.json) {
840
+ console.log(JSON.stringify(envelope2, null, 2));
841
+ return;
842
+ }
843
+ console.error(`${info.code}: ${info.message}`);
844
+ if (info.details) {
845
+ console.error(JSON.stringify(info.details, null, 2));
846
+ }
847
+ };
848
+
809
849
  // packages/cli/src/cli-runtime.ts
810
850
  var getRootCommand = (command) => {
811
851
  let current = command;
@@ -996,7 +1036,7 @@ var parseJson = (value, label) => {
996
1036
  };
997
1037
  var registerDriveCommands = (program2) => {
998
1038
  const drive = program2.command("drive").description("Drive commands");
999
- drive.command("navigate").description("Navigate to a URL").requiredOption("--session-id <id>", "Session identifier").requiredOption("--url <url>", "URL to navigate to").option("--tab-id <id>", "Tab identifier (defaults to active tab)").option("--wait <mode>", "Wait mode (none, domcontentloaded)").action(async (options, command) => {
1039
+ drive.command("navigate").description("Navigate to a URL").requiredOption("--session-id <id>", "Session identifier").requiredOption("--url <url>", "URL to navigate to").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").option("--wait <mode>", "Wait mode (none, domcontentloaded)").action(async (options, command) => {
1000
1040
  await runCommand(command, (client) => {
1001
1041
  const payload = parseInput(DriveNavigateInputSchema, {
1002
1042
  session_id: options.sessionId,
@@ -1007,7 +1047,7 @@ var registerDriveCommands = (program2) => {
1007
1047
  return client.post("/drive/navigate", payload);
1008
1048
  });
1009
1049
  });
1010
- drive.command("go-back").description("Go back in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1050
+ drive.command("go-back").description("Go back in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1011
1051
  await runCommand(command, (client) => {
1012
1052
  const payload = parseInput(DriveGoBackInputSchema, {
1013
1053
  session_id: options.sessionId,
@@ -1016,7 +1056,7 @@ var registerDriveCommands = (program2) => {
1016
1056
  return client.post("/drive/go_back", payload);
1017
1057
  });
1018
1058
  });
1019
- drive.command("back").description("Go back in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1059
+ drive.command("back").description("Go back in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1020
1060
  await runCommand(command, (client) => {
1021
1061
  const payload = parseInput(DriveBackInputSchema, {
1022
1062
  session_id: options.sessionId,
@@ -1025,7 +1065,7 @@ var registerDriveCommands = (program2) => {
1025
1065
  return client.post("/drive/back", payload);
1026
1066
  });
1027
1067
  });
1028
- drive.command("go-forward").description("Go forward in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1068
+ drive.command("go-forward").description("Go forward in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1029
1069
  await runCommand(command, (client) => {
1030
1070
  const payload = parseInput(DriveGoForwardInputSchema, {
1031
1071
  session_id: options.sessionId,
@@ -1034,7 +1074,7 @@ var registerDriveCommands = (program2) => {
1034
1074
  return client.post("/drive/go_forward", payload);
1035
1075
  });
1036
1076
  });
1037
- drive.command("forward").description("Go forward in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1077
+ drive.command("forward").description("Go forward in browser history").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1038
1078
  await runCommand(command, (client) => {
1039
1079
  const payload = parseInput(DriveForwardInputSchema, {
1040
1080
  session_id: options.sessionId,
@@ -1043,7 +1083,7 @@ var registerDriveCommands = (program2) => {
1043
1083
  return client.post("/drive/forward", payload);
1044
1084
  });
1045
1085
  });
1046
- drive.command("click").description("Click an element").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--click-count <count>", "Click count").action(async (options, command) => {
1086
+ drive.command("click").description("Click an element").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--click-count <count>", "Click count").action(async (options, command) => {
1047
1087
  await runCommand(command, (client) => {
1048
1088
  const locator = requireLocator({
1049
1089
  locatorRef: options.locatorRef,
@@ -1062,7 +1102,7 @@ var registerDriveCommands = (program2) => {
1062
1102
  return client.post("/drive/click", payload);
1063
1103
  });
1064
1104
  });
1065
- drive.command("hover").description("Hover over an element").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--delay-ms <ms>", "Delay after hover in milliseconds").action(async (options, command) => {
1105
+ drive.command("hover").description("Hover over an element").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--delay-ms <ms>", "Delay after hover in milliseconds").action(async (options, command) => {
1066
1106
  await runCommand(command, (client) => {
1067
1107
  const locator = requireLocator({
1068
1108
  locatorRef: options.locatorRef,
@@ -1081,7 +1121,7 @@ var registerDriveCommands = (program2) => {
1081
1121
  return client.post("/drive/hover", payload);
1082
1122
  });
1083
1123
  });
1084
- drive.command("select").description("Select an option in a dropdown").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--value <value>", "Option value attribute").option("--text <text>", "Option visible text").option("--index <index>", "Option index (0-based)").action(async (options, command) => {
1124
+ drive.command("select").description("Select an option in a dropdown").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--value <value>", "Option value attribute").option("--text <text>", "Option visible text").option("--index <index>", "Option index (0-based)").action(async (options, command) => {
1085
1125
  await runCommand(command, (client) => {
1086
1126
  const locator = requireLocator({
1087
1127
  locatorRef: options.locatorRef,
@@ -1102,7 +1142,7 @@ var registerDriveCommands = (program2) => {
1102
1142
  return client.post("/drive/select", payload);
1103
1143
  });
1104
1144
  });
1105
- drive.command("type").description("Type into a field").requiredOption("--session-id <id>", "Session identifier").requiredOption("--text <text>", "Text to enter").option("--tab-id <id>", "Tab identifier").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--clear", "Clear input before typing").option("--submit", "Submit after typing").action(async (options, command) => {
1145
+ drive.command("type").description("Type into a field").requiredOption("--session-id <id>", "Session identifier").requiredOption("--text <text>", "Text to enter").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").option("--locator-ref <ref>", "Locator ref (e.g., @e1)").option("--locator-testid <id>", "Locator test id").option("--locator-css <selector>", "Locator CSS selector").option("--locator-text <text>", "Locator text").option("--locator-role <role>", "Locator role name").option("--locator-role-value <value>", "Locator role value").option("--clear", "Clear input before typing").option("--submit", "Submit after typing").action(async (options, command) => {
1106
1146
  await runCommand(command, (client) => {
1107
1147
  const locator = buildLocator({
1108
1148
  locatorRef: options.locatorRef,
@@ -1123,7 +1163,7 @@ var registerDriveCommands = (program2) => {
1123
1163
  return client.post("/drive/type", payload);
1124
1164
  });
1125
1165
  });
1126
- drive.command("fill-form").description("Fill multiple form fields").requiredOption("--session-id <id>", "Session identifier").requiredOption("--fields <json>", "JSON array of fields to fill").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1166
+ drive.command("fill-form").description("Fill multiple form fields").requiredOption("--session-id <id>", "Session identifier").requiredOption("--fields <json>", "JSON array of fields to fill").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1127
1167
  await runCommand(command, (client) => {
1128
1168
  const fields = parseJson(options.fields, "fields");
1129
1169
  const payload = parseInput(DriveFillFormInputSchema, {
@@ -1134,7 +1174,7 @@ var registerDriveCommands = (program2) => {
1134
1174
  return client.post("/drive/fill_form", payload);
1135
1175
  });
1136
1176
  });
1137
- drive.command("drag").description("Drag an element to a target").requiredOption("--session-id <id>", "Session identifier").option("--from-locator-ref <ref>", "Source locator ref (e.g., @e1)").option("--from-locator-testid <id>", "Source locator test id").option("--from-locator-css <selector>", "Source locator CSS selector").option("--from-locator-text <text>", "Source locator text").option("--from-locator-role <role>", "Source locator role name").option("--from-locator-role-value <value>", "Source locator role value").option("--to-locator-ref <ref>", "Target locator ref (e.g., @e1)").option("--to-locator-testid <id>", "Target locator test id").option("--to-locator-css <selector>", "Target locator CSS selector").option("--to-locator-text <text>", "Target locator text").option("--to-locator-role <role>", "Target locator role name").option("--to-locator-role-value <value>", "Target locator role value").option("--steps <steps>", "Number of drag steps").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1177
+ drive.command("drag").description("Drag an element to a target").requiredOption("--session-id <id>", "Session identifier").option("--from-locator-ref <ref>", "Source locator ref (e.g., @e1)").option("--from-locator-testid <id>", "Source locator test id").option("--from-locator-css <selector>", "Source locator CSS selector").option("--from-locator-text <text>", "Source locator text").option("--from-locator-role <role>", "Source locator role name").option("--from-locator-role-value <value>", "Source locator role value").option("--to-locator-ref <ref>", "Target locator ref (e.g., @e1)").option("--to-locator-testid <id>", "Target locator test id").option("--to-locator-css <selector>", "Target locator CSS selector").option("--to-locator-text <text>", "Target locator text").option("--to-locator-role <role>", "Target locator role name").option("--to-locator-role-value <value>", "Target locator role value").option("--steps <steps>", "Number of drag steps").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1138
1178
  await runCommand(command, (client) => {
1139
1179
  const from = requireLocator({
1140
1180
  locatorRef: options.fromLocatorRef,
@@ -1162,7 +1202,7 @@ var registerDriveCommands = (program2) => {
1162
1202
  return client.post("/drive/drag", payload);
1163
1203
  });
1164
1204
  });
1165
- drive.command("handle-dialog").description("Handle a JavaScript dialog").requiredOption("--session-id <id>", "Session identifier").requiredOption("--action <action>", "Dialog action (accept, dismiss)").option("--prompt-text <text>", "Prompt text for prompt() dialogs").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1205
+ drive.command("handle-dialog").description("Handle a JavaScript dialog").requiredOption("--session-id <id>", "Session identifier").requiredOption("--action <action>", "Dialog action (accept, dismiss)").option("--prompt-text <text>", "Prompt text for prompt() dialogs").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1166
1206
  await runCommand(command, (client) => {
1167
1207
  const payload = parseInput(DriveHandleDialogInputSchema, {
1168
1208
  session_id: options.sessionId,
@@ -1173,7 +1213,7 @@ var registerDriveCommands = (program2) => {
1173
1213
  return client.post("/drive/handle_dialog", payload);
1174
1214
  });
1175
1215
  });
1176
- drive.command("key-press").description("Press a keyboard key").requiredOption("--session-id <id>", "Session identifier").requiredOption("--key <key>", "Key to press (e.g. Enter, ArrowDown)").option("--ctrl", "Hold control modifier").option("--alt", "Hold alt modifier").option("--shift", "Hold shift modifier").option("--meta", "Hold meta modifier").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1216
+ drive.command("key-press").description("Press a keyboard key").requiredOption("--session-id <id>", "Session identifier").requiredOption("--key <key>", "Key to press (e.g. Enter, ArrowDown)").option("--ctrl", "Hold control modifier").option("--alt", "Hold alt modifier").option("--shift", "Hold shift modifier").option("--meta", "Hold meta modifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1177
1217
  await runCommand(command, (client) => {
1178
1218
  const payload = parseInput(DriveKeyPressInputSchema, {
1179
1219
  session_id: options.sessionId,
@@ -1194,7 +1234,7 @@ var registerDriveCommands = (program2) => {
1194
1234
  "Modifier key (ctrl, alt, shift, meta)",
1195
1235
  (value, previous) => [...previous ?? [], value],
1196
1236
  []
1197
- ).option("--repeat <count>", "Number of times to press").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1237
+ ).option("--repeat <count>", "Number of times to press").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1198
1238
  await runCommand(command, (client) => {
1199
1239
  const payload = parseInput(DriveKeyInputSchema, {
1200
1240
  session_id: options.sessionId,
@@ -1206,7 +1246,7 @@ var registerDriveCommands = (program2) => {
1206
1246
  return client.post("/drive/key", payload);
1207
1247
  });
1208
1248
  });
1209
- drive.command("scroll").description("Scroll the page").requiredOption("--session-id <id>", "Session identifier").option("--delta-x <px>", "Scroll delta X").option("--delta-y <px>", "Scroll delta Y").option("--top <px>", "Scroll top position").option("--left <px>", "Scroll left position").option("--behavior <mode>", "Scroll behavior (auto, smooth)").option("--tab-id <id>", "Tab identifier").action(async (options, command) => {
1249
+ drive.command("scroll").description("Scroll the page").requiredOption("--session-id <id>", "Session identifier").option("--delta-x <px>", "Scroll delta X").option("--delta-y <px>", "Scroll delta Y").option("--top <px>", "Scroll top position").option("--left <px>", "Scroll left position").option("--behavior <mode>", "Scroll behavior (auto, smooth)").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").action(async (options, command) => {
1210
1250
  await runCommand(command, (client) => {
1211
1251
  const payload = parseInput(DriveScrollInputSchema, {
1212
1252
  session_id: options.sessionId,
@@ -1220,7 +1260,7 @@ var registerDriveCommands = (program2) => {
1220
1260
  return client.post("/drive/scroll", payload);
1221
1261
  });
1222
1262
  });
1223
- drive.command("wait-for").description("Wait for a condition").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier").requiredOption(
1263
+ drive.command("wait-for").description("Wait for a condition").requiredOption("--session-id <id>", "Session identifier").option("--tab-id <id>", "Tab identifier (defaults to agent window/tab)").requiredOption(
1224
1264
  "--kind <kind>",
1225
1265
  "Condition kind (locator_visible, text_present, url_matches)"
1226
1266
  ).requiredOption("--value <value>", "Condition value").option("--timeout-ms <ms>", "Timeout in milliseconds").action(async (options, command) => {
@@ -1381,7 +1421,7 @@ var registerInspectCommands = (program2) => {
1381
1421
  // packages/mcp-adapter/src/core-client.ts
1382
1422
  var DEFAULT_HOST2 = "127.0.0.1";
1383
1423
  var DEFAULT_PORT2 = 3210;
1384
- var DEFAULT_TIMEOUT_MS2 = 4e3;
1424
+ var DEFAULT_TIMEOUT_MS2 = 3e4;
1385
1425
  var resolveHost2 = (host) => {
1386
1426
  const candidate = host?.trim() || process.env.BROWSER_BRIDGE_CORE_HOST || process.env.BROWSER_VISION_CORE_HOST;
1387
1427
  if (candidate && candidate.length > 0) {
@@ -1664,7 +1704,7 @@ var TOOL_DEFINITIONS = [
1664
1704
  name: "drive.scroll",
1665
1705
  config: {
1666
1706
  title: "Drive Scroll",
1667
- description: "Scroll the active tab.",
1707
+ description: "Scroll the default tab (agent window/tab unless tab_id is provided).",
1668
1708
  inputSchema: DriveScrollInputSchema,
1669
1709
  outputSchema: envelope(DriveScrollOutputSchema),
1670
1710
  corePath: "/drive/scroll"