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