@zyro-sec/schema 1.0.2 → 1.0.3
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/AGENTS.md +95 -95
- package/package.json +1 -1
- package/script/build.ts +9 -9
- package/script/config-schema.ts +86 -86
- package/script/config-v1.json +1311 -1311
- package/script/pack.ts +5 -5
- package/src/agent.ts +68 -68
- package/src/artifact.ts +81 -81
- package/src/automation.ts +224 -224
- package/src/blob-store.ts +25 -25
- package/src/command.ts +18 -18
- package/src/config/agent.ts +26 -26
- package/src/config/command.ts +14 -14
- package/src/config/compaction.ts +27 -27
- package/src/config/experimental.ts +72 -72
- package/src/config/flag.ts +39 -39
- package/src/config/formatter.ts +13 -13
- package/src/config/lsp.ts +19 -19
- package/src/config/mcp.ts +22 -22
- package/src/config/media.ts +15 -15
- package/src/config/model.ts +37 -37
- package/src/config/plugin.ts +14 -14
- package/src/config/policy.ts +57 -57
- package/src/config/provider.ts +122 -122
- package/src/config/reference.ts +23 -23
- package/src/config/shell.ts +10 -10
- package/src/config/tool-output.ts +9 -9
- package/src/config/warming.ts +21 -21
- package/src/config/watcher.ts +8 -8
- package/src/config/websearch.ts +17 -17
- package/src/config/worktree.ts +10 -10
- package/src/config.ts +149 -149
- package/src/connection.ts +38 -38
- package/src/credential-legacy.ts +29 -29
- package/src/credential.ts +78 -78
- package/src/durable-event-manifest.ts +7 -7
- package/src/event-log.ts +21 -21
- package/src/event-manifest.ts +108 -108
- package/src/event.ts +205 -205
- package/src/file-diff.ts +25 -25
- package/src/filesystem-v1.ts +1 -1
- package/src/filesystem.ts +48 -48
- package/src/form.ts +177 -177
- package/src/generate.ts +292 -292
- package/src/goal.ts +46 -46
- package/src/identifier.ts +32 -32
- package/src/index.ts +51 -51
- package/src/installation-event.ts +20 -20
- package/src/instruction-entry.ts +40 -40
- package/src/instruction.ts +25 -25
- package/src/integration-id.ts +13 -13
- package/src/integration.ts +129 -129
- package/src/job.ts +79 -79
- package/src/legacy-event.ts +1 -1
- package/src/llm.ts +6 -6
- package/src/location-event.ts +8 -8
- package/src/location.ts +36 -36
- package/src/lsp-event.ts +7 -7
- package/src/mcp-event.ts +63 -63
- package/src/mcp.ts +171 -171
- package/src/model-compatibility.ts +55 -55
- package/src/model.ts +176 -176
- package/src/models-dev.ts +9 -9
- package/src/money.ts +18 -18
- package/src/permission-saved.ts +25 -25
- package/src/permission-v1.ts +1 -1
- package/src/permission.ts +67 -67
- package/src/persistent-pty.ts +73 -73
- package/src/plugin.ts +62 -62
- package/src/project-id.ts +9 -9
- package/src/project.ts +62 -62
- package/src/prompt-input.ts +33 -33
- package/src/prompt.ts +117 -117
- package/src/provider.ts +136 -136
- package/src/pty-ticket.ts +10 -10
- package/src/pty.ts +61 -61
- package/src/push.ts +86 -86
- package/src/question.ts +22 -22
- package/src/reference.ts +40 -40
- package/src/rpc.ts +167 -167
- package/src/schema.ts +41 -41
- package/src/server-event.ts +8 -8
- package/src/session-error.ts +14 -14
- package/src/session-event.ts +739 -739
- package/src/session-fork.ts +10 -10
- package/src/session-id.ts +12 -12
- package/src/session-inbox.ts +102 -102
- package/src/session-legacy.ts +117 -117
- package/src/session-message.ts +352 -352
- package/src/session-metadata.ts +11 -11
- package/src/session-revert.ts +86 -86
- package/src/session-stats.ts +68 -68
- package/src/session-status-event.ts +53 -53
- package/src/session-transfer.ts +11 -11
- package/src/session-v1.ts +1 -1
- package/src/session.ts +147 -147
- package/src/shell.ts +90 -90
- package/src/skill.ts +68 -68
- package/src/snapshot.ts +6 -6
- package/src/token-usage.ts +18 -18
- package/src/tool.ts +143 -143
- package/src/tui-event.ts +59 -59
- package/src/usage-limits.ts +76 -76
- package/src/v1/filesystem.ts +11 -11
- package/src/v1/legacy-event.ts +18 -18
- package/src/v1/permission.ts +66 -66
- package/src/v1/session.ts +667 -667
- package/src/vcs-event.ts +14 -14
- package/src/vcs.ts +41 -41
- package/src/websearch.ts +44 -44
- package/src/workspace-event.ts +32 -32
- package/src/workspace-id.ts +19 -19
- package/src/workspace.ts +20 -20
- package/src/worktree-event.ts +22 -22
- package/src/worktree.ts +109 -109
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +14 -14
- package/test/agent.test.ts +0 -10
- package/test/automation.test.ts +0 -48
- package/test/compatibility.test.ts +0 -10
- package/test/config.test.ts +0 -194
- package/test/contract-hygiene.test.ts +0 -352
- package/test/credential-legacy.test.ts +0 -55
- package/test/event-manifest.test.ts +0 -228
- package/test/event.test.ts +0 -52
- package/test/legacy-event.test.ts +0 -46
- package/test/mcp.test.ts +0 -37
- package/test/model.test.ts +0 -104
- package/test/session-cursor.test.ts +0 -16
- package/test/session-error.test.ts +0 -51
- package/test/session-legacy.test.ts +0 -178
- package/test/session-terminal.test.ts +0 -50
- package/test/token-usage.test.ts +0 -18
- package/test/v1-isolation.test.ts +0 -26
- package/test/vcs.test.ts +0 -23
- package/test/worktree.test.ts +0 -45
package/src/model.ts
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
export * as Model from "./model.js"
|
|
2
|
-
|
|
3
|
-
import { Schema, Struct } from "effect"
|
|
4
|
-
import { optional, statics } from "./schema.js"
|
|
5
|
-
import { Provider } from "./provider.js"
|
|
6
|
-
import { Compatibility, MaxTokensField, MediaInput, ReasoningField } from "./model-compatibility.js"
|
|
7
|
-
import { Money } from "./money.js"
|
|
8
|
-
import { FreeformFormat } from "./tool.js"
|
|
9
|
-
import { ephemeral, inventory } from "./event.js"
|
|
10
|
-
|
|
11
|
-
export const ID = Schema.String.pipe(Schema.brand("Model.ID"))
|
|
12
|
-
export type ID = typeof ID.Type
|
|
13
|
-
|
|
14
|
-
const Updated = ephemeral({ type: "model.updated", schema: {} })
|
|
15
|
-
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
16
|
-
|
|
17
|
-
export const VariantID = Schema.String.pipe(Schema.brand("Model.VariantID"))
|
|
18
|
-
export type VariantID = typeof VariantID.Type
|
|
19
|
-
|
|
20
|
-
export const Ref = Schema.Struct({
|
|
21
|
-
id: ID,
|
|
22
|
-
providerID: Provider.ID,
|
|
23
|
-
variant: VariantID.pipe(optional),
|
|
24
|
-
})
|
|
25
|
-
.annotate({ identifier: "Model.Ref" })
|
|
26
|
-
.pipe(
|
|
27
|
-
statics((schema) => ({
|
|
28
|
-
parse: (input: string) => {
|
|
29
|
-
const providerEnd = input.indexOf("/")
|
|
30
|
-
if (providerEnd <= 0) throw new Error(`Invalid model reference: ${input}`)
|
|
31
|
-
const providerID = input.slice(0, providerEnd)
|
|
32
|
-
const variantStart = input.indexOf("#", providerEnd + 1)
|
|
33
|
-
const id = input.slice(providerEnd + 1, variantStart === -1 ? undefined : variantStart)
|
|
34
|
-
const variant = variantStart === -1 ? undefined : input.slice(variantStart + 1)
|
|
35
|
-
if (!id || providerID.includes("#") || (variant !== undefined && (!variant || variant.includes("#"))))
|
|
36
|
-
throw new Error(`Invalid model reference: ${input}`)
|
|
37
|
-
return schema.make({
|
|
38
|
-
providerID: Provider.ID.make(providerID),
|
|
39
|
-
id: ID.make(id),
|
|
40
|
-
...(variant ? { variant: VariantID.make(variant) } : {}),
|
|
41
|
-
})
|
|
42
|
-
},
|
|
43
|
-
})),
|
|
44
|
-
)
|
|
45
|
-
export interface Ref extends Schema.Schema.Type<typeof Ref> {}
|
|
46
|
-
|
|
47
|
-
export { Compatibility, MaxTokensField, MediaInput, ReasoningField }
|
|
48
|
-
|
|
49
|
-
export const Family = Schema.String.pipe(Schema.brand("Model.Family"))
|
|
50
|
-
export type Family = typeof Family.Type
|
|
51
|
-
|
|
52
|
-
/** What a model produces, from models.dev. Open-ended: new types keep being added. Only chat models are offered for sessions; an unset type means chat. */
|
|
53
|
-
export type Type = "chat" | "decision" | "image" | "video" | (string & {})
|
|
54
|
-
export const Type: Schema.Codec<Type> = Schema.Union([
|
|
55
|
-
Schema.Literals(["chat", "decision", "image", "video"]),
|
|
56
|
-
Schema.String,
|
|
57
|
-
]).annotate({ identifier: "Model.Type" })
|
|
58
|
-
|
|
59
|
-
export const Settings = Schema.StructWithRest(
|
|
60
|
-
Schema.Struct(Struct.pick(Provider.Settings.schema.fields, ["compaction", "cache", "encoding"])),
|
|
61
|
-
// Provider packages may define arbitrary model-level options beyond OpenCode's shared compaction policy.
|
|
62
|
-
[Schema.Record(Schema.String, Schema.Any)],
|
|
63
|
-
).annotate({ identifier: "Model.Settings" })
|
|
64
|
-
export type Settings = typeof Settings.Type
|
|
65
|
-
|
|
66
|
-
// Variants switch request settings. The prompt cache belongs to the model, so a variant can't change it.
|
|
67
|
-
const VariantSettings = Schema.StructWithRest(
|
|
68
|
-
Schema.Struct(Struct.omit(Settings.schema.fields, ["cache"])),
|
|
69
|
-
Settings.records,
|
|
70
|
-
).annotate({ identifier: "Model.VariantSettings" })
|
|
71
|
-
|
|
72
|
-
export const Overlays = {
|
|
73
|
-
settings: Settings.pipe(optional),
|
|
74
|
-
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
75
|
-
body: Schema.Record(Schema.String, Schema.Any).pipe(optional),
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
|
|
79
|
-
export const Capabilities = Schema.Struct({
|
|
80
|
-
tools: Schema.Boolean,
|
|
81
|
-
/** Freeform tool input formats advertised by the selected API. Absent or empty means JSON tools only. */
|
|
82
|
-
freeform: Schema.Array(FreeformFormat).pipe(optional),
|
|
83
|
-
input: Schema.Array(Schema.String),
|
|
84
|
-
output: Schema.Array(Schema.String),
|
|
85
|
-
/** Whether the model accepts a sampling temperature. Unknown when unset. */
|
|
86
|
-
temperature: Schema.Boolean.pipe(optional),
|
|
87
|
-
})
|
|
88
|
-
.annotate({ identifier: "Model.Capabilities" })
|
|
89
|
-
.pipe(
|
|
90
|
-
statics(() => ({
|
|
91
|
-
default: () => ({ tools: true, input: ["text", "image"], output: ["text"] }) satisfies Capabilities,
|
|
92
|
-
})),
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
export interface Cost extends Schema.Schema.Type<typeof Cost> {}
|
|
96
|
-
export const Cost = Schema.Struct({
|
|
97
|
-
tier: Schema.Struct({
|
|
98
|
-
type: Schema.tag("context"),
|
|
99
|
-
size: Schema.Int,
|
|
100
|
-
}).pipe(optional),
|
|
101
|
-
input: Money.USDPerMillionTokens,
|
|
102
|
-
output: Money.USDPerMillionTokens,
|
|
103
|
-
cache: Schema.Struct({
|
|
104
|
-
read: Money.USDPerMillionTokens,
|
|
105
|
-
write: Money.USDPerMillionTokens,
|
|
106
|
-
}),
|
|
107
|
-
}).annotate({ identifier: "Model.Cost" })
|
|
108
|
-
|
|
109
|
-
export interface Variant extends Schema.Schema.Type<typeof Variant> {}
|
|
110
|
-
export const Variant = Schema.Struct({
|
|
111
|
-
id: VariantID,
|
|
112
|
-
...Overlays,
|
|
113
|
-
settings: VariantSettings.pipe(optional),
|
|
114
|
-
}).annotate({ identifier: "Model.Variant" })
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Set on a model that is another model served faster or slower, such as "gpt-5.5-fast" for "gpt-5.5". Clients offer
|
|
118
|
-
* it as a speed of that model instead of listing it.
|
|
119
|
-
*/
|
|
120
|
-
export interface Speed extends Schema.Schema.Type<typeof Speed> {}
|
|
121
|
-
export const Speed = Schema.Struct({
|
|
122
|
-
/** The same provider's model at its standard speed. */
|
|
123
|
-
base: ID,
|
|
124
|
-
/** The speed's name, such as "fast" or "flex". */
|
|
125
|
-
id: Schema.String,
|
|
126
|
-
/** Whether it is faster than the standard speed. A slower speed trades latency for a lower price. */
|
|
127
|
-
faster: Schema.Boolean,
|
|
128
|
-
}).annotate({ identifier: "Model.Speed" })
|
|
129
|
-
|
|
130
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
131
|
-
export const Info = Schema.Struct({
|
|
132
|
-
id: ID,
|
|
133
|
-
modelID: ID,
|
|
134
|
-
providerID: Provider.ID,
|
|
135
|
-
canonical: Provider.ID.pipe(optional),
|
|
136
|
-
type: Type.pipe(optional),
|
|
137
|
-
family: Family.pipe(optional),
|
|
138
|
-
name: Schema.String,
|
|
139
|
-
compatibility: Compatibility.pipe(optional),
|
|
140
|
-
package: Provider.Package.pipe(optional),
|
|
141
|
-
...Overlays,
|
|
142
|
-
capabilities: Capabilities,
|
|
143
|
-
variants: Schema.Array(Variant),
|
|
144
|
-
/** Experimental: may change without compatibility guarantees. */
|
|
145
|
-
experimental: Schema.Struct({ speed: Speed.pipe(optional) }).pipe(optional),
|
|
146
|
-
time: Schema.Struct({
|
|
147
|
-
released: Schema.Finite,
|
|
148
|
-
}),
|
|
149
|
-
cost: Schema.Array(Cost),
|
|
150
|
-
status: Schema.Literals(["alpha", "beta", "deprecated", "active"]),
|
|
151
|
-
enabled: Schema.Boolean,
|
|
152
|
-
limit: Schema.Struct({
|
|
153
|
-
context: Schema.Int,
|
|
154
|
-
input: Schema.Int.pipe(optional),
|
|
155
|
-
output: Schema.Int,
|
|
156
|
-
}),
|
|
157
|
-
})
|
|
158
|
-
.annotate({ identifier: "Model.Info" })
|
|
159
|
-
.pipe(
|
|
160
|
-
statics(() => ({
|
|
161
|
-
default: (providerID: Provider.ID, id: ID) =>
|
|
162
|
-
({
|
|
163
|
-
id,
|
|
164
|
-
modelID: id,
|
|
165
|
-
providerID,
|
|
166
|
-
name: id,
|
|
167
|
-
capabilities: Capabilities.default(),
|
|
168
|
-
variants: [],
|
|
169
|
-
time: { released: 0 },
|
|
170
|
-
cost: [],
|
|
171
|
-
status: "active",
|
|
172
|
-
enabled: true,
|
|
173
|
-
limit: { context: 200_000, output: 32_000 },
|
|
174
|
-
}) satisfies Info,
|
|
175
|
-
})),
|
|
176
|
-
)
|
|
1
|
+
export * as Model from "./model.js"
|
|
2
|
+
|
|
3
|
+
import { Schema, Struct } from "effect"
|
|
4
|
+
import { optional, statics } from "./schema.js"
|
|
5
|
+
import { Provider } from "./provider.js"
|
|
6
|
+
import { Compatibility, MaxTokensField, MediaInput, ReasoningField } from "./model-compatibility.js"
|
|
7
|
+
import { Money } from "./money.js"
|
|
8
|
+
import { FreeformFormat } from "./tool.js"
|
|
9
|
+
import { ephemeral, inventory } from "./event.js"
|
|
10
|
+
|
|
11
|
+
export const ID = Schema.String.pipe(Schema.brand("Model.ID"))
|
|
12
|
+
export type ID = typeof ID.Type
|
|
13
|
+
|
|
14
|
+
const Updated = ephemeral({ type: "model.updated", schema: {} })
|
|
15
|
+
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
16
|
+
|
|
17
|
+
export const VariantID = Schema.String.pipe(Schema.brand("Model.VariantID"))
|
|
18
|
+
export type VariantID = typeof VariantID.Type
|
|
19
|
+
|
|
20
|
+
export const Ref = Schema.Struct({
|
|
21
|
+
id: ID,
|
|
22
|
+
providerID: Provider.ID,
|
|
23
|
+
variant: VariantID.pipe(optional),
|
|
24
|
+
})
|
|
25
|
+
.annotate({ identifier: "Model.Ref" })
|
|
26
|
+
.pipe(
|
|
27
|
+
statics((schema) => ({
|
|
28
|
+
parse: (input: string) => {
|
|
29
|
+
const providerEnd = input.indexOf("/")
|
|
30
|
+
if (providerEnd <= 0) throw new Error(`Invalid model reference: ${input}`)
|
|
31
|
+
const providerID = input.slice(0, providerEnd)
|
|
32
|
+
const variantStart = input.indexOf("#", providerEnd + 1)
|
|
33
|
+
const id = input.slice(providerEnd + 1, variantStart === -1 ? undefined : variantStart)
|
|
34
|
+
const variant = variantStart === -1 ? undefined : input.slice(variantStart + 1)
|
|
35
|
+
if (!id || providerID.includes("#") || (variant !== undefined && (!variant || variant.includes("#"))))
|
|
36
|
+
throw new Error(`Invalid model reference: ${input}`)
|
|
37
|
+
return schema.make({
|
|
38
|
+
providerID: Provider.ID.make(providerID),
|
|
39
|
+
id: ID.make(id),
|
|
40
|
+
...(variant ? { variant: VariantID.make(variant) } : {}),
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
})),
|
|
44
|
+
)
|
|
45
|
+
export interface Ref extends Schema.Schema.Type<typeof Ref> {}
|
|
46
|
+
|
|
47
|
+
export { Compatibility, MaxTokensField, MediaInput, ReasoningField }
|
|
48
|
+
|
|
49
|
+
export const Family = Schema.String.pipe(Schema.brand("Model.Family"))
|
|
50
|
+
export type Family = typeof Family.Type
|
|
51
|
+
|
|
52
|
+
/** What a model produces, from models.dev. Open-ended: new types keep being added. Only chat models are offered for sessions; an unset type means chat. */
|
|
53
|
+
export type Type = "chat" | "decision" | "image" | "video" | (string & {})
|
|
54
|
+
export const Type: Schema.Codec<Type> = Schema.Union([
|
|
55
|
+
Schema.Literals(["chat", "decision", "image", "video"]),
|
|
56
|
+
Schema.String,
|
|
57
|
+
]).annotate({ identifier: "Model.Type" })
|
|
58
|
+
|
|
59
|
+
export const Settings = Schema.StructWithRest(
|
|
60
|
+
Schema.Struct(Struct.pick(Provider.Settings.schema.fields, ["compaction", "cache", "encoding"])),
|
|
61
|
+
// Provider packages may define arbitrary model-level options beyond OpenCode's shared compaction policy.
|
|
62
|
+
[Schema.Record(Schema.String, Schema.Any)],
|
|
63
|
+
).annotate({ identifier: "Model.Settings" })
|
|
64
|
+
export type Settings = typeof Settings.Type
|
|
65
|
+
|
|
66
|
+
// Variants switch request settings. The prompt cache belongs to the model, so a variant can't change it.
|
|
67
|
+
const VariantSettings = Schema.StructWithRest(
|
|
68
|
+
Schema.Struct(Struct.omit(Settings.schema.fields, ["cache"])),
|
|
69
|
+
Settings.records,
|
|
70
|
+
).annotate({ identifier: "Model.VariantSettings" })
|
|
71
|
+
|
|
72
|
+
export const Overlays = {
|
|
73
|
+
settings: Settings.pipe(optional),
|
|
74
|
+
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
75
|
+
body: Schema.Record(Schema.String, Schema.Any).pipe(optional),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
|
|
79
|
+
export const Capabilities = Schema.Struct({
|
|
80
|
+
tools: Schema.Boolean,
|
|
81
|
+
/** Freeform tool input formats advertised by the selected API. Absent or empty means JSON tools only. */
|
|
82
|
+
freeform: Schema.Array(FreeformFormat).pipe(optional),
|
|
83
|
+
input: Schema.Array(Schema.String),
|
|
84
|
+
output: Schema.Array(Schema.String),
|
|
85
|
+
/** Whether the model accepts a sampling temperature. Unknown when unset. */
|
|
86
|
+
temperature: Schema.Boolean.pipe(optional),
|
|
87
|
+
})
|
|
88
|
+
.annotate({ identifier: "Model.Capabilities" })
|
|
89
|
+
.pipe(
|
|
90
|
+
statics(() => ({
|
|
91
|
+
default: () => ({ tools: true, input: ["text", "image"], output: ["text"] }) satisfies Capabilities,
|
|
92
|
+
})),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
export interface Cost extends Schema.Schema.Type<typeof Cost> {}
|
|
96
|
+
export const Cost = Schema.Struct({
|
|
97
|
+
tier: Schema.Struct({
|
|
98
|
+
type: Schema.tag("context"),
|
|
99
|
+
size: Schema.Int,
|
|
100
|
+
}).pipe(optional),
|
|
101
|
+
input: Money.USDPerMillionTokens,
|
|
102
|
+
output: Money.USDPerMillionTokens,
|
|
103
|
+
cache: Schema.Struct({
|
|
104
|
+
read: Money.USDPerMillionTokens,
|
|
105
|
+
write: Money.USDPerMillionTokens,
|
|
106
|
+
}),
|
|
107
|
+
}).annotate({ identifier: "Model.Cost" })
|
|
108
|
+
|
|
109
|
+
export interface Variant extends Schema.Schema.Type<typeof Variant> {}
|
|
110
|
+
export const Variant = Schema.Struct({
|
|
111
|
+
id: VariantID,
|
|
112
|
+
...Overlays,
|
|
113
|
+
settings: VariantSettings.pipe(optional),
|
|
114
|
+
}).annotate({ identifier: "Model.Variant" })
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Set on a model that is another model served faster or slower, such as "gpt-5.5-fast" for "gpt-5.5". Clients offer
|
|
118
|
+
* it as a speed of that model instead of listing it.
|
|
119
|
+
*/
|
|
120
|
+
export interface Speed extends Schema.Schema.Type<typeof Speed> {}
|
|
121
|
+
export const Speed = Schema.Struct({
|
|
122
|
+
/** The same provider's model at its standard speed. */
|
|
123
|
+
base: ID,
|
|
124
|
+
/** The speed's name, such as "fast" or "flex". */
|
|
125
|
+
id: Schema.String,
|
|
126
|
+
/** Whether it is faster than the standard speed. A slower speed trades latency for a lower price. */
|
|
127
|
+
faster: Schema.Boolean,
|
|
128
|
+
}).annotate({ identifier: "Model.Speed" })
|
|
129
|
+
|
|
130
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
131
|
+
export const Info = Schema.Struct({
|
|
132
|
+
id: ID,
|
|
133
|
+
modelID: ID,
|
|
134
|
+
providerID: Provider.ID,
|
|
135
|
+
canonical: Provider.ID.pipe(optional),
|
|
136
|
+
type: Type.pipe(optional),
|
|
137
|
+
family: Family.pipe(optional),
|
|
138
|
+
name: Schema.String,
|
|
139
|
+
compatibility: Compatibility.pipe(optional),
|
|
140
|
+
package: Provider.Package.pipe(optional),
|
|
141
|
+
...Overlays,
|
|
142
|
+
capabilities: Capabilities,
|
|
143
|
+
variants: Schema.Array(Variant),
|
|
144
|
+
/** Experimental: may change without compatibility guarantees. */
|
|
145
|
+
experimental: Schema.Struct({ speed: Speed.pipe(optional) }).pipe(optional),
|
|
146
|
+
time: Schema.Struct({
|
|
147
|
+
released: Schema.Finite,
|
|
148
|
+
}),
|
|
149
|
+
cost: Schema.Array(Cost),
|
|
150
|
+
status: Schema.Literals(["alpha", "beta", "deprecated", "active"]),
|
|
151
|
+
enabled: Schema.Boolean,
|
|
152
|
+
limit: Schema.Struct({
|
|
153
|
+
context: Schema.Int,
|
|
154
|
+
input: Schema.Int.pipe(optional),
|
|
155
|
+
output: Schema.Int,
|
|
156
|
+
}),
|
|
157
|
+
})
|
|
158
|
+
.annotate({ identifier: "Model.Info" })
|
|
159
|
+
.pipe(
|
|
160
|
+
statics(() => ({
|
|
161
|
+
default: (providerID: Provider.ID, id: ID) =>
|
|
162
|
+
({
|
|
163
|
+
id,
|
|
164
|
+
modelID: id,
|
|
165
|
+
providerID,
|
|
166
|
+
name: id,
|
|
167
|
+
capabilities: Capabilities.default(),
|
|
168
|
+
variants: [],
|
|
169
|
+
time: { released: 0 },
|
|
170
|
+
cost: [],
|
|
171
|
+
status: "active",
|
|
172
|
+
enabled: true,
|
|
173
|
+
limit: { context: 200_000, output: 32_000 },
|
|
174
|
+
}) satisfies Info,
|
|
175
|
+
})),
|
|
176
|
+
)
|
package/src/models-dev.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as ModelsDev from "./models-dev.js"
|
|
2
|
-
|
|
3
|
-
import { ephemeral, inventory } from "./event.js"
|
|
4
|
-
|
|
5
|
-
const Refreshed = ephemeral({
|
|
6
|
-
type: "models-dev.refreshed",
|
|
7
|
-
schema: {},
|
|
8
|
-
})
|
|
9
|
-
export const Event = { Refreshed, Definitions: inventory(Refreshed) }
|
|
1
|
+
export * as ModelsDev from "./models-dev.js"
|
|
2
|
+
|
|
3
|
+
import { ephemeral, inventory } from "./event.js"
|
|
4
|
+
|
|
5
|
+
const Refreshed = ephemeral({
|
|
6
|
+
type: "models-dev.refreshed",
|
|
7
|
+
schema: {},
|
|
8
|
+
})
|
|
9
|
+
export const Event = { Refreshed, Definitions: inventory(Refreshed) }
|
package/src/money.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * as Money from "./money.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { statics } from "./schema.js"
|
|
5
|
-
|
|
6
|
-
export const USD = Schema.Finite.pipe(
|
|
7
|
-
Schema.brand("Money.USD"),
|
|
8
|
-
Schema.annotate({ identifier: "Money.USD" }),
|
|
9
|
-
statics((schema) => ({ zero: schema.make(0) })),
|
|
10
|
-
)
|
|
11
|
-
export type USD = typeof USD.Type
|
|
12
|
-
|
|
13
|
-
export const USDPerMillionTokens = Schema.Finite.pipe(
|
|
14
|
-
Schema.brand("Money.USDPerMillionTokens"),
|
|
15
|
-
Schema.annotate({ identifier: "Money.USDPerMillionTokens" }),
|
|
16
|
-
statics((schema) => ({ zero: schema.make(0) })),
|
|
17
|
-
)
|
|
18
|
-
export type USDPerMillionTokens = typeof USDPerMillionTokens.Type
|
|
1
|
+
export * as Money from "./money.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { statics } from "./schema.js"
|
|
5
|
+
|
|
6
|
+
export const USD = Schema.Finite.pipe(
|
|
7
|
+
Schema.brand("Money.USD"),
|
|
8
|
+
Schema.annotate({ identifier: "Money.USD" }),
|
|
9
|
+
statics((schema) => ({ zero: schema.make(0) })),
|
|
10
|
+
)
|
|
11
|
+
export type USD = typeof USD.Type
|
|
12
|
+
|
|
13
|
+
export const USDPerMillionTokens = Schema.Finite.pipe(
|
|
14
|
+
Schema.brand("Money.USDPerMillionTokens"),
|
|
15
|
+
Schema.annotate({ identifier: "Money.USDPerMillionTokens" }),
|
|
16
|
+
statics((schema) => ({ zero: schema.make(0) })),
|
|
17
|
+
)
|
|
18
|
+
export type USDPerMillionTokens = typeof USDPerMillionTokens.Type
|
package/src/permission-saved.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * as PermissionSaved from "./permission-saved.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { ascending } from "./identifier.js"
|
|
5
|
-
import { ProjectID } from "./project-id.js"
|
|
6
|
-
import { DateTimeUtcFromMillis, statics } from "./schema.js"
|
|
7
|
-
|
|
8
|
-
export const ID = Schema.String.pipe(
|
|
9
|
-
Schema.brand("PermissionSaved.ID"),
|
|
10
|
-
Schema.annotate({ identifier: "PermissionSaved.ID" }),
|
|
11
|
-
statics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
|
12
|
-
)
|
|
13
|
-
export type ID = typeof ID.Type
|
|
14
|
-
|
|
15
|
-
export const Info = Schema.Struct({
|
|
16
|
-
id: ID,
|
|
17
|
-
projectID: ProjectID,
|
|
18
|
-
action: Schema.String,
|
|
19
|
-
resource: Schema.String,
|
|
20
|
-
time: Schema.Struct({
|
|
21
|
-
created: DateTimeUtcFromMillis,
|
|
22
|
-
updated: DateTimeUtcFromMillis,
|
|
23
|
-
}),
|
|
24
|
-
}).annotate({ identifier: "PermissionSaved.Info" })
|
|
25
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
1
|
+
export * as PermissionSaved from "./permission-saved.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { ascending } from "./identifier.js"
|
|
5
|
+
import { ProjectID } from "./project-id.js"
|
|
6
|
+
import { DateTimeUtcFromMillis, statics } from "./schema.js"
|
|
7
|
+
|
|
8
|
+
export const ID = Schema.String.pipe(
|
|
9
|
+
Schema.brand("PermissionSaved.ID"),
|
|
10
|
+
Schema.annotate({ identifier: "PermissionSaved.ID" }),
|
|
11
|
+
statics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
|
12
|
+
)
|
|
13
|
+
export type ID = typeof ID.Type
|
|
14
|
+
|
|
15
|
+
export const Info = Schema.Struct({
|
|
16
|
+
id: ID,
|
|
17
|
+
projectID: ProjectID,
|
|
18
|
+
action: Schema.String,
|
|
19
|
+
resource: Schema.String,
|
|
20
|
+
time: Schema.Struct({
|
|
21
|
+
created: DateTimeUtcFromMillis,
|
|
22
|
+
updated: DateTimeUtcFromMillis,
|
|
23
|
+
}),
|
|
24
|
+
}).annotate({ identifier: "PermissionSaved.Info" })
|
|
25
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
package/src/permission-v1.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./v1/permission.js"
|
|
1
|
+
export * from "./v1/permission.js"
|
package/src/permission.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
export * as Permission from "./permission.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional } from "./schema.js"
|
|
5
|
-
import { ephemeral, inventory } from "./event.js"
|
|
6
|
-
import { ascending } from "./identifier.js"
|
|
7
|
-
import { SessionID } from "./session-id.js"
|
|
8
|
-
import { statics } from "./schema.js"
|
|
9
|
-
|
|
10
|
-
export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(
|
|
11
|
-
Schema.brand("Permission.ID"),
|
|
12
|
-
Schema.annotate({ identifier: "Permission.ID" }),
|
|
13
|
-
statics((schema) => ({ create: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
|
14
|
-
)
|
|
15
|
-
export type ID = typeof ID.Type
|
|
16
|
-
|
|
17
|
-
export const Source = Schema.Union([
|
|
18
|
-
Schema.Struct({
|
|
19
|
-
type: Schema.Literal("tool"),
|
|
20
|
-
messageID: Schema.String,
|
|
21
|
-
id: Schema.String,
|
|
22
|
-
}),
|
|
23
|
-
]).annotate({ identifier: "Permission.Source" })
|
|
24
|
-
export type Source = typeof Source.Type
|
|
25
|
-
|
|
26
|
-
const RequestFields = {
|
|
27
|
-
sessionID: SessionID,
|
|
28
|
-
action: Schema.String,
|
|
29
|
-
resources: Schema.Array(Schema.String),
|
|
30
|
-
save: Schema.Array(Schema.String).pipe(optional),
|
|
31
|
-
metadata: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
|
|
32
|
-
source: Source.pipe(optional),
|
|
33
|
-
message: Schema.String.pipe(optional),
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const Request = Schema.Struct({
|
|
37
|
-
id: ID,
|
|
38
|
-
...RequestFields,
|
|
39
|
-
}).annotate({ identifier: "Permission.Request" })
|
|
40
|
-
export interface Request extends Schema.Schema.Type<typeof Request> {}
|
|
41
|
-
|
|
42
|
-
export const Reply = Schema.Literals(["once", "always", "reject"]).annotate({ identifier: "Permission.Reply" })
|
|
43
|
-
export type Reply = typeof Reply.Type
|
|
44
|
-
|
|
45
|
-
const Asked = ephemeral({ type: "permission.asked", schema: Request.fields })
|
|
46
|
-
const Replied = ephemeral({
|
|
47
|
-
type: "permission.replied",
|
|
48
|
-
schema: {
|
|
49
|
-
sessionID: SessionID,
|
|
50
|
-
requestID: ID,
|
|
51
|
-
reply: Reply,
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
export const Event = { Asked, Replied, Definitions: inventory(Asked, Replied) }
|
|
55
|
-
|
|
56
|
-
export const Effect = Schema.Literals(["allow", "deny", "ask"]).annotate({ identifier: "Permission.Effect" })
|
|
57
|
-
export type Effect = typeof Effect.Type
|
|
58
|
-
|
|
59
|
-
export interface Rule extends Schema.Schema.Type<typeof Rule> {}
|
|
60
|
-
export const Rule = Schema.Struct({
|
|
61
|
-
action: Schema.String,
|
|
62
|
-
resource: Schema.String,
|
|
63
|
-
effect: Effect,
|
|
64
|
-
}).annotate({ identifier: "Permission.Rule" })
|
|
65
|
-
|
|
66
|
-
export const Ruleset = Schema.Array(Rule).annotate({ identifier: "Permission.Ruleset" })
|
|
67
|
-
export type Ruleset = typeof Ruleset.Type
|
|
1
|
+
export * as Permission from "./permission.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional } from "./schema.js"
|
|
5
|
+
import { ephemeral, inventory } from "./event.js"
|
|
6
|
+
import { ascending } from "./identifier.js"
|
|
7
|
+
import { SessionID } from "./session-id.js"
|
|
8
|
+
import { statics } from "./schema.js"
|
|
9
|
+
|
|
10
|
+
export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(
|
|
11
|
+
Schema.brand("Permission.ID"),
|
|
12
|
+
Schema.annotate({ identifier: "Permission.ID" }),
|
|
13
|
+
statics((schema) => ({ create: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
|
14
|
+
)
|
|
15
|
+
export type ID = typeof ID.Type
|
|
16
|
+
|
|
17
|
+
export const Source = Schema.Union([
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
type: Schema.Literal("tool"),
|
|
20
|
+
messageID: Schema.String,
|
|
21
|
+
id: Schema.String,
|
|
22
|
+
}),
|
|
23
|
+
]).annotate({ identifier: "Permission.Source" })
|
|
24
|
+
export type Source = typeof Source.Type
|
|
25
|
+
|
|
26
|
+
const RequestFields = {
|
|
27
|
+
sessionID: SessionID,
|
|
28
|
+
action: Schema.String,
|
|
29
|
+
resources: Schema.Array(Schema.String),
|
|
30
|
+
save: Schema.Array(Schema.String).pipe(optional),
|
|
31
|
+
metadata: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
|
|
32
|
+
source: Source.pipe(optional),
|
|
33
|
+
message: Schema.String.pipe(optional),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Request = Schema.Struct({
|
|
37
|
+
id: ID,
|
|
38
|
+
...RequestFields,
|
|
39
|
+
}).annotate({ identifier: "Permission.Request" })
|
|
40
|
+
export interface Request extends Schema.Schema.Type<typeof Request> {}
|
|
41
|
+
|
|
42
|
+
export const Reply = Schema.Literals(["once", "always", "reject"]).annotate({ identifier: "Permission.Reply" })
|
|
43
|
+
export type Reply = typeof Reply.Type
|
|
44
|
+
|
|
45
|
+
const Asked = ephemeral({ type: "permission.asked", schema: Request.fields })
|
|
46
|
+
const Replied = ephemeral({
|
|
47
|
+
type: "permission.replied",
|
|
48
|
+
schema: {
|
|
49
|
+
sessionID: SessionID,
|
|
50
|
+
requestID: ID,
|
|
51
|
+
reply: Reply,
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
export const Event = { Asked, Replied, Definitions: inventory(Asked, Replied) }
|
|
55
|
+
|
|
56
|
+
export const Effect = Schema.Literals(["allow", "deny", "ask"]).annotate({ identifier: "Permission.Effect" })
|
|
57
|
+
export type Effect = typeof Effect.Type
|
|
58
|
+
|
|
59
|
+
export interface Rule extends Schema.Schema.Type<typeof Rule> {}
|
|
60
|
+
export const Rule = Schema.Struct({
|
|
61
|
+
action: Schema.String,
|
|
62
|
+
resource: Schema.String,
|
|
63
|
+
effect: Effect,
|
|
64
|
+
}).annotate({ identifier: "Permission.Rule" })
|
|
65
|
+
|
|
66
|
+
export const Ruleset = Schema.Array(Rule).annotate({ identifier: "Permission.Ruleset" })
|
|
67
|
+
export type Ruleset = typeof Ruleset.Type
|