@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,82 @@
|
|
|
1
|
+
import { Shell } from "@opencode-ai/schema/shell";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { NonNegativeInt } from "@opencode-ai/schema/schema";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
6
|
+
import { ShellNotFoundError } from "../errors.js";
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
|
+
const TimeoutInput = Schema.Struct({
|
|
9
|
+
timeout: NonNegativeInt,
|
|
10
|
+
});
|
|
11
|
+
export const ShellGroup = HttpApiGroup.make("server.shell")
|
|
12
|
+
.add(HttpApiEndpoint.get("shell.list", "/api/shell", {
|
|
13
|
+
query: LocationQuery,
|
|
14
|
+
success: Location.response(Schema.Array(Shell.Info)),
|
|
15
|
+
})
|
|
16
|
+
.annotateMerge(locationQueryOpenApi)
|
|
17
|
+
.annotateMerge(OpenApi.annotations({
|
|
18
|
+
identifier: "v2.shell.list",
|
|
19
|
+
summary: "List running shell commands",
|
|
20
|
+
description: "List currently running shell commands for a location. Exited commands are not included.",
|
|
21
|
+
})))
|
|
22
|
+
.add(HttpApiEndpoint.post("shell.create", "/api/shell", {
|
|
23
|
+
query: LocationQuery,
|
|
24
|
+
payload: Shell.CreateInput,
|
|
25
|
+
success: Location.response(Shell.Info),
|
|
26
|
+
})
|
|
27
|
+
.annotateMerge(locationQueryOpenApi)
|
|
28
|
+
.annotateMerge(OpenApi.annotations({
|
|
29
|
+
identifier: "v2.shell.create",
|
|
30
|
+
summary: "Run shell command",
|
|
31
|
+
description: "Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.",
|
|
32
|
+
})))
|
|
33
|
+
.add(HttpApiEndpoint.get("shell.get", "/api/shell/:id", {
|
|
34
|
+
params: { id: Shell.ID },
|
|
35
|
+
query: LocationQuery,
|
|
36
|
+
success: Location.response(Shell.Info),
|
|
37
|
+
error: ShellNotFoundError,
|
|
38
|
+
})
|
|
39
|
+
.annotateMerge(locationQueryOpenApi)
|
|
40
|
+
.annotateMerge(OpenApi.annotations({
|
|
41
|
+
identifier: "v2.shell.get",
|
|
42
|
+
summary: "Get shell command",
|
|
43
|
+
description: "Get one shell command, including its status and exit code once exited.",
|
|
44
|
+
})))
|
|
45
|
+
.add(HttpApiEndpoint.patch("shell.timeout", "/api/shell/:id/timeout", {
|
|
46
|
+
params: { id: Shell.ID },
|
|
47
|
+
query: LocationQuery,
|
|
48
|
+
payload: TimeoutInput,
|
|
49
|
+
success: Location.response(Shell.Info),
|
|
50
|
+
error: ShellNotFoundError,
|
|
51
|
+
})
|
|
52
|
+
.annotateMerge(locationQueryOpenApi)
|
|
53
|
+
.annotateMerge(OpenApi.annotations({
|
|
54
|
+
identifier: "v2.shell.timeout",
|
|
55
|
+
summary: "Update shell timeout",
|
|
56
|
+
description: "Replace a running shell command's timeout from now, or clear it with zero.",
|
|
57
|
+
})))
|
|
58
|
+
.add(HttpApiEndpoint.get("shell.output", "/api/shell/:id/output", {
|
|
59
|
+
params: { id: Shell.ID },
|
|
60
|
+
query: Schema.Struct({ ...LocationQuery.fields, ...Shell.OutputInput.fields }),
|
|
61
|
+
success: Location.response(Shell.Output),
|
|
62
|
+
error: ShellNotFoundError,
|
|
63
|
+
})
|
|
64
|
+
.annotateMerge(locationQueryOpenApi)
|
|
65
|
+
.annotateMerge(OpenApi.annotations({
|
|
66
|
+
identifier: "v2.shell.output",
|
|
67
|
+
summary: "Read shell output",
|
|
68
|
+
description: "Page through captured combined output by absolute byte cursor.",
|
|
69
|
+
})))
|
|
70
|
+
.add(HttpApiEndpoint.delete("shell.remove", "/api/shell/:id", {
|
|
71
|
+
params: { id: Shell.ID },
|
|
72
|
+
query: LocationQuery,
|
|
73
|
+
success: HttpApiSchema.NoContent,
|
|
74
|
+
error: ShellNotFoundError,
|
|
75
|
+
})
|
|
76
|
+
.annotateMerge(locationQueryOpenApi)
|
|
77
|
+
.annotateMerge(OpenApi.annotations({
|
|
78
|
+
identifier: "v2.shell.remove",
|
|
79
|
+
summary: "Remove shell command",
|
|
80
|
+
description: "Terminate and remove one shell command and its retained output.",
|
|
81
|
+
})))
|
|
82
|
+
.annotateMerge(OpenApi.annotations({ title: "shell", description: "Experimental location-scoped shell command routes." }));
|
|
@@ -0,0 +1,20 @@
|
|
|
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 SkillGroup: HttpApiGroup.HttpApiGroup<"server.skill", HttpApiEndpoint.HttpApiEndpoint<"skill.list", "GET", "/api/skill", 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.Struct<{
|
|
10
|
+
readonly location: typeof Location.Info;
|
|
11
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
12
|
+
readonly id: Schema.brand<Schema.String, "Skill.ID">;
|
|
13
|
+
readonly name: Schema.brand<Schema.String, "Skill.Name">;
|
|
14
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
15
|
+
readonly slash: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
16
|
+
readonly autoinvoke: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
17
|
+
readonly location: Schema.brand<Schema.String, "AbsolutePath">;
|
|
18
|
+
readonly content: Schema.String;
|
|
19
|
+
}>>;
|
|
20
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Skill } from "@opencode-ai/schema/skill";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
6
|
+
export const SkillGroup = HttpApiGroup.make("server.skill")
|
|
7
|
+
.add(HttpApiEndpoint.get("skill.list", "/api/skill", {
|
|
8
|
+
query: LocationQuery,
|
|
9
|
+
success: Location.response(Schema.Array(Skill.Info)),
|
|
10
|
+
})
|
|
11
|
+
.annotateMerge(locationQueryOpenApi)
|
|
12
|
+
.annotateMerge(OpenApi.annotations({
|
|
13
|
+
identifier: "v2.skill.list",
|
|
14
|
+
summary: "List skills",
|
|
15
|
+
description: "Retrieve currently registered skills.",
|
|
16
|
+
})))
|
|
17
|
+
.annotateMerge(OpenApi.annotations({
|
|
18
|
+
title: "skill",
|
|
19
|
+
description: "Experimental skill routes.",
|
|
20
|
+
}));
|
|
@@ -0,0 +1,46 @@
|
|
|
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 VcsGroup: HttpApiGroup.HttpApiGroup<"server.vcs", HttpApiEndpoint.HttpApiEndpoint<"vcs.get", "GET", "/api/vcs", 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.Struct<{
|
|
10
|
+
readonly location: typeof Location.Info;
|
|
11
|
+
readonly data: Schema.Struct<{
|
|
12
|
+
readonly branch: Schema.Struct<{
|
|
13
|
+
readonly current: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
14
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.status", "GET", "/api/vcs/status", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
18
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
19
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
20
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
21
|
+
}>>;
|
|
22
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
23
|
+
readonly location: typeof Location.Info;
|
|
24
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
25
|
+
readonly file: Schema.String;
|
|
26
|
+
readonly additions: Schema.Int;
|
|
27
|
+
readonly deletions: Schema.Int;
|
|
28
|
+
readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
|
|
29
|
+
}>>;
|
|
30
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"vcs.diff", "GET", "/api/vcs/diff", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
31
|
+
readonly mode: Schema.Literals<readonly ["working", "branch"]>;
|
|
32
|
+
readonly context: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
|
|
33
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
34
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
35
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
36
|
+
}>>;
|
|
37
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
38
|
+
readonly location: typeof Location.Info;
|
|
39
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
40
|
+
readonly file: Schema.String;
|
|
41
|
+
readonly patch: Schema.String;
|
|
42
|
+
readonly additions: Schema.Int;
|
|
43
|
+
readonly deletions: Schema.Int;
|
|
44
|
+
readonly status: Schema.Literals<readonly ["added", "deleted", "modified"]>;
|
|
45
|
+
}>>;
|
|
46
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FileDiff } from "@opencode-ai/schema/file-diff";
|
|
2
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
3
|
+
import { NonNegativeInt } from "@opencode-ai/schema/schema";
|
|
4
|
+
import { Vcs } from "@opencode-ai/schema/vcs";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
|
+
const DiffQuery = Schema.Struct({
|
|
9
|
+
...LocationQuery.fields,
|
|
10
|
+
mode: Vcs.Mode,
|
|
11
|
+
context: Schema.NumberFromString.pipe(Schema.decodeTo(NonNegativeInt), Schema.optional),
|
|
12
|
+
});
|
|
13
|
+
export const VcsGroup = HttpApiGroup.make("server.vcs")
|
|
14
|
+
.add(HttpApiEndpoint.get("vcs.get", "/api/vcs", {
|
|
15
|
+
query: LocationQuery,
|
|
16
|
+
success: Location.response(Vcs.Info),
|
|
17
|
+
})
|
|
18
|
+
.annotateMerge(locationQueryOpenApi)
|
|
19
|
+
.annotateMerge(OpenApi.annotations({
|
|
20
|
+
identifier: "v2.vcs.get",
|
|
21
|
+
summary: "VCS info",
|
|
22
|
+
description: "Get current and default branch information for the requested location.",
|
|
23
|
+
})))
|
|
24
|
+
.add(HttpApiEndpoint.get("vcs.status", "/api/vcs/status", {
|
|
25
|
+
query: LocationQuery,
|
|
26
|
+
success: Location.response(Schema.Array(Vcs.FileStatus)),
|
|
27
|
+
})
|
|
28
|
+
.annotateMerge(locationQueryOpenApi)
|
|
29
|
+
.annotateMerge(OpenApi.annotations({
|
|
30
|
+
identifier: "v2.vcs.status",
|
|
31
|
+
summary: "VCS status",
|
|
32
|
+
description: "List uncommitted working-copy changes relative to the requested location.",
|
|
33
|
+
})))
|
|
34
|
+
.add(HttpApiEndpoint.get("vcs.diff", "/api/vcs/diff", {
|
|
35
|
+
query: DiffQuery,
|
|
36
|
+
success: Location.response(Schema.Array(FileDiff.Info)),
|
|
37
|
+
})
|
|
38
|
+
.annotateMerge(locationQueryOpenApi)
|
|
39
|
+
.annotateMerge(OpenApi.annotations({
|
|
40
|
+
identifier: "v2.vcs.diff",
|
|
41
|
+
summary: "VCS diff",
|
|
42
|
+
description: "Diff the working copy against HEAD (mode git) or the default-branch merge base (mode branch) for the requested location.",
|
|
43
|
+
})))
|
|
44
|
+
.annotateMerge(OpenApi.annotations({
|
|
45
|
+
title: "vcs",
|
|
46
|
+
description: "Location-scoped version control routes.",
|
|
47
|
+
}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
2
|
+
import { WebSearch } from "@opencode-ai/schema/websearch";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
5
|
+
import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
6
|
+
export declare const WebSearchGroup: HttpApiGroup.HttpApiGroup<"server.websearch", HttpApiEndpoint.HttpApiEndpoint<"websearch.providers", "GET", "/api/websearch/provider", 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 id: Schema.brand<Schema.String, "WebSearch.ID">;
|
|
15
|
+
readonly name: Schema.String;
|
|
16
|
+
}>>;
|
|
17
|
+
}>>, Schema.toCodecJson<typeof ServiceUnavailableError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"websearch.query", "POST", "/api/websearch", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
18
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
19
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
20
|
+
readonly workspace: Schema.optional<Schema.String>;
|
|
21
|
+
}>>;
|
|
22
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
23
|
+
readonly query: Schema.String;
|
|
24
|
+
readonly providerID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "WebSearch.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "WebSearch.ID">>, never, never>;
|
|
25
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
26
|
+
readonly location: typeof Location.Info;
|
|
27
|
+
readonly data: typeof WebSearch.Response;
|
|
28
|
+
}>>, Schema.toCodecJson<typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Location } from "@opencode-ai/schema/location";
|
|
2
|
+
import { WebSearch } from "@opencode-ai/schema/websearch";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
import { InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
6
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
7
|
+
export const WebSearchGroup = HttpApiGroup.make("server.websearch")
|
|
8
|
+
.add(HttpApiEndpoint.get("websearch.providers", "/api/websearch/provider", {
|
|
9
|
+
query: LocationQuery,
|
|
10
|
+
success: Location.response(Schema.Array(WebSearch.Provider)),
|
|
11
|
+
error: ServiceUnavailableError,
|
|
12
|
+
})
|
|
13
|
+
.annotateMerge(locationQueryOpenApi)
|
|
14
|
+
.annotateMerge(OpenApi.annotations({
|
|
15
|
+
identifier: "v2.websearch.providers",
|
|
16
|
+
summary: "List web search providers",
|
|
17
|
+
description: "Return the registered web search providers.",
|
|
18
|
+
})))
|
|
19
|
+
.add(HttpApiEndpoint.post("websearch.query", "/api/websearch", {
|
|
20
|
+
query: LocationQuery,
|
|
21
|
+
payload: Schema.Struct(WebSearch.Input.fields),
|
|
22
|
+
success: Location.response(WebSearch.Response),
|
|
23
|
+
error: [InvalidRequestError, ServiceUnavailableError],
|
|
24
|
+
})
|
|
25
|
+
.annotateMerge(locationQueryOpenApi)
|
|
26
|
+
.annotateMerge(OpenApi.annotations({
|
|
27
|
+
identifier: "v2.websearch.query",
|
|
28
|
+
summary: "Search the web",
|
|
29
|
+
description: "Run one web search through the selected provider. Specify a provider to override the configured default.",
|
|
30
|
+
})))
|
|
31
|
+
.annotateMerge(OpenApi.annotations({
|
|
32
|
+
title: "websearch",
|
|
33
|
+
description: "Location-scoped web search routes.",
|
|
34
|
+
}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
|
|
3
|
+
declare const WorktreeError_base: Schema.Class<WorktreeError, Schema.Struct<{
|
|
4
|
+
readonly name: Schema.Literal<"WorktreeError">;
|
|
5
|
+
readonly data: Schema.Struct<{
|
|
6
|
+
readonly message: Schema.String;
|
|
7
|
+
readonly forceRequired: Schema.optional<Schema.Boolean>;
|
|
8
|
+
}>;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
export declare class WorktreeError extends WorktreeError_base {
|
|
11
|
+
}
|
|
12
|
+
export declare const WorktreeGroup: HttpApiGroup.HttpApiGroup<"server.worktree", HttpApiEndpoint.HttpApiEndpoint<"worktree.list", "GET", "/api/worktree/:projectID", Schema.toCodecStringTree<Schema.Struct<{
|
|
13
|
+
projectID: Schema.brand<Schema.String, "Project.ID"> & {
|
|
14
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
15
|
+
};
|
|
16
|
+
}>>, never, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
|
|
17
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
18
|
+
readonly strategy: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
19
|
+
}>>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.create", "POST", "/api/worktree/:projectID", Schema.toCodecStringTree<Schema.Struct<{
|
|
20
|
+
projectID: Schema.brand<Schema.String, "Project.ID"> & {
|
|
21
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
22
|
+
};
|
|
23
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
24
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
25
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
26
|
+
readonly from: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "AbsolutePath">>>, Schema.optionalKey<Schema.brand<Schema.String, "AbsolutePath">>, never, never>;
|
|
27
|
+
readonly strategy: Schema.brand<Schema.Trim, "Worktree.StrategyID">;
|
|
28
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
29
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
30
|
+
}>>, Schema.toCodecJson<typeof WorktreeError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.remove", "DELETE", "/api/worktree/:projectID", Schema.toCodecStringTree<Schema.Struct<{
|
|
31
|
+
projectID: Schema.brand<Schema.String, "Project.ID"> & {
|
|
32
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
33
|
+
};
|
|
34
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
35
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
36
|
+
readonly force: Schema.Boolean;
|
|
37
|
+
}>>, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof WorktreeError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"worktree.refresh", "POST", "/api/worktree/:projectID/refresh", Schema.toCodecStringTree<Schema.Struct<{
|
|
38
|
+
projectID: Schema.brand<Schema.String, "Project.ID"> & {
|
|
39
|
+
global: string & import("effect/Brand").Brand<"Project.ID">;
|
|
40
|
+
};
|
|
41
|
+
}>>, never, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof WorktreeError>, never, never>, false>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Project } from "@opencode-ai/schema/project";
|
|
2
|
+
import { Worktree } from "@opencode-ai/schema/worktree";
|
|
3
|
+
import { Schema, Struct } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
|
|
5
|
+
const root = "/api/worktree/:projectID";
|
|
6
|
+
export class WorktreeError extends Schema.ErrorClass("WorktreeError")({
|
|
7
|
+
name: Schema.Literal("WorktreeError"),
|
|
8
|
+
data: Schema.Struct({
|
|
9
|
+
message: Schema.String,
|
|
10
|
+
forceRequired: Schema.optional(Schema.Boolean),
|
|
11
|
+
}),
|
|
12
|
+
}, { httpApiStatus: 400 }) {
|
|
13
|
+
}
|
|
14
|
+
const CreatePayload = Schema.Struct(Struct.omit(Worktree.CreateInput.fields, ["projectID"]));
|
|
15
|
+
const RemovePayload = Schema.Struct(Struct.omit(Worktree.RemoveInput.fields, ["projectID"]));
|
|
16
|
+
export const WorktreeGroup = HttpApiGroup.make("server.worktree")
|
|
17
|
+
.add(HttpApiEndpoint.get("worktree.list", root, {
|
|
18
|
+
params: { projectID: Project.ID },
|
|
19
|
+
success: Worktree.List,
|
|
20
|
+
}).annotateMerge(OpenApi.annotations({
|
|
21
|
+
identifier: "v2.worktree.list",
|
|
22
|
+
summary: "List worktrees",
|
|
23
|
+
description: "List known local worktrees for a project.",
|
|
24
|
+
})))
|
|
25
|
+
.add(HttpApiEndpoint.post("worktree.create", root, {
|
|
26
|
+
params: { projectID: Project.ID },
|
|
27
|
+
payload: CreatePayload,
|
|
28
|
+
success: Worktree.Info,
|
|
29
|
+
error: WorktreeError,
|
|
30
|
+
}).annotateMerge(OpenApi.annotations({
|
|
31
|
+
identifier: "v2.worktree.create",
|
|
32
|
+
summary: "Create worktree",
|
|
33
|
+
description: "Create a worktree for a project.",
|
|
34
|
+
})))
|
|
35
|
+
.add(HttpApiEndpoint.delete("worktree.remove", root, {
|
|
36
|
+
params: { projectID: Project.ID },
|
|
37
|
+
payload: RemovePayload,
|
|
38
|
+
success: HttpApiSchema.NoContent,
|
|
39
|
+
error: WorktreeError,
|
|
40
|
+
}).annotateMerge(OpenApi.annotations({
|
|
41
|
+
identifier: "v2.worktree.remove",
|
|
42
|
+
summary: "Remove worktree",
|
|
43
|
+
description: "Remove a managed worktree from a project.",
|
|
44
|
+
})))
|
|
45
|
+
.add(HttpApiEndpoint.post("worktree.refresh", `${root}/refresh`, {
|
|
46
|
+
params: { projectID: Project.ID },
|
|
47
|
+
success: HttpApiSchema.NoContent,
|
|
48
|
+
error: WorktreeError,
|
|
49
|
+
}).annotateMerge(OpenApi.annotations({
|
|
50
|
+
identifier: "v2.worktree.refresh",
|
|
51
|
+
summary: "Refresh worktrees",
|
|
52
|
+
description: "Reconcile stored worktrees with the project repositories.",
|
|
53
|
+
})))
|
|
54
|
+
.annotateMerge(OpenApi.annotations({ title: "worktree", description: "Project worktree management routes." }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpApiMiddleware } from "effect/unstable/httpapi";
|
|
2
|
+
import { UnauthorizedError } from "../errors.js";
|
|
3
|
+
declare const Authorization_base: HttpApiMiddleware.ServiceClass<Authorization, "@opencode/HttpApiAuthorization", {
|
|
4
|
+
requires: never;
|
|
5
|
+
provides: never;
|
|
6
|
+
error: typeof UnauthorizedError;
|
|
7
|
+
clientError: never;
|
|
8
|
+
requiredForClient: false;
|
|
9
|
+
security: never;
|
|
10
|
+
}, HttpApiMiddleware.HttpApiMiddleware<never, typeof UnauthorizedError, never>>;
|
|
11
|
+
export declare class Authorization extends Authorization_base {
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpApiMiddleware } from "effect/unstable/httpapi";
|
|
2
|
+
import { InvalidRequestError } from "../errors.js";
|
|
3
|
+
declare const SchemaErrorMiddleware_base: HttpApiMiddleware.ServiceClass<SchemaErrorMiddleware, "@opencode/HttpApiSchemaError", {
|
|
4
|
+
requires: never;
|
|
5
|
+
provides: never;
|
|
6
|
+
error: typeof InvalidRequestError;
|
|
7
|
+
clientError: never;
|
|
8
|
+
requiredForClient: false;
|
|
9
|
+
security: never;
|
|
10
|
+
}, HttpApiMiddleware.HttpApiMiddleware<never, typeof InvalidRequestError, never>>;
|
|
11
|
+
export declare class SchemaErrorMiddleware extends SchemaErrorMiddleware_base {
|
|
12
|
+
}
|
|
13
|
+
export {};
|