@opencode/server 0.0.0-dev-19575 → 0.0.0-dev-19579
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.
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Credential } from "@opencode/core/credential";
|
|
2
|
+
export declare const CredentialHandler: import("effect/Layer").Layer<import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.credential">, never, import("@opencode/protocol/middleware/schema-error").SchemaErrorMiddleware | import("@opencode/protocol/middleware/authorization").Authorization | import("effect/unstable/http/HttpRouter").Request<"Requires", Credential.Service>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Credential } from "@opencode/core/credential";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
4
4
|
import { Api } from "../api";
|
|
5
5
|
export const CredentialHandler = HttpApiBuilder.group(Api, "server.credential", (handlers) => handlers.handle("credential.update", Effect.fn(function* (ctx) {
|
|
6
|
-
yield* (yield*
|
|
6
|
+
yield* (yield* Credential.Service).update(ctx.params.credentialID, { label: ctx.payload.label });
|
|
7
7
|
return HttpApiSchema.NoContent.make();
|
|
8
8
|
})).handle("credential.activate", Effect.fn(function* (ctx) {
|
|
9
|
-
yield* (yield*
|
|
9
|
+
yield* (yield* Credential.Service).activate(ctx.params.credentialID);
|
|
10
10
|
return HttpApiSchema.NoContent.make();
|
|
11
11
|
})).handle("credential.remove", Effect.fn(function* (ctx) {
|
|
12
|
-
yield* (yield*
|
|
12
|
+
yield* (yield* Credential.Service).remove(ctx.params.credentialID);
|
|
13
13
|
return HttpApiSchema.NoContent.make();
|
|
14
14
|
})));
|
|
@@ -2,7 +2,12 @@ import { Integration } from "@opencode/core/integration";
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
4
4
|
import { Api } from "../api";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IntegrationAttemptNotFoundError,
|
|
7
|
+
IntegrationMethodNotFoundError,
|
|
8
|
+
IntegrationNotFoundError,
|
|
9
|
+
InvalidRequestError
|
|
10
|
+
} from "@opencode/protocol/errors";
|
|
6
11
|
import { response } from "../location";
|
|
7
12
|
import { WellKnown } from "@opencode/core/wellknown";
|
|
8
13
|
const authorize = (effect) => effect.pipe(Effect.mapError((error) => new InvalidRequestError({
|
|
@@ -28,6 +33,11 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|
|
28
33
|
return HttpApiSchema.NoContent.make();
|
|
29
34
|
})).handle("integration.connect.key", Effect.fn(function* (ctx) {
|
|
30
35
|
const service = yield* Integration.Service;
|
|
36
|
+
if (!(yield* service.get(ctx.params.integrationID)))
|
|
37
|
+
return yield* new IntegrationNotFoundError({
|
|
38
|
+
integrationID: ctx.params.integrationID,
|
|
39
|
+
message: `Integration not found: ${ctx.params.integrationID}`
|
|
40
|
+
});
|
|
31
41
|
yield* authorize(service.connection.key({
|
|
32
42
|
integrationID: ctx.params.integrationID,
|
|
33
43
|
key: ctx.payload.key,
|
|
@@ -45,19 +55,42 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|
|
45
55
|
})));
|
|
46
56
|
})).handle("integration.oauth.status", Effect.fn(function* (ctx) {
|
|
47
57
|
const service = yield* Integration.Service;
|
|
58
|
+
if (!(yield* service.get(ctx.params.integrationID)))
|
|
59
|
+
return yield* new IntegrationNotFoundError({
|
|
60
|
+
integrationID: ctx.params.integrationID,
|
|
61
|
+
message: `Integration not found: ${ctx.params.integrationID}`
|
|
62
|
+
});
|
|
48
63
|
return yield* response(service.oauth.status({
|
|
49
64
|
integrationID: ctx.params.integrationID,
|
|
50
65
|
attemptID: ctx.params.attemptID
|
|
51
|
-
}))
|
|
66
|
+
}).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
|
|
67
|
+
integrationID: error.integrationID,
|
|
68
|
+
attemptID: error.attemptID,
|
|
69
|
+
message: `OAuth attempt not found: ${error.attemptID}`
|
|
70
|
+
}))));
|
|
52
71
|
})).handle("integration.oauth.complete", Effect.fn(function* (ctx) {
|
|
53
|
-
|
|
72
|
+
const service = yield* Integration.Service;
|
|
73
|
+
if (!(yield* service.get(ctx.params.integrationID)))
|
|
74
|
+
return yield* new IntegrationNotFoundError({
|
|
75
|
+
integrationID: ctx.params.integrationID,
|
|
76
|
+
message: `Integration not found: ${ctx.params.integrationID}`
|
|
77
|
+
});
|
|
78
|
+
yield* service.oauth.complete({
|
|
54
79
|
integrationID: ctx.params.integrationID,
|
|
55
80
|
attemptID: ctx.params.attemptID,
|
|
56
81
|
code: ctx.payload.code
|
|
57
|
-
}).pipe(Effect.mapError((error) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
}).pipe(Effect.mapError((error) => {
|
|
83
|
+
if (error._tag === "Integration.AttemptNotFound")
|
|
84
|
+
return new IntegrationAttemptNotFoundError({
|
|
85
|
+
integrationID: error.integrationID,
|
|
86
|
+
attemptID: error.attemptID,
|
|
87
|
+
message: `OAuth attempt not found: ${error.attemptID}`
|
|
88
|
+
});
|
|
89
|
+
return new InvalidRequestError({
|
|
90
|
+
message: error._tag === "Integration.CodeRequired" ? "Authorization code is required" : "Authentication failed",
|
|
91
|
+
kind: error._tag === "Integration.CodeRequired" ? "integration_code_required" : "integration_authorization"
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
61
94
|
return HttpApiSchema.NoContent.make();
|
|
62
95
|
})).handle("integration.oauth.cancel", Effect.fn(function* (ctx) {
|
|
63
96
|
yield* (yield* Integration.Service).oauth.cancel({
|
|
@@ -66,7 +99,18 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|
|
66
99
|
});
|
|
67
100
|
return HttpApiSchema.NoContent.make();
|
|
68
101
|
})).handle("integration.command.connect", Effect.fn(function* (ctx) {
|
|
69
|
-
const service = yield* Integration.Service;
|
|
102
|
+
const service = yield* Integration.Service, integration = yield* service.get(ctx.params.integrationID);
|
|
103
|
+
if (!integration)
|
|
104
|
+
return yield* new IntegrationNotFoundError({
|
|
105
|
+
integrationID: ctx.params.integrationID,
|
|
106
|
+
message: `Integration not found: ${ctx.params.integrationID}`
|
|
107
|
+
});
|
|
108
|
+
if (!integration.methods.some((method) => method.type === "command" && method.id === ctx.payload.methodID))
|
|
109
|
+
return yield* new IntegrationMethodNotFoundError({
|
|
110
|
+
integrationID: ctx.params.integrationID,
|
|
111
|
+
methodID: ctx.payload.methodID,
|
|
112
|
+
message: `Integration method not found: ${ctx.payload.methodID}`
|
|
113
|
+
});
|
|
70
114
|
return yield* response(authorize(service.command.connect({
|
|
71
115
|
integrationID: ctx.params.integrationID,
|
|
72
116
|
methodID: ctx.payload.methodID,
|
|
@@ -74,10 +118,19 @@ export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration"
|
|
|
74
118
|
})));
|
|
75
119
|
})).handle("integration.command.status", Effect.fn(function* (ctx) {
|
|
76
120
|
const service = yield* Integration.Service;
|
|
121
|
+
if (!(yield* service.get(ctx.params.integrationID)))
|
|
122
|
+
return yield* new IntegrationNotFoundError({
|
|
123
|
+
integrationID: ctx.params.integrationID,
|
|
124
|
+
message: `Integration not found: ${ctx.params.integrationID}`
|
|
125
|
+
});
|
|
77
126
|
return yield* response(service.command.status({
|
|
78
127
|
integrationID: ctx.params.integrationID,
|
|
79
128
|
attemptID: ctx.params.attemptID
|
|
80
|
-
}))
|
|
129
|
+
}).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
|
|
130
|
+
integrationID: error.integrationID,
|
|
131
|
+
attemptID: error.attemptID,
|
|
132
|
+
message: `Command attempt not found: ${error.attemptID}`
|
|
133
|
+
}))));
|
|
81
134
|
})).handle("integration.command.cancel", Effect.fn(function* (ctx) {
|
|
82
135
|
yield* (yield* Integration.Service).command.cancel({
|
|
83
136
|
integrationID: ctx.params.integrationID,
|
package/dist/handlers/session.js
CHANGED
|
@@ -113,7 +113,7 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl
|
|
|
113
113
|
return HttpApiSchema.NoContent.make();
|
|
114
114
|
})).handle("session.fork", Effect.fn(function* (ctx) {
|
|
115
115
|
return {
|
|
116
|
-
data: yield* session.fork({ sessionID: ctx.params.sessionID,
|
|
116
|
+
data: yield* session.fork({ sessionID: ctx.params.sessionID, before: ctx.payload.before }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.ForkEmptyError", (error) => new InvalidRequestError({ message: error.message, kind: "empty_session" })))
|
|
117
117
|
};
|
|
118
118
|
})).handle("session.switchAgent", Effect.fn(function* (ctx) {
|
|
119
119
|
yield* session.switchAgent({ sessionID: ctx.params.sessionID, agent: ctx.payload.agent }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
package/dist/handlers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
export declare const handlers: Layer.Layer<import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.generate"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.message"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.model"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.provider"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.session"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.permission"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.fs"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.form"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.command"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.skill"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.rpc"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.event"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.agent"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.plugin"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.server"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.debug"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.pty"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.experimental"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.shell"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.reference"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.location"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.integration"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.websearch"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.mcp"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.credential"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.project"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.worktree"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.vcs"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.migration"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.config">, never, import("@opencode/protocol/middleware/schema-error").SchemaErrorMiddleware | import("@opencode/protocol/middleware/authorization").Authorization | import("@opencode/util/global").Service | import("@opencode/core/bus").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/location-service-map").Service | import("@opencode/core/session").Service | import("@opencode/core/instance").Service | import("./location").LocationMiddleware | import("./middleware/form-location").FormLocationMiddleware | import("./middleware/session-location").SessionLocationMiddleware | import("@opencode/core/pty/ticket").Service | import("@opencode/core/session/transfer").Service | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/database/database").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/permission/saved").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/plugin/update").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("./server-info").Service> | import("./pty-environment").Service | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/wellknown").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/project").Service>>;
|
|
2
|
+
export declare const handlers: Layer.Layer<import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.generate"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.message"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.model"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.provider"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.session"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.permission"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.fs"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.form"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.command"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.skill"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.rpc"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.event"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.agent"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.plugin"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.server"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.debug"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.pty"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.experimental"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.shell"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.reference"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.location"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.integration"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.websearch"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.mcp"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.credential"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.project"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.worktree"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.vcs"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.migration"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.config">, never, import("@opencode/protocol/middleware/schema-error").SchemaErrorMiddleware | import("@opencode/protocol/middleware/authorization").Authorization | import("@opencode/util/global").Service | import("@opencode/core/bus").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/location-service-map").Service | import("@opencode/core/session").Service | import("@opencode/core/instance").Service | import("./location").LocationMiddleware | import("./middleware/form-location").FormLocationMiddleware | import("./middleware/session-location").SessionLocationMiddleware | import("@opencode/core/pty/ticket").Service | import("@opencode/core/session/transfer").Service | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/database/database").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/permission/saved").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/plugin/update").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("./server-info").Service> | import("./pty-environment").Service | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/wellknown").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/credential").Service> | import("effect/unstable/http/HttpRouter").Request<"Requires", import("@opencode/core/project").Service>>;
|
package/dist/routes.js
CHANGED
|
@@ -110,7 +110,7 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
110
110
|
const { simulationReplacements } = yield* Effect.promise(() => import("@opencode/simulation/backend")), simulation = yield* simulationReplacements({ version: App.make(options.app).version });
|
|
111
111
|
return build([...overrides, ...simulation]);
|
|
112
112
|
})) : build(overrides)).pipe(Layer.flatMap((context) => {
|
|
113
|
-
const services = Layer.succeedContext(context), requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), ServerInfo.layer(serviceURLs, options.app)), api = HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig, options)))), Layer.provide(formLocationLayer), Layer.provide(sessionLocationLayer), Layer.provide(layer), Layer.provide(authorizationLayer), Layer.provide(schemaErrorLayer), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
|
|
113
|
+
const services = Layer.succeedContext(context), requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), ServerInfo.layer(serviceURLs, options.app)), api = HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig, options)))), Layer.provide(formLocationLayer), Layer.provide(sessionLocationLayer), Layer.provide(layer), Layer.provide(authorizationLayer), Layer.provide(schemaErrorLayer), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
|
|
114
114
|
return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
|
|
115
115
|
}));
|
|
116
116
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/server",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-19579",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@effect/platform-node": "4.0.0-rc.112",
|
|
32
32
|
"@effect/platform-node-shared": "4.0.0-rc.112",
|
|
33
|
-
"@opencode/core": "0.0.0-dev-
|
|
34
|
-
"@opencode/protocol": "0.0.0-dev-
|
|
35
|
-
"@opencode/schema": "0.0.0-dev-
|
|
36
|
-
"@opencode/simulation": "0.0.0-dev-
|
|
37
|
-
"@opencode/util": "0.0.0-dev-
|
|
33
|
+
"@opencode/core": "0.0.0-dev-19579",
|
|
34
|
+
"@opencode/protocol": "0.0.0-dev-19579",
|
|
35
|
+
"@opencode/schema": "0.0.0-dev-19579",
|
|
36
|
+
"@opencode/simulation": "0.0.0-dev-19579",
|
|
37
|
+
"@opencode/util": "0.0.0-dev-19579",
|
|
38
38
|
"drizzle-orm": "1.0.0-rc.5-169397b",
|
|
39
39
|
"effect": "4.0.0-rc.112"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@opencode/client": "0.0.0-dev-
|
|
43
|
-
"@opencode/plugin": "0.0.0-dev-
|
|
42
|
+
"@opencode/client": "0.0.0-dev-19579",
|
|
43
|
+
"@opencode/plugin": "0.0.0-dev-19579",
|
|
44
44
|
"@tsconfig/bun": "1.0.9",
|
|
45
45
|
"@types/bun": "1.4.0",
|
|
46
46
|
"@typescript/native-preview": "7.0.0-dev.20251207.1"
|