@opencode-ai/protocol 0.0.0-dev-17471
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +53 -0
- package/dist/api.js +73 -0
- package/dist/client.d.ts +61 -0
- package/dist/client.js +47 -0
- package/dist/errors.d.ts +133 -0
- package/dist/errors.js +105 -0
- package/dist/groups/agent.d.ts +194 -0
- package/dist/groups/agent.js +30 -0
- package/dist/groups/command.d.ts +63 -0
- package/dist/groups/command.js +20 -0
- package/dist/groups/config.d.ts +9 -0
- package/dist/groups/config.js +16 -0
- package/dist/groups/credential.d.ts +23 -0
- package/dist/groups/credential.js +29 -0
- package/dist/groups/debug.d.ts +17 -0
- package/dist/groups/debug.js +23 -0
- package/dist/groups/event.d.ts +12882 -0
- package/dist/groups/event.js +42 -0
- package/dist/groups/form.d.ts +781 -0
- package/dist/groups/form.js +97 -0
- package/dist/groups/fs.d.ts +35 -0
- package/dist/groups/fs.js +51 -0
- package/dist/groups/generate.d.ts +38 -0
- package/dist/groups/generate.js +27 -0
- package/dist/groups/health.d.ts +27 -0
- package/dist/groups/health.js +34 -0
- package/dist/groups/integration.d.ts +1152 -0
- package/dist/groups/integration.js +149 -0
- package/dist/groups/location.d.ts +16 -0
- package/dist/groups/location.js +34 -0
- package/dist/groups/mcp.d.ts +82 -0
- package/dist/groups/mcp.js +78 -0
- package/dist/groups/message.d.ts +592 -0
- package/dist/groups/message.js +37 -0
- package/dist/groups/migration.d.ts +28 -0
- package/dist/groups/migration.js +21 -0
- package/dist/groups/model.d.ts +218 -0
- package/dist/groups/model.js +33 -0
- package/dist/groups/permission.d.ts +153 -0
- package/dist/groups/permission.js +99 -0
- package/dist/groups/plugin.d.ts +14 -0
- package/dist/groups/plugin.js +20 -0
- package/dist/groups/project.d.ts +41 -0
- package/dist/groups/project.js +27 -0
- package/dist/groups/provider.d.ts +82 -0
- package/dist/groups/provider.js +34 -0
- package/dist/groups/pty.d.ts +145 -0
- package/dist/groups/pty.js +112 -0
- package/dist/groups/reference.d.ts +29 -0
- package/dist/groups/reference.js +20 -0
- package/dist/groups/server.d.ts +5 -0
- package/dist/groups/server.js +11 -0
- package/dist/groups/session.d.ts +9247 -0
- package/dist/groups/session.js +515 -0
- package/dist/groups/shell.d.ts +152 -0
- package/dist/groups/shell.js +82 -0
- package/dist/groups/skill.d.ts +20 -0
- package/dist/groups/skill.js +20 -0
- package/dist/groups/vcs.d.ts +46 -0
- package/dist/groups/vcs.js +47 -0
- package/dist/groups/websearch.d.ts +28 -0
- package/dist/groups/websearch.js +34 -0
- package/dist/groups/worktree.d.ts +42 -0
- package/dist/groups/worktree.js +54 -0
- package/dist/middleware/authorization.d.ts +13 -0
- package/dist/middleware/authorization.js +6 -0
- package/dist/middleware/schema-error.d.ts +13 -0
- package/dist/middleware/schema-error.js +4 -0
- package/dist/simulation.d.ts +1590 -0
- package/dist/simulation.js +460 -0
- package/package.json +44 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Integration } from "@opencode-ai/schema/integration";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Form } from "@opencode-ai/schema/form";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
6
|
+
import { InvalidRequestError } from "../errors.js";
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
|
+
export const IntegrationGroup = HttpApiGroup.make("server.integration")
|
|
9
|
+
.add(HttpApiEndpoint.get("integration.list", "/api/integration", {
|
|
10
|
+
query: LocationQuery,
|
|
11
|
+
success: Location.response(Schema.Array(Integration.Info)),
|
|
12
|
+
})
|
|
13
|
+
.annotateMerge(locationQueryOpenApi)
|
|
14
|
+
.annotateMerge(OpenApi.annotations({
|
|
15
|
+
identifier: "v2.integration.list",
|
|
16
|
+
summary: "List integrations",
|
|
17
|
+
description: "Retrieve available integrations and their authentication methods.",
|
|
18
|
+
})))
|
|
19
|
+
.add(HttpApiEndpoint.get("integration.get", "/api/integration/:integrationID", {
|
|
20
|
+
params: { integrationID: Integration.ID },
|
|
21
|
+
query: LocationQuery,
|
|
22
|
+
success: Location.response(Schema.UndefinedOr(Integration.Info)),
|
|
23
|
+
})
|
|
24
|
+
.annotateMerge(locationQueryOpenApi)
|
|
25
|
+
.annotateMerge(OpenApi.annotations({
|
|
26
|
+
identifier: "v2.integration.get",
|
|
27
|
+
summary: "Get integration",
|
|
28
|
+
description: "Retrieve one integration and its authentication methods.",
|
|
29
|
+
})))
|
|
30
|
+
.add(HttpApiEndpoint.post("integration.wellknown.add", "/api/experimental/integration/wellknown", {
|
|
31
|
+
query: LocationQuery,
|
|
32
|
+
payload: Schema.Struct({ url: Schema.String }),
|
|
33
|
+
success: HttpApiSchema.NoContent,
|
|
34
|
+
error: InvalidRequestError,
|
|
35
|
+
})
|
|
36
|
+
.annotateMerge(locationQueryOpenApi)
|
|
37
|
+
.annotateMerge(OpenApi.annotations({
|
|
38
|
+
identifier: "v2.experimental.integration.wellknown.add",
|
|
39
|
+
summary: "Add wellknown integration",
|
|
40
|
+
description: "Discover and persist an experimental wellknown integration source.",
|
|
41
|
+
})))
|
|
42
|
+
.add(HttpApiEndpoint.post("integration.connect.key", "/api/integration/:integrationID/connect/key", {
|
|
43
|
+
params: { integrationID: Integration.ID },
|
|
44
|
+
query: LocationQuery,
|
|
45
|
+
payload: Schema.Struct({
|
|
46
|
+
key: Schema.String,
|
|
47
|
+
answer: Schema.optional(Form.Answer),
|
|
48
|
+
label: Schema.optional(Schema.String),
|
|
49
|
+
}),
|
|
50
|
+
success: HttpApiSchema.NoContent,
|
|
51
|
+
error: InvalidRequestError,
|
|
52
|
+
})
|
|
53
|
+
.annotateMerge(locationQueryOpenApi)
|
|
54
|
+
.annotateMerge(OpenApi.annotations({
|
|
55
|
+
identifier: "v2.integration.connect.key",
|
|
56
|
+
summary: "Connect with key",
|
|
57
|
+
description: "Run a key authentication method and store the resulting credential.",
|
|
58
|
+
})))
|
|
59
|
+
.add(HttpApiEndpoint.post("integration.oauth.connect", "/api/integration/:integrationID/connect/oauth", {
|
|
60
|
+
params: { integrationID: Integration.ID },
|
|
61
|
+
query: LocationQuery,
|
|
62
|
+
payload: Schema.Struct({
|
|
63
|
+
methodID: Integration.MethodID,
|
|
64
|
+
answer: Schema.optional(Form.Answer),
|
|
65
|
+
label: Schema.optional(Schema.String),
|
|
66
|
+
}),
|
|
67
|
+
success: Location.response(Integration.Attempt),
|
|
68
|
+
error: InvalidRequestError,
|
|
69
|
+
})
|
|
70
|
+
.annotateMerge(locationQueryOpenApi)
|
|
71
|
+
.annotateMerge(OpenApi.annotations({
|
|
72
|
+
identifier: "v2.integration.oauth.connect",
|
|
73
|
+
summary: "Begin OAuth connection",
|
|
74
|
+
description: "Start an OAuth attempt and return the authorization details.",
|
|
75
|
+
})))
|
|
76
|
+
.add(HttpApiEndpoint.get("integration.oauth.status", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
77
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
78
|
+
query: LocationQuery,
|
|
79
|
+
success: Location.response(Integration.AttemptStatus),
|
|
80
|
+
})
|
|
81
|
+
.annotateMerge(locationQueryOpenApi)
|
|
82
|
+
.annotateMerge(OpenApi.annotations({
|
|
83
|
+
identifier: "v2.integration.oauth.status",
|
|
84
|
+
summary: "Get OAuth attempt status",
|
|
85
|
+
description: "Poll the current status of an OAuth attempt.",
|
|
86
|
+
})))
|
|
87
|
+
.add(HttpApiEndpoint.post("integration.oauth.complete", "/api/integration/:integrationID/connect/oauth/:attemptID/complete", {
|
|
88
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
89
|
+
query: LocationQuery,
|
|
90
|
+
payload: Schema.Struct({ code: Schema.optional(Schema.String) }),
|
|
91
|
+
success: HttpApiSchema.NoContent,
|
|
92
|
+
error: InvalidRequestError,
|
|
93
|
+
})
|
|
94
|
+
.annotateMerge(locationQueryOpenApi)
|
|
95
|
+
.annotateMerge(OpenApi.annotations({
|
|
96
|
+
identifier: "v2.integration.oauth.complete",
|
|
97
|
+
summary: "Complete OAuth connection",
|
|
98
|
+
description: "Complete a code-based OAuth attempt and store the resulting credential.",
|
|
99
|
+
})))
|
|
100
|
+
.add(HttpApiEndpoint.delete("integration.oauth.cancel", "/api/integration/:integrationID/connect/oauth/:attemptID", {
|
|
101
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
102
|
+
query: LocationQuery,
|
|
103
|
+
success: HttpApiSchema.NoContent,
|
|
104
|
+
})
|
|
105
|
+
.annotateMerge(locationQueryOpenApi)
|
|
106
|
+
.annotateMerge(OpenApi.annotations({
|
|
107
|
+
identifier: "v2.integration.oauth.cancel",
|
|
108
|
+
summary: "Cancel OAuth connection",
|
|
109
|
+
description: "Cancel an OAuth attempt and release its resources.",
|
|
110
|
+
})))
|
|
111
|
+
.add(HttpApiEndpoint.post("integration.command.connect", "/api/integration/:integrationID/connect/command", {
|
|
112
|
+
params: { integrationID: Integration.ID },
|
|
113
|
+
query: LocationQuery,
|
|
114
|
+
payload: Schema.Struct({
|
|
115
|
+
methodID: Integration.MethodID,
|
|
116
|
+
label: Schema.optional(Schema.String),
|
|
117
|
+
}),
|
|
118
|
+
success: Location.response(Integration.CommandAttempt),
|
|
119
|
+
error: InvalidRequestError,
|
|
120
|
+
})
|
|
121
|
+
.annotateMerge(locationQueryOpenApi)
|
|
122
|
+
.annotateMerge(OpenApi.annotations({
|
|
123
|
+
identifier: "v2.integration.command.connect",
|
|
124
|
+
summary: "Begin command connection",
|
|
125
|
+
description: "Start a command authentication attempt.",
|
|
126
|
+
})))
|
|
127
|
+
.add(HttpApiEndpoint.get("integration.command.status", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
128
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
129
|
+
query: LocationQuery,
|
|
130
|
+
success: Location.response(Integration.CommandAttemptStatus),
|
|
131
|
+
})
|
|
132
|
+
.annotateMerge(locationQueryOpenApi)
|
|
133
|
+
.annotateMerge(OpenApi.annotations({
|
|
134
|
+
identifier: "v2.integration.command.status",
|
|
135
|
+
summary: "Get command attempt status",
|
|
136
|
+
description: "Poll the current status and output of a command authentication attempt.",
|
|
137
|
+
})))
|
|
138
|
+
.add(HttpApiEndpoint.delete("integration.command.cancel", "/api/integration/:integrationID/connect/command/:attemptID", {
|
|
139
|
+
params: { integrationID: Integration.ID, attemptID: Integration.AttemptID },
|
|
140
|
+
query: LocationQuery,
|
|
141
|
+
success: HttpApiSchema.NoContent,
|
|
142
|
+
})
|
|
143
|
+
.annotateMerge(locationQueryOpenApi)
|
|
144
|
+
.annotateMerge(OpenApi.annotations({
|
|
145
|
+
identifier: "v2.integration.command.cancel",
|
|
146
|
+
summary: "Cancel command connection",
|
|
147
|
+
description: "Cancel a command authentication attempt and terminate its process.",
|
|
148
|
+
})))
|
|
149
|
+
.annotateMerge(OpenApi.annotations({ title: "integration", description: "Integration discovery and authentication routes." }));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
4
|
+
export declare const LocationQuery: Schema.Struct<{
|
|
5
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
6
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
7
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
8
|
+
}>>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const locationQueryOpenApi: import("effect/Context").Context<never>;
|
|
11
|
+
export declare const LocationGroup: HttpApiGroup.HttpApiGroup<"server.location", HttpApiEndpoint.HttpApiEndpoint<"location.get", "GET", "/api/location", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
12
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
13
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
14
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
15
|
+
}>>;
|
|
16
|
+
}>>, never, never, Schema.toCodecJson<typeof Location.Info>, never, never, never>, false>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
4
|
+
export const LocationQuery = Schema.Struct({
|
|
5
|
+
location: Schema.optional(Schema.Struct({
|
|
6
|
+
directory: Schema.optional(Schema.String),
|
|
7
|
+
workspace: Schema.optional(Schema.String),
|
|
8
|
+
})),
|
|
9
|
+
}).annotate({ identifier: "LocationQuery" });
|
|
10
|
+
export const locationQueryOpenApi = OpenApi.annotations({
|
|
11
|
+
transform: (operation) => {
|
|
12
|
+
const parameters = operation.parameters;
|
|
13
|
+
if (!Array.isArray(parameters))
|
|
14
|
+
return operation;
|
|
15
|
+
return {
|
|
16
|
+
...operation,
|
|
17
|
+
parameters: parameters.map((parameter) => parameter?.name === "location" && parameter?.in === "query"
|
|
18
|
+
? { ...parameter, style: "deepObject", explode: true }
|
|
19
|
+
: parameter),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
export const LocationGroup = HttpApiGroup.make("server.location")
|
|
24
|
+
.add(HttpApiEndpoint.get("location.get", "/api/location", {
|
|
25
|
+
query: LocationQuery,
|
|
26
|
+
success: Location.Info,
|
|
27
|
+
})
|
|
28
|
+
.annotateMerge(locationQueryOpenApi)
|
|
29
|
+
.annotateMerge(OpenApi.annotations({
|
|
30
|
+
identifier: "v2.location.get",
|
|
31
|
+
summary: "Get location",
|
|
32
|
+
description: "Resolve the requested location or the server default location.",
|
|
33
|
+
})))
|
|
34
|
+
.annotateMerge(OpenApi.annotations({ title: "location" }));
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Mcp } from "@opencode-ai/schema/mcp";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
|
|
5
|
+
import { McpServerNotFoundError } from "../errors.js";
|
|
6
|
+
export declare const McpGroup: HttpApiGroup.HttpApiGroup<"server.mcp", HttpApiEndpoint.HttpApiEndpoint<"mcp.list", "GET", "/api/mcp", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
7
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
8
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
9
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
10
|
+
}>>;
|
|
11
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
12
|
+
readonly location: typeof Location.Info;
|
|
13
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
14
|
+
readonly name: Schema.String;
|
|
15
|
+
readonly status: Schema.toTaggedUnion<"status", readonly [Schema.Struct<{
|
|
16
|
+
readonly status: Schema.Literal<"connected">;
|
|
17
|
+
}>, Schema.Struct<{
|
|
18
|
+
readonly status: Schema.Literal<"pending">;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly status: Schema.Literal<"disabled">;
|
|
21
|
+
}>, Schema.Struct<{
|
|
22
|
+
readonly status: Schema.Literal<"failed">;
|
|
23
|
+
readonly error: Schema.String;
|
|
24
|
+
}>, Schema.Struct<{
|
|
25
|
+
readonly status: Schema.Literal<"needs_auth">;
|
|
26
|
+
}>]>;
|
|
27
|
+
readonly integrationID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Integration.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Integration.ID">>, never, never>;
|
|
28
|
+
}>>;
|
|
29
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mcp.add", "PUT", "/api/mcp/:server", Schema.toCodecStringTree<Schema.Struct<{
|
|
30
|
+
server: Schema.String;
|
|
31
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
32
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
33
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
34
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
35
|
+
}>>;
|
|
36
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
37
|
+
readonly config: Schema.toTaggedUnion<"type", readonly [typeof Mcp.LocalConfig, typeof Mcp.RemoteConfig]>;
|
|
38
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mcp.remove", "DELETE", "/api/mcp/:server", Schema.toCodecStringTree<Schema.Struct<{
|
|
39
|
+
server: Schema.String;
|
|
40
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
41
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
42
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
43
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
44
|
+
}>>;
|
|
45
|
+
}>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof McpServerNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mcp.connect", "POST", "/api/mcp/:server/connect", Schema.toCodecStringTree<Schema.Struct<{
|
|
46
|
+
server: Schema.String;
|
|
47
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
48
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
49
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
50
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
51
|
+
}>>;
|
|
52
|
+
}>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof McpServerNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mcp.disconnect", "POST", "/api/mcp/:server/disconnect", Schema.toCodecStringTree<Schema.Struct<{
|
|
53
|
+
server: Schema.String;
|
|
54
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
55
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
56
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
57
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
58
|
+
}>>;
|
|
59
|
+
}>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof McpServerNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"mcp.resource.catalog", "GET", "/api/mcp/resource", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
60
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
61
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
62
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
63
|
+
}>>;
|
|
64
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
65
|
+
readonly location: typeof Location.Info;
|
|
66
|
+
readonly data: Schema.Struct<{
|
|
67
|
+
readonly resources: Schema.$Array<Schema.Struct<{
|
|
68
|
+
readonly server: Schema.String;
|
|
69
|
+
readonly name: Schema.String;
|
|
70
|
+
readonly uri: Schema.String;
|
|
71
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
72
|
+
readonly mimeType: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
73
|
+
}>>;
|
|
74
|
+
readonly templates: Schema.$Array<Schema.Struct<{
|
|
75
|
+
readonly server: Schema.String;
|
|
76
|
+
readonly name: Schema.String;
|
|
77
|
+
readonly uriTemplate: Schema.String;
|
|
78
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
79
|
+
readonly mimeType: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
80
|
+
}>>;
|
|
81
|
+
}>;
|
|
82
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Mcp } from "@opencode-ai/schema/mcp";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
import { McpServerNotFoundError } from "../errors.js";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
export const McpGroup = HttpApiGroup.make("server.mcp")
|
|
8
|
+
.add(HttpApiEndpoint.get("mcp.list", "/api/mcp", {
|
|
9
|
+
query: LocationQuery,
|
|
10
|
+
success: Location.response(Schema.Array(Mcp.Server)),
|
|
11
|
+
})
|
|
12
|
+
.annotateMerge(locationQueryOpenApi)
|
|
13
|
+
.annotateMerge(OpenApi.annotations({
|
|
14
|
+
identifier: "v2.mcp.list",
|
|
15
|
+
summary: "List MCP servers",
|
|
16
|
+
description: "Retrieve configured MCP servers and their connection status.",
|
|
17
|
+
})))
|
|
18
|
+
.add(HttpApiEndpoint.put("mcp.add", "/api/mcp/:server", {
|
|
19
|
+
params: { server: Schema.String },
|
|
20
|
+
query: LocationQuery,
|
|
21
|
+
// Wrapped in a struct because the client codegen flattens payload fields and cannot
|
|
22
|
+
// represent a top-level union payload.
|
|
23
|
+
payload: Schema.Struct({ config: Mcp.ServerConfig }),
|
|
24
|
+
success: HttpApiSchema.NoContent,
|
|
25
|
+
})
|
|
26
|
+
.annotateMerge(locationQueryOpenApi)
|
|
27
|
+
.annotateMerge(OpenApi.annotations({
|
|
28
|
+
identifier: "v2.mcp.add",
|
|
29
|
+
summary: "Add MCP server",
|
|
30
|
+
description: "Add an MCP server at runtime or replace an existing one, connecting it immediately.",
|
|
31
|
+
})))
|
|
32
|
+
.add(HttpApiEndpoint.delete("mcp.remove", "/api/mcp/:server", {
|
|
33
|
+
params: { server: Schema.String },
|
|
34
|
+
query: LocationQuery,
|
|
35
|
+
success: HttpApiSchema.NoContent,
|
|
36
|
+
error: McpServerNotFoundError,
|
|
37
|
+
})
|
|
38
|
+
.annotateMerge(locationQueryOpenApi)
|
|
39
|
+
.annotateMerge(OpenApi.annotations({
|
|
40
|
+
identifier: "v2.mcp.remove",
|
|
41
|
+
summary: "Remove MCP server",
|
|
42
|
+
description: "Stop an MCP server and remove it from the runtime set until restart.",
|
|
43
|
+
})))
|
|
44
|
+
.add(HttpApiEndpoint.post("mcp.connect", "/api/mcp/:server/connect", {
|
|
45
|
+
params: { server: Schema.String },
|
|
46
|
+
query: LocationQuery,
|
|
47
|
+
success: HttpApiSchema.NoContent,
|
|
48
|
+
error: McpServerNotFoundError,
|
|
49
|
+
})
|
|
50
|
+
.annotateMerge(locationQueryOpenApi)
|
|
51
|
+
.annotateMerge(OpenApi.annotations({
|
|
52
|
+
identifier: "v2.mcp.connect",
|
|
53
|
+
summary: "Connect MCP server",
|
|
54
|
+
description: "Connect an MCP server at runtime, overriding a disabled configuration until restart.",
|
|
55
|
+
})))
|
|
56
|
+
.add(HttpApiEndpoint.post("mcp.disconnect", "/api/mcp/:server/disconnect", {
|
|
57
|
+
params: { server: Schema.String },
|
|
58
|
+
query: LocationQuery,
|
|
59
|
+
success: HttpApiSchema.NoContent,
|
|
60
|
+
error: McpServerNotFoundError,
|
|
61
|
+
})
|
|
62
|
+
.annotateMerge(locationQueryOpenApi)
|
|
63
|
+
.annotateMerge(OpenApi.annotations({
|
|
64
|
+
identifier: "v2.mcp.disconnect",
|
|
65
|
+
summary: "Disconnect MCP server",
|
|
66
|
+
description: "Disconnect an MCP server at runtime, removing its tools until reconnected.",
|
|
67
|
+
})))
|
|
68
|
+
.add(HttpApiEndpoint.get("mcp.resource.catalog", "/api/mcp/resource", {
|
|
69
|
+
query: LocationQuery,
|
|
70
|
+
success: Location.response(Mcp.ResourceCatalog),
|
|
71
|
+
})
|
|
72
|
+
.annotateMerge(locationQueryOpenApi)
|
|
73
|
+
.annotateMerge(OpenApi.annotations({
|
|
74
|
+
identifier: "v2.mcp.resource.catalog",
|
|
75
|
+
summary: "List MCP resources",
|
|
76
|
+
description: "Retrieve resources and resource templates from connected MCP servers.",
|
|
77
|
+
})))
|
|
78
|
+
.annotateMerge(OpenApi.annotations({ title: "mcp", description: "MCP server and resource routes." }));
|