@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,29 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/provider.ts
9
+ import { Provider } from "@opencode/core/provider";
10
+ import { ProviderNotFoundError } from "@opencode/protocol/errors";
11
+ import { Effect } from "effect";
12
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
13
+ var ProviderHandler2 = HttpApiBuilder.group(Api2, "server.provider", (handlers) => Effect.gen(function* () {
14
+ return handlers.handle("provider.list", Effect.fn(function* () {
15
+ const providers = yield* Provider.Service;
16
+ return yield* response2(providers.available());
17
+ })).handle("provider.get", Effect.fn(function* (ctx) {
18
+ const providers = yield* Provider.Service;
19
+ const provider = yield* providers.get(ctx.params.providerID);
20
+ if (!provider)
21
+ return yield* new ProviderNotFoundError({
22
+ providerID: ctx.params.providerID,
23
+ message: `Provider not found: ${ctx.params.providerID}`
24
+ });
25
+ return yield* response2(Effect.succeed(provider));
26
+ }));
27
+ }));
28
+
29
+ export { ProviderHandler2 };
@@ -0,0 +1,99 @@
1
+ import {
2
+ GenerateHandler2
3
+ } from "./auth-d2g7egyw.js";
4
+ import {
5
+ MessageHandler2
6
+ } from "./auth-40g8rvw4.js";
7
+ import {
8
+ ModelHandler2
9
+ } from "./auth-fyjxk8m3.js";
10
+ import {
11
+ ProviderHandler2
12
+ } from "./auth-760vtqy2.js";
13
+ import {
14
+ SessionHandler2
15
+ } from "./auth-r4dhhtgz.js";
16
+ import {
17
+ PermissionHandler2
18
+ } from "./auth-kv6ycdgm.js";
19
+ import {
20
+ FileSystemHandler2
21
+ } from "./auth-8nbs1vvt.js";
22
+ import {
23
+ FormHandler2
24
+ } from "./auth-pd1pbg0v.js";
25
+ import {
26
+ CommandHandler2
27
+ } from "./auth-bgzrbsek.js";
28
+ import {
29
+ SkillHandler2
30
+ } from "./auth-34e6wr3b.js";
31
+ import {
32
+ RpcHandler2
33
+ } from "./auth-1wj0ectp.js";
34
+ import {
35
+ layer3
36
+ } from "./auth-rjpqaa8h.js";
37
+ import {
38
+ EventHandler2
39
+ } from "./auth-b4atwt7w.js";
40
+ import {
41
+ AgentHandler2
42
+ } from "./auth-zxvt7wd3.js";
43
+ import {
44
+ PluginHandler2
45
+ } from "./auth-vgxn80m1.js";
46
+ import {
47
+ ServerHandler2
48
+ } from "./auth-byzd2nk7.js";
49
+ import {
50
+ DebugHandler2
51
+ } from "./auth-8e21y1bd.js";
52
+ import {
53
+ PtyHandler2
54
+ } from "./auth-3582t7j8.js";
55
+ import {
56
+ PersistentPtyHandler2
57
+ } from "./auth-0qzy9yxk.js";
58
+ import {
59
+ ShellHandler2
60
+ } from "./auth-z3nth2hg.js";
61
+ import {
62
+ ReferenceHandler2
63
+ } from "./auth-cm8xmqjn.js";
64
+ import {
65
+ LocationHandler2
66
+ } from "./auth-tk6nqkmh.js";
67
+ import {
68
+ IntegrationHandler2
69
+ } from "./auth-erwrh284.js";
70
+ import {
71
+ WebSearchHandler2
72
+ } from "./auth-6aya8ky6.js";
73
+ import {
74
+ McpHandler2
75
+ } from "./auth-8ygjd1s8.js";
76
+ import {
77
+ CredentialHandler2
78
+ } from "./auth-e09mshwt.js";
79
+ import {
80
+ ProjectHandler2
81
+ } from "./auth-7qtja2kq.js";
82
+ import {
83
+ WorktreeHandler2
84
+ } from "./auth-bkb1xk38.js";
85
+ import {
86
+ VcsHandler2
87
+ } from "./auth-zw9j8b8g.js";
88
+ import {
89
+ MigrationHandler2
90
+ } from "./auth-txhx6f1m.js";
91
+ import {
92
+ ConfigHandler2
93
+ } from "./auth-xpxp1sqb.js";
94
+
95
+ // src/handlers.ts
96
+ import { Layer } from "effect";
97
+ var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(layer3)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
98
+
99
+ export { handlers2 };
@@ -0,0 +1,15 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+
5
+ // src/handlers/project.ts
6
+ import { Project } from "@opencode/core/project";
7
+ import { Effect } from "effect";
8
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
9
+ import { ProjectNotFoundError } from "@opencode/protocol/errors";
10
+ var ProjectHandler2 = HttpApiBuilder.group(Api2, "server.project", (handlers) => handlers.handle("project.list", () => Project.Service.use((project) => project.list())).handle("project.update", (ctx) => Project.Service.use((project) => project.update({ ...ctx.payload, projectID: ctx.params.projectID }).pipe(Effect.mapError(() => new ProjectNotFoundError({
11
+ projectID: ctx.params.projectID,
12
+ message: `Project not found: ${ctx.params.projectID}`
13
+ }))))));
14
+
15
+ export { ProjectHandler2 };
@@ -0,0 +1,20 @@
1
+ import {
2
+ requestRef2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/debug.ts
9
+ import { LocationServiceMap } from "@opencode/core/location-service-map";
10
+ import { Effect, Option, RcMap } from "effect";
11
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
12
+ var DebugHandler2 = HttpApiBuilder.group(Api2, "server.debug", (handlers) => handlers.handle("debug.location", Effect.fn(function* () {
13
+ const locations = Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service));
14
+ return Array.from(yield* RcMap.keys(locations.rcMap));
15
+ })).handle("debug.location.evict", Effect.fn(function* (ctx) {
16
+ const locations = Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service));
17
+ yield* locations.invalidate(requestRef2(ctx.request));
18
+ })));
19
+
20
+ export { DebugHandler2 };
@@ -0,0 +1,34 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/fs.ts
9
+ import { FileSystem } from "@opencode/core/filesystem";
10
+ import { RelativePath } from "@opencode/core/schema";
11
+ import { FileNotFoundError } from "@opencode/protocol/errors";
12
+ import { Effect } from "effect";
13
+ import { HttpServerResponse } from "effect/unstable/http";
14
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
15
+ var FileSystemHandler2 = HttpApiBuilder.group(Api2, "server.fs", (handlers) => Effect.gen(function* () {
16
+ return handlers.handleRaw("fs.read", (ctx) => Effect.gen(function* () {
17
+ const fs = yield* FileSystem.Service;
18
+ const file = yield* fs.read({
19
+ path: RelativePath.make(decodeURIComponent(new URL(ctx.request.url, "http://localhost").pathname.slice(13)))
20
+ }).pipe(Effect.mapError((error) => new FileNotFoundError({ path: error.path, message: `File not found: ${error.path}` })));
21
+ return HttpServerResponse.uint8Array(file.content, { contentType: file.mime });
22
+ })).handle("fs.list", (ctx) => response2(Effect.gen(function* () {
23
+ const fs = yield* FileSystem.Service;
24
+ return yield* fs.list(ctx.query);
25
+ }))).handle("fs.find", (ctx) => response2(Effect.gen(function* () {
26
+ const fs = yield* FileSystem.Service;
27
+ return yield* fs.find(ctx.query);
28
+ }))).handle("fs.write", (ctx) => response2(Effect.gen(function* () {
29
+ const fs = yield* FileSystem.Service;
30
+ return yield* fs.write({ path: ctx.query.path, data: ctx.payload });
31
+ })));
32
+ }));
33
+
34
+ export { FileSystemHandler2 };
@@ -0,0 +1,40 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/mcp.ts
9
+ import { Mcp } from "@opencode/core/mcp/index";
10
+ import { McpServerNotFoundError } from "@opencode/protocol/errors";
11
+ import { Effect } from "effect";
12
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
13
+ var notFound = (effect) => effect.pipe(Effect.mapError((error) => new McpServerNotFoundError({ server: error.server, message: error.message })));
14
+ var McpHandler2 = HttpApiBuilder.group(Api2, "server.mcp", (handlers) => Effect.gen(function* () {
15
+ return handlers.handle("mcp.list", Effect.fn(function* () {
16
+ const service = yield* Mcp.Service;
17
+ return yield* response2(service.servers().pipe(Effect.map((servers) => servers.map((info) => ({ name: info.name, status: info.status, integrationID: info.integrationID })))));
18
+ })).handle("mcp.add", Effect.fn(function* (ctx) {
19
+ const service = yield* Mcp.Service;
20
+ yield* service.add(ctx.params.server, ctx.payload.config);
21
+ return HttpApiSchema.NoContent.make();
22
+ })).handle("mcp.remove", Effect.fn(function* (ctx) {
23
+ const service = yield* Mcp.Service;
24
+ yield* notFound(service.remove(ctx.params.server));
25
+ return HttpApiSchema.NoContent.make();
26
+ })).handle("mcp.connect", Effect.fn(function* (ctx) {
27
+ const service = yield* Mcp.Service;
28
+ yield* notFound(service.connect(ctx.params.server));
29
+ return HttpApiSchema.NoContent.make();
30
+ })).handle("mcp.disconnect", Effect.fn(function* (ctx) {
31
+ const service = yield* Mcp.Service;
32
+ yield* notFound(service.disconnect(ctx.params.server));
33
+ return HttpApiSchema.NoContent.make();
34
+ })).handle("mcp.resource.catalog", Effect.fn(function* () {
35
+ const service = yield* Mcp.Service;
36
+ return yield* response2(service.resourceCatalog());
37
+ }));
38
+ }));
39
+
40
+ export { McpHandler2 };
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+
16
+ export { __export };
@@ -0,0 +1,37 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+ import {
5
+ Service3,
6
+ frame2
7
+ } from "./auth-rjpqaa8h.js";
8
+
9
+ // src/handlers/event.ts
10
+ import { Event } from "@opencode/schema/event";
11
+ import { Effect, Stream } from "effect";
12
+ import { HttpServerResponse } from "effect/unstable/http";
13
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
14
+ var EventHandler2 = HttpApiBuilder.group(Api2, "server.event", (handlers) => Effect.gen(function* () {
15
+ const feed = yield* Service3;
16
+ return handlers.handleRaw("event.subscribe", () => Effect.gen(function* () {
17
+ const connected = {
18
+ id: Event.ID.create(),
19
+ type: "server.connected",
20
+ data: {}
21
+ };
22
+ const output = Stream.unwrap(feed.subscribe.pipe(Effect.map((live) => Stream.make(frame2(connected)).pipe(Stream.concat(live)))));
23
+ const heartbeat = Stream.tick("15 seconds").pipe(Stream.map(() => `: heartbeat
24
+
25
+ `));
26
+ return HttpServerResponse.stream(output.pipe(Stream.merge(heartbeat, { haltStrategy: "left" }), Stream.encodeText), {
27
+ contentType: "text/event-stream",
28
+ headers: {
29
+ "Cache-Control": "no-cache, no-transform",
30
+ "X-Accel-Buffering": "no",
31
+ "X-Content-Type-Options": "nosniff"
32
+ }
33
+ });
34
+ }));
35
+ }));
36
+
37
+ export { EventHandler2 };
@@ -0,0 +1,13 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/command.ts
9
+ import { Command } from "@opencode/core/command";
10
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
11
+ var CommandHandler2 = HttpApiBuilder.group(Api2, "server.command", (handlers) => handlers.handle("command.list", () => response2(Command.Service.use((command) => command.list()))));
12
+
13
+ export { CommandHandler2 };
@@ -0,0 +1,42 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+
5
+ // src/handlers/worktree.ts
6
+ import { Git } from "@opencode/core/git";
7
+ import { Worktree } from "@opencode/core/worktree";
8
+ import { ProjectNotFoundError } from "@opencode/protocol/errors";
9
+ import { WorktreeError } from "@opencode/protocol/groups/worktree";
10
+ import { Effect } from "effect";
11
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
12
+ var WorktreeHandler2 = HttpApiBuilder.group(Api2, "server.worktree", (handlers) => Effect.gen(function* () {
13
+ const worktrees = yield* Worktree.Service;
14
+ 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())));
15
+ }));
16
+ function badRequest(effect) {
17
+ return effect.pipe(Effect.catchTag("Project.NotFoundError", missingProject), Effect.mapError((error) => error instanceof ProjectNotFoundError ? error : new WorktreeError({
18
+ name: "WorktreeError",
19
+ data: {
20
+ message: message(error),
21
+ forceRequired: error instanceof Git.WorktreeError || error instanceof Worktree.OperationError ? error.forceRequired : undefined
22
+ }
23
+ })));
24
+ }
25
+ function missingProject(error) {
26
+ return Effect.fail(new ProjectNotFoundError({ projectID: error.projectID, message: `Project not found: ${error.projectID}` }));
27
+ }
28
+ function message(error) {
29
+ if (error instanceof Worktree.SourceDirectoryNotFoundError)
30
+ return error.directory ? `Worktree source not found: ${error.directory}` : `Worktree source not found for project: ${error.projectID}`;
31
+ if (error instanceof Worktree.DestinationExistsError)
32
+ return `Worktree destination already exists: ${error.directory}`;
33
+ if (error instanceof Worktree.DirectoryUnavailableError)
34
+ return `Worktree directory unavailable: ${error.directory}`;
35
+ if (error instanceof Worktree.InvalidDirectoryError)
36
+ return `Invalid worktree directory: ${error.directory}`;
37
+ if (error instanceof Worktree.StrategyUnavailableError)
38
+ return `Worktree strategy unavailable: ${error.strategy}`;
39
+ return error.message;
40
+ }
41
+
42
+ export { WorktreeHandler2 };
@@ -0,0 +1,23 @@
1
+ import {
2
+ __export
3
+ } from "./auth-9rqn6x4v.js";
4
+
5
+ // src/pty-environment.ts
6
+ var exports_pty_environment = {};
7
+ __export(exports_pty_environment, {
8
+ PtyEnvironment: () => exports_pty_environment,
9
+ Service: () => Service2,
10
+ layer: () => layer2,
11
+ node: () => node2
12
+ });
13
+ import { Context, Effect, Layer } from "effect";
14
+ import { makeGlobalNode } from "@opencode/util/effect/app-node";
15
+
16
+ class Service2 extends Context.Service()("@opencode/ServerPtyEnvironment") {
17
+ }
18
+ var layer2 = Layer.succeed(Service2, Service2.of({
19
+ get: () => Effect.succeed({})
20
+ }));
21
+ var node2 = makeGlobalNode({ service: Service2, layer: layer2, deps: [] });
22
+
23
+ export { Service2, layer2, node2, exports_pty_environment };
@@ -0,0 +1,21 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+ import {
5
+ Service4
6
+ } from "./auth-5p62ed52.js";
7
+
8
+ // src/handlers/server.ts
9
+ import { Effect } from "effect";
10
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
11
+ var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => handlers.handle("server.info", () => Effect.gen(function* () {
12
+ const info = yield* Service4;
13
+ return {
14
+ version: info.app.version ?? "unknown",
15
+ pid: process.pid ?? 0,
16
+ urls: info.urls(),
17
+ paths: info.paths
18
+ };
19
+ })));
20
+
21
+ export { ServerHandler2 };
@@ -0,0 +1,13 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/reference.ts
9
+ import { Reference } from "@opencode/core/reference";
10
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
11
+ var ReferenceHandler2 = HttpApiBuilder.group(Api2, "server.reference", (handlers) => handlers.handle("reference.list", () => response2(Reference.Service.use((reference) => reference.list()))));
12
+
13
+ export { ReferenceHandler2 };
@@ -0,0 +1,25 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+
5
+ // src/handlers/generate.ts
6
+ import { Generate } from "@opencode/core/generate";
7
+ import { Location } from "@opencode/core/location";
8
+ import { LocationServiceMap } from "@opencode/core/location-services";
9
+ import { AbsolutePath } from "@opencode/core/schema";
10
+ import { InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors";
11
+ import { Global } from "@opencode/util/global";
12
+ import { Effect } from "effect";
13
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
14
+ var GenerateHandler2 = HttpApiBuilder.group(Api2, "server.generate", (handlers) => Effect.gen(function* () {
15
+ const global = yield* Global.Service;
16
+ const locations = yield* LocationServiceMap.Service;
17
+ const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }));
18
+ return handlers.handle("generate.text", Effect.fn("server.generate.text")(function* (request) {
19
+ const generate = yield* Generate.Service;
20
+ const text = yield* generate.text(request.payload).pipe(Effect.mapError((error) => error._tag === "Generate.ModelSelectionError" ? new InvalidRequestError({ message: error.message }) : new ServiceUnavailableError({ message: error.message, service: error.service })));
21
+ return { data: { text } };
22
+ }, Effect.provide(services)));
23
+ }));
24
+
25
+ export { GenerateHandler2 };
@@ -0,0 +1,23 @@
1
+ import {
2
+ Api2
3
+ } from "./auth-z6kg9h7e.js";
4
+
5
+ // src/handlers/credential.ts
6
+ import { Credential } from "@opencode/core/credential";
7
+ import { Effect } from "effect";
8
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
9
+ var CredentialHandler2 = HttpApiBuilder.group(Api2, "server.credential", (handlers) => handlers.handle("credential.update", Effect.fn(function* (ctx) {
10
+ const credential = yield* Credential.Service;
11
+ yield* credential.update(ctx.params.credentialID, { label: ctx.payload.label });
12
+ return HttpApiSchema.NoContent.make();
13
+ })).handle("credential.activate", Effect.fn(function* (ctx) {
14
+ const credential = yield* Credential.Service;
15
+ yield* credential.activate(ctx.params.credentialID);
16
+ return HttpApiSchema.NoContent.make();
17
+ })).handle("credential.remove", Effect.fn(function* (ctx) {
18
+ const credential = yield* Credential.Service;
19
+ yield* credential.remove(ctx.params.credentialID);
20
+ return HttpApiSchema.NoContent.make();
21
+ })));
22
+
23
+ export { CredentialHandler2 };
@@ -0,0 +1,156 @@
1
+ import {
2
+ response2
3
+ } from "./auth-0ar9gf7q.js";
4
+ import {
5
+ Api2
6
+ } from "./auth-z6kg9h7e.js";
7
+
8
+ // src/handlers/integration.ts
9
+ import { Integration } from "@opencode/core/integration";
10
+ import { Plugin } from "@opencode/core/plugin";
11
+ import { Effect } from "effect";
12
+ import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
13
+ import {
14
+ IntegrationAttemptNotFoundError,
15
+ IntegrationMethodNotFoundError,
16
+ IntegrationNotFoundError,
17
+ InvalidRequestError
18
+ } from "@opencode/protocol/errors";
19
+ import { WellKnown } from "@opencode/core/wellknown";
20
+ var authorize = (effect) => effect.pipe(Effect.mapError((error) => new InvalidRequestError({
21
+ message: error.cause instanceof Error && error.cause.message.trim() ? error.cause.message : "Authentication failed",
22
+ kind: "integration_authorization"
23
+ })));
24
+ var IntegrationHandler2 = HttpApiBuilder.group(Api2, "server.integration", (handlers) => Effect.gen(function* () {
25
+ return handlers.handle("integration.list", Effect.fn(function* () {
26
+ yield* Plugin.awaitActivation;
27
+ const service = yield* Integration.Service;
28
+ return yield* response2(service.list());
29
+ })).handle("integration.get", Effect.fn(function* (ctx) {
30
+ const service = yield* Integration.Service;
31
+ const integration = yield* service.get(ctx.params.integrationID);
32
+ if (!integration)
33
+ return yield* new IntegrationNotFoundError({
34
+ integrationID: ctx.params.integrationID,
35
+ message: `Integration not found: ${ctx.params.integrationID}`
36
+ });
37
+ return yield* response2(Effect.succeed(integration));
38
+ })).handle("integration.wellknown.add", Effect.fn(function* (ctx) {
39
+ const wellknown = yield* WellKnown.Service;
40
+ const integration = yield* Integration.Service;
41
+ yield* wellknown.add(ctx.payload.url).pipe(Effect.mapError((error) => new InvalidRequestError({ message: error.message, kind: "well_known_discovery" })));
42
+ yield* integration.reload();
43
+ return HttpApiSchema.NoContent.make();
44
+ })).handle("integration.connect.key", Effect.fn(function* (ctx) {
45
+ const service = yield* Integration.Service;
46
+ if (!(yield* service.get(ctx.params.integrationID)))
47
+ return yield* new IntegrationNotFoundError({
48
+ integrationID: ctx.params.integrationID,
49
+ message: `Integration not found: ${ctx.params.integrationID}`
50
+ });
51
+ yield* authorize(service.connection.key({
52
+ integrationID: ctx.params.integrationID,
53
+ key: ctx.payload.key,
54
+ answer: ctx.payload.answer,
55
+ label: ctx.payload.label
56
+ }));
57
+ return HttpApiSchema.NoContent.make();
58
+ })).handle("integration.oauth.connect", Effect.fn(function* (ctx) {
59
+ const service = yield* Integration.Service;
60
+ return yield* response2(authorize(service.oauth.connect({
61
+ integrationID: ctx.params.integrationID,
62
+ methodID: ctx.payload.methodID,
63
+ answer: ctx.payload.answer,
64
+ label: ctx.payload.label
65
+ })));
66
+ })).handle("integration.oauth.status", Effect.fn(function* (ctx) {
67
+ const service = yield* Integration.Service;
68
+ if (!(yield* service.get(ctx.params.integrationID)))
69
+ return yield* new IntegrationNotFoundError({
70
+ integrationID: ctx.params.integrationID,
71
+ message: `Integration not found: ${ctx.params.integrationID}`
72
+ });
73
+ return yield* response2(service.oauth.status({
74
+ integrationID: ctx.params.integrationID,
75
+ attemptID: ctx.params.attemptID
76
+ }).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
77
+ integrationID: error.integrationID,
78
+ attemptID: error.attemptID,
79
+ message: `OAuth attempt not found: ${error.attemptID}`
80
+ }))));
81
+ })).handle("integration.oauth.complete", Effect.fn(function* (ctx) {
82
+ const service = yield* Integration.Service;
83
+ if (!(yield* service.get(ctx.params.integrationID)))
84
+ return yield* new IntegrationNotFoundError({
85
+ integrationID: ctx.params.integrationID,
86
+ message: `Integration not found: ${ctx.params.integrationID}`
87
+ });
88
+ yield* service.oauth.complete({
89
+ integrationID: ctx.params.integrationID,
90
+ attemptID: ctx.params.attemptID,
91
+ code: ctx.payload.code
92
+ }).pipe(Effect.mapError((error) => {
93
+ if (error._tag === "Integration.AttemptNotFound")
94
+ return new IntegrationAttemptNotFoundError({
95
+ integrationID: error.integrationID,
96
+ attemptID: error.attemptID,
97
+ message: `OAuth attempt not found: ${error.attemptID}`
98
+ });
99
+ return new InvalidRequestError({
100
+ message: error._tag === "Integration.CodeRequired" ? "Authorization code is required" : "Authentication failed",
101
+ kind: error._tag === "Integration.CodeRequired" ? "integration_code_required" : "integration_authorization"
102
+ });
103
+ }));
104
+ return HttpApiSchema.NoContent.make();
105
+ })).handle("integration.oauth.cancel", Effect.fn(function* (ctx) {
106
+ const service = yield* Integration.Service;
107
+ yield* service.oauth.cancel({
108
+ integrationID: ctx.params.integrationID,
109
+ attemptID: ctx.params.attemptID
110
+ });
111
+ return HttpApiSchema.NoContent.make();
112
+ })).handle("integration.command.connect", Effect.fn(function* (ctx) {
113
+ const service = yield* Integration.Service;
114
+ const integration = yield* service.get(ctx.params.integrationID);
115
+ if (!integration)
116
+ return yield* new IntegrationNotFoundError({
117
+ integrationID: ctx.params.integrationID,
118
+ message: `Integration not found: ${ctx.params.integrationID}`
119
+ });
120
+ if (!integration.methods.some((method) => method.type === "command" && method.id === ctx.payload.methodID))
121
+ return yield* new IntegrationMethodNotFoundError({
122
+ integrationID: ctx.params.integrationID,
123
+ methodID: ctx.payload.methodID,
124
+ message: `Integration method not found: ${ctx.payload.methodID}`
125
+ });
126
+ return yield* response2(authorize(service.command.connect({
127
+ integrationID: ctx.params.integrationID,
128
+ methodID: ctx.payload.methodID,
129
+ label: ctx.payload.label
130
+ })));
131
+ })).handle("integration.command.status", Effect.fn(function* (ctx) {
132
+ const service = yield* Integration.Service;
133
+ if (!(yield* service.get(ctx.params.integrationID)))
134
+ return yield* new IntegrationNotFoundError({
135
+ integrationID: ctx.params.integrationID,
136
+ message: `Integration not found: ${ctx.params.integrationID}`
137
+ });
138
+ return yield* response2(service.command.status({
139
+ integrationID: ctx.params.integrationID,
140
+ attemptID: ctx.params.attemptID
141
+ }).pipe(Effect.mapError((error) => new IntegrationAttemptNotFoundError({
142
+ integrationID: error.integrationID,
143
+ attemptID: error.attemptID,
144
+ message: `Command attempt not found: ${error.attemptID}`
145
+ }))));
146
+ })).handle("integration.command.cancel", Effect.fn(function* (ctx) {
147
+ const service = yield* Integration.Service;
148
+ yield* service.command.cancel({
149
+ integrationID: ctx.params.integrationID,
150
+ attemptID: ctx.params.attemptID
151
+ });
152
+ return HttpApiSchema.NoContent.make();
153
+ }));
154
+ }));
155
+
156
+ export { IntegrationHandler2 };
@@ -0,0 +1,33 @@
1
+ import {
2
+ sessionInfo2,
3
+ requestRef2
4
+ } from "./auth-0ar9gf7q.js";
5
+
6
+ // src/middleware/form-location.ts
7
+ import { Instance } from "@opencode/core/instance/service";
8
+ import { LocationServiceMap } from "@opencode/core/location-services";
9
+ import { Session } from "@opencode/core/session";
10
+ import { InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors";
11
+ import { Effect, Layer } from "effect";
12
+ import { HttpRouter, HttpServerRequest } from "effect/unstable/http";
13
+ import { HttpApiMiddleware } from "effect/unstable/httpapi";
14
+ class FormLocationMiddleware2 extends HttpApiMiddleware.Service()("@opencode/HttpApiFormLocation", {
15
+ error: [InvalidRequestError, SessionNotFoundError]
16
+ }) {
17
+ }
18
+ var formLocationLayer2 = Layer.effect(FormLocationMiddleware2, Effect.gen(function* () {
19
+ const sessions = yield* Session.Service;
20
+ const instances = yield* Instance.Service;
21
+ const locations = yield* LocationServiceMap.Service;
22
+ return FormLocationMiddleware2.of((effect) => Effect.gen(function* () {
23
+ const route = yield* HttpRouter.RouteContext;
24
+ if (route.params.sessionID === "global") {
25
+ const request = yield* HttpServerRequest.HttpServerRequest;
26
+ return yield* effect.pipe(Effect.provide(locations.get(requestRef2(request))));
27
+ }
28
+ const session = yield* sessionInfo2(sessions, route.params.sessionID);
29
+ return yield* effect.pipe(instances.provide(session));
30
+ }));
31
+ }));
32
+
33
+ export { FormLocationMiddleware2, formLocationLayer2 };