@kilocode/protocol 0.0.0-stage → 0.0.0-v2-9
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 +58 -0
- package/dist/api.js +77 -0
- package/dist/client.d.ts +63 -0
- package/dist/client.js +55 -0
- package/dist/errors.d.ts +193 -0
- package/dist/errors.js +152 -0
- package/dist/groups/agent.d.ts +225 -0
- package/dist/groups/agent.js +30 -0
- package/dist/groups/command.d.ts +15 -0
- package/dist/groups/command.js +20 -0
- package/dist/groups/config.d.ts +14 -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 +14853 -0
- package/dist/groups/event.js +51 -0
- package/dist/groups/form.d.ts +138 -0
- package/dist/groups/form.js +18 -0
- package/dist/groups/fs.d.ts +48 -0
- package/dist/groups/fs.js +73 -0
- package/dist/groups/generate.d.ts +33 -0
- package/dist/groups/generate.js +23 -0
- package/dist/groups/integration.d.ts +1724 -0
- package/dist/groups/integration.js +169 -0
- package/dist/groups/location.d.ts +23 -0
- package/dist/groups/location.js +45 -0
- package/dist/groups/mcp.d.ts +103 -0
- package/dist/groups/mcp.js +114 -0
- package/dist/groups/message.d.ts +1416 -0
- package/dist/groups/message.js +77 -0
- package/dist/groups/migration.d.ts +28 -0
- package/dist/groups/migration.js +21 -0
- package/dist/groups/model.d.ts +399 -0
- package/dist/groups/model.js +33 -0
- package/dist/groups/permission.d.ts +175 -0
- package/dist/groups/permission.js +110 -0
- package/dist/groups/persistent-pty.d.ts +242 -0
- package/dist/groups/persistent-pty.js +92 -0
- package/dist/groups/plugin.d.ts +86 -0
- package/dist/groups/plugin.js +45 -0
- package/dist/groups/project.d.ts +83 -0
- package/dist/groups/project.js +33 -0
- package/dist/groups/provider.d.ts +231 -0
- package/dist/groups/provider.js +34 -0
- package/dist/groups/pty.d.ts +151 -0
- package/dist/groups/pty.js +112 -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 +44 -0
- package/dist/groups/server.js +53 -0
- package/dist/groups/session.d.ts +11380 -0
- package/dist/groups/session.js +611 -0
- package/dist/groups/shell.d.ts +125 -0
- package/dist/groups/shell.js +64 -0
- package/dist/groups/skill.d.ts +19 -0
- package/dist/groups/skill.js +20 -0
- package/dist/groups/vcs.d.ts +87 -0
- package/dist/groups/vcs.js +93 -0
- package/dist/groups/voice.d.ts +93 -0
- package/dist/groups/voice.js +89 -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.d.ts +1830 -0
- package/dist/simulation.js +497 -0
- package/package.json +45 -4
- package/README.md +0 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Event } from "@opencode/schema/event";
|
|
2
|
+
import { EventManifest } from "@opencode/schema/event-manifest";
|
|
3
|
+
import { Location } from "@opencode/schema/location";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
6
|
+
const fields = {
|
|
7
|
+
id: Event.ID,
|
|
8
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
9
|
+
location: Schema.optional(Location.PublicRef),
|
|
10
|
+
};
|
|
11
|
+
const rpcEvent = Schema.Struct({
|
|
12
|
+
id: Event.ID,
|
|
13
|
+
created: Schema.Finite,
|
|
14
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
15
|
+
type: Schema.TemplateLiteral(["rpc.", Schema.String]),
|
|
16
|
+
location: Location.PublicRef,
|
|
17
|
+
data: Schema.Record(Schema.String, Schema.Unknown),
|
|
18
|
+
}).annotate({ identifier: "V2Event.rpc" });
|
|
19
|
+
const schema = (definitions) => Schema.Union([
|
|
20
|
+
...definitions,
|
|
21
|
+
rpcEvent,
|
|
22
|
+
...(definitions.some((definition) => definition.type === "server.connected")
|
|
23
|
+
? []
|
|
24
|
+
: [
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
...fields,
|
|
27
|
+
type: Schema.Literal("server.connected"),
|
|
28
|
+
data: Schema.Struct({}),
|
|
29
|
+
}).annotate({ identifier: "V2Event.server.connected" }),
|
|
30
|
+
]),
|
|
31
|
+
]).annotate({ identifier: "V2Event" });
|
|
32
|
+
const make = (definitions) => {
|
|
33
|
+
const EventSchema = schema(definitions);
|
|
34
|
+
return {
|
|
35
|
+
schema: EventSchema,
|
|
36
|
+
group: HttpApiGroup.make("server.event")
|
|
37
|
+
.add(HttpApiEndpoint.get("event.subscribe", "/api/event", {
|
|
38
|
+
success: HttpApiSchema.StreamSse({ data: EventSchema }),
|
|
39
|
+
}).annotateMerge(OpenApi.annotations({
|
|
40
|
+
identifier: "event.subscribe",
|
|
41
|
+
summary: "Subscribe to events",
|
|
42
|
+
description: "Subscribe to native events and plugin RPC events across all server locations. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.",
|
|
43
|
+
})))
|
|
44
|
+
.annotateMerge(OpenApi.annotations({ title: "event", description: "Experimental event stream routes." })),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export const makeEventGroup = (definitions) => make(definitions).group;
|
|
48
|
+
const event = make(EventManifest.ServerDefinitions);
|
|
49
|
+
export const EventGroup = event.group;
|
|
50
|
+
export const OpenCodeEvent = event.schema;
|
|
51
|
+
export const isOpenCodeEvent = (event) => event.type === "server.connected" || EventManifest.isServer(event) || event.type.startsWith("rpc.");
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Context, Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware } from "effect/http-api";
|
|
3
|
+
export declare const makeFormGroup: <LocationId extends HttpApiMiddleware.AnyId, LocationService>(locationMiddleware: Context.Key<LocationId, LocationService>) => HttpApiGroup.HttpApiGroup<"server.form", HttpApiEndpoint.HttpApiEndpoint<"form.list", "GET", "/api/form", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
4
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
5
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
6
|
+
}>>;
|
|
7
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
8
|
+
readonly location: Schema.Struct<{
|
|
9
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
10
|
+
}>;
|
|
11
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
12
|
+
readonly id: Schema.brand<Schema.String, "Form.ID"> & {
|
|
13
|
+
create: (id?: string) => string & import("effect/Brand").Brand<"Form.ID">;
|
|
14
|
+
};
|
|
15
|
+
readonly sessionID: Schema.String;
|
|
16
|
+
readonly title: Schema.String;
|
|
17
|
+
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
18
|
+
readonly fields: Schema.NonEmptyArray<Schema.Union<readonly [Schema.Struct<{
|
|
19
|
+
readonly key: Schema.String;
|
|
20
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
21
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
22
|
+
readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
23
|
+
readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
24
|
+
readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
25
|
+
readonly key: Schema.String;
|
|
26
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
27
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
28
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
29
|
+
readonly key: Schema.String;
|
|
30
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
31
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
32
|
+
}>>>, never, never>;
|
|
33
|
+
readonly type: Schema.Literal<"string">;
|
|
34
|
+
readonly format: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["email", "uri", "date", "date-time"]>>>, Schema.optionalKey<Schema.Literals<readonly ["email", "uri", "date", "date-time"]>>, never, never>;
|
|
35
|
+
readonly minLength: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
36
|
+
readonly maxLength: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
37
|
+
readonly pattern: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
38
|
+
readonly placeholder: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
39
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
40
|
+
readonly options: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
41
|
+
readonly value: Schema.String;
|
|
42
|
+
readonly label: Schema.String;
|
|
43
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
44
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
45
|
+
readonly value: Schema.String;
|
|
46
|
+
readonly label: Schema.String;
|
|
47
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
48
|
+
}>>>, never, never>;
|
|
49
|
+
readonly custom: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
50
|
+
}>, Schema.Struct<{
|
|
51
|
+
readonly key: Schema.String;
|
|
52
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
53
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
54
|
+
readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
55
|
+
readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
56
|
+
readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
57
|
+
readonly key: Schema.String;
|
|
58
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
59
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
60
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
61
|
+
readonly key: Schema.String;
|
|
62
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
63
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
64
|
+
}>>>, never, never>;
|
|
65
|
+
readonly type: Schema.Literal<"number">;
|
|
66
|
+
readonly minimum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
67
|
+
readonly maximum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
68
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
69
|
+
}>, Schema.Struct<{
|
|
70
|
+
readonly key: Schema.String;
|
|
71
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
72
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
73
|
+
readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
74
|
+
readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
75
|
+
readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
76
|
+
readonly key: Schema.String;
|
|
77
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
78
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
79
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
80
|
+
readonly key: Schema.String;
|
|
81
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
82
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
83
|
+
}>>>, never, never>;
|
|
84
|
+
readonly type: Schema.Literal<"integer">;
|
|
85
|
+
readonly minimum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
86
|
+
readonly maximum: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
87
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Number>>, Schema.optionalKey<Schema.Number>, never, never>;
|
|
88
|
+
}>, Schema.Struct<{
|
|
89
|
+
readonly key: Schema.String;
|
|
90
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
91
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
92
|
+
readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
93
|
+
readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
94
|
+
readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
95
|
+
readonly key: Schema.String;
|
|
96
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
97
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
98
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
99
|
+
readonly key: Schema.String;
|
|
100
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
101
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
102
|
+
}>>>, never, never>;
|
|
103
|
+
readonly type: Schema.Literal<"boolean">;
|
|
104
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
105
|
+
}>, Schema.Struct<{
|
|
106
|
+
readonly key: Schema.String;
|
|
107
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
108
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
109
|
+
readonly required: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
110
|
+
readonly hidden: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
111
|
+
readonly when: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.Struct<{
|
|
112
|
+
readonly key: Schema.String;
|
|
113
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
114
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
115
|
+
}>>>>, Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
116
|
+
readonly key: Schema.String;
|
|
117
|
+
readonly op: Schema.Literals<readonly ["eq", "neq"]>;
|
|
118
|
+
readonly value: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>;
|
|
119
|
+
}>>>, never, never>;
|
|
120
|
+
readonly type: Schema.Literal<"multiselect">;
|
|
121
|
+
readonly options: Schema.$Array<Schema.Struct<{
|
|
122
|
+
readonly value: Schema.String;
|
|
123
|
+
readonly label: Schema.String;
|
|
124
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
125
|
+
}>>;
|
|
126
|
+
readonly minItems: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
127
|
+
readonly maxItems: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Int>>, Schema.optionalKey<Schema.Int>, never, never>;
|
|
128
|
+
readonly custom: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Boolean>>, Schema.optionalKey<Schema.Boolean>, never, never>;
|
|
129
|
+
readonly default: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Array<Schema.String>>>, Schema.optionalKey<Schema.$Array<Schema.String>>, never, never>;
|
|
130
|
+
}>, Schema.Struct<{
|
|
131
|
+
readonly key: Schema.String;
|
|
132
|
+
readonly type: Schema.Literal<"external">;
|
|
133
|
+
readonly url: Schema.String;
|
|
134
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
135
|
+
readonly description: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
136
|
+
}>]>>;
|
|
137
|
+
}>>;
|
|
138
|
+
}>>, never, LocationId, HttpApiMiddleware.Requires<LocationId>>, false>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Form } from "@opencode/schema/form";
|
|
2
|
+
import { Location } from "@opencode/schema/location";
|
|
3
|
+
import { Context, Schema } from "effect";
|
|
4
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, OpenApi } from "effect/http-api";
|
|
5
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
6
|
+
export const makeFormGroup = (locationMiddleware) => HttpApiGroup.make("server.form")
|
|
7
|
+
.add(HttpApiEndpoint.get("form.list", "/api/form", {
|
|
8
|
+
query: LocationQuery,
|
|
9
|
+
success: Location.response(Schema.Array(Form.Info)),
|
|
10
|
+
})
|
|
11
|
+
.annotateMerge(locationQueryOpenApi)
|
|
12
|
+
.annotateMerge(OpenApi.annotations({
|
|
13
|
+
identifier: "form.list",
|
|
14
|
+
summary: "List pending forms",
|
|
15
|
+
description: "Retrieve pending forms for a location.",
|
|
16
|
+
})))
|
|
17
|
+
.middleware(locationMiddleware)
|
|
18
|
+
.annotateMerge(OpenApi.annotations({ title: "form", description: "Location form routes." }));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
3
|
+
import { FileNotFoundError } from "../errors.js";
|
|
4
|
+
export declare const FileSystemGroup: HttpApiGroup.HttpApiGroup<"server.fs", HttpApiEndpoint.HttpApiEndpoint<"fs.find", "GET", "/api/fs/find", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
5
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
6
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
7
|
+
}>>;
|
|
8
|
+
readonly query: Schema.String;
|
|
9
|
+
readonly type: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literals<readonly ["file", "directory"]>>>, Schema.optionalKey<Schema.Literals<readonly ["file", "directory"]>>, never, never>;
|
|
10
|
+
readonly limit: Schema.optional<Schema.compose<Schema.Int, Schema.NumberFromString>>;
|
|
11
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
12
|
+
readonly location: Schema.Struct<{
|
|
13
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
14
|
+
}>;
|
|
15
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
16
|
+
readonly path: Schema.brand<Schema.String, "RelativePath">;
|
|
17
|
+
readonly type: Schema.Literals<readonly ["file", "directory"]>;
|
|
18
|
+
}>>;
|
|
19
|
+
}>>, never, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.list", "GET", "/api/fs/list", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
20
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
21
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly path: Schema.optional<Schema.String>;
|
|
24
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
25
|
+
readonly location: Schema.Struct<{
|
|
26
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
27
|
+
}>;
|
|
28
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
29
|
+
readonly path: Schema.brand<Schema.String, "RelativePath">;
|
|
30
|
+
readonly type: Schema.Literals<readonly ["file", "directory"]>;
|
|
31
|
+
}>>;
|
|
32
|
+
}>>, Schema.toCodecJson<typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.read", "GET", "/api/fs/read/*", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
33
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
34
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
35
|
+
}>>;
|
|
36
|
+
}>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof FileNotFoundError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"fs.write", "POST", "/api/experimental/fs/write", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
37
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
38
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
39
|
+
}>>;
|
|
40
|
+
readonly path: Schema.String;
|
|
41
|
+
}>>, Schema.toCodecJson<Schema.Uint8Array>, never, Schema.toCodecJson<Schema.Struct<{
|
|
42
|
+
readonly location: Schema.Struct<{
|
|
43
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
44
|
+
}>;
|
|
45
|
+
readonly data: Schema.Struct<{
|
|
46
|
+
readonly path: Schema.brand<Schema.String, "AbsolutePath">;
|
|
47
|
+
}>;
|
|
48
|
+
}>>, never, never, never>, false>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FileSystem } from "@opencode/schema/filesystem";
|
|
2
|
+
import { Location } from "@opencode/schema/location";
|
|
3
|
+
import { PositiveInt } from "@opencode/schema/schema";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
6
|
+
import { FileNotFoundError } from "../errors.js";
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
|
+
const ListQuery = Schema.Struct({
|
|
9
|
+
...LocationQuery.fields,
|
|
10
|
+
path: Schema.String.pipe(Schema.optional).annotate({
|
|
11
|
+
description: "An absolute path or a path relative to the requested location. Defaults to the location directory.",
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
const WriteQuery = Schema.Struct({
|
|
15
|
+
...LocationQuery.fields,
|
|
16
|
+
path: Schema.String.annotate({
|
|
17
|
+
description: "An absolute path or a path relative to the requested location. Missing parent directories are created.",
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
const FindQuery = Schema.Struct({
|
|
21
|
+
...LocationQuery.fields,
|
|
22
|
+
query: FileSystem.FindInput.fields.query,
|
|
23
|
+
type: FileSystem.FindInput.fields.type,
|
|
24
|
+
limit: Schema.NumberFromString.pipe(Schema.decodeTo(PositiveInt), Schema.optional),
|
|
25
|
+
});
|
|
26
|
+
export const FileSystemGroup = HttpApiGroup.make("server.fs")
|
|
27
|
+
.add(HttpApiEndpoint.get("fs.read", "/api/fs/read/*", {
|
|
28
|
+
query: LocationQuery,
|
|
29
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
30
|
+
error: FileNotFoundError,
|
|
31
|
+
})
|
|
32
|
+
.annotateMerge(locationQueryOpenApi)
|
|
33
|
+
.annotateMerge(OpenApi.annotations({
|
|
34
|
+
identifier: "fs.read",
|
|
35
|
+
summary: "Read file",
|
|
36
|
+
description: "Stream one file relative to the requested location with ETag, Last-Modified, and single-range HTTP Range support (206 Partial Content, 416 Range Not Satisfiable, and 304 Not Modified; multi-range and malformed Range headers fall back to 200).",
|
|
37
|
+
})))
|
|
38
|
+
.add(HttpApiEndpoint.get("fs.list", "/api/fs/list", {
|
|
39
|
+
query: ListQuery,
|
|
40
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
41
|
+
error: FileNotFoundError,
|
|
42
|
+
})
|
|
43
|
+
.annotateMerge(locationQueryOpenApi)
|
|
44
|
+
.annotateMerge(OpenApi.annotations({
|
|
45
|
+
identifier: "fs.list",
|
|
46
|
+
summary: "List directory",
|
|
47
|
+
description: "List direct children using an absolute path or a path relative to the requested location, including parents and siblings outside its directory. Entry paths remain relative to the requested location; listing does not switch locations.",
|
|
48
|
+
})))
|
|
49
|
+
.add(HttpApiEndpoint.get("fs.find", "/api/fs/find", {
|
|
50
|
+
query: FindQuery,
|
|
51
|
+
success: Location.response(Schema.Array(FileSystem.Entry)),
|
|
52
|
+
})
|
|
53
|
+
.annotateMerge(locationQueryOpenApi)
|
|
54
|
+
.annotateMerge(OpenApi.annotations({
|
|
55
|
+
identifier: "fs.find",
|
|
56
|
+
summary: "Find files",
|
|
57
|
+
description: "Find recursively ranked filesystem entries relative to the requested location.",
|
|
58
|
+
})))
|
|
59
|
+
.add(HttpApiEndpoint.post("fs.write", "/api/experimental/fs/write", {
|
|
60
|
+
query: WriteQuery,
|
|
61
|
+
payload: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
62
|
+
success: Location.response(FileSystem.Write),
|
|
63
|
+
})
|
|
64
|
+
.annotateMerge(locationQueryOpenApi)
|
|
65
|
+
.annotateMerge(OpenApi.annotations({
|
|
66
|
+
identifier: "experimental.fs.write",
|
|
67
|
+
summary: "Write file",
|
|
68
|
+
description: "Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.",
|
|
69
|
+
})))
|
|
70
|
+
.annotateMerge(OpenApi.annotations({
|
|
71
|
+
title: "filesystem",
|
|
72
|
+
description: "Experimental location-scoped filesystem routes.",
|
|
73
|
+
}));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
3
|
+
import { LocationNotFoundError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
4
|
+
export declare const GenerateGroup: HttpApiGroup.HttpApiGroup<"server.generate", HttpApiEndpoint.HttpApiEndpoint<"generate.text", "POST", "/api/experimental/generate", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
5
|
+
readonly prompt: Schema.String;
|
|
6
|
+
readonly model: Schema.optional<Schema.Struct<{
|
|
7
|
+
readonly id: Schema.brand<Schema.String, "Model.ID">;
|
|
8
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
9
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
10
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
11
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
12
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
13
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
14
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
15
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
16
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
17
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
18
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
19
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
20
|
+
};
|
|
21
|
+
readonly variant: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Model.VariantID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Model.VariantID">>, never, never>;
|
|
22
|
+
}> & {
|
|
23
|
+
parse: (input: string) => {
|
|
24
|
+
readonly id: string & import("effect/Brand").Brand<"Model.ID">;
|
|
25
|
+
readonly providerID: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
26
|
+
readonly variant?: (string & import("effect/Brand").Brand<"Model.VariantID">) | undefined;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
30
|
+
readonly data: Schema.Struct<{
|
|
31
|
+
readonly text: Schema.String;
|
|
32
|
+
}>;
|
|
33
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError>, never, never>, false>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Model } from "@opencode/schema/model";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
|
|
4
|
+
import { LocationNotFoundError, InvalidRequestError, ServiceUnavailableError } from "../errors.js";
|
|
5
|
+
export const GenerateGroup = HttpApiGroup.make("server.generate")
|
|
6
|
+
.add(HttpApiEndpoint.post("generate.text", "/api/experimental/generate", {
|
|
7
|
+
payload: Schema.Struct({
|
|
8
|
+
prompt: Schema.String,
|
|
9
|
+
model: Model.Ref.pipe(Schema.optional),
|
|
10
|
+
}),
|
|
11
|
+
success: Schema.Struct({
|
|
12
|
+
data: Schema.Struct({ text: Schema.String }),
|
|
13
|
+
}).annotate({ identifier: "GenerateTextResponse" }),
|
|
14
|
+
error: [InvalidRequestError, ServiceUnavailableError, LocationNotFoundError],
|
|
15
|
+
}).annotateMerge(OpenApi.annotations({
|
|
16
|
+
identifier: "experimental.generate.text",
|
|
17
|
+
summary: "Generate text",
|
|
18
|
+
description: "Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.",
|
|
19
|
+
})))
|
|
20
|
+
.annotateMerge(OpenApi.annotations({
|
|
21
|
+
title: "generate",
|
|
22
|
+
description: "Experimental one-shot generation routes.",
|
|
23
|
+
}));
|