@mu-agent/mu 0.0.1 → 0.0.2

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.
@@ -19,4 +19,5 @@ export { iterateSse } from "./sse.js";
19
19
  export { AssistantStream, EventStream } from "./stream.js";
20
20
  export type { Cassette, RecordedInteraction, ReplayCall, ReplayHandle } from "./testing/replay.js";
21
21
  export { recordFetch, replayFetch } from "./testing/replay.js";
22
+ export { defaultThinkingLevel, supportedThinkingLevels, thinkingLevelForModel, } from "./thinking.js";
22
23
  export * from "./types.js";
@@ -0,0 +1,4 @@
1
+ import type { ModelInfo, ThinkingLevel } from "./types.js";
2
+ export declare function supportedThinkingLevels(model: ModelInfo): ThinkingLevel[];
3
+ export declare function defaultThinkingLevel(model: ModelInfo): ThinkingLevel;
4
+ export declare function thinkingLevelForModel(model: ModelInfo, requested: ThinkingLevel | undefined): ThinkingLevel;
@@ -89,10 +89,12 @@ export interface ModelInfo {
89
89
  maxOutput: number;
90
90
  modalities: ("text" | "image")[];
91
91
  thinking?: boolean;
92
+ thinkingLevels?: ThinkingLevel[];
93
+ defaultThinkingLevel?: ThinkingLevel;
92
94
  thinkingMode?: "adaptive" | "budget";
93
95
  pricing: ModelPricing;
94
96
  }
95
- export type ThinkingLevel = "off" | "low" | "medium" | "high";
97
+ export type ThinkingLevel = "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "ultra" | (string & {});
96
98
  export type Credential = {
97
99
  type: "apiKey";
98
100
  apiKey: string;
@@ -14,6 +14,12 @@ export interface CompactionRequest {
14
14
  keepFromIndex: number;
15
15
  carryover?: unknown;
16
16
  }
17
+ export interface CompactionPlan {
18
+ keepFromIndex: number;
19
+ keptTokens: number;
20
+ isSplitTurn: boolean;
21
+ turnStartIndex: number | null;
22
+ }
17
23
  export interface CompactionResult {
18
24
  summary: string;
19
25
  carryover?: unknown;
@@ -26,15 +32,16 @@ export declare class CompactionError extends Error {
26
32
  readonly usage?: Usage | undefined;
27
33
  constructor(message: string, usage?: Usage | undefined);
28
34
  }
29
- export declare function planCompaction(messages: AgentMessage[], keepRatio?: number): {
30
- keepFromIndex: number;
31
- };
35
+ export declare const DEFAULT_KEEP_RECENT_TOKENS = 20000;
36
+ export declare function planCompaction(messages: AgentMessage[], keepRecentTokens?: number): CompactionPlan;
32
37
  export declare const SUMMARY_PROMPT = "Summarize the conversation so far so that work can continue without the original transcript.\n\nPreserve, in this order:\n1. What the user asked for \u2014 the goal, in their terms, including any constraints they stated.\n2. Decisions taken and why, including approaches tried and rejected.\n3. Current task state: what is done, what is in progress, what remains.\n4. Concrete facts discovered that would be expensive to rediscover (file locations, API shapes, error messages, command invocations that work).\n5. Anything the user corrected you on.\n\nBe specific and factual. Do not include pleasantries or narration. This summary replaces the transcript, so anything you omit is lost.";
38
+ export declare function serializeCompactionMessages(messages: AgentMessage[]): string;
33
39
  export interface CompactorOptions {
34
40
  provider: Provider;
35
41
  model: ModelInfo;
36
42
  carryoverExtractor?: (messages: AgentMessage[]) => unknown;
37
- keepRatio?: number;
43
+ keepRecentTokens?: number;
44
+ customInstructions?: string;
38
45
  signal?: AbortSignal;
39
46
  streamOpts?: StreamOpts;
40
47
  }
@@ -34,6 +34,8 @@ export type StreamDelta = {
34
34
  toolCallId: string;
35
35
  };
36
36
  export type AgentEndReason = "done" | "aborted" | "budget" | "maxTurns" | "error";
37
+ export type CompactionTrigger = "manual" | "threshold" | "overflow" | "model-change";
38
+ export type CompactionStage = "clearing-tool-output" | "summarizing" | "installing";
37
39
  export type AgentEvent = {
38
40
  type: "agent_start";
39
41
  } | {
@@ -80,11 +82,25 @@ export type AgentEvent = {
80
82
  } | {
81
83
  type: "compaction_start";
82
84
  layer: 1 | 2 | 3;
85
+ trigger?: CompactionTrigger;
86
+ contextTokensBefore?: number;
87
+ } | {
88
+ type: "compaction_update";
89
+ layer: 1 | 2 | 3;
90
+ stage: CompactionStage;
91
+ toolResultsCleared?: number;
83
92
  } | {
84
93
  type: "compaction_end";
85
94
  layer: 1 | 2 | 3;
86
95
  tokensFreed: number;
87
96
  summaryEntryId?: string;
97
+ trigger?: CompactionTrigger;
98
+ status?: "completed" | "failed" | "cancelled" | "noop";
99
+ contextTokensBefore?: number;
100
+ contextTokensAfter?: number;
101
+ toolResultsCleared?: number;
102
+ keptTokens?: number;
103
+ errorMessage?: string;
88
104
  } | {
89
105
  type: "task_started";
90
106
  taskId: string;
@@ -2,9 +2,9 @@ export type { CheckpointDiffFile, CheckpointEntry, CheckpointProvider, } from ".
2
2
  export { CheckpointHistory } from "./checkpoint.js";
3
3
  export type { Command, CommandContext, CommandResult } from "./commands.js";
4
4
  export { CommandRegistry } from "./commands.js";
5
- export type { CompactionRequest, CompactionResult, CompactorOptions, ContextState, } from "./compaction.js";
6
- export { AUTO_COMPACT_THRESHOLD, applyCompaction, CompactionError, compact, compactionSummaryMessage, contextState, estimateTokens, formatCarryover, planCompaction, SUMMARY_PROMPT, shouldCompact, } from "./compaction.js";
7
- export type { AgentEndReason, AgentEvent, AgentEventType, EventSink, StreamDelta, } from "./events.js";
5
+ export type { CompactionPlan, CompactionRequest, CompactionResult, CompactorOptions, ContextState, } from "./compaction.js";
6
+ export { AUTO_COMPACT_THRESHOLD, applyCompaction, CompactionError, compact, compactionSummaryMessage, contextState, DEFAULT_KEEP_RECENT_TOKENS, estimateTokens, formatCarryover, planCompaction, SUMMARY_PROMPT, serializeCompactionMessages, shouldCompact, } from "./compaction.js";
7
+ export type { AgentEndReason, AgentEvent, AgentEventType, CompactionStage, CompactionTrigger, EventSink, StreamDelta, } from "./events.js";
8
8
  export type { Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, InputDirective, LifecycleEvent, LifecycleNotification, ToolCallDirective, ToolCallHookInfo, ToolRenderer, ToolResultDirective, ToolResultHookInfo, } from "./extensions.js";
9
9
  export { ExtensionHost } from "./extensions.js";
10
10
  export type { AfterToolCallInfo, AgentContext, AgentRunResult, BeforeToolCallInfo, ContextPreparation, LoopConfig, NextTurnDirective, TurnInfo, } from "./loop.js";
@@ -9,6 +9,7 @@ export interface PermissionRequest {
9
9
  id: string;
10
10
  toolCallId: string;
11
11
  toolName: string;
12
+ permission: string;
12
13
  pattern: string;
13
14
  description: string;
14
15
  preview?: PermissionPreview;
@@ -24,4 +25,4 @@ export interface ToolPermissionDetails {
24
25
  description?: string;
25
26
  preview?: PermissionPreview;
26
27
  }
27
- export declare function evaluate(rules: PermissionRule[], permission: string, pattern: string): PermissionAction;
28
+ export declare function evaluate(rules: PermissionRule[], permission: string | readonly string[], pattern: string): PermissionAction;
@@ -21,6 +21,15 @@ export type SessionEntry = {
21
21
  carryover?: unknown;
22
22
  firstKeptEntryId: string | null;
23
23
  timestamp?: number;
24
+ trigger?: "manual" | "threshold" | "overflow" | "model-change";
25
+ contextTokensBefore?: number;
26
+ contextTokensAfter?: number;
27
+ model?: string;
28
+ compactorModel?: string;
29
+ windowNumber?: number;
30
+ strategy?: "summary-tail";
31
+ keptTokens?: number;
32
+ toolResultsCleared?: number;
24
33
  } | {
25
34
  type: "microcompaction";
26
35
  id: string;
@@ -13,6 +13,8 @@ export interface Tool<Args = Record<string, unknown>> {
13
13
  isConcurrencySafe?: (args: Args) => boolean;
14
14
  executionMode?: "sequential";
15
15
  changesState?: boolean | ((args: Args) => boolean);
16
+ permissionScope?: (args: Args) => string;
17
+ permissionPattern?: (args: Args) => string;
16
18
  permissionDetails?: (args: Args) => ToolPermissionDetails | undefined | Promise<ToolPermissionDetails | undefined>;
17
19
  execute: (toolCallId: string, args: Args, signal: AbortSignal, onUpdate?: (partial: ToolResultContent[]) => void) => Promise<ToolResult>;
18
20
  }
@@ -22,6 +22,8 @@ export declare class ShadowCheckpointProvider implements CheckpointProvider {
22
22
  private env;
23
23
  private git;
24
24
  private ensure;
25
+ private ignoredDisposableDirectories;
26
+ private checkpointPathspecs;
25
27
  snapshot(label?: string): Promise<string | undefined>;
26
28
  restore(ref: string): Promise<void>;
27
29
  restoreResources(ref: string, resources: string[]): Promise<void>;
@@ -25,6 +25,7 @@ export { codingEnvironment, contextMessages, DEFAULT_INSTRUCTION_FALLBACKS, DEFA
25
25
  export { CODING_PERMISSION_DEFAULTS, CODING_PERMISSION_MODES, layerPermissions, loadProjectConfig, rememberAllow, } from "./permissions.js";
26
26
  export { codingPrompt } from "./prompts.js";
27
27
  export { shellCommand, terminateProcessTree, windowsTaskkillCommand } from "./shell.js";
28
+ export { classifyShellCommand, isInspectionShellCommand, parseInspectionCommands, type ShellCommandClassification, } from "./shell-inspection.js";
28
29
  export { FileState } from "./state.js";
29
30
  export { bashTool } from "./tools/bash.js";
30
31
  export { editTool, lsTool, readTool, resolveInRoot, writeTool } from "./tools/files.js";
@@ -0,0 +1,4 @@
1
+ export type ShellCommandClassification = "inspect" | "other";
2
+ export declare function parseInspectionCommands(source: string): string[][] | undefined;
3
+ export declare function classifyShellCommand(command: string): ShellCommandClassification;
4
+ export declare function isInspectionShellCommand(command: string): boolean;
@@ -46,6 +46,15 @@ export interface CheckpointActionResult {
46
46
  message: string;
47
47
  data?: CheckpointActionData;
48
48
  }
49
+ export interface ManualCompactionResult {
50
+ status: "completed" | "queued" | "failed" | "cancelled" | "noop";
51
+ message: string;
52
+ tokensBefore?: number;
53
+ tokensAfter?: number;
54
+ tokensFreed?: number;
55
+ toolResultsCleared?: number;
56
+ summaryEntryId?: string;
57
+ }
49
58
  export interface AgentRunOptions<T = unknown> {
50
59
  output?: z.ZodType<T>;
51
60
  model?: string | ModelInfo;
@@ -63,6 +72,11 @@ export declare class Agent {
63
72
  private followUps;
64
73
  private totals;
65
74
  private compactRequested;
75
+ private compactRequestedFocus;
76
+ private queuedManualCompactionFocus;
77
+ private manualCompactionQueued;
78
+ private compacting;
79
+ private compactorOverride;
66
80
  private lastContextPercent;
67
81
  private lastContextUsage;
68
82
  private readonly checkpoints;
@@ -88,7 +102,9 @@ export declare class Agent {
88
102
  get modelRef(): string;
89
103
  get contextWindow(): number;
90
104
  get thinking(): ThinkingLevel;
105
+ get thinkingLevels(): ThinkingLevel[];
91
106
  get isRunning(): boolean;
107
+ get isCompacting(): boolean;
92
108
  get permissions(): PermissionRule[];
93
109
  setPermissions(rules: PermissionRule[]): void;
94
110
  addPermissionRule(rule: PermissionRule): void;
@@ -106,7 +122,9 @@ export declare class Agent {
106
122
  stop(): void;
107
123
  shutdown(): Promise<void>;
108
124
  abort(): void;
109
- requestCompaction(): void;
125
+ requestCompaction(focus?: string): void;
126
+ compactNow(focus?: string): Promise<ManualCompactionResult>;
127
+ private executeManualCompaction;
110
128
  get checkpointHistory(): CheckpointHistory;
111
129
  undo(): Promise<CheckpointActionResult>;
112
130
  redo(): Promise<CheckpointActionResult>;
@@ -140,5 +158,6 @@ export declare class Agent {
140
158
  private providerFor;
141
159
  private publishToSubscribers;
142
160
  private scheduleAutonomousRun;
161
+ private scheduleManualCompaction;
143
162
  private resolveIdleIfDone;
144
163
  }
@@ -1,6 +1,6 @@
1
1
  import { type Usage } from "../ai/index.js";
2
2
  import { type CheckpointDiffFile, type Command, CommandRegistry } from "../core/index.js";
3
- import type { CheckpointActionResult } from "./agent.js";
3
+ import type { CheckpointActionResult, ManualCompactionResult } from "./agent.js";
4
4
  export interface ForkPoint {
5
5
  id: string;
6
6
  description: string;
@@ -10,7 +10,7 @@ export interface DiffCommandData {
10
10
  files: CheckpointDiffFile[];
11
11
  }
12
12
  export interface CoreCommandHooks {
13
- requestCompaction?: () => void;
13
+ requestCompaction?: (focus?: string) => ManualCompactionResult | undefined | Promise<ManualCompactionResult | undefined>;
14
14
  usage?: () => Usage & {
15
15
  contextPercent: number;
16
16
  };
@@ -1,8 +1,8 @@
1
1
  export type { Credential, ModelDiscoveryOptions, ModelInfo, Provider, ProviderModelDiscoveryOptions, ThinkingLevel, Usage, } from "../ai/index.js";
2
- export { builtinProviderConfigs, defaultModelRef, discoverModels, findModel, listModels, providerHasCredentials, refreshModels, registerModels, registerProvider, } from "../ai/index.js";
2
+ export { builtinProviderConfigs, defaultModelRef, defaultThinkingLevel, discoverModels, findModel, listModels, providerHasCredentials, refreshModels, registerModels, registerProvider, supportedThinkingLevels, thinkingLevelForModel, } from "../ai/index.js";
3
3
  export type { AgentEvent, AgentMessage, AnyTool, Command, CommandContext, CommandResult, CustomMessage, Extension, ExtensionAPI, ExtensionEvent, ExtensionEventFor, ExtensionEventType, LifecycleEvent, LifecycleNotification, PermissionMode, PermissionRequest, PermissionRule, ProfileRuntime, ProfileRuntimeHost, 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, HaltReason, RunResult, } from "./agent.js";
5
+ export type { AgentOptions, AgentRunOptions, CheckpointActionData, CheckpointActionResult, HaltReason, ManualCompactionResult, RunResult, } 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";
@@ -29,3 +29,5 @@ export { defaultSkillRoots, discoverSkills, loadSkill, skillListing, skillsExten
29
29
  export { STRUCTURED_OUTPUT_TOOL, structuredOutputPrompt, structuredOutputTool, } from "./structured-output.js";
30
30
  export type { ToolDefinition, ToolResult } from "./tool.js";
31
31
  export { tool } from "./tool.js";
32
+ export type { MarkdownTranscript, TranscriptMarkdownOptions, } from "./transcript-markdown.js";
33
+ export { sessionToMarkdown } from "./transcript-markdown.js";
@@ -8,6 +8,8 @@ export interface ToolDefinition<Schema extends z.ZodType> {
8
8
  isConcurrencySafe?: (args: z.infer<Schema>) => boolean;
9
9
  executionMode?: "sequential";
10
10
  changesState?: boolean | ((args: z.infer<Schema>) => boolean);
11
+ permissionScope?: (args: z.infer<Schema>) => string;
12
+ permissionPattern?: (args: z.infer<Schema>) => string;
11
13
  permissionDetails?: (args: z.infer<Schema>) => ToolPermissionDetails | undefined | Promise<ToolPermissionDetails | undefined>;
12
14
  execute: (args: z.infer<Schema>, ctx: {
13
15
  toolCallId: string;
@@ -0,0 +1,11 @@
1
+ import type { SessionTree } from "../core/index.js";
2
+ export interface TranscriptMarkdownOptions {
3
+ sessionId?: string;
4
+ model?: string;
5
+ exportedAt?: Date;
6
+ }
7
+ export interface MarkdownTranscript {
8
+ markdown: string;
9
+ messageCount: number;
10
+ }
11
+ export declare function sessionToMarkdown(session: SessionTree, options?: TranscriptMarkdownOptions): MarkdownTranscript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-agent/mu",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
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",
@@ -64,9 +64,9 @@
64
64
  "registry": "https://registry.npmjs.org/"
65
65
  },
66
66
  "devDependencies": {
67
- "@mu/profile-coding": "0.0.1",
68
- "@mu/tui": "0.0.1",
69
- "mu": "0.0.1",
70
- "@mu/core": "0.0.1"
67
+ "@mu/profile-coding": "workspace:*",
68
+ "@mu/tui": "workspace:*",
69
+ "mu": "workspace:*",
70
+ "@mu/core": "workspace:*"
71
71
  }
72
72
  }
@@ -1,5 +0,0 @@
1
- import type { AssistantStream } from "../stream.js";
2
- import type { LlmContext, ModelInfo, Provider, ProviderModelDiscoveryOptions, StreamOpts } from "../types.js";
3
- export declare function discoverRadiusModels(options: ProviderModelDiscoveryOptions): Promise<ModelInfo[] | undefined>;
4
- export declare function streamRadius(model: ModelInfo, context: LlmContext, opts?: StreamOpts): AssistantStream;
5
- export declare const radius: Provider;