@opencode/server 0.0.0-dev-21599 → 0.0.0-dev-21612
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-61g22bd8.js → event-feed-1e765wh0.js} +2 -2
- package/dist/chunks/{routes-scq1j2yg.js → event-feed-3d7qdbre.js} +1 -1
- package/dist/chunks/{routes-1ahadpvw.js → event-feed-4gnb9897.js} +1 -1
- package/dist/chunks/{routes-026wrard.js → event-feed-4nbah0zs.js} +3 -3
- package/dist/chunks/{routes-gqq6kfhc.js → event-feed-50bbk3b2.js} +3 -3
- package/dist/chunks/{routes-j66ekhc9.js → event-feed-547pgmmc.js} +2 -2
- package/dist/chunks/{routes-6v4wsps6.js → event-feed-7b9xm1qg.js} +3 -2
- package/dist/chunks/{routes-qbrxhger.js → event-feed-7xe5pzvy.js} +1 -1
- package/dist/chunks/{routes-vg7gkftg.js → event-feed-9r2awqr1.js} +2 -2
- package/dist/chunks/{routes-yet0vexm.js → event-feed-b3bmdkga.js} +1 -1
- package/dist/chunks/{routes-j7r8acj2.js → event-feed-c7jc25ee.js} +8 -8
- package/dist/chunks/{routes-hnty54ys.js → event-feed-c8a27nas.js} +10 -10
- package/dist/chunks/{routes-vkgak0vv.js → event-feed-cpp0zjdy.js} +2 -2
- package/dist/chunks/{routes-0q7s66m2.js → event-feed-e6e4kz0w.js} +4 -4
- package/dist/chunks/{routes-9h3s5d39.js → event-feed-emkxpff3.js} +3 -3
- package/dist/chunks/{routes-5bchp9s2.js → event-feed-fazm2c7b.js} +2 -2
- package/dist/chunks/{routes-aajxxgqb.js → event-feed-fysmzcya.js} +2 -2
- package/dist/chunks/event-feed-g3mfewdn.js +107 -0
- package/dist/chunks/{routes-y7p3rgqn.js → event-feed-g7sdbt1s.js} +2 -2
- package/dist/chunks/{routes-t7dxwnb0.js → event-feed-gq8jw616.js} +2 -2
- package/dist/chunks/{routes-nmcxqxxx.js → event-feed-gw6rc7x0.js} +2 -2
- package/dist/chunks/{routes-p4bw85h1.js → event-feed-hax29h09.js} +34 -34
- package/dist/chunks/{routes-zfjz2b4g.js → event-feed-hwqxzcvy.js} +1 -1
- package/dist/chunks/{routes-j4at0y5c.js → event-feed-j4at0y5c.js} +1 -1
- package/dist/chunks/{routes-g1bp01xw.js → event-feed-jd2d9483.js} +2 -2
- package/dist/chunks/{routes-4vaqgjp8.js → event-feed-jk5edc6h.js} +2 -2
- package/dist/chunks/{routes-sxc2jqq8.js → event-feed-m3zxp3ph.js} +3 -3
- package/dist/chunks/{routes-w9jcwh65.js → event-feed-mzs0n5xz.js} +7 -7
- package/dist/chunks/{routes-10jzh2zk.js → event-feed-nnsgc8by.js} +3 -3
- package/dist/chunks/{routes-rrf9gkkq.js → event-feed-qcfps8nc.js} +2 -2
- package/dist/chunks/{routes-t0tqzssv.js → event-feed-qfbp1fd5.js} +4 -4
- package/dist/chunks/{routes-e2cx9grb.js → event-feed-qx5ydgm0.js} +1 -1
- package/dist/chunks/{routes-j3626vk8.js → event-feed-rhdada90.js} +2 -2
- package/dist/chunks/{routes-2s3n8phw.js → event-feed-s0qm098c.js} +2 -2
- package/dist/chunks/{routes-dc18tjnc.js → event-feed-sc3gatcy.js} +3 -3
- package/dist/chunks/{routes-hxgz4x38.js → event-feed-t4c683g8.js} +2 -2
- package/dist/chunks/{routes-vg73xc24.js → event-feed-tp6qcw6t.js} +1 -1
- package/dist/chunks/{routes-ksvmmk2r.js → event-feed-w4e9jgda.js} +1 -1
- package/dist/chunks/{routes-g0g9ma1m.js → event-feed-wexwfee0.js} +2 -2
- package/dist/chunks/{routes-kr95sp16.js → event-feed-wq8rfg6g.js} +15 -15
- package/dist/chunks/{routes-b7rpzsrb.js → event-feed-ye9tw5gq.js} +4 -4
- package/dist/chunks/{routes-ntj59ngc.js → event-feed-z3akqjf6.js} +1 -1
- package/dist/chunks/{routes-7dtbad8d.js → event-feed-z3e7v67k.js} +7 -7
- package/dist/chunks/{routes-xt7xrv1r.js → event-feed-z6z134jc.js} +2 -2
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +7 -7
- package/dist/fetch.js +47 -47
- 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.d.ts +3 -1
- package/dist/handlers/mcp.js +8 -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 +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 +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/voice.js +6 -6
- package/dist/handlers/websearch.js +6 -6
- package/dist/handlers/worktree.js +6 -6
- package/dist/handlers.js +43 -43
- package/dist/location.js +4 -4
- package/dist/middleware/authorization.js +2 -2
- 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 +53 -52
- package/dist/request-tracing.js +1 -1
- package/dist/routes.js +46 -46
- package/dist/server-info.js +5 -5
- package/dist/service-status.js +3 -3
- package/dist/workerd.js +48 -48
- package/package.json +8 -8
- package/dist/chunks/routes-bvbs05c3.js +0 -40
- /package/dist/chunks/{routes-9rqn6x4v.js → event-feed-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{routes-erzfdgke.js → event-feed-erzfdgke.js} +0 -0
- /package/dist/chunks/{routes-h6rt5k9s.js → event-feed-h6rt5k9s.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-yc7nft6q.js → event-feed-yc7nft6q.js} +0 -0
package/dist/api.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import"./chunks/
|
|
5
|
-
import"./chunks/
|
|
6
|
-
import"./chunks/
|
|
7
|
-
import"./chunks/
|
|
3
|
+
} from "./chunks/event-feed-4nbah0zs.js";
|
|
4
|
+
import"./chunks/event-feed-4gnb9897.js";
|
|
5
|
+
import"./chunks/event-feed-b3bmdkga.js";
|
|
6
|
+
import"./chunks/event-feed-50bbk3b2.js";
|
|
7
|
+
import"./chunks/event-feed-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
10
10
|
};
|
package/dist/auth.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2,
|
|
3
3
|
failedMessageDecode2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./event-feed-smaf4a18.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./event-feed-4nbah0zs.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/message.ts
|
|
10
10
|
import { SessionMessage } from "@opencode/core/session/message";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationMiddleware2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
FormLocationMiddleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-4gnb9897.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionLocationMiddleware2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./event-feed-b3bmdkga.js";
|
|
10
10
|
|
|
11
11
|
// src/api.ts
|
|
12
12
|
import { makeDefaultApi } from "@opencode/protocol/api";
|
|
@@ -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";
|
|
@@ -59,7 +59,7 @@ function decode(input) {
|
|
|
59
59
|
return input;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
var
|
|
62
|
+
var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
63
63
|
const locations = yield* LocationServiceMap.Service;
|
|
64
64
|
return LocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
65
65
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
@@ -67,4 +67,4 @@ var layer3 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
|
67
67
|
}));
|
|
68
68
|
}));
|
|
69
69
|
|
|
70
|
-
export { LocationMiddleware2, locationErrors2, awaitPlugins2, response2, sessionInfo2, requestRef2,
|
|
70
|
+
export { LocationMiddleware2, locationErrors2, awaitPlugins2, response2, sessionInfo2, requestRef2, layer4 };
|
|
@@ -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";
|
|
@@ -12,6 +12,7 @@ import { Authorization } from "@opencode/protocol/middleware/authorization";
|
|
|
12
12
|
import { Authorization as Authorization2 } from "@opencode/protocol/middleware/authorization";
|
|
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
|
+
import { MCP_CLIENT_PATH } from "@opencode/protocol/groups/mcp";
|
|
15
16
|
import { PAIRING_CONNECT_PATH } from "@opencode/protocol/groups/server";
|
|
16
17
|
import { Effect, Layer, Redacted } from "effect";
|
|
17
18
|
import { Base64 } from "effect/encoding";
|
|
@@ -70,7 +71,7 @@ var authorizationLayer2 = Layer.effect(Authorization, Effect.gen(function* () {
|
|
|
70
71
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
71
72
|
const route = yield* HttpRouter.RouteContext;
|
|
72
73
|
const url = new URL(request.url, "http://localhost");
|
|
73
|
-
if ((route.route.path === PTY_CONNECT_PATH || route.route.path === PERSISTENT_PTY_CONNECT_PATH) && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY) || route.route.path === PAIRING_CONNECT_PATH)
|
|
74
|
+
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)
|
|
74
75
|
return yield* effect;
|
|
75
76
|
if (yield* authorizedRequest2(request, config))
|
|
76
77
|
return yield* effect;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./event-feed-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./event-feed-4nbah0zs.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/voice.ts
|
|
10
10
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-4nbah0zs.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
|
-
|
|
12
|
-
} from "./
|
|
11
|
+
Service2
|
|
12
|
+
} from "./event-feed-z3e7v67k.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 { Duration, Effect } from "effect";
|
|
@@ -21,10 +21,10 @@ import { HttpApiBuilder } from "effect/http-api";
|
|
|
21
21
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
22
22
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
23
23
|
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
24
|
-
const pairing = yield*
|
|
24
|
+
const pairing = yield* Service4;
|
|
25
25
|
const auth = yield* Config2;
|
|
26
26
|
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
27
|
-
const info = yield*
|
|
27
|
+
const info = yield* Service2;
|
|
28
28
|
return {
|
|
29
29
|
version: info.app.version ?? "unknown",
|
|
30
30
|
pid: process.pid ?? 0,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-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: () => Service3,
|
|
11
11
|
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
12
|
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
13
|
frame: () => frame2,
|
|
14
|
-
layer: () =>
|
|
15
|
-
make: () =>
|
|
14
|
+
layer: () => layer3,
|
|
15
|
+
make: () => make4
|
|
16
16
|
});
|
|
17
17
|
import { Bus } from "@opencode/core/bus";
|
|
18
18
|
import { Event } from "@opencode/schema/event";
|
|
@@ -30,14 +30,14 @@ class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
|
|
|
30
30
|
}) {
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class Service3 extends Context.Service()("@opencode/server/EventFeed") {
|
|
34
34
|
}
|
|
35
35
|
function frame2(event) {
|
|
36
36
|
return `data: ${JSON.stringify(event)}
|
|
37
37
|
|
|
38
38
|
`;
|
|
39
39
|
}
|
|
40
|
-
var
|
|
40
|
+
var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
41
41
|
const capacity = options?.capacity ?? SubscriberCapacity2;
|
|
42
42
|
const render = options?.encode ?? frame2;
|
|
43
43
|
const subscribers = new Set;
|
|
@@ -71,13 +71,13 @@ var make3 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
|
71
71
|
});
|
|
72
72
|
const unsubscribe = yield* observe(publish);
|
|
73
73
|
yield* Effect.addFinalizer(() => unsubscribe);
|
|
74
|
-
return
|
|
74
|
+
return Service3.of({
|
|
75
75
|
subscribe: Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.add(queue)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
var
|
|
78
|
+
var layer3 = Layer.effect(Service3, Effect.gen(function* () {
|
|
79
79
|
const bus = yield* Bus.Service;
|
|
80
|
-
return yield*
|
|
80
|
+
return yield* make4(bus.listen);
|
|
81
81
|
}));
|
|
82
82
|
|
|
83
|
-
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2,
|
|
83
|
+
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service3, frame2, make4, layer3, exports_event_feed };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./event-feed-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./event-feed-4nbah0zs.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/model.ts
|
|
10
10
|
import { Model } from "@opencode/core/model";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-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 make4 = Effect.fnUntraced(function* (options = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { make3, exports_service_status };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-smaf4a18.js";
|
|
4
4
|
import {
|
|
5
5
|
locationErrors2,
|
|
6
6
|
response2,
|
|
7
7
|
sessionInfo2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./event-feed-50bbk3b2.js";
|
|
9
9
|
import {
|
|
10
10
|
Api2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./event-feed-4nbah0zs.js";
|
|
12
12
|
|
|
13
13
|
// src/handlers/permission.ts
|
|
14
14
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-4nbah0zs.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/provider.ts
|
|
9
9
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-4nbah0zs.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/command.ts
|
|
9
9
|
import { Command } from "@opencode/core/command";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
locationErrors2,
|
|
3
|
+
response2,
|
|
4
|
+
requestRef2
|
|
5
|
+
} from "./event-feed-50bbk3b2.js";
|
|
6
|
+
import {
|
|
7
|
+
Api2
|
|
8
|
+
} from "./event-feed-4nbah0zs.js";
|
|
9
|
+
import {
|
|
10
|
+
CorsConfig2,
|
|
11
|
+
isAllowedRequestOrigin2
|
|
12
|
+
} from "./event-feed-q4bn6dy8.js";
|
|
13
|
+
import {
|
|
14
|
+
runPtySocket2
|
|
15
|
+
} from "./event-feed-h6rt5k9s.js";
|
|
16
|
+
|
|
17
|
+
// src/handlers/mcp.ts
|
|
18
|
+
import { Location } from "@opencode/core/location";
|
|
19
|
+
import { LocationServiceMap } from "@opencode/core/location-service-map";
|
|
20
|
+
import { Mcp } from "@opencode/core/mcp/index";
|
|
21
|
+
import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
22
|
+
import { ForbiddenError, McpServerNotFoundError } from "@opencode/protocol/errors";
|
|
23
|
+
import { PTY_CONNECT_TOKEN_HEADER, PTY_CONNECT_TOKEN_HEADER_VALUE } from "@opencode/protocol/groups/pty";
|
|
24
|
+
import { Effect, Queue } from "effect";
|
|
25
|
+
import { HttpServerResponse } from "effect/http";
|
|
26
|
+
import { HttpApiBuilder, HttpApiSchema } from "effect/http-api";
|
|
27
|
+
import { Socket } from "effect/socket";
|
|
28
|
+
var notFound = (effect) => effect.pipe(Effect.mapError((error) => new McpServerNotFoundError({ server: error.server, message: error.message })));
|
|
29
|
+
var McpHandler2 = HttpApiBuilder.group(Api2, "server.mcp", (handlers) => Effect.gen(function* () {
|
|
30
|
+
const locations = yield* LocationServiceMap.Service;
|
|
31
|
+
const cors = yield* CorsConfig2;
|
|
32
|
+
const tickets = yield* PtyTicket.Service;
|
|
33
|
+
return handlers.handle("mcp.list", Effect.fn(function* () {
|
|
34
|
+
const service = yield* Mcp.Service;
|
|
35
|
+
return yield* response2(service.servers());
|
|
36
|
+
})).handle("mcp.add", Effect.fn(function* (ctx) {
|
|
37
|
+
const service = yield* Mcp.Service;
|
|
38
|
+
yield* service.add(ctx.params.server, ctx.payload.config);
|
|
39
|
+
return HttpApiSchema.NoContent.make();
|
|
40
|
+
})).handle("mcp.remove", Effect.fn(function* (ctx) {
|
|
41
|
+
const service = yield* Mcp.Service;
|
|
42
|
+
yield* notFound(service.remove(ctx.params.server));
|
|
43
|
+
return HttpApiSchema.NoContent.make();
|
|
44
|
+
})).handle("mcp.connect", Effect.fn(function* (ctx) {
|
|
45
|
+
const service = yield* Mcp.Service;
|
|
46
|
+
yield* notFound(service.connect(ctx.params.server));
|
|
47
|
+
return HttpApiSchema.NoContent.make();
|
|
48
|
+
})).handle("mcp.disconnect", Effect.fn(function* (ctx) {
|
|
49
|
+
const service = yield* Mcp.Service;
|
|
50
|
+
yield* notFound(service.disconnect(ctx.params.server));
|
|
51
|
+
return HttpApiSchema.NoContent.make();
|
|
52
|
+
})).handle("mcp.resource.catalog", Effect.fn(function* () {
|
|
53
|
+
const service = yield* Mcp.Service;
|
|
54
|
+
return yield* response2(service.resourceCatalog());
|
|
55
|
+
})).handle("mcp.clientToken", Effect.fn(function* (ctx) {
|
|
56
|
+
if (ctx.headers[PTY_CONNECT_TOKEN_HEADER] !== PTY_CONNECT_TOKEN_HEADER_VALUE || !isAllowedRequestOrigin2(ctx.request.headers.origin, ctx.request.headers.host, cors))
|
|
57
|
+
return yield* new ForbiddenError({ message: "Invalid client MCP connect token request" });
|
|
58
|
+
const location = yield* Location.Service;
|
|
59
|
+
return yield* response2(tickets.issue({
|
|
60
|
+
mcpClient: ctx.query.name,
|
|
61
|
+
directory: location.directory,
|
|
62
|
+
workspaceID: location.workspaceID
|
|
63
|
+
}));
|
|
64
|
+
})).handleRaw("mcp.client", Effect.fn("McpHandler.client")(function* (ctx) {
|
|
65
|
+
if (!isAllowedRequestOrigin2(ctx.request.headers.origin, ctx.request.headers.host, cors))
|
|
66
|
+
return HttpServerResponse.empty({ status: 403 });
|
|
67
|
+
const name = ctx.query.name;
|
|
68
|
+
const ref = LocationServiceMap.canonical(requestRef2(ctx.request));
|
|
69
|
+
if (ctx.query.ticket && !(yield* tickets.consume({
|
|
70
|
+
ticket: ctx.query.ticket,
|
|
71
|
+
mcpClient: name,
|
|
72
|
+
directory: ref.directory,
|
|
73
|
+
workspaceID: ref.workspaceID
|
|
74
|
+
})))
|
|
75
|
+
return HttpServerResponse.empty({ status: 403 });
|
|
76
|
+
return yield* Effect.gen(function* () {
|
|
77
|
+
const mcp = yield* Mcp.Service;
|
|
78
|
+
const { McpSocketClient } = yield* Effect.promise(() => import("@opencode/core/mcp/socket-client"));
|
|
79
|
+
const socket = yield* Effect.orDie(ctx.request.upgrade);
|
|
80
|
+
const outbox = yield* Queue.unbounded();
|
|
81
|
+
const state = { attached: false, disconnected: false };
|
|
82
|
+
const transport = McpSocketClient.make({
|
|
83
|
+
send: (text) => Queue.offerUnsafe(outbox, text),
|
|
84
|
+
close: (code, reason) => {
|
|
85
|
+
if (state.attached)
|
|
86
|
+
Queue.offerUnsafe(outbox, new Socket.CloseEvent(code, reason));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const decoder = new TextDecoder;
|
|
90
|
+
yield* mcp.attach(name, transport).pipe(Effect.tap(() => Effect.sync(() => {
|
|
91
|
+
state.attached = true;
|
|
92
|
+
})), Effect.catch((error) => state.disconnected ? Effect.logInfo("client MCP disconnected during initialize", { name, error: error.message }) : Effect.logError("client MCP attach failed", { name, error: error.message }).pipe(Effect.andThen(Effect.sync(() => Queue.offerUnsafe(outbox, new Socket.CloseEvent(1011, "attach failed")))))), Effect.forkScoped);
|
|
93
|
+
yield* runPtySocket2({
|
|
94
|
+
socket,
|
|
95
|
+
outbox,
|
|
96
|
+
onMessage: (message) => Effect.sync(() => transport.deliver(typeof message === "string" ? message : decoder.decode(message))),
|
|
97
|
+
detach: () => {
|
|
98
|
+
state.disconnected = true;
|
|
99
|
+
transport.ended();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return HttpServerResponse.empty();
|
|
103
|
+
}).pipe(Effect.scoped, Effect.provide(locations.get(ref)), locationErrors2);
|
|
104
|
+
}));
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
export { McpHandler2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./event-feed-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./event-feed-4nbah0zs.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/generate.ts
|
|
10
10
|
import { Generate } from "@opencode/core/generate";
|
|
@@ -1,102 +1,102 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GenerateHandler2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./event-feed-gq8jw616.js";
|
|
4
4
|
import {
|
|
5
5
|
VoiceHandler2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./event-feed-9r2awqr1.js";
|
|
7
7
|
import {
|
|
8
8
|
MessageHandler2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./event-feed-1e765wh0.js";
|
|
10
10
|
import {
|
|
11
11
|
ModelHandler2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./event-feed-cpp0zjdy.js";
|
|
13
13
|
import {
|
|
14
14
|
ProviderHandler2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./event-feed-fazm2c7b.js";
|
|
16
16
|
import {
|
|
17
17
|
SessionHandler2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./event-feed-nnsgc8by.js";
|
|
19
19
|
import {
|
|
20
20
|
PermissionHandler2
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./event-feed-emkxpff3.js";
|
|
22
22
|
import {
|
|
23
23
|
FileSystemHandler2
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./event-feed-qcfps8nc.js";
|
|
25
25
|
import {
|
|
26
26
|
FormHandler2
|
|
27
|
-
} from "./
|
|
27
|
+
} from "./event-feed-s0qm098c.js";
|
|
28
28
|
import {
|
|
29
29
|
CommandHandler2
|
|
30
|
-
} from "./
|
|
30
|
+
} from "./event-feed-fysmzcya.js";
|
|
31
31
|
import {
|
|
32
32
|
SkillHandler2
|
|
33
|
-
} from "./
|
|
33
|
+
} from "./event-feed-547pgmmc.js";
|
|
34
34
|
import {
|
|
35
35
|
RpcHandler2
|
|
36
|
-
} from "./
|
|
36
|
+
} from "./event-feed-w4e9jgda.js";
|
|
37
37
|
import {
|
|
38
|
-
|
|
39
|
-
} from "./
|
|
38
|
+
layer3
|
|
39
|
+
} from "./event-feed-c8a27nas.js";
|
|
40
40
|
import {
|
|
41
41
|
EventHandler2
|
|
42
|
-
} from "./
|
|
42
|
+
} from "./event-feed-qfbp1fd5.js";
|
|
43
43
|
import {
|
|
44
44
|
AgentHandler2
|
|
45
|
-
} from "./
|
|
45
|
+
} from "./event-feed-g7sdbt1s.js";
|
|
46
46
|
import {
|
|
47
47
|
PluginHandler2
|
|
48
|
-
} from "./
|
|
48
|
+
} from "./event-feed-jd2d9483.js";
|
|
49
49
|
import {
|
|
50
50
|
ServerHandler2
|
|
51
|
-
} from "./
|
|
51
|
+
} from "./event-feed-c7jc25ee.js";
|
|
52
52
|
import {
|
|
53
53
|
DebugHandler2
|
|
54
|
-
} from "./
|
|
54
|
+
} from "./event-feed-rhdada90.js";
|
|
55
55
|
import {
|
|
56
56
|
PtyHandler2
|
|
57
|
-
} from "./
|
|
57
|
+
} from "./event-feed-ye9tw5gq.js";
|
|
58
58
|
import {
|
|
59
59
|
PersistentPtyHandler2
|
|
60
|
-
} from "./
|
|
60
|
+
} from "./event-feed-sc3gatcy.js";
|
|
61
61
|
import {
|
|
62
62
|
ShellHandler2
|
|
63
|
-
} from "./
|
|
63
|
+
} from "./event-feed-t4c683g8.js";
|
|
64
64
|
import {
|
|
65
65
|
ReferenceHandler2
|
|
66
|
-
} from "./
|
|
66
|
+
} from "./event-feed-z6z134jc.js";
|
|
67
67
|
import {
|
|
68
68
|
LocationHandler2
|
|
69
|
-
} from "./
|
|
69
|
+
} from "./event-feed-7xe5pzvy.js";
|
|
70
70
|
import {
|
|
71
71
|
IntegrationHandler2
|
|
72
|
-
} from "./
|
|
72
|
+
} from "./event-feed-jk5edc6h.js";
|
|
73
73
|
import {
|
|
74
74
|
WebSearchHandler2
|
|
75
|
-
} from "./
|
|
75
|
+
} from "./event-feed-wexwfee0.js";
|
|
76
76
|
import {
|
|
77
77
|
McpHandler2
|
|
78
|
-
} from "./
|
|
78
|
+
} from "./event-feed-g3mfewdn.js";
|
|
79
79
|
import {
|
|
80
80
|
CredentialHandler2
|
|
81
|
-
} from "./
|
|
81
|
+
} from "./event-feed-qx5ydgm0.js";
|
|
82
82
|
import {
|
|
83
83
|
ProjectHandler2
|
|
84
|
-
} from "./
|
|
84
|
+
} from "./event-feed-3d7qdbre.js";
|
|
85
85
|
import {
|
|
86
86
|
WorktreeHandler2
|
|
87
|
-
} from "./
|
|
87
|
+
} from "./event-feed-z3akqjf6.js";
|
|
88
88
|
import {
|
|
89
89
|
VcsHandler2
|
|
90
|
-
} from "./
|
|
90
|
+
} from "./event-feed-gw6rc7x0.js";
|
|
91
91
|
import {
|
|
92
92
|
MigrationHandler2
|
|
93
|
-
} from "./
|
|
93
|
+
} from "./event-feed-tp6qcw6t.js";
|
|
94
94
|
import {
|
|
95
95
|
ConfigHandler2
|
|
96
|
-
} from "./
|
|
96
|
+
} from "./event-feed-hwqxzcvy.js";
|
|
97
97
|
|
|
98
98
|
// src/handlers.ts
|
|
99
99
|
import { Layer } from "effect";
|
|
100
|
-
var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, VoiceHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(
|
|
100
|
+
var handlers2 = Layer.mergeAll(ServerHandler2, DebugHandler2, MigrationHandler2, LocationHandler2, AgentHandler2, PluginHandler2, SessionHandler2, MessageHandler2, ModelHandler2, GenerateHandler2, VoiceHandler2, ProviderHandler2, IntegrationHandler2, WebSearchHandler2, McpHandler2, CredentialHandler2, ProjectHandler2, FormHandler2, PermissionHandler2, FileSystemHandler2, CommandHandler2, SkillHandler2, RpcHandler2, EventHandler2.pipe(Layer.provide(layer3)), PtyHandler2, PersistentPtyHandler2, ShellHandler2, ReferenceHandler2, WorktreeHandler2, VcsHandler2, ConfigHandler2);
|
|
101
101
|
|
|
102
102
|
export { handlers2 };
|