@lobu/runtime-device 24.1.0 → 24.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.
- package/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +26 -28
- package/npm-shrinkwrap.json +155 -172
- package/package.json +1 -1
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +14 -5
- package/vendor/cli/dist/chrome-extension/accessibility-tree.js +834 -0
- package/vendor/cli/dist/chrome-extension/ambient-context.js +53 -0
- package/vendor/cli/dist/chrome-extension/auth-refresh.js +167 -0
- package/vendor/cli/dist/chrome-extension/automation-run.js +13 -0
- package/vendor/cli/dist/chrome-extension/background.js +1155 -0
- package/vendor/cli/dist/chrome-extension/bridge.js +140 -0
- package/vendor/cli/dist/chrome-extension/browser-origin-policy.js +62 -0
- package/vendor/cli/dist/chrome-extension/browser-recovery.js +260 -0
- package/vendor/cli/dist/chrome-extension/browser-url-sanitizer.js +284 -0
- package/vendor/cli/dist/chrome-extension/completion-response.js +12 -0
- package/vendor/cli/dist/chrome-extension/config.js +144 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome.json +1516 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_bookmarks.json +84 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_downloads.json +86 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests/chrome_history.json +78 -0
- package/vendor/cli/dist/chrome-extension/connector-manifests.js +1767 -0
- package/vendor/cli/dist/chrome-extension/console-capture.js +627 -0
- package/vendor/cli/dist/chrome-extension/control-activity.js +70 -0
- package/vendor/cli/dist/chrome-extension/debugger-lease.js +439 -0
- package/vendor/cli/dist/chrome-extension/feed-listener.js +488 -0
- package/vendor/cli/dist/chrome-extension/feed-transaction.js +48 -0
- package/vendor/cli/dist/chrome-extension/feeds.js +632 -0
- package/vendor/cli/dist/chrome-extension/focus-tab.js +25 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-mono-latin-500-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-sans-latin-400-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/fonts/dm-sans-latin-600-normal.woff2 +0 -0
- package/vendor/cli/dist/chrome-extension/heartbeat.js +140 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-128-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-128.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-16-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-16.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-32-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-32.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-48-rec.png +0 -0
- package/vendor/cli/dist/chrome-extension/icons/icon-48.png +0 -0
- package/vendor/cli/dist/chrome-extension/lens-page.js +135 -0
- package/vendor/cli/dist/chrome-extension/lens-target.js +20 -0
- package/vendor/cli/dist/chrome-extension/manifest.json +76 -0
- package/vendor/cli/dist/chrome-extension/network-intercept.js +657 -0
- package/vendor/cli/dist/chrome-extension/page-activation.js +120 -0
- package/vendor/cli/dist/chrome-extension/page-dialogs.js +125 -0
- package/vendor/cli/dist/chrome-extension/page-url.js +11 -0
- package/vendor/cli/dist/chrome-extension/panel-session.js +184 -0
- package/vendor/cli/dist/chrome-extension/poll-auth.js +85 -0
- package/vendor/cli/dist/chrome-extension/poll-backoff.js +22 -0
- package/vendor/cli/dist/chrome-extension/run-fence.js +117 -0
- package/vendor/cli/dist/chrome-extension/setup-status.js +71 -0
- package/vendor/cli/dist/chrome-extension/side-panel-action-click.js +65 -0
- package/vendor/cli/dist/chrome-extension/sidepanel-context.js +50 -0
- package/vendor/cli/dist/chrome-extension/sidepanel.html +680 -0
- package/vendor/cli/dist/chrome-extension/sidepanel.js +1643 -0
- package/vendor/cli/dist/chrome-extension/tab-labels.js +233 -0
- package/vendor/cli/dist/chrome-extension/tools.js +3354 -0
- package/vendor/cli/dist/chrome-extension/watch-observer.js +354 -0
- package/vendor/cli/dist/chrome-extension/watch-redact.js +96 -0
- package/vendor/cli/dist/chrome-extension/watch.js +348 -0
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +6 -4
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +5 -3
- package/vendor/cli/dist/commands/_lib/apply/diff.js +4 -3
- package/vendor/cli/dist/commands/_lib/apply/render.js +4 -14
- package/vendor/cli/dist/commands/_lib/chrome-for-testing.d.ts +13 -0
- package/vendor/cli/dist/commands/_lib/chrome-for-testing.js +226 -0
- package/vendor/cli/dist/commands/_lib/device-credential.d.ts +34 -0
- package/vendor/cli/dist/commands/_lib/device-credential.js +157 -0
- package/vendor/cli/dist/commands/_lib/device-wizard.d.ts +17 -0
- package/vendor/cli/dist/commands/_lib/device-wizard.js +11 -2
- package/vendor/cli/dist/commands/_lib/native-messaging.d.ts +7 -0
- package/vendor/cli/dist/commands/_lib/native-messaging.js +40 -0
- package/vendor/cli/dist/commands/browser.d.ts +23 -0
- package/vendor/cli/dist/commands/browser.js +492 -0
- package/vendor/cli/dist/commands/call.d.ts +12 -0
- package/vendor/cli/dist/commands/call.js +48 -26
- package/vendor/cli/dist/commands/context.d.ts +3 -1
- package/vendor/cli/dist/commands/context.js +13 -2
- package/vendor/cli/dist/commands/daemon.js +2 -152
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +4 -1
- package/vendor/cli/dist/commands/memory/_lib/errors.js +9 -1
- package/vendor/cli/dist/commands/memory/_lib/mcp.d.ts +0 -9
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +1 -23
- package/vendor/cli/dist/commands/memory/_lib/memory-auth.d.ts +20 -4
- package/vendor/cli/dist/commands/memory/_lib/memory-auth.js +21 -17
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -17
- package/vendor/cli/dist/commands/memory/run.js +4 -25
- package/vendor/cli/dist/connectors/google_gmail.ts +70 -41
- package/vendor/cli/dist/connectors/google_gmail_references.ts +406 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin.ts +1 -1
- package/vendor/cli/dist/connectors/postgres.ts +5 -3
- package/vendor/cli/dist/connectors/reddit.ts +171 -5
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/vendor/cli/dist/connectors/whatsapp_web.ts +48 -17
- package/vendor/cli/dist/connectors/x-dm-adapter.js +252 -35
- package/vendor/cli/dist/connectors/x.ts +189 -13
- package/vendor/cli/dist/index.js +46 -6
- package/vendor/cli/dist/internal/device-state.d.ts +2 -0
- package/vendor/cli/dist/internal/device-state.js +4 -0
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +3 -1
- package/vendor/cli/dist/templates/TESTING.md.tmpl +8 -8
- package/vendor/cli/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +9 -0
- package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +23 -2
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +14 -6
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +62 -25
- package/vendor/connector-worker/dist/agent-turn/media-tools.d.ts +1 -0
- package/vendor/connector-worker/dist/agent-turn/media-tools.js +5 -2
- package/vendor/connector-worker/dist/bin.js +2 -0
- package/vendor/connector-worker/dist/daemon/agent-turn.js +52 -17
- package/vendor/connector-worker/dist/daemon/automation.js +2 -12
- package/vendor/connector-worker/dist/daemon/client.d.ts +8 -2
- package/vendor/connector-worker/dist/daemon/client.js +8 -1
- package/vendor/connector-worker/dist/daemon/interactive-session.js +29 -6
- package/vendor/connector-worker/dist/daemon/poll-loop.js +23 -1
- package/vendor/connector-worker/dist/daemon/terminal-delivery.d.ts +5 -10
- package/vendor/connector-worker/dist/daemon/terminal-delivery.js +55 -23
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +2 -2
- package/vendor/connector-worker/dist/executor/isolate.js +3 -0
- package/vendor/connector-worker/package.json +1 -1
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +113 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +41 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +6 -1
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- /package/vendor/postgres/{.bun-tag-2f292c6554a8475e → .bun-tag-22d644c2873790db} +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Per-run heartbeat for browser-worker runs.
|
|
2
|
+
//
|
|
3
|
+
// The connector-worker daemon (packages/connector-worker/src/daemon/executor.ts
|
|
4
|
+
// in the lobu repo) heartbeats every 30s while a run is in flight so the
|
|
5
|
+
// gateway's stale-run reaper can safely write off runs whose worker
|
|
6
|
+
// crashed mid-flight. The Chrome service-worker run path needs the same
|
|
7
|
+
// signal — without it, when the user closes a tab, the laptop sleeps,
|
|
8
|
+
// or the extension is killed, the corresponding `runs` row sits in
|
|
9
|
+
// `claimed`/`running` forever.
|
|
10
|
+
//
|
|
11
|
+
// MV3 service workers are torn down between events, so a setInterval
|
|
12
|
+
// won't survive a SW sleep. chrome.alarms persists across SW restarts
|
|
13
|
+
// and re-fires when Chrome wakes the worker — exactly the lifecycle
|
|
14
|
+
// guarantee we need for a long-running tab-bound run.
|
|
15
|
+
//
|
|
16
|
+
// One alarm per in-flight run, named `${HEARTBEAT_ALARM_PREFIX}<runId>`.
|
|
17
|
+
// Callers wire `startHeartbeatAlarm(runId)` at run start and
|
|
18
|
+
// `stopHeartbeatAlarm(runId)` at run completion / error / tab close.
|
|
19
|
+
|
|
20
|
+
// Mirrors the daemon's 30s cadence. Chrome 120+ enforces 30s minimum;
|
|
21
|
+
// earlier versions clamp to a longer period. We pin
|
|
22
|
+
// `minimum_chrome_version: 120` in manifest.json so this cadence is
|
|
23
|
+
// honoured rather than silently extended.
|
|
24
|
+
export const HEARTBEAT_PERIOD_MINUTES = 0.5;
|
|
25
|
+
export const HEARTBEAT_ALARM_PREFIX = "owletto.heartbeat.";
|
|
26
|
+
|
|
27
|
+
// Tracks runs whose executor is live in THIS service-worker instance.
|
|
28
|
+
// MV3 alarms persist across SW restarts, so an alarm can wake the
|
|
29
|
+
// worker after a crash and try to heartbeat a run whose local executor
|
|
30
|
+
// is gone. Without this guard the heartbeat would keep the dead run
|
|
31
|
+
// "alive" forever in the gateway's eyes, defeating the stale-run reaper.
|
|
32
|
+
// On every tick the handler checks `isRunActive(runId)`; if the run is
|
|
33
|
+
// not in this set the alarm is cleared and no POST is sent, so the
|
|
34
|
+
// gateway reaper recovers the row normally.
|
|
35
|
+
const activeRunIds = new Set();
|
|
36
|
+
|
|
37
|
+
function markRunActive(runId) {
|
|
38
|
+
activeRunIds.add(runId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function markRunInactive(runId) {
|
|
42
|
+
activeRunIds.delete(runId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function isRunActive(runId) {
|
|
46
|
+
return activeRunIds.has(runId);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Test-only: reset the in-memory registry between cases.
|
|
50
|
+
export function __resetActiveRunsForTest() {
|
|
51
|
+
activeRunIds.clear();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function startHeartbeatAlarm(chromeApi, runId) {
|
|
55
|
+
markRunActive(runId);
|
|
56
|
+
chromeApi.alarms.create(`${HEARTBEAT_ALARM_PREFIX}${runId}`, {
|
|
57
|
+
periodInMinutes: HEARTBEAT_PERIOD_MINUTES,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function stopHeartbeatAlarm(chromeApi, runId) {
|
|
62
|
+
// Mark inactive synchronously first so any in-flight heartbeat tick
|
|
63
|
+
// that observes the registry after this point becomes a no-op even
|
|
64
|
+
// before chrome.alarms.clear() resolves. This closes the race where
|
|
65
|
+
// the alarm has already fired but sendHeartbeat hasn't yet checked
|
|
66
|
+
// `isRunActive`.
|
|
67
|
+
markRunInactive(runId);
|
|
68
|
+
try {
|
|
69
|
+
await chromeApi.alarms.clear(`${HEARTBEAT_ALARM_PREFIX}${runId}`);
|
|
70
|
+
} catch {
|
|
71
|
+
// chrome.alarms.clear can reject if the alarm doesn't exist; the
|
|
72
|
+
// result is the same as success for our purposes.
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isHeartbeatAlarm(alarmName) {
|
|
77
|
+
return typeof alarmName === "string" && alarmName.startsWith(HEARTBEAT_ALARM_PREFIX);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function runIdFromAlarmName(alarmName) {
|
|
81
|
+
if (!isHeartbeatAlarm(alarmName)) return null;
|
|
82
|
+
const n = Number(alarmName.slice(HEARTBEAT_ALARM_PREFIX.length));
|
|
83
|
+
return Number.isFinite(n) ? n : null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// POST /api/workers/heartbeat for `runId`. The handler ignores the
|
|
87
|
+
// returned value; callers can `await` it just to see the network error
|
|
88
|
+
// surface. Guards:
|
|
89
|
+
//
|
|
90
|
+
// - If the run is not in the active registry, the alarm is cleared
|
|
91
|
+
// and no POST is sent. This covers two cases: (a) the SW was torn
|
|
92
|
+
// down and woke later — the executor isn't running here anymore,
|
|
93
|
+
// so let the gateway reaper recover the row; (b) the alarm tick
|
|
94
|
+
// fires between safeComplete's `markRunInactive` and the actual
|
|
95
|
+
// `chrome.alarms.clear` resolving — the registry check makes the
|
|
96
|
+
// tick a no-op so we never POST after completion.
|
|
97
|
+
// - On 4xx the alarm is stopped and the run is dropped from the
|
|
98
|
+
// registry (the run is already terminal server-side or the worker
|
|
99
|
+
// was unpaired); on 5xx we throw so the onAlarm listener logs it
|
|
100
|
+
// and the next 30s tick retries.
|
|
101
|
+
export async function sendHeartbeat(chromeApi, runId, {
|
|
102
|
+
gatewayUrl,
|
|
103
|
+
workerId,
|
|
104
|
+
token,
|
|
105
|
+
fetchImpl = fetch,
|
|
106
|
+
}) {
|
|
107
|
+
if (!isRunActive(runId)) {
|
|
108
|
+
await stopHeartbeatAlarm(chromeApi, runId);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!gatewayUrl || !workerId || !token) {
|
|
112
|
+
await stopHeartbeatAlarm(chromeApi, runId);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Yield once before the fetch so a `stopHeartbeatAlarm` queued
|
|
116
|
+
// synchronously by safeComplete on the same tick observably sets
|
|
117
|
+
// `isRunActive(runId) = false` first. Without this, a heartbeat that
|
|
118
|
+
// entered sendHeartbeat in the same microtask as completion would
|
|
119
|
+
// still race ahead of the stop and POST after the run was marked
|
|
120
|
+
// complete. With it, the second `isRunActive` check below catches
|
|
121
|
+
// that race.
|
|
122
|
+
await Promise.resolve();
|
|
123
|
+
if (!isRunActive(runId)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const res = await fetchImpl(`${gatewayUrl}/api/workers/heartbeat`, {
|
|
127
|
+
method: "POST",
|
|
128
|
+
headers: {
|
|
129
|
+
"content-type": "application/json",
|
|
130
|
+
authorization: `Bearer ${token}`,
|
|
131
|
+
},
|
|
132
|
+
body: JSON.stringify({ run_id: runId, worker_id: workerId }),
|
|
133
|
+
});
|
|
134
|
+
if (!res.ok) {
|
|
135
|
+
if (res.status >= 400 && res.status < 500) {
|
|
136
|
+
await stopHeartbeatAlarm(chromeApi, runId);
|
|
137
|
+
}
|
|
138
|
+
throw new Error(`heartbeat → ${res.status}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Lobu owns the Lens UI and renders its real React attention surface into the
|
|
2
|
+
// Document PiP window. This content script is deliberately only a bridge:
|
|
3
|
+
// Chrome supplies active-page context and focuses/opens browser targets.
|
|
4
|
+
|
|
5
|
+
const LENS_CONTEXT_EVENT = "owletto:lobu-lens-context";
|
|
6
|
+
const LENS_OPEN_TARGET_EVENT = "owletto:lobu-lens-open-target";
|
|
7
|
+
const LENS_OPEN_TARGET_RESPONSE_EVENT =
|
|
8
|
+
"owletto:lobu-lens-open-target-response";
|
|
9
|
+
|
|
10
|
+
function runtimeMessage(message) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
chrome.runtime.sendMessage(message, (response) => {
|
|
13
|
+
const runtimeError = chrome.runtime.lastError;
|
|
14
|
+
if (runtimeError) {
|
|
15
|
+
reject(new Error(runtimeError.message));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
resolve(response);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function bridge(message) {
|
|
24
|
+
const response = await runtimeMessage(message);
|
|
25
|
+
if (!response?.ok) {
|
|
26
|
+
throw new Error(response?.error || "Owletto Lens bridge failed.");
|
|
27
|
+
}
|
|
28
|
+
return response.value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseDetail(event) {
|
|
32
|
+
if (!(event instanceof CustomEvent) || typeof event.detail !== "string") {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(event.detail);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function dispatchPageEvent(name, detail) {
|
|
43
|
+
document.dispatchEvent(
|
|
44
|
+
new CustomEvent(name, { detail: JSON.stringify(detail) }),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function refreshDebuggerState() {
|
|
49
|
+
const attached = Boolean(await bridge({ op: "lens-debugger-attached" }));
|
|
50
|
+
document.documentElement.dataset.owlettoDebuggerAttached = String(attached);
|
|
51
|
+
return attached;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function publishContext(context) {
|
|
55
|
+
if (context) dispatchPageEvent(LENS_CONTEXT_EVENT, context);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void (async () => {
|
|
59
|
+
document.documentElement.setAttribute("data-owletto-lens-bridge", "");
|
|
60
|
+
void refreshDebuggerState().catch(() => {});
|
|
61
|
+
|
|
62
|
+
document.addEventListener(
|
|
63
|
+
"pointerenter",
|
|
64
|
+
(event) => {
|
|
65
|
+
if (event.target?.closest?.("[data-lobu-lens-open]")) {
|
|
66
|
+
void refreshDebuggerState().catch(() => {});
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
true,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
document.addEventListener("owletto:lobu-lens-context-request", () => {
|
|
73
|
+
void bridge({ op: "lens-context-get" })
|
|
74
|
+
.then(publishContext)
|
|
75
|
+
.catch(() => {});
|
|
76
|
+
});
|
|
77
|
+
document.addEventListener(LENS_OPEN_TARGET_EVENT, (event) => {
|
|
78
|
+
const request = parseDetail(event);
|
|
79
|
+
if (!request?.id) return;
|
|
80
|
+
if (typeof request.url !== "string" && request.focusHost !== true) return;
|
|
81
|
+
const operation = request.focusHost
|
|
82
|
+
? { op: "lens-focus-host" }
|
|
83
|
+
: { op: "lens-open-target", url: request.url };
|
|
84
|
+
void bridge(operation)
|
|
85
|
+
.then(() =>
|
|
86
|
+
dispatchPageEvent(LENS_OPEN_TARGET_RESPONSE_EVENT, {
|
|
87
|
+
id: request.id,
|
|
88
|
+
ok: true,
|
|
89
|
+
}),
|
|
90
|
+
)
|
|
91
|
+
.catch((error) =>
|
|
92
|
+
dispatchPageEvent(LENS_OPEN_TARGET_RESPONSE_EVENT, {
|
|
93
|
+
id: request.id,
|
|
94
|
+
ok: false,
|
|
95
|
+
error: error instanceof Error ? error.message : String(error),
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
chrome.runtime.onMessage.addListener((message) => {
|
|
101
|
+
if (message?.op === "lens-context-changed") {
|
|
102
|
+
publishContext(message.context);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
publishContext(await bridge({ op: "lens-context-get" }).catch(() => null));
|
|
109
|
+
})();
|
|
110
|
+
|
|
111
|
+
// Versioned, read-only onboarding bridge. The service worker validates the
|
|
112
|
+
// sender origin before touching storage; the page never receives credentials.
|
|
113
|
+
document.addEventListener("lobu:extension-setup-request", (event) => {
|
|
114
|
+
const request = parseDetail(event);
|
|
115
|
+
if (
|
|
116
|
+
request?.protocolVersion !== 1 ||
|
|
117
|
+
typeof request.id !== "string" ||
|
|
118
|
+
!/^[a-zA-Z0-9-]{1,80}$/.test(request.id)
|
|
119
|
+
)
|
|
120
|
+
return;
|
|
121
|
+
void bridge({ op: "setup-status-get", protocolVersion: 1 })
|
|
122
|
+
.then((value) =>
|
|
123
|
+
dispatchPageEvent("lobu:extension-setup-response", {
|
|
124
|
+
id: request.id,
|
|
125
|
+
ok: true,
|
|
126
|
+
value,
|
|
127
|
+
}),
|
|
128
|
+
)
|
|
129
|
+
.catch(() =>
|
|
130
|
+
dispatchPageEvent("lobu:extension-setup-response", {
|
|
131
|
+
id: request.id,
|
|
132
|
+
ok: false,
|
|
133
|
+
}),
|
|
134
|
+
);
|
|
135
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function normalizeLensTarget(value) {
|
|
2
|
+
try {
|
|
3
|
+
const url = new URL(value);
|
|
4
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
5
|
+
const pathname = url.pathname.replace(/\/+$/, "") || "/";
|
|
6
|
+
return `${url.origin}${pathname}${url.search}`;
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function findExistingLensTab(tabs, value) {
|
|
13
|
+
const target = normalizeLensTarget(value);
|
|
14
|
+
if (!target) return null;
|
|
15
|
+
return (
|
|
16
|
+
(Array.isArray(tabs) ? tabs : []).find(
|
|
17
|
+
(tab) => normalizeLensTarget(tab?.url) === target,
|
|
18
|
+
) ?? null
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "Lobu",
|
|
4
|
+
"short_name": "Lobu",
|
|
5
|
+
"description": "Connect this Chrome profile to your Lobu agent.",
|
|
6
|
+
"version": "0.9.9",
|
|
7
|
+
"minimum_chrome_version": "120",
|
|
8
|
+
"incognito": "not_allowed",
|
|
9
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt7XWpX2zQlMV7aFunbz8p5DTSv+8MvCw2PSfSV56tEF4j2bsb3mKlBMBKNCxJNV+5D4l/9MgY7fEA5LmQ4pUHV+LoboQGTH8iR7wPKpnQ7U9NW7I4FL/rDlAFB2/rcgJex7/jkDNHIF4C7A0DUuDNj2Mij15Cg5pyA3Ek8Fw5B/Qfl8OvcJtcNtSpcbvGGM/uS23BW8iIlF1aFTrLuiI9NlASfbbAY0Xozb/snt0HQOl4flOIr3LF/xRFHeo/Ko+mAdGeOlBblk4T0lYlDTVsoBJsjTyYh9hn7NEOm8a5yV60z2p/wrRlEAcwp+CoO+AHweGxw5NMZbSpC6pKTKqYQIDAQAB",
|
|
10
|
+
"permissions": [
|
|
11
|
+
"tabs",
|
|
12
|
+
"tabGroups",
|
|
13
|
+
"scripting",
|
|
14
|
+
"activeTab",
|
|
15
|
+
"debugger",
|
|
16
|
+
"storage",
|
|
17
|
+
"sidePanel",
|
|
18
|
+
"alarms",
|
|
19
|
+
"nativeMessaging",
|
|
20
|
+
"notifications"
|
|
21
|
+
],
|
|
22
|
+
"optional_permissions": [
|
|
23
|
+
"history",
|
|
24
|
+
"bookmarks",
|
|
25
|
+
"downloads"
|
|
26
|
+
],
|
|
27
|
+
"optional_host_permissions": [],
|
|
28
|
+
"content_scripts": [
|
|
29
|
+
{
|
|
30
|
+
"matches": [
|
|
31
|
+
"https://lobu.ai/*",
|
|
32
|
+
"https://*.lobu.ai/*"
|
|
33
|
+
],
|
|
34
|
+
"js": [
|
|
35
|
+
"lens-page.js"
|
|
36
|
+
],
|
|
37
|
+
"run_at": "document_idle"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"web_accessible_resources": [
|
|
41
|
+
{
|
|
42
|
+
"resources": [
|
|
43
|
+
"accessibility-tree.js",
|
|
44
|
+
"watch-observer.js"
|
|
45
|
+
],
|
|
46
|
+
"matches": [
|
|
47
|
+
"<all_urls>"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"icons": {
|
|
52
|
+
"16": "icons/icon-16.png",
|
|
53
|
+
"32": "icons/icon-32.png",
|
|
54
|
+
"48": "icons/icon-48.png",
|
|
55
|
+
"128": "icons/icon-128.png"
|
|
56
|
+
},
|
|
57
|
+
"background": {
|
|
58
|
+
"service_worker": "background.js",
|
|
59
|
+
"type": "module"
|
|
60
|
+
},
|
|
61
|
+
"side_panel": {
|
|
62
|
+
"default_path": "sidepanel.html"
|
|
63
|
+
},
|
|
64
|
+
"action": {
|
|
65
|
+
"default_title": "Lobu",
|
|
66
|
+
"default_icon": {
|
|
67
|
+
"16": "icons/icon-16.png",
|
|
68
|
+
"32": "icons/icon-32.png",
|
|
69
|
+
"48": "icons/icon-48.png",
|
|
70
|
+
"128": "icons/icon-128.png"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"host_permissions": [
|
|
74
|
+
"<all_urls>"
|
|
75
|
+
]
|
|
76
|
+
}
|