dsh-inner-browser-use 0.13.0 → 0.27.0
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/README.md +7 -3
- package/README.zh.md +3 -1
- package/docs/ARCHITECTURE.md +15 -1
- package/docs/BENCH.md +224 -5
- package/docs/ROADMAP.md +129 -3
- package/docs/VERIFY.md +69 -2
- package/index.js +3 -0
- package/package.json +9 -3
- package/read.js +981 -0
- package/sidecar.js +42 -1
- package/tools.js +1749 -0
package/sidecar.js
CHANGED
|
@@ -910,6 +910,36 @@ export class Sidecar {
|
|
|
910
910
|
this.idle = null
|
|
911
911
|
this.lastError = ''
|
|
912
912
|
this.lastUrl = ''
|
|
913
|
+
/* What the person did in the mirror, and when. It starts empty rather than
|
|
914
|
+
missing: an adopted browser has no record of a hand on it yet, and asking
|
|
915
|
+
about one used to throw instead of answering. */
|
|
916
|
+
this.person = { at: 0, kind: '', x: 0, y: 0, seen: true } // ui-copy-ignore
|
|
917
|
+
/* How long after the person's last real input the agent holds off. Short
|
|
918
|
+
enough that a stray click does not stall a run, long enough that the agent
|
|
919
|
+
does not type into a field the person is in the middle of filling. */
|
|
920
|
+
this.holdMs = 6000
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* The person touched the mirror by hand; every action waits for them now.
|
|
925
|
+
* Called from the input route, which only sees the person's own input.
|
|
926
|
+
*/
|
|
927
|
+
humanUse({ kind = '', x = 0, y = 0 } = {}) {
|
|
928
|
+
this.person = { at: Date.now(), kind, x, y, seen: false }
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/** @returns {number} ms the agent should still hold off; 0 when free to act. */
|
|
932
|
+
holding() {
|
|
933
|
+
if (this.person === undefined || this.person.at === 0) return 0
|
|
934
|
+
const left = this.holdMs - (Date.now() - this.person.at)
|
|
935
|
+
return left > 0 ? left : 0
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/** Take the page back now, without waiting out the hold. */
|
|
939
|
+
release() {
|
|
940
|
+
if (this.person === undefined) this.person = { at: 0, kind: '', x: 0, y: 0, seen: true } // ui-copy-ignore
|
|
941
|
+
this.person.at = 0
|
|
942
|
+
this.person.seen = true
|
|
913
943
|
}
|
|
914
944
|
|
|
915
945
|
/**
|
|
@@ -946,7 +976,18 @@ export class Sidecar {
|
|
|
946
976
|
*/
|
|
947
977
|
async ensure(options = {}) {
|
|
948
978
|
if (options.profile !== undefined) this.profile = options.profile
|
|
949
|
-
|
|
979
|
+
const wanted = options.headless === undefined ? this.headless : options.headless !== false
|
|
980
|
+
const modeChanged = wanted !== this.headless
|
|
981
|
+
this.headless = wanted
|
|
982
|
+
/* A windowless browser and a windowed one are different processes, so asking
|
|
983
|
+
for the other one has to restart it. Setting the flag alone left the request
|
|
984
|
+
with no effect at all: a site that refuses a windowless browser stayed out
|
|
985
|
+
of reach until the browser happened to close for an unrelated reason. */
|
|
986
|
+
if (this.alive && modeChanged) {
|
|
987
|
+
const wasAt = options.url ?? this.page?.lastUrl ?? this.lastUrl
|
|
988
|
+
await this.shutdown()
|
|
989
|
+
return this.ensure({ ...options, url: wasAt })
|
|
990
|
+
}
|
|
950
991
|
if (this.alive) {
|
|
951
992
|
const page = this.page
|
|
952
993
|
/* A page that stopped answering is a page nobody can drive. Start a new
|