@opencode/ai 0.0.0-dev-1021 → 0.0.0-dev-1024
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/README.md +2 -0
- package/dist/decision.d.ts +10 -0
- package/dist/decision.js +2 -0
- package/dist/protocols/openai-decisions.js +14 -1
- package/dist/protocols/system-one.js +8 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -322,6 +322,8 @@ const [refund, department] = response.answers
|
|
|
322
322
|
```
|
|
323
323
|
|
|
324
324
|
`input` is a JSON object or an ordered list of `text`, `json` and `media` parts. Answers come back in question order.
|
|
325
|
+
A `predicate` can say what counts as true and as false with `criteria: { true, false }`; hosts without a criteria field
|
|
326
|
+
read them appended to the instructions.
|
|
325
327
|
A question the host declines is `{ name, type: "error", reason, message? }`, with `reason` such as `"refusal"`; the
|
|
326
328
|
other answers still come back.
|
|
327
329
|
`response.usage` has `inputTokens`, `outputTokens`, `totalTokens` and the host's reported `cost` when it sends one;
|
package/dist/decision.d.ts
CHANGED
|
@@ -104,6 +104,11 @@ export declare const PredicateQuestion: Schema.Struct<{
|
|
|
104
104
|
readonly name: Schema.String;
|
|
105
105
|
readonly type: Schema.Literal<"predicate">;
|
|
106
106
|
readonly instructions: Schema.String;
|
|
107
|
+
/** What counts as true and as false, for statements the instructions alone leave ambiguous. */
|
|
108
|
+
readonly criteria: Schema.optional<Schema.Struct<{
|
|
109
|
+
readonly true: Schema.optional<Schema.String>;
|
|
110
|
+
readonly false: Schema.optional<Schema.String>;
|
|
111
|
+
}>>;
|
|
107
112
|
}>;
|
|
108
113
|
export type PredicateQuestion = Schema.Schema.Type<typeof PredicateQuestion>;
|
|
109
114
|
export declare const ChoiceQuestion: Schema.Struct<{
|
|
@@ -130,6 +135,11 @@ export declare const DecisionQuestion: Schema.toTaggedUnion<"type", readonly [Sc
|
|
|
130
135
|
readonly name: Schema.String;
|
|
131
136
|
readonly type: Schema.Literal<"predicate">;
|
|
132
137
|
readonly instructions: Schema.String;
|
|
138
|
+
/** What counts as true and as false, for statements the instructions alone leave ambiguous. */
|
|
139
|
+
readonly criteria: Schema.optional<Schema.Struct<{
|
|
140
|
+
readonly true: Schema.optional<Schema.String>;
|
|
141
|
+
readonly false: Schema.optional<Schema.String>;
|
|
142
|
+
}>>;
|
|
133
143
|
}>, Schema.Struct<{
|
|
134
144
|
readonly name: Schema.String;
|
|
135
145
|
readonly type: Schema.Literal<"choice">;
|
package/dist/decision.js
CHANGED
|
@@ -23,6 +23,8 @@ export const PredicateQuestion = Schema.Struct({
|
|
|
23
23
|
name: Schema.String,
|
|
24
24
|
type: Schema.Literal("predicate"),
|
|
25
25
|
instructions: Schema.String,
|
|
26
|
+
/** What counts as true and as false, for statements the instructions alone leave ambiguous. */
|
|
27
|
+
criteria: Schema.optional(Schema.Struct({ true: Schema.optional(Schema.String), false: Schema.optional(Schema.String) })),
|
|
26
28
|
});
|
|
27
29
|
export const ChoiceQuestion = Schema.Struct({
|
|
28
30
|
name: Schema.String,
|
|
@@ -54,7 +54,20 @@ const fromRequest = Effect.fn("OpenAIDecisions.fromRequest")(function* (request)
|
|
|
54
54
|
}, request.http?.body),
|
|
55
55
|
model: request.model.id,
|
|
56
56
|
input: [{ role: "user", content: yield* Effect.forEach(request.input, (part) => inputPart(request, part)) }],
|
|
57
|
-
questions: request.questions
|
|
57
|
+
questions: request.questions.map((question) => {
|
|
58
|
+
if (question.type !== "predicate")
|
|
59
|
+
return question;
|
|
60
|
+
// Predicates have no criteria field, so what true and false mean is appended to the instructions.
|
|
61
|
+
const meanings = [
|
|
62
|
+
question.criteria?.true === undefined ? [] : [`True means: ${question.criteria.true}`],
|
|
63
|
+
question.criteria?.false === undefined ? [] : [`False means: ${question.criteria.false}`],
|
|
64
|
+
].flat();
|
|
65
|
+
return {
|
|
66
|
+
name: question.name,
|
|
67
|
+
type: question.type,
|
|
68
|
+
instructions: meanings.length === 0 ? question.instructions : `${question.instructions}\n\n${meanings.join("\n")}`,
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
58
71
|
};
|
|
59
72
|
});
|
|
60
73
|
// `input_json` takes an object or a list of objects; other JSON values go as text.
|
|
@@ -47,7 +47,14 @@ export const encodeBody = Effect.fn("SystemOne.encodeBody")(function* (request,
|
|
|
47
47
|
});
|
|
48
48
|
const encodeQuestions = (questions) => Effect.forEach(questions, (question) => {
|
|
49
49
|
if (question.type === "predicate")
|
|
50
|
-
return Effect.succeed([
|
|
50
|
+
return Effect.succeed([
|
|
51
|
+
question.name,
|
|
52
|
+
{
|
|
53
|
+
type: "noul",
|
|
54
|
+
instructions: question.instructions,
|
|
55
|
+
...(question.criteria === undefined ? {} : { criteria: question.criteria }),
|
|
56
|
+
},
|
|
57
|
+
]);
|
|
51
58
|
if (question.type === "score")
|
|
52
59
|
return Effect.succeed([
|
|
53
60
|
question.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-1024",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
"devDependencies": {
|
|
521
521
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
522
522
|
"@effect/platform-node": "4.1.0",
|
|
523
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
523
|
+
"@opencode/http-recorder": "0.0.0-dev-1024",
|
|
524
524
|
"@tsconfig/bun": "1.0.9",
|
|
525
525
|
"@types/bun": "1.4.3",
|
|
526
526
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -530,7 +530,7 @@
|
|
|
530
530
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
531
531
|
"@smithy/eventstream-codec": "4.2.14",
|
|
532
532
|
"@smithy/util-utf8": "4.2.2",
|
|
533
|
-
"@opencode/schema": "0.0.0-dev-
|
|
533
|
+
"@opencode/schema": "0.0.0-dev-1024",
|
|
534
534
|
"aws4fetch": "1.0.20",
|
|
535
535
|
"effect": "4.1.0",
|
|
536
536
|
"google-auth-library": "10.5.0"
|