@opencode/protocol 2.2.2 → 2.2.4
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/client.js +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +10 -0
- package/dist/groups/agent.d.ts +4 -0
- package/dist/groups/artifact.d.ts +173 -0
- package/dist/groups/artifact.js +80 -0
- package/dist/groups/credential.d.ts +2 -2
- package/dist/groups/credential.js +3 -3
- package/dist/groups/event.d.ts +333 -1
- package/dist/groups/experimental.d.ts +275 -10
- package/dist/groups/experimental.js +2 -1
- package/dist/groups/generate.d.ts +4 -0
- package/dist/groups/message.d.ts +30 -0
- package/dist/groups/model.d.ts +6 -0
- package/dist/groups/persistent-pty.d.ts +13 -4
- package/dist/groups/persistent-pty.js +6 -3
- package/dist/groups/provider.d.ts +7 -0
- package/dist/groups/schedule.d.ts +128 -12
- package/dist/groups/session.d.ts +57 -0
- package/dist/groups/usage.d.ts +1 -0
- package/package.json +2 -2
package/dist/client.js
CHANGED
package/dist/errors.d.ts
CHANGED
|
@@ -190,6 +190,12 @@ declare const PtyNotFoundError_base: Schema.Class<PtyNotFoundError, Schema.Tagge
|
|
|
190
190
|
}>, import("effect/Cause").YieldableError>;
|
|
191
191
|
export declare class PtyNotFoundError extends PtyNotFoundError_base {
|
|
192
192
|
}
|
|
193
|
+
declare const PtyFeatureUnsupportedError_base: Schema.Class<PtyFeatureUnsupportedError, Schema.TaggedStruct<"PtyFeatureUnsupportedError", {
|
|
194
|
+
readonly feature: Schema.String;
|
|
195
|
+
readonly message: Schema.String;
|
|
196
|
+
}>, import("effect/Cause").YieldableError>;
|
|
197
|
+
export declare class PtyFeatureUnsupportedError extends PtyFeatureUnsupportedError_base {
|
|
198
|
+
}
|
|
193
199
|
declare const ShellNotFoundError_base: Schema.Class<ShellNotFoundError, Schema.TaggedStruct<"ShellNotFoundError", {
|
|
194
200
|
readonly id: Schema.String;
|
|
195
201
|
readonly message: Schema.String;
|
|
@@ -228,4 +234,10 @@ declare const ScheduleNotFoundError_base: Schema.Class<ScheduleNotFoundError, Sc
|
|
|
228
234
|
}>, import("effect/Cause").YieldableError>;
|
|
229
235
|
export declare class ScheduleNotFoundError extends ScheduleNotFoundError_base {
|
|
230
236
|
}
|
|
237
|
+
declare const ArtifactNotFoundError_base: Schema.Class<ArtifactNotFoundError, Schema.TaggedStruct<"ArtifactNotFoundError", {
|
|
238
|
+
readonly artifactID: Schema.String;
|
|
239
|
+
readonly message: Schema.String;
|
|
240
|
+
}>, import("effect/Cause").YieldableError>;
|
|
241
|
+
export declare class ArtifactNotFoundError extends ArtifactNotFoundError_base {
|
|
242
|
+
}
|
|
231
243
|
export {};
|
package/dist/errors.js
CHANGED
|
@@ -150,6 +150,11 @@ export class PtyNotFoundError extends Schema.TaggedError()("PtyNotFoundError", {
|
|
|
150
150
|
message: Schema.String,
|
|
151
151
|
}, { httpApiStatus: 404 }) {
|
|
152
152
|
}
|
|
153
|
+
export class PtyFeatureUnsupportedError extends Schema.TaggedError()("PtyFeatureUnsupportedError", {
|
|
154
|
+
feature: Schema.String,
|
|
155
|
+
message: Schema.String,
|
|
156
|
+
}, { httpApiStatus: 501 }) {
|
|
157
|
+
}
|
|
153
158
|
export class ShellNotFoundError extends Schema.TaggedError()("ShellNotFoundError", {
|
|
154
159
|
id: Schema.String,
|
|
155
160
|
message: Schema.String,
|
|
@@ -190,3 +195,8 @@ export class ScheduleNotFoundError extends Schema.TaggedError()("ScheduleNotFoun
|
|
|
190
195
|
message: Schema.String,
|
|
191
196
|
}, { httpApiStatus: 404 }) {
|
|
192
197
|
}
|
|
198
|
+
export class ArtifactNotFoundError extends Schema.TaggedError()("ArtifactNotFoundError", {
|
|
199
|
+
artifactID: Schema.String,
|
|
200
|
+
message: Schema.String,
|
|
201
|
+
}, { httpApiStatus: 404 }) {
|
|
202
|
+
}
|
package/dist/groups/agent.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
|
|
|
24
24
|
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
25
25
|
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
26
26
|
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
27
|
+
claudeAgent: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
27
28
|
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
28
29
|
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
29
30
|
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
@@ -46,6 +47,7 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
|
|
|
46
47
|
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
47
48
|
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
48
49
|
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
50
|
+
claudeAgent: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
49
51
|
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
50
52
|
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
51
53
|
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
@@ -138,6 +140,7 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
|
|
|
138
140
|
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
139
141
|
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
140
142
|
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
143
|
+
claudeAgent: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
141
144
|
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
142
145
|
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
143
146
|
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
@@ -160,6 +163,7 @@ export declare const AgentGroup: HttpApiGroup.HttpApiGroup<"server.agent", HttpA
|
|
|
160
163
|
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
161
164
|
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
162
165
|
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
166
|
+
claudeAgent: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
163
167
|
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
164
168
|
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
165
169
|
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiSchema } from "effect/http-api";
|
|
3
|
+
import { ArtifactNotFoundError, FileNotFoundError, ForbiddenError, InvalidRequestError, LocationNotFoundError, ProviderNotFoundError, ServiceUnavailableError, SessionNotFoundError } from "../errors.js";
|
|
4
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
5
|
+
export declare const ArtifactEndpoints: readonly [HttpApiEndpoint.HttpApiEndpoint<"artifacts.providers", "GET", "/api/experimental/artifacts/providers", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
6
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
7
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
8
|
+
}>>;
|
|
9
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
10
|
+
readonly location: Schema.Struct<{
|
|
11
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
12
|
+
}>;
|
|
13
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
14
|
+
readonly id: Schema.brand<Schema.Trim, "Artifact.ProviderID">;
|
|
15
|
+
readonly name: Schema.String;
|
|
16
|
+
readonly capabilities: Schema.$Array<Schema.Literals<readonly ["static", "server-code", "sqlite", "durable-objects"]>>;
|
|
17
|
+
readonly default: Schema.Boolean;
|
|
18
|
+
}>>;
|
|
19
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError | typeof ForbiddenError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.list", "GET", "/api/experimental/artifacts", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
20
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
21
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly sessionID: Schema.optional<Schema.brand<Schema.String, "SessionID"> & {
|
|
24
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
25
|
+
}>;
|
|
26
|
+
readonly provider: Schema.optional<Schema.brand<Schema.Trim, "Artifact.ProviderID">>;
|
|
27
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
28
|
+
readonly location: Schema.Struct<{
|
|
29
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
30
|
+
}>;
|
|
31
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
32
|
+
readonly id: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
33
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
34
|
+
};
|
|
35
|
+
readonly provider: Schema.brand<Schema.Trim, "Artifact.ProviderID">;
|
|
36
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
37
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
38
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
39
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
40
|
+
}>, never, never>;
|
|
41
|
+
readonly title: Schema.String;
|
|
42
|
+
readonly entry: Schema.String;
|
|
43
|
+
readonly url: Schema.String;
|
|
44
|
+
readonly time: Schema.Struct<{
|
|
45
|
+
readonly created: Schema.Finite;
|
|
46
|
+
readonly updated: Schema.Finite;
|
|
47
|
+
}>;
|
|
48
|
+
}>>;
|
|
49
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError | typeof SessionNotFoundError | typeof ForbiddenError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.create", "POST", "/api/experimental/artifacts", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
50
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
51
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
52
|
+
}>>;
|
|
53
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
54
|
+
readonly title: Schema.String;
|
|
55
|
+
readonly files: Schema.$Record<Schema.String, Schema.String>;
|
|
56
|
+
readonly entry: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
57
|
+
readonly provider: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Trim, "Artifact.ProviderID">>>, Schema.optionalKey<Schema.brand<Schema.Trim, "Artifact.ProviderID">>, never, never>;
|
|
58
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
59
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
60
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
61
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
62
|
+
}>, never, never>;
|
|
63
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
64
|
+
readonly location: Schema.Struct<{
|
|
65
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
66
|
+
}>;
|
|
67
|
+
readonly data: Schema.Struct<{
|
|
68
|
+
readonly id: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
69
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
70
|
+
};
|
|
71
|
+
readonly provider: Schema.brand<Schema.Trim, "Artifact.ProviderID">;
|
|
72
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
73
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
74
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
75
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
76
|
+
}>, never, never>;
|
|
77
|
+
readonly title: Schema.String;
|
|
78
|
+
readonly entry: Schema.String;
|
|
79
|
+
readonly url: Schema.String;
|
|
80
|
+
readonly time: Schema.Struct<{
|
|
81
|
+
readonly created: Schema.Finite;
|
|
82
|
+
readonly updated: Schema.Finite;
|
|
83
|
+
}>;
|
|
84
|
+
}>;
|
|
85
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof ProviderNotFoundError | typeof SessionNotFoundError | typeof ForbiddenError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.get", "GET", "/api/experimental/artifacts/:artifactID", Schema.toCodecStringTree<Schema.Struct<{
|
|
86
|
+
artifactID: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
87
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
88
|
+
};
|
|
89
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
90
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
91
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
92
|
+
}>>;
|
|
93
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
94
|
+
readonly location: Schema.Struct<{
|
|
95
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
96
|
+
}>;
|
|
97
|
+
readonly data: Schema.Struct<{
|
|
98
|
+
readonly info: Schema.Struct<{
|
|
99
|
+
readonly id: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
100
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
101
|
+
};
|
|
102
|
+
readonly provider: Schema.brand<Schema.Trim, "Artifact.ProviderID">;
|
|
103
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
104
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
105
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
106
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
107
|
+
}>, never, never>;
|
|
108
|
+
readonly title: Schema.String;
|
|
109
|
+
readonly entry: Schema.String;
|
|
110
|
+
readonly url: Schema.String;
|
|
111
|
+
readonly time: Schema.Struct<{
|
|
112
|
+
readonly created: Schema.Finite;
|
|
113
|
+
readonly updated: Schema.Finite;
|
|
114
|
+
}>;
|
|
115
|
+
}>;
|
|
116
|
+
readonly files: Schema.$Record<Schema.String, Schema.String>;
|
|
117
|
+
}>;
|
|
118
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError | typeof ForbiddenError | typeof ArtifactNotFoundError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.update", "PATCH", "/api/experimental/artifacts/:artifactID", Schema.toCodecStringTree<Schema.Struct<{
|
|
119
|
+
artifactID: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
120
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
121
|
+
};
|
|
122
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
123
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
124
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
125
|
+
}>>;
|
|
126
|
+
}>>, Schema.toCodecJson<Schema.Struct<{
|
|
127
|
+
readonly title: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
128
|
+
readonly files: Schema.$Record<Schema.String, Schema.String>;
|
|
129
|
+
readonly entry: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
130
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
131
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
132
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
133
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
134
|
+
}>, never, never>;
|
|
135
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
136
|
+
readonly location: Schema.Struct<{
|
|
137
|
+
readonly directory: Schema.brand<Schema.String, "AbsolutePath">;
|
|
138
|
+
}>;
|
|
139
|
+
readonly data: Schema.Struct<{
|
|
140
|
+
readonly id: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
141
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
142
|
+
};
|
|
143
|
+
readonly provider: Schema.brand<Schema.Trim, "Artifact.ProviderID">;
|
|
144
|
+
readonly sessionID: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "SessionID"> & {
|
|
145
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
146
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.String, "SessionID"> & {
|
|
147
|
+
create: () => string & import("effect/Brand").Brand<"SessionID">;
|
|
148
|
+
}>, never, never>;
|
|
149
|
+
readonly title: Schema.String;
|
|
150
|
+
readonly entry: Schema.String;
|
|
151
|
+
readonly url: Schema.String;
|
|
152
|
+
readonly time: Schema.Struct<{
|
|
153
|
+
readonly created: Schema.Finite;
|
|
154
|
+
readonly updated: Schema.Finite;
|
|
155
|
+
}>;
|
|
156
|
+
}>;
|
|
157
|
+
}>>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof SessionNotFoundError | typeof ForbiddenError | typeof ArtifactNotFoundError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.delete", "DELETE", "/api/experimental/artifacts/:artifactID", Schema.toCodecStringTree<Schema.Struct<{
|
|
158
|
+
artifactID: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
159
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
160
|
+
};
|
|
161
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
162
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
163
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
164
|
+
}>>;
|
|
165
|
+
}>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<typeof LocationNotFoundError | typeof ServiceUnavailableError | typeof ForbiddenError | typeof ArtifactNotFoundError>, never, never>, HttpApiEndpoint.HttpApiEndpoint<"artifacts.view", "GET", "/api/experimental/artifacts/:artifactID/view/*", Schema.toCodecStringTree<Schema.Struct<{
|
|
166
|
+
artifactID: Schema.brand<Schema.String, "Artifact.ID"> & {
|
|
167
|
+
create: () => string & import("effect/Brand").Brand<"Artifact.ID">;
|
|
168
|
+
};
|
|
169
|
+
}>>, Schema.toCodecStringTree<Schema.Struct<{
|
|
170
|
+
readonly location: Schema.optional<Schema.Struct<{
|
|
171
|
+
readonly directory: Schema.optional<Schema.String>;
|
|
172
|
+
}>>;
|
|
173
|
+
}>>, never, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof LocationNotFoundError | typeof InvalidRequestError | typeof ServiceUnavailableError | typeof FileNotFoundError | typeof ForbiddenError | typeof ArtifactNotFoundError>, never, never>];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Artifact } from "@opencode/schema/artifact";
|
|
2
|
+
import { Location } from "@opencode/schema/location";
|
|
3
|
+
import { Session } from "@opencode/schema/session";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { HttpApiEndpoint, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
6
|
+
import { ArtifactNotFoundError, FileNotFoundError, ForbiddenError, InvalidRequestError, LocationNotFoundError, ProviderNotFoundError, ServiceUnavailableError, SessionNotFoundError, } from "../errors.js";
|
|
7
|
+
import { LocationQuery, locationQueryOpenApi } from "./location.js";
|
|
8
|
+
const EXPERIMENTAL = "Experimental: needs experimental.artifacts in the Location's config and may change without notice.";
|
|
9
|
+
const params = { artifactID: Artifact.ID };
|
|
10
|
+
const ListQuery = Schema.Struct({
|
|
11
|
+
...LocationQuery.fields,
|
|
12
|
+
sessionID: Schema.optional(Session.ID),
|
|
13
|
+
provider: Schema.optional(Artifact.ProviderID),
|
|
14
|
+
});
|
|
15
|
+
const annotations = (identifier, summary, description) => OpenApi.annotations({
|
|
16
|
+
identifier: `experimental.artifacts.${identifier}`,
|
|
17
|
+
summary,
|
|
18
|
+
description: `${description} ${EXPERIMENTAL}`,
|
|
19
|
+
transform: (operation) => ({ ...operation, tags: ["experimental"] }),
|
|
20
|
+
});
|
|
21
|
+
const commonErrors = [ForbiddenError, LocationNotFoundError, ServiceUnavailableError];
|
|
22
|
+
const itemErrors = [ArtifactNotFoundError, ...commonErrors];
|
|
23
|
+
/** Lives in the `server.experimental` group (see `groups/experimental.ts`). */
|
|
24
|
+
export const ArtifactEndpoints = [
|
|
25
|
+
HttpApiEndpoint.get("artifacts.providers", "/api/experimental/artifacts/providers", {
|
|
26
|
+
query: LocationQuery,
|
|
27
|
+
success: Location.response(Schema.Array(Artifact.Provider)),
|
|
28
|
+
error: commonErrors,
|
|
29
|
+
})
|
|
30
|
+
.annotateMerge(locationQueryOpenApi)
|
|
31
|
+
.annotateMerge(annotations("providers", "List artifact providers", "Return active artifact providers and default.")),
|
|
32
|
+
HttpApiEndpoint.get("artifacts.list", "/api/experimental/artifacts", {
|
|
33
|
+
query: ListQuery,
|
|
34
|
+
success: Location.response(Schema.Array(Artifact.Info)),
|
|
35
|
+
error: [SessionNotFoundError, ...commonErrors],
|
|
36
|
+
})
|
|
37
|
+
.annotateMerge(locationQueryOpenApi)
|
|
38
|
+
.annotateMerge(annotations("list", "List artifacts", "List published artifacts, newest update first.")),
|
|
39
|
+
HttpApiEndpoint.post("artifacts.create", "/api/experimental/artifacts", {
|
|
40
|
+
query: LocationQuery,
|
|
41
|
+
payload: Artifact.CreateInput,
|
|
42
|
+
success: Location.response(Artifact.Info),
|
|
43
|
+
error: [InvalidRequestError, ProviderNotFoundError, SessionNotFoundError, ...commonErrors],
|
|
44
|
+
})
|
|
45
|
+
.annotateMerge(locationQueryOpenApi)
|
|
46
|
+
.annotateMerge(annotations("create", "Create artifact", "Publish a new artifact through the selected or default artifact provider.")),
|
|
47
|
+
HttpApiEndpoint.get("artifacts.get", "/api/experimental/artifacts/:artifactID", {
|
|
48
|
+
params,
|
|
49
|
+
query: LocationQuery,
|
|
50
|
+
success: Location.response(Artifact.Content),
|
|
51
|
+
error: itemErrors,
|
|
52
|
+
})
|
|
53
|
+
.annotateMerge(locationQueryOpenApi)
|
|
54
|
+
.annotateMerge(annotations("get", "Read artifact", "Read an artifact's metadata and file contents.")),
|
|
55
|
+
HttpApiEndpoint.patch("artifacts.update", "/api/experimental/artifacts/:artifactID", {
|
|
56
|
+
params,
|
|
57
|
+
query: LocationQuery,
|
|
58
|
+
payload: Artifact.UpdateInput,
|
|
59
|
+
success: Location.response(Artifact.Info),
|
|
60
|
+
error: [InvalidRequestError, SessionNotFoundError, ...itemErrors],
|
|
61
|
+
})
|
|
62
|
+
.annotateMerge(locationQueryOpenApi)
|
|
63
|
+
.annotateMerge(annotations("update", "Update artifact", "Replace an artifact's files at the same ID and URL.")),
|
|
64
|
+
HttpApiEndpoint.delete("artifacts.delete", "/api/experimental/artifacts/:artifactID", {
|
|
65
|
+
params,
|
|
66
|
+
query: LocationQuery,
|
|
67
|
+
success: HttpApiSchema.NoContent,
|
|
68
|
+
error: itemErrors,
|
|
69
|
+
})
|
|
70
|
+
.annotateMerge(locationQueryOpenApi)
|
|
71
|
+
.annotateMerge(annotations("delete", "Delete artifact", "Remove an artifact and its stored files.")),
|
|
72
|
+
HttpApiEndpoint.get("artifacts.view", "/api/experimental/artifacts/:artifactID/view/*", {
|
|
73
|
+
params,
|
|
74
|
+
query: LocationQuery,
|
|
75
|
+
success: Schema.Uint8Array.pipe(HttpApiSchema.asUint8Array()),
|
|
76
|
+
error: [FileNotFoundError, InvalidRequestError, ...itemErrors],
|
|
77
|
+
})
|
|
78
|
+
.annotateMerge(locationQueryOpenApi)
|
|
79
|
+
.annotateMerge(annotations("view", "View local artifact", "Serve HTML and static files from the local provider.")),
|
|
80
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
3
|
-
import { ConflictError } from "../errors.js";
|
|
3
|
+
import { ConflictError, InvalidRequestError } from "../errors.js";
|
|
4
4
|
export declare const CredentialGroup: HttpApiGroup.HttpApiGroup<"server.credential", HttpApiEndpoint.HttpApiEndpoint<"credential.activate", "POST", "/api/credential/:credentialID/activate", Schema.toCodecStringTree<Schema.Struct<{
|
|
5
5
|
credentialID: Schema.brand<Schema.String, "Credential.ID"> & {
|
|
6
6
|
create: () => string & import("effect/Brand").Brand<"Credential.ID">;
|
|
@@ -55,7 +55,7 @@ export declare const CredentialGroup: HttpApiGroup.HttpApiGroup<"server.credenti
|
|
|
55
55
|
readonly metadata: Schema.decodeTo<Schema.optional<Schema.toType<Schema.$Record<Schema.String, Schema.Unknown>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>, never, never>;
|
|
56
56
|
}>]>;
|
|
57
57
|
}>;
|
|
58
|
-
}>>, Schema.toCodecJson<typeof ConflictError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"credential.list", "GET", "/api/credential", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
58
|
+
}>>, Schema.toCodecJson<typeof InvalidRequestError | typeof ConflictError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"credential.list", "GET", "/api/credential", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
59
59
|
readonly data: Schema.$Array<Schema.Struct<{
|
|
60
60
|
readonly id: Schema.brand<Schema.String, "Credential.ID"> & {
|
|
61
61
|
create: () => string & import("effect/Brand").Brand<"Credential.ID">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Credential } from "@opencode/schema/credential";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api";
|
|
4
|
-
import { ConflictError } from "../errors.js";
|
|
4
|
+
import { ConflictError, InvalidRequestError } from "../errors.js";
|
|
5
5
|
export const CredentialGroup = HttpApiGroup.make("server.credential")
|
|
6
6
|
.add(HttpApiEndpoint.get("credential.list", "/api/credential", {
|
|
7
7
|
success: Schema.Struct({ data: Schema.Array(Credential.Entry) }),
|
|
@@ -13,11 +13,11 @@ export const CredentialGroup = HttpApiGroup.make("server.credential")
|
|
|
13
13
|
.add(HttpApiEndpoint.post("credential.create", "/api/credential", {
|
|
14
14
|
payload: Credential.CreateInput,
|
|
15
15
|
success: Schema.Struct({ data: Credential.Entry }),
|
|
16
|
-
error: ConflictError,
|
|
16
|
+
error: [ConflictError, InvalidRequestError],
|
|
17
17
|
}).annotateMerge(OpenApi.annotations({
|
|
18
18
|
identifier: "credential.create",
|
|
19
19
|
summary: "Create credential",
|
|
20
|
-
description: "Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.",
|
|
20
|
+
description: "Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists, and with an invalid request when an `integration.connect` policy denies the integration.",
|
|
21
21
|
})))
|
|
22
22
|
.add(HttpApiEndpoint.patch("credential.update", "/api/credential/:credentialID", {
|
|
23
23
|
params: { credentialID: Credential.ID },
|