diff --git a/core/src/background/agent-loop.ts b/core/src/background/agent-loop.ts index 91b4df7..495d1d9 100644 --- a/core/src/background/agent-loop.ts +++ b/core/src/background/agent-loop.ts @@ -1906,7 +1906,7 @@ export async function runTask(task: AgentTask, deps: AgentDeps): Promise { +async function takeSnapshotOrRecover(tabId: number, recoveryUrl: string | undefined): Promise { try { return await takeSnapshot(tabId); } catch (err) { @@ -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, diff --git a/core/src/background/bridge-collection.ts b/core/src/background/bridge-collection.ts index 0192941..da81790 100644 --- a/core/src/background/bridge-collection.ts +++ b/core/src/background/bridge-collection.ts @@ -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 } @@ -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 { const raw = (await chrome.storage.session.get(STORE_KEY))[STORE_KEY]; diff --git a/core/src/background/cdp-actions.ts b/core/src/background/cdp-actions.ts index fda0583..87bb94c 100644 --- a/core/src/background/cdp-actions.ts +++ b/core/src/background/cdp-actions.ts @@ -778,7 +778,7 @@ function sleep(ms: number): Promise { /** * Applies stealth evasions to prevent automated browser detection (navigator.webdriver, plugins, permissions). */ -export async function applyStealthPatches(target: Debuggee): Promise { +async function applyStealthPatches(target: Debuggee): Promise { const stealthScript = ` try { Object.defineProperty(navigator, 'webdriver', { diff --git a/core/src/background/fsm.ts b/core/src/background/fsm.ts index f22740a..2425d37 100644 --- a/core/src/background/fsm.ts +++ b/core/src/background/fsm.ts @@ -14,7 +14,7 @@ export type AgentState = | 'COMPLETED' | 'FAILED'; -export interface StateTransitionEvent { +interface StateTransitionEvent { from: AgentState; to: AgentState; taskId: string; diff --git a/core/src/lib/actions.ts b/core/src/lib/actions.ts index 13db7dd..88984ff 100644 --- a/core/src/lib/actions.ts +++ b/core/src/lib/actions.ts @@ -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 { +function waitForSettledDom(maxWaitMs = 1200, quietMs = 100): Promise { return new Promise((resolve) => { let timer: number | null = null; let maxTimeout: number | null = null; diff --git a/core/src/lib/attachment-staging.ts b/core/src/lib/attachment-staging.ts index 8574402..27d75e9 100644 --- a/core/src/lib/attachment-staging.ts +++ b/core/src/lib/attachment-staging.ts @@ -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 diff --git a/core/src/lib/batch-actions.ts b/core/src/lib/batch-actions.ts index cddf15a..9aa805b 100644 --- a/core/src/lib/batch-actions.ts +++ b/core/src/lib/batch-actions.ts @@ -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(['click', 'type', 'press', 'select']); const SAFE_CLICK_ROLES = new Set(['button', 'checkbox', 'radio', 'switch', 'tab']); diff --git a/core/src/lib/captcha-solver.ts b/core/src/lib/captcha-solver.ts index cd52884..75129c5 100644 --- a/core/src/lib/captcha-solver.ts +++ b/core/src/lib/captcha-solver.ts @@ -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; +type LLMCaptchaCaller = (prompt: string, imagesBase64?: string[]) => Promise; export interface CaptchaSolverOptions { settings?: Settings; @@ -1258,7 +1258,7 @@ export async function detectPageCaptcha(tabId: number): Promise { @@ -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 diff --git a/core/src/lib/context-compression.ts b/core/src/lib/context-compression.ts index deb0964..9368307 100644 --- a/core/src/lib/context-compression.ts +++ b/core/src/lib/context-compression.ts @@ -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. diff --git a/core/src/lib/findings-ledger.ts b/core/src/lib/findings-ledger.ts index 72343f8..9a16ee1 100644 --- a/core/src/lib/findings-ledger.ts +++ b/core/src/lib/findings-ledger.ts @@ -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; diff --git a/core/src/lib/hf-classifier.ts b/core/src/lib/hf-classifier.ts index fb25d87..37b522c 100644 --- a/core/src/lib/hf-classifier.ts +++ b/core/src/lib/hf-classifier.ts @@ -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 { +async function getHFPipeline(): Promise { if (embeddingPipeline) return embeddingPipeline; if (isInitializing) { @@ -80,7 +80,7 @@ export async function getHFPipeline(): Promise { /** * Generates normalized embedding vector for a given text. */ -export async function getEmbedding(text: string): Promise { +async function getEmbedding(text: string): Promise { 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); @@ -90,7 +90,7 @@ export async function getEmbedding(text: string): Promise { /** * Pre-warms neural embeddings for all built-in skills. */ -export async function precomputeSkillEmbeddings(): Promise { +async function precomputeSkillEmbeddings(): Promise { for (const skill of BUILT_IN_SKILLS) { if (skill.risk === 'high') continue; if (!skillEmbeddingCache.has(skill.id)) { diff --git a/core/src/lib/image-read.ts b/core/src/lib/image-read.ts index ed539b3..d720d79 100644 --- a/core/src/lib/image-read.ts +++ b/core/src/lib/image-read.ts @@ -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; diff --git a/core/src/lib/memory.ts b/core/src/lib/memory.ts index 5ea3400..e84d882 100644 --- a/core/src/lib/memory.ts +++ b/core/src/lib/memory.ts @@ -1,7 +1,7 @@ import type { ToolCall } from './types'; // ── Memory types ───────────────────────────────────────────────────── -export interface SiteMemory { +interface SiteMemory { urlPattern: string; lastVisited: number; hits: number; @@ -12,7 +12,7 @@ export interface SiteMemory { successTips: string[]; // what works well } -export interface AgentMemory { +interface AgentMemory { version: 1; sites: Record; // url pattern → site memory recentWins: string[]; // last 5 successful task summaries @@ -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\./, ''); @@ -46,7 +46,7 @@ export function siteKey(url: string): string { // ── Load / Save ────────────────────────────────────────────────────── const STORAGE_KEY = 'agent_memory'; -export async function loadMemory(): Promise { +async function loadMemory(): Promise { try { const raw = await chrome.storage.local.get(STORAGE_KEY) as Record; // Storage returns an untyped bag; the guard below is what actually @@ -57,7 +57,7 @@ export async function loadMemory(): Promise { return emptyMemory(); } -export async function saveMemory(mem: AgentMemory): Promise { +async function saveMemory(mem: AgentMemory): Promise { mem.updatedAt = Date.now(); await chrome.storage.local.set({ [STORAGE_KEY]: mem }); } diff --git a/core/src/lib/orchestrator-types.ts b/core/src/lib/orchestrator-types.ts index 33e290f..0ad3a38 100644 --- a/core/src/lib/orchestrator-types.ts +++ b/core/src/lib/orchestrator-types.ts @@ -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; diff --git a/core/src/lib/orchestrator.ts b/core/src/lib/orchestrator.ts index 07c960a..dc1e0f5 100644 --- a/core/src/lib/orchestrator.ts +++ b/core/src/lib/orchestrator.ts @@ -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, diff --git a/core/src/lib/planner.ts b/core/src/lib/planner.ts index c501859..e35f177 100644 --- a/core/src/lib/planner.ts +++ b/core/src/lib/planner.ts @@ -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)` : ''}`; -} diff --git a/core/src/lib/port-channel.ts b/core/src/lib/port-channel.ts index b26bb06..eb72557 100644 --- a/core/src/lib/port-channel.ts +++ b/core/src/lib/port-channel.ts @@ -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 }; diff --git a/core/src/lib/prompts.ts b/core/src/lib/prompts.ts index ed68969..d1521a2 100644 --- a/core/src/lib/prompts.ts +++ b/core/src/lib/prompts.ts @@ -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). diff --git a/core/src/lib/semantic-memory.ts b/core/src/lib/semantic-memory.ts index adc3585..4f405b3 100644 --- a/core/src/lib/semantic-memory.ts +++ b/core/src/lib/semantic-memory.ts @@ -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 { +async function getSitePattern(snapshot: A11ySnapshot): Promise { const pat = urlPattern(snapshot.url); return db.sitePatterns.get(pat); } diff --git a/core/src/lib/session-memory.ts b/core/src/lib/session-memory.ts index 864041e..58fd6a3 100644 --- a/core/src/lib/session-memory.ts +++ b/core/src/lib/session-memory.ts @@ -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, diff --git a/core/src/lib/skills.ts b/core/src/lib/skills.ts index 225bdd8..ca48d12 100644 --- a/core/src/lib/skills.ts +++ b/core/src/lib/skills.ts @@ -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; diff --git a/core/src/lib/tool-call-parse.ts b/core/src/lib/tool-call-parse.ts index 528ed9c..1722a44 100644 --- a/core/src/lib/tool-call-parse.ts +++ b/core/src/lib/tool-call-parse.ts @@ -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; } diff --git a/core/src/lib/tool-validator.ts b/core/src/lib/tool-validator.ts index 53a4b52..468b9e2 100644 --- a/core/src/lib/tool-validator.ts +++ b/core/src/lib/tool-validator.ts @@ -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; diff --git a/core/src/lib/types.ts b/core/src/lib/types.ts index 8f37546..554f1ed 100644 --- a/core/src/lib/types.ts +++ b/core/src/lib/types.ts @@ -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; @@ -310,7 +310,7 @@ export const PROFILE_LATENCY_MULT: Record = { // `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 @@ -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; @@ -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; @@ -454,7 +454,7 @@ export interface AgentPlan { createdAt: number; } -export interface AgentOrchestrationSubtask { +interface AgentOrchestrationSubtask { id: string; index: number; description: string; @@ -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' diff --git a/core/src/sidepanel/components/ConfirmBox.tsx b/core/src/sidepanel/components/ConfirmBox.tsx index 9247198..186d5cf 100644 --- a/core/src/sidepanel/components/ConfirmBox.tsx +++ b/core/src/sidepanel/components/ConfirmBox.tsx @@ -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; const reason = typeof args.reason === 'string' ? args.reason : ''; diff --git a/core/src/sidepanel/utils/markdown.ts b/core/src/sidepanel/utils/markdown.ts index 7f5b41a..a588dea 100644 --- a/core/src/sidepanel/utils/markdown.ts +++ b/core/src/sidepanel/utils/markdown.ts @@ -60,7 +60,7 @@ export function renderMarkdown(text: string): string { return html; } -export function renderMarkdownTables(markdown: string): string { +function renderMarkdownTables(markdown: string): string { const lines = markdown.split('\n'); const rendered: string[] = []; @@ -89,7 +89,7 @@ export function renderMarkdownTables(markdown: string): string { return rendered.join('\n'); } -export function renderMarkdownTable(headers: string[], rows: string[][]): string { +function renderMarkdownTable(headers: string[], rows: string[][]): string { const safeHeaders = normalizeTableCells(headers, headers.length); const headerHtml = safeHeaders.map((cell) => `${cell}`).join(''); const bodyHtml = rows @@ -122,13 +122,13 @@ function splitMarkdownTableRow(line: string): string[] { .map((cell) => cell.trim()); } -export function renderSafeLink(label: string, rawHref: string): string { +function renderSafeLink(label: string, rawHref: string): string { const href = normalizeSafeLinkHref(rawHref); if (!href) return label; return `link`; } -export function normalizeSafeLinkHref(rawHref: string): string | null { +function normalizeSafeLinkHref(rawHref: string): string | null { const href = rawHref.trim(); if (!href) return null; @@ -149,20 +149,20 @@ export function unescapeHtml(value: string): string { return value.replace(/&(amp|lt|gt);/g, (_match, name: string) => (name === 'amp' ? '&' : name === 'lt' ? '<' : '>')); } -export function escapeHtml(value: string): string { +function escapeHtml(value: string): string { return value .replace(/&/g, '&') .replace(//g, '>'); } -export function escapeHtmlAttribute(value: string): string { +function escapeHtmlAttribute(value: string): string { return escapeHtml(value) .replace(/"/g, '"') .replace(/'/g, '''); } -export function normalizeAnswerText(text: string): string { +function normalizeAnswerText(text: string): string { return text .replace(/\\r\\n/g, '\n') .replace(/\\n/g, '\n')