@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,35 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/shell.ts
9
+ import { Shell } from "@opencode/core/shell";
10
+ import { Location } from "@opencode/core/location";
11
+ import { Effect } from "effect";
12
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
13
+ import { ShellNotFoundError } from "@opencode/protocol/errors";
14
+ var ShellHandler2 = HttpApiBuilder.group(Api2, "server.shell", (handlers) => Effect.gen(function* () {
15
+ return handlers.handle("shell.list", Effect.fn(function* () {
16
+ const shell = yield* Shell.Service;
17
+ return yield* response2(shell.list());
18
+ })).handle("shell.create", Effect.fn(function* (ctx) {
19
+ const shell = yield* Shell.Service;
20
+ const location = yield* Location.Service;
21
+ return yield* response2(shell.create({ ...ctx.payload, cwd: ctx.payload.cwd || location.directory }).pipe(Effect.orDie));
22
+ })).handle("shell.get", Effect.fn(function* (ctx) {
23
+ const shell = yield* Shell.Service;
24
+ return yield* response2(shell.get(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
25
+ })).handle("shell.output", Effect.fn(function* (ctx) {
26
+ const shell = yield* Shell.Service;
27
+ return yield* response2(shell.output(ctx.params.id, { cursor: ctx.query.cursor, limit: ctx.query.limit }).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
28
+ })).handle("shell.remove", Effect.fn(function* (ctx) {
29
+ const shell = yield* Shell.Service;
30
+ yield* shell.remove(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => Effect.void));
31
+ return HttpApiSchema.NoContent.make();
32
+ }));
33
+ }));
34
+
35
+ export { ShellHandler2 };
@@ -0,0 +1,19 @@
1
+ import {
2
+ LocationMiddleware2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ FormLocationMiddleware2
6
+ } from "./auth-frv6gfy7.js";
7
+ import {
8
+ SessionLocationMiddleware2
9
+ } from "./auth-23w8t84j.js";
10
+
11
+ // src/api.ts
12
+ import { makeDefaultApi } from "@opencode/protocol/api";
13
+ var Api2 = makeDefaultApi({
14
+ locationMiddleware: LocationMiddleware2,
15
+ formLocationMiddleware: FormLocationMiddleware2,
16
+ sessionLocationMiddleware: SessionLocationMiddleware2
17
+ });
18
+
19
+ export { Api2 };
@@ -0,0 +1,32 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/vcs.ts
9
+ import { Vcs } from "@opencode/core/vcs";
10
+ import { ServiceUnavailableError } from "@opencode/protocol/errors";
11
+ import { Effect } from "effect";
12
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
13
+ var VcsHandler2 = HttpApiBuilder.group(Api2, "server.vcs", (handlers) => Effect.gen(function* () {
14
+ return handlers.handle("vcs.get", () => response2(Effect.gen(function* () {
15
+ const vcs = yield* Vcs.Service;
16
+ return yield* vcs.info();
17
+ }))).handle("vcs.base", () => response2(Effect.gen(function* () {
18
+ const vcs = yield* Vcs.Service;
19
+ return yield* vcs.base().pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
20
+ }))).handle("vcs.status", () => response2(Effect.gen(function* () {
21
+ const vcs = yield* Vcs.Service;
22
+ return yield* vcs.status();
23
+ }))).handle("vcs.branch.list", (ctx) => response2(Effect.gen(function* () {
24
+ const vcs = yield* Vcs.Service;
25
+ return yield* vcs.branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) });
26
+ }))).handle("vcs.diff", (ctx) => response2(Effect.gen(function* () {
27
+ const vcs = yield* Vcs.Service;
28
+ return yield* vcs.diff(ctx.query.mode, { context: ctx.query.context, base: ctx.query.base }).pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
29
+ })));
30
+ }));
31
+
32
+ export { VcsHandler2 };
@@ -0,0 +1,25 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/agent.ts
9
+ import { Agent } from "@opencode/core/agent";
10
+ import { Effect } from "effect";
11
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
12
+ import { AgentNotFoundError } from "@opencode/protocol/errors";
13
+ var AgentHandler2 = HttpApiBuilder.group(Api2, "server.agent", (handlers) => handlers.handle("agent.list", () => Effect.gen(function* () {
14
+ return yield* response2(Agent.Service.use((agent) => agent.list()));
15
+ })).handle("agent.get", Effect.fn(function* (ctx) {
16
+ const agent = yield* Agent.Service.use((service) => service.get(ctx.params.agentID));
17
+ if (!agent)
18
+ return yield* new AgentNotFoundError({
19
+ agentID: ctx.params.agentID,
20
+ message: `Agent not found: ${ctx.params.agentID}`
21
+ });
22
+ return yield* response2(Effect.succeed(agent));
23
+ })));
24
+
25
+ export { AgentHandler2 };
@@ -0,0 +1,30 @@
1
+ import {
2
+ __export
3
+ } from "./auth-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/auth-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
+ Service3,
6
+ frame2,
7
+ make4,
8
+ layer3,
9
+ exports_event_feed
10
+ } from "./chunks/auth-rjpqaa8h.js";
11
+ export {
12
+ EncodingError2 as EncodingError,
13
+ exports_event_feed as EventFeed,
14
+ Service3 as Service,
15
+ SubscriberCapacity2 as SubscriberCapacity,
16
+ SubscriberOverflowError2 as SubscriberOverflowError,
17
+ frame2 as frame,
18
+ layer3 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
+ make3,
3
+ exports_fetch
4
+ } from "./chunks/auth-p5hgn93y.js";
5
+ import"./chunks/auth-gsks0nj8.js";
6
+ import"./chunks/auth-t8yzmczr.js";
7
+ import"./chunks/auth-m6wvgbfq.js";
8
+ import"./chunks/auth-7bj707s9.js";
9
+ import"./chunks/auth-pd1pbg0v.js";
10
+ import"./chunks/auth-tk6nqkmh.js";
11
+ import"./chunks/auth-8nbs1vvt.js";
12
+ import"./chunks/auth-cm8xmqjn.js";
13
+ import"./chunks/auth-1wj0ectp.js";
14
+ import"./chunks/auth-bkb1xk38.js";
15
+ import"./chunks/auth-z3nth2hg.js";
16
+ import"./chunks/auth-6aya8ky6.js";
17
+ import"./chunks/auth-d2g7egyw.js";
18
+ import"./chunks/auth-b4atwt7w.js";
19
+ import"./chunks/auth-0qzy9yxk.js";
20
+ import"./chunks/auth-zw9j8b8g.js";
21
+ import"./chunks/auth-byzd2nk7.js";
22
+ import"./chunks/auth-zxvt7wd3.js";
23
+ import"./chunks/auth-fyjxk8m3.js";
24
+ import"./chunks/auth-bgzrbsek.js";
25
+ import"./chunks/auth-8e21y1bd.js";
26
+ import"./chunks/auth-3582t7j8.js";
27
+ import"./chunks/auth-34e6wr3b.js";
28
+ import"./chunks/auth-erwrh284.js";
29
+ import"./chunks/auth-40g8rvw4.js";
30
+ import"./chunks/auth-e09mshwt.js";
31
+ import"./chunks/auth-txhx6f1m.js";
32
+ import"./chunks/auth-xpxp1sqb.js";
33
+ import"./chunks/auth-7qtja2kq.js";
34
+ import"./chunks/auth-vgxn80m1.js";
35
+ import"./chunks/auth-hezj1jdf.js";
36
+ import"./chunks/auth-760vtqy2.js";
37
+ import"./chunks/auth-r4dhhtgz.js";
38
+ import"./chunks/auth-8ygjd1s8.js";
39
+ import"./chunks/auth-kv6ycdgm.js";
40
+ import"./chunks/auth-zyv89x5n.js";
41
+ import"./chunks/auth-bkk2wfbz.js";
42
+ import"./chunks/auth-q4bn6dy8.js";
43
+ import"./chunks/auth-rjpqaa8h.js";
44
+ import"./chunks/auth-5p62ed52.js";
45
+ import"./chunks/auth-z6kg9h7e.js";
46
+ import"./chunks/auth-23w8t84j.js";
47
+ import"./chunks/auth-frv6gfy7.js";
48
+ import"./chunks/auth-0ar9gf7q.js";
49
+ import"./chunks/auth-smaf4a18.js";
50
+ export {
51
+ exports_fetch as ServerFetch,
52
+ make3 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/auth-zxvt7wd3.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-bgzrbsek.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-xpxp1sqb.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-e09mshwt.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-8e21y1bd.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-b4atwt7w.js";
4
+ import"../chunks/auth-rjpqaa8h.js";
5
+ import"../chunks/auth-z6kg9h7e.js";
6
+ import"../chunks/auth-23w8t84j.js";
7
+ import"../chunks/auth-frv6gfy7.js";
8
+ import"../chunks/auth-0ar9gf7q.js";
9
+ import"../chunks/auth-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/auth-pd1pbg0v.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-8nbs1vvt.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-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/auth-d2g7egyw.js";
4
+ import"../chunks/auth-z6kg9h7e.js";
5
+ import"../chunks/auth-23w8t84j.js";
6
+ import"../chunks/auth-frv6gfy7.js";
7
+ import"../chunks/auth-0ar9gf7q.js";
8
+ import"../chunks/auth-smaf4a18.js";
9
+ export {
10
+ GenerateHandler2 as GenerateHandler
11
+ };