@opencode-ai/schema 0.0.0-next-14742 → 0.0.0-next-14758
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/dist/event-manifest.d.ts +1202 -556
- package/dist/event-manifest.js +9 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/question.d.ts +516 -0
- package/dist/question.js +64 -0
- package/package.json +1 -1
- package/dist/form.d.ts +0 -1339
- package/dist/form.js +0 -105
package/dist/question.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export * as Question from "./question.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { optional } from "./schema.js";
|
|
4
|
+
import { define, inventory } from "./event.js";
|
|
5
|
+
import { ascending } from "./identifier.js";
|
|
6
|
+
import { SessionID } from "./session-id.js";
|
|
7
|
+
import { statics } from "./schema.js";
|
|
8
|
+
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(Schema.brand("QuestionV2.ID"), statics((schema) => {
|
|
9
|
+
const create = () => schema.make("que_" + ascending());
|
|
10
|
+
return {
|
|
11
|
+
create,
|
|
12
|
+
ascending: (id) => (id === undefined ? create() : schema.make(id)),
|
|
13
|
+
};
|
|
14
|
+
}));
|
|
15
|
+
export const Option = Schema.Struct({
|
|
16
|
+
label: Schema.String.annotate({ description: "Display text (1-5 words, concise)" }),
|
|
17
|
+
description: Schema.String.annotate({ description: "Explanation of choice" }),
|
|
18
|
+
}).annotate({ identifier: "QuestionV2.Option" });
|
|
19
|
+
const base = {
|
|
20
|
+
question: Schema.String.annotate({ description: "Complete question" }),
|
|
21
|
+
header: Schema.String.annotate({ description: "Very short label (max 30 chars)" }),
|
|
22
|
+
options: Schema.Array(Option).annotate({ description: "Available choices" }),
|
|
23
|
+
multiple: Schema.Boolean.pipe(optional).annotate({ description: "Allow selecting multiple choices" }),
|
|
24
|
+
};
|
|
25
|
+
export const Info = Schema.Struct({
|
|
26
|
+
...base,
|
|
27
|
+
custom: Schema.Boolean.pipe(optional).annotate({
|
|
28
|
+
description: "Allow typing a custom answer (default: true)",
|
|
29
|
+
}),
|
|
30
|
+
}).annotate({ identifier: "QuestionV2.Info" });
|
|
31
|
+
export const Prompt = Schema.Struct(base).annotate({ identifier: "QuestionV2.Prompt" });
|
|
32
|
+
export const Tool = Schema.Struct({
|
|
33
|
+
messageID: Schema.String,
|
|
34
|
+
callID: Schema.String,
|
|
35
|
+
}).annotate({ identifier: "QuestionV2.Tool" });
|
|
36
|
+
export const Request = Schema.Struct({
|
|
37
|
+
id: ID,
|
|
38
|
+
sessionID: SessionID,
|
|
39
|
+
questions: Schema.Array(Info).annotate({ description: "Questions to ask" }),
|
|
40
|
+
tool: Tool.pipe(optional),
|
|
41
|
+
}).annotate({ identifier: "QuestionV2.Request" });
|
|
42
|
+
export const Answer = Schema.Array(Schema.String).annotate({ identifier: "QuestionV2.Answer" });
|
|
43
|
+
export const Reply = Schema.Struct({
|
|
44
|
+
answers: Schema.Array(Answer).annotate({
|
|
45
|
+
description: "User answers in order of questions (each answer is an array of selected labels)",
|
|
46
|
+
}),
|
|
47
|
+
}).annotate({ identifier: "QuestionV2.Reply" });
|
|
48
|
+
const Asked = define({ type: "question.v2.asked", schema: Request.fields });
|
|
49
|
+
const Replied = define({
|
|
50
|
+
type: "question.v2.replied",
|
|
51
|
+
schema: {
|
|
52
|
+
sessionID: SessionID,
|
|
53
|
+
requestID: ID,
|
|
54
|
+
answers: Schema.Array(Answer),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const Rejected = define({
|
|
58
|
+
type: "question.v2.rejected",
|
|
59
|
+
schema: {
|
|
60
|
+
sessionID: SessionID,
|
|
61
|
+
requestID: ID,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
export const Event = { Asked, Replied, Rejected, Definitions: inventory(Asked, Replied, Rejected) };
|