@mu-agent/mu 0.2.3 → 0.3.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.
Files changed (64) hide show
  1. package/README.md +22 -13
  2. package/dist/index.js +465 -312
  3. package/dist/mu.js +651 -468
  4. package/dist/types/ai/errors.d.ts +2 -0
  5. package/dist/types/ai/index.d.ts +4 -3
  6. package/dist/types/ai/providers/citation-markup.d.ts +12 -0
  7. package/dist/types/ai/providers/inception.d.ts +3 -0
  8. package/dist/types/ai/providers/llama-cpp.d.ts +1 -1
  9. package/dist/types/ai/retry.d.ts +7 -0
  10. package/dist/types/ai/sse.d.ts +2 -1
  11. package/dist/types/ai/thinking.d.ts +2 -0
  12. package/dist/types/ai/types.d.ts +5 -0
  13. package/dist/types/core/checkpoint.d.ts +4 -1
  14. package/dist/types/core/commands.d.ts +3 -0
  15. package/dist/types/core/compaction.d.ts +2 -0
  16. package/dist/types/core/events.d.ts +43 -0
  17. package/dist/types/core/extensions.d.ts +10 -1
  18. package/dist/types/core/index.d.ts +6 -6
  19. package/dist/types/core/loop.d.ts +2 -0
  20. package/dist/types/core/messages.d.ts +3 -1
  21. package/dist/types/core/microcompaction.d.ts +2 -0
  22. package/dist/types/core/permission.d.ts +28 -1
  23. package/dist/types/core/process.d.ts +13 -2
  24. package/dist/types/core/profile.d.ts +12 -2
  25. package/dist/types/core/testing/fake-provider.d.ts +3 -1
  26. package/dist/types/core/tools.d.ts +6 -2
  27. package/dist/types/profile-browser/actions/click.d.ts +1 -0
  28. package/dist/types/profile-browser/actions/input.d.ts +1 -0
  29. package/dist/types/profile-browser/actions/navigate.d.ts +1 -0
  30. package/dist/types/profile-browser/actions/types.d.ts +1 -1
  31. package/dist/types/profile-browser/agent/handoff.d.ts +6 -1
  32. package/dist/types/profile-browser/agent/permissions.d.ts +8 -1
  33. package/dist/types/profile-browser/browser/lease.d.ts +22 -0
  34. package/dist/types/profile-browser/browser/manager.d.ts +9 -0
  35. package/dist/types/profile-browser/browser/tabs.d.ts +7 -1
  36. package/dist/types/profile-browser/index.d.ts +1 -2
  37. package/dist/types/profile-browser/page/model.d.ts +1 -0
  38. package/dist/types/profile-browser/page/text.d.ts +4 -2
  39. package/dist/types/profile-browser/testing/fixture-site.d.ts +1 -0
  40. package/dist/types/profile-browser/tools/shared.d.ts +9 -0
  41. package/dist/types/profile-coding/checkpoint.d.ts +39 -5
  42. package/dist/types/profile-coding/index.d.ts +5 -7
  43. package/dist/types/profile-coding/permissions.d.ts +16 -1
  44. package/dist/types/profile-coding/prompts.d.ts +0 -1
  45. package/dist/types/profile-coding/shell-permissions.d.ts +5 -0
  46. package/dist/types/profile-coding/terminal-text.d.ts +1 -0
  47. package/dist/types/profile-coding/tools/bash.d.ts +7 -2
  48. package/dist/types/profile-coding/tools/diff.d.ts +8 -0
  49. package/dist/types/profile-coding/tools/files.d.ts +5 -0
  50. package/dist/types/profile-coding/tools/tasks.d.ts +2 -1
  51. package/dist/types/profile-coding/track-commands.d.ts +9 -0
  52. package/dist/types/sdk/agent.d.ts +53 -2
  53. package/dist/types/sdk/commands.d.ts +1 -0
  54. package/dist/types/sdk/index.d.ts +14 -12
  55. package/dist/types/sdk/markdown-commands.d.ts +3 -1
  56. package/dist/types/sdk/mcp-catalog.d.ts +36 -0
  57. package/dist/types/sdk/mcp-config.d.ts +61 -0
  58. package/dist/types/sdk/mcp.d.ts +12 -18
  59. package/dist/types/sdk/skills.d.ts +39 -5
  60. package/dist/types/sdk/structured-output.d.ts +8 -1
  61. package/dist/types/sdk/subagents.d.ts +53 -5
  62. package/dist/types/sdk/tool.d.ts +5 -1
  63. package/package.json +1 -1
  64. package/dist/types/sdk/todo.d.ts +0 -16
@@ -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;
@@ -1,12 +1,10 @@
1
1
  import { type AgentMessage, type Profile } from "../core/index.js";
2
- import { TodoStore } from "../sdk/index.js";
3
2
  import { type CommitLedger, type NotesStore } from "./agent/state.js";
4
3
  import { BrowserManager } from "./browser/manager.js";
5
4
  import { type BrowserProfileOptions, type ResolvedBrowserOptions } from "./config.js";
6
5
  export interface BrowserProfile extends Profile {
7
6
  browser: BrowserManager;
8
7
  config: ResolvedBrowserOptions;
9
- todos: TodoStore;
10
8
  notes: NotesStore;
11
9
  ledger: CommitLedger;
12
10
  }
@@ -18,4 +16,5 @@ export { BrowserManager };
18
16
  export { closeManaged, managedState } from "./browser/connect.js";
19
17
  export { discoverBrowser } from "./browser/discover.js";
20
18
  export { launchForSignIn } from "./browser/launch.js";
19
+ export { type LeaseHolder, liveHolder, ProfileInUseError, profileInUseMessage, } from "./browser/lease.js";
21
20
  export default browserProfile;
@@ -35,6 +35,7 @@ export interface PageNode {
35
35
  options?: string[];
36
36
  optionCount?: number;
37
37
  cursorOnly?: boolean;
38
+ focusable?: boolean;
38
39
  form?: {
39
40
  post: boolean;
40
41
  submit?: boolean;
@@ -1,9 +1,11 @@
1
1
  import type { PageModel, PageNode } from "./model.js";
2
2
  export declare const READ_PAGE_CHARS = 12000;
3
- export declare function pageMarkdown(model: PageModel): {
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;
@@ -3,6 +3,7 @@ export interface FixtureSite {
3
3
  origin: string;
4
4
  crossOrigin: string;
5
5
  url: (page: string) => string;
6
+ requests: string[];
6
7
  submissions: Record<string, unknown>[];
7
8
  signups: {
8
9
  email: 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>;
@@ -2,33 +2,67 @@ import type { CheckpointDiffFile, CheckpointProvider } from "../core/index.js";
2
2
  export interface ShadowCheckpointOptions {
3
3
  root: string;
4
4
  shadowDir?: string;
5
+ home?: string;
5
6
  scope?: string;
6
7
  run?: GitRunner;
8
+ include?: string[];
9
+ coverage?: "full" | "declared";
7
10
  }
8
- export type GitRunner = (args: string[], env: Record<string, string>, cwd: string) => Promise<{
11
+ export interface GitRunOptions {
12
+ signal?: AbortSignal;
13
+ stdin?: string;
14
+ background?: boolean;
15
+ }
16
+ export type GitRunner = (args: string[], env: Record<string, string>, cwd: string, options?: GitRunOptions) => Promise<{
9
17
  stdout: string;
10
18
  stderr: string;
11
19
  exitCode: number;
12
20
  }>;
13
21
  export declare function gitConfigNullDevice(platform?: NodeJS.Platform): string;
22
+ export declare function partialCheckpointNotice(root: string, home?: string, run?: GitRunner): Promise<string | undefined>;
14
23
  export declare class ShadowCheckpointProvider implements CheckpointProvider {
24
+ readonly coverage: "full" | "declared";
15
25
  private readonly root;
16
26
  private readonly shadowDir;
17
27
  private readonly run;
18
28
  private readonly lockDir;
19
- private readonly excludedPathspecs;
29
+ private readonly excludedPrefixes;
30
+ private included;
20
31
  private initialized;
32
+ private lastMaintenance;
33
+ private maintenance;
21
34
  constructor(options: ShadowCheckpointOptions);
22
35
  get directory(): string;
36
+ get includedPaths(): string[];
37
+ setIncludedPaths(paths: string[]): void;
38
+ workspacePath(path: string): string;
39
+ private isIncluded;
23
40
  private env;
24
41
  private git;
42
+ private cancellableGit;
43
+ private workspaceGit;
44
+ private isExcluded;
25
45
  private acquireLock;
26
46
  private locked;
27
47
  private ensure;
28
- private ignoredDisposableDirectories;
29
- private checkpointPathspecs;
30
- snapshot(label?: string): Promise<string | undefined>;
48
+ private workspacePaths;
49
+ private updateIndex;
50
+ private stage;
51
+ snapshot(label?: string, signal?: AbortSignal): Promise<string | undefined>;
52
+ settled(): Promise<void>;
53
+ private startMaintenance;
54
+ private maintain;
55
+ private capture;
56
+ private commit;
57
+ snapshotResources(baseRef: string | undefined, resources: string[], label?: string): Promise<string | undefined>;
58
+ private captureResources;
59
+ private buildTree;
60
+ private recordedPaths;
61
+ private head;
62
+ private resourceScope;
63
+ private requireCheckpoints;
31
64
  restore(ref: string): Promise<void>;
65
+ private removeEmptyParents;
32
66
  restoreResources(ref: string, resources: string[]): Promise<void>;
33
67
  diff(fromRef: string, toRef?: string): Promise<CheckpointDiffFile[]>;
34
68
  }
@@ -1,5 +1,4 @@
1
1
  import { ProcessManager, type Profile } from "../core/index.js";
2
- import { TodoStore } from "../sdk/index.js";
3
2
  import { InstructionLoader, type InstructionSettings } from "./context.js";
4
3
  import { FileState } from "./state.js";
5
4
  import { bashTool } from "./tools/bash.js";
@@ -11,25 +10,24 @@ export interface CodingProfileOptions {
11
10
  home?: string;
12
11
  instructions?: InstructionSettings;
13
12
  managedInstructionPaths?: string[];
13
+ checkpoints?: boolean;
14
14
  }
15
15
  export interface CodingProfile extends Profile {
16
16
  fileState: FileState;
17
- todos: TodoStore;
18
17
  processes: ProcessManager;
19
18
  instructions: InstructionLoader;
20
19
  }
21
20
  export declare function codingProfile(options?: CodingProfileOptions): Promise<CodingProfile>;
22
- export type { TodoItem } from "../sdk/index.js";
23
- export { renderTodos, TodoStore, todoTool } from "../sdk/index.js";
24
21
  export type { GitRunner, ShadowCheckpointOptions } from "./checkpoint.js";
25
- export { gitConfigNullDevice, ShadowCheckpointProvider } from "./checkpoint.js";
22
+ export { gitConfigNullDevice, partialCheckpointNotice, ShadowCheckpointProvider, } from "./checkpoint.js";
26
23
  export { codingEnvironment, contextMessages, DEFAULT_INSTRUCTION_FALLBACKS, DEFAULT_PROJECT_ROOT_MARKERS, discoverContextFiles, environmentMessage, type InstructionDiagnostic, InstructionLoader, type InstructionLoaderOptions, type InstructionSettings, type InstructionSnapshot, type InstructionSource, } from "./context.js";
27
- export { CODING_PERMISSION_DEFAULTS, CODING_PERMISSION_MODES, layerPermissions, loadProjectConfig, rememberAllow, } from "./permissions.js";
24
+ export { CODING_PERMISSION_DEFAULTS, CODING_PERMISSION_MODES, codingPermissionModes, layerPermissions, loadProjectConfig, localConfigPath, rememberAllow, } from "./permissions.js";
28
25
  export { codingPrompt } from "./prompts.js";
29
26
  export { shellCommand, terminateProcessTree, windowsTaskkillCommand } from "./shell.js";
30
27
  export { classifyShellCommand, isInspectionShellCommand, parseInspectionCommands, type ShellCommandClassification, } from "./shell-inspection.js";
28
+ export { shellPermissionTargets } from "./shell-permissions.js";
31
29
  export { FileState } from "./state.js";
32
30
  export { bashTool } from "./tools/bash.js";
33
- export { editTool, lsTool, readTool, resolveInRoot, writeTool } from "./tools/files.js";
31
+ export { editPreviewProbe, editTool, lsTool, readTool, resolveInRoot, writeTool, } from "./tools/files.js";
34
32
  export { shellSpawner, taskTools } from "./tools/tasks.js";
35
33
  export { MAX_OUTPUT_CHARS, truncateOutput, withNotice } from "./truncate.js";
@@ -1,12 +1,18 @@
1
- import type { PermissionMode, PermissionRule } from "../core/index.js";
1
+ import type { PermissionMode, PermissionRule, SavedPermissionRule } from "../core/index.js";
2
2
  import { z } from "zod";
3
3
  import type { InstructionSettings } from "./context.js";
4
4
  export declare const CODING_PERMISSION_DEFAULTS: PermissionRule[];
5
+ export declare function codingPermissionModes(configured?: PermissionRule[]): PermissionMode[];
5
6
  export declare const CODING_PERMISSION_MODES: PermissionMode[];
6
7
  export interface ProjectConfig {
7
8
  permissions?: PermissionRule[];
8
9
  model?: string;
9
10
  instructions?: InstructionSettings;
11
+ checkpoints?: {
12
+ enabled?: boolean | undefined;
13
+ include?: string[] | undefined;
14
+ [key: string]: unknown;
15
+ };
10
16
  [key: string]: unknown;
11
17
  }
12
18
  export declare const instructionSettingsSchema: z.ZodObject<{
@@ -16,7 +22,16 @@ export declare const instructionSettingsSchema: z.ZodObject<{
16
22
  imports: z.ZodOptional<z.ZodBoolean>;
17
23
  claudeRules: z.ZodOptional<z.ZodBoolean>;
18
24
  }, z.core.$strip>;
25
+ export declare const checkpointSettingsSchema: z.ZodObject<{
26
+ enabled: z.ZodOptional<z.ZodBoolean>;
27
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
+ }, z.core.$loose>;
19
29
  export declare function configPath(root: string): string;
20
30
  export declare function loadProjectConfig(root: string, onWarning?: (message: string) => void): Promise<ProjectConfig>;
21
31
  export declare function layerPermissions(...layers: (PermissionRule[] | undefined)[]): PermissionRule[];
32
+ export declare function localConfigPath(root: string): string;
33
+ export declare function loadPermissionsFile(path: string, onWarning?: (message: string) => void): Promise<PermissionRule[]>;
22
34
  export declare function rememberAllow(root: string, permission: string, pattern: string): Promise<void>;
35
+ export declare function savedPermissions(paths: string[]): Promise<SavedPermissionRule[]>;
36
+ export declare function forgetPermission(rule: SavedPermissionRule): Promise<void>;
37
+ export declare function saveCheckpointIncludes(root: string, include: string[]): Promise<void>;
@@ -1,5 +1,4 @@
1
1
  import type { PromptSection } from "../ai/index.js";
2
2
  export declare const CODING_SIDE_BOUNDARY = "This is a coding side conversation. Do not modify files, source, git state, configuration, or workspace state unless the user deliberately changes the side conversation's permission mode. Do not request broader permissions or use subagents.";
3
- export declare const CODING_SEARCH_PROMPT = "Use rg and rg --files through bash for broad discovery, then use read offsets and limits to inspect only the relevant ranges. Do not read a whole file merely to inspect one symbol or range. Ground every finding in exact workspace-relative paths and 1-based line ranges. Distinguish observed code behavior from hypotheses.";
4
3
  export declare const CODING_COUNSEL_PROMPT = "Inspect the current implementation and tests before judging. Cite exact workspace-relative paths and 1-based line ranges for the evidence behind the recommendation.";
5
4
  export declare function codingPrompt(modelRef: string): PromptSection[];
@@ -0,0 +1,5 @@
1
+ import type { PermissionTarget } from "../core/index.js";
2
+ export declare function shellPermissionTargets(command: string, options?: {
3
+ background?: boolean;
4
+ platform?: NodeJS.Platform;
5
+ }): PermissionTarget[];
@@ -0,0 +1 @@
1
+ export declare function plainTerminalText(text: string): string;
@@ -1,4 +1,4 @@
1
- import { type ProcessManager } from "../../core/index.js";
1
+ import { type ManagedProcessHandle, type ProcessManager } from "../../core/index.js";
2
2
  type OutputStream = "stdout" | "stderr";
3
3
  type OutputChunk = (text: string, stream: OutputStream) => void;
4
4
  interface SpawnResult {
@@ -6,11 +6,16 @@ interface SpawnResult {
6
6
  stderr: string;
7
7
  exitCode: number | null;
8
8
  timedOut: boolean;
9
+ backgrounded?: boolean;
10
+ }
11
+ export interface BackgroundHandOff {
12
+ signal: AbortSignal;
13
+ adopt: (handle: ManagedProcessHandle) => (chunk: string) => void;
9
14
  }
10
15
  export interface BashDeps {
11
16
  root: string;
12
17
  processes?: ProcessManager;
13
- spawn?: (command: string, cwd: string, signal: AbortSignal, timeoutMs: number, onOutput?: OutputChunk) => Promise<SpawnResult>;
18
+ spawn?: (command: string, cwd: string, signal: AbortSignal, timeoutMs: number, onOutput?: OutputChunk, background?: BackgroundHandOff) => Promise<SpawnResult>;
14
19
  }
15
20
  export declare function bashTool(deps: BashDeps): import("../../sdk/index.js").Tool<{
16
21
  command: string;
@@ -0,0 +1,8 @@
1
+ import type { CheckpointDiffFile } from "../../core/index.js";
2
+ export declare function fileDiff(path: string, before: string | undefined, after: string): CheckpointDiffFile;
3
+ export interface Replacement {
4
+ start: number;
5
+ end: number;
6
+ newString: string;
7
+ }
8
+ export declare function replacementDiff(path: string, content: string, replacements: readonly Replacement[]): CheckpointDiffFile;
@@ -13,6 +13,7 @@ export interface ToolDeps {
13
13
  export declare function resolveInRoot(root: string, path: string): string;
14
14
  export declare function resolveExistingInRoot(root: string, path: string): Promise<string>;
15
15
  export declare function resolveForWriteInRoot(root: string, path: string): Promise<string>;
16
+ export declare function checkpointResource(root: string, path: string): string;
16
17
  export declare function filePermissionDiff(path: string, before: string | undefined, after: string): CheckpointDiffFile;
17
18
  export declare function readTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
18
19
  path: string;
@@ -23,6 +24,10 @@ export declare function writeTool(deps: ToolDeps): import("../../sdk/index.js").
23
24
  path: string;
24
25
  content: string;
25
26
  }>;
27
+ export declare function editPreviewProbe(root: string): {
28
+ occurrences(path: string, text: string): number | undefined;
29
+ exists(path: string): boolean | undefined;
30
+ };
26
31
  export declare function coerceEditInput(raw: unknown): unknown;
27
32
  export declare function editTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
28
33
  path: string;
@@ -1,8 +1,9 @@
1
1
  import { type ProcessManager, type Spawner } from "../../core/index.js";
2
2
  export declare function shellSpawner(root: string): Spawner;
3
- export declare function taskTools(manager: ProcessManager): (import("../../sdk/index.js").Tool<{
3
+ export declare function taskTools(manager: ProcessManager, waiting?: Map<string, number>): (import("../../sdk/index.js").Tool<{
4
4
  taskId: string;
5
5
  full?: boolean | undefined;
6
+ timeoutMs?: number | undefined;
6
7
  }> | import("../../sdk/index.js").Tool<{
7
8
  taskId: string;
8
9
  data: string;
@@ -0,0 +1,9 @@
1
+ import type { Command } from "../core/index.js";
2
+ import type { ShadowCheckpointProvider } from "./checkpoint.js";
3
+ export interface TrackCommandOptions {
4
+ root: string;
5
+ checkpoints?: ShadowCheckpointProvider;
6
+ unavailable?: string;
7
+ save?: (root: string, include: string[]) => Promise<void>;
8
+ }
9
+ export declare function trackCommands(options: TrackCommandOptions): Command[];
@@ -1,5 +1,5 @@
1
1
  import { type Credential, type ModelInfo, type PromptSection, type Provider, type ThinkingLevel, type Usage } from "../ai/index.js";
2
- import { type AgentEvent, type AgentMessage, type AnyTool, type CheckpointDiffFile, CheckpointHistory, type CheckpointProvider, type CustomMessage, type EventSink, type ExtensionHost, type PermissionRequest, type PermissionRule, type ProfileRuntime, type SessionStore, SessionTree, type UserContent } from "../core/index.js";
2
+ import { type AgentEvent, type AgentMessage, type AnyTool, type CheckpointDiffFile, CheckpointHistory, type CheckpointProvider, type CustomMessage, type EventSink, type ExtensionHost, type PermissionReply, type PermissionRequest, type PermissionRule, type ProfileRuntime, type SessionStore, SessionTree, type UserContent } from "../core/index.js";
3
3
  import type { z } from "zod";
4
4
  import { type Budget } from "./budget.js";
5
5
  export type HaltReason = "done" | "aborted" | "error" | "maxTurns" | "maxCostUsd" | "maxTokens";
@@ -9,7 +9,7 @@ export interface AgentOptions {
9
9
  systemPrompt?: string | PromptSection[];
10
10
  tools?: AnyTool[];
11
11
  permissions?: PermissionRule[];
12
- onPermission?: (request: PermissionRequest) => Promise<"allow" | "deny">;
12
+ onPermission?: (request: PermissionRequest) => Promise<PermissionReply>;
13
13
  budget?: Budget;
14
14
  session?: SessionStore;
15
15
  sessionId?: string;
@@ -28,6 +28,8 @@ export interface AgentOptions {
28
28
  imageRetentionTurns?: number;
29
29
  imageBudgetTokens?: number;
30
30
  checkpointProvider?: CheckpointProvider;
31
+ checkpointUnavailable?: string;
32
+ checkpointNotice?: string;
31
33
  runtime?: ProfileRuntime;
32
34
  extensions?: ExtensionHost;
33
35
  }
@@ -37,6 +39,7 @@ export interface RunResult {
37
39
  usage: Usage;
38
40
  reason: HaltReason;
39
41
  sessionId: string;
42
+ error?: string;
40
43
  }
41
44
  export interface CheckpointActionData {
42
45
  kind: "checkpoint";
@@ -69,6 +72,7 @@ export interface AgentRunOptions<T = unknown> {
69
72
  output?: z.ZodType<T>;
70
73
  model?: string | ModelInfo;
71
74
  allowedTools?: string[];
75
+ context?: CustomMessage[];
72
76
  }
73
77
  export interface ChildAgentOptions {
74
78
  model?: ModelInfo;
@@ -79,6 +83,12 @@ export interface ChildAgentOptions {
79
83
  budget?: Budget;
80
84
  inheritContext?: boolean;
81
85
  refreshContext?: AgentOptions["refreshContext"];
86
+ permissionLabel?: string | (() => string | undefined);
87
+ }
88
+ export interface BackgroundWork {
89
+ label: string;
90
+ done: Promise<unknown>;
91
+ stop: (reason: "user" | "session") => void;
82
92
  }
83
93
  export declare class Agent {
84
94
  private readonly options;
@@ -90,6 +100,9 @@ export declare class Agent {
90
100
  private controller;
91
101
  private steering;
92
102
  private followUps;
103
+ private notices;
104
+ private noticesHeld;
105
+ private heldPublished;
93
106
  private totals;
94
107
  private compactRequested;
95
108
  private compactRequestedFocus;
@@ -102,9 +115,14 @@ export declare class Agent {
102
115
  private lastContextUsage;
103
116
  private readonly checkpoints;
104
117
  private recoveryAttempted;
118
+ private turnRetries;
105
119
  private reactiveRecoveryPending;
106
120
  private pendingCheckpoint;
121
+ private readonly runningTasks;
122
+ private readonly backgroundCalls;
107
123
  private currentThinking;
124
+ private requestedThinking;
125
+ private readonly thinkingNotices;
108
126
  private running;
109
127
  private stopping;
110
128
  private activeEmit;
@@ -116,8 +134,14 @@ export declare class Agent {
116
134
  private shutdownPromise;
117
135
  private sessionStarted;
118
136
  private permissionRules;
137
+ private parentAgent;
138
+ private inheritsPermissions;
139
+ private readonly children;
140
+ private readonly background;
119
141
  constructor(options?: AgentOptions);
120
142
  get sessionId(): string;
143
+ get checkpointUnavailable(): string | undefined;
144
+ get checkpointNotice(): string | undefined;
121
145
  get usage(): Usage;
122
146
  get session(): SessionTree;
123
147
  get sessionStore(): SessionStore;
@@ -128,18 +152,34 @@ export declare class Agent {
128
152
  get thinkingLevels(): ThinkingLevel[];
129
153
  get isRunning(): boolean;
130
154
  get isCompacting(): boolean;
155
+ get isStopping(): boolean;
131
156
  get permissions(): PermissionRule[];
157
+ get waitingOnUser(): {
158
+ reason: string;
159
+ done: Promise<void>;
160
+ } | undefined;
161
+ get backgroundWork(): string[];
132
162
  get tools(): AnyTool[];
133
163
  availableModel(ref: string): ModelInfo | undefined;
134
164
  createChild(options: ChildAgentOptions): Agent;
135
165
  setPermissions(rules: PermissionRule[]): void;
136
166
  addPermissionRule(rule: PermissionRule): void;
167
+ chargeUsage(usage: Usage): void;
168
+ trackBackground(work: BackgroundWork): void;
169
+ stopBackgroundWork(label: string): boolean;
170
+ waitForSettled(): Promise<void>;
171
+ recordMessage(message: CustomMessage): Promise<void>;
137
172
  setModel(ref: string | ModelInfo): void;
173
+ refreshModelInfo(): boolean;
138
174
  setThinking(level: ThinkingLevel): void;
139
175
  resume(tree: SessionTree): void;
140
176
  newSession(sessionId?: string): void;
141
177
  send(message: string): void;
142
178
  followUp(message: string | CustomMessage): void;
179
+ notify(message: CustomMessage): void;
180
+ private publishHeld;
181
+ private releaseHeld;
182
+ withdrawFollowUp(message: AgentMessage): boolean;
143
183
  removeQueuedMessage(kind: "steer" | "follow-up", text: string): boolean;
144
184
  emitTaskEvent(event: AgentEvent): void;
145
185
  subscribe(listener: EventSink): () => void;
@@ -148,8 +188,11 @@ export declare class Agent {
148
188
  stop(): void;
149
189
  shutdown(): Promise<void>;
150
190
  abort(): void;
191
+ get backgroundableCalls(): string[];
192
+ backgroundToolCalls(ids?: readonly string[]): string[];
151
193
  requestCompaction(focus?: string): void;
152
194
  compactNow(focus?: string): Promise<ManualCompactionResult>;
195
+ private releaseNotices;
153
196
  private executeManualCompaction;
154
197
  get checkpointHistory(): CheckpointHistory;
155
198
  undoPoints(): UndoPoint[];
@@ -178,6 +221,7 @@ export declare class Agent {
178
221
  private beginCheckpoint;
179
222
  private finishCheckpoint;
180
223
  private appendCheckpointCursor;
224
+ private captureCurrent;
181
225
  private restoreCheckpointResources;
182
226
  private checkpointDetails;
183
227
  private rebuildCheckpointHistory;
@@ -185,6 +229,13 @@ export declare class Agent {
185
229
  private executeRun;
186
230
  private compactionContextTokens;
187
231
  private providerFor;
232
+ private backgroundBlocker;
233
+ private effectivePermissionRules;
234
+ private stopBackground;
235
+ private combinedUsage;
236
+ private claimChildUsage;
237
+ private budgetBreach;
238
+ private budgetBreachWithChild;
188
239
  private resolveChildPermission;
189
240
  private publishEvent;
190
241
  private refreshContextAccounting;
@@ -27,6 +27,7 @@ export interface CoreCommandHooks {
27
27
  }>;
28
28
  forkPoints?: () => ForkPoint[];
29
29
  diff?: () => Promise<CheckpointDiffFile[]>;
30
+ checkpointUnavailable?: string;
30
31
  }
31
32
  export declare function formatUsageBreakdown(usage: Usage & {
32
33
  contextPercent: number;
@@ -1,8 +1,8 @@
1
1
  export type { Credential, ModelDiscoveryOptions, ModelInfo, Provider, ProviderModelDiscoveryOptions, ThinkingLevel, Usage, WebSearchAction, WebSearchCitation, WebSearchContent, } from "../ai/index.js";
2
- export { builtinProviderConfigs, defaultModelId, defaultModelRef, defaultThinkingLevel, discoverModels, findModel, listModels, providerConfig, providerHasCredentials, refreshModels, registerModels, registerProvider, supportedThinkingLevels, thinkingLevelForModel, } from "../ai/index.js";
3
- export type { AgentEvent, AgentMessage, AnyTool, Command, CommandContext, CommandResult, CustomMessage, Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, LifecycleEvent, LifecycleNotification, PermissionMode, PermissionModeTone, PermissionRequest, PermissionRule, ProfileRuntime, ProfileRuntimeHost, SessionStore, StreamDelta, Tool, ToolRenderer, UserContent, } from "../core/index.js";
2
+ export { builtinProviderConfigs, defaultModelId, defaultModelRef, defaultThinkingLevel, discoverModels, findModel, listModels, providerConfig, providerEnvVars, providerHasCredentials, refreshModels, registerModels, registerProvider, supportedThinkingLevels, thinkingEffort, thinkingLevelForModel, } from "../ai/index.js";
3
+ export type { AgentEvent, AgentMessage, AnyTool, Command, CommandContext, CommandResult, CustomMessage, Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, LifecycleEvent, LifecycleNotification, PermissionMode, PermissionModeTone, PermissionReply, PermissionRequest, PermissionRule, PermissionTarget, ProfileRuntime, ProfileRuntimeHost, SavedPermissionRule, SessionStore, StreamDelta, Tool, ToolRenderer, UserContent, } from "../core/index.js";
4
4
  export { CommandRegistry, customMessage, ExtensionHost, errorResult, MemorySessionStore, SessionTree, textResult, userMessage, } from "../core/index.js";
5
- export type { AgentOptions, AgentRunOptions, CheckpointActionData, CheckpointActionResult, ChildAgentOptions, HaltReason, ManualCompactionResult, RunResult, UndoPoint, } from "./agent.js";
5
+ export type { AgentOptions, AgentRunOptions, BackgroundWork, CheckpointActionData, CheckpointActionResult, ChildAgentOptions, HaltReason, ManualCompactionResult, RunResult, UndoPoint, } from "./agent.js";
6
6
  export { Agent } from "./agent.js";
7
7
  export type { AuthFile, AuthStoreOptions, OpenAiCallbackServer, OpenAiLoginOptions, OpenAiLoginResult, PlanLoginCallbackServer, PlanLoginOptions, PlanLoginResult, StoredApiKey, StoredCredential, StoredOpenAiOAuth, StoredPlanOAuth, } from "./auth.js";
8
8
  export { createCredentialResolver, defaultAuthFile, loginGitHubCopilot, loginKimiCoding, loginOpenAI, loginOpenRouter, loginXai, preferredAuthProvider, readAuthFile, removeStoredCredential, saveApiKey, storedAuthProviders, } from "./auth.js";
@@ -18,21 +18,23 @@ export type { FileSessionStoreOptions } from "./file-store.js";
18
18
  export { FileSessionStore } from "./file-store.js";
19
19
  export type { MarkdownCommand, MarkdownCommandOptions, MarkdownCommandRun, } from "./markdown-commands.js";
20
20
  export { loadMarkdownCommands, parseFrontmatter, parseMarkdownCommand, substituteArguments, toCommand, } from "./markdown-commands.js";
21
- export type { LoadMcpConfigOptions, McpConfigReport, McpStdioServerConfig, } from "./mcp.js";
22
- export { loadMcpConfig, mcpExtension } from "./mcp.js";
21
+ export type { McpExtensionOptions } from "./mcp.js";
22
+ export { MCP_CONTEXT_TYPE, mcpExtension } from "./mcp.js";
23
+ export type { CatalogTool, ServerCatalog } from "./mcp-catalog.js";
24
+ export { describeText, openText, signature, validateArgs } from "./mcp-catalog.js";
25
+ export type { LoadMcpConfigOptions, McpApprovals, McpConfigReport, McpExposure, McpScope, McpServerSpec, McpSource, McpTransport, } from "./mcp-config.js";
26
+ export { loadMcpApprovals, loadMcpConfig, updateUserServerEntry } from "./mcp-config.js";
23
27
  export type { Profile, ProfileImporter } from "./profile.js";
24
28
  export { loadProfile, optionsFromProfile } from "./profile.js";
25
29
  export type { HookEvent, HookRunner, HookSpec } from "./shell-hooks.js";
26
30
  export { shellHooksExtension } from "./shell-hooks.js";
27
31
  export type { SideConversation, SideConversationInput } from "./side.js";
28
32
  export { startSideConversation } from "./side.js";
29
- export type { Skill } from "./skills.js";
30
- export { defaultSkillRoots, discoverSkills, loadSkill, skillListing, skillsExtension, } from "./skills.js";
31
- export { STRUCTURED_OUTPUT_TOOL, structuredOutputPrompt, structuredOutputTool, } from "./structured-output.js";
32
- export type { SubagentDetails, SubagentExtensionOptions, SubagentKind, SubagentProgressUpdate, } from "./subagents.js";
33
- export { subagentsExtension } from "./subagents.js";
34
- export type { TodoItem } from "./todo.js";
35
- export { renderTodos, TodoStore, todoTool } from "./todo.js";
33
+ export type { Skill, SkillCatalog, SkillRoot, SkillRootOptions, SkillScope, SkillSource, SkillsExtensionOptions, } from "./skills.js";
34
+ export { describeSkillCatalog, discoverSkills, loadSkill, projectDirectories, SKILLS_CONTEXT_TYPE, skillListing, skillRoots, skillsExtension, } from "./skills.js";
35
+ export { STRUCTURED_OUTPUT_TOOL, StructuredOutputError, structuredOutputPrompt, structuredOutputTool, } from "./structured-output.js";
36
+ export type { BackgroundSubagentDetails, SubagentDetails, SubagentExtensionOptions, SubagentKind, SubagentProgressUpdate, SubagentRoute, SubagentRouteOverride, SubagentRoutesStyle, SubagentsCommandData, } from "./subagents.js";
37
+ export { formatSubagentRoutes, subagentsExtension, subagentThinking } from "./subagents.js";
36
38
  export type { ToolDefinition, ToolResult } from "./tool.js";
37
39
  export { tool } from "./tool.js";
38
40
  export type { MarkdownTranscript, TranscriptMarkdownOptions, } from "./transcript-markdown.js";