// Original example by Jev Directory, based on TypeSafe’s composite-scoring pattern. // Source: https://docs.typesafe.ai/patterns/composite-scoring // Original bug-report example. The separate questions and deterministic weighting adapt the official architectural pattern. /* MIT License Copyright (c) 2026 Jev Directory contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Setup: npm install @typesafe-ai/sdk@0.6.0 // Set TYPESAFE_API_KEY in your environment. Never put it in browser code. // Save as decision.ts; run with Node.js 24: node decision.ts // API calls incur provider charges. Not live-tested by Jev Directory. import { score, TypeSafeClient, type JsonValue } from "@typesafe-ai/sdk"; // Illustrative input, not a recorded model test. const state: JsonValue = { "report": "On Android 15, open Settings and tap Export. The app closes before showing the share sheet. Expected: a CSV export. Reproduced three times on version 2.4." }; const client = new TypeSafeClient(); try { const response = await client.systemOne({ model: "jev-latest", state, questions: { reproduction: score( "How usable are this report’s reproduction steps?", [ "No steps or triggering context.", "Some context, but important steps are missing.", "Clear steps and environment sufficient for an initial attempt." ] ), behavior: score( "How clearly does the report distinguish observed and expected behavior?", [ "Neither is clear.", "One is clear, but the other is missing or vague.", "Both are specific and distinguishable." ] ) }, }); const { reproduction, behavior } = response.answers; const review = Math.min(reproduction.confidence, behavior.confidence) < 0.7; const usefulness = 0.6 * (reproduction.score / 2) + 0.4 * (behavior.score / 2); console.log({ usefulness, action: review ? "review_scores" : "rank_report" }); } catch (error) { console.error("Decision unavailable; use your fallback or human review.", error); process.exitCode = 1; }