dsh-browser-cdp 1.2.4 → 1.2.5

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.
Files changed (2) hide show
  1. package/lib/index.js +43 -12
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1004,6 +1004,19 @@ function parseCliStatus(stdout) {
1004
1004
  }
1005
1005
  }
1006
1006
  /**
1007
+ * R4 — the ego CLI may route the embedded runtime's output to either stream.
1008
+ * 0.6.0.16 on Windows sends everything (console.log, process.stdout.write and
1009
+ * our sentinels) to stderr and leaves stdout empty, so every sentinel/facade
1010
+ * reader must look at both. stdout goes first: when a CLI writes to both, the
1011
+ * authoritative payload stays where it always was.
1012
+ * @internal exported for tests
1013
+ */
1014
+ function mergeCliOutput(result) {
1015
+ if (result.stdout === "") return result.stderr;
1016
+ if (result.stderr === "") return result.stdout;
1017
+ return `${result.stdout}\n${result.stderr}`;
1018
+ }
1019
+ /**
1007
1020
  * Probe one link end to end: resolve → pick a working shape → (optionally)
1008
1021
  * read `--status` → confirm with a real heredoc round-trip.
1009
1022
  *
@@ -1055,7 +1068,7 @@ async function probeCliLink(input, io) {
1055
1068
  };
1056
1069
  let running;
1057
1070
  if (statusRun && statusRun.exitCode === 0 && !statusRun.timedOut) {
1058
- const parsed = parseCliStatus(statusRun.stdout);
1071
+ const parsed = parseCliStatus(mergeCliOutput(statusRun));
1059
1072
  if (parsed.ok) running = parsed.running;
1060
1073
  }
1061
1074
  const sdkArgs = input.useSdkPath === true && (input.sdkPath ?? "") !== "" ? ["--sdk-path", input.sdkPath] : [];
@@ -1092,9 +1105,9 @@ async function probeCliLink(input, io) {
1092
1105
  message: `spawn failed: ${result.spawnErrorCode}`,
1093
1106
  ...base
1094
1107
  };
1095
- const facadeMatch = (/* @__PURE__ */ new RegExp(`${CLI_READY_SENTINEL} (\\w+) (\\w+)`)).exec(result.stdout);
1108
+ const facadeMatch = (/* @__PURE__ */ new RegExp(`${CLI_READY_SENTINEL} (\\w+) (\\w+)`)).exec(mergeCliOutput(result));
1096
1109
  const facadesOk = input.useSdkPath !== true || facadeMatch?.[1] === "object" && facadeMatch?.[2] === "object";
1097
- if (result.exitCode !== 0 || !result.stdout.includes(CLI_READY_SENTINEL) || !facadesOk) {
1110
+ if (result.exitCode !== 0 || !mergeCliOutput(result).includes(CLI_READY_SENTINEL) || !facadesOk) {
1098
1111
  const tail = (result.stderr || result.stdout).trim().slice(-400);
1099
1112
  const facadeNote = facadesOk ? "" : `; the SDK harness did not expose the facade (taskSpaces=${facadeMatch?.[1] ?? "undefined"}, browser=${facadeMatch?.[2] ?? "undefined"})`;
1100
1113
  return {
@@ -7397,6 +7410,7 @@ async function runWithStaleSpaceRetry(ctx, cfg, exec, buildScript, graceOverride
7397
7410
  return result;
7398
7411
  }
7399
7412
  /** Find the last line carrying the sentinel and JSON-parse its payload. */
7413
+ /** @internal exported for tests */
7400
7414
  function parseSentinel(stdout) {
7401
7415
  const lines = stdout.split("\n");
7402
7416
  for (let i = lines.length - 1; i >= 0; i--) {
@@ -7486,8 +7500,8 @@ async function runEgoScript(subprocess, script, exec, cfg, graceOverrideMs) {
7486
7500
  spill: { maxBytes: cfg.maxOutputBytes }
7487
7501
  },
7488
7502
  stderr: {
7489
- maxBytes: 512e3,
7490
- spill: { maxBytes: 2e6 }
7503
+ maxBytes: cfg.maxOutputBytes,
7504
+ spill: { maxBytes: cfg.maxOutputBytes }
7491
7505
  }
7492
7506
  },
7493
7507
  graceMs: Number.isFinite(graceOverrideMs) && graceOverrideMs > 0 ? graceOverrideMs : cfg.graceMs,
@@ -7526,10 +7540,13 @@ async function runEgoScript(subprocess, script, exec, cfg, graceOverrideMs) {
7526
7540
  stdout,
7527
7541
  stderr
7528
7542
  };
7529
- const value = parseSentinel(stdout);
7543
+ const value = parseSentinel(mergeCliOutput({
7544
+ stdout,
7545
+ stderr
7546
+ }));
7530
7547
  if (value === void 0) return {
7531
7548
  ok: false,
7532
- error: `ego-browser finished but no ${SENTINEL} JSON payload was found on stdout${describeStderr(stderr)}`,
7549
+ error: `ego-browser finished but no ${SENTINEL} JSON payload was found on stdout/stderr${describeStderr(stderr)}`,
7533
7550
  stdout,
7534
7551
  stderr
7535
7552
  };
@@ -8075,7 +8092,10 @@ function registerEgoStatus(ctx, cfg, reg, tiers) {
8075
8092
  graceMs: 15e3
8076
8093
  });
8077
8094
  const outcome = await handle.done;
8078
- const facades = parseStatusFacades(readAll(handle.collected.stdout));
8095
+ const facades = parseStatusFacades(mergeCliOutput({
8096
+ stdout: readAll(handle.collected.stdout),
8097
+ stderr: readAll(handle.collected.stderr)
8098
+ }));
8079
8099
  return {
8080
8100
  ok: true,
8081
8101
  available: outcome.exitCode === 0 && facades?.taskSpaces === "object" && facades?.browser === "object",
@@ -8883,6 +8903,10 @@ function registerActionTools(ctx, cfg, reg) {
8883
8903
  required: true
8884
8904
  },
8885
8905
  stderr: { type: "string" },
8906
+ output: {
8907
+ type: "string",
8908
+ description: "Merged stdout+stderr text of the CLI run. The ego CLI writes script output to stderr on Windows, so read this when `stdout` looks empty."
8909
+ },
8886
8910
  result: { type: "json" }
8887
8911
  }
8888
8912
  },
@@ -8893,11 +8917,12 @@ function registerActionTools(ctx, cfg, reg) {
8893
8917
  markEgoToolCall(callingSessionId(exec));
8894
8918
  const result = await runWithStaleSpaceRetry(ctx, cfg, exec, () => str(args.script, ""));
8895
8919
  if (!result.ok) throw new Error(result.error);
8896
- const parsed = parseSentinel(result.stdout);
8920
+ const parsed = parseSentinel(mergeCliOutput(result));
8897
8921
  return {
8898
8922
  ok: true,
8899
8923
  stdout: result.stdout,
8900
8924
  stderr: result.stderr,
8925
+ output: mergeCliOutput(result),
8901
8926
  result: parsed ?? null
8902
8927
  };
8903
8928
  },
@@ -8949,7 +8974,7 @@ function registerHelpAndDoctor(ctx, cfg, reg, tiers) {
8949
8974
  kind: null,
8950
8975
  error: result.error
8951
8976
  };
8952
- const hc = (parseSentinel(result.stdout) || {}).humanCheck;
8977
+ const hc = (parseSentinel(mergeCliOutput(result)) || {}).humanCheck;
8953
8978
  return {
8954
8979
  ok: true,
8955
8980
  detected: !!hc?.detected,
@@ -9169,6 +9194,10 @@ function registerHelpAndDoctor(ctx, cfg, reg, tiers) {
9169
9194
  required: true
9170
9195
  },
9171
9196
  stderr: { type: "string" },
9197
+ output: {
9198
+ type: "string",
9199
+ description: "Merged stdout+stderr text of the CLI run. The ego CLI writes script output to stderr on Windows, so read this when `stdout` looks empty."
9200
+ },
9172
9201
  result: { type: "json" },
9173
9202
  durationMs: { type: "integer" },
9174
9203
  timedOut: { type: "boolean" },
@@ -9188,15 +9217,17 @@ function registerHelpAndDoctor(ctx, cfg, reg, tiers) {
9188
9217
  ok: false,
9189
9218
  stdout: result.stdout,
9190
9219
  stderr: result.stderr,
9220
+ output: mergeCliOutput(result),
9191
9221
  durationMs,
9192
9222
  timedOut: false,
9193
9223
  error: result.error
9194
9224
  };
9195
- const parsed = parseSentinel(result.stdout);
9225
+ const parsed = parseSentinel(mergeCliOutput(result));
9196
9226
  return {
9197
9227
  ok: true,
9198
9228
  stdout: result.stdout,
9199
9229
  stderr: result.stderr,
9230
+ output: mergeCliOutput(result),
9200
9231
  result: parsed ?? null,
9201
9232
  durationMs,
9202
9233
  timedOut: false
@@ -9813,4 +9844,4 @@ function registerHelpAndDoctor(ctx, cfg, reg, tiers) {
9813
9844
  }
9814
9845
 
9815
9846
  //#endregion
9816
- export { Config, STATUS_FACADE_SCRIPT, STATUS_FACADE_SENTINEL, apply, buildEgoToolArgv, cdpAttachError, createActiveSpaceTracker, decideCdpAttach, findChromeBinary, findUpstreamPluginInstall, inject, name, parseStatusFacades, resolveEgoEnv, runWithStaleSpaceRetry, shouldReapBrowser };
9847
+ export { Config, STATUS_FACADE_SCRIPT, STATUS_FACADE_SENTINEL, apply, buildEgoToolArgv, cdpAttachError, createActiveSpaceTracker, decideCdpAttach, findChromeBinary, findUpstreamPluginInstall, inject, name, parseSentinel, parseStatusFacades, resolveEgoEnv, runWithStaleSpaceRetry, shouldReapBrowser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-browser-cdp",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "dsh-browser-cdp: DSH browser plugin — attach to a running Chrome/Edge over CDP (no bundled browser needed); structured browser-automation tools (30+ bcdp_*) that drive the vendored ego runtime through ctx.subprocess, plus a realtime watch panel (live SSE screencast + direct mouse interaction + download capture + human-verification notice). Web shell: floating watch panel without dsh-better-sidebar, sidebar tab with it. Headless/TUI hosts: tools-only. [DSH 0.1.7-rc.1 ~ 0.2.1-rc.1 line (exact rc enumeration): declarative settings via Config .volatile() fields; for DSH 0.1.2-rc.1 ~ 0.1.5-rc.3 use the 0.17.x line]",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",