yunti-browser-runtime 0.1.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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -0
  3. package/bin/yunti-browser-runtime.js +86 -0
  4. package/docs/EXECUTION_PLAN.md +1278 -0
  5. package/docs/INSTALL.md +205 -0
  6. package/docs/PROJECT_INTENT.md +44 -0
  7. package/docs/PROJECT_STATUS.md +263 -0
  8. package/docs/PUBLISHING_BLOCKERS.md +110 -0
  9. package/docs/RELEASE.md +148 -0
  10. package/docs/ROADMAP.md +42 -0
  11. package/docs/SECURITY.md +56 -0
  12. package/docs/TOOL_GUIDE.md +69 -0
  13. package/extension/background.js +55 -0
  14. package/extension/cdp.js +582 -0
  15. package/extension/content.css +9 -0
  16. package/extension/content.js +946 -0
  17. package/extension/manifest.json +35 -0
  18. package/extension/network-monitor.js +140 -0
  19. package/extension/popup.css +66 -0
  20. package/extension/popup.html +30 -0
  21. package/extension/popup.js +55 -0
  22. package/extension/session-manager.js +332 -0
  23. package/extension/settings.js +94 -0
  24. package/extension/tool-handlers.js +1158 -0
  25. package/lib/runtime-paths.js +39 -0
  26. package/mcp/bridge-hub.js +604 -0
  27. package/mcp/http-server.js +326 -0
  28. package/mcp/json-rpc.js +35 -0
  29. package/mcp/memory.js +126 -0
  30. package/mcp/redaction.js +94 -0
  31. package/mcp/server.js +269 -0
  32. package/mcp/tools.js +1092 -0
  33. package/package.json +60 -0
  34. package/scripts/check-package-metadata.js +131 -0
  35. package/scripts/check-published-package.js +113 -0
  36. package/scripts/doctor.js +163 -0
  37. package/scripts/package-extension.js +137 -0
  38. package/scripts/print-config.js +116 -0
  39. package/scripts/release-check.js +472 -0
  40. package/skills/yunti-browser-runtime/SKILL.md +77 -0
@@ -0,0 +1,94 @@
1
+ export const DEFAULT_BRIDGE_URL = "http://127.0.0.1:48887"
2
+ export const BRIDGE_TOKEN_HEADER = "x-yunti-browser-token"
3
+ export const DEFAULT_PLATFORM_MATCHES = ["*"]
4
+
5
+ export async function getSettings() {
6
+ const stored = await chrome.storage.local.get([
7
+ "localUserName",
8
+ "localUserId",
9
+ "bridgeUrl",
10
+ "bridgeToken",
11
+ "platformMatches",
12
+ ])
13
+ const platformMatches = normalizePlatformMatches(stored.platformMatches)
14
+ const localUserName = normalizeLocalUserName(stored.localUserName || "local")
15
+ const localUserId = stored.localUserId || "local"
16
+ return {
17
+ localUserName,
18
+ localUserId,
19
+ bridgeUrl: normalizeBaseUrl(stored.bridgeUrl || DEFAULT_BRIDGE_URL),
20
+ bridgeToken: normalizeBridgeToken(stored.bridgeToken || ""),
21
+ agentType: "browser_agent",
22
+ platformMatches,
23
+ }
24
+ }
25
+
26
+ export function normalizeBaseUrl(value) {
27
+ return String(value || "")
28
+ .trim()
29
+ .replace(/\/+$/, "")
30
+ }
31
+
32
+ export function normalizeBridgeToken(value) {
33
+ return String(value || "").trim()
34
+ }
35
+
36
+ export function normalizePlatformMatches(value) {
37
+ const list = Array.isArray(value)
38
+ ? value
39
+ : String(value || "")
40
+ .split(/[\n,]/)
41
+ .map((item) => item.trim())
42
+ const normalized = list.map(normalizeHostPattern).filter(Boolean)
43
+ return normalized.length ? [...new Set(normalized)] : DEFAULT_PLATFORM_MATCHES
44
+ }
45
+
46
+ function normalizeHostPattern(value) {
47
+ let text = String(value || "")
48
+ .trim()
49
+ .toLowerCase()
50
+ if (!text) return ""
51
+ text = text.replace(/^https?:\/\//, "").replace(/\/.*$/, "")
52
+ return text
53
+ }
54
+
55
+ export function normalizeLocalUserName(value) {
56
+ return String(value || "").trim().slice(0, 120)
57
+ }
58
+
59
+ export function isPlatformUrl(rawUrl, settings = null) {
60
+ try {
61
+ const url = new URL(String(rawUrl || ""))
62
+ if (!["http:", "https:"].includes(url.protocol)) return false
63
+ const matches = settings?.platformMatches || DEFAULT_PLATFORM_MATCHES
64
+ return matches.some((pattern) => hostMatchesPattern(url.hostname, pattern))
65
+ } catch {
66
+ return false
67
+ }
68
+ }
69
+
70
+ export function platformLabelForUrl(rawUrl) {
71
+ try {
72
+ return new URL(String(rawUrl || "")).hostname
73
+ } catch {
74
+ return "page"
75
+ }
76
+ }
77
+
78
+ function hostMatchesPattern(hostname, pattern) {
79
+ const host = String(hostname || "").toLowerCase()
80
+ const pat = String(pattern || "").toLowerCase()
81
+ if (!host || !pat) return false
82
+ if (pat === "*") return true
83
+ if (pat.startsWith("*.")) {
84
+ const suffix = pat.slice(1)
85
+ return host.endsWith(suffix) && host.length > suffix.length
86
+ }
87
+ return host === pat
88
+ }
89
+
90
+ export function bridgeHeaders(settings) {
91
+ const headers = { "content-type": "application/json" }
92
+ if (settings?.bridgeToken) headers[BRIDGE_TOKEN_HEADER] = settings.bridgeToken
93
+ return headers
94
+ }