@opencode/server 2.0.15 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +9 -0
- package/dist/api.js +5 -5
- package/dist/auth.d.ts +4 -0
- package/dist/auth.js +10 -2
- package/dist/chunks/{location-00nn3k4b.js → handlers-140y8w7p.js} +2 -2
- package/dist/chunks/{location-rcg4y18n.js → handlers-26ta7ngt.js} +2 -2
- package/dist/chunks/{location-drtkgc0f.js → handlers-2ek8eabn.js} +6 -6
- package/dist/chunks/{location-99sfd1j8.js → handlers-2sy3c7de.js} +7 -7
- package/dist/chunks/{location-gdvmrvey.js → handlers-367ngss7.js} +2 -2
- package/dist/chunks/{location-3kzx88w9.js → handlers-3kzx88w9.js} +1 -1
- package/dist/chunks/{location-04xw3v55.js → handlers-44xy5pnk.js} +1 -1
- package/dist/chunks/{location-ysabas57.js → handlers-5bwq5cz2.js} +2 -2
- package/dist/chunks/{location-5rwqcaw2.js → handlers-5rwqcaw2.js} +1 -1
- package/dist/chunks/{location-xsrtpxyd.js → handlers-5w24ch67.js} +4 -4
- package/dist/chunks/{location-6gkz39ey.js → handlers-6gkz39ey.js} +1 -1
- package/dist/chunks/{location-qnwpcgp7.js → handlers-6qwktr1g.js} +1 -1
- package/dist/chunks/{location-br99j6q1.js → handlers-7eckj7zq.js} +2 -2
- package/dist/chunks/{location-hjnxtxmk.js → handlers-96s6m0w3.js} +2 -2
- package/dist/chunks/handlers-anm12x33.js +66 -0
- package/dist/chunks/{location-254zvkj6.js → handlers-b1rdg9nf.js} +2 -2
- package/dist/chunks/{location-5kep8qnm.js → handlers-bhrnjhj4.js} +7 -7
- package/dist/chunks/{location-7rzt3wm8.js → handlers-bmqkn4ah.js} +1 -1
- package/dist/chunks/{location-j2pfq4q6.js → handlers-bt9tc5rb.js} +1 -1
- package/dist/chunks/{location-ceh2h0m9.js → handlers-ctscy0f5.js} +2 -2
- package/dist/chunks/{location-6nvan4e0.js → handlers-ees77nh9.js} +2 -2
- package/dist/chunks/{location-d4bshj6j.js → handlers-em4bkx9t.js} +4 -4
- package/dist/chunks/{location-syqhk5a3.js → handlers-f05bgvye.js} +33 -33
- package/dist/chunks/{location-bjrwanme.js → handlers-f8rap8f6.js} +1 -1
- package/dist/chunks/{location-m6wvgbfq.js → handlers-gtkdacvk.js} +28 -7
- package/dist/chunks/{location-pnqq1zxv.js → handlers-haswyr8z.js} +2 -2
- package/dist/chunks/{location-q0ycym90.js → handlers-hp5sxeae.js} +2 -2
- package/dist/chunks/{location-19c9ysa1.js → handlers-hr75rahr.js} +2 -2
- package/dist/chunks/handlers-j0xcyacv.js +53 -0
- package/dist/chunks/{location-s4aja1df.js → handlers-mzr9gftb.js} +7 -7
- package/dist/chunks/{location-a6yp8301.js → handlers-np19kmxx.js} +2 -2
- package/dist/chunks/{location-r7e9r02j.js → handlers-pme11y2y.js} +2 -2
- package/dist/chunks/{location-zp2jm6dt.js → handlers-qj9kjxn3.js} +1 -1
- package/dist/chunks/{location-4vn5bvkr.js → handlers-rjqbhscq.js} +1 -1
- package/dist/chunks/{location-mwnk46cf.js → handlers-s0padj6k.js} +3 -3
- package/dist/chunks/{location-arj41x43.js → handlers-t88f2hhf.js} +3 -3
- package/dist/chunks/{location-b0b71rwa.js → handlers-v1emgcvb.js} +2 -2
- package/dist/chunks/{location-z5shrcz9.js → handlers-v573ws0d.js} +3 -3
- package/dist/chunks/{location-amg15650.js → handlers-vdkg476e.js} +17 -13
- package/dist/chunks/{location-0d9kah4z.js → handlers-wv5twc2g.js} +8 -8
- package/dist/chunks/{location-8bajbwjh.js → handlers-wz0qz28j.js} +2 -2
- package/dist/chunks/{location-req22b70.js → handlers-x5ncpjy3.js} +1 -1
- package/dist/chunks/handlers-x6486bry.js +35 -0
- package/dist/chunks/{location-4g0fa6m0.js → handlers-zpz5afwq.js} +2 -2
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +49 -48
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +6 -6
- 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 +6 -6
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/location.js +6 -6
- package/dist/handlers/mcp.js +6 -6
- package/dist/handlers/message.js +6 -6
- 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.js +8 -8
- 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 +9 -9
- package/dist/handlers/reference.js +6 -6
- package/dist/handlers/rpc.js +6 -6
- package/dist/handlers/server.d.ts +3 -1
- package/dist/handlers/server.js +9 -7
- package/dist/handlers/session-error.js +1 -1
- package/dist/handlers/session.js +6 -6
- package/dist/handlers/shell.js +6 -6
- package/dist/handlers/skill.js +6 -6
- package/dist/handlers/vcs.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 +43 -41
- package/dist/location.js +2 -2
- package/dist/middleware/authorization.d.ts +2 -1
- package/dist/middleware/authorization.js +5 -3
- 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.d.ts +13 -0
- package/dist/pairing.js +10 -0
- package/dist/process.js +56 -59
- package/dist/pty-environment.js +7 -7
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +3 -2
- package/dist/routes.js +46 -45
- package/dist/server-info.js +5 -5
- package/dist/service-status.js +3 -3
- package/dist/workerd.js +50 -49
- package/package.json +8 -8
- package/dist/chunks/location-4cf3x1kw.js +0 -21
- package/dist/chunks/location-zyv89x5n.js +0 -30
- /package/dist/chunks/{location-9rqn6x4v.js → handlers-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{location-hezj1jdf.js → handlers-hezj1jdf.js} +0 -0
- /package/dist/chunks/{location-q4bn6dy8.js → handlers-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{location-smaf4a18.js → handlers-smaf4a18.js} +0 -0
- /package/dist/chunks/{location-t8yzmczr.js → handlers-t8yzmczr.js} +0 -0
- /package/dist/chunks/{location-yc7nft6q.js → handlers-yc7nft6q.js} +0 -0
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GenerateHandler2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-rjqbhscq.js";
|
|
4
4
|
import {
|
|
5
5
|
MessageHandler2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-26ta7ngt.js";
|
|
7
7
|
import {
|
|
8
8
|
ModelHandler2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./handlers-b1rdg9nf.js";
|
|
10
10
|
import {
|
|
11
11
|
ProviderHandler2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./handlers-haswyr8z.js";
|
|
13
13
|
import {
|
|
14
14
|
SessionHandler2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./handlers-367ngss7.js";
|
|
16
16
|
import {
|
|
17
17
|
PermissionHandler2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./handlers-t88f2hhf.js";
|
|
19
19
|
import {
|
|
20
20
|
FileSystemHandler2
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./handlers-96s6m0w3.js";
|
|
22
22
|
import {
|
|
23
23
|
FormHandler2
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./handlers-ees77nh9.js";
|
|
25
25
|
import {
|
|
26
26
|
CommandHandler2
|
|
27
|
-
} from "./
|
|
27
|
+
} from "./handlers-pme11y2y.js";
|
|
28
28
|
import {
|
|
29
29
|
SkillHandler2
|
|
30
|
-
} from "./
|
|
30
|
+
} from "./handlers-hp5sxeae.js";
|
|
31
31
|
import {
|
|
32
32
|
RpcHandler2
|
|
33
|
-
} from "./
|
|
33
|
+
} from "./handlers-f8rap8f6.js";
|
|
34
34
|
import {
|
|
35
|
-
|
|
36
|
-
} from "./
|
|
35
|
+
layer2
|
|
36
|
+
} from "./handlers-2sy3c7de.js";
|
|
37
37
|
import {
|
|
38
38
|
EventHandler2
|
|
39
|
-
} from "./
|
|
39
|
+
} from "./handlers-em4bkx9t.js";
|
|
40
40
|
import {
|
|
41
41
|
AgentHandler2
|
|
42
|
-
} from "./
|
|
42
|
+
} from "./handlers-ctscy0f5.js";
|
|
43
43
|
import {
|
|
44
44
|
PluginHandler2
|
|
45
|
-
} from "./
|
|
45
|
+
} from "./handlers-hr75rahr.js";
|
|
46
46
|
import {
|
|
47
47
|
ServerHandler2
|
|
48
|
-
} from "./
|
|
48
|
+
} from "./handlers-j0xcyacv.js";
|
|
49
49
|
import {
|
|
50
50
|
DebugHandler2
|
|
51
|
-
} from "./
|
|
51
|
+
} from "./handlers-140y8w7p.js";
|
|
52
52
|
import {
|
|
53
53
|
PtyHandler2
|
|
54
|
-
} from "./
|
|
54
|
+
} from "./handlers-bhrnjhj4.js";
|
|
55
55
|
import {
|
|
56
56
|
PersistentPtyHandler2
|
|
57
|
-
} from "./
|
|
57
|
+
} from "./handlers-s0padj6k.js";
|
|
58
58
|
import {
|
|
59
59
|
ShellHandler2
|
|
60
|
-
} from "./
|
|
60
|
+
} from "./handlers-7eckj7zq.js";
|
|
61
61
|
import {
|
|
62
62
|
ReferenceHandler2
|
|
63
|
-
} from "./
|
|
63
|
+
} from "./handlers-5bwq5cz2.js";
|
|
64
64
|
import {
|
|
65
65
|
LocationHandler2
|
|
66
|
-
} from "./
|
|
66
|
+
} from "./handlers-x5ncpjy3.js";
|
|
67
67
|
import {
|
|
68
68
|
IntegrationHandler2
|
|
69
|
-
} from "./
|
|
69
|
+
} from "./handlers-np19kmxx.js";
|
|
70
70
|
import {
|
|
71
71
|
WebSearchHandler2
|
|
72
|
-
} from "./
|
|
72
|
+
} from "./handlers-v1emgcvb.js";
|
|
73
73
|
import {
|
|
74
74
|
McpHandler2
|
|
75
|
-
} from "./
|
|
75
|
+
} from "./handlers-wz0qz28j.js";
|
|
76
76
|
import {
|
|
77
77
|
CredentialHandler2
|
|
78
|
-
} from "./
|
|
78
|
+
} from "./handlers-44xy5pnk.js";
|
|
79
79
|
import {
|
|
80
80
|
ProjectHandler2
|
|
81
|
-
} from "./
|
|
81
|
+
} from "./handlers-qj9kjxn3.js";
|
|
82
82
|
import {
|
|
83
83
|
WorktreeHandler2
|
|
84
|
-
} from "./
|
|
84
|
+
} from "./handlers-bt9tc5rb.js";
|
|
85
85
|
import {
|
|
86
86
|
VcsHandler2
|
|
87
|
-
} from "./
|
|
87
|
+
} from "./handlers-zpz5afwq.js";
|
|
88
88
|
import {
|
|
89
89
|
MigrationHandler2
|
|
90
|
-
} from "./
|
|
90
|
+
} from "./handlers-bmqkn4ah.js";
|
|
91
91
|
import {
|
|
92
92
|
ConfigHandler2
|
|
93
|
-
} from "./
|
|
93
|
+
} from "./handlers-6qwktr1g.js";
|
|
94
94
|
|
|
95
95
|
// src/handlers.ts
|
|
96
96
|
import { Layer } from "effect";
|
|
97
|
-
var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(
|
|
97
|
+
var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(layer2)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
|
|
98
98
|
|
|
99
99
|
export { handlers2 };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Config2,
|
|
3
3
|
required2,
|
|
4
|
-
authorized2
|
|
5
|
-
|
|
4
|
+
authorized2,
|
|
5
|
+
verifySession2,
|
|
6
|
+
sessionCookieName2
|
|
7
|
+
} from "./handlers-anm12x33.js";
|
|
6
8
|
|
|
7
9
|
// src/middleware/authorization.ts
|
|
8
10
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
@@ -10,6 +12,7 @@ import { Authorization } from "@opencode/protocol/middleware/authorization";
|
|
|
10
12
|
import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
|
|
11
13
|
import { hasPtyConnectTicketURL } from "@opencode/protocol/groups/pty";
|
|
12
14
|
import { hasPersistentPtyConnectTicketURL } from "@opencode/protocol/groups/persistent-pty";
|
|
15
|
+
import { isPairingConnectURL } from "@opencode/protocol/groups/server";
|
|
13
16
|
import { Effect, Encoding, Layer, Redacted } from "effect";
|
|
14
17
|
import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
15
18
|
var AUTH_TOKEN_QUERY = "auth_token";
|
|
@@ -38,8 +41,25 @@ function credentialFromRequest(request) {
|
|
|
38
41
|
return decodeCredential(match[1]);
|
|
39
42
|
return Effect.succeed(emptyCredential());
|
|
40
43
|
}
|
|
44
|
+
var UNAUTHORIZED_MESSAGE = "Authentication required";
|
|
45
|
+
function challengeRequest(request) {
|
|
46
|
+
const mode = request.headers["sec-fetch-mode"];
|
|
47
|
+
return mode === undefined || mode === "navigate";
|
|
48
|
+
}
|
|
49
|
+
function unauthorizedResponse2(request) {
|
|
50
|
+
return HttpServerResponse.jsonUnsafe({ _tag: "UnauthorizedError", message: UNAUTHORIZED_MESSAGE }, { status: 401, headers: challengeRequest(request) ? { "www-authenticate": WWW_AUTHENTICATE } : undefined });
|
|
51
|
+
}
|
|
41
52
|
function authorizedRequest2(request, config) {
|
|
42
|
-
return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config)));
|
|
53
|
+
return credentialFromRequest(request).pipe(Effect.map((credential) => authorized2(credential, config) || authorizedSessionCookie(request, config)));
|
|
54
|
+
}
|
|
55
|
+
function authorizedSessionCookie(request, config) {
|
|
56
|
+
const token = request.cookies[sessionCookieName2(request.headers.host)];
|
|
57
|
+
if (!token)
|
|
58
|
+
return false;
|
|
59
|
+
const origin = request.headers.origin;
|
|
60
|
+
if (origin !== undefined && URL.parse(origin)?.host !== request.headers.host)
|
|
61
|
+
return false;
|
|
62
|
+
return verifySession2(token, config);
|
|
43
63
|
}
|
|
44
64
|
var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
45
65
|
const config = yield* Config2;
|
|
@@ -48,13 +68,14 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
|
48
68
|
return Authorization.of((effect) => Effect.gen(function* () {
|
|
49
69
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
50
70
|
const url = new URL(request.url, "http://localhost");
|
|
51
|
-
if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url))
|
|
71
|
+
if (hasPtyConnectTicketURL(url) || hasPersistentPtyConnectTicketURL(url) || isPairingConnectURL(url))
|
|
52
72
|
return yield* effect;
|
|
53
73
|
if (yield* authorizedRequest2(request, config))
|
|
54
74
|
return yield* effect;
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
if (challengeRequest(request))
|
|
76
|
+
yield* HttpEffect.appendPreResponseHandler((_request, response) => Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)));
|
|
77
|
+
return yield* new UnauthorizedError({ message: UNAUTHORIZED_MESSAGE });
|
|
57
78
|
}));
|
|
58
79
|
}));
|
|
59
80
|
|
|
60
|
-
export { authorizedRequest2, authorizationLayer2, Authorization2 };
|
|
81
|
+
export { unauthorizedResponse2, authorizedRequest2, authorizationLayer2, Authorization2 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-v573ws0d.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/provider.ts
|
|
9
9
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Api2
|
|
3
|
+
} from "./handlers-v573ws0d.js";
|
|
4
|
+
import {
|
|
5
|
+
SESSION_TTL_SECONDS2,
|
|
6
|
+
Config2,
|
|
7
|
+
issueSession2,
|
|
8
|
+
sessionCookieName2
|
|
9
|
+
} from "./handlers-anm12x33.js";
|
|
10
|
+
import {
|
|
11
|
+
Service3
|
|
12
|
+
} from "./handlers-mzr9gftb.js";
|
|
13
|
+
import {
|
|
14
|
+
Service4
|
|
15
|
+
} from "./handlers-x6486bry.js";
|
|
16
|
+
|
|
17
|
+
// src/handlers/server.ts
|
|
18
|
+
import { Duration, Effect } from "effect";
|
|
19
|
+
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
20
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
21
|
+
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
22
|
+
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
23
|
+
const pairing = yield* Service4;
|
|
24
|
+
const auth = yield* Config2;
|
|
25
|
+
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
26
|
+
const info = yield* Service3;
|
|
27
|
+
return {
|
|
28
|
+
version: info.app.version ?? "unknown",
|
|
29
|
+
pid: process.pid ?? 0,
|
|
30
|
+
urls: info.urls(),
|
|
31
|
+
paths: info.paths
|
|
32
|
+
};
|
|
33
|
+
})).handle("server.pair", () => pairing.issue()).handle("server.connect", Effect.fn(function* (ctx) {
|
|
34
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
35
|
+
const browser = request.headers.accept?.includes("text/html") === true;
|
|
36
|
+
const token = (yield* pairing.consume(ctx.params.code)) ? issueSession2(auth) : undefined;
|
|
37
|
+
if (token === undefined) {
|
|
38
|
+
if (!browser)
|
|
39
|
+
return yield* new UnauthorizedError({ message: "Pairing link expired or already used" });
|
|
40
|
+
return HttpServerResponse.text("This pairing link expired or was already used. Run `opencode pair` to get a new one.", { status: 401 });
|
|
41
|
+
}
|
|
42
|
+
if (!browser)
|
|
43
|
+
return { token };
|
|
44
|
+
return HttpServerResponse.redirect("/").pipe(HttpServerResponse.setCookieUnsafe(sessionCookieName2(request.headers.host), token, {
|
|
45
|
+
path: "/",
|
|
46
|
+
httpOnly: true,
|
|
47
|
+
sameSite: "lax",
|
|
48
|
+
maxAge: Duration.seconds(SESSION_TTL_SECONDS2)
|
|
49
|
+
}));
|
|
50
|
+
}));
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
export { ServerHandler2 };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/server-info.ts
|
|
6
6
|
var exports_server_info = {};
|
|
7
7
|
__export(exports_server_info, {
|
|
8
8
|
ServerInfo: () => exports_server_info,
|
|
9
|
-
Service: () =>
|
|
9
|
+
Service: () => Service3,
|
|
10
10
|
connectionURLs: () => connectionURLs2,
|
|
11
|
-
layer: () =>
|
|
11
|
+
layer: () => layer3
|
|
12
12
|
});
|
|
13
13
|
import { Context, Layer } from "effect";
|
|
14
14
|
import { networkInterfaces } from "node:os";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class Service3 extends Context.Service()("@opencode/server/ServerInfo") {
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return Layer.succeed(
|
|
18
|
+
function layer3(urls, tmp, app = {}) {
|
|
19
|
+
return Layer.succeed(Service3, Service3.of({ urls, app, paths: { tmp } }));
|
|
20
20
|
}
|
|
21
21
|
function connectionURLs2(value, requestedHostname) {
|
|
22
22
|
const url = new URL(value);
|
|
@@ -33,4 +33,4 @@ function connectionURLs2(value, requestedHostname) {
|
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export {
|
|
36
|
+
export { Service3, layer3, connectionURLs2, exports_server_info };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-v573ws0d.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/integration.ts
|
|
9
9
|
import { Integration } from "@opencode/core/integration";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-v573ws0d.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/command.ts
|
|
9
9
|
import { Command } from "@opencode/core/command";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-v573ws0d.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./handlers-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
runPtySocket2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./handlers-hezj1jdf.js";
|
|
11
11
|
|
|
12
12
|
// src/handlers/persistent-pty.ts
|
|
13
13
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-smaf4a18.js";
|
|
4
4
|
import {
|
|
5
5
|
response2,
|
|
6
6
|
sessionInfo2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./handlers-6gkz39ey.js";
|
|
8
8
|
import {
|
|
9
9
|
Api2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./handlers-v573ws0d.js";
|
|
11
11
|
|
|
12
12
|
// src/handlers/permission.ts
|
|
13
13
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-v573ws0d.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/websearch.ts
|
|
9
9
|
import { WebSearch } from "@opencode/core/websearch";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationMiddleware2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
FormLocationMiddleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-5rwqcaw2.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionLocationMiddleware2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./handlers-3kzx88w9.js";
|
|
10
10
|
|
|
11
11
|
// src/api.ts
|
|
12
12
|
import { makeDefaultApi } from "@opencode/protocol/api";
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layer4
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-6gkz39ey.js";
|
|
4
4
|
import {
|
|
5
5
|
formLocationLayer2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./handlers-5rwqcaw2.js";
|
|
7
7
|
import {
|
|
8
8
|
sessionLocationLayer2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./handlers-3kzx88w9.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./handlers-v573ws0d.js";
|
|
13
13
|
import {
|
|
14
14
|
Config2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./handlers-anm12x33.js";
|
|
16
16
|
import {
|
|
17
17
|
CorsConfig2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./handlers-q4bn6dy8.js";
|
|
19
19
|
import {
|
|
20
|
-
|
|
21
|
-
} from "./
|
|
20
|
+
layer3
|
|
21
|
+
} from "./handlers-mzr9gftb.js";
|
|
22
22
|
import {
|
|
23
23
|
node2
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./handlers-x6486bry.js";
|
|
25
|
+
import {
|
|
26
|
+
node3
|
|
27
|
+
} from "./handlers-wv5twc2g.js";
|
|
25
28
|
import {
|
|
26
29
|
handlers2
|
|
27
|
-
} from "./
|
|
30
|
+
} from "./handlers-f05bgvye.js";
|
|
28
31
|
import {
|
|
29
32
|
authorizationLayer2
|
|
30
|
-
} from "./
|
|
33
|
+
} from "./handlers-gtkdacvk.js";
|
|
31
34
|
import {
|
|
32
35
|
schemaErrorLayer2
|
|
33
|
-
} from "./
|
|
36
|
+
} from "./handlers-t8yzmczr.js";
|
|
34
37
|
|
|
35
38
|
// src/routes.ts
|
|
36
39
|
import { Database } from "@opencode/core/database/database";
|
|
@@ -88,6 +91,7 @@ var applicationServiceNodes = [
|
|
|
88
91
|
PersistentPty.node,
|
|
89
92
|
Credential.node,
|
|
90
93
|
WellKnown.node,
|
|
94
|
+
node3,
|
|
91
95
|
node2,
|
|
92
96
|
LocationServiceMap.node,
|
|
93
97
|
LocationActivity.node,
|
|
@@ -140,7 +144,7 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
140
144
|
})) : build(overrides);
|
|
141
145
|
return serviceLayer.pipe(Layer.flatMap((context) => {
|
|
142
146
|
const services = Layer.succeedContext(context);
|
|
143
|
-
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)),
|
|
147
|
+
const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer3(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
|
|
144
148
|
const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer4), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer));
|
|
145
149
|
return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
|
|
146
150
|
}));
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./handlers-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/pty-environment.ts
|
|
6
6
|
var exports_pty_environment = {};
|
|
7
7
|
__export(exports_pty_environment, {
|
|
8
8
|
PtyEnvironment: () => exports_pty_environment,
|
|
9
|
-
Service: () =>
|
|
10
|
-
layer: () =>
|
|
11
|
-
node: () =>
|
|
9
|
+
Service: () => Service5,
|
|
10
|
+
layer: () => layer5,
|
|
11
|
+
node: () => node3
|
|
12
12
|
});
|
|
13
13
|
import { Context, Effect, Layer } from "effect";
|
|
14
14
|
import { makeGlobalNode } from "@opencode/util/effect/app-node";
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class Service5 extends Context.Service()("@opencode/ServerPtyEnvironment") {
|
|
17
17
|
}
|
|
18
|
-
var
|
|
18
|
+
var layer5 = Layer.succeed(Service5, Service5.of({
|
|
19
19
|
get: () => Effect.succeed({})
|
|
20
20
|
}));
|
|
21
|
-
var
|
|
21
|
+
var node3 = makeGlobalNode({ service: Service5, layer: layer5, deps: [] });
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { Service5, layer5, node3, exports_pty_environment };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./handlers-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/pairing.ts
|
|
6
|
+
var exports_pairing = {};
|
|
7
|
+
__export(exports_pairing, {
|
|
8
|
+
ServerPairing: () => exports_pairing,
|
|
9
|
+
Service: () => Service4,
|
|
10
|
+
node: () => node2
|
|
11
|
+
});
|
|
12
|
+
import { Cache, Context, Duration, Effect, Layer } from "effect";
|
|
13
|
+
import { makeGlobalNode } from "@opencode/util/effect/app-node";
|
|
14
|
+
import { randomBytes } from "node:crypto";
|
|
15
|
+
var TTL = Duration.minutes(5);
|
|
16
|
+
|
|
17
|
+
class Service4 extends Context.Service()("@opencode/ServerPairing") {
|
|
18
|
+
}
|
|
19
|
+
var noLookup = () => Effect.die(new Error("ServerPairing cache must be used via set/invalidateWhen, never get"));
|
|
20
|
+
var layer = Layer.effect(Service4, Effect.gen(function* () {
|
|
21
|
+
const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
|
|
22
|
+
return Service4.of({
|
|
23
|
+
issue: Effect.fn("ServerPairing.issue")(function* () {
|
|
24
|
+
const code = randomBytes(16).toString("base64url");
|
|
25
|
+
yield* Cache.set(cache, code, true);
|
|
26
|
+
return { code, expires_in: Duration.toSeconds(TTL) };
|
|
27
|
+
}),
|
|
28
|
+
consume: Effect.fn("ServerPairing.consume")(function* (code) {
|
|
29
|
+
return yield* Cache.invalidateWhen(cache, code, () => true);
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}));
|
|
33
|
+
var node2 = makeGlobalNode({ service: Service4, layer, deps: [] });
|
|
34
|
+
|
|
35
|
+
export { Service4, node2, exports_pairing };
|
package/dist/cors.js
CHANGED