@robota-sdk/agent-framework 3.0.0-beta.76 → 3.0.0-beta.78

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,6 +1,6 @@
1
1
  # @robota-sdk/agent-framework
2
2
 
3
- 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.
3
+ Programmatic SDK for building AI agents with Robota. Provides `InteractiveSession` as the central client-facing API, `createQuery()` for one-shot use, `createAgentRuntime()` as a composition factory for headless and multi-session consumers, session management, SDK-owned command/common APIs, permissions, hooks, streaming, context loading, bounded prompt file references, and context reference inventory.
4
4
 
5
5
  This is the **assembly layer** of the Robota ecosystem — it composes lower-level packages (`agent-core`, `agent-tools`, `agent-session`, `agent-provider`) into a cohesive SDK.
6
6
 
@@ -36,11 +36,30 @@ const queryWithOptions = createQuery({
36
36
  const detailedResponse = await queryWithOptions('Analyze the code');
37
37
  ```
38
38
 
39
+ ### Headless / multi-session runtime
40
+
41
+ For headless or multi-session consumers, `createAgentRuntime()` builds a composition root that
42
+ spawns `InteractiveSession`s sharing one configuration (provider, cwd, command modules, session
43
+ store, transports):
44
+
45
+ ```typescript
46
+ import { createAgentRuntime } from '@robota-sdk/agent-framework';
47
+ import { AnthropicProvider } from '@robota-sdk/agent-provider/anthropic';
48
+
49
+ const runtime = createAgentRuntime({
50
+ cwd: process.cwd(),
51
+ provider: new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY }),
52
+ });
53
+
54
+ // Each call composes a fresh InteractiveSession that inherits the runtime config.
55
+ const session = runtime.createSession({});
56
+ ```
57
+
39
58
  ## Features
40
59
 
41
60
  - **InteractiveSession** — Event-driven session wrapper (composition over Session). Central client-facing API for CLI, web, API server, or any other client
42
61
  - **SystemCommandExecutor + ISystemCommand** — SDK-level command execution infrastructure for product-composed command modules
43
- - **CommandRegistry, BuiltinCommandSource, SkillCommandSource** — Command registry and SDK common discovery APIs. User-visible built-ins are composed through `agent-command-*` packages.
62
+ - **CommandRegistry, BuiltinCommandSource, SkillCommandSource** — Command registry and SDK common discovery APIs. User-visible built-ins are composed through `agent-command` packages.
44
63
  - **Model Command Common APIs** — Provider-neutral `/model` helpers that resolve active provider catalogs and optionally invoke provider-owned refresh hooks
45
64
  - **createQuery()** — Provider-bound factory for one-shot AI agent interactions with streaming support
46
65
  - **Session assembly** — Internal factory wires tools, provider, config, and context for `InteractiveSession`
@@ -95,22 +114,20 @@ The SDK is **pure TypeScript with no React dependency**. The CLI is a thin TUI-o
95
114
 
96
115
  ```typescript
97
116
  import { InteractiveSession, createProjectSessionStore } from '@robota-sdk/agent-framework';
98
- import type { IInteractiveSessionOptions } from '@robota-sdk/agent-framework';
117
+ import type { IAIProvider } from '@robota-sdk/agent-core';
99
118
 
119
+ declare const provider: IAIProvider;
100
120
  const cwd = process.cwd();
101
121
  const sessionStore = createProjectSessionStore(cwd);
102
122
 
103
123
  const session = new InteractiveSession({
104
- config,
105
- context,
106
- projectInfo,
124
+ cwd,
125
+ provider,
107
126
  sessionStore, // SDK-owned project-local persistence facade
108
- resumeSessionId, // Session ID to restore, including sandbox snapshot when available
109
- forkSession, // Session ID to fork from (optional)
127
+ resumeSessionId: 'sess_123', // Session ID to restore, incl. sandbox snapshot (optional)
128
+ forkSession: false, // Fork the resumed session into a new one (optional)
110
129
  permissionMode: 'default',
111
130
  maxTurns: 10,
112
- cwd,
113
- permissionHandler: async (toolName, toolArgs) => ({ allowed: true }),
114
131
  });
115
132
 
116
133
  // Subscribe to events
@@ -147,7 +164,7 @@ await session.submit('Explain this code');
147
164
  await session.submit('Explain @AGENTS.md and @docs/SPEC.md');
148
165
 
149
166
  // Submit with display override (shown in UI) and raw input (for hook matching)
150
- await session.submit(fullPrompt, '/audit', '/rulebased-harness:audit');
167
+ await session.submit('full expanded prompt…', '/audit', '/rulebased-harness:audit');
151
168
 
152
169
  // Execute slash commands through the command layer. With the skills command module composed,
153
170
  // `/audit src/index.ts` is normalized by SDK to command "skills" with args "audit src/index.ts".
@@ -188,8 +205,10 @@ session.getSession(); // Session
188
205
 
189
206
  ```typescript
190
207
  import { SystemCommandExecutor, createSystemCommands } from '@robota-sdk/agent-framework';
191
- import type { ICommandResult } from '@robota-sdk/agent-framework';
208
+ import type { ICommandHostContext } from '@robota-sdk/agent-framework';
209
+ import type { ICommandResult } from '@robota-sdk/agent-interface-transport';
192
210
 
211
+ declare const session: ICommandHostContext;
193
212
  const executor = new SystemCommandExecutor(); // starts empty unless commands are supplied
194
213
 
195
214
  // Execute a command
@@ -210,7 +229,7 @@ executor.listCommands(); // ISystemCommand[]
210
229
  executor.hasCommand('permissions'); // boolean
211
230
  ```
212
231
 
213
- 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`.
232
+ 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`.
214
233
 
215
234
  Command modules may use SDK common APIs for shared provider-neutral behavior. For `/model`, the SDK
216
235
  resolves the active provider from settings, reads provider-owned fallback metadata from injected
@@ -235,7 +254,7 @@ These classes provide slash command discovery and aggregation for clients that e
235
254
 
236
255
  ```typescript
237
256
  import { CommandRegistry } from '@robota-sdk/agent-framework';
238
- import { createSkillsCommandModule } from '@robota-sdk/agent-command-skills';
257
+ import { createSkillsCommandModule } from '@robota-sdk/agent-command';
239
258
 
240
259
  const registry = new CommandRegistry();
241
260
  registry.addModule(createSkillsCommandModule({ cwd: process.cwd() }));
@@ -258,7 +277,7 @@ registry.resolveQualifiedName('audit'); // "my-plugin:audit"
258
277
  - `<cwd>/.agents/skills/*/SKILL.md`
259
278
 
260
279
  Model-invocable skills are exposed to the model as metadata only when the session has a composed
261
- model-invocable `skills` command descriptor. `@robota-sdk/agent-command-skills` owns `skills` and
280
+ model-invocable `skills` command descriptor. `@robota-sdk/agent-command` owns `skills` and
262
281
  activates skills through the SDK host API. Models use the SDK-projected `robota_command_skills`
263
282
  tool with skill arguments in `args`. Mentioning a skill in ordinary prose,
264
283
  recommending a skill in assistant text, or matching a natural-language phrase in SDK/TUI code does
@@ -314,6 +333,8 @@ import {
314
333
 
315
334
  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:
316
335
 
336
+ <!-- doc-example-skip: requires the optional e2b dependency -->
337
+
317
338
  ```typescript
318
339
  import { InteractiveSession } from '@robota-sdk/agent-framework';
319
340
  import { AnthropicProvider } from '@robota-sdk/agent-provider/anthropic';
@@ -340,7 +361,7 @@ const session = new InteractiveSession({
340
361
  });
341
362
  ```
342
363
 
343
- `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`.
364
+ `E2BSandboxClient` is a structural adapter owned by `agent-tools`, and it does not make `e2b` a dependency of `agent-framework`. 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`.
344
365
 
345
366
  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.
346
367
 
@@ -350,13 +371,12 @@ When `sessionStore` and a snapshot-capable `sandboxClient` are both provided, `I
350
371
 
351
372
  ```typescript
352
373
  import { createSubagentSession } from '@robota-sdk/agent-framework';
374
+ import type { ISubagentOptions } from '@robota-sdk/agent-framework';
353
375
 
354
- const subSession = createSubagentSession({
355
- parentSession: session,
356
- agentDefinition: 'explore',
357
- prompt: 'Analyze the test coverage gaps',
358
- });
359
- const result = await subSession.run();
376
+ // agentDefinition, parentConfig/parentContext/parentTools, provider, terminal, …
377
+ declare const options: ISubagentOptions;
378
+ const subSession = createSubagentSession(options);
379
+ const result = await subSession.run('Analyze the test coverage gaps');
360
380
  ```
361
381
 
362
382
  ### Agent Definitions
@@ -379,7 +399,7 @@ Provider-native payload events are emitted by concrete provider packages through
379
399
 
380
400
  ## Hook Executors (SDK-Specific)
381
401
 
382
- `agent-sdk` provides two `IHookTypeExecutor` implementations beyond the `command` and `http` executors in `agent-core`:
402
+ `agent-framework` provides two `IHookTypeExecutor` implementations beyond the `command` and `http` executors in `agent-core`:
383
403
 
384
404
  | Executor | Hook Type | Description |
385
405
  | ---------------- | --------- | ------------------------------------------------------------------------- |
@@ -411,26 +431,24 @@ Manages plugin installation and uninstallation:
411
431
 
412
432
  ## Plugins
413
433
 
414
- `agent-plugin-*` packages are **consumer opt-in** — they are not built into the CLI or SDK by default. Application consumers register plugins at composition time by passing plugin instances to the SDK assembly API.
434
+ `@robota-sdk/agent-plugin` plugins are **consumer opt-in** — they are not built into the CLI or SDK by default. Application consumers register plugins at composition time by passing plugin instances to the SDK assembly API.
415
435
 
416
436
  ```typescript
417
- import { InteractiveSession } from '@robota-sdk/agent-framework';
418
- import { AnthropicProvider } from '@robota-sdk/agent-provider/anthropic';
419
- import { ConversationHistoryPlugin } from '@robota-sdk/agent-plugin';
420
- import { LoggingPlugin } from '@robota-sdk/agent-plugin';
437
+ import { Robota } from '@robota-sdk/agent-core';
438
+ import { ConversationHistoryPlugin, LoggingPlugin } from '@robota-sdk/agent-plugin';
439
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
421
440
 
422
- const session = new InteractiveSession({
423
- cwd: process.cwd(),
424
- config,
425
- context,
441
+ declare const base: IAgentConfig;
442
+ const agent = new Robota({
443
+ ...base,
426
444
  plugins: [
427
- new ConversationHistoryPlugin({ maxMessages: 100 }),
428
- new LoggingPlugin({ level: 'info' }),
445
+ new ConversationHistoryPlugin({ storage: 'memory' }),
446
+ new LoggingPlugin({ strategy: 'console', level: 'info' }),
429
447
  ],
430
448
  });
431
449
  ```
432
450
 
433
- Each plugin implements `AbstractPlugin` from `@robota-sdk/agent-core` and depends only on `agent-core`. Available plugins: `agent-plugin-conversation-history`, `agent-plugin-error-handling`, `agent-plugin-event-emitter`, `agent-plugin-execution-analytics`, `agent-plugin-limits`, `agent-plugin-logging`, `agent-plugin-performance`, `agent-plugin-usage`, `agent-plugin-webhook`.
451
+ Each plugin implements `AbstractPlugin` from `@robota-sdk/agent-core` and depends only on `agent-core`. The 8 plugins ship consolidated in a single package, `@robota-sdk/agent-plugin`: `ConversationHistoryPlugin`, `ErrorHandlingPlugin`, `ExecutionAnalyticsPlugin`, `LimitsPlugin`, `LoggingPlugin`, `PerformancePlugin`, `UsagePlugin`, `WebhookPlugin`.
434
452
 
435
453
  ## Configuration
436
454
 
@@ -510,4 +528,4 @@ See [docs/SPEC.md](./docs/SPEC.md) for the full specification, architecture deta
510
528
 
511
529
  ## License
512
530
 
513
- MIT
531
+ Robota is dual-licensed under the [GNU AGPL-3.0](../../LICENSE) or a [commercial license](../../COMMERCIAL.md). See [LICENSING.md](../../LICENSING.md).