dsh-moli 1.1.2 → 1.1.3

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 (3) hide show
  1. package/index.js +1 -0
  2. package/lib/moli.js +47 -3
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -110,6 +110,7 @@ const FETCH_OUTPUT_SCHEMA = {
110
110
  path: { type: 'string' },
111
111
  chars: { type: 'integer' },
112
112
  bytes: { type: 'integer' },
113
+ empty: { type: 'boolean' },
113
114
  truncated: { type: 'boolean' },
114
115
  error: { type: 'string' },
115
116
  hint: { type: 'string' },
package/lib/moli.js CHANGED
@@ -314,7 +314,45 @@ export function runFetch(options) {
314
314
  const bytes = outcome.stdout.length;
315
315
  const stderr = outcome.spawnError === undefined ? outcome.stderr : `${outcome.spawnError} | ${outcome.stderr}`;
316
316
 
317
- if (outcome.status !== 0 || bytes === 0) {
317
+ // Empty stdout on a zero exit is not a failure: a page can legitimately have
318
+ // no content in the requested format, which is exactly what a client-rendered
319
+ // page yields under `noJs` with a text dump. moli is right to print nothing
320
+ // for it, and the old code answered with "moli exited with status 0 and no
321
+ // output" plus a hint to re-check the install, sending the caller after a host
322
+ // that was never broken.
323
+ //
324
+ // Both decisions live in this one branch on purpose. Splitting them -- empty
325
+ // stdout treated as success here and stderr checked further down -- lets the
326
+ // case below (silent stdout, a complaint on stderr, exit 0) fall through to
327
+ // the normal success path with the complaint silently dropped.
328
+ if (outcome.status === 0 && bytes === 0) {
329
+ if (stderr !== '') {
330
+ return {
331
+ ok: false,
332
+ url: args.url,
333
+ error: stderr,
334
+ sandboxTlsBlock: isSandboxTlsFailure(stderr),
335
+ unreachable: false,
336
+ possiblyUnreachable: false,
337
+ hint: 'The engine exited cleanly but produced no output and explained why on stderr; the text above is its own message.',
338
+ };
339
+ }
340
+ return {
341
+ ok: true,
342
+ url: args.url,
343
+ kind: 'text',
344
+ dump: args.dump ?? 'html',
345
+ content: '',
346
+ chars: 0,
347
+ bytes: 0,
348
+ empty: true,
349
+ note: 'moli succeeded and produced no output, so the page had no content in this format. '
350
+ + 'A page whose content is built by JavaScript yields nothing when noJs is set; '
351
+ + 'the same URL renders normally without it.',
352
+ };
353
+ }
354
+
355
+ if (outcome.status !== 0) {
318
356
  const sandboxTls = isSandboxTlsFailure(stderr);
319
357
  // A blocked host fails at connect time ("Failed to connect" / RST) or, when
320
358
  // the socket never opens, as a readiness timeout with nothing to show. A
@@ -459,7 +497,11 @@ export function probe(exe, probeUrl, insecureTls = false) {
459
497
  if (insecureTls) probeArgs.push('--insecure-disable-tls-host-verification');
460
498
  const outcome = fetchOnce({ exe, args: probeArgs, timeoutMs: 20000 });
461
499
  const stderr = outcome.spawnError === undefined ? outcome.stderr : `${outcome.spawnError} | ${outcome.stderr}`;
462
- const ok = outcome.status === 0 && outcome.stdout.length > 0;
500
+ // A zero exit means moli reached the host and fetched it. Requiring non-empty
501
+ // stdout as well would report httpsOk:false for a page that simply has no
502
+ // text — a probe URL is not guaranteed to carry content, and the field is
503
+ // documented as "can reach HTTPS", which is what the exit status proves.
504
+ const ok = outcome.status === 0;
463
505
  const revocation = /CRYPT_E_REVOCATION_OFFLINE|revocation/iu.test(stderr);
464
506
  return {
465
507
  exe,
@@ -467,7 +509,9 @@ export function probe(exe, probeUrl, insecureTls = false) {
467
509
  httpsOk: ok,
468
510
  probeUrl,
469
511
  detail: ok
470
- ? 'HTTPS fetch succeeded from the DSH host process.'
512
+ ? (outcome.stdout.length > 0
513
+ ? 'HTTPS fetch succeeded from the DSH host process.'
514
+ : 'HTTPS fetch succeeded from the DSH host process (the probe URL returned no text).')
471
515
  : revocation && !insecureTls
472
516
  ? `${stderr} | This is a certificate-revocation check failing (offline CRL/OCSP responder); retrying with the no-verify flag normally clears it.`
473
517
  : stderr,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-moli",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "DeepSeek Harness tools for the local Moli headless browser: rendered fetches, markdown, semantic trees, screenshots, and PDFs.",
6
6
  "license": "MIT",