@open-multi-agent/core 1.4.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/LICENSE +21 -0
- package/README.md +373 -0
- package/dist/agent/agent.d.ts +153 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +559 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/loop-detector.d.ts +39 -0
- package/dist/agent/loop-detector.d.ts.map +1 -0
- package/dist/agent/loop-detector.js +122 -0
- package/dist/agent/loop-detector.js.map +1 -0
- package/dist/agent/pool.d.ts +158 -0
- package/dist/agent/pool.d.ts.map +1 -0
- package/dist/agent/pool.js +320 -0
- package/dist/agent/pool.js.map +1 -0
- package/dist/agent/runner.d.ts +242 -0
- package/dist/agent/runner.d.ts.map +1 -0
- package/dist/agent/runner.js +943 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/structured-output.d.ts +33 -0
- package/dist/agent/structured-output.d.ts.map +1 -0
- package/dist/agent/structured-output.js +116 -0
- package/dist/agent/structured-output.js.map +1 -0
- package/dist/cli/oma.d.ts +30 -0
- package/dist/cli/oma.d.ts.map +1 -0
- package/dist/cli/oma.js +433 -0
- package/dist/cli/oma.js.map +1 -0
- package/dist/dashboard/layout-tasks.d.ts +23 -0
- package/dist/dashboard/layout-tasks.d.ts.map +1 -0
- package/dist/dashboard/layout-tasks.js +79 -0
- package/dist/dashboard/layout-tasks.js.map +1 -0
- package/dist/dashboard/render-team-run-dashboard.d.ts +11 -0
- package/dist/dashboard/render-team-run-dashboard.d.ts.map +1 -0
- package/dist/dashboard/render-team-run-dashboard.js +456 -0
- package/dist/dashboard/render-team-run-dashboard.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/adapter.d.ts +54 -0
- package/dist/llm/adapter.d.ts.map +1 -0
- package/dist/llm/adapter.js +101 -0
- package/dist/llm/adapter.js.map +1 -0
- package/dist/llm/anthropic.d.ts +57 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +432 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/azure-openai.d.ts +74 -0
- package/dist/llm/azure-openai.d.ts.map +1 -0
- package/dist/llm/azure-openai.js +267 -0
- package/dist/llm/azure-openai.js.map +1 -0
- package/dist/llm/bedrock.d.ts +41 -0
- package/dist/llm/bedrock.d.ts.map +1 -0
- package/dist/llm/bedrock.js +345 -0
- package/dist/llm/bedrock.js.map +1 -0
- package/dist/llm/copilot.d.ts +92 -0
- package/dist/llm/copilot.d.ts.map +1 -0
- package/dist/llm/copilot.js +433 -0
- package/dist/llm/copilot.js.map +1 -0
- package/dist/llm/deepseek.d.ts +21 -0
- package/dist/llm/deepseek.d.ts.map +1 -0
- package/dist/llm/deepseek.js +24 -0
- package/dist/llm/deepseek.js.map +1 -0
- package/dist/llm/gemini.d.ts +65 -0
- package/dist/llm/gemini.d.ts.map +1 -0
- package/dist/llm/gemini.js +427 -0
- package/dist/llm/gemini.js.map +1 -0
- package/dist/llm/grok.d.ts +21 -0
- package/dist/llm/grok.d.ts.map +1 -0
- package/dist/llm/grok.js +24 -0
- package/dist/llm/grok.js.map +1 -0
- package/dist/llm/minimax.d.ts +21 -0
- package/dist/llm/minimax.d.ts.map +1 -0
- package/dist/llm/minimax.js +24 -0
- package/dist/llm/minimax.js.map +1 -0
- package/dist/llm/openai-common.d.ts +65 -0
- package/dist/llm/openai-common.d.ts.map +1 -0
- package/dist/llm/openai-common.js +286 -0
- package/dist/llm/openai-common.js.map +1 -0
- package/dist/llm/openai.d.ts +63 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +256 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/qiniu.d.ts +21 -0
- package/dist/llm/qiniu.d.ts.map +1 -0
- package/dist/llm/qiniu.js +24 -0
- package/dist/llm/qiniu.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +2 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory/shared.d.ts +162 -0
- package/dist/memory/shared.d.ts.map +1 -0
- package/dist/memory/shared.js +294 -0
- package/dist/memory/shared.js.map +1 -0
- package/dist/memory/store.d.ts +72 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +121 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +245 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +1400 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator/scheduler.d.ts +112 -0
- package/dist/orchestrator/scheduler.d.ts.map +1 -0
- package/dist/orchestrator/scheduler.js +256 -0
- package/dist/orchestrator/scheduler.js.map +1 -0
- package/dist/task/queue.d.ts +191 -0
- package/dist/task/queue.d.ts.map +1 -0
- package/dist/task/queue.js +408 -0
- package/dist/task/queue.js.map +1 -0
- package/dist/task/task.d.ts +90 -0
- package/dist/task/task.d.ts.map +1 -0
- package/dist/task/task.js +206 -0
- package/dist/task/task.js.map +1 -0
- package/dist/team/messaging.d.ts +106 -0
- package/dist/team/messaging.d.ts.map +1 -0
- package/dist/team/messaging.js +183 -0
- package/dist/team/messaging.js.map +1 -0
- package/dist/team/team.d.ts +141 -0
- package/dist/team/team.d.ts.map +1 -0
- package/dist/team/team.js +293 -0
- package/dist/team/team.js.map +1 -0
- package/dist/tool/built-in/bash.d.ts +12 -0
- package/dist/tool/built-in/bash.d.ts.map +1 -0
- package/dist/tool/built-in/bash.js +133 -0
- package/dist/tool/built-in/bash.js.map +1 -0
- package/dist/tool/built-in/delegate.d.ts +29 -0
- package/dist/tool/built-in/delegate.d.ts.map +1 -0
- package/dist/tool/built-in/delegate.js +92 -0
- package/dist/tool/built-in/delegate.js.map +1 -0
- package/dist/tool/built-in/file-edit.d.ts +14 -0
- package/dist/tool/built-in/file-edit.d.ts.map +1 -0
- package/dist/tool/built-in/file-edit.js +130 -0
- package/dist/tool/built-in/file-edit.js.map +1 -0
- package/dist/tool/built-in/file-read.d.ts +12 -0
- package/dist/tool/built-in/file-read.d.ts.map +1 -0
- package/dist/tool/built-in/file-read.js +82 -0
- package/dist/tool/built-in/file-read.js.map +1 -0
- package/dist/tool/built-in/file-write.d.ts +11 -0
- package/dist/tool/built-in/file-write.d.ts.map +1 -0
- package/dist/tool/built-in/file-write.js +70 -0
- package/dist/tool/built-in/file-write.js.map +1 -0
- package/dist/tool/built-in/fs-walk.d.ts +23 -0
- package/dist/tool/built-in/fs-walk.d.ts.map +1 -0
- package/dist/tool/built-in/fs-walk.js +78 -0
- package/dist/tool/built-in/fs-walk.js.map +1 -0
- package/dist/tool/built-in/glob.d.ts +12 -0
- package/dist/tool/built-in/glob.d.ts.map +1 -0
- package/dist/tool/built-in/glob.js +82 -0
- package/dist/tool/built-in/glob.js.map +1 -0
- package/dist/tool/built-in/grep.d.ts +15 -0
- package/dist/tool/built-in/grep.d.ts.map +1 -0
- package/dist/tool/built-in/grep.js +218 -0
- package/dist/tool/built-in/grep.js.map +1 -0
- package/dist/tool/built-in/index.d.ts +48 -0
- package/dist/tool/built-in/index.d.ts.map +1 -0
- package/dist/tool/built-in/index.js +56 -0
- package/dist/tool/built-in/index.js.map +1 -0
- package/dist/tool/executor.d.ts +100 -0
- package/dist/tool/executor.d.ts.map +1 -0
- package/dist/tool/executor.js +184 -0
- package/dist/tool/executor.js.map +1 -0
- package/dist/tool/framework.d.ts +167 -0
- package/dist/tool/framework.d.ts.map +1 -0
- package/dist/tool/framework.js +402 -0
- package/dist/tool/framework.js.map +1 -0
- package/dist/tool/mcp.d.ts +31 -0
- package/dist/tool/mcp.d.ts.map +1 -0
- package/dist/tool/mcp.js +175 -0
- package/dist/tool/mcp.js.map +1 -0
- package/dist/tool/text-tool-extractor.d.ts +32 -0
- package/dist/tool/text-tool-extractor.d.ts.map +1 -0
- package/dist/tool/text-tool-extractor.js +195 -0
- package/dist/tool/text-tool-extractor.js.map +1 -0
- package/dist/types.d.ts +916 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/keywords.d.ts +18 -0
- package/dist/utils/keywords.d.ts.map +1 -0
- package/dist/utils/keywords.js +32 -0
- package/dist/utils/keywords.js.map +1 -0
- package/dist/utils/semaphore.d.ts +49 -0
- package/dist/utils/semaphore.d.ts.map +1 -0
- package/dist/utils/semaphore.js +89 -0
- package/dist/utils/semaphore.js.map +1 -0
- package/dist/utils/tokens.d.ts +7 -0
- package/dist/utils/tokens.d.ts.map +1 -0
- package/dist/utils/tokens.js +30 -0
- package/dist/utils/tokens.js.map +1 -0
- package/dist/utils/trace.d.ts +12 -0
- package/dist/utils/trace.d.ts.map +1 -0
- package/dist/utils/trace.js +30 -0
- package/dist/utils/trace.js.map +1 -0
- package/docs/DECISIONS.md +49 -0
- package/docs/cli.md +265 -0
- package/docs/context-management.md +24 -0
- package/docs/featured-partner.md +28 -0
- package/docs/observability.md +56 -0
- package/docs/providers.md +78 -0
- package/docs/shared-memory.md +27 -0
- package/docs/tool-configuration.md +152 -0
- package/package.json +96 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Core conversation loop engine for open-multi-agent.
|
|
3
|
+
*
|
|
4
|
+
* {@link AgentRunner} is the heart of the framework. It handles:
|
|
5
|
+
* - Sending messages to the LLM adapter
|
|
6
|
+
* - Extracting tool-use blocks from the response
|
|
7
|
+
* - Executing tool calls in parallel via {@link ToolExecutor}
|
|
8
|
+
* - Appending tool results and looping back until `end_turn`
|
|
9
|
+
* - Accumulating token usage and timing data across all turns
|
|
10
|
+
*
|
|
11
|
+
* The loop follows a standard agentic conversation pattern:
|
|
12
|
+
* one outer `while (true)` that breaks on `end_turn` or maxTurns exhaustion.
|
|
13
|
+
*/
|
|
14
|
+
import type { LLMMessage, ToolCallRecord, TokenUsage, StreamEvent, ToolResult, TeamInfo, LLMAdapter, TraceEvent, LoopDetectionConfig, ContextStrategy, ThinkingConfig } from '../types.js';
|
|
15
|
+
import type { ToolRegistry } from '../tool/framework.js';
|
|
16
|
+
import type { ToolExecutor } from '../tool/executor.js';
|
|
17
|
+
/** Predefined tool sets for common agent use cases. */
|
|
18
|
+
export declare const TOOL_PRESETS: {
|
|
19
|
+
readonly readonly: readonly ["file_read", "grep", "glob"];
|
|
20
|
+
readonly readwrite: readonly ["file_read", "file_write", "file_edit", "grep", "glob"];
|
|
21
|
+
readonly full: readonly ["file_read", "file_write", "file_edit", "grep", "glob", "bash"];
|
|
22
|
+
};
|
|
23
|
+
/** Framework-level disallowed tools for safety rails. */
|
|
24
|
+
export declare const AGENT_FRAMEWORK_DISALLOWED: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Static configuration for an {@link AgentRunner} instance.
|
|
27
|
+
* These values are constant across every `run` / `stream` call.
|
|
28
|
+
*/
|
|
29
|
+
export interface RunnerOptions {
|
|
30
|
+
/** LLM model identifier, e.g. `'claude-opus-4-6'`. */
|
|
31
|
+
readonly model: string;
|
|
32
|
+
/** Optional system prompt prepended to every conversation. */
|
|
33
|
+
readonly systemPrompt?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum number of tool-call round-trips before the runner stops.
|
|
36
|
+
* Prevents unbounded loops. Defaults to `10`.
|
|
37
|
+
*/
|
|
38
|
+
readonly maxTurns?: number;
|
|
39
|
+
/** Maximum output tokens per LLM response. */
|
|
40
|
+
readonly maxTokens?: number;
|
|
41
|
+
/** Sampling temperature passed to the adapter. */
|
|
42
|
+
readonly temperature?: number;
|
|
43
|
+
/** Nucleus sampling top_p. Forwarded to all adapters. */
|
|
44
|
+
readonly topP?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Top-k sampling. Forwarded to Anthropic and OpenAI-compatible local
|
|
47
|
+
* servers. Cloud OpenAI rejects this parameter.
|
|
48
|
+
*/
|
|
49
|
+
readonly topK?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Min-p sampling. Only supported by OpenAI-compatible local servers.
|
|
52
|
+
* Cloud OpenAI rejects this parameter; the Anthropic adapter ignores it.
|
|
53
|
+
*/
|
|
54
|
+
readonly minP?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the model may emit multiple tool calls in a single assistant
|
|
57
|
+
* turn. Forwarded to OpenAI cloud and OpenAI-compatible local servers as
|
|
58
|
+
* `parallel_tool_calls`. The Anthropic adapter ignores this field.
|
|
59
|
+
*/
|
|
60
|
+
readonly parallelToolCalls?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Frequency penalty. Forwarded to OpenAI cloud and OpenAI-compatible local
|
|
63
|
+
* servers. The Anthropic adapter ignores this field.
|
|
64
|
+
*/
|
|
65
|
+
readonly frequencyPenalty?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Presence penalty. Forwarded to OpenAI cloud and OpenAI-compatible local
|
|
68
|
+
* servers. The Anthropic adapter ignores this field.
|
|
69
|
+
*/
|
|
70
|
+
readonly presencePenalty?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Adapter-specific escape hatch merged into the outgoing request payload.
|
|
73
|
+
* See {@link AgentConfig.extraBody} for the override precedence contract.
|
|
74
|
+
*/
|
|
75
|
+
readonly extraBody?: Record<string, unknown>;
|
|
76
|
+
/** See {@link AgentConfig.thinking}. */
|
|
77
|
+
readonly thinking?: ThinkingConfig;
|
|
78
|
+
/** AbortSignal that cancels any in-flight adapter call and stops the loop. */
|
|
79
|
+
readonly abortSignal?: AbortSignal;
|
|
80
|
+
/**
|
|
81
|
+
* Tool access control configuration.
|
|
82
|
+
* - `toolPreset`: Predefined tool sets for common use cases
|
|
83
|
+
* - `allowedTools`: Whitelist of tool names (allowlist)
|
|
84
|
+
* - `disallowedTools`: Blacklist of tool names (denylist)
|
|
85
|
+
* Tools are resolved in order: preset → allowlist → denylist
|
|
86
|
+
*/
|
|
87
|
+
readonly toolPreset?: 'readonly' | 'readwrite' | 'full';
|
|
88
|
+
readonly allowedTools?: readonly string[];
|
|
89
|
+
readonly disallowedTools?: readonly string[];
|
|
90
|
+
/** Display name of the agent driving this runner (used in tool context). */
|
|
91
|
+
readonly agentName?: string;
|
|
92
|
+
/** Short role description of the agent (used in tool context). */
|
|
93
|
+
readonly agentRole?: string;
|
|
94
|
+
/** Loop detection configuration. When set, detects stuck agent loops. */
|
|
95
|
+
readonly loopDetection?: LoopDetectionConfig;
|
|
96
|
+
/** Maximum cumulative tokens (input + output) allowed for this run. */
|
|
97
|
+
readonly maxTokenBudget?: number;
|
|
98
|
+
/** Optional context compression strategy for long multi-turn runs. */
|
|
99
|
+
readonly contextStrategy?: ContextStrategy;
|
|
100
|
+
/**
|
|
101
|
+
* Compress tool results that the agent has already processed.
|
|
102
|
+
* See {@link AgentConfig.compressToolResults} for details.
|
|
103
|
+
*/
|
|
104
|
+
readonly compressToolResults?: boolean | {
|
|
105
|
+
readonly minChars?: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Per-call callbacks for observing tool execution in real time.
|
|
110
|
+
* All callbacks are optional; unused ones are simply skipped.
|
|
111
|
+
*/
|
|
112
|
+
export interface RunOptions {
|
|
113
|
+
/** Fired just before each tool is dispatched. */
|
|
114
|
+
readonly onToolCall?: (name: string, input: Record<string, unknown>) => void;
|
|
115
|
+
/** Fired after each tool result is received. */
|
|
116
|
+
readonly onToolResult?: (name: string, result: ToolResult) => void;
|
|
117
|
+
/** Fired after each complete {@link LLMMessage} is appended. */
|
|
118
|
+
readonly onMessage?: (message: LLMMessage) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Fired when the runner detects a potential configuration issue.
|
|
121
|
+
* For example, when a model appears to ignore tool definitions.
|
|
122
|
+
*/
|
|
123
|
+
readonly onWarning?: (message: string) => void;
|
|
124
|
+
/** Trace callback for observability spans. Async callbacks are safe. */
|
|
125
|
+
readonly onTrace?: (event: TraceEvent) => void | Promise<void>;
|
|
126
|
+
/** Run ID for trace correlation. */
|
|
127
|
+
readonly runId?: string;
|
|
128
|
+
/** Task ID for trace correlation. */
|
|
129
|
+
readonly taskId?: string;
|
|
130
|
+
/** Agent name for trace correlation (overrides RunnerOptions.agentName). */
|
|
131
|
+
readonly traceAgent?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Per-call abort signal. When set, takes precedence over the static
|
|
134
|
+
* {@link RunnerOptions.abortSignal}. Useful for per-run timeouts.
|
|
135
|
+
*/
|
|
136
|
+
readonly abortSignal?: AbortSignal;
|
|
137
|
+
/**
|
|
138
|
+
* Team context for built-in tools such as `delegate_to_agent`.
|
|
139
|
+
* Injected by the orchestrator during `runTeam` / `runTasks` pool runs.
|
|
140
|
+
*/
|
|
141
|
+
readonly team?: TeamInfo;
|
|
142
|
+
}
|
|
143
|
+
/** The aggregated result returned when a full run completes. */
|
|
144
|
+
export interface RunResult {
|
|
145
|
+
/** All messages accumulated during this run (assistant + tool results). */
|
|
146
|
+
readonly messages: LLMMessage[];
|
|
147
|
+
/** The final text output from the last assistant turn. */
|
|
148
|
+
readonly output: string;
|
|
149
|
+
/** All tool calls made during this run, in execution order. */
|
|
150
|
+
readonly toolCalls: ToolCallRecord[];
|
|
151
|
+
/** Aggregated token counts across every LLM call in this run. */
|
|
152
|
+
readonly tokenUsage: TokenUsage;
|
|
153
|
+
/** Total number of LLM turns (including tool-call follow-ups). */
|
|
154
|
+
readonly turns: number;
|
|
155
|
+
/** True when the run was terminated or warned due to loop detection. */
|
|
156
|
+
readonly loopDetected?: boolean;
|
|
157
|
+
/** True when the run was terminated due to token budget limits. */
|
|
158
|
+
readonly budgetExceeded?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Drives a full agentic conversation: LLM calls, tool execution, and looping.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const runner = new AgentRunner(adapter, registry, executor, {
|
|
166
|
+
* model: 'claude-opus-4-6',
|
|
167
|
+
* maxTurns: 10,
|
|
168
|
+
* })
|
|
169
|
+
* const result = await runner.run(messages)
|
|
170
|
+
* console.log(result.output)
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare class AgentRunner {
|
|
174
|
+
private readonly adapter;
|
|
175
|
+
private readonly toolRegistry;
|
|
176
|
+
private readonly toolExecutor;
|
|
177
|
+
private readonly options;
|
|
178
|
+
private readonly maxTurns;
|
|
179
|
+
private summarizeCache;
|
|
180
|
+
constructor(adapter: LLMAdapter, toolRegistry: ToolRegistry, toolExecutor: ToolExecutor, options: RunnerOptions);
|
|
181
|
+
private serializeMessage;
|
|
182
|
+
private truncateToSlidingWindow;
|
|
183
|
+
private summarizeMessages;
|
|
184
|
+
private applyContextStrategy;
|
|
185
|
+
/**
|
|
186
|
+
* Resolve the final set of tools available to this agent based on the
|
|
187
|
+
* three-layer configuration: preset → allowlist → denylist → framework safety.
|
|
188
|
+
*
|
|
189
|
+
* Returns LLMToolDef[] for direct use with LLM adapters.
|
|
190
|
+
*/
|
|
191
|
+
private resolveTools;
|
|
192
|
+
/**
|
|
193
|
+
* Run a complete conversation starting from `messages`.
|
|
194
|
+
*
|
|
195
|
+
* The call may internally make multiple LLM requests (one per tool-call
|
|
196
|
+
* round-trip). It returns only when:
|
|
197
|
+
* - The LLM emits `end_turn` with no tool-use blocks, or
|
|
198
|
+
* - `maxTurns` is exceeded, or
|
|
199
|
+
* - The abort signal is triggered.
|
|
200
|
+
*/
|
|
201
|
+
run(messages: LLMMessage[], options?: RunOptions): Promise<RunResult>;
|
|
202
|
+
/**
|
|
203
|
+
* Run the conversation and yield {@link StreamEvent}s incrementally.
|
|
204
|
+
*
|
|
205
|
+
* Callers receive:
|
|
206
|
+
* - `{ type: 'text', data: string }` for each text delta
|
|
207
|
+
* - `{ type: 'tool_use', data: ToolUseBlock }` when the model requests a tool
|
|
208
|
+
* - `{ type: 'tool_result', data: ToolResultBlock }` after each execution
|
|
209
|
+
* - `{ type: 'budget_exceeded', data: TokenBudgetExceededError }` on budget trip
|
|
210
|
+
* - `{ type: 'done', data: RunResult }` at the very end
|
|
211
|
+
* - `{ type: 'error', data: Error }` on unrecoverable failure
|
|
212
|
+
*/
|
|
213
|
+
stream(initialMessages: LLMMessage[], options?: RunOptions): AsyncGenerator<StreamEvent>;
|
|
214
|
+
/**
|
|
215
|
+
* Rule-based selective context compaction (no LLM calls).
|
|
216
|
+
*
|
|
217
|
+
* Compresses old turns while preserving the conversation skeleton:
|
|
218
|
+
* - tool_use blocks (decisions) are always kept
|
|
219
|
+
* - Long tool_result content is replaced with a compact marker
|
|
220
|
+
* - Long assistant text blocks are truncated with an excerpt
|
|
221
|
+
* - Error tool_results are never compressed
|
|
222
|
+
* - Recent turns (within `preserveRecentTurns`) are kept intact
|
|
223
|
+
*/
|
|
224
|
+
private compactMessages;
|
|
225
|
+
/**
|
|
226
|
+
* Replace consumed tool results with compact markers.
|
|
227
|
+
*
|
|
228
|
+
* A tool_result is "consumed" when the assistant has produced a response
|
|
229
|
+
* after seeing it (i.e. there is an assistant message following the user
|
|
230
|
+
* message that contains the tool_result). The most recent user message
|
|
231
|
+
* with tool results is always kept intact — the LLM is about to see it.
|
|
232
|
+
*
|
|
233
|
+
* Error results and results shorter than `minChars` are never compressed.
|
|
234
|
+
*/
|
|
235
|
+
private compressConsumedToolResults;
|
|
236
|
+
/**
|
|
237
|
+
* Build the {@link ToolUseContext} passed to every tool execution.
|
|
238
|
+
* Identifies this runner as the invoking agent.
|
|
239
|
+
*/
|
|
240
|
+
private buildToolContext;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/agent/runner.ts"],"names":[],"mappings":"AAA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