@opencode/server 2.0.16 → 2.0.17

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 (111) hide show
  1. package/dist/api.d.ts +9 -0
  2. package/dist/api.js +5 -5
  3. package/dist/auth.d.ts +4 -0
  4. package/dist/auth.js +10 -2
  5. package/dist/chunks/{auth-e3vgmqs2.js → handlers-140y8w7p.js} +2 -2
  6. package/dist/chunks/{auth-pqe05x32.js → handlers-26ta7ngt.js} +2 -2
  7. package/dist/chunks/{auth-vnsgjb6m.js → handlers-2ek8eabn.js} +3 -3
  8. package/dist/chunks/{auth-99sfd1j8.js → handlers-2sy3c7de.js} +7 -7
  9. package/dist/chunks/{auth-ahxdh0dq.js → handlers-367ngss7.js} +2 -2
  10. package/dist/chunks/{auth-d65y46ag.js → handlers-3kzx88w9.js} +1 -1
  11. package/dist/chunks/{auth-n0k9wajg.js → handlers-44xy5pnk.js} +1 -1
  12. package/dist/chunks/{auth-jd22znxy.js → handlers-5bwq5cz2.js} +2 -2
  13. package/dist/chunks/{auth-hrfm0p6n.js → handlers-5rwqcaw2.js} +1 -1
  14. package/dist/chunks/{auth-5w24ch67.js → handlers-5w24ch67.js} +1 -1
  15. package/dist/chunks/{auth-43k13dmj.js → handlers-6gkz39ey.js} +3 -3
  16. package/dist/chunks/{auth-fdfc8k8f.js → handlers-6qwktr1g.js} +1 -1
  17. package/dist/chunks/{auth-tsyxj4xh.js → handlers-7eckj7zq.js} +2 -2
  18. package/dist/chunks/{auth-vsmvcx85.js → handlers-96s6m0w3.js} +2 -2
  19. package/dist/chunks/handlers-anm12x33.js +66 -0
  20. package/dist/chunks/{auth-ybmm73jc.js → handlers-b1rdg9nf.js} +2 -2
  21. package/dist/chunks/{auth-y4j2wswm.js → handlers-bhrnjhj4.js} +7 -7
  22. package/dist/chunks/{auth-5frajas6.js → handlers-bmqkn4ah.js} +1 -1
  23. package/dist/chunks/{auth-jefcrg4z.js → handlers-bt9tc5rb.js} +1 -1
  24. package/dist/chunks/{auth-f2ryx3d8.js → handlers-ctscy0f5.js} +2 -2
  25. package/dist/chunks/{auth-1aa7fc0d.js → handlers-ees77nh9.js} +2 -2
  26. package/dist/chunks/{auth-kb2gw6wm.js → handlers-em4bkx9t.js} +4 -4
  27. package/dist/chunks/{auth-0xemx5a5.js → handlers-f05bgvye.js} +33 -33
  28. package/dist/chunks/{auth-50jg7xmc.js → handlers-f8rap8f6.js} +1 -1
  29. package/dist/chunks/{auth-m6wvgbfq.js → handlers-gtkdacvk.js} +28 -7
  30. package/dist/chunks/{auth-b6gan3yw.js → handlers-haswyr8z.js} +2 -2
  31. package/dist/chunks/{auth-83rfx0sp.js → handlers-hp5sxeae.js} +2 -2
  32. package/dist/chunks/{auth-qmx5gmxb.js → handlers-hr75rahr.js} +2 -2
  33. package/dist/chunks/handlers-j0xcyacv.js +53 -0
  34. package/dist/chunks/{auth-s4aja1df.js → handlers-mzr9gftb.js} +7 -7
  35. package/dist/chunks/{auth-bp2kj98m.js → handlers-np19kmxx.js} +2 -2
  36. package/dist/chunks/{auth-h91pzmtp.js → handlers-pme11y2y.js} +2 -2
  37. package/dist/chunks/{auth-eptkag0m.js → handlers-qj9kjxn3.js} +1 -1
  38. package/dist/chunks/{auth-9vrrrs57.js → handlers-rjqbhscq.js} +1 -1
  39. package/dist/chunks/{auth-v84hnbsb.js → handlers-s0padj6k.js} +3 -3
  40. package/dist/chunks/{auth-p0qxanbk.js → handlers-t88f2hhf.js} +3 -3
  41. package/dist/chunks/{auth-h1w0a8ky.js → handlers-v1emgcvb.js} +2 -2
  42. package/dist/chunks/{auth-2v3qky60.js → handlers-v573ws0d.js} +3 -3
  43. package/dist/chunks/{auth-mcn2wrk8.js → handlers-vdkg476e.js} +19 -15
  44. package/dist/chunks/{auth-s1rvn990.js → handlers-wv5twc2g.js} +8 -8
  45. package/dist/chunks/{auth-epwv4y6g.js → handlers-wz0qz28j.js} +2 -2
  46. package/dist/chunks/{auth-y07r8paj.js → handlers-x5ncpjy3.js} +1 -1
  47. package/dist/chunks/handlers-x6486bry.js +35 -0
  48. package/dist/chunks/{auth-7zxr3tkk.js → handlers-zpz5afwq.js} +2 -2
  49. package/dist/cors.js +1 -1
  50. package/dist/event-feed.js +5 -5
  51. package/dist/fetch.js +47 -46
  52. package/dist/handlers/agent.js +6 -6
  53. package/dist/handlers/command.js +6 -6
  54. package/dist/handlers/config.js +6 -6
  55. package/dist/handlers/credential.js +6 -6
  56. package/dist/handlers/debug.js +6 -6
  57. package/dist/handlers/event.js +7 -7
  58. package/dist/handlers/form.js +6 -6
  59. package/dist/handlers/fs.js +6 -6
  60. package/dist/handlers/generate.js +6 -6
  61. package/dist/handlers/integration.js +6 -6
  62. package/dist/handlers/location.js +6 -6
  63. package/dist/handlers/mcp.js +6 -6
  64. package/dist/handlers/message.js +6 -6
  65. package/dist/handlers/migration.js +6 -6
  66. package/dist/handlers/model.js +6 -6
  67. package/dist/handlers/permission.js +6 -6
  68. package/dist/handlers/persistent-pty.js +8 -8
  69. package/dist/handlers/plugin.js +6 -6
  70. package/dist/handlers/project.js +6 -6
  71. package/dist/handlers/provider.js +6 -6
  72. package/dist/handlers/pty-socket.js +1 -1
  73. package/dist/handlers/pty.js +9 -9
  74. package/dist/handlers/reference.js +6 -6
  75. package/dist/handlers/rpc.js +6 -6
  76. package/dist/handlers/server.d.ts +3 -1
  77. package/dist/handlers/server.js +9 -7
  78. package/dist/handlers/session-error.js +1 -1
  79. package/dist/handlers/session.js +6 -6
  80. package/dist/handlers/shell.js +6 -6
  81. package/dist/handlers/skill.js +6 -6
  82. package/dist/handlers/vcs.js +6 -6
  83. package/dist/handlers/websearch.js +6 -6
  84. package/dist/handlers/worktree.js +6 -6
  85. package/dist/handlers.d.ts +1 -1
  86. package/dist/handlers.js +43 -41
  87. package/dist/location.js +4 -4
  88. package/dist/middleware/authorization.d.ts +2 -1
  89. package/dist/middleware/authorization.js +5 -3
  90. package/dist/middleware/form-location.js +3 -3
  91. package/dist/middleware/schema-error.js +1 -1
  92. package/dist/middleware/session-location.js +3 -3
  93. package/dist/pairing.d.ts +13 -0
  94. package/dist/pairing.js +10 -0
  95. package/dist/process.js +54 -57
  96. package/dist/pty-environment.js +7 -7
  97. package/dist/request-tracing.js +1 -1
  98. package/dist/routes.d.ts +3 -2
  99. package/dist/routes.js +46 -45
  100. package/dist/server-info.js +5 -5
  101. package/dist/service-status.js +1 -1
  102. package/dist/workerd.js +48 -47
  103. package/package.json +8 -8
  104. package/dist/chunks/auth-qh9c2857.js +0 -21
  105. package/dist/chunks/auth-zyv89x5n.js +0 -30
  106. /package/dist/chunks/{auth-9rqn6x4v.js → handlers-9rqn6x4v.js} +0 -0
  107. /package/dist/chunks/{auth-hezj1jdf.js → handlers-hezj1jdf.js} +0 -0
  108. /package/dist/chunks/{auth-q4bn6dy8.js → handlers-q4bn6dy8.js} +0 -0
  109. /package/dist/chunks/{auth-smaf4a18.js → handlers-smaf4a18.js} +0 -0
  110. /package/dist/chunks/{auth-t8yzmczr.js → handlers-t8yzmczr.js} +0 -0
  111. /package/dist/chunks/{auth-yc7nft6q.js → handlers-yc7nft6q.js} +0 -0
@@ -1,99 +1,99 @@
1
1
  import {
2
2
  GenerateHandler2
3
- } from "./auth-9vrrrs57.js";
3
+ } from "./handlers-rjqbhscq.js";
4
4
  import {
5
5
  MessageHandler2
6
- } from "./auth-pqe05x32.js";
6
+ } from "./handlers-26ta7ngt.js";
7
7
  import {
8
8
  ModelHandler2
9
- } from "./auth-ybmm73jc.js";
9
+ } from "./handlers-b1rdg9nf.js";
10
10
  import {
11
11
  ProviderHandler2
12
- } from "./auth-b6gan3yw.js";
12
+ } from "./handlers-haswyr8z.js";
13
13
  import {
14
14
  SessionHandler2
15
- } from "./auth-ahxdh0dq.js";
15
+ } from "./handlers-367ngss7.js";
16
16
  import {
17
17
  PermissionHandler2
18
- } from "./auth-p0qxanbk.js";
18
+ } from "./handlers-t88f2hhf.js";
19
19
  import {
20
20
  FileSystemHandler2
21
- } from "./auth-vsmvcx85.js";
21
+ } from "./handlers-96s6m0w3.js";
22
22
  import {
23
23
  FormHandler2
24
- } from "./auth-1aa7fc0d.js";
24
+ } from "./handlers-ees77nh9.js";
25
25
  import {
26
26
  CommandHandler2
27
- } from "./auth-h91pzmtp.js";
27
+ } from "./handlers-pme11y2y.js";
28
28
  import {
29
29
  SkillHandler2
30
- } from "./auth-83rfx0sp.js";
30
+ } from "./handlers-hp5sxeae.js";
31
31
  import {
32
32
  RpcHandler2
33
- } from "./auth-50jg7xmc.js";
33
+ } from "./handlers-f8rap8f6.js";
34
34
  import {
35
- layer5
36
- } from "./auth-99sfd1j8.js";
35
+ layer2
36
+ } from "./handlers-2sy3c7de.js";
37
37
  import {
38
38
  EventHandler2
39
- } from "./auth-kb2gw6wm.js";
39
+ } from "./handlers-em4bkx9t.js";
40
40
  import {
41
41
  AgentHandler2
42
- } from "./auth-f2ryx3d8.js";
42
+ } from "./handlers-ctscy0f5.js";
43
43
  import {
44
44
  PluginHandler2
45
- } from "./auth-qmx5gmxb.js";
45
+ } from "./handlers-hr75rahr.js";
46
46
  import {
47
47
  ServerHandler2
48
- } from "./auth-qh9c2857.js";
48
+ } from "./handlers-j0xcyacv.js";
49
49
  import {
50
50
  DebugHandler2
51
- } from "./auth-e3vgmqs2.js";
51
+ } from "./handlers-140y8w7p.js";
52
52
  import {
53
53
  PtyHandler2
54
- } from "./auth-y4j2wswm.js";
54
+ } from "./handlers-bhrnjhj4.js";
55
55
  import {
56
56
  PersistentPtyHandler2
57
- } from "./auth-v84hnbsb.js";
57
+ } from "./handlers-s0padj6k.js";
58
58
  import {
59
59
  ShellHandler2
60
- } from "./auth-tsyxj4xh.js";
60
+ } from "./handlers-7eckj7zq.js";
61
61
  import {
62
62
  ReferenceHandler2
63
- } from "./auth-jd22znxy.js";
63
+ } from "./handlers-5bwq5cz2.js";
64
64
  import {
65
65
  LocationHandler2
66
- } from "./auth-y07r8paj.js";
66
+ } from "./handlers-x5ncpjy3.js";
67
67
  import {
68
68
  IntegrationHandler2
69
- } from "./auth-bp2kj98m.js";
69
+ } from "./handlers-np19kmxx.js";
70
70
  import {
71
71
  WebSearchHandler2
72
- } from "./auth-h1w0a8ky.js";
72
+ } from "./handlers-v1emgcvb.js";
73
73
  import {
74
74
  McpHandler2
75
- } from "./auth-epwv4y6g.js";
75
+ } from "./handlers-wz0qz28j.js";
76
76
  import {
77
77
  CredentialHandler2
78
- } from "./auth-n0k9wajg.js";
78
+ } from "./handlers-44xy5pnk.js";
79
79
  import {
80
80
  ProjectHandler2
81
- } from "./auth-eptkag0m.js";
81
+ } from "./handlers-qj9kjxn3.js";
82
82
  import {
83
83
  WorktreeHandler2
84
- } from "./auth-jefcrg4z.js";
84
+ } from "./handlers-bt9tc5rb.js";
85
85
  import {
86
86
  VcsHandler2
87
- } from "./auth-7zxr3tkk.js";
87
+ } from "./handlers-zpz5afwq.js";
88
88
  import {
89
89
  MigrationHandler2
90
- } from "./auth-5frajas6.js";
90
+ } from "./handlers-bmqkn4ah.js";
91
91
  import {
92
92
  ConfigHandler2
93
- } from "./auth-fdfc8k8f.js";
93
+ } from "./handlers-6qwktr1g.js";
94
94
 
95
95
  // src/handlers.ts
96
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(layer5)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
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(layer2)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
98
98
 
99
99
  export { handlers2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./handlers-v573ws0d.js";
4
4
 
5
5
  // src/handlers/rpc.ts
6
6
  import { Rpc } from "@opencode/core/rpc";
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  Config2,
3
3
  required2,
4
- authorized2
5
- } from "./auth-zyv89x5n.js";
4
+ authorized2,
5
+ verifySession2,
6
+ sessionCookieName2
7
+ } from "./handlers-anm12x33.js";
6
8
 
7
9
  // src/middleware/authorization.ts
8
10
  import { UnauthorizedError } from "@opencode/protocol/errors";
@@ -10,6 +12,7 @@ import { Authorization } from "@opencode/protocol/middleware/authorization";
10
12
  import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
11
13
  import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
12
14
  import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
15
+ import { isPairingConnectURL } from "@opencode/protocol/groups/server";
13
16
  import { Effect, Encoding, Layer, Redacted } from "effect";
14
17
  import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
15
18
  var AUTH_TOKEN_QUERY = "auth_token";
@@ -38,8 +41,25 @@ function credentialFromRequest(request) {
38
41
  return decodeCredential(match[1]);
39
42
  return Effect.succeed(emptyCredential());
40
43
  }
44
+ var UNAUTHORIZED_MESSAGE = "Authentication required";
45
+ function challengeRequest(request) {
46
+ const mode = request.headers["sec-fetch-mode"];
47
+ return mode === undefined || mode === "navigate";
48
+ }
49
+ function unauthorizedResponse2(request) {
50
+ return HttpServerResponse.jsonUnsafe({ _tag: "UnauthorizedError", message: UNAUTHORIZED_MESSAGE }, { status: 401, headers: challengeRequest(request) ? { "www-authenticate": WWW_AUTHENTICATE } : undefined });
51
+ }
41
52
  function authorizedRequest2(request, config) {
42
- return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config)));
53
+ return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config) || authorizedSessionCookie(request, config)));
54
+ }
55
+ function authorizedSessionCookie(request, config) {
56
+ const token = request.cookies[sessionCookieName2(request.headers.host)];
57
+ if (!token)
58
+ return false;
59
+ const origin = request.headers.origin;
60
+ if (origin !== undefined && URL.parse(origin)?.host !== request.headers.host)
61
+ return false;
62
+ return verifySession2(token, config);
43
63
  }
44
64
  var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
45
65
  const config = yield* Config2;
@@ -48,13 +68,14 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
48
68
  return Authorization.of((effect) => Effect.gen(function* () {
49
69
  const request = yield* HttpServerRequest.HttpServerRequest;
50
70
  const url = new URL(request.url, "http://localhost");
51
- if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url))
71
+ if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url) || isPairingConnectURL(url))
52
72
  return yield* effect;
53
73
  if (yield* authorizedRequest2(request, config))
54
74
  return yield* effect;
55
- yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
56
- return yield* new UnauthorizedError({ message: "Authentication required" });
75
+ if (challengeRequest(request))
76
+ yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
77
+ return yield* new UnauthorizedError({ message: UNAUTHORIZED_MESSAGE });
57
78
  }));
58
79
  }));
59
80
 
60
- export { authorizedRequest2, authorizationLayer2, Authorization2 };
81
+ export { unauthorizedResponse2, authorizedRequest2, authorizationLayer2, Authorization2 };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/provider.ts
9
9
  import { Provider } from "@opencode/core/provider";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/skill.ts
9
9
  import { Skill } from "@opencode/core/skill";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/plugin.ts
9
9
  import { Plugin } from "@opencode/core/plugin";
@@ -0,0 +1,53 @@
1
+ import {
2
+ Api2
3
+ } from "./handlers-v573ws0d.js";
4
+ import {
5
+ SESSION_TTL_SECONDS2,
6
+ Config2,
7
+ issueSession2,
8
+ sessionCookieName2
9
+ } from "./handlers-anm12x33.js";
10
+ import {
11
+ Service3
12
+ } from "./handlers-mzr9gftb.js";
13
+ import {
14
+ Service4
15
+ } from "./handlers-x6486bry.js";
16
+
17
+ // src/handlers/server.ts
18
+ import { Duration, Effect } from "effect";
19
+ import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
20
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
21
+ import { UnauthorizedError } from "@opencode/protocol/errors";
22
+ var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
23
+ const pairing = yield* Service4;
24
+ const auth = yield* Config2;
25
+ return handlers.handle("server.info", () => Effect.gen(function* () {
26
+ const info = yield* Service3;
27
+ return {
28
+ version: info.app.version ?? "unknown",
29
+ pid: process.pid ?? 0,
30
+ urls: info.urls(),
31
+ paths: info.paths
32
+ };
33
+ })).handle("server.pair", () => pairing.issue()).handle("server.connect", Effect.fn(function* (ctx) {
34
+ const request = yield* HttpServerRequest.HttpServerRequest;
35
+ const browser = request.headers.accept?.includes("text/html") === true;
36
+ const token = (yield* pairing.consume(ctx.params.code)) ? issueSession2(auth) : undefined;
37
+ if (token === undefined) {
38
+ if (!browser)
39
+ return yield* new UnauthorizedError({ message: "Pairing link expired or already used" });
40
+ return HttpServerResponse.text("This pairing link expired or was already used. Run `opencode pair` to get a new one.", { status: 401 });
41
+ }
42
+ if (!browser)
43
+ return { token };
44
+ return HttpServerResponse.redirect("/").pipe(HttpServerResponse.setCookieUnsafe(sessionCookieName2(request.headers.host), token, {
45
+ path: "/",
46
+ httpOnly: true,
47
+ sameSite: "lax",
48
+ maxAge: Duration.seconds(SESSION_TTL_SECONDS2)
49
+ }));
50
+ }));
51
+ }));
52
+
53
+ export { ServerHandler2 };
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./handlers-9rqn6x4v.js";
4
4
 
5
5
  // src/server-info.ts
6
6
  var exports_server_info = {};
7
7
  __export(exports_server_info, {
8
8
  ServerInfo: () => exports_server_info,
9
- Service: () => Service2,
9
+ Service: () => Service3,
10
10
  connectionURLs: () => connectionURLs2,
11
- layer: () => layer2
11
+ layer: () => layer3
12
12
  });
13
13
  import { Context, Layer } from "effect";
14
14
  import { networkInterfaces } from "node:os";
15
15
 
16
- class Service2 extends Context.Service()("@opencode/server/ServerInfo") {
16
+ class Service3 extends Context.Service()("@opencode/server/ServerInfo") {
17
17
  }
18
- function layer2(urls, tmp, app = {}) {
19
- return Layer.succeed(Service2, Service2.of({ urls, app, paths: { tmp } }));
18
+ function layer3(urls, tmp, app = {}) {
19
+ return Layer.succeed(Service3, Service3.of({ urls, app, paths: { tmp } }));
20
20
  }
21
21
  function connectionURLs2(value, requestedHostname) {
22
22
  const url = new URL(value);
@@ -33,4 +33,4 @@ function connectionURLs2(value, requestedHostname) {
33
33
  ];
34
34
  }
35
35
 
36
- export { Service2, layer2, connectionURLs2, exports_server_info };
36
+ export { Service3, layer3, connectionURLs2, exports_server_info };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/integration.ts
9
9
  import { Integration } from "@opencode/core/integration";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/command.ts
9
9
  import { Command } from "@opencode/core/command";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./handlers-v573ws0d.js";
4
4
 
5
5
  // src/handlers/project.ts
6
6
  import { Project } from "@opencode/core/project";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./handlers-v573ws0d.js";
4
4
 
5
5
  // src/handlers/generate.ts
6
6
  import { Generate } from "@opencode/core/generate";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./handlers-v573ws0d.js";
4
4
  import {
5
5
  CorsConfig2,
6
6
  isAllowedRequestOrigin2
7
- } from "./auth-q4bn6dy8.js";
7
+ } from "./handlers-q4bn6dy8.js";
8
8
  import {
9
9
  runPtySocket2
10
- } from "./auth-hezj1jdf.js";
10
+ } from "./handlers-hezj1jdf.js";
11
11
 
12
12
  // src/handlers/persistent-pty.ts
13
13
  import { PersistentPty } from "@opencode/core/persistent-pty";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./auth-smaf4a18.js";
3
+ } from "./handlers-smaf4a18.js";
4
4
  import {
5
5
  response2,
6
6
  sessionInfo2
7
- } from "./auth-43k13dmj.js";
7
+ } from "./handlers-6gkz39ey.js";
8
8
  import {
9
9
  Api2
10
- } from "./auth-2v3qky60.js";
10
+ } from "./handlers-v573ws0d.js";
11
11
 
12
12
  // src/handlers/permission.ts
13
13
  import { Instance } from "@opencode/core/instance/service";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/websearch.ts
9
9
  import { WebSearch } from "@opencode/core/websearch";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  LocationMiddleware2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  FormLocationMiddleware2
6
- } from "./auth-hrfm0p6n.js";
6
+ } from "./handlers-5rwqcaw2.js";
7
7
  import {
8
8
  SessionLocationMiddleware2
9
- } from "./auth-d65y46ag.js";
9
+ } from "./handlers-3kzx88w9.js";
10
10
 
11
11
  // src/api.ts
12
12
  import { makeDefaultApi } from "@opencode/protocol/api";
@@ -1,36 +1,39 @@
1
1
  import {
2
- layer3
3
- } from "./auth-43k13dmj.js";
2
+ layer4
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  formLocationLayer2
6
- } from "./auth-hrfm0p6n.js";
6
+ } from "./handlers-5rwqcaw2.js";
7
7
  import {
8
8
  sessionLocationLayer2
9
- } from "./auth-d65y46ag.js";
9
+ } from "./handlers-3kzx88w9.js";
10
10
  import {
11
11
  Api2
12
- } from "./auth-2v3qky60.js";
12
+ } from "./handlers-v573ws0d.js";
13
13
  import {
14
14
  Config2
15
- } from "./auth-zyv89x5n.js";
15
+ } from "./handlers-anm12x33.js";
16
16
  import {
17
17
  CorsConfig2
18
- } from "./auth-q4bn6dy8.js";
18
+ } from "./handlers-q4bn6dy8.js";
19
19
  import {
20
- layer2
21
- } from "./auth-s4aja1df.js";
20
+ layer3
21
+ } from "./handlers-mzr9gftb.js";
22
22
  import {
23
23
  node2
24
- } from "./auth-s1rvn990.js";
24
+ } from "./handlers-x6486bry.js";
25
+ import {
26
+ node3
27
+ } from "./handlers-wv5twc2g.js";
25
28
  import {
26
29
  handlers2
27
- } from "./auth-0xemx5a5.js";
30
+ } from "./handlers-f05bgvye.js";
28
31
  import {
29
32
  authorizationLayer2
30
- } from "./auth-m6wvgbfq.js";
33
+ } from "./handlers-gtkdacvk.js";
31
34
  import {
32
35
  schemaErrorLayer2
33
- } from "./auth-t8yzmczr.js";
36
+ } from "./handlers-t8yzmczr.js";
34
37
 
35
38
  // src/routes.ts
36
39
  import { Database } from "@opencode/core/database/database";
@@ -88,6 +91,7 @@ var applicationServiceNodes = [
88
91
  PersistentPty.node,
89
92
  Credential.node,
90
93
  WellKnown.node,
94
+ node3,
91
95
  node2,
92
96
  LocationServiceMap.node,
93
97
  LocationActivity.node,
@@ -140,8 +144,8 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
140
144
  })) : build(overrides);
141
145
  return serviceLayer.pipe(Layer.flatMap((context) => {
142
146
  const services = Layer.succeedContext(context);
143
- const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer2(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
144
- const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer3), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
147
+ const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer3(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
148
+ const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer4), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
145
149
  return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
146
150
  }));
147
151
  }
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./handlers-9rqn6x4v.js";
4
4
 
5
5
  // src/pty-environment.ts
6
6
  var exports_pty_environment = {};
7
7
  __export(exports_pty_environment, {
8
8
  PtyEnvironment: () => exports_pty_environment,
9
- Service: () => Service3,
10
- layer: () => layer4,
11
- node: () => node2
9
+ Service: () => Service5,
10
+ layer: () => layer5,
11
+ node: () => node3
12
12
  });
13
13
  import { Context, Effect, Layer } from "effect";
14
14
  import { makeGlobalNode } from "@opencode/util/effect/app-node";
15
15
 
16
- class Service3 extends Context.Service()("@opencode/ServerPtyEnvironment") {
16
+ class Service5 extends Context.Service()("@opencode/ServerPtyEnvironment") {
17
17
  }
18
- var layer4 = Layer.succeed(Service3, Service3.of({
18
+ var layer5 = Layer.succeed(Service5, Service5.of({
19
19
  get: () => Effect.succeed({})
20
20
  }));
21
- var node2 = makeGlobalNode({ service: Service3, layer: layer4, deps: [] });
21
+ var node3 = makeGlobalNode({ service: Service5, layer: layer5, deps: [] });
22
22
 
23
- export { Service3, layer4, node2, exports_pty_environment };
23
+ export { Service5, layer5, node3, exports_pty_environment };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/mcp.ts
9
9
  import { Mcp } from "@opencode/core/mcp/index";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./handlers-v573ws0d.js";
4
4
 
5
5
  // src/handlers/location.ts
6
6
  import { Location } from "@opencode/core/location";
@@ -0,0 +1,35 @@
1
+ import {
2
+ __export
3
+ } from "./handlers-9rqn6x4v.js";
4
+
5
+ // src/pairing.ts
6
+ var exports_pairing = {};
7
+ __export(exports_pairing, {
8
+ ServerPairing: () => exports_pairing,
9
+ Service: () => Service4,
10
+ node: () => node2
11
+ });
12
+ import { Cache, Context, Duration, Effect, Layer } from "effect";
13
+ import { makeGlobalNode } from "@opencode/util/effect/app-node";
14
+ import { randomBytes } from "node:crypto";
15
+ var TTL = Duration.minutes(5);
16
+
17
+ class Service4 extends Context.Service()("@opencode/ServerPairing") {
18
+ }
19
+ var noLookup = () => Effect.die(new Error("ServerPairing cache must be used via set/invalidateWhen, never get"));
20
+ var layer = Layer.effect(Service4, Effect.gen(function* () {
21
+ const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
22
+ return Service4.of({
23
+ issue: Effect.fn("ServerPairing.issue")(function* () {
24
+ const code = randomBytes(16).toString("base64url");
25
+ yield* Cache.set(cache, code, true);
26
+ return { code, expires_in: Duration.toSeconds(TTL) };
27
+ }),
28
+ consume: Effect.fn("ServerPairing.consume")(function* (code) {
29
+ return yield* Cache.invalidateWhen(cache, code, () => true);
30
+ })
31
+ });
32
+ }));
33
+ var node2 = makeGlobalNode({ service: Service4, layer, deps: [] });
34
+
35
+ export { Service4, node2, exports_pairing };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./handlers-6gkz39ey.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./handlers-v573ws0d.js";
7
7
 
8
8
  // src/handlers/vcs.ts
9
9
  import { Vcs } from "@opencode/core/vcs";
package/dist/cors.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  CorsConfig2,
3
3
  isAllowedCorsOrigin2,
4
4
  isAllowedRequestOrigin2
5
- } from "./chunks/auth-q4bn6dy8.js";
5
+ } from "./chunks/handlers-q4bn6dy8.js";
6
6
  export {
7
7
  CorsConfig2 as CorsConfig,
8
8
  isAllowedCorsOrigin2 as isAllowedCorsOrigin,