The best way to control Claude Code, Codex and more from any computer or phone

main
ts 123 lines 3.11 KB
Raw
1 /**
2 * Schemas for OpenRouter's alpha Decisions API.
3 *
4 * @stability unstable
5 * @since 4.0.0
6 */
7 import * as Schema from "effect/Schema"
8 import * as Generated from "./Generated.ts"
9
10 const Entry = Schema.Union([Schema.String, Schema.JsonObject, Schema.Array(Schema.Json)])
11
12 /**
13 * A choice question with descriptions keyed by choice label.
14 *
15 * @stability unstable
16 * @category schemas
17 * @since 4.0.0
18 */
19 export const ChoiceQuestion = Schema.Struct({
20 type: Schema.Literal("choice"),
21 instructions: Entry,
22 criteria: Schema.Record(Schema.String, Schema.NullOr(Entry))
23 })
24
25 /**
26 * A score question with ordered criteria.
27 *
28 * @stability unstable
29 * @category schemas
30 * @since 4.0.0
31 */
32 export const ScoreQuestion = Schema.Struct({
33 type: Schema.Literal("score"),
34 instructions: Entry,
35 criteria: Schema.Array(Entry)
36 })
37
38 /**
39 * A probability question with optional true and false descriptions.
40 *
41 * @stability unstable
42 * @category schemas
43 * @since 4.0.0
44 */
45 export const NoulQuestion = Schema.Struct({
46 type: Schema.Literal("noul"),
47 instructions: Entry,
48 criteria: Schema.optional(Schema.Struct({ true: Entry, false: Entry }))
49 })
50
51 /**
52 * A choice, score, or probability question with string, JSON object, or JSON array
53 * instructions and descriptions. Choice descriptions also accept `null`.
54 *
55 * @stability unstable
56 * @category schemas
57 * @since 4.0.0
58 */
59 export const DecisionsQuestion = Schema.Union([
60 ChoiceQuestion,
61 ScoreQuestion,
62 NoulQuestion
63 ])
64
65 /**
66 * A provider answer with optional probabilities and confidence.
67 *
68 * @stability unstable
69 * @category schemas
70 * @since 4.0.0
71 */
72 export const Answer = Schema.Union([
73 Schema.Struct({
74 type: Schema.Literal("choice"),
75 choice: Schema.String,
76 confidence: Schema.optional(Schema.Finite),
77 probabilities: Schema.optional(Schema.Record(Schema.String, Schema.Finite))
78 }),
79 Schema.Struct({
80 type: Schema.Literal("score"),
81 score: Schema.Finite,
82 confidence: Schema.optional(Schema.Finite),
83 probabilities: Schema.optional(Schema.Record(Schema.String, Schema.Finite)),
84 legend: Schema.optional(Schema.Record(Schema.String, Schema.Json))
85 }),
86 Schema.Struct({ type: Schema.Literal("noul"), noul: Schema.Finite })
87 ])
88
89 /**
90 * Request body for the alpha Decisions endpoint.
91 *
92 * @stability unstable
93 * @category schemas
94 * @since 4.0.0
95 */
96 export const DecisionsRequest = Schema.Struct({
97 model: Schema.String,
98 state: Schema.Unknown,
99 questions: Schema.Record(Schema.String, DecisionsQuestion),
100 provider: Schema.optional(Generated.ProviderPreferences),
101 session_id: Schema.optional(Schema.String),
102 user: Schema.optional(Schema.String),
103 trace: Schema.optional(Schema.Record(Schema.String, Schema.Unknown))
104 })
105
106 /**
107 * Response body for the alpha Decisions endpoint.
108 *
109 * @stability unstable
110 * @category schemas
111 * @since 4.0.0
112 */
113 export const DecisionsResponse = Schema.Struct({
114 model: Schema.String,
115 answers: Schema.Record(Schema.String, Answer),
116 usage: Schema.Struct({
117 input_tokens: Schema.Int,
118 output_tokens: Schema.Int,
119 cost: Schema.optional(Schema.Finite)
120 }),
121 id: Schema.optional(Schema.String),
122 provider: Schema.optional(Schema.String)
123 })