@anvia/jev 0.3.0 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/jev/models.ts","../src/jev/client.ts","../src/jev/index.ts"],"mappings":";;;qBAEa;qBACA;KACD,iCAAiC,oBAAoB;KACrD,qBAAqB,QAAQ;KCM7B;EAEN;EACA;EACA,UAAU;EACV;;EAGA,QAAQ;EACR;EACA;EACA;;KAGM;EAA4B,SAAS;;KACrC,yBAAyB;qBAExB,qBAAqB;mBACf;EAEL,YAAA,SAAS;EA8BrB,cAAc,SAAS,0BAA0B;EAO3C,WAAW;IAAY,cAAc;MAA4B,QAAQ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/jev/models.ts","../src/jev/client.ts","../src/jev/index.ts"],"mappings":";;;qBAEa;qBACA;KACD,iCAAiC,oBAAoB;KACrD,qBAAqB,QAAQ;KCM7B;EAEN;EACA;EACA,UAAU;EACV;;EAGA,QAAQ;EACR;EACA;EACA;;KAGM;EAA4B,SAAS;;KACrC,yBAAyB;qBAExB,qBAAqB;mBACf;EAEL,YAAA,SAAS;EAiCrB,cAAc,SAAS,0BAA0B;EAQ3C,WAAW;IAAY,cAAc;MAA4B,QAAQ"}
package/dist/index.js CHANGED
@@ -1,8 +1,168 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
2
  import { ModelListingError } from "@anvia/core/model-listing";
3
3
  import { APITimeoutError, TypeSafeClient } from "@typesafe-ai/sdk";
4
+ import { Usage } from "@anvia/core/completion";
4
5
  import { DecisionProviderOutputError } from "@anvia/core/decision";
5
- import { Usage, isJsonValue } from "@anvia/core/completion";
6
+ import { isDecisionDataObject, isDecisionProbability, isDecisionTokenCount, probabilitiesSumToOne } from "@anvia/core/internal/provider";
7
+ // src/jev/decision-request.ts
8
+ function compileJevQuestions(questions) {
9
+ const compiled = [];
10
+ const wireQuestions = [];
11
+ for (const [index, [name, question]] of Object.entries(questions).entries()) {
12
+ const key = `q${index}`;
13
+ if (question.type === "multi-label") {
14
+ const keys = Object.entries(question.options).map(([label, description], labelIndex) => {
15
+ const labelKey = `${key}_${labelIndex}`;
16
+ wireQuestions.push([labelKey, {
17
+ type: "noul",
18
+ instructions: {
19
+ instructions: question.instructions,
20
+ label,
21
+ task: "Does this label apply to the state? Evaluate it independently of other labels."
22
+ },
23
+ criteria: { true: toEntry(description) }
24
+ }]);
25
+ return labelKey;
26
+ });
27
+ compiled.push({
28
+ name,
29
+ question,
30
+ keys
31
+ });
32
+ } else {
33
+ const native = nativeQuestion(question);
34
+ wireQuestions.push([key, native]);
35
+ compiled.push({
36
+ name,
37
+ question,
38
+ keys: [key]
39
+ });
40
+ }
41
+ }
42
+ return {
43
+ compiled,
44
+ wireQuestions
45
+ };
46
+ }
47
+ /** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */
48
+ function toEntry(value) {
49
+ const normalized = sdkJson(value);
50
+ return typeof normalized === "number" || typeof normalized === "boolean" ? { value: normalized } : normalized;
51
+ }
52
+ function nativeQuestion(question) {
53
+ switch (question.type) {
54
+ case "choice": return {
55
+ type: "choice",
56
+ instructions: question.instructions,
57
+ criteria: Object.fromEntries(Object.entries(question.options).map(([label, description]) => [label, toEntry(description)]))
58
+ };
59
+ case "score": return {
60
+ type: "score",
61
+ instructions: question.instructions,
62
+ criteria: question.rubric.map(toEntry)
63
+ };
64
+ case "check": return {
65
+ type: "noul",
66
+ instructions: question.instructions
67
+ };
68
+ }
69
+ }
70
+ function sdkJson(value) {
71
+ if (Array.isArray(value)) return value.map(sdkJson);
72
+ if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));
73
+ return value;
74
+ }
75
+ // src/jev/decision-response.ts
76
+ function mapJevDecisionResponse(rawResponse, compiled, expectedKeys, modelId) {
77
+ const fail = (message, questionName) => {
78
+ throw new DecisionProviderOutputError(message, {
79
+ provider: "jev",
80
+ modelId,
81
+ questionName
82
+ });
83
+ };
84
+ if (!isDecisionDataObject(rawResponse) || !isDecisionDataObject(rawResponse.answers)) return fail("Jev returned an invalid answer envelope.");
85
+ const rawAnswers = rawResponse.answers;
86
+ if (Object.keys(rawAnswers).length !== expectedKeys.length || expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))) return fail("Jev answers do not match the requested questions.");
87
+ const answers = Object.fromEntries(compiled.map(({ name, question, keys }) => {
88
+ const getAnswer = (key) => {
89
+ const answer = key === void 0 ? void 0 : rawAnswers[key];
90
+ if (!isDecisionDataObject(answer)) return fail("Jev returned an invalid answer.", name);
91
+ return answer;
92
+ };
93
+ if (question.type === "multi-label") {
94
+ const labels = Object.keys(question.options);
95
+ const probabilities = Object.fromEntries(labels.map((label, index) => {
96
+ const answer = getAnswer(keys[index]);
97
+ if (answer.type !== "noul" || !isDecisionProbability(answer.noul)) return fail("Jev returned an invalid label probability.", name);
98
+ return [label, answer.noul];
99
+ }));
100
+ return [name, {
101
+ type: "multi-label",
102
+ labels: labels.filter((label) => probabilities[label] >= (question.threshold ?? .5)),
103
+ probabilities
104
+ }];
105
+ }
106
+ const answer = getAnswer(keys[0]);
107
+ if (question.type === "check") {
108
+ if (answer.type !== "noul" || !isDecisionProbability(answer.noul)) return fail("Jev returned an invalid boolean probability.", name);
109
+ return [name, {
110
+ type: "check",
111
+ probability: answer.noul
112
+ }];
113
+ }
114
+ if (answer.type !== question.type || !isDecisionProbability(answer.confidence) || !isDecisionDataObject(answer.probabilities)) return fail("Jev returned an invalid choice or score answer.", name);
115
+ if (question.type === "choice") {
116
+ if (typeof answer.choice !== "string" || !Object.hasOwn(question.options, answer.choice)) return fail("Jev selected an unknown option.", name);
117
+ validateDistribution(answer.probabilities, Object.keys(question.options), () => fail("Jev returned invalid choice probabilities.", name));
118
+ return [name, {
119
+ type: "choice",
120
+ choice: answer.choice,
121
+ probabilities: answer.probabilities,
122
+ confidence: answer.confidence
123
+ }];
124
+ }
125
+ const levelKeys = question.rubric.map((_, index) => String(index));
126
+ const expectedLegend = Object.fromEntries(question.rubric.map((level, index) => [String(index), toEntry(level)]));
127
+ if (!isDecisionDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) return fail("Jev returned a legend that does not match the requested rubric.", name);
128
+ const scoreProbabilities = answer.probabilities;
129
+ validateDistribution(scoreProbabilities, levelKeys, () => fail("Jev returned invalid score probabilities.", name));
130
+ if (typeof answer.score !== "number" || !Number.isFinite(answer.score) || answer.score < 0 || answer.score > question.rubric.length - 1) return fail("Jev returned a score outside the requested rubric.", name);
131
+ return [name, {
132
+ type: "score",
133
+ score: answer.score,
134
+ rubric: question.rubric,
135
+ probabilities: levelKeys.map((key) => scoreProbabilities[key]),
136
+ confidence: answer.confidence
137
+ }];
138
+ }));
139
+ const usage = rawResponse.usage;
140
+ if (!isDecisionDataObject(usage) || !isDecisionTokenCount(usage.input_tokens) || !isDecisionTokenCount(usage.output_tokens)) return fail("Jev returned invalid token usage.");
141
+ return {
142
+ answers,
143
+ usage: {
144
+ ...Usage.empty(),
145
+ inputTokens: usage.input_tokens,
146
+ outputTokens: usage.output_tokens,
147
+ totalTokens: usage.input_tokens + usage.output_tokens
148
+ },
149
+ rawResponse
150
+ };
151
+ }
152
+ /** Compare validated JSON without depending on object property order. */
153
+ function jsonEqual(left, right) {
154
+ if (left === right) return true;
155
+ if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => jsonEqual(value, right[index]));
156
+ if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
157
+ const leftObject = left;
158
+ const rightObject = right;
159
+ const keys = Object.keys(leftObject);
160
+ return Object.keys(rightObject).length === keys.length && keys.every((key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key], rightObject[key]));
161
+ }
162
+ function validateDistribution(value, keys, fail) {
163
+ const values = Object.values(value);
164
+ if (values.length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)) || !values.every(isDecisionProbability) || !probabilitiesSumToOne(values)) fail();
165
+ }
6
166
  // src/jev/errors.ts
7
167
  /** Distinguish SDK timeout cancellation from cancellation requested by the caller. */
8
168
  function normalizeJevError(error, abortSignal) {
@@ -40,46 +200,14 @@ var JevDecisionModel = class {
40
200
  this.modelId = modelId;
41
201
  }
42
202
  async decision(request, options) {
43
- const compiled = [];
44
- const questions = [];
45
- for (const [index, [name, question]] of Object.entries(request.questions).entries()) {
46
- const key = `q${index}`;
47
- if (question.type === "multi-label") {
48
- const keys = Object.entries(question.options).map(([label, description], labelIndex) => {
49
- const labelKey = `${key}_${labelIndex}`;
50
- questions.push([labelKey, {
51
- type: "noul",
52
- instructions: {
53
- instructions: question.instructions,
54
- label,
55
- task: "Does this label apply to the state? Evaluate it independently of other labels."
56
- },
57
- criteria: { true: toEntry(description) }
58
- }]);
59
- return labelKey;
60
- });
61
- compiled.push({
62
- name,
63
- question,
64
- keys
65
- });
66
- } else {
67
- const native = nativeQuestion(question);
68
- questions.push([key, native]);
69
- compiled.push({
70
- name,
71
- question,
72
- keys: [key]
73
- });
74
- }
75
- }
203
+ const { compiled, wireQuestions } = compileJevQuestions(request.questions);
76
204
  let rawResponse;
77
205
  try {
78
206
  const body = {
79
207
  ...request.providerOptions,
80
208
  state: toEntry(request.state) ?? { value: null },
81
209
  model: this.modelId,
82
- questions: Object.fromEntries(questions)
210
+ questions: Object.fromEntries(wireQuestions)
83
211
  };
84
212
  const requestOptions = { retry: { maxRetries: 0 } };
85
213
  if (options?.abortSignal !== void 0) requestOptions.signal = options.abortSignal;
@@ -87,134 +215,9 @@ var JevDecisionModel = class {
87
215
  } catch (error) {
88
216
  throw normalizeJevError(error, options?.abortSignal);
89
217
  }
90
- const fail = (message, questionName) => {
91
- throw new DecisionProviderOutputError(message, {
92
- provider: this.provider,
93
- modelId: this.modelId,
94
- questionName
95
- });
96
- };
97
- if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) return fail("Jev returned an invalid answer envelope.");
98
- const rawAnswers = rawResponse.answers;
99
- const expectedKeys = questions.map(([key]) => key);
100
- if (Object.keys(rawAnswers).length !== expectedKeys.length || expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))) return fail("Jev answers do not match the requested questions.");
101
- const answers = Object.fromEntries(compiled.map(({ name, question, keys }) => {
102
- const getAnswer = (key) => {
103
- const answer = key === void 0 ? void 0 : rawAnswers[key];
104
- if (!isDataObject(answer)) return fail("Jev returned an invalid answer.", name);
105
- return answer;
106
- };
107
- if (question.type === "multi-label") {
108
- const labels = Object.keys(question.options);
109
- const probabilities = Object.fromEntries(labels.map((label, index) => {
110
- const answer = getAnswer(keys[index]);
111
- if (answer.type !== "noul" || !isProbability(answer.noul)) return fail("Jev returned an invalid label probability.", name);
112
- return [label, answer.noul];
113
- }));
114
- return [name, {
115
- type: "multi-label",
116
- labels: labels.filter((label) => probabilities[label] >= (question.threshold ?? .5)),
117
- probabilities
118
- }];
119
- }
120
- const answer = getAnswer(keys[0]);
121
- if (question.type === "check") {
122
- if (answer.type !== "noul" || !isProbability(answer.noul)) return fail("Jev returned an invalid boolean probability.", name);
123
- return [name, {
124
- type: "check",
125
- probability: answer.noul
126
- }];
127
- }
128
- if (answer.type !== question.type || !isProbability(answer.confidence) || !isDataObject(answer.probabilities)) return fail("Jev returned an invalid choice or score answer.", name);
129
- if (question.type === "choice") {
130
- if (typeof answer.choice !== "string" || !Object.hasOwn(question.options, answer.choice)) return fail("Jev selected an unknown option.", name);
131
- validateDistribution(answer.probabilities, Object.keys(question.options), () => fail("Jev returned invalid choice probabilities.", name));
132
- return [name, {
133
- type: "choice",
134
- choice: answer.choice,
135
- probabilities: answer.probabilities,
136
- confidence: answer.confidence
137
- }];
138
- }
139
- const levelKeys = question.rubric.map((_, index) => String(index));
140
- const expectedLegend = Object.fromEntries(question.rubric.map((level, index) => [String(index), toEntry(level)]));
141
- if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) return fail("Jev returned a legend that does not match the requested rubric.", name);
142
- const scoreProbabilities = answer.probabilities;
143
- validateDistribution(scoreProbabilities, levelKeys, () => fail("Jev returned invalid score probabilities.", name));
144
- if (typeof answer.score !== "number" || !Number.isFinite(answer.score) || answer.score < 0 || answer.score > question.rubric.length - 1) return fail("Jev returned a score outside the requested rubric.", name);
145
- return [name, {
146
- type: "score",
147
- score: answer.score,
148
- rubric: question.rubric,
149
- probabilities: levelKeys.map((key) => scoreProbabilities[key]),
150
- confidence: answer.confidence
151
- }];
152
- }));
153
- const usage = rawResponse.usage;
154
- if (!isDataObject(usage) || !isTokenCount(usage.input_tokens) || !isTokenCount(usage.output_tokens)) return fail("Jev returned invalid token usage.");
155
- return {
156
- answers,
157
- usage: {
158
- ...Usage.empty(),
159
- inputTokens: usage.input_tokens,
160
- outputTokens: usage.output_tokens,
161
- totalTokens: usage.input_tokens + usage.output_tokens
162
- },
163
- rawResponse
164
- };
218
+ return mapJevDecisionResponse(rawResponse, compiled, wireQuestions.map(([key]) => key), this.modelId);
165
219
  }
166
220
  };
167
- function nativeQuestion(question) {
168
- switch (question.type) {
169
- case "choice": return {
170
- type: "choice",
171
- instructions: question.instructions,
172
- criteria: Object.fromEntries(Object.entries(question.options).map(([label, description]) => [label, toEntry(description)]))
173
- };
174
- case "score": return {
175
- type: "score",
176
- instructions: question.instructions,
177
- criteria: question.rubric.map(toEntry)
178
- };
179
- case "check": return {
180
- type: "noul",
181
- instructions: question.instructions
182
- };
183
- }
184
- }
185
- /** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */
186
- function toEntry(value) {
187
- const normalized = sdkJson(value);
188
- return typeof normalized === "number" || typeof normalized === "boolean" ? { value: normalized } : normalized;
189
- }
190
- function sdkJson(value) {
191
- if (Array.isArray(value)) return value.map(sdkJson);
192
- if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));
193
- return value;
194
- }
195
- function isDataObject(value) {
196
- return value !== null && typeof value === "object" && !Array.isArray(value) && isJsonValue(value);
197
- }
198
- /** Compare validated JSON without depending on object property order. */
199
- function jsonEqual(left, right) {
200
- if (left === right) return true;
201
- if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => jsonEqual(value, right[index]));
202
- if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
203
- const leftObject = left;
204
- const rightObject = right;
205
- const keys = Object.keys(leftObject);
206
- return Object.keys(rightObject).length === keys.length && keys.every((key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key], rightObject[key]));
207
- }
208
- function isProbability(value) {
209
- return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
210
- }
211
- function isTokenCount(value) {
212
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
213
- }
214
- function validateDistribution(value, keys, fail) {
215
- const values = Object.values(value);
216
- if (values.length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)) || !values.every(isProbability) || Math.abs(values.reduce((sum, probability) => sum + probability, 0) - 1) > 1e-5) fail();
217
- }
218
221
  // src/jev/client.ts
219
222
  var JevClient = class {
220
223
  sdk;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/jev/errors.ts","../src/jev/decision.ts","../src/jev/client.ts","../src/jev/models.ts","../src/jev/index.ts"],"sourcesContent":["import { APITimeoutError } from \"@typesafe-ai/sdk\";\n\n/** Distinguish SDK timeout cancellation from cancellation requested by the caller. */\nexport function normalizeJevError(error: unknown, abortSignal?: AbortSignal): unknown {\n if (abortSignal?.aborted) {\n const aborted = new Error(\"The Jev request was aborted.\", { cause: error });\n aborted.name = \"AbortError\";\n return aborted;\n }\n if (error instanceof APITimeoutError) {\n // The SDK timeout cause is AbortError. Keep it outside the cause chain so core\n // retries recognize a timeout without mistaking it for caller cancellation.\n return Object.assign(new Error(error.message), { name: \"TimeoutError\", providerError: error });\n }\n return error;\n}\n","import {\n DecisionProviderOutputError,\n type DecisionAnswers,\n type DecisionCapabilities,\n type DecisionModel,\n type DecisionQuestion,\n type DecisionQuestions,\n type DecisionRequest,\n type DecisionResult,\n type JsonValue,\n type ModelCallOptions,\n} from \"@anvia/core/decision\";\nimport { isJsonValue, Usage } from \"@anvia/core/completion\";\nimport type {\n EntryType,\n JsonValue as SdkJsonValue,\n Question,\n TypeSafeClient,\n} from \"@typesafe-ai/sdk\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\ntype CompiledQuestion = {\n name: string;\n question: DecisionQuestion;\n keys: string[];\n};\n\nexport class JevDecisionModel implements DecisionModel<unknown> {\n readonly provider = \"jev\";\n readonly capabilities: DecisionCapabilities = Object.freeze({\n questionSupport: Object.freeze({\n choice: \"native\",\n \"multi-label\": \"composed\",\n score: \"native\",\n check: \"native\",\n }),\n mixedQuestions: true,\n limits: Object.freeze({ maxChoiceOptions: 255, maxRubricLevels: 10 }),\n });\n\n constructor(\n private readonly sdk: TypeSafeClient,\n readonly modelId: JevDecisionModelId,\n ) {}\n\n async decision<const Questions extends DecisionQuestions>(\n request: DecisionRequest<Questions>,\n options?: ModelCallOptions,\n ): Promise<DecisionResult<Questions, unknown>> {\n const compiled: CompiledQuestion[] = [];\n const questions: [string, Question][] = [];\n for (const [index, [name, question]] of Object.entries(request.questions).entries()) {\n const key = `q${index}`;\n if (question.type === \"multi-label\") {\n const keys = Object.entries(question.options).map(([label, description], labelIndex) => {\n const labelKey = `${key}_${labelIndex}`;\n questions.push([\n labelKey,\n {\n type: \"noul\",\n instructions: {\n instructions: question.instructions,\n label,\n task: \"Does this label apply to the state? Evaluate it independently of other labels.\",\n },\n criteria: { true: toEntry(description) },\n },\n ]);\n return labelKey;\n });\n compiled.push({ name, question, keys });\n } else {\n const native = nativeQuestion(question);\n questions.push([key, native]);\n compiled.push({ name, question, keys: [key] });\n }\n }\n\n let rawResponse: unknown;\n try {\n const body = {\n ...request.providerOptions,\n state: toEntry(request.state) ?? { value: null },\n model: this.modelId,\n questions: Object.fromEntries(questions),\n };\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"systemOne\"]>[1]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n rawResponse = await this.sdk.systemOne(body, requestOptions);\n } catch (error) {\n throw normalizeJevError(error, options?.abortSignal);\n }\n\n const fail = (message: string, questionName?: string): never => {\n throw new DecisionProviderOutputError(message, {\n provider: this.provider,\n modelId: this.modelId,\n questionName,\n });\n };\n if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) {\n return fail(\"Jev returned an invalid answer envelope.\");\n }\n const rawAnswers = rawResponse.answers;\n const expectedKeys = questions.map(([key]) => key);\n if (\n Object.keys(rawAnswers).length !== expectedKeys.length ||\n expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))\n ) {\n return fail(\"Jev answers do not match the requested questions.\");\n }\n const answers = Object.fromEntries(\n compiled.map(({ name, question, keys }) => {\n const getAnswer = (key: string | undefined): Record<string, JsonValue> => {\n const answer = key === undefined ? undefined : rawAnswers[key];\n if (!isDataObject(answer)) return fail(\"Jev returned an invalid answer.\", name);\n return answer;\n };\n if (question.type === \"multi-label\") {\n const labels = Object.keys(question.options);\n const probabilities = Object.fromEntries(\n labels.map((label, index) => {\n const answer = getAnswer(keys[index]);\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid label probability.\", name);\n }\n return [label, answer.noul];\n }),\n );\n return [\n name,\n {\n type: \"multi-label\",\n labels: labels.filter(\n (label) => probabilities[label]! >= (question.threshold ?? 0.5),\n ),\n probabilities,\n },\n ];\n }\n const answer = getAnswer(keys[0]);\n if (question.type === \"check\") {\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid boolean probability.\", name);\n }\n return [name, { type: \"check\", probability: answer.noul }];\n }\n if (\n answer.type !== question.type ||\n !isProbability(answer.confidence) ||\n !isDataObject(answer.probabilities)\n ) {\n return fail(\"Jev returned an invalid choice or score answer.\", name);\n }\n if (question.type === \"choice\") {\n if (\n typeof answer.choice !== \"string\" ||\n !Object.hasOwn(question.options, answer.choice)\n ) {\n return fail(\"Jev selected an unknown option.\", name);\n }\n validateDistribution(answer.probabilities, Object.keys(question.options), () =>\n fail(\"Jev returned invalid choice probabilities.\", name),\n );\n return [\n name,\n {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities,\n confidence: answer.confidence,\n },\n ];\n }\n const levelKeys = question.rubric.map((_, index) => String(index));\n const expectedLegend = Object.fromEntries(\n question.rubric.map((level, index) => [String(index), toEntry(level)]),\n ) as Record<string, JsonValue>;\n if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) {\n return fail(\"Jev returned a legend that does not match the requested rubric.\", name);\n }\n const scoreProbabilities = answer.probabilities;\n validateDistribution(scoreProbabilities, levelKeys, () =>\n fail(\"Jev returned invalid score probabilities.\", name),\n );\n if (\n typeof answer.score !== \"number\" ||\n !Number.isFinite(answer.score) ||\n answer.score < 0 ||\n answer.score > question.rubric.length - 1\n ) {\n return fail(\"Jev returned a score outside the requested rubric.\", name);\n }\n return [\n name,\n {\n type: \"score\",\n score: answer.score,\n rubric: question.rubric,\n probabilities: levelKeys.map((key) => scoreProbabilities[key]),\n confidence: answer.confidence,\n },\n ];\n }),\n ) as DecisionAnswers<Questions>;\n\n const usage = rawResponse.usage;\n if (\n !isDataObject(usage) ||\n !isTokenCount(usage.input_tokens) ||\n !isTokenCount(usage.output_tokens)\n ) {\n return fail(\"Jev returned invalid token usage.\");\n }\n return {\n answers,\n usage: {\n ...Usage.empty(),\n inputTokens: usage.input_tokens,\n outputTokens: usage.output_tokens,\n totalTokens: usage.input_tokens + usage.output_tokens,\n },\n rawResponse,\n };\n }\n}\n\nfunction nativeQuestion(question: Exclude<DecisionQuestion, { type: \"multi-label\" }>): Question {\n switch (question.type) {\n case \"choice\":\n return {\n type: \"choice\",\n instructions: question.instructions,\n criteria: Object.fromEntries(\n Object.entries(question.options).map(([label, description]) => [\n label,\n toEntry(description),\n ]),\n ),\n };\n case \"score\":\n return {\n type: \"score\",\n instructions: question.instructions,\n criteria: question.rubric.map(toEntry) as [EntryType, EntryType, ...EntryType[]],\n };\n case \"check\":\n return { type: \"noul\", instructions: question.instructions };\n }\n}\n\n/** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */\nfunction toEntry(value: JsonValue): EntryType {\n const normalized = sdkJson(value);\n return typeof normalized === \"number\" || typeof normalized === \"boolean\"\n ? { value: normalized }\n : normalized;\n}\n\nfunction sdkJson(value: JsonValue): SdkJsonValue {\n if (Array.isArray(value)) return value.map(sdkJson);\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));\n }\n return value as string | number | boolean | null;\n}\n\nfunction isDataObject(value: unknown): value is Record<string, JsonValue> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value) && isJsonValue(value);\n}\n\n/** Compare validated JSON without depending on object property order. */\nfunction jsonEqual(left: JsonValue, right: JsonValue): boolean {\n if (left === right) return true;\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((value, index) => jsonEqual(value, right[index]!))\n );\n }\n if (left === null || right === null || typeof left !== \"object\" || typeof right !== \"object\")\n return false;\n // Array.isArray does not narrow readonly JSON arrays out of the object union.\n const leftObject = left as Record<string, JsonValue>;\n const rightObject = right as Record<string, JsonValue>;\n const keys = Object.keys(leftObject);\n return (\n Object.keys(rightObject).length === keys.length &&\n keys.every(\n (key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key]!, rightObject[key]!),\n )\n );\n}\n\nfunction isProbability(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0 && value <= 1;\n}\n\nfunction isTokenCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction validateDistribution(\n value: Record<string, JsonValue>,\n keys: string[],\n fail: () => never,\n): void {\n const values = Object.values(value);\n if (\n values.length !== keys.length ||\n keys.some((key) => !Object.hasOwn(value, key)) ||\n !values.every(isProbability) ||\n Math.abs(values.reduce((sum, probability) => sum + probability, 0) - 1) > 1e-5\n ) {\n fail();\n }\n}\n","import type { DecisionModel } from \"@anvia/core/decision\";\nimport {\n ModelListingError,\n type ModelList,\n type ModelListingClient,\n} from \"@anvia/core/model-listing\";\nimport { TypeSafeClient } from \"@typesafe-ai/sdk\";\nimport { JevDecisionModel } from \"./decision\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\nexport type JevClientOptions =\n | {\n apiKey?: string | undefined;\n baseUrl?: string | undefined;\n headers?: Record<string, string> | undefined;\n client?: never;\n }\n | {\n client: TypeSafeClient;\n apiKey?: never;\n baseUrl?: never;\n headers?: never;\n };\n\nexport type JevDecisionModelOptions = { modelId: JevDecisionModelId };\nexport type JevDecisionModelHandle = DecisionModel<unknown>;\n\nexport class JevClient implements ModelListingClient {\n private readonly sdk: TypeSafeClient;\n\n constructor(options: JevClientOptions) {\n if (options.client !== undefined) {\n if ([\"apiKey\", \"baseUrl\", \"headers\"].some((key) => key in options)) {\n throw new TypeError(\"JevClient cannot combine an injected client with managed options.\");\n }\n this.sdk = options.client;\n return;\n }\n const apiKey = options.apiKey ?? process.env.TYPESAFE_API_KEY;\n if (typeof apiKey !== \"string\" || apiKey.trim().length === 0) {\n throw new TypeError(\"JevClient requires apiKey or TYPESAFE_API_KEY.\");\n }\n\n const clientOptions: ConstructorParameters<typeof TypeSafeClient>[0] = {\n apiKey,\n retry: { maxRetries: 0 },\n logLevel: \"off\",\n };\n\n if (options.baseUrl !== undefined) {\n clientOptions.baseURL = options.baseUrl;\n }\n\n if (options.headers !== undefined) {\n clientOptions.defaultHeaders = options.headers;\n }\n\n this.sdk = new TypeSafeClient(clientOptions);\n }\n\n decisionModel(options: JevDecisionModelOptions): JevDecisionModelHandle {\n if (typeof options.modelId !== \"string\" || options.modelId.trim().length === 0) {\n throw new TypeError(\"Jev modelId must be a non-empty string.\");\n }\n return new JevDecisionModel(this.sdk, options.modelId);\n }\n\n async listModels(options?: { abortSignal?: AbortSignal | undefined }): Promise<ModelList> {\n try {\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"models\"][\"list\"]>[0]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n const models = await this.sdk.models.list(requestOptions);\n if (\n !Array.isArray(models) ||\n models.some(\n (model) =>\n typeof model?.name !== \"string\" ||\n typeof model.description !== \"string\" ||\n typeof model.release_date !== \"string\",\n )\n ) {\n throw new TypeError(\"Jev returned invalid model metadata.\");\n }\n return {\n data: models.map((model) => ({\n id: model.name,\n name: model.name,\n description: model.description,\n type: \"decision\",\n })),\n };\n } catch (error) {\n const normalized = normalizeJevError(error, options?.abortSignal);\n if (options?.abortSignal?.aborted) {\n throw normalized;\n }\n throw new ModelListingError(\"Failed to list Jev models.\", {\n provider: \"jev\",\n cause: normalized,\n });\n }\n }\n}\n","import type { ModelId } from \"@anvia/core/model-listing\";\n\nexport const JEV_LATEST = \"jev-latest\";\nexport const JEV_PREVIEW = \"jev-preview\";\nexport type KnownJevDecisionModelId = typeof JEV_LATEST | typeof JEV_PREVIEW;\nexport type JevDecisionModelId = ModelId<KnownJevDecisionModelId>;\n","export {\n JevClient,\n type JevClientOptions,\n type JevDecisionModelOptions,\n type JevDecisionModelHandle,\n} from \"./client\";\nexport {\n JEV_LATEST,\n JEV_PREVIEW,\n type KnownJevDecisionModelId,\n type JevDecisionModelId,\n} from \"./models\";\n"],"mappings":";;;;;;;AAGA,SAAgB,kBAAkB,OAAgB,aAAoC;CACpF,IAAI,aAAa,SAAS;EACxB,MAAM,UAAU,IAAI,MAAM,gCAAgC,EAAE,OAAO,MAAM,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SAAS,YACvB,OAAO,MAAM,gBAAgB,YAC7B,OAAO,MAAM,iBAAiB,QAClC,GAEA,MAAM,IAAI,UAAU,sCAAsC;GAE5D,OAAO,EACL,MAAM,OAAO,KAAK,WAAW;IAC3B,IAAI,MAAM;IACV,MAAM,MAAM;IACZ,aAAa,MAAM;IACnB,MAAM;GACR,EAAE,EACJ;EACF,SAAS,OAAO;GACd,MAAM,aAAa,kBAAkB,OAAO,SAAS,WAAW;GAChE,IAAI,SAAS,aAAa,SACxB,MAAM;GAER,MAAM,IAAI,kBAAkB,8BAA8B;IACxD,UAAU;IACV,OAAO;GACT,CAAC;EACH;CACF;AACF;;AC3GA,MAAa,aAAa;AAC1B,MAAa,cAAc"}
1
+ {"version":3,"file":"index.js","names":["isDataObject","isProbability","isTokenCount"],"sources":["../src/jev/decision-request.ts","../src/jev/decision-response.ts","../src/jev/errors.ts","../src/jev/decision.ts","../src/jev/client.ts","../src/jev/models.ts","../src/jev/index.ts"],"sourcesContent":["import type { DecisionQuestion, DecisionQuestions, JsonValue } from \"@anvia/core/decision\";\nimport type { EntryType, JsonValue as SdkJsonValue, Question } from \"@typesafe-ai/sdk\";\n\nexport type CompiledJevQuestion = {\n name: string;\n question: DecisionQuestion;\n keys: string[];\n};\n\nexport function compileJevQuestions(questions: DecisionQuestions): {\n compiled: CompiledJevQuestion[];\n wireQuestions: [string, Question][];\n} {\n const compiled: CompiledJevQuestion[] = [];\n const wireQuestions: [string, Question][] = [];\n for (const [index, [name, question]] of Object.entries(questions).entries()) {\n const key = `q${index}`;\n\n if (question.type === \"multi-label\") {\n const keys = Object.entries(question.options).map(([label, description], labelIndex) => {\n const labelKey = `${key}_${labelIndex}`;\n wireQuestions.push([\n labelKey,\n {\n type: \"noul\",\n instructions: {\n instructions: question.instructions,\n label,\n task: \"Does this label apply to the state? Evaluate it independently of other labels.\",\n },\n criteria: { true: toEntry(description) },\n },\n ]);\n return labelKey;\n });\n compiled.push({ name, question, keys });\n } else {\n const native = nativeQuestion(question);\n wireQuestions.push([key, native]);\n compiled.push({ name, question, keys: [key] });\n }\n }\n return { compiled, wireQuestions };\n}\n\n/** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */\nexport function toEntry(value: JsonValue): EntryType {\n const normalized = sdkJson(value);\n return typeof normalized === \"number\" || typeof normalized === \"boolean\"\n ? { value: normalized }\n : normalized;\n}\n\nfunction nativeQuestion(question: Exclude<DecisionQuestion, { type: \"multi-label\" }>): Question {\n switch (question.type) {\n case \"choice\":\n return {\n type: \"choice\",\n instructions: question.instructions,\n criteria: Object.fromEntries(\n Object.entries(question.options).map(([label, description]) => [\n label,\n toEntry(description),\n ]),\n ),\n };\n case \"score\":\n return {\n type: \"score\",\n instructions: question.instructions,\n criteria: question.rubric.map(toEntry) as [EntryType, EntryType, ...EntryType[]],\n };\n case \"check\":\n return { type: \"noul\", instructions: question.instructions };\n }\n}\n\nfunction sdkJson(value: JsonValue): SdkJsonValue {\n if (Array.isArray(value)) return value.map(sdkJson);\n\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));\n }\n\n return value as string | number | boolean | null;\n}\n","import { Usage } from \"@anvia/core/completion\";\nimport {\n type DecisionAnswers,\n DecisionProviderOutputError,\n type DecisionQuestions,\n type DecisionResult,\n type JsonValue,\n} from \"@anvia/core/decision\";\nimport {\n isDecisionDataObject as isDataObject,\n isDecisionProbability as isProbability,\n isDecisionTokenCount as isTokenCount,\n probabilitiesSumToOne,\n} from \"@anvia/core/internal/provider\";\nimport { type CompiledJevQuestion, toEntry } from \"./decision-request\";\n\nexport function mapJevDecisionResponse<Questions extends DecisionQuestions>(\n rawResponse: unknown,\n compiled: CompiledJevQuestion[],\n expectedKeys: readonly string[],\n modelId: string,\n): DecisionResult<Questions, unknown> {\n const fail = (message: string, questionName?: string): never => {\n throw new DecisionProviderOutputError(message, {\n provider: \"jev\",\n modelId,\n questionName,\n });\n };\n\n if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) {\n return fail(\"Jev returned an invalid answer envelope.\");\n }\n\n const rawAnswers = rawResponse.answers;\n\n if (\n Object.keys(rawAnswers).length !== expectedKeys.length ||\n expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))\n ) {\n return fail(\"Jev answers do not match the requested questions.\");\n }\n\n const answers = Object.fromEntries(\n compiled.map(({ name, question, keys }) => {\n const getAnswer = (key: string | undefined): Record<string, JsonValue> => {\n const answer = key === undefined ? undefined : rawAnswers[key];\n\n if (!isDataObject(answer)) return fail(\"Jev returned an invalid answer.\", name);\n\n return answer;\n };\n\n if (question.type === \"multi-label\") {\n const labels = Object.keys(question.options);\n const probabilities = Object.fromEntries(\n labels.map((label, index) => {\n const answer = getAnswer(keys[index]);\n\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid label probability.\", name);\n }\n\n return [label, answer.noul];\n }),\n );\n return [\n name,\n {\n type: \"multi-label\",\n labels: labels.filter((label) => probabilities[label]! >= (question.threshold ?? 0.5)),\n probabilities,\n },\n ];\n }\n\n const answer = getAnswer(keys[0]);\n\n if (question.type === \"check\") {\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid boolean probability.\", name);\n }\n\n return [name, { type: \"check\", probability: answer.noul }];\n }\n\n if (\n answer.type !== question.type ||\n !isProbability(answer.confidence) ||\n !isDataObject(answer.probabilities)\n ) {\n return fail(\"Jev returned an invalid choice or score answer.\", name);\n }\n\n if (question.type === \"choice\") {\n if (typeof answer.choice !== \"string\" || !Object.hasOwn(question.options, answer.choice)) {\n return fail(\"Jev selected an unknown option.\", name);\n }\n\n validateDistribution(answer.probabilities, Object.keys(question.options), () =>\n fail(\"Jev returned invalid choice probabilities.\", name),\n );\n return [\n name,\n {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities,\n confidence: answer.confidence,\n },\n ];\n }\n\n const levelKeys = question.rubric.map((_, index) => String(index));\n const expectedLegend = Object.fromEntries(\n question.rubric.map((level, index) => [String(index), toEntry(level)]),\n ) as Record<string, JsonValue>;\n\n if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) {\n return fail(\"Jev returned a legend that does not match the requested rubric.\", name);\n }\n\n const scoreProbabilities = answer.probabilities;\n validateDistribution(scoreProbabilities, levelKeys, () =>\n fail(\"Jev returned invalid score probabilities.\", name),\n );\n\n if (\n typeof answer.score !== \"number\" ||\n !Number.isFinite(answer.score) ||\n answer.score < 0 ||\n answer.score > question.rubric.length - 1\n ) {\n return fail(\"Jev returned a score outside the requested rubric.\", name);\n }\n\n return [\n name,\n {\n type: \"score\",\n score: answer.score,\n rubric: question.rubric,\n probabilities: levelKeys.map((key) => scoreProbabilities[key]),\n confidence: answer.confidence,\n },\n ];\n }),\n ) as DecisionAnswers<Questions>;\n\n const usage = rawResponse.usage;\n\n if (\n !isDataObject(usage) ||\n !isTokenCount(usage.input_tokens) ||\n !isTokenCount(usage.output_tokens)\n ) {\n return fail(\"Jev returned invalid token usage.\");\n }\n\n return {\n answers,\n usage: {\n ...Usage.empty(),\n inputTokens: usage.input_tokens,\n outputTokens: usage.output_tokens,\n totalTokens: usage.input_tokens + usage.output_tokens,\n },\n rawResponse,\n };\n}\n\n/** Compare validated JSON without depending on object property order. */\nfunction jsonEqual(left: JsonValue, right: JsonValue): boolean {\n if (left === right) return true;\n\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((value, index) => jsonEqual(value, right[index]!))\n );\n }\n\n if (left === null || right === null || typeof left !== \"object\" || typeof right !== \"object\")\n return false;\n\n const leftObject = left as Record<string, JsonValue>;\n const rightObject = right as Record<string, JsonValue>;\n const keys = Object.keys(leftObject);\n return (\n Object.keys(rightObject).length === keys.length &&\n keys.every(\n (key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key]!, rightObject[key]!),\n )\n );\n}\n\nfunction validateDistribution(\n value: Record<string, JsonValue>,\n keys: string[],\n fail: () => never,\n): void {\n const values = Object.values(value);\n\n if (\n values.length !== keys.length ||\n keys.some((key) => !Object.hasOwn(value, key)) ||\n !values.every(isProbability) ||\n !probabilitiesSumToOne(values)\n ) {\n fail();\n }\n}\n","import { APITimeoutError } from \"@typesafe-ai/sdk\";\n\n/** Distinguish SDK timeout cancellation from cancellation requested by the caller. */\nexport function normalizeJevError(error: unknown, abortSignal?: AbortSignal): unknown {\n if (abortSignal?.aborted) {\n const aborted = new Error(\"The Jev request was aborted.\", { cause: error });\n aborted.name = \"AbortError\";\n return aborted;\n }\n\n if (error instanceof APITimeoutError) {\n return Object.assign(new Error(error.message), { name: \"TimeoutError\", providerError: error });\n }\n\n return error;\n}\n","import type {\n DecisionCapabilities,\n DecisionModel,\n DecisionQuestions,\n DecisionRequest,\n DecisionResult,\n ModelCallOptions,\n} from \"@anvia/core/decision\";\nimport type { TypeSafeClient } from \"@typesafe-ai/sdk\";\nimport { compileJevQuestions, toEntry } from \"./decision-request\";\nimport { mapJevDecisionResponse } from \"./decision-response\";\nimport { normalizeJevError } from \"./errors\";\nimport type { JevDecisionModelId } from \"./models\";\n\nexport class JevDecisionModel implements DecisionModel<unknown> {\n readonly provider = \"jev\";\n readonly capabilities: DecisionCapabilities = Object.freeze({\n questionSupport: Object.freeze({\n choice: \"native\",\n \"multi-label\": \"composed\",\n score: \"native\",\n check: \"native\",\n }),\n mixedQuestions: true,\n limits: Object.freeze({ maxChoiceOptions: 255, maxRubricLevels: 10 }),\n });\n\n constructor(\n private readonly sdk: TypeSafeClient,\n readonly modelId: JevDecisionModelId,\n ) {}\n\n async decision<const Questions extends DecisionQuestions>(\n request: DecisionRequest<Questions>,\n options?: ModelCallOptions,\n ): Promise<DecisionResult<Questions, unknown>> {\n const { compiled, wireQuestions } = compileJevQuestions(request.questions);\n\n let rawResponse: unknown;\n try {\n const body = {\n ...request.providerOptions,\n state: toEntry(request.state) ?? { value: null },\n model: this.modelId,\n questions: Object.fromEntries(wireQuestions),\n };\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"systemOne\"]>[1]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n rawResponse = await this.sdk.systemOne(body, requestOptions);\n } catch (error) {\n throw normalizeJevError(error, options?.abortSignal);\n }\n\n return mapJevDecisionResponse<Questions>(\n rawResponse,\n compiled,\n wireQuestions.map(([key]) => key),\n this.modelId,\n );\n }\n}\n","import type { DecisionModel } from \"@anvia/core/decision\";\nimport {\n ModelListingError,\n type ModelList,\n type ModelListingClient,\n} from \"@anvia/core/model-listing\";\nimport { TypeSafeClient } from \"@typesafe-ai/sdk\";\nimport { JevDecisionModel } from \"./decision\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\nexport type JevClientOptions =\n | {\n apiKey?: string | undefined;\n baseUrl?: string | undefined;\n headers?: Record<string, string> | undefined;\n client?: never;\n }\n | {\n client: TypeSafeClient;\n apiKey?: never;\n baseUrl?: never;\n headers?: never;\n };\n\nexport type JevDecisionModelOptions = { modelId: JevDecisionModelId };\nexport type JevDecisionModelHandle = DecisionModel<unknown>;\n\nexport class JevClient implements ModelListingClient {\n private readonly sdk: TypeSafeClient;\n\n constructor(options: JevClientOptions) {\n if (options.client !== undefined) {\n if ([\"apiKey\", \"baseUrl\", \"headers\"].some((key) => key in options)) {\n throw new TypeError(\"JevClient cannot combine an injected client with managed options.\");\n }\n\n this.sdk = options.client;\n return;\n }\n\n const apiKey = options.apiKey ?? process.env.TYPESAFE_API_KEY;\n\n if (typeof apiKey !== \"string\" || apiKey.trim().length === 0) {\n throw new TypeError(\"JevClient requires apiKey or TYPESAFE_API_KEY.\");\n }\n\n const clientOptions: ConstructorParameters<typeof TypeSafeClient>[0] = {\n apiKey,\n retry: { maxRetries: 0 },\n logLevel: \"off\",\n };\n\n if (options.baseUrl !== undefined) {\n clientOptions.baseURL = options.baseUrl;\n }\n\n if (options.headers !== undefined) {\n clientOptions.defaultHeaders = options.headers;\n }\n\n this.sdk = new TypeSafeClient(clientOptions);\n }\n\n decisionModel(options: JevDecisionModelOptions): JevDecisionModelHandle {\n if (typeof options.modelId !== \"string\" || options.modelId.trim().length === 0) {\n throw new TypeError(\"Jev modelId must be a non-empty string.\");\n }\n\n return new JevDecisionModel(this.sdk, options.modelId);\n }\n\n async listModels(options?: { abortSignal?: AbortSignal | undefined }): Promise<ModelList> {\n try {\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"models\"][\"list\"]>[0]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n const models = await this.sdk.models.list(requestOptions);\n\n if (\n !Array.isArray(models) ||\n models.some(\n (model) =>\n typeof model?.name !== \"string\" ||\n typeof model.description !== \"string\" ||\n typeof model.release_date !== \"string\",\n )\n ) {\n throw new TypeError(\"Jev returned invalid model metadata.\");\n }\n\n return {\n data: models.map((model) => ({\n id: model.name,\n name: model.name,\n description: model.description,\n type: \"decision\",\n })),\n };\n } catch (error) {\n const normalized = normalizeJevError(error, options?.abortSignal);\n\n if (options?.abortSignal?.aborted) {\n throw normalized;\n }\n\n throw new ModelListingError(\"Failed to list Jev models.\", {\n provider: \"jev\",\n cause: normalized,\n });\n }\n }\n}\n","import type { ModelId } from \"@anvia/core/model-listing\";\n\nexport const JEV_LATEST = \"jev-latest\";\nexport const JEV_PREVIEW = \"jev-preview\";\nexport type KnownJevDecisionModelId = typeof JEV_LATEST | typeof JEV_PREVIEW;\nexport type JevDecisionModelId = ModelId<KnownJevDecisionModelId>;\n","export {\n JevClient,\n type JevClientOptions,\n type JevDecisionModelOptions,\n type JevDecisionModelHandle,\n} from \"./client\";\nexport {\n JEV_LATEST,\n JEV_PREVIEW,\n type KnownJevDecisionModelId,\n type JevDecisionModelId,\n} from \"./models\";\n"],"mappings":";;;;;;;AASA,SAAgB,oBAAoB,WAGlC;CACA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AM,IAAI,UAAU,sCAAsC;GAG5D,OAAO,EACL,MAAM,OAAO,KAAK,WAAW;IAC3B,IAAI,MAAM;IACV,MAAM,MAAM;IACZ,aAAa,MAAM;IACnB,MAAM;GACR,EAAE,EACJ;EACF,SAAS,OAAO;GACd,MAAM,aAAa,kBAAkB,OAAO,SAAS,WAAW;GAEhE,IAAI,SAAS,aAAa,SACxB,MAAM;GAGR,MAAM,IAAI,kBAAkB,8BAA8B;IACxD,UAAU;IACV,OAAO;GACT,CAAC;EACH;CACF;AACF;;ACnHA,MAAa,aAAa;AAC1B,MAAa,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anvia/jev",
3
- "version": "0.3.0",
3
+ "version": "1.0.0",
4
4
  "description": "Jev decision model adapter for Anvia.",
5
5
  "author": "anvia",
6
6
  "license": "MIT",
@@ -32,16 +32,16 @@
32
32
  "tsdown": "^0.23.4",
33
33
  "typescript": "^5.9.3",
34
34
  "vitest": "^4.1.11",
35
- "@anvia/core": "1.21.0"
35
+ "@anvia/core": "1.23.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@anvia/core": "^1.21.0"
38
+ "@anvia/core": "^1.23.0"
39
39
  },
40
40
  "scripts": {
41
41
  "prebuild": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",
42
42
  "build": "tsdown src/index.ts --format esm --dts --sourcemap --clean --no-fixed-extension",
43
43
  "test": "vitest run",
44
44
  "pretypecheck": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",
45
- "typecheck": "tsc --noEmit"
45
+ "typecheck": "tsrs --noEmit"
46
46
  }
47
47
  }