@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
@@ -0,0 +1,30 @@
1
+ import {
2
+ __export
3
+ } from "./workerd-9rqn6x4v.js";
4
+
5
+ // src/auth.ts
6
+ var exports_auth = {};
7
+ __export(exports_auth, {
8
+ Config: () => Config2,
9
+ ServerAuth: () => exports_auth,
10
+ authorized: () => authorized2,
11
+ required: () => required2
12
+ });
13
+ import { Context, Layer, Option, Redacted } from "effect";
14
+
15
+ class Config2 extends Context.Service()("@opencode/ServerAuthConfig") {
16
+ static configLayer(input) {
17
+ return Layer.succeed(this, this.of({ ...input, username: "opencode" }));
18
+ }
19
+ static get layer() {
20
+ return this.configLayer({ password: Option.none() });
21
+ }
22
+ }
23
+ function required2(config) {
24
+ return Option.isSome(config.password) && config.password.value !== "";
25
+ }
26
+ function authorized2(credentials, config) {
27
+ return Option.isSome(config.password) && credentials.username === config.username && Redacted.value(credentials.password) === config.password.value;
28
+ }
29
+
30
+ export { Config2, required2, authorized2, exports_auth };
package/dist/cors.js CHANGED
@@ -1,36 +1,10 @@
1
- import { Context } from "effect";
2
- const opencodeOrigin = /^https:\/\/([a-z0-9-]+\.)*opencode\.ai$/;
3
- export const CorsConfig = Context.Reference("@opencode/ServerCorsConfig", {
4
- defaultValue: () => {
5
- return;
6
- }
7
- });
8
- export function isAllowedCorsOrigin(input, opts) {
9
- if (!input)
10
- return !0;
11
- if (input.startsWith("http://localhost:"))
12
- return !0;
13
- if (input.startsWith("http://127.0.0.1:"))
14
- return !0;
15
- if (input.startsWith("oc://renderer"))
16
- return !0;
17
- if (input === "tauri://localhost" || input === "http://tauri.localhost" || input === "https://tauri.localhost")
18
- return !0;
19
- if (opencodeOrigin.test(input))
20
- return !0;
21
- return opts?.cors?.includes(input) ?? !1;
22
- }
23
- export function isAllowedRequestOrigin(input, host, opts) {
24
- if (!input)
25
- return !0;
26
- if (host && sameHost(input, host))
27
- return !0;
28
- return isAllowedCorsOrigin(input, opts);
29
- }
30
- function sameHost(origin, host) {
31
- try {
32
- return new URL(origin).host === host;
33
- } catch {
34
- return !1;
35
- }
36
- }
1
+ import {
2
+ CorsConfig2,
3
+ isAllowedCorsOrigin2,
4
+ isAllowedRequestOrigin2
5
+ } from "./chunks/workerd-q4bn6dy8.js";
6
+ export {
7
+ CorsConfig2 as CorsConfig,
8
+ isAllowedCorsOrigin2 as isAllowedCorsOrigin,
9
+ isAllowedRequestOrigin2 as isAllowedRequestOrigin
10
+ };
@@ -1,60 +1,20 @@
1
- export * as EventFeed from "./event-feed";
2
- import { Bus } from "@opencode/core/bus";
3
- import { Event } from "@opencode/schema/event";
4
- import { isOpenCodeEvent } from "@opencode/protocol/groups/event";
5
- import { Cause, Context, Effect, Layer, Queue, Schema, Scope, Stream } from "effect";
6
- export const SubscriberCapacity = 4096;
7
-
8
- export class SubscriberOverflowError extends Schema.TaggedError()("EventFeed.SubscriberOverflow", { capacity: Schema.Int }) {
9
- }
10
-
11
- export class EncodingError extends Schema.TaggedError()("EventFeed.EncodingError", {
12
- eventID: Event.ID,
13
- eventType: Schema.String,
14
- cause: Schema.Defect()
15
- }) {
16
- }
17
-
18
- export class Service extends Context.Service()("@opencode/server/EventFeed") {
19
- }
20
- export function frame(event) {
21
- return `data: ${JSON.stringify(event)}
22
-
23
- `;
24
- }
25
- export const make = Effect.fn("EventFeed.make")(function* (observe, options) {
26
- const capacity = options?.capacity ?? SubscriberCapacity, render = options?.encode ?? frame, subscribers = new Set, fail = (error) => Effect.sync(() => {
27
- const current = Array.from(subscribers);
28
- subscribers.clear();
29
- for (const subscriber of current)
30
- Queue.failCauseUnsafe(subscriber, Cause.fail(error));
31
- }), publish = Effect.fnUntraced(function* (event) {
32
- if (!isOpenCodeEvent(event))
33
- return;
34
- if (subscribers.size === 0)
35
- return;
36
- const encoded = yield* Effect.try({
37
- try: () => render(event),
38
- catch: (cause) => new EncodingError({ eventID: event.id, eventType: event.type, cause })
39
- }).pipe(Effect.catch((error) => Effect.logError("Failed to encode public event", {
40
- eventID: error.eventID,
41
- eventType: error.eventType,
42
- cause: error.cause
43
- }).pipe(Effect.andThen(fail(error)), Effect.as(void 0))));
44
- if (encoded === void 0)
45
- return;
46
- for (const subscriber of subscribers) {
47
- if (Queue.offerUnsafe(subscriber, encoded))
48
- continue;
49
- subscribers.delete(subscriber);
50
- Queue.failCauseUnsafe(subscriber, Cause.fail(new SubscriberOverflowError({ capacity })));
51
- }
52
- }), unsubscribe = yield* observe(publish);
53
- yield* Effect.addFinalizer(() => unsubscribe);
54
- return Service.of({
55
- subscribe: Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.add(queue)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
56
- });
57
- }), layer = Layer.effect(Service, Effect.gen(function* () {
58
- const bus = yield* Bus.Service;
59
- return yield* make(bus.listen);
60
- }));
1
+ import {
2
+ SubscriberCapacity2,
3
+ SubscriberOverflowError2,
4
+ EncodingError2,
5
+ Service2,
6
+ frame2,
7
+ make4,
8
+ layer2,
9
+ exports_event_feed
10
+ } from "./chunks/workerd-2sy3c7de.js";
11
+ export {
12
+ EncodingError2 as EncodingError,
13
+ exports_event_feed as EventFeed,
14
+ Service2 as Service,
15
+ SubscriberCapacity2 as SubscriberCapacity,
16
+ SubscriberOverflowError2 as SubscriberOverflowError,
17
+ frame2 as frame,
18
+ layer2 as layer,
19
+ make4 as make
20
+ };
package/dist/fetch.js CHANGED
@@ -1,11 +1,53 @@
1
- export * as ServerFetch from "./fetch";
2
- import { Context, Effect, Layer } from "effect";
3
- import { HttpEffect, HttpMiddleware, HttpRouter, HttpServer } from "effect/unstable/http";
4
- import { SessionRestart } from "@opencode/core/session/execution/restart";
5
- import { isAllowedCorsOrigin } from "./cors";
6
- import { createRoutes } from "./routes";
7
- export const make = Effect.fn("ServerFetch.make")(function* (options = {}, boot = {}) {
8
- const context = yield* Layer.build(createRoutes(options, () => [], boot.overrides ?? []).pipe(Layer.provide(HttpServer.layerServices)));
9
- yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions);
10
- return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin(origin, options), maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
11
- });
1
+ import {
2
+ make2,
3
+ exports_fetch
4
+ } from "./chunks/workerd-bkqymx4n.js";
5
+ import"./chunks/workerd-6ptwb1q1.js";
6
+ import"./chunks/workerd-m6wvgbfq.js";
7
+ import"./chunks/workerd-t8yzmczr.js";
8
+ import"./chunks/workerd-zyv89x5n.js";
9
+ import"./chunks/workerd-2rvsests.js";
10
+ import"./chunks/workerd-7cfyat0f.js";
11
+ import"./chunks/workerd-q0ycym90.js";
12
+ import"./chunks/workerd-bjrwanme.js";
13
+ import"./chunks/workerd-254zvkj6.js";
14
+ import"./chunks/workerd-4g0fa6m0.js";
15
+ import"./chunks/workerd-19c9ysa1.js";
16
+ import"./chunks/workerd-req22b70.js";
17
+ import"./chunks/workerd-a6yp8301.js";
18
+ import"./chunks/workerd-j2pfq4q6.js";
19
+ import"./chunks/workerd-1c4qas2w.js";
20
+ import"./chunks/workerd-4vn5bvkr.js";
21
+ import"./chunks/workerd-8bajbwjh.js";
22
+ import"./chunks/workerd-ceh2h0m9.js";
23
+ import"./chunks/workerd-ysabas57.js";
24
+ import"./chunks/workerd-arj41x43.js";
25
+ import"./chunks/workerd-b0b71rwa.js";
26
+ import"./chunks/workerd-hjnxtxmk.js";
27
+ import"./chunks/workerd-br99j6q1.js";
28
+ import"./chunks/workerd-qzap92t7.js";
29
+ import"./chunks/workerd-x1haxfjx.js";
30
+ import"./chunks/workerd-6nvan4e0.js";
31
+ import"./chunks/workerd-qnwpcgp7.js";
32
+ import"./chunks/workerd-r7e9r02j.js";
33
+ import"./chunks/workerd-pnqq1zxv.js";
34
+ import"./chunks/workerd-rcg4y18n.js";
35
+ import"./chunks/workerd-zp2jm6dt.js";
36
+ import"./chunks/workerd-n0er2m55.js";
37
+ import"./chunks/workerd-hezj1jdf.js";
38
+ import"./chunks/workerd-00nn3k4b.js";
39
+ import"./chunks/workerd-04xw3v55.js";
40
+ import"./chunks/workerd-7rzt3wm8.js";
41
+ import"./chunks/workerd-2sy3c7de.js";
42
+ import"./chunks/workerd-q4bn6dy8.js";
43
+ import"./chunks/workerd-mzr9gftb.js";
44
+ import"./chunks/workerd-z5shrcz9.js";
45
+ import"./chunks/workerd-3kzx88w9.js";
46
+ import"./chunks/workerd-5rwqcaw2.js";
47
+ import"./chunks/workerd-6gkz39ey.js";
48
+ import"./chunks/workerd-smaf4a18.js";
49
+ import"./chunks/workerd-75c938bc.js";
50
+ export {
51
+ exports_fetch as ServerFetch,
52
+ make2 as make
53
+ };
@@ -1,17 +1,11 @@
1
- import { Agent } from "@opencode/core/agent";
2
- import { Effect } from "effect";
3
- import { HttpApiBuilder } from "effect/unstable/httpapi";
4
- import { Api } from "../api";
5
- import { response } from "../location";
6
- import { AgentNotFoundError } from "@opencode/protocol/errors";
7
- export const AgentHandler = HttpApiBuilder.group(Api, "server.agent", (handlers) => handlers.handle("agent.list", () => Effect.gen(function* () {
8
- return yield* response(Agent.Service.use((agent) => agent.list()));
9
- })).handle("agent.get", Effect.fn(function* (ctx) {
10
- const agent = yield* Agent.Service.use((service) => service.get(ctx.params.agentID));
11
- if (!agent)
12
- return yield* new AgentNotFoundError({
13
- agentID: ctx.params.agentID,
14
- message: `Agent not found: ${ctx.params.agentID}`
15
- });
16
- return yield* response(Effect.succeed(agent));
17
- })));
1
+ import {
2
+ AgentHandler2
3
+ } from "../chunks/workerd-ceh2h0m9.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
+ AgentHandler2 as AgentHandler
11
+ };
@@ -1,5 +1,11 @@
1
- import { Command } from "@opencode/core/command";
2
- import { HttpApiBuilder } from "effect/unstable/httpapi";
3
- import { Api } from "../api";
4
- import { response } from "../location";
5
- export const CommandHandler = HttpApiBuilder.group(Api, "server.command", (handlers) => handlers.handle("command.list", () => response(Command.Service.use((command) => command.list()))));
1
+ import {
2
+ CommandHandler2
3
+ } from "../chunks/workerd-r7e9r02j.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
+ CommandHandler2 as CommandHandler
11
+ };
@@ -1,16 +1,11 @@
1
- import { Config } from "@opencode/core/config";
2
- import { ShellSelect } from "@opencode/core/shell/select";
3
- import { Effect } from "effect";
4
- import { HttpApiBuilder } from "effect/unstable/httpapi";
5
- import { Api } from "../api";
6
- export const ConfigHandler = HttpApiBuilder.group(Api, "server.config", (handlers) => handlers.handle("config.get", () => Config.Service.use((config) => config.entries())).handle("config.update", Effect.fn(function* (ctx) {
7
- const config = yield* Config.Service;
8
- if (!config.update)
9
- return yield* Effect.die(Error("Config updates are unavailable"));
10
- return yield* config.update(ctx.payload).pipe(Effect.orDie);
11
- })).handle("config.shells", Effect.fn(function* () {
12
- const shell = yield* ShellSelect.Service;
13
- if (!shell.list)
14
- return yield* Effect.die(Error("Shell discovery is unavailable"));
15
- return yield* shell.list();
16
- })));
1
+ import {
2
+ ConfigHandler2
3
+ } from "../chunks/workerd-qnwpcgp7.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
+ ConfigHandler2 as ConfigHandler
11
+ };
@@ -1,14 +1,11 @@
1
- import { Credential } from "@opencode/core/credential";
2
- import { Effect } from "effect";
3
- import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
4
- import { Api } from "../api";
5
- export const CredentialHandler = HttpApiBuilder.group(Api, "server.credential", (handlers) => handlers.handle("credential.update", Effect.fn(function* (ctx) {
6
- yield* (yield* Credential.Service).update(ctx.params.credentialID, { label: ctx.payload.label });
7
- return HttpApiSchema.NoContent.make();
8
- })).handle("credential.activate", Effect.fn(function* (ctx) {
9
- yield* (yield* Credential.Service).activate(ctx.params.credentialID);
10
- return HttpApiSchema.NoContent.make();
11
- })).handle("credential.remove", Effect.fn(function* (ctx) {
12
- yield* (yield* Credential.Service).remove(ctx.params.credentialID);
13
- return HttpApiSchema.NoContent.make();
14
- })));
1
+ import {
2
+ CredentialHandler2
3
+ } from "../chunks/workerd-04xw3v55.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
+ CredentialHandler2 as CredentialHandler
11
+ };
@@ -1,11 +1,11 @@
1
- import { LocationServiceMap } from "@opencode/core/location-service-map";
2
- import { Effect, Option, RcMap } from "effect";
3
- import { HttpApiBuilder } from "effect/unstable/httpapi";
4
- import { Api } from "../api";
5
- import { requestRef } from "../location";
6
- export const DebugHandler = HttpApiBuilder.group(Api, "server.debug", (handlers) => handlers.handle("debug.location", Effect.fn(function* () {
7
- const locations = Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service));
8
- return Array.from(yield* RcMap.keys(locations.rcMap));
9
- })).handle("debug.location.evict", Effect.fn(function* (ctx) {
10
- yield* Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service)).invalidate(requestRef(ctx.request));
11
- })));
1
+ import {
2
+ DebugHandler2
3
+ } from "../chunks/workerd-00nn3k4b.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
+ DebugHandler2 as DebugHandler
11
+ };
@@ -1,27 +1,12 @@
1
- import { Bus } from "@opencode/core/bus";
2
- import { Event } from "@opencode/schema/event";
3
- import { Effect, Stream } from "effect";
4
- import { HttpServerResponse } from "effect/unstable/http";
5
- import { HttpApiBuilder } from "effect/unstable/httpapi";
6
- import { Api } from "../api";
7
- import { EventFeed } from "../event-feed";
8
- export const EventHandler = HttpApiBuilder.group(Api, "server.event", (handlers) => Effect.gen(function* () {
9
- const feed = yield* EventFeed.Service;
10
- return handlers.handleRaw("event.subscribe", () => Effect.gen(function* () {
11
- const connected = {
12
- id: Event.ID.create(),
13
- type: "server.connected",
14
- data: {}
15
- }, output = Stream.unwrap(feed.subscribe.pipe(Effect.map((live) => Stream.make(EventFeed.frame(connected)).pipe(Stream.concat(live))))), heartbeat = Stream.tick("15 seconds").pipe(Stream.map(() => `: heartbeat
16
-
17
- `));
18
- return HttpServerResponse.stream(output.pipe(Stream.merge(heartbeat, { haltStrategy: "left" }), Stream.encodeText), {
19
- contentType: "text/event-stream",
20
- headers: {
21
- "Cache-Control": "no-cache, no-transform",
22
- "X-Accel-Buffering": "no",
23
- "X-Content-Type-Options": "nosniff"
24
- }
25
- });
26
- }));
27
- }));
1
+ import {
2
+ EventHandler2
3
+ } from "../chunks/workerd-7cfyat0f.js";
4
+ import"../chunks/workerd-2sy3c7de.js";
5
+ import"../chunks/workerd-z5shrcz9.js";
6
+ import"../chunks/workerd-3kzx88w9.js";
7
+ import"../chunks/workerd-5rwqcaw2.js";
8
+ import"../chunks/workerd-6gkz39ey.js";
9
+ import"../chunks/workerd-smaf4a18.js";
10
+ export {
11
+ EventHandler2 as EventHandler
12
+ };
@@ -1,9 +1,11 @@
1
- import { Form } from "@opencode/core/form";
2
- import { Effect } from "effect";
3
- import { HttpApiBuilder } from "effect/unstable/httpapi";
4
- import { Api } from "../api";
5
- import { response } from "../location";
6
- export const FormHandler = HttpApiBuilder.group(Api, "server.form", (handlers) => handlers.handle("form.list", Effect.fn(function* () {
7
- const form = yield* Form.Service;
8
- return yield* response(form.list());
9
- })));
1
+ import {
2
+ FormHandler2
3
+ } from "../chunks/workerd-6nvan4e0.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
+ FormHandler2 as FormHandler
11
+ };
@@ -1,22 +1,11 @@
1
- import { FileSystem } from "@opencode/core/filesystem";
2
- import { RelativePath } from "@opencode/core/schema";
3
- import { FileNotFoundError } from "@opencode/protocol/errors";
4
- import { Effect } from "effect";
5
- import { HttpServerResponse } from "effect/unstable/http";
6
- import { HttpApiBuilder } from "effect/unstable/httpapi";
7
- import { Api } from "../api";
8
- import { response } from "../location";
9
- export const FileSystemHandler = HttpApiBuilder.group(Api, "server.fs", (handlers) => Effect.gen(function* () {
10
- return handlers.handleRaw("fs.read", (ctx) => Effect.gen(function* () {
11
- const file = yield* (yield* FileSystem.Service).read({
12
- path: RelativePath.make(decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13)))
13
- }).pipe(Effect.mapError((error) => new FileNotFoundError({ path: error.path, message: `File not found: ${error.path}` })));
14
- return HttpServerResponse.uint8Array(file.content, { contentType: file.mime });
15
- })).handle("fs.list", (ctx) => response(Effect.gen(function* () {
16
- return yield* (yield* FileSystem.Service).list(ctx.query);
17
- }))).handle("fs.find", (ctx) => response(Effect.gen(function* () {
18
- return yield* (yield* FileSystem.Service).find(ctx.query);
19
- }))).handle("fs.write", (ctx) => response(Effect.gen(function* () {
20
- return yield* (yield* FileSystem.Service).write({ path: ctx.query.path, data: ctx.payload });
21
- })));
22
- }));
1
+ import {
2
+ FileSystemHandler2
3
+ } from "../chunks/workerd-hjnxtxmk.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
+ FileSystemHandler2 as FileSystemHandler
11
+ };
@@ -1,15 +1,11 @@
1
- import { Generate } from "@opencode/core/generate";
2
- import { Location } from "@opencode/core/location";
3
- import { LocationServiceMap } from "@opencode/core/location-services";
4
- import { AbsolutePath } from "@opencode/core/schema";
5
- import { InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors";
6
- import { Global } from "@opencode/util/global";
7
- import { Effect } from "effect";
8
- import { HttpApiBuilder } from "effect/unstable/httpapi";
9
- import { Api } from "../api";
10
- export const GenerateHandler = HttpApiBuilder.group(Api, "server.generate", (handlers) => Effect.gen(function* () {
11
- const global = yield* Global.Service, services = (yield* LocationServiceMap.Service).get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }));
12
- return handlers.handle("generate.text", Effect.fn("server.generate.text")(function* (request) {
13
- return { data: { text: yield* (yield* Generate.Service).text(request.payload).pipe(Effect.mapError((error) => error._tag === "Generate.ModelSelectionError" ? new InvalidRequestError({ message: error.message }) : new ServiceUnavailableError({ message: error.message, service: error.service }))) } };
14
- }, Effect.provide(services)));
15
- }));
1
+ import {
2
+ GenerateHandler2
3
+ } from "../chunks/workerd-4vn5bvkr.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
+ GenerateHandler2 as GenerateHandler
11
+ };
@@ -1,143 +1,11 @@
1
- import { Integration } from "@opencode/core/integration";
2
- import { Plugin } from "@opencode/core/plugin";
3
- import { Effect } from "effect";
4
- import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
5
- import { Api } from "../api";
6
1
  import {
7
- IntegrationAttemptNotFoundError,
8
- IntegrationMethodNotFoundError,
9
- IntegrationNotFoundError,
10
- InvalidRequestError
11
- } from "@opencode/protocol/errors";
12
- import { response } from "../location";
13
- import { WellKnown } from "@opencode/core/wellknown";
14
- const authorize = (effect) => effect.pipe(Effect.mapError((error) => new InvalidRequestError({
15
- message: error.cause instanceof Error && error.cause.message.trim() ? error.cause.message : "Authentication failed",
16
- kind: "integration_authorization"
17
- })));
18
- export const IntegrationHandler = HttpApiBuilder.group(Api, "server.integration", (handlers) => Effect.gen(function* () {
19
- return handlers.handle("integration.list", Effect.fn(function* () {
20
- yield* Plugin.awaitActivation;
21
- const service = yield* Integration.Service;
22
- return yield* response(service.list());
23
- })).handle("integration.get", Effect.fn(function* (ctx) {
24
- const integration = yield* (yield* Integration.Service).get(ctx.params.integrationID);
25
- if (!integration)
26
- return yield* new IntegrationNotFoundError({
27
- integrationID: ctx.params.integrationID,
28
- message: `Integration not found: ${ctx.params.integrationID}`
29
- });
30
- return yield* response(Effect.succeed(integration));
31
- })).handle("integration.wellknown.add", Effect.fn(function* (ctx) {
32
- const wellknown = yield* WellKnown.Service, integration = yield* Integration.Service;
33
- yield* wellknown.add(ctx.payload.url).pipe(Effect.mapError((error) => new InvalidRequestError({ message: error.message, kind: "well_known_discovery" })));
34
- yield* integration.reload();
35
- return HttpApiSchema.NoContent.make();
36
- })).handle("integration.connect.key", Effect.fn(function* (ctx) {
37
- const service = yield* Integration.Service;
38
- if (!(yield* service.get(ctx.params.integrationID)))
39
- return yield* new IntegrationNotFoundError({
40
- integrationID: ctx.params.integrationID,
41
- message: `Integration not found: ${ctx.params.integrationID}`
42
- });
43
- yield* authorize(service.connection.key({
44
- integrationID: ctx.params.integrationID,
45
- key: ctx.payload.key,
46
- answer: ctx.payload.answer,
47
- label: ctx.payload.label
48
- }));
49
- return HttpApiSchema.NoContent.make();
50
- })).handle("integration.oauth.connect", Effect.fn(function* (ctx) {
51
- const service = yield* Integration.Service;
52
- return yield* response(authorize(service.oauth.connect({
53
- integrationID: ctx.params.integrationID,
54
- methodID: ctx.payload.methodID,
55
- answer: ctx.payload.answer,
56
- label: ctx.payload.label
57
- })));
58
- })).handle("integration.oauth.status", Effect.fn(function* (ctx) {
59
- const service = yield* Integration.Service;
60
- if (!(yield* service.get(ctx.params.integrationID)))
61
- return yield* new IntegrationNotFoundError({
62
- integrationID: ctx.params.integrationID,
63
- message: `Integration not found: ${ctx.params.integrationID}`
64
- });
65
- return yield* response(service.oauth.status({
66
- integrationID: ctx.params.integrationID,
67
- attemptID: ctx.params.attemptID
68
- }).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
69
- integrationID: error.integrationID,
70
- attemptID: error.attemptID,
71
- message: `OAuth attempt not found: ${error.attemptID}`
72
- }))));
73
- })).handle("integration.oauth.complete", Effect.fn(function* (ctx) {
74
- const service = yield* Integration.Service;
75
- if (!(yield* service.get(ctx.params.integrationID)))
76
- return yield* new IntegrationNotFoundError({
77
- integrationID: ctx.params.integrationID,
78
- message: `Integration not found: ${ctx.params.integrationID}`
79
- });
80
- yield* service.oauth.complete({
81
- integrationID: ctx.params.integrationID,
82
- attemptID: ctx.params.attemptID,
83
- code: ctx.payload.code
84
- }).pipe(Effect.mapError((error) => {
85
- if (error._tag === "Integration.AttemptNotFound")
86
- return new IntegrationAttemptNotFoundError({
87
- integrationID: error.integrationID,
88
- attemptID: error.attemptID,
89
- message: `OAuth attempt not found: ${error.attemptID}`
90
- });
91
- return new InvalidRequestError({
92
- message: error._tag === "Integration.CodeRequired" ? "Authorization code is required" : "Authentication failed",
93
- kind: error._tag === "Integration.CodeRequired" ? "integration_code_required" : "integration_authorization"
94
- });
95
- }));
96
- return HttpApiSchema.NoContent.make();
97
- })).handle("integration.oauth.cancel", Effect.fn(function* (ctx) {
98
- yield* (yield* Integration.Service).oauth.cancel({
99
- integrationID: ctx.params.integrationID,
100
- attemptID: ctx.params.attemptID
101
- });
102
- return HttpApiSchema.NoContent.make();
103
- })).handle("integration.command.connect", Effect.fn(function* (ctx) {
104
- const service = yield* Integration.Service, integration = yield* service.get(ctx.params.integrationID);
105
- if (!integration)
106
- return yield* new IntegrationNotFoundError({
107
- integrationID: ctx.params.integrationID,
108
- message: `Integration not found: ${ctx.params.integrationID}`
109
- });
110
- if (!integration.methods.some((method) => method.type === "command" && method.id === ctx.payload.methodID))
111
- return yield* new IntegrationMethodNotFoundError({
112
- integrationID: ctx.params.integrationID,
113
- methodID: ctx.payload.methodID,
114
- message: `Integration method not found: ${ctx.payload.methodID}`
115
- });
116
- return yield* response(authorize(service.command.connect({
117
- integrationID: ctx.params.integrationID,
118
- methodID: ctx.payload.methodID,
119
- label: ctx.payload.label
120
- })));
121
- })).handle("integration.command.status", Effect.fn(function* (ctx) {
122
- const service = yield* Integration.Service;
123
- if (!(yield* service.get(ctx.params.integrationID)))
124
- return yield* new IntegrationNotFoundError({
125
- integrationID: ctx.params.integrationID,
126
- message: `Integration not found: ${ctx.params.integrationID}`
127
- });
128
- return yield* response(service.command.status({
129
- integrationID: ctx.params.integrationID,
130
- attemptID: ctx.params.attemptID
131
- }).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
132
- integrationID: error.integrationID,
133
- attemptID: error.attemptID,
134
- message: `Command attempt not found: ${error.attemptID}`
135
- }))));
136
- })).handle("integration.command.cancel", Effect.fn(function* (ctx) {
137
- yield* (yield* Integration.Service).command.cancel({
138
- integrationID: ctx.params.integrationID,
139
- attemptID: ctx.params.attemptID
140
- });
141
- return HttpApiSchema.NoContent.make();
142
- }));
143
- }));
2
+ IntegrationHandler2
3
+ } from "../chunks/workerd-a6yp8301.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
+ IntegrationHandler2 as IntegrationHandler
11
+ };