@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
@@ -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
+ }
@@ -1,13 +1,14 @@
1
- import { type ModelInfo, type ThinkingLevel, type Usage } from "../ai/index.js";
2
- import type { AgentMessage, Extension, PermissionRule, ProfileSubagents } from "../core/index.js";
1
+ import { type ModelInfo, type TextContent, type ThinkingLevel, type Usage } from "../ai/index.js";
2
+ import { type AgentMessage, type Extension, type PermissionRule, type ProfileSubagents } from "../core/index.js";
3
3
  import type { Agent, HaltReason } from "./agent.js";
4
- export type SubagentKind = "task" | "search" | "counsel" | "recall";
4
+ export type SubagentKind = "task" | "counsel" | "recall";
5
5
  export interface SubagentDetails {
6
6
  type: "subagent";
7
7
  kind: SubagentKind;
8
8
  description: string;
9
9
  model: string;
10
10
  thinkingLevel: ThinkingLevel;
11
+ ownModel?: boolean;
11
12
  durationMs: number;
12
13
  messages: AgentMessage[];
13
14
  usage: Usage;
@@ -19,6 +20,7 @@ export interface SubagentProgressUpdate {
19
20
  description: string;
20
21
  model: string;
21
22
  thinkingLevel: ThinkingLevel;
23
+ ownModel?: boolean;
22
24
  event: {
23
25
  type: "assistant_start";
24
26
  } | {
@@ -29,12 +31,46 @@ export interface SubagentProgressUpdate {
29
31
  message: AgentMessage;
30
32
  };
31
33
  }
34
+ export interface SubagentRouteOverride {
35
+ model?: ModelInfo;
36
+ thinkingLevel?: ThinkingLevel;
37
+ unavailable?: string;
38
+ }
39
+ export interface SubagentCallChoice {
40
+ model?: ModelInfo;
41
+ thinkingLevel?: ThinkingLevel;
42
+ }
43
+ export interface SubagentRoute {
44
+ kind: SubagentKind;
45
+ model: string;
46
+ thinkingLevel?: ThinkingLevel;
47
+ pinned?: boolean;
48
+ unavailable?: string;
49
+ }
50
+ export interface SubagentsCommandData {
51
+ kind: "subagents";
52
+ routes: SubagentRoute[];
53
+ }
54
+ export interface BackgroundSubagentDetails {
55
+ type: "subagent-background";
56
+ subagentId: string;
57
+ kind: SubagentKind;
58
+ description: string;
59
+ }
60
+ export interface BackgroundSubagentResultDetails {
61
+ type: "subagent-background-result";
62
+ subagentId: string;
63
+ toolCallId: string;
64
+ status: "done" | "error" | "stopped";
65
+ content: TextContent[];
66
+ result?: SubagentDetails;
67
+ }
32
68
  interface SubagentExtensionBaseOptions {
33
69
  parent: () => Agent;
34
70
  taskSession?: ProfileSubagents["taskSession"];
35
71
  excludeTools?: readonly string[];
36
- searchModel?: (parent: Agent) => ModelInfo | undefined;
37
- counselModel?: (parent: Agent) => ModelInfo | undefined;
72
+ modelChoices?: (parent: Agent) => ModelInfo[] | Promise<ModelInfo[]>;
73
+ routeOverride?: (kind: SubagentKind, parent: Agent) => SubagentRouteOverride | undefined | Promise<SubagentRouteOverride | undefined>;
38
74
  }
39
75
  export type SubagentExtensionOptions = SubagentExtensionBaseOptions & ({
40
76
  coding: ProfileSubagents;
@@ -43,5 +79,17 @@ export type SubagentExtensionOptions = SubagentExtensionBaseOptions & ({
43
79
  coding?: undefined;
44
80
  inspectionPermissions?: PermissionRule[];
45
81
  });
82
+ export declare function subagentThinking(kind: SubagentKind, model: ModelInfo, parentThinking: ThinkingLevel): ThinkingLevel;
83
+ export declare function matchModel(query: string, models: readonly ModelInfo[]): {
84
+ model: ModelInfo;
85
+ } | {
86
+ matches: ModelInfo[];
87
+ };
88
+ export declare function similarModels(query: string, models: readonly ModelInfo[]): ModelInfo[];
89
+ export interface SubagentRoutesStyle {
90
+ name?: (kind: SubagentKind, text: string) => string;
91
+ route?: (text: string) => string;
92
+ }
93
+ export declare function formatSubagentRoutes(routes: readonly SubagentRoute[], style?: SubagentRoutesStyle): string[];
46
94
  export declare function subagentsExtension(options: SubagentExtensionOptions): Extension;
47
95
  export {};
@@ -1,4 +1,4 @@
1
- import type { AnyTool, Tool, ToolPermissionDetails, ToolResult } from "../core/index.js";
1
+ import type { AnyTool, PermissionTarget, Tool, ToolPermissionDetails, ToolResult } from "../core/index.js";
2
2
  import { z } from "zod";
3
3
  export type { ToolResult };
4
4
  export interface ToolDefinition<Schema extends z.ZodType> {
@@ -9,13 +9,17 @@ export interface ToolDefinition<Schema extends z.ZodType> {
9
9
  isConcurrencySafe?: (args: z.infer<Schema>) => boolean;
10
10
  executionMode?: "sequential";
11
11
  changesState?: boolean | ((args: z.infer<Schema>) => boolean);
12
+ changedResources?: (args: z.infer<Schema>) => string[];
12
13
  permissionScope?: (args: z.infer<Schema>) => string;
13
14
  permissionPattern?: (args: z.infer<Schema>) => string;
15
+ permissionTargets?: (args: z.infer<Schema>) => PermissionTarget[];
14
16
  permissionDetails?: (args: z.infer<Schema>) => ToolPermissionDetails | undefined | Promise<ToolPermissionDetails | undefined>;
17
+ canBackground?: (args: z.infer<Schema>) => boolean;
15
18
  execute: (args: z.infer<Schema>, ctx: {
16
19
  toolCallId: string;
17
20
  signal: AbortSignal;
18
21
  update: (text: string, details?: unknown) => void;
22
+ background: AbortSignal;
19
23
  }) => Promise<ToolResult | string> | ToolResult | string;
20
24
  }
21
25
  export declare function tool<Schema extends z.ZodType>(definition: ToolDefinition<Schema>): Tool<z.infer<Schema>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-agent/mu",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Mu, a general-purpose extensible AI agent platform for the terminal and TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,16 +0,0 @@
1
- export interface TodoItem {
2
- content: string;
3
- status: "pending" | "in_progress" | "completed";
4
- }
5
- export declare class TodoStore {
6
- private items;
7
- replace(items: TodoItem[]): void;
8
- all(): TodoItem[];
9
- }
10
- export declare function renderTodos(items: TodoItem[]): string;
11
- export declare function todoTool(store: TodoStore): import("../core/index.js").Tool<{
12
- items: {
13
- content: string;
14
- status: "completed" | "pending" | "in_progress";
15
- }[];
16
- }>;