@zyro-sec/schema 1.0.1 → 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 +5 -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/mcp-event.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
export * as McpEvent from "./mcp-event.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { Event } from "./event.js"
|
|
5
|
-
|
|
6
|
-
export const ToolsChanged = Event.ephemeral({
|
|
7
|
-
type: "mcp.tools.changed",
|
|
8
|
-
schema: {
|
|
9
|
-
server: Schema.String,
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const ResourcesChanged = Event.ephemeral({
|
|
14
|
-
type: "mcp.resources.changed",
|
|
15
|
-
schema: {
|
|
16
|
-
server: Schema.String,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
// Emitted whenever a server's connection status settles (connected, failed, needs_auth, closed) so
|
|
21
|
-
// observers can refresh status without polling.
|
|
22
|
-
export const StatusChanged = Event.ephemeral({
|
|
23
|
-
type: "mcp.status.changed",
|
|
24
|
-
schema: {
|
|
25
|
-
server: Schema.String,
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// Experimental: MCP Events is a draft extension; may change without compatibility guarantees.
|
|
30
|
-
|
|
31
|
-
/** One event from an MCP Events subscription. Delivery is at least once: dedupe on `id` and `eventId`. */
|
|
32
|
-
export const ExperimentalEvent = Event.ephemeral({
|
|
33
|
-
type: "experimental.mcp.event",
|
|
34
|
-
schema: {
|
|
35
|
-
/** The subscription that received it. */
|
|
36
|
-
id: Schema.String,
|
|
37
|
-
server: Schema.String,
|
|
38
|
-
name: Schema.String,
|
|
39
|
-
eventId: Schema.String,
|
|
40
|
-
timestamp: Schema.String,
|
|
41
|
-
data: Schema.Json,
|
|
42
|
-
/** Where the subscription resumes from after this event; null when the event type has no replay. */
|
|
43
|
-
cursor: Schema.NullOr(Schema.String),
|
|
44
|
-
/** The server skipped events before this one, which it could not replay. */
|
|
45
|
-
truncated: Schema.optional(Schema.Boolean),
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
/** A subscription's status changed; read it with the MCP service's `subscriptions`. */
|
|
50
|
-
export const ExperimentalSubscriptionChanged = Event.ephemeral({
|
|
51
|
-
type: "experimental.mcp.subscription.changed",
|
|
52
|
-
schema: {
|
|
53
|
-
id: Schema.String,
|
|
54
|
-
},
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
export const Definitions = Event.inventory(
|
|
58
|
-
ToolsChanged,
|
|
59
|
-
ResourcesChanged,
|
|
60
|
-
StatusChanged,
|
|
61
|
-
ExperimentalEvent,
|
|
62
|
-
ExperimentalSubscriptionChanged,
|
|
63
|
-
)
|
|
1
|
+
export * as McpEvent from "./mcp-event.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { Event } from "./event.js"
|
|
5
|
+
|
|
6
|
+
export const ToolsChanged = Event.ephemeral({
|
|
7
|
+
type: "mcp.tools.changed",
|
|
8
|
+
schema: {
|
|
9
|
+
server: Schema.String,
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const ResourcesChanged = Event.ephemeral({
|
|
14
|
+
type: "mcp.resources.changed",
|
|
15
|
+
schema: {
|
|
16
|
+
server: Schema.String,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// Emitted whenever a server's connection status settles (connected, failed, needs_auth, closed) so
|
|
21
|
+
// observers can refresh status without polling.
|
|
22
|
+
export const StatusChanged = Event.ephemeral({
|
|
23
|
+
type: "mcp.status.changed",
|
|
24
|
+
schema: {
|
|
25
|
+
server: Schema.String,
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Experimental: MCP Events is a draft extension; may change without compatibility guarantees.
|
|
30
|
+
|
|
31
|
+
/** One event from an MCP Events subscription. Delivery is at least once: dedupe on `id` and `eventId`. */
|
|
32
|
+
export const ExperimentalEvent = Event.ephemeral({
|
|
33
|
+
type: "experimental.mcp.event",
|
|
34
|
+
schema: {
|
|
35
|
+
/** The subscription that received it. */
|
|
36
|
+
id: Schema.String,
|
|
37
|
+
server: Schema.String,
|
|
38
|
+
name: Schema.String,
|
|
39
|
+
eventId: Schema.String,
|
|
40
|
+
timestamp: Schema.String,
|
|
41
|
+
data: Schema.Json,
|
|
42
|
+
/** Where the subscription resumes from after this event; null when the event type has no replay. */
|
|
43
|
+
cursor: Schema.NullOr(Schema.String),
|
|
44
|
+
/** The server skipped events before this one, which it could not replay. */
|
|
45
|
+
truncated: Schema.optional(Schema.Boolean),
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
/** A subscription's status changed; read it with the MCP service's `subscriptions`. */
|
|
50
|
+
export const ExperimentalSubscriptionChanged = Event.ephemeral({
|
|
51
|
+
type: "experimental.mcp.subscription.changed",
|
|
52
|
+
schema: {
|
|
53
|
+
id: Schema.String,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export const Definitions = Event.inventory(
|
|
58
|
+
ToolsChanged,
|
|
59
|
+
ResourcesChanged,
|
|
60
|
+
StatusChanged,
|
|
61
|
+
ExperimentalEvent,
|
|
62
|
+
ExperimentalSubscriptionChanged,
|
|
63
|
+
)
|
package/src/mcp.ts
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
export * as Mcp from "./mcp.js"
|
|
2
|
-
|
|
3
|
-
import { Schema } from "effect"
|
|
4
|
-
import { optional, PositiveInt } from "./schema.js"
|
|
5
|
-
import { IntegrationID } from "./integration-id.js"
|
|
6
|
-
|
|
7
|
-
export class TimeoutConfig extends Schema.Class<TimeoutConfig>("Mcp.TimeoutConfig")({
|
|
8
|
-
startup: PositiveInt.pipe(optional).annotate({
|
|
9
|
-
description: "Maximum time in milliseconds to establish and initialize the MCP server.",
|
|
10
|
-
}),
|
|
11
|
-
catalog: PositiveInt.pipe(optional).annotate({
|
|
12
|
-
description: "Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.",
|
|
13
|
-
}),
|
|
14
|
-
execution: PositiveInt.pipe(optional).annotate({
|
|
15
|
-
description: "Maximum time in milliseconds to wait for MCP tool and prompt execution.",
|
|
16
|
-
}),
|
|
17
|
-
}) {}
|
|
18
|
-
|
|
19
|
-
export type Protocol = typeof Protocol.Type
|
|
20
|
-
export const Protocol = Schema.Literals(["legacy", "auto", "2026-07-28"]).annotate({
|
|
21
|
-
identifier: "Mcp.Protocol",
|
|
22
|
-
description:
|
|
23
|
-
'MCP protocol negotiation. "auto" (default) probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "legacy" opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "2026-07-28" requires that revision and fails otherwise.',
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export class LocalConfig extends Schema.Class<LocalConfig>("Mcp.LocalConfig")({
|
|
27
|
-
type: Schema.Literal("local"),
|
|
28
|
-
command: Schema.String.pipe(Schema.Array),
|
|
29
|
-
cwd: Schema.String.pipe(optional).annotate({
|
|
30
|
-
description: "Working directory for the MCP server process. Relative paths resolve from the workspace directory.",
|
|
31
|
-
}),
|
|
32
|
-
environment: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
33
|
-
disabled: Schema.Boolean.pipe(optional),
|
|
34
|
-
codemode: Schema.Boolean.pipe(optional).annotate({
|
|
35
|
-
description: "Expose this server's tools through Code Mode. Defaults to true.",
|
|
36
|
-
}),
|
|
37
|
-
timeout: TimeoutConfig.pipe(optional),
|
|
38
|
-
protocol: Protocol.pipe(optional),
|
|
39
|
-
pool: Schema.Boolean.pipe(optional).annotate({
|
|
40
|
-
description:
|
|
41
|
-
'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.',
|
|
42
|
-
}),
|
|
43
|
-
}) {}
|
|
44
|
-
|
|
45
|
-
export class OAuthConfig extends Schema.Class<OAuthConfig>("Mcp.OAuthConfig")({
|
|
46
|
-
client_id: Schema.String.pipe(optional),
|
|
47
|
-
client_secret: Schema.String.pipe(optional),
|
|
48
|
-
scope: Schema.String.pipe(optional),
|
|
49
|
-
callback_port: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 })).pipe(optional),
|
|
50
|
-
redirect_uri: Schema.String.pipe(optional),
|
|
51
|
-
auth_server_metadata_url: Schema.String.pipe(optional).annotate({
|
|
52
|
-
description:
|
|
53
|
-
"URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server.",
|
|
54
|
-
}),
|
|
55
|
-
}) {}
|
|
56
|
-
|
|
57
|
-
export class RemoteConfig extends Schema.Class<RemoteConfig>("Mcp.RemoteConfig")({
|
|
58
|
-
type: Schema.Literal("remote"),
|
|
59
|
-
url: Schema.String,
|
|
60
|
-
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
61
|
-
oauth: Schema.Union([OAuthConfig, Schema.Literal(false)]).pipe(optional),
|
|
62
|
-
disabled: Schema.Boolean.pipe(optional),
|
|
63
|
-
codemode: Schema.Boolean.pipe(optional).annotate({
|
|
64
|
-
description: "Expose this server's tools through Code Mode. Defaults to true.",
|
|
65
|
-
}),
|
|
66
|
-
timeout: TimeoutConfig.pipe(optional),
|
|
67
|
-
protocol: Protocol.pipe(optional),
|
|
68
|
-
pool: Schema.Boolean.pipe(optional).annotate({
|
|
69
|
-
description:
|
|
70
|
-
'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.',
|
|
71
|
-
}),
|
|
72
|
-
}) {}
|
|
73
|
-
|
|
74
|
-
export const ServerConfig = Schema.Union([LocalConfig, RemoteConfig]).pipe(Schema.toTaggedUnion("type"))
|
|
75
|
-
export type ServerConfig = typeof ServerConfig.Type
|
|
76
|
-
|
|
77
|
-
const Connected = Schema.Struct({ status: Schema.Literal("connected") }).annotate({
|
|
78
|
-
identifier: "Mcp.Status.Connected",
|
|
79
|
-
})
|
|
80
|
-
const Pending = Schema.Struct({ status: Schema.Literal("pending") }).annotate({
|
|
81
|
-
identifier: "Mcp.Status.Pending",
|
|
82
|
-
})
|
|
83
|
-
const Disabled = Schema.Struct({ status: Schema.Literal("disabled") }).annotate({
|
|
84
|
-
identifier: "Mcp.Status.Disabled",
|
|
85
|
-
})
|
|
86
|
-
const Failed = Schema.Struct({ status: Schema.Literal("failed"), error: Schema.String }).annotate({
|
|
87
|
-
identifier: "Mcp.Status.Failed",
|
|
88
|
-
})
|
|
89
|
-
const NeedsAuth = Schema.Struct({ status: Schema.Literal("needs_auth"), error: Schema.String }).annotate({
|
|
90
|
-
identifier: "Mcp.Status.NeedsAuth",
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
export type Status = typeof Status.Type
|
|
94
|
-
export const Status = Schema.Union([Connected, Pending, Disabled, Failed, NeedsAuth]).pipe(
|
|
95
|
-
Schema.toTaggedUnion("status"),
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* An MCP Events subscription: `pending` until its server confirms the stream, `active` while it does, and `ended` when
|
|
100
|
-
* the server terminated or rejected it, or no longer offers events. Pending covers a server that is not connected.
|
|
101
|
-
* Experimental: MCP Events is a draft extension; may change without compatibility guarantees.
|
|
102
|
-
*/
|
|
103
|
-
export const SubscriptionStatus = Schema.Union([
|
|
104
|
-
Schema.Struct({ status: Schema.Literal("pending") }),
|
|
105
|
-
Schema.Struct({ status: Schema.Literal("active") }),
|
|
106
|
-
Schema.Struct({ status: Schema.Literal("ended"), reason: Schema.Literal("unavailable") }),
|
|
107
|
-
Schema.Struct({
|
|
108
|
-
status: Schema.Literal("ended"),
|
|
109
|
-
reason: Schema.Literals(["terminated", "rejected"]),
|
|
110
|
-
error: Schema.Struct({ code: Schema.Number, message: Schema.String }),
|
|
111
|
-
}),
|
|
112
|
-
]).annotate({ identifier: "Mcp.SubscriptionStatus" })
|
|
113
|
-
export type SubscriptionStatus = typeof SubscriptionStatus.Type
|
|
114
|
-
|
|
115
|
-
export interface Server extends Schema.Schema.Type<typeof Server> {}
|
|
116
|
-
export const Server = Schema.Struct({
|
|
117
|
-
name: Schema.String,
|
|
118
|
-
status: Status,
|
|
119
|
-
// Display title from the connected server's `serverInfo.title`; absent while disconnected or when not provided.
|
|
120
|
-
title: optional(Schema.String),
|
|
121
|
-
// Set for remote servers registered as OAuth integrations; lets clients act on the right integration
|
|
122
|
-
// without matching by name, which could collide with provider or plugin integrations.
|
|
123
|
-
integrationID: optional(IntegrationID),
|
|
124
|
-
}).annotate({ identifier: "Mcp.Server" })
|
|
125
|
-
|
|
126
|
-
export interface Resource extends Schema.Schema.Type<typeof Resource> {}
|
|
127
|
-
export const Resource = Schema.Struct({
|
|
128
|
-
server: Schema.String,
|
|
129
|
-
name: Schema.String,
|
|
130
|
-
uri: Schema.String,
|
|
131
|
-
description: optional(Schema.String),
|
|
132
|
-
mimeType: optional(Schema.String),
|
|
133
|
-
}).annotate({ identifier: "Mcp.Resource" })
|
|
134
|
-
|
|
135
|
-
export interface ResourceTemplate extends Schema.Schema.Type<typeof ResourceTemplate> {}
|
|
136
|
-
export const ResourceTemplate = Schema.Struct({
|
|
137
|
-
server: Schema.String,
|
|
138
|
-
name: Schema.String,
|
|
139
|
-
uriTemplate: Schema.String,
|
|
140
|
-
description: optional(Schema.String),
|
|
141
|
-
mimeType: optional(Schema.String),
|
|
142
|
-
}).annotate({ identifier: "Mcp.ResourceTemplate" })
|
|
143
|
-
|
|
144
|
-
export interface ResourceCatalog extends Schema.Schema.Type<typeof ResourceCatalog> {}
|
|
145
|
-
export const ResourceCatalog = Schema.Struct({
|
|
146
|
-
resources: Schema.Array(Resource),
|
|
147
|
-
templates: Schema.Array(ResourceTemplate),
|
|
148
|
-
}).annotate({ identifier: "Mcp.ResourceCatalog" })
|
|
149
|
-
|
|
150
|
-
export const ResourceContentPart = Schema.Union([
|
|
151
|
-
Schema.Struct({
|
|
152
|
-
type: Schema.Literal("text"),
|
|
153
|
-
uri: Schema.String,
|
|
154
|
-
text: Schema.String,
|
|
155
|
-
mimeType: optional(Schema.String),
|
|
156
|
-
}),
|
|
157
|
-
Schema.Struct({
|
|
158
|
-
type: Schema.Literal("blob"),
|
|
159
|
-
uri: Schema.String,
|
|
160
|
-
blob: Schema.String,
|
|
161
|
-
mimeType: optional(Schema.String),
|
|
162
|
-
}),
|
|
163
|
-
]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Mcp.ResourceContentPart" }))
|
|
164
|
-
export type ResourceContentPart = typeof ResourceContentPart.Type
|
|
165
|
-
|
|
166
|
-
export interface ResourceContent extends Schema.Schema.Type<typeof ResourceContent> {}
|
|
167
|
-
export const ResourceContent = Schema.Struct({
|
|
168
|
-
server: Schema.String,
|
|
169
|
-
uri: Schema.String,
|
|
170
|
-
contents: Schema.Array(ResourceContentPart),
|
|
171
|
-
}).annotate({ identifier: "Mcp.ResourceContent" })
|
|
1
|
+
export * as Mcp from "./mcp.js"
|
|
2
|
+
|
|
3
|
+
import { Schema } from "effect"
|
|
4
|
+
import { optional, PositiveInt } from "./schema.js"
|
|
5
|
+
import { IntegrationID } from "./integration-id.js"
|
|
6
|
+
|
|
7
|
+
export class TimeoutConfig extends Schema.Class<TimeoutConfig>("Mcp.TimeoutConfig")({
|
|
8
|
+
startup: PositiveInt.pipe(optional).annotate({
|
|
9
|
+
description: "Maximum time in milliseconds to establish and initialize the MCP server.",
|
|
10
|
+
}),
|
|
11
|
+
catalog: PositiveInt.pipe(optional).annotate({
|
|
12
|
+
description: "Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.",
|
|
13
|
+
}),
|
|
14
|
+
execution: PositiveInt.pipe(optional).annotate({
|
|
15
|
+
description: "Maximum time in milliseconds to wait for MCP tool and prompt execution.",
|
|
16
|
+
}),
|
|
17
|
+
}) {}
|
|
18
|
+
|
|
19
|
+
export type Protocol = typeof Protocol.Type
|
|
20
|
+
export const Protocol = Schema.Literals(["legacy", "auto", "2026-07-28"]).annotate({
|
|
21
|
+
identifier: "Mcp.Protocol",
|
|
22
|
+
description:
|
|
23
|
+
'MCP protocol negotiation. "auto" (default) probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "legacy" opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "2026-07-28" requires that revision and fails otherwise.',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export class LocalConfig extends Schema.Class<LocalConfig>("Mcp.LocalConfig")({
|
|
27
|
+
type: Schema.Literal("local"),
|
|
28
|
+
command: Schema.String.pipe(Schema.Array),
|
|
29
|
+
cwd: Schema.String.pipe(optional).annotate({
|
|
30
|
+
description: "Working directory for the MCP server process. Relative paths resolve from the workspace directory.",
|
|
31
|
+
}),
|
|
32
|
+
environment: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
33
|
+
disabled: Schema.Boolean.pipe(optional),
|
|
34
|
+
codemode: Schema.Boolean.pipe(optional).annotate({
|
|
35
|
+
description: "Expose this server's tools through Code Mode. Defaults to true.",
|
|
36
|
+
}),
|
|
37
|
+
timeout: TimeoutConfig.pipe(optional),
|
|
38
|
+
protocol: Protocol.pipe(optional),
|
|
39
|
+
pool: Schema.Boolean.pipe(optional).annotate({
|
|
40
|
+
description:
|
|
41
|
+
'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.',
|
|
42
|
+
}),
|
|
43
|
+
}) {}
|
|
44
|
+
|
|
45
|
+
export class OAuthConfig extends Schema.Class<OAuthConfig>("Mcp.OAuthConfig")({
|
|
46
|
+
client_id: Schema.String.pipe(optional),
|
|
47
|
+
client_secret: Schema.String.pipe(optional),
|
|
48
|
+
scope: Schema.String.pipe(optional),
|
|
49
|
+
callback_port: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 })).pipe(optional),
|
|
50
|
+
redirect_uri: Schema.String.pipe(optional),
|
|
51
|
+
auth_server_metadata_url: Schema.String.pipe(optional).annotate({
|
|
52
|
+
description:
|
|
53
|
+
"URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server.",
|
|
54
|
+
}),
|
|
55
|
+
}) {}
|
|
56
|
+
|
|
57
|
+
export class RemoteConfig extends Schema.Class<RemoteConfig>("Mcp.RemoteConfig")({
|
|
58
|
+
type: Schema.Literal("remote"),
|
|
59
|
+
url: Schema.String,
|
|
60
|
+
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
|
61
|
+
oauth: Schema.Union([OAuthConfig, Schema.Literal(false)]).pipe(optional),
|
|
62
|
+
disabled: Schema.Boolean.pipe(optional),
|
|
63
|
+
codemode: Schema.Boolean.pipe(optional).annotate({
|
|
64
|
+
description: "Expose this server's tools through Code Mode. Defaults to true.",
|
|
65
|
+
}),
|
|
66
|
+
timeout: TimeoutConfig.pipe(optional),
|
|
67
|
+
protocol: Protocol.pipe(optional),
|
|
68
|
+
pool: Schema.Boolean.pipe(optional).annotate({
|
|
69
|
+
description:
|
|
70
|
+
'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.',
|
|
71
|
+
}),
|
|
72
|
+
}) {}
|
|
73
|
+
|
|
74
|
+
export const ServerConfig = Schema.Union([LocalConfig, RemoteConfig]).pipe(Schema.toTaggedUnion("type"))
|
|
75
|
+
export type ServerConfig = typeof ServerConfig.Type
|
|
76
|
+
|
|
77
|
+
const Connected = Schema.Struct({ status: Schema.Literal("connected") }).annotate({
|
|
78
|
+
identifier: "Mcp.Status.Connected",
|
|
79
|
+
})
|
|
80
|
+
const Pending = Schema.Struct({ status: Schema.Literal("pending") }).annotate({
|
|
81
|
+
identifier: "Mcp.Status.Pending",
|
|
82
|
+
})
|
|
83
|
+
const Disabled = Schema.Struct({ status: Schema.Literal("disabled") }).annotate({
|
|
84
|
+
identifier: "Mcp.Status.Disabled",
|
|
85
|
+
})
|
|
86
|
+
const Failed = Schema.Struct({ status: Schema.Literal("failed"), error: Schema.String }).annotate({
|
|
87
|
+
identifier: "Mcp.Status.Failed",
|
|
88
|
+
})
|
|
89
|
+
const NeedsAuth = Schema.Struct({ status: Schema.Literal("needs_auth"), error: Schema.String }).annotate({
|
|
90
|
+
identifier: "Mcp.Status.NeedsAuth",
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
export type Status = typeof Status.Type
|
|
94
|
+
export const Status = Schema.Union([Connected, Pending, Disabled, Failed, NeedsAuth]).pipe(
|
|
95
|
+
Schema.toTaggedUnion("status"),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* An MCP Events subscription: `pending` until its server confirms the stream, `active` while it does, and `ended` when
|
|
100
|
+
* the server terminated or rejected it, or no longer offers events. Pending covers a server that is not connected.
|
|
101
|
+
* Experimental: MCP Events is a draft extension; may change without compatibility guarantees.
|
|
102
|
+
*/
|
|
103
|
+
export const SubscriptionStatus = Schema.Union([
|
|
104
|
+
Schema.Struct({ status: Schema.Literal("pending") }),
|
|
105
|
+
Schema.Struct({ status: Schema.Literal("active") }),
|
|
106
|
+
Schema.Struct({ status: Schema.Literal("ended"), reason: Schema.Literal("unavailable") }),
|
|
107
|
+
Schema.Struct({
|
|
108
|
+
status: Schema.Literal("ended"),
|
|
109
|
+
reason: Schema.Literals(["terminated", "rejected"]),
|
|
110
|
+
error: Schema.Struct({ code: Schema.Number, message: Schema.String }),
|
|
111
|
+
}),
|
|
112
|
+
]).annotate({ identifier: "Mcp.SubscriptionStatus" })
|
|
113
|
+
export type SubscriptionStatus = typeof SubscriptionStatus.Type
|
|
114
|
+
|
|
115
|
+
export interface Server extends Schema.Schema.Type<typeof Server> {}
|
|
116
|
+
export const Server = Schema.Struct({
|
|
117
|
+
name: Schema.String,
|
|
118
|
+
status: Status,
|
|
119
|
+
// Display title from the connected server's `serverInfo.title`; absent while disconnected or when not provided.
|
|
120
|
+
title: optional(Schema.String),
|
|
121
|
+
// Set for remote servers registered as OAuth integrations; lets clients act on the right integration
|
|
122
|
+
// without matching by name, which could collide with provider or plugin integrations.
|
|
123
|
+
integrationID: optional(IntegrationID),
|
|
124
|
+
}).annotate({ identifier: "Mcp.Server" })
|
|
125
|
+
|
|
126
|
+
export interface Resource extends Schema.Schema.Type<typeof Resource> {}
|
|
127
|
+
export const Resource = Schema.Struct({
|
|
128
|
+
server: Schema.String,
|
|
129
|
+
name: Schema.String,
|
|
130
|
+
uri: Schema.String,
|
|
131
|
+
description: optional(Schema.String),
|
|
132
|
+
mimeType: optional(Schema.String),
|
|
133
|
+
}).annotate({ identifier: "Mcp.Resource" })
|
|
134
|
+
|
|
135
|
+
export interface ResourceTemplate extends Schema.Schema.Type<typeof ResourceTemplate> {}
|
|
136
|
+
export const ResourceTemplate = Schema.Struct({
|
|
137
|
+
server: Schema.String,
|
|
138
|
+
name: Schema.String,
|
|
139
|
+
uriTemplate: Schema.String,
|
|
140
|
+
description: optional(Schema.String),
|
|
141
|
+
mimeType: optional(Schema.String),
|
|
142
|
+
}).annotate({ identifier: "Mcp.ResourceTemplate" })
|
|
143
|
+
|
|
144
|
+
export interface ResourceCatalog extends Schema.Schema.Type<typeof ResourceCatalog> {}
|
|
145
|
+
export const ResourceCatalog = Schema.Struct({
|
|
146
|
+
resources: Schema.Array(Resource),
|
|
147
|
+
templates: Schema.Array(ResourceTemplate),
|
|
148
|
+
}).annotate({ identifier: "Mcp.ResourceCatalog" })
|
|
149
|
+
|
|
150
|
+
export const ResourceContentPart = Schema.Union([
|
|
151
|
+
Schema.Struct({
|
|
152
|
+
type: Schema.Literal("text"),
|
|
153
|
+
uri: Schema.String,
|
|
154
|
+
text: Schema.String,
|
|
155
|
+
mimeType: optional(Schema.String),
|
|
156
|
+
}),
|
|
157
|
+
Schema.Struct({
|
|
158
|
+
type: Schema.Literal("blob"),
|
|
159
|
+
uri: Schema.String,
|
|
160
|
+
blob: Schema.String,
|
|
161
|
+
mimeType: optional(Schema.String),
|
|
162
|
+
}),
|
|
163
|
+
]).pipe(Schema.toTaggedUnion("type"), Schema.annotate({ identifier: "Mcp.ResourceContentPart" }))
|
|
164
|
+
export type ResourceContentPart = typeof ResourceContentPart.Type
|
|
165
|
+
|
|
166
|
+
export interface ResourceContent extends Schema.Schema.Type<typeof ResourceContent> {}
|
|
167
|
+
export const ResourceContent = Schema.Struct({
|
|
168
|
+
server: Schema.String,
|
|
169
|
+
uri: Schema.String,
|
|
170
|
+
contents: Schema.Array(ResourceContentPart),
|
|
171
|
+
}).annotate({ identifier: "Mcp.ResourceContent" })
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { Schema, Struct } from "effect"
|
|
2
|
-
import { optional } from "./schema.js"
|
|
3
|
-
|
|
4
|
-
// Shared by model and provider schemas; kept separate because model.ts imports provider.ts.
|
|
5
|
-
export type ReasoningField = "reasoning" | "reasoning_content" | "reasoning_text" | (string & {})
|
|
6
|
-
export const ReasoningField: Schema.Codec<ReasoningField> = Schema.Union([
|
|
7
|
-
Schema.Literals(["reasoning", "reasoning_content", "reasoning_text"]),
|
|
8
|
-
Schema.String,
|
|
9
|
-
]).annotate({ identifier: "Model.ReasoningField" })
|
|
10
|
-
|
|
11
|
-
export const MaxTokensField = Schema.Literals(["max_completion_tokens", "max_tokens"]).annotate({
|
|
12
|
-
identifier: "Model.MaxTokensField",
|
|
13
|
-
})
|
|
14
|
-
export type MaxTokensField = typeof MaxTokensField.Type
|
|
15
|
-
|
|
16
|
-
/** Where a System One decision host reads media, from models.dev `compatibility.media_input`. */
|
|
17
|
-
export const MediaInput = Schema.Literals(["assets", "state", "root"]).annotate({
|
|
18
|
-
identifier: "Model.MediaInput",
|
|
19
|
-
})
|
|
20
|
-
export type MediaInput = typeof MediaInput.Type
|
|
21
|
-
|
|
22
|
-
export const CacheFormat = Schema.Literals(["anthropic", "alibaba"]).annotate({ identifier: "Model.CacheFormat" })
|
|
23
|
-
export type CacheFormat = typeof CacheFormat.Type
|
|
24
|
-
|
|
25
|
-
export interface Compatibility extends Schema.Schema.Type<typeof Compatibility> {}
|
|
26
|
-
export const Compatibility = Schema.Struct({
|
|
27
|
-
/** OpenAI Chat: assistant-message field that carries reasoning. Unset uses the streamed field, else `reasoning_content`. */
|
|
28
|
-
reasoningField: ReasoningField.pipe(optional),
|
|
29
|
-
/** OpenAI Chat: send the reasoning field on every prior assistant message, even when empty. */
|
|
30
|
-
requireReasoning: Schema.Boolean.pipe(optional),
|
|
31
|
-
/** OpenAI Chat: body field for the output token limit. Unset detects it from the provider. */
|
|
32
|
-
maxTokensField: MaxTokensField.pipe(optional),
|
|
33
|
-
/** OpenAI Chat: fail a stream that ends without `finish_reason`. Defaults to true. */
|
|
34
|
-
requireFinishReason: Schema.Boolean.pipe(optional),
|
|
35
|
-
/** OpenAI Chat: insert an assistant message between a tool result and the next user message. */
|
|
36
|
-
requireAssistantAfterTool: Schema.Boolean.pipe(optional),
|
|
37
|
-
/** OpenAI Chat, OpenAI Responses and Mistral: whether the endpoint accepts `prompt_cache_key`. */
|
|
38
|
-
supportsPromptCacheKey: Schema.Boolean.pipe(optional),
|
|
39
|
-
/** OpenAI Chat: request usage in the stream with `stream_options.include_usage`. Defaults to true. */
|
|
40
|
-
streamUsage: Schema.Boolean.pipe(optional),
|
|
41
|
-
/** Prompt-cache marker syntax the endpoint accepts. Overrides the route default; both send `cache_control`, and `alibaba` skips tool definitions. */
|
|
42
|
-
cacheFormat: CacheFormat.pipe(optional),
|
|
43
|
-
/** Anthropic Messages and Bedrock Converse: supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
44
|
-
supportsThinkingBlockBinding: Schema.Boolean.pipe(optional),
|
|
45
|
-
/** Anthropic Messages and OpenAI Responses: supports per-message effort updates. Overrides model-ID detection. */
|
|
46
|
-
supportsEffortUpdates: Schema.Boolean.pipe(optional),
|
|
47
|
-
/** System One: where the decision host reads media. Unset keeps the route default. */
|
|
48
|
-
mediaInput: MediaInput.pipe(optional),
|
|
49
|
-
}).annotate({ identifier: "Model.Compatibility" })
|
|
50
|
-
|
|
51
|
-
// Provider defaults inherited by its models. Model-version features stay model-only.
|
|
52
|
-
export interface ProviderCompatibility extends Schema.Schema.Type<typeof ProviderCompatibility> {}
|
|
53
|
-
export const ProviderCompatibility = Schema.Struct(
|
|
54
|
-
Struct.omit(Compatibility.fields, ["supportsThinkingBlockBinding", "supportsEffortUpdates"]),
|
|
55
|
-
).annotate({ identifier: "Provider.Compatibility" })
|
|
1
|
+
import { Schema, Struct } from "effect"
|
|
2
|
+
import { optional } from "./schema.js"
|
|
3
|
+
|
|
4
|
+
// Shared by model and provider schemas; kept separate because model.ts imports provider.ts.
|
|
5
|
+
export type ReasoningField = "reasoning" | "reasoning_content" | "reasoning_text" | (string & {})
|
|
6
|
+
export const ReasoningField: Schema.Codec<ReasoningField> = Schema.Union([
|
|
7
|
+
Schema.Literals(["reasoning", "reasoning_content", "reasoning_text"]),
|
|
8
|
+
Schema.String,
|
|
9
|
+
]).annotate({ identifier: "Model.ReasoningField" })
|
|
10
|
+
|
|
11
|
+
export const MaxTokensField = Schema.Literals(["max_completion_tokens", "max_tokens"]).annotate({
|
|
12
|
+
identifier: "Model.MaxTokensField",
|
|
13
|
+
})
|
|
14
|
+
export type MaxTokensField = typeof MaxTokensField.Type
|
|
15
|
+
|
|
16
|
+
/** Where a System One decision host reads media, from models.dev `compatibility.media_input`. */
|
|
17
|
+
export const MediaInput = Schema.Literals(["assets", "state", "root"]).annotate({
|
|
18
|
+
identifier: "Model.MediaInput",
|
|
19
|
+
})
|
|
20
|
+
export type MediaInput = typeof MediaInput.Type
|
|
21
|
+
|
|
22
|
+
export const CacheFormat = Schema.Literals(["anthropic", "alibaba"]).annotate({ identifier: "Model.CacheFormat" })
|
|
23
|
+
export type CacheFormat = typeof CacheFormat.Type
|
|
24
|
+
|
|
25
|
+
export interface Compatibility extends Schema.Schema.Type<typeof Compatibility> {}
|
|
26
|
+
export const Compatibility = Schema.Struct({
|
|
27
|
+
/** OpenAI Chat: assistant-message field that carries reasoning. Unset uses the streamed field, else `reasoning_content`. */
|
|
28
|
+
reasoningField: ReasoningField.pipe(optional),
|
|
29
|
+
/** OpenAI Chat: send the reasoning field on every prior assistant message, even when empty. */
|
|
30
|
+
requireReasoning: Schema.Boolean.pipe(optional),
|
|
31
|
+
/** OpenAI Chat: body field for the output token limit. Unset detects it from the provider. */
|
|
32
|
+
maxTokensField: MaxTokensField.pipe(optional),
|
|
33
|
+
/** OpenAI Chat: fail a stream that ends without `finish_reason`. Defaults to true. */
|
|
34
|
+
requireFinishReason: Schema.Boolean.pipe(optional),
|
|
35
|
+
/** OpenAI Chat: insert an assistant message between a tool result and the next user message. */
|
|
36
|
+
requireAssistantAfterTool: Schema.Boolean.pipe(optional),
|
|
37
|
+
/** OpenAI Chat, OpenAI Responses and Mistral: whether the endpoint accepts `prompt_cache_key`. */
|
|
38
|
+
supportsPromptCacheKey: Schema.Boolean.pipe(optional),
|
|
39
|
+
/** OpenAI Chat: request usage in the stream with `stream_options.include_usage`. Defaults to true. */
|
|
40
|
+
streamUsage: Schema.Boolean.pipe(optional),
|
|
41
|
+
/** Prompt-cache marker syntax the endpoint accepts. Overrides the route default; both send `cache_control`, and `alibaba` skips tool definitions. */
|
|
42
|
+
cacheFormat: CacheFormat.pipe(optional),
|
|
43
|
+
/** Anthropic Messages and Bedrock Converse: supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
|
|
44
|
+
supportsThinkingBlockBinding: Schema.Boolean.pipe(optional),
|
|
45
|
+
/** Anthropic Messages and OpenAI Responses: supports per-message effort updates. Overrides model-ID detection. */
|
|
46
|
+
supportsEffortUpdates: Schema.Boolean.pipe(optional),
|
|
47
|
+
/** System One: where the decision host reads media. Unset keeps the route default. */
|
|
48
|
+
mediaInput: MediaInput.pipe(optional),
|
|
49
|
+
}).annotate({ identifier: "Model.Compatibility" })
|
|
50
|
+
|
|
51
|
+
// Provider defaults inherited by its models. Model-version features stay model-only.
|
|
52
|
+
export interface ProviderCompatibility extends Schema.Schema.Type<typeof ProviderCompatibility> {}
|
|
53
|
+
export const ProviderCompatibility = Schema.Struct(
|
|
54
|
+
Struct.omit(Compatibility.fields, ["supportsThinkingBlockBinding", "supportsEffortUpdates"]),
|
|
55
|
+
).annotate({ identifier: "Provider.Compatibility" })
|