@opencode/server 0.0.0-dev-19715 → 0.0.0-dev-19717

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,11 +2,12 @@ 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.status", () => Effect.gen(function* () {
5
+ export const ServerHandler = HttpApiBuilder.group(Api, "server.server", (handlers) => handlers.handle("server.info", () => Effect.gen(function* () {
6
6
  const info = yield* ServerInfo.Service;
7
7
  return {
8
8
  version: info.app.version ?? "unknown",
9
9
  pid: process.pid ?? 0,
10
- urls: info.urls()
10
+ urls: info.urls(),
11
+ paths: info.paths
11
12
  };
12
13
  })));
package/dist/process.js CHANGED
@@ -5,6 +5,7 @@ import { SessionRestart } from "@opencode/core/session/execution/restart";
5
5
  import { InstallationEvent } from "@opencode/schema/installation-event";
6
6
  import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
7
7
  import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
8
+ import { Global } from "@opencode/util/global";
8
9
  import { Cause, Context, Effect, Exit, Latch, Layer, Option, Ref, Scope } from "effect";
9
10
  import {
10
11
  HttpMiddleware,
@@ -34,7 +35,7 @@ export const start = Effect.fn("ServerProcess.start")(function* (options, lifecy
34
35
  const host = address.family === "IPv6" ? `[${address.address}]` : address.address;
35
36
  return ServerInfo.connectionURLs(`http://${host}:${address.port}`, hostname);
36
37
  }, 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);
38
+ yield* bound.http.serve(dispatch(password, status, application, options.app?.version ?? "unknown", urls, Global.Path.tmp).pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin(origin, options), maxAge: 86400 })), errorResponseLogger).pipe(withoutParentSpan);
38
39
  if (lifecycle)
39
40
  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);
40
41
  const parentScope = yield* Scope.Scope, applicationScope = yield* Scope.fork(parentScope);
@@ -87,16 +88,15 @@ function addressInUse(error) {
87
88
  const cause = error.cause;
88
89
  return typeof cause === "object" && cause !== null && "code" in cause && cause.code === "EADDRINUSE";
89
90
  }
90
- function dispatch(password, status, application, version, urls) {
91
+ function dispatch(password, status, application, version, urls, tmp) {
91
92
  const auth = ServerAuth.Config.of({ password: Option.some(password), username: "opencode" });
92
93
  return Effect.gen(function* () {
93
- const request = yield* HttpServerRequest.HttpServerRequest, url = new URL(request.url, "http://localhost");
94
- if (request.method === "GET" && url.pathname === "/api/status") {
94
+ const request = yield* HttpServerRequest.HttpServerRequest, url = new URL(request.url, "http://localhost"), state = yield* status.current, app = yield* Ref.get(application), ready = state.type === "ready" && Option.isSome(app);
95
+ if (request.method === "GET" && url.pathname === "/api/info" && !ready) {
95
96
  if (!(yield* authorizedRequest(request, auth)))
96
97
  return unauthorized();
97
- return yield* statusResponse(status, version, urls);
98
+ return yield* infoResponse(status, version, urls, tmp);
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)))
101
101
  return unauthorized();
102
102
  if (ready)
@@ -110,9 +110,9 @@ function unauthorized() {
110
110
  headers: { "www-authenticate": 'Basic realm="Secure Area"' }
111
111
  });
112
112
  }
113
- const statusResponse = Effect.fnUntraced(function* (status, version, urls) {
113
+ const infoResponse = Effect.fnUntraced(function* (status, version, urls, tmp) {
114
114
  const state = yield* status.current;
115
- return HttpServerResponse.jsonUnsafe({ version, pid: process.pid, urls: urls() }, {
115
+ return HttpServerResponse.jsonUnsafe({ version, pid: process.pid, urls: urls(), paths: { tmp } }, {
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/dist/routes.js CHANGED
@@ -112,7 +112,7 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
112
112
  const { simulationReplacements } = yield* Effect.promise(() => import("@opencode/simulation/backend")), simulation = yield* simulationReplacements({ version: App.make(options.app).version });
113
113
  return build([...overrides, ...simulation]);
114
114
  })) : build(overrides)).pipe(Layer.flatMap((context) => {
115
- 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));
115
+ 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, Context.get(context, Global.Service).tmp, 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));
116
116
  return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
117
117
  }));
118
118
  }
@@ -3,9 +3,12 @@ import type { ServerOptions } from "./options";
3
3
  declare const Service_base: Context.ServiceClass<Service, "@opencode/server/ServerInfo", {
4
4
  readonly urls: () => ReadonlyArray<string>;
5
5
  readonly app: NonNullable<ServerOptions["app"]>;
6
+ readonly paths: {
7
+ readonly tmp: string;
8
+ };
6
9
  }>;
7
10
  export declare class Service extends Service_base {
8
11
  }
9
- export declare function layer(urls: () => ReadonlyArray<string>, app?: ServerOptions["app"]): Layer.Layer<Service, never, never>;
12
+ export declare function layer(urls: () => ReadonlyArray<string>, tmp: string, app?: ServerOptions["app"]): Layer.Layer<Service, never, never>;
10
13
  export declare function connectionURLs(value: string, requestedHostname?: string): string[];
11
14
  export * as ServerInfo from "./server-info";
@@ -3,8 +3,8 @@ import { networkInterfaces } from "node:os";
3
3
 
4
4
  export class Service extends Context.Service()("@opencode/server/ServerInfo") {
5
5
  }
6
- export function layer(urls, app = {}) {
7
- return Layer.succeed(Service, Service.of({ urls, app }));
6
+ export function layer(urls, tmp, app = {}) {
7
+ return Layer.succeed(Service, Service.of({ urls, app, paths: { tmp } }));
8
8
  }
9
9
  export function connectionURLs(value, requestedHostname) {
10
10
  const url = new URL(value), hostname = requestedHostname ?? url.hostname, family = hostname === "0.0.0.0" ? "IPv4" : hostname === "::" || hostname === "[::]" ? "IPv6" : void 0;
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-19715",
4
+ "version": "0.0.0-dev-19717",
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-19715",
34
- "@opencode/protocol": "0.0.0-dev-19715",
35
- "@opencode/schema": "0.0.0-dev-19715",
36
- "@opencode/simulation": "0.0.0-dev-19715",
37
- "@opencode/util": "0.0.0-dev-19715",
33
+ "@opencode/core": "0.0.0-dev-19717",
34
+ "@opencode/protocol": "0.0.0-dev-19717",
35
+ "@opencode/schema": "0.0.0-dev-19717",
36
+ "@opencode/simulation": "0.0.0-dev-19717",
37
+ "@opencode/util": "0.0.0-dev-19717",
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-19715",
43
- "@opencode/plugin": "0.0.0-dev-19715",
42
+ "@opencode/client": "0.0.0-dev-19717",
43
+ "@opencode/plugin": "0.0.0-dev-19717",
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"