@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,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,12 +152,23 @@ 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;
138
173
  refreshModelInfo(): boolean;
139
174
  setThinking(level: ThinkingLevel): void;
@@ -141,6 +176,10 @@ export declare class Agent {
141
176
  newSession(sessionId?: string): void;
142
177
  send(message: string): void;
143
178
  followUp(message: string | CustomMessage): void;
179
+ notify(message: CustomMessage): void;
180
+ private publishHeld;
181
+ private releaseHeld;
182
+ withdrawFollowUp(message: AgentMessage): boolean;
144
183
  removeQueuedMessage(kind: "steer" | "follow-up", text: string): boolean;
145
184
  emitTaskEvent(event: AgentEvent): void;
146
185
  subscribe(listener: EventSink): () => void;
@@ -149,8 +188,11 @@ export declare class Agent {
149
188
  stop(): void;
150
189
  shutdown(): Promise<void>;
151
190
  abort(): void;
191
+ get backgroundableCalls(): string[];
192
+ backgroundToolCalls(ids?: readonly string[]): string[];
152
193
  requestCompaction(focus?: string): void;
153
194
  compactNow(focus?: string): Promise<ManualCompactionResult>;
195
+ private releaseNotices;
154
196
  private executeManualCompaction;
155
197
  get checkpointHistory(): CheckpointHistory;
156
198
  undoPoints(): UndoPoint[];
@@ -179,6 +221,7 @@ export declare class Agent {
179
221
  private beginCheckpoint;
180
222
  private finishCheckpoint;
181
223
  private appendCheckpointCursor;
224
+ private captureCurrent;
182
225
  private restoreCheckpointResources;
183
226
  private checkpointDetails;
184
227
  private rebuildCheckpointHistory;
@@ -186,6 +229,13 @@ export declare class Agent {
186
229
  private executeRun;
187
230
  private compactionContextTokens;
188
231
  private providerFor;
232
+ private backgroundBlocker;
233
+ private effectivePermissionRules;
234
+ private stopBackground;
235
+ private combinedUsage;
236
+ private claimChildUsage;
237
+ private budgetBreach;
238
+ private budgetBreachWithChild;
189
239
  private resolveChildPermission;
190
240
  private publishEvent;
191
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";
@@ -1,4 +1,4 @@
1
- import type { Command } from "../core/index.js";
1
+ import { type Command, type CustomMessage } from "../core/index.js";
2
2
  export interface MarkdownCommand {
3
3
  name: string;
4
4
  description: string;
@@ -11,6 +11,7 @@ export interface MarkdownCommandRun {
11
11
  prompt: string;
12
12
  model?: string;
13
13
  allowedTools?: string[];
14
+ context?: CustomMessage[];
14
15
  }
15
16
  export declare function parseFrontmatter(source: string): {
16
17
  meta: Record<string, string | string[]>;
@@ -26,4 +27,5 @@ export declare function loadMarkdownCommands(options?: MarkdownCommandOptions):
26
27
  export declare function toCommand(markdown: MarkdownCommand, submit?: (prompt: string, options: {
27
28
  model?: string;
28
29
  allowedTools?: string[];
30
+ context?: CustomMessage[];
29
31
  }) => unknown | Promise<unknown>): Command;
@@ -0,0 +1,36 @@
1
+ export interface CatalogTool {
2
+ name: string;
3
+ description?: string;
4
+ inputSchema: Record<string, unknown>;
5
+ annotations?: {
6
+ readOnlyHint?: boolean;
7
+ destructiveHint?: boolean;
8
+ [key: string]: unknown;
9
+ };
10
+ }
11
+ export interface ServerCatalog {
12
+ serverInfo?: {
13
+ name?: string;
14
+ title?: string;
15
+ version?: string;
16
+ };
17
+ instructions?: string;
18
+ tools: CatalogTool[];
19
+ resources: boolean;
20
+ fetchedAt: number;
21
+ }
22
+ type Schema = Record<string, any>;
23
+ export declare const LARGE_SERVER_TOKENS = 1000;
24
+ export declare function estimateTokens(text: string): number;
25
+ export declare function firstSentence(text: string | undefined, max: number): string;
26
+ export declare function signature(tool: CatalogTool): string;
27
+ export declare function isLargeServer(catalog: ServerCatalog): boolean;
28
+ export declare function openText(server: string, catalog: ServerCatalog): string;
29
+ export declare function describeText(server: string, catalog: ServerCatalog, names: string[]): string;
30
+ export declare function validateArgs(value: unknown, schema: Schema | undefined, path?: string): string[];
31
+ export declare function listingLine(server: string, options: {
32
+ description?: string;
33
+ catalog?: ServerCatalog;
34
+ note?: string;
35
+ }): string;
36
+ export {};
@@ -0,0 +1,61 @@
1
+ export type McpTransport = {
2
+ type: "stdio";
3
+ command: string;
4
+ args?: string[];
5
+ env?: Record<string, string>;
6
+ cwd?: string;
7
+ } | {
8
+ type: "http" | "sse";
9
+ url: string;
10
+ headers?: Record<string, string>;
11
+ };
12
+ export type McpSource = "mu" | "claude" | "codex" | "cursor" | "opencode" | "gemini" | "vscode";
13
+ export type McpScope = "user" | "project";
14
+ export type McpExposure = "open" | "direct";
15
+ export interface McpServerSpec {
16
+ name: string;
17
+ transport: McpTransport;
18
+ source: McpSource;
19
+ scope: McpScope;
20
+ file: string;
21
+ enabled: boolean;
22
+ exposure: McpExposure;
23
+ description?: string;
24
+ includeTools?: string[];
25
+ excludeTools?: string[];
26
+ startupTimeoutMs?: number;
27
+ toolTimeoutMs?: number;
28
+ }
29
+ export interface McpConfigReport {
30
+ servers: McpServerSpec[];
31
+ shadowed: McpServerSpec[];
32
+ errors: {
33
+ file: string;
34
+ message: string;
35
+ }[];
36
+ }
37
+ export interface LoadMcpConfigOptions {
38
+ projectDir?: string;
39
+ home?: string;
40
+ userFile?: string;
41
+ foreign?: boolean;
42
+ }
43
+ type Raw = Record<string, unknown>;
44
+ export declare function parseJsonc(text: string): unknown;
45
+ export declare function transportFingerprint(transport: McpTransport): string;
46
+ export declare function loadMcpConfig(options?: LoadMcpConfigOptions): Promise<McpConfigReport>;
47
+ export declare function expandVariables(value: string, env: Record<string, string | undefined>, extra?: Record<string, string>): {
48
+ value: string;
49
+ missing: string[];
50
+ };
51
+ export declare function expandTransport(transport: McpTransport, env: Record<string, string | undefined>, extra?: Record<string, string>): {
52
+ transport: McpTransport;
53
+ missing: string[];
54
+ };
55
+ export interface McpApprovals {
56
+ isApproved(projectDir: string, spec: McpServerSpec): boolean;
57
+ approve(projectDir: string, spec: McpServerSpec): Promise<void>;
58
+ }
59
+ export declare function loadMcpApprovals(file: string): Promise<McpApprovals>;
60
+ export declare function updateUserServerEntry(file: string, name: string, patch: Raw): Promise<void>;
61
+ export {};
@@ -1,22 +1,16 @@
1
1
  import { type Extension } from "../core/index.js";
2
- export interface McpStdioServerConfig {
3
- command: string;
4
- args?: string[];
5
- env?: Record<string, string>;
6
- cwd?: string;
7
- startupTimeoutMs?: number;
8
- toolTimeoutMs?: number;
9
- }
10
- export interface McpConfigReport {
11
- servers: Record<string, McpStdioServerConfig>;
12
- errors: {
13
- file: string;
14
- message: string;
15
- }[];
16
- }
17
- export interface LoadMcpConfigOptions {
2
+ import { type McpApprovals, type McpConfigReport, type McpServerSpec } from "./mcp-config.js";
3
+ export declare const MCP_CONTEXT_TYPE = "mcp_servers";
4
+ export interface McpExtensionOptions {
5
+ servers: McpServerSpec[];
6
+ shadowed?: McpServerSpec[];
7
+ errors?: McpConfigReport["errors"];
18
8
  projectDir?: string;
9
+ approvals?: McpApprovals;
10
+ cacheDir?: string | false;
19
11
  userFile?: string;
12
+ env?: Record<string, string | undefined>;
13
+ home?: string;
14
+ warm?: boolean;
20
15
  }
21
- export declare function loadMcpConfig(options?: LoadMcpConfigOptions): Promise<McpConfigReport>;
22
- export declare function mcpExtension(servers: Record<string, McpStdioServerConfig>): Extension;
16
+ export declare function mcpExtension(options: McpExtensionOptions): Extension;
@@ -1,12 +1,46 @@
1
- import type { Extension } from "../core/index.js";
1
+ import { type AgentMessage, type CustomMessage, type Extension } from "../core/index.js";
2
+ export type SkillSource = "mu" | "agents" | "claude" | "codex" | "opencode";
3
+ export type SkillScope = "project" | "user";
4
+ export interface SkillRoot {
5
+ directory: string;
6
+ scope: SkillScope;
7
+ source: SkillSource;
8
+ }
2
9
  export interface Skill {
3
10
  name: string;
4
11
  description: string;
5
12
  body: string;
6
13
  directory: string;
14
+ scope: SkillScope;
15
+ source: SkillSource;
16
+ disableModelInvocation: boolean;
17
+ userInvocable: boolean;
18
+ allowedTools?: string[];
19
+ }
20
+ export interface SkillCatalog {
21
+ skills: Skill[];
22
+ shadowed: Skill[];
23
+ warnings: string[];
7
24
  }
8
- export declare function loadSkill(directory: string): Promise<Skill | undefined>;
9
- export declare function discoverSkills(roots: string[]): Promise<Skill[]>;
10
- export declare function defaultSkillRoots(projectDir?: string): string[];
25
+ export interface SkillRootOptions {
26
+ home?: string;
27
+ projectDirs?: string[];
28
+ }
29
+ export declare function skillRoots(options?: SkillRootOptions): SkillRoot[];
30
+ export declare function loadSkill(directory: string, root?: Pick<SkillRoot, "scope" | "source">): Promise<Skill | string>;
31
+ export declare function discoverSkills(roots: SkillRoot[]): Promise<SkillCatalog>;
32
+ export declare const SKILLS_CONTEXT_TYPE = "skills";
11
33
  export declare function skillListing(skills: Skill[]): string;
12
- export declare function skillsExtension(skills: Skill[]): Extension;
34
+ export declare function snapshotMessage(type: string, text: string): CustomMessage;
35
+ export declare function refreshedSnapshot(messages: AgentMessage[], type: string, text: string): AgentMessage[];
36
+ export declare function skillContent(skill: Skill, files: string[]): string;
37
+ export declare function describeSkillCatalog(catalog: SkillCatalog): string;
38
+ export interface SkillsExtensionOptions {
39
+ roots: SkillRoot[];
40
+ catalog?: SkillCatalog;
41
+ }
42
+ export declare function skillsExtension(options: SkillsExtensionOptions): Extension;
43
+ export declare function projectDirectories(cwd: string, options?: {
44
+ home?: string;
45
+ markers?: string[];
46
+ }): Promise<string[]>;
@@ -1,5 +1,12 @@
1
- import type { AnyTool } from "../core/index.js";
1
+ import { type AnyTool, type CustomMessage } from "../core/index.js";
2
2
  import { z } from "zod";
3
+ import type { RunResult } from "./agent.js";
3
4
  export declare const STRUCTURED_OUTPUT_TOOL = "structured_output";
4
5
  export declare function structuredOutputTool<Schema extends z.ZodType>(schema: Schema, capture: (value: z.infer<Schema>) => void): AnyTool;
5
6
  export declare function structuredOutputPrompt(): string;
7
+ export declare const STRUCTURED_OUTPUT_REMINDERS = 2;
8
+ export declare function structuredOutputReminder(): CustomMessage;
9
+ export declare class StructuredOutputError extends Error {
10
+ readonly result: RunResult;
11
+ constructor(message: string, result: RunResult);
12
+ }