Repository navigation
Expand file tree
/
Copy pathplugin.ts
More file actions
80 lines (79 loc) · 2.94 KB
/
Copy pathplugin.ts
File metadata and controls
80 lines (79 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Location } from "@opencode/schema/location"
import { Plugin } from "@opencode/schema/plugin"
import { Schema } from "effect"
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "../errors.js"
import { LocationQuery, locationQueryOpenApi } from "./location.js"
export const PluginGroup = HttpApiGroup.make("server.plugin")
.add(
HttpApiEndpoint.get("plugin.list", "/api/plugin", {
query: LocationQuery,
success: Location.response(Schema.Array(Plugin.Info)),
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "plugin.list",
summary: "List plugins",
description: "Retrieve enabled server plugins and their current status.",
}),
),
)
.add(
HttpApiEndpoint.get("plugin.gui", "/api/plugin/gui", {
query: Schema.Struct({
...LocationQuery.fields,
id: Plugin.ID,
}),
success: Location.response(Plugin.GuiBundle),
error: PluginNotFoundError,
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "plugin.gui",
summary: "Read plugin GUI bundle",
description:
"Read an active plugin's prebuilt CommonJS `./gui-experimental` bundle. Desktop app windows run its default export; the desktop app's main process runs its `main` export. Fails with not found when no active plugin has the id or the plugin exports no `./gui-experimental`.",
}),
),
)
.add(
HttpApiEndpoint.post("plugin.check", "/api/plugin/check", {
query: LocationQuery,
payload: Schema.Struct({ target: Schema.String.pipe(Schema.optional) }),
success: Location.response(Schema.Array(Plugin.Info)),
error: InvalidRequestError,
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "plugin.check",
summary: "Check plugin updates",
description: "Check one or all package plugins for available updates.",
}),
),
)
.add(
HttpApiEndpoint.post("plugin.update", "/api/plugin/update", {
query: LocationQuery,
payload: Schema.Struct({ targets: Schema.Array(Schema.String) }),
success: HttpApiSchema.NoContent,
error: [InvalidRequestError, ServiceUnavailableError],
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
OpenApi.annotations({
identifier: "plugin.update",
summary: "Update plugins",
description:
"Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.",
}),
),
)
.annotateMerge(
OpenApi.annotations({
title: "plugin",
description: "Experimental plugin routes.",
}),
)