@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 open-multi-agent contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
<br />
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/open-multi-agent/open-multi-agent/main/.github/brand/logo-mark-dark.svg">
|
|
6
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/open-multi-agent/open-multi-agent/main/.github/brand/logo-mark-light.svg">
|
|
7
|
+
<img alt="Open Multi-Agent" src="https://raw.githubusercontent.com/open-multi-agent/open-multi-agent/main/.github/brand/logo-mark-light.svg" width="96">
|
|
8
|
+
</picture>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<br />
|
|
12
|
+
|
|
13
|
+
<h1 align="center">Open Multi-Agent</h1>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<strong>From a goal to a task DAG, automatically.</strong><br/>
|
|
17
|
+
TypeScript-native multi-agent orchestration. Three runtime dependencies.
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://www.npmjs.com/package/@open-multi-agent/core"><img src="https://img.shields.io/npm/v/@open-multi-agent/core" alt="npm version"></a>
|
|
22
|
+
<a href="https://github.com/open-multi-agent/open-multi-agent/actions/workflows/ci.yml"><img src="https://github.com/open-multi-agent/open-multi-agent/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
23
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="MIT License"></a>
|
|
24
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.6-blue" alt="TypeScript"></a>
|
|
25
|
+
<a href="https://codecov.io/gh/open-multi-agent/open-multi-agent"><img src="https://codecov.io/gh/open-multi-agent/open-multi-agent/graph/badge.svg" alt="codecov"></a>
|
|
26
|
+
<a href="https://github.com/open-multi-agent/open-multi-agent/blob/main/package.json"><img src="https://img.shields.io/badge/runtime_deps-3-brightgreen" alt="runtime deps"></a>
|
|
27
|
+
<a href="https://github.com/open-multi-agent/open-multi-agent/stargazers"><img src="https://img.shields.io/github/stars/open-multi-agent/open-multi-agent" alt="GitHub stars"></a>
|
|
28
|
+
<a href="https://github.com/open-multi-agent/open-multi-agent/network/members"><img src="https://img.shields.io/github/forks/open-multi-agent/open-multi-agent" alt="GitHub forks"></a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<img src="https://raw.githubusercontent.com/open-multi-agent/open-multi-agent/main/.github/brand/demo-dashboard-hero.gif" alt="Animated task DAG dashboard: coordinator decomposes a goal into tasks, executes them in parallel, and synthesizes the result — with token breakdown and agent output log" width="960" height="456" loading="eager">
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<br />
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<strong>English</strong> · <a href="./README_zh.md">中文</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<br />
|
|
42
|
+
|
|
43
|
+
`open-multi-agent` is a multi-agent orchestration framework for TypeScript backends. Give it a goal; a coordinator agent decomposes it into a task DAG, parallelizes independents, and synthesizes the result. Three runtime dependencies, drops into any Node.js backend.
|
|
44
|
+
|
|
45
|
+
> **Package update:** the official npm package is now `@open-multi-agent/core`.
|
|
46
|
+
> The previous package, `@jackchen_me/open-multi-agent`, remains supported during the migration window.
|
|
47
|
+
|
|
48
|
+
> **Your engineers describe the goal, not the graph.**
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
Requires Node.js >= 18.
|
|
53
|
+
|
|
54
|
+
### Use it in your project
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install @open-multi-agent/core
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { OpenMultiAgent, type AgentConfig } from '@open-multi-agent/core'
|
|
62
|
+
|
|
63
|
+
const agents: AgentConfig[] = [
|
|
64
|
+
{ name: 'architect', model: 'claude-sonnet-4-6', systemPrompt: 'Design clean API contracts.', tools: ['file_write'] },
|
|
65
|
+
{ name: 'developer', model: 'claude-sonnet-4-6', systemPrompt: 'Implement runnable TypeScript.', tools: ['bash', 'file_read', 'file_write', 'file_edit'] },
|
|
66
|
+
{ name: 'reviewer', model: 'claude-sonnet-4-6', systemPrompt: 'Review correctness and security.', tools: ['file_read', 'grep'] },
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
const orchestrator = new OpenMultiAgent({
|
|
70
|
+
defaultModel: 'claude-sonnet-4-6',
|
|
71
|
+
onProgress: (event) => console.log(event.type, event.task ?? event.agent ?? ''),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const team = orchestrator.createTeam('api-team', { name: 'api-team', agents, sharedMemory: true })
|
|
75
|
+
const result = await orchestrator.runTeam(team, 'Create a REST API for a todo list in /tmp/todo-api/')
|
|
76
|
+
|
|
77
|
+
console.log(result.success, result.totalTokenUsage.output_tokens)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Run an example locally
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/open-multi-agent/open-multi-agent && cd open-multi-agent
|
|
84
|
+
npm install
|
|
85
|
+
export ANTHROPIC_API_KEY=sk-...
|
|
86
|
+
npx tsx examples/basics/team-collaboration.ts
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Three agents collaborate on a REST API while `onProgress` streams the coordinator's task DAG:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
agent_start coordinator
|
|
93
|
+
task_start design-api
|
|
94
|
+
task_complete design-api
|
|
95
|
+
task_start implement-handlers
|
|
96
|
+
task_start scaffold-tests // independent tasks run in parallel
|
|
97
|
+
task_complete scaffold-tests
|
|
98
|
+
task_complete implement-handlers
|
|
99
|
+
task_start review-code // unblocked after implementation
|
|
100
|
+
task_complete review-code
|
|
101
|
+
agent_complete coordinator // synthesizes final result
|
|
102
|
+
Success: true
|
|
103
|
+
Tokens: 12847 output tokens
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Local models via Ollama need no API key, see [`providers/ollama`](examples/providers/ollama.ts). For hosted providers (`OPENAI_API_KEY`, `GEMINI_API_KEY`, etc.), see [Supported Providers](#supported-providers).
|
|
107
|
+
|
|
108
|
+
### Three Ways to Run
|
|
109
|
+
|
|
110
|
+
| Mode | Method | When to use | Example |
|
|
111
|
+
|------|--------|-------------|---------|
|
|
112
|
+
| Single agent | `runAgent()` | One agent, one prompt | [`basics/single-agent`](examples/basics/single-agent.ts) |
|
|
113
|
+
| Auto-orchestrated team | `runTeam()` | Give a goal, let the coordinator plan and execute | [`basics/team-collaboration`](examples/basics/team-collaboration.ts) |
|
|
114
|
+
| Explicit pipeline | `runTasks()` | You define the task graph and assignments | [`basics/task-pipeline`](examples/basics/task-pipeline.ts) |
|
|
115
|
+
|
|
116
|
+
Preview the coordinator's task DAG without executing agents:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const plan = await orchestrator.runTeam(team, goal, { planOnly: true })
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
For MapReduce-style fan-out without task dependencies, use `AgentPool.runParallel()` directly. See [`patterns/fan-out-aggregate`](examples/patterns/fan-out-aggregate.ts).
|
|
123
|
+
|
|
124
|
+
For shell and CI, use the JSON-first `oma` binary. See [docs/cli.md](./docs/cli.md).
|
|
125
|
+
|
|
126
|
+
## Features
|
|
127
|
+
|
|
128
|
+
| Capability | What you get |
|
|
129
|
+
|------------|--------------|
|
|
130
|
+
| **Goal-driven coordinator** | One `runTeam(team, goal)` call. The coordinator decomposes the goal into a task DAG, parallelizes independents, and synthesizes the result. |
|
|
131
|
+
| **Mix providers in one team** | 10 built-in: Anthropic, OpenAI, Azure, Bedrock, Gemini, Grok, DeepSeek, MiniMax, Qiniu, Copilot. Ollama / vLLM / LM Studio / OpenRouter / Groq via OpenAI-compatible. ([full setup](./docs/providers.md)) |
|
|
132
|
+
| **Tools + MCP** | 6 built-in (`bash`, `file_*`, `grep`, `glob`), opt-in `delegate_to_agent`, custom tools via `defineTool()` + Zod, stdio MCP servers via `connectMCPTools()`. ([tool config](./docs/tool-configuration.md)) |
|
|
133
|
+
| **Streaming + structured output** | Token-by-token streaming on every adapter; Zod-validated final answer with auto-retry on parse failure. ([`structured-output`](examples/patterns/structured-output.ts)) |
|
|
134
|
+
| **Observability** | `onProgress` events, `onTrace` spans, post-run HTML dashboard rendering the executed task DAG. ([observability guide](./docs/observability.md)) |
|
|
135
|
+
| **Pluggable shared memory** | Default in-process KV; swap in Redis / Postgres / your own backend by implementing `MemoryStore`. ([shared memory](./docs/shared-memory.md)) |
|
|
136
|
+
|
|
137
|
+
Production controls (context strategies, task retry with backoff, loop detection, tool output truncation/compression) are covered in the [Production Checklist](#production-checklist).
|
|
138
|
+
|
|
139
|
+
## Examples
|
|
140
|
+
|
|
141
|
+
[`examples/`](./examples/) is organized by category: basics, cookbook, patterns, providers, integrations, and production. See [`examples/README.md`](./examples/README.md) for the full index.
|
|
142
|
+
|
|
143
|
+
### Real-world workflows ([`cookbook/`](./examples/cookbook/))
|
|
144
|
+
|
|
145
|
+
End-to-end scenarios you can run today. Each one is a complete, opinionated workflow.
|
|
146
|
+
|
|
147
|
+
- [`contract-review-dag`](examples/cookbook/contract-review-dag.ts): four-task DAG for contract review with parallel branches and step-level retry on failure.
|
|
148
|
+
- [`meeting-summarizer`](examples/cookbook/meeting-summarizer.ts): three specialised agents fan out on a transcript, an aggregator merges them into one Markdown report with action items and sentiment.
|
|
149
|
+
- [`competitive-monitoring`](examples/cookbook/competitive-monitoring.ts): three parallel source agents extract claims from feeds; an aggregator cross-checks them and flags contradictions.
|
|
150
|
+
- [`translation-backtranslation`](examples/cookbook/translation-backtranslation.ts): translate EN to target with one provider, back-translate with another, flag semantic drift.
|
|
151
|
+
|
|
152
|
+
### Patterns and integrations
|
|
153
|
+
|
|
154
|
+
- [`basics/team-collaboration`](examples/basics/team-collaboration.ts): `runTeam()` coordinator pattern.
|
|
155
|
+
- [`patterns/structured-output`](examples/patterns/structured-output.ts): any agent returns Zod-validated JSON.
|
|
156
|
+
- [`patterns/fan-out-aggregate`](examples/patterns/fan-out-aggregate.ts): MapReduce-style fan-out via `AgentPool.runParallel()`.
|
|
157
|
+
- [`patterns/agent-handoff`](examples/patterns/agent-handoff.ts): synchronous sub-agent delegation via `delegate_to_agent`.
|
|
158
|
+
- [`integrations/trace-observability`](examples/integrations/trace-observability.ts): `onTrace` spans for LLM calls, tools, and tasks.
|
|
159
|
+
- [`integrations/mcp-github`](examples/integrations/mcp-github.ts): expose an MCP server's tools to an agent via `connectMCPTools()`.
|
|
160
|
+
- [`integrations/with-vercel-ai-sdk`](examples/integrations/with-vercel-ai-sdk/): Next.js app combining OMA `runTeam()` with AI SDK `useChat` streaming.
|
|
161
|
+
- **Provider examples**: scripts under [`examples/providers/`](examples/providers/) covering hosted providers, OpenAI-compatible endpoints, and local models.
|
|
162
|
+
|
|
163
|
+
Run any script with `npx tsx examples/<path>.ts`.
|
|
164
|
+
|
|
165
|
+
## How is this different from X?
|
|
166
|
+
|
|
167
|
+
A quick router. Mechanism breakdown follows.
|
|
168
|
+
|
|
169
|
+
| If you need | Pick |
|
|
170
|
+
|-------------|------|
|
|
171
|
+
| Fixed production topology with mature checkpointing | LangGraph JS |
|
|
172
|
+
| Explicit Supervisor + hand-wired workflows | Mastra |
|
|
173
|
+
| Python stack with mature multi-agent ecosystem | CrewAI |
|
|
174
|
+
| AI app toolkit with broad model-provider support | Vercel AI SDK |
|
|
175
|
+
| **TypeScript, goal to result with auto task decomposition** | **open-multi-agent** |
|
|
176
|
+
|
|
177
|
+
**vs. LangGraph JS.** LangGraph compiles a declarative graph (nodes, edges, conditional routing) into an invokable. `open-multi-agent` runs a Coordinator that decomposes the goal into a task DAG at runtime, then auto-parallelizes independents. Same end (orchestrated execution), opposite directions: LangGraph is graph-first, OMA is goal-first.
|
|
178
|
+
|
|
179
|
+
**vs. Mastra.** Both are TypeScript-native. Mastra's Supervisor pattern requires you to wire agents and workflows by hand; OMA's Coordinator does the wiring at runtime from the goal string. If the workflow is known up front, Mastra's explicitness pays off. If you'd rather not enumerate every step, OMA's `runTeam(team, goal)` is one call.
|
|
180
|
+
|
|
181
|
+
**vs. CrewAI.** CrewAI is the mature multi-agent option in Python. OMA targets TypeScript backends with three runtime dependencies and direct Node.js embedding. Roughly comparable orchestration surface; the choice is the language stack.
|
|
182
|
+
|
|
183
|
+
**vs. Vercel AI SDK.** AI SDK provides the LLM-call layer — provider abstraction, streaming, tool calls, and structured outputs. It does not orchestrate goal-driven multi-agent teams. The two are complementary: AI SDK for app surfaces and single-agent calls, OMA when you need a team.
|
|
184
|
+
|
|
185
|
+
## Ecosystem
|
|
186
|
+
|
|
187
|
+
`open-multi-agent` launched 2026-04-01 under MIT. Known users and integrations to date:
|
|
188
|
+
|
|
189
|
+
### In production
|
|
190
|
+
|
|
191
|
+
- **[temodar-agent](https://github.com/xeloxa/temodar-agent)** (~60 stars). WordPress security analysis platform by [Ali Sünbül](https://github.com/xeloxa). Uses our built-in tools (`bash`, `file_*`, `grep`) directly inside a Docker runtime. Confirmed production use.
|
|
192
|
+
- **Cybersecurity SOC (home lab).** A private setup running Qwen 2.5 + DeepSeek Coder entirely offline via Ollama, building an autonomous SOC pipeline on Wazuh + Proxmox. Early user, not yet public.
|
|
193
|
+
|
|
194
|
+
Using `open-multi-agent` in production or a side project? [Open a discussion](https://github.com/open-multi-agent/open-multi-agent/discussions) and we will list it here.
|
|
195
|
+
|
|
196
|
+
### Integrations
|
|
197
|
+
|
|
198
|
+
- **[Engram](https://www.engram-memory.com)** — "Git for AI memory." Syncs knowledge across agents instantly and flags conflicts. ([repo](https://github.com/Agentscreator/engram-memory))
|
|
199
|
+
- **[@agentsonar/oma](https://github.com/agentsonar/agentsonar-oma)** — Sidecar detecting cross-run delegation cycles, repetition, and rate bursts.
|
|
200
|
+
|
|
201
|
+
Built an integration? [Open a discussion](https://github.com/open-multi-agent/open-multi-agent/discussions) to get listed.
|
|
202
|
+
|
|
203
|
+
### Featured partner
|
|
204
|
+
|
|
205
|
+
For products and platforms with a deep `open-multi-agent` integration. See the [Featured partner program](./docs/featured-partner.md) for terms and how to apply.
|
|
206
|
+
|
|
207
|
+
## Architecture
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
211
|
+
│ OpenMultiAgent (Orchestrator) │
|
|
212
|
+
│ │
|
|
213
|
+
│ createTeam() runTeam() runTasks() runAgent() getStatus() │
|
|
214
|
+
└──────────────────────┬──────────────────────────────────────────┘
|
|
215
|
+
│
|
|
216
|
+
┌──────────▼──────────┐
|
|
217
|
+
│ Team │
|
|
218
|
+
│ - AgentConfig[] │
|
|
219
|
+
│ - MessageBus │
|
|
220
|
+
│ - TaskQueue │
|
|
221
|
+
│ - SharedMemory │
|
|
222
|
+
└──────────┬──────────┘
|
|
223
|
+
│
|
|
224
|
+
┌─────────────┴─────────────┐
|
|
225
|
+
│ │
|
|
226
|
+
┌────────▼──────────┐ ┌───────────▼───────────┐
|
|
227
|
+
│ AgentPool │ │ TaskQueue │
|
|
228
|
+
│ - Semaphore │ │ - dependency graph │
|
|
229
|
+
│ - runParallel() │ │ - auto unblock │
|
|
230
|
+
└────────┬──────────┘ │ - cascade failure │
|
|
231
|
+
│ └───────────────────────┘
|
|
232
|
+
┌────────▼──────────┐
|
|
233
|
+
│ Agent │
|
|
234
|
+
│ - run() │ ┌────────────────────────┐
|
|
235
|
+
│ - prompt() │───►│ LLMAdapter │
|
|
236
|
+
│ - stream() │ │ - AnthropicAdapter │
|
|
237
|
+
└────────┬──────────┘ │ - OpenAIAdapter │
|
|
238
|
+
│ │ - AzureOpenAIAdapter │
|
|
239
|
+
│ │ - BedrockAdapter │
|
|
240
|
+
│ │ - CopilotAdapter │
|
|
241
|
+
│ │ - GeminiAdapter │
|
|
242
|
+
│ │ - GrokAdapter │
|
|
243
|
+
│ │ - MiniMaxAdapter │
|
|
244
|
+
│ │ - DeepSeekAdapter │
|
|
245
|
+
│ │ - QiniuAdapter │
|
|
246
|
+
│ └────────────────────────┘
|
|
247
|
+
┌────────▼──────────┐
|
|
248
|
+
│ AgentRunner │ ┌──────────────────────┐
|
|
249
|
+
│ - conversation │───►│ ToolRegistry │
|
|
250
|
+
│ loop │ │ - defineTool() │
|
|
251
|
+
│ - tool dispatch │ │ - 6 built-in tools │
|
|
252
|
+
└───────────────────┘ │ + delegate (opt-in) │
|
|
253
|
+
└──────────────────────┘
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Core Concepts
|
|
257
|
+
|
|
258
|
+
- **Tools + MCP.** Built-ins cover `bash`, `file_read`, `file_write`, `file_edit`, `grep`, and `glob`; custom tools use `defineTool()` + Zod; stdio MCP servers connect through `connectMCPTools()`. See [tool configuration](./docs/tool-configuration.md).
|
|
259
|
+
- **Observability.** Wire `onProgress` for live lifecycle events, `onTrace` for structured spans, and `renderTeamRunDashboard(result)` for a static DAG dashboard. See [observability](./docs/observability.md).
|
|
260
|
+
- **Shared memory.** Use the default in-process KV or bring Redis, Postgres, Engram, or any `MemoryStore`. See [shared memory](./docs/shared-memory.md).
|
|
261
|
+
- **Context management.** Use sliding windows, summarization, rule-based compaction, or a custom compressor for long-running agents. See [context management](./docs/context-management.md).
|
|
262
|
+
|
|
263
|
+
## Supported Providers
|
|
264
|
+
|
|
265
|
+
Change `provider`, `model`, and set the env var. The agent config shape stays the same.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
const agent: AgentConfig = {
|
|
269
|
+
name: 'my-agent',
|
|
270
|
+
provider: 'anthropic',
|
|
271
|
+
model: 'claude-sonnet-4-6',
|
|
272
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
| Kind | How to configure | Services |
|
|
277
|
+
|------|------------------|----------|
|
|
278
|
+
| Built-in shortcuts | Set `provider` to `anthropic`, `gemini`, `openai`, `azure-openai`, `copilot`, `grok`, `deepseek`, `minimax`, `qiniu`, or `bedrock`; the framework supplies the endpoint. | Anthropic, Gemini, OpenAI, Azure OpenAI, GitHub Copilot, xAI Grok, DeepSeek, MiniMax, Qiniu, AWS Bedrock |
|
|
279
|
+
| OpenAI-compatible endpoints | Set `provider: 'openai'` plus `baseURL` and, when needed, `apiKey`. | Ollama, vLLM, LM Studio, llama.cpp server, OpenRouter, Groq, Mistral |
|
|
280
|
+
|
|
281
|
+
See [docs/providers.md](./docs/providers.md) for env vars, model examples, local tool-calling, timeouts, and troubleshooting.
|
|
282
|
+
|
|
283
|
+
## Production Checklist
|
|
284
|
+
|
|
285
|
+
Before going live, wire up the controls that protect token spend, recover from failure, and let you debug.
|
|
286
|
+
|
|
287
|
+
| Concern | Knob | Where it lives |
|
|
288
|
+
|---------|------|----------------|
|
|
289
|
+
| Bound the conversation | `maxTurns` per agent + `contextStrategy` (`sliding-window` / `summarize` / `compact` / `custom`) | `AgentConfig` |
|
|
290
|
+
| Cap tool output | `maxToolOutputChars` (or per-tool `maxOutputChars`) + `compressToolResults: true` | `AgentConfig` and `defineTool()` |
|
|
291
|
+
| Recover from failure | Per-task `maxRetries`, `retryDelayMs`, `retryBackoff` (exponential multiplier) | Task config used via `runTasks()` |
|
|
292
|
+
| Hard-cap spend | `maxTokenBudget` on the orchestrator | `OrchestratorConfig` |
|
|
293
|
+
| Catch stuck agents | `loopDetection` with `onLoopDetected: 'terminate'` (or a custom handler) | `AgentConfig` |
|
|
294
|
+
| Trace and audit | `onTrace` to your tracing backend; persist `renderTeamRunDashboard(result)` | `OrchestratorConfig` |
|
|
295
|
+
|
|
296
|
+
## Contributing
|
|
297
|
+
|
|
298
|
+
Issues, feature requests, and PRs are welcome. Some areas where contributions would be especially valuable:
|
|
299
|
+
|
|
300
|
+
- **Production examples.** Real-world end-to-end workflows. See [`examples/production/README.md`](./examples/production/README.md) for the acceptance criteria and submission format.
|
|
301
|
+
- **Documentation.** Guides, tutorials, and API docs.
|
|
302
|
+
- **Translations.** Help translate this README into other languages. [Open a PR](https://github.com/open-multi-agent/open-multi-agent/pulls).
|
|
303
|
+
|
|
304
|
+
## Contributors
|
|
305
|
+
|
|
306
|
+
<a href="https://github.com/open-multi-agent/open-multi-agent/graphs/contributors">
|
|
307
|
+
<img src="https://contrib.rocks/image?repo=open-multi-agent/open-multi-agent&max=100&v=20260507" />
|
|
308
|
+
</a>
|
|
309
|
+
|
|
310
|
+
<details>
|
|
311
|
+
<summary>Contributor credits by area</summary>
|
|
312
|
+
|
|
313
|
+
**Framework features**
|
|
314
|
+
|
|
315
|
+
- [@ibrahimkzmv](https://github.com/ibrahimkzmv) (token budget, context strategy, dependency-scoped context, tool presets, glob, MCP integration, configurable coordinator, CLI, dashboard rendering, trace event types)
|
|
316
|
+
- [@apollo-mg](https://github.com/apollo-mg) (context compaction fix, sampling parameters)
|
|
317
|
+
- [@tizerluo](https://github.com/tizerluo) (onPlanReady, onAgentStream)
|
|
318
|
+
- [@CodingBangboo](https://github.com/CodingBangboo) (planOnly mode)
|
|
319
|
+
- [@Xin-Mai](https://github.com/Xin-Mai) (output schema validation)
|
|
320
|
+
- [@JasonOA888](https://github.com/JasonOA888) (AbortSignal support)
|
|
321
|
+
- [@EchoOfZion](https://github.com/EchoOfZion) (coordinator skip for simple goals)
|
|
322
|
+
- [@voidborne-d](https://github.com/voidborne-d) (OpenAI mixed content fix)
|
|
323
|
+
- [@NamelessNATM](https://github.com/NamelessNATM) (agent delegation base implementation)
|
|
324
|
+
- [@MyPrototypeWhat](https://github.com/MyPrototypeWhat) (reasoning blocks, reasoning_effort, sampling parity, trace input/output)
|
|
325
|
+
- [@SiMinus](https://github.com/SiMinus) (streaming reasoning events)
|
|
326
|
+
|
|
327
|
+
**Provider integrations**
|
|
328
|
+
|
|
329
|
+
- [@ibrahimkzmv](https://github.com/ibrahimkzmv) (Gemini)
|
|
330
|
+
- [@hkalex](https://github.com/hkalex) (DeepSeek, MiniMax)
|
|
331
|
+
- [@marceloceccon](https://github.com/marceloceccon) (Grok)
|
|
332
|
+
- [@Klarline](https://github.com/Klarline) (Azure OpenAI)
|
|
333
|
+
- [@Deathwing](https://github.com/Deathwing) (GitHub Copilot)
|
|
334
|
+
- [@JackChiang233](https://github.com/JackChiang233) (Qiniu)
|
|
335
|
+
- [@CodingBangboo](https://github.com/CodingBangboo) (AWS Bedrock)
|
|
336
|
+
|
|
337
|
+
**Examples & cookbook**
|
|
338
|
+
|
|
339
|
+
- [@mvanhorn](https://github.com/mvanhorn) (research aggregation, code review, meeting summarizer, Groq example, Mistral example)
|
|
340
|
+
- [@Kinoo0](https://github.com/Kinoo0) (code review upgrade)
|
|
341
|
+
- [@Optimisttt](https://github.com/Optimisttt) (research aggregation upgrade)
|
|
342
|
+
- [@Agentscreator](https://github.com/Agentscreator) (Engram memory integration)
|
|
343
|
+
- [@fault-segment](https://github.com/fault-segment) (contract-review DAG)
|
|
344
|
+
- [@HuXiangyu123](https://github.com/HuXiangyu123) (cost-tiered example)
|
|
345
|
+
- [@zouhh22333-beep](https://github.com/zouhh22333-beep) (translation/backtranslation)
|
|
346
|
+
- [@pei-pei45](https://github.com/pei-pei45) (competitive monitoring)
|
|
347
|
+
- [@mmjwxbc](https://github.com/mmjwxbc) (interview simulator)
|
|
348
|
+
- [@binghuaren96](https://github.com/binghuaren96) (incident postmortem DAG)
|
|
349
|
+
- [@DaiMao-UT](https://github.com/DaiMao-UT) (paper replication triage)
|
|
350
|
+
- [@oooooowoooooo](https://github.com/oooooowoooooo) (rare disease information triage)
|
|
351
|
+
- [@CodingBangboo](https://github.com/CodingBangboo) (Express customer support pipeline)
|
|
352
|
+
|
|
353
|
+
**Docs & tests**
|
|
354
|
+
|
|
355
|
+
- [@tmchow](https://github.com/tmchow) (llama.cpp docs)
|
|
356
|
+
- [@kenrogers](https://github.com/kenrogers) (OpenRouter docs)
|
|
357
|
+
- [@jadegold55](https://github.com/jadegold55) (LLM adapter test coverage)
|
|
358
|
+
|
|
359
|
+
</details>
|
|
360
|
+
|
|
361
|
+
## Star History
|
|
362
|
+
|
|
363
|
+
<a href="https://star-history.com/#open-multi-agent/open-multi-agent&Date">
|
|
364
|
+
<picture>
|
|
365
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=open-multi-agent/open-multi-agent&type=Date&theme=dark&v=20260425" />
|
|
366
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=open-multi-agent/open-multi-agent&type=Date&v=20260425" />
|
|
367
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=open-multi-agent/open-multi-agent&type=Date&v=20260425" />
|
|
368
|
+
</picture>
|
|
369
|
+
</a>
|
|
370
|
+
|
|
371
|
+
## License
|
|
372
|
+
|
|
373
|
+
MIT
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview High-level Agent class for open-multi-agent.
|
|
3
|
+
*
|
|
4
|
+
* {@link Agent} is the primary interface most consumers interact with.
|
|
5
|
+
* It wraps {@link AgentRunner} with:
|
|
6
|
+
* - Persistent conversation history (`prompt()`)
|
|
7
|
+
* - Fresh-conversation semantics (`run()`)
|
|
8
|
+
* - Streaming support (`stream()`)
|
|
9
|
+
* - Dynamic tool registration at runtime
|
|
10
|
+
* - Full lifecycle state tracking (`idle → running → completed | error`)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Agent, ToolRegistry, ToolExecutor, registerBuiltInTools } from '@open-multi-agent/core'
|
|
15
|
+
*
|
|
16
|
+
* const registry = new ToolRegistry()
|
|
17
|
+
* registerBuiltInTools(registry)
|
|
18
|
+
* const executor = new ToolExecutor(registry)
|
|
19
|
+
*
|
|
20
|
+
* const agent = new Agent(
|
|
21
|
+
* {
|
|
22
|
+
* name: 'researcher',
|
|
23
|
+
* model: 'claude-sonnet-4-6',
|
|
24
|
+
* systemPrompt: 'You are a rigorous research assistant.',
|
|
25
|
+
* tools: ['file_read', 'grep'],
|
|
26
|
+
* },
|
|
27
|
+
* registry,
|
|
28
|
+
* executor,
|
|
29
|
+
* )
|
|
30
|
+
*
|
|
31
|
+
* const result = await agent.run('Summarise the project README.')
|
|
32
|
+
* console.log(result.output)
|
|
33
|
+
*
|
|
34
|
+
* // For one-shot runs without managing the Agent instance, use
|
|
35
|
+
* // `new OpenMultiAgent().runAgent(config, prompt)` instead.
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
import type { AgentConfig, AgentState, AgentRunResult, LLMMessage, StreamEvent, ToolUseContext } from '../types.js';
|
|
39
|
+
import type { ToolDefinition as FrameworkToolDefinition, ToolRegistry } from '../tool/framework.js';
|
|
40
|
+
import type { ToolExecutor } from '../tool/executor.js';
|
|
41
|
+
import { type RunOptions } from './runner.js';
|
|
42
|
+
/**
|
|
43
|
+
* High-level wrapper around {@link AgentRunner} that manages conversation
|
|
44
|
+
* history, state transitions, and tool lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
export declare class Agent {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly config: AgentConfig;
|
|
49
|
+
private runner;
|
|
50
|
+
private state;
|
|
51
|
+
private readonly _toolRegistry;
|
|
52
|
+
private readonly _toolExecutor;
|
|
53
|
+
private messageHistory;
|
|
54
|
+
/**
|
|
55
|
+
* @param config - Static configuration for this agent.
|
|
56
|
+
* @param toolRegistry - Registry used to resolve and manage tools.
|
|
57
|
+
* @param toolExecutor - Executor that dispatches tool calls.
|
|
58
|
+
*
|
|
59
|
+
* `toolRegistry` and `toolExecutor` are injected rather than instantiated
|
|
60
|
+
* internally so that teams of agents can share a single registry.
|
|
61
|
+
*/
|
|
62
|
+
constructor(config: AgentConfig, toolRegistry: ToolRegistry, toolExecutor: ToolExecutor);
|
|
63
|
+
/**
|
|
64
|
+
* Lazily create the {@link AgentRunner}.
|
|
65
|
+
*
|
|
66
|
+
* The adapter is created asynchronously (it may lazy-import provider SDKs),
|
|
67
|
+
* so we defer construction until the first `run` / `prompt` / `stream` call.
|
|
68
|
+
*/
|
|
69
|
+
private getRunner;
|
|
70
|
+
/**
|
|
71
|
+
* Run `prompt` in a fresh conversation (history is NOT used).
|
|
72
|
+
*
|
|
73
|
+
* Equivalent to constructing a brand-new messages array `[{ role:'user', … }]`
|
|
74
|
+
* and calling the runner once. The agent's persistent history is not modified.
|
|
75
|
+
*
|
|
76
|
+
* Use this for one-shot queries where past context is irrelevant.
|
|
77
|
+
*/
|
|
78
|
+
run(prompt: string, runOptions?: Partial<RunOptions>): Promise<AgentRunResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Run `prompt` as part of the ongoing conversation.
|
|
81
|
+
*
|
|
82
|
+
* Appends the user message to the persistent history, runs the agent, then
|
|
83
|
+
* appends the resulting messages to the history for the next call.
|
|
84
|
+
*
|
|
85
|
+
* Use this for multi-turn interactions.
|
|
86
|
+
*/
|
|
87
|
+
prompt(message: string): Promise<AgentRunResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Stream a fresh-conversation response, yielding {@link StreamEvent}s.
|
|
90
|
+
*
|
|
91
|
+
* Like {@link run}, this does not use or update the persistent history.
|
|
92
|
+
*/
|
|
93
|
+
stream(prompt: string, runOptions?: Partial<RunOptions>): AsyncGenerator<StreamEvent>;
|
|
94
|
+
/** Return a snapshot of the current agent state (does not clone nested objects). */
|
|
95
|
+
getState(): AgentState;
|
|
96
|
+
/** Return a copy of the persistent message history. */
|
|
97
|
+
getHistory(): LLMMessage[];
|
|
98
|
+
/**
|
|
99
|
+
* Clear the persistent conversation history and reset state to `idle`.
|
|
100
|
+
* Does NOT discard the runner instance — the adapter connection is reused.
|
|
101
|
+
*/
|
|
102
|
+
reset(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Register a new tool with this agent's tool registry at runtime.
|
|
105
|
+
*
|
|
106
|
+
* The tool becomes available to the next LLM call — no restart required.
|
|
107
|
+
*/
|
|
108
|
+
addTool(tool: FrameworkToolDefinition): void;
|
|
109
|
+
/**
|
|
110
|
+
* Deregister a tool by name.
|
|
111
|
+
* If the tool is not registered this is a no-op (no error is thrown).
|
|
112
|
+
*/
|
|
113
|
+
removeTool(name: string): void;
|
|
114
|
+
/** Return the names of all currently registered tools. */
|
|
115
|
+
getTools(): string[];
|
|
116
|
+
/**
|
|
117
|
+
* Shared execution path used by both `run` and `prompt`.
|
|
118
|
+
* Handles state transitions and error wrapping.
|
|
119
|
+
*/
|
|
120
|
+
private executeRun;
|
|
121
|
+
/** Emit an `agent` trace event if `onTrace` is provided. */
|
|
122
|
+
private emitAgentTrace;
|
|
123
|
+
/**
|
|
124
|
+
* Validate agent output against the configured `outputSchema`.
|
|
125
|
+
* On first validation failure, retry once with error feedback.
|
|
126
|
+
*/
|
|
127
|
+
private validateStructuredOutput;
|
|
128
|
+
/**
|
|
129
|
+
* Shared streaming path used by `stream`.
|
|
130
|
+
* Handles state transitions and error wrapping.
|
|
131
|
+
*/
|
|
132
|
+
private executeStream;
|
|
133
|
+
/** Extract the prompt text from the last user message to build hook context. */
|
|
134
|
+
private buildBeforeRunHookContext;
|
|
135
|
+
/**
|
|
136
|
+
* Apply a (possibly modified) hook context back to the messages array.
|
|
137
|
+
*
|
|
138
|
+
* Only text blocks in the last user message are replaced; non-text content
|
|
139
|
+
* (images, tool results) is preserved. The array element is replaced (not
|
|
140
|
+
* mutated in place) so that shallow copies of the original array (e.g. from
|
|
141
|
+
* `prompt()`) are not affected.
|
|
142
|
+
*/
|
|
143
|
+
private applyHookContext;
|
|
144
|
+
private transitionTo;
|
|
145
|
+
private transitionToError;
|
|
146
|
+
private toAgentRunResult;
|
|
147
|
+
/**
|
|
148
|
+
* Build a {@link ToolUseContext} that identifies this agent.
|
|
149
|
+
* Exposed so team orchestrators can inject richer context (e.g. `TeamInfo`).
|
|
150
|
+
*/
|
|
151
|
+
buildToolContext(abortSignal?: AbortSignal): ToolUseContext;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EAEd,UAAU,EACV,WAAW,EAEX,cAAc,EACf,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,cAAc,IAAI,uBAAuB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAmC,KAAK,UAAU,EAAkB,MAAM,aAAa,CAAA;AAqC9F;;;GAGG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAE5B,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAc;IAC5C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAc;IAC5C,OAAO,CAAC,cAAc,CAAmB;IAEzC;;;;;;;OAOG;gBAED,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY;IAkB5B;;;;;OAKG;YACW,SAAS;IAwDvB;;;;;;;OAOG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAQpF;;;;;;;OAOG;IAEG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAkBtD;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,WAAW,CAAC;IAY5F,oFAAoF;IACpF,QAAQ,IAAI,UAAU;IAItB,uDAAuD;IACvD,UAAU,IAAI,UAAU,EAAE;IAI1B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAab;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI;IAI5C;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,0DAA0D;IAC1D,QAAQ,IAAI,MAAM,EAAE;IAQpB;;;OAGG;YACW,UAAU;IAiGxB,4DAA4D;IAC5D,OAAO,CAAC,cAAc;IAqBtB;;;OAGG;YACW,wBAAwB;IAiFtC;;;OAGG;YACY,aAAa;IAwD5B,gFAAgF;IAChF,OAAO,CAAC,yBAAyB;IAgBjC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,gBAAgB;IAqBxB;;;OAGG;IACH,gBAAgB,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,cAAc;CAU5D"}
|