@godspeedai/cognate-provider-anthropic-compatible 0.7.1 → 0.9.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.
- package/package.json +4 -4
- package/src/EGM.md +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@godspeedai/cognate-provider-anthropic-compatible",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Anthropic Messages API compatible ModelProvider with tools and SSE streaming.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
".": "./src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@godspeedai/cognate-capabilities": "^0.
|
|
26
|
-
"@godspeedai/cognate-provider-auth": "^0.
|
|
27
|
-
"@godspeedai/cognate-provider-wire": "^0.
|
|
25
|
+
"@godspeedai/cognate-capabilities": "^0.9.0",
|
|
26
|
+
"@godspeedai/cognate-provider-auth": "^0.9.0",
|
|
27
|
+
"@godspeedai/cognate-provider-wire": "^0.9.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/EGM.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# provider-anthropic-compatible / src — Anthropic Messages adapter
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A `ModelProvider` over an Anthropic-compatible `/messages` endpoint, mapping Cognate `ModelRequest`/`ModelResponse` shapes to the Anthropic Messages wire format in both unary and SSE streaming modes `[index.ts:anthropicCompatible]`. It composes `@godspeedai/cognate-provider-auth` for credential headers and `@godspeedai/cognate-provider-wire` for `sendJson`, `readSSE`, and `requestSignal` `[index.ts:3]`. The module exports `anthropicCompatible` and the `AnthropicCompatibleOptions` type `[index.ts:AnthropicCompatibleOptions]`.
|
|
6
|
+
|
|
7
|
+
## Interface
|
|
8
|
+
|
|
9
|
+
- `anthropicCompatible` — builds the provider with `generate` and `stream` `[index.ts:anthropicCompatible]`
|
|
10
|
+
- `AnthropicCompatibleOptions` — id, baseURL, model, credentials, version, fetch, timeout, context limit `[index.ts:AnthropicCompatibleOptions]`
|
|
11
|
+
- `wire` — internal request translator to the Messages wire shape `[index.ts:wire]`
|
|
12
|
+
- `finalResponse` — internal unary translator including stop-reason mapping `[index.ts:finalResponse]`
|
|
13
|
+
|
|
14
|
+
## Invariants
|
|
15
|
+
|
|
16
|
+
- A request carrying `responseFormat` is rejected with `ModelProviderError("invalid_request")` because native JSON-schema output is not implemented `[index.ts:wire]`
|
|
17
|
+
- A tool message without `toolCallId` is rejected as `invalid_request` `[index.ts:wire]`
|
|
18
|
+
- System messages are folded into the top-level `system` string and never sent as message roles `[index.ts:wire]`
|
|
19
|
+
- `max_tokens` defaults to 1024 and the default `anthropic-version` is `2023-06-01` `[index.ts:anthropicCompatible]`
|
|
20
|
+
- A stream without `message_stop` throws `malformed_response` `[index.ts:anthropicCompatible]`
|
|
21
|
+
- A `content_block_delta` with no matching open block throws `malformed_response` `[index.ts:anthropicCompatible]`
|
|
22
|
+
- Unparseable SSE data throws `malformed_response`, and an `error` event throws `unavailable` `[index.ts:anthropicCompatible]`
|
|
23
|
+
- `stop_reason` maps to `length`, `tool_calls`, `stop`, `content_filter`, or `error` `[index.ts:finalResponse]`
|
|
24
|
+
|
|
25
|
+
## Side Effects
|
|
26
|
+
|
|
27
|
+
- Outbound HTTP POST to `${baseURL}/messages`, with a trailing slash stripped from the base `[index.ts:anthropicCompatible]`
|
|
28
|
+
- Credential acquisition through the injected `CredentialSource` on every request `[index.ts:anthropicCompatible]`
|
|
29
|
+
- Streaming network read via `readSSE` and timeout/abort signalling via `requestSignal` `[index.ts:anthropicCompatible]`
|
|
30
|
+
|
|
31
|
+
## Verification
|
|
32
|
+
|
|
33
|
+
- Run: `cd packages/provider-anthropic-compatible && bun test`
|