@radheim/protocol 0.0.0-stage → 2.4.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/dist/api.d.ts +60 -0
- package/dist/api.js +81 -0
- package/dist/client.d.ts +69 -0
- package/dist/client.js +102 -0
- package/dist/errors.d.ts +273 -0
- package/dist/errors.js +227 -0
- package/dist/groups/agent.d.ts +299 -0
- package/dist/groups/agent.js +30 -0
- package/dist/groups/artifact.d.ts +173 -0
- package/dist/groups/artifact.js +80 -0
- package/dist/groups/automation.d.ts +480 -0
- package/dist/groups/automation.js +55 -0
- package/dist/groups/blob.d.ts +415 -0
- package/dist/groups/blob.js +79 -0
- package/dist/groups/command.d.ts +15 -0
- package/dist/groups/command.js +20 -0
- package/dist/groups/config.d.ts +27 -0
- package/dist/groups/config.js +32 -0
- package/dist/groups/credential.d.ts +93 -0
- package/dist/groups/credential.js +50 -0
- package/dist/groups/debug.d.ts +22 -0
- package/dist/groups/debug.js +49 -0
- package/dist/groups/event.d.ts +16442 -0
- package/dist/groups/event.js +68 -0
- package/dist/groups/experimental/browser-tunnel.d.ts +20 -0
- package/dist/groups/experimental/browser-tunnel.js +29 -0
- package/dist/groups/experimental.d.ts +1519 -0
- package/dist/groups/experimental.js +12 -0
- package/dist/groups/flag.d.ts +12 -0
- package/dist/groups/flag.js +19 -0
- package/dist/groups/form.d.ts +138 -0
- package/dist/groups/form.js +18 -0
- package/dist/groups/fs.d.ts +60 -0
- package/dist/groups/fs.js +101 -0
- package/dist/groups/generate.d.ts +397 -0
- package/dist/groups/generate.js +77 -0
- package/dist/groups/integration.d.ts +1724 -0
- package/dist/groups/integration.js +169 -0
- package/dist/groups/job.d.ts +95 -0
- package/dist/groups/job.js +45 -0
- package/dist/groups/location.d.ts +23 -0
- package/dist/groups/location.js +47 -0
- package/dist/groups/machine.d.ts +91 -0
- package/dist/groups/machine.js +61 -0
- package/dist/groups/mcp.d.ts +104 -0
- package/dist/groups/mcp.js +125 -0
- package/dist/groups/media.d.ts +8 -0
- package/dist/groups/media.js +18 -0
- package/dist/groups/message.d.ts +3696 -0
- package/dist/groups/message.js +102 -0
- package/dist/groups/migration.d.ts +28 -0
- package/dist/groups/migration.js +21 -0
- package/dist/groups/model.d.ts +536 -0
- package/dist/groups/model.js +39 -0
- package/dist/groups/permission.d.ts +175 -0
- package/dist/groups/permission.js +115 -0
- package/dist/groups/persistent-pty.d.ts +251 -0
- package/dist/groups/persistent-pty.js +109 -0
- package/dist/groups/plugin.d.ts +102 -0
- package/dist/groups/plugin.js +59 -0
- package/dist/groups/project.d.ts +83 -0
- package/dist/groups/project.js +37 -0
- package/dist/groups/provider.d.ts +354 -0
- package/dist/groups/provider.js +34 -0
- package/dist/groups/pty.d.ts +151 -0
- package/dist/groups/pty.js +117 -0
- package/dist/groups/push.d.ts +123 -0
- package/dist/groups/push.js +60 -0
- package/dist/groups/reference.d.ts +25 -0
- package/dist/groups/reference.js +33 -0
- package/dist/groups/rpc.d.ts +21 -0
- package/dist/groups/rpc.js +24 -0
- package/dist/groups/server.d.ts +46 -0
- package/dist/groups/server.js +55 -0
- package/dist/groups/session.d.ts +11874 -0
- package/dist/groups/session.js +663 -0
- package/dist/groups/shell.d.ts +125 -0
- package/dist/groups/shell.js +65 -0
- package/dist/groups/skill.d.ts +26 -0
- package/dist/groups/skill.js +34 -0
- package/dist/groups/space.d.ts +56 -0
- package/dist/groups/space.js +59 -0
- package/dist/groups/usage.d.ts +96 -0
- package/dist/groups/usage.js +22 -0
- package/dist/groups/vcs.d.ts +89 -0
- package/dist/groups/vcs.js +94 -0
- package/dist/groups/voice.d.ts +81 -0
- package/dist/groups/voice.js +75 -0
- package/dist/groups/websearch.d.ts +29 -0
- package/dist/groups/websearch.js +34 -0
- package/dist/groups/worktree.d.ts +41 -0
- package/dist/groups/worktree.js +52 -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/image.d.ts +35 -0
- package/dist/simulation/image.js +21 -0
- package/dist/simulation/terminal.d.ts +81 -0
- package/dist/simulation/terminal.js +49 -0
- package/dist/simulation.d.ts +1784 -0
- package/dist/simulation.js +485 -0
- package/package.json +46 -4
- package/README.md +0 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PersistentPty } from "@radheim/schema/persistent-pty";
|
|
2
|
+
import { Pty } from "@radheim/schema/pty";
|
|
3
|
+
import { PtyTicket } from "@radheim/schema/pty-ticket";
|
|
4
|
+
import { Session } from "@radheim/schema/session";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
7
|
+
import { ForbiddenError, InvalidRequestError, PtyFeatureUnsupportedError, PtyNotFoundError, ServiceUnavailableError, } from "../errors.js";
|
|
8
|
+
import { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE } from "./pty.js";
|
|
9
|
+
export { PTY_CONNECT_TICKET_QUERY, PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE };
|
|
10
|
+
export const PERSISTENT_PTY_CONNECT_PATH = "/api/experimental/persistent-pty/:ptyID/connect";
|
|
11
|
+
const PERSISTENT_PTY_CONNECT_URL = /^\/api\/experimental\/persistent-pty\/[^/]+\/connect$/;
|
|
12
|
+
export function hasPersistentPtyConnectTicketURL(url) {
|
|
13
|
+
return PERSISTENT_PTY_CONNECT_URL.test(url.pathname) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY);
|
|
14
|
+
}
|
|
15
|
+
const errors = [InvalidRequestError, ServiceUnavailableError];
|
|
16
|
+
const terminalErrors = [PtyNotFoundError, ServiceUnavailableError];
|
|
17
|
+
export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
|
18
|
+
.add(HttpApiEndpoint.get("persistentPty.read", "/api/experimental/session/:sessionID/terminal/read", {
|
|
19
|
+
params: { sessionID: Session.ID },
|
|
20
|
+
query: {
|
|
21
|
+
lines: Schema.NumberFromString.pipe(Schema.decodeTo(PersistentPty.ReadLines), Schema.optional).annotateKey({
|
|
22
|
+
description: "Number of trailing rows to read, up to 65535. Defaults to the live terminal height; larger counts include retained history.",
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
success: Schema.Struct({ data: Schema.NullOr(PersistentPty.ReadResult) }),
|
|
26
|
+
error: [ServiceUnavailableError],
|
|
27
|
+
}).annotateMerge(OpenApi.annotations({
|
|
28
|
+
identifier: "experimental.persistentPty.read",
|
|
29
|
+
summary: "Read the session's most recently controlled terminal",
|
|
30
|
+
description: "Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.",
|
|
31
|
+
})))
|
|
32
|
+
.add(HttpApiEndpoint.get("persistentPty.list", "/api/experimental/session/:sessionID/terminal", {
|
|
33
|
+
params: { sessionID: Session.ID },
|
|
34
|
+
success: Schema.Struct({ data: Schema.Array(PersistentPty.Info) }),
|
|
35
|
+
error: errors,
|
|
36
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.list" })))
|
|
37
|
+
.add(HttpApiEndpoint.post("persistentPty.create", "/api/experimental/session/:sessionID/terminal", {
|
|
38
|
+
params: { sessionID: Session.ID },
|
|
39
|
+
payload: PersistentPty.CreateInput,
|
|
40
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
41
|
+
error: errors,
|
|
42
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.create" })))
|
|
43
|
+
.add(HttpApiEndpoint.post("persistentPty.shutdown", "/api/experimental/persistent-pty/shutdown", {
|
|
44
|
+
success: HttpApiSchema.NoContent,
|
|
45
|
+
error: [ServiceUnavailableError],
|
|
46
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.shutdown" })))
|
|
47
|
+
.add(HttpApiEndpoint.post("persistentPty.handoff", "/api/experimental/persistent-pty/handoff", {
|
|
48
|
+
success: Schema.Struct({ handoff: Schema.NullOr(PersistentPty.Handoff) }),
|
|
49
|
+
error: [ServiceUnavailableError],
|
|
50
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.handoff" })))
|
|
51
|
+
.add(HttpApiEndpoint.get("persistentPty.get", "/api/experimental/persistent-pty/:ptyID", {
|
|
52
|
+
params: { ptyID: Pty.ID },
|
|
53
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
54
|
+
error: terminalErrors,
|
|
55
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.get" })))
|
|
56
|
+
.add(HttpApiEndpoint.put("persistentPty.update", "/api/experimental/persistent-pty/:ptyID", {
|
|
57
|
+
params: { ptyID: Pty.ID },
|
|
58
|
+
payload: PersistentPty.UpdateInput,
|
|
59
|
+
success: Schema.Struct({ data: PersistentPty.Info }),
|
|
60
|
+
error: [...terminalErrors, PtyFeatureUnsupportedError],
|
|
61
|
+
}).annotateMerge(OpenApi.annotations({
|
|
62
|
+
identifier: "experimental.persistentPty.update",
|
|
63
|
+
description: "Resize when size is present and rename when title is present; a null title clears the user title so the shell's title shows again. Renaming fails with 501 while the terminal service predates renaming.",
|
|
64
|
+
})))
|
|
65
|
+
.add(HttpApiEndpoint.get("persistentPty.snapshot", "/api/experimental/persistent-pty/:ptyID/snapshot", {
|
|
66
|
+
params: { ptyID: Pty.ID },
|
|
67
|
+
success: Schema.Struct({ data: PersistentPty.Snapshot }),
|
|
68
|
+
error: terminalErrors,
|
|
69
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.snapshot" })))
|
|
70
|
+
.add(HttpApiEndpoint.delete("persistentPty.remove", "/api/experimental/persistent-pty/:ptyID", {
|
|
71
|
+
params: { ptyID: Pty.ID },
|
|
72
|
+
success: HttpApiSchema.NoContent,
|
|
73
|
+
error: terminalErrors,
|
|
74
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.remove" })))
|
|
75
|
+
.add(HttpApiEndpoint.post("persistentPty.connectToken", "/api/experimental/persistent-pty/:ptyID/connect-token", {
|
|
76
|
+
params: { ptyID: Pty.ID },
|
|
77
|
+
headers: Schema.Struct({
|
|
78
|
+
[PTY_CONNECT_TOKEN_HEADER]: Schema.optional(Schema.String).annotateKey({
|
|
79
|
+
description: `Must be ${PTY_CONNECT_TOKEN_HEADER_VALUE}; requests without it are refused.`,
|
|
80
|
+
}),
|
|
81
|
+
}),
|
|
82
|
+
success: Schema.Struct({ data: PtyTicket.ConnectToken }),
|
|
83
|
+
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
84
|
+
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.connectToken" })))
|
|
85
|
+
.add(HttpApiEndpoint.get("persistentPty.connect", PERSISTENT_PTY_CONNECT_PATH, {
|
|
86
|
+
params: { ptyID: Pty.ID },
|
|
87
|
+
success: Schema.Boolean,
|
|
88
|
+
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
|
89
|
+
}).annotateMerge(OpenApi.annotations({
|
|
90
|
+
identifier: "experimental.persistentPty.connect",
|
|
91
|
+
summary: "Connect to a persistent PTY",
|
|
92
|
+
description: "Stream persistent PTY output through the radhe.im server.",
|
|
93
|
+
transform: (operation) => ({
|
|
94
|
+
...operation,
|
|
95
|
+
"x-websocket": true,
|
|
96
|
+
parameters: [
|
|
97
|
+
...(operation.parameters ?? []),
|
|
98
|
+
{ in: "query", name: "attachment_id", schema: { type: "string" } },
|
|
99
|
+
...Object.entries({
|
|
100
|
+
cursor: "Output offset to replay from. Defaults to 0.",
|
|
101
|
+
role: "Attach as controller (the default) or observer.",
|
|
102
|
+
takeover: "Set to true to take over control of the terminal.",
|
|
103
|
+
input_protocol: "Set to 1 to send framed input messages instead of raw terminal input.",
|
|
104
|
+
[PTY_CONNECT_TICKET_QUERY]: "Single-use ticket from experimental.persistentPty.connectToken, which authorizes the connection without the usual credentials.",
|
|
105
|
+
}).map(([name, description]) => ({ in: "query", name, description, schema: { type: "string" } })),
|
|
106
|
+
],
|
|
107
|
+
}),
|
|
108
|
+
})))
|
|
109
|
+
.annotateMerge(OpenApi.annotations({ title: "persistentPty", description: "Prototype persistent PTY routes." }));
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
3
|
+
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "../errors.js";
|
|
4
|
+
export declare const PluginGroup: HttpApiGroup.HttpApiGroup<"server.plugin", HttpApiEndpoint.HttpApiEndpoint<"plugin.check", "POST", "/api/plugin/check", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
5
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
6
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
7
|
+
}>>;
|
|
8
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
9
|
+
readonly target: Schema.optional<Schema.String>;
|
|
10
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
11
|
+
readonly location: Schema.Struct<{
|
|
12
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
13
|
+
}>;
|
|
14
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
15
|
+
readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Plugin.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Plugin.ID">>, never, never>;
|
|
16
|
+
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
17
|
+
readonly type: Schema.Literal<"builtin">;
|
|
18
|
+
}>, Schema.Struct<{
|
|
19
|
+
readonly type: Schema.Literal<"package">;
|
|
20
|
+
readonly target: Schema.String;
|
|
21
|
+
readonly version: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
22
|
+
readonly outdated: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
23
|
+
readonly updating: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
24
|
+
}>, Schema.Struct<{
|
|
25
|
+
readonly type: Schema.Literal<"local">;
|
|
26
|
+
readonly path: Schema.String;
|
|
27
|
+
}>, Schema.Struct<{
|
|
28
|
+
readonly type: Schema.Literal<"sdk">;
|
|
29
|
+
}>]>;
|
|
30
|
+
readonly features: Schema.Struct<{
|
|
31
|
+
readonly server: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
32
|
+
readonly tui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
33
|
+
readonly rpc: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
34
|
+
readonly gui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
35
|
+
}>;
|
|
36
|
+
readonly state: Schema.Union<readonly [Schema.Struct<{
|
|
37
|
+
readonly status: Schema.Literal<"active">;
|
|
38
|
+
}>, Schema.Struct<{
|
|
39
|
+
readonly status: Schema.Literal<"failed">;
|
|
40
|
+
readonly error: Schema.String;
|
|
41
|
+
readonly ref: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
42
|
+
}>]>;
|
|
43
|
+
}>>;
|
|
44
|
+
}>>, Schema.toCodecJson<typeof InvalidRequestError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"plugin.gui", "GET", "/api/plugin/gui", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
45
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
46
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
47
|
+
}>>;
|
|
48
|
+
readonly id: Schema.brand<Schema.String, "Plugin.ID">;
|
|
49
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
50
|
+
readonly location: Schema.Struct<{
|
|
51
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
52
|
+
}>;
|
|
53
|
+
readonly data: Schema.Struct<{
|
|
54
|
+
readonly code: Schema.String;
|
|
55
|
+
readonly revision: Schema.String;
|
|
56
|
+
readonly options: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
57
|
+
}>;
|
|
58
|
+
}>>, Schema.toCodecJson<typeof PluginNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"plugin.list", "GET", "/api/plugin", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
59
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
60
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
61
|
+
}>>;
|
|
62
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
63
|
+
readonly location: Schema.Struct<{
|
|
64
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
65
|
+
}>;
|
|
66
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
67
|
+
readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Plugin.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Plugin.ID">>, never, never>;
|
|
68
|
+
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
69
|
+
readonly type: Schema.Literal<"builtin">;
|
|
70
|
+
}>, Schema.Struct<{
|
|
71
|
+
readonly type: Schema.Literal<"package">;
|
|
72
|
+
readonly target: Schema.String;
|
|
73
|
+
readonly version: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
74
|
+
readonly outdated: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
75
|
+
readonly updating: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
76
|
+
}>, Schema.Struct<{
|
|
77
|
+
readonly type: Schema.Literal<"local">;
|
|
78
|
+
readonly path: Schema.String;
|
|
79
|
+
}>, Schema.Struct<{
|
|
80
|
+
readonly type: Schema.Literal<"sdk">;
|
|
81
|
+
}>]>;
|
|
82
|
+
readonly features: Schema.Struct<{
|
|
83
|
+
readonly server: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
84
|
+
readonly tui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
85
|
+
readonly rpc: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
86
|
+
readonly gui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
87
|
+
}>;
|
|
88
|
+
readonly state: Schema.Union<readonly [Schema.Struct<{
|
|
89
|
+
readonly status: Schema.Literal<"active">;
|
|
90
|
+
}>, Schema.Struct<{
|
|
91
|
+
readonly status: Schema.Literal<"failed">;
|
|
92
|
+
readonly error: Schema.String;
|
|
93
|
+
readonly ref: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
94
|
+
}>]>;
|
|
95
|
+
}>>;
|
|
96
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"plugin.update", "POST", "/api/plugin/update", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
97
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
98
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
99
|
+
}>>;
|
|
100
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
101
|
+
readonly targets: Schema.$Array<Schema.String>;
|
|
102
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Location } from "@radheim/schema/location";
|
|
2
|
+
import { Plugin } from "@radheim/schema/plugin";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
5
|
+
import { InvalidRequestError, PluginNotFoundError, ServiceUnavailableError } from "../errors.js";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
export const PluginGroup = HttpApiGroup.make("server.plugin")
|
|
8
|
+
.add(HttpApiEndpoint.get("plugin.list", "/api/plugin", {
|
|
9
|
+
query: LocationQuery,
|
|
10
|
+
success: Location.response(Schema.Array(Plugin.Info)),
|
|
11
|
+
})
|
|
12
|
+
.annotateMerge(locationQueryOpenApi)
|
|
13
|
+
.annotateMerge(OpenApi.annotations({
|
|
14
|
+
identifier: "plugin.list",
|
|
15
|
+
summary: "List plugins",
|
|
16
|
+
description: "Retrieve enabled server plugins and their current status.",
|
|
17
|
+
})))
|
|
18
|
+
.add(HttpApiEndpoint.get("plugin.gui", "/api/plugin/gui", {
|
|
19
|
+
query: Schema.Struct({
|
|
20
|
+
...LocationQuery.fields,
|
|
21
|
+
id: Plugin.ID,
|
|
22
|
+
}),
|
|
23
|
+
success: Location.response(Plugin.GuiBundle),
|
|
24
|
+
error: PluginNotFoundError,
|
|
25
|
+
})
|
|
26
|
+
.annotateMerge(locationQueryOpenApi)
|
|
27
|
+
.annotateMerge(OpenApi.annotations({
|
|
28
|
+
identifier: "plugin.gui",
|
|
29
|
+
summary: "Read plugin GUI bundle",
|
|
30
|
+
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`.",
|
|
31
|
+
})))
|
|
32
|
+
.add(HttpApiEndpoint.post("plugin.check", "/api/plugin/check", {
|
|
33
|
+
query: LocationQuery,
|
|
34
|
+
payload: Schema.Struct({ target: Schema.String.pipe(Schema.optional) }),
|
|
35
|
+
success: Location.response(Schema.Array(Plugin.Info)),
|
|
36
|
+
error: InvalidRequestError,
|
|
37
|
+
})
|
|
38
|
+
.annotateMerge(locationQueryOpenApi)
|
|
39
|
+
.annotateMerge(OpenApi.annotations({
|
|
40
|
+
identifier: "plugin.check",
|
|
41
|
+
summary: "Check plugin updates",
|
|
42
|
+
description: "Check one or all package plugins for available updates.",
|
|
43
|
+
})))
|
|
44
|
+
.add(HttpApiEndpoint.post("plugin.update", "/api/plugin/update", {
|
|
45
|
+
query: LocationQuery,
|
|
46
|
+
payload: Schema.Struct({ targets: Schema.Array(Schema.String) }),
|
|
47
|
+
success: HttpApiSchema.NoContent,
|
|
48
|
+
error: [InvalidRequestError, ServiceUnavailableError],
|
|
49
|
+
})
|
|
50
|
+
.annotateMerge(locationQueryOpenApi)
|
|
51
|
+
.annotateMerge(OpenApi.annotations({
|
|
52
|
+
identifier: "plugin.update",
|
|
53
|
+
summary: "Update plugins",
|
|
54
|
+
description: "Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.",
|
|
55
|
+
})))
|
|
56
|
+
.annotateMerge(OpenApi.annotations({
|
|
57
|
+
title: "plugin",
|
|
58
|
+
description: "Experimental plugin routes.",
|
|
59
|
+
}));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
3
|
+
import { ProjectNotFoundError } from "../errors.js";
|
|
4
|
+
export declare const ProjectGroup: HttpApiGroup.HttpApiGroup<"server.project", HttpApiEndpoint.HttpApiEndpoint<"project.list", "GET", "/api/project", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
5
|
+
readonly archived: Schema.optional<Schema.decodeTo<Schema.Boolean, Schema.Literals<readonly ["true", "false"]>, never, never>>;
|
|
6
|
+
}>>, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
|
|
7
|
+
readonly id: Schema.brand<Schema.String, "Project.ID"> & {
|
|
8
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
9
|
+
};
|
|
10
|
+
readonly canonical: Schema.brand<Schema.String, "AbsolutePath">;
|
|
11
|
+
readonly vcs: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
12
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
13
|
+
readonly icon: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
14
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
15
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
16
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
17
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
18
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
19
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
20
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
21
|
+
}>>, never, never>;
|
|
22
|
+
readonly commands: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
23
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
24
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
25
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
26
|
+
}>>, never, never>;
|
|
27
|
+
readonly time: Schema.Struct<{
|
|
28
|
+
readonly created: Schema.Int;
|
|
29
|
+
readonly updated: Schema.Int;
|
|
30
|
+
readonly active: Schema.Int;
|
|
31
|
+
readonly archived: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
32
|
+
}>;
|
|
33
|
+
readonly sandboxes: Schema.$Array<Schema.String>;
|
|
34
|
+
}>>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"project.update", "PATCH", "/api/project/:projectID", Schema.toCodecStringTree<Schema.Struct<{
|
|
35
|
+
projectID: Schema.brand<Schema.String, "Project.ID"> & {
|
|
36
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
37
|
+
};
|
|
38
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
39
|
+
readonly canonical: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "AbsolutePath">>>, Schema.optionalKey<Schema.brand<Schema.String, "AbsolutePath">>, never, never>;
|
|
40
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
41
|
+
readonly icon: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
42
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
43
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
44
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
45
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
46
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
47
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
48
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
49
|
+
}>>, never, never>;
|
|
50
|
+
readonly commands: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
51
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
52
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
53
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
54
|
+
}>>, never, never>;
|
|
55
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
56
|
+
readonly id: Schema.brand<Schema.String, "Project.ID"> & {
|
|
57
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
58
|
+
};
|
|
59
|
+
readonly canonical: Schema.brand<Schema.String, "AbsolutePath">;
|
|
60
|
+
readonly vcs: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
61
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
62
|
+
readonly icon: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
63
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
64
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
65
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
66
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
67
|
+
readonly url: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
68
|
+
readonly override: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
69
|
+
readonly color: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
70
|
+
}>>, never, never>;
|
|
71
|
+
readonly commands: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
72
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
73
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
74
|
+
readonly start: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
75
|
+
}>>, never, never>;
|
|
76
|
+
readonly time: Schema.Struct<{
|
|
77
|
+
readonly created: Schema.Int;
|
|
78
|
+
readonly updated: Schema.Int;
|
|
79
|
+
readonly active: Schema.Int;
|
|
80
|
+
readonly archived: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
81
|
+
}>;
|
|
82
|
+
readonly sandboxes: Schema.$Array<Schema.String>;
|
|
83
|
+
}>>, Schema.toCodecJson<typeof ProjectNotFoundError>, never, never>, false>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Project } from "@radheim/schema/project";
|
|
2
|
+
import { Schema, SchemaGetter, Struct } from "effect";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
|
|
4
|
+
import { ProjectNotFoundError } from "../errors.js";
|
|
5
|
+
const root = "/api/project";
|
|
6
|
+
const UpdatePayload = Schema.Struct(Struct.omit(Project.UpdateInput.fields, ["projectID"]));
|
|
7
|
+
const BooleanFromString = Schema.Literals(["true", "false"]).pipe(Schema.decodeTo(Schema.Boolean, {
|
|
8
|
+
decode: SchemaGetter.transform((value) => value === "true"),
|
|
9
|
+
encode: SchemaGetter.transform((value) => (value ? "true" : "false")),
|
|
10
|
+
}));
|
|
11
|
+
export const ProjectGroup = HttpApiGroup.make("server.project")
|
|
12
|
+
.add(HttpApiEndpoint.get("project.list", root, {
|
|
13
|
+
query: Schema.Struct({
|
|
14
|
+
archived: BooleanFromString.pipe(Schema.optional).annotateKey({
|
|
15
|
+
description: "Set to true to include archived projects.",
|
|
16
|
+
}),
|
|
17
|
+
}),
|
|
18
|
+
success: Schema.Array(Project.Info),
|
|
19
|
+
}).annotateMerge(OpenApi.annotations({
|
|
20
|
+
identifier: "project.list",
|
|
21
|
+
summary: "List projects",
|
|
22
|
+
description: "List known projects. Archived projects are excluded unless archived=true.",
|
|
23
|
+
})))
|
|
24
|
+
.add(HttpApiEndpoint.patch("project.update", `${root}/:projectID`, {
|
|
25
|
+
params: { projectID: Project.ID },
|
|
26
|
+
payload: UpdatePayload,
|
|
27
|
+
success: Project.Info,
|
|
28
|
+
error: ProjectNotFoundError,
|
|
29
|
+
}).annotateMerge(OpenApi.annotations({
|
|
30
|
+
identifier: "project.update",
|
|
31
|
+
summary: "Update project",
|
|
32
|
+
description: "Update the project canonical directory, display metadata, and workspace commands.",
|
|
33
|
+
})))
|
|
34
|
+
.annotateMerge(OpenApi.annotations({
|
|
35
|
+
title: "project",
|
|
36
|
+
description: "Project routes.",
|
|
37
|
+
}));
|