@anweat/dsh-browser 0.1.7 → 0.1.9

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 (74) hide show
  1. package/README.md +356 -245
  2. package/cordis.patch.yml +26 -16
  3. package/lib/approval-policy.js +34 -0
  4. package/lib/approval-policy.js.map +1 -1
  5. package/lib/auth-profiles.js +10 -1
  6. package/lib/auth-profiles.js.map +1 -1
  7. package/lib/automation-assets-rpc.d.ts +5 -0
  8. package/lib/automation-assets-rpc.js +63 -0
  9. package/lib/automation-assets-rpc.js.map +1 -0
  10. package/lib/automation-assets.d.ts +139 -0
  11. package/lib/automation-assets.js +372 -0
  12. package/lib/automation-assets.js.map +1 -0
  13. package/lib/automation-development.d.ts +13 -0
  14. package/lib/automation-development.js +37 -0
  15. package/lib/automation-development.js.map +1 -0
  16. package/lib/automation-execution.d.ts +14 -0
  17. package/lib/automation-execution.js +55 -0
  18. package/lib/automation-execution.js.map +1 -0
  19. package/lib/browser-service.d.ts +73 -25
  20. package/lib/browser-service.js +286 -74
  21. package/lib/browser-service.js.map +1 -1
  22. package/lib/client/SettingsCard.d.ts +2 -0
  23. package/lib/client/SettingsCard.js +69 -0
  24. package/lib/client/SettingsCard.js.map +1 -0
  25. package/lib/client/automation-assets-client.d.ts +38 -0
  26. package/lib/client/automation-assets-client.js +83 -0
  27. package/lib/client/automation-assets-client.js.map +1 -0
  28. package/lib/client/context-types.d.ts +8 -0
  29. package/lib/client/context-types.js +2 -0
  30. package/lib/client/context-types.js.map +1 -0
  31. package/lib/client/form.d.ts +62 -0
  32. package/lib/client/form.js +224 -0
  33. package/lib/client/form.js.map +1 -0
  34. package/lib/client/index.d.ts +27 -0
  35. package/lib/client/index.js +28 -0
  36. package/lib/client/index.js.map +1 -0
  37. package/lib/client/locales.d.ts +86 -0
  38. package/lib/client/locales.js +65 -0
  39. package/lib/client/locales.js.map +1 -0
  40. package/lib/client/settings-namespace.d.ts +2 -0
  41. package/lib/client/settings-namespace.js +3 -0
  42. package/lib/client/settings-namespace.js.map +1 -0
  43. package/lib/client/styles.d.ts +48 -0
  44. package/lib/client/styles.js +28 -0
  45. package/lib/client/styles.js.map +1 -0
  46. package/lib/client.js +1282 -0
  47. package/lib/client.js.map +1 -0
  48. package/lib/config.d.ts +14 -0
  49. package/lib/config.js +43 -0
  50. package/lib/config.js.map +1 -1
  51. package/lib/deps.d.ts +7 -1
  52. package/lib/deps.js +22 -6
  53. package/lib/deps.js.map +1 -1
  54. package/lib/freedom.d.ts +4 -1
  55. package/lib/freedom.js +14 -0
  56. package/lib/freedom.js.map +1 -1
  57. package/lib/index.d.ts +3 -1
  58. package/lib/index.js +20 -3
  59. package/lib/index.js.map +1 -1
  60. package/lib/opencli-catalog.d.ts +21 -0
  61. package/lib/opencli-catalog.js +49 -0
  62. package/lib/opencli-catalog.js.map +1 -0
  63. package/lib/scripts.d.ts +1 -1
  64. package/lib/scripts.js +30 -29
  65. package/lib/scripts.js.map +1 -1
  66. package/lib/tools.d.ts +2 -1
  67. package/lib/tools.js +222 -11
  68. package/lib/tools.js.map +1 -1
  69. package/lib/usage-policy.d.ts +49 -0
  70. package/lib/usage-policy.js +171 -0
  71. package/lib/usage-policy.js.map +1 -0
  72. package/package.json +133 -78
  73. package/scripts/check-client-bundle.mjs +15 -0
  74. package/scripts/clean-lib.mjs +3 -0
@@ -0,0 +1,171 @@
1
+ /** Bounded, approval-independent buffering for browser and crawler traffic. */
2
+ const DEFAULT_POLICY = {
3
+ minDelayMs: 750,
4
+ maxConcurrency: 2,
5
+ burst: 3,
6
+ maxPagesPerRun: 20,
7
+ maxDepth: 2,
8
+ retryLimit: 2,
9
+ backoffBaseMs: 1_000,
10
+ cooldownMs: 30_000,
11
+ };
12
+ function boundedInteger(name, value, fallback, min, max) {
13
+ const resolved = value ?? fallback;
14
+ if (!Number.isInteger(resolved) || Number(resolved) < min || Number(resolved) > max) {
15
+ throw new Error(`usagePolicy.${name} must be an integer from ${min} to ${max}`);
16
+ }
17
+ return Number(resolved);
18
+ }
19
+ export function resolveUsagePolicy(input) {
20
+ return {
21
+ minDelayMs: boundedInteger('minDelayMs', input?.minDelayMs, DEFAULT_POLICY.minDelayMs, 0, 60_000),
22
+ maxConcurrency: boundedInteger('maxConcurrency', input?.maxConcurrency, DEFAULT_POLICY.maxConcurrency, 1, 8),
23
+ burst: boundedInteger('burst', input?.burst, DEFAULT_POLICY.burst, 1, 20),
24
+ maxPagesPerRun: boundedInteger('maxPagesPerRun', input?.maxPagesPerRun, DEFAULT_POLICY.maxPagesPerRun, 1, 100),
25
+ maxDepth: boundedInteger('maxDepth', input?.maxDepth, DEFAULT_POLICY.maxDepth, 0, 5),
26
+ retryLimit: boundedInteger('retryLimit', input?.retryLimit, DEFAULT_POLICY.retryLimit, 0, 5),
27
+ backoffBaseMs: boundedInteger('backoffBaseMs', input?.backoffBaseMs, DEFAULT_POLICY.backoffBaseMs, 1, 60_000),
28
+ cooldownMs: boundedInteger('cooldownMs', input?.cooldownMs, DEFAULT_POLICY.cooldownMs, 100, 300_000),
29
+ };
30
+ }
31
+ function abortedError() {
32
+ return new Error('usage policy wait aborted');
33
+ }
34
+ function delay(ms, signal) {
35
+ if (signal?.aborted)
36
+ return Promise.reject(abortedError());
37
+ if (ms <= 0)
38
+ return Promise.resolve();
39
+ return new Promise((resolve, reject) => {
40
+ const timer = setTimeout(() => {
41
+ signal?.removeEventListener('abort', onAbort);
42
+ resolve();
43
+ }, ms);
44
+ const onAbort = () => {
45
+ clearTimeout(timer);
46
+ signal?.removeEventListener('abort', onAbort);
47
+ reject(abortedError());
48
+ };
49
+ signal?.addEventListener('abort', onAbort, { once: true });
50
+ });
51
+ }
52
+ export class UsageGovernor {
53
+ policy;
54
+ active = 0;
55
+ globalWaiters = [];
56
+ hosts = new Map();
57
+ queued = 0;
58
+ totalRuns = 0;
59
+ totalWaitMs = 0;
60
+ backoffEvents = 0;
61
+ constructor(policy) {
62
+ this.policy = policy;
63
+ }
64
+ host(url) {
65
+ let key;
66
+ try {
67
+ key = new URL(url).hostname.toLowerCase();
68
+ }
69
+ catch {
70
+ throw new Error('usage policy requires an absolute HTTP(S) URL');
71
+ }
72
+ if (!key)
73
+ throw new Error('usage policy requires a URL hostname');
74
+ let state = this.hosts.get(key);
75
+ if (!state) {
76
+ state = { starts: [], blockedUntil: 0, consecutiveFailures: 0 };
77
+ this.hosts.set(key, state);
78
+ }
79
+ return { key, state };
80
+ }
81
+ async acquireGlobal(signal) {
82
+ if (signal?.aborted)
83
+ throw abortedError();
84
+ if (this.active < this.policy.maxConcurrency) {
85
+ this.active++;
86
+ return;
87
+ }
88
+ this.queued++;
89
+ await new Promise((resolve, reject) => {
90
+ const resume = () => {
91
+ signal?.removeEventListener('abort', onAbort);
92
+ this.queued--;
93
+ resolve();
94
+ };
95
+ const onAbort = () => {
96
+ const index = this.globalWaiters.indexOf(resume);
97
+ if (index >= 0)
98
+ this.globalWaiters.splice(index, 1);
99
+ signal?.removeEventListener('abort', onAbort);
100
+ this.queued--;
101
+ reject(abortedError());
102
+ };
103
+ this.globalWaiters.push(resume);
104
+ signal?.addEventListener('abort', onAbort, { once: true });
105
+ });
106
+ }
107
+ releaseGlobal() {
108
+ const next = this.globalWaiters.shift();
109
+ if (next)
110
+ next();
111
+ else
112
+ this.active--;
113
+ }
114
+ async acquireHost(state, signal) {
115
+ while (true) {
116
+ const now = Date.now();
117
+ const windowStart = now - this.policy.minDelayMs;
118
+ state.starts = state.starts.filter(start => start > windowStart);
119
+ const burstReady = state.starts.length < this.policy.burst;
120
+ const readyAt = Math.max(state.blockedUntil, burstReady ? now : (state.starts[0] ?? now) + this.policy.minDelayMs);
121
+ if (readyAt <= now) {
122
+ state.starts.push(now);
123
+ return;
124
+ }
125
+ const waitMs = readyAt - now;
126
+ this.totalWaitMs += waitMs;
127
+ await delay(waitMs, signal);
128
+ }
129
+ }
130
+ async run(url, operation, signal) {
131
+ const { state } = this.host(url);
132
+ await this.acquireGlobal(signal);
133
+ try {
134
+ await this.acquireHost(state, signal);
135
+ this.totalRuns++;
136
+ return await operation();
137
+ }
138
+ finally {
139
+ this.releaseGlobal();
140
+ }
141
+ }
142
+ /** Record server pressure. Returns the applied host cooldown in milliseconds. */
143
+ noteResponse(url, status, retryAfterMs) {
144
+ const { state } = this.host(url);
145
+ if (status >= 200 && status < 400) {
146
+ state.consecutiveFailures = 0;
147
+ return 0;
148
+ }
149
+ if (![429, 502, 503, 504].includes(status))
150
+ return 0;
151
+ state.consecutiveFailures++;
152
+ this.backoffEvents++;
153
+ const exponential = this.policy.backoffBaseMs * (2 ** Math.max(0, state.consecutiveFailures - 1));
154
+ const applied = Math.min(Math.max(retryAfterMs ?? exponential, 0), this.policy.cooldownMs);
155
+ state.blockedUntil = Math.max(state.blockedUntil, Date.now() + applied);
156
+ return applied;
157
+ }
158
+ snapshot() {
159
+ const now = Date.now();
160
+ return {
161
+ active: this.active,
162
+ queued: this.queued,
163
+ trackedHosts: this.hosts.size,
164
+ coolingHosts: [...this.hosts.values()].filter(state => state.blockedUntil > now).length,
165
+ totalRuns: this.totalRuns,
166
+ totalWaitMs: this.totalWaitMs,
167
+ backoffEvents: this.backoffEvents,
168
+ };
169
+ }
170
+ }
171
+ //# sourceMappingURL=usage-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-policy.js","sourceRoot":"","sources":["../src/usage-policy.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAwB/E,MAAM,cAAc,GAAgB;IAClC,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,CAAC;IACjB,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,EAAE;IAClB,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,KAAK;IACpB,UAAU,EAAE,MAAM;CACnB,CAAA;AAED,SAAS,cAAc,CAAC,IAAY,EAAE,KAAc,EAAE,QAAgB,EAAE,GAAW,EAAE,GAAW;IAC9F,MAAM,QAAQ,GAAG,KAAK,IAAI,QAA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plugin for DeepSeek Harness (scoped @anweat) — bundles Playwright (chromium) and OpenCLI as plugin-local dependencies (with global-reuse fallback), exposes a `browser` service and interactive browser tools.",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "lib/index.js",
8
- "types": "lib/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./lib/index.d.ts",
12
- "default": "./lib/index.js"
13
- },
14
- "./cordis.patch.yml": "./cordis.patch.yml",
15
- "./package.json": "./package.json"
16
- },
17
- "files": [
18
- "lib",
19
- "cordis.patch.yml",
20
- "README.md",
21
- "scripts",
22
- "LICENSE"
23
- ],
24
- "engines": {
25
- "node": "^22.19 || >=24"
26
- },
27
- "scripts": {
28
- "build": "tsc -p tsconfig.json",
29
- "test": "node --test --experimental-transform-types test/*.test.ts",
30
- "prepublishOnly": "npm run build",
31
- "prepare": "npm run build"
32
- },
33
- "peerDependencies": {
34
- "@deepseek-ai/cordis": "^4.0.1",
35
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
36
- "@deepseek-ai/schemastery": "^3.18.1"
37
- },
38
- "peerDependenciesMeta": {
39
- "@deepseek-ai/cordis": {
40
- "optional": true
41
- },
42
- "@deepseek-ai/dsh-tools": {
43
- "optional": true
44
- },
45
- "@deepseek-ai/schemastery": {
46
- "optional": true
47
- }
48
- },
49
- "dependencies": {
50
- "@jackwener/opencli": "^1.8.6",
51
- "playwright": "^1.60.0"
52
- },
53
- "devDependencies": {
54
- "@deepseek-ai/cordis": "^4.0.1",
55
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
56
- "@deepseek-ai/schemastery": "^3.18.1",
57
- "typescript": "^5.6.0",
58
- "@types/node": "^22.0.0"
59
- },
60
- "dsh": {
61
- "bundle": {
62
- "patch": "./cordis.patch.yml"
63
- }
64
- },
65
- "packageManager": "pnpm@11.7.0",
66
- "repository": {
67
- "type": "git",
68
- "url": "git+https://github.com/anweat/dsh-browser.git"
69
- },
70
- "keywords": [
71
- "dsh",
72
- "deepseek-harness",
73
- "plugin",
74
- "browser",
75
- "playwright",
76
- "opencli"
77
- ]
78
- }
1
+ {
2
+ "name": "@anweat/dsh-browser",
3
+ "version": "0.1.9",
4
+ "description": "Self-contained browser runtime plugin for DeepSeek Harness (scoped @anweat) — bundles Playwright (chromium) and OpenCLI as plugin-local dependencies (with global-reuse fallback), exposes a `browser` service and interactive browser tools.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "./client": {
15
+ "types": "./lib/client/index.d.ts",
16
+ "default": "./lib/client.js"
17
+ },
18
+ "./cordis.patch.yml": "./cordis.patch.yml",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "lib",
23
+ "cordis.patch.yml",
24
+ "README.md",
25
+ "scripts",
26
+ "LICENSE"
27
+ ],
28
+ "engines": {
29
+ "node": "^22.19 || >=24"
30
+ },
31
+ "peerDependencies": {
32
+ "@deepseek-ai/cordis": "^4.0.1",
33
+ "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
34
+ "@deepseek-ai/dsh-client-connection": "^0.1.1-rc.2",
35
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
36
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
37
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
38
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
39
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
40
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
41
+ "@deepseek-ai/schemastery": "^3.18.1"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "@deepseek-ai/cordis": {
45
+ "optional": true
46
+ },
47
+ "@deepseek-ai/dsh-tools": {
48
+ "optional": true
49
+ },
50
+ "@deepseek-ai/dsh-client-connection": {
51
+ "optional": true
52
+ },
53
+ "@deepseek-ai/dsh-client-locale": {
54
+ "optional": true
55
+ },
56
+ "@deepseek-ai/dsh-client-runtime": {
57
+ "optional": true
58
+ },
59
+ "@deepseek-ai/dsh-client-ui-settings": {
60
+ "optional": true
61
+ },
62
+ "@deepseek-ai/dsh-client-ui-settings-plugins": {
63
+ "optional": true
64
+ },
65
+ "@deepseek-ai/dsh-client-ui-slots": {
66
+ "optional": true
67
+ },
68
+ "@deepseek-ai/dsh-settings": {
69
+ "optional": true
70
+ },
71
+ "@deepseek-ai/schemastery": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "dependencies": {
76
+ "@jackwener/opencli": "^1.8.6",
77
+ "patchright": "^1.62.1",
78
+ "playwright": "^1.60.0"
79
+ },
80
+ "devDependencies": {
81
+ "@deepseek-ai/cordis": "^4.0.1",
82
+ "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
83
+ "@deepseek-ai/dsh-client-connection": "^0.1.1-rc.2",
84
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
85
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
86
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.2",
87
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.2",
88
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
89
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.2",
90
+ "@deepseek-ai/schemastery": "^3.18.1",
91
+ "@types/react": "~18.3.1",
92
+ "@types/react-dom": "~18.3.1",
93
+ "react": "^18.2.0",
94
+ "react-dom": "18.2.0",
95
+ "tsdown": "^0.22.2",
96
+ "typescript": "^5.6.0",
97
+ "@types/node": "^22.0.0"
98
+ },
99
+ "dsh": {
100
+ "client": {
101
+ "inject": [
102
+ "@deepseek-ai/dsh-client-connection",
103
+ "@deepseek-ai/dsh-client-locale",
104
+ "@deepseek-ai/dsh-client-runtime",
105
+ "@deepseek-ai/dsh-client-ui-settings",
106
+ "@deepseek-ai/dsh-client-ui-settings-plugins"
107
+ ],
108
+ "platform": "web"
109
+ },
110
+ "bundle": {
111
+ "patch": "./cordis.patch.yml"
112
+ }
113
+ },
114
+ "repository": {
115
+ "type": "git",
116
+ "url": "git+https://github.com/anweat/dsh-browser.git"
117
+ },
118
+ "keywords": [
119
+ "dsh",
120
+ "deepseek-harness",
121
+ "plugin",
122
+ "browser",
123
+ "playwright",
124
+ "opencli"
125
+ ],
126
+ "scripts": {
127
+ "build": "node scripts/clean-lib.mjs && tsc -p tsconfig.json && tsdown",
128
+ "typecheck": "tsc -p tsconfig.json --noEmit",
129
+ "test": "node --test --experimental-transform-types test/*.test.ts",
130
+ "test:client-bundle": "node scripts/check-client-bundle.mjs",
131
+ "verify": "pnpm run typecheck && pnpm run build && pnpm test && pnpm run test:client-bundle"
132
+ }
133
+ }
@@ -0,0 +1,15 @@
1
+ import assert from 'node:assert/strict'
2
+ import { readFile } from 'node:fs/promises'
3
+
4
+ const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
5
+ const sourceMap = JSON.parse(await readFile(new URL('../lib/client.js.map', import.meta.url), 'utf8'))
6
+ const imports = [...source.matchAll(/\brequire\((['"])([^'"]+)\1\)/g)].map(match => match[2])
7
+ const allowed = new Set(['react', 'react/jsx-runtime', 'react-dom', 'react-dom/client', '@deepseek-ai/cordis', '@deepseek-ai/dsh-client-runtime/client', '@deepseek-ai/dsh-client-ui-slots'])
8
+ const forbidden = [...new Set(imports.filter(id => !allowed.has(id)))].sort()
9
+
10
+ assert.deepEqual(forbidden, [], `client bundle contains unavailable imports: ${forbidden.join(', ')}`)
11
+ assert.match(source, /settings\.plugin\.item/)
12
+ assert.match(source, /dsh-browser/)
13
+ assert.match(source, /Browser automation/)
14
+ assert.equal('sourcesContent' in sourceMap, false, 'client source map must exclude source contents')
15
+ console.log(`client bundle check passed (${[...new Set(imports)].length} module-table imports)`)
@@ -0,0 +1,3 @@
1
+ import { rm } from 'node:fs/promises'
2
+
3
+ await rm(new URL('../lib', import.meta.url), { recursive: true, force: true })