@d0nj/dsh-browser 0.1.0 → 0.1.1

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/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 d0nj
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 d0nj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/launch.js CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import { spawn } from 'node:child_process';
12
12
  import { mkdir, readFile, rm } from 'node:fs/promises';
13
- import { join, posix } from 'node:path';
13
+ import { join, posix, win32 } from 'node:path';
14
14
  /**
15
15
  * Candidate executable paths for a platform, in preference order.
16
16
  * @param platform - `process.platform`.
@@ -25,29 +25,29 @@ export function executableCandidates(platform, env, home) {
25
25
  for (const root of [env['ProgramFiles'], env['ProgramFiles(x86)'], env['LOCALAPPDATA']]) {
26
26
  if (root === undefined || root === '')
27
27
  continue;
28
- candidates.push(join(root, 'Google', 'Chrome', 'Application', 'chrome.exe'));
28
+ candidates.push(win32.join(root, 'Google', 'Chrome', 'Application', 'chrome.exe'));
29
29
  }
30
30
  for (const root of [env['LOCALAPPDATA'], env['ProgramFiles']]) {
31
31
  if (root === undefined || root === '')
32
32
  continue;
33
- candidates.push(join(root, 'Chromium', 'Application', 'chrome.exe'));
33
+ candidates.push(win32.join(root, 'Chromium', 'Application', 'chrome.exe'));
34
34
  }
35
- const scoop = env['SCOOP'] ?? join(home, 'scoop');
36
- candidates.push(join(scoop, 'apps', 'chromium', 'current', 'chrome.exe'), join(scoop, 'apps', 'googlechrome', 'current', 'chrome.exe'), join(scoop, 'apps', 'brave', 'current', 'brave.exe'), join(scoop, 'shims', 'chromium.exe'), join(scoop, 'shims', 'chrome.exe'));
35
+ const scoop = env['SCOOP'] ?? win32.join(home, 'scoop');
36
+ candidates.push(win32.join(scoop, 'apps', 'chromium', 'current', 'chrome.exe'), win32.join(scoop, 'apps', 'googlechrome', 'current', 'chrome.exe'), win32.join(scoop, 'apps', 'brave', 'current', 'brave.exe'), win32.join(scoop, 'shims', 'chromium.exe'), win32.join(scoop, 'shims', 'chrome.exe'));
37
37
  const programData = env['ProgramData'];
38
38
  if (programData !== undefined && programData !== '') {
39
- candidates.push(join(programData, 'chocolatey', 'bin', 'chrome.exe'), join(programData, 'chocolatey', 'bin', 'chromium.exe'));
39
+ candidates.push(win32.join(programData, 'chocolatey', 'bin', 'chrome.exe'), win32.join(programData, 'chocolatey', 'bin', 'chromium.exe'));
40
40
  }
41
41
  for (const root of [env['ProgramFiles'], env['LOCALAPPDATA']]) {
42
42
  if (root === undefined || root === '')
43
43
  continue;
44
- candidates.push(join(root, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'));
44
+ candidates.push(win32.join(root, 'BraveSoftware', 'Brave-Browser', 'Application', 'brave.exe'));
45
45
  }
46
46
  // Edge often ships with remote debugging disabled by policy, so it is tried last.
47
47
  for (const root of [env['ProgramFiles(x86)'], env['ProgramFiles'], env['LOCALAPPDATA']]) {
48
48
  if (root === undefined || root === '')
49
49
  continue;
50
- candidates.push(join(root, 'Microsoft', 'Edge', 'Application', 'msedge.exe'));
50
+ candidates.push(win32.join(root, 'Microsoft', 'Edge', 'Application', 'msedge.exe'));
51
51
  }
52
52
  return candidates;
53
53
  }
package/dist/tab.js CHANGED
@@ -2,70 +2,70 @@ import { ConsoleBuffer, describeRemoteObject } from './console.js';
2
2
  import { parseKeyChord } from './keys.js';
3
3
  import { renderAccessibilityTree } from './snapshot.js';
4
4
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
5
- const SCROLL_AND_MEASURE = `function () {
6
- const element = this;
7
- if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
8
- element.scrollIntoView({ block: 'center', inline: 'center' });
9
- const rect = element.getBoundingClientRect();
10
- const style = window.getComputedStyle(element);
11
- return {
12
- ok: true,
13
- x: rect.left + rect.width / 2,
14
- y: rect.top + rect.height / 2,
15
- width: rect.width,
16
- height: rect.height,
17
- visible: rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none' && Number.parseFloat(style.opacity || '1') > 0,
18
- disabled: ('disabled' in element && element.disabled === true) || element.getAttribute('aria-disabled') === 'true',
19
- tag: element.tagName.toLowerCase(),
20
- };
5
+ const SCROLL_AND_MEASURE = `function () {
6
+ const element = this;
7
+ if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
8
+ element.scrollIntoView({ block: 'center', inline: 'center' });
9
+ const rect = element.getBoundingClientRect();
10
+ const style = window.getComputedStyle(element);
11
+ return {
12
+ ok: true,
13
+ x: rect.left + rect.width / 2,
14
+ y: rect.top + rect.height / 2,
15
+ width: rect.width,
16
+ height: rect.height,
17
+ visible: rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none' && Number.parseFloat(style.opacity || '1') > 0,
18
+ disabled: ('disabled' in element && element.disabled === true) || element.getAttribute('aria-disabled') === 'true',
19
+ tag: element.tagName.toLowerCase(),
20
+ };
21
21
  }`;
22
- const MEASURE_DOCUMENT_BOX = `function () {
23
- const element = this;
24
- if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
25
- element.scrollIntoView({ block: 'center', inline: 'center' });
26
- const rect = element.getBoundingClientRect();
27
- return { ok: true, x: rect.left + window.scrollX, y: rect.top + window.scrollY, width: rect.width, height: rect.height };
22
+ const MEASURE_DOCUMENT_BOX = `function () {
23
+ const element = this;
24
+ if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
25
+ element.scrollIntoView({ block: 'center', inline: 'center' });
26
+ const rect = element.getBoundingClientRect();
27
+ return { ok: true, x: rect.left + window.scrollX, y: rect.top + window.scrollY, width: rect.width, height: rect.height };
28
28
  }`;
29
- const FOCUS_FOR_TYPING = `function (clear) {
30
- const element = this;
31
- if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
32
- element.scrollIntoView({ block: 'center', inline: 'center' });
33
- if (element instanceof HTMLElement) element.focus({ preventScroll: true });
34
- if (!clear) return { ok: true };
35
- if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
36
- const prototype = element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
37
- const setter = Object.getOwnPropertyDescriptor(prototype, 'value')?.set;
38
- setter === undefined ? (element.value = '') : setter.call(element, '');
39
- element.dispatchEvent(new Event('input', { bubbles: true }));
40
- return { ok: true };
41
- }
42
- if (element.isContentEditable) {
43
- const range = document.createRange();
44
- range.selectNodeContents(element);
45
- const selection = window.getSelection();
46
- selection?.removeAllRanges();
47
- selection?.addRange(range);
48
- return { ok: true };
49
- }
50
- return { ok: true };
29
+ const FOCUS_FOR_TYPING = `function (clear) {
30
+ const element = this;
31
+ if (!(element instanceof Element)) return { ok: false, reason: 'not-an-element' };
32
+ element.scrollIntoView({ block: 'center', inline: 'center' });
33
+ if (element instanceof HTMLElement) element.focus({ preventScroll: true });
34
+ if (!clear) return { ok: true };
35
+ if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
36
+ const prototype = element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
37
+ const setter = Object.getOwnPropertyDescriptor(prototype, 'value')?.set;
38
+ setter === undefined ? (element.value = '') : setter.call(element, '');
39
+ element.dispatchEvent(new Event('input', { bubbles: true }));
40
+ return { ok: true };
41
+ }
42
+ if (element.isContentEditable) {
43
+ const range = document.createRange();
44
+ range.selectNodeContents(element);
45
+ const selection = window.getSelection();
46
+ selection?.removeAllRanges();
47
+ selection?.addRange(range);
48
+ return { ok: true };
49
+ }
50
+ return { ok: true };
51
51
  }`;
52
- const SELECT_OPTIONS = `function (values) {
53
- const element = this;
54
- if (!(element instanceof HTMLSelectElement)) return { ok: false, reason: 'not-a-select' };
55
- const wanted = new Set(values);
56
- let changed = false;
57
- for (const option of Array.from(element.options)) {
58
- const selected = wanted.has(option.value) || wanted.has(option.label);
59
- if (option.selected !== selected) {
60
- option.selected = selected;
61
- changed = true;
62
- }
63
- }
64
- if (changed) {
65
- element.dispatchEvent(new Event('input', { bubbles: true }));
66
- element.dispatchEvent(new Event('change', { bubbles: true }));
67
- }
68
- return { ok: true, selected: Array.from(element.selectedOptions).map((option) => option.label || option.value) };
52
+ const SELECT_OPTIONS = `function (values) {
53
+ const element = this;
54
+ if (!(element instanceof HTMLSelectElement)) return { ok: false, reason: 'not-a-select' };
55
+ const wanted = new Set(values);
56
+ let changed = false;
57
+ for (const option of Array.from(element.options)) {
58
+ const selected = wanted.has(option.value) || wanted.has(option.label);
59
+ if (option.selected !== selected) {
60
+ option.selected = selected;
61
+ changed = true;
62
+ }
63
+ }
64
+ if (changed) {
65
+ element.dispatchEvent(new Event('input', { bubbles: true }));
66
+ element.dispatchEvent(new Event('change', { bubbles: true }));
67
+ }
68
+ return { ok: true, selected: Array.from(element.selectedOptions).map((option) => option.label || option.value) };
69
69
  }`;
70
70
  const BUTTON_MASK = { left: 1, right: 2, middle: 4 };
71
71
  /** Schemes a navigation may use; anything else is refused before it reaches Chrome. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0nj/dsh-browser",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A real browser for DeepSeek Harness agents, headless by default: the `browser` tool navigates, reads the page as a numbered accessibility tree, and clicks, types and scrolls by ref.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,20 +46,20 @@
46
46
  }
47
47
  },
48
48
  "peerDependencies": {
49
- "@deepseek-ai/cordis": "~4.0.5",
50
- "@deepseek-ai/dsh-attachment": "0.2.1-rc.5",
51
- "@deepseek-ai/dsh-llm": "0.2.1-rc.5",
52
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.5",
53
- "@deepseek-ai/dsh-tools": "0.2.1-rc.5",
54
- "@deepseek-ai/schemastery": "~3.18.5"
49
+ "@deepseek-ai/cordis": "~4.1.0",
50
+ "@deepseek-ai/dsh-attachment": "^0.2.2-rc.1",
51
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
52
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
53
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
54
+ "@deepseek-ai/schemastery": "~3.19.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@deepseek-ai/cordis": "~4.0.5",
58
- "@deepseek-ai/dsh-attachment": "0.2.1-rc.5",
59
- "@deepseek-ai/dsh-llm": "0.2.1-rc.5",
60
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.5",
61
- "@deepseek-ai/dsh-tools": "0.2.1-rc.5",
62
- "@deepseek-ai/schemastery": "~3.18.5",
57
+ "@deepseek-ai/cordis": "~4.1.0",
58
+ "@deepseek-ai/dsh-attachment": "^0.2.2-rc.1",
59
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
60
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
61
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
62
+ "@deepseek-ai/schemastery": "~3.19.0",
63
63
  "@types/node": "^24.0.0",
64
64
  "typescript": "^5.9.0"
65
65
  },