@opencode/server 2.0.16 → 2.0.18

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-43k13dmj.js → service-status-0ar9gf7q.js} +3 -3
  6. package/dist/chunks/{auth-v84hnbsb.js → service-status-0qzy9yxk.js} +3 -3
  7. package/dist/chunks/{auth-50jg7xmc.js → service-status-1wj0ectp.js} +1 -1
  8. package/dist/chunks/{auth-d65y46ag.js → service-status-23w8t84j.js} +1 -1
  9. package/dist/chunks/{auth-83rfx0sp.js → service-status-34e6wr3b.js} +2 -2
  10. package/dist/chunks/{auth-y4j2wswm.js → service-status-3582t7j8.js} +7 -7
  11. package/dist/chunks/{auth-pqe05x32.js → service-status-40g8rvw4.js} +2 -2
  12. package/dist/chunks/{auth-h1w0a8ky.js → service-status-6aya8ky6.js} +2 -2
  13. package/dist/chunks/{auth-mcn2wrk8.js → service-status-74x861p1.js} +19 -15
  14. package/dist/chunks/{auth-b6gan3yw.js → service-status-760vtqy2.js} +2 -2
  15. package/dist/chunks/{auth-eptkag0m.js → service-status-7qtja2kq.js} +1 -1
  16. package/dist/chunks/{auth-e3vgmqs2.js → service-status-8e21y1bd.js} +2 -2
  17. package/dist/chunks/{auth-vsmvcx85.js → service-status-8nbs1vvt.js} +2 -2
  18. package/dist/chunks/{auth-epwv4y6g.js → service-status-8ygjd1s8.js} +2 -2
  19. package/dist/chunks/service-status-anm12x33.js +66 -0
  20. package/dist/chunks/{auth-vnsgjb6m.js → service-status-b85xjfat.js} +6 -6
  21. package/dist/chunks/{auth-h91pzmtp.js → service-status-bgzrbsek.js} +2 -2
  22. package/dist/chunks/{auth-jefcrg4z.js → service-status-bkb1xk38.js} +1 -1
  23. package/dist/chunks/{auth-s1rvn990.js → service-status-bkk2wfbz.js} +7 -7
  24. package/dist/chunks/{auth-jd22znxy.js → service-status-cm8xmqjn.js} +2 -2
  25. package/dist/chunks/{auth-9vrrrs57.js → service-status-d2g7egyw.js} +1 -1
  26. package/dist/chunks/{auth-n0k9wajg.js → service-status-e09mshwt.js} +1 -1
  27. package/dist/chunks/{auth-0xemx5a5.js → service-status-e6vbr4xb.js} +33 -33
  28. package/dist/chunks/{auth-bp2kj98m.js → service-status-erwrh284.js} +2 -2
  29. package/dist/chunks/{auth-ahxdh0dq.js → service-status-f78xgav9.js} +2 -2
  30. package/dist/chunks/{auth-hrfm0p6n.js → service-status-frv6gfy7.js} +1 -1
  31. package/dist/chunks/{auth-ybmm73jc.js → service-status-fyjxk8m3.js} +2 -2
  32. package/dist/chunks/{auth-m6wvgbfq.js → service-status-gtkdacvk.js} +28 -7
  33. package/dist/chunks/{auth-p0qxanbk.js → service-status-kv6ycdgm.js} +3 -3
  34. package/dist/chunks/{auth-s4aja1df.js → service-status-mzr9gftb.js} +7 -7
  35. package/dist/chunks/{auth-99sfd1j8.js → service-status-n9y13hgv.js} +4 -4
  36. package/dist/chunks/service-status-nvqjvwgj.js +53 -0
  37. package/dist/chunks/{auth-1aa7fc0d.js → service-status-pd1pbg0v.js} +2 -2
  38. package/dist/chunks/service-status-sstsrjtg.js +35 -0
  39. package/dist/chunks/{auth-y07r8paj.js → service-status-tk6nqkmh.js} +1 -1
  40. package/dist/chunks/{auth-5frajas6.js → service-status-txhx6f1m.js} +1 -1
  41. package/dist/chunks/{auth-qmx5gmxb.js → service-status-vgxn80m1.js} +2 -2
  42. package/dist/chunks/{auth-kb2gw6wm.js → service-status-xaw29g0h.js} +2 -2
  43. package/dist/chunks/{auth-fdfc8k8f.js → service-status-xpxp1sqb.js} +1 -1
  44. package/dist/chunks/{auth-5w24ch67.js → service-status-xsrtpxyd.js} +4 -4
  45. package/dist/chunks/{auth-tsyxj4xh.js → service-status-z3nth2hg.js} +2 -2
  46. package/dist/chunks/{auth-2v3qky60.js → service-status-z6kg9h7e.js} +3 -3
  47. package/dist/chunks/{auth-7zxr3tkk.js → service-status-zw9j8b8g.js} +2 -2
  48. package/dist/chunks/{auth-f2ryx3d8.js → service-status-zxvt7wd3.js} +2 -2
  49. package/dist/cors.js +1 -1
  50. package/dist/event-feed.js +3 -3
  51. package/dist/fetch.js +49 -48
  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 +56 -59
  96. package/dist/pty-environment.js +5 -5
  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 +3 -3
  102. package/dist/workerd.js +50 -49
  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 → service-status-9rqn6x4v.js} +0 -0
  107. /package/dist/chunks/{auth-hezj1jdf.js → service-status-hezj1jdf.js} +0 -0
  108. /package/dist/chunks/{auth-q4bn6dy8.js → service-status-q4bn6dy8.js} +0 -0
  109. /package/dist/chunks/{auth-smaf4a18.js → service-status-smaf4a18.js} +0 -0
  110. /package/dist/chunks/{auth-t8yzmczr.js → service-status-t8yzmczr.js} +0 -0
  111. /package/dist/chunks/{auth-yc7nft6q.js → service-status-yc7nft6q.js} +0 -0
@@ -1,99 +1,99 @@
1
1
  import {
2
2
  GenerateHandler2
3
- } from "./auth-9vrrrs57.js";
3
+ } from "./service-status-d2g7egyw.js";
4
4
  import {
5
5
  MessageHandler2
6
- } from "./auth-pqe05x32.js";
6
+ } from "./service-status-40g8rvw4.js";
7
7
  import {
8
8
  ModelHandler2
9
- } from "./auth-ybmm73jc.js";
9
+ } from "./service-status-fyjxk8m3.js";
10
10
  import {
11
11
  ProviderHandler2
12
- } from "./auth-b6gan3yw.js";
12
+ } from "./service-status-760vtqy2.js";
13
13
  import {
14
14
  SessionHandler2
15
- } from "./auth-ahxdh0dq.js";
15
+ } from "./service-status-f78xgav9.js";
16
16
  import {
17
17
  PermissionHandler2
18
- } from "./auth-p0qxanbk.js";
18
+ } from "./service-status-kv6ycdgm.js";
19
19
  import {
20
20
  FileSystemHandler2
21
- } from "./auth-vsmvcx85.js";
21
+ } from "./service-status-8nbs1vvt.js";
22
22
  import {
23
23
  FormHandler2
24
- } from "./auth-1aa7fc0d.js";
24
+ } from "./service-status-pd1pbg0v.js";
25
25
  import {
26
26
  CommandHandler2
27
- } from "./auth-h91pzmtp.js";
27
+ } from "./service-status-bgzrbsek.js";
28
28
  import {
29
29
  SkillHandler2
30
- } from "./auth-83rfx0sp.js";
30
+ } from "./service-status-34e6wr3b.js";
31
31
  import {
32
32
  RpcHandler2
33
- } from "./auth-50jg7xmc.js";
33
+ } from "./service-status-1wj0ectp.js";
34
34
  import {
35
- layer5
36
- } from "./auth-99sfd1j8.js";
35
+ layer4
36
+ } from "./service-status-n9y13hgv.js";
37
37
  import {
38
38
  EventHandler2
39
- } from "./auth-kb2gw6wm.js";
39
+ } from "./service-status-xaw29g0h.js";
40
40
  import {
41
41
  AgentHandler2
42
- } from "./auth-f2ryx3d8.js";
42
+ } from "./service-status-zxvt7wd3.js";
43
43
  import {
44
44
  PluginHandler2
45
- } from "./auth-qmx5gmxb.js";
45
+ } from "./service-status-vgxn80m1.js";
46
46
  import {
47
47
  ServerHandler2
48
- } from "./auth-qh9c2857.js";
48
+ } from "./service-status-nvqjvwgj.js";
49
49
  import {
50
50
  DebugHandler2
51
- } from "./auth-e3vgmqs2.js";
51
+ } from "./service-status-8e21y1bd.js";
52
52
  import {
53
53
  PtyHandler2
54
- } from "./auth-y4j2wswm.js";
54
+ } from "./service-status-3582t7j8.js";
55
55
  import {
56
56
  PersistentPtyHandler2
57
- } from "./auth-v84hnbsb.js";
57
+ } from "./service-status-0qzy9yxk.js";
58
58
  import {
59
59
  ShellHandler2
60
- } from "./auth-tsyxj4xh.js";
60
+ } from "./service-status-z3nth2hg.js";
61
61
  import {
62
62
  ReferenceHandler2
63
- } from "./auth-jd22znxy.js";
63
+ } from "./service-status-cm8xmqjn.js";
64
64
  import {
65
65
  LocationHandler2
66
- } from "./auth-y07r8paj.js";
66
+ } from "./service-status-tk6nqkmh.js";
67
67
  import {
68
68
  IntegrationHandler2
69
- } from "./auth-bp2kj98m.js";
69
+ } from "./service-status-erwrh284.js";
70
70
  import {
71
71
  WebSearchHandler2
72
- } from "./auth-h1w0a8ky.js";
72
+ } from "./service-status-6aya8ky6.js";
73
73
  import {
74
74
  McpHandler2
75
- } from "./auth-epwv4y6g.js";
75
+ } from "./service-status-8ygjd1s8.js";
76
76
  import {
77
77
  CredentialHandler2
78
- } from "./auth-n0k9wajg.js";
78
+ } from "./service-status-e09mshwt.js";
79
79
  import {
80
80
  ProjectHandler2
81
- } from "./auth-eptkag0m.js";
81
+ } from "./service-status-7qtja2kq.js";
82
82
  import {
83
83
  WorktreeHandler2
84
- } from "./auth-jefcrg4z.js";
84
+ } from "./service-status-bkb1xk38.js";
85
85
  import {
86
86
  VcsHandler2
87
- } from "./auth-7zxr3tkk.js";
87
+ } from "./service-status-zw9j8b8g.js";
88
88
  import {
89
89
  MigrationHandler2
90
- } from "./auth-5frajas6.js";
90
+ } from "./service-status-txhx6f1m.js";
91
91
  import {
92
92
  ConfigHandler2
93
- } from "./auth-fdfc8k8f.js";
93
+ } from "./service-status-xpxp1sqb.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(layer4)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
98
98
 
99
99
  export { handlers2 };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/integration.ts
9
9
  import { Integration } from "@opencode/core/integration";
@@ -3,10 +3,10 @@ import {
3
3
  missingMessage2,
4
4
  failedMessageDecode2,
5
5
  failedSnapshot2
6
- } from "./auth-smaf4a18.js";
6
+ } from "./service-status-smaf4a18.js";
7
7
  import {
8
8
  Api2
9
- } from "./auth-2v3qky60.js";
9
+ } from "./service-status-z6kg9h7e.js";
10
10
 
11
11
  // src/handlers/session.ts
12
12
  import { Session } from "@opencode/core/session";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  sessionInfo2,
3
3
  requestRef2
4
- } from "./auth-43k13dmj.js";
4
+ } from "./service-status-0ar9gf7q.js";
5
5
 
6
6
  // src/middleware/form-location.ts
7
7
  import { Instance } from "@opencode/core/instance/service";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/model.ts
9
9
  import { Model } from "@opencode/core/model";
@@ -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 "./service-status-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,13 +1,13 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./auth-smaf4a18.js";
3
+ } from "./service-status-smaf4a18.js";
4
4
  import {
5
5
  response2,
6
6
  sessionInfo2
7
- } from "./auth-43k13dmj.js";
7
+ } from "./service-status-0ar9gf7q.js";
8
8
  import {
9
9
  Api2
10
- } from "./auth-2v3qky60.js";
10
+ } from "./service-status-z6kg9h7e.js";
11
11
 
12
12
  // src/handlers/permission.ts
13
13
  import { Instance } from "@opencode/core/instance/service";
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-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,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/event-feed.ts
6
6
  var exports_event_feed = {};
@@ -11,7 +11,7 @@ __export(exports_event_feed, {
11
11
  SubscriberCapacity: () => SubscriberCapacity2,
12
12
  SubscriberOverflowError: () => SubscriberOverflowError2,
13
13
  frame: () => frame2,
14
- layer: () => layer5,
14
+ layer: () => layer4,
15
15
  make: () => make4
16
16
  });
17
17
  import { Bus } from "@opencode/core/bus";
@@ -75,9 +75,9 @@ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
75
75
  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))
76
76
  });
77
77
  });
78
- var layer5 = Layer.effect(Service4, Effect.gen(function* () {
78
+ var layer4 = Layer.effect(Service4, Effect.gen(function* () {
79
79
  const bus = yield* Bus.Service;
80
80
  return yield* make4(bus.listen);
81
81
  }));
82
82
 
83
- export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make4, layer5, exports_event_feed };
83
+ export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make4, layer4, exports_event_feed };
@@ -0,0 +1,53 @@
1
+ import {
2
+ Api2
3
+ } from "./service-status-z6kg9h7e.js";
4
+ import {
5
+ SESSION_TTL_SECONDS2,
6
+ Config2,
7
+ issueSession2,
8
+ sessionCookieName2
9
+ } from "./service-status-anm12x33.js";
10
+ import {
11
+ Service3
12
+ } from "./service-status-mzr9gftb.js";
13
+ import {
14
+ Service5
15
+ } from "./service-status-sstsrjtg.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* Service5;
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,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/form.ts
9
9
  import { Form } from "@opencode/core/form";
@@ -0,0 +1,35 @@
1
+ import {
2
+ __export
3
+ } from "./service-status-9rqn6x4v.js";
4
+
5
+ // src/pairing.ts
6
+ var exports_pairing = {};
7
+ __export(exports_pairing, {
8
+ ServerPairing: () => exports_pairing,
9
+ Service: () => Service5,
10
+ node: () => node3
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 Service5 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(Service5, Effect.gen(function* () {
21
+ const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
22
+ return Service5.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 node3 = makeGlobalNode({ service: Service5, layer, deps: [] });
34
+
35
+ export { Service5, node3, exports_pairing };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./service-status-z6kg9h7e.js";
4
4
 
5
5
  // src/handlers/location.ts
6
6
  import { Location } from "@opencode/core/location";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./service-status-z6kg9h7e.js";
4
4
 
5
5
  // src/handlers/migration.ts
6
6
  import { V1Migration } from "@opencode/core/database/v1-migration";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/plugin.ts
9
9
  import { Plugin } from "@opencode/core/plugin";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./service-status-z6kg9h7e.js";
4
4
  import {
5
5
  Service4,
6
6
  frame2
7
- } from "./auth-99sfd1j8.js";
7
+ } from "./service-status-n9y13hgv.js";
8
8
 
9
9
  // src/handlers/event.ts
10
10
  import { Event } from "@opencode/schema/event";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-2v3qky60.js";
3
+ } from "./service-status-z6kg9h7e.js";
4
4
 
5
5
  // src/handlers/config.ts
6
6
  import { Config } from "@opencode/core/config";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/service-status.ts
6
6
  var exports_service_status = {};
7
7
  __export(exports_service_status, {
8
8
  Status: () => exports_service_status,
9
- make: () => make3
9
+ make: () => make2
10
10
  });
11
11
  import { Effect, Ref } from "effect";
12
- var make3 = Effect.fnUntraced(function* (options = {}) {
12
+ var make2 = Effect.fnUntraced(function* (options = {}) {
13
13
  const current = yield* Ref.make(options.initial ?? { type: "starting" });
14
14
  const beginStopping = Ref.update(current, (status) => status.type === "stopping" ? status : { type: "stopping" });
15
15
  return {
@@ -20,4 +20,4 @@ var make3 = Effect.fnUntraced(function* (options = {}) {
20
20
  };
21
21
  });
22
22
 
23
- export { make3, exports_service_status };
23
+ export { make2, exports_service_status };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/shell.ts
9
9
  import { Shell } from "@opencode/core/shell";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  LocationMiddleware2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  FormLocationMiddleware2
6
- } from "./auth-hrfm0p6n.js";
6
+ } from "./service-status-frv6gfy7.js";
7
7
  import {
8
8
  SessionLocationMiddleware2
9
- } from "./auth-d65y46ag.js";
9
+ } from "./service-status-23w8t84j.js";
10
10
 
11
11
  // src/api.ts
12
12
  import { makeDefaultApi } from "@opencode/protocol/api";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/vcs.ts
9
9
  import { Vcs } from "@opencode/core/vcs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-43k13dmj.js";
3
+ } from "./service-status-0ar9gf7q.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-2v3qky60.js";
6
+ } from "./service-status-z6kg9h7e.js";
7
7
 
8
8
  // src/handlers/agent.ts
9
9
  import { Agent } from "@opencode/core/agent";
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/service-status-q4bn6dy8.js";
6
6
  export {
7
7
  CorsConfig2 as CorsConfig,
8
8
  isAllowedCorsOrigin2 as isAllowedCorsOrigin,
@@ -5,9 +5,9 @@ import {
5
5
  Service4,
6
6
  frame2,
7
7
  make4,
8
- layer5,
8
+ layer4,
9
9
  exports_event_feed
10
- } from "./chunks/auth-99sfd1j8.js";
10
+ } from "./chunks/service-status-n9y13hgv.js";
11
11
  export {
12
12
  EncodingError2 as EncodingError,
13
13
  exports_event_feed as EventFeed,
@@ -15,6 +15,6 @@ export {
15
15
  SubscriberCapacity2 as SubscriberCapacity,
16
16
  SubscriberOverflowError2 as SubscriberOverflowError,
17
17
  frame2 as frame,
18
- layer5 as layer,
18
+ layer4 as layer,
19
19
  make4 as make
20
20
  };