anbaric 1.41.0 → 1.43.0

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.
@@ -3,7 +3,7 @@
3
3
  Who performs work, and how AI models plug in. Import from `anbaric`.
4
4
 
5
5
  ```ts
6
- import {Code, Human, SystemActor, Agent, OpenAIAgent, RemoteLLMAgenticAction} from "anbaric";
6
+ import {Code, Human, SystemActor, Agent, OpenAIAgent, AnthropicAgent, GeminiAgent, RemoteLLMAgenticAction} from "anbaric";
7
7
  import type {Actor, ActorType} from "anbaric";
8
8
  ```
9
9
 
@@ -155,6 +155,53 @@ const triager = new OpenAIAgent("triager", "support", {
155
155
  The optional `fetchFn` lets you inject a custom fetch (useful in tests). Requests
156
156
  that fail throw `The OpenAI request failed with status <n>`.
157
157
 
158
+ ### `AnthropicAgent`
159
+
160
+ An `Agent` backed by the Anthropic Messages API. The API has no JSON-schema
161
+ response format, so the output schema is offered as a single tool the model is
162
+ forced to call; its arguments are the structured output. System messages are
163
+ lifted out of the conversation into the API's own `system` field.
164
+
165
+ ```ts
166
+ class AnthropicAgent extends Agent
167
+ constructor(id : string, role : string, connection : AnthropicConnection, fetchFn? : FetchFn)
168
+
169
+ type AnthropicConnection = {
170
+ apiKey : string,
171
+ model : string,
172
+ baseUrl? : string, // default "https://api.anthropic.com/v1"
173
+ version? : string, // anthropic-version header, default "2023-06-01"
174
+ maxTokens? : number, // the Messages API requires a budget, default 4096
175
+ }
176
+ ```
177
+
178
+ Failures throw `The Anthropic request failed with status <n>`; a model that
179
+ answers with prose instead of calling the tool throws `The Anthropic response
180
+ carried no structured content`.
181
+
182
+ ### `GeminiAgent`
183
+
184
+ An `Agent` backed by the Gemini generative language API, asking for JSON against
185
+ the output schema. System messages become `systemInstruction`, assistant turns
186
+ are sent as the `model` role, and the API key travels as a header rather than a
187
+ query parameter.
188
+
189
+ ```ts
190
+ class GeminiAgent extends Agent
191
+ constructor(id : string, role : string, connection : GeminiConnection, fetchFn? : FetchFn)
192
+
193
+ type GeminiConnection = {
194
+ apiKey : string,
195
+ model : string,
196
+ baseUrl? : string, // default "https://generativelanguage.googleapis.com/v1beta"
197
+ }
198
+ ```
199
+
200
+ Gemini's `responseSchema` is an OpenAPI subset rather than JSON Schema, so the
201
+ schema you pass is converted: types are upper-cased and keywords it rejects
202
+ (`additionalProperties` among them) are dropped. Failures throw `The Gemini
203
+ request failed with status <n>`.
204
+
158
205
  ---
159
206
 
160
207
  ### See also
@@ -8,7 +8,7 @@ almost everything:
8
8
  import {
9
9
  StateMachine, State, Terminal, Action, Await, Transition,
10
10
  Job, PropertyDefinition,
11
- Code, Human, SystemActor, Agent, OpenAIAgent, RemoteLLMAgenticAction,
11
+ Code, Human, SystemActor, Agent, OpenAIAgent, AnthropicAgent, GeminiAgent, RemoteLLMAgenticAction,
12
12
  JsonStoreFactory, SecretStoreFactory, SqlStoreFactory, PromptManagerFactory,
13
13
  registerEntitlement, hasEntitlement,
14
14
  } from "anbaric";
@@ -26,7 +26,7 @@ An Anbaric app is a standard Node.js **ESM** program in TypeScript: set
26
26
  `Action`, `Await`, `WaitForInput`, `Transition`, `Job`, `PropertyDefinition`,
27
27
  `Actor`.
28
28
  - **[Actors and agents](actors-and-agents.md)** — `Code`, `Human`,
29
- `SystemActor`, `Agent`, `RemoteLLMAgenticAction`, `OpenAIAgent`.
29
+ `SystemActor`, `Agent`, `RemoteLLMAgenticAction`, `OpenAIAgent`, `AnthropicAgent`, `GeminiAgent`.
30
30
  - **[Stores](stores.md)** — `JsonStore`, `SecretStore`, `SqlStore`,
31
31
  `PromptManager` and their factories, plus `JsonSchema`.
32
32
  - **[Entitlements](../features/entitlements.md)** — `registerEntitlement`,
@@ -73,21 +73,40 @@ const triage = new RemoteLLMAgenticAction("Triage the ticket", triager,
73
73
  [{ role: "system", content: prompt.instructions }], prompt.outputSchema!);
74
74
  ```
75
75
 
76
- ## Bring your own model
76
+ ## Choose a provider
77
77
 
78
- `OpenAIAgent` targets any OpenAI-compatible endpoint. Configure it with a
79
- connection object:
78
+ Three agents ship with the library. They take the same `(id, role, connection)`
79
+ shape, produce the same structured output against your schema, and are
80
+ interchangeable in an agentic action - only the connection differs:
80
81
 
81
82
  ```ts
83
+ import {AnthropicAgent, GeminiAgent, OpenAIAgent} from "anbaric";
84
+
82
85
  new OpenAIAgent("triager", "support", {
83
86
  apiKey: process.env.OPENAI_API_KEY!,
84
87
  model: "gpt-5.4-mini",
85
88
  baseUrl: "https://api.openai.com/v1", // optional; override for a compatible provider
86
89
  organization: "org_...", // optional
87
90
  });
91
+
92
+ new AnthropicAgent("triager", "support", {
93
+ apiKey: process.env.ANTHROPIC_API_KEY!,
94
+ model: "claude-opus-5",
95
+ maxTokens: 4096, // optional; the Messages API needs a budget
96
+ });
97
+
98
+ new GeminiAgent("triager", "support", {
99
+ apiKey: process.env.GEMINI_API_KEY!,
100
+ model: "gemini-3-pro",
101
+ });
88
102
  ```
89
103
 
90
- For a different provider entirely, implement an `Agent.Client` (a class with a
104
+ Each asks its provider for structured output the way that provider supports it -
105
+ OpenAI's JSON-schema response format, a forced tool call on Anthropic, Gemini's
106
+ JSON response schema - so your action only ever sees properties matching the
107
+ schema you gave it.
108
+
109
+ For a provider none of them covers, implement an `Agent.Client` (a class with a
91
110
  `generate(request)` method) and pass it to a plain `Agent`. See the [API
92
111
  reference](../api/actors-and-agents.md#agents-and-ai) for the client contract.
93
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anbaric",
3
- "version": "1.41.0",
3
+ "version": "1.43.0",
4
4
  "description": "Everything needed to write an Anbaric app: state machines, jobs, document and secret stores, local in-memory implementations and the Anbaric Cloud clients",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24,9 +24,9 @@
24
24
  "prepublishOnly": "npm run build"
25
25
  },
26
26
  "dependencies": {
27
- "anbaric-impl-cloud": "^1.41.0",
28
- "anbaric-data-store": "^1.41.0",
29
- "anbaric-state-machine": "^1.41.0",
30
- "anbaric-tsapi": "^1.41.0"
27
+ "anbaric-impl-cloud": "^1.43.0",
28
+ "anbaric-data-store": "^1.43.0",
29
+ "anbaric-state-machine": "^1.43.0",
30
+ "anbaric-tsapi": "^1.43.0"
31
31
  }
32
32
  }