@mu-agent/mu 0.1.1 → 0.2.2
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/README.md +27 -0
- package/dist/index.js +849 -192
- package/dist/mu.js +1101 -316
- package/dist/types/ai/types.d.ts +4 -0
- package/dist/types/core/index.d.ts +3 -3
- package/dist/types/core/permission.d.ts +12 -0
- package/dist/types/core/profile.d.ts +7 -0
- package/dist/types/core/tools.d.ts +4 -0
- package/dist/types/index.d.ts +8 -4
- package/dist/types/profile-browser/actions/classify.d.ts +19 -0
- package/dist/types/profile-browser/actions/click.d.ts +48 -0
- package/dist/types/profile-browser/actions/dates.d.ts +11 -0
- package/dist/types/profile-browser/actions/files.d.ts +9 -0
- package/dist/types/profile-browser/actions/filetype.d.ts +8 -0
- package/dist/types/profile-browser/actions/input.d.ts +17 -0
- package/dist/types/profile-browser/actions/keyboard.d.ts +16 -0
- package/dist/types/profile-browser/actions/navigate.d.ts +11 -0
- package/dist/types/profile-browser/actions/page.d.ts +8 -0
- package/dist/types/profile-browser/actions/pointer.d.ts +39 -0
- package/dist/types/profile-browser/actions/scroll.d.ts +8 -0
- package/dist/types/profile-browser/actions/submission.d.ts +7 -0
- package/dist/types/profile-browser/actions/types.d.ts +38 -0
- package/dist/types/profile-browser/agent/dataflow.d.ts +18 -0
- package/dist/types/profile-browser/agent/handoff.d.ts +15 -0
- package/dist/types/profile-browser/agent/ledger.d.ts +4 -0
- package/dist/types/profile-browser/agent/notes.d.ts +6 -0
- package/dist/types/profile-browser/agent/permissions.d.ts +18 -0
- package/dist/types/profile-browser/agent/prompts.d.ts +4 -0
- package/dist/types/profile-browser/agent/state.d.ts +48 -0
- package/dist/types/profile-browser/browser/connect.d.ts +45 -0
- package/dist/types/profile-browser/browser/discover.d.ts +31 -0
- package/dist/types/profile-browser/browser/downloads.d.ts +24 -0
- package/dist/types/profile-browser/browser/frames.d.ts +34 -0
- package/dist/types/profile-browser/browser/launch.d.ts +42 -0
- package/dist/types/profile-browser/browser/manager.d.ts +135 -0
- package/dist/types/profile-browser/browser/tabs.d.ts +52 -0
- package/dist/types/profile-browser/cdp/connection.d.ts +53 -0
- package/dist/types/profile-browser/cdp/session.d.ts +23 -0
- package/dist/types/profile-browser/cdp/types.d.ts +10 -0
- package/dist/types/profile-browser/commands.d.ts +5 -0
- package/dist/types/profile-browser/config.d.ts +73 -0
- package/dist/types/profile-browser/evals/live.d.ts +64 -0
- package/dist/types/profile-browser/index.d.ts +21 -0
- package/dist/types/profile-browser/page/capture-script.d.ts +1 -0
- package/dist/types/profile-browser/page/injection.d.ts +2 -0
- package/dist/types/profile-browser/page/model.d.ts +67 -0
- package/dist/types/profile-browser/page/network.d.ts +12 -0
- package/dist/types/profile-browser/page/observe.d.ts +39 -0
- package/dist/types/profile-browser/page/refs.d.ts +38 -0
- package/dist/types/profile-browser/page/render.d.ts +27 -0
- package/dist/types/profile-browser/page/resolve.d.ts +15 -0
- package/dist/types/profile-browser/page/screenshot.d.ts +25 -0
- package/dist/types/profile-browser/page/secrets.d.ts +7 -0
- package/dist/types/profile-browser/page/settle.d.ts +13 -0
- package/dist/types/profile-browser/page/snapshot.d.ts +9 -0
- package/dist/types/profile-browser/page/text.d.ts +22 -0
- package/dist/types/profile-browser/testing/agent-scenarios.d.ts +27 -0
- package/dist/types/profile-browser/testing/bench.d.ts +19 -0
- package/dist/types/profile-browser/testing/chrome.d.ts +12 -0
- package/dist/types/profile-browser/testing/fixture-site.d.ts +14 -0
- package/dist/types/profile-browser/testing/pdf.d.ts +1 -0
- package/dist/types/profile-browser/testing/wait.d.ts +1 -0
- package/dist/types/profile-browser/tools/delegate.d.ts +23 -0
- package/dist/types/profile-browser/tools/files.d.ts +3 -0
- package/dist/types/profile-browser/tools/gate.d.ts +8 -0
- package/dist/types/profile-browser/tools/interact.d.ts +86 -0
- package/dist/types/profile-browser/tools/navigate.d.ts +5 -0
- package/dist/types/profile-browser/tools/observe.d.ts +18 -0
- package/dist/types/profile-browser/tools/shared.d.ts +23 -0
- package/dist/types/profile-browser/tools/tabs.d.ts +8 -0
- package/dist/types/profile-coding/index.d.ts +3 -3
- package/dist/types/sdk/agent.d.ts +1 -0
- package/dist/types/sdk/index.d.ts +2 -0
- package/dist/types/sdk/subagents.d.ts +1 -0
- package/dist/types/{profile-coding/tools → sdk}/todo.d.ts +2 -2
- package/package.json +2 -1
package/dist/types/ai/types.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ export interface ToolResultMessage {
|
|
|
82
82
|
usage?: Usage;
|
|
83
83
|
isError: boolean;
|
|
84
84
|
evicted?: boolean;
|
|
85
|
+
retention?: {
|
|
86
|
+
key: string;
|
|
87
|
+
summary: string;
|
|
88
|
+
};
|
|
85
89
|
timestamp: number;
|
|
86
90
|
}
|
|
87
91
|
export type AiMessage = UserMessage | AssistantMessage | ToolResultMessage;
|
|
@@ -14,11 +14,11 @@ export * from "./messages.js";
|
|
|
14
14
|
export { customMessage, isCustomMessage, renderCustomMessage, toAiMessages, userMessage, } from "./messages.js";
|
|
15
15
|
export type { MicrocompactionOptions, MicrocompactionResult } from "./microcompaction.js";
|
|
16
16
|
export { IMAGE_TOMBSTONE, MICROCOMPACT_THRESHOLD, microcompact, TOMBSTONE, } from "./microcompaction.js";
|
|
17
|
-
export type { PermissionAction, PermissionPreview, PermissionRequest, PermissionRule, ToolPermissionDetails, } from "./permission.js";
|
|
18
|
-
export { evaluate } from "./permission.js";
|
|
17
|
+
export type { PermissionAction, PermissionField, PermissionPreview, PermissionRequest, PermissionRule, PermissionSection, ToolPermissionDetails, } from "./permission.js";
|
|
18
|
+
export { evaluate, permissionPreviewLines } from "./permission.js";
|
|
19
19
|
export type { ManagedProcessHandle, ProcessEvents, Spawner, SpawnRequest, TaskInfo, TaskStatus, } from "./process.js";
|
|
20
20
|
export { exitNotification, OutputBuffer, ProcessManager } from "./process.js";
|
|
21
|
-
export type { PermissionMode, PermissionModeTone, Profile, ProfileFactory, ProfileRuntime, ProfileRuntimeHost, ProfileSubagents, } from "./profile.js";
|
|
21
|
+
export type { PermissionMode, PermissionModeTone, Profile, ProfileFactory, ProfileRuntime, ProfileRuntimeHost, ProfileSubagents, TaskSubagentSession, } from "./profile.js";
|
|
22
22
|
export type { RecoveryAttempt } from "./recovery.js";
|
|
23
23
|
export { isContextTooLongError, isContextTooLongResult, withContextRecovery, } from "./recovery.js";
|
|
24
24
|
export type { NewTreeEntry, SessionEntry, SessionStore, TreeEntry } from "./session.js";
|
|
@@ -20,7 +20,19 @@ export type PermissionPreview = {
|
|
|
20
20
|
} | {
|
|
21
21
|
kind: "diff";
|
|
22
22
|
file: CheckpointDiffFile;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "fields";
|
|
25
|
+
sections: PermissionSection[];
|
|
23
26
|
};
|
|
27
|
+
export interface PermissionField {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PermissionSection {
|
|
32
|
+
title?: string;
|
|
33
|
+
fields: PermissionField[];
|
|
34
|
+
}
|
|
35
|
+
export declare function permissionPreviewLines(preview: PermissionPreview | undefined): string[];
|
|
24
36
|
export interface ToolPermissionDetails {
|
|
25
37
|
description?: string;
|
|
26
38
|
preview?: PermissionPreview;
|
|
@@ -24,7 +24,14 @@ export interface ProfileRuntime {
|
|
|
24
24
|
stop?: () => void;
|
|
25
25
|
shutdown?: () => void | Promise<void>;
|
|
26
26
|
}
|
|
27
|
+
export interface TaskSubagentSession {
|
|
28
|
+
tools: AnyTool[];
|
|
29
|
+
prompt?: string;
|
|
30
|
+
refreshContext?: Profile["refreshContext"];
|
|
31
|
+
close: () => void | Promise<void>;
|
|
32
|
+
}
|
|
27
33
|
export interface ProfileSubagents {
|
|
34
|
+
taskSession?: (description: string, signal: AbortSignal) => Promise<TaskSubagentSession>;
|
|
28
35
|
inspectionTools: string[];
|
|
29
36
|
searchPrompt?: string;
|
|
30
37
|
counselPrompt?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { type BrowserProfile, type BrowserProfileOptions, browserProfile } from "./profile-browser/index.js";
|
|
1
2
|
import { type CodingProfile, type CodingProfileOptions, codingProfile } from "./profile-coding/index.js";
|
|
2
3
|
import { Agent, type AgentOptions, type Profile } from "./sdk/index.js";
|
|
3
4
|
export * from "./sdk/index.js";
|
|
4
|
-
export { codingProfile };
|
|
5
|
-
export type { CodingProfile, CodingProfileOptions };
|
|
6
|
-
export
|
|
5
|
+
export { browserProfile, codingProfile };
|
|
6
|
+
export type { BrowserProfile, BrowserProfileOptions, CodingProfile, CodingProfileOptions };
|
|
7
|
+
export type CreateAgentOptions = AgentOptions & ({
|
|
7
8
|
profile?: "coding" | Profile;
|
|
8
9
|
profileOptions?: CodingProfileOptions;
|
|
9
|
-
}
|
|
10
|
+
} | {
|
|
11
|
+
profile: "browser";
|
|
12
|
+
profileOptions?: BrowserProfileOptions;
|
|
13
|
+
});
|
|
10
14
|
export declare function createAgent(options?: CreateAgentOptions): Promise<Agent>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RefMeta } from "../page/refs.js";
|
|
2
|
+
export interface Classification {
|
|
3
|
+
scope: string;
|
|
4
|
+
reason?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function matchesCommitLexicon(text: string | undefined): boolean;
|
|
7
|
+
export interface PageContext {
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
11
|
+
export type CommitStrength = "final" | "step";
|
|
12
|
+
export declare function commitStrength(names: (string | undefined)[], before: PageContext, after?: PageContext, credentials?: boolean): CommitStrength;
|
|
13
|
+
export interface ClassifyInput {
|
|
14
|
+
tool: string;
|
|
15
|
+
args: Record<string, unknown>;
|
|
16
|
+
meta: (ref: string) => RefMeta | undefined;
|
|
17
|
+
page?: PageContext | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function classify({ tool, args, meta, page }: ClassifyInput): Classification;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { BrowserManager } from "../browser/manager.js";
|
|
2
|
+
import type { Tab, TabInfo } from "../browser/tabs.js";
|
|
3
|
+
import { type ResolvedRef } from "../page/resolve.js";
|
|
4
|
+
import { type Modifier, type MouseButton, type Occluder, type Point } from "./pointer.js";
|
|
5
|
+
import type { OutcomeKind, Stopwatch } from "./types.js";
|
|
6
|
+
export interface ActionContext {
|
|
7
|
+
tab: Tab;
|
|
8
|
+
browser: BrowserManager;
|
|
9
|
+
stopwatch: Stopwatch;
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface ActionResult {
|
|
13
|
+
ok?: boolean;
|
|
14
|
+
summary: string;
|
|
15
|
+
kind?: OutcomeKind;
|
|
16
|
+
settle?: string;
|
|
17
|
+
tab?: Tab;
|
|
18
|
+
extra?: string;
|
|
19
|
+
path?: "mouse" | "js" | "keyboard";
|
|
20
|
+
occludedBy?: Occluder;
|
|
21
|
+
newTab?: TabInfo;
|
|
22
|
+
}
|
|
23
|
+
interface TargetInfo {
|
|
24
|
+
tag: string;
|
|
25
|
+
type: string;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
options?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function targetInfo(target: ResolvedRef, signal?: AbortSignal): Promise<TargetInfo>;
|
|
30
|
+
export declare function viewportSize(tab: Tab, signal?: AbortSignal): Promise<{
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function describeOccluder(occluder: Occluder): string;
|
|
35
|
+
export declare function raceDialog(tab: Tab, work: Promise<unknown>): Promise<"done" | "dialog">;
|
|
36
|
+
export declare function mainPoint(ctx: ActionContext, target: ResolvedRef, point: Point): Promise<Point>;
|
|
37
|
+
export declare function clickRef(ctx: ActionContext, ref: string, options?: {
|
|
38
|
+
button?: MouseButton;
|
|
39
|
+
double?: boolean;
|
|
40
|
+
modifiers?: Modifier[];
|
|
41
|
+
}): Promise<ActionResult>;
|
|
42
|
+
export declare function clickPoint(ctx: ActionContext, point: Point, options?: {
|
|
43
|
+
button?: MouseButton;
|
|
44
|
+
double?: boolean;
|
|
45
|
+
}): Promise<ActionResult>;
|
|
46
|
+
export declare function hoverRef(ctx: ActionContext, ref: string): Promise<ActionResult>;
|
|
47
|
+
export declare function dragBetween(ctx: ActionContext, from: string | Point, to: string | Point): Promise<ActionResult>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DateTarget {
|
|
2
|
+
year: number;
|
|
3
|
+
month?: number;
|
|
4
|
+
day?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const MONTHS: string[];
|
|
7
|
+
export declare function parseDate(text: string): DateTarget | undefined;
|
|
8
|
+
export declare function isoFor(type: string, target: DateTarget): string | undefined;
|
|
9
|
+
export declare function namesDate(name: string, target: DateTarget, shown: string): boolean;
|
|
10
|
+
export declare function shownPeriod(names: string[]): number | undefined;
|
|
11
|
+
export declare function periodOf(target: DateTarget): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ActionContext, type ActionResult } from "./click.js";
|
|
2
|
+
export declare function sensitivePath(path: string): boolean;
|
|
3
|
+
export declare function uploadRoots(config: {
|
|
4
|
+
workspace: string;
|
|
5
|
+
downloadsDir: string;
|
|
6
|
+
}): string[];
|
|
7
|
+
export declare function resolveUploadPaths(paths: string[], roots: string[]): string[];
|
|
8
|
+
export declare function uploadFiles(ctx: ActionContext, ref: string, paths: string[], roots: string[]): Promise<ActionResult>;
|
|
9
|
+
export declare function handleDialog(ctx: ActionContext, action: "accept" | "dismiss", text?: string): Promise<ActionResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface FileType {
|
|
2
|
+
mime: string;
|
|
3
|
+
label: string;
|
|
4
|
+
extensions: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function detectType(path: string): FileType;
|
|
7
|
+
export declare function describeFile(path: string): string;
|
|
8
|
+
export declare function uploadProblem(accept: string, path: string): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ActionContext, type ActionResult } from "./click.js";
|
|
2
|
+
export declare function normalizeDateValue(type: string, value: string): string;
|
|
3
|
+
export interface TypeOptions {
|
|
4
|
+
clear?: boolean;
|
|
5
|
+
submit?: boolean;
|
|
6
|
+
keystrokes?: boolean;
|
|
7
|
+
settle?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function typeText(ctx: ActionContext, ref: string, text: string, options?: TypeOptions): Promise<ActionResult>;
|
|
10
|
+
export declare function pressKeys(ctx: ActionContext, keys: string, ref?: string): Promise<ActionResult>;
|
|
11
|
+
export declare function setChecked(ctx: ActionContext, ref: string, checked: boolean): Promise<ActionResult>;
|
|
12
|
+
export declare function selectOptions(ctx: ActionContext, ref: string, options: string[]): Promise<ActionResult>;
|
|
13
|
+
export interface FormField {
|
|
14
|
+
ref: string;
|
|
15
|
+
value: string | boolean | string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function fillForm(ctx: ActionContext, fields: FormField[], submitRef?: string): Promise<ActionResult>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CdpSession } from "../cdp/session.js";
|
|
2
|
+
import type { Modifier } from "./pointer.js";
|
|
3
|
+
export interface KeyDefinition {
|
|
4
|
+
key: string;
|
|
5
|
+
code: string;
|
|
6
|
+
keyCode: number;
|
|
7
|
+
text?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface KeyCombo {
|
|
10
|
+
modifiers: Modifier[];
|
|
11
|
+
key: KeyDefinition;
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseKeys(input: string, platform?: NodeJS.Platform): KeyCombo;
|
|
15
|
+
export declare function pressCombo(session: CdpSession, combo: KeyCombo, signal?: AbortSignal, platform?: NodeJS.Platform): Promise<void>;
|
|
16
|
+
export declare function typeKeystrokes(session: CdpSession, text: string, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Tab } from "../browser/tabs.js";
|
|
2
|
+
export declare function normalizeUrl(input: string): string;
|
|
3
|
+
export declare function hostOf(url: string): string;
|
|
4
|
+
export interface NavigationResult {
|
|
5
|
+
settle: string;
|
|
6
|
+
sameDocument: boolean;
|
|
7
|
+
ms: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function navigateTo(tab: Tab, url: string, signal?: AbortSignal): Promise<NavigationResult>;
|
|
10
|
+
export declare function goHistory(tab: Tab, delta: -1 | 1, signal?: AbortSignal): Promise<NavigationResult | undefined>;
|
|
11
|
+
export declare function reload(tab: Tab, signal?: AbortSignal): Promise<NavigationResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ActionContext, type ActionResult } from "./click.js";
|
|
2
|
+
export declare const MAX_WAIT_SECONDS = 30;
|
|
3
|
+
export declare function waitFor(ctx: ActionContext, options: {
|
|
4
|
+
text?: string | undefined;
|
|
5
|
+
gone?: boolean | undefined;
|
|
6
|
+
seconds?: number | undefined;
|
|
7
|
+
}): Promise<ActionResult>;
|
|
8
|
+
export declare function evaluateScript(ctx: ActionContext, source: string, ref?: string): Promise<ActionResult>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Tab } from "../browser/tabs.js";
|
|
2
|
+
import type { CdpSession } from "../cdp/session.js";
|
|
3
|
+
import type { ResolvedRef } from "../page/resolve.js";
|
|
4
|
+
export type MouseButton = "left" | "right" | "middle";
|
|
5
|
+
export type Modifier = "Alt" | "Control" | "Meta" | "Shift";
|
|
6
|
+
export interface Point {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
export interface Occluder {
|
|
11
|
+
ref?: string;
|
|
12
|
+
role: string;
|
|
13
|
+
name: string;
|
|
14
|
+
inside: {
|
|
15
|
+
ref?: string;
|
|
16
|
+
role: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
export declare function modifierMask(modifiers?: Modifier[]): number;
|
|
21
|
+
export declare function sessionOffset(tab: Tab, frameId: string, signal?: AbortSignal): Promise<Point>;
|
|
22
|
+
export declare function clickablePoint(target: ResolvedRef, viewport: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}, signal?: AbortSignal): Promise<Point | undefined>;
|
|
26
|
+
export declare function hitTest(target: ResolvedRef, point: Point, refOf: (frameId: string, backendNodeId: number) => string | undefined, signal?: AbortSignal): Promise<{
|
|
27
|
+
ok: true;
|
|
28
|
+
} | {
|
|
29
|
+
ok: false;
|
|
30
|
+
occluder: Occluder;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function mouseClick(session: CdpSession, point: Point, options?: {
|
|
33
|
+
button?: MouseButton;
|
|
34
|
+
clickCount?: number;
|
|
35
|
+
modifiers?: Modifier[];
|
|
36
|
+
signal?: AbortSignal | undefined;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
export declare function mouseMove(session: CdpSession, point: Point, signal?: AbortSignal): Promise<boolean>;
|
|
39
|
+
export declare function mouseDrag(session: CdpSession, from: Point, to: Point, signal?: AbortSignal): Promise<"html5" | "pointer">;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionContext, ActionResult } from "./click.js";
|
|
2
|
+
export interface ScrollOptions {
|
|
3
|
+
direction?: "up" | "down" | "left" | "right";
|
|
4
|
+
to?: "top" | "bottom";
|
|
5
|
+
amount?: "page" | "half" | number;
|
|
6
|
+
ref?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function scrollPage(ctx: ActionContext, options: ScrollOptions): Promise<ActionResult>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Tab } from "../browser/tabs.js";
|
|
2
|
+
export interface SubmissionContent {
|
|
3
|
+
kind: "fields" | "text";
|
|
4
|
+
lines: string[];
|
|
5
|
+
credentials?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function submissionContent(tab: Tab, ref: string): Promise<SubmissionContent | undefined>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TabInfo } from "../browser/tabs.js";
|
|
2
|
+
export type Ref = string;
|
|
3
|
+
export interface Timings {
|
|
4
|
+
cdpMs: number;
|
|
5
|
+
settleMs: number;
|
|
6
|
+
snapshotMs: number;
|
|
7
|
+
screenshotMs: number;
|
|
8
|
+
totalMs: number;
|
|
9
|
+
}
|
|
10
|
+
export type OutcomeKind = "stale-ref" | "occluded" | "no-change" | "navigated" | "new-tab" | "dialog" | "value-mismatch" | "timeout" | "blocked-by-dialog" | "not-interactable" | "error";
|
|
11
|
+
export interface OutcomeDetails {
|
|
12
|
+
timings: Timings;
|
|
13
|
+
url: string;
|
|
14
|
+
title: string;
|
|
15
|
+
tabId: string;
|
|
16
|
+
fingerprint: string;
|
|
17
|
+
snapshotTokens: number;
|
|
18
|
+
settle?: string;
|
|
19
|
+
path?: "mouse" | "js" | "keyboard";
|
|
20
|
+
}
|
|
21
|
+
export interface ActionOutcome {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
summary: string;
|
|
24
|
+
kind?: OutcomeKind;
|
|
25
|
+
occludedBy?: {
|
|
26
|
+
ref?: Ref;
|
|
27
|
+
role: string;
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
newTab?: TabInfo;
|
|
31
|
+
details: OutcomeDetails;
|
|
32
|
+
}
|
|
33
|
+
export declare class Stopwatch {
|
|
34
|
+
private readonly started;
|
|
35
|
+
readonly timings: Omit<Timings, "totalMs">;
|
|
36
|
+
time<T>(phase: keyof Omit<Timings, "totalMs">, work: () => Promise<T>): Promise<T>;
|
|
37
|
+
finish(): Timings;
|
|
38
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Leak {
|
|
2
|
+
from: string;
|
|
3
|
+
sample: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class DataFlowGuard {
|
|
6
|
+
private readonly corpora;
|
|
7
|
+
private readonly tokens;
|
|
8
|
+
private readonly links;
|
|
9
|
+
private user;
|
|
10
|
+
observe(host: string, text: string): void;
|
|
11
|
+
private tokenLeak;
|
|
12
|
+
link(url: string): void;
|
|
13
|
+
userSaid(text: string): void;
|
|
14
|
+
visited(host: string): boolean;
|
|
15
|
+
leak(value: string, targetHost: string): Leak | undefined;
|
|
16
|
+
navigationLeak(url: string): string | undefined;
|
|
17
|
+
typingLeak(values: string[], pageUrl: string): string | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ProfileRuntimeHost } from "../../core/index.js";
|
|
2
|
+
import type { BrowserManager } from "../browser/manager.js";
|
|
3
|
+
import type { Tab } from "../browser/tabs.js";
|
|
4
|
+
export declare class Handoffs {
|
|
5
|
+
private readonly pollMs;
|
|
6
|
+
private host;
|
|
7
|
+
private timer;
|
|
8
|
+
constructor(pollMs?: number);
|
|
9
|
+
attach(host: ProfileRuntimeHost): void;
|
|
10
|
+
start(tab: Tab, reason: string): void;
|
|
11
|
+
cancel(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function handoffTool(browser: BrowserManager, handoffs: Handoffs): import("../../sdk/index.js").Tool<{
|
|
14
|
+
reason: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyTool } from "../../core/index.js";
|
|
2
|
+
import type { BrowserManager } from "../browser/manager.js";
|
|
3
|
+
import type { BrowserState } from "./state.js";
|
|
4
|
+
export declare function recordingCommits(tool: AnyTool, browser: BrowserManager, state: BrowserState): AnyTool;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PermissionMode, PermissionRule } from "../../core/index.js";
|
|
2
|
+
export declare const SCOPES: {
|
|
3
|
+
readonly observe: "browser:observe";
|
|
4
|
+
readonly navigate: "browser:navigate";
|
|
5
|
+
readonly interact: "browser:interact";
|
|
6
|
+
readonly commit: "browser:commit";
|
|
7
|
+
readonly secret: "browser:secret";
|
|
8
|
+
readonly upload: "browser:upload";
|
|
9
|
+
readonly script: "browser:script";
|
|
10
|
+
readonly delegate: "browser:delegate";
|
|
11
|
+
readonly share: "browser:share";
|
|
12
|
+
};
|
|
13
|
+
export declare const BROWSER_PERMISSION_DEFAULTS: PermissionRule[];
|
|
14
|
+
export declare function hostRules(allowedHosts: string[], blockedHosts: string[]): PermissionRule[];
|
|
15
|
+
export declare function browserPermissionModes(hosts?: PermissionRule[]): PermissionMode[];
|
|
16
|
+
export declare function rememberedPermissionsPath(home: string): string;
|
|
17
|
+
export declare function loadRememberedPermissions(home: string, onWarning?: (message: string) => void): PermissionRule[];
|
|
18
|
+
export declare function rememberAllow(home: string, permission: string, pattern: string): PermissionRule[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PromptSection } from "../../ai/index.js";
|
|
2
|
+
export declare function browserPrompt(modelRef: string): PromptSection[];
|
|
3
|
+
export declare const BROWSER_TASK_PROMPT = "You are a browser sub-task, running alongside others for the main agent in a browser window of your own.\n- Your first browser action opens your window. You see and use only the tabs you open (and popups from them); other tabs belong to the main agent or other sub-tasks.\n- The brief is all you know about the task; the rules above still apply. Only take consequential actions the brief explicitly authorizes (the user still approves each one), and stop where the brief says to stop.\n- Keep the progress file the brief names (under progress/) up to date as you finish steps; never edit another sub-task's file.\n- Anything only the user can do (sign in, a CAPTCHA, an answer your files do not give) is a blocker: stop and report exactly what is needed.\n- Before finishing, close the tabs you no longer need. Leave open only a tab the user should review (for example a filled form waiting for their submit) and name it in your report.\n- Report the outcome, what was submitted and the confirmation the page showed, what is left and why, and any tab left open.";
|
|
4
|
+
export declare const BROWSER_SIDE_BOUNDARY = "This is a side conversation about the browser session. Do not operate the browser, submit forms or change pages unless the user deliberately changes the side conversation's permission mode.";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type AgentMessage } from "../../core/index.js";
|
|
2
|
+
import type { CommitStrength } from "../actions/classify.js";
|
|
3
|
+
export interface NoteEntry {
|
|
4
|
+
key: string;
|
|
5
|
+
text: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CommitRecord {
|
|
8
|
+
id: string;
|
|
9
|
+
at: number;
|
|
10
|
+
host: string;
|
|
11
|
+
url: string;
|
|
12
|
+
action: string;
|
|
13
|
+
target: string;
|
|
14
|
+
valuesDigest?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CommitDetails extends CommitRecord {
|
|
17
|
+
name?: string;
|
|
18
|
+
sends?: string[];
|
|
19
|
+
strength: CommitStrength;
|
|
20
|
+
}
|
|
21
|
+
export declare const STATE_TYPE = "browser-state";
|
|
22
|
+
export declare const DEFAULT_NOTE_KEY = "notes";
|
|
23
|
+
export declare class NotesStore {
|
|
24
|
+
private readonly notes;
|
|
25
|
+
entries(): NoteEntry[];
|
|
26
|
+
get(key: string): string | undefined;
|
|
27
|
+
append(key: string, text: string): void;
|
|
28
|
+
replace(key: string, text: string): void;
|
|
29
|
+
clear(key?: string): void;
|
|
30
|
+
load(entries: NoteEntry[]): void;
|
|
31
|
+
}
|
|
32
|
+
export declare class CommitLedger {
|
|
33
|
+
private list;
|
|
34
|
+
records(): CommitRecord[];
|
|
35
|
+
append(record: CommitRecord): void;
|
|
36
|
+
load(records: CommitRecord[]): void;
|
|
37
|
+
}
|
|
38
|
+
export declare function formatNotes(entries: NoteEntry[]): string;
|
|
39
|
+
export declare function formatLedger(records: CommitRecord[]): string;
|
|
40
|
+
export declare class BrowserState {
|
|
41
|
+
readonly ledger: CommitLedger;
|
|
42
|
+
readonly notes: NotesStore;
|
|
43
|
+
sessionId: string | undefined;
|
|
44
|
+
constructor(ledger?: CommitLedger);
|
|
45
|
+
rebuild(messages: AgentMessage[]): void;
|
|
46
|
+
private snapshotText;
|
|
47
|
+
snapshotIfChanged(messages: AgentMessage[]): AgentMessage[];
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type CdpConnection } from "../cdp/connection.js";
|
|
2
|
+
import { type DiscoveredBrowser } from "./discover.js";
|
|
3
|
+
import { type BrowserEndpoint, type LaunchOptions, type Size } from "./launch.js";
|
|
4
|
+
export interface BrowserLauncher {
|
|
5
|
+
discover(prefs: {
|
|
6
|
+
executable?: string | undefined;
|
|
7
|
+
channel?: string | undefined;
|
|
8
|
+
}): Promise<DiscoveredBrowser>;
|
|
9
|
+
launch(options: LaunchOptions): Promise<BrowserEndpoint>;
|
|
10
|
+
}
|
|
11
|
+
export declare const defaultLauncher: BrowserLauncher;
|
|
12
|
+
interface Signals {
|
|
13
|
+
signal?: AbortSignal | undefined;
|
|
14
|
+
timeoutMs?: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare function endpointAlive(wsUrl: string, options?: Signals): Promise<boolean>;
|
|
17
|
+
export declare function resolveCdpUrl(endpoint: string, options?: Signals): Promise<string>;
|
|
18
|
+
export declare function profileLocked(userDataDir: string): boolean;
|
|
19
|
+
export declare function waitForUnlock(userDataDir: string, signal?: AbortSignal, timeoutMs?: number): Promise<void>;
|
|
20
|
+
export interface ManagedConnectOptions {
|
|
21
|
+
userDataDir: string;
|
|
22
|
+
headless: boolean;
|
|
23
|
+
viewport: Size;
|
|
24
|
+
executable?: string | undefined;
|
|
25
|
+
channel?: string | undefined;
|
|
26
|
+
args?: string[] | undefined;
|
|
27
|
+
url?: string | undefined;
|
|
28
|
+
launcher?: BrowserLauncher | undefined;
|
|
29
|
+
signal?: AbortSignal | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface ConnectedBrowser {
|
|
32
|
+
connection: CdpConnection;
|
|
33
|
+
endpoint: BrowserEndpoint;
|
|
34
|
+
browser?: DiscoveredBrowser;
|
|
35
|
+
}
|
|
36
|
+
export declare function connectManaged(options: ManagedConnectOptions): Promise<ConnectedBrowser>;
|
|
37
|
+
export declare function connectToEndpoint(endpoint: string, options?: Signals): Promise<ConnectedBrowser>;
|
|
38
|
+
export interface ManagedState {
|
|
39
|
+
running: boolean;
|
|
40
|
+
endpoint?: string;
|
|
41
|
+
locked: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function managedState(userDataDir: string): Promise<ManagedState>;
|
|
44
|
+
export declare function closeManaged(userDataDir: string): Promise<boolean>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type BrowserChannel = "chrome" | "chromium" | "brave" | "edge";
|
|
2
|
+
export declare const BROWSER_CHANNELS: BrowserChannel[];
|
|
3
|
+
export interface BrowserCandidate {
|
|
4
|
+
channel: BrowserChannel;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DiscoveredBrowser {
|
|
8
|
+
path: string;
|
|
9
|
+
channel: BrowserChannel | "custom";
|
|
10
|
+
product: string;
|
|
11
|
+
version: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DiscoverDeps {
|
|
14
|
+
platform: NodeJS.Platform;
|
|
15
|
+
env: Record<string, string | undefined>;
|
|
16
|
+
home: string;
|
|
17
|
+
exists: (path: string) => boolean;
|
|
18
|
+
which: (command: string) => string | null;
|
|
19
|
+
probeVersion: (path: string) => Promise<string | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export declare function knownPaths(platform: NodeJS.Platform, env: Record<string, string | undefined>, home: string): BrowserCandidate[];
|
|
22
|
+
export declare function parseVersionOutput(output: string): {
|
|
23
|
+
product: string;
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function defaultDiscoverDeps(): DiscoverDeps;
|
|
27
|
+
export declare function findCandidates(channel: BrowserChannel | undefined, deps: DiscoverDeps): BrowserCandidate[];
|
|
28
|
+
export declare function discoverBrowser(prefs?: {
|
|
29
|
+
executable?: string | undefined;
|
|
30
|
+
channel?: string | undefined;
|
|
31
|
+
}, deps?: DiscoverDeps): Promise<DiscoveredBrowser>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CdpConnection } from "../cdp/connection.js";
|
|
2
|
+
export interface DownloadRecord {
|
|
3
|
+
guid: string;
|
|
4
|
+
url: string;
|
|
5
|
+
filename: string;
|
|
6
|
+
path: string;
|
|
7
|
+
state: "in progress" | "completed" | "canceled";
|
|
8
|
+
receivedBytes: number;
|
|
9
|
+
totalBytes: number;
|
|
10
|
+
startedAt: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class DownloadTracker {
|
|
13
|
+
readonly directory: string;
|
|
14
|
+
private readonly records;
|
|
15
|
+
private readonly listeners;
|
|
16
|
+
constructor(directory: string);
|
|
17
|
+
attach(connection: CdpConnection, signal?: AbortSignal): Promise<void>;
|
|
18
|
+
private notify;
|
|
19
|
+
list(): DownloadRecord[];
|
|
20
|
+
since(time: number): DownloadRecord[];
|
|
21
|
+
waitForStart(time: number, capMs: number, signal?: AbortSignal): Promise<void>;
|
|
22
|
+
waitForFinished(time: number, capMs: number, signal?: AbortSignal): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare function formatDownloads(records: DownloadRecord[]): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CdpConnection } from "../cdp/connection.js";
|
|
2
|
+
import { CdpSession } from "../cdp/session.js";
|
|
3
|
+
export interface FrameInfo {
|
|
4
|
+
frameId: string;
|
|
5
|
+
parentId?: string | undefined;
|
|
6
|
+
url: string;
|
|
7
|
+
loaderId?: string | undefined;
|
|
8
|
+
session: CdpSession;
|
|
9
|
+
}
|
|
10
|
+
export declare class FrameRegistry {
|
|
11
|
+
private readonly connection;
|
|
12
|
+
readonly root: CdpSession;
|
|
13
|
+
private readonly frames;
|
|
14
|
+
private readonly children;
|
|
15
|
+
private readonly offs;
|
|
16
|
+
private readonly worlds;
|
|
17
|
+
private readonly sessionHooks;
|
|
18
|
+
private readonly hookOffs;
|
|
19
|
+
constructor(connection: CdpConnection, root: CdpSession);
|
|
20
|
+
get mainFrameId(): string | undefined;
|
|
21
|
+
list(): FrameInfo[];
|
|
22
|
+
get(frameId: string): FrameInfo | undefined;
|
|
23
|
+
childSessions(): CdpSession[];
|
|
24
|
+
onSession(hook: (session: CdpSession) => () => void): void;
|
|
25
|
+
private runHook;
|
|
26
|
+
start(signal?: AbortSignal): Promise<void>;
|
|
27
|
+
isolatedWorld(frameId: string, signal?: AbortSignal): Promise<number>;
|
|
28
|
+
forgetWorlds(frameId?: string): void;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
private record;
|
|
31
|
+
private watchSession;
|
|
32
|
+
private removeFrame;
|
|
33
|
+
private adoptChild;
|
|
34
|
+
}
|