Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/background/agent-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ export async function runTask(task: AgentTask, deps: AgentDeps): Promise<AgentTa
* a blocking page left the tab stranded — the largest fixable cluster in the benchmark. Steering
* back to the last page that worked costs one navigation and keeps the run alive.
*/
export async function takeSnapshotOrRecover(tabId: number, recoveryUrl: string | undefined): Promise<A11ySnapshot> {
async function takeSnapshotOrRecover(tabId: number, recoveryUrl: string | undefined): Promise<A11ySnapshot> {
try {
return await takeSnapshot(tabId);
} catch (err) {
Expand Down Expand Up @@ -2225,7 +2225,7 @@ function serializeOrchestration(plan: OrchestrationPlan): AgentOrchestrationStat
* deterministic summary when the model is unreachable — a provider outage is
* one of the reasons a user hits stop, so this must not depend on one.
*/
export async function summarizeInterruptedWork(
async function summarizeInterruptedWork(
task: AgentTask,
settings: Settings,
model: string,
Expand Down
4 changes: 2 additions & 2 deletions core/src/background/bridge-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ToolCall } from '@/lib/types';
const STORE_KEY = 'bridgeCollections';
const MAX_STORED = 20;
/** Well inside the 30 s every bridge path allows, leaving room for one slow last step. */
export const FOLLOW_BUDGET_MS = 12_000;
const FOLLOW_BUDGET_MS = 12_000;

type Mode = 'rows' | 'chunk';
interface Stored { collection: Collection; mode: Mode; tabId: number; selector?: string; updatedAt: number }
Expand All @@ -23,7 +23,7 @@ export interface CollectDeps {
newId?: () => string;
}

export type StopReason = 'complete' | 'deadline' | 'stalled' | 'no_more_pages' | 'single_capture' | 'error';
type StopReason = 'complete' | 'deadline' | 'stalled' | 'no_more_pages' | 'single_capture' | 'error';

async function loadStore(): Promise<Store> {
const raw = (await chrome.storage.session.get(STORE_KEY))[STORE_KEY];
Expand Down
2 changes: 1 addition & 1 deletion core/src/background/cdp-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ function sleep(ms: number): Promise<void> {
/**
* Applies stealth evasions to prevent automated browser detection (navigator.webdriver, plugins, permissions).
*/
export async function applyStealthPatches(target: Debuggee): Promise<void> {
async function applyStealthPatches(target: Debuggee): Promise<void> {
const stealthScript = `
try {
Object.defineProperty(navigator, 'webdriver', {
Expand Down
2 changes: 1 addition & 1 deletion core/src/background/fsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type AgentState =
| 'COMPLETED'
| 'FAILED';

export interface StateTransitionEvent {
interface StateTransitionEvent {
from: AgentState;
to: AgentState;
taskId: string;
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ function cssPath(el: HTMLElement): string {
return `${tag}:nth-of-type(${siblings.indexOf(el) + 1})`;
}

export function waitForSettledDom(maxWaitMs = 1200, quietMs = 100): Promise<void> {
function waitForSettledDom(maxWaitMs = 1200, quietMs = 100): Promise<void> {
return new Promise((resolve) => {
let timer: number | null = null;
let maxTimeout: number | null = null;
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/attachment-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import type { TaskAttachment } from './types';

export const ATTACHMENT_FOLDER = 'weboperator-attachments';
export const MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
const ATTACHMENT_FOLDER = 'weboperator-attachments';
const MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;

function slugify(name: string): string {
return name
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/batch-actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { frameIdFromRef } from './frames';
import type { A11ySnapshot, ToolCall } from './types';

export const BATCH_MIN_ACTIONS = 2;
export const BATCH_MAX_ACTIONS = 5;
const BATCH_MIN_ACTIONS = 2;
const BATCH_MAX_ACTIONS = 5;

const BATCHABLE_NAMES = new Set<ToolCall['name']>(['click', 'type', 'press', 'select']);
const SAFE_CLICK_ROLES = new Set(['button', 'checkbox', 'radio', 'switch', 'tab']);
Expand Down
8 changes: 4 additions & 4 deletions core/src/lib/captcha-solver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export interface CaptchaDetection {
inputRef?: string;
}

export interface CaptchaHandoffPreparation {
interface CaptchaHandoffPreparation {
prepared: boolean;
message: string;
}

export type LLMCaptchaCaller = (prompt: string, imagesBase64?: string[]) => Promise<string>;
type LLMCaptchaCaller = (prompt: string, imagesBase64?: string[]) => Promise<string>;

export interface CaptchaSolverOptions {
settings?: Settings;
Expand Down Expand Up @@ -1258,7 +1258,7 @@ export async function detectPageCaptcha(tabId: number): Promise<CaptchaDetection
/**
* Makes an interactive challenge easy to reach during a human handoff.
*/
export async function prepareCaptchaHandoff(
async function prepareCaptchaHandoff(
tabId: number,
type: CaptchaDetection['type']
): Promise<CaptchaHandoffPreparation> {
Expand Down Expand Up @@ -1714,7 +1714,7 @@ Return ONLY the raw code string without spaces, quotes, markdown formatting, or
/**
* Transcribes an audio challenge buffer or base64 data using OpenAI Whisper API or local fallback.
*/
export async function transcribeCaptchaAudio(
async function transcribeCaptchaAudio(
base64Audio: string,
mimeType = 'audio/mp3',
options?: CaptchaSolverOptions
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/context-compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { A11ySnapshot, Settings } from './types';
// How many of the most recent page snapshots stay in the history at full size.
// Older observations are collapsed to a one-line summary (the action taken on them
// is preserved in the assistant tool-call message that follows each observation).
export const OBSERVATION_WINDOW = 2;
const OBSERVATION_WINDOW = 2;

// How many of the most recent whole steps are kept verbatim when the history is
// folded for budget. Cutting at a step boundary keeps assistant/tool pairs intact.
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/findings-ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const MAX_FINDING_CHARS = 2400;
const MAX_FINDINGS = 80;

/** Share of the model's context budget the ledger may occupy. */
export const LEDGER_BUDGET_RATIO = 0.15;
const LEDGER_BUDGET_RATIO = 0.15;

/** Absolute ceiling, so a large cloud budget does not turn every observation into a data dump. */
const LEDGER_MAX_CHARS = 6000;
Expand Down
6 changes: 3 additions & 3 deletions core/src/lib/hf-classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function cosineSimilarity(a: number[], b: number[]): number {
/**
* Lazily loads the Hugging Face Transformers feature extraction pipeline.
*/
export async function getHFPipeline(): Promise<unknown> {
async function getHFPipeline(): Promise<unknown> {

if (embeddingPipeline) return embeddingPipeline;
if (isInitializing) {
Expand All @@ -80,7 +80,7 @@ export async function getHFPipeline(): Promise<unknown> {
/**
* Generates normalized embedding vector for a given text.
*/
export async function getEmbedding(text: string): Promise<number[]> {
async function getEmbedding(text: string): Promise<number[]> {
const extractor = (await getHFPipeline()) as (t: string, opts: unknown) => Promise<{ data: Float32Array }>;
const output = await extractor(text, { pooling: 'mean', normalize: true });
return Array.from(output.data);
Expand All @@ -90,7 +90,7 @@ export async function getEmbedding(text: string): Promise<number[]> {
/**
* Pre-warms neural embeddings for all built-in skills.
*/
export async function precomputeSkillEmbeddings(): Promise<void> {
async function precomputeSkillEmbeddings(): Promise<void> {
for (const skill of BUILT_IN_SKILLS) {
if (skill.risk === 'high') continue;
if (!skillEmbeddingCache.has(skill.id)) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/image-read.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { findElementByRef } from '@/lib/a11y';

/** An image read from the page: its bytes as base64, what it is, and where it came from. */
export interface PageImage {
interface PageImage {
src: string;
mimeType: string;
base64: string;
Expand Down
10 changes: 5 additions & 5 deletions core/src/lib/memory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ToolCall } from './types';

// ── Memory types ─────────────────────────────────────────────────────
export interface SiteMemory {
interface SiteMemory {
urlPattern: string;
lastVisited: number;
hits: number;
Expand All @@ -12,7 +12,7 @@ export interface SiteMemory {
successTips: string[]; // what works well
}

export interface AgentMemory {
interface AgentMemory {
version: 1;
sites: Record<string, SiteMemory>; // url pattern → site memory
recentWins: string[]; // last 5 successful task summaries
Expand All @@ -34,7 +34,7 @@ function emptyMemory(): AgentMemory {
}

// ── URL pattern extraction ───────────────────────────────────────────
export function siteKey(url: string): string {
function siteKey(url: string): string {
try {
const u = new URL(url);
return u.hostname.replace(/^www\./, '');
Expand All @@ -46,7 +46,7 @@ export function siteKey(url: string): string {
// ── Load / Save ──────────────────────────────────────────────────────
const STORAGE_KEY = 'agent_memory';

export async function loadMemory(): Promise<AgentMemory> {
async function loadMemory(): Promise<AgentMemory> {
try {
const raw = await chrome.storage.local.get(STORAGE_KEY) as Record<string, unknown>;
// Storage returns an untyped bag; the guard below is what actually
Expand All @@ -57,7 +57,7 @@ export async function loadMemory(): Promise<AgentMemory> {
return emptyMemory();
}

export async function saveMemory(mem: AgentMemory): Promise<void> {
async function saveMemory(mem: AgentMemory): Promise<void> {
mem.updatedAt = Date.now();
await chrome.storage.local.set({ [STORAGE_KEY]: mem });
}
Expand Down
10 changes: 0 additions & 10 deletions core/src/lib/orchestrator-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,3 @@ export type OrchestratorEvent =
| { kind: 'orchestrator:done'; taskId: string; success: boolean; summary: string }
| { kind: 'orchestrator:checkpoint:saved'; taskId: string; subtaskId: string }
| { kind: 'orchestrator:checkpoint:restored'; taskId: string };

export const DEFAULT_ORCHESTRATOR_CONFIG = {
maxSubtasks: 20,
maxParallelTabs: 3,
subtaskTimeoutMs: 120_000,
checkpointIntervalMs: 30_000,
maxCheckpointAgeDays: 7,
} as const;

export type OrchestratorConfig = typeof DEFAULT_ORCHESTRATOR_CONFIG;
2 changes: 1 addition & 1 deletion core/src/lib/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export function mirrorPlanProgress(plan: AgentPlan, orch: OrchestrationPlan): vo
orch.updatedAt = Date.now();
}

export function buildOrchestrationPlan(
function buildOrchestrationPlan(
taskId: string,
goal: string,
decomposition: DecompositionResult,
Expand Down
5 changes: 0 additions & 5 deletions core/src/lib/planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,3 @@ export function planContext(plan: AgentPlan): string {
return lines.join('\n');
}

export function planSummary(plan: AgentPlan): string {
const done = plan.steps.filter((s) => s.status === 'done').length;
const failed = plan.steps.filter((s) => s.status === 'failed').length;
return `${done}/${plan.steps.length} steps done${failed > 0 ? ` (${failed} failed)` : ''}`;
}
2 changes: 1 addition & 1 deletion core/src/lib/port-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type PortInboundMessage =
| { kind: 'session:attach'; tabId?: number }
| { kind: 'sw:message'; message: SWMessage };

export type PortOutboundMessage =
type PortOutboundMessage =
| { type: 'pong'; timestamp: number }
| { type: 'sw:event'; event: SWEvent }
| { type: 'sw:response'; correlationId?: string; result?: unknown; error?: string };
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { enabledSkillPrompts } from './skills';
import type { Settings } from './types';

export const SYSTEM_PROMPT = `Browser agent. You see a11y snapshots (@eN refs). Reply with exactly one of the tools supplied for the current step. No other text. Never answer with a raw final JSON object such as {"success":true,...}; when the task is finished, call done(success,summary).
const SYSTEM_PROMPT = `Browser agent. You see a11y snapshots (@eN refs). Reply with exactly one of the tools supplied for the current step. No other text. Never answer with a raw final JSON object such as {"success":true,...}; when the task is finished, call done(success,summary).



Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/semantic-memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { urlPattern } from './action-cache';
import type { A11ySnapshot, RecoveryMemory, SitePattern, ToolCall } from './types';
import { parseBatchActions } from './batch-actions';

export async function getSitePattern(snapshot: A11ySnapshot): Promise<SitePattern | undefined> {
async function getSitePattern(snapshot: A11ySnapshot): Promise<SitePattern | undefined> {
const pat = urlPattern(snapshot.url);
return db.sitePatterns.get(pat);
}
Expand Down
10 changes: 0 additions & 10 deletions core/src/lib/session-memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

import { listTasks, loadSteps } from './storage';

export interface SessionTurnSummary {
taskId: string;
goal: string;
answer: string | null;
status: 'done' | 'failed';
lastUrl?: string;
extractedSnippet?: string;
timestamp: number;
}

export async function getRecentSessionContext(
tabId: number,
currentUrl?: string,
Expand Down
5 changes: 1 addition & 4 deletions core/src/lib/skills.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type { CustomSkillDefinition, SkillId } from './types';


export type SkillRisk = 'safe' | 'medium' | 'high';
import type { CustomSkillDefinition, SkillId, SkillRisk } from './types';

export interface SkillDefinition {
id: SkillId;
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/tool-call-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function safeJsonAny(value: string): unknown {
}
}

export function stripCodeFence(content: string): string {
function stripCodeFence(content: string): string {
const match = content.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);
return match ? match[1].trim() : content;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/tool-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { ToolCall } from './types';
import { validateBatchCall } from './batch-actions';

export type ToolRiskLevel = 'safe' | 'low' | 'high';
type ToolRiskLevel = 'safe' | 'low' | 'high';

export interface ToolValidationResult {
valid: boolean;
Expand Down
12 changes: 6 additions & 6 deletions core/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export interface CredentialSummary {
updatedAt: number;
}

export type StepStatus = 'pending' | 'running' | 'ok' | 'fail' | 'skipped';
type StepStatus = 'pending' | 'running' | 'ok' | 'fail' | 'skipped';

export interface StepTimings {
snapshotMs?: number;
Expand Down Expand Up @@ -310,7 +310,7 @@ export const PROFILE_LATENCY_MULT: Record<ModelProfile, number> = {

// `stopped` is the user pressing stop, and is deliberately not `failed`: the
// run was cut short on purpose, its evidence is intact, and it can be resumed.
export type TaskStatus = 'idle' | 'planning' | 'running' | 'paused' | 'done' | 'failed' | 'stopped' | 'awaiting_confirm';
type TaskStatus = 'idle' | 'planning' | 'running' | 'paused' | 'done' | 'failed' | 'stopped' | 'awaiting_confirm';

/**
* Why a task is sitting in `paused`. `bot_challenge` means the page put up a
Expand All @@ -319,7 +319,7 @@ export type TaskStatus = 'idle' | 'planning' | 'running' | 'paused' | 'done' | '
* manual Resume control remains available. The agent does not attempt to
* defeat the challenge itself.
*/
export interface TaskPauseReason {
interface TaskPauseReason {
kind: 'bot_challenge';
challengeType?: 'cloudflare' | 'recaptcha' | 'hcaptcha' | 'image' | 'slider' | 'audio' | 'press_and_hold' | 'pow' | 'unknown';
url: string;
Expand Down Expand Up @@ -352,7 +352,7 @@ export interface AgentTask {
}

export type ScheduleRepeat = 'once' | 'hourly' | 'daily' | 'weekly';
export type ScheduledTaskStatus = 'enabled' | 'paused' | 'running' | 'last_success' | 'last_failed' | 'needs_user';
type ScheduledTaskStatus = 'enabled' | 'paused' | 'running' | 'last_success' | 'last_failed' | 'needs_user';

export interface ScheduledTask {
id: string;
Expand Down Expand Up @@ -454,7 +454,7 @@ export interface AgentPlan {
createdAt: number;
}

export interface AgentOrchestrationSubtask {
interface AgentOrchestrationSubtask {
id: string;
index: number;
description: string;
Expand All @@ -475,7 +475,7 @@ export interface AgentOrchestrationState {
}

// ── Verifier types ──
export type VerifyStatus = 'success' | 'partial' | 'failed' | 'uncertain';
type VerifyStatus = 'success' | 'partial' | 'failed' | 'uncertain';
export type RetryStrategy =
| 'none'
| 'retry_same'
Expand Down
2 changes: 1 addition & 1 deletion core/src/sidepanel/components/ConfirmBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function ConfirmBox({ task, onDecide }: { task: AgentTask; onDecide: (all
);
}

export function describeToolCall(call: AgentStep['toolCall'] | undefined): string {
function describeToolCall(call: AgentStep['toolCall'] | undefined): string {
if (!call) return 'The agent is waiting for your approval to continue.';
const args = (call.arguments ?? {}) as Record<string, unknown>;
const reason = typeof args.reason === 'string' ? args.reason : '';
Expand Down
Loading
Loading