@robota-sdk/agent-core 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
@@ -22,8 +22,8 @@ const agent = new Robota({
22
22
  defaultModel: {
23
23
  provider: 'anthropic',
24
24
  model: 'claude-sonnet-4-6',
25
- systemMessage: 'You are a helpful assistant.',
26
25
  },
26
+ systemMessage: 'You are a helpful assistant.',
27
27
  });
28
28
 
29
29
  const response = await agent.run('Hello, world!');
@@ -52,6 +52,10 @@ console.log(response);
52
52
  ## Robota API
53
53
 
54
54
  ```typescript
55
+ import { Robota } from '@robota-sdk/agent-core';
56
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
57
+
58
+ declare const config: IAgentConfig;
55
59
  const agent = new Robota(config);
56
60
 
57
61
  // Send a message (executes tool calls automatically)
@@ -65,6 +69,80 @@ agent.clearHistory();
65
69
  agent.setModel({ provider: 'openai', model: 'gpt-4o' });
66
70
  ```
67
71
 
72
+ ### Structured Output
73
+
74
+ `run(input, { output })` returns a schema-validated object instead of a string. Zod schemas give a
75
+ typed result; the schema is forwarded to the provider's native structured-output surface where one
76
+ exists, and the response is always validated core-side with a bounded retry on violation
77
+ (`outputRetries`, default 2). Exhausted retries throw `StructuredOutputError`.
78
+
79
+ ```typescript
80
+ import { z } from 'zod';
81
+ import { Robota } from '@robota-sdk/agent-core';
82
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
83
+
84
+ declare const config: IAgentConfig;
85
+ const agent = new Robota(config);
86
+
87
+ const reportSchema = z.object({
88
+ title: z.string(),
89
+ score: z.number(),
90
+ summary: z.string(),
91
+ });
92
+
93
+ // Typed result: { title: string; score: number; summary: string }
94
+ const report = await agent.run('Summarize the meeting as a report.', {
95
+ output: reportSchema,
96
+ });
97
+
98
+ // Streaming variant: deltas stream as usual; the validated object is the
99
+ // generator's return value (the final { done: true, value } iterator result).
100
+ const stream = agent.runStream('Summarize again.', { output: reportSchema });
101
+ const iterator = stream[Symbol.asyncIterator]();
102
+ let next = await iterator.next();
103
+ while (!next.done) {
104
+ process.stdout.write(next.value);
105
+ next = await iterator.next();
106
+ }
107
+ const streamedReport = next.value;
108
+ console.log(streamedReport.title);
109
+ ```
110
+
111
+ A raw JSON-schema wrapper is also accepted: `{ output: { jsonSchema: { type: 'object', properties: { answer: { type: 'string' } }, required: ['answer'] } } }`.
112
+
113
+ ### Model Options per Run
114
+
115
+ `run`/`runStream` accept run-scoped model options that win over `defaultModel.*`:
116
+ `maxTokens`, `temperature`, and `toolChoice`. `toolChoice` directs tool invocation —
117
+ `'auto'` (model decides), `'none'` (suppress tool calls), `'required'` (must call some
118
+ tool), or `{ tool: name }` (must call the named tool). A named tool missing from the run's
119
+ tool list throws immediately; nothing is silently ignored. Forcing directives apply to the
120
+ run's first model call only — rounds after tool results revert to `'auto'` so the model can
121
+ consume the results and finish.
122
+
123
+ ```typescript
124
+ import { Robota } from '@robota-sdk/agent-core';
125
+ import type { IAgentConfig } from '@robota-sdk/agent-core';
126
+
127
+ declare const config: IAgentConfig;
128
+ const agent = new Robota(config);
129
+
130
+ // Force the model to answer via the router tool (decision-agent pattern)
131
+ const decision = await agent.run('Route this request.', {
132
+ toolChoice: { tool: 'route-request' },
133
+ allowToolOnlyCompletion: true,
134
+ });
135
+
136
+ // Suppress tools for a plain-text turn, capped at 100 output tokens
137
+ const summary = await agent.run('Summarize the discussion.', {
138
+ toolChoice: 'none',
139
+ maxTokens: 100,
140
+ });
141
+ console.log(decision, summary);
142
+ ```
143
+
144
+ The same directive can be set agent-wide via `defaultModel.toolChoice`.
145
+
68
146
  ### Execution Boundary Events
69
147
 
70
148
  `run()` accepts `onExecutionEvent` in run options. The execution loop emits provider-neutral events that higher layers can persist as append-only session provenance:
@@ -85,27 +163,27 @@ Provider-specific SDK payload capture remains provider-owned. Providers may call
85
163
 
86
164
  ## IAgentConfig
87
165
 
88
- | Field | Type | Description |
89
- | ---------------------------- | -------------------------- | ------------------------------ |
90
- | `name` | `string` | Agent name |
91
- | `aiProviders` | `IAIProvider[]` | One or more provider instances |
92
- | `defaultModel.provider` | `string` | Provider name |
93
- | `defaultModel.model` | `string` | Model identifier |
94
- | `defaultModel.systemMessage` | `string?` | System prompt |
95
- | `tools` | `IToolWithEventService[]?` | Tools the agent can call |
96
- | `plugins` | `IPluginContract[]?` | Plugins for lifecycle hooks |
166
+ | Field | Type | Description |
167
+ | ----------------------- | -------------------------- | ------------------------------ |
168
+ | `name` | `string` | Agent name |
169
+ | `aiProviders` | `IAIProvider[]` | One or more provider instances |
170
+ | `defaultModel.provider` | `string` | Provider name |
171
+ | `defaultModel.model` | `string` | Model identifier |
172
+ | `systemMessage` | `string?` | System prompt (top-level) |
173
+ | `tools` | `IToolWithEventService[]?` | Tools the agent can call |
174
+ | `plugins` | `IPluginContract[]?` | Plugins for lifecycle hooks |
97
175
 
98
176
  ## Architecture
99
177
 
100
178
  ```
101
179
  agent-core (this package — zero workspace dependencies)
102
180
  ↑
103
- agent-sessions ← Session lifecycle
181
+ agent-session ← Session lifecycle
104
182
  agent-tools ← Tool implementations
105
- agent-providers ← AI provider implementations
106
- agent-plugins ← Plugin implementations (8 extracted packages)
183
+ agent-provider ← AI provider implementations (consolidated, multi-vendor sub-paths)
184
+ agent-plugin ← Plugin implementations (8 plugins, consolidated)
107
185
  ↑
108
- agent-sdk ← Assembly layer
186
+ agent-framework ← Assembly layer
109
187
  ↑
110
188
  agent-cli ← Terminal UI
111
189
  ```
@@ -130,8 +208,8 @@ agent-cli ← Terminal UI
130
208
  | --------------------------------------------- | ---------------------------- |
131
209
  | `FunctionTool`, `ToolRegistry`, `OpenAPITool` | `@robota-sdk/agent-tools` |
132
210
  | `MCPTool`, `RelayMcpTool` | `@robota-sdk/agent-tool-mcp` |
133
- | 8 plugins (logging, usage, performance, etc.) | `@robota-sdk/agent-plugin-*` |
211
+ | 8 plugins (logging, usage, performance, etc.) | `@robota-sdk/agent-plugin` |
134
212
 
135
213
  ## License
136
214
 
137
- MIT
215
+ Robota is dual-licensed under the [GNU AGPL-3.0](../../LICENSE) or a [commercial license](../../COMMERCIAL.md). See [LICENSING.md](../../LICENSING.md).