@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/form.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export * as Form from "./form.js";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { define, inventory } from "./event.js";
|
|
4
|
-
import { ascending } from "./identifier.js";
|
|
5
|
-
import { NonNegativeInt, optional, statics } from "./schema.js";
|
|
6
|
-
const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"));
|
|
7
|
-
export const ID = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
|
|
8
|
-
export const Metadata = Schema.Record(Schema.String, Schema.Unknown).annotate({ identifier: "Form.Metadata" });
|
|
9
|
-
export const Option = Schema.Struct({
|
|
10
|
-
value: Schema.String,
|
|
11
|
-
label: Schema.String,
|
|
12
|
-
description: Schema.String.pipe(optional),
|
|
13
|
-
}).annotate({ identifier: "Form.Option" });
|
|
14
|
-
export const When = Schema.Struct({
|
|
15
|
-
key: Schema.String,
|
|
16
|
-
op: Schema.Literals(["eq", "neq"]),
|
|
17
|
-
value: Schema.String,
|
|
18
|
-
}).annotate({ identifier: "Form.When" });
|
|
19
|
-
const FieldBase = {
|
|
20
|
-
key: Schema.String,
|
|
21
|
-
title: Schema.String.pipe(optional),
|
|
22
|
-
description: Schema.String.pipe(optional),
|
|
23
|
-
required: Schema.Boolean.pipe(optional),
|
|
24
|
-
when: When.pipe(optional),
|
|
25
|
-
};
|
|
26
|
-
export const StringField = Schema.Struct({
|
|
27
|
-
...FieldBase,
|
|
28
|
-
type: Schema.Literal("string"),
|
|
29
|
-
format: Schema.Literals(["email", "uri", "date", "date-time"]).pipe(optional),
|
|
30
|
-
minLength: NonNegativeInt.pipe(optional),
|
|
31
|
-
maxLength: NonNegativeInt.pipe(optional),
|
|
32
|
-
pattern: Schema.String.pipe(optional),
|
|
33
|
-
placeholder: Schema.String.pipe(optional),
|
|
34
|
-
default: Schema.String.pipe(optional),
|
|
35
|
-
options: Schema.Array(Option).pipe(optional),
|
|
36
|
-
custom: Schema.Boolean.pipe(optional),
|
|
37
|
-
}).annotate({ identifier: "Form.StringField" });
|
|
38
|
-
export const NumberField = Schema.Struct({
|
|
39
|
-
...FieldBase,
|
|
40
|
-
type: Schema.Literal("number"),
|
|
41
|
-
minimum: Schema.Number.pipe(optional),
|
|
42
|
-
maximum: Schema.Number.pipe(optional),
|
|
43
|
-
default: Schema.Number.pipe(optional),
|
|
44
|
-
}).annotate({ identifier: "Form.NumberField" });
|
|
45
|
-
export const IntegerField = Schema.Struct({
|
|
46
|
-
...FieldBase,
|
|
47
|
-
type: Schema.Literal("integer"),
|
|
48
|
-
minimum: Schema.Number.pipe(optional),
|
|
49
|
-
maximum: Schema.Number.pipe(optional),
|
|
50
|
-
default: Schema.Number.pipe(optional),
|
|
51
|
-
}).annotate({ identifier: "Form.IntegerField" });
|
|
52
|
-
export const BooleanField = Schema.Struct({
|
|
53
|
-
...FieldBase,
|
|
54
|
-
type: Schema.Literal("boolean"),
|
|
55
|
-
default: Schema.Boolean.pipe(optional),
|
|
56
|
-
}).annotate({ identifier: "Form.BooleanField" });
|
|
57
|
-
export const MultiselectField = Schema.Struct({
|
|
58
|
-
...FieldBase,
|
|
59
|
-
type: Schema.Literal("multiselect"),
|
|
60
|
-
options: Schema.Array(Option),
|
|
61
|
-
minItems: NonNegativeInt.pipe(optional),
|
|
62
|
-
maxItems: NonNegativeInt.pipe(optional),
|
|
63
|
-
custom: Schema.Boolean.pipe(optional),
|
|
64
|
-
default: Schema.Array(Schema.String).pipe(optional),
|
|
65
|
-
}).annotate({ identifier: "Form.MultiselectField" });
|
|
66
|
-
export const Field = Schema.Union([StringField, NumberField, IntegerField, BooleanField, MultiselectField]).pipe(Schema.toTaggedUnion("type"));
|
|
67
|
-
const InfoBase = {
|
|
68
|
-
id: ID,
|
|
69
|
-
// Public form flows are session-owned. This is intentionally `string` because the server
|
|
70
|
-
// currently accepts an undocumented `global` sentinel for MCP elicitation forms that cannot
|
|
71
|
-
// be attributed to a concrete session yet. Do not document or rely on `global` outside our
|
|
72
|
-
// own clients; remove the sentinel path once MCP elicitation can carry session ownership.
|
|
73
|
-
sessionID: Schema.String,
|
|
74
|
-
title: Schema.String.pipe(optional),
|
|
75
|
-
metadata: Metadata.pipe(optional),
|
|
76
|
-
};
|
|
77
|
-
export const FormInfo = Schema.Struct({
|
|
78
|
-
...InfoBase,
|
|
79
|
-
mode: Schema.Literal("form"),
|
|
80
|
-
fields: Schema.Array(Field),
|
|
81
|
-
}).annotate({ identifier: "Form.FormInfo" });
|
|
82
|
-
export const UrlInfo = Schema.Struct({
|
|
83
|
-
...InfoBase,
|
|
84
|
-
mode: Schema.Literal("url"),
|
|
85
|
-
url: Schema.String,
|
|
86
|
-
}).annotate({ identifier: "Form.UrlInfo" });
|
|
87
|
-
export const Info = Schema.Union([FormInfo, UrlInfo]).pipe(Schema.toTaggedUnion("mode"));
|
|
88
|
-
export const Value = Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Array(Schema.String)]).annotate({
|
|
89
|
-
identifier: "Form.Value",
|
|
90
|
-
});
|
|
91
|
-
export const Answer = Schema.Record(Schema.String, Value).annotate({ identifier: "Form.Answer" });
|
|
92
|
-
export const State = Schema.Union([
|
|
93
|
-
Schema.Struct({ status: Schema.Literal("pending") }),
|
|
94
|
-
Schema.Struct({ status: Schema.Literal("answered"), answer: Answer }),
|
|
95
|
-
Schema.Struct({ status: Schema.Literal("cancelled") }),
|
|
96
|
-
])
|
|
97
|
-
.pipe(Schema.toTaggedUnion("status"))
|
|
98
|
-
.annotate({ identifier: "Form.State" });
|
|
99
|
-
export const Reply = Schema.Struct({
|
|
100
|
-
answer: Answer,
|
|
101
|
-
}).annotate({ identifier: "Form.Reply" });
|
|
102
|
-
const Created = define({ type: "form.created", schema: { form: Info } });
|
|
103
|
-
const Replied = define({ type: "form.replied", schema: { id: ID, sessionID: Schema.String, answer: Answer } });
|
|
104
|
-
const Cancelled = define({ type: "form.cancelled", schema: { id: ID, sessionID: Schema.String } });
|
|
105
|
-
export const Event = { Created, Replied, Cancelled, Definitions: inventory(Created, Replied, Cancelled) };
|