omowright 0.0.0 → 0.2.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -2
  3. package/TOOLS.md +487 -0
  4. package/bin/omowright-cloak.mjs +112 -0
  5. package/package.json +57 -4
  6. package/presets/agent-events/SKILL.md +75 -0
  7. package/presets/captcha/SKILL.md +129 -0
  8. package/presets/chrome/SKILL.md +88 -0
  9. package/presets/cloak-bridge/SKILL.md +43 -0
  10. package/presets/network/SKILL.md +126 -0
  11. package/presets/visual-browse/SKILL.md +103 -0
  12. package/skills/omowright/SKILL.md +193 -0
  13. package/skills/omowright/references/1password.md +118 -0
  14. package/skills/omowright/references/browserskill.md +195 -0
  15. package/skills/omowright/references/eval-kernel.md +100 -0
  16. package/skills/omowright/references/frames-layers-human.md +123 -0
  17. package/skills/omowright/references/quickstart.md +109 -0
  18. package/skills/omowright/references/stealth.md +174 -0
  19. package/src/agent-tabs.js +179 -0
  20. package/src/aria-hidden.js +47 -0
  21. package/src/bridge-schemas.js +44 -0
  22. package/src/bridge-transport.js +83 -0
  23. package/src/browser-context.js +105 -0
  24. package/src/browser-process.js +127 -0
  25. package/src/bsk/browser-signals.js +90 -0
  26. package/src/bsk/browsers.js +114 -0
  27. package/src/bsk/connect.js +75 -0
  28. package/src/bsk/daemon-info.js +100 -0
  29. package/src/bsk/external-extension.js +110 -0
  30. package/src/bsk/identify-browser.js +88 -0
  31. package/src/bsk/install-cli.js +81 -0
  32. package/src/bsk/ipc-client.js +236 -0
  33. package/src/bsk/onboard.js +140 -0
  34. package/src/bsk/screenshot.js +49 -0
  35. package/src/bsk/session.js +131 -0
  36. package/src/bsk/snapshot.js +56 -0
  37. package/src/bsk/targets.js +25 -0
  38. package/src/captcha-wait.js +79 -0
  39. package/src/captcha.js +142 -0
  40. package/src/cdp-errors.js +23 -0
  41. package/src/cdp-methods.js +69 -0
  42. package/src/chrome-profile.js +176 -0
  43. package/src/chrome.js +194 -0
  44. package/src/cloak-profile.js +266 -0
  45. package/src/connection.js +234 -0
  46. package/src/console-events.js +12 -0
  47. package/src/cookies.js +39 -0
  48. package/src/core.js +1702 -0
  49. package/src/cua.js +74 -0
  50. package/src/dialog-policy.js +80 -0
  51. package/src/emulate.js +127 -0
  52. package/src/events.js +111 -0
  53. package/src/frames-snapshot.js +138 -0
  54. package/src/har.js +103 -0
  55. package/src/human-handoff.js +124 -0
  56. package/src/index.js +89 -0
  57. package/src/injected.js +3 -0
  58. package/src/instance-lock.js +74 -0
  59. package/src/instances.js +490 -0
  60. package/src/internal-capability.js +1 -0
  61. package/src/launch-endpoint.js +185 -0
  62. package/src/layers.js +138 -0
  63. package/src/llm.js +201 -0
  64. package/src/lock-backend-win32.js +54 -0
  65. package/src/lock-backend.js +81 -0
  66. package/src/native-host-win32.js +201 -0
  67. package/src/network-events.js +223 -0
  68. package/src/network-snoop.js +229 -0
  69. package/src/nul-frames.js +28 -0
  70. package/src/open-shadow-query.js +101 -0
  71. package/src/owner-only.js +196 -0
  72. package/src/page-bundle.js +1478 -0
  73. package/src/page-events.js +45 -0
  74. package/src/page-routes.js +94 -0
  75. package/src/page-setup.js +239 -0
  76. package/src/pipe.js +418 -0
  77. package/src/process-start-time.js +64 -0
  78. package/src/routes.js +256 -0
  79. package/src/running-browser.js +85 -0
  80. package/src/scroll-collect.js +73 -0
  81. package/src/serial-emitter.js +17 -0
  82. package/src/shared-connections.js +285 -0
  83. package/src/snapshot-diff.js +75 -0
  84. package/src/text-matching.js +101 -0
  85. package/src/trace.js +183 -0
  86. package/src/url-match.js +148 -0
  87. package/src/viewport.js +12 -0
@@ -0,0 +1,148 @@
1
+ // URL matching for page.waitForURL, ported from Playwright's packages/isomorphic/urlMatch.ts
2
+ // (Copyright (c) Microsoft Corporation, Apache License 2.0) so that globs, regular expressions and
3
+ // predicates written for Playwright match the same URLs here. OmOWright has no baseURL option, so
4
+ // globs resolve the way Playwright resolves them without one.
5
+
6
+ const escapedChars = new Set(["$", "^", "+", ".", "*", "(", ")", "|", "\\", "?", "{", "}", "[", "]"]);
7
+
8
+ function globToRegexPattern(glob) {
9
+ const tokens = ["^"];
10
+ let inGroup = false;
11
+ for (let i = 0; i < glob.length; ++i) {
12
+ const c = glob[i];
13
+ if (c === "\\" && i + 1 < glob.length) {
14
+ const char = glob[++i];
15
+ tokens.push(escapedChars.has(char) ? "\\" + char : char);
16
+ continue;
17
+ }
18
+ if (c === "*") {
19
+ const charBefore = glob[i - 1];
20
+ let starCount = 1;
21
+ while (glob[i + 1] === "*") {
22
+ starCount++;
23
+ i++;
24
+ }
25
+ if (starCount > 1) {
26
+ const charAfter = glob[i + 1];
27
+ // Match either /..something../ or /.
28
+ if (charAfter === "/") {
29
+ if (charBefore === "/") tokens.push("((.+/)|)");
30
+ else tokens.push("(.*/)");
31
+ ++i;
32
+ } else {
33
+ tokens.push("(.*)");
34
+ }
35
+ } else {
36
+ tokens.push("([^/]*)");
37
+ }
38
+ continue;
39
+ }
40
+
41
+ switch (c) {
42
+ case "{":
43
+ if (inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: nested '{' is not supported`);
44
+ inGroup = true;
45
+ tokens.push("(");
46
+ break;
47
+ case "}":
48
+ if (!inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: unmatched '}'`);
49
+ inGroup = false;
50
+ tokens.push(")");
51
+ break;
52
+ case ",":
53
+ if (inGroup) {
54
+ tokens.push("|");
55
+ break;
56
+ }
57
+ tokens.push("\\" + c);
58
+ break;
59
+ default:
60
+ tokens.push(escapedChars.has(c) ? "\\" + c : c);
61
+ }
62
+ }
63
+ if (inGroup) throw new Error(`Invalid glob pattern ${JSON.stringify(glob)}: unmatched '{'`);
64
+ tokens.push("$");
65
+ return tokens.join("");
66
+ }
67
+
68
+ function resolveGlob(match) {
69
+ if (match.startsWith("*")) return match;
70
+ const tokenMap = new Map();
71
+ function mapToken(original, replacement) {
72
+ if (original.length === 0) return "";
73
+ tokenMap.set(replacement, original);
74
+ return replacement;
75
+ }
76
+ // Escaped `\\?` behaves the same as `?` in these glob patterns.
77
+ match = match.replaceAll(/\\\\\?/g, "?");
78
+ if (match.startsWith("about:") || match.startsWith("data:")
79
+ || match.startsWith("chrome:") || match.startsWith("edge:")
80
+ || match.startsWith("file:")) return match;
81
+ // Glob symbols may be escaped in the URL and some of them such as ? affect resolution,
82
+ // so they are replaced with safe components first.
83
+ const relativePath = match.split("/").map((token, index) => {
84
+ if (token === "." || token === ".." || token === "") return token;
85
+ // http*:// and similar: the stand-in scheme must be a web scheme so slashes follow the host.
86
+ if (index === 0 && token.endsWith(":")) {
87
+ if (token.indexOf("*") !== -1 || token.indexOf("{") !== -1) return mapToken(token, "http:");
88
+ // An explicit scheme is kept as is; it decides trailing slashes after the host.
89
+ return token;
90
+ }
91
+ // Literal components round-trip through new URL() so default ports, percent-encoding and IDN
92
+ // hosts are normalized; only components with glob characters are replaced.
93
+ if (!/[*?{}\\]/.test(token)) return token;
94
+ const questionIndex = token.indexOf("?");
95
+ if (questionIndex === -1) return mapToken(token, `$_${index}_$`);
96
+ const newPrefix = mapToken(token.substring(0, questionIndex), `$_${index}_$`);
97
+ const newSuffix = mapToken(token.substring(questionIndex), `?$_${index}_$`);
98
+ return newPrefix + newSuffix;
99
+ }).join("/");
100
+ const result = resolveURL(relativePath);
101
+ let resolved = result.resolved;
102
+ for (const [token, original] of tokenMap) {
103
+ const normalize = result.caseInsensitivePart?.includes(token);
104
+ const replacement = normalize ? original.toLowerCase() : original;
105
+ // The function form keeps `$$`, `$&` and similar replacement patterns literal.
106
+ resolved = resolved.replace(token, () => replacement);
107
+ }
108
+ return resolved;
109
+ }
110
+
111
+ function resolveURL(givenURL) {
112
+ try {
113
+ const url = new URL(givenURL);
114
+ // Scheme and host are case-insensitive.
115
+ return { resolved: url.toString(), caseInsensitivePart: url.origin };
116
+ } catch {
117
+ return { resolved: givenURL };
118
+ }
119
+ }
120
+
121
+ function parseURL(url) {
122
+ try {
123
+ return new URL(url);
124
+ } catch {
125
+ return null;
126
+ }
127
+ }
128
+
129
+ function isRegExp(value) {
130
+ return value instanceof RegExp || Object.prototype.toString.call(value) === "[object RegExp]";
131
+ }
132
+
133
+ /**
134
+ * Playwright's URL match: a glob string, a RegExp, or a predicate receiving a URL object.
135
+ * An empty or missing match accepts every URL; an invalid glob throws.
136
+ */
137
+ export async function urlMatches(urlString, match) {
138
+ if (match === undefined || match === "") return true;
139
+ if (typeof match === "string") match = new RegExp(globToRegexPattern(resolveGlob(match)));
140
+ if (isRegExp(match)) {
141
+ match.lastIndex = 0;
142
+ return match.test(urlString);
143
+ }
144
+ if (typeof match !== "function") throw new TypeError("url parameter should be string, RegExp or function");
145
+ const url = parseURL(urlString);
146
+ if (!url) return false;
147
+ return Boolean(await match(url));
148
+ }
@@ -0,0 +1,12 @@
1
+ export const DEFAULT_AGENT_VIEWPORT = Object.freeze({ width: 1440, height: 900 });
2
+
3
+ function validateViewport(viewport) {
4
+ if (!viewport || !Number.isInteger(viewport.width) || viewport.width <= 0 || !Number.isInteger(viewport.height) || viewport.height <= 0) throw new TypeError("viewport width and height must be positive integers");
5
+ return { width: viewport.width, height: viewport.height };
6
+ }
7
+ export async function repinViewport(page, viewport, options = {}) {
8
+ const size = validateViewport(viewport); const sessionId = await page.resolveSessionId();
9
+ await page.cdp.send("Emulation.setDeviceMetricsOverride", { ...size, screenWidth: size.width, screenHeight: size.height, deviceScaleFactor: options.deviceScaleFactor ?? 1, mobile: options.mobile ?? false }, sessionId);
10
+ page.setCachedViewportSize(size); return { ...size };
11
+ }
12
+ export { validateViewport };