@opencode/server 2.0.8 → 2.0.10

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 (104) hide show
  1. package/dist/api.d.ts +4 -4
  2. package/dist/api.js +10 -9
  3. package/dist/auth.js +12 -17
  4. package/dist/chunks/auth-0ar9gf7q.js +55 -0
  5. package/dist/chunks/auth-0qzy9yxk.js +163 -0
  6. package/dist/chunks/auth-1wj0ectp.js +22 -0
  7. package/dist/chunks/auth-23w8t84j.js +26 -0
  8. package/dist/chunks/auth-34e6wr3b.js +13 -0
  9. package/dist/chunks/auth-3582t7j8.js +139 -0
  10. package/dist/chunks/auth-40g8rvw4.js +59 -0
  11. package/dist/chunks/auth-5p62ed52.js +36 -0
  12. package/dist/chunks/auth-6aya8ky6.js +39 -0
  13. package/dist/chunks/auth-760vtqy2.js +29 -0
  14. package/dist/chunks/auth-7bj707s9.js +99 -0
  15. package/dist/chunks/auth-7qtja2kq.js +15 -0
  16. package/dist/chunks/auth-8e21y1bd.js +20 -0
  17. package/dist/chunks/auth-8nbs1vvt.js +34 -0
  18. package/dist/chunks/auth-8ygjd1s8.js +40 -0
  19. package/dist/chunks/auth-9rqn6x4v.js +16 -0
  20. package/dist/chunks/auth-b4atwt7w.js +37 -0
  21. package/dist/chunks/auth-bgzrbsek.js +13 -0
  22. package/dist/chunks/auth-bkb1xk38.js +42 -0
  23. package/dist/chunks/auth-bkk2wfbz.js +23 -0
  24. package/dist/chunks/auth-byzd2nk7.js +21 -0
  25. package/dist/chunks/auth-cm8xmqjn.js +13 -0
  26. package/dist/chunks/auth-d2g7egyw.js +25 -0
  27. package/dist/chunks/auth-e09mshwt.js +23 -0
  28. package/dist/chunks/auth-erwrh284.js +156 -0
  29. package/dist/chunks/auth-frv6gfy7.js +33 -0
  30. package/dist/chunks/auth-fyjxk8m3.js +22 -0
  31. package/dist/chunks/auth-gsks0nj8.js +149 -0
  32. package/dist/chunks/auth-hezj1jdf.js +7 -0
  33. package/dist/chunks/auth-kv6ycdgm.js +77 -0
  34. package/dist/chunks/auth-m6wvgbfq.js +60 -0
  35. package/dist/chunks/auth-p5hgn93y.js +26 -0
  36. package/dist/chunks/auth-pd1pbg0v.js +17 -0
  37. package/dist/chunks/auth-q4bn6dy8.js +39 -0
  38. package/dist/chunks/auth-r4dhhtgz.js +346 -0
  39. package/dist/chunks/auth-rjpqaa8h.js +83 -0
  40. package/dist/chunks/auth-smaf4a18.js +28 -0
  41. package/dist/chunks/auth-t8yzmczr.js +18 -0
  42. package/dist/chunks/auth-tk6nqkmh.js +22 -0
  43. package/dist/chunks/auth-txhx6f1m.js +13 -0
  44. package/dist/chunks/auth-vgxn80m1.js +61 -0
  45. package/dist/chunks/auth-xpxp1sqb.js +22 -0
  46. package/dist/chunks/auth-xsrtpxyd.js +23 -0
  47. package/dist/chunks/auth-yc7nft6q.js +5 -0
  48. package/dist/chunks/auth-z3nth2hg.js +35 -0
  49. package/dist/chunks/auth-z6kg9h7e.js +19 -0
  50. package/dist/chunks/auth-zw9j8b8g.js +32 -0
  51. package/dist/chunks/auth-zxvt7wd3.js +25 -0
  52. package/dist/chunks/auth-zyv89x5n.js +30 -0
  53. package/dist/cors.js +10 -36
  54. package/dist/event-feed.js +20 -60
  55. package/dist/fetch.js +53 -11
  56. package/dist/handlers/agent.js +11 -17
  57. package/dist/handlers/command.js +11 -5
  58. package/dist/handlers/config.js +11 -16
  59. package/dist/handlers/credential.js +11 -14
  60. package/dist/handlers/debug.js +11 -11
  61. package/dist/handlers/event.js +12 -27
  62. package/dist/handlers/form.js +11 -9
  63. package/dist/handlers/fs.js +11 -22
  64. package/dist/handlers/generate.js +11 -15
  65. package/dist/handlers/integration.js +10 -142
  66. package/dist/handlers/location.js +11 -16
  67. package/dist/handlers/mcp.js +11 -31
  68. package/dist/handlers/message.js +10 -42
  69. package/dist/handlers/migration.js +11 -7
  70. package/dist/handlers/model.js +11 -14
  71. package/dist/handlers/permission.js +11 -57
  72. package/dist/handlers/persistent-pty.js +12 -135
  73. package/dist/handlers/plugin.js +11 -47
  74. package/dist/handlers/project.js +11 -9
  75. package/dist/handlers/provider.js +11 -20
  76. package/dist/handlers/pty-socket.js +6 -4
  77. package/dist/handlers/pty.js +13 -107
  78. package/dist/handlers/reference.js +11 -5
  79. package/dist/handlers/rpc.js +11 -15
  80. package/dist/handlers/server.js +12 -13
  81. package/dist/handlers/session-error.js +12 -26
  82. package/dist/handlers/session.js +10 -311
  83. package/dist/handlers/shell.js +11 -25
  84. package/dist/handlers/skill.js +11 -5
  85. package/dist/handlers/vcs.js +11 -19
  86. package/dist/handlers/websearch.js +11 -31
  87. package/dist/handlers/worktree.js +11 -37
  88. package/dist/handlers.d.ts +1 -1
  89. package/dist/handlers.js +46 -33
  90. package/dist/location.js +15 -49
  91. package/dist/middleware/authorization.js +11 -49
  92. package/dist/middleware/form-location.js +10 -25
  93. package/dist/middleware/schema-error.js +8 -15
  94. package/dist/middleware/session-location.js +10 -19
  95. package/dist/options.js +5 -1
  96. package/dist/process.js +108 -28
  97. package/dist/pty-environment.js +12 -9
  98. package/dist/request-tracing.js +6 -2
  99. package/dist/routes.d.ts +2 -2
  100. package/dist/routes.js +52 -118
  101. package/dist/server-info.js +12 -22
  102. package/dist/service-status.js +8 -11
  103. package/dist/workerd.js +80 -12
  104. package/package.json +8 -8
@@ -0,0 +1,22 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/model.ts
9
+ import { Model } from "@opencode/core/model";
10
+ import { Effect } from "effect";
11
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
12
+ var ModelHandler2 = HttpApiBuilder.group(Api2, "server.model", (handlers) => Effect.gen(function* () {
13
+ return handlers.handle("model.list", Effect.fn(function* () {
14
+ const models = yield* Model.Service;
15
+ return yield* response2(models.available());
16
+ })).handle("model.default", Effect.fn(function* () {
17
+ const models = yield* Model.Service;
18
+ return yield* response2(models.default());
19
+ }));
20
+ }));
21
+
22
+ export { ModelHandler2 };
@@ -0,0 +1,149 @@
1
+ import {
2
+ layer5
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ formLocationLayer2
6
+ } from "./auth-frv6gfy7.js";
7
+ import {
8
+ sessionLocationLayer2
9
+ } from "./auth-23w8t84j.js";
10
+ import {
11
+ Api2
12
+ } from "./auth-z6kg9h7e.js";
13
+ import {
14
+ Config2
15
+ } from "./auth-zyv89x5n.js";
16
+ import {
17
+ CorsConfig2
18
+ } from "./auth-q4bn6dy8.js";
19
+ import {
20
+ layer4
21
+ } from "./auth-5p62ed52.js";
22
+ import {
23
+ node2
24
+ } from "./auth-bkk2wfbz.js";
25
+ import {
26
+ handlers2
27
+ } from "./auth-7bj707s9.js";
28
+ import {
29
+ authorizationLayer2
30
+ } from "./auth-m6wvgbfq.js";
31
+ import {
32
+ schemaErrorLayer2
33
+ } from "./auth-t8yzmczr.js";
34
+
35
+ // src/routes.ts
36
+ import { Database } from "@opencode/core/database/database";
37
+ import { V1Migration } from "@opencode/core/database/v1-migration";
38
+ import { App } from "@opencode/core/app";
39
+ import { LayerNode } from "@opencode/util/effect/layer-node";
40
+ import { httpClient } from "@opencode/util/effect/app-node-platform";
41
+ import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder";
42
+ import { Bus } from "@opencode/core/bus";
43
+ import { EventLogger } from "@opencode/core/event-logger";
44
+ import { FileSystemSearch } from "@opencode/core/filesystem/search";
45
+ import { Credential } from "@opencode/core/credential";
46
+ import { Config } from "@opencode/core/config";
47
+ import { PermissionSaved } from "@opencode/core/permission/saved";
48
+ import { PtyTicket } from "@opencode/core/pty/ticket";
49
+ import { PersistentPty } from "@opencode/core/persistent-pty";
50
+ import { Project } from "@opencode/core/project";
51
+ import { Worktree } from "@opencode/core/worktree";
52
+ import { Session } from "@opencode/core/session";
53
+ import { Instance } from "@opencode/core/instance/service";
54
+ import { SessionTransfer } from "@opencode/core/session/transfer";
55
+ import { ShellSelect } from "@opencode/core/shell/select";
56
+ import { Job } from "@opencode/core/job";
57
+ import { Mcp } from "@opencode/core/mcp/index";
58
+ import { Global } from "@opencode/util/global";
59
+ import { InstructionDiscovery } from "@opencode/core/instruction-discovery";
60
+ import { LocationServiceMap } from "@opencode/core/location-service-map";
61
+ import { LocationActivity } from "@opencode/core/location-activity";
62
+ import { ModelsDev } from "@opencode/core/models-dev";
63
+ import { SessionRestart } from "@opencode/core/session/execution/restart";
64
+ import { PluginUpdate } from "@opencode/core/plugin/update";
65
+ import { SdkPlugins } from "@opencode/core/plugin/sdk";
66
+ import { WellKnown } from "@opencode/core/wellknown";
67
+ import { Workspace } from "@opencode/core/workspace";
68
+ import { Watcher } from "@opencode/core/filesystem/watcher";
69
+ import { HttpRouter } from "effect/unstable/http";
70
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
71
+ import { Context, Effect, Layer, Option } from "effect";
72
+ var applicationServiceNodes = [
73
+ Global.node,
74
+ Database.node,
75
+ Bus.node,
76
+ EventLogger.node,
77
+ httpClient,
78
+ Job.node,
79
+ Project.node,
80
+ Worktree.node,
81
+ Session.node,
82
+ Instance.node,
83
+ SessionTransfer.node,
84
+ SdkPlugins.node,
85
+ PluginUpdate.node,
86
+ PermissionSaved.node,
87
+ PtyTicket.node,
88
+ PersistentPty.node,
89
+ Credential.node,
90
+ WellKnown.node,
91
+ node2,
92
+ LocationServiceMap.node,
93
+ LocationActivity.node,
94
+ SessionRestart.node,
95
+ Workspace.node
96
+ ];
97
+ var applicationServices = LayerNode.group(applicationServiceNodes);
98
+ function createRoutes2(options = {}, serviceURLs = () => [], overrides = []) {
99
+ return makeRoutes(options.password ? Config2.configLayer({ password: Option.some(options.password) }) : Config2.layer, options, serviceURLs, overrides);
100
+ }
101
+ function createEmbeddedRoutes2(options = {}, overrides = [], instances) {
102
+ return makeRoutes(Config2.configLayer({ password: Option.none() }), options, () => [], overrides, instances);
103
+ }
104
+ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
105
+ const standard = [
106
+ Database.node.replace(Database.configured(options.database)),
107
+ PersistentPty.node.replace(PersistentPty.configured(options.pty)),
108
+ Bus.node.replace(Bus.configured({ persist: options.events?.persist })),
109
+ App.node.replace(App.configured(options.app)),
110
+ ModelsDev.node.replace(ModelsDev.configured(options.models)),
111
+ Watcher.node.replace(Watcher.configured({ enabled: options.fs?.filewatcher })),
112
+ FileSystemSearch.node.replace(FileSystemSearch.configured({ fff: options.fs?.fff })),
113
+ Global.node.replace(Global.layerWith(options.config?.directory ? { config: options.config.directory } : {})),
114
+ Config.node.replace(Config.configured({
115
+ project: options.config?.project,
116
+ file: options.config?.file,
117
+ content: options.config?.content
118
+ })),
119
+ InstructionDiscovery.node.replace(InstructionDiscovery.configured({ project: options.config?.project })),
120
+ ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
121
+ Mcp.node.replace(Mcp.configured({
122
+ clientInfo: {
123
+ name: options.app?.name ?? "opencode",
124
+ version: options.app?.version ?? "unknown"
125
+ }
126
+ }))
127
+ ];
128
+ const build = (overrides) => {
129
+ const replacements = [
130
+ ...standard,
131
+ ...instances ? [Instance.node.replace(instances(() => replacements))] : [],
132
+ ...overrides
133
+ ];
134
+ return AppNodeBuilder.build(applicationServices, replacements);
135
+ };
136
+ const serviceLayer = options.simulation ? Layer.unwrap(Effect.gen(function* () {
137
+ const { simulationReplacements } = yield* Effect.promise(() => import("@opencode/simulation/backend"));
138
+ const simulation = yield* simulationReplacements({ version: App.make(options.app).version });
139
+ return build([...overrides, ...simulation]);
140
+ })) : build(overrides);
141
+ return serviceLayer.pipe(Layer.flatMap((context) => {
142
+ const services = Layer.succeedContext(context);
143
+ const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer4(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
144
+ const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer5), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
145
+ return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
146
+ }));
147
+ }
148
+
149
+ export { createRoutes2, createEmbeddedRoutes2 };
@@ -0,0 +1,7 @@
1
+ // src/handlers/pty-socket.ts
2
+ import { Effect } from "effect";
3
+ function runPtySocket2(drain, socket, detach) {
4
+ return Effect.raceFirst(drain, socket).pipe(Effect.ensuring(Effect.sync(detach)));
5
+ }
6
+
7
+ export { runPtySocket2 };
@@ -0,0 +1,77 @@
1
+ import {
2
+ missingSession2
3
+ } from "./auth-smaf4a18.js";
4
+ import {
5
+ response2,
6
+ sessionInfo2
7
+ } from "./auth-0ar9gf7q.js";
8
+ import {
9
+ Api2
10
+ } from "./auth-z6kg9h7e.js";
11
+
12
+ // src/handlers/permission.ts
13
+ import { Instance } from "@opencode/core/instance/service";
14
+ import { Location } from "@opencode/core/location";
15
+ import { Permission } from "@opencode/core/permission";
16
+ import { PermissionSaved } from "@opencode/core/permission/saved";
17
+ import { Session } from "@opencode/core/session";
18
+ import { Effect } from "effect";
19
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
20
+ import { PermissionNotFoundError } from "@opencode/protocol/errors";
21
+ function missingRequest(id) {
22
+ return new PermissionNotFoundError({ requestID: id, message: `Permission request not found: ${id}` });
23
+ }
24
+ var PermissionHandler2 = HttpApiBuilder.group(Api2, "server.permission", (handlers) => Effect.gen(function* () {
25
+ const instances = yield* Instance.Service;
26
+ const sessions = yield* Session.Service;
27
+ const requireOwnedRequest = Effect.fnUntraced(function* (sessionID, requestID) {
28
+ const permission = yield* Permission.Service;
29
+ const request = yield* permission.get(requestID);
30
+ if (!request || request.sessionID !== sessionID)
31
+ return yield* missingRequest(requestID);
32
+ return { permission, request };
33
+ });
34
+ return handlers.handle("permission.request.list", Effect.fn(function* () {
35
+ const permission = yield* Permission.Service;
36
+ return yield* response2(permission.list());
37
+ })).handle("session.permission.create", Effect.fn(function* (ctx) {
38
+ const permission = yield* Permission.Service;
39
+ return {
40
+ data: yield* permission.ask({
41
+ id: ctx.payload.id,
42
+ sessionID: ctx.params.sessionID,
43
+ action: ctx.payload.action,
44
+ resources: ctx.payload.resources,
45
+ save: ctx.payload.save,
46
+ metadata: ctx.payload.metadata,
47
+ source: ctx.payload.source,
48
+ agent: ctx.payload.agent
49
+ }).pipe(Effect.catchTag("Session.NotFoundError", missingSession2))
50
+ };
51
+ })).handle("session.permission.list", Effect.fn(function* (ctx) {
52
+ const session = yield* sessionInfo2(sessions, ctx.params.sessionID);
53
+ const requests = yield* Permission.Service.use((permission) => permission.forSession(ctx.params.sessionID)).pipe(instances.provide(session));
54
+ return { data: requests };
55
+ })).handle("session.permission.get", Effect.fn(function* (ctx) {
56
+ const owned = yield* requireOwnedRequest(ctx.params.sessionID, ctx.params.requestID);
57
+ return { data: owned.request };
58
+ })).handle("session.permission.reply", Effect.fn(function* (ctx) {
59
+ const owned = yield* requireOwnedRequest(ctx.params.sessionID, ctx.params.requestID);
60
+ yield* owned.permission.reply({ requestID: ctx.params.requestID, reply: ctx.payload.decision, message: ctx.payload.message }).pipe(Effect.catchTag("Permission.NotFoundError", () => missingRequest(ctx.params.requestID)));
61
+ return HttpApiSchema.NoContent.make();
62
+ })).handle("permission.saved.list", Effect.fn(function* (ctx) {
63
+ const location = yield* Location.Service;
64
+ const saved = yield* PermissionSaved.Service;
65
+ return {
66
+ data: yield* saved.list({
67
+ projectID: ctx.query.projectID ?? location.project.id
68
+ })
69
+ };
70
+ })).handle("permission.saved.remove", Effect.fn(function* (ctx) {
71
+ const saved = yield* PermissionSaved.Service;
72
+ yield* saved.remove(ctx.params.id);
73
+ return HttpApiSchema.NoContent.make();
74
+ }));
75
+ }));
76
+
77
+ export { PermissionHandler2 };
@@ -0,0 +1,60 @@
1
+ import {
2
+ Config2,
3
+ required2,
4
+ authorized2
5
+ } from "./auth-zyv89x5n.js";
6
+
7
+ // src/middleware/authorization.ts
8
+ import { UnauthorizedError } from "@opencode/protocol/errors";
9
+ import { Authorization } from "@opencode/protocol/middleware/authorization";
10
+ import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
11
+ import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
12
+ import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
13
+ import { Effect, Encoding, Layer, Redacted } from "effect";
14
+ import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
15
+ var AUTH_TOKEN_QUERY = "auth_token";
16
+ var WWW_AUTHENTICATE = 'Basic realm="Secure Area"';
17
+ function emptyCredential() {
18
+ return { username: "", password: Redacted.make("") };
19
+ }
20
+ function decodeCredential(input) {
21
+ return Effect.fromResult(Encoding.decodeBase64String(input)).pipe(Effect.match({
22
+ onFailure: emptyCredential,
23
+ onSuccess: (header) => {
24
+ const separator = header.indexOf(":");
25
+ if (separator === -1)
26
+ return emptyCredential();
27
+ return { username: header.slice(0, separator), password: Redacted.make(header.slice(separator + 1)) };
28
+ }
29
+ }));
30
+ }
31
+ function credentialFromRequest(request) {
32
+ const url = new URL(request.url, "http://localhost");
33
+ const token = url.searchParams.get(AUTH_TOKEN_QUERY);
34
+ if (token)
35
+ return decodeCredential(token);
36
+ const match = /^Basic\s+(.+)$/i.exec(request.headers.authorization ?? "");
37
+ if (match)
38
+ return decodeCredential(match[1]);
39
+ return Effect.succeed(emptyCredential());
40
+ }
41
+ function authorizedRequest2(request, config) {
42
+ return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config)));
43
+ }
44
+ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
45
+ const config = yield* Config2;
46
+ if (!required2(config))
47
+ return Authorization.of((effect) => effect);
48
+ return Authorization.of((effect) => Effect.gen(function* () {
49
+ const request = yield* HttpServerRequest.HttpServerRequest;
50
+ const url = new URL(request.url, "http://localhost");
51
+ if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url))
52
+ return yield* effect;
53
+ if (yield* authorizedRequest2(request, config))
54
+ return yield* effect;
55
+ yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
56
+ return yield* new UnauthorizedError({ message: "Authentication required" });
57
+ }));
58
+ }));
59
+
60
+ export { authorizedRequest2, authorizationLayer2, Authorization2 };
@@ -0,0 +1,26 @@
1
+ import {
2
+ isAllowedCorsOrigin2
3
+ } from "./auth-q4bn6dy8.js";
4
+ import {
5
+ createRoutes2
6
+ } from "./auth-gsks0nj8.js";
7
+ import {
8
+ __export
9
+ } from "./auth-9rqn6x4v.js";
10
+
11
+ // src/fetch.ts
12
+ var exports_fetch = {};
13
+ __export(exports_fetch, {
14
+ ServerFetch: () => exports_fetch,
15
+ make: () => make3
16
+ });
17
+ import { Context, Effect, Layer } from "effect";
18
+ import { HttpEffect, HttpMiddleware, HttpRouter, HttpServer } from "effect/unstable/http";
19
+ import { SessionRestart } from "@opencode/core/session/execution/restart";
20
+ var make3 = Effect.fn("ServerFetch.make")(function* (options = {}, boot = {}) {
21
+ const context = yield* Layer.build(createRoutes2(options, () => [], boot.overrides ?? []).pipe(Layer.provide(HttpServer.layerServices)));
22
+ yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions);
23
+ return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin2(origin, options), maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
24
+ });
25
+
26
+ export { make3, exports_fetch };
@@ -0,0 +1,17 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/form.ts
9
+ import { Form } from "@opencode/core/form";
10
+ import { Effect } from "effect";
11
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
12
+ var FormHandler2 = HttpApiBuilder.group(Api2, "server.form", (handlers) => handlers.handle("form.list", Effect.fn(function* () {
13
+ const form = yield* Form.Service;
14
+ return yield* response2(form.list());
15
+ })));
16
+
17
+ export { FormHandler2 };
@@ -0,0 +1,39 @@
1
+ // src/cors.ts
2
+ import { Context } from "effect";
3
+ var opencodeOrigin = /^https:\/\/([a-z0-9-]+\.)*opencode\.ai$/;
4
+ var CorsConfig2 = Context.Reference("@opencode/ServerCorsConfig", {
5
+ defaultValue: () => {
6
+ return;
7
+ }
8
+ });
9
+ function isAllowedCorsOrigin2(input, opts) {
10
+ if (!input)
11
+ return true;
12
+ if (input.startsWith("http://localhost:"))
13
+ return true;
14
+ if (input.startsWith("http://127.0.0.1:"))
15
+ return true;
16
+ if (input.startsWith("oc://renderer"))
17
+ return true;
18
+ if (input === "tauri://localhost" || input === "http://tauri.localhost" || input === "https://tauri.localhost")
19
+ return true;
20
+ if (opencodeOrigin.test(input))
21
+ return true;
22
+ return opts?.cors?.includes(input) ?? false;
23
+ }
24
+ function isAllowedRequestOrigin2(input, host, opts) {
25
+ if (!input)
26
+ return true;
27
+ if (host && sameHost(input, host))
28
+ return true;
29
+ return isAllowedCorsOrigin2(input, opts);
30
+ }
31
+ function sameHost(origin, host) {
32
+ try {
33
+ return new URL(origin).host === host;
34
+ } catch {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ export { CorsConfig2, isAllowedCorsOrigin2, isAllowedRequestOrigin2 };