@rowan-agent/models 0.4.4
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 +36 -0
- package/dist/chunk-J6S6ZJJA.js +1227 -0
- package/dist/index-ChnUfIk1.d.cts +426 -0
- package/dist/index-ChnUfIk1.d.ts +426 -0
- package/dist/index.cjs +1595 -0
- package/dist/index.d.cts +109 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +337 -0
- package/dist/providers/index.cjs +1262 -0
- package/dist/providers/index.d.cts +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +26 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @rowan-agent/adapters
|
|
2
|
+
|
|
3
|
+
## Main Features
|
|
4
|
+
|
|
5
|
+
`@rowan-agent/adapters` connects external model services to the Rowan runtime protocol. The current primary implementation is an OpenAI-compatible Chat Completions adapter that resolves configuration, builds requests, handles retries and timeouts, and normalizes JSON model output into typed Rowan phase output events such as routing decisions, tasks, tool calls, and verification results.
|
|
6
|
+
|
|
7
|
+
The package also provides JSON extraction helpers. They can parse complete JSON, `json` fenced code blocks, or balanced JSON fragments embedded in text. When model output does not match the expected contract, the adapter raises `OpenAICompatibleError` or `JsonExtractionError` with useful error codes for logging and recovery.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
`src/index.ts` exports the package surface.
|
|
12
|
+
|
|
13
|
+
`src/openai-compatible.ts` is the main adapter layer and has three core responsibilities:
|
|
14
|
+
|
|
15
|
+
- `resolveOpenAICompatibleConfig` resolves `baseUrl`, `apiKey`, `model`, timeout, retry, and tool settings from input options and environment variables.
|
|
16
|
+
- `callOpenAICompatibleChatCompletion` wraps HTTP requests, response parsing, error normalization, exponential backoff retries, and abort/timeout handling.
|
|
17
|
+
- `createOpenAICompatibleStream` implements Rowan's `StreamFn`, uses `@rowan-agent/context` to build phase prompts, and converts model output into typed `phase_output` events from `@rowan-agent/protocol`.
|
|
18
|
+
|
|
19
|
+
`src/json-extract.ts` only handles JSON extraction and parse errors from model text. It is independent from model providers and runtime phases.
|
|
20
|
+
|
|
21
|
+
## Usage Flow
|
|
22
|
+
|
|
23
|
+
1. Prepare OpenAI-compatible environment variables: `ROWAN_OPENAI_BASE_URL` is optional, while `ROWAN_OPENAI_API_KEY` and `ROWAN_MODEL` are required.
|
|
24
|
+
2. Call `resolveOpenAICompatibleConfig` and pass the runtime tools through `tools`.
|
|
25
|
+
3. Call `createOpenAICompatibleStream` to create a `StreamFn` that the Rowan runtime can consume.
|
|
26
|
+
4. Pass the `stream` to `Agent` from `@rowan-agent/agent`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
createOpenAICompatibleStream,
|
|
31
|
+
resolveOpenAICompatibleConfig,
|
|
32
|
+
} from "@rowan-agent/adapters";
|
|
33
|
+
|
|
34
|
+
const config = resolveOpenAICompatibleConfig({ tools });
|
|
35
|
+
const stream = createOpenAICompatibleStream(config);
|
|
36
|
+
```
|