@opencode/server 0.0.0-dev-1325 → 0.0.0-dev-1328
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/{location-065pppgn.js → service-status-065pppgn.js} +2 -2
- package/dist/chunks/{location-0tp9bckc.js → service-status-0tp9bckc.js} +1 -1
- package/dist/chunks/{location-bwjy9ex5.js → service-status-11f90p14.js} +4 -4
- package/dist/chunks/{location-27f8nny0.js → service-status-27f8nny0.js} +2 -2
- package/dist/chunks/{location-2b13xzyt.js → service-status-2b13xzyt.js} +2 -2
- package/dist/chunks/{location-mevm0qpj.js → service-status-2mxtghfa.js} +4 -4
- package/dist/chunks/{location-2q06e3dd.js → service-status-2q06e3dd.js} +1 -1
- package/dist/chunks/{location-500wz90y.js → service-status-500wz90y.js} +2 -2
- package/dist/chunks/{location-3te71694.js → service-status-5pdfedjd.js} +4 -4
- package/dist/chunks/{location-669rq3zn.js → service-status-669rq3zn.js} +3 -3
- package/dist/chunks/{location-7qpea5x7.js → service-status-7qpea5x7.js} +2 -2
- package/dist/chunks/{location-7ydfwv45.js → service-status-7ydfwv45.js} +1 -1
- package/dist/chunks/{location-8pn9ceqg.js → service-status-8pn9ceqg.js} +3 -3
- package/dist/chunks/{location-8sb6qqpn.js → service-status-8sb6qqpn.js} +1 -1
- package/dist/chunks/{location-9cd3a4b8.js → service-status-9cd3a4b8.js} +1 -1
- package/dist/chunks/{location-66wjg7cg.js → service-status-9m7aaymn.js} +6 -6
- package/dist/chunks/{location-ah2sj2pr.js → service-status-ah2sj2pr.js} +1 -1
- package/dist/chunks/{location-ahhjt1wh.js → service-status-ahhjt1wh.js} +2 -2
- package/dist/chunks/{location-c0pd5awd.js → service-status-c0pd5awd.js} +2 -2
- package/dist/chunks/{location-20aw7tea.js → service-status-c2jea2a4.js} +35 -35
- package/dist/chunks/{location-cx7az6y7.js → service-status-cx7az6y7.js} +2 -2
- package/dist/chunks/{location-qzq425w0.js → service-status-czwdbrx9.js} +8 -8
- package/dist/chunks/{location-3d706mcp.js → service-status-ddhwaz88.js} +16 -14
- package/dist/chunks/service-status-dea17tr1.js +181 -0
- package/dist/chunks/{location-djr0jy89.js → service-status-djr0jy89.js} +1 -1
- package/dist/chunks/{location-39nnfjx1.js → service-status-e6e4kz0w.js} +4 -4
- package/dist/chunks/{location-fhb2ewd9.js → service-status-fhb2ewd9.js} +2 -2
- package/dist/chunks/{location-g23ffrnz.js → service-status-g23ffrnz.js} +2 -2
- package/dist/chunks/{location-ghcy4ddk.js → service-status-ghcy4ddk.js} +1 -1
- package/dist/chunks/{location-j4at0y5c.js → service-status-j4at0y5c.js} +1 -1
- package/dist/chunks/{location-j9bm09j4.js → service-status-j9bm09j4.js} +1 -1
- package/dist/chunks/{location-9epy4pks.js → service-status-jefwk804.js} +4 -4
- package/dist/chunks/{location-k3qt4jsw.js → service-status-k3qt4jsw.js} +1 -1
- package/dist/chunks/{location-mzs0n5xz.js → service-status-kqr36gas.js} +7 -7
- package/dist/chunks/{location-9chkqb53.js → service-status-kzdsh5dh.js} +4 -4
- package/dist/chunks/{location-myqk22k5.js → service-status-myqk22k5.js} +2 -2
- package/dist/chunks/{location-n7n1k6t0.js → service-status-n7n1k6t0.js} +2 -2
- package/dist/chunks/{location-nezkqcz0.js → service-status-nezkqcz0.js} +2 -2
- package/dist/chunks/{location-7b9xm1qg.js → service-status-rktygpea.js} +4 -1
- package/dist/chunks/{location-ryf8gt7t.js → service-status-ryf8gt7t.js} +2 -2
- package/dist/chunks/{location-fvpjvjpp.js → service-status-s802fzg1.js} +7 -7
- package/dist/chunks/{location-2ghz4m36.js → service-status-sy5t2m60.js} +15 -9
- package/dist/chunks/{location-t32e1bbt.js → service-status-t32e1bbt.js} +1 -1
- package/dist/chunks/{location-vw0q3knq.js → service-status-vw0q3knq.js} +1 -1
- package/dist/chunks/{location-w7qv5azt.js → service-status-w7qv5azt.js} +2 -2
- package/dist/chunks/{location-wtrkk6n8.js → service-status-wtrkk6n8.js} +1 -1
- package/dist/chunks/{location-01ta1g14.js → service-status-xbjz2dvd.js} +4 -4
- package/dist/chunks/{location-xhsknm82.js → service-status-xhsknm82.js} +2 -2
- package/dist/chunks/{location-xygx09yd.js → service-status-xygx09yd.js} +2 -2
- package/dist/chunks/{location-yr4jk19s.js → service-status-yr4jk19s.js} +2 -2
- package/dist/chunks/{location-ywn523ee.js → service-status-ywn523ee.js} +1 -1
- package/dist/chunks/{location-3svx81fb.js → service-status-yyxv56x7.js} +3 -3
- package/dist/chunks/{location-z030czn6.js → service-status-z030czn6.js} +2 -2
- package/dist/chunks/{location-z4znncxg.js → service-status-z4znncxg.js} +2 -2
- package/dist/content-headers.js +1 -1
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +62 -61
- 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 +83 -0
- package/dist/handlers/machine.js +18 -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 +2 -2
- 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 +72 -65
- 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 +3 -3
- package/dist/workerd.js +63 -62
- package/package.json +8 -8
- /package/dist/chunks/{location-9rqn6x4v.js → service-status-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{location-bd8755ek.js → service-status-bd8755ek.js} +0 -0
- /package/dist/chunks/{location-n26yr6pw.js → service-status-n26yr6pw.js} +0 -0
- /package/dist/chunks/{location-q187pxxd.js → service-status-q187pxxd.js} +0 -0
- /package/dist/chunks/{location-q4bn6dy8.js → service-status-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{location-smaf4a18.js → service-status-smaf4a18.js} +0 -0
- /package/dist/chunks/{location-xthc02cw.js → service-status-xthc02cw.js} +0 -0
- /package/dist/chunks/{location-yc7nft6q.js → service-status-yc7nft6q.js} +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// src/handlers/machine.ts
|
|
2
|
+
import { NodeHttpServerRequest } from "@effect/platform-node";
|
|
3
|
+
import { WebSocketServer } from "@effect/platform-node-shared/NodeWS";
|
|
4
|
+
import { Environment } from "@opencode/core/environment/index";
|
|
5
|
+
import { Flag } from "@opencode/core/flag";
|
|
6
|
+
import { Location } from "@opencode/core/location";
|
|
7
|
+
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
8
|
+
import { Frames } from "@opencode/core/machine/frames";
|
|
9
|
+
import { Join } from "@opencode/core/machine/join";
|
|
10
|
+
import { Link } from "@opencode/core/machine/link";
|
|
11
|
+
import { Machines } from "@opencode/core/machine/machines";
|
|
12
|
+
import { AbsolutePath } from "@opencode/core/schema";
|
|
13
|
+
import { ConflictError, ForbiddenError, InvalidRequestError, MachineNotFoundError } from "@opencode/protocol/errors";
|
|
14
|
+
import { isWebSocketUpgrade } from "@opencode/protocol/groups/machine";
|
|
15
|
+
import { Global } from "@opencode/util/global";
|
|
16
|
+
import { Context, Effect, Latch, Option, Scope, Semaphore } from "effect";
|
|
17
|
+
import { HttpMiddleware, HttpServerResponse } from "effect/http";
|
|
18
|
+
import { HttpApiSchema } from "effect/http-api";
|
|
19
|
+
import { Socket } from "effect/socket";
|
|
20
|
+
import { IncomingMessage } from "node:http";
|
|
21
|
+
var MAX_HANDSHAKES = 32;
|
|
22
|
+
var MAX_FRAME = 65535;
|
|
23
|
+
var MIN_FRAME = 16;
|
|
24
|
+
var MAX_WAITING = Frames.MAX_MESSAGE;
|
|
25
|
+
var STALL = "60 seconds";
|
|
26
|
+
var PING = "30 seconds";
|
|
27
|
+
var CLOSING = "5 seconds";
|
|
28
|
+
var STOPPING = "1 second";
|
|
29
|
+
var CLOSE = 1008;
|
|
30
|
+
var Watch2 = Context.Reference("@opencode/MachineLink/Watch", {
|
|
31
|
+
defaultValue: () => () => {}
|
|
32
|
+
});
|
|
33
|
+
var machinesEnabled2 = Effect.gen(function* () {
|
|
34
|
+
const global = yield* Global.Service;
|
|
35
|
+
const locations = yield* LocationServiceMap.Service;
|
|
36
|
+
return Flag.enabled("machines").pipe(Effect.provide(locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }))), Effect.orElseSucceed(() => false));
|
|
37
|
+
});
|
|
38
|
+
var drop = (socket) => {
|
|
39
|
+
socket.close(CLOSE);
|
|
40
|
+
socket.terminate();
|
|
41
|
+
};
|
|
42
|
+
var upgrade2 = (sockets, request) => Effect.acquireRelease(Effect.callback((resume) => {
|
|
43
|
+
const refused = () => resume(Effect.fail(new Link.Closed));
|
|
44
|
+
if (request.socket.destroyed)
|
|
45
|
+
return refused();
|
|
46
|
+
request.socket.once("close", refused);
|
|
47
|
+
sockets.handleUpgrade(request, request.socket, Buffer.alloc(0), (socket) => {
|
|
48
|
+
request.socket.off("close", refused);
|
|
49
|
+
socket.on("message", (data) => {
|
|
50
|
+
if ([data].flat().reduce((bytes, part) => bytes + part.byteLength, 0) < MIN_FRAME)
|
|
51
|
+
drop(socket);
|
|
52
|
+
});
|
|
53
|
+
resume(Effect.succeed(socket));
|
|
54
|
+
});
|
|
55
|
+
}), (socket) => Effect.gen(function* () {
|
|
56
|
+
const gone = Effect.callback((resume) => {
|
|
57
|
+
if (socket.readyState === socket.CLOSED)
|
|
58
|
+
return resume(Effect.void);
|
|
59
|
+
socket.once("close", () => resume(Effect.void));
|
|
60
|
+
});
|
|
61
|
+
socket.close(CLOSE);
|
|
62
|
+
if (Option.isNone(yield* Effect.timeoutOption(gone, CLOSING)))
|
|
63
|
+
socket.terminate();
|
|
64
|
+
}));
|
|
65
|
+
var carrier2 = (reader, transport) => {
|
|
66
|
+
const waiting = [];
|
|
67
|
+
return {
|
|
68
|
+
send: (message) => Effect.gen(function* () {
|
|
69
|
+
const taken = Latch.makeUnsafe();
|
|
70
|
+
transport.send(message, () => taken.openUnsafe());
|
|
71
|
+
while (true) {
|
|
72
|
+
const held = transport.bufferedAmount;
|
|
73
|
+
if (Option.isSome(yield* Effect.timeoutOption(taken.await, STALL)))
|
|
74
|
+
return;
|
|
75
|
+
if (transport.bufferedAmount >= held)
|
|
76
|
+
return transport.terminate();
|
|
77
|
+
}
|
|
78
|
+
}),
|
|
79
|
+
receive: Effect.gen(function* () {
|
|
80
|
+
if (waiting.length === 0) {
|
|
81
|
+
const read = yield* reader.pull;
|
|
82
|
+
if (read.reduce((bytes, message) => bytes + message.length, 0) > MAX_WAITING)
|
|
83
|
+
return yield* new Link.Closed;
|
|
84
|
+
waiting.push(...read);
|
|
85
|
+
}
|
|
86
|
+
const message = waiting.shift();
|
|
87
|
+
if (message === undefined || typeof message === "string")
|
|
88
|
+
return yield* new Link.Closed;
|
|
89
|
+
return message;
|
|
90
|
+
}).pipe(Effect.mapError(() => new Link.Closed))
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
var keepalive2 = (transport) => Effect.gen(function* () {
|
|
94
|
+
const interval = { heard: true, paused: false };
|
|
95
|
+
const heard = () => {
|
|
96
|
+
interval.heard = true;
|
|
97
|
+
};
|
|
98
|
+
const events = ["pong", "ping", "message"];
|
|
99
|
+
events.forEach((event) => transport.on(event, heard));
|
|
100
|
+
yield* Effect.addFinalizer(() => Effect.sync(() => events.forEach((event) => transport.off(event, heard))));
|
|
101
|
+
while (interval.heard || interval.paused || transport.isPaused) {
|
|
102
|
+
interval.heard = false;
|
|
103
|
+
interval.paused = transport.isPaused;
|
|
104
|
+
transport.ping();
|
|
105
|
+
yield* Effect.sleep(PING);
|
|
106
|
+
}
|
|
107
|
+
transport.terminate();
|
|
108
|
+
}).pipe(Effect.scoped);
|
|
109
|
+
var makeMachineLink2 = Effect.gen(function* () {
|
|
110
|
+
const enabled = yield* machinesEnabled2;
|
|
111
|
+
const services = yield* Effect.context();
|
|
112
|
+
const handshakes = Semaphore.makeUnsafe(MAX_HANDSHAKES);
|
|
113
|
+
const scope = yield* Effect.scope;
|
|
114
|
+
const watch = yield* Watch2;
|
|
115
|
+
const server = yield* Effect.cached(Effect.acquireRelease(Effect.sync(() => {
|
|
116
|
+
const sockets = new WebSocketServer({ noServer: true, maxPayload: MAX_FRAME });
|
|
117
|
+
watch(sockets);
|
|
118
|
+
return sockets;
|
|
119
|
+
}), (sockets) => Effect.gen(function* () {
|
|
120
|
+
sockets.clients.forEach((socket) => socket.close(CLOSE));
|
|
121
|
+
const empty = Effect.callback((resume) => sockets.close(() => resume(Effect.void)));
|
|
122
|
+
if (Option.isNone(yield* Effect.timeoutOption(empty, STOPPING)))
|
|
123
|
+
sockets.clients.forEach((socket) => socket.terminate());
|
|
124
|
+
})).pipe(Scope.provide(scope)));
|
|
125
|
+
return Effect.fn("MachineLink.serve")(function* (request) {
|
|
126
|
+
const incoming = NodeHttpServerRequest.toIncomingMessage(request);
|
|
127
|
+
if (!(incoming instanceof IncomingMessage) || !isWebSocketUpgrade(request) || Option.isNone(yield* Effect.option(request.upgrade)) || !(yield* enabled))
|
|
128
|
+
return HttpServerResponse.empty({ status: 404 });
|
|
129
|
+
return yield* Effect.gen(function* () {
|
|
130
|
+
const sockets = yield* server;
|
|
131
|
+
const admitted = yield* handshakes.withPermitsIfAvailable(1)(Effect.gen(function* () {
|
|
132
|
+
const transport = yield* upgrade2(sockets, incoming);
|
|
133
|
+
yield* HttpMiddleware.withLoggerDisabled(Effect.void);
|
|
134
|
+
const socket = yield* Socket.fromWebSocket(Effect.succeed(transport));
|
|
135
|
+
const link = yield* Link.serve(carrier2(yield* socket.reader, transport)).pipe(Effect.onError(() => Effect.sync(() => drop(transport))));
|
|
136
|
+
return { transport, link };
|
|
137
|
+
}));
|
|
138
|
+
if (Option.isNone(admitted))
|
|
139
|
+
return HttpServerResponse.empty({ status: 503 });
|
|
140
|
+
yield* Effect.forkScoped(keepalive2(admitted.value.transport));
|
|
141
|
+
const machines = yield* Machines.Service;
|
|
142
|
+
yield* machines.connect(admitted.value.link.machine, admitted.value.link.connection);
|
|
143
|
+
return HttpServerResponse.empty();
|
|
144
|
+
}).pipe(Effect.scoped, Effect.orElseSucceed(() => HttpServerResponse.empty()), Effect.provide(services));
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
var makeMachine2 = Effect.gen(function* () {
|
|
148
|
+
const enabled = yield* machinesEnabled2;
|
|
149
|
+
const machines = yield* Machines.Service;
|
|
150
|
+
const requireEnabled = Effect.gen(function* () {
|
|
151
|
+
if (yield* enabled)
|
|
152
|
+
return;
|
|
153
|
+
return yield* new ForbiddenError({ message: "Machines are disabled; enable experimental.machines" });
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
list: Effect.fn("MachineHandler.list")(function* () {
|
|
157
|
+
yield* requireEnabled;
|
|
158
|
+
return { data: yield* machines.list() };
|
|
159
|
+
}),
|
|
160
|
+
add: Effect.fn("MachineHandler.add")(function* (payload) {
|
|
161
|
+
yield* requireEnabled;
|
|
162
|
+
const id = yield* machines.add(payload.name).pipe(Effect.catchTag("Machines.AlreadyExists", (error) => Effect.succeed(error.machine)), Effect.catchTag("Machines.InvalidName", (error) => Effect.fail(new InvalidRequestError({ message: error.message, kind: "invalid_name", field: "name" }))));
|
|
163
|
+
const join = yield* machines.invite(id, { reach: payload.reach, replace: payload.replace }).pipe(Effect.catchTags({
|
|
164
|
+
"Machines.AlreadyPaired": (error) => Effect.fail(new ConflictError({ message: error.message, resource: error.machine })),
|
|
165
|
+
"Machines.NotFound": (error) => Effect.fail(new MachineNotFoundError({ machine: error.machine, message: error.message })),
|
|
166
|
+
"Identity.InvalidKey": (error) => Effect.die(error)
|
|
167
|
+
}));
|
|
168
|
+
const decoded = Option.getOrUndefined(Join.decode(join));
|
|
169
|
+
if (!decoded)
|
|
170
|
+
return yield* Effect.die(new Error("Server produced an unreadable join string"));
|
|
171
|
+
return { data: { name: id, join, expires: decoded.expires } };
|
|
172
|
+
}),
|
|
173
|
+
remove: Effect.fn("MachineHandler.remove")(function* (name) {
|
|
174
|
+
yield* requireEnabled;
|
|
175
|
+
yield* machines.remove(Environment.ID.make(name));
|
|
176
|
+
return HttpApiSchema.NoContent.make();
|
|
177
|
+
})
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
export { Watch2, machinesEnabled2, upgrade2, carrier2, keepalive2, makeMachineLink2, makeMachine2 };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
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: () =>
|
|
9
|
+
make: () => make3
|
|
10
10
|
});
|
|
11
11
|
import { Effect, Ref } from "effect";
|
|
12
|
-
var
|
|
12
|
+
var make3 = 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 make2 = Effect.fnUntraced(function* (options = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { make3, exports_service_status };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/websearch.ts
|
|
9
9
|
import { WebSearch } from "@opencode/core/websearch";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
download2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-t32e1bbt.js";
|
|
4
4
|
import {
|
|
5
5
|
parse2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8sb6qqpn.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/blob.ts
|
|
9
9
|
import { BlobStore } from "@opencode/core/blob-store";
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
locationErrors2,
|
|
3
3
|
response2,
|
|
4
4
|
requestRef2
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./service-status-ywn523ee.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./service-status-8pn9ceqg.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./service-status-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2,
|
|
15
15
|
holdLocation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./service-status-q187pxxd.js";
|
|
17
17
|
|
|
18
18
|
// src/handlers/mcp.ts
|
|
19
19
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-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: () => Service2,
|
|
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 Service2 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(Service2, Effect.gen(function* () {
|
|
21
21
|
const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
|
|
22
|
-
return
|
|
22
|
+
return Service2.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(Service4, Effect.gen(function* () {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
}));
|
|
33
|
-
var node2 = makeGlobalNode({ service:
|
|
33
|
+
var node2 = makeGlobalNode({ service: Service2, layer, deps: [] });
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { Service2, node2, exports_pairing };
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
missingMessage2,
|
|
4
4
|
failedMessageDecode2,
|
|
5
5
|
failedSnapshot2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-smaf4a18.js";
|
|
7
7
|
import {
|
|
8
8
|
locationErrors2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./service-status-ywn523ee.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./service-status-8pn9ceqg.js";
|
|
13
13
|
import {
|
|
14
14
|
wantsMediaRefs2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./service-status-xthc02cw.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/session.ts
|
|
18
18
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAllowedRequestOrigin2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-9rqn6x4v.js";
|
|
7
7
|
|
|
8
8
|
// src/request-site.ts
|
|
9
9
|
var exports_request_site = {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/usage.ts
|
|
9
9
|
import { UsageLimits } from "@opencode/core/usage-limits";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/agent.ts
|
|
9
9
|
import { Agent } from "@opencode/core/agent";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
authorized2,
|
|
5
5
|
verifySession2,
|
|
6
6
|
sessionCookieName2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./service-status-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))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/plugin.ts
|
|
9
9
|
import { Plugin } from "@opencode/core/plugin";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/event-feed.ts
|
|
6
6
|
var exports_event_feed = {};
|
|
7
7
|
__export(exports_event_feed, {
|
|
8
8
|
EncodingError: () => EncodingError2,
|
|
9
9
|
EventFeed: () => exports_event_feed,
|
|
10
|
-
Service: () =>
|
|
10
|
+
Service: () => Service4,
|
|
11
11
|
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
12
|
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
13
|
frame: () => frame2,
|
|
14
|
-
layer: () =>
|
|
14
|
+
layer: () => layer3,
|
|
15
15
|
make: () => make4
|
|
16
16
|
});
|
|
17
17
|
import { Bus } from "@opencode/core/bus";
|
|
@@ -30,7 +30,7 @@ class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
|
|
|
30
30
|
}) {
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class Service4 extends Context.Service()("@opencode/server/EventFeed") {
|
|
34
34
|
}
|
|
35
35
|
function frame2(event) {
|
|
36
36
|
return `data: ${JSON.stringify(event)}
|
|
@@ -72,13 +72,13 @@ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
|
72
72
|
});
|
|
73
73
|
const unsubscribe = yield* observe(publish);
|
|
74
74
|
yield* Effect.addFinalizer(() => unsubscribe);
|
|
75
|
-
return
|
|
75
|
+
return Service4.of({
|
|
76
76
|
subscribe: (types) => Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.set(queue, types?.length ? new Set(types) : undefined)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
var
|
|
79
|
+
var layer3 = Layer.effect(Service4, Effect.gen(function* () {
|
|
80
80
|
const bus = yield* Bus.Service;
|
|
81
81
|
return yield* make4(bus.listen);
|
|
82
82
|
}));
|
|
83
83
|
|
|
84
|
-
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2,
|
|
84
|
+
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make4, layer3, exports_event_feed };
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-8pn9ceqg.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./service-status-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
makeArtifact2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./service-status-7qpea5x7.js";
|
|
11
11
|
import {
|
|
12
12
|
makeBlobGet2
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./service-status-g23ffrnz.js";
|
|
14
14
|
import {
|
|
15
15
|
makeAutomation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./service-status-9cd3a4b8.js";
|
|
17
17
|
import {
|
|
18
18
|
makeJob2
|
|
19
|
-
} from "./
|
|
19
|
+
} from "./service-status-7ydfwv45.js";
|
|
20
|
+
import {
|
|
21
|
+
makeMachineLink2,
|
|
22
|
+
makeMachine2
|
|
23
|
+
} from "./service-status-dea17tr1.js";
|
|
20
24
|
import {
|
|
21
25
|
makeMediaGet2
|
|
22
|
-
} from "./
|
|
26
|
+
} from "./service-status-djr0jy89.js";
|
|
23
27
|
import {
|
|
24
28
|
runPtySocket2
|
|
25
|
-
} from "./
|
|
29
|
+
} from "./service-status-q187pxxd.js";
|
|
26
30
|
|
|
27
31
|
// src/handlers/persistent-pty.ts
|
|
28
32
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
@@ -51,7 +55,9 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
|
|
|
51
55
|
const mediaGet = yield* makeMediaGet2;
|
|
52
56
|
const blobGet = yield* makeBlobGet2;
|
|
53
57
|
const automation = yield* makeAutomation2;
|
|
54
|
-
|
|
58
|
+
const machine = yield* makeMachine2;
|
|
59
|
+
const machineLink = yield* makeMachineLink2;
|
|
60
|
+
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("machine.list", () => machine.list()).handle("machine.add", (ctx) => machine.add(ctx.payload)).handle("machine.remove", (ctx) => machine.remove(ctx.params.name)).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
61
|
return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
|
|
56
62
|
})).handle("persistentPty.list", Effect.fn(function* (ctx) {
|
|
57
63
|
return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/generate.ts
|
|
9
9
|
import { Flag } from "@opencode/core/flag";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
import {
|
|
8
8
|
download2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./service-status-t32e1bbt.js";
|
|
10
10
|
import {
|
|
11
11
|
parse2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./service-status-8sb6qqpn.js";
|
|
13
13
|
|
|
14
14
|
// src/handlers/fs.ts
|
|
15
15
|
import { FileSystem } from "@opencode/core/filesystem";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/shell.ts
|
|
9
9
|
import { Shell } from "@opencode/core/shell";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/voice.ts
|
|
9
9
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./service-status-ywn523ee.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./service-status-8pn9ceqg.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/reference.ts
|
|
9
9
|
import { Reference } from "@opencode/core/reference";
|