@mu-agent/mu 0.2.4 → 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 (51) hide show
  1. package/README.md +22 -13
  2. package/dist/index.js +343 -279
  3. package/dist/mu.js +522 -432
  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/retry.d.ts +7 -0
  9. package/dist/types/ai/sse.d.ts +2 -1
  10. package/dist/types/ai/thinking.d.ts +2 -0
  11. package/dist/types/ai/types.d.ts +5 -0
  12. package/dist/types/core/checkpoint.d.ts +4 -1
  13. package/dist/types/core/commands.d.ts +3 -0
  14. package/dist/types/core/events.d.ts +33 -0
  15. package/dist/types/core/extensions.d.ts +10 -1
  16. package/dist/types/core/index.d.ts +4 -4
  17. package/dist/types/core/loop.d.ts +2 -0
  18. package/dist/types/core/messages.d.ts +3 -1
  19. package/dist/types/core/permission.d.ts +28 -1
  20. package/dist/types/core/process.d.ts +13 -2
  21. package/dist/types/core/profile.d.ts +12 -2
  22. package/dist/types/core/testing/fake-provider.d.ts +3 -1
  23. package/dist/types/core/tools.d.ts +6 -2
  24. package/dist/types/profile-browser/actions/input.d.ts +1 -0
  25. package/dist/types/profile-browser/agent/handoff.d.ts +6 -1
  26. package/dist/types/profile-browser/agent/permissions.d.ts +1 -0
  27. package/dist/types/profile-browser/index.d.ts +0 -2
  28. package/dist/types/profile-coding/checkpoint.d.ts +39 -5
  29. package/dist/types/profile-coding/index.d.ts +5 -7
  30. package/dist/types/profile-coding/permissions.d.ts +16 -1
  31. package/dist/types/profile-coding/prompts.d.ts +0 -1
  32. package/dist/types/profile-coding/shell-permissions.d.ts +5 -0
  33. package/dist/types/profile-coding/terminal-text.d.ts +1 -0
  34. package/dist/types/profile-coding/tools/bash.d.ts +7 -2
  35. package/dist/types/profile-coding/tools/diff.d.ts +8 -0
  36. package/dist/types/profile-coding/tools/files.d.ts +5 -0
  37. package/dist/types/profile-coding/tools/tasks.d.ts +2 -1
  38. package/dist/types/profile-coding/track-commands.d.ts +9 -0
  39. package/dist/types/sdk/agent.d.ts +52 -2
  40. package/dist/types/sdk/commands.d.ts +1 -0
  41. package/dist/types/sdk/index.d.ts +14 -12
  42. package/dist/types/sdk/markdown-commands.d.ts +3 -1
  43. package/dist/types/sdk/mcp-catalog.d.ts +36 -0
  44. package/dist/types/sdk/mcp-config.d.ts +61 -0
  45. package/dist/types/sdk/mcp.d.ts +12 -18
  46. package/dist/types/sdk/skills.d.ts +39 -5
  47. package/dist/types/sdk/structured-output.d.ts +8 -1
  48. package/dist/types/sdk/subagents.d.ts +53 -5
  49. package/dist/types/sdk/tool.d.ts +5 -1
  50. package/package.json +1 -1
  51. package/dist/types/sdk/todo.d.ts +0 -16
@@ -1,4 +1,5 @@
1
1
  export type AiErrorKind = "auth" | "rate_limit" | "overloaded" | "context_too_long" | "bad_request" | "not_found" | "network" | "api";
2
+ export declare function isRetryableErrorKind(kind: string | undefined): boolean;
2
3
  export declare class AiError extends Error {
3
4
  readonly kind: AiErrorKind;
4
5
  readonly status?: number;
@@ -11,3 +12,4 @@ export declare class AiError extends Error {
11
12
  }
12
13
  export declare function isContextTooLongMessage(message: string): boolean;
13
14
  export declare function classifyHttpError(status: number, body: string, headers: Headers): AiError;
15
+ export declare function classifyStreamError(payload: unknown, raw: string): AiError;
@@ -3,22 +3,23 @@ export type { ModelDiscoveryOptions } from "./catalog.js";
3
3
  export { defaultModelId, defaultModelRef, discoverModels, findModel, listModels, modelRef, providerHasCredentials, refreshModels, registerModels, } from "./catalog.js";
4
4
  export { addUsage, computeCostUsd, zeroUsage } from "./cost.js";
5
5
  export type { AiErrorKind } from "./errors.js";
6
- export { AiError, classifyHttpError, isContextTooLongMessage } from "./errors.js";
6
+ export { AiError, classifyHttpError, classifyStreamError, isContextTooLongMessage, isRetryableErrorKind, } from "./errors.js";
7
7
  export { parseJsonWithRepair, parsePartialJson, repairJson, salvageToolArgs } from "./json.js";
8
8
  export { builtinProviderConfigs, modelApi, providerBaseUrl, providerConfig, providerEnvVars, } from "./provider-config.js";
9
9
  export { anthropic, streamAnthropic } from "./providers/anthropic.js";
10
10
  export { gemini, streamGemini } from "./providers/gemini.js";
11
11
  export { discoverGitHubCopilotModels } from "./providers/github-copilot.js";
12
+ export { discoverInceptionModels, inceptionProvider } from "./providers/inception.js";
12
13
  export { discoverLlamaCppModels, llamaCpp } from "./providers/llama-cpp.js";
13
14
  export { discoverOpenAICodexModels, openai, openaiCodex, streamOpenAI, } from "./providers/openai.js";
14
15
  export { openaiCompletions, streamOpenAICompletions } from "./providers/openai-completions.js";
15
16
  export { getProvider, providers, registerProvider } from "./registry.js";
16
17
  export type { RetryOpts } from "./retry.js";
17
- export { withRetries } from "./retry.js";
18
+ export { MAX_TURN_RETRIES, MAX_TURN_RETRY_DELAY_MS, sleep, turnRetryDelayMs, withRetries, } from "./retry.js";
18
19
  export type { SseEvent } from "./sse.js";
19
20
  export { iterateSse } from "./sse.js";
20
21
  export { AssistantStream, EventStream } from "./stream.js";
21
22
  export type { Cassette, RecordedInteraction, ReplayCall, ReplayHandle } from "./testing/replay.js";
22
23
  export { recordFetch, replayFetch } from "./testing/replay.js";
23
- export { defaultThinkingLevel, supportedThinkingLevels, thinkingLevelForModel, } from "./thinking.js";
24
+ export { defaultThinkingLevel, supportedThinkingLevels, THINKING_EFFORTS, thinkingEffort, thinkingLevelForModel, } from "./thinking.js";
24
25
  export * from "./types.js";
@@ -0,0 +1,12 @@
1
+ export declare class CitationMarkupFilter {
2
+ private held;
3
+ private consumed;
4
+ private emitted;
5
+ private dropSpace;
6
+ private readonly removed;
7
+ push(delta: string): string;
8
+ flush(): string;
9
+ mapIndex(raw: number): number;
10
+ private emit;
11
+ }
12
+ export declare function stripCitationMarkup(text: string): string;
@@ -0,0 +1,3 @@
1
+ import type { ModelInfo, Provider, ProviderModelDiscoveryOptions } from "../types.js";
2
+ export declare function discoverInceptionModels(options: ProviderModelDiscoveryOptions): Promise<ModelInfo[] | undefined>;
3
+ export declare const inceptionProvider: Provider;
@@ -1,6 +1,13 @@
1
+ export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
1
2
  export interface RetryOpts {
2
3
  maxRetries?: number;
3
4
  maxRetryDelayMs?: number;
4
5
  signal?: AbortSignal;
5
6
  }
6
7
  export declare function withRetries<T>(request: () => Promise<T>, opts?: RetryOpts): Promise<T>;
8
+ export declare const MAX_TURN_RETRIES = 4;
9
+ export declare const MAX_TURN_RETRY_DELAY_MS: number;
10
+ export declare function turnRetryDelayMs(failure: {
11
+ errorKind?: string;
12
+ retryAfterMs?: number;
13
+ }, attempt: number): number | undefined;
@@ -2,4 +2,5 @@ export interface SseEvent {
2
2
  event: string | null;
3
3
  data: string;
4
4
  }
5
- export declare function iterateSse(body: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<SseEvent>;
5
+ export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
6
+ export declare function iterateSse(body: ReadableStream<Uint8Array>, signal?: AbortSignal, idleTimeoutMs?: number): AsyncGenerator<SseEvent>;
@@ -1,4 +1,6 @@
1
1
  import type { ModelInfo, ThinkingLevel } from "./types.js";
2
2
  export declare function supportedThinkingLevels(model: ModelInfo): ThinkingLevel[];
3
3
  export declare function defaultThinkingLevel(model: ModelInfo): ThinkingLevel;
4
+ export declare const THINKING_EFFORTS: readonly ThinkingLevel[];
5
+ export declare function thinkingEffort(level: ThinkingLevel): number | undefined;
4
6
  export declare function thinkingLevelForModel(model: ModelInfo, requested: ThinkingLevel | undefined): ThinkingLevel;
@@ -1,3 +1,4 @@
1
+ import type { AiErrorKind } from "./errors.js";
1
2
  export interface TextContent {
2
3
  type: "text";
3
4
  text: string;
@@ -71,6 +72,8 @@ export interface AssistantMessage {
71
72
  usage: Usage;
72
73
  stopReason: StopReason;
73
74
  errorMessage?: string;
75
+ errorKind?: AiErrorKind;
76
+ retryAfterMs?: number;
74
77
  timestamp: number;
75
78
  }
76
79
  export interface ToolResultMessage {
@@ -130,6 +133,7 @@ export interface ModelInfo {
130
133
  defaultThinkingLevel?: ThinkingLevel;
131
134
  thinkingMode?: "adaptive" | "budget";
132
135
  pricing: ModelPricing;
136
+ inferred?: boolean;
133
137
  }
134
138
  export type ThinkingLevel = "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | (string & {});
135
139
  export type Credential = {
@@ -160,6 +164,7 @@ export interface StreamOpts {
160
164
  thinkingLevel?: ThinkingLevel;
161
165
  signal?: AbortSignal;
162
166
  maxRetries?: number;
167
+ idleTimeoutMs?: number;
163
168
  headers?: Record<string, string>;
164
169
  fetch?: typeof fetch;
165
170
  }
@@ -3,9 +3,12 @@ export interface CheckpointDiffFile {
3
3
  added: number;
4
4
  removed: number;
5
5
  hunks: string[];
6
+ approximate?: boolean;
6
7
  }
7
8
  export interface CheckpointProvider {
8
- snapshot(label?: string): Promise<string | undefined>;
9
+ readonly coverage?: "full" | "declared";
10
+ snapshot(label?: string, signal?: AbortSignal): Promise<string | undefined>;
11
+ snapshotResources?(baseRef: string | undefined, resources: string[], label?: string): Promise<string | undefined>;
9
12
  restore(ref: string): Promise<void>;
10
13
  restoreResources?(ref: string, resources: string[]): Promise<void>;
11
14
  diff(fromRef: string, toRef?: string): Promise<CheckpointDiffFile[]>;
@@ -5,6 +5,7 @@ export interface CommandContext {
5
5
  print: (text: string) => void;
6
6
  getModel: () => string;
7
7
  setModel: (ref: string) => void;
8
+ isRunning?: () => boolean;
8
9
  }
9
10
  export interface CommandResult {
10
11
  handled: boolean;
@@ -15,6 +16,8 @@ export interface Command {
15
16
  name: string;
16
17
  description: string;
17
18
  sessionScoped?: boolean;
19
+ fallback?: boolean;
20
+ kind?: "skill";
18
21
  run: (ctx: CommandContext) => CommandResult | void | Promise<CommandResult | void>;
19
22
  }
20
23
  export declare class CommandRegistry {
@@ -72,6 +72,7 @@ export type AgentEvent = {
72
72
  toolCallId: string;
73
73
  toolName: string;
74
74
  args: unknown;
75
+ backgroundable?: true;
75
76
  } | {
76
77
  type: "tool_execution_update";
77
78
  toolCallId: string;
@@ -123,6 +124,7 @@ export type AgentEvent = {
123
124
  taskId: string;
124
125
  command: string;
125
126
  background: boolean;
127
+ startedAt?: number;
126
128
  } | {
127
129
  type: "task_output";
128
130
  taskId: string;
@@ -132,6 +134,37 @@ export type AgentEvent = {
132
134
  taskId: string;
133
135
  exitCode: number | null;
134
136
  status?: "exited" | "killed";
137
+ } | {
138
+ type: "provider_retry";
139
+ attempt: number;
140
+ maxAttempts: number;
141
+ delayMs: number;
142
+ errorMessage: string;
143
+ } | {
144
+ type: "notices_held";
145
+ count: number;
146
+ } | {
147
+ type: "thinking_adjusted";
148
+ model: string;
149
+ requested: string;
150
+ level: string;
151
+ inferredModel?: boolean;
152
+ } | {
153
+ type: "subagent_started";
154
+ subagentId: string;
155
+ toolCallId: string;
156
+ kind: string;
157
+ description: string;
158
+ } | {
159
+ type: "subagent_progress";
160
+ subagentId: string;
161
+ details: unknown;
162
+ } | {
163
+ type: "subagent_ended";
164
+ subagentId: string;
165
+ status: "done" | "error" | "stopped";
166
+ content: ToolResultContent[];
167
+ details?: unknown;
135
168
  } | {
136
169
  type: "usage_updated";
137
170
  sessionTotals: Usage;
@@ -1,7 +1,7 @@
1
1
  import type { ModelInfo, Provider } from "../ai/index.js";
2
2
  import { type Command, CommandRegistry } from "./commands.js";
3
3
  import type { AgentEvent } from "./events.js";
4
- import type { AgentMessage } from "./messages.js";
4
+ import type { AgentMessage, CustomMessage } from "./messages.js";
5
5
  import type { AnyTool, ToolResult } from "./tools.js";
6
6
  export interface ToolCallDirective {
7
7
  block?: boolean;
@@ -15,6 +15,7 @@ export interface ToolResultDirective {
15
15
  export interface InputDirective {
16
16
  consume?: boolean;
17
17
  text?: string;
18
+ context?: CustomMessage[];
18
19
  }
19
20
  export interface ToolCallHookInfo {
20
21
  toolName: string;
@@ -53,11 +54,15 @@ export interface ToolRenderer {
53
54
  result?: ToolResult;
54
55
  }) => string[];
55
56
  }
57
+ export type ContextProvider = (messages: AgentMessage[], context: {
58
+ sessionId: string;
59
+ }) => AgentMessage[] | Promise<AgentMessage[]>;
56
60
  export interface ExtensionAPI {
57
61
  on<T extends ExtensionEventType>(event: T, handler: (event: ExtensionEventFor<T>) => void): void;
58
62
  onToolCall(handler: (info: ToolCallHookInfo) => ToolCallDirective | undefined | Promise<ToolCallDirective | undefined>): void;
59
63
  onToolResult(handler: (info: ToolResultHookInfo) => ToolResultDirective | undefined | Promise<ToolResultDirective | undefined>): void;
60
64
  onContext(handler: (messages: AgentMessage[]) => AgentMessage[] | Promise<AgentMessage[]>): void;
65
+ registerContextProvider(provider: ContextProvider): void;
61
66
  onInput(handler: (text: string) => InputDirective | undefined | Promise<InputDirective | undefined>): void;
62
67
  registerTool(tool: AnyTool): void;
63
68
  registerCommand(command: Command): void;
@@ -83,6 +88,7 @@ export declare class ExtensionHost {
83
88
  private toolCallHooks;
84
89
  private toolResultHooks;
85
90
  private contextHooks;
91
+ private contextProviders;
86
92
  private inputHooks;
87
93
  register(extension: Extension): Promise<void>;
88
94
  shutdown(): Promise<void>;
@@ -92,6 +98,9 @@ export declare class ExtensionHost {
92
98
  runToolCallHooks(info: ToolCallHookInfo): Promise<ToolCallDirective | undefined>;
93
99
  runToolResultHooks(info: ToolResultHookInfo): Promise<ToolResultDirective | undefined>;
94
100
  runContextHooks(messages: AgentMessage[]): Promise<AgentMessage[]>;
101
+ runContextProviders(messages: AgentMessage[], context: {
102
+ sessionId: string;
103
+ }): Promise<AgentMessage[]>;
95
104
  runInputHooks(text: string): Promise<InputDirective | undefined>;
96
105
  get hasContextHooks(): boolean;
97
106
  }
@@ -5,7 +5,7 @@ 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
7
  export type { AgentEndReason, AgentEvent, AgentEventType, CompactionProgress, CompactionStage, CompactionTrigger, EventSink, StreamDelta, } from "./events.js";
8
- export type { Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, InputDirective, LifecycleEvent, LifecycleNotification, ToolCallDirective, ToolCallHookInfo, ToolRenderer, ToolResultDirective, ToolResultHookInfo, } from "./extensions.js";
8
+ export type { ContextProvider, 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";
11
11
  export { AgentEventStream, runAgent, runLoop } from "./loop.js";
@@ -14,8 +14,8 @@ 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, SUPERSEDE_WITHIN_TURNS, TOMBSTONE, } from "./microcompaction.js";
17
- export type { PermissionAction, PermissionField, PermissionPreview, PermissionRequest, PermissionRule, PermissionSection, ToolPermissionDetails, } from "./permission.js";
18
- export { evaluate, permissionPreviewLines } from "./permission.js";
17
+ export type { PermissionAction, PermissionField, PermissionPreview, PermissionReply, PermissionRequest, PermissionRule, PermissionSection, PermissionTarget, SavedPermissionRule, ToolPermissionDetails, } from "./permission.js";
18
+ export { evaluate, evaluateTargets, permissionOutcome, 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
21
  export type { PermissionMode, PermissionModeTone, Profile, ProfileFactory, ProfileRuntime, ProfileRuntimeHost, ProfileSubagents, TaskSubagentSession, } from "./profile.js";
@@ -24,4 +24,4 @@ export { isContextTooLongError, isContextTooLongResult, withContextRecovery, } f
24
24
  export type { NewTreeEntry, SessionEntry, SessionStore, TreeEntry } from "./session.js";
25
25
  export { isTreeEntry, MemorySessionStore, newEntryId, parseEntry, parseSession, SESSION_VERSION, SessionTree, serializeEntry, serializeSession, } from "./session.js";
26
26
  export type { AnyTool, Tool, ToolResult } from "./tools.js";
27
- export { concurrencySafe, errorResult, textResult } from "./tools.js";
27
+ export { canBackground, concurrencySafe, errorResult, textResult } from "./tools.js";
@@ -42,6 +42,7 @@ export interface LoopConfig {
42
42
  maxTurns?: number;
43
43
  getSteeringMessages?: () => AgentMessage[] | Promise<AgentMessage[]>;
44
44
  getFollowUpMessages?: () => AgentMessage[] | Promise<AgentMessage[]>;
45
+ getNotices?: () => AgentMessage[] | Promise<AgentMessage[]>;
45
46
  beforeToolCall?: (info: BeforeToolCallInfo, signal: AbortSignal) => {
46
47
  block?: boolean;
47
48
  reason?: string;
@@ -57,6 +58,7 @@ export interface LoopConfig {
57
58
  prepareNextTurn?: (turn: TurnInfo) => NextTurnDirective | undefined | Promise<NextTurnDirective | undefined>;
58
59
  prepareContext?: (messages: AgentMessage[]) => ContextPreparation | AgentMessage[] | Promise<ContextPreparation | AgentMessage[]>;
59
60
  transformContext?: (messages: AgentMessage[]) => AgentMessage[] | Promise<AgentMessage[]>;
61
+ backgroundCalls?: Map<string, AbortController>;
60
62
  }
61
63
  export interface AgentRunResult {
62
64
  messages: AgentMessage[];
@@ -1,4 +1,4 @@
1
- import type { AiMessage, AssistantMessage, ImageContent, TextContent, ToolResultMessage, UserMessage } from "../ai/index.js";
1
+ import type { AiMessage, AssistantMessage, ImageContent, TextContent, ToolResultMessage, Usage, UserMessage } from "../ai/index.js";
2
2
  export type { AssistantContent, AssistantMessage, ImageContent, StopReason, TextContent, ThinkingContent, ToolCallContent, ToolResultContent, ToolResultMessage, Usage, UserContent, UserMessage, WebSearchAction, WebSearchCitation, WebSearchContent, } from "../ai/index.js";
3
3
  export interface CustomMessage {
4
4
  role: "custom";
@@ -8,6 +8,8 @@ export interface CustomMessage {
8
8
  retention?: {
9
9
  key: string;
10
10
  };
11
+ details?: unknown;
12
+ usage?: Usage;
11
13
  timestamp: number;
12
14
  }
13
15
  export type AgentMessage = UserMessage | AssistantMessage | ToolResultMessage | CustomMessage;
@@ -5,6 +5,9 @@ export interface PermissionRule {
5
5
  pattern: string;
6
6
  action: PermissionAction;
7
7
  }
8
+ export interface SavedPermissionRule extends PermissionRule {
9
+ source: string;
10
+ }
8
11
  export interface PermissionRequest {
9
12
  id: string;
10
13
  toolCallId: string;
@@ -13,6 +16,24 @@ export interface PermissionRequest {
13
16
  pattern: string;
14
17
  description: string;
15
18
  preview?: PermissionPreview;
19
+ allowRules?: {
20
+ permission: string;
21
+ pattern: string;
22
+ }[];
23
+ }
24
+ export type PermissionReply = "allow" | "deny" | {
25
+ outcome: "allow" | "deny";
26
+ message?: string | undefined;
27
+ };
28
+ export declare function permissionOutcome(reply: PermissionReply): {
29
+ outcome: "allow" | "deny";
30
+ message?: string;
31
+ };
32
+ export interface PermissionTarget {
33
+ permission?: string;
34
+ pattern: string;
35
+ exact?: boolean;
36
+ remember?: string;
16
37
  }
17
38
  export type PermissionPreview = {
18
39
  kind: "text";
@@ -37,4 +58,10 @@ export interface ToolPermissionDetails {
37
58
  description?: string;
38
59
  preview?: PermissionPreview;
39
60
  }
40
- export declare function evaluate(rules: PermissionRule[], permission: string | readonly string[], pattern: string): PermissionAction;
61
+ export declare function evaluate(rules: PermissionRule[], permission: string | readonly string[], pattern: string, options?: {
62
+ exact?: boolean | undefined;
63
+ }): PermissionAction;
64
+ export declare function evaluateTargets(rules: PermissionRule[], toolName: string, targets: readonly PermissionTarget[]): {
65
+ action: PermissionAction;
66
+ asked: PermissionTarget[];
67
+ };
@@ -1,5 +1,6 @@
1
1
  export interface ManagedProcessHandle {
2
2
  write: (data: string) => void;
3
+ acceptsInput?: boolean;
3
4
  resize: (cols: number, rows: number) => void;
4
5
  detach: () => void;
5
6
  kill: () => void;
@@ -23,6 +24,7 @@ export interface TaskInfo {
23
24
  outputBytes: number;
24
25
  truncated: boolean;
25
26
  detached: boolean;
27
+ acceptsInput?: false;
26
28
  }
27
29
  export declare class OutputBuffer {
28
30
  private headLimit;
@@ -59,10 +61,19 @@ export declare class ProcessManager {
59
61
  cols?: number;
60
62
  rows?: number;
61
63
  }): TaskInfo;
64
+ adopt(command: string, handle: ManagedProcessHandle, options: {
65
+ startedAt: number;
66
+ output?: string;
67
+ }): {
68
+ task: TaskInfo;
69
+ onOutput: (chunk: string) => void;
70
+ };
71
+ private prepare;
72
+ private register;
62
73
  get(id: string): TaskInfo | undefined;
63
74
  list(): TaskInfo[];
64
75
  get runningCount(): number;
65
- output(id: string, since?: "start" | "new"): {
76
+ output(id: string, since?: "start" | "new" | "peek"): {
66
77
  text: string;
67
78
  truncated: boolean;
68
79
  } | undefined;
@@ -76,4 +87,4 @@ export declare class ProcessManager {
76
87
  private requestStops;
77
88
  wait(id: string): Promise<TaskInfo | undefined>;
78
89
  }
79
- export declare function exitNotification(task: TaskInfo): string;
90
+ export declare function exitNotification(task: TaskInfo, stoppedByUser?: boolean): string;
@@ -4,7 +4,7 @@ import type { Command } from "./commands.js";
4
4
  import type { AgentEvent } from "./events.js";
5
5
  import type { ToolRenderer } from "./extensions.js";
6
6
  import type { AgentMessage, CustomMessage } from "./messages.js";
7
- import type { PermissionRule } from "./permission.js";
7
+ import type { PermissionRule, SavedPermissionRule } from "./permission.js";
8
8
  import type { AnyTool } from "./tools.js";
9
9
  export type PermissionModeTone = "restrictive" | "permissive" | "unrestricted";
10
10
  export interface PermissionMode {
@@ -17,10 +17,17 @@ export interface PermissionMode {
17
17
  export interface ProfileRuntimeHost {
18
18
  emit: (event: AgentEvent) => void;
19
19
  followUp: (message: string | CustomMessage) => void;
20
+ notify?: (message: CustomMessage) => void;
21
+ record?: (message: CustomMessage) => void;
20
22
  }
21
23
  export interface ProfileRuntime {
22
24
  attach: (host: ProfileRuntimeHost) => void;
23
25
  resize?: (cols: number, rows: number) => void;
26
+ stopTask?: (taskId: string) => boolean;
27
+ waitingOnUser?: () => {
28
+ reason: string;
29
+ done: Promise<void>;
30
+ } | undefined;
24
31
  stop?: () => void;
25
32
  shutdown?: () => void | Promise<void>;
26
33
  }
@@ -33,7 +40,6 @@ export interface TaskSubagentSession {
33
40
  export interface ProfileSubagents {
34
41
  taskSession?: (description: string, signal: AbortSignal) => Promise<TaskSubagentSession>;
35
42
  inspectionTools: string[];
36
- searchPrompt?: string;
37
43
  counselPrompt?: string;
38
44
  recallScope?: Record<string, string>;
39
45
  }
@@ -45,6 +51,8 @@ export interface Profile {
45
51
  permissionModes?: PermissionMode[];
46
52
  defaultPermissionMode?: string;
47
53
  rememberPermission?: (permission: string, pattern: string) => void | Promise<void>;
54
+ savedPermissions?: () => SavedPermissionRule[] | Promise<SavedPermissionRule[]>;
55
+ forgetPermission?: (rule: SavedPermissionRule) => void | Promise<void>;
48
56
  renderers?: Record<string, ToolRenderer>;
49
57
  commands?: Command[];
50
58
  environment?: () => Promise<Record<string, string>> | Record<string, string>;
@@ -57,6 +65,8 @@ export interface Profile {
57
65
  diagnostics?: string[];
58
66
  carryoverExtractor?: (messages: AgentMessage[]) => unknown;
59
67
  checkpointProvider?: CheckpointProvider;
68
+ checkpointUnavailable?: string;
69
+ checkpointNotice?: string;
60
70
  runtime?: ProfileRuntime;
61
71
  scope?: () => Promise<string> | string;
62
72
  }
@@ -1,8 +1,10 @@
1
- import { type AssistantContent, AssistantStream, type LlmContext, type ModelInfo, type Provider, type StopReason, type StreamOpts, type Usage } from "../../ai/index.js";
1
+ import { type AiErrorKind, type AssistantContent, AssistantStream, type LlmContext, type ModelInfo, type Provider, type StopReason, type StreamOpts, type Usage } from "../../ai/index.js";
2
2
  export interface ScriptedTurn {
3
3
  content: AssistantContent[];
4
4
  stopReason?: StopReason;
5
5
  errorMessage?: string;
6
+ errorKind?: AiErrorKind;
7
+ retryAfterMs?: number;
6
8
  usage?: Partial<Usage>;
7
9
  delayMs?: number;
8
10
  }
@@ -1,5 +1,5 @@
1
1
  import type { ToolResultContent, Usage } from "../ai/index.js";
2
- import type { ToolPermissionDetails } from "./permission.js";
2
+ import type { PermissionTarget, ToolPermissionDetails } from "./permission.js";
3
3
  export interface ToolResult {
4
4
  content: ToolResultContent[];
5
5
  details?: unknown;
@@ -19,12 +19,16 @@ export interface Tool<Args = Record<string, unknown>> {
19
19
  isConcurrencySafe?: (args: Args) => boolean;
20
20
  executionMode?: "sequential";
21
21
  changesState?: boolean | ((args: Args) => boolean);
22
+ changedResources?: (args: Args) => string[];
22
23
  permissionScope?: (args: Args) => string;
23
24
  permissionPattern?: (args: Args) => string;
25
+ permissionTargets?: (args: Args) => PermissionTarget[];
24
26
  permissionDetails?: (args: Args) => ToolPermissionDetails | undefined | Promise<ToolPermissionDetails | undefined>;
25
- execute: (toolCallId: string, args: Args, signal: AbortSignal, onUpdate?: (partial: ToolResultContent[], details?: unknown) => void) => Promise<ToolResult>;
27
+ canBackground?: (args: Args) => boolean;
28
+ execute: (toolCallId: string, args: Args, signal: AbortSignal, onUpdate?: (partial: ToolResultContent[], details?: unknown) => void, background?: AbortSignal) => Promise<ToolResult>;
26
29
  }
27
30
  export type AnyTool = Tool<any>;
28
31
  export declare function errorResult(message: string): ToolResult;
29
32
  export declare function textResult(text: string): ToolResult;
33
+ export declare function canBackground(tool: AnyTool, args: unknown): boolean;
30
34
  export declare function concurrencySafe(tool: AnyTool, args: unknown): boolean;
@@ -5,6 +5,7 @@ export interface TypeOptions {
5
5
  submit?: boolean;
6
6
  keystrokes?: boolean;
7
7
  settle?: boolean;
8
+ choosing?: boolean;
8
9
  }
9
10
  export declare function typeText(ctx: ActionContext, ref: string, text: string, options?: TypeOptions): Promise<ActionResult>;
10
11
  export declare function pressKeys(ctx: ActionContext, keys: string, ref?: string): Promise<ActionResult>;
@@ -5,10 +5,15 @@ export declare class Handoffs {
5
5
  private readonly pollMs;
6
6
  private host;
7
7
  private timer;
8
+ private waiting;
8
9
  constructor(pollMs?: number);
9
10
  attach(host: ProfileRuntimeHost): void;
11
+ get pending(): {
12
+ reason: string;
13
+ done: Promise<void>;
14
+ } | undefined;
10
15
  start(tab: Tab, reason: string): void;
11
- cancel(): void;
16
+ cancel(settle?: boolean): void;
12
17
  }
13
18
  export declare function handoffTool(browser: BrowserManager, handoffs: Handoffs): import("../../sdk/index.js").Tool<{
14
19
  reason: string;
@@ -22,3 +22,4 @@ export declare function browserPermissionModes(hosts?: PermissionRule[]): Permis
22
22
  export declare function rememberedPermissionsPath(home: string): string;
23
23
  export declare function loadRememberedPermissions(home: string, onWarning?: (message: string) => void): PermissionRule[];
24
24
  export declare function rememberAllow(home: string, permission: string, pattern: string): PermissionRule[];
25
+ export declare function forgetRemembered(home: string, permission: string, pattern: string): 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
  }
@@ -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
  }