pi-harness-runtime 1.1.385 → 1.1.387
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.ts +42 -24
- package/package.json +3 -2
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/auto-continue.d.ts.map +1 -1
- package/packages/jev-judge/dist/auto-continue.js +26 -0
- package/packages/jev-judge/dist/auto-continue.js.map +1 -1
- package/packages/jev-judge/dist/environment-judge.d.ts.map +1 -1
- package/packages/jev-judge/dist/environment-judge.js +7 -4
- package/packages/jev-judge/dist/environment-judge.js.map +1 -1
- package/packages/jev-judge/dist/index.d.ts +87 -12
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +291 -75
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/provider-error.d.ts +61 -0
- package/packages/jev-judge/dist/provider-error.d.ts.map +1 -0
- package/packages/jev-judge/dist/provider-error.js +165 -0
- package/packages/jev-judge/dist/provider-error.js.map +1 -0
- package/packages/jev-judge/dist/task-intake.d.ts.map +1 -1
- package/packages/jev-judge/dist/task-intake.js +3 -2
- package/packages/jev-judge/dist/task-intake.js.map +1 -1
- package/packages/jev-judge/dist/types.d.ts +56 -2
- package/packages/jev-judge/dist/types.d.ts.map +1 -1
- package/packages/jev-judge/dist/typesafe-provider.d.ts +26 -1
- package/packages/jev-judge/dist/typesafe-provider.d.ts.map +1 -1
- package/packages/jev-judge/dist/typesafe-provider.js +153 -62
- package/packages/jev-judge/dist/typesafe-provider.js.map +1 -1
- package/packages/jev-judge/dist/typesafe-request.d.ts +65 -0
- package/packages/jev-judge/dist/typesafe-request.d.ts.map +1 -0
- package/packages/jev-judge/dist/typesafe-request.js +138 -0
- package/packages/jev-judge/dist/typesafe-request.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/auto-continue.ts +26 -0
- package/packages/jev-judge/src/environment-judge.ts +7 -4
- package/packages/jev-judge/src/index.ts +617 -333
- package/packages/jev-judge/src/provider-error.ts +190 -0
- package/packages/jev-judge/src/task-intake.ts +3 -2
- package/packages/jev-judge/src/types.ts +62 -5
- package/packages/jev-judge/src/typesafe-provider.ts +452 -318
- package/packages/jev-judge/src/typesafe-request.ts +181 -0
- package/packages/jev-judge/tests/jev-provider-chain.test.ts +536 -0
- package/packages/jev-judge/tests/typesafe-provider.test.ts +504 -44
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
- package/scripts/run-root-tests.mjs +207 -0
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
* API: POST https://api.typesafe.ai/v1/systemone
|
|
8
8
|
* Auth: Bearer token (TYPESAFE_API_KEY)
|
|
9
|
+
*
|
|
10
|
+
* The request contract (choice criteria as a dictionary, score questions with
|
|
11
|
+
* a mandatory rubric) is implemented in ./typesafe-request.ts; the mapping was
|
|
12
|
+
* verified against the live endpoint.
|
|
9
13
|
*/
|
|
14
|
+
import { buildChoiceCriteria, buildScoreScale, scorePositionToProbability, scorePositionToValue, validateQuestion, } from "./typesafe-request.js";
|
|
15
|
+
import { JevProviderError, isRetryableStatus, isTransportError } from "./provider-error.js";
|
|
10
16
|
/**
|
|
11
17
|
* Default configuration
|
|
12
18
|
*/
|
|
@@ -36,42 +42,38 @@ export class TypeSafeJudge {
|
|
|
36
42
|
const startTime = Date.now();
|
|
37
43
|
// Convert state to string if object
|
|
38
44
|
const stateStr = typeof state === "string" ? state : JSON.stringify(state);
|
|
39
|
-
// Build
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const questionObj = q;
|
|
43
|
-
questionsMap[id] = {
|
|
44
|
-
type: questionObj.type,
|
|
45
|
-
instructions: questionObj.instructions,
|
|
46
|
-
};
|
|
47
|
-
if (questionObj.type === "choice") {
|
|
48
|
-
questionsMap[id].options = questionObj.options;
|
|
49
|
-
// For choice questions, criteria defines ordered preference levels
|
|
50
|
-
questionsMap[id].criteria = questionObj.options;
|
|
51
|
-
}
|
|
52
|
-
else if (questionObj.type === "score") {
|
|
53
|
-
questionsMap[id].min = questionObj.min ?? 0;
|
|
54
|
-
questionsMap[id].max = questionObj.max ?? 100;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
45
|
+
// Build and validate the request. One invalid question fails the whole
|
|
46
|
+
// request on the API side, so contract problems are caught locally.
|
|
47
|
+
const { request, scoreScales } = this.buildRequest(stateStr, questions);
|
|
57
48
|
// Call TypeSafe API directly
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
49
|
+
let response;
|
|
50
|
+
try {
|
|
51
|
+
response = await fetch(`${this.config.baseUrl}/v1/systemone`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
56
|
+
},
|
|
57
|
+
// Only the wire format is sent: the API rejects unknown fields.
|
|
58
|
+
body: JSON.stringify(request),
|
|
59
|
+
signal: AbortSignal.timeout(this.config.timeoutMs),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// A network failure, a timeout or an abort never reached a server
|
|
64
|
+
// that rejected the request: another provider can still serve it.
|
|
65
|
+
// Anything else (a malformed URL, a bug in our own code) is NOT
|
|
66
|
+
// retryable - it must not disappear behind a fallback.
|
|
67
|
+
throw new JevProviderError(`TypeSafe request failed: ${error instanceof Error ? error.message : String(error)}`, { provider: "typesafe", retryable: isTransportError(error), cause: error });
|
|
68
|
+
}
|
|
71
69
|
const latencyMs = Date.now() - startTime;
|
|
72
70
|
if (!response.ok) {
|
|
73
71
|
const errorText = await response.text().catch(() => "Unknown error");
|
|
74
|
-
throw new
|
|
72
|
+
throw new JevProviderError(`TypeSafe API error ${response.status}: ${errorText}`, {
|
|
73
|
+
provider: "typesafe",
|
|
74
|
+
status: response.status,
|
|
75
|
+
retryable: isRetryableStatus(response.status),
|
|
76
|
+
});
|
|
75
77
|
}
|
|
76
78
|
const data = await response.json();
|
|
77
79
|
// Build decisions map
|
|
@@ -81,16 +83,67 @@ export class TypeSafeJudge {
|
|
|
81
83
|
const answer = data.answers?.[questionId];
|
|
82
84
|
// Reject missing required answers
|
|
83
85
|
if (!answer) {
|
|
84
|
-
throw new
|
|
86
|
+
throw new JevProviderError(`TypeSafe API: missing answer for required question "${questionId}"`, { provider: "typesafe", retryable: false });
|
|
85
87
|
}
|
|
86
|
-
const decision = this.buildDecision(questionId, questionData, answer);
|
|
88
|
+
const decision = this.buildDecision(questionId, questionData, answer, scoreScales[questionId]);
|
|
87
89
|
decisions[questionId] = decision;
|
|
88
90
|
}
|
|
89
91
|
return {
|
|
90
92
|
decisions,
|
|
91
93
|
state: stateStr,
|
|
92
94
|
latencyMs,
|
|
93
|
-
model: data.model ??
|
|
95
|
+
model: data.model ?? this.config.model,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build the API request and validate it against the API contract.
|
|
100
|
+
*
|
|
101
|
+
* The returned `request` is the wire format; `scoreScales` is local
|
|
102
|
+
* bookkeeping and is never sent to the API (it rejects unknown fields).
|
|
103
|
+
*/
|
|
104
|
+
buildRequest(stateStr, questions) {
|
|
105
|
+
const questionsMap = {};
|
|
106
|
+
const scoreScales = {};
|
|
107
|
+
for (const [id, raw] of Object.entries(questions)) {
|
|
108
|
+
const questionObj = raw;
|
|
109
|
+
const scoreScale = validateQuestion(id, questionObj);
|
|
110
|
+
if (questionObj.type === "choice") {
|
|
111
|
+
questionsMap[id] = {
|
|
112
|
+
type: "choice",
|
|
113
|
+
instructions: questionObj.instructions,
|
|
114
|
+
criteria: buildChoiceCriteria(id, questionObj),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
else if (questionObj.type === "score") {
|
|
118
|
+
const { criteria } = buildScoreScale(id, questionObj);
|
|
119
|
+
questionsMap[id] = {
|
|
120
|
+
type: "score",
|
|
121
|
+
instructions: questionObj.instructions,
|
|
122
|
+
criteria,
|
|
123
|
+
};
|
|
124
|
+
if (scoreScale)
|
|
125
|
+
scoreScales[id] = scoreScale;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
questionsMap[id] = {
|
|
129
|
+
type: "noul",
|
|
130
|
+
instructions: questionObj.instructions,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (Object.keys(questionsMap).length === 0) {
|
|
135
|
+
throw new JevProviderError("TypeSafe request invalid: no questions to ask", {
|
|
136
|
+
provider: "typesafe",
|
|
137
|
+
retryable: false,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
request: {
|
|
142
|
+
model: this.config.model,
|
|
143
|
+
state: stateStr,
|
|
144
|
+
questions: questionsMap,
|
|
145
|
+
},
|
|
146
|
+
scoreScales,
|
|
94
147
|
};
|
|
95
148
|
}
|
|
96
149
|
/**
|
|
@@ -138,20 +191,20 @@ export class TypeSafeJudge {
|
|
|
138
191
|
/**
|
|
139
192
|
* Build JevDecision from TypeSafe answer
|
|
140
193
|
*/
|
|
141
|
-
buildDecision(questionId, question, answer) {
|
|
194
|
+
buildDecision(questionId, question, answer, scoreScale) {
|
|
142
195
|
let response;
|
|
143
196
|
let probability;
|
|
144
197
|
switch (answer.type) {
|
|
145
198
|
case "noul":
|
|
146
199
|
// FIX: Validate noul value is present and in range [0, 1]
|
|
147
200
|
if (answer.noul === undefined || answer.noul === null) {
|
|
148
|
-
throw new
|
|
201
|
+
throw new JevProviderError(`TypeSafe API: missing noul value for question "${questionId}"`, { provider: "typesafe", retryable: false });
|
|
149
202
|
}
|
|
150
203
|
if (typeof answer.noul !== "number" || isNaN(answer.noul)) {
|
|
151
|
-
throw new
|
|
204
|
+
throw new JevProviderError(`TypeSafe API: invalid noul value for question "${questionId}": ${JSON.stringify(answer.noul)}`, { provider: "typesafe", retryable: false });
|
|
152
205
|
}
|
|
153
206
|
if (answer.noul < 0 || answer.noul > 1) {
|
|
154
|
-
throw new
|
|
207
|
+
throw new JevProviderError(`TypeSafe API: noul value out of range [0,1] for question "${questionId}": ${answer.noul}`, { provider: "typesafe", retryable: false });
|
|
155
208
|
}
|
|
156
209
|
response = {
|
|
157
210
|
type: "noul",
|
|
@@ -160,9 +213,7 @@ export class TypeSafeJudge {
|
|
|
160
213
|
probability = answer.noul;
|
|
161
214
|
break;
|
|
162
215
|
case "choice": {
|
|
163
|
-
const options = question
|
|
164
|
-
? (question.options ?? [])
|
|
165
|
-
: [];
|
|
216
|
+
const options = choiceCandidates(question);
|
|
166
217
|
// The model's choice MUST win. The previous expression
|
|
167
218
|
// (`answer.choice ?? question.type === "choice" ? options[0] : ""`)
|
|
168
219
|
// was parsed as `(answer.choice ?? (question.type === "choice")) ? options[0] : ""`,
|
|
@@ -194,17 +245,29 @@ export class TypeSafeJudge {
|
|
|
194
245
|
probability = answer.confidence ?? 0.5;
|
|
195
246
|
break;
|
|
196
247
|
}
|
|
197
|
-
case "score":
|
|
198
|
-
|
|
199
|
-
|
|
248
|
+
case "score": {
|
|
249
|
+
if (answer.score === undefined || answer.score === null) {
|
|
250
|
+
throw new JevProviderError(`TypeSafe API: missing score value for question "${questionId}"`, { provider: "typesafe", retryable: false });
|
|
251
|
+
}
|
|
252
|
+
if (typeof answer.score !== "number" || isNaN(answer.score)) {
|
|
253
|
+
throw new JevProviderError(`TypeSafe API: invalid score value for question "${questionId}": ${JSON.stringify(answer.score)}`, { provider: "typesafe", retryable: false });
|
|
254
|
+
}
|
|
255
|
+
// The API answers with the probability-weighted POSITION in the
|
|
256
|
+
// rubric (0 .. levels-1), not with a value on the min/max scale.
|
|
257
|
+
const scale = scoreScale ?? {
|
|
258
|
+
levels: 2,
|
|
259
|
+
min: question.type === "score" ? question.min ?? 0 : 0,
|
|
260
|
+
max: question.type === "score" ? question.max ?? 100 : 100,
|
|
261
|
+
};
|
|
262
|
+
const value = scorePositionToValue(answer.score, scale);
|
|
200
263
|
response = {
|
|
201
264
|
type: "score",
|
|
202
|
-
score:
|
|
265
|
+
score: value,
|
|
203
266
|
confidence: answer.confidence ?? 0.5,
|
|
204
267
|
};
|
|
205
|
-
|
|
206
|
-
probability = ((answer.score ?? (min + max) / 2) - min) / (max - min);
|
|
268
|
+
probability = scorePositionToProbability(answer.score, scale);
|
|
207
269
|
break;
|
|
270
|
+
}
|
|
208
271
|
default:
|
|
209
272
|
// Fallback for unknown types
|
|
210
273
|
response = {
|
|
@@ -236,23 +299,51 @@ export class TypeSafeJudge {
|
|
|
236
299
|
}
|
|
237
300
|
}
|
|
238
301
|
/**
|
|
239
|
-
*
|
|
302
|
+
* The candidate names of a choice question.
|
|
303
|
+
*
|
|
304
|
+
* `options` is the ergonomic way to name the candidates; a question that only
|
|
305
|
+
* carries `criteria` is read from the criteria itself.
|
|
240
306
|
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
307
|
+
function choiceCandidates(question) {
|
|
308
|
+
if (question.type !== "choice")
|
|
309
|
+
return [];
|
|
310
|
+
const options = question.options;
|
|
311
|
+
if (options && options.length > 0)
|
|
312
|
+
return [...options];
|
|
313
|
+
const criteria = question.criteria;
|
|
314
|
+
if (Array.isArray(criteria))
|
|
315
|
+
return [...criteria];
|
|
316
|
+
if (criteria)
|
|
317
|
+
return Object.keys(criteria);
|
|
318
|
+
return [];
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Determine the provider that owns a base URL.
|
|
322
|
+
*
|
|
323
|
+
* The provider is derived from the ENDPOINT, never from the shape of a key:
|
|
324
|
+
* guessing from a key is how an OpenRouter key ended up being sent to the
|
|
325
|
+
* TypeSafe API.
|
|
326
|
+
*/
|
|
327
|
+
export function providerForBaseUrl(baseUrl) {
|
|
328
|
+
if (baseUrl.includes("typesafe.ai"))
|
|
244
329
|
return "typesafe";
|
|
245
|
-
|
|
246
|
-
// If using OpenRouter URL, use OpenRouter
|
|
247
|
-
if (baseUrl?.includes("openrouter")) {
|
|
330
|
+
if (baseUrl.includes("openrouter"))
|
|
248
331
|
return "openrouter";
|
|
332
|
+
throw new Error(`Jev: unknown provider base URL "${baseUrl}". Use resolveJevProviders() or pass an explicit provider chain.`);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Detect which provider to use based on API key or config
|
|
336
|
+
*
|
|
337
|
+
* @deprecated The provider cannot be derived from a key - a bare key says
|
|
338
|
+
* nothing about the endpoint it belongs to, and guessing from its length is
|
|
339
|
+
* how an OpenRouter key ended up being sent to the TypeSafe API. Pass the
|
|
340
|
+
* `baseUrl` of the provider, or use `resolveJevProviders()` (see ./index.ts),
|
|
341
|
+
* which binds every credential to its own provider.
|
|
342
|
+
*/
|
|
343
|
+
export function detectProvider(_apiKey, baseUrl) {
|
|
344
|
+
if (!baseUrl) {
|
|
345
|
+
throw new Error("Jev: detectProvider() cannot guess the provider from the key. Pass the baseUrl of the provider or use resolveJevProviders().");
|
|
249
346
|
}
|
|
250
|
-
|
|
251
|
-
// TypeSafe keys are typically longer than OpenAI-compatible keys
|
|
252
|
-
if (apiKey.length > 50) {
|
|
253
|
-
return "typesafe";
|
|
254
|
-
}
|
|
255
|
-
// Default to OpenRouter for short keys (OpenAI-compatible)
|
|
256
|
-
return "openrouter";
|
|
347
|
+
return providerForBaseUrl(baseUrl);
|
|
257
348
|
}
|
|
258
349
|
//# sourceMappingURL=typesafe-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesafe-provider.js","sourceRoot":"","sources":["../src/typesafe-provider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"typesafe-provider.js","sourceRoot":"","sources":["../src/typesafe-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAYH,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,gBAAgB,GAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAiE5F;;GAEG;AACH,MAAM,cAAc,GAAG;IACtB,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,yBAAyB;IAClC,SAAS,EAAE,KAAK;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACjB,MAAM,CAA2B;IAEzC,YAAY,MAAsB;QACjC,IAAI,CAAC,MAAM,GAAG;YACb,GAAG,cAAc;YACjB,GAAG,MAAM;SACmB,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CACb,KAAsB,EACtB,SAA0B;QAE1B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,oCAAoC;QACpC,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAE3E,uEAAuE;QACvE,oEAAoE;QACpE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAExE,6BAA6B;QAC7B,IAAI,QAAkB,CAAC;QACvB,IAAI,CAAC;YACJ,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,eAAe,EAAE;gBAC7D,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;o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D,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request building for the TypeSafe System One API.
|
|
3
|
+
*
|
|
4
|
+
* The API contract (https://docs.typesafe.ai/api.md, verified against the live
|
|
5
|
+
* endpoint) is stricter than a plain prompt-and-parse call:
|
|
6
|
+
*
|
|
7
|
+
* - `noul` : { type, instructions } - optional criteria {"true","false"}
|
|
8
|
+
* - `choice` : { type, instructions, criteria } where criteria is a
|
|
9
|
+
* DICTIONARY of `name -> description`. A list of names is
|
|
10
|
+
* rejected with 422 "Input should be a valid dictionary".
|
|
11
|
+
* - `score` : { type, instructions, criteria } where criteria is a REQUIRED
|
|
12
|
+
* ordered list of level descriptions (1..10 entries). The answer
|
|
13
|
+
* is the probability-weighted POSITION in that list, not an
|
|
14
|
+
* arbitrary number.
|
|
15
|
+
*
|
|
16
|
+
* A single invalid question fails the whole request, so the mapping is
|
|
17
|
+
* validated locally before anything is sent.
|
|
18
|
+
*/
|
|
19
|
+
import type { JevChoiceQuestion, JevQuestion, JevScoreQuestion } from "./types.js";
|
|
20
|
+
/** The API accepts at most 10 rubric levels for a score question. */
|
|
21
|
+
export declare const MAX_SCORE_LEVELS = 10;
|
|
22
|
+
/** The criteria shape the API expects for a choice question. */
|
|
23
|
+
export type TypeSafeChoiceCriteria = Record<string, string>;
|
|
24
|
+
/** A score scale: the rubric levels plus the scale the answer is reported on. */
|
|
25
|
+
export interface ScoreScale {
|
|
26
|
+
/** Number of rubric levels. */
|
|
27
|
+
levels: number;
|
|
28
|
+
/** Lower bound of the reported scale. */
|
|
29
|
+
min: number;
|
|
30
|
+
/** Upper bound of the reported scale. */
|
|
31
|
+
max: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the `criteria` dictionary of a choice question.
|
|
35
|
+
*
|
|
36
|
+
* A dictionary is used as-is. A list of names is converted to a dictionary
|
|
37
|
+
* whose description is the name itself, which is how the API reads a question
|
|
38
|
+
* that only names its candidates (the API rejects a LIST with 422).
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildChoiceCriteria(questionId: string, question: JevChoiceQuestion): TypeSafeChoiceCriteria;
|
|
41
|
+
/**
|
|
42
|
+
* Build the rubric of a score question and the scale its answer is reported on.
|
|
43
|
+
*
|
|
44
|
+
* An explicit rubric is used as-is. Otherwise one is derived from min/max,
|
|
45
|
+
* limited to the 10 levels the API accepts.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildScoreScale(questionId: string, question: JevScoreQuestion): {
|
|
48
|
+
criteria: string[];
|
|
49
|
+
scale: ScoreScale;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Convert a rubric position into the value on the reported scale.
|
|
53
|
+
*/
|
|
54
|
+
export declare function scorePositionToValue(position: number, scale: ScoreScale): number;
|
|
55
|
+
/**
|
|
56
|
+
* Convert a rubric position into a probability.
|
|
57
|
+
*/
|
|
58
|
+
export declare function scorePositionToProbability(position: number, scale: ScoreScale): number;
|
|
59
|
+
/**
|
|
60
|
+
* Validate that a question can be expressed for the TypeSafe API.
|
|
61
|
+
*
|
|
62
|
+
* Returns the score scale of the question when it is a score question.
|
|
63
|
+
*/
|
|
64
|
+
export declare function validateQuestion(questionId: string, question: JevQuestion): ScoreScale | null;
|
|
65
|
+
//# sourceMappingURL=typesafe-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typesafe-request.d.ts","sourceRoot":"","sources":["../src/typesafe-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAGpB,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,gEAAgE;AAChE,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5D,iFAAiF;AACjF,MAAM,WAAW,UAAU;IAC1B,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;CACZ;AASD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,iBAAiB,GACzB,sBAAsB,CAoCxB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,gBAAgB,GACxB;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CA4B3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAIhF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAItF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,WAAW,GACnB,UAAU,GAAG,IAAI,CAkBnB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request building for the TypeSafe System One API.
|
|
3
|
+
*
|
|
4
|
+
* The API contract (https://docs.typesafe.ai/api.md, verified against the live
|
|
5
|
+
* endpoint) is stricter than a plain prompt-and-parse call:
|
|
6
|
+
*
|
|
7
|
+
* - `noul` : { type, instructions } - optional criteria {"true","false"}
|
|
8
|
+
* - `choice` : { type, instructions, criteria } where criteria is a
|
|
9
|
+
* DICTIONARY of `name -> description`. A list of names is
|
|
10
|
+
* rejected with 422 "Input should be a valid dictionary".
|
|
11
|
+
* - `score` : { type, instructions, criteria } where criteria is a REQUIRED
|
|
12
|
+
* ordered list of level descriptions (1..10 entries). The answer
|
|
13
|
+
* is the probability-weighted POSITION in that list, not an
|
|
14
|
+
* arbitrary number.
|
|
15
|
+
*
|
|
16
|
+
* A single invalid question fails the whole request, so the mapping is
|
|
17
|
+
* validated locally before anything is sent.
|
|
18
|
+
*/
|
|
19
|
+
import { JevProviderError } from "./provider-error.js";
|
|
20
|
+
/** The API accepts at most 10 rubric levels for a score question. */
|
|
21
|
+
export const MAX_SCORE_LEVELS = 10;
|
|
22
|
+
function invalid(message) {
|
|
23
|
+
return new JevProviderError(`TypeSafe request invalid: ${message}`, {
|
|
24
|
+
provider: "typesafe",
|
|
25
|
+
retryable: false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the `criteria` dictionary of a choice question.
|
|
30
|
+
*
|
|
31
|
+
* A dictionary is used as-is. A list of names is converted to a dictionary
|
|
32
|
+
* whose description is the name itself, which is how the API reads a question
|
|
33
|
+
* that only names its candidates (the API rejects a LIST with 422).
|
|
34
|
+
*/
|
|
35
|
+
export function buildChoiceCriteria(questionId, question) {
|
|
36
|
+
const explicit = question.criteria;
|
|
37
|
+
if (explicit && !Array.isArray(explicit)) {
|
|
38
|
+
const entries = Object.entries(explicit);
|
|
39
|
+
if (entries.length === 0) {
|
|
40
|
+
throw invalid(`question "${questionId}" has an empty choice criteria dictionary`);
|
|
41
|
+
}
|
|
42
|
+
const criteria = {};
|
|
43
|
+
for (const [name, description] of entries) {
|
|
44
|
+
// An empty description is replaced by the name: the API reads the
|
|
45
|
+
// description as the meaning of the candidate, and the name is the
|
|
46
|
+
// only thing we know for sure.
|
|
47
|
+
criteria[name] =
|
|
48
|
+
typeof description === "string" && description.trim() !== ""
|
|
49
|
+
? description
|
|
50
|
+
: name;
|
|
51
|
+
}
|
|
52
|
+
return criteria;
|
|
53
|
+
}
|
|
54
|
+
const names = Array.isArray(explicit) ? explicit : (question.options ?? []);
|
|
55
|
+
if (names.length === 0) {
|
|
56
|
+
throw invalid(`question "${questionId}" needs "options" or "criteria" for a choice question`);
|
|
57
|
+
}
|
|
58
|
+
const descriptions = question.optionDescriptions ?? {};
|
|
59
|
+
const criteria = {};
|
|
60
|
+
for (const name of names) {
|
|
61
|
+
const description = descriptions[name];
|
|
62
|
+
criteria[name] =
|
|
63
|
+
typeof description === "string" && description.trim() !== "" ? description : name;
|
|
64
|
+
}
|
|
65
|
+
return criteria;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build the rubric of a score question and the scale its answer is reported on.
|
|
69
|
+
*
|
|
70
|
+
* An explicit rubric is used as-is. Otherwise one is derived from min/max,
|
|
71
|
+
* limited to the 10 levels the API accepts.
|
|
72
|
+
*/
|
|
73
|
+
export function buildScoreScale(questionId, question) {
|
|
74
|
+
const min = question.min ?? 0;
|
|
75
|
+
const max = question.max ?? 100;
|
|
76
|
+
const explicit = question.criteria;
|
|
77
|
+
if (explicit && explicit.length > 0) {
|
|
78
|
+
if (explicit.length > MAX_SCORE_LEVELS) {
|
|
79
|
+
throw invalid(`question "${questionId}" has ${explicit.length} rubric levels, the TypeSafe API accepts at most ${MAX_SCORE_LEVELS}`);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
criteria: explicit.map((level) => String(level)),
|
|
83
|
+
scale: { levels: explicit.length, min, max },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const span = Math.max(1, Math.round(max - min) + 1);
|
|
87
|
+
const levels = Math.min(span, MAX_SCORE_LEVELS);
|
|
88
|
+
const criteria = [];
|
|
89
|
+
for (let i = 0; i < levels; i++) {
|
|
90
|
+
const value = levels > 1 ? min + (i * (max - min)) / (levels - 1) : min;
|
|
91
|
+
// The API wants level DESCRIPTIONS. A derived level has no meaning of
|
|
92
|
+
// its own, so it is described by the value it stands for.
|
|
93
|
+
criteria.push(`score ${Math.round(value * 100) / 100}`);
|
|
94
|
+
}
|
|
95
|
+
return { criteria, scale: { levels, min, max } };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Convert a rubric position into the value on the reported scale.
|
|
99
|
+
*/
|
|
100
|
+
export function scorePositionToValue(position, scale) {
|
|
101
|
+
if (scale.levels <= 1)
|
|
102
|
+
return scale.min;
|
|
103
|
+
const clamped = Math.min(Math.max(position, 0), scale.levels - 1);
|
|
104
|
+
return scale.min + (clamped * (scale.max - scale.min)) / (scale.levels - 1);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Convert a rubric position into a probability.
|
|
108
|
+
*/
|
|
109
|
+
export function scorePositionToProbability(position, scale) {
|
|
110
|
+
if (scale.levels <= 1)
|
|
111
|
+
return 0.5;
|
|
112
|
+
const clamped = Math.min(Math.max(position, 0), scale.levels - 1);
|
|
113
|
+
return clamped / (scale.levels - 1);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Validate that a question can be expressed for the TypeSafe API.
|
|
117
|
+
*
|
|
118
|
+
* Returns the score scale of the question when it is a score question.
|
|
119
|
+
*/
|
|
120
|
+
export function validateQuestion(questionId, question) {
|
|
121
|
+
if (!question || typeof question !== "object") {
|
|
122
|
+
throw invalid(`question "${questionId}" is not an object`);
|
|
123
|
+
}
|
|
124
|
+
if (typeof question.instructions !== "string" || question.instructions.trim() === "") {
|
|
125
|
+
throw invalid(`question "${questionId}" has no instructions`);
|
|
126
|
+
}
|
|
127
|
+
if (question.type === "noul")
|
|
128
|
+
return null;
|
|
129
|
+
if (question.type === "choice") {
|
|
130
|
+
buildChoiceCriteria(questionId, question);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
if (question.type === "score") {
|
|
134
|
+
return buildScoreScale(questionId, question).scale;
|
|
135
|
+
}
|
|
136
|
+
throw invalid(`question "${questionId}" has unsupported type "${question.type}"`);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=typesafe-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typesafe-request.js","sourceRoot":"","sources":["../src/typesafe-request.ts"],"names":[],"mappings":"A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AC"}
|
|
@@ -102,16 +102,35 @@ export class AutoContinueJudge {
|
|
|
102
102
|
instructions: "Risk level if agent proceeds without user confirmation",
|
|
103
103
|
min: 1,
|
|
104
104
|
max: 5,
|
|
105
|
+
criteria: [
|
|
106
|
+
"1 - minimal risk, nothing can go wrong",
|
|
107
|
+
"2 - low risk, easily reversible",
|
|
108
|
+
"3 - moderate risk, partly reversible",
|
|
109
|
+
"4 - high risk, hard to reverse",
|
|
110
|
+
"5 - severe risk, irreversible damage possible",
|
|
111
|
+
],
|
|
105
112
|
},
|
|
106
113
|
urgency: {
|
|
107
114
|
type: "choice",
|
|
108
115
|
instructions: "How urgent are the remaining tasks?",
|
|
109
116
|
options: ["critical", "high", "normal", "low"],
|
|
117
|
+
optionDescriptions: {
|
|
118
|
+
critical: "must be handled right now, everything else waits",
|
|
119
|
+
high: "should be handled today",
|
|
120
|
+
normal: "should be handled within the current work cycle",
|
|
121
|
+
low: "can wait until the current work cycle is done",
|
|
122
|
+
},
|
|
110
123
|
},
|
|
111
124
|
estimatedImpact: {
|
|
112
125
|
type: "choice",
|
|
113
126
|
instructions: "Impact if the agent makes wrong decision by proceeding",
|
|
114
127
|
options: ["minimal", "moderate", "significant", "major"],
|
|
128
|
+
optionDescriptions: {
|
|
129
|
+
minimal: "a small amount of extra work",
|
|
130
|
+
moderate: "noticeable rework, still contained",
|
|
131
|
+
significant: "substantial rework or lost work",
|
|
132
|
+
major: "irreversible loss, data loss or a broken system",
|
|
133
|
+
},
|
|
115
134
|
},
|
|
116
135
|
waitBenefit: {
|
|
117
136
|
type: "noul",
|
|
@@ -124,6 +143,13 @@ export class AutoContinueJudge {
|
|
|
124
143
|
"How complex are the remaining tasks compared to completed ones?",
|
|
125
144
|
min: 1,
|
|
126
145
|
max: 5,
|
|
146
|
+
criteria: [
|
|
147
|
+
"1 - trivial, a single mechanical step",
|
|
148
|
+
"2 - simple, a few well known steps",
|
|
149
|
+
"3 - moderate, some design decisions needed",
|
|
150
|
+
"4 - complex, many interacting parts",
|
|
151
|
+
"5 - very complex, unknown territory",
|
|
152
|
+
],
|
|
127
153
|
},
|
|
128
154
|
});
|
|
129
155
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Solution: Jev analyzes environment context to guide safe operations.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { JevJudge,
|
|
11
|
+
import { JevJudge, resolveJevProviders } from "./index.js";
|
|
12
12
|
import { logError } from "./file-logger.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -71,10 +71,13 @@ export class EnvironmentJudge {
|
|
|
71
71
|
prodPatterns: config.prodPatterns ?? DEFAULT_CONFIG.prodPatterns,
|
|
72
72
|
} as Required<EnvironmentConfig>;
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// Bind every credential to its own provider: a bare key cannot be
|
|
75
|
+
// attributed to an endpoint, which is how an OpenRouter key used to be
|
|
76
|
+
// sent to the TypeSafe API.
|
|
77
|
+
const providers = resolveJevProviders();
|
|
78
|
+
if (providers.length > 0) {
|
|
76
79
|
try {
|
|
77
|
-
this.jev = new JevJudge({
|
|
80
|
+
this.jev = new JevJudge({ providers });
|
|
78
81
|
} catch {
|
|
79
82
|
// Jev not available
|
|
80
83
|
}
|