@zhafron/opencode-kiro-auth 1.4.6 → 1.4.7

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 (2) hide show
  1. package/dist/plugin.js +28 -0
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -253,6 +253,34 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
253
253
  retry++;
254
254
  continue;
255
255
  }
256
+ if (res.status === 500) {
257
+ acc.failCount = (acc.failCount || 0) + 1;
258
+ let errorMessage = 'Internal Server Error';
259
+ try {
260
+ const errorBody = await res.text();
261
+ const errorData = JSON.parse(errorBody);
262
+ if (errorData.message) {
263
+ errorMessage = errorData.message;
264
+ }
265
+ else if (errorData.Message) {
266
+ errorMessage = errorData.Message;
267
+ }
268
+ }
269
+ catch (e) {
270
+ // If we can't parse the error, use default message
271
+ }
272
+ if (acc.failCount < 3) {
273
+ const delay = 1000 * Math.pow(2, acc.failCount - 1);
274
+ showToast(`Server Error (500): ${errorMessage}. Retrying in ${Math.ceil(delay / 1000)}s...`, 'warning');
275
+ await sleep(delay);
276
+ continue;
277
+ }
278
+ else {
279
+ acc.failCount = 0;
280
+ showToast(`Server Error (500): ${errorMessage}. Switching account...`, 'warning');
281
+ continue;
282
+ }
283
+ }
256
284
  if (res.status === 429) {
257
285
  const w = parseInt(res.headers.get('retry-after') || '60') * 1000;
258
286
  am.markRateLimited(acc, w);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhafron/opencode-kiro-auth",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "OpenCode plugin for AWS Kiro (CodeWhisperer) providing access to Claude models",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",