@backendkit-labs/agent-core 0.14.0 → 0.15.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 +149 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @backendkit-labs/agent-core
|
|
2
|
+
|
|
3
|
+
Generic multi-agent engine for TypeScript — model-agnostic, transport-agnostic, extensible.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @backendkit-labs/agent-core
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createBaseEngine } from '@backendkit-labs/agent-core';
|
|
15
|
+
import { AnthropicProvider } from '@backendkit-labs/agent-coding';
|
|
16
|
+
|
|
17
|
+
const engine = createBaseEngine({
|
|
18
|
+
providers: { claude: new AnthropicProvider(process.env.ANTHROPIC_API_KEY!) },
|
|
19
|
+
defaultProvider: 'claude',
|
|
20
|
+
agents: [{
|
|
21
|
+
id: 'assistant',
|
|
22
|
+
name: 'Assistant',
|
|
23
|
+
description: 'A helpful assistant',
|
|
24
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
25
|
+
allowedTools: [],
|
|
26
|
+
delegatesTo: [],
|
|
27
|
+
}],
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await engine.run('Hello, what can you do?');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or scaffold a full project:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx create-bk-agent my-project
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Agent types
|
|
42
|
+
|
|
43
|
+
| Factory | Package | Use case |
|
|
44
|
+
|---------|---------|---------|
|
|
45
|
+
| `createBaseEngine` | `agent-core` | Full control — bring your own agents, tools, provider |
|
|
46
|
+
| `createCodingEngine` | `agent-coding` | Coding assistant with file tools, git, code execution |
|
|
47
|
+
| `createAutonomousAgent` | `agent-core` | Event-driven — cron, webhooks, custom events |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Key APIs
|
|
52
|
+
|
|
53
|
+
### `createBaseEngine(opts)`
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { createBaseEngine } from '@backendkit-labs/agent-core';
|
|
57
|
+
|
|
58
|
+
const engine = createBaseEngine({
|
|
59
|
+
providers: { [id]: provider }, // LLMProvider instances
|
|
60
|
+
defaultProvider: 'my-provider',
|
|
61
|
+
agents: [agentProfile], // AgentProfile[]
|
|
62
|
+
tools: [toolDef], // ToolDefinition[]
|
|
63
|
+
defaultAgent: 'agent-id',
|
|
64
|
+
workingDir: process.cwd(), // for file tool sandboxing
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await engine.run('user input');
|
|
68
|
+
engine.abort(); // cancel in-flight request
|
|
69
|
+
engine.updateWorkingDir('/new/path'); // live workspace switch
|
|
70
|
+
engine.reloadSkills(); // reload YAML skills from disk
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `createAutonomousAgent(opts)`
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { createAutonomousAgent } from '@backendkit-labs/agent-core';
|
|
77
|
+
|
|
78
|
+
const agent = createAutonomousAgent({
|
|
79
|
+
providers, defaultProvider, agents,
|
|
80
|
+
goal: 'Monitor PRs and flag security issues',
|
|
81
|
+
triggers: [
|
|
82
|
+
{ type: 'schedule', cron: '0 9 * * 1-5', task: 'Send daily digest' },
|
|
83
|
+
{ type: 'webhook', path: '/github/pr', secret: process.env.GH_SECRET },
|
|
84
|
+
{ type: 'event', topic: 'ci.failed' },
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await agent.start();
|
|
89
|
+
process.on('SIGTERM', () => agent.stop());
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### `defineTool(opts)`
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { defineTool, z } from '@backendkit-labs/agent-core';
|
|
96
|
+
|
|
97
|
+
const myTool = defineTool({
|
|
98
|
+
name: 'get_weather',
|
|
99
|
+
description: 'Get current weather for a city',
|
|
100
|
+
input: z.object({
|
|
101
|
+
city: z.string().describe('City name'),
|
|
102
|
+
}),
|
|
103
|
+
execute: async ({ city }) => {
|
|
104
|
+
return `Weather in ${city}: sunny, 22°C`;
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `SkillManager` — install skill packs
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { createSkillManager } from '@backendkit-labs/agent-core';
|
|
113
|
+
|
|
114
|
+
const manager = createSkillManager('my-app');
|
|
115
|
+
await manager.install('https://github.com/my-org/my-skills');
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Slash commands
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { SlashCommandRegistry, registerBuiltinCommands } from '@backendkit-labs/agent-core';
|
|
122
|
+
|
|
123
|
+
const registry = new SlashCommandRegistry();
|
|
124
|
+
registerBuiltinCommands(registry); // adds /help /agents /skills /workspace etc.
|
|
125
|
+
|
|
126
|
+
registry.register('/my-command', 'Description', async (ctx) => {
|
|
127
|
+
ctx.emit('Hello from my command!');
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Sub-path exports
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { ... } from '@backendkit-labs/agent-core'; // main
|
|
137
|
+
import { ... } from '@backendkit-labs/agent-core/orchestration'; // Orchestrator, FSM, PolicyEngine
|
|
138
|
+
import { ... } from '@backendkit-labs/agent-core/skills'; // SkillLoader, SkillManager
|
|
139
|
+
import { ... } from '@backendkit-labs/agent-core/workflow'; // WorkflowBuilder, WorkflowRunner
|
|
140
|
+
import { ... } from '@backendkit-labs/agent-core/triggers'; // TriggerManager, createAutonomousAgent
|
|
141
|
+
import { ... } from '@backendkit-labs/agent-core/memory'; // MemorySystem, EpisodicMemory
|
|
142
|
+
import { ... } from '@backendkit-labs/agent-core/observability'; // ObservabilityManager, Tracer
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT © [BackendKit Labs](https://github.com/BackendKit-labs)
|