@zhafron/opencode-kiro-auth 1.2.3 → 1.2.5
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 +3 -18
- package/dist/constants.js +0 -3
- package/dist/plugin/request.js +44 -0
- package/dist/plugin.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zhafron/opencode-kiro-auth)
|
|
4
4
|
[](https://www.npmjs.com/package/@zhafron/opencode-kiro-auth)
|
|
5
5
|
|
|
6
|
-
OpenCode plugin for AWS Kiro (CodeWhisperer) providing access to
|
|
6
|
+
OpenCode plugin for AWS Kiro (CodeWhisperer) providing access to Claude Sonnet and Haiku models with substantial trial quotas.
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
@@ -26,30 +26,15 @@ Add the plugin to your `opencode.json` or `opencode.jsonc`:
|
|
|
26
26
|
"provider": {
|
|
27
27
|
"kiro": {
|
|
28
28
|
"models": {
|
|
29
|
-
"claude-opus-4-5": {
|
|
30
|
-
"name": "Claude Opus 4.5",
|
|
31
|
-
"limit": { "context": 200000, "output": 64000 },
|
|
32
|
-
"modalities": { "input": ["text", "image"], "output": ["text"] }
|
|
33
|
-
},
|
|
34
|
-
"claude-opus-4-5-thinking": {
|
|
35
|
-
"name": "Claude Opus 4.5 Thinking",
|
|
36
|
-
"limit": { "context": 200000, "output": 64000 },
|
|
37
|
-
"modalities": { "input": ["text", "image"], "output": ["text"] },
|
|
38
|
-
"variants": {
|
|
39
|
-
"low": { "thinkingConfig": { "thinkingBudget": 8192 } },
|
|
40
|
-
"medium": { "thinkingConfig": { "thinkingBudget": 16384 } },
|
|
41
|
-
"max": { "thinkingConfig": { "thinkingBudget": 32768 } }
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
29
|
"claude-sonnet-4-5": {
|
|
45
30
|
"name": "Claude Sonnet 4.5",
|
|
46
31
|
"limit": { "context": 200000, "output": 64000 },
|
|
47
|
-
"modalities": { "input": ["text", "image"], "output": ["text"] }
|
|
32
|
+
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
|
|
48
33
|
},
|
|
49
34
|
"claude-sonnet-4-5-thinking": {
|
|
50
35
|
"name": "Claude Sonnet 4.5 Thinking",
|
|
51
36
|
"limit": { "context": 200000, "output": 64000 },
|
|
52
|
-
"modalities": { "input": ["text", "image"], "output": ["text"] },
|
|
37
|
+
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
|
|
53
38
|
"variants": {
|
|
54
39
|
"low": { "thinkingConfig": { "thinkingBudget": 8192 } },
|
|
55
40
|
"medium": { "thinkingConfig": { "thinkingBudget": 16384 } },
|
package/dist/constants.js
CHANGED
|
@@ -40,9 +40,6 @@ export const KIRO_CONSTANTS = {
|
|
|
40
40
|
ORIGIN_AI_EDITOR: 'AI_EDITOR'
|
|
41
41
|
};
|
|
42
42
|
export const MODEL_MAPPING = {
|
|
43
|
-
'claude-opus-4-5': 'claude-opus-4.5',
|
|
44
|
-
'claude-opus-4-5-thinking': 'claude-opus-4.5',
|
|
45
|
-
'claude-opus-4-5-20251101': 'claude-opus-4.5',
|
|
46
43
|
'claude-haiku-4-5': 'claude-haiku-4.5',
|
|
47
44
|
'claude-sonnet-4-5': 'CLAUDE_SONNET_4_5_20250929_V1_0',
|
|
48
45
|
'claude-sonnet-4-5-thinking': 'CLAUDE_SONNET_4_5_20250929_V1_0',
|
package/dist/plugin/request.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as crypto from 'crypto';
|
|
|
2
2
|
import * as os from 'os';
|
|
3
3
|
import { KIRO_CONSTANTS } from '../constants.js';
|
|
4
4
|
import { resolveKiroModel } from './models.js';
|
|
5
|
+
import * as logger from './logger.js';
|
|
5
6
|
export function transformToCodeWhisperer(url, body, model, auth, think = false, budget = 20000) {
|
|
6
7
|
const req = typeof body === 'string' ? JSON.parse(body) : body;
|
|
7
8
|
const { messages, tools, system, conversationId } = req;
|
|
@@ -268,6 +269,33 @@ export function transformToCodeWhisperer(url, body, model, auth, think = false,
|
|
|
268
269
|
ctx.tools = cwTools;
|
|
269
270
|
if (Object.keys(ctx).length)
|
|
270
271
|
uim.userInputMessageContext = ctx;
|
|
272
|
+
const hasToolsInHistory = historyHasToolCalling(history);
|
|
273
|
+
if (hasToolsInHistory) {
|
|
274
|
+
const toolNamesInHistory = extractToolNamesFromHistory(history);
|
|
275
|
+
if (toolNamesInHistory.size > 0) {
|
|
276
|
+
const existingTools = uim.userInputMessageContext?.tools || [];
|
|
277
|
+
const existingToolNames = new Set(existingTools.map((t) => t.toolSpecification?.name).filter(Boolean));
|
|
278
|
+
const missingToolNames = Array.from(toolNamesInHistory).filter((name) => !existingToolNames.has(name));
|
|
279
|
+
if (missingToolNames.length > 0) {
|
|
280
|
+
logger.log(`[Kiro] Adding ${missingToolNames.length} missing tool definitions: ${missingToolNames.join(', ')}`);
|
|
281
|
+
const placeholderTools = missingToolNames.map((name) => ({
|
|
282
|
+
toolSpecification: {
|
|
283
|
+
name,
|
|
284
|
+
description: 'Tool',
|
|
285
|
+
inputSchema: {
|
|
286
|
+
json: {
|
|
287
|
+
type: 'object',
|
|
288
|
+
properties: {}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}));
|
|
293
|
+
if (!uim.userInputMessageContext)
|
|
294
|
+
uim.userInputMessageContext = {};
|
|
295
|
+
uim.userInputMessageContext.tools = [...existingTools, ...placeholderTools];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
271
299
|
}
|
|
272
300
|
const machineId = crypto
|
|
273
301
|
.createHash('sha256')
|
|
@@ -364,3 +392,19 @@ function deduplicateToolResults(trs) {
|
|
|
364
392
|
}
|
|
365
393
|
return u;
|
|
366
394
|
}
|
|
395
|
+
function historyHasToolCalling(history) {
|
|
396
|
+
return history.some((h) => h.assistantResponseMessage?.toolUses ||
|
|
397
|
+
h.userInputMessage?.userInputMessageContext?.toolResults);
|
|
398
|
+
}
|
|
399
|
+
function extractToolNamesFromHistory(history) {
|
|
400
|
+
const toolNames = new Set();
|
|
401
|
+
for (const h of history) {
|
|
402
|
+
if (h.assistantResponseMessage?.toolUses) {
|
|
403
|
+
for (const tu of h.assistantResponseMessage.toolUses) {
|
|
404
|
+
if (tu.name)
|
|
405
|
+
toolNames.add(tu.name);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return toolNames;
|
|
410
|
+
}
|
package/dist/plugin.js
CHANGED
|
@@ -56,7 +56,7 @@ export const createKiroPlugin = (id) => async ({ client, directory }) => {
|
|
|
56
56
|
if (!KIRO_API_PATTERN.test(url))
|
|
57
57
|
return fetch(input, init);
|
|
58
58
|
const body = init?.body ? JSON.parse(init.body) : {};
|
|
59
|
-
const model = extractModel(url) || body.model || 'claude-
|
|
59
|
+
const model = extractModel(url) || body.model || 'claude-sonnet-4-5';
|
|
60
60
|
const think = model.endsWith('-thinking') || !!body.providerOptions?.thinkingConfig;
|
|
61
61
|
const budget = body.providerOptions?.thinkingConfig?.thinkingBudget || 20000;
|
|
62
62
|
let retry = 0;
|