
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@robota-sdk/agent-sdk
Advanced tools
Programmatic SDK for building AI agents with Robota — provides InteractiveSession, createQuery(), command APIs, permissions, hooks, and context loading
Programmatic SDK for building AI agents with Robota. Provides InteractiveSession as the central client-facing API, createQuery() for one-shot use, session management, SDK-owned command/common APIs, permissions, hooks, streaming, context loading, bounded prompt file references, and context reference inventory.
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.
npm install @robota-sdk/agent-sdk
# or
pnpm add @robota-sdk/agent-sdk
import { createQuery } from '@robota-sdk/agent-sdk';
import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
const provider = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY });
const query = createQuery({ provider });
// Simple one-shot query
const response = await query('Show me the file list');
// With options
const queryWithOptions = createQuery({
provider,
cwd: '/path/to/project',
permissionMode: 'acceptEdits',
maxTurns: 10,
onTextDelta: (delta) => process.stdout.write(delta),
});
const detailedResponse = await queryWithOptions('Analyze the code');
agent-command-* packages./model helpers that resolve active provider catalogs and optionally invoke provider-owned refresh hooksInteractiveSession@robota-sdk/agent-toolssandboxClient injection routes Bash and core file tools through a provider-backed execution plane; workspaceManifest can prepare a fresh sandbox workspace before session creationsandboxSnapshotId on shutdown and restore it before saved message replay on non-fork resumeplan, default, acceptEdits, bypassPermissionsPreToolUse, PostToolUse, PreCompact, PostCompact, SessionStart, UserPromptSubmit, Stop events with shell command executiononTextDelta@file prompt references are resolved by the SDK under the session cwd, bounded by size/recursion limits, recorded as structured history events, and registered as observed context references/context add references are stored by InteractiveSession, included in future prompt model input, and exposed through SDK command common APIs$ENV:VAR substitution for provider credentialssession.compact()Agent({ jobs: [...] }) starts explicit parallel subagent requests deterministicallyagent-sdk (assembly layer)
├── InteractiveSession ← central client-facing API (event-driven)
│ └── Session ← generic session (agent-sessions)
├── SystemCommandExecutor ← SDK-level command execution
├── CommandRegistry / BuiltinCommandSource / SkillCommandSource
├── Agent runtime dependencies and background orchestration
├── Edit checkpoints and command-driven memory
├── createQuery() ← one-shot entry point factory
├── createSession() ← internal assembly factory
└── deps:
agent-sessions (Session, SessionStore)
agent-tools (tool infrastructure + 8 built-in tools)
agent-provider-anthropic (Anthropic LLM provider)
agent-core (Robota engine, providers, permissions, hooks)
agent-cli (TUI layer — bridges InteractiveSession events to React/Ink state)
→ agent-sdk
The SDK is pure TypeScript with no React dependency. The CLI is a thin TUI-only layer that consumes InteractiveSession events and maps them to React state. Any other client (web app, API server, worker) can do the same.
InteractiveSession wraps Session (composition over inheritance) to provide event-driven interaction for any client. It manages streaming text accumulation, tool execution state tracking, prompt queuing, abort orchestration, and message history. Logic that was previously embedded in CLI React hooks now lives here.
import { InteractiveSession, createProjectSessionStore } from '@robota-sdk/agent-sdk';
import type { IInteractiveSessionOptions } from '@robota-sdk/agent-sdk';
const cwd = process.cwd();
const sessionStore = createProjectSessionStore(cwd);
const session = new InteractiveSession({
config,
context,
projectInfo,
sessionStore, // SDK-owned project-local persistence facade
resumeSessionId, // Session ID to restore, including sandbox snapshot when available
forkSession, // Session ID to fork from (optional)
permissionMode: 'default',
maxTurns: 10,
cwd,
permissionHandler: async (toolName, toolArgs) => ({ allowed: true }),
});
// Subscribe to events
session.on('text_delta', (delta: string) => {
process.stdout.write(delta); // streaming text chunk
});
session.on('tool_start', (state) => {
console.log(`Running: ${state.toolName}`);
});
session.on('tool_end', (state) => {
console.log(`Done: ${state.toolName} — ${state.result}`);
});
session.on('thinking', (isThinking: boolean) => {
// show/hide spinner
});
session.on('complete', (result) => {
console.log(result.response);
});
session.on('error', (error: Error) => {
console.error(error);
});
session.on('context_update', (state) => {
// token usage updated
});
session.on('interrupted', (result) => {
// abort completed
});
// Submit a prompt (queues if already executing, max 1 queued)
await session.submit('Explain this code');
// Path-like @file references are expanded into model-only prompt context by the SDK.
// The user-visible history keeps the original prompt plus a structured file-reference event.
await session.submit('Explain @AGENTS.md and @docs/SPEC.md');
// Submit with display override (shown in UI) and raw input (for hook matching)
await session.submit(fullPrompt, '/audit', '/rulebased-harness:audit');
// Execute slash commands through the command layer. With the skills command module composed,
// `/audit src/index.ts` is normalized by SDK to command "skills" with args "audit src/index.ts".
await session.executeCommand('audit', 'src/index.ts');
// Abort current execution and clear queue
session.abort();
// Cancel queued prompt without aborting current execution
session.cancelQueue();
// Execute system commands
const result = await session.executeCommand('context', '');
// result.message, result.success, result.data
// List all registered system commands
session.listCommands(); // Array<{ name, description }>
// State queries
session.isExecuting(); // boolean
session.getPendingPrompt(); // string | null
session.getMessages(); // TUniversalMessage[]
session.getContextState(); // IContextWindowState
session.getStreamingText(); // string (accumulated so far)
session.getActiveTools(); // IToolState[]
// Session naming
session.getName(); // string | undefined
session.setName('my-task'); // sets the session name
// Access underlying Session for advanced use
session.getSession(); // Session
SystemCommandExecutor executes named system commands against an InteractiveSession. Commands are pure TypeScript — no React, no TUI dependency. The CLI wraps them as slash commands with UI chrome.
import { SystemCommandExecutor, createSystemCommands } from '@robota-sdk/agent-sdk';
import type { ICommandResult } from '@robota-sdk/agent-sdk';
const executor = new SystemCommandExecutor(); // starts empty unless commands are supplied
// Execute a command
const result: ICommandResult | null = await executor.execute('status', session, '');
if (result) {
console.log(result.message); // "OK"
}
// Register a custom command
executor.register({
name: 'status',
description: 'Show agent status',
execute: (session, args) => ({ message: 'OK', success: true }),
});
// List all commands
executor.listCommands(); // ISystemCommand[]
executor.hasCommand('permissions'); // boolean
SDK core does not own user-visible built-in commands. Product built-ins are supplied as agent-command-* modules. SDK command identity is slash-free (skills, help, compact); UI shells render and parse those commands as slash syntax such as /skills, /help, and /compact.
Command modules may use SDK common APIs for shared provider-neutral behavior. For /model, the SDK
resolves the active provider from settings, reads provider-owned fallback metadata from injected
IProviderDefinition records, and can invoke provider-owned catalog refresh hooks. The CLI/TUI must
only render command results and must not own provider model lists.
For provider setup, the SDK projects provider-owned setup help links from IProviderDefinition
records into generic prompt descriptions. The CLI/TUI renders those descriptions without owning
provider-specific API key or console URLs.
For /permissions, the SDK owns permission-mode constants, subcommand descriptors, validation,
state formatting, and command-host adapter access. The command module owns user-visible behavior and
keeps permission-mode changes under /permissions [mode].
For /validate-session, the session command module calls SDK session command APIs to locate and
validate the current JSONL session log. Hosts may override validateCurrentSessionReplayLog() in
ICommandHostContext when they own a non-file-backed session log store.
These classes provide slash command discovery and aggregation for clients that expose a command palette or autocomplete UI.
import { CommandRegistry } from '@robota-sdk/agent-sdk';
import { createSkillsCommandModule } from '@robota-sdk/agent-command-skills';
const registry = new CommandRegistry();
registry.addModule(createSkillsCommandModule({ cwd: process.cwd() }));
// Get all commands (returns ICommand[])
const commands = registry.getCommands();
// Filter by prefix (for autocomplete)
const filtered = registry.getCommands('mod'); // matches "mode", "model"
// Resolve short plugin name to fully qualified form
registry.resolveQualifiedName('audit'); // "my-plugin:audit"
SkillCommandSource is the SDK common API used by the skills command module. It discovers skills from (highest priority first):
<cwd>/.claude/skills/*/SKILL.md<cwd>/.claude/commands/*.md (Claude Code compatible)~/.robota/skills/*/SKILL.md<cwd>/.agents/skills/*/SKILL.mdModel-invocable skills are exposed to the model as metadata only when the session has a composed
model-invocable skills command descriptor. @robota-sdk/agent-command-skills owns skills and
activates skills through the SDK host API. Models use the SDK-projected robota_command_skills
tool with skill arguments in args. Mentioning a skill in ordinary prose,
recommending a skill in assistant text, or matching a natural-language phrase in SDK/TUI code does
not activate the skill.
import { createQuery } from '@robota-sdk/agent-sdk';
import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
const provider = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY });
const query = createQuery({ provider });
const response = await query('Show me the file list');
const queryWithOptions = createQuery({
provider,
cwd: '/path/to/project',
permissionMode: 'acceptEdits',
maxTurns: 10,
onTextDelta: (delta) => process.stdout.write(delta),
});
const detailedResponse = await queryWithOptions('Analyze the code');
createSession(), loadConfig(), loadContext(), and detectProject() are internal SDK assembly
details. Use InteractiveSession for event-driven sessions or createQuery() for prompt-only
one-shot calls.
@robota-sdk/agent-sdk assembles built-in tools for SDK sessions, but direct tool usage imports
from the owner package:
import {
bashTool,
editTool,
globTool,
grepTool,
readTool,
webFetchTool,
webSearchTool,
writeTool,
} from '@robota-sdk/agent-tools';
SDK sessions can receive a provider-neutral sandbox client. When provided, Bash, Read, Write, and Edit use the sandbox execution plane instead of the host process/filesystem:
import { InteractiveSession } from '@robota-sdk/agent-sdk';
import { AnthropicProvider } from '@robota-sdk/agent-provider-anthropic';
import { E2BSandboxClient } from '@robota-sdk/agent-tools';
import type { IWorkspaceManifest } from '@robota-sdk/agent-tools';
import { Sandbox } from 'e2b';
const provider = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY });
const sandbox = await Sandbox.create();
const workspaceManifest: IWorkspaceManifest = {
entries: {
'task.md': { type: 'file', content: 'Review this repository.\n' },
repo: { type: 'gitRepo', url: 'https://github.com/example/project.git', ref: 'main' },
output: { type: 'dir' },
},
};
const session = new InteractiveSession({
cwd: process.cwd(),
provider,
sandboxClient: new E2BSandboxClient({ sandbox }),
workspaceManifest,
reversibleExecution: { mode: 'local-first' },
});
E2BSandboxClient is a structural adapter owned by agent-tools, and it does not make e2b a dependency of agent-sdk. Install and create the concrete provider SDK in the application layer, then pass the adapter into InteractiveSession. workspaceManifest also uses the agent-tools contract; SDK applies it once before constructing the underlying Session.
When sessionStore and a snapshot-capable sandboxClient are both provided, InteractiveSession.shutdown() stores sandboxSnapshotId in the session record. A later non-fork resumeSessionId restore calls sandboxClient.restore(snapshotId) before saved messages are injected back into the Session. Forked sessions intentionally do not hydrate the previous sandbox reference because provider pause/resume references can be one-to-one.
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. Callers may provide a stable sessionId and sessionLogger so the child session writes a durable transcript.
import { createSubagentSession } from '@robota-sdk/agent-sdk';
const subSession = createSubagentSession({
parentSession: session,
agentDefinition: 'explore',
prompt: 'Analyze the test coverage gaps',
});
const result = await subSession.run();
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.
Built-in agents: general-purpose (full tool access), Explore (read-only, Haiku model), Plan (read-only planning).
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.
Background subagent lifecycle events are persisted through InteractiveSession when an SDK session persistence facade is configured. Streaming chunks are written to append-only JSONL logs/transcripts rather than rewriting the main session JSON per token.
Session.run() forwards core execution events through the session logger. Current events include provider request envelopes, provider-native raw request/response/stream payloads, provider-normalized responses, assistant message commits, tool batch starts, tool execution requests, and tool execution results.
Provider-native payload events are emitted by concrete provider packages through IChatOptions.onProviderNativeRawPayload, then redacted and externalized by the session logger before they are written to disk. The SDK exposes session command APIs so command modules such as /validate-session can validate replay coverage without adding file-log logic to CLI/TUI hosts.
agent-sdk provides two IHookTypeExecutor implementations beyond the command and http executors in agent-core:
| Executor | Hook Type | Description |
|---|---|---|
PromptExecutor | prompt | Injects the hook's prompt text into the session as a system instruction |
AgentExecutor | agent | Creates a sub-agent session to process the hook input and return a result |
Bundle plugins package reusable extensions (tools, hooks, permissions, system prompt additions) into installable units.
| Type | Description |
|---|---|
IBundlePluginManifest | Plugin metadata: name, version, description, author, keywords |
ILoadedBundlePlugin | Full bundle: manifest + tools, hooks, permissions, systemPrompt |
Loads a bundle plugin from a directory path. Reads the manifest, resolves tool/hook definitions, and validates the bundle structure.
Manages plugin installation and uninstallation:
~/.robota/plugins/ (user) or .robota/plugins/ (project)Settings are merged from lowest to highest priority:
| Layer | Path | Scope |
|---|---|---|
| 1 | ~/.robota/settings.json | User global |
| 2 | ~/.claude/settings.json | User global (Claude Code compatible) |
| 3 | .robota/settings.json | Project |
| 4 | .robota/settings.local.json | Project (local) |
| 5 | .claude/settings.json | Project (Claude Code compatible) |
| 6 | .claude/settings.local.json | Project (local, Claude Code compatible) |
$ENV:VAR substitution is applied after merge for provider API keys.
{
"defaultMode": "default",
"currentProvider": "qwen",
"providers": {
"qwen": {
"type": "qwen",
"model": "qwen-plus",
"apiKey": "$ENV:DASHSCOPE_API_KEY",
"baseURL": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
},
"gemma": {
"type": "gemma",
"model": "supergemma4-26b-uncensored-v2",
"apiKey": "lm-studio",
"baseURL": "http://localhost:1234/v1"
},
"openai": {
"type": "openai",
"model": "<openai-compatible-model>",
"apiKey": "$ENV:OPENAI_API_KEY"
},
"anthropic": {
"type": "anthropic",
"model": "claude-sonnet-4-6",
"apiKey": "$ENV:ANTHROPIC_API_KEY"
}
},
"permissions": {
"allow": ["Bash(pnpm *)"],
"deny": ["Bash(rm -rf *)"]
}
}
currentProvider selects the active entry from providers. Qwen Model Studio profiles use type: "qwen" with the documented DashScope OpenAI-compatible baseURL. DeepSeek API profiles use type: "deepseek" with the documented DeepSeek OpenAI-compatible baseURL. Gemma-family local models should use a type: "gemma" profile so provider-specific stream projection is applied. The resolved SDK config normalizes the active profile into provider.name, provider.model, provider.apiKey, optional provider.baseURL, and optional provider.timeout. The legacy provider object remains supported when currentProvider is not configured.
| Mode | Read/Glob/Grep | Write/Edit | Bash |
|---|---|---|---|
plan | auto | deny | deny |
default | auto | approve | approve |
acceptEdits | auto | auto | approve |
bypassPermissions | auto | auto | auto |
| Package | Purpose |
|---|---|
@robota-sdk/agent-core | Engine, providers, permissions, hooks |
@robota-sdk/agent-sessions | Session, SessionStore |
@robota-sdk/agent-tools | Tool infrastructure + built-in tools |
@robota-sdk/agent-provider-anthropic | Anthropic LLM provider |
chalk | Terminal colors (permission prompt) |
zod | Settings schema validation |
See docs/SPEC.md for the full specification, architecture details, and design decisions.
MIT
FAQs
Programmatic SDK for building AI agents with Robota — provides InteractiveSession, createQuery(), command APIs, permissions, hooks, and context loading
We found that @robota-sdk/agent-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.