@robota-sdk/agent-sdk 3.0.0-beta.33 → 3.0.0-beta.35

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 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 Session management, built-in tools, permissions, hooks, streaming, and context loading.
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 -- it composes lower-level packages (`agent-core`, `agent-tools`, `agent-sessions`) into a cohesive SDK.
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()** -- Single entry point for AI agent interactions with streaming support
35
- - **Session** -- Wraps the Robota engine with permission checks, tool wiring, history, and streaming
36
- - **Built-in Tools** -- Bash, Read, Write, Edit, Glob, Grep (from `@robota-sdk/agent-tools`)
37
- - **Agent Tool** -- Sub-agent session creation for multi-agent workflows
38
- - **Permissions** -- 3-step evaluation (deny list, allow list, mode policy) with four modes: `plan`, `default`, `acceptEdits`, `bypassPermissions`
39
- - **Hooks** -- `PreToolUse`, `PostToolUse`, `SessionStart`, `Stop` events with shell command execution
40
- - **Streaming** -- Real-time text delta callbacks via `onTextDelta`
41
- - **Context Loading** -- AGENTS.md / CLAUDE.md walk-up discovery and system prompt assembly
42
- - **Config Loading** -- 3-layer merge (user global, project, local) with `$ENV:VAR` substitution
43
- - **Context Window Management** -- Token tracking, auto-compaction at ~83.5%, manual `session.compact()`
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 + 6 built-in tools)
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 -- it does not re-implement functionality that belongs in lower layers.
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 a child session for delegating subtasks. The subagent forks the parent's context, inherits hooks and permissions, and runs with its own conversation history.
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). `AgentDefinitionLoader` discovers definitions from `.claude/agents/` and built-in defaults.
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: `explore` (read-only), `plan` (read-only planning), and a general-purpose agent with full tool access.
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 that the AI can invoke directly. The parent session's hooks, permissions, and context are forwarded to the child. The tool assembles the subagent prompt from the agent definition and the caller's instructions.
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
- ## Session Usage
132
+ ## Hook Executors (SDK-Specific)
82
133
 
83
- ```typescript
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
- const session = new Session({ config, context, terminal, permissionMode });
87
- const response = await session.run('Hello');
88
- session.getHistory();
89
- session.clearHistory();
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.