@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/prompt.ts
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import { Schema } from "effect"
|
|
2
|
-
import { optional } from "./schema.js"
|
|
3
|
-
import { statics } from "./schema.js"
|
|
4
|
-
import { Skill } from "./skill.js"
|
|
5
|
-
|
|
6
|
-
export interface PromptMention extends Schema.Schema.Type<typeof PromptMention> {}
|
|
7
|
-
export const PromptMention = Schema.Struct({
|
|
8
|
-
start: Schema.Finite,
|
|
9
|
-
end: Schema.Finite,
|
|
10
|
-
text: Schema.String,
|
|
11
|
-
}).annotate({ identifier: "Prompt.Mention" })
|
|
12
|
-
|
|
13
|
-
export const FileSource = Schema.Union([
|
|
14
|
-
Schema.Struct({ type: Schema.Literal("inline") }),
|
|
15
|
-
Schema.Struct({ type: Schema.Literal("uri"), uri: Schema.String }),
|
|
16
|
-
])
|
|
17
|
-
.pipe(Schema.toTaggedUnion("type"))
|
|
18
|
-
.annotate({ identifier: "Prompt.FileSource" })
|
|
19
|
-
export type FileSource = typeof FileSource.Type
|
|
20
|
-
|
|
21
|
-
// The canonical pattern backtracks on large inputs, so it only supplies metadata (OpenAPI, errors) while an equivalent linear check runs.
|
|
22
|
-
export const Base64 = Schema.String.check(
|
|
23
|
-
Schema.makeFilter(
|
|
24
|
-
(value: string) => value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/u.test(value),
|
|
25
|
-
Schema.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations,
|
|
26
|
-
),
|
|
27
|
-
).annotate({ identifier: "Prompt.Base64" })
|
|
28
|
-
export type Base64 = typeof Base64.Type
|
|
29
|
-
|
|
30
|
-
export interface FileAttachment extends Schema.Schema.Type<typeof FileAttachment> {}
|
|
31
|
-
export const FileAttachment = Schema.Struct({
|
|
32
|
-
data: Base64,
|
|
33
|
-
mime: Schema.String,
|
|
34
|
-
source: FileSource,
|
|
35
|
-
name: Schema.String.pipe(optional),
|
|
36
|
-
description: Schema.String.pipe(optional),
|
|
37
|
-
mention: PromptMention.pipe(optional),
|
|
38
|
-
})
|
|
39
|
-
.annotate({ identifier: "Prompt.FileAttachment" })
|
|
40
|
-
.pipe(
|
|
41
|
-
statics((schema) => ({
|
|
42
|
-
create: (input: FileAttachment) =>
|
|
43
|
-
schema.make({
|
|
44
|
-
data: input.data,
|
|
45
|
-
mime: input.mime,
|
|
46
|
-
source: input.source,
|
|
47
|
-
name: input.name,
|
|
48
|
-
description: input.description,
|
|
49
|
-
mention: input.mention,
|
|
50
|
-
}),
|
|
51
|
-
})),
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
/** `media:` and the lowercase hex SHA-256 of a stored blob's bytes. Names no server route. */
|
|
55
|
-
export const MediaRef = Schema.String.check(Schema.isPattern(/^media:[0-9a-f]{64}$/)).annotate({
|
|
56
|
-
identifier: "Prompt.MediaRef",
|
|
57
|
-
})
|
|
58
|
-
export type MediaRef = typeof MediaRef.Type
|
|
59
|
-
|
|
60
|
-
const { data: _, ...fileAttachmentFields } = FileAttachment.fields
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* An attachment whose bytes stay on the server, sent to clients that opt in with the experimental `experimental-media-uri`
|
|
64
|
-
* capability. Fetch the bytes from `GET /api/experimental/media/:hash`.
|
|
65
|
-
*/
|
|
66
|
-
export interface MediaFileAttachment extends Schema.Schema.Type<typeof MediaFileAttachment> {}
|
|
67
|
-
export const MediaFileAttachment = Schema.Struct({
|
|
68
|
-
...fileAttachmentFields,
|
|
69
|
-
uri: MediaRef,
|
|
70
|
-
bytes: Schema.Int.pipe(optional),
|
|
71
|
-
width: Schema.Int.pipe(optional),
|
|
72
|
-
height: Schema.Int.pipe(optional),
|
|
73
|
-
}).annotate({ identifier: "Prompt.MediaFileAttachment" })
|
|
74
|
-
|
|
75
|
-
export const Attachment = Schema.Union([FileAttachment, MediaFileAttachment]).annotate({
|
|
76
|
-
identifier: "Prompt.Attachment",
|
|
77
|
-
})
|
|
78
|
-
export type Attachment = typeof Attachment.Type
|
|
79
|
-
|
|
80
|
-
export interface AgentAttachment extends Schema.Schema.Type<typeof AgentAttachment> {}
|
|
81
|
-
export const AgentAttachment = Schema.Struct({
|
|
82
|
-
name: Schema.String,
|
|
83
|
-
mention: PromptMention.pipe(optional),
|
|
84
|
-
}).annotate({
|
|
85
|
-
identifier: "Prompt.AgentAttachment",
|
|
86
|
-
description:
|
|
87
|
-
"An agent @-mentioned in the prompt, such as @explore, to suggest the model use it. Only the @name in text reaches the model; this records which agent it names and doesn't change the session's own agent.",
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
export interface SkillAttachment extends Schema.Schema.Type<typeof SkillAttachment> {}
|
|
91
|
-
export const SkillAttachment = Schema.Struct({
|
|
92
|
-
id: Skill.ID,
|
|
93
|
-
name: Skill.Name,
|
|
94
|
-
text: Schema.String.pipe(optional),
|
|
95
|
-
mention: PromptMention.pipe(optional),
|
|
96
|
-
}).annotate({ identifier: "Prompt.SkillAttachment" })
|
|
97
|
-
|
|
98
|
-
export interface Prompt extends Schema.Schema.Type<typeof Prompt> {}
|
|
99
|
-
export const Prompt = Schema.Struct({
|
|
100
|
-
text: Schema.String,
|
|
101
|
-
files: Schema.Array(FileAttachment).pipe(optional),
|
|
102
|
-
agents: Schema.Array(AgentAttachment).pipe(optional),
|
|
103
|
-
skills: Schema.Array(SkillAttachment).pipe(optional),
|
|
104
|
-
})
|
|
105
|
-
.annotate({ identifier: "Prompt" })
|
|
106
|
-
.pipe(
|
|
107
|
-
statics((schema) => ({
|
|
108
|
-
equivalence: Schema.toEquivalence(schema),
|
|
109
|
-
fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents" | "skills">) =>
|
|
110
|
-
schema.make({
|
|
111
|
-
text: input.text,
|
|
112
|
-
...(input.files === undefined ? {} : { files: input.files }),
|
|
113
|
-
...(input.agents === undefined ? {} : { agents: input.agents }),
|
|
114
|
-
...(input.skills === undefined ? {} : { skills: input.skills }),
|
|
115
|
-
}),
|
|
116
|
-
})),
|
|
117
|
-
)
|
|
1
|
+
import { Schema } from "effect"
|
|
2
|
+
import { optional } from "./schema.js"
|
|
3
|
+
import { statics } from "./schema.js"
|
|
4
|
+
import { Skill } from "./skill.js"
|
|
5
|
+
|
|
6
|
+
export interface PromptMention extends Schema.Schema.Type<typeof PromptMention> {}
|
|
7
|
+
export const PromptMention = Schema.Struct({
|
|
8
|
+
start: Schema.Finite,
|
|
9
|
+
end: Schema.Finite,
|
|
10
|
+
text: Schema.String,
|
|
11
|
+
}).annotate({ identifier: "Prompt.Mention" })
|
|
12
|
+
|
|
13
|
+
export const FileSource = Schema.Union([
|
|
14
|
+
Schema.Struct({ type: Schema.Literal("inline") }),
|
|
15
|
+
Schema.Struct({ type: Schema.Literal("uri"), uri: Schema.String }),
|
|
16
|
+
])
|
|
17
|
+
.pipe(Schema.toTaggedUnion("type"))
|
|
18
|
+
.annotate({ identifier: "Prompt.FileSource" })
|
|
19
|
+
export type FileSource = typeof FileSource.Type
|
|
20
|
+
|
|
21
|
+
// The canonical pattern backtracks on large inputs, so it only supplies metadata (OpenAPI, errors) while an equivalent linear check runs.
|
|
22
|
+
export const Base64 = Schema.String.check(
|
|
23
|
+
Schema.makeFilter(
|
|
24
|
+
(value: string) => value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/u.test(value),
|
|
25
|
+
Schema.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u).annotations,
|
|
26
|
+
),
|
|
27
|
+
).annotate({ identifier: "Prompt.Base64" })
|
|
28
|
+
export type Base64 = typeof Base64.Type
|
|
29
|
+
|
|
30
|
+
export interface FileAttachment extends Schema.Schema.Type<typeof FileAttachment> {}
|
|
31
|
+
export const FileAttachment = Schema.Struct({
|
|
32
|
+
data: Base64,
|
|
33
|
+
mime: Schema.String,
|
|
34
|
+
source: FileSource,
|
|
35
|
+
name: Schema.String.pipe(optional),
|
|
36
|
+
description: Schema.String.pipe(optional),
|
|
37
|
+
mention: PromptMention.pipe(optional),
|
|
38
|
+
})
|
|
39
|
+
.annotate({ identifier: "Prompt.FileAttachment" })
|
|
40
|
+
.pipe(
|
|
41
|
+
statics((schema) => ({
|
|
42
|
+
create: (input: FileAttachment) =>
|
|
43
|
+
schema.make({
|
|
44
|
+
data: input.data,
|
|
45
|
+
mime: input.mime,
|
|
46
|
+
source: input.source,
|
|
47
|
+
name: input.name,
|
|
48
|
+
description: input.description,
|
|
49
|
+
mention: input.mention,
|
|
50
|
+
}),
|
|
51
|
+
})),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
/** `media:` and the lowercase hex SHA-256 of a stored blob's bytes. Names no server route. */
|
|
55
|
+
export const MediaRef = Schema.String.check(Schema.isPattern(/^media:[0-9a-f]{64}$/)).annotate({
|
|
56
|
+
identifier: "Prompt.MediaRef",
|
|
57
|
+
})
|
|
58
|
+
export type MediaRef = typeof MediaRef.Type
|
|
59
|
+
|
|
60
|
+
const { data: _, ...fileAttachmentFields } = FileAttachment.fields
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* An attachment whose bytes stay on the server, sent to clients that opt in with the experimental `experimental-media-uri`
|
|
64
|
+
* capability. Fetch the bytes from `GET /api/experimental/media/:hash`.
|
|
65
|
+
*/
|
|
66
|
+
export interface MediaFileAttachment extends Schema.Schema.Type<typeof MediaFileAttachment> {}
|
|
67
|
+
export const MediaFileAttachment = Schema.Struct({
|
|
68
|
+
...fileAttachmentFields,
|
|
69
|
+
uri: MediaRef,
|
|
70
|
+
bytes: Schema.Int.pipe(optional),
|
|
71
|
+
width: Schema.Int.pipe(optional),
|
|
72
|
+
height: Schema.Int.pipe(optional),
|
|
73
|
+
}).annotate({ identifier: "Prompt.MediaFileAttachment" })
|
|
74
|
+
|
|
75
|
+
export const Attachment = Schema.Union([FileAttachment, MediaFileAttachment]).annotate({
|
|
76
|
+
identifier: "Prompt.Attachment",
|
|
77
|
+
})
|
|
78
|
+
export type Attachment = typeof Attachment.Type
|
|
79
|
+
|
|
80
|
+
export interface AgentAttachment extends Schema.Schema.Type<typeof AgentAttachment> {}
|
|
81
|
+
export const AgentAttachment = Schema.Struct({
|
|
82
|
+
name: Schema.String,
|
|
83
|
+
mention: PromptMention.pipe(optional),
|
|
84
|
+
}).annotate({
|
|
85
|
+
identifier: "Prompt.AgentAttachment",
|
|
86
|
+
description:
|
|
87
|
+
"An agent @-mentioned in the prompt, such as @explore, to suggest the model use it. Only the @name in text reaches the model; this records which agent it names and doesn't change the session's own agent.",
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
export interface SkillAttachment extends Schema.Schema.Type<typeof SkillAttachment> {}
|
|
91
|
+
export const SkillAttachment = Schema.Struct({
|
|
92
|
+
id: Skill.ID,
|
|
93
|
+
name: Skill.Name,
|
|
94
|
+
text: Schema.String.pipe(optional),
|
|
95
|
+
mention: PromptMention.pipe(optional),
|
|
96
|
+
}).annotate({ identifier: "Prompt.SkillAttachment" })
|
|
97
|
+
|
|
98
|
+
export interface Prompt extends Schema.Schema.Type<typeof Prompt> {}
|
|
99
|
+
export const Prompt = Schema.Struct({
|
|
100
|
+
text: Schema.String,
|
|
101
|
+
files: Schema.Array(FileAttachment).pipe(optional),
|
|
102
|
+
agents: Schema.Array(AgentAttachment).pipe(optional),
|
|
103
|
+
skills: Schema.Array(SkillAttachment).pipe(optional),
|
|
104
|
+
})
|
|
105
|
+
.annotate({ identifier: "Prompt" })
|
|
106
|
+
.pipe(
|
|
107
|
+
statics((schema) => ({
|
|
108
|
+
equivalence: Schema.toEquivalence(schema),
|
|
109
|
+
fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents" | "skills">) =>
|
|
110
|
+
schema.make({
|
|
111
|
+
text: input.text,
|
|
112
|
+
...(input.files === undefined ? {} : { files: input.files }),
|
|
113
|
+
...(input.agents === undefined ? {} : { agents: input.agents }),
|
|
114
|
+
...(input.skills === undefined ? {} : { skills: input.skills }),
|
|
115
|
+
}),
|
|
116
|
+
})),
|
|
117
|
+
)
|
package/src/provider.ts
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
export * as Provider from "./provider.js"
|
|
2
|
-
|
|
3
|
-
import { Effect, Schema } from "effect"
|
|
4
|
-
import { Integration } from "./integration.js"
|
|
5
|
-
import { ProviderCompatibility } from "./model-compatibility.js"
|
|
6
|
-
import { optional, statics } from "./schema.js"
|
|
7
|
-
import { ephemeral, inventory } from "./event.js"
|
|
8
|
-
|
|
9
|
-
export const ID = Schema.String.pipe(
|
|
10
|
-
Schema.brand("Provider.ID"),
|
|
11
|
-
Schema.annotate({ identifier: "Provider.ID" }),
|
|
12
|
-
statics((schema) => ({
|
|
13
|
-
opencode: schema.make("opencode"),
|
|
14
|
-
anthropic: schema.make("anthropic"),
|
|
15
|
-
openai: schema.make("openai"),
|
|
16
|
-
google: schema.make("google"),
|
|
17
|
-
googleVertex: schema.make("google-vertex"),
|
|
18
|
-
githubCopilot: schema.make("github-copilot"),
|
|
19
|
-
claudeAgent: schema.make("claude-agent"),
|
|
20
|
-
amazonBedrock: schema.make("amazon-bedrock"),
|
|
21
|
-
azure: schema.make("azure"),
|
|
22
|
-
openrouter: schema.make("openrouter"),
|
|
23
|
-
mistral: schema.make("mistral"),
|
|
24
|
-
gitlab: schema.make("gitlab"),
|
|
25
|
-
})),
|
|
26
|
-
)
|
|
27
|
-
export type ID = typeof ID.Type
|
|
28
|
-
|
|
29
|
-
const Updated = ephemeral({ type: "provider.updated", schema: {} })
|
|
30
|
-
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
31
|
-
|
|
32
|
-
export const Package = Schema.String
|
|
33
|
-
export type Package = typeof Package.Type
|
|
34
|
-
|
|
35
|
-
export const Activation = Schema.Literals(["auto", "enabled", "disabled"])
|
|
36
|
-
export type Activation = typeof Activation.Type
|
|
37
|
-
|
|
38
|
-
export const Compaction = Schema.Union([
|
|
39
|
-
Schema.Struct({ type: Schema.Literal("summary") }),
|
|
40
|
-
Schema.Struct({ type: Schema.Literal("native") }),
|
|
41
|
-
])
|
|
42
|
-
.pipe(Schema.toTaggedUnion("type"))
|
|
43
|
-
.annotate({ identifier: "Provider.Compaction" })
|
|
44
|
-
export type Compaction = typeof Compaction.Type
|
|
45
|
-
|
|
46
|
-
/** "websocket" on a route without a WebSocket channel warns and falls back to HTTP. */
|
|
47
|
-
export const Transport = Schema.Literals(["http", "websocket"]).annotate({ identifier: "Provider.Transport" })
|
|
48
|
-
export type Transport = typeof Transport.Type
|
|
49
|
-
|
|
50
|
-
/** Prompt-cache lifetime such as "5m", "30m", "1h" or "24h", in models.dev's duration format. */
|
|
51
|
-
export const CacheTTL = Schema.TemplateLiteral([Schema.Number, Schema.Literals(["ms", "s", "m", "h", "d"])])
|
|
52
|
-
.check(Schema.isPattern(/^\d+(ms|s|m|h|d)$/))
|
|
53
|
-
.annotate({ identifier: "Provider.CacheTTL" })
|
|
54
|
-
export type CacheTTL = typeof CacheTTL.Type
|
|
55
|
-
|
|
56
|
-
/** Keep-alive requests for this provider's or model's sessions; overrides the top-level `warming`. */
|
|
57
|
-
export const CacheWarming = Schema.Union([
|
|
58
|
-
Schema.Boolean,
|
|
59
|
-
Schema.Struct({
|
|
60
|
-
// Settings hold JSON, so durations stay strings here; the warming plugin parses them.
|
|
61
|
-
interval: Schema.Union([Schema.Literal("auto"), Schema.String])
|
|
62
|
-
.pipe(optional)
|
|
63
|
-
.annotate({ description: 'Duration such as "4 minutes", or "auto" (default) for 90% of the model\'s cache.ttl' }),
|
|
64
|
-
duration: Schema.String.pipe(optional).annotate({ description: 'Duration such as "30 minutes"' }),
|
|
65
|
-
}),
|
|
66
|
-
]).annotate({ identifier: "Provider.CacheWarming" })
|
|
67
|
-
export type CacheWarming = typeof CacheWarming.Type
|
|
68
|
-
|
|
69
|
-
/** Prompt-cache settings. `ttl` is sent to the provider as given; each provider accepts its own set. */
|
|
70
|
-
export const Cache = Schema.Struct({
|
|
71
|
-
ttl: CacheTTL.pipe(optional),
|
|
72
|
-
warming: CacheWarming.pipe(optional),
|
|
73
|
-
}).annotate({ identifier: "Provider.Cache" })
|
|
74
|
-
export type Cache = typeof Cache.Type
|
|
75
|
-
|
|
76
|
-
/** HTTP request body compression; only endpoints known to decode it should enable it. */
|
|
77
|
-
export const Encoding = Schema.Literals(["zstd", "gzip", "none"]).annotate({ identifier: "Provider.Encoding" })
|
|
78
|
-
export type Encoding = typeof Encoding.Type
|
|
79
|
-
|
|
80
|
-
const Timeout = Schema.Union([Schema.Finite, Schema.Literal(false)]).pipe(optional)
|
|
81
|
-
|
|
82
|
-
/** Client certificate for gateways that require mutual TLS. Values are PEM text; use `{file:...}` to read a file. */
|
|
83
|
-
export const Tls = Schema.Struct({
|
|
84
|
-
cert: Schema.String.annotate({ description: "PEM client certificate, usually `{file:/path/to/client.pem}`" }),
|
|
85
|
-
key: Schema.String.annotate({ description: "PEM private key, usually `{file:/path/to/client.key}`" }),
|
|
86
|
-
passphrase: Schema.String.pipe(optional).annotate({ description: "Passphrase for an encrypted private key" }),
|
|
87
|
-
}).annotate({ identifier: "Provider.Tls" })
|
|
88
|
-
export type Tls = typeof Tls.Type
|
|
89
|
-
|
|
90
|
-
// The named fields are the settings OpenCode reads itself; every other key is a provider option for the provider package.
|
|
91
|
-
export const Settings = Schema.StructWithRest(
|
|
92
|
-
Schema.Struct({
|
|
93
|
-
timeout: Timeout,
|
|
94
|
-
headerTimeout: Timeout,
|
|
95
|
-
chunkTimeout: Timeout,
|
|
96
|
-
compaction: Compaction.pipe(optional),
|
|
97
|
-
cache: Cache.pipe(optional),
|
|
98
|
-
transport: Transport.pipe(optional),
|
|
99
|
-
encoding: Encoding.pipe(optional),
|
|
100
|
-
tls: Tls.pipe(optional),
|
|
101
|
-
}),
|
|
102
|
-
[Schema.Record(Schema.String, Schema.Any)],
|
|
103
|
-
).annotate({ identifier: "Provider.Settings" })
|
|
104
|
-
export type Settings = typeof Settings.Type
|
|
105
|
-
|
|
106
|
-
export const Overlays = {
|
|
107
|
-
settings: Settings.pipe(optional),
|
|
108
|
-
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
109
|
-
body: Schema.Record(Schema.String, Schema.Any).pipe(optional),
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface Request extends Schema.Schema.Type<typeof Request> {}
|
|
113
|
-
export const Request = Schema.Struct({
|
|
114
|
-
settings: Settings.pipe(Schema.withConstructorDefault(Effect.succeed({}))),
|
|
115
|
-
headers: Schema.Record(Schema.String, Schema.String),
|
|
116
|
-
body: Schema.Record(Schema.String, Schema.Any),
|
|
117
|
-
}).annotate({ identifier: "Provider.Request" })
|
|
118
|
-
|
|
119
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
120
|
-
export const Info = Schema.Struct({
|
|
121
|
-
id: ID,
|
|
122
|
-
canonical: ID.pipe(optional),
|
|
123
|
-
integrationID: Integration.ID.pipe(optional),
|
|
124
|
-
name: Schema.String,
|
|
125
|
-
activation: Activation,
|
|
126
|
-
package: Package,
|
|
127
|
-
/** Inherited by every model of this provider; model compatibility overrides individual fields. */
|
|
128
|
-
compatibility: ProviderCompatibility.pipe(optional),
|
|
129
|
-
...Overlays,
|
|
130
|
-
})
|
|
131
|
-
.annotate({ identifier: "Provider.Info" })
|
|
132
|
-
.pipe(
|
|
133
|
-
statics(() => ({
|
|
134
|
-
empty: (id: ID): Info => ({ id, name: id, activation: "auto", package: "" }),
|
|
135
|
-
})),
|
|
136
|
-
)
|
|
1
|
+
export * as Provider from "./provider.js"
|
|
2
|
+
|
|
3
|
+
import { Effect, Schema } from "effect"
|
|
4
|
+
import { Integration } from "./integration.js"
|
|
5
|
+
import { ProviderCompatibility } from "./model-compatibility.js"
|
|
6
|
+
import { optional, statics } from "./schema.js"
|
|
7
|
+
import { ephemeral, inventory } from "./event.js"
|
|
8
|
+
|
|
9
|
+
export const ID = Schema.String.pipe(
|
|
10
|
+
Schema.brand("Provider.ID"),
|
|
11
|
+
Schema.annotate({ identifier: "Provider.ID" }),
|
|
12
|
+
statics((schema) => ({
|
|
13
|
+
opencode: schema.make("opencode"),
|
|
14
|
+
anthropic: schema.make("anthropic"),
|
|
15
|
+
openai: schema.make("openai"),
|
|
16
|
+
google: schema.make("google"),
|
|
17
|
+
googleVertex: schema.make("google-vertex"),
|
|
18
|
+
githubCopilot: schema.make("github-copilot"),
|
|
19
|
+
claudeAgent: schema.make("claude-agent"),
|
|
20
|
+
amazonBedrock: schema.make("amazon-bedrock"),
|
|
21
|
+
azure: schema.make("azure"),
|
|
22
|
+
openrouter: schema.make("openrouter"),
|
|
23
|
+
mistral: schema.make("mistral"),
|
|
24
|
+
gitlab: schema.make("gitlab"),
|
|
25
|
+
})),
|
|
26
|
+
)
|
|
27
|
+
export type ID = typeof ID.Type
|
|
28
|
+
|
|
29
|
+
const Updated = ephemeral({ type: "provider.updated", schema: {} })
|
|
30
|
+
export const Event = { Updated, Definitions: inventory(Updated) }
|
|
31
|
+
|
|
32
|
+
export const Package = Schema.String
|
|
33
|
+
export type Package = typeof Package.Type
|
|
34
|
+
|
|
35
|
+
export const Activation = Schema.Literals(["auto", "enabled", "disabled"])
|
|
36
|
+
export type Activation = typeof Activation.Type
|
|
37
|
+
|
|
38
|
+
export const Compaction = Schema.Union([
|
|
39
|
+
Schema.Struct({ type: Schema.Literal("summary") }),
|
|
40
|
+
Schema.Struct({ type: Schema.Literal("native") }),
|
|
41
|
+
])
|
|
42
|
+
.pipe(Schema.toTaggedUnion("type"))
|
|
43
|
+
.annotate({ identifier: "Provider.Compaction" })
|
|
44
|
+
export type Compaction = typeof Compaction.Type
|
|
45
|
+
|
|
46
|
+
/** "websocket" on a route without a WebSocket channel warns and falls back to HTTP. */
|
|
47
|
+
export const Transport = Schema.Literals(["http", "websocket"]).annotate({ identifier: "Provider.Transport" })
|
|
48
|
+
export type Transport = typeof Transport.Type
|
|
49
|
+
|
|
50
|
+
/** Prompt-cache lifetime such as "5m", "30m", "1h" or "24h", in models.dev's duration format. */
|
|
51
|
+
export const CacheTTL = Schema.TemplateLiteral([Schema.Number, Schema.Literals(["ms", "s", "m", "h", "d"])])
|
|
52
|
+
.check(Schema.isPattern(/^\d+(ms|s|m|h|d)$/))
|
|
53
|
+
.annotate({ identifier: "Provider.CacheTTL" })
|
|
54
|
+
export type CacheTTL = typeof CacheTTL.Type
|
|
55
|
+
|
|
56
|
+
/** Keep-alive requests for this provider's or model's sessions; overrides the top-level `warming`. */
|
|
57
|
+
export const CacheWarming = Schema.Union([
|
|
58
|
+
Schema.Boolean,
|
|
59
|
+
Schema.Struct({
|
|
60
|
+
// Settings hold JSON, so durations stay strings here; the warming plugin parses them.
|
|
61
|
+
interval: Schema.Union([Schema.Literal("auto"), Schema.String])
|
|
62
|
+
.pipe(optional)
|
|
63
|
+
.annotate({ description: 'Duration such as "4 minutes", or "auto" (default) for 90% of the model\'s cache.ttl' }),
|
|
64
|
+
duration: Schema.String.pipe(optional).annotate({ description: 'Duration such as "30 minutes"' }),
|
|
65
|
+
}),
|
|
66
|
+
]).annotate({ identifier: "Provider.CacheWarming" })
|
|
67
|
+
export type CacheWarming = typeof CacheWarming.Type
|
|
68
|
+
|
|
69
|
+
/** Prompt-cache settings. `ttl` is sent to the provider as given; each provider accepts its own set. */
|
|
70
|
+
export const Cache = Schema.Struct({
|
|
71
|
+
ttl: CacheTTL.pipe(optional),
|
|
72
|
+
warming: CacheWarming.pipe(optional),
|
|
73
|
+
}).annotate({ identifier: "Provider.Cache" })
|
|
74
|
+
export type Cache = typeof Cache.Type
|
|
75
|
+
|
|
76
|
+
/** HTTP request body compression; only endpoints known to decode it should enable it. */
|
|
77
|
+
export const Encoding = Schema.Literals(["zstd", "gzip", "none"]).annotate({ identifier: "Provider.Encoding" })
|
|
78
|
+
export type Encoding = typeof Encoding.Type
|
|
79
|
+
|
|
80
|
+
const Timeout = Schema.Union([Schema.Finite, Schema.Literal(false)]).pipe(optional)
|
|
81
|
+
|
|
82
|
+
/** Client certificate for gateways that require mutual TLS. Values are PEM text; use `{file:...}` to read a file. */
|
|
83
|
+
export const Tls = Schema.Struct({
|
|
84
|
+
cert: Schema.String.annotate({ description: "PEM client certificate, usually `{file:/path/to/client.pem}`" }),
|
|
85
|
+
key: Schema.String.annotate({ description: "PEM private key, usually `{file:/path/to/client.key}`" }),
|
|
86
|
+
passphrase: Schema.String.pipe(optional).annotate({ description: "Passphrase for an encrypted private key" }),
|
|
87
|
+
}).annotate({ identifier: "Provider.Tls" })
|
|
88
|
+
export type Tls = typeof Tls.Type
|
|
89
|
+
|
|
90
|
+
// The named fields are the settings OpenCode reads itself; every other key is a provider option for the provider package.
|
|
91
|
+
export const Settings = Schema.StructWithRest(
|
|
92
|
+
Schema.Struct({
|
|
93
|
+
timeout: Timeout,
|
|
94
|
+
headerTimeout: Timeout,
|
|
95
|
+
chunkTimeout: Timeout,
|
|
96
|
+
compaction: Compaction.pipe(optional),
|
|
97
|
+
cache: Cache.pipe(optional),
|
|
98
|
+
transport: Transport.pipe(optional),
|
|
99
|
+
encoding: Encoding.pipe(optional),
|
|
100
|
+
tls: Tls.pipe(optional),
|
|
101
|
+
}),
|
|
102
|
+
[Schema.Record(Schema.String, Schema.Any)],
|
|
103
|
+
).annotate({ identifier: "Provider.Settings" })
|
|
104
|
+
export type Settings = typeof Settings.Type
|
|
105
|
+
|
|
106
|
+
export const Overlays = {
|
|
107
|
+
settings: Settings.pipe(optional),
|
|
108
|
+
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
109
|
+
body: Schema.Record(Schema.String, Schema.Any).pipe(optional),
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface Request extends Schema.Schema.Type<typeof Request> {}
|
|
113
|
+
export const Request = Schema.Struct({
|
|
114
|
+
settings: Settings.pipe(Schema.withConstructorDefault(Effect.succeed({}))),
|
|
115
|
+
headers: Schema.Record(Schema.String, Schema.String),
|
|
116
|
+
body: Schema.Record(Schema.String, Schema.Any),
|
|
117
|
+
}).annotate({ identifier: "Provider.Request" })
|
|
118
|
+
|
|
119
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
120
|
+
export const Info = Schema.Struct({
|
|
121
|
+
id: ID,
|
|
122
|
+
canonical: ID.pipe(optional),
|
|
123
|
+
integrationID: Integration.ID.pipe(optional),
|
|
124
|
+
name: Schema.String,
|
|
125
|
+
activation: Activation,
|
|
126
|
+
package: Package,
|
|
127
|
+
/** Inherited by every model of this provider; model compatibility overrides individual fields. */
|
|
128
|
+
compatibility: ProviderCompatibility.pipe(optional),
|
|
129
|
+
...Overlays,
|
|
130
|
+
})
|
|
131
|
+
.annotate({ identifier: "Provider.Info" })
|
|
132
|
+
.pipe(
|
|
133
|
+
statics(() => ({
|
|
134
|
+
empty: (id: ID): Info => ({ id, name: id, activation: "auto", package: "" }),
|
|
135
|
+
})),
|
|
136
|
+
)
|
package/src/pty-ticket.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * as PtyTicket from "./pty-ticket.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { PositiveInt } from "./schema.js"
|
|
5
|
-
|
|
6
|
-
export const ConnectToken = Schema.Struct({
|
|
7
|
-
ticket: Schema.String,
|
|
8
|
-
expires_in: PositiveInt,
|
|
9
|
-
}).annotate({ identifier: "PtyTicket.ConnectToken" })
|
|
10
|
-
export interface ConnectToken extends Schema.Schema.Type<typeof ConnectToken> {}
|
|
1
|
+
export * as PtyTicket from "./pty-ticket.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { PositiveInt } from "./schema.js"
|
|
5
|
+
|
|
6
|
+
export const ConnectToken = Schema.Struct({
|
|
7
|
+
ticket: Schema.String,
|
|
8
|
+
expires_in: PositiveInt,
|
|
9
|
+
}).annotate({ identifier: "PtyTicket.ConnectToken" })
|
|
10
|
+
export interface ConnectToken extends Schema.Schema.Type<typeof ConnectToken> {}
|
package/src/pty.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
export * as Pty from "./pty.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 { NonNegativeInt, PositiveInt, statics } from "./schema.js"
|
|
8
|
-
|
|
9
|
-
const IDSchema = Schema.String.check(Schema.isStartingWith("pty")).pipe(
|
|
10
|
-
Schema.brand("PtyID"),
|
|
11
|
-
Schema.annotate({ identifier: "Pty.ID" }),
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
export const ID = IDSchema.pipe(
|
|
15
|
-
statics((schema: typeof IDSchema) => {
|
|
16
|
-
const create = () => schema.make("pty_" + ascending())
|
|
17
|
-
return {
|
|
18
|
-
create,
|
|
19
|
-
ascending: (id?: string) => (id === undefined ? create() : schema.make(id)),
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
)
|
|
23
|
-
export type ID = typeof ID.Type
|
|
24
|
-
|
|
25
|
-
export const Info = Schema.Struct({
|
|
26
|
-
id: ID,
|
|
27
|
-
title: Schema.String,
|
|
28
|
-
command: Schema.String,
|
|
29
|
-
args: Schema.Array(Schema.String),
|
|
30
|
-
cwd: Schema.String,
|
|
31
|
-
status: Schema.Literals(["running", "exited"]),
|
|
32
|
-
pid: NonNegativeInt,
|
|
33
|
-
exitCode: optional(NonNegativeInt),
|
|
34
|
-
}).annotate({ identifier: "Pty" })
|
|
35
|
-
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
36
|
-
|
|
37
|
-
const Created = ephemeral({ type: "pty.created", schema: { info: Info } })
|
|
38
|
-
const Updated = ephemeral({ type: "pty.updated", schema: { info: Info } })
|
|
39
|
-
const Exited = ephemeral({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
|
40
|
-
const Deleted = ephemeral({ type: "pty.deleted", schema: { id: ID } })
|
|
41
|
-
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
|
42
|
-
|
|
43
|
-
export const CreateInput = Schema.Struct({
|
|
44
|
-
command: optional(Schema.String),
|
|
45
|
-
args: optional(Schema.Array(Schema.String)),
|
|
46
|
-
cwd: optional(Schema.String),
|
|
47
|
-
title: optional(Schema.String),
|
|
48
|
-
env: optional(Schema.Record(Schema.String, Schema.String)),
|
|
49
|
-
})
|
|
50
|
-
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
51
|
-
|
|
52
|
-
export const UpdateInput = Schema.Struct({
|
|
53
|
-
title: optional(Schema.String),
|
|
54
|
-
size: optional(
|
|
55
|
-
Schema.Struct({
|
|
56
|
-
rows: PositiveInt,
|
|
57
|
-
cols: PositiveInt,
|
|
58
|
-
}),
|
|
59
|
-
),
|
|
60
|
-
})
|
|
61
|
-
export interface UpdateInput extends Schema.Schema.Type<typeof UpdateInput> {}
|
|
1
|
+
export * as Pty from "./pty.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 { NonNegativeInt, PositiveInt, statics } from "./schema.js"
|
|
8
|
+
|
|
9
|
+
const IDSchema = Schema.String.check(Schema.isStartingWith("pty")).pipe(
|
|
10
|
+
Schema.brand("PtyID"),
|
|
11
|
+
Schema.annotate({ identifier: "Pty.ID" }),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const ID = IDSchema.pipe(
|
|
15
|
+
statics((schema: typeof IDSchema) => {
|
|
16
|
+
const create = () => schema.make("pty_" + ascending())
|
|
17
|
+
return {
|
|
18
|
+
create,
|
|
19
|
+
ascending: (id?: string) => (id === undefined ? create() : schema.make(id)),
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
export type ID = typeof ID.Type
|
|
24
|
+
|
|
25
|
+
export const Info = Schema.Struct({
|
|
26
|
+
id: ID,
|
|
27
|
+
title: Schema.String,
|
|
28
|
+
command: Schema.String,
|
|
29
|
+
args: Schema.Array(Schema.String),
|
|
30
|
+
cwd: Schema.String,
|
|
31
|
+
status: Schema.Literals(["running", "exited"]),
|
|
32
|
+
pid: NonNegativeInt,
|
|
33
|
+
exitCode: optional(NonNegativeInt),
|
|
34
|
+
}).annotate({ identifier: "Pty" })
|
|
35
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
36
|
+
|
|
37
|
+
const Created = ephemeral({ type: "pty.created", schema: { info: Info } })
|
|
38
|
+
const Updated = ephemeral({ type: "pty.updated", schema: { info: Info } })
|
|
39
|
+
const Exited = ephemeral({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
|
40
|
+
const Deleted = ephemeral({ type: "pty.deleted", schema: { id: ID } })
|
|
41
|
+
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
|
42
|
+
|
|
43
|
+
export const CreateInput = Schema.Struct({
|
|
44
|
+
command: optional(Schema.String),
|
|
45
|
+
args: optional(Schema.Array(Schema.String)),
|
|
46
|
+
cwd: optional(Schema.String),
|
|
47
|
+
title: optional(Schema.String),
|
|
48
|
+
env: optional(Schema.Record(Schema.String, Schema.String)),
|
|
49
|
+
})
|
|
50
|
+
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
51
|
+
|
|
52
|
+
export const UpdateInput = Schema.Struct({
|
|
53
|
+
title: optional(Schema.String),
|
|
54
|
+
size: optional(
|
|
55
|
+
Schema.Struct({
|
|
56
|
+
rows: PositiveInt,
|
|
57
|
+
cols: PositiveInt,
|
|
58
|
+
}),
|
|
59
|
+
),
|
|
60
|
+
})
|
|
61
|
+
export interface UpdateInput extends Schema.Schema.Type<typeof UpdateInput> {}
|