@opencode/server 0.0.0-dev-1325 → 0.0.0-dev-1326

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 (130) hide show
  1. package/dist/api.js +5 -5
  2. package/dist/auth.js +1 -1
  3. package/dist/chunks/{location-j9bm09j4.js → event-feed-0bzgr4rt.js} +1 -1
  4. package/dist/chunks/{location-z030czn6.js → event-feed-0d9m1wm4.js} +2 -2
  5. package/dist/chunks/{location-wtrkk6n8.js → event-feed-1pw2nrsx.js} +1 -1
  6. package/dist/chunks/{location-ghcy4ddk.js → event-feed-2d18d1yn.js} +1 -1
  7. package/dist/chunks/{location-39nnfjx1.js → event-feed-39nnfjx1.js} +1 -1
  8. package/dist/chunks/{location-3svx81fb.js → event-feed-3cp4agan.js} +3 -3
  9. package/dist/chunks/{location-2b13xzyt.js → event-feed-4vbpeb73.js} +2 -2
  10. package/dist/chunks/{location-cx7az6y7.js → event-feed-55yh37zc.js} +2 -2
  11. package/dist/chunks/{location-nezkqcz0.js → event-feed-5b1w9hwr.js} +2 -2
  12. package/dist/chunks/{location-3d706mcp.js → event-feed-5z0ssrt9.js} +18 -16
  13. package/dist/chunks/{location-n7n1k6t0.js → event-feed-6f7nn4kk.js} +2 -2
  14. package/dist/chunks/{location-20aw7tea.js → event-feed-6jmqkv3t.js} +35 -35
  15. package/dist/chunks/{location-w7qv5azt.js → event-feed-6ptjjp36.js} +2 -2
  16. package/dist/chunks/{location-c0pd5awd.js → event-feed-735y9bwf.js} +2 -2
  17. package/dist/chunks/{location-7ydfwv45.js → event-feed-7ydfwv45.js} +1 -1
  18. package/dist/chunks/{location-xygx09yd.js → event-feed-8ptkdkh0.js} +2 -2
  19. package/dist/chunks/{location-27f8nny0.js → event-feed-8q8t4r9z.js} +2 -2
  20. package/dist/chunks/{location-8sb6qqpn.js → event-feed-8sb6qqpn.js} +1 -1
  21. package/dist/chunks/{location-9cd3a4b8.js → event-feed-9cd3a4b8.js} +1 -1
  22. package/dist/chunks/{location-065pppgn.js → event-feed-9d8cvn0j.js} +2 -2
  23. package/dist/chunks/{location-z4znncxg.js → event-feed-a5hb5213.js} +2 -2
  24. package/dist/chunks/{location-8pn9ceqg.js → event-feed-a9m1qywq.js} +3 -3
  25. package/dist/chunks/{location-fvpjvjpp.js → event-feed-arzv3fj6.js} +4 -4
  26. package/dist/chunks/{location-7qpea5x7.js → event-feed-aw6r5m46.js} +2 -2
  27. package/dist/chunks/{location-3te71694.js → event-feed-b1prsepx.js} +4 -4
  28. package/dist/chunks/{location-669rq3zn.js → event-feed-cha5bc7v.js} +3 -3
  29. package/dist/chunks/{location-bwjy9ex5.js → event-feed-d6gdrha6.js} +2 -2
  30. package/dist/chunks/{location-djr0jy89.js → event-feed-djr0jy89.js} +1 -1
  31. package/dist/chunks/{location-0tp9bckc.js → event-feed-dx59hhqy.js} +1 -1
  32. package/dist/chunks/{location-xhsknm82.js → event-feed-e4amrgg0.js} +2 -2
  33. package/dist/chunks/{location-g23ffrnz.js → event-feed-g23ffrnz.js} +2 -2
  34. package/dist/chunks/{location-2q06e3dd.js → event-feed-harnzwyx.js} +1 -1
  35. package/dist/chunks/{location-j4at0y5c.js → event-feed-j4at0y5c.js} +1 -1
  36. package/dist/chunks/{location-500wz90y.js → event-feed-jdn2h5zy.js} +2 -2
  37. package/dist/chunks/{location-9chkqb53.js → event-feed-knscys1g.js} +4 -4
  38. package/dist/chunks/{location-ah2sj2pr.js → event-feed-kstarh2s.js} +1 -1
  39. package/dist/chunks/{location-k3qt4jsw.js → event-feed-mbf5t0tq.js} +1 -1
  40. package/dist/chunks/{location-ahhjt1wh.js → event-feed-mnk4yp0a.js} +2 -2
  41. package/dist/chunks/{location-myqk22k5.js → event-feed-myqk22k5.js} +2 -2
  42. package/dist/chunks/{location-mzs0n5xz.js → event-feed-mzs0n5xz.js} +1 -1
  43. package/dist/chunks/{location-fhb2ewd9.js → event-feed-p4hr7w7j.js} +2 -2
  44. package/dist/chunks/{location-01ta1g14.js → event-feed-p7f8d9ed.js} +4 -4
  45. package/dist/chunks/{location-7b9xm1qg.js → event-feed-rktygpea.js} +4 -1
  46. package/dist/chunks/{location-9epy4pks.js → event-feed-rxp97434.js} +4 -4
  47. package/dist/chunks/event-feed-syfzpkey.js +144 -0
  48. package/dist/chunks/{location-t32e1bbt.js → event-feed-t32e1bbt.js} +1 -1
  49. package/dist/chunks/{location-2ghz4m36.js → event-feed-tb37vts4.js} +13 -9
  50. package/dist/chunks/{location-ywn523ee.js → event-feed-tdwf54y9.js} +3 -3
  51. package/dist/chunks/{location-66wjg7cg.js → event-feed-tphz28p0.js} +4 -4
  52. package/dist/chunks/{location-yr4jk19s.js → event-feed-vjj7wrqn.js} +2 -2
  53. package/dist/chunks/{location-qzq425w0.js → event-feed-vxnq9y72.js} +5 -5
  54. package/dist/chunks/{location-mevm0qpj.js → event-feed-y50v5y23.js} +4 -4
  55. package/dist/chunks/{location-ryf8gt7t.js → event-feed-ye16b3jy.js} +2 -2
  56. package/dist/chunks/{location-vw0q3knq.js → event-feed-ytyf0yt4.js} +1 -1
  57. package/dist/content-headers.js +1 -1
  58. package/dist/cors.js +1 -1
  59. package/dist/event-feed.js +3 -3
  60. package/dist/fetch.js +60 -59
  61. package/dist/handlers/agent.js +6 -6
  62. package/dist/handlers/artifact.js +3 -3
  63. package/dist/handlers/automation.js +2 -2
  64. package/dist/handlers/blob.js +3 -3
  65. package/dist/handlers/command.js +6 -6
  66. package/dist/handlers/config.js +6 -6
  67. package/dist/handlers/credential.js +7 -7
  68. package/dist/handlers/debug.js +6 -6
  69. package/dist/handlers/event.js +7 -7
  70. package/dist/handlers/form.js +6 -6
  71. package/dist/handlers/fs.js +8 -8
  72. package/dist/handlers/generate.js +6 -6
  73. package/dist/handlers/integration.js +6 -6
  74. package/dist/handlers/job.js +2 -2
  75. package/dist/handlers/location.js +6 -6
  76. package/dist/handlers/machine.d.ts +61 -0
  77. package/dist/handlers/machine.js +16 -0
  78. package/dist/handlers/mcp.js +8 -8
  79. package/dist/handlers/media.js +2 -2
  80. package/dist/handlers/message.js +7 -7
  81. package/dist/handlers/migration.js +6 -6
  82. package/dist/handlers/model.js +6 -6
  83. package/dist/handlers/permission.js +6 -6
  84. package/dist/handlers/persistent-pty.d.ts +1 -1
  85. package/dist/handlers/persistent-pty.js +16 -15
  86. package/dist/handlers/plugin.js +6 -6
  87. package/dist/handlers/project.js +6 -6
  88. package/dist/handlers/provider.js +6 -6
  89. package/dist/handlers/pty-socket.js +1 -1
  90. package/dist/handlers/pty.js +8 -8
  91. package/dist/handlers/reference.js +6 -6
  92. package/dist/handlers/rpc.js +6 -6
  93. package/dist/handlers/server.js +9 -9
  94. package/dist/handlers/session-error.js +1 -1
  95. package/dist/handlers/session.js +7 -7
  96. package/dist/handlers/shell.js +6 -6
  97. package/dist/handlers/skill.js +6 -6
  98. package/dist/handlers/usage.js +6 -6
  99. package/dist/handlers/vcs.js +6 -6
  100. package/dist/handlers/voice.js +6 -6
  101. package/dist/handlers/websearch.js +6 -6
  102. package/dist/handlers/worktree.js +6 -6
  103. package/dist/handlers.d.ts +1 -1
  104. package/dist/handlers.js +53 -52
  105. package/dist/location.js +4 -4
  106. package/dist/media-uri.js +1 -1
  107. package/dist/middleware/authorization.js +2 -2
  108. package/dist/middleware/defect-response.js +1 -1
  109. package/dist/middleware/form-location.js +3 -3
  110. package/dist/middleware/schema-error.js +1 -1
  111. package/dist/middleware/session-location.js +3 -3
  112. package/dist/pairing.js +1 -1
  113. package/dist/process.js +70 -63
  114. package/dist/range.js +1 -1
  115. package/dist/request-site.js +2 -2
  116. package/dist/request-tracing.js +1 -1
  117. package/dist/routes.d.ts +3 -2
  118. package/dist/routes.js +57 -56
  119. package/dist/server-info.js +3 -3
  120. package/dist/service-status.js +1 -1
  121. package/dist/workerd.js +61 -60
  122. package/package.json +8 -8
  123. /package/dist/chunks/{location-9rqn6x4v.js → event-feed-9rqn6x4v.js} +0 -0
  124. /package/dist/chunks/{location-bd8755ek.js → event-feed-bd8755ek.js} +0 -0
  125. /package/dist/chunks/{location-n26yr6pw.js → event-feed-n26yr6pw.js} +0 -0
  126. /package/dist/chunks/{location-q187pxxd.js → event-feed-q187pxxd.js} +0 -0
  127. /package/dist/chunks/{location-q4bn6dy8.js → event-feed-q4bn6dy8.js} +0 -0
  128. /package/dist/chunks/{location-smaf4a18.js → event-feed-smaf4a18.js} +0 -0
  129. /package/dist/chunks/{location-xthc02cw.js → event-feed-xthc02cw.js} +0 -0
  130. /package/dist/chunks/{location-yc7nft6q.js → event-feed-yc7nft6q.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./location-8pn9ceqg.js";
3
+ } from "./event-feed-a9m1qywq.js";
4
4
 
5
5
  // src/handlers/worktree.ts
6
6
  import { Git } from "@opencode/core/git";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./location-9rqn6x4v.js";
3
+ } from "./event-feed-9rqn6x4v.js";
4
4
 
5
5
  // src/auth.ts
6
6
  var exports_auth = {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  requestRef2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
 
8
8
  // src/handlers/debug.ts
9
9
  import { LocationServiceMap } from "@opencode/core/location-service-map";
@@ -3,16 +3,16 @@ import {
3
3
  missingMessage2,
4
4
  failedMessageDecode2,
5
5
  failedSnapshot2
6
- } from "./location-smaf4a18.js";
6
+ } from "./event-feed-smaf4a18.js";
7
7
  import {
8
8
  locationErrors2
9
- } from "./location-ywn523ee.js";
9
+ } from "./event-feed-tdwf54y9.js";
10
10
  import {
11
11
  Api2
12
- } from "./location-8pn9ceqg.js";
12
+ } from "./event-feed-a9m1qywq.js";
13
13
  import {
14
14
  wantsMediaRefs2
15
- } from "./location-xthc02cw.js";
15
+ } from "./event-feed-xthc02cw.js";
16
16
 
17
17
  // src/handlers/session.ts
18
18
  import { Instance } from "@opencode/core/instance/service";
@@ -2,7 +2,7 @@ import {
2
2
  locationErrors2,
3
3
  sessionInfo2,
4
4
  requestRef2
5
- } from "./location-ywn523ee.js";
5
+ } from "./event-feed-tdwf54y9.js";
6
6
 
7
7
  // src/middleware/form-location.ts
8
8
  import { Instance } from "@opencode/core/instance/service";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./location-8pn9ceqg.js";
3
+ } from "./event-feed-a9m1qywq.js";
4
4
 
5
5
  // src/handlers/rpc.ts
6
6
  import { Rpc } from "@opencode/core/rpc";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
 
8
8
  // src/handlers/model.ts
9
9
  import { Model } from "@opencode/core/model";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isAllowedRequestOrigin2
3
- } from "./location-q4bn6dy8.js";
3
+ } from "./event-feed-q4bn6dy8.js";
4
4
  import {
5
5
  __export
6
- } from "./location-9rqn6x4v.js";
6
+ } from "./event-feed-9rqn6x4v.js";
7
7
 
8
8
  // src/request-site.ts
9
9
  var exports_request_site = {};
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./location-9rqn6x4v.js";
3
+ } from "./event-feed-9rqn6x4v.js";
4
4
 
5
5
  // src/pairing.ts
6
6
  var exports_pairing = {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
 
8
8
  // src/handlers/websearch.ts
9
9
  import { WebSearch } from "@opencode/core/websearch";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  response2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
  import {
8
8
  download2
9
- } from "./location-t32e1bbt.js";
9
+ } from "./event-feed-t32e1bbt.js";
10
10
  import {
11
11
  parse2
12
- } from "./location-8sb6qqpn.js";
12
+ } from "./event-feed-8sb6qqpn.js";
13
13
 
14
14
  // src/handlers/fs.ts
15
15
  import { FileSystem } from "@opencode/core/filesystem";
@@ -4,7 +4,7 @@ import {
4
4
  authorized2,
5
5
  verifySession2,
6
6
  sessionCookieName2
7
- } from "./location-j4at0y5c.js";
7
+ } from "./event-feed-j4at0y5c.js";
8
8
 
9
9
  // src/middleware/authorization.ts
10
10
  import { UnauthorizedError } from "@opencode/protocol/errors";
@@ -13,6 +13,7 @@ import { Authorization as Authorization2 } from "@opencode/protocol/middleware/a
13
13
  import { PTY_CONNECT_PATH, PTY_CONNECT_TICKET_QUERY } from "@opencode/protocol/groups/pty";
14
14
  import { PERSISTENT_PTY_CONNECT_PATH } from "@opencode/protocol/groups/persistent-pty";
15
15
  import { MCP_CLIENT_PATH } from "@opencode/protocol/groups/mcp";
16
+ import { isWebSocketUpgrade, MACHINE_LINK_PATH } from "@opencode/protocol/groups/machine";
16
17
  import { PAIRING_CONNECT_PATH } from "@opencode/protocol/groups/server";
17
18
  import { Effect, Layer, Redacted } from "effect";
18
19
  import { Base64 } from "effect/encoding";
@@ -73,6 +74,8 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
73
74
  const url = new URL(request.url, "http://localhost");
74
75
  if ((route.route.path === PTY_CONNECT_PATH || route.route.path === PERSISTENT_PTY_CONNECT_PATH || route.route.path === MCP_CLIENT_PATH) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY) || route.route.path === PAIRING_CONNECT_PATH)
75
76
  return yield* effect;
77
+ if (route.route.path === MACHINE_LINK_PATH && isWebSocketUpgrade(request))
78
+ return yield* effect;
76
79
  if (yield* authorizedRequest2(request, config))
77
80
  return yield* effect;
78
81
  if (challengeRequest(request))
@@ -2,18 +2,18 @@ import {
2
2
  locationErrors2,
3
3
  response2,
4
4
  requestRef2
5
- } from "./location-ywn523ee.js";
5
+ } from "./event-feed-tdwf54y9.js";
6
6
  import {
7
7
  Api2
8
- } from "./location-8pn9ceqg.js";
8
+ } from "./event-feed-a9m1qywq.js";
9
9
  import {
10
10
  CorsConfig2,
11
11
  isAllowedRequestOrigin2
12
- } from "./location-q4bn6dy8.js";
12
+ } from "./event-feed-q4bn6dy8.js";
13
13
  import {
14
14
  runPtySocket2,
15
15
  holdLocation2
16
- } from "./location-q187pxxd.js";
16
+ } from "./event-feed-q187pxxd.js";
17
17
 
18
18
  // src/handlers/mcp.ts
19
19
  import { Location } from "@opencode/core/location";
@@ -0,0 +1,144 @@
1
+ // src/handlers/machine.ts
2
+ import { NodeHttpServerRequest } from "@effect/platform-node";
3
+ import { WebSocketServer } from "@effect/platform-node-shared/NodeWS";
4
+ import { Flag } from "@opencode/core/flag";
5
+ import { Location } from "@opencode/core/location";
6
+ import { LocationServiceMap } from "@opencode/core/location-services";
7
+ import { Frames } from "@opencode/core/machine/frames";
8
+ import { Link } from "@opencode/core/machine/link";
9
+ import { Machines } from "@opencode/core/machine/machines";
10
+ import { AbsolutePath } from "@opencode/core/schema";
11
+ import { isWebSocketUpgrade } from "@opencode/protocol/groups/machine";
12
+ import { Global } from "@opencode/util/global";
13
+ import { Context, Effect, Latch, Option, Scope, Semaphore } from "effect";
14
+ import { HttpMiddleware, HttpServerResponse } from "effect/http";
15
+ import { Socket } from "effect/socket";
16
+ import { IncomingMessage } from "node:http";
17
+ var MAX_HANDSHAKES = 32;
18
+ var MAX_FRAME = 65535;
19
+ var MIN_FRAME = 16;
20
+ var MAX_WAITING = Frames.MAX_MESSAGE;
21
+ var STALL = "60 seconds";
22
+ var PING = "30 seconds";
23
+ var CLOSING = "5 seconds";
24
+ var STOPPING = "1 second";
25
+ var CLOSE = 1008;
26
+ var Watch2 = Context.Reference("@opencode/MachineLink/Watch", {
27
+ defaultValue: () => () => {}
28
+ });
29
+ var machinesEnabled2 = Effect.gen(function* () {
30
+ const global = yield* Global.Service;
31
+ const locations = yield* LocationServiceMap.Service;
32
+ return Flag.enabled("machines").pipe(Effect.provide(locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }))), Effect.orElseSucceed(() => false));
33
+ });
34
+ var drop = (socket) => {
35
+ socket.close(CLOSE);
36
+ socket.terminate();
37
+ };
38
+ var upgrade2 = (sockets, request) => Effect.acquireRelease(Effect.callback((resume) => {
39
+ const refused = () => resume(Effect.fail(new Link.Closed));
40
+ if (request.socket.destroyed)
41
+ return refused();
42
+ request.socket.once("close", refused);
43
+ sockets.handleUpgrade(request, request.socket, Buffer.alloc(0), (socket) => {
44
+ request.socket.off("close", refused);
45
+ socket.on("message", (data) => {
46
+ if ([data].flat().reduce((bytes, part) => bytes + part.byteLength, 0) < MIN_FRAME)
47
+ drop(socket);
48
+ });
49
+ resume(Effect.succeed(socket));
50
+ });
51
+ }), (socket) => Effect.gen(function* () {
52
+ const gone = Effect.callback((resume) => {
53
+ if (socket.readyState === socket.CLOSED)
54
+ return resume(Effect.void);
55
+ socket.once("close", () => resume(Effect.void));
56
+ });
57
+ socket.close(CLOSE);
58
+ if (Option.isNone(yield* Effect.timeoutOption(gone, CLOSING)))
59
+ socket.terminate();
60
+ }));
61
+ var carrier2 = (reader, transport) => {
62
+ const waiting = [];
63
+ return {
64
+ send: (message) => Effect.gen(function* () {
65
+ const taken = Latch.makeUnsafe();
66
+ transport.send(message, () => taken.openUnsafe());
67
+ while (true) {
68
+ const held = transport.bufferedAmount;
69
+ if (Option.isSome(yield* Effect.timeoutOption(taken.await, STALL)))
70
+ return;
71
+ if (transport.bufferedAmount >= held)
72
+ return transport.terminate();
73
+ }
74
+ }),
75
+ receive: Effect.gen(function* () {
76
+ if (waiting.length === 0) {
77
+ const read = yield* reader.pull;
78
+ if (read.reduce((bytes, message) => bytes + message.length, 0) > MAX_WAITING)
79
+ return yield* new Link.Closed;
80
+ waiting.push(...read);
81
+ }
82
+ const message = waiting.shift();
83
+ if (message === undefined || typeof message === "string")
84
+ return yield* new Link.Closed;
85
+ return message;
86
+ }).pipe(Effect.mapError(() => new Link.Closed))
87
+ };
88
+ };
89
+ var keepalive2 = (transport) => Effect.gen(function* () {
90
+ const interval = { heard: true, paused: false };
91
+ const heard = () => {
92
+ interval.heard = true;
93
+ };
94
+ const events = ["pong", "ping", "message"];
95
+ events.forEach((event) => transport.on(event, heard));
96
+ yield* Effect.addFinalizer(() => Effect.sync(() => events.forEach((event) => transport.off(event, heard))));
97
+ while (interval.heard || interval.paused || transport.isPaused) {
98
+ interval.heard = false;
99
+ interval.paused = transport.isPaused;
100
+ transport.ping();
101
+ yield* Effect.sleep(PING);
102
+ }
103
+ transport.terminate();
104
+ }).pipe(Effect.scoped);
105
+ var makeMachineLink2 = Effect.gen(function* () {
106
+ const enabled = yield* machinesEnabled2;
107
+ const services = yield* Effect.context();
108
+ const handshakes = Semaphore.makeUnsafe(MAX_HANDSHAKES);
109
+ const scope = yield* Effect.scope;
110
+ const watch = yield* Watch2;
111
+ const server = yield* Effect.cached(Effect.acquireRelease(Effect.sync(() => {
112
+ const sockets = new WebSocketServer({ noServer: true, maxPayload: MAX_FRAME });
113
+ watch(sockets);
114
+ return sockets;
115
+ }), (sockets) => Effect.gen(function* () {
116
+ sockets.clients.forEach((socket) => socket.close(CLOSE));
117
+ const empty = Effect.callback((resume) => sockets.close(() => resume(Effect.void)));
118
+ if (Option.isNone(yield* Effect.timeoutOption(empty, STOPPING)))
119
+ sockets.clients.forEach((socket) => socket.terminate());
120
+ })).pipe(Scope.provide(scope)));
121
+ return Effect.fn("MachineLink.serve")(function* (request) {
122
+ const incoming = NodeHttpServerRequest.toIncomingMessage(request);
123
+ if (!(incoming instanceof IncomingMessage) || !isWebSocketUpgrade(request) || Option.isNone(yield* Effect.option(request.upgrade)) || !(yield* enabled))
124
+ return HttpServerResponse.empty({ status: 404 });
125
+ return yield* Effect.gen(function* () {
126
+ const sockets = yield* server;
127
+ const admitted = yield* handshakes.withPermitsIfAvailable(1)(Effect.gen(function* () {
128
+ const transport = yield* upgrade2(sockets, incoming);
129
+ yield* HttpMiddleware.withLoggerDisabled(Effect.void);
130
+ const socket = yield* Socket.fromWebSocket(Effect.succeed(transport));
131
+ const link = yield* Link.serve(carrier2(yield* socket.reader, transport)).pipe(Effect.onError(() => Effect.sync(() => drop(transport))));
132
+ return { transport, link };
133
+ }));
134
+ if (Option.isNone(admitted))
135
+ return HttpServerResponse.empty({ status: 503 });
136
+ yield* Effect.forkScoped(keepalive2(admitted.value.transport));
137
+ const machines = yield* Machines.Service;
138
+ yield* machines.connect(admitted.value.link.machine, admitted.value.link.connection);
139
+ return HttpServerResponse.empty();
140
+ }).pipe(Effect.scoped, Effect.orElseSucceed(() => HttpServerResponse.empty()), Effect.provide(services));
141
+ });
142
+ });
143
+
144
+ export { Watch2, machinesEnabled2, upgrade2, carrier2, keepalive2, makeMachineLink2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./location-9rqn6x4v.js";
3
+ } from "./event-feed-9rqn6x4v.js";
4
4
 
5
5
  // src/content-headers.ts
6
6
  var exports_content_headers = {};
@@ -1,28 +1,31 @@
1
1
  import {
2
2
  Api2
3
- } from "./location-8pn9ceqg.js";
3
+ } from "./event-feed-a9m1qywq.js";
4
4
  import {
5
5
  CorsConfig2,
6
6
  isAllowedRequestOrigin2
7
- } from "./location-q4bn6dy8.js";
7
+ } from "./event-feed-q4bn6dy8.js";
8
8
  import {
9
9
  makeArtifact2
10
- } from "./location-7qpea5x7.js";
10
+ } from "./event-feed-aw6r5m46.js";
11
11
  import {
12
12
  makeBlobGet2
13
- } from "./location-g23ffrnz.js";
13
+ } from "./event-feed-g23ffrnz.js";
14
14
  import {
15
15
  makeAutomation2
16
- } from "./location-9cd3a4b8.js";
16
+ } from "./event-feed-9cd3a4b8.js";
17
17
  import {
18
18
  makeJob2
19
- } from "./location-7ydfwv45.js";
19
+ } from "./event-feed-7ydfwv45.js";
20
+ import {
21
+ makeMachineLink2
22
+ } from "./event-feed-syfzpkey.js";
20
23
  import {
21
24
  makeMediaGet2
22
- } from "./location-djr0jy89.js";
25
+ } from "./event-feed-djr0jy89.js";
23
26
  import {
24
27
  runPtySocket2
25
- } from "./location-q187pxxd.js";
28
+ } from "./event-feed-q187pxxd.js";
26
29
 
27
30
  // src/handlers/persistent-pty.ts
28
31
  import { PersistentPty } from "@opencode/core/persistent-pty";
@@ -51,7 +54,8 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
51
54
  const mediaGet = yield* makeMediaGet2;
52
55
  const blobGet = yield* makeBlobGet2;
53
56
  const automation = yield* makeAutomation2;
54
- return handlers.handleRaw("media.get", (ctx) => mediaGet(ctx.params.hash, ctx.request)).handleRaw("blob.get", (ctx) => blobGet(ctx.params.id, ctx.request)).handle("job.list", (ctx) => job.list(ctx.query)).handle("job.cancel", (ctx) => job.cancel(ctx.params.id)).handle("artifacts.providers", (ctx) => artifact.providers(ctx.query, ctx.request)).handle("artifacts.list", (ctx) => artifact.list(ctx.query, ctx.request)).handle("artifacts.create", (ctx) => artifact.create(ctx.query, ctx.payload, ctx.request)).handle("artifacts.get", (ctx) => artifact.get(ctx.params.artifactID, ctx.query, ctx.request)).handle("artifacts.update", (ctx) => artifact.update(ctx.params.artifactID, ctx.query, ctx.payload, ctx.request)).handle("artifacts.delete", (ctx) => artifact.remove(ctx.params.artifactID, ctx.query, ctx.request)).handleRaw("artifacts.view", (ctx) => artifact.view(ctx.params.artifactID, ctx.query, ctx.request)).handle("automation.create", (ctx) => automation.create(ctx.payload)).handle("automation.list", (ctx) => automation.list(ctx.query)).handle("automation.get", (ctx) => automation.get(ctx.params.automationID)).handle("automation.pause", (ctx) => automation.pause(ctx.params.automationID)).handle("automation.resume", (ctx) => automation.resume(ctx.params.automationID)).handle("automation.delete", (ctx) => automation.remove(ctx.params.automationID)).handle("persistentPty.read", Effect.fn(function* (ctx) {
57
+ const machineLink = yield* makeMachineLink2;
58
+ return handlers.handleRaw("media.get", (ctx) => mediaGet(ctx.params.hash, ctx.request)).handleRaw("blob.get", (ctx) => blobGet(ctx.params.id, ctx.request)).handle("job.list", (ctx) => job.list(ctx.query)).handle("job.cancel", (ctx) => job.cancel(ctx.params.id)).handleRaw("machine.link", (ctx) => machineLink(ctx.request)).handle("artifacts.providers", (ctx) => artifact.providers(ctx.query, ctx.request)).handle("artifacts.list", (ctx) => artifact.list(ctx.query, ctx.request)).handle("artifacts.create", (ctx) => artifact.create(ctx.query, ctx.payload, ctx.request)).handle("artifacts.get", (ctx) => artifact.get(ctx.params.artifactID, ctx.query, ctx.request)).handle("artifacts.update", (ctx) => artifact.update(ctx.params.artifactID, ctx.query, ctx.payload, ctx.request)).handle("artifacts.delete", (ctx) => artifact.remove(ctx.params.artifactID, ctx.query, ctx.request)).handleRaw("artifacts.view", (ctx) => artifact.view(ctx.params.artifactID, ctx.query, ctx.request)).handle("automation.create", (ctx) => automation.create(ctx.payload)).handle("automation.list", (ctx) => automation.list(ctx.query)).handle("automation.get", (ctx) => automation.get(ctx.params.automationID)).handle("automation.pause", (ctx) => automation.pause(ctx.params.automationID)).handle("automation.resume", (ctx) => automation.resume(ctx.params.automationID)).handle("automation.delete", (ctx) => automation.remove(ctx.params.automationID)).handle("persistentPty.read", Effect.fn(function* (ctx) {
55
59
  return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
56
60
  })).handle("persistentPty.list", Effect.fn(function* (ctx) {
57
61
  return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./location-smaf4a18.js";
3
+ } from "./event-feed-smaf4a18.js";
4
4
 
5
5
  // src/location.ts
6
6
  import { FileSystem } from "@opencode/core/filesystem";
@@ -51,7 +51,7 @@ function decode(input) {
51
51
  return input;
52
52
  }
53
53
  }
54
- var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
54
+ var layer2 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
55
55
  const locations = yield* LocationServiceMap.Service;
56
56
  return LocationMiddleware2.of((effect) => Effect.gen(function* () {
57
57
  const request = yield* HttpServerRequest.HttpServerRequest;
@@ -59,4 +59,4 @@ var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
59
59
  }));
60
60
  }));
61
61
 
62
- export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2, layer4 };
62
+ export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2, layer2 };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  Api2
3
- } from "./location-8pn9ceqg.js";
3
+ } from "./event-feed-a9m1qywq.js";
4
4
  import {
5
5
  SESSION_TTL_SECONDS2,
6
6
  Config2,
7
7
  issueSession2,
8
8
  sessionCookieName2
9
- } from "./location-j4at0y5c.js";
9
+ } from "./event-feed-j4at0y5c.js";
10
10
  import {
11
11
  Service3
12
- } from "./location-3te71694.js";
12
+ } from "./event-feed-b1prsepx.js";
13
13
  import {
14
14
  Service4
15
- } from "./location-mzs0n5xz.js";
15
+ } from "./event-feed-mzs0n5xz.js";
16
16
 
17
17
  // src/handlers/server.ts
18
18
  import { hostname } from "node:os";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
 
8
8
  // src/handlers/reference.ts
9
9
  import { Reference } from "@opencode/core/reference";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  isAllowedCorsOrigin2
3
- } from "./location-q4bn6dy8.js";
3
+ } from "./event-feed-q4bn6dy8.js";
4
4
  import {
5
5
  middleware2
6
- } from "./location-myqk22k5.js";
6
+ } from "./event-feed-myqk22k5.js";
7
7
  import {
8
8
  withoutParentSpan2
9
- } from "./location-yc7nft6q.js";
9
+ } from "./event-feed-yc7nft6q.js";
10
10
  import {
11
11
  createRoutes2
12
- } from "./location-3d706mcp.js";
12
+ } from "./event-feed-5z0ssrt9.js";
13
13
  import {
14
14
  __export
15
- } from "./location-9rqn6x4v.js";
15
+ } from "./event-feed-9rqn6x4v.js";
16
16
 
17
17
  // src/fetch.ts
18
18
  var exports_fetch = {};
@@ -2,18 +2,18 @@ import {
2
2
  locationErrors2,
3
3
  response2,
4
4
  requestRef2
5
- } from "./location-ywn523ee.js";
5
+ } from "./event-feed-tdwf54y9.js";
6
6
  import {
7
7
  Api2
8
- } from "./location-8pn9ceqg.js";
8
+ } from "./event-feed-a9m1qywq.js";
9
9
  import {
10
10
  CorsConfig2,
11
11
  isAllowedRequestOrigin2
12
- } from "./location-q4bn6dy8.js";
12
+ } from "./event-feed-q4bn6dy8.js";
13
13
  import {
14
14
  runPtySocket2,
15
15
  holdLocation2
16
- } from "./location-q187pxxd.js";
16
+ } from "./event-feed-q187pxxd.js";
17
17
 
18
18
  // src/handlers/pty.ts
19
19
  import { Pty } from "@opencode/core/pty";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./location-ywn523ee.js";
3
+ } from "./event-feed-tdwf54y9.js";
4
4
  import {
5
5
  Api2
6
- } from "./location-8pn9ceqg.js";
6
+ } from "./event-feed-a9m1qywq.js";
7
7
 
8
8
  // src/handlers/plugin.ts
9
9
  import { Plugin } from "@opencode/core/plugin";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  locationErrors2,
3
3
  sessionInfo2
4
- } from "./location-ywn523ee.js";
4
+ } from "./event-feed-tdwf54y9.js";
5
5
 
6
6
  // src/middleware/session-location.ts
7
7
  import { Instance } from "@opencode/core/instance/service";
@@ -3,7 +3,7 @@ import {
3
3
  download2,
4
4
  disposition2,
5
5
  exports_content_headers
6
- } from "./chunks/location-t32e1bbt.js";
6
+ } from "./chunks/event-feed-t32e1bbt.js";
7
7
  export {
8
8
  CONTENT_SECURITY_POLICY2 as CONTENT_SECURITY_POLICY,
9
9
  exports_content_headers as ContentHeaders,
package/dist/cors.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  CorsConfig2,
3
3
  isAllowedCorsOrigin2,
4
4
  isAllowedRequestOrigin2
5
- } from "./chunks/location-q4bn6dy8.js";
5
+ } from "./chunks/event-feed-q4bn6dy8.js";
6
6
  export {
7
7
  CorsConfig2 as CorsConfig,
8
8
  isAllowedCorsOrigin2 as isAllowedCorsOrigin,
@@ -5,9 +5,9 @@ import {
5
5
  Service2,
6
6
  frame2,
7
7
  make4,
8
- layer2,
8
+ layer3,
9
9
  exports_event_feed
10
- } from "./chunks/location-fvpjvjpp.js";
10
+ } from "./chunks/event-feed-arzv3fj6.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
- layer2 as layer,
18
+ layer3 as layer,
19
19
  make4 as make
20
20
  };