@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,97 @@
|
|
|
1
|
+
import { Form } from "@opencode-ai/schema/form";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Context, Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
import { ConflictError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidRequestError, SessionNotFoundError, } from "../errors.js";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
const CreatePayload = Schema.Struct({
|
|
8
|
+
id: Form.ID.pipe(Schema.optional),
|
|
9
|
+
title: Form.Info.fields.title,
|
|
10
|
+
metadata: Form.Info.fields.metadata,
|
|
11
|
+
fields: Form.Info.fields.fields,
|
|
12
|
+
}).annotate({ identifier: "Form.CreatePayload" });
|
|
13
|
+
// Form routes intentionally look session-scoped, but use a form-specific middleware instead of
|
|
14
|
+
// SessionLocationMiddleware. The middleware treats real session IDs normally and has an
|
|
15
|
+
// undocumented `global` sentinel branch for MCP elicitation forms that are still Location-scoped
|
|
16
|
+
// but not session-owned. This is temporary and should disappear once elicitations are attributable.
|
|
17
|
+
export const makeFormGroup = (locationMiddleware, formLocationMiddleware) => HttpApiGroup.make("server.form")
|
|
18
|
+
.add(HttpApiEndpoint.get("form.request.list", "/api/form/request", {
|
|
19
|
+
query: LocationQuery,
|
|
20
|
+
success: Location.response(Schema.Array(Form.Info)),
|
|
21
|
+
})
|
|
22
|
+
.annotateMerge(locationQueryOpenApi)
|
|
23
|
+
.annotateMerge(OpenApi.annotations({
|
|
24
|
+
identifier: "v2.form.request.list",
|
|
25
|
+
summary: "List pending form requests",
|
|
26
|
+
description: "Retrieve pending forms for a location.",
|
|
27
|
+
})))
|
|
28
|
+
.middleware(locationMiddleware)
|
|
29
|
+
.add(HttpApiEndpoint.get("session.form.list", "/api/session/:sessionID/form", {
|
|
30
|
+
params: { sessionID: Schema.String },
|
|
31
|
+
success: Schema.Struct({ data: Schema.Array(Form.Info) }),
|
|
32
|
+
error: SessionNotFoundError,
|
|
33
|
+
})
|
|
34
|
+
.middleware(formLocationMiddleware)
|
|
35
|
+
.annotateMerge(OpenApi.annotations({
|
|
36
|
+
identifier: "v2.session.form.list",
|
|
37
|
+
summary: "List session forms",
|
|
38
|
+
description: "Retrieve pending forms for a session.",
|
|
39
|
+
})))
|
|
40
|
+
.add(HttpApiEndpoint.post("session.form.create", "/api/session/:sessionID/form", {
|
|
41
|
+
params: { sessionID: Schema.String },
|
|
42
|
+
payload: CreatePayload,
|
|
43
|
+
success: Schema.Struct({ data: Form.Info }),
|
|
44
|
+
error: [SessionNotFoundError, ConflictError, InvalidRequestError],
|
|
45
|
+
})
|
|
46
|
+
.middleware(formLocationMiddleware)
|
|
47
|
+
.annotateMerge(OpenApi.annotations({
|
|
48
|
+
identifier: "v2.session.form.create",
|
|
49
|
+
summary: "Create session form",
|
|
50
|
+
description: "Create a form for a session.",
|
|
51
|
+
})))
|
|
52
|
+
.add(HttpApiEndpoint.get("session.form.get", "/api/session/:sessionID/form/:formID", {
|
|
53
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
54
|
+
success: Schema.Struct({ data: Form.Info }),
|
|
55
|
+
error: [SessionNotFoundError, FormNotFoundError],
|
|
56
|
+
})
|
|
57
|
+
.middleware(formLocationMiddleware)
|
|
58
|
+
.annotateMerge(OpenApi.annotations({
|
|
59
|
+
identifier: "v2.session.form.get",
|
|
60
|
+
summary: "Get session form",
|
|
61
|
+
description: "Retrieve a form for a session.",
|
|
62
|
+
})))
|
|
63
|
+
.add(HttpApiEndpoint.get("session.form.state", "/api/session/:sessionID/form/:formID/state", {
|
|
64
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
65
|
+
success: Schema.Struct({ data: Form.State }),
|
|
66
|
+
error: [SessionNotFoundError, FormNotFoundError],
|
|
67
|
+
})
|
|
68
|
+
.middleware(formLocationMiddleware)
|
|
69
|
+
.annotateMerge(OpenApi.annotations({
|
|
70
|
+
identifier: "v2.session.form.state",
|
|
71
|
+
summary: "Get form state",
|
|
72
|
+
description: "Retrieve the current state for a form.",
|
|
73
|
+
})))
|
|
74
|
+
.add(HttpApiEndpoint.post("session.form.reply", "/api/session/:sessionID/form/:formID/reply", {
|
|
75
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
76
|
+
payload: Form.Reply,
|
|
77
|
+
success: HttpApiSchema.NoContent,
|
|
78
|
+
error: [SessionNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError],
|
|
79
|
+
})
|
|
80
|
+
.middleware(formLocationMiddleware)
|
|
81
|
+
.annotateMerge(OpenApi.annotations({
|
|
82
|
+
identifier: "v2.session.form.reply",
|
|
83
|
+
summary: "Reply to form",
|
|
84
|
+
description: "Submit an answer to a pending form.",
|
|
85
|
+
})))
|
|
86
|
+
.add(HttpApiEndpoint.post("session.form.cancel", "/api/session/:sessionID/form/:formID/cancel", {
|
|
87
|
+
params: { sessionID: Schema.String, formID: Form.ID },
|
|
88
|
+
success: HttpApiSchema.NoContent,
|
|
89
|
+
error: [SessionNotFoundError, FormAlreadySettledError, FormNotFoundError],
|
|
90
|
+
})
|
|
91
|
+
.middleware(formLocationMiddleware)
|
|
92
|
+
.annotateMerge(OpenApi.annotations({
|
|
93
|
+
identifier: "v2.session.form.cancel",
|
|
94
|
+
summary: "Cancel form",
|
|
95
|
+
description: "Cancel a pending form.",
|
|
96
|
+
})))
|
|
97
|
+
.annotateMerge(OpenApi.annotations({ title: "form", description: "Session form routes." }));
|
|
@@ -0,0 +1,35 @@
|
|
|
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 FileSystemGroup: HttpApiGroup.HttpApiGroup<"server.fs", HttpApiEndpoint.HttpApiEndpoint<"fs.read", "GET", "/api/fs/read/*", never, Schema.toCodecStringTree<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
|
+
}>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.list", "GET", "/api/fs/list", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
10
|
+
readonly path: Schema.optional<Schema.brand<Schema.String, "RelativePath">>;
|
|
11
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
12
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
13
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
14
|
+
}>>;
|
|
15
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
16
|
+
readonly location: typeof Location.Info;
|
|
17
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
18
|
+
readonly path: Schema.brand<Schema.String, "RelativePath">;
|
|
19
|
+
readonly type: Schema.Literals<readonly ["file", "directory"]>;
|
|
20
|
+
}>>;
|
|
21
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.find", "GET", "/api/fs/find", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
22
|
+
readonly query: Schema.String;
|
|
23
|
+
readonly type: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["file", "directory"]>>>, Schema.optionalKey<Schema.Literals<readonly ["file", "directory"]>>, never, never>;
|
|
24
|
+
readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
|
|
25
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
26
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
27
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
28
|
+
}>>;
|
|
29
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
30
|
+
readonly location: typeof Location.Info;
|
|
31
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
32
|
+
readonly path: Schema.brand<Schema.String, "RelativePath">;
|
|
33
|
+
readonly type: Schema.Literals<readonly ["file", "directory"]>;
|
|
34
|
+
}>>;
|
|
35
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FileSystem } from "@opencode-ai/schema/filesystem";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { PositiveInt, RelativePath } from "@opencode-ai/schema/schema";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
const ListQuery = Schema.Struct({
|
|
8
|
+
...LocationQuery.fields,
|
|
9
|
+
path: RelativePath.pipe(Schema.optional),
|
|
10
|
+
});
|
|
11
|
+
const FindQuery = Schema.Struct({
|
|
12
|
+
...LocationQuery.fields,
|
|
13
|
+
query: FileSystem.FindInput.fields.query,
|
|
14
|
+
type: FileSystem.FindInput.fields.type,
|
|
15
|
+
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
|
|
16
|
+
});
|
|
17
|
+
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
|
18
|
+
.add(HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
|
|
19
|
+
query: LocationQuery,
|
|
20
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
21
|
+
})
|
|
22
|
+
.annotateMerge(locationQueryOpenApi)
|
|
23
|
+
.annotateMerge(OpenApi.annotations({
|
|
24
|
+
identifier: "v2.fs.read",
|
|
25
|
+
summary: "Read file",
|
|
26
|
+
description: "Serve one file relative to the requested location.",
|
|
27
|
+
})))
|
|
28
|
+
.add(HttpApiEndpoint.get("fs.list", "/api/fs/list", {
|
|
29
|
+
query: ListQuery,
|
|
30
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
31
|
+
})
|
|
32
|
+
.annotateMerge(locationQueryOpenApi)
|
|
33
|
+
.annotateMerge(OpenApi.annotations({
|
|
34
|
+
identifier: "v2.fs.list",
|
|
35
|
+
summary: "List directory",
|
|
36
|
+
description: "List direct children of one directory relative to the requested location.",
|
|
37
|
+
})))
|
|
38
|
+
.add(HttpApiEndpoint.get("fs.find", "/api/fs/find", {
|
|
39
|
+
query: FindQuery,
|
|
40
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
41
|
+
})
|
|
42
|
+
.annotateMerge(locationQueryOpenApi)
|
|
43
|
+
.annotateMerge(OpenApi.annotations({
|
|
44
|
+
identifier: "v2.fs.find",
|
|
45
|
+
summary: "Find files",
|
|
46
|
+
description: "Find recursively ranked filesystem entries relative to the requested location.",
|
|
47
|
+
})))
|
|
48
|
+
.annotateMerge(OpenApi.annotations({
|
|
49
|
+
title: "filesystem",
|
|
50
|
+
description: "Experimental location-scoped filesystem routes.",
|
|
51
|
+
}));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
3
|
+
import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
4
|
+
export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate", HttpApiEndpoint.HttpApiEndpoint<"generate.text", "POST", "/api/generate", never, Schema.toCodecStringTree<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
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
10
|
+
readonly prompt: Schema.String;
|
|
11
|
+
readonly model: Schema.optional<Schema.Struct<{
|
|
12
|
+
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
13
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
14
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
15
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
16
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
17
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
18
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
19
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
20
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
21
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
22
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
23
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
24
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
25
|
+
};
|
|
26
|
+
readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
|
|
27
|
+
}> & {
|
|
28
|
+
parse: (input: string) => {
|
|
29
|
+
readonly id: string & import("effect/Brand").Brand<"Model.ID">;
|
|
30
|
+
readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
31
|
+
readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
35
|
+
readonly data: Schema.Struct<{
|
|
36
|
+
readonly text: Schema.String;
|
|
37
|
+
}>;
|
|
38
|
+
}>>, Schema.toCodecJson<typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Model } from "@opencode-ai/schema/model";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
4
|
+
import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
6
|
+
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
7
|
+
.add(HttpApiEndpoint.post("generate.text", "/api/generate", {
|
|
8
|
+
query: LocationQuery,
|
|
9
|
+
payload: Schema.Struct({
|
|
10
|
+
prompt: Schema.String,
|
|
11
|
+
model: Model.Ref.pipe(Schema.optional),
|
|
12
|
+
}),
|
|
13
|
+
success: Schema.Struct({
|
|
14
|
+
data: Schema.Struct({ text: Schema.String }),
|
|
15
|
+
}).annotate({ identifier: "GenerateTextResponse" }),
|
|
16
|
+
error: [InvalidRequestError, ServiceUnavailableError],
|
|
17
|
+
})
|
|
18
|
+
.annotateMerge(locationQueryOpenApi)
|
|
19
|
+
.annotateMerge(OpenApi.annotations({
|
|
20
|
+
identifier: "v2.generate.text",
|
|
21
|
+
summary: "Generate text",
|
|
22
|
+
description: "Run one stateless model generation at the requested location and return the assistant text. Uses the location's default model when none is specified.",
|
|
23
|
+
})))
|
|
24
|
+
.annotateMerge(OpenApi.annotations({
|
|
25
|
+
title: "generate",
|
|
26
|
+
description: "Experimental one-shot generation routes.",
|
|
27
|
+
}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
3
|
+
export declare namespace ServiceStatus {
|
|
4
|
+
const Health: Schema.Struct<{
|
|
5
|
+
readonly healthy: Schema.Literal<true>;
|
|
6
|
+
readonly version: Schema.String;
|
|
7
|
+
readonly pid: Schema.Int;
|
|
8
|
+
}>;
|
|
9
|
+
type Health = typeof Health.Type;
|
|
10
|
+
const StopRequest: Schema.Struct<{
|
|
11
|
+
readonly instanceID: Schema.String;
|
|
12
|
+
}>;
|
|
13
|
+
type StopRequest = typeof StopRequest.Type;
|
|
14
|
+
const StopResponse: Schema.Struct<{
|
|
15
|
+
readonly accepted: Schema.Boolean;
|
|
16
|
+
}>;
|
|
17
|
+
type StopResponse = typeof StopResponse.Type;
|
|
18
|
+
}
|
|
19
|
+
export declare const HealthGroup: HttpApiGroup.HttpApiGroup<"server.health", HttpApiEndpoint.HttpApiEndpoint<"health.get", "GET", "/api/health", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
20
|
+
readonly healthy: Schema.Literal<true>;
|
|
21
|
+
readonly version: Schema.String;
|
|
22
|
+
readonly pid: Schema.Int;
|
|
23
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"health.stop", "POST", "/api/service/stop", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
24
|
+
readonly instanceID: Schema.String;
|
|
25
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
26
|
+
readonly accepted: Schema.Boolean;
|
|
27
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
3
|
+
export var ServiceStatus;
|
|
4
|
+
(function (ServiceStatus) {
|
|
5
|
+
ServiceStatus.Health = Schema.Struct({
|
|
6
|
+
healthy: Schema.Literal(true),
|
|
7
|
+
version: Schema.String,
|
|
8
|
+
// 0 means the runtime has no OS process identity (e.g. workerd).
|
|
9
|
+
pid: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
10
|
+
}).annotate({ identifier: "ServiceHealth" });
|
|
11
|
+
ServiceStatus.StopRequest = Schema.Struct({
|
|
12
|
+
instanceID: Schema.String,
|
|
13
|
+
}).annotate({ identifier: "ServiceStopRequest" });
|
|
14
|
+
ServiceStatus.StopResponse = Schema.Struct({
|
|
15
|
+
accepted: Schema.Boolean,
|
|
16
|
+
}).annotate({ identifier: "ServiceStopResponse" });
|
|
17
|
+
})(ServiceStatus || (ServiceStatus = {}));
|
|
18
|
+
export const HealthGroup = HttpApiGroup.make("server.health")
|
|
19
|
+
.add(HttpApiEndpoint.get("health.get", "/api/health", {
|
|
20
|
+
success: ServiceStatus.Health,
|
|
21
|
+
}).annotateMerge(OpenApi.annotations({
|
|
22
|
+
identifier: "v2.health.get",
|
|
23
|
+
summary: "Check server health",
|
|
24
|
+
description: "Report the owning server process and its application status.",
|
|
25
|
+
})))
|
|
26
|
+
.add(HttpApiEndpoint.post("health.stop", "/api/service/stop", {
|
|
27
|
+
payload: ServiceStatus.StopRequest,
|
|
28
|
+
success: ServiceStatus.StopResponse,
|
|
29
|
+
}).annotateMerge(OpenApi.annotations({
|
|
30
|
+
identifier: "v2.health.stop",
|
|
31
|
+
summary: "Stop the managed server",
|
|
32
|
+
description: "Request graceful shutdown of one exact managed server instance.",
|
|
33
|
+
})))
|
|
34
|
+
.annotateMerge(OpenApi.annotations({ title: "health" }));
|