@magpie-community/opencode-kiro-auth 0.1.11 → 0.1.12
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/index.mjs +15 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -645,6 +645,17 @@ function thinking(req, model) {
|
|
|
645
645
|
return 20000
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
+
// formatText is the structured output a request asks for, said in words:
|
|
649
|
+
// Anthropic's output_config.format (or the AI SDK's output_format) with a
|
|
650
|
+
// JSON schema, "" when it asks for none. A JSON object with no schema
|
|
651
|
+
// reaches the plugin already told in the system prompt, as Messages has no
|
|
652
|
+
// field for it.
|
|
653
|
+
function formatText(req) {
|
|
654
|
+
const f = req.output_config?.format ?? req.output_format
|
|
655
|
+
if (f?.type !== "json_schema" || !f.schema || typeof f.schema !== "object") return ""
|
|
656
|
+
return "Respond with a single JSON value and nothing else, matching this JSON schema:\n" + JSON.stringify(f.schema) + "."
|
|
657
|
+
}
|
|
658
|
+
|
|
648
659
|
// buildKiro is the body of a generateAssistantResponse call.
|
|
649
660
|
function buildKiro(req, model, profile, budget) {
|
|
650
661
|
const entries = []
|
|
@@ -756,6 +767,10 @@ function buildKiro(req, model, profile, budget) {
|
|
|
756
767
|
for (const e of entries) if (e.assistantResponseMessage && !e.assistantResponseMessage.toolUses.length) delete e.assistantResponseMessage.toolUses
|
|
757
768
|
// the instructions go at the head of the first message
|
|
758
769
|
let system = typeof req.system === "string" ? req.system : textOf(req.system)
|
|
770
|
+
// Kiro has no field for the answer's format: it is told in words, at the
|
|
771
|
+
// end of the instructions, as magpie's built-in tells it (inSystem)
|
|
772
|
+
const format = formatText(req)
|
|
773
|
+
if (format) system = system ? system + "\n\n" + format : format
|
|
759
774
|
if (budget) system = `<thinking_mode>enabled</thinking_mode><max_thinking_length>${budget}</max_thinking_length>` + (system ? "\n" + system : "")
|
|
760
775
|
if (system) entries[0].userInputMessage.content = system + "\n\n" + entries[0].userInputMessage.content
|
|
761
776
|
if (Array.isArray(req.system)) mark(entries[0].userInputMessage, req.system)
|