@effect-agent/ai-typesafe 0.1.0-beta.101 → 0.1.0-beta.103

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.
@@ -0,0 +1,305 @@
1
+ import * as Schema from "effect/Schema";
2
+ declare namespace TypeSafeSchema_d_exports {
3
+ export { Answer, AnswerFor, Answers, ChoiceAnswer, ChoiceQuestion, Content, EvaluateRequest, EvaluateResponse, NoulAnswer, NoulQuestion, Probability, Question, Questions, ScoreAnswer, ScoreQuestion, Usage };
4
+ }
5
+ /**
6
+ * Text or JSON objects and arrays used as state and question instructions.
7
+ *
8
+ * @category schemas
9
+ * @since 0.1.0
10
+ */
11
+ declare const Content: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
12
+ /** @category models
13
+ * @since 0.1.0
14
+ */
15
+ type Content = typeof Content.Type;
16
+ /**
17
+ * A choice between named options. A null rubric uses the option name alone.
18
+ *
19
+ * @category schemas
20
+ * @since 0.1.0
21
+ */
22
+ declare const ChoiceQuestion: Schema.Struct<{
23
+ readonly type: Schema.Literal<"choice">;
24
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
25
+ readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
26
+ }>;
27
+ /** @category models
28
+ * @since 0.1.0
29
+ */
30
+ type ChoiceQuestion = typeof ChoiceQuestion.Type;
31
+ /**
32
+ * A rating along at least two ordered, zero-indexed level descriptions.
33
+ *
34
+ * @category schemas
35
+ * @since 0.1.0
36
+ */
37
+ declare const ScoreQuestion: Schema.Struct<{
38
+ readonly type: Schema.Literal<"score">;
39
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
40
+ readonly criteria: Schema.$Array<Schema.String>;
41
+ }>;
42
+ /** @category models
43
+ * @since 0.1.0
44
+ */
45
+ type ScoreQuestion = typeof ScoreQuestion.Type;
46
+ /**
47
+ * A yes/no judgment, with optional descriptions of either outcome.
48
+ *
49
+ * @category schemas
50
+ * @since 0.1.0
51
+ */
52
+ declare const NoulQuestion: Schema.Struct<{
53
+ readonly type: Schema.Literal<"noul">;
54
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
55
+ readonly criteria: Schema.optionalKey<Schema.Struct<{
56
+ readonly true: Schema.optionalKey<Schema.String>;
57
+ readonly false: Schema.optionalKey<Schema.String>;
58
+ }>>;
59
+ }>;
60
+ /** @category models
61
+ * @since 0.1.0
62
+ */
63
+ type NoulQuestion = typeof NoulQuestion.Type;
64
+ /** @category schemas
65
+ * @since 0.1.0
66
+ */
67
+ declare const Question: Schema.Union<readonly [Schema.Struct<{
68
+ readonly type: Schema.Literal<"choice">;
69
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
70
+ readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
71
+ }>, Schema.Struct<{
72
+ readonly type: Schema.Literal<"score">;
73
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
74
+ readonly criteria: Schema.$Array<Schema.String>;
75
+ }>, Schema.Struct<{
76
+ readonly type: Schema.Literal<"noul">;
77
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
78
+ readonly criteria: Schema.optionalKey<Schema.Struct<{
79
+ readonly true: Schema.optionalKey<Schema.String>;
80
+ readonly false: Schema.optionalKey<Schema.String>;
81
+ }>>;
82
+ }>]>;
83
+ /** @category models
84
+ * @since 0.1.0
85
+ */
86
+ type Question = typeof Question.Type;
87
+ /** @category schemas
88
+ * @since 0.1.0
89
+ */
90
+ declare const Questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
91
+ readonly type: Schema.Literal<"choice">;
92
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
93
+ readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
94
+ }>, Schema.Struct<{
95
+ readonly type: Schema.Literal<"score">;
96
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
97
+ readonly criteria: Schema.$Array<Schema.String>;
98
+ }>, Schema.Struct<{
99
+ readonly type: Schema.Literal<"noul">;
100
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
101
+ readonly criteria: Schema.optionalKey<Schema.Struct<{
102
+ readonly true: Schema.optionalKey<Schema.String>;
103
+ readonly false: Schema.optionalKey<Schema.String>;
104
+ }>>;
105
+ }>]>>;
106
+ /** @category models
107
+ * @since 0.1.0
108
+ */
109
+ type Questions = typeof Questions.Type;
110
+ /** @category schemas
111
+ * @since 0.1.0
112
+ */
113
+ declare const EvaluateRequest: Schema.Struct<{
114
+ readonly model: Schema.String;
115
+ readonly state: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
116
+ readonly questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
117
+ readonly type: Schema.Literal<"choice">;
118
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
119
+ readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
120
+ }>, Schema.Struct<{
121
+ readonly type: Schema.Literal<"score">;
122
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
123
+ readonly criteria: Schema.$Array<Schema.String>;
124
+ }>, Schema.Struct<{
125
+ readonly type: Schema.Literal<"noul">;
126
+ readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
127
+ readonly criteria: Schema.optionalKey<Schema.Struct<{
128
+ readonly true: Schema.optionalKey<Schema.String>;
129
+ readonly false: Schema.optionalKey<Schema.String>;
130
+ }>>;
131
+ }>]>>;
132
+ }>;
133
+ /**
134
+ * Evaluation input. Keep question literals with `satisfies Questions` when
135
+ * storing questions separately from the call to `evaluate`.
136
+ *
137
+ * @category models
138
+ * @since 0.1.0
139
+ */
140
+ type EvaluateRequest<Q extends Questions = Questions> = Omit<typeof EvaluateRequest.Type, "questions"> & {
141
+ readonly questions: Q;
142
+ };
143
+ /**
144
+ * A finite probability or confidence in the inclusive range [0, 1].
145
+ *
146
+ * @category schemas
147
+ * @since 0.1.0
148
+ */
149
+ declare const Probability: Schema.Finite;
150
+ /**
151
+ * A selected option and its full distribution. Confidence summarizes the
152
+ * distribution; it does not guarantee correctness.
153
+ *
154
+ * @category schemas
155
+ * @since 0.1.0
156
+ */
157
+ declare const ChoiceAnswer: Schema.Struct<{
158
+ readonly type: Schema.Literal<"choice">;
159
+ readonly choice: Schema.String;
160
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
161
+ readonly confidence: Schema.Finite;
162
+ }>;
163
+ /**
164
+ * Known option unions infer literal choices and required probability keys.
165
+ * Open string or template-pattern option types allow absent dictionary entries.
166
+ *
167
+ * @category models
168
+ * @since 0.1.0
169
+ */
170
+ type ChoiceAnswer<Choice extends string = string> = Omit<typeof ChoiceAnswer.Type, "choice" | "probabilities"> & {
171
+ readonly choice: Choice;
172
+ readonly probabilities: { readonly [K in Choice]: {} extends Pick<Record<Choice, unknown>, K> ? number | undefined : number; };
173
+ };
174
+ /**
175
+ * A fractional, probability-weighted level, with the supplied rubric as legend.
176
+ *
177
+ * @category schemas
178
+ * @since 0.1.0
179
+ */
180
+ declare const ScoreAnswer: Schema.Struct<{
181
+ readonly type: Schema.Literal<"score">;
182
+ readonly score: Schema.Finite;
183
+ readonly legend: Schema.$Record<Schema.String, Schema.String>;
184
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
185
+ readonly confidence: Schema.Finite;
186
+ }>;
187
+ /**
188
+ * Score levels are keyed at runtime; an arbitrary legend or probability lookup
189
+ * may be absent.
190
+ *
191
+ * @category models
192
+ * @since 0.1.0
193
+ */
194
+ type ScoreAnswer = Omit<typeof ScoreAnswer.Type, "legend" | "probabilities"> & {
195
+ readonly legend: {
196
+ readonly [level: string]: string | undefined;
197
+ };
198
+ readonly probabilities: {
199
+ readonly [level: string]: number | undefined;
200
+ };
201
+ };
202
+ /**
203
+ * The probability of yes. Noul has no separate confidence field.
204
+ *
205
+ * @category schemas
206
+ * @since 0.1.0
207
+ */
208
+ declare const NoulAnswer: Schema.Struct<{
209
+ readonly type: Schema.Literal<"noul">;
210
+ readonly noul: Schema.Finite;
211
+ }>;
212
+ /** @category models
213
+ * @since 0.1.0
214
+ */
215
+ type NoulAnswer = typeof NoulAnswer.Type;
216
+ /** @category schemas
217
+ * @since 0.1.0
218
+ */
219
+ declare const Answer: Schema.Union<readonly [Schema.Struct<{
220
+ readonly type: Schema.Literal<"choice">;
221
+ readonly choice: Schema.String;
222
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
223
+ readonly confidence: Schema.Finite;
224
+ }>, Schema.Struct<{
225
+ readonly type: Schema.Literal<"score">;
226
+ readonly score: Schema.Finite;
227
+ readonly legend: Schema.$Record<Schema.String, Schema.String>;
228
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
229
+ readonly confidence: Schema.Finite;
230
+ }>, Schema.Struct<{
231
+ readonly type: Schema.Literal<"noul">;
232
+ readonly noul: Schema.Finite;
233
+ }>]>;
234
+ /** @category models
235
+ * @since 0.1.0
236
+ */
237
+ type Answer = ChoiceAnswer | ScoreAnswer | NoulAnswer;
238
+ /** @category schemas
239
+ * @since 0.1.0
240
+ */
241
+ declare const Usage: Schema.Struct<{
242
+ readonly input_tokens: Schema.Natural;
243
+ readonly output_tokens: Schema.Natural;
244
+ }>;
245
+ /** @category models
246
+ * @since 0.1.0
247
+ */
248
+ type Usage = typeof Usage.Type;
249
+ /**
250
+ * The wire response shape. `TypeSafeClient.evaluate` additionally validates
251
+ * answer IDs, question kinds, criteria, distributions, and score correlations.
252
+ *
253
+ * @category schemas
254
+ * @since 0.1.0
255
+ */
256
+ declare const EvaluateResponse: Schema.Struct<{
257
+ readonly model: Schema.String;
258
+ readonly answers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
259
+ readonly type: Schema.Literal<"choice">;
260
+ readonly choice: Schema.String;
261
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
262
+ readonly confidence: Schema.Finite;
263
+ }>, Schema.Struct<{
264
+ readonly type: Schema.Literal<"score">;
265
+ readonly score: Schema.Finite;
266
+ readonly legend: Schema.$Record<Schema.String, Schema.String>;
267
+ readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
268
+ readonly confidence: Schema.Finite;
269
+ }>, Schema.Struct<{
270
+ readonly type: Schema.Literal<"noul">;
271
+ readonly noul: Schema.Finite;
272
+ }>]>>;
273
+ readonly usage: Schema.Struct<{
274
+ readonly input_tokens: Schema.Natural;
275
+ readonly output_tokens: Schema.Natural;
276
+ }>;
277
+ }>;
278
+ type ChoiceAnswerFor<Criteria> = Criteria extends unknown ? Omit<typeof ChoiceAnswer.Type, "choice" | "probabilities"> & {
279
+ readonly choice: `${Extract<keyof Criteria, string | number>}`;
280
+ readonly probabilities: { readonly [K in keyof Criteria as K extends string | number ? `${K}` : never]: {} extends Pick<Criteria, K> ? number | undefined : number; };
281
+ } : never;
282
+ /**
283
+ * Infer a question's answer, preserving optional choice criteria in its probabilities.
284
+ *
285
+ * @category models
286
+ * @since 0.1.0
287
+ */
288
+ type AnswerFor<Q extends Question> = Q extends ChoiceQuestion ? ChoiceAnswerFor<Q["criteria"]> : Q extends ScoreQuestion ? ScoreAnswer : NoulAnswer;
289
+ /**
290
+ * One answer for each required question. Optional properties and open string,
291
+ * numeric, or template-pattern indexes require checking an entry for absence.
292
+ *
293
+ * @category models
294
+ * @since 0.1.0
295
+ */
296
+ type Answers<Q extends Questions> = { readonly [K in keyof Q as K extends string | number ? `${K}` : never]: {} extends Pick<Q, K> ? AnswerFor<NonNullable<Q[K]>> | undefined : AnswerFor<Q[K]>; };
297
+ /** @category models
298
+ * @since 0.1.0
299
+ */
300
+ type EvaluateResponse<Q extends Questions = Questions> = Omit<typeof EvaluateResponse.Type, "answers"> & {
301
+ readonly answers: Answers<Q>;
302
+ };
303
+ //#endregion
304
+ export { Usage as _, ChoiceQuestion as a, EvaluateResponse as c, Probability as d, Question as f, TypeSafeSchema_d_exports as g, ScoreQuestion as h, ChoiceAnswer as i, NoulAnswer as l, ScoreAnswer as m, AnswerFor as n, Content as o, Questions as p, Answers as r, EvaluateRequest as s, Answer as t, NoulQuestion as u };
305
+ //# sourceMappingURL=TypeSafeSchema-Dn4_Tptf.d.mts.map
@@ -1,305 +1,2 @@
1
- import * as Schema from "effect/Schema";
2
- declare namespace TypeSafeSchema_d_exports {
3
- export { Answer, AnswerFor, Answers, ChoiceAnswer, ChoiceQuestion, Content, EvaluateRequest, EvaluateResponse, NoulAnswer, NoulQuestion, Probability, Question, Questions, ScoreAnswer, ScoreQuestion, Usage };
4
- }
5
- /**
6
- * Text or JSON objects and arrays used as state and question instructions.
7
- *
8
- * @category schemas
9
- * @since 0.1.0
10
- */
11
- export declare const Content: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
12
- /** @category models
13
- * @since 0.1.0
14
- */
15
- export type Content = typeof Content.Type;
16
- /**
17
- * A choice between named options. A null rubric uses the option name alone.
18
- *
19
- * @category schemas
20
- * @since 0.1.0
21
- */
22
- export declare const ChoiceQuestion: Schema.Struct<{
23
- readonly type: Schema.Literal<"choice">;
24
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
25
- readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
26
- }>;
27
- /** @category models
28
- * @since 0.1.0
29
- */
30
- export type ChoiceQuestion = typeof ChoiceQuestion.Type;
31
- /**
32
- * A rating along at least two ordered, zero-indexed level descriptions.
33
- *
34
- * @category schemas
35
- * @since 0.1.0
36
- */
37
- export declare const ScoreQuestion: Schema.Struct<{
38
- readonly type: Schema.Literal<"score">;
39
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
40
- readonly criteria: Schema.$Array<Schema.String>;
41
- }>;
42
- /** @category models
43
- * @since 0.1.0
44
- */
45
- export type ScoreQuestion = typeof ScoreQuestion.Type;
46
- /**
47
- * A yes/no judgment, with optional descriptions of either outcome.
48
- *
49
- * @category schemas
50
- * @since 0.1.0
51
- */
52
- export declare const NoulQuestion: Schema.Struct<{
53
- readonly type: Schema.Literal<"noul">;
54
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
55
- readonly criteria: Schema.optionalKey<Schema.Struct<{
56
- readonly true: Schema.optionalKey<Schema.String>;
57
- readonly false: Schema.optionalKey<Schema.String>;
58
- }>>;
59
- }>;
60
- /** @category models
61
- * @since 0.1.0
62
- */
63
- export type NoulQuestion = typeof NoulQuestion.Type;
64
- /** @category schemas
65
- * @since 0.1.0
66
- */
67
- export declare const Question: Schema.Union<readonly [Schema.Struct<{
68
- readonly type: Schema.Literal<"choice">;
69
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
70
- readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
71
- }>, Schema.Struct<{
72
- readonly type: Schema.Literal<"score">;
73
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
74
- readonly criteria: Schema.$Array<Schema.String>;
75
- }>, Schema.Struct<{
76
- readonly type: Schema.Literal<"noul">;
77
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
78
- readonly criteria: Schema.optionalKey<Schema.Struct<{
79
- readonly true: Schema.optionalKey<Schema.String>;
80
- readonly false: Schema.optionalKey<Schema.String>;
81
- }>>;
82
- }>]>;
83
- /** @category models
84
- * @since 0.1.0
85
- */
86
- export type Question = typeof Question.Type;
87
- /** @category schemas
88
- * @since 0.1.0
89
- */
90
- export declare const Questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
91
- readonly type: Schema.Literal<"choice">;
92
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
93
- readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
94
- }>, Schema.Struct<{
95
- readonly type: Schema.Literal<"score">;
96
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
97
- readonly criteria: Schema.$Array<Schema.String>;
98
- }>, Schema.Struct<{
99
- readonly type: Schema.Literal<"noul">;
100
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
101
- readonly criteria: Schema.optionalKey<Schema.Struct<{
102
- readonly true: Schema.optionalKey<Schema.String>;
103
- readonly false: Schema.optionalKey<Schema.String>;
104
- }>>;
105
- }>]>>;
106
- /** @category models
107
- * @since 0.1.0
108
- */
109
- export type Questions = typeof Questions.Type;
110
- /** @category schemas
111
- * @since 0.1.0
112
- */
113
- export declare const EvaluateRequest: Schema.Struct<{
114
- readonly model: Schema.String;
115
- readonly state: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
116
- readonly questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
117
- readonly type: Schema.Literal<"choice">;
118
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
119
- readonly criteria: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
120
- }>, Schema.Struct<{
121
- readonly type: Schema.Literal<"score">;
122
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
123
- readonly criteria: Schema.$Array<Schema.String>;
124
- }>, Schema.Struct<{
125
- readonly type: Schema.Literal<"noul">;
126
- readonly instructions: Schema.Union<readonly [Schema.String, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>]>;
127
- readonly criteria: Schema.optionalKey<Schema.Struct<{
128
- readonly true: Schema.optionalKey<Schema.String>;
129
- readonly false: Schema.optionalKey<Schema.String>;
130
- }>>;
131
- }>]>>;
132
- }>;
133
- /**
134
- * Evaluation input. Keep question literals with `satisfies Questions` when
135
- * storing questions separately from the call to `evaluate`.
136
- *
137
- * @category models
138
- * @since 0.1.0
139
- */
140
- export type EvaluateRequest<Q extends Questions = Questions> = Omit<typeof EvaluateRequest.Type, "questions"> & {
141
- readonly questions: Q;
142
- };
143
- /**
144
- * A finite probability or confidence in the inclusive range [0, 1].
145
- *
146
- * @category schemas
147
- * @since 0.1.0
148
- */
149
- export declare const Probability: Schema.Finite;
150
- /**
151
- * A selected option and its full distribution. Confidence summarizes the
152
- * distribution; it does not guarantee correctness.
153
- *
154
- * @category schemas
155
- * @since 0.1.0
156
- */
157
- export declare const ChoiceAnswer: Schema.Struct<{
158
- readonly type: Schema.Literal<"choice">;
159
- readonly choice: Schema.String;
160
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
161
- readonly confidence: Schema.Finite;
162
- }>;
163
- /**
164
- * Known option unions infer literal choices and required probability keys.
165
- * Open string or template-pattern option types allow absent dictionary entries.
166
- *
167
- * @category models
168
- * @since 0.1.0
169
- */
170
- export type ChoiceAnswer<Choice extends string = string> = Omit<typeof ChoiceAnswer.Type, "choice" | "probabilities"> & {
171
- readonly choice: Choice;
172
- readonly probabilities: { readonly [K in Choice]: {} extends Pick<Record<Choice, unknown>, K> ? number | undefined : number; };
173
- };
174
- /**
175
- * A fractional, probability-weighted level, with the supplied rubric as legend.
176
- *
177
- * @category schemas
178
- * @since 0.1.0
179
- */
180
- export declare const ScoreAnswer: Schema.Struct<{
181
- readonly type: Schema.Literal<"score">;
182
- readonly score: Schema.Finite;
183
- readonly legend: Schema.$Record<Schema.String, Schema.String>;
184
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
185
- readonly confidence: Schema.Finite;
186
- }>;
187
- /**
188
- * Score levels are keyed at runtime; an arbitrary legend or probability lookup
189
- * may be absent.
190
- *
191
- * @category models
192
- * @since 0.1.0
193
- */
194
- export type ScoreAnswer = Omit<typeof ScoreAnswer.Type, "legend" | "probabilities"> & {
195
- readonly legend: {
196
- readonly [level: string]: string | undefined;
197
- };
198
- readonly probabilities: {
199
- readonly [level: string]: number | undefined;
200
- };
201
- };
202
- /**
203
- * The probability of yes. Noul has no separate confidence field.
204
- *
205
- * @category schemas
206
- * @since 0.1.0
207
- */
208
- export declare const NoulAnswer: Schema.Struct<{
209
- readonly type: Schema.Literal<"noul">;
210
- readonly noul: Schema.Finite;
211
- }>;
212
- /** @category models
213
- * @since 0.1.0
214
- */
215
- export type NoulAnswer = typeof NoulAnswer.Type;
216
- /** @category schemas
217
- * @since 0.1.0
218
- */
219
- export declare const Answer: Schema.Union<readonly [Schema.Struct<{
220
- readonly type: Schema.Literal<"choice">;
221
- readonly choice: Schema.String;
222
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
223
- readonly confidence: Schema.Finite;
224
- }>, Schema.Struct<{
225
- readonly type: Schema.Literal<"score">;
226
- readonly score: Schema.Finite;
227
- readonly legend: Schema.$Record<Schema.String, Schema.String>;
228
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
229
- readonly confidence: Schema.Finite;
230
- }>, Schema.Struct<{
231
- readonly type: Schema.Literal<"noul">;
232
- readonly noul: Schema.Finite;
233
- }>]>;
234
- /** @category models
235
- * @since 0.1.0
236
- */
237
- export type Answer = ChoiceAnswer | ScoreAnswer | NoulAnswer;
238
- /** @category schemas
239
- * @since 0.1.0
240
- */
241
- export declare const Usage: Schema.Struct<{
242
- readonly input_tokens: Schema.Natural;
243
- readonly output_tokens: Schema.Natural;
244
- }>;
245
- /** @category models
246
- * @since 0.1.0
247
- */
248
- export type Usage = typeof Usage.Type;
249
- /**
250
- * The wire response shape. `TypeSafeClient.evaluate` additionally validates
251
- * answer IDs, question kinds, criteria, distributions, and score correlations.
252
- *
253
- * @category schemas
254
- * @since 0.1.0
255
- */
256
- export declare const EvaluateResponse: Schema.Struct<{
257
- readonly model: Schema.String;
258
- readonly answers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
259
- readonly type: Schema.Literal<"choice">;
260
- readonly choice: Schema.String;
261
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
262
- readonly confidence: Schema.Finite;
263
- }>, Schema.Struct<{
264
- readonly type: Schema.Literal<"score">;
265
- readonly score: Schema.Finite;
266
- readonly legend: Schema.$Record<Schema.String, Schema.String>;
267
- readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>;
268
- readonly confidence: Schema.Finite;
269
- }>, Schema.Struct<{
270
- readonly type: Schema.Literal<"noul">;
271
- readonly noul: Schema.Finite;
272
- }>]>>;
273
- readonly usage: Schema.Struct<{
274
- readonly input_tokens: Schema.Natural;
275
- readonly output_tokens: Schema.Natural;
276
- }>;
277
- }>;
278
- type ChoiceAnswerFor<Criteria> = Criteria extends unknown ? Omit<typeof ChoiceAnswer.Type, "choice" | "probabilities"> & {
279
- readonly choice: `${Extract<keyof Criteria, string | number>}`;
280
- readonly probabilities: { readonly [K in keyof Criteria as K extends string | number ? `${K}` : never]: {} extends Pick<Criteria, K> ? number | undefined : number; };
281
- } : never;
282
- /**
283
- * Infer a question's answer, preserving optional choice criteria in its probabilities.
284
- *
285
- * @category models
286
- * @since 0.1.0
287
- */
288
- export type AnswerFor<Q extends Question> = Q extends ChoiceQuestion ? ChoiceAnswerFor<Q["criteria"]> : Q extends ScoreQuestion ? ScoreAnswer : NoulAnswer;
289
- /**
290
- * One answer for each required question. Optional properties and open string,
291
- * numeric, or template-pattern indexes require checking an entry for absence.
292
- *
293
- * @category models
294
- * @since 0.1.0
295
- */
296
- export type Answers<Q extends Questions> = { readonly [K in keyof Q as K extends string | number ? `${K}` : never]: {} extends Pick<Q, K> ? AnswerFor<NonNullable<Q[K]>> | undefined : AnswerFor<Q[K]>; };
297
- /** @category models
298
- * @since 0.1.0
299
- */
300
- export type EvaluateResponse<Q extends Questions = Questions> = Omit<typeof EvaluateResponse.Type, "answers"> & {
301
- readonly answers: Answers<Q>;
302
- };
303
- //#endregion
304
- export { TypeSafeSchema_d_exports as t };
305
- //# sourceMappingURL=TypeSafeSchema.d.mts.map
1
+ import { _ as Usage, a as ChoiceQuestion, c as EvaluateResponse, d as Probability, f as Question, h as ScoreQuestion, i as ChoiceAnswer, l as NoulAnswer, m as ScoreAnswer, n as AnswerFor, o as Content, p as Questions, r as Answers, s as EvaluateRequest, t as Answer, u as NoulQuestion } from "./TypeSafeSchema-Dn4_Tptf.mjs";
2
+ export { Answer, AnswerFor, Answers, ChoiceAnswer, ChoiceQuestion, Content, EvaluateRequest, EvaluateResponse, NoulAnswer, NoulQuestion, Probability, Question, Questions, ScoreAnswer, ScoreQuestion, Usage };
@@ -1,5 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import * as Schema from "effect/Schema";
3
+ import { DecisionSchema } from "@effect-agent/ai-decision";
3
4
  //#region src/TypeSafeSchema.ts
4
5
  /**
5
6
  * Request and response schemas for TypeSafe's System One HTTP API.
@@ -28,33 +29,21 @@ var TypeSafeSchema_exports = /* @__PURE__ */ __exportAll({
28
29
  * @category schemas
29
30
  * @since 0.1.0
30
31
  */
31
- const Content = Schema.Union([
32
- Schema.String,
33
- Schema.JsonObject,
34
- Schema.Array(Schema.Json)
35
- ]);
32
+ const Content = DecisionSchema.Content;
36
33
  /**
37
34
  * A choice between named options. A null rubric uses the option name alone.
38
35
  *
39
36
  * @category schemas
40
37
  * @since 0.1.0
41
38
  */
42
- const ChoiceQuestion = Schema.Struct({
43
- type: Schema.Literal("choice"),
44
- instructions: Content,
45
- criteria: Schema.Record(Schema.String, Schema.NullOr(Schema.String)).check(Schema.isMinProperties(1))
46
- });
39
+ const ChoiceQuestion = DecisionSchema.ChoiceQuestion;
47
40
  /**
48
41
  * A rating along at least two ordered, zero-indexed level descriptions.
49
42
  *
50
43
  * @category schemas
51
44
  * @since 0.1.0
52
45
  */
53
- const ScoreQuestion = Schema.Struct({
54
- type: Schema.Literal("score"),
55
- instructions: Content,
56
- criteria: Schema.Array(Schema.String).check(Schema.isMinLength(2))
57
- });
46
+ const ScoreQuestion = DecisionSchema.ScoreQuestion;
58
47
  /**
59
48
  * A yes/no judgment, with optional descriptions of either outcome.
60
49
  *
@@ -95,10 +84,7 @@ const EvaluateRequest = Schema.Struct({
95
84
  * @category schemas
96
85
  * @since 0.1.0
97
86
  */
98
- const Probability = Schema.Finite.check(Schema.isBetween({
99
- minimum: 0,
100
- maximum: 1
101
- }));
87
+ const Probability = DecisionSchema.Probability;
102
88
  /**
103
89
  * A selected option and its full distribution. Confidence summarizes the
104
90
  * distribution; it does not guarantee correctness.
@@ -107,9 +93,7 @@ const Probability = Schema.Finite.check(Schema.isBetween({
107
93
  * @since 0.1.0
108
94
  */
109
95
  const ChoiceAnswer = Schema.Struct({
110
- type: Schema.Literal("choice"),
111
- choice: Schema.String,
112
- probabilities: Schema.Record(Schema.String, Probability),
96
+ ...DecisionSchema.ChoiceAnswer.fields,
113
97
  confidence: Probability
114
98
  });
115
99
  /**
@@ -119,10 +103,7 @@ const ChoiceAnswer = Schema.Struct({
119
103
  * @since 0.1.0
120
104
  */
121
105
  const ScoreAnswer = Schema.Struct({
122
- type: Schema.Literal("score"),
123
- score: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)),
124
- legend: Schema.Record(Schema.String, Schema.String),
125
- probabilities: Schema.Record(Schema.String, Probability),
106
+ ...DecisionSchema.ScoreAnswer.fields,
126
107
  confidence: Probability
127
108
  });
128
109
  /**