@opencode-ai/server 0.0.0-dev-18666 → 0.0.0-dev-18668

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/fetch.d.ts CHANGED
@@ -59,6 +59,7 @@ export declare const make: (options?: {
59
59
  readonly gitbash?: string | undefined;
60
60
  } | undefined;
61
61
  readonly port?: number | undefined;
62
+ readonly cors?: readonly string[] | undefined;
62
63
  readonly password?: string | undefined;
63
64
  readonly app?: {
64
65
  readonly version?: string | undefined;
package/dist/fetch.js CHANGED
@@ -7,5 +7,5 @@ import { createRoutes } from "./routes";
7
7
  export const make = Effect.fn("ServerFetch.make")(function* (options = {}, boot = {}) {
8
8
  const context = yield* Layer.build(createRoutes(options, () => [], boot.overrides ?? []).pipe(Layer.provide(HttpServer.layerServices)));
9
9
  yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions);
10
- return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.cors({ allowedOrigins: isAllowedCorsOrigin, maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
10
+ return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin(origin, options), maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
11
11
  });
package/dist/options.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare const ServerOptions: Schema.Struct<{
8
8
  readonly hostname: Schema.optional<Schema.String>;
9
9
  readonly port: Schema.optional<Schema.Int>;
10
10
  readonly password: Schema.optional<Schema.String>;
11
+ readonly cors: Schema.optional<Schema.$Array<Schema.String>>;
11
12
  readonly simulation: Schema.optional<Schema.Boolean>;
12
13
  readonly database: Schema.optional<Schema.Struct<{
13
14
  readonly path: Schema.optional<Schema.String>;
package/dist/options.js CHANGED
@@ -11,6 +11,7 @@ export const ServerOptions = Schema.Struct({
11
11
  hostname: Schema.optional(Schema.String),
12
12
  port: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(65535))),
13
13
  password: Schema.optional(Schema.String),
14
+ cors: Schema.optional(Schema.Array(Schema.String)),
14
15
  simulation: Schema.optional(Schema.Boolean),
15
16
  database: Schema.optional(Database.Options),
16
17
  pty: Schema.optional(PersistentPty.Options),
package/dist/process.d.ts CHANGED
@@ -35,6 +35,7 @@ export declare const start: <E, R>(options: {
35
35
  readonly gitbash?: string | undefined;
36
36
  } | undefined;
37
37
  readonly port?: number | undefined;
38
+ readonly cors?: readonly string[] | undefined;
38
39
  readonly password?: string | undefined;
39
40
  readonly app?: {
40
41
  readonly version?: string | undefined;
package/dist/process.js CHANGED
@@ -26,7 +26,7 @@ export const start = Effect.fn("ServerProcess.start")(function* (options, lifecy
26
26
  if (!password)
27
27
  return yield* Effect.fail(Error("Missing server password"));
28
28
  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());
29
- yield* bound.http.serve(dispatch(password, status, application, options.app?.version ?? "unknown").pipe(HttpMiddleware.cors({ allowedOrigins: isAllowedCorsOrigin, maxAge: 86400 })), errorResponseLogger).pipe(withoutParentSpan);
29
+ 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
30
  if (lifecycle)
31
31
  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);
32
32
  const parentScope = yield* Scope.Scope, applicationScope = yield* Scope.fork(parentScope);
package/dist/routes.js CHANGED
@@ -35,6 +35,7 @@ import { HttpApiBuilder } from "effect/unstable/httpapi";
35
35
  import { Context, Effect, Layer, Option } from "effect";
36
36
  import { Api } from "./api";
37
37
  import { ServerAuth } from "./auth";
38
+ import { CorsConfig } from "./cors";
38
39
  import { handlers } from "./handlers";
39
40
  import { authorizationLayer } from "./middleware/authorization";
40
41
  import { schemaErrorLayer } from "./middleware/schema-error";
@@ -109,7 +110,7 @@ function makeRoutes(auth, options, serviceURLs, overrides) {
109
110
  const { simulationReplacements } = yield* Effect.promise(() => import("@opencode-ai/simulation/backend")), simulation = yield* simulationReplacements({ version: App.make(options.app).version });
110
111
  return AppNodeBuilder.build(applicationServices, [...replacements, ...simulation]);
111
112
  })) : AppNodeBuilder.build(applicationServices, replacements)).pipe(Layer.flatMap((context) => {
112
- const services = Layer.succeedContext(context), requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, PermissionSaved.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(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, PermissionSaved.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
114
  return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
114
115
  }));
115
116
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode-ai/server",
4
- "version": "0.0.0-dev-18666",
4
+ "version": "0.0.0-dev-18668",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -30,11 +30,11 @@
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-ai/core": "0.0.0-dev-18666",
34
- "@opencode-ai/protocol": "0.0.0-dev-18666",
35
- "@opencode-ai/schema": "0.0.0-dev-18666",
36
- "@opencode-ai/simulation": "0.0.0-dev-18666",
37
- "@opencode-ai/util": "0.0.0-dev-18666",
33
+ "@opencode-ai/core": "0.0.0-dev-18668",
34
+ "@opencode-ai/protocol": "0.0.0-dev-18668",
35
+ "@opencode-ai/schema": "0.0.0-dev-18668",
36
+ "@opencode-ai/simulation": "0.0.0-dev-18668",
37
+ "@opencode-ai/util": "0.0.0-dev-18668",
38
38
  "drizzle-orm": "1.0.0-rc.5-169397b",
39
39
  "effect": "4.0.0-rc.112"
40
40
  },