@corbits/system-one 0.1.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.
- package/LICENSE +176 -0
- package/README.md +279 -0
- package/dist/adapter.d.ts +12 -0
- package/dist/adapter.js +193 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.js +67 -0
- package/dist/config.d.ts +36 -0
- package/dist/config.js +88 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +47 -0
- package/dist/evaluate.d.ts +18 -0
- package/dist/evaluate.js +346 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/schemas.d.ts +444 -0
- package/dist/schemas.js +311 -0
- package/dist/telemetry.d.ts +24 -0
- package/dist/telemetry.js +51 -0
- package/package.json +64 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
export declare const JsonRecord: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
2
|
+
[x: string]: unknown;
|
|
3
|
+
}, {}>;
|
|
4
|
+
export type JsonRecord = typeof JsonRecord.infer;
|
|
5
|
+
export declare const Description: import("arktype").BaseType<string | {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
} | unknown[], {}>;
|
|
8
|
+
export type Description = typeof Description.infer;
|
|
9
|
+
export declare const State: import("arktype").BaseType<string | {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
} | unknown[], {}>;
|
|
12
|
+
export type State = typeof State.infer;
|
|
13
|
+
export declare const ChoiceQuestion: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
14
|
+
id: string;
|
|
15
|
+
type: "choice";
|
|
16
|
+
instructions: string | {
|
|
17
|
+
[x: string]: unknown;
|
|
18
|
+
} | unknown[];
|
|
19
|
+
criteria: {
|
|
20
|
+
[x: string]: string | {
|
|
21
|
+
[x: string]: unknown;
|
|
22
|
+
} | unknown[] | null;
|
|
23
|
+
};
|
|
24
|
+
}, {}>;
|
|
25
|
+
export type ChoiceQuestion = typeof ChoiceQuestion.infer;
|
|
26
|
+
export declare const ScoreQuestion: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
27
|
+
id: string;
|
|
28
|
+
type: "score";
|
|
29
|
+
instructions: string | {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
} | unknown[];
|
|
32
|
+
criteria: (string | {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
} | unknown[])[];
|
|
35
|
+
}, {}>;
|
|
36
|
+
export type ScoreQuestion = typeof ScoreQuestion.infer;
|
|
37
|
+
export declare const NoulQuestion: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
38
|
+
id: string;
|
|
39
|
+
type: "noul";
|
|
40
|
+
instructions: string | {
|
|
41
|
+
[x: string]: unknown;
|
|
42
|
+
} | unknown[];
|
|
43
|
+
criteria?: {
|
|
44
|
+
true?: string | {
|
|
45
|
+
[x: string]: unknown;
|
|
46
|
+
} | unknown[];
|
|
47
|
+
false?: string | {
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
} | unknown[];
|
|
50
|
+
};
|
|
51
|
+
}, {}>;
|
|
52
|
+
export type NoulQuestion = typeof NoulQuestion.infer;
|
|
53
|
+
export declare const BooleanQuestion: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
54
|
+
id: string;
|
|
55
|
+
type: "boolean";
|
|
56
|
+
instructions: string | {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
} | unknown[];
|
|
59
|
+
criteria?: {
|
|
60
|
+
true?: string | {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
} | unknown[];
|
|
63
|
+
false?: string | {
|
|
64
|
+
[x: string]: unknown;
|
|
65
|
+
} | unknown[];
|
|
66
|
+
};
|
|
67
|
+
}, {}>;
|
|
68
|
+
export type BooleanQuestion = typeof BooleanQuestion.infer;
|
|
69
|
+
export declare const Question: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
70
|
+
id: string;
|
|
71
|
+
type: "choice";
|
|
72
|
+
instructions: string | {
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
} | unknown[];
|
|
75
|
+
criteria: {
|
|
76
|
+
[x: string]: string | {
|
|
77
|
+
[x: string]: unknown;
|
|
78
|
+
} | unknown[] | null;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
id: string;
|
|
82
|
+
type: "score";
|
|
83
|
+
instructions: string | {
|
|
84
|
+
[x: string]: unknown;
|
|
85
|
+
} | unknown[];
|
|
86
|
+
criteria: (string | {
|
|
87
|
+
[x: string]: unknown;
|
|
88
|
+
} | unknown[])[];
|
|
89
|
+
} | {
|
|
90
|
+
id: string;
|
|
91
|
+
type: "noul";
|
|
92
|
+
instructions: string | {
|
|
93
|
+
[x: string]: unknown;
|
|
94
|
+
} | unknown[];
|
|
95
|
+
criteria?: {
|
|
96
|
+
true?: string | {
|
|
97
|
+
[x: string]: unknown;
|
|
98
|
+
} | unknown[];
|
|
99
|
+
false?: string | {
|
|
100
|
+
[x: string]: unknown;
|
|
101
|
+
} | unknown[];
|
|
102
|
+
};
|
|
103
|
+
} | {
|
|
104
|
+
id: string;
|
|
105
|
+
type: "boolean";
|
|
106
|
+
instructions: string | {
|
|
107
|
+
[x: string]: unknown;
|
|
108
|
+
} | unknown[];
|
|
109
|
+
criteria?: {
|
|
110
|
+
true?: string | {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
} | unknown[];
|
|
113
|
+
false?: string | {
|
|
114
|
+
[x: string]: unknown;
|
|
115
|
+
} | unknown[];
|
|
116
|
+
};
|
|
117
|
+
}, {}>;
|
|
118
|
+
export type Question = typeof Question.infer;
|
|
119
|
+
export declare const QuestionList: import("arktype/internal/variants/array.ts").ArrayType<({
|
|
120
|
+
id: string;
|
|
121
|
+
type: "choice";
|
|
122
|
+
instructions: string | {
|
|
123
|
+
[x: string]: unknown;
|
|
124
|
+
} | unknown[];
|
|
125
|
+
criteria: {
|
|
126
|
+
[x: string]: string | {
|
|
127
|
+
[x: string]: unknown;
|
|
128
|
+
} | unknown[] | null;
|
|
129
|
+
};
|
|
130
|
+
} | {
|
|
131
|
+
id: string;
|
|
132
|
+
type: "score";
|
|
133
|
+
instructions: string | {
|
|
134
|
+
[x: string]: unknown;
|
|
135
|
+
} | unknown[];
|
|
136
|
+
criteria: (string | {
|
|
137
|
+
[x: string]: unknown;
|
|
138
|
+
} | unknown[])[];
|
|
139
|
+
} | {
|
|
140
|
+
id: string;
|
|
141
|
+
type: "noul";
|
|
142
|
+
instructions: string | {
|
|
143
|
+
[x: string]: unknown;
|
|
144
|
+
} | unknown[];
|
|
145
|
+
criteria?: {
|
|
146
|
+
true?: string | {
|
|
147
|
+
[x: string]: unknown;
|
|
148
|
+
} | unknown[];
|
|
149
|
+
false?: string | {
|
|
150
|
+
[x: string]: unknown;
|
|
151
|
+
} | unknown[];
|
|
152
|
+
};
|
|
153
|
+
} | {
|
|
154
|
+
id: string;
|
|
155
|
+
type: "boolean";
|
|
156
|
+
instructions: string | {
|
|
157
|
+
[x: string]: unknown;
|
|
158
|
+
} | unknown[];
|
|
159
|
+
criteria?: {
|
|
160
|
+
true?: string | {
|
|
161
|
+
[x: string]: unknown;
|
|
162
|
+
} | unknown[];
|
|
163
|
+
false?: string | {
|
|
164
|
+
[x: string]: unknown;
|
|
165
|
+
} | unknown[];
|
|
166
|
+
};
|
|
167
|
+
})[], {}>;
|
|
168
|
+
export type QuestionList = typeof QuestionList.infer;
|
|
169
|
+
export declare const EndpointConfig: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
170
|
+
kind: "custom";
|
|
171
|
+
url: string;
|
|
172
|
+
model?: string;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "official" | "gateway";
|
|
175
|
+
model?: string;
|
|
176
|
+
}, {}>;
|
|
177
|
+
export type EndpointConfig = typeof EndpointConfig.infer;
|
|
178
|
+
export declare const EvaluateConfig: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
179
|
+
endpoint?: {
|
|
180
|
+
kind: "custom";
|
|
181
|
+
url: string;
|
|
182
|
+
model?: string;
|
|
183
|
+
} | {
|
|
184
|
+
kind: "official" | "gateway";
|
|
185
|
+
model?: string;
|
|
186
|
+
};
|
|
187
|
+
timeoutMs?: unknown;
|
|
188
|
+
apiKey?: string;
|
|
189
|
+
}, {}>;
|
|
190
|
+
export type EvaluateConfig = typeof EvaluateConfig.infer;
|
|
191
|
+
export declare const EvaluateInput: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
192
|
+
state: string | {
|
|
193
|
+
[x: string]: unknown;
|
|
194
|
+
} | unknown[];
|
|
195
|
+
questions: ({
|
|
196
|
+
id: string;
|
|
197
|
+
type: "choice";
|
|
198
|
+
instructions: string | {
|
|
199
|
+
[x: string]: unknown;
|
|
200
|
+
} | unknown[];
|
|
201
|
+
criteria: {
|
|
202
|
+
[x: string]: string | {
|
|
203
|
+
[x: string]: unknown;
|
|
204
|
+
} | unknown[] | null;
|
|
205
|
+
};
|
|
206
|
+
} | {
|
|
207
|
+
id: string;
|
|
208
|
+
type: "score";
|
|
209
|
+
instructions: string | {
|
|
210
|
+
[x: string]: unknown;
|
|
211
|
+
} | unknown[];
|
|
212
|
+
criteria: (string | {
|
|
213
|
+
[x: string]: unknown;
|
|
214
|
+
} | unknown[])[];
|
|
215
|
+
} | {
|
|
216
|
+
id: string;
|
|
217
|
+
type: "noul";
|
|
218
|
+
instructions: string | {
|
|
219
|
+
[x: string]: unknown;
|
|
220
|
+
} | unknown[];
|
|
221
|
+
criteria?: {
|
|
222
|
+
true?: string | {
|
|
223
|
+
[x: string]: unknown;
|
|
224
|
+
} | unknown[];
|
|
225
|
+
false?: string | {
|
|
226
|
+
[x: string]: unknown;
|
|
227
|
+
} | unknown[];
|
|
228
|
+
};
|
|
229
|
+
} | {
|
|
230
|
+
id: string;
|
|
231
|
+
type: "boolean";
|
|
232
|
+
instructions: string | {
|
|
233
|
+
[x: string]: unknown;
|
|
234
|
+
} | unknown[];
|
|
235
|
+
criteria?: {
|
|
236
|
+
true?: string | {
|
|
237
|
+
[x: string]: unknown;
|
|
238
|
+
} | unknown[];
|
|
239
|
+
false?: string | {
|
|
240
|
+
[x: string]: unknown;
|
|
241
|
+
} | unknown[];
|
|
242
|
+
};
|
|
243
|
+
})[];
|
|
244
|
+
config?: {
|
|
245
|
+
endpoint?: {
|
|
246
|
+
kind: "custom";
|
|
247
|
+
url: string;
|
|
248
|
+
model?: string;
|
|
249
|
+
} | {
|
|
250
|
+
kind: "official" | "gateway";
|
|
251
|
+
model?: string;
|
|
252
|
+
};
|
|
253
|
+
timeoutMs?: unknown;
|
|
254
|
+
apiKey?: string;
|
|
255
|
+
};
|
|
256
|
+
}, {}>;
|
|
257
|
+
export type EvaluateInput = typeof EvaluateInput.infer;
|
|
258
|
+
/** One question in wire form: no id (the map key carries it). */
|
|
259
|
+
export declare const WireQuestion: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
260
|
+
type: "choice" | "score" | "noul";
|
|
261
|
+
instructions: string | {
|
|
262
|
+
[x: string]: unknown;
|
|
263
|
+
} | unknown[];
|
|
264
|
+
criteria?: unknown;
|
|
265
|
+
}, {}>;
|
|
266
|
+
export type WireQuestion = typeof WireQuestion.infer;
|
|
267
|
+
/** The exact POST body: model + state + id-keyed questions. */
|
|
268
|
+
export declare const WireRequest: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
269
|
+
model: string;
|
|
270
|
+
state: string | {
|
|
271
|
+
[x: string]: unknown;
|
|
272
|
+
} | unknown[];
|
|
273
|
+
questions: {
|
|
274
|
+
[x: string]: {
|
|
275
|
+
type: "choice" | "score" | "noul";
|
|
276
|
+
instructions: string | {
|
|
277
|
+
[x: string]: unknown;
|
|
278
|
+
} | unknown[];
|
|
279
|
+
criteria?: unknown;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
}, {}>;
|
|
283
|
+
export type WireRequest = typeof WireRequest.infer;
|
|
284
|
+
/**
|
|
285
|
+
* Maps caller-facing questions to the wire map. The `boolean` alias becomes
|
|
286
|
+
* native `noul`; everything else passes through with its id as the key.
|
|
287
|
+
*/
|
|
288
|
+
export declare function toWireQuestions(questions: Question[]): Record<string, WireQuestion>;
|
|
289
|
+
export declare const Confidence: import("arktype/internal/variants/number.ts").NumberType<number, {}>;
|
|
290
|
+
export type Confidence = typeof Confidence.infer;
|
|
291
|
+
export declare const ProbabilityMap: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
292
|
+
[x: string]: number;
|
|
293
|
+
}, {}>;
|
|
294
|
+
export type ProbabilityMap = typeof ProbabilityMap.infer;
|
|
295
|
+
/** Tolerance for probability-sum checks (backend rounds to 2 decimals). */
|
|
296
|
+
export declare const APPROXIMATE_SUM_TOLERANCE = 0.02;
|
|
297
|
+
export declare const WireAnswer: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
298
|
+
type: "choice" | "score" | "noul";
|
|
299
|
+
choice?: string;
|
|
300
|
+
score?: number;
|
|
301
|
+
noul?: number;
|
|
302
|
+
probabilities?: {
|
|
303
|
+
[x: string]: number;
|
|
304
|
+
};
|
|
305
|
+
confidence?: number;
|
|
306
|
+
legend?: {
|
|
307
|
+
[x: string]: string;
|
|
308
|
+
};
|
|
309
|
+
}, {}>;
|
|
310
|
+
export type WireAnswer = typeof WireAnswer.infer;
|
|
311
|
+
export declare const WireUsage: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
312
|
+
input_tokens: number;
|
|
313
|
+
output_tokens: number;
|
|
314
|
+
}, {}>;
|
|
315
|
+
export type WireUsage = typeof WireUsage.infer;
|
|
316
|
+
export declare const WireResponseBody: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
317
|
+
answers: {
|
|
318
|
+
[x: string]: {
|
|
319
|
+
type: "choice" | "score" | "noul";
|
|
320
|
+
choice?: string;
|
|
321
|
+
score?: number;
|
|
322
|
+
noul?: number;
|
|
323
|
+
probabilities?: {
|
|
324
|
+
[x: string]: number;
|
|
325
|
+
};
|
|
326
|
+
confidence?: number;
|
|
327
|
+
legend?: {
|
|
328
|
+
[x: string]: string;
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
model?: string;
|
|
333
|
+
usage?: {
|
|
334
|
+
input_tokens: number;
|
|
335
|
+
output_tokens: number;
|
|
336
|
+
};
|
|
337
|
+
}, {}>;
|
|
338
|
+
export type WireResponseBody = typeof WireResponseBody.infer;
|
|
339
|
+
export declare const Decision: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
340
|
+
id: string;
|
|
341
|
+
type: "noul";
|
|
342
|
+
noul: number;
|
|
343
|
+
} | {
|
|
344
|
+
id: string;
|
|
345
|
+
type: "choice";
|
|
346
|
+
choice: string;
|
|
347
|
+
probabilities: {
|
|
348
|
+
[x: string]: number;
|
|
349
|
+
};
|
|
350
|
+
confidence: number;
|
|
351
|
+
} | {
|
|
352
|
+
id: string;
|
|
353
|
+
type: "score";
|
|
354
|
+
score: number;
|
|
355
|
+
legend: {
|
|
356
|
+
[x: string]: string;
|
|
357
|
+
};
|
|
358
|
+
probabilities: {
|
|
359
|
+
[x: string]: number;
|
|
360
|
+
};
|
|
361
|
+
confidence: number;
|
|
362
|
+
}, {}>;
|
|
363
|
+
export type Decision = typeof Decision.infer;
|
|
364
|
+
/**
|
|
365
|
+
* Builds a caller-facing decision from a wire answer: the kind's contract
|
|
366
|
+
* fields only, so cross-kind extras are dropped and a malformed answer
|
|
367
|
+
* (e.g. a choice answer missing `choice`) throws a typed `SystemOneError`
|
|
368
|
+
* instead of producing a half-empty decision.
|
|
369
|
+
*/
|
|
370
|
+
export declare function toDecision(id: string, answer: WireAnswer): Decision;
|
|
371
|
+
export declare const Usage: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
372
|
+
inputTokens: number;
|
|
373
|
+
outputTokens: number;
|
|
374
|
+
}, {}>;
|
|
375
|
+
export type Usage = typeof Usage.infer;
|
|
376
|
+
export declare const EvaluateResponseBody: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
377
|
+
answers: {
|
|
378
|
+
[x: string]: {
|
|
379
|
+
type: "choice" | "score" | "noul";
|
|
380
|
+
choice?: string;
|
|
381
|
+
score?: number;
|
|
382
|
+
noul?: number;
|
|
383
|
+
probabilities?: {
|
|
384
|
+
[x: string]: number;
|
|
385
|
+
};
|
|
386
|
+
confidence?: number;
|
|
387
|
+
legend?: {
|
|
388
|
+
[x: string]: string;
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
model?: string;
|
|
393
|
+
usage?: {
|
|
394
|
+
input_tokens: number;
|
|
395
|
+
output_tokens: number;
|
|
396
|
+
};
|
|
397
|
+
}, {}>;
|
|
398
|
+
export type EvaluateResponseBody = typeof EvaluateResponseBody.infer;
|
|
399
|
+
export declare const EvaluateResult: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
400
|
+
decisions: ({
|
|
401
|
+
id: string;
|
|
402
|
+
type: "noul";
|
|
403
|
+
noul: number;
|
|
404
|
+
} | {
|
|
405
|
+
id: string;
|
|
406
|
+
type: "choice";
|
|
407
|
+
choice: string;
|
|
408
|
+
probabilities: {
|
|
409
|
+
[x: string]: number;
|
|
410
|
+
};
|
|
411
|
+
confidence: number;
|
|
412
|
+
} | {
|
|
413
|
+
id: string;
|
|
414
|
+
type: "score";
|
|
415
|
+
score: number;
|
|
416
|
+
legend: {
|
|
417
|
+
[x: string]: string;
|
|
418
|
+
};
|
|
419
|
+
probabilities: {
|
|
420
|
+
[x: string]: number;
|
|
421
|
+
};
|
|
422
|
+
confidence: number;
|
|
423
|
+
})[];
|
|
424
|
+
modelId: string;
|
|
425
|
+
backend: "custom" | "gateway" | "corbits-system-one";
|
|
426
|
+
latencyMs: number;
|
|
427
|
+
fallback: false;
|
|
428
|
+
usage?: {
|
|
429
|
+
inputTokens: number;
|
|
430
|
+
outputTokens: number;
|
|
431
|
+
};
|
|
432
|
+
}, {}>;
|
|
433
|
+
export type EvaluateResult = typeof EvaluateResult.infer;
|
|
434
|
+
export declare const FallbackReason: import("arktype/internal/variants/string.ts").StringType<"no-key" | "timeout" | "network" | "http-error" | "parse-error" | "backend-unreachable", {}>;
|
|
435
|
+
export type FallbackReason = typeof FallbackReason.infer;
|
|
436
|
+
export declare const FallbackResult: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
437
|
+
fallback: true;
|
|
438
|
+
reason: "no-key" | "timeout" | "network" | "http-error" | "parse-error" | "backend-unreachable";
|
|
439
|
+
latencyMs: number;
|
|
440
|
+
backendAttempted: string;
|
|
441
|
+
httpStatus?: number;
|
|
442
|
+
detail?: string;
|
|
443
|
+
}, {}>;
|
|
444
|
+
export type FallbackResult = typeof FallbackResult.infer;
|