@opencode/server 0.0.0-dev-19794 → 0.0.0-dev-19808

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.
Files changed (101) hide show
  1. package/dist/api.js +10 -9
  2. package/dist/auth.js +12 -17
  3. package/dist/chunks/workerd-00nn3k4b.js +20 -0
  4. package/dist/chunks/workerd-04xw3v55.js +23 -0
  5. package/dist/chunks/workerd-19c9ysa1.js +61 -0
  6. package/dist/chunks/workerd-1c4qas2w.js +346 -0
  7. package/dist/chunks/workerd-254zvkj6.js +22 -0
  8. package/dist/chunks/workerd-2rvsests.js +99 -0
  9. package/dist/chunks/workerd-2sy3c7de.js +83 -0
  10. package/dist/chunks/workerd-3kzx88w9.js +26 -0
  11. package/dist/chunks/workerd-4g0fa6m0.js +32 -0
  12. package/dist/chunks/workerd-4vn5bvkr.js +25 -0
  13. package/dist/chunks/workerd-5rwqcaw2.js +33 -0
  14. package/dist/chunks/workerd-5w24ch67.js +23 -0
  15. package/dist/chunks/workerd-6gkz39ey.js +55 -0
  16. package/dist/chunks/workerd-6nvan4e0.js +17 -0
  17. package/dist/chunks/workerd-6ptwb1q1.js +149 -0
  18. package/dist/chunks/workerd-75c938bc.js +23 -0
  19. package/dist/chunks/workerd-7cfyat0f.js +37 -0
  20. package/dist/chunks/workerd-7rzt3wm8.js +13 -0
  21. package/dist/chunks/workerd-8bajbwjh.js +40 -0
  22. package/dist/chunks/workerd-9rqn6x4v.js +16 -0
  23. package/dist/chunks/workerd-a6yp8301.js +156 -0
  24. package/dist/chunks/workerd-arj41x43.js +77 -0
  25. package/dist/chunks/workerd-b0b71rwa.js +39 -0
  26. package/dist/chunks/workerd-bjrwanme.js +22 -0
  27. package/dist/chunks/workerd-bkqymx4n.js +26 -0
  28. package/dist/chunks/workerd-br99j6q1.js +35 -0
  29. package/dist/chunks/workerd-ceh2h0m9.js +25 -0
  30. package/dist/chunks/workerd-hezj1jdf.js +7 -0
  31. package/dist/chunks/workerd-hjnxtxmk.js +34 -0
  32. package/dist/chunks/workerd-j2pfq4q6.js +42 -0
  33. package/dist/chunks/workerd-m6wvgbfq.js +60 -0
  34. package/dist/chunks/workerd-mzr9gftb.js +36 -0
  35. package/dist/chunks/workerd-n0er2m55.js +163 -0
  36. package/dist/chunks/workerd-pnqq1zxv.js +29 -0
  37. package/dist/chunks/workerd-q0ycym90.js +13 -0
  38. package/dist/chunks/workerd-q4bn6dy8.js +39 -0
  39. package/dist/chunks/workerd-qnwpcgp7.js +22 -0
  40. package/dist/chunks/workerd-qzap92t7.js +139 -0
  41. package/dist/chunks/workerd-r7e9r02j.js +13 -0
  42. package/dist/chunks/workerd-rcg4y18n.js +59 -0
  43. package/dist/chunks/workerd-req22b70.js +22 -0
  44. package/dist/chunks/workerd-smaf4a18.js +28 -0
  45. package/dist/chunks/workerd-t8yzmczr.js +18 -0
  46. package/dist/chunks/workerd-x1haxfjx.js +21 -0
  47. package/dist/chunks/workerd-yc7nft6q.js +5 -0
  48. package/dist/chunks/workerd-ysabas57.js +13 -0
  49. package/dist/chunks/workerd-z5shrcz9.js +19 -0
  50. package/dist/chunks/workerd-zp2jm6dt.js +15 -0
  51. package/dist/chunks/workerd-zyv89x5n.js +30 -0
  52. package/dist/cors.js +10 -36
  53. package/dist/event-feed.js +20 -60
  54. package/dist/fetch.js +53 -11
  55. package/dist/handlers/agent.js +11 -17
  56. package/dist/handlers/command.js +11 -5
  57. package/dist/handlers/config.js +11 -16
  58. package/dist/handlers/credential.js +11 -14
  59. package/dist/handlers/debug.js +11 -11
  60. package/dist/handlers/event.js +12 -27
  61. package/dist/handlers/form.js +11 -9
  62. package/dist/handlers/fs.js +11 -22
  63. package/dist/handlers/generate.js +11 -15
  64. package/dist/handlers/integration.js +10 -142
  65. package/dist/handlers/location.js +11 -16
  66. package/dist/handlers/mcp.js +11 -31
  67. package/dist/handlers/message.js +10 -42
  68. package/dist/handlers/migration.js +11 -7
  69. package/dist/handlers/model.js +11 -14
  70. package/dist/handlers/permission.js +11 -57
  71. package/dist/handlers/persistent-pty.js +12 -135
  72. package/dist/handlers/plugin.js +11 -47
  73. package/dist/handlers/project.js +11 -9
  74. package/dist/handlers/provider.js +11 -20
  75. package/dist/handlers/pty-socket.js +6 -4
  76. package/dist/handlers/pty.js +13 -107
  77. package/dist/handlers/reference.js +11 -5
  78. package/dist/handlers/rpc.js +11 -15
  79. package/dist/handlers/server.js +12 -13
  80. package/dist/handlers/session-error.js +12 -26
  81. package/dist/handlers/session.js +10 -311
  82. package/dist/handlers/shell.js +11 -25
  83. package/dist/handlers/skill.js +11 -5
  84. package/dist/handlers/vcs.js +11 -19
  85. package/dist/handlers/websearch.js +11 -31
  86. package/dist/handlers/worktree.js +11 -37
  87. package/dist/handlers.js +46 -33
  88. package/dist/location.js +15 -49
  89. package/dist/middleware/authorization.js +11 -49
  90. package/dist/middleware/form-location.js +10 -25
  91. package/dist/middleware/schema-error.js +8 -15
  92. package/dist/middleware/session-location.js +10 -19
  93. package/dist/options.js +5 -1
  94. package/dist/process.js +108 -28
  95. package/dist/pty-environment.js +12 -9
  96. package/dist/request-tracing.js +6 -2
  97. package/dist/routes.js +52 -118
  98. package/dist/server-info.js +12 -22
  99. package/dist/service-status.js +8 -11
  100. package/dist/workerd.js +80 -12
  101. package/package.json +8 -8
@@ -1,19 +1,11 @@
1
- import { Vcs } from "@opencode/core/vcs";
2
- import { ServiceUnavailableError } from "@opencode/protocol/errors";
3
- import { Effect } from "effect";
4
- import { HttpApiBuilder } from "effect/unstable/httpapi";
5
- import { Api } from "../api";
6
- import { response } from "../location";
7
- export const VcsHandler = HttpApiBuilder.group(Api, "server.vcs", (handlers) => Effect.gen(function* () {
8
- return handlers.handle("vcs.get", () => response(Effect.gen(function* () {
9
- return yield* (yield* Vcs.Service).info();
10
- }))).handle("vcs.base", () => response(Effect.gen(function* () {
11
- return yield* (yield* Vcs.Service).base().pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
12
- }))).handle("vcs.status", () => response(Effect.gen(function* () {
13
- return yield* (yield* Vcs.Service).status();
14
- }))).handle("vcs.branch.list", (ctx) => response(Effect.gen(function* () {
15
- return yield* (yield* Vcs.Service).branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) });
16
- }))).handle("vcs.diff", (ctx) => response(Effect.gen(function* () {
17
- return yield* (yield* Vcs.Service).diff(ctx.query.mode, { context: ctx.query.context, base: ctx.query.base }).pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
18
- })));
19
- }));
1
+ import {
2
+ VcsHandler2
3
+ } from "../chunks/workerd-4g0fa6m0.js";
4
+ import"../chunks/workerd-z5shrcz9.js";
5
+ import"../chunks/workerd-3kzx88w9.js";
6
+ import"../chunks/workerd-5rwqcaw2.js";
7
+ import"../chunks/workerd-6gkz39ey.js";
8
+ import"../chunks/workerd-smaf4a18.js";
9
+ export {
10
+ VcsHandler2 as VcsHandler
11
+ };
@@ -1,31 +1,11 @@
1
- import { WebSearch } from "@opencode/core/websearch";
2
- import { InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors";
3
- import { Effect } from "effect";
4
- import { HttpApiBuilder } from "effect/unstable/httpapi";
5
- import { Api } from "../api";
6
- import { response } from "../location";
7
- export const WebSearchHandler = HttpApiBuilder.group(Api, "server.websearch", (handlers) => Effect.gen(function* () {
8
- return handlers.handle("websearch.providers", Effect.fn("server.websearch.providers")(function* () {
9
- const websearch = yield* WebSearch.Service;
10
- return yield* response(websearch.providers());
11
- })).handle("websearch.query", Effect.fn("server.websearch.query")(function* (request) {
12
- const websearch = yield* WebSearch.Service;
13
- return yield* response(websearch.query(request.payload).pipe(Effect.catchTags({
14
- "WebSearch.ProviderRequired": () => new InvalidRequestError({
15
- message: "Web search provider is required",
16
- kind: "websearch_provider_required",
17
- field: "providerID"
18
- }),
19
- "WebSearch.ProviderNotFound": (error) => new InvalidRequestError({
20
- message: `Web search provider not found: ${error.providerID}`,
21
- kind: "websearch_provider_not_found",
22
- field: "providerID"
23
- }),
24
- "WebSearch.Disabled": () => new InvalidRequestError({ message: "Web search is disabled", kind: "websearch_disabled" }),
25
- "WebSearch.Request": (error) => new ServiceUnavailableError({
26
- message: `Web search request failed: ${error.providerID}`,
27
- service: error.providerID
28
- })
29
- })));
30
- }));
31
- }));
1
+ import {
2
+ WebSearchHandler2
3
+ } from "../chunks/workerd-b0b71rwa.js";
4
+ import"../chunks/workerd-z5shrcz9.js";
5
+ import"../chunks/workerd-3kzx88w9.js";
6
+ import"../chunks/workerd-5rwqcaw2.js";
7
+ import"../chunks/workerd-6gkz39ey.js";
8
+ import"../chunks/workerd-smaf4a18.js";
9
+ export {
10
+ WebSearchHandler2 as WebSearchHandler
11
+ };
@@ -1,37 +1,11 @@
1
- import { Git } from "@opencode/core/git";
2
- import { Worktree } from "@opencode/core/worktree";
3
- import { Project } from "@opencode/core/project";
4
- import { ProjectNotFoundError } from "@opencode/protocol/errors";
5
- import { WorktreeError } from "@opencode/protocol/groups/worktree";
6
- import { Effect } from "effect";
7
- import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
8
- import { Api } from "../api";
9
- export const WorktreeHandler = HttpApiBuilder.group(Api, "server.worktree", (handlers) => Effect.gen(function* () {
10
- const worktrees = yield* Worktree.Service;
11
- return handlers.handle("worktree.list", (ctx) => worktrees.list(ctx.query).pipe(Effect.catchTag("Project.NotFoundError", missingProject))).handle("worktree.create", (ctx) => worktrees.create(ctx.payload).pipe(badRequest)).handle("worktree.remove", (ctx) => worktrees.remove(ctx.payload).pipe(badRequest, Effect.as(HttpApiSchema.NoContent.make()))).handle("worktree.refresh", (ctx) => worktrees.refresh(ctx.payload).pipe(badRequest, Effect.as(HttpApiSchema.NoContent.make())));
12
- }));
13
- function badRequest(effect) {
14
- return effect.pipe(Effect.catchTag("Project.NotFoundError", missingProject), Effect.mapError((error) => error instanceof ProjectNotFoundError ? error : new WorktreeError({
15
- name: "WorktreeError",
16
- data: {
17
- message: message(error),
18
- forceRequired: error instanceof Git.WorktreeError || error instanceof Worktree.OperationError ? error.forceRequired : void 0
19
- }
20
- })));
21
- }
22
- function missingProject(error) {
23
- return Effect.fail(new ProjectNotFoundError({ projectID: error.projectID, message: `Project not found: ${error.projectID}` }));
24
- }
25
- function message(error) {
26
- if (error instanceof Worktree.SourceDirectoryNotFoundError)
27
- return error.directory ? `Worktree source not found: ${error.directory}` : `Worktree source not found for project: ${error.projectID}`;
28
- if (error instanceof Worktree.DestinationExistsError)
29
- return `Worktree destination already exists: ${error.directory}`;
30
- if (error instanceof Worktree.DirectoryUnavailableError)
31
- return `Worktree directory unavailable: ${error.directory}`;
32
- if (error instanceof Worktree.InvalidDirectoryError)
33
- return `Invalid worktree directory: ${error.directory}`;
34
- if (error instanceof Worktree.StrategyUnavailableError)
35
- return `Worktree strategy unavailable: ${error.strategy}`;
36
- return error.message;
37
- }
1
+ import {
2
+ WorktreeHandler2
3
+ } from "../chunks/workerd-j2pfq4q6.js";
4
+ import"../chunks/workerd-z5shrcz9.js";
5
+ import"../chunks/workerd-3kzx88w9.js";
6
+ import"../chunks/workerd-5rwqcaw2.js";
7
+ import"../chunks/workerd-6gkz39ey.js";
8
+ import"../chunks/workerd-smaf4a18.js";
9
+ export {
10
+ WorktreeHandler2 as WorktreeHandler
11
+ };
package/dist/handlers.js CHANGED
@@ -1,33 +1,46 @@
1
- import { Layer } from "effect";
2
- import { GenerateHandler } from "./handlers/generate";
3
- import { MessageHandler } from "./handlers/message";
4
- import { ModelHandler } from "./handlers/model";
5
- import { ProviderHandler } from "./handlers/provider";
6
- import { SessionHandler } from "./handlers/session";
7
- import { PermissionHandler } from "./handlers/permission";
8
- import { FileSystemHandler } from "./handlers/fs";
9
- import { FormHandler } from "./handlers/form";
10
- import { CommandHandler } from "./handlers/command";
11
- import { SkillHandler } from "./handlers/skill";
12
- import { RpcHandler } from "./handlers/rpc";
13
- import { EventHandler } from "./handlers/event";
14
- import { AgentHandler } from "./handlers/agent";
15
- import { PluginHandler } from "./handlers/plugin";
16
- import { ServerHandler } from "./handlers/server";
17
- import { DebugHandler } from "./handlers/debug";
18
- import { PtyHandler } from "./handlers/pty";
19
- import { PersistentPtyHandler } from "./handlers/persistent-pty";
20
- import { ShellHandler } from "./handlers/shell";
21
- import { ReferenceHandler } from "./handlers/reference";
22
- import { LocationHandler } from "./handlers/location";
23
- import { IntegrationHandler } from "./handlers/integration";
24
- import { WebSearchHandler } from "./handlers/websearch";
25
- import { McpHandler } from "./handlers/mcp";
26
- import { CredentialHandler } from "./handlers/credential";
27
- import { ProjectHandler } from "./handlers/project";
28
- import { WorktreeHandler } from "./handlers/worktree";
29
- import { VcsHandler } from "./handlers/vcs";
30
- import { EventFeed } from "./event-feed";
31
- import { MigrationHandler } from "./handlers/migration";
32
- import { ConfigHandler } from "./handlers/config";
33
- 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, VcsHandler, ConfigHandler);
1
+ import {
2
+ handlers2
3
+ } from "./chunks/workerd-2rvsests.js";
4
+ import"./chunks/workerd-7cfyat0f.js";
5
+ import"./chunks/workerd-q0ycym90.js";
6
+ import"./chunks/workerd-bjrwanme.js";
7
+ import"./chunks/workerd-254zvkj6.js";
8
+ import"./chunks/workerd-4g0fa6m0.js";
9
+ import"./chunks/workerd-19c9ysa1.js";
10
+ import"./chunks/workerd-req22b70.js";
11
+ import"./chunks/workerd-a6yp8301.js";
12
+ import"./chunks/workerd-j2pfq4q6.js";
13
+ import"./chunks/workerd-1c4qas2w.js";
14
+ import"./chunks/workerd-4vn5bvkr.js";
15
+ import"./chunks/workerd-8bajbwjh.js";
16
+ import"./chunks/workerd-ceh2h0m9.js";
17
+ import"./chunks/workerd-ysabas57.js";
18
+ import"./chunks/workerd-arj41x43.js";
19
+ import"./chunks/workerd-b0b71rwa.js";
20
+ import"./chunks/workerd-hjnxtxmk.js";
21
+ import"./chunks/workerd-br99j6q1.js";
22
+ import"./chunks/workerd-qzap92t7.js";
23
+ import"./chunks/workerd-x1haxfjx.js";
24
+ import"./chunks/workerd-6nvan4e0.js";
25
+ import"./chunks/workerd-qnwpcgp7.js";
26
+ import"./chunks/workerd-r7e9r02j.js";
27
+ import"./chunks/workerd-pnqq1zxv.js";
28
+ import"./chunks/workerd-rcg4y18n.js";
29
+ import"./chunks/workerd-zp2jm6dt.js";
30
+ import"./chunks/workerd-n0er2m55.js";
31
+ import"./chunks/workerd-hezj1jdf.js";
32
+ import"./chunks/workerd-00nn3k4b.js";
33
+ import"./chunks/workerd-04xw3v55.js";
34
+ import"./chunks/workerd-7rzt3wm8.js";
35
+ import"./chunks/workerd-2sy3c7de.js";
36
+ import"./chunks/workerd-q4bn6dy8.js";
37
+ import"./chunks/workerd-mzr9gftb.js";
38
+ import"./chunks/workerd-z5shrcz9.js";
39
+ import"./chunks/workerd-3kzx88w9.js";
40
+ import"./chunks/workerd-5rwqcaw2.js";
41
+ import"./chunks/workerd-6gkz39ey.js";
42
+ import"./chunks/workerd-smaf4a18.js";
43
+ import"./chunks/workerd-75c938bc.js";
44
+ export {
45
+ handlers2 as handlers
46
+ };
package/dist/location.js CHANGED
@@ -1,49 +1,15 @@
1
- import { Location } from "@opencode/core/location";
2
- import { LocationServiceMap } from "@opencode/core/location-services";
3
- import { AbsolutePath } from "@opencode/core/schema";
4
- import { Session } from "@opencode/core/session";
5
- import { InvalidRequestError } from "@opencode/protocol/errors";
6
- import { Effect, Layer, Schema } from "effect";
7
- import { HttpServerRequest } from "effect/unstable/http";
8
- import { HttpApiMiddleware } from "effect/unstable/httpapi";
9
- import { missingSession } from "./handlers/session-error";
10
-
11
- export class LocationMiddleware extends HttpApiMiddleware.Service()("@opencode/HttpApiLocation") {
12
- }
13
- export function response(data) {
14
- return Effect.gen(function* () {
15
- const location = yield* Location.Service;
16
- return {
17
- location: new Location.Info({
18
- directory: location.directory,
19
- project: location.project
20
- }),
21
- data: yield* data
22
- };
23
- });
24
- }
25
- const decodeSessionID = Schema.decodeUnknownEffect(Session.ID);
26
- export const sessionInfo = Effect.fnUntraced(function* (sessions, sessionID) {
27
- const id = yield* decodeSessionID(sessionID).pipe(Effect.mapError(() => new InvalidRequestError({ message: "Invalid session ID", field: "sessionID" })));
28
- return yield* sessions.get(id).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
29
- });
30
- export function requestRef(request) {
31
- const directory = new URL(request.url, "http://localhost").searchParams.get("location[directory]") || (request.headers["x-opencode-directory"] ? decode(request.headers["x-opencode-directory"]) : process.cwd());
32
- return Location.Ref.make({
33
- directory: AbsolutePath.make(directory)
34
- });
35
- }
36
- function decode(input) {
37
- try {
38
- return decodeURIComponent(input);
39
- } catch {
40
- return input;
41
- }
42
- }
43
- export const layer = Layer.effect(LocationMiddleware, Effect.gen(function* () {
44
- const locations = yield* LocationServiceMap.Service;
45
- return LocationMiddleware.of((effect) => Effect.gen(function* () {
46
- const request = yield* HttpServerRequest.HttpServerRequest;
47
- return yield* effect.pipe(Effect.provide(locations.get(requestRef(request))));
48
- }));
49
- }));
1
+ import {
2
+ LocationMiddleware2,
3
+ response2,
4
+ sessionInfo2,
5
+ requestRef2,
6
+ layer4
7
+ } from "./chunks/workerd-6gkz39ey.js";
8
+ import"./chunks/workerd-smaf4a18.js";
9
+ export {
10
+ LocationMiddleware2 as LocationMiddleware,
11
+ layer4 as layer,
12
+ requestRef2 as requestRef,
13
+ response2 as response,
14
+ sessionInfo2 as sessionInfo
15
+ };
@@ -1,49 +1,11 @@
1
- import { ServerAuth } from "../auth";
2
- import { UnauthorizedError } from "@opencode/protocol/errors";
3
- import { Authorization } from "@opencode/protocol/middleware/authorization";
4
- export { Authorization } from "@opencode/protocol/middleware/authorization";
5
- import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
6
- import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
7
- import { Effect, Encoding, Layer, Redacted } from "effect";
8
- import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
9
- const AUTH_TOKEN_QUERY = "auth_token", WWW_AUTHENTICATE = 'Basic realm="Secure Area"';
10
- function emptyCredential() {
11
- return { username: "", password: Redacted.make("") };
12
- }
13
- function decodeCredential(input) {
14
- return Effect.fromResult(Encoding.decodeBase64String(input)).pipe(Effect.match({
15
- onFailure: emptyCredential,
16
- onSuccess: (header) => {
17
- const separator = header.indexOf(":");
18
- if (separator === -1)
19
- return emptyCredential();
20
- return { username: header.slice(0, separator), password: Redacted.make(header.slice(separator + 1)) };
21
- }
22
- }));
23
- }
24
- function credentialFromRequest(request) {
25
- const token = new URL(request.url, "http://localhost").searchParams.get(AUTH_TOKEN_QUERY);
26
- if (token)
27
- return decodeCredential(token);
28
- const match = /^Basic\s+(.+)$/i.exec(request.headers.authorization ?? "");
29
- if (match)
30
- return decodeCredential(match[1]);
31
- return Effect.succeed(emptyCredential());
32
- }
33
- export function authorizedRequest(request, config) {
34
- return credentialFromRequest(request).pipe(Effect.map((credential) => ServerAuth.authorized(credential, config)));
35
- }
36
- export const authorizationLayer = Layer.effect(Authorization, Effect.gen(function* () {
37
- const config = yield* ServerAuth.Config;
38
- if (!ServerAuth.required(config))
39
- return Authorization.of((effect) => effect);
40
- return Authorization.of((effect) => Effect.gen(function* () {
41
- const request = yield* HttpServerRequest.HttpServerRequest, url = new URL(request.url, "http://localhost");
42
- if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url))
43
- return yield* effect;
44
- if (yield* authorizedRequest(request, config))
45
- return yield* effect;
46
- yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
47
- return yield* new UnauthorizedError({ message: "Authentication required" });
48
- }));
49
- }));
1
+ import {
2
+ authorizedRequest2,
3
+ authorizationLayer2,
4
+ Authorization2
5
+ } from "../chunks/workerd-m6wvgbfq.js";
6
+ import"../chunks/workerd-zyv89x5n.js";
7
+ export {
8
+ Authorization2 as Authorization,
9
+ authorizationLayer2 as authorizationLayer,
10
+ authorizedRequest2 as authorizedRequest
11
+ };
@@ -1,25 +1,10 @@
1
- import { Instance } from "@opencode/core/instance/service";
2
- import { LocationServiceMap } from "@opencode/core/location-services";
3
- import { Session } from "@opencode/core/session";
4
- import { InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors";
5
- import { Effect, Layer } from "effect";
6
- import { HttpRouter, HttpServerRequest } from "effect/unstable/http";
7
- import { HttpApiMiddleware } from "effect/unstable/httpapi";
8
- import { requestRef, sessionInfo } from "../location";
9
-
10
- export class FormLocationMiddleware extends HttpApiMiddleware.Service()("@opencode/HttpApiFormLocation", {
11
- error: [InvalidRequestError, SessionNotFoundError]
12
- }) {
13
- }
14
- export const formLocationLayer = Layer.effect(FormLocationMiddleware, Effect.gen(function* () {
15
- const sessions = yield* Session.Service, instances = yield* Instance.Service, locations = yield* LocationServiceMap.Service;
16
- return FormLocationMiddleware.of((effect) => Effect.gen(function* () {
17
- const route = yield* HttpRouter.RouteContext;
18
- if (route.params.sessionID === "global") {
19
- const request = yield* HttpServerRequest.HttpServerRequest;
20
- return yield* effect.pipe(Effect.provide(locations.get(requestRef(request))));
21
- }
22
- const session = yield* sessionInfo(sessions, route.params.sessionID);
23
- return yield* effect.pipe(instances.provide(session));
24
- }));
25
- }));
1
+ import {
2
+ FormLocationMiddleware2,
3
+ formLocationLayer2
4
+ } from "../chunks/workerd-5rwqcaw2.js";
5
+ import"../chunks/workerd-6gkz39ey.js";
6
+ import"../chunks/workerd-smaf4a18.js";
7
+ export {
8
+ FormLocationMiddleware2 as FormLocationMiddleware,
9
+ formLocationLayer2 as formLocationLayer
10
+ };
@@ -1,15 +1,8 @@
1
- import { Effect } from "effect";
2
- import { HttpApiMiddleware } from "effect/unstable/httpapi";
3
- import { InvalidRequestError } from "@opencode/protocol/errors";
4
- import { SchemaErrorMiddleware } from "@opencode/protocol/middleware/schema-error";
5
- export { SchemaErrorMiddleware } from "@opencode/protocol/middleware/schema-error";
6
- const REASON_LIMIT = 1024;
7
- function truncateReason(reason) {
8
- if (reason.length <= REASON_LIMIT)
9
- return reason;
10
- return reason.slice(0, REASON_LIMIT) + `... (${reason.length - REASON_LIMIT} more chars)`;
11
- }
12
- export const schemaErrorLayer = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
13
- const reason = truncateReason(error.cause.message);
14
- return Effect.logWarning("schema rejection").pipe(Effect.annotateLogs({ kind: error.kind, reason }), Effect.andThen(Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))));
15
- });
1
+ import {
2
+ schemaErrorLayer2,
3
+ SchemaErrorMiddleware2
4
+ } from "../chunks/workerd-t8yzmczr.js";
5
+ export {
6
+ SchemaErrorMiddleware2 as SchemaErrorMiddleware,
7
+ schemaErrorLayer2 as schemaErrorLayer
8
+ };
@@ -1,19 +1,10 @@
1
- import { Instance } from "@opencode/core/instance/service";
2
- import { Session } from "@opencode/core/session";
3
- import { Effect, Layer } from "effect";
4
- import { HttpRouter } from "effect/unstable/http";
5
- import { HttpApiMiddleware } from "effect/unstable/httpapi";
6
- import { InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors";
7
- import { sessionInfo } from "../location";
8
-
9
- export class SessionLocationMiddleware extends HttpApiMiddleware.Service()("@opencode/HttpApiSessionLocation", {
10
- error: [InvalidRequestError, SessionNotFoundError]
11
- }) {
12
- }
13
- export const sessionLocationLayer = Layer.effect(SessionLocationMiddleware, Effect.gen(function* () {
14
- const sessions = yield* Session.Service, instances = yield* Instance.Service;
15
- return SessionLocationMiddleware.of((effect) => Effect.gen(function* () {
16
- const route = yield* HttpRouter.RouteContext, session = yield* sessionInfo(sessions, route.params.sessionID);
17
- return yield* effect.pipe(instances.provide(session));
18
- }));
19
- }));
1
+ import {
2
+ SessionLocationMiddleware2,
3
+ sessionLocationLayer2
4
+ } from "../chunks/workerd-3kzx88w9.js";
5
+ import"../chunks/workerd-6gkz39ey.js";
6
+ import"../chunks/workerd-smaf4a18.js";
7
+ export {
8
+ SessionLocationMiddleware2 as SessionLocationMiddleware,
9
+ sessionLocationLayer2 as sessionLocationLayer
10
+ };
package/dist/options.js CHANGED
@@ -1,8 +1,9 @@
1
+ // src/options.ts
1
2
  import { Database } from "@opencode/core/database/database";
2
3
  import { ModelsDev } from "@opencode/core/models-dev";
3
4
  import { PersistentPty } from "@opencode/core/persistent-pty";
4
5
  import { Schema } from "effect";
5
- export const ServerOptions = Schema.Struct({
6
+ var ServerOptions = Schema.Struct({
6
7
  app: Schema.optional(Schema.Struct({
7
8
  name: Schema.optional(Schema.String),
8
9
  version: Schema.optional(Schema.String),
@@ -33,3 +34,6 @@ export const ServerOptions = Schema.Struct({
33
34
  fff: Schema.optional(Schema.Boolean)
34
35
  }))
35
36
  });
37
+ export {
38
+ ServerOptions
39
+ };