opencode-crs-bedrock 1.0.6 → 1.0.8

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.
Files changed (3) hide show
  1. package/README.md +58 -98
  2. package/index.ts +5 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -25,54 +25,33 @@ This plugin transforms the CRS response stream to match what the Anthropic SDK e
25
25
 
26
26
  ## Installation
27
27
 
28
- ### Local Development
28
+ ```bash
29
+ npm install -g opencode-crs-bedrock
30
+ ```
29
31
 
30
- Reference directly in your OpenCode config:
32
+ Or add to your OpenCode config to auto-install:
31
33
 
32
34
  ```json
33
35
  {
34
- "plugin": [
35
- "file:///path/to/opencode-crs-bedrock"
36
- ]
36
+ "plugin": ["opencode-crs-bedrock@latest"]
37
37
  }
38
38
  ```
39
39
 
40
- ### From npm (when published)
41
-
42
- ```bash
43
- npm install -g opencode-crs-bedrock
44
- ```
45
-
46
- ## Configuration
47
-
48
- > **Note**: Both `apiKey` and `baseURL` are optional. You can configure them via environment variables, use `opencode auth login crs` for interactive setup, or configure them directly in the config file.
49
-
50
- ### Option 1: Using Environment Variables (Recommended)
51
-
52
- Set environment variables for automatic configuration:
53
-
54
- ```bash
55
- export ANTHROPIC_BASE_URL=https://your-crs-endpoint.com/api
56
- export ANTHROPIC_AUTH_TOKEN=cr_your_api_key_here
57
- ```
40
+ ## Quick Start
58
41
 
59
- Add to your shell profile (`~/.bashrc`, `~/.zshrc`) to persist.
42
+ ### Step 1: Configure OpenCode
60
43
 
61
- Then create `opencode.json` in your project or `~/.config/opencode/opencode.json`:
44
+ Create or edit `opencode.json` in your project root or `~/.config/opencode/opencode.json`:
62
45
 
63
46
  ```json
64
47
  {
65
48
  "$schema": "https://opencode.ai/config.json",
66
49
  "plugin": [
67
- "opencode-crs-bedrock"
50
+ "opencode-crs-bedrock@latest"
68
51
  ],
69
52
  "provider": {
70
53
  "crs": {
71
54
  "npm": "@ai-sdk/anthropic",
72
- "options": {
73
- "baseURL": "{env:ANTHROPIC_BASE_URL}",
74
- "apiKey": "{env:ANTHROPIC_AUTH_TOKEN}"
75
- },
76
55
  "models": {
77
56
  "claude-opus-4-5": {
78
57
  "name": "Opus 4.5 [CRS]",
@@ -97,64 +76,28 @@ Then create `opencode.json` in your project or `~/.config/opencode/opencode.json
97
76
  }
98
77
  ```
99
78
 
100
- ### Option 2: Using OpenCode Auth (Interactive)
79
+ ### Step 2: Authenticate
101
80
 
102
- The plugin supports interactive authentication. First, create the config **without** `baseURL` or `apiKey`:
103
-
104
- ```json
105
- {
106
- "$schema": "https://opencode.ai/config.json",
107
- "plugin": [
108
- "opencode-crs-bedrock"
109
- ],
110
- "provider": {
111
- "crs": {
112
- "npm": "@ai-sdk/anthropic",
113
- "models": {
114
- "claude-sonnet-4-5": {
115
- "name": "Sonnet 4.5 [CRS]",
116
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
117
- }
118
- }
119
- }
120
- }
121
- }
122
- ```
123
-
124
- Then run the auth login command to store your credentials:
81
+ Run the OpenCode auth login command:
125
82
 
126
83
  ```bash
127
- opencode auth login crs
84
+ opencode auth login
128
85
  ```
129
86
 
130
- OpenCode will prompt you to enter your CRS API key, which will be securely stored. The plugin's auth loader will then be triggered automatically to configure the custom fetch handler for CRS/Bedrock compatibility.
87
+ When prompted:
88
+ 1. Select **Other provider**
89
+ 2. Enter provider id: **`crs`**
90
+ 3. Enter your CRS API key (starts with `cr_`)
131
91
 
132
- ### Option 3: Direct Configuration (No Environment Variables)
92
+ Your credentials will be securely stored and the plugin will automatically configure the custom fetch handler for CRS/Bedrock compatibility
133
93
 
134
- You can also hardcode credentials directly in the config (not recommended for shared configs):
135
-
136
- ```json
137
- {
138
- "provider": {
139
- "crs": {
140
- "npm": "@ai-sdk/anthropic",
141
- "options": {
142
- "baseURL": "https://your-crs-endpoint.com/api",
143
- "apiKey": "cr_your_api_key_here"
144
- },
145
- "models": { /* ... */ }
146
- }
147
- }
148
- }
149
- ```
150
-
151
- ### Using the Model
94
+ ## Usage
152
95
 
153
96
  ```bash
154
97
  # Interactive mode
155
98
  opencode
156
99
 
157
- # Or direct run with default model
100
+ # Or direct run with a specific model
158
101
  opencode run -m crs/claude-sonnet-4-5 "Hello, world!"
159
102
 
160
103
  # Use with thinking budget variants
@@ -192,6 +135,9 @@ Models available through CRS/Bedrock:
192
135
  |----------|------------|
193
136
  | `claude-sonnet-4-20250514` | `us.anthropic.claude-sonnet-4-20250514-v1:0` |
194
137
  | `claude-opus-4-20250514` | `us.anthropic.claude-opus-4-20250514-v1:0` |
138
+ | `claude-opus-4-5-20251101` | `us.anthropic.claude-opus-4-5-20251101-v1:0` |
139
+ | `claude-haiku-4-5-20251001` | `us.anthropic.claude-haiku-4-5-20251001-v1:0` |
140
+ | `claude-sonnet-4-5-20250929` | `us.anthropic.claude-sonnet-4-5-20250929-v1:0` |
195
141
  | `claude-3-5-sonnet-20241022` | `us.anthropic.claude-3-5-sonnet-20241022-v2:0` |
196
142
  | `claude-3-5-haiku-20241022` | `us.anthropic.claude-3-5-haiku-20241022-v1:0` |
197
143
  | `claude-3-opus-20240229` | `us.anthropic.claude-3-opus-20240229-v1:0` |
@@ -228,44 +174,58 @@ The inference scores each tool by:
228
174
 
229
175
  ## Troubleshooting
230
176
 
231
- ### "Invalid input: expected array, received undefined"
177
+ ### Authentication Issues
232
178
 
233
- This error means tool name inference failed. Enable debug logging to see which tool was inferred.
179
+ **Check stored credentials:**
180
+ ```bash
181
+ opencode auth list
182
+ ```
234
183
 
235
- ### API Key Format
184
+ If your CRS credentials aren't listed, run the authentication step again:
185
+ ```bash
186
+ opencode auth login
187
+ ```
236
188
 
237
- CRS API keys start with `cr_`. The plugin uses the `x-api-key` header instead of the standard Anthropic auth.
189
+ Make sure to:
190
+ - Select **Other provider**
191
+ - Enter provider id: **`crs`**
192
+ - Enter your CRS API key (starts with `cr_`)
238
193
 
239
- ### Connection Issues
194
+ ### "Invalid input: expected array, received undefined"
195
+
196
+ This error means tool name inference failed. Enable debug logging to see which tool was inferred:
240
197
 
241
- 1. Check your authentication method:
242
- - **Environment variables**: Verify they're set:
243
- ```bash
244
- echo $ANTHROPIC_BASE_URL
245
- echo $ANTHROPIC_AUTH_TOKEN
246
- ```
247
- - **OpenCode auth**: Run `opencode auth list` to see stored credentials
248
- - **Direct config**: Check your `opencode.json` has correct values
198
+ ```bash
199
+ CRS_DEBUG_SSE=true opencode run -m crs/claude-sonnet-4-5 "test"
200
+ ```
201
+
202
+ ### Connection Issues
249
203
 
250
- 2. Test the endpoint (if using environment variables):
204
+ 1. Verify your credentials are stored:
251
205
  ```bash
252
- curl -H "x-api-key: $ANTHROPIC_AUTH_TOKEN" "$ANTHROPIC_BASE_URL/v1/messages"
206
+ opencode auth list
253
207
  ```
254
208
 
255
- 3. Enable debug logging:
209
+ 2. Check your `opencode.json` has the correct provider configuration (see Quick Start above)
210
+
211
+ 3. Enable debug logging to see request details:
256
212
  ```bash
257
213
  CRS_DEBUG_SSE=true opencode run -m crs/claude-sonnet-4-5 "test"
258
214
  ```
259
215
 
260
- ### Missing API Key or Base URL
216
+ ## Local Development
261
217
 
262
- Both `apiKey` and `baseURL` are **optional** in the plugin:
218
+ For contributors working on the plugin itself:
263
219
 
264
- - If **not provided via environment variables or config**, use `opencode auth login crs` to store credentials interactively
265
- - The plugin defaults to `https://crs.tonob.net/api` if no `baseURL` is specified
266
- - You can mix and match: set `baseURL` in config and use `opencode auth login` for the `apiKey`, or vice versa
220
+ ```json
221
+ {
222
+ "plugin": [
223
+ "file:///path/to/opencode-crs-bedrock"
224
+ ]
225
+ }
226
+ ```
267
227
 
268
- **Important**: The plugin's custom fetch handler (which fixes CRS/Bedrock compatibility issues) is only activated when using `opencode auth login` or environment variables. If you hardcode credentials directly in the config, the auth loader may not be triggered.
228
+ Reference the local directory in your OpenCode config for live development.
269
229
 
270
230
  ## License
271
231
 
package/index.ts CHANGED
@@ -335,6 +335,9 @@ const BEDROCK_MODEL_MAPPINGS: Record<string, string> = {
335
335
  "us.anthropic.claude-3-5-sonnet-20241022-v2:0": "claude-3-5-sonnet-20241022",
336
336
  "us.anthropic.claude-3-5-haiku-20241022-v1:0": "claude-3-5-haiku-20241022",
337
337
  "us.anthropic.claude-3-opus-20240229-v1:0": "claude-3-opus-20240229",
338
+ "us.anthropic.claude-opus-4-5-20251101-v1:0": "claude-opus-4-5-20251101",
339
+ "us.anthropic.claude-haiku-4-5-20251001-v1:0": "claude-haiku-4-5-20251001",
340
+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0": "claude-sonnet-4-5-20250929",
338
341
  };
339
342
 
340
343
  /**
@@ -1071,8 +1074,8 @@ export const CRSAuthPlugin: Plugin = async ({ client }: PluginContext) => {
1071
1074
 
1072
1075
  const auth = await getAuth();
1073
1076
  // OpenCode stores API keys as 'key' field when type is 'api'
1074
- const apiKey = (auth.key || auth.apiKey) as string | undefined;
1075
- const baseURL = (auth.baseURL as string | undefined) || process.env.ANTHROPIC_BASE_URL || "https://crs.tonob.net/api";
1077
+ const apiKey = auth.key as string | undefined;
1078
+ const baseURL = process.env.ANTHROPIC_BASE_URL || "https://crs.tonob.net/api";
1076
1079
 
1077
1080
  debugLog("Auth details:", { hasApiKey: !!apiKey, baseURL, authKeys: Object.keys(auth) });
1078
1081
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-crs-bedrock",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "OpenCode plugin for FeedMob CRS proxy to AWS Bedrock Anthropic models",
5
5
  "type": "module",
6
6
  "main": "index.ts",