@opencode/server 0.0.0-dev-1324 → 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.
- package/dist/api.js +5 -5
- package/dist/auth.js +1 -1
- package/dist/chunks/{routes-g97h7k0s.js → event-feed-0bzgr4rt.js} +1 -1
- package/dist/chunks/{routes-g80pvn6e.js → event-feed-0d9m1wm4.js} +2 -2
- package/dist/chunks/{routes-wh07bcjv.js → event-feed-1pw2nrsx.js} +1 -1
- package/dist/chunks/{routes-pv4dnzzq.js → event-feed-2d18d1yn.js} +1 -1
- package/dist/chunks/{routes-39nnfjx1.js → event-feed-39nnfjx1.js} +1 -1
- package/dist/chunks/{routes-gp51b0m6.js → event-feed-3cp4agan.js} +3 -3
- package/dist/chunks/{routes-4r2ye500.js → event-feed-4vbpeb73.js} +2 -2
- package/dist/chunks/{routes-zrptb2x8.js → event-feed-55yh37zc.js} +2 -2
- package/dist/chunks/{routes-k26h7zjg.js → event-feed-5b1w9hwr.js} +2 -2
- package/dist/chunks/{routes-r90c0ath.js → event-feed-5z0ssrt9.js} +18 -16
- package/dist/chunks/{routes-4gbck4qg.js → event-feed-6f7nn4kk.js} +2 -2
- package/dist/chunks/{routes-p89q26vy.js → event-feed-6jmqkv3t.js} +35 -35
- package/dist/chunks/{routes-p3ekc874.js → event-feed-6ptjjp36.js} +2 -2
- package/dist/chunks/{routes-4apj6a8e.js → event-feed-735y9bwf.js} +2 -2
- package/dist/chunks/{routes-7ydfwv45.js → event-feed-7ydfwv45.js} +1 -1
- package/dist/chunks/{routes-v0z8pce5.js → event-feed-8ptkdkh0.js} +2 -2
- package/dist/chunks/{routes-b87bs0cf.js → event-feed-8q8t4r9z.js} +2 -2
- package/dist/chunks/{routes-8sb6qqpn.js → event-feed-8sb6qqpn.js} +1 -1
- package/dist/chunks/{routes-9cd3a4b8.js → event-feed-9cd3a4b8.js} +1 -1
- package/dist/chunks/{routes-6t6fd9bq.js → event-feed-9d8cvn0j.js} +2 -2
- package/dist/chunks/{routes-86dz2n4m.js → event-feed-a5hb5213.js} +2 -2
- package/dist/chunks/{routes-s8t5gq7c.js → event-feed-a9m1qywq.js} +3 -3
- package/dist/chunks/{routes-wecgp61r.js → event-feed-arzv3fj6.js} +7 -7
- package/dist/chunks/{routes-t62b1gmw.js → event-feed-aw6r5m46.js} +2 -2
- package/dist/chunks/{routes-5pdfedjd.js → event-feed-b1prsepx.js} +4 -4
- package/dist/chunks/{routes-8n1ypg70.js → event-feed-cha5bc7v.js} +3 -3
- package/dist/chunks/{routes-6s1v5h8n.js → event-feed-d6gdrha6.js} +4 -4
- package/dist/chunks/{routes-djr0jy89.js → event-feed-djr0jy89.js} +1 -1
- package/dist/chunks/{routes-edwk6ehd.js → event-feed-dx59hhqy.js} +1 -1
- package/dist/chunks/{routes-b1x3j2e8.js → event-feed-e4amrgg0.js} +2 -2
- package/dist/chunks/{routes-50kbksvb.js → event-feed-g23ffrnz.js} +2 -2
- package/dist/chunks/{routes-p9wp66hf.js → event-feed-harnzwyx.js} +1 -1
- package/dist/chunks/{routes-j4at0y5c.js → event-feed-j4at0y5c.js} +1 -1
- package/dist/chunks/{routes-b7yt2ykh.js → event-feed-jdn2h5zy.js} +2 -2
- package/dist/chunks/{routes-4d81c38p.js → event-feed-knscys1g.js} +4 -4
- package/dist/chunks/{routes-n6ypjnhz.js → event-feed-kstarh2s.js} +1 -1
- package/dist/chunks/{routes-p4zkxzv7.js → event-feed-mbf5t0tq.js} +1 -1
- package/dist/chunks/{routes-d0advawr.js → event-feed-mnk4yp0a.js} +2 -2
- package/dist/chunks/{routes-myqk22k5.js → event-feed-myqk22k5.js} +2 -2
- package/dist/chunks/{routes-kqr36gas.js → event-feed-mzs0n5xz.js} +7 -7
- package/dist/chunks/{routes-7x6cg3xs.js → event-feed-p4hr7w7j.js} +2 -2
- package/dist/chunks/{routes-wbrxtn62.js → event-feed-p7f8d9ed.js} +4 -4
- package/dist/chunks/{routes-7b9xm1qg.js → event-feed-rktygpea.js} +4 -1
- package/dist/chunks/{routes-bvm82fhd.js → event-feed-rxp97434.js} +4 -4
- package/dist/chunks/event-feed-syfzpkey.js +144 -0
- package/dist/chunks/{routes-t32e1bbt.js → event-feed-t32e1bbt.js} +1 -1
- package/dist/chunks/{routes-s8cv2y4y.js → event-feed-tb37vts4.js} +13 -9
- package/dist/chunks/{routes-j80tzjj3.js → event-feed-tdwf54y9.js} +3 -3
- package/dist/chunks/{routes-4gdxfk9h.js → event-feed-tphz28p0.js} +6 -6
- package/dist/chunks/{routes-t8azv5ge.js → event-feed-vjj7wrqn.js} +2 -2
- package/dist/chunks/{routes-g329ycmh.js → event-feed-vxnq9y72.js} +5 -5
- package/dist/chunks/{routes-nkfbbfe7.js → event-feed-y50v5y23.js} +4 -4
- package/dist/chunks/{routes-20wvj9q6.js → event-feed-ye16b3jy.js} +2 -2
- package/dist/chunks/{routes-qahj7606.js → event-feed-ytyf0yt4.js} +1 -1
- package/dist/content-headers.js +1 -1
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +60 -59
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/artifact.js +3 -3
- package/dist/handlers/automation.js +2 -2
- package/dist/handlers/blob.js +3 -3
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +7 -7
- package/dist/handlers/debug.js +6 -6
- package/dist/handlers/event.js +7 -7
- package/dist/handlers/form.js +6 -6
- package/dist/handlers/fs.js +8 -8
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/job.js +2 -2
- package/dist/handlers/location.js +6 -6
- package/dist/handlers/machine.d.ts +61 -0
- package/dist/handlers/machine.js +16 -0
- package/dist/handlers/mcp.js +8 -8
- package/dist/handlers/media.js +2 -2
- package/dist/handlers/message.js +7 -7
- package/dist/handlers/migration.js +6 -6
- package/dist/handlers/model.js +6 -6
- package/dist/handlers/permission.js +6 -6
- package/dist/handlers/persistent-pty.d.ts +1 -1
- package/dist/handlers/persistent-pty.js +16 -15
- package/dist/handlers/plugin.js +6 -6
- package/dist/handlers/project.js +6 -6
- package/dist/handlers/provider.js +6 -6
- package/dist/handlers/pty-socket.js +1 -1
- package/dist/handlers/pty.js +8 -8
- package/dist/handlers/reference.js +6 -6
- package/dist/handlers/rpc.js +6 -6
- package/dist/handlers/server.js +9 -9
- package/dist/handlers/session-error.js +1 -1
- package/dist/handlers/session.js +7 -7
- package/dist/handlers/shell.js +6 -6
- package/dist/handlers/skill.js +6 -6
- package/dist/handlers/usage.js +6 -6
- package/dist/handlers/vcs.js +6 -6
- package/dist/handlers/voice.js +6 -6
- package/dist/handlers/websearch.js +6 -6
- package/dist/handlers/worktree.js +6 -6
- package/dist/handlers.d.ts +1 -1
- package/dist/handlers.js +53 -52
- package/dist/location.js +4 -4
- package/dist/media-uri.js +1 -1
- package/dist/middleware/authorization.js +2 -2
- package/dist/middleware/defect-response.js +1 -1
- package/dist/middleware/form-location.js +3 -3
- package/dist/middleware/schema-error.js +1 -1
- package/dist/middleware/session-location.js +3 -3
- package/dist/pairing.js +3 -3
- package/dist/process.js +70 -63
- package/dist/range.js +1 -1
- package/dist/request-site.js +2 -2
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +3 -2
- package/dist/routes.js +57 -56
- package/dist/server-info.js +3 -3
- package/dist/service-status.js +1 -1
- package/dist/workerd.js +61 -60
- package/package.json +8 -8
- /package/dist/chunks/{routes-9rqn6x4v.js → event-feed-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{routes-bd8755ek.js → event-feed-bd8755ek.js} +0 -0
- /package/dist/chunks/{routes-n26yr6pw.js → event-feed-n26yr6pw.js} +0 -0
- /package/dist/chunks/{routes-q187pxxd.js → event-feed-q187pxxd.js} +0 -0
- /package/dist/chunks/{routes-q4bn6dy8.js → event-feed-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{routes-smaf4a18.js → event-feed-smaf4a18.js} +0 -0
- /package/dist/chunks/{routes-xthc02cw.js → event-feed-xthc02cw.js} +0 -0
- /package/dist/chunks/{routes-yc7nft6q.js → event-feed-yc7nft6q.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
download2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-t32e1bbt.js";
|
|
4
4
|
import {
|
|
5
5
|
parse2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-8sb6qqpn.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/blob.ts
|
|
9
9
|
import { BlobStore } from "@opencode/core/blob-store";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestRef2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-tdwf54y9.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
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 "./
|
|
6
|
+
} from "./event-feed-smaf4a18.js";
|
|
7
7
|
import {
|
|
8
8
|
locationErrors2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./event-feed-tdwf54y9.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-a9m1qywq.js";
|
|
13
13
|
import {
|
|
14
14
|
wantsMediaRefs2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./event-feed-xthc02cw.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/session.ts
|
|
18
18
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/pairing.ts
|
|
6
6
|
var exports_pairing = {};
|
|
7
7
|
__export(exports_pairing, {
|
|
8
8
|
ServerPairing: () => exports_pairing,
|
|
9
|
-
Service: () =>
|
|
9
|
+
Service: () => Service4,
|
|
10
10
|
node: () => node2
|
|
11
11
|
});
|
|
12
12
|
import { Cache, Context, Duration, Effect, Layer } from "effect";
|
|
@@ -14,12 +14,12 @@ import { makeGlobalNode } from "@opencode/util/effect/app-node";
|
|
|
14
14
|
import { randomBytes } from "node:crypto";
|
|
15
15
|
var TTL = Duration.minutes(5);
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class Service4 extends Context.Service()("@opencode/ServerPairing") {
|
|
18
18
|
}
|
|
19
19
|
var noLookup = () => Effect.die(new Error("ServerPairing cache must be used via set/invalidateWhen, never get"));
|
|
20
|
-
var layer = Layer.effect(
|
|
20
|
+
var layer = Layer.effect(Service4, Effect.gen(function* () {
|
|
21
21
|
const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
|
|
22
|
-
return
|
|
22
|
+
return Service4.of({
|
|
23
23
|
issue: Effect.fn("ServerPairing.issue")(function* () {
|
|
24
24
|
const code = randomBytes(16).toString("base64url");
|
|
25
25
|
yield* Cache.set(cache, code, true);
|
|
@@ -30,6 +30,6 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
}));
|
|
33
|
-
var node2 = makeGlobalNode({ service:
|
|
33
|
+
var node2 = makeGlobalNode({ service: Service4, layer, deps: [] });
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { Service4, node2, exports_pairing };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-tdwf54y9.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
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 "./
|
|
3
|
+
} from "./event-feed-tdwf54y9.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-a9m1qywq.js";
|
|
7
7
|
import {
|
|
8
8
|
download2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./event-feed-t32e1bbt.js";
|
|
10
10
|
import {
|
|
11
11
|
parse2
|
|
12
|
-
} from "./
|
|
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 "./
|
|
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 "./
|
|
5
|
+
} from "./event-feed-tdwf54y9.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./event-feed-a9m1qywq.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2,
|
|
15
15
|
holdLocation2
|
|
16
|
-
} from "./
|
|
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,28 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-a9m1qywq.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./event-feed-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
makeArtifact2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./event-feed-aw6r5m46.js";
|
|
11
11
|
import {
|
|
12
12
|
makeBlobGet2
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./event-feed-g23ffrnz.js";
|
|
14
14
|
import {
|
|
15
15
|
makeAutomation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./event-feed-9cd3a4b8.js";
|
|
17
17
|
import {
|
|
18
18
|
makeJob2
|
|
19
|
-
} from "./
|
|
19
|
+
} from "./event-feed-7ydfwv45.js";
|
|
20
|
+
import {
|
|
21
|
+
makeMachineLink2
|
|
22
|
+
} from "./event-feed-syfzpkey.js";
|
|
20
23
|
import {
|
|
21
24
|
makeMediaGet2
|
|
22
|
-
} from "./
|
|
25
|
+
} from "./event-feed-djr0jy89.js";
|
|
23
26
|
import {
|
|
24
27
|
runPtySocket2
|
|
25
|
-
} from "./
|
|
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
|
-
|
|
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 "./
|
|
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
|
|
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 layer3 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
|
59
59
|
}));
|
|
60
60
|
}));
|
|
61
61
|
|
|
62
|
-
export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2,
|
|
62
|
+
export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2, layer2 };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
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 "./
|
|
9
|
+
} from "./event-feed-j4at0y5c.js";
|
|
10
10
|
import {
|
|
11
11
|
Service3
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-b1prsepx.js";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./
|
|
14
|
+
Service4
|
|
15
|
+
} from "./event-feed-mzs0n5xz.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/server.ts
|
|
18
18
|
import { hostname } from "node:os";
|
|
@@ -22,7 +22,7 @@ import { HttpApiBuilder } from "effect/http-api";
|
|
|
22
22
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
23
23
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
24
24
|
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
25
|
-
const pairing = yield*
|
|
25
|
+
const pairing = yield* Service4;
|
|
26
26
|
const auth = yield* Config2;
|
|
27
27
|
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
28
28
|
const info = yield* Service3;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-tdwf54y9.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
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 "./
|
|
3
|
+
} from "./event-feed-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
middleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-myqk22k5.js";
|
|
7
7
|
import {
|
|
8
8
|
withoutParentSpan2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./event-feed-yc7nft6q.js";
|
|
10
10
|
import {
|
|
11
11
|
createRoutes2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-5z0ssrt9.js";
|
|
13
13
|
import {
|
|
14
14
|
__export
|
|
15
|
-
} from "./
|
|
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 "./
|
|
5
|
+
} from "./event-feed-tdwf54y9.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./event-feed-a9m1qywq.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2,
|
|
15
15
|
holdLocation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./event-feed-q187pxxd.js";
|
|
17
17
|
|
|
18
18
|
// src/handlers/pty.ts
|
|
19
19
|
import { Pty } from "@opencode/core/pty";
|
package/dist/content-headers.js
CHANGED
package/dist/cors.js
CHANGED
package/dist/event-feed.js
CHANGED
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
SubscriberCapacity2,
|
|
3
3
|
SubscriberOverflowError2,
|
|
4
4
|
EncodingError2,
|
|
5
|
-
|
|
5
|
+
Service2,
|
|
6
6
|
frame2,
|
|
7
7
|
make4,
|
|
8
|
-
|
|
8
|
+
layer3,
|
|
9
9
|
exports_event_feed
|
|
10
|
-
} from "./chunks/
|
|
10
|
+
} from "./chunks/event-feed-arzv3fj6.js";
|
|
11
11
|
export {
|
|
12
12
|
EncodingError2 as EncodingError,
|
|
13
13
|
exports_event_feed as EventFeed,
|
|
14
|
-
|
|
14
|
+
Service2 as Service,
|
|
15
15
|
SubscriberCapacity2 as SubscriberCapacity,
|
|
16
16
|
SubscriberOverflowError2 as SubscriberOverflowError,
|
|
17
17
|
frame2 as frame,
|
|
18
|
-
|
|
18
|
+
layer3 as layer,
|
|
19
19
|
make4 as make
|
|
20
20
|
};
|