@mu-agent/mu 0.2.3 → 0.2.4
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/index.js +324 -235
- package/dist/mu.js +483 -390
- package/dist/types/ai/providers/llama-cpp.d.ts +1 -1
- package/dist/types/core/compaction.d.ts +2 -0
- package/dist/types/core/events.d.ts +10 -0
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/microcompaction.d.ts +2 -0
- package/dist/types/profile-browser/actions/click.d.ts +1 -0
- package/dist/types/profile-browser/actions/navigate.d.ts +1 -0
- package/dist/types/profile-browser/actions/types.d.ts +1 -1
- package/dist/types/profile-browser/agent/permissions.d.ts +7 -1
- package/dist/types/profile-browser/browser/lease.d.ts +22 -0
- package/dist/types/profile-browser/browser/manager.d.ts +9 -0
- package/dist/types/profile-browser/browser/tabs.d.ts +7 -1
- package/dist/types/profile-browser/index.d.ts +1 -0
- package/dist/types/profile-browser/page/model.d.ts +1 -0
- package/dist/types/profile-browser/page/text.d.ts +4 -2
- package/dist/types/profile-browser/testing/fixture-site.d.ts +1 -0
- package/dist/types/profile-browser/tools/shared.d.ts +9 -0
- package/dist/types/sdk/agent.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ModelInfo, Provider, ProviderModelDiscoveryOptions } from "../types.js";
|
|
2
|
-
export declare function discoverLlamaCppModels(options: ProviderModelDiscoveryOptions): Promise<ModelInfo[]>;
|
|
2
|
+
export declare function discoverLlamaCppModels(options: ProviderModelDiscoveryOptions): Promise<ModelInfo[] | undefined>;
|
|
3
3
|
export declare const llamaCpp: Provider;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ModelInfo, type Provider, type StreamOpts, type Usage } from "../ai/index.js";
|
|
2
|
+
import type { CompactionProgress } from "./events.js";
|
|
2
3
|
import type { AgentMessage } from "./messages.js";
|
|
3
4
|
export declare function estimateTextTokens(text: string): number;
|
|
4
5
|
export declare function estimateTokens(messages: AgentMessage[]): number;
|
|
@@ -52,6 +53,7 @@ export interface CompactorOptions {
|
|
|
52
53
|
streamOpts?: StreamOpts;
|
|
53
54
|
contextTokens?: number;
|
|
54
55
|
canContinue?: (usage: Usage) => boolean;
|
|
56
|
+
onProgress?: (progress: CompactionProgress) => void;
|
|
55
57
|
}
|
|
56
58
|
export declare function compact(messages: AgentMessage[], options: CompactorOptions): Promise<CompactionResult>;
|
|
57
59
|
export declare function applyCompaction(result: CompactionTranscript): AgentMessage[];
|
|
@@ -36,6 +36,15 @@ export type StreamDelta = {
|
|
|
36
36
|
export type AgentEndReason = "done" | "aborted" | "budget" | "maxTurns" | "error";
|
|
37
37
|
export type CompactionTrigger = "manual" | "threshold" | "overflow" | "model-change";
|
|
38
38
|
export type CompactionStage = "clearing-tool-output" | "summarizing" | "installing";
|
|
39
|
+
export interface CompactionProgress {
|
|
40
|
+
sourceTokens: number;
|
|
41
|
+
sourceChars: number;
|
|
42
|
+
summarizedChars: number;
|
|
43
|
+
request: number;
|
|
44
|
+
requestChars: number;
|
|
45
|
+
outputChars: number;
|
|
46
|
+
expectedOutputChars: number;
|
|
47
|
+
}
|
|
39
48
|
export type AgentEvent = {
|
|
40
49
|
type: "agent_start";
|
|
41
50
|
} | {
|
|
@@ -96,6 +105,7 @@ export type AgentEvent = {
|
|
|
96
105
|
layer: 1 | 2 | 3;
|
|
97
106
|
stage: CompactionStage;
|
|
98
107
|
toolResultsCleared?: number;
|
|
108
|
+
progress?: CompactionProgress;
|
|
99
109
|
} | {
|
|
100
110
|
type: "compaction_end";
|
|
101
111
|
layer: 1 | 2 | 3;
|
|
@@ -4,7 +4,7 @@ export type { Command, CommandContext, CommandResult } from "./commands.js";
|
|
|
4
4
|
export { CommandRegistry } from "./commands.js";
|
|
5
5
|
export type { CompactionPlan, CompactionRequest, CompactionResult, CompactorOptions, ContextState, } from "./compaction.js";
|
|
6
6
|
export { AUTO_COMPACT_THRESHOLD, applyCompaction, CompactionError, compact, compactionSummaryMessage, contextState, DEFAULT_KEEP_RECENT_TOKENS, estimateTextTokens, estimateTokens, formatCarryover, planCompaction, SUMMARY_PROMPT, serializeCompactionMessages, shouldCompact, } from "./compaction.js";
|
|
7
|
-
export type { AgentEndReason, AgentEvent, AgentEventType, CompactionStage, CompactionTrigger, EventSink, StreamDelta, } from "./events.js";
|
|
7
|
+
export type { AgentEndReason, AgentEvent, AgentEventType, CompactionProgress, CompactionStage, CompactionTrigger, EventSink, StreamDelta, } from "./events.js";
|
|
8
8
|
export type { Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, InputDirective, LifecycleEvent, LifecycleNotification, ToolCallDirective, ToolCallHookInfo, ToolRenderer, ToolResultDirective, ToolResultHookInfo, } from "./extensions.js";
|
|
9
9
|
export { ExtensionHost } from "./extensions.js";
|
|
10
10
|
export type { AfterToolCallInfo, AgentContext, AgentRunResult, BeforeToolCallInfo, ContextPreparation, LoopConfig, NextTurnDirective, TurnInfo, } from "./loop.js";
|
|
@@ -13,7 +13,7 @@ export type { AgentMessage, CustomMessage } from "./messages.js";
|
|
|
13
13
|
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
|
-
export { IMAGE_TOMBSTONE, MICROCOMPACT_THRESHOLD, microcompact, TOMBSTONE, } from "./microcompaction.js";
|
|
16
|
+
export { IMAGE_TOMBSTONE, MICROCOMPACT_THRESHOLD, microcompact, SUPERSEDE_WITHIN_TURNS, TOMBSTONE, } from "./microcompaction.js";
|
|
17
17
|
export type { PermissionAction, PermissionField, PermissionPreview, PermissionRequest, PermissionRule, PermissionSection, ToolPermissionDetails, } from "./permission.js";
|
|
18
18
|
export { evaluate, permissionPreviewLines } from "./permission.js";
|
|
19
19
|
export type { ManagedProcessHandle, ProcessEvents, Spawner, SpawnRequest, TaskInfo, TaskStatus, } from "./process.js";
|
|
@@ -7,7 +7,9 @@ export interface MicrocompactionOptions {
|
|
|
7
7
|
imageRetentionTurns?: number;
|
|
8
8
|
imageBudgetTokens?: number;
|
|
9
9
|
imagesOnly?: boolean;
|
|
10
|
+
supersedeWithinTurns?: number;
|
|
10
11
|
}
|
|
12
|
+
export declare const SUPERSEDE_WITHIN_TURNS = 2;
|
|
11
13
|
export interface MicrocompactionResult {
|
|
12
14
|
messages: AgentMessage[];
|
|
13
15
|
evicted: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Tab } from "../browser/tabs.js";
|
|
2
2
|
export declare function normalizeUrl(input: string): string;
|
|
3
3
|
export declare function hostOf(url: string): string;
|
|
4
|
+
export declare function pagePattern(url: string): string;
|
|
4
5
|
export interface NavigationResult {
|
|
5
6
|
settle: string;
|
|
6
7
|
sameDocument: boolean;
|
|
@@ -7,7 +7,7 @@ export interface Timings {
|
|
|
7
7
|
screenshotMs: number;
|
|
8
8
|
totalMs: number;
|
|
9
9
|
}
|
|
10
|
-
export type OutcomeKind = "stale-ref" | "occluded" | "no-change" | "navigated" | "new-tab" | "dialog" | "value-mismatch" | "timeout" | "blocked-by-dialog" | "not-interactable" | "error";
|
|
10
|
+
export type OutcomeKind = "stale-ref" | "occluded" | "no-change" | "navigated" | "new-tab" | "dialog" | "value-mismatch" | "timeout" | "blocked-by-dialog" | "not-interactable" | "blocked-host" | "error";
|
|
11
11
|
export interface OutcomeDetails {
|
|
12
12
|
timings: Timings;
|
|
13
13
|
url: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PermissionMode, type PermissionRule } from "../../core/index.js";
|
|
2
2
|
export declare const SCOPES: {
|
|
3
3
|
readonly observe: "browser:observe";
|
|
4
4
|
readonly navigate: "browser:navigate";
|
|
@@ -12,6 +12,12 @@ export declare const SCOPES: {
|
|
|
12
12
|
};
|
|
13
13
|
export declare const BROWSER_PERMISSION_DEFAULTS: PermissionRule[];
|
|
14
14
|
export declare function hostRules(allowedHosts: string[], blockedHosts: string[]): PermissionRule[];
|
|
15
|
+
export interface HostLists {
|
|
16
|
+
allowedHosts: string[];
|
|
17
|
+
blockedHosts: string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function restrictsHosts(lists: HostLists): boolean;
|
|
20
|
+
export declare function hostAllowed(url: string, lists: HostLists): boolean;
|
|
15
21
|
export declare function browserPermissionModes(hosts?: PermissionRule[]): PermissionMode[];
|
|
16
22
|
export declare function rememberedPermissionsPath(home: string): string;
|
|
17
23
|
export declare function loadRememberedPermissions(home: string, onWarning?: (message: string) => void): PermissionRule[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface LeaseHolder {
|
|
2
|
+
pid: number;
|
|
3
|
+
host: string;
|
|
4
|
+
token: string;
|
|
5
|
+
since: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function profileInUseMessage(holder: LeaseHolder, profileName: string): string;
|
|
8
|
+
export declare class ProfileInUseError extends Error {
|
|
9
|
+
readonly holder: LeaseHolder;
|
|
10
|
+
constructor(holder: LeaseHolder, profileName: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function liveHolder(userDataDir: string): LeaseHolder | undefined;
|
|
13
|
+
export declare class ProfileLease {
|
|
14
|
+
readonly userDataDir: string;
|
|
15
|
+
readonly profileName: string;
|
|
16
|
+
private readonly token;
|
|
17
|
+
private timer;
|
|
18
|
+
constructor(userDataDir: string, profileName: string);
|
|
19
|
+
acquire(): void;
|
|
20
|
+
release(): void;
|
|
21
|
+
private hold;
|
|
22
|
+
}
|
|
@@ -4,6 +4,7 @@ import { SecretRegistry } from "../page/secrets.js";
|
|
|
4
4
|
import { type BrowserLauncher, type ConnectedBrowser } from "./connect.js";
|
|
5
5
|
import { DownloadTracker } from "./downloads.js";
|
|
6
6
|
import type { Size } from "./launch.js";
|
|
7
|
+
import { ProfileLease } from "./lease.js";
|
|
7
8
|
import { Tab, type TabInfo } from "./tabs.js";
|
|
8
9
|
export interface BrowserManagerOptions {
|
|
9
10
|
connect: "managed" | "cdp";
|
|
@@ -18,6 +19,7 @@ export interface BrowserManagerOptions {
|
|
|
18
19
|
keepOpen: boolean;
|
|
19
20
|
launcher?: BrowserLauncher | undefined;
|
|
20
21
|
downloadsDir?: string | undefined;
|
|
22
|
+
hostAllowed?: ((url: string) => boolean) | undefined;
|
|
21
23
|
}
|
|
22
24
|
export interface BrowserStatus {
|
|
23
25
|
mode: "managed" | "cdp";
|
|
@@ -57,6 +59,7 @@ declare class SharedBrowser {
|
|
|
57
59
|
nextTab: number;
|
|
58
60
|
nextLane: number;
|
|
59
61
|
closingIntentionally: boolean;
|
|
62
|
+
lease: ProfileLease | undefined;
|
|
60
63
|
product: {
|
|
61
64
|
product: string;
|
|
62
65
|
version: string;
|
|
@@ -68,6 +71,7 @@ declare class SharedBrowser {
|
|
|
68
71
|
readonly downloads: DownloadTracker;
|
|
69
72
|
readonly secrets: SecretRegistry;
|
|
70
73
|
readonly dataflow: DataFlowGuard;
|
|
74
|
+
readonly blockedLoads: Map<string, string>;
|
|
71
75
|
constructor(downloadsDir: string | undefined);
|
|
72
76
|
}
|
|
73
77
|
export declare class BrowserManager {
|
|
@@ -101,6 +105,9 @@ export declare class BrowserManager {
|
|
|
101
105
|
drainNotices(): string[];
|
|
102
106
|
ensureConnected(signal?: AbortSignal): Promise<CdpConnection>;
|
|
103
107
|
private connect;
|
|
108
|
+
private guardNewPages;
|
|
109
|
+
private guardPage;
|
|
110
|
+
private agentOwned;
|
|
104
111
|
private requireCdpUrl;
|
|
105
112
|
private onDisconnect;
|
|
106
113
|
private tabIdFor;
|
|
@@ -112,6 +119,8 @@ export declare class BrowserManager {
|
|
|
112
119
|
private own;
|
|
113
120
|
private info;
|
|
114
121
|
tabs(): TabInfo[];
|
|
122
|
+
tabPattern(tabId?: string): string | undefined;
|
|
123
|
+
userTab(tab: Tab): boolean;
|
|
115
124
|
openedSince(since: number, openerTargetIds: string[]): TabInfo[];
|
|
116
125
|
private attach;
|
|
117
126
|
activeTab(signal?: AbortSignal): Promise<Tab>;
|
|
@@ -16,6 +16,8 @@ export interface JsDialog {
|
|
|
16
16
|
message: string;
|
|
17
17
|
defaultPrompt?: string;
|
|
18
18
|
}
|
|
19
|
+
export declare function blockOffHostLoads(session: CdpSession, mainFrameId: () => string, hostAllowed: (url: string) => boolean, onBlocked: (url: string) => void): () => void;
|
|
20
|
+
export declare function enableLoadBlocking(session: CdpSession, signal?: AbortSignal): Promise<unknown>;
|
|
19
21
|
export declare class Tab {
|
|
20
22
|
readonly tabId: string;
|
|
21
23
|
readonly targetId: string;
|
|
@@ -36,6 +38,9 @@ export declare class Tab {
|
|
|
36
38
|
} | undefined;
|
|
37
39
|
lastFingerprint: string | undefined;
|
|
38
40
|
unchangedStreak: number;
|
|
41
|
+
blockedNavigation: string | undefined;
|
|
42
|
+
errorPage: boolean;
|
|
43
|
+
private repeats;
|
|
39
44
|
private readonly offs;
|
|
40
45
|
private constructor();
|
|
41
46
|
static attach(connection: CdpConnection, target: {
|
|
@@ -45,7 +50,8 @@ export declare class Tab {
|
|
|
45
50
|
}, tabId: string, openedByAgent: boolean, signal?: AbortSignal, emulateViewport?: {
|
|
46
51
|
width: number;
|
|
47
52
|
height: number;
|
|
48
|
-
}): Promise<Tab>;
|
|
53
|
+
}, hostAllowed?: (url: string) => boolean): Promise<Tab>;
|
|
54
|
+
countRepeat(documentId: string, key: string): number;
|
|
49
55
|
get detached(): boolean;
|
|
50
56
|
info(active: boolean): TabInfo;
|
|
51
57
|
dispose(): void;
|
|
@@ -18,4 +18,5 @@ export { BrowserManager };
|
|
|
18
18
|
export { closeManaged, managedState } from "./browser/connect.js";
|
|
19
19
|
export { discoverBrowser } from "./browser/discover.js";
|
|
20
20
|
export { launchForSignIn } from "./browser/launch.js";
|
|
21
|
+
export { type LeaseHolder, liveHolder, ProfileInUseError, profileInUseMessage, } from "./browser/lease.js";
|
|
21
22
|
export default browserProfile;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { PageModel, PageNode } from "./model.js";
|
|
2
2
|
export declare const READ_PAGE_CHARS = 12000;
|
|
3
|
-
export
|
|
3
|
+
export interface PageText {
|
|
4
4
|
markdown: string;
|
|
5
|
+
full: string;
|
|
5
6
|
scope: string;
|
|
6
|
-
}
|
|
7
|
+
}
|
|
8
|
+
export declare function pageMarkdown(model: PageModel): PageText;
|
|
7
9
|
export declare function filterSections(markdown: string, query: string): string;
|
|
8
10
|
export declare function paginate(text: string, offset: number, size?: number): {
|
|
9
11
|
chunk: string;
|
|
@@ -11,7 +11,14 @@ export interface BrowserToolDeps {
|
|
|
11
11
|
notes?: () => string;
|
|
12
12
|
}
|
|
13
13
|
export declare const observationKey: (slot: number) => string;
|
|
14
|
+
export declare function repeatNudge(tab: Tab, documentId: string, tool: string, key: string): string | undefined;
|
|
14
15
|
export type ActResult = ActionResult;
|
|
16
|
+
export interface HostBlock {
|
|
17
|
+
result: ActResult;
|
|
18
|
+
withhold: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function enforceHosts(deps: BrowserToolDeps, tab: Tab, signal: AbortSignal): Promise<HostBlock | undefined>;
|
|
21
|
+
export declare function withheldResult(block: HostBlock, tab: Tab, stopwatch: Stopwatch): ToolResult;
|
|
15
22
|
export interface PageActionOptions {
|
|
16
23
|
blockedByDialog?: boolean;
|
|
17
24
|
screenshot?: boolean;
|
|
@@ -19,5 +26,7 @@ export interface PageActionOptions {
|
|
|
19
26
|
subtreeRef?: string;
|
|
20
27
|
detectChange?: boolean;
|
|
21
28
|
tabSwitch?: boolean;
|
|
29
|
+
leavesPage?: boolean;
|
|
30
|
+
repeatTool?: string;
|
|
22
31
|
}
|
|
23
32
|
export declare function pageAction(deps: BrowserToolDeps, toolSignal: AbortSignal, act: (tab: Tab, stopwatch: Stopwatch, signal: AbortSignal) => Promise<ActResult>, options?: PageActionOptions): Promise<ToolResult>;
|
|
@@ -135,6 +135,7 @@ export declare class Agent {
|
|
|
135
135
|
setPermissions(rules: PermissionRule[]): void;
|
|
136
136
|
addPermissionRule(rule: PermissionRule): void;
|
|
137
137
|
setModel(ref: string | ModelInfo): void;
|
|
138
|
+
refreshModelInfo(): boolean;
|
|
138
139
|
setThinking(level: ThinkingLevel): void;
|
|
139
140
|
resume(tree: SessionTree): void;
|
|
140
141
|
newSession(sessionId?: string): void;
|