@sunerpy/opencode-kiro-auth 0.13.7 → 0.14.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/README.md CHANGED
@@ -218,9 +218,9 @@ Details and the full JSON example: [docs/MODELS.md](docs/MODELS.md).
218
218
  > [Reasoning display](docs/CONFIGURATION.md#reasoning-display) for details.
219
219
 
220
220
  > **Note:** Per-request thinking level via model variants — pick
221
- > `kiro-auth/claude-opus-4-8-xhigh` (or similar) straight from the model
221
+ > `kiro-auth/claude-opus-5-xhigh` (or similar) straight from the model
222
222
  > list to pin an explicit Kiro effort level for that model, no `kiro.json`
223
- > edit needed. Base models like `claude-opus-4-8` remain available and keep
223
+ > edit needed. Base models like `claude-opus-5` remain available and keep
224
224
  > using the global `effort` setting. See [docs/VARIANTS.md](docs/VARIANTS.md)
225
225
  > for the full variant list and why they exist.
226
226
 
package/dist/constants.js CHANGED
@@ -73,6 +73,9 @@ export const MODEL_MAPPING = {
73
73
  'claude-opus-4-7-thinking': 'claude-opus-4.7',
74
74
  'claude-opus-4-8': 'claude-opus-4.8',
75
75
  'claude-opus-4-8-thinking': 'claude-opus-4.8',
76
+ // Wire id has no dot suffix (probe-confirmed against the live API).
77
+ 'claude-opus-5': 'claude-opus-5',
78
+ 'claude-opus-5-thinking': 'claude-opus-5',
76
79
  // Auto
77
80
  auto: 'auto',
78
81
  // Open weight models
@@ -117,6 +120,7 @@ export const MODEL_CONTEXT_LIMITS = {
117
120
  'claude-opus-4-6-1m': 1000000,
118
121
  'claude-opus-4-7': 1000000,
119
122
  'claude-opus-4-8': 1000000,
123
+ 'claude-opus-5': 1000000,
120
124
  'deepseek-3.2': 128000,
121
125
  'glm-5': 200000,
122
126
  'minimax-m2.5': 200000,
@@ -14,6 +14,19 @@ import { RetryStrategy } from './retry-strategy.js';
14
14
  import { SdkEventStreamIterationError, UpstreamUnexpectedError } from './stream-error.js';
15
15
  const KIRO_API_PATTERN = /^(https?:\/\/)?q\.[a-z0-9-]+\.amazonaws\.com/;
16
16
  const REAUTH_FAILURE_COOLDOWN_MS = 60000;
17
+ function describeError(error, depth = 0) {
18
+ if (!(error instanceof Error))
19
+ return String(error);
20
+ const code = error.code;
21
+ return {
22
+ name: error.name,
23
+ message: error.message,
24
+ ...(code !== undefined ? { code } : {}),
25
+ ...(depth < 2 && error.cause !== undefined
26
+ ? { cause: describeError(error.cause, depth + 1) }
27
+ : {})
28
+ };
29
+ }
17
30
  export class RequestHandler {
18
31
  accountManager;
19
32
  config;
@@ -244,6 +257,15 @@ export class RequestHandler {
244
257
  region: sdkPrep.region
245
258
  }),
246
259
  onUpstreamWaitEnd: endUpstreamWait,
260
+ onIterationError: (error, afterCompletionMetadata) => logger.warn('Kiro SDK event stream iteration failed', {
261
+ model,
262
+ effectiveModel: sdkPrep.effectiveModel,
263
+ region: sdkPrep.region,
264
+ platform: process.platform,
265
+ afterCompletionMetadata,
266
+ recovered: afterCompletionMetadata,
267
+ error: describeError(error)
268
+ }),
247
269
  onComplete: completeRequest,
248
270
  onTerminal: cleanupRequest,
249
271
  onCancel: (reason) => requestController.abort(reason),
@@ -3,6 +3,7 @@ export interface SdkResponseLifecycle {
3
3
  signal?: AbortSignal;
4
4
  onUpstreamWaitStart?: () => void;
5
5
  onUpstreamWaitEnd?: () => void;
6
+ onIterationError?: (error: unknown, afterCompletionMetadata: boolean) => void;
6
7
  onComplete?: () => void | Promise<void>;
7
8
  onTerminal?: () => void;
8
9
  onCancel?: (reason: unknown) => void;
@@ -11,13 +11,22 @@ async function closeIterator(iterator) {
11
11
  }
12
12
  catch { }
13
13
  }
14
- function wrapSdkEventStream(sdkResponse, signal, onUpstreamWaitStart, onUpstreamWaitEnd) {
14
+ function isCompletionMetadataEvent(event) {
15
+ if (typeof event !== 'object' || event === null || !('metadataEvent' in event))
16
+ return false;
17
+ const metadata = event.metadataEvent;
18
+ if (typeof metadata !== 'object' || metadata === null || !('tokenUsage' in metadata))
19
+ return false;
20
+ return typeof metadata.tokenUsage === 'object' && metadata.tokenUsage !== null;
21
+ }
22
+ function wrapSdkEventStream(sdkResponse, signal, onUpstreamWaitStart, onUpstreamWaitEnd, onIterationError) {
15
23
  const eventStream = sdkResponse.generateAssistantResponseResponse;
16
24
  if (!eventStream || typeof eventStream[Symbol.asyncIterator] !== 'function') {
17
25
  return { response: sdkResponse, closeRaw: async () => { } };
18
26
  }
19
27
  const rawIterator = eventStream[Symbol.asyncIterator]();
20
28
  let closed = false;
29
+ let completionMetadataSeen = false;
21
30
  const closeRaw = async () => {
22
31
  if (closed)
23
32
  return;
@@ -57,11 +66,20 @@ function wrapSdkEventStream(sdkResponse, signal, onUpstreamWaitStart, onUpstream
57
66
  const wrappedIterator = {
58
67
  async next() {
59
68
  try {
60
- return await nextRaw();
69
+ const result = await nextRaw();
70
+ if (!result.done && isCompletionMetadataEvent(result.value)) {
71
+ completionMetadataSeen = true;
72
+ }
73
+ return result;
61
74
  }
62
75
  catch (error) {
63
76
  if (signal?.aborted)
64
77
  throw abortReason(signal);
78
+ onIterationError?.(error, completionMetadataSeen);
79
+ if (completionMetadataSeen) {
80
+ await closeRaw();
81
+ return { done: true, value: undefined };
82
+ }
65
83
  throw new SdkEventStreamIterationError(error);
66
84
  }
67
85
  },
@@ -119,7 +137,7 @@ export class ResponseHandler {
119
137
  }), { headers: { 'Content-Type': 'text/event-stream' } });
120
138
  }
121
139
  async handleSdkStreaming(sdkResponse, model, conversationId, lifecycle) {
122
- const wrapped = wrapSdkEventStream(sdkResponse, lifecycle.signal, lifecycle.onUpstreamWaitStart, lifecycle.onUpstreamWaitEnd);
140
+ const wrapped = wrapSdkEventStream(sdkResponse, lifecycle.signal, lifecycle.onUpstreamWaitStart, lifecycle.onUpstreamWaitEnd, lifecycle.onIterationError);
123
141
  const transformed = transformSdkStream(wrapped.response, model, conversationId);
124
142
  const buffered = [];
125
143
  let firstSemantic;
@@ -228,7 +246,7 @@ export class ResponseHandler {
228
246
  const toolCalls = [];
229
247
  let inputTokens = 0;
230
248
  let outputTokens = 0;
231
- const wrapped = wrapSdkEventStream(sdkResponse, lifecycle.signal, lifecycle.onUpstreamWaitStart, lifecycle.onUpstreamWaitEnd);
249
+ const wrapped = wrapSdkEventStream(sdkResponse, lifecycle.signal, lifecycle.onUpstreamWaitStart, lifecycle.onUpstreamWaitEnd, lifecycle.onIterationError);
232
250
  const eventStream = wrapped.response.generateAssistantResponseResponse;
233
251
  if (eventStream) {
234
252
  try {
@@ -14,6 +14,7 @@ const GPT_REASONING_MODELS = new Set(['gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-l
14
14
  * These models support up to 128k thinking tokens with max effort.
15
15
  */
16
16
  const XHIGH_CAPABLE_MODELS = new Set([
17
+ 'claude-opus-5',
17
18
  'claude-opus-4.7',
18
19
  'claude-opus-4.8',
19
20
  'claude-sonnet-5',
@@ -68,7 +69,7 @@ export function resolveEffort(kiroModel, requested) {
68
69
  if (!supportsEffort(kiroModel)) {
69
70
  return undefined;
70
71
  }
71
- // xhigh is only supported on opus-4.7 and opus-4.8
72
+ // xhigh is only supported on models in XHIGH_CAPABLE_MODELS.
72
73
  if (requested === 'xhigh' && !supportsXHighEffort(kiroModel)) {
73
74
  return 'max';
74
75
  }
@@ -7,6 +7,7 @@ export function resolveKiroModel(model) {
7
7
  return resolved;
8
8
  }
9
9
  const VARIANT_BASE_ALLOWLIST = new Set([
10
+ 'claude-opus-5',
10
11
  'claude-opus-4-8',
11
12
  'claude-opus-4-7',
12
13
  'claude-sonnet-5',
package/dist/plugin.js CHANGED
@@ -234,6 +234,36 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
234
234
  limit: { context: 1000000, output: 64000 },
235
235
  modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
236
236
  },
237
+ 'claude-opus-5': {
238
+ name: 'Claude Opus 5 (2.2x)',
239
+ limit: { context: 1000000, output: 64000 },
240
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
241
+ },
242
+ 'claude-opus-5-low': {
243
+ name: 'Claude Opus 5 (low) (2.2x)',
244
+ limit: { context: 1000000, output: 64000 },
245
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
246
+ },
247
+ 'claude-opus-5-medium': {
248
+ name: 'Claude Opus 5 (medium) (2.2x)',
249
+ limit: { context: 1000000, output: 64000 },
250
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
251
+ },
252
+ 'claude-opus-5-high': {
253
+ name: 'Claude Opus 5 (high) (2.2x)',
254
+ limit: { context: 1000000, output: 64000 },
255
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
256
+ },
257
+ 'claude-opus-5-xhigh': {
258
+ name: 'Claude Opus 5 (xhigh) (2.2x)',
259
+ limit: { context: 1000000, output: 64000 },
260
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
261
+ },
262
+ 'claude-opus-5-max': {
263
+ name: 'Claude Opus 5 (max) (2.2x)',
264
+ limit: { context: 1000000, output: 64000 },
265
+ modalities: { input: ['text', 'image', 'pdf'], output: ['text'] }
266
+ },
237
267
  // Open weight models
238
268
  'deepseek-3.2': {
239
269
  name: 'DeepSeek 3.2 (0.25x)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunerpy/opencode-kiro-auth",
3
- "version": "0.13.7",
3
+ "version": "0.14.0",
4
4
  "description": "OpenCode plugin for AWS Kiro (CodeWhisperer) providing access to Claude models",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",