@opencode/server 0.0.0-dev-19552 → 0.0.0-dev-19553

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.
@@ -2,6 +2,11 @@ import { Effect } from "effect";
2
2
  import { HttpApiBuilder } from "effect/unstable/httpapi";
3
3
  import { Api } from "../api";
4
4
  import { ServerInfo } from "../server-info";
5
- export const ServerHandler = HttpApiBuilder.group(Api, "server.server", (handlers) => handlers.handle("server.get", () => Effect.gen(function* () {
6
- return { urls: (yield* ServerInfo.Service).urls() };
5
+ export const ServerHandler = HttpApiBuilder.group(Api, "server.server", (handlers) => handlers.handle("server.status", () => Effect.gen(function* () {
6
+ const info = yield* ServerInfo.Service;
7
+ return {
8
+ version: info.app.version ?? "unknown",
9
+ pid: process.pid ?? 0,
10
+ urls: info.urls()
11
+ };
7
12
  })));
@@ -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.health"> | 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"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.workspace">, 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/workspace").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"> | import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.workspace">, 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/workspace").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>>;
package/dist/handlers.js CHANGED
@@ -13,7 +13,6 @@ import { RpcHandler } from "./handlers/rpc";
13
13
  import { EventHandler } from "./handlers/event";
14
14
  import { AgentHandler } from "./handlers/agent";
15
15
  import { PluginHandler } from "./handlers/plugin";
16
- import { HealthHandler } from "./handlers/health";
17
16
  import { ServerHandler } from "./handlers/server";
18
17
  import { DebugHandler } from "./handlers/debug";
19
18
  import { PtyHandler } from "./handlers/pty";
@@ -32,4 +31,4 @@ import { EventFeed } from "./event-feed";
32
31
  import { MigrationHandler } from "./handlers/migration";
33
32
  import { ConfigHandler } from "./handlers/config";
34
33
  import { WorkspaceHandler } from "./handlers/workspace";
35
- export const handlers = Layer.mergeAll(HealthHandler, ServerHandler, DebugHandler, MigrationHandler, LocationHandler, AgentHandler, PluginHandler, SessionHandler, MessageHandler, ModelHandler, GenerateHandler, ProviderHandler, IntegrationHandler, WebSearchHandler, McpHandler, CredentialHandler, ProjectHandler, FormHandler, PermissionHandler, FileSystemHandler, CommandHandler, SkillHandler, RpcHandler, EventHandler.pipe(Layer.provide(EventFeed.layer)), PtyHandler, PersistentPtyHandler, ShellHandler, ReferenceHandler, WorktreeHandler, WorkspaceHandler, VcsHandler, ConfigHandler);
34
+ export const handlers = Layer.mergeAll(ServerHandler, DebugHandler, MigrationHandler, LocationHandler, AgentHandler, PluginHandler, SessionHandler, MessageHandler, ModelHandler, GenerateHandler, ProviderHandler, IntegrationHandler, WebSearchHandler, McpHandler, CredentialHandler, ProjectHandler, FormHandler, PermissionHandler, FileSystemHandler, CommandHandler, SkillHandler, RpcHandler, EventHandler.pipe(Layer.provide(EventFeed.layer)), PtyHandler, PersistentPtyHandler, ShellHandler, ReferenceHandler, WorktreeHandler, WorkspaceHandler, VcsHandler, ConfigHandler);
package/dist/process.js CHANGED
@@ -27,8 +27,14 @@ export const start = Effect.fn("ServerProcess.start")(function* (options, lifecy
27
27
  const password = options.password;
28
28
  if (!password)
29
29
  return yield* Effect.fail(Error("Missing server password"));
30
- const hostname = options.hostname ?? "127.0.0.1", port = Option.fromNullishOr(options.port), shutdown = yield* Latch.make(), status = yield* Status.make(), bound = yield* listen({ hostname, port }), application = yield* Ref.make(Option.none());
31
- yield* bound.http.serve(dispatch(password, status, application, options.app?.version ?? "unknown").pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin(origin, options), maxAge: 86400 })), errorResponseLogger).pipe(withoutParentSpan);
30
+ const hostname = options.hostname ?? "127.0.0.1", port = Option.fromNullishOr(options.port), shutdown = yield* Latch.make(), status = yield* Status.make(), bound = yield* listen({ hostname, port }), urls = () => {
31
+ const address = bound.server.address();
32
+ if (address === null || typeof address === "string")
33
+ return [];
34
+ const host = address.family === "IPv6" ? `[${address.address}]` : address.address;
35
+ return ServerInfo.connectionURLs(`http://${host}:${address.port}`, hostname);
36
+ }, application = yield* Ref.make(Option.none());
37
+ yield* bound.http.serve(dispatch(password, status, application, options.app?.version ?? "unknown", urls).pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin(origin, options), maxAge: 86400 })), errorResponseLogger).pipe(withoutParentSpan);
32
38
  if (lifecycle)
33
39
  yield* lifecycle.onListen(bound.http.address, shutdown.open.pipe(Effect.asVoid)).pipe(Effect.flatMap((cleanup) => Effect.addFinalizer(() => Scope.close(bound.scope, Exit.void).pipe(Effect.andThen(cleanup)))), Effect.uninterruptible);
34
40
  const parentScope = yield* Scope.Scope, applicationScope = yield* Scope.fork(parentScope);
@@ -37,13 +43,7 @@ export const start = Effect.fn("ServerProcess.start")(function* (options, lifecy
37
43
  const context = yield* Layer.buildWithScope(createRoutes({
38
44
  ...options,
39
45
  password
40
- }, () => {
41
- const address = bound.server.address();
42
- if (address === null || typeof address === "string")
43
- return [];
44
- const host = address.family === "IPv6" ? `[${address.address}]` : address.address;
45
- return ServerInfo.connectionURLs(`http://${host}:${address.port}`, hostname);
46
- }).pipe(Layer.provideMerge(NodeHttpServer.layerHttpServices)), applicationScope);
46
+ }, urls).pipe(Layer.provideMerge(NodeHttpServer.layerHttpServices)), applicationScope);
47
47
  if (lifecycle)
48
48
  yield* installRestartContinuity(Context.get(context, SessionRestart.Service)).pipe(Effect.provideService(Scope.Scope, applicationScope));
49
49
  const app = Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.compression(), Effect.provideService(HttpPlatform.HttpPlatform, Context.get(context, HttpPlatform.HttpPlatform)));
@@ -87,14 +87,14 @@ function addressInUse(error) {
87
87
  const cause = error.cause;
88
88
  return typeof cause === "object" && cause !== null && "code" in cause && cause.code === "EADDRINUSE";
89
89
  }
90
- function dispatch(password, status, application, version) {
90
+ function dispatch(password, status, application, version, urls) {
91
91
  const auth = ServerAuth.Config.of({ password: Option.some(password), username: "opencode" });
92
92
  return Effect.gen(function* () {
93
93
  const request = yield* HttpServerRequest.HttpServerRequest, url = new URL(request.url, "http://localhost");
94
- if (request.method === "GET" && url.pathname === "/api/health") {
94
+ if (request.method === "GET" && url.pathname === "/api/status") {
95
95
  if (!(yield* authorizedRequest(request, auth)))
96
96
  return unauthorized();
97
- return yield* healthResponse(status, version);
97
+ return yield* statusResponse(status, version, urls);
98
98
  }
99
99
  const state = yield* status.current, app = yield* Ref.get(application), ready = state.type === "ready" && Option.isSome(app);
100
100
  if ((!ready || !hasPtyConnectTicketURL(url) && !hasPersistentPtyConnectTicketURL(url)) && !(yield* authorizedRequest(request, auth)))
@@ -110,9 +110,9 @@ function unauthorized() {
110
110
  headers: { "www-authenticate": 'Basic realm="Secure Area"' }
111
111
  });
112
112
  }
113
- const healthResponse = Effect.fnUntraced(function* (status, version) {
113
+ const statusResponse = Effect.fnUntraced(function* (status, version, urls) {
114
114
  const state = yield* status.current;
115
- return HttpServerResponse.jsonUnsafe({ healthy: !0, version, pid: process.pid }, {
115
+ return HttpServerResponse.jsonUnsafe({ version, pid: process.pid, urls: urls() }, {
116
116
  status: state.type === "ready" ? 200 : state.type === "failed" ? 500 : 503,
117
117
  headers: state.type === "starting" || state.type === "stopping" ? { "retry-after": "1" } : void 0
118
118
  });
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-19552",
4
+ "version": "0.0.0-dev-19553",
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-19552",
34
- "@opencode/protocol": "0.0.0-dev-19552",
35
- "@opencode/schema": "0.0.0-dev-19552",
36
- "@opencode/simulation": "0.0.0-dev-19552",
37
- "@opencode/util": "0.0.0-dev-19552",
33
+ "@opencode/core": "0.0.0-dev-19553",
34
+ "@opencode/protocol": "0.0.0-dev-19553",
35
+ "@opencode/schema": "0.0.0-dev-19553",
36
+ "@opencode/simulation": "0.0.0-dev-19553",
37
+ "@opencode/util": "0.0.0-dev-19553",
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-19552",
43
- "@opencode/plugin": "0.0.0-dev-19552",
42
+ "@opencode/client": "0.0.0-dev-19553",
43
+ "@opencode/plugin": "0.0.0-dev-19553",
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"
@@ -1,2 +0,0 @@
1
- import { ServerInfo } from "../server-info";
2
- export declare const HealthHandler: import("effect/Layer").Layer<import("effect/unstable/httpapi/HttpApiGroup").Service<"server", "server.health">, never, import("@opencode/protocol/middleware/schema-error").SchemaErrorMiddleware | import("@opencode/protocol/middleware/authorization").Authorization | import("effect/unstable/http/HttpRouter").Request<"Requires", ServerInfo.Service>>;
@@ -1,11 +0,0 @@
1
- import { Effect } from "effect";
2
- import { HttpApiBuilder } from "effect/unstable/httpapi";
3
- import { Api } from "../api";
4
- import { ServerInfo } from "../server-info";
5
- export const HealthHandler = HttpApiBuilder.group(Api, "server.health", (handlers) => handlers.handle("health.get", () => Effect.gen(function* () {
6
- return {
7
- healthy: !0,
8
- version: (yield* ServerInfo.Service).app.version ?? "unknown",
9
- pid: process.pid ?? 0
10
- };
11
- })));