@mu-agent/mu 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/THIRD_PARTY_LICENSES.txt +32 -0
- package/dist/index.js +226 -0
- package/dist/mu.js +397 -0
- package/dist/types/ai/auth.d.ts +2 -0
- package/dist/types/ai/catalog.d.ts +20 -0
- package/dist/types/ai/cost.d.ts +4 -0
- package/dist/types/ai/errors.d.ts +13 -0
- package/dist/types/ai/index.d.ts +22 -0
- package/dist/types/ai/json.d.ts +4 -0
- package/dist/types/ai/provider-config.d.ts +15 -0
- package/dist/types/ai/providers/anthropic.d.ts +4 -0
- package/dist/types/ai/providers/gemini.d.ts +4 -0
- package/dist/types/ai/providers/github-copilot.d.ts +2 -0
- package/dist/types/ai/providers/openai-completions.d.ts +4 -0
- package/dist/types/ai/providers/openai.d.ts +6 -0
- package/dist/types/ai/providers/radius.d.ts +5 -0
- package/dist/types/ai/providers/request.d.ts +6 -0
- package/dist/types/ai/providers/shared.d.ts +6 -0
- package/dist/types/ai/registry.d.ts +4 -0
- package/dist/types/ai/retry.d.ts +6 -0
- package/dist/types/ai/sse.d.ts +5 -0
- package/dist/types/ai/stream.d.ts +18 -0
- package/dist/types/ai/testing/replay.d.ts +31 -0
- package/dist/types/ai/types.d.ts +187 -0
- package/dist/types/core/checkpoint.d.ts +39 -0
- package/dist/types/core/commands.d.ts +30 -0
- package/dist/types/core/compaction.d.ts +45 -0
- package/dist/types/core/events.d.ts +109 -0
- package/dist/types/core/extensions.d.ts +97 -0
- package/dist/types/core/index.d.ts +27 -0
- package/dist/types/core/loop.d.ts +69 -0
- package/dist/types/core/messages.d.ts +15 -0
- package/dist/types/core/microcompaction.d.ts +14 -0
- package/dist/types/core/permission.d.ts +27 -0
- package/dist/types/core/process.d.ts +79 -0
- package/dist/types/core/profile.d.ts +46 -0
- package/dist/types/core/recovery.d.ts +14 -0
- package/dist/types/core/session.d.ts +103 -0
- package/dist/types/core/testing/fake-provider.d.ts +19 -0
- package/dist/types/core/tools.d.ts +22 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/profile-coding/checkpoint.d.ts +29 -0
- package/dist/types/profile-coding/context.d.ts +76 -0
- package/dist/types/profile-coding/index.d.ts +35 -0
- package/dist/types/profile-coding/permissions.d.ts +13 -0
- package/dist/types/profile-coding/prompts.d.ts +2 -0
- package/dist/types/profile-coding/shell.d.ts +12 -0
- package/dist/types/profile-coding/state.d.ts +10 -0
- package/dist/types/profile-coding/tools/bash.d.ts +21 -0
- package/dist/types/profile-coding/tools/files.d.ts +32 -0
- package/dist/types/profile-coding/tools/search.d.ts +23 -0
- package/dist/types/profile-coding/tools/tasks.d.ts +9 -0
- package/dist/types/profile-coding/tools/todo.d.ts +16 -0
- package/dist/types/profile-coding/truncate.d.ts +8 -0
- package/dist/types/sdk/agent.d.ts +144 -0
- package/dist/types/sdk/auth-page.d.ts +9 -0
- package/dist/types/sdk/auth.d.ts +78 -0
- package/dist/types/sdk/budget.d.ts +9 -0
- package/dist/types/sdk/commands.d.ts +30 -0
- package/dist/types/sdk/extension-loader.d.ts +15 -0
- package/dist/types/sdk/file-store.d.ts +13 -0
- package/dist/types/sdk/index.d.ts +31 -0
- package/dist/types/sdk/markdown-commands.d.ts +29 -0
- package/dist/types/sdk/mcp.d.ts +22 -0
- package/dist/types/sdk/profile.d.ts +6 -0
- package/dist/types/sdk/shell-hooks.d.ts +14 -0
- package/dist/types/sdk/skills.d.ts +12 -0
- package/dist/types/sdk/structured-output.d.ts +5 -0
- package/dist/types/sdk/testing/mcp-fixture-server.d.ts +1 -0
- package/dist/types/sdk/tool.d.ts +19 -0
- package/package.json +72 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ProcessManager, type Profile } from "../core/index.js";
|
|
2
|
+
import { InstructionLoader, type InstructionSettings } from "./context.js";
|
|
3
|
+
import { FileState } from "./state.js";
|
|
4
|
+
import { bashTool } from "./tools/bash.js";
|
|
5
|
+
import { TodoStore } from "./tools/todo.js";
|
|
6
|
+
export interface CodingProfileOptions {
|
|
7
|
+
root?: string;
|
|
8
|
+
spawn?: Parameters<typeof bashTool>[0]["spawn"];
|
|
9
|
+
spawner?: ConstructorParameters<typeof ProcessManager>[0];
|
|
10
|
+
processEvents?: ConstructorParameters<typeof ProcessManager>[1];
|
|
11
|
+
home?: string;
|
|
12
|
+
instructions?: InstructionSettings;
|
|
13
|
+
managedInstructionPaths?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface CodingProfile extends Profile {
|
|
16
|
+
fileState: FileState;
|
|
17
|
+
todos: TodoStore;
|
|
18
|
+
processes: ProcessManager;
|
|
19
|
+
instructions: InstructionLoader;
|
|
20
|
+
}
|
|
21
|
+
export declare function codingProfile(options?: CodingProfileOptions): Promise<CodingProfile>;
|
|
22
|
+
export type { GitRunner, ShadowCheckpointOptions } from "./checkpoint.js";
|
|
23
|
+
export { gitConfigNullDevice, ShadowCheckpointProvider } from "./checkpoint.js";
|
|
24
|
+
export { codingEnvironment, contextMessages, DEFAULT_INSTRUCTION_FALLBACKS, DEFAULT_INSTRUCTION_MAX_BYTES, DEFAULT_PROJECT_ROOT_MARKERS, discoverContextFiles, environmentMessage, type InstructionDiagnostic, InstructionLoader, type InstructionLoaderOptions, type InstructionSettings, type InstructionSnapshot, type InstructionSource, } from "./context.js";
|
|
25
|
+
export { CODING_PERMISSION_DEFAULTS, CODING_PERMISSION_MODES, layerPermissions, loadProjectConfig, rememberAllow, } from "./permissions.js";
|
|
26
|
+
export { codingPrompt } from "./prompts.js";
|
|
27
|
+
export { shellCommand, terminateProcessTree, windowsTaskkillCommand } from "./shell.js";
|
|
28
|
+
export { FileState } from "./state.js";
|
|
29
|
+
export { bashTool } from "./tools/bash.js";
|
|
30
|
+
export { editTool, lsTool, readTool, resolveInRoot, writeTool } from "./tools/files.js";
|
|
31
|
+
export { globTool, globToRegExp, grepTool, type RipgrepRunner, resolveNpmRipgrepExecutable, resolveRipgrepExecutable, type SearchToolOptions, } from "./tools/search.js";
|
|
32
|
+
export { shellSpawner, taskTools } from "./tools/tasks.js";
|
|
33
|
+
export type { TodoItem } from "./tools/todo.js";
|
|
34
|
+
export { renderTodos, TodoStore, todoTool } from "./tools/todo.js";
|
|
35
|
+
export { MAX_OUTPUT_CHARS, truncateOutput, withNotice } from "./truncate.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PermissionMode, PermissionRule } from "../core/index.js";
|
|
2
|
+
import type { InstructionSettings } from "./context.js";
|
|
3
|
+
export declare const CODING_PERMISSION_DEFAULTS: PermissionRule[];
|
|
4
|
+
export declare const CODING_PERMISSION_MODES: PermissionMode[];
|
|
5
|
+
export interface ProjectConfig {
|
|
6
|
+
permissions?: PermissionRule[];
|
|
7
|
+
model?: string;
|
|
8
|
+
instructions?: InstructionSettings;
|
|
9
|
+
}
|
|
10
|
+
export declare function configPath(root: string): string;
|
|
11
|
+
export declare function loadProjectConfig(root: string): Promise<ProjectConfig>;
|
|
12
|
+
export declare function layerPermissions(...layers: (PermissionRule[] | undefined)[]): PermissionRule[];
|
|
13
|
+
export declare function rememberAllow(root: string, permission: string, pattern: string): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ShellCommandOptions {
|
|
2
|
+
platform?: NodeJS.Platform;
|
|
3
|
+
interactive?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface ProcessTreeTarget {
|
|
6
|
+
pid: number;
|
|
7
|
+
exitCode: number | null;
|
|
8
|
+
kill(signal?: NodeJS.Signals | number): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function shellCommand(command: string, options?: ShellCommandOptions): string[];
|
|
11
|
+
export declare function windowsTaskkillCommand(pid: number): string[];
|
|
12
|
+
export declare function terminateProcessTree(process: ProcessTreeTarget, signal: NodeJS.Signals, platform?: NodeJS.Platform): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class FileState {
|
|
2
|
+
private reads;
|
|
3
|
+
private modified;
|
|
4
|
+
markRead(path: string): void;
|
|
5
|
+
markWritten(path: string): void;
|
|
6
|
+
hasRead(path: string): boolean;
|
|
7
|
+
isStale(path: string): boolean;
|
|
8
|
+
readFiles(): string[];
|
|
9
|
+
modifiedFiles(): string[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ProcessManager } from "../../core/index.js";
|
|
2
|
+
type OutputStream = "stdout" | "stderr";
|
|
3
|
+
type OutputChunk = (text: string, stream: OutputStream) => void;
|
|
4
|
+
interface SpawnResult {
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
exitCode: number | null;
|
|
8
|
+
timedOut: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface BashDeps {
|
|
11
|
+
root: string;
|
|
12
|
+
processes?: ProcessManager;
|
|
13
|
+
spawn?: (command: string, cwd: string, signal: AbortSignal, timeoutMs: number, onOutput?: OutputChunk) => Promise<SpawnResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare function bashTool(deps: BashDeps): import("../../sdk/index.js").Tool<{
|
|
16
|
+
command: string;
|
|
17
|
+
description?: string | undefined;
|
|
18
|
+
timeoutMs?: number | undefined;
|
|
19
|
+
run_in_background?: boolean | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type CheckpointDiffFile } from "../../core/index.js";
|
|
2
|
+
import type { FileState } from "../state.js";
|
|
3
|
+
export interface ToolDeps {
|
|
4
|
+
root: string;
|
|
5
|
+
state: FileState;
|
|
6
|
+
instructions?: {
|
|
7
|
+
instructionsForPath: (path: string) => Promise<{
|
|
8
|
+
text: string;
|
|
9
|
+
sources: string[];
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function resolveInRoot(root: string, path: string): string;
|
|
14
|
+
export declare function filePermissionDiff(path: string, before: string | undefined, after: string): CheckpointDiffFile;
|
|
15
|
+
export declare function readTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
|
|
16
|
+
path: string;
|
|
17
|
+
offset?: number | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function writeTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
|
|
21
|
+
path: string;
|
|
22
|
+
content: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function editTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
|
|
25
|
+
path: string;
|
|
26
|
+
oldString: string;
|
|
27
|
+
newString: string;
|
|
28
|
+
replaceAll?: boolean | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function lsTool(deps: ToolDeps): import("../../sdk/index.js").Tool<{
|
|
31
|
+
path?: string | undefined;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ToolDeps } from "./files.js";
|
|
2
|
+
export interface RipgrepRunResult {
|
|
3
|
+
exitCode: number;
|
|
4
|
+
stderr: string;
|
|
5
|
+
stopped: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type RipgrepRunner = (args: string[], cwd: string, signal: AbortSignal, onLine: (line: string) => boolean) => Promise<RipgrepRunResult | undefined>;
|
|
8
|
+
export interface SearchToolOptions {
|
|
9
|
+
ripgrep?: RipgrepRunner | false;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveNpmRipgrepExecutable(platform?: NodeJS.Platform, architecture?: NodeJS.Architecture, from?: string, resolvePackage?: (specifier: string, from: string) => string): string | undefined;
|
|
12
|
+
export declare function resolveRipgrepExecutable(execPath?: string, platform?: NodeJS.Platform, which?: (command: string) => string | null, resolveNpm?: () => string | undefined): string | undefined;
|
|
13
|
+
export declare function globToRegExp(pattern: string): RegExp;
|
|
14
|
+
export declare function globTool(deps: ToolDeps, options?: SearchToolOptions): import("../../sdk/index.js").Tool<{
|
|
15
|
+
pattern: string;
|
|
16
|
+
path?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function grepTool(deps: ToolDeps, options?: SearchToolOptions): import("../../sdk/index.js").Tool<{
|
|
19
|
+
pattern: string;
|
|
20
|
+
path?: string | undefined;
|
|
21
|
+
include?: string | undefined;
|
|
22
|
+
ignoreCase?: boolean | undefined;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ProcessManager, type Spawner } from "../../core/index.js";
|
|
2
|
+
export declare function shellSpawner(root: string): Spawner;
|
|
3
|
+
export declare function taskTools(manager: ProcessManager): (import("../../sdk/index.js").Tool<{
|
|
4
|
+
taskId: string;
|
|
5
|
+
full?: boolean | undefined;
|
|
6
|
+
}> | import("../../sdk/index.js").Tool<{
|
|
7
|
+
taskId: string;
|
|
8
|
+
data: string;
|
|
9
|
+
}> | import("../../sdk/index.js").Tool<Record<string, never>>)[];
|
|
@@ -0,0 +1,16 @@
|
|
|
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("../../sdk/index.js").Tool<{
|
|
12
|
+
items: {
|
|
13
|
+
content: string;
|
|
14
|
+
status: "completed" | "pending" | "in_progress";
|
|
15
|
+
}[];
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const MAX_OUTPUT_CHARS = 30000;
|
|
2
|
+
export declare const MAX_OUTPUT_LINES = 1000;
|
|
3
|
+
export interface TruncationResult {
|
|
4
|
+
text: string;
|
|
5
|
+
truncated: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function truncateOutput(text: string, maxChars?: number, maxLines?: number): TruncationResult;
|
|
8
|
+
export declare function withNotice(result: TruncationResult, what: string): string;
|
|
@@ -0,0 +1,144 @@
|
|
|
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 EventSink, type ExtensionHost, type PermissionRequest, type PermissionRule, type ProfileRuntime, type SessionStore, SessionTree, type UserContent } from "../core/index.js";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import { type Budget } from "./budget.js";
|
|
5
|
+
export type HaltReason = "done" | "aborted" | "error" | "maxTurns" | "maxCostUsd" | "maxTokens";
|
|
6
|
+
export interface AgentOptions {
|
|
7
|
+
model?: string | ModelInfo;
|
|
8
|
+
provider?: Provider;
|
|
9
|
+
systemPrompt?: string | PromptSection[];
|
|
10
|
+
tools?: AnyTool[];
|
|
11
|
+
permissions?: PermissionRule[];
|
|
12
|
+
onPermission?: (request: PermissionRequest) => Promise<"allow" | "deny">;
|
|
13
|
+
budget?: Budget;
|
|
14
|
+
session?: SessionStore;
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
thinkingLevel?: ThinkingLevel;
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
getCredentials?: (provider: string) => Promise<Credential | undefined>;
|
|
19
|
+
initialMessages?: AgentMessage[];
|
|
20
|
+
refreshContext?: (messages: AgentMessage[], context: {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
}) => Promise<AgentMessage[]> | AgentMessage[];
|
|
23
|
+
carryoverExtractor?: (messages: AgentMessage[]) => unknown;
|
|
24
|
+
autoCompact?: boolean;
|
|
25
|
+
compactThreshold?: number;
|
|
26
|
+
checkpointProvider?: CheckpointProvider;
|
|
27
|
+
runtime?: ProfileRuntime;
|
|
28
|
+
extensions?: ExtensionHost;
|
|
29
|
+
}
|
|
30
|
+
export interface RunResult {
|
|
31
|
+
text: string;
|
|
32
|
+
messages: AgentMessage[];
|
|
33
|
+
usage: Usage;
|
|
34
|
+
reason: HaltReason;
|
|
35
|
+
sessionId: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CheckpointActionData {
|
|
38
|
+
kind: "checkpoint";
|
|
39
|
+
action: "undo" | "redo";
|
|
40
|
+
files: CheckpointDiffFile[];
|
|
41
|
+
messageCount: number;
|
|
42
|
+
prompt?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CheckpointActionResult {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
message: string;
|
|
47
|
+
data?: CheckpointActionData;
|
|
48
|
+
}
|
|
49
|
+
export interface AgentRunOptions<T = unknown> {
|
|
50
|
+
output?: z.ZodType<T>;
|
|
51
|
+
model?: string | ModelInfo;
|
|
52
|
+
allowedTools?: string[];
|
|
53
|
+
}
|
|
54
|
+
export declare class Agent {
|
|
55
|
+
private readonly options;
|
|
56
|
+
private model;
|
|
57
|
+
private provider;
|
|
58
|
+
private readonly store;
|
|
59
|
+
private tree;
|
|
60
|
+
private _sessionId;
|
|
61
|
+
private controller;
|
|
62
|
+
private steering;
|
|
63
|
+
private followUps;
|
|
64
|
+
private totals;
|
|
65
|
+
private compactRequested;
|
|
66
|
+
private lastContextPercent;
|
|
67
|
+
private lastContextUsage;
|
|
68
|
+
private readonly checkpoints;
|
|
69
|
+
private recoveryAttempted;
|
|
70
|
+
private reactiveRecoveryPending;
|
|
71
|
+
private pendingCheckpoint;
|
|
72
|
+
private currentThinking;
|
|
73
|
+
private running;
|
|
74
|
+
private stopping;
|
|
75
|
+
private activeEmit;
|
|
76
|
+
private activeExecution;
|
|
77
|
+
private autonomousScheduled;
|
|
78
|
+
private readonly subscribers;
|
|
79
|
+
private readonly idleWaiters;
|
|
80
|
+
private shutdownPromise;
|
|
81
|
+
private sessionStarted;
|
|
82
|
+
private permissionRules;
|
|
83
|
+
constructor(options?: AgentOptions);
|
|
84
|
+
get sessionId(): string;
|
|
85
|
+
get usage(): Usage;
|
|
86
|
+
get session(): SessionTree;
|
|
87
|
+
get sessionStore(): SessionStore;
|
|
88
|
+
get modelRef(): string;
|
|
89
|
+
get contextWindow(): number;
|
|
90
|
+
get thinking(): ThinkingLevel;
|
|
91
|
+
get isRunning(): boolean;
|
|
92
|
+
get permissions(): PermissionRule[];
|
|
93
|
+
setPermissions(rules: PermissionRule[]): void;
|
|
94
|
+
addPermissionRule(rule: PermissionRule): void;
|
|
95
|
+
setModel(ref: string | ModelInfo): void;
|
|
96
|
+
setThinking(level: ThinkingLevel): void;
|
|
97
|
+
resume(tree: SessionTree): void;
|
|
98
|
+
newSession(sessionId?: string): void;
|
|
99
|
+
send(message: string): void;
|
|
100
|
+
followUp(message: string): void;
|
|
101
|
+
removeQueuedMessage(kind: "steer" | "follow-up", text: string): boolean;
|
|
102
|
+
emitTaskEvent(event: AgentEvent): void;
|
|
103
|
+
subscribe(listener: EventSink): () => void;
|
|
104
|
+
resize(cols: number, rows: number): void;
|
|
105
|
+
waitForIdle(): Promise<void>;
|
|
106
|
+
stop(): void;
|
|
107
|
+
shutdown(): Promise<void>;
|
|
108
|
+
abort(): void;
|
|
109
|
+
requestCompaction(): void;
|
|
110
|
+
get checkpointHistory(): CheckpointHistory;
|
|
111
|
+
undo(): Promise<CheckpointActionResult>;
|
|
112
|
+
redo(): Promise<CheckpointActionResult>;
|
|
113
|
+
sessionDiff(): Promise<Awaited<ReturnType<CheckpointProvider["diff"]>>>;
|
|
114
|
+
forkPoints(): {
|
|
115
|
+
id: string;
|
|
116
|
+
description: string;
|
|
117
|
+
}[];
|
|
118
|
+
fork(entryId: string): Promise<{
|
|
119
|
+
ok: boolean;
|
|
120
|
+
message: string;
|
|
121
|
+
}>;
|
|
122
|
+
get contextPercent(): number;
|
|
123
|
+
run<T>(prompt: string | UserContent[], opts: AgentRunOptions<T> & {
|
|
124
|
+
output: z.ZodType<T>;
|
|
125
|
+
}): Promise<RunResult & {
|
|
126
|
+
output: T;
|
|
127
|
+
}>;
|
|
128
|
+
run(prompt: string | UserContent[], opts?: AgentRunOptions): Promise<RunResult>;
|
|
129
|
+
stream(prompt: string | UserContent[], opts?: AgentRunOptions): AsyncIterable<AgentEvent> & {
|
|
130
|
+
result(): Promise<RunResult>;
|
|
131
|
+
};
|
|
132
|
+
private beginCheckpoint;
|
|
133
|
+
private finishCheckpoint;
|
|
134
|
+
private appendCheckpointCursor;
|
|
135
|
+
private restoreCheckpointResources;
|
|
136
|
+
private checkpointDetails;
|
|
137
|
+
private rebuildCheckpointHistory;
|
|
138
|
+
private execute;
|
|
139
|
+
private executeRun;
|
|
140
|
+
private providerFor;
|
|
141
|
+
private publishToSubscribers;
|
|
142
|
+
private scheduleAutonomousRun;
|
|
143
|
+
private resolveIdleIfDone;
|
|
144
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface AuthPageOptions {
|
|
2
|
+
provider: string;
|
|
3
|
+
status: "success" | "error";
|
|
4
|
+
heading: string;
|
|
5
|
+
detail: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function renderAuthPage(options: AuthPageOptions): string;
|
|
8
|
+
export declare function authSuccessPage(provider: string): string;
|
|
9
|
+
export declare function authErrorPage(provider: string, detail: string): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Credential } from "../ai/index.js";
|
|
2
|
+
export interface StoredApiKey {
|
|
3
|
+
type: "apiKey";
|
|
4
|
+
apiKey: string;
|
|
5
|
+
}
|
|
6
|
+
export interface StoredOpenAiOAuth {
|
|
7
|
+
type: "oauth";
|
|
8
|
+
accessToken: string;
|
|
9
|
+
refreshToken: string;
|
|
10
|
+
idToken?: string;
|
|
11
|
+
expiresAt: number;
|
|
12
|
+
accountId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface StoredPlanOAuth {
|
|
15
|
+
type: "oauth";
|
|
16
|
+
accessToken: string;
|
|
17
|
+
refreshToken: string;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
accountId?: string;
|
|
20
|
+
idToken?: string;
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
availableModelIds?: string[];
|
|
23
|
+
}
|
|
24
|
+
export type StoredCredential = StoredApiKey | StoredPlanOAuth;
|
|
25
|
+
export interface AuthFile {
|
|
26
|
+
version: 1;
|
|
27
|
+
activeProvider?: string;
|
|
28
|
+
providers: Record<string, StoredCredential>;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthStoreOptions {
|
|
31
|
+
authFile?: string;
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
now?: () => number;
|
|
34
|
+
openAiIssuer?: string;
|
|
35
|
+
openAiClientId?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface OpenAiLoginOptions extends AuthStoreOptions {
|
|
38
|
+
port?: number;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
onAuthUrl?: (url: string) => void | Promise<void>;
|
|
42
|
+
callbackServer?: (state: string, signal: AbortSignal) => Promise<OpenAiCallbackServer>;
|
|
43
|
+
}
|
|
44
|
+
export interface OpenAiLoginResult {
|
|
45
|
+
provider: "openai-codex";
|
|
46
|
+
accountId: string;
|
|
47
|
+
}
|
|
48
|
+
export interface PlanLoginOptions extends AuthStoreOptions {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
onAuthUrl?: (url: string) => void | Promise<void>;
|
|
51
|
+
onDeviceCode?: (url: string, code: string) => void | Promise<void>;
|
|
52
|
+
callbackServer?: (provider: string, signal?: AbortSignal) => Promise<PlanLoginCallbackServer>;
|
|
53
|
+
}
|
|
54
|
+
export interface PlanLoginResult {
|
|
55
|
+
provider: "github-copilot" | "kimi-coding" | "openrouter" | "xai";
|
|
56
|
+
}
|
|
57
|
+
export interface PlanLoginCallbackServer {
|
|
58
|
+
callbackUrl: string;
|
|
59
|
+
code: Promise<string>;
|
|
60
|
+
close: () => void;
|
|
61
|
+
}
|
|
62
|
+
export interface OpenAiCallbackServer {
|
|
63
|
+
redirectUri: string;
|
|
64
|
+
callback: Promise<string>;
|
|
65
|
+
close: () => void;
|
|
66
|
+
}
|
|
67
|
+
export declare function defaultAuthFile(): string;
|
|
68
|
+
export declare function readAuthFile(options?: AuthStoreOptions): Promise<AuthFile>;
|
|
69
|
+
export declare function saveApiKey(provider: string, apiKey: string, options?: AuthStoreOptions): Promise<void>;
|
|
70
|
+
export declare function removeStoredCredential(provider: string, options?: AuthStoreOptions): Promise<boolean>;
|
|
71
|
+
export declare function storedAuthProviders(options?: AuthStoreOptions): Promise<string[]>;
|
|
72
|
+
export declare function preferredAuthProvider(options?: AuthStoreOptions): Promise<string | undefined>;
|
|
73
|
+
export declare function createCredentialResolver(options?: AuthStoreOptions): (provider: string) => Promise<Credential | undefined>;
|
|
74
|
+
export declare function loginOpenAI(options?: OpenAiLoginOptions): Promise<OpenAiLoginResult>;
|
|
75
|
+
export declare function loginKimiCoding(options?: PlanLoginOptions): Promise<PlanLoginResult>;
|
|
76
|
+
export declare function loginXai(options?: PlanLoginOptions): Promise<PlanLoginResult>;
|
|
77
|
+
export declare function loginGitHubCopilot(options?: PlanLoginOptions): Promise<PlanLoginResult>;
|
|
78
|
+
export declare function loginOpenRouter(options?: PlanLoginOptions): Promise<PlanLoginResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Usage } from "../ai/index.js";
|
|
2
|
+
export interface Budget {
|
|
3
|
+
maxTurns?: number;
|
|
4
|
+
maxCostUsd?: number;
|
|
5
|
+
maxTokens?: number;
|
|
6
|
+
}
|
|
7
|
+
export type BudgetBreach = "maxCostUsd" | "maxTokens";
|
|
8
|
+
export declare function totalTokens(usage: Usage): number;
|
|
9
|
+
export declare function checkBudget(budget: Budget | undefined, usage: Usage): BudgetBreach | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Usage } from "../ai/index.js";
|
|
2
|
+
import { type CheckpointDiffFile, type Command, CommandRegistry } from "../core/index.js";
|
|
3
|
+
import type { CheckpointActionResult } from "./agent.js";
|
|
4
|
+
export interface ForkPoint {
|
|
5
|
+
id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DiffCommandData {
|
|
9
|
+
kind: "diff";
|
|
10
|
+
files: CheckpointDiffFile[];
|
|
11
|
+
}
|
|
12
|
+
export interface CoreCommandHooks {
|
|
13
|
+
requestCompaction?: () => void;
|
|
14
|
+
usage?: () => Usage & {
|
|
15
|
+
contextPercent: number;
|
|
16
|
+
};
|
|
17
|
+
undo?: () => Promise<CheckpointActionResult>;
|
|
18
|
+
redo?: () => Promise<CheckpointActionResult>;
|
|
19
|
+
fork?: (entryId: string) => Promise<{
|
|
20
|
+
ok: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
}>;
|
|
23
|
+
forkPoints?: () => ForkPoint[];
|
|
24
|
+
diff?: () => Promise<CheckpointDiffFile[]>;
|
|
25
|
+
}
|
|
26
|
+
export declare function formatUsageBreakdown(usage: Usage & {
|
|
27
|
+
contextPercent: number;
|
|
28
|
+
}): string;
|
|
29
|
+
export declare function coreCommands(hooks?: CoreCommandHooks): Command[];
|
|
30
|
+
export declare function registryWithCoreCommands(hooks?: CoreCommandHooks): CommandRegistry;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtensionHost } from "../core/index.js";
|
|
2
|
+
export interface LoadOptions {
|
|
3
|
+
paths?: string[];
|
|
4
|
+
userDir?: boolean;
|
|
5
|
+
projectDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveExtensionFiles(options?: LoadOptions): Promise<string[]>;
|
|
8
|
+
export interface LoadReport {
|
|
9
|
+
loaded: string[];
|
|
10
|
+
failed: {
|
|
11
|
+
file: string;
|
|
12
|
+
error: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export declare function loadExtensions(host: ExtensionHost, options?: LoadOptions): Promise<LoadReport>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SessionStore, SessionTree } from "../core/index.js";
|
|
2
|
+
export interface FileSessionStoreOptions {
|
|
3
|
+
root?: string;
|
|
4
|
+
scope?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class FileSessionStore implements SessionStore {
|
|
7
|
+
private readonly dir;
|
|
8
|
+
constructor(options?: FileSessionStoreOptions);
|
|
9
|
+
private path;
|
|
10
|
+
load(sessionId: string): Promise<SessionTree | undefined>;
|
|
11
|
+
save(sessionId: string, tree: SessionTree): Promise<void>;
|
|
12
|
+
list(): Promise<string[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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";
|
|
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
|
+
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";
|
|
6
|
+
export { Agent } from "./agent.js";
|
|
7
|
+
export type { AuthFile, AuthStoreOptions, OpenAiCallbackServer, OpenAiLoginOptions, OpenAiLoginResult, PlanLoginCallbackServer, PlanLoginOptions, PlanLoginResult, StoredApiKey, StoredCredential, StoredOpenAiOAuth, StoredPlanOAuth, } from "./auth.js";
|
|
8
|
+
export { createCredentialResolver, defaultAuthFile, loginGitHubCopilot, loginKimiCoding, loginOpenAI, loginOpenRouter, loginXai, preferredAuthProvider, readAuthFile, removeStoredCredential, saveApiKey, storedAuthProviders, } from "./auth.js";
|
|
9
|
+
export type { AuthPageOptions } from "./auth-page.js";
|
|
10
|
+
export { authErrorPage, authSuccessPage, renderAuthPage } from "./auth-page.js";
|
|
11
|
+
export type { Budget, BudgetBreach } from "./budget.js";
|
|
12
|
+
export { checkBudget, totalTokens } from "./budget.js";
|
|
13
|
+
export type { DiffCommandData, ForkPoint } from "./commands.js";
|
|
14
|
+
export { coreCommands, registryWithCoreCommands } from "./commands.js";
|
|
15
|
+
export type { LoadOptions, LoadReport } from "./extension-loader.js";
|
|
16
|
+
export { loadExtensions, resolveExtensionFiles } from "./extension-loader.js";
|
|
17
|
+
export type { FileSessionStoreOptions } from "./file-store.js";
|
|
18
|
+
export { FileSessionStore } from "./file-store.js";
|
|
19
|
+
export type { MarkdownCommand, MarkdownCommandOptions, MarkdownCommandRun, } from "./markdown-commands.js";
|
|
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";
|
|
23
|
+
export type { Profile, ProfileImporter } from "./profile.js";
|
|
24
|
+
export { loadProfile, optionsFromProfile } from "./profile.js";
|
|
25
|
+
export type { HookEvent, HookRunner, HookSpec } from "./shell-hooks.js";
|
|
26
|
+
export { shellHooksExtension } from "./shell-hooks.js";
|
|
27
|
+
export type { Skill } from "./skills.js";
|
|
28
|
+
export { defaultSkillRoots, discoverSkills, loadSkill, skillListing, skillsExtension, } from "./skills.js";
|
|
29
|
+
export { STRUCTURED_OUTPUT_TOOL, structuredOutputPrompt, structuredOutputTool, } from "./structured-output.js";
|
|
30
|
+
export type { ToolDefinition, ToolResult } from "./tool.js";
|
|
31
|
+
export { tool } from "./tool.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Command } from "../core/index.js";
|
|
2
|
+
export interface MarkdownCommand {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
body: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
allowedTools?: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface MarkdownCommandRun {
|
|
10
|
+
kind: "markdown-command";
|
|
11
|
+
prompt: string;
|
|
12
|
+
model?: string;
|
|
13
|
+
allowedTools?: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function parseFrontmatter(source: string): {
|
|
16
|
+
meta: Record<string, string | string[]>;
|
|
17
|
+
body: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function substituteArguments(body: string, args: string): string;
|
|
20
|
+
export declare function parseMarkdownCommand(name: string, source: string): MarkdownCommand;
|
|
21
|
+
export interface MarkdownCommandOptions {
|
|
22
|
+
userDir?: string;
|
|
23
|
+
projectDir?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function loadMarkdownCommands(options?: MarkdownCommandOptions): Promise<MarkdownCommand[]>;
|
|
26
|
+
export declare function toCommand(markdown: MarkdownCommand, submit?: (prompt: string, options: {
|
|
27
|
+
model?: string;
|
|
28
|
+
allowedTools?: string[];
|
|
29
|
+
}) => unknown | Promise<unknown>): Command;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {
|
|
18
|
+
projectDir?: string;
|
|
19
|
+
userFile?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function loadMcpConfig(options?: LoadMcpConfigOptions): Promise<McpConfigReport>;
|
|
22
|
+
export declare function mcpExtension(servers: Record<string, McpStdioServerConfig>): Extension;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Profile } from "../core/index.js";
|
|
2
|
+
import type { AgentOptions } from "./agent.js";
|
|
3
|
+
export type { Profile };
|
|
4
|
+
export declare function optionsFromProfile(profile: Profile, modelRef: string, overrides?: AgentOptions): Promise<AgentOptions>;
|
|
5
|
+
export type ProfileImporter = (specifier: string) => Promise<Record<string, unknown>>;
|
|
6
|
+
export declare function loadProfile(name: string, options?: Record<string, unknown>, importer?: ProfileImporter): Promise<Profile>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Extension } from "../core/index.js";
|
|
2
|
+
export type HookEvent = "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "SessionStart" | "Stop";
|
|
3
|
+
export interface HookSpec {
|
|
4
|
+
event: HookEvent;
|
|
5
|
+
command: string;
|
|
6
|
+
matcher?: string;
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export type HookRunner = (command: string, input: string, timeoutMs: number) => Promise<{
|
|
10
|
+
exitCode: number;
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function shellHooksExtension(hooks: HookSpec[], runner?: HookRunner): Extension;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Extension } from "../core/index.js";
|
|
2
|
+
export interface Skill {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
body: string;
|
|
6
|
+
directory: string;
|
|
7
|
+
}
|
|
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[];
|
|
11
|
+
export declare function skillListing(skills: Skill[]): string;
|
|
12
|
+
export declare function skillsExtension(skills: Skill[]): Extension;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyTool } from "../core/index.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const STRUCTURED_OUTPUT_TOOL = "structured_output";
|
|
4
|
+
export declare function structuredOutputTool<Schema extends z.ZodType>(schema: Schema, capture: (value: z.infer<Schema>) => void): AnyTool;
|
|
5
|
+
export declare function structuredOutputPrompt(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|