dsh-inner-browser-use 0.34.96 → 0.34.97
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/client.js +10 -1
- package/package.json +1 -1
- package/sidecar.js +53 -0
package/client.js
CHANGED
|
@@ -598,7 +598,16 @@ window.__ModuleLoader__.load({
|
|
|
598
598
|
})
|
|
599
599
|
.then((answer) => (answer.ok === true ? answer.json() : { ok: false }))
|
|
600
600
|
.then((said) => {
|
|
601
|
-
if (!live
|
|
601
|
+
if (!live) return
|
|
602
|
+
/* The browser answers with the shape it actually took: drawing
|
|
603
|
+
the picture at that size fills the pane even when the page
|
|
604
|
+
refused the exact one asked for. */
|
|
605
|
+
const took = said?.view ?? null
|
|
606
|
+
if (said?.ok === true && took !== null && Number(took.width) > 0 && Number(took.height) > 0) {
|
|
607
|
+
setView({ w: Math.round(Number(took.width)), h: Math.round(Number(took.height)) })
|
|
608
|
+
return
|
|
609
|
+
}
|
|
610
|
+
if (said?.ok === true || tries >= 5) return
|
|
602
611
|
tries += 1
|
|
603
612
|
timer = setTimeout(send, 400)
|
|
604
613
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-inner-browser-use",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.97",
|
|
4
4
|
"description": "An agent-owned Chromium sidecar mirrored into the DeepSeek Harness right column: the agent drives it, the person watches and can take the mouse, and logins survive restarts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/sidecar.js
CHANGED
|
@@ -1962,6 +1962,10 @@ export class Sidecar {
|
|
|
1962
1962
|
/* One tab per chat: a second chat opening an address gets a tab of its
|
|
1963
1963
|
own, so neither can navigate the other's page away. */
|
|
1964
1964
|
this.pages = new Map()
|
|
1965
|
+
/* Every tab a chat has driven, so its column can offer its own windows
|
|
1966
|
+
back after it switches away: a tab the chat left is still its own, and a
|
|
1967
|
+
tab nobody claimed belongs to no column at all. */
|
|
1968
|
+
this.claims = new Map()
|
|
1965
1969
|
/* Tabs left behind by an earlier plugin load are closed once, on the first
|
|
1966
1970
|
call that finds this browser: a profile used for weeks otherwise keeps a
|
|
1967
1971
|
renderer per chat that ever opened it. */
|
|
@@ -2048,6 +2052,41 @@ export class Sidecar {
|
|
|
2048
2052
|
* @param {string} session - chat id, empty for the default tab.
|
|
2049
2053
|
* @returns {SidecarPage | null} the tab, if the browser is up.
|
|
2050
2054
|
*/
|
|
2055
|
+
/**
|
|
2056
|
+
* Remember that a tab belongs to a chat: switching away from it keeps it in
|
|
2057
|
+
* that chat's window list, and no other chat can see it.
|
|
2058
|
+
* @param {string} session - chat that drove the tab. // ui-copy-ignore
|
|
2059
|
+
* @param {string} targetId - the browser target.
|
|
2060
|
+
*/
|
|
2061
|
+
claim(session, targetId) {
|
|
2062
|
+
const who = String(session ?? '')
|
|
2063
|
+
const target = String(targetId ?? '')
|
|
2064
|
+
if (who === '' || target === '') return
|
|
2065
|
+
let set = this.claims.get(who)
|
|
2066
|
+
if (set === undefined) {
|
|
2067
|
+
set = new Set()
|
|
2068
|
+
this.claims.set(who, set)
|
|
2069
|
+
}
|
|
2070
|
+
/* A chat cannot hold an unbounded list: the oldest tab it left falls off. */
|
|
2071
|
+
if (set.size >= 12 && set.has(target) !== true) {
|
|
2072
|
+
const first = set.values().next()
|
|
2073
|
+
if (first.done !== true) set.delete(first.value)
|
|
2074
|
+
}
|
|
2075
|
+
set.add(target)
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
/**
|
|
2079
|
+
* Forget a tab a chat no longer has.
|
|
2080
|
+
* @param {string} session - chat that owned it. // ui-copy-ignore
|
|
2081
|
+
* @param {string} targetId - the browser target.
|
|
2082
|
+
*/
|
|
2083
|
+
unclaim(session, targetId) {
|
|
2084
|
+
const set = this.claims.get(String(session ?? ''))
|
|
2085
|
+
if (set === undefined) return
|
|
2086
|
+
set.delete(String(targetId ?? ''))
|
|
2087
|
+
if (set.size === 0) this.claims.delete(String(session ?? ''))
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2051
2090
|
pageFor(session) {
|
|
2052
2091
|
const id = String(session ?? '')
|
|
2053
2092
|
if (id === '') return this.page
|
|
@@ -2265,6 +2304,7 @@ export class Sidecar {
|
|
|
2265
2304
|
await cdp.ready
|
|
2266
2305
|
const page = await this.bind(await new SidecarPage(cdp, this.profile, port, () => this.holding()).start()) // ui-copy-ignore
|
|
2267
2306
|
this.pages.set(id, page)
|
|
2307
|
+
this.claim(id, page.targetId)
|
|
2268
2308
|
this.touch()
|
|
2269
2309
|
this.rememberTab(id, address)
|
|
2270
2310
|
return page
|
|
@@ -2614,10 +2654,21 @@ export class Sidecar {
|
|
|
2614
2654
|
const list = await this.tabs(session)
|
|
2615
2655
|
const page = this.pageFor(session) ?? this.page
|
|
2616
2656
|
const foreign = new Set(typeof page?.siblings === 'function' ? page.siblings().map(String) : [])
|
|
2657
|
+
const who = String(session ?? '')
|
|
2658
|
+
const claimed = this.claims.get(who) ?? new Set()
|
|
2659
|
+
/* Tabs the browser no longer has must not linger in a chat's list. */
|
|
2660
|
+
if (claimed.size > 0) {
|
|
2661
|
+
const live = new Set(list.map((row) => String(row.targetId)))
|
|
2662
|
+
for (const id of [...claimed]) if (live.has(id) !== true) claimed.delete(id)
|
|
2663
|
+
if (claimed.size === 0) this.claims.delete(who)
|
|
2664
|
+
}
|
|
2617
2665
|
const shown = []
|
|
2618
2666
|
for (let at = 0; at < list.length; at += 1) {
|
|
2619
2667
|
const row = list[at]
|
|
2620
2668
|
if (foreign.has(String(row.targetId))) continue
|
|
2669
|
+
/* A tab nobody in this chat drove is not this chat's window: a page
|
|
2670
|
+
opened behind the browser's back belongs to no column. */
|
|
2671
|
+
if (row.current !== true && claimed.has(String(row.targetId)) !== true) continue
|
|
2621
2672
|
/* The index is the browser's own row, not this shorter list's: switching
|
|
2622
2673
|
goes back through `tabs()` unfiltered. */
|
|
2623
2674
|
shown.push({ title: String(row.title ?? ''), url: String(row.url ?? ''), current: row.current === true, index: at })
|
|
@@ -2666,6 +2717,7 @@ export class Sidecar {
|
|
|
2666
2717
|
await cdp.ready
|
|
2667
2718
|
const page = await this.bind(await new SidecarPage(cdp, this.profile, mine.port, () => this.holding()).start()) // ui-copy-ignore
|
|
2668
2719
|
this.pages.set(String(session), page)
|
|
2720
|
+
this.claim(session, tab.targetId)
|
|
2669
2721
|
mine.cdp.send('Page.stopScreencast').catch(() => {})
|
|
2670
2722
|
mine.cdp.close()
|
|
2671
2723
|
await page.cast()
|
|
@@ -2701,6 +2753,7 @@ export class Sidecar {
|
|
|
2701
2753
|
alone = other < 0
|
|
2702
2754
|
if (!alone) await this.useTab(other, session)
|
|
2703
2755
|
}
|
|
2756
|
+
this.unclaim(session, tab.targetId)
|
|
2704
2757
|
if (port > 0) await fetch(`http://127.0.0.1:${port}/json/close/${tab.targetId}`, { signal: AbortSignal.timeout(1000) }).catch(() => {}) // ui-copy-ignore
|
|
2705
2758
|
if (alone && mine !== null) {
|
|
2706
2759
|
/* The chat still needs somewhere to go: a fresh tab in the same browser. */
|