@robota-sdk/agent-sdk 3.0.0-beta.33 → 3.0.0-beta.34
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 +148 -26
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# @robota-sdk/agent-sdk
|
|
2
2
|
|
|
3
|
-
Programmatic SDK for building AI agents with Robota. Provides a single `query()` entry point along with
|
|
3
|
+
Programmatic SDK for building AI agents with Robota. Provides a single `query()` entry point along with session management, built-in tools, permissions, hooks, streaming, and context loading.
|
|
4
4
|
|
|
5
|
-
This is the **assembly layer** of the Robota ecosystem
|
|
5
|
+
This is the **assembly layer** of the Robota ecosystem — it composes lower-level packages (`agent-core`, `agent-tools`, `agent-sessions`, `agent-provider-anthropic`) into a cohesive SDK.
|
|
6
|
+
|
|
7
|
+
**Version**: 3.0.0-beta.33
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -31,31 +33,80 @@ const response = await query('Analyze the code', {
|
|
|
31
33
|
|
|
32
34
|
## Features
|
|
33
35
|
|
|
34
|
-
- **query()**
|
|
35
|
-
- **
|
|
36
|
-
- **Built-in Tools**
|
|
37
|
-
- **Agent Tool**
|
|
38
|
-
- **Permissions**
|
|
39
|
-
- **Hooks**
|
|
40
|
-
- **Streaming**
|
|
41
|
-
- **Context Loading**
|
|
42
|
-
- **Config Loading**
|
|
43
|
-
- **Context Window Management**
|
|
36
|
+
- **query()** — Single entry point for AI agent interactions with streaming support
|
|
37
|
+
- **createSession()** — Assembly factory: wires tools, provider, config, and context into a Session
|
|
38
|
+
- **Built-in Tools** — Bash, Read, Write, Edit, Glob, Grep (re-exported from `@robota-sdk/agent-tools`)
|
|
39
|
+
- **Agent Tool** — Sub-agent session creation for multi-agent workflows
|
|
40
|
+
- **Permissions** — 3-step evaluation (deny list, allow list, mode policy) with four modes: `plan`, `default`, `acceptEdits`, `bypassPermissions`
|
|
41
|
+
- **Hooks** — `PreToolUse`, `PostToolUse`, `PreCompact`, `PostCompact`, `SessionStart`, `UserPromptSubmit`, `Stop` events with shell command execution
|
|
42
|
+
- **Streaming** — Real-time text delta callbacks via `onTextDelta`
|
|
43
|
+
- **Context Loading** — AGENTS.md / CLAUDE.md walk-up discovery and system prompt assembly
|
|
44
|
+
- **Config Loading** — 6-layer merge (CLI flags, local, project, Claude Code compat, user global, user global Claude Code compat) with `$ENV:VAR` substitution
|
|
45
|
+
- **Context Window Management** — Token tracking, auto-compaction at ~83.5%, manual `session.compact()`
|
|
46
|
+
- **Bundle Plugin System** — Install and manage reusable extensions packaged as bundle plugins
|
|
44
47
|
|
|
45
48
|
## Architecture
|
|
46
49
|
|
|
47
50
|
```
|
|
48
51
|
agent-sdk (assembly layer)
|
|
49
52
|
-> agent-sessions (Session, SessionStore)
|
|
50
|
-
-> agent-tools (tool infrastructure +
|
|
53
|
+
-> agent-tools (tool infrastructure + 8 built-in tools)
|
|
54
|
+
-> agent-provider-anthropic (Anthropic LLM provider)
|
|
51
55
|
-> agent-core (Robota engine, providers, permissions, hooks)
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
`agent-sdk` assembles existing packages
|
|
58
|
+
`agent-sdk` assembles existing packages — it does not re-implement functionality that belongs in lower layers.
|
|
59
|
+
|
|
60
|
+
## API
|
|
61
|
+
|
|
62
|
+
### query()
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { query } from '@robota-sdk/agent-sdk';
|
|
66
|
+
|
|
67
|
+
const response = await query('Show me the file list');
|
|
68
|
+
|
|
69
|
+
const response = await query('Analyze the code', {
|
|
70
|
+
cwd: '/path/to/project',
|
|
71
|
+
permissionMode: 'acceptEdits',
|
|
72
|
+
maxTurns: 10,
|
|
73
|
+
onTextDelta: (delta) => process.stdout.write(delta),
|
|
74
|
+
onCompact: () => console.log('Context compacted'),
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### createSession()
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { createSession, loadConfig, loadContext, detectProject } from '@robota-sdk/agent-sdk';
|
|
82
|
+
|
|
83
|
+
const [config, context, projectInfo] = await Promise.all([
|
|
84
|
+
loadConfig(cwd),
|
|
85
|
+
loadContext(cwd),
|
|
86
|
+
detectProject(cwd),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
const session = createSession({ config, context, terminal, projectInfo, permissionMode });
|
|
90
|
+
const response = await session.run('Hello');
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Built-in Tools
|
|
94
|
+
|
|
95
|
+
`@robota-sdk/agent-sdk` re-exports 6 of the 8 built-in tools from `@robota-sdk/agent-tools`:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { bashTool, readTool, writeTool, editTool, globTool, grepTool } from '@robota-sdk/agent-sdk';
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`webFetchTool` and `webSearchTool` are **not** re-exported from `@robota-sdk/agent-sdk`. Import them directly from the owning package:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { webFetchTool, webSearchTool } from '@robota-sdk/agent-tools';
|
|
105
|
+
```
|
|
55
106
|
|
|
56
107
|
## Subagent Sessions
|
|
57
108
|
|
|
58
|
-
`createSubagentSession()` creates
|
|
109
|
+
`createSubagentSession()` creates an isolated child session for delegating subtasks. The subagent receives pre-resolved config and context from the parent — it does not load config files or context from disk.
|
|
59
110
|
|
|
60
111
|
```typescript
|
|
61
112
|
import { createSubagentSession } from '@robota-sdk/agent-sdk';
|
|
@@ -70,25 +121,96 @@ const result = await subSession.run();
|
|
|
70
121
|
|
|
71
122
|
### Agent Definitions
|
|
72
123
|
|
|
73
|
-
`IAgentDefinition` describes a reusable agent configuration (system prompt, allowed tools, permission mode).
|
|
124
|
+
`IAgentDefinition` describes a reusable agent configuration (system prompt, allowed tools, permission mode). Custom agents are discovered from `.robota/agents/` (project), `.claude/agents/` (Claude Code compatible), and `~/.robota/agents/` (user). `AgentDefinitionLoader` is an internal class — it is not part of the public API.
|
|
74
125
|
|
|
75
|
-
Built-in agents: `
|
|
126
|
+
Built-in agents: `general-purpose` (full tool access), `Explore` (read-only, Haiku model), `Plan` (read-only planning).
|
|
76
127
|
|
|
77
|
-
### createAgentTool
|
|
128
|
+
### createAgentTool()
|
|
78
129
|
|
|
79
|
-
`createAgentTool()` wraps subagent creation into a tool
|
|
130
|
+
`createAgentTool()` wraps subagent creation into a tool the AI can invoke directly. The parent session's hooks, permissions, and context are forwarded to the child.
|
|
80
131
|
|
|
81
|
-
##
|
|
132
|
+
## Hook Executors (SDK-Specific)
|
|
82
133
|
|
|
83
|
-
|
|
84
|
-
import { Session } from '@robota-sdk/agent-sessions';
|
|
134
|
+
`agent-sdk` provides two `IHookTypeExecutor` implementations beyond the `command` and `http` executors in `agent-core`:
|
|
85
135
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
session
|
|
89
|
-
session
|
|
136
|
+
| Executor | Hook Type | Description |
|
|
137
|
+
| ---------------- | --------- | ------------------------------------------------------------------------- |
|
|
138
|
+
| `PromptExecutor` | `prompt` | Injects the hook's prompt text into the session as a system instruction |
|
|
139
|
+
| `AgentExecutor` | `agent` | Creates a sub-agent session to process the hook input and return a result |
|
|
140
|
+
|
|
141
|
+
## Bundle Plugin System
|
|
142
|
+
|
|
143
|
+
Bundle plugins package reusable extensions (tools, hooks, permissions, system prompt additions) into installable units.
|
|
144
|
+
|
|
145
|
+
### Types
|
|
146
|
+
|
|
147
|
+
| Type | Description |
|
|
148
|
+
| ----------------------- | --------------------------------------------------------------- |
|
|
149
|
+
| `IBundlePluginManifest` | Plugin metadata: name, version, description, author, keywords |
|
|
150
|
+
| `ILoadedBundlePlugin` | Full bundle: manifest + tools, hooks, permissions, systemPrompt |
|
|
151
|
+
|
|
152
|
+
### BundlePluginLoader
|
|
153
|
+
|
|
154
|
+
Loads a bundle plugin from a directory path. Reads the manifest, resolves tool/hook definitions, and validates the bundle structure.
|
|
155
|
+
|
|
156
|
+
### BundlePluginInstaller
|
|
157
|
+
|
|
158
|
+
Manages plugin installation and uninstallation:
|
|
159
|
+
|
|
160
|
+
- Installs bundles to `~/.robota/plugins/` (user) or `.robota/plugins/` (project)
|
|
161
|
+
- Tracks installed plugins in a registry file
|
|
162
|
+
- Handles enable/disable state per plugin
|
|
163
|
+
|
|
164
|
+
## Configuration
|
|
165
|
+
|
|
166
|
+
Settings are loaded from (highest priority first):
|
|
167
|
+
|
|
168
|
+
| Layer | Path | Scope |
|
|
169
|
+
| ----- | --------------------------------- | ------------------------------------ |
|
|
170
|
+
| 1 | CLI flags / environment variables | Invocation |
|
|
171
|
+
| 2 | `.robota/settings.local.json` | Project (local) |
|
|
172
|
+
| 3 | `.robota/settings.json` | Project |
|
|
173
|
+
| 4 | `.claude/settings.json` | Project (Claude Code compatible) |
|
|
174
|
+
| 5 | `~/.robota/settings.json` | User global |
|
|
175
|
+
| 6 | `~/.claude/settings.json` | User global (Claude Code compatible) |
|
|
176
|
+
|
|
177
|
+
`$ENV:VAR` substitution is applied after merge.
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"defaultMode": "default",
|
|
182
|
+
"provider": {
|
|
183
|
+
"name": "anthropic",
|
|
184
|
+
"model": "claude-sonnet-4-6",
|
|
185
|
+
"apiKey": "$ENV:ANTHROPIC_API_KEY"
|
|
186
|
+
},
|
|
187
|
+
"permissions": {
|
|
188
|
+
"allow": ["Bash(pnpm *)"],
|
|
189
|
+
"deny": ["Bash(rm -rf *)"]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
90
192
|
```
|
|
91
193
|
|
|
194
|
+
## Permission Modes
|
|
195
|
+
|
|
196
|
+
| Mode | Read/Glob/Grep | Write/Edit | Bash |
|
|
197
|
+
| ------------------- | :------------: | :--------: | :-----: |
|
|
198
|
+
| `plan` | auto | deny | deny |
|
|
199
|
+
| `default` | auto | approve | approve |
|
|
200
|
+
| `acceptEdits` | auto | auto | approve |
|
|
201
|
+
| `bypassPermissions` | auto | auto | auto |
|
|
202
|
+
|
|
203
|
+
## Dependencies
|
|
204
|
+
|
|
205
|
+
| Package | Purpose |
|
|
206
|
+
| -------------------------------------- | ------------------------------------- |
|
|
207
|
+
| `@robota-sdk/agent-core` | Engine, providers, permissions, hooks |
|
|
208
|
+
| `@robota-sdk/agent-sessions` | Session, SessionStore |
|
|
209
|
+
| `@robota-sdk/agent-tools` | Tool infrastructure + built-in tools |
|
|
210
|
+
| `@robota-sdk/agent-provider-anthropic` | Anthropic LLM provider |
|
|
211
|
+
| `chalk` | Terminal colors (permission prompt) |
|
|
212
|
+
| `zod` | Settings schema validation |
|
|
213
|
+
|
|
92
214
|
## Documentation
|
|
93
215
|
|
|
94
216
|
See [docs/SPEC.md](./docs/SPEC.md) for the full specification, architecture details, and design decisions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.34",
|
|
4
4
|
"description": "Programmatic SDK for building AI agents with Robota — provides Session, query(), built-in tools, permissions, hooks, and context loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.js",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chalk": "^5.3.0",
|
|
26
26
|
"zod": "^3.24.0",
|
|
27
|
-
"@robota-sdk/agent-
|
|
28
|
-
"@robota-sdk/agent-sessions": "3.0.0-beta.
|
|
29
|
-
"@robota-sdk/agent-
|
|
30
|
-
"@robota-sdk/agent-tools": "3.0.0-beta.
|
|
27
|
+
"@robota-sdk/agent-core": "3.0.0-beta.34",
|
|
28
|
+
"@robota-sdk/agent-sessions": "3.0.0-beta.34",
|
|
29
|
+
"@robota-sdk/agent-provider-anthropic": "3.0.0-beta.34",
|
|
30
|
+
"@robota-sdk/agent-tools": "3.0.0-beta.34"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"rimraf": "^5.0.5",
|