@opencode/server 0.0.0-dev-19794 → 0.0.0-dev-19808
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 +10 -9
- package/dist/auth.js +12 -17
- package/dist/chunks/workerd-00nn3k4b.js +20 -0
- package/dist/chunks/workerd-04xw3v55.js +23 -0
- package/dist/chunks/workerd-19c9ysa1.js +61 -0
- package/dist/chunks/workerd-1c4qas2w.js +346 -0
- package/dist/chunks/workerd-254zvkj6.js +22 -0
- package/dist/chunks/workerd-2rvsests.js +99 -0
- package/dist/chunks/workerd-2sy3c7de.js +83 -0
- package/dist/chunks/workerd-3kzx88w9.js +26 -0
- package/dist/chunks/workerd-4g0fa6m0.js +32 -0
- package/dist/chunks/workerd-4vn5bvkr.js +25 -0
- package/dist/chunks/workerd-5rwqcaw2.js +33 -0
- package/dist/chunks/workerd-5w24ch67.js +23 -0
- package/dist/chunks/workerd-6gkz39ey.js +55 -0
- package/dist/chunks/workerd-6nvan4e0.js +17 -0
- package/dist/chunks/workerd-6ptwb1q1.js +149 -0
- package/dist/chunks/workerd-75c938bc.js +23 -0
- package/dist/chunks/workerd-7cfyat0f.js +37 -0
- package/dist/chunks/workerd-7rzt3wm8.js +13 -0
- package/dist/chunks/workerd-8bajbwjh.js +40 -0
- package/dist/chunks/workerd-9rqn6x4v.js +16 -0
- package/dist/chunks/workerd-a6yp8301.js +156 -0
- package/dist/chunks/workerd-arj41x43.js +77 -0
- package/dist/chunks/workerd-b0b71rwa.js +39 -0
- package/dist/chunks/workerd-bjrwanme.js +22 -0
- package/dist/chunks/workerd-bkqymx4n.js +26 -0
- package/dist/chunks/workerd-br99j6q1.js +35 -0
- package/dist/chunks/workerd-ceh2h0m9.js +25 -0
- package/dist/chunks/workerd-hezj1jdf.js +7 -0
- package/dist/chunks/workerd-hjnxtxmk.js +34 -0
- package/dist/chunks/workerd-j2pfq4q6.js +42 -0
- package/dist/chunks/workerd-m6wvgbfq.js +60 -0
- package/dist/chunks/workerd-mzr9gftb.js +36 -0
- package/dist/chunks/workerd-n0er2m55.js +163 -0
- package/dist/chunks/workerd-pnqq1zxv.js +29 -0
- package/dist/chunks/workerd-q0ycym90.js +13 -0
- package/dist/chunks/workerd-q4bn6dy8.js +39 -0
- package/dist/chunks/workerd-qnwpcgp7.js +22 -0
- package/dist/chunks/workerd-qzap92t7.js +139 -0
- package/dist/chunks/workerd-r7e9r02j.js +13 -0
- package/dist/chunks/workerd-rcg4y18n.js +59 -0
- package/dist/chunks/workerd-req22b70.js +22 -0
- package/dist/chunks/workerd-smaf4a18.js +28 -0
- package/dist/chunks/workerd-t8yzmczr.js +18 -0
- package/dist/chunks/workerd-x1haxfjx.js +21 -0
- package/dist/chunks/workerd-yc7nft6q.js +5 -0
- package/dist/chunks/workerd-ysabas57.js +13 -0
- package/dist/chunks/workerd-z5shrcz9.js +19 -0
- package/dist/chunks/workerd-zp2jm6dt.js +15 -0
- package/dist/chunks/workerd-zyv89x5n.js +30 -0
- package/dist/cors.js +10 -36
- package/dist/event-feed.js +20 -60
- package/dist/fetch.js +53 -11
- package/dist/handlers/agent.js +11 -17
- package/dist/handlers/command.js +11 -5
- package/dist/handlers/config.js +11 -16
- package/dist/handlers/credential.js +11 -14
- package/dist/handlers/debug.js +11 -11
- package/dist/handlers/event.js +12 -27
- package/dist/handlers/form.js +11 -9
- package/dist/handlers/fs.js +11 -22
- package/dist/handlers/generate.js +11 -15
- package/dist/handlers/integration.js +10 -142
- package/dist/handlers/location.js +11 -16
- package/dist/handlers/mcp.js +11 -31
- package/dist/handlers/message.js +10 -42
- package/dist/handlers/migration.js +11 -7
- package/dist/handlers/model.js +11 -14
- package/dist/handlers/permission.js +11 -57
- package/dist/handlers/persistent-pty.js +12 -135
- package/dist/handlers/plugin.js +11 -47
- package/dist/handlers/project.js +11 -9
- package/dist/handlers/provider.js +11 -20
- package/dist/handlers/pty-socket.js +6 -4
- package/dist/handlers/pty.js +13 -107
- package/dist/handlers/reference.js +11 -5
- package/dist/handlers/rpc.js +11 -15
- package/dist/handlers/server.js +12 -13
- package/dist/handlers/session-error.js +12 -26
- package/dist/handlers/session.js +10 -311
- package/dist/handlers/shell.js +11 -25
- package/dist/handlers/skill.js +11 -5
- package/dist/handlers/vcs.js +11 -19
- package/dist/handlers/websearch.js +11 -31
- package/dist/handlers/worktree.js +11 -37
- package/dist/handlers.js +46 -33
- package/dist/location.js +15 -49
- package/dist/middleware/authorization.js +11 -49
- package/dist/middleware/form-location.js +10 -25
- package/dist/middleware/schema-error.js +8 -15
- package/dist/middleware/session-location.js +10 -19
- package/dist/options.js +5 -1
- package/dist/process.js +108 -28
- package/dist/pty-environment.js +12 -9
- package/dist/request-tracing.js +6 -2
- package/dist/routes.js +52 -118
- package/dist/server-info.js +12 -22
- package/dist/service-status.js +8 -11
- package/dist/workerd.js +80 -12
- package/package.json +8 -8
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./workerd-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/event-feed.ts
|
|
6
|
+
var exports_event_feed = {};
|
|
7
|
+
__export(exports_event_feed, {
|
|
8
|
+
EncodingError: () => EncodingError2,
|
|
9
|
+
EventFeed: () => exports_event_feed,
|
|
10
|
+
Service: () => Service2,
|
|
11
|
+
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
|
+
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
|
+
frame: () => frame2,
|
|
14
|
+
layer: () => layer2,
|
|
15
|
+
make: () => make4
|
|
16
|
+
});
|
|
17
|
+
import { Bus } from "@opencode/core/bus";
|
|
18
|
+
import { Event } from "@opencode/schema/event";
|
|
19
|
+
import { isOpenCodeEvent } from "@opencode/protocol/groups/event";
|
|
20
|
+
import { Cause, Context, Effect, Layer, Queue, Schema, Stream } from "effect";
|
|
21
|
+
var SubscriberCapacity2 = 4096;
|
|
22
|
+
|
|
23
|
+
class SubscriberOverflowError2 extends Schema.TaggedError()("EventFeed.SubscriberOverflow", { capacity: Schema.Int }) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
|
|
27
|
+
eventID: Event.ID,
|
|
28
|
+
eventType: Schema.String,
|
|
29
|
+
cause: Schema.Defect()
|
|
30
|
+
}) {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Service2 extends Context.Service()("@opencode/server/EventFeed") {
|
|
34
|
+
}
|
|
35
|
+
function frame2(event) {
|
|
36
|
+
return `data: ${JSON.stringify(event)}
|
|
37
|
+
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
41
|
+
const capacity = options?.capacity ?? SubscriberCapacity2;
|
|
42
|
+
const render = options?.encode ?? frame2;
|
|
43
|
+
const subscribers = new Set;
|
|
44
|
+
const fail = (error) => Effect.sync(() => {
|
|
45
|
+
const current = Array.from(subscribers);
|
|
46
|
+
subscribers.clear();
|
|
47
|
+
for (const subscriber of current)
|
|
48
|
+
Queue.failCauseUnsafe(subscriber, Cause.fail(error));
|
|
49
|
+
});
|
|
50
|
+
const publish = Effect.fnUntraced(function* (event) {
|
|
51
|
+
if (!isOpenCodeEvent(event))
|
|
52
|
+
return;
|
|
53
|
+
if (subscribers.size === 0)
|
|
54
|
+
return;
|
|
55
|
+
const encoded = yield* Effect.try({
|
|
56
|
+
try: () => render(event),
|
|
57
|
+
catch: (cause) => new EncodingError2({ eventID: event.id, eventType: event.type, cause })
|
|
58
|
+
}).pipe(Effect.catch((error) => Effect.logError("Failed to encode public event", {
|
|
59
|
+
eventID: error.eventID,
|
|
60
|
+
eventType: error.eventType,
|
|
61
|
+
cause: error.cause
|
|
62
|
+
}).pipe(Effect.andThen(fail(error)), Effect.as(undefined))));
|
|
63
|
+
if (encoded === undefined)
|
|
64
|
+
return;
|
|
65
|
+
for (const subscriber of subscribers) {
|
|
66
|
+
if (Queue.offerUnsafe(subscriber, encoded))
|
|
67
|
+
continue;
|
|
68
|
+
subscribers.delete(subscriber);
|
|
69
|
+
Queue.failCauseUnsafe(subscriber, Cause.fail(new SubscriberOverflowError2({ capacity })));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const unsubscribe = yield* observe(publish);
|
|
73
|
+
yield* Effect.addFinalizer(() => unsubscribe);
|
|
74
|
+
return Service2.of({
|
|
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
|
+
});
|
|
77
|
+
});
|
|
78
|
+
var layer2 = Layer.effect(Service2, Effect.gen(function* () {
|
|
79
|
+
const bus = yield* Bus.Service;
|
|
80
|
+
return yield* make4(bus.listen);
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service2, frame2, make4, layer2, exports_event_feed };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sessionInfo2
|
|
3
|
+
} from "./workerd-6gkz39ey.js";
|
|
4
|
+
|
|
5
|
+
// src/middleware/session-location.ts
|
|
6
|
+
import { Instance } from "@opencode/core/instance/service";
|
|
7
|
+
import { Session } from "@opencode/core/session";
|
|
8
|
+
import { Effect, Layer } from "effect";
|
|
9
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
10
|
+
import { HttpApiMiddleware } from "effect/unstable/httpapi";
|
|
11
|
+
import { InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors";
|
|
12
|
+
class SessionLocationMiddleware2 extends HttpApiMiddleware.Service()("@opencode/HttpApiSessionLocation", {
|
|
13
|
+
error: [InvalidRequestError, SessionNotFoundError]
|
|
14
|
+
}) {
|
|
15
|
+
}
|
|
16
|
+
var sessionLocationLayer2 = Layer.effect(SessionLocationMiddleware2, Effect.gen(function* () {
|
|
17
|
+
const sessions = yield* Session.Service;
|
|
18
|
+
const instances = yield* Instance.Service;
|
|
19
|
+
return SessionLocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
20
|
+
const route = yield* HttpRouter.RouteContext;
|
|
21
|
+
const session = yield* sessionInfo2(sessions, route.params.sessionID);
|
|
22
|
+
return yield* effect.pipe(instances.provide(session));
|
|
23
|
+
}));
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
export { SessionLocationMiddleware2, sessionLocationLayer2 };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
response2
|
|
3
|
+
} from "./workerd-6gkz39ey.js";
|
|
4
|
+
import {
|
|
5
|
+
Api2
|
|
6
|
+
} from "./workerd-z5shrcz9.js";
|
|
7
|
+
|
|
8
|
+
// src/handlers/vcs.ts
|
|
9
|
+
import { Vcs } from "@opencode/core/vcs";
|
|
10
|
+
import { ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
13
|
+
var VcsHandler2 = HttpApiBuilder.group(Api2, "server.vcs", (handlers) => Effect.gen(function* () {
|
|
14
|
+
return handlers.handle("vcs.get", () => response2(Effect.gen(function* () {
|
|
15
|
+
const vcs = yield* Vcs.Service;
|
|
16
|
+
return yield* vcs.info();
|
|
17
|
+
}))).handle("vcs.base", () => response2(Effect.gen(function* () {
|
|
18
|
+
const vcs = yield* Vcs.Service;
|
|
19
|
+
return yield* vcs.base().pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
|
|
20
|
+
}))).handle("vcs.status", () => response2(Effect.gen(function* () {
|
|
21
|
+
const vcs = yield* Vcs.Service;
|
|
22
|
+
return yield* vcs.status();
|
|
23
|
+
}))).handle("vcs.branch.list", (ctx) => response2(Effect.gen(function* () {
|
|
24
|
+
const vcs = yield* Vcs.Service;
|
|
25
|
+
return yield* vcs.branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) });
|
|
26
|
+
}))).handle("vcs.diff", (ctx) => response2(Effect.gen(function* () {
|
|
27
|
+
const vcs = yield* Vcs.Service;
|
|
28
|
+
return yield* vcs.diff(ctx.query.mode, { context: ctx.query.context, base: ctx.query.base }).pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
|
|
29
|
+
})));
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
export { VcsHandler2 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Api2
|
|
3
|
+
} from "./workerd-z5shrcz9.js";
|
|
4
|
+
|
|
5
|
+
// src/handlers/generate.ts
|
|
6
|
+
import { Generate } from "@opencode/core/generate";
|
|
7
|
+
import { Location } from "@opencode/core/location";
|
|
8
|
+
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
9
|
+
import { AbsolutePath } from "@opencode/core/schema";
|
|
10
|
+
import { InvalidRequestError, ServiceUnavailableError } from "@opencode/protocol/errors";
|
|
11
|
+
import { Global } from "@opencode/util/global";
|
|
12
|
+
import { Effect } from "effect";
|
|
13
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
14
|
+
var GenerateHandler2 = HttpApiBuilder.group(Api2, "server.generate", (handlers) => Effect.gen(function* () {
|
|
15
|
+
const global = yield* Global.Service;
|
|
16
|
+
const locations = yield* LocationServiceMap.Service;
|
|
17
|
+
const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }));
|
|
18
|
+
return handlers.handle("generate.text", Effect.fn("server.generate.text")(function* (request) {
|
|
19
|
+
const generate = yield* Generate.Service;
|
|
20
|
+
const text = yield* generate.text(request.payload).pipe(Effect.mapError((error) => error._tag === "Generate.ModelSelectionError" ? new InvalidRequestError({ message: error.message }) : new ServiceUnavailableError({ message: error.message, service: error.service })));
|
|
21
|
+
return { data: { text } };
|
|
22
|
+
}, Effect.provide(services)));
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
export { GenerateHandler2 };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sessionInfo2,
|
|
3
|
+
requestRef2
|
|
4
|
+
} from "./workerd-6gkz39ey.js";
|
|
5
|
+
|
|
6
|
+
// src/middleware/form-location.ts
|
|
7
|
+
import { Instance } from "@opencode/core/instance/service";
|
|
8
|
+
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
9
|
+
import { Session } from "@opencode/core/session";
|
|
10
|
+
import { InvalidRequestError, SessionNotFoundError } from "@opencode/protocol/errors";
|
|
11
|
+
import { Effect, Layer } from "effect";
|
|
12
|
+
import { HttpRouter, HttpServerRequest } from "effect/unstable/http";
|
|
13
|
+
import { HttpApiMiddleware } from "effect/unstable/httpapi";
|
|
14
|
+
class FormLocationMiddleware2 extends HttpApiMiddleware.Service()("@opencode/HttpApiFormLocation", {
|
|
15
|
+
error: [InvalidRequestError, SessionNotFoundError]
|
|
16
|
+
}) {
|
|
17
|
+
}
|
|
18
|
+
var formLocationLayer2 = Layer.effect(FormLocationMiddleware2, Effect.gen(function* () {
|
|
19
|
+
const sessions = yield* Session.Service;
|
|
20
|
+
const instances = yield* Instance.Service;
|
|
21
|
+
const locations = yield* LocationServiceMap.Service;
|
|
22
|
+
return FormLocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
23
|
+
const route = yield* HttpRouter.RouteContext;
|
|
24
|
+
if (route.params.sessionID === "global") {
|
|
25
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
26
|
+
return yield* effect.pipe(Effect.provide(locations.get(requestRef2(request))));
|
|
27
|
+
}
|
|
28
|
+
const session = yield* sessionInfo2(sessions, route.params.sessionID);
|
|
29
|
+
return yield* effect.pipe(instances.provide(session));
|
|
30
|
+
}));
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
export { FormLocationMiddleware2, formLocationLayer2 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./workerd-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/service-status.ts
|
|
6
|
+
var exports_service_status = {};
|
|
7
|
+
__export(exports_service_status, {
|
|
8
|
+
Status: () => exports_service_status,
|
|
9
|
+
make: () => make3
|
|
10
|
+
});
|
|
11
|
+
import { Effect, Ref } from "effect";
|
|
12
|
+
var make3 = Effect.fnUntraced(function* (options = {}) {
|
|
13
|
+
const current = yield* Ref.make(options.initial ?? { type: "starting" });
|
|
14
|
+
const beginStopping = Ref.update(current, (status) => status.type === "stopping" ? status : { type: "stopping" });
|
|
15
|
+
return {
|
|
16
|
+
current: Ref.get(current),
|
|
17
|
+
ready: Ref.update(current, (status) => status.type === "starting" ? { type: "ready" } : status),
|
|
18
|
+
fail: Ref.update(current, (status) => status.type === "starting" ? { type: "failed" } : status),
|
|
19
|
+
beginStopping
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export { make3, exports_service_status };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
missingSession2
|
|
3
|
+
} from "./workerd-smaf4a18.js";
|
|
4
|
+
|
|
5
|
+
// src/location.ts
|
|
6
|
+
import { Location } from "@opencode/core/location";
|
|
7
|
+
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
8
|
+
import { AbsolutePath } from "@opencode/core/schema";
|
|
9
|
+
import { Session } from "@opencode/core/session";
|
|
10
|
+
import { InvalidRequestError } from "@opencode/protocol/errors";
|
|
11
|
+
import { Effect, Layer, Schema } from "effect";
|
|
12
|
+
import { HttpServerRequest } from "effect/unstable/http";
|
|
13
|
+
import { HttpApiMiddleware } from "effect/unstable/httpapi";
|
|
14
|
+
class LocationMiddleware2 extends HttpApiMiddleware.Service()("@opencode/HttpApiLocation") {
|
|
15
|
+
}
|
|
16
|
+
function response2(data) {
|
|
17
|
+
return Effect.gen(function* () {
|
|
18
|
+
const location = yield* Location.Service;
|
|
19
|
+
return {
|
|
20
|
+
location: new Location.Info({
|
|
21
|
+
directory: location.directory,
|
|
22
|
+
project: location.project
|
|
23
|
+
}),
|
|
24
|
+
data: yield* data
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
var decodeSessionID = Schema.decodeUnknownEffect(Session.ID);
|
|
29
|
+
var sessionInfo2 = Effect.fnUntraced(function* (sessions, sessionID) {
|
|
30
|
+
const id = yield* decodeSessionID(sessionID).pipe(Effect.mapError(() => new InvalidRequestError({ message: "Invalid session ID", field: "sessionID" })));
|
|
31
|
+
return yield* sessions.get(id).pipe(Effect.catchTag("Session.NotFoundError", missingSession2));
|
|
32
|
+
});
|
|
33
|
+
function requestRef2(request) {
|
|
34
|
+
const query = new URL(request.url, "http://localhost").searchParams;
|
|
35
|
+
const directory = query.get("location[directory]") || (request.headers["x-opencode-directory"] ? decode(request.headers["x-opencode-directory"]) : process.cwd());
|
|
36
|
+
return Location.Ref.make({
|
|
37
|
+
directory: AbsolutePath.make(directory)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function decode(input) {
|
|
41
|
+
try {
|
|
42
|
+
return decodeURIComponent(input);
|
|
43
|
+
} catch {
|
|
44
|
+
return input;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
|
|
48
|
+
const locations = yield* LocationServiceMap.Service;
|
|
49
|
+
return LocationMiddleware2.of((effect) => Effect.gen(function* () {
|
|
50
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
51
|
+
return yield* effect.pipe(Effect.provide(locations.get(requestRef2(request))));
|
|
52
|
+
}));
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
export { LocationMiddleware2, response2, sessionInfo2, requestRef2, layer4 };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
response2
|
|
3
|
+
} from "./workerd-6gkz39ey.js";
|
|
4
|
+
import {
|
|
5
|
+
Api2
|
|
6
|
+
} from "./workerd-z5shrcz9.js";
|
|
7
|
+
|
|
8
|
+
// src/handlers/form.ts
|
|
9
|
+
import { Form } from "@opencode/core/form";
|
|
10
|
+
import { Effect } from "effect";
|
|
11
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
12
|
+
var FormHandler2 = HttpApiBuilder.group(Api2, "server.form", (handlers) => handlers.handle("form.list", Effect.fn(function* () {
|
|
13
|
+
const form = yield* Form.Service;
|
|
14
|
+
return yield* response2(form.list());
|
|
15
|
+
})));
|
|
16
|
+
|
|
17
|
+
export { FormHandler2 };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
layer4
|
|
3
|
+
} from "./workerd-6gkz39ey.js";
|
|
4
|
+
import {
|
|
5
|
+
formLocationLayer2
|
|
6
|
+
} from "./workerd-5rwqcaw2.js";
|
|
7
|
+
import {
|
|
8
|
+
sessionLocationLayer2
|
|
9
|
+
} from "./workerd-3kzx88w9.js";
|
|
10
|
+
import {
|
|
11
|
+
Api2
|
|
12
|
+
} from "./workerd-z5shrcz9.js";
|
|
13
|
+
import {
|
|
14
|
+
Config2
|
|
15
|
+
} from "./workerd-zyv89x5n.js";
|
|
16
|
+
import {
|
|
17
|
+
CorsConfig2
|
|
18
|
+
} from "./workerd-q4bn6dy8.js";
|
|
19
|
+
import {
|
|
20
|
+
layer3
|
|
21
|
+
} from "./workerd-mzr9gftb.js";
|
|
22
|
+
import {
|
|
23
|
+
node2
|
|
24
|
+
} from "./workerd-75c938bc.js";
|
|
25
|
+
import {
|
|
26
|
+
handlers2
|
|
27
|
+
} from "./workerd-2rvsests.js";
|
|
28
|
+
import {
|
|
29
|
+
authorizationLayer2
|
|
30
|
+
} from "./workerd-m6wvgbfq.js";
|
|
31
|
+
import {
|
|
32
|
+
schemaErrorLayer2
|
|
33
|
+
} from "./workerd-t8yzmczr.js";
|
|
34
|
+
|
|
35
|
+
// src/routes.ts
|
|
36
|
+
import { Database } from "@opencode/core/database/database";
|
|
37
|
+
import { V1Migration } from "@opencode/core/database/v1-migration";
|
|
38
|
+
import { App } from "@opencode/core/app";
|
|
39
|
+
import { LayerNode } from "@opencode/util/effect/layer-node";
|
|
40
|
+
import { httpClient } from "@opencode/util/effect/app-node-platform";
|
|
41
|
+
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder";
|
|
42
|
+
import { Bus } from "@opencode/core/bus";
|
|
43
|
+
import { EventLogger } from "@opencode/core/event-logger";
|
|
44
|
+
import { FileSystemSearch } from "@opencode/core/filesystem/search";
|
|
45
|
+
import { Credential } from "@opencode/core/credential";
|
|
46
|
+
import { Config } from "@opencode/core/config";
|
|
47
|
+
import { PermissionSaved } from "@opencode/core/permission/saved";
|
|
48
|
+
import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
49
|
+
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
50
|
+
import { Project } from "@opencode/core/project";
|
|
51
|
+
import { Worktree } from "@opencode/core/worktree";
|
|
52
|
+
import { Session } from "@opencode/core/session";
|
|
53
|
+
import { Instance } from "@opencode/core/instance/service";
|
|
54
|
+
import { SessionTransfer } from "@opencode/core/session/transfer";
|
|
55
|
+
import { ShellSelect } from "@opencode/core/shell/select";
|
|
56
|
+
import { Job } from "@opencode/core/job";
|
|
57
|
+
import { Mcp } from "@opencode/core/mcp/index";
|
|
58
|
+
import { Global } from "@opencode/util/global";
|
|
59
|
+
import { InstructionDiscovery } from "@opencode/core/instruction-discovery";
|
|
60
|
+
import { LocationServiceMap } from "@opencode/core/location-service-map";
|
|
61
|
+
import { LocationActivity } from "@opencode/core/location-activity";
|
|
62
|
+
import { ModelsDev } from "@opencode/core/models-dev";
|
|
63
|
+
import { SessionRestart } from "@opencode/core/session/execution/restart";
|
|
64
|
+
import { PluginUpdate } from "@opencode/core/plugin/update";
|
|
65
|
+
import { SdkPlugins } from "@opencode/core/plugin/sdk";
|
|
66
|
+
import { WellKnown } from "@opencode/core/wellknown";
|
|
67
|
+
import { Workspace } from "@opencode/core/workspace";
|
|
68
|
+
import { Watcher } from "@opencode/core/filesystem/watcher";
|
|
69
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
70
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
71
|
+
import { Context, Effect, Layer, Option } from "effect";
|
|
72
|
+
var applicationServiceNodes = [
|
|
73
|
+
Global.node,
|
|
74
|
+
Database.node,
|
|
75
|
+
Bus.node,
|
|
76
|
+
EventLogger.node,
|
|
77
|
+
httpClient,
|
|
78
|
+
Job.node,
|
|
79
|
+
Project.node,
|
|
80
|
+
Worktree.node,
|
|
81
|
+
Session.node,
|
|
82
|
+
Instance.node,
|
|
83
|
+
SessionTransfer.node,
|
|
84
|
+
SdkPlugins.node,
|
|
85
|
+
PluginUpdate.node,
|
|
86
|
+
PermissionSaved.node,
|
|
87
|
+
PtyTicket.node,
|
|
88
|
+
PersistentPty.node,
|
|
89
|
+
Credential.node,
|
|
90
|
+
WellKnown.node,
|
|
91
|
+
node2,
|
|
92
|
+
LocationServiceMap.node,
|
|
93
|
+
LocationActivity.node,
|
|
94
|
+
SessionRestart.node,
|
|
95
|
+
Workspace.node
|
|
96
|
+
];
|
|
97
|
+
var applicationServices = LayerNode.group(applicationServiceNodes);
|
|
98
|
+
function createRoutes2(options = {}, serviceURLs = () => [], overrides = []) {
|
|
99
|
+
return makeRoutes(options.password ? Config2.configLayer({ password: Option.some(options.password) }) : Config2.layer, options, serviceURLs, overrides);
|
|
100
|
+
}
|
|
101
|
+
function createEmbeddedRoutes2(options = {}, overrides = [], instances) {
|
|
102
|
+
return makeRoutes(Config2.configLayer({ password: Option.none() }), options, () => [], overrides, instances);
|
|
103
|
+
}
|
|
104
|
+
function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
105
|
+
const standard = [
|
|
106
|
+
Database.node.replace(Database.configured(options.database)),
|
|
107
|
+
PersistentPty.node.replace(PersistentPty.configured(options.pty)),
|
|
108
|
+
Bus.node.replace(Bus.configured({ persist: options.events?.persist })),
|
|
109
|
+
App.node.replace(App.configured(options.app)),
|
|
110
|
+
ModelsDev.node.replace(ModelsDev.configured(options.models)),
|
|
111
|
+
Watcher.node.replace(Watcher.configured({ enabled: options.fs?.filewatcher })),
|
|
112
|
+
FileSystemSearch.node.replace(FileSystemSearch.configured({ fff: options.fs?.fff })),
|
|
113
|
+
Global.node.replace(Global.layerWith(options.config?.directory ? { config: options.config.directory } : {})),
|
|
114
|
+
Config.node.replace(Config.configured({
|
|
115
|
+
project: options.config?.project,
|
|
116
|
+
file: options.config?.file,
|
|
117
|
+
content: options.config?.content
|
|
118
|
+
})),
|
|
119
|
+
InstructionDiscovery.node.replace(InstructionDiscovery.configured({ project: options.config?.project })),
|
|
120
|
+
ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
|
|
121
|
+
Mcp.node.replace(Mcp.configured({
|
|
122
|
+
clientInfo: {
|
|
123
|
+
name: options.app?.name ?? "opencode",
|
|
124
|
+
version: options.app?.version ?? "unknown"
|
|
125
|
+
}
|
|
126
|
+
}))
|
|
127
|
+
];
|
|
128
|
+
const build = (overrides) => {
|
|
129
|
+
const replacements = [
|
|
130
|
+
...standard,
|
|
131
|
+
...instances ? [Instance.node.replace(instances(() => replacements))] : [],
|
|
132
|
+
...overrides
|
|
133
|
+
];
|
|
134
|
+
return AppNodeBuilder.build(applicationServices, replacements);
|
|
135
|
+
};
|
|
136
|
+
const serviceLayer = options.simulation ? Layer.unwrap(Effect.gen(function* () {
|
|
137
|
+
const { simulationReplacements } = yield* Effect.promise(() => import("@opencode/simulation/backend"));
|
|
138
|
+
const simulation = yield* simulationReplacements({ version: App.make(options.app).version });
|
|
139
|
+
return build([...overrides, ...simulation]);
|
|
140
|
+
})) : build(overrides);
|
|
141
|
+
return serviceLayer.pipe(Layer.flatMap((context) => {
|
|
142
|
+
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)), layer3(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
|
|
144
|
+
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
|
+
return Layer.merge(api, V1Migration.layer.pipe(Layer.provide(services)));
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export { createRoutes2, createEmbeddedRoutes2 };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./workerd-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/pty-environment.ts
|
|
6
|
+
var exports_pty_environment = {};
|
|
7
|
+
__export(exports_pty_environment, {
|
|
8
|
+
PtyEnvironment: () => exports_pty_environment,
|
|
9
|
+
Service: () => Service4,
|
|
10
|
+
layer: () => layer5,
|
|
11
|
+
node: () => node2
|
|
12
|
+
});
|
|
13
|
+
import { Context, Effect, Layer } from "effect";
|
|
14
|
+
import { makeGlobalNode } from "@opencode/util/effect/app-node";
|
|
15
|
+
|
|
16
|
+
class Service4 extends Context.Service()("@opencode/ServerPtyEnvironment") {
|
|
17
|
+
}
|
|
18
|
+
var layer5 = Layer.succeed(Service4, Service4.of({
|
|
19
|
+
get: () => Effect.succeed({})
|
|
20
|
+
}));
|
|
21
|
+
var node2 = makeGlobalNode({ service: Service4, layer: layer5, deps: [] });
|
|
22
|
+
|
|
23
|
+
export { Service4, layer5, node2, exports_pty_environment };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Api2
|
|
3
|
+
} from "./workerd-z5shrcz9.js";
|
|
4
|
+
import {
|
|
5
|
+
Service2,
|
|
6
|
+
frame2
|
|
7
|
+
} from "./workerd-2sy3c7de.js";
|
|
8
|
+
|
|
9
|
+
// src/handlers/event.ts
|
|
10
|
+
import { Event } from "@opencode/schema/event";
|
|
11
|
+
import { Effect, Stream } from "effect";
|
|
12
|
+
import { HttpServerResponse } from "effect/unstable/http";
|
|
13
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
14
|
+
var EventHandler2 = HttpApiBuilder.group(Api2, "server.event", (handlers) => Effect.gen(function* () {
|
|
15
|
+
const feed = yield* Service2;
|
|
16
|
+
return handlers.handleRaw("event.subscribe", () => Effect.gen(function* () {
|
|
17
|
+
const connected = {
|
|
18
|
+
id: Event.ID.create(),
|
|
19
|
+
type: "server.connected",
|
|
20
|
+
data: {}
|
|
21
|
+
};
|
|
22
|
+
const output = Stream.unwrap(feed.subscribe.pipe(Effect.map((live) => Stream.make(frame2(connected)).pipe(Stream.concat(live)))));
|
|
23
|
+
const heartbeat = Stream.tick("15 seconds").pipe(Stream.map(() => `: heartbeat
|
|
24
|
+
|
|
25
|
+
`));
|
|
26
|
+
return HttpServerResponse.stream(output.pipe(Stream.merge(heartbeat, { haltStrategy: "left" }), Stream.encodeText), {
|
|
27
|
+
contentType: "text/event-stream",
|
|
28
|
+
headers: {
|
|
29
|
+
"Cache-Control": "no-cache, no-transform",
|
|
30
|
+
"X-Accel-Buffering": "no",
|
|
31
|
+
"X-Content-Type-Options": "nosniff"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
export { EventHandler2 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Api2
|
|
3
|
+
} from "./workerd-z5shrcz9.js";
|
|
4
|
+
|
|
5
|
+
// src/handlers/migration.ts
|
|
6
|
+
import { V1Migration } from "@opencode/core/database/v1-migration";
|
|
7
|
+
import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
8
|
+
import { Effect } from "effect";
|
|
9
|
+
var MigrationHandler2 = HttpApiBuilder.group(Api2, "server.migration", (handlers) => handlers.handle("migration.v1.status", Effect.fn(function* () {
|
|
10
|
+
return yield* V1Migration.status();
|
|
11
|
+
})));
|
|
12
|
+
|
|
13
|
+
export { MigrationHandler2 };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
response2
|
|
3
|
+
} from "./workerd-6gkz39ey.js";
|
|
4
|
+
import {
|
|
5
|
+
Api2
|
|
6
|
+
} from "./workerd-z5shrcz9.js";
|
|
7
|
+
|
|
8
|
+
// src/handlers/mcp.ts
|
|
9
|
+
import { Mcp } from "@opencode/core/mcp/index";
|
|
10
|
+
import { McpServerNotFoundError } from "@opencode/protocol/errors";
|
|
11
|
+
import { Effect } from "effect";
|
|
12
|
+
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
13
|
+
var notFound = (effect) => effect.pipe(Effect.mapError((error) => new McpServerNotFoundError({ server: error.server, message: error.message })));
|
|
14
|
+
var McpHandler2 = HttpApiBuilder.group(Api2, "server.mcp", (handlers) => Effect.gen(function* () {
|
|
15
|
+
return handlers.handle("mcp.list", Effect.fn(function* () {
|
|
16
|
+
const service = yield* Mcp.Service;
|
|
17
|
+
return yield* response2(service.servers().pipe(Effect.map((servers) => servers.map((info) => ({ name: info.name, status: info.status, integrationID: info.integrationID })))));
|
|
18
|
+
})).handle("mcp.add", Effect.fn(function* (ctx) {
|
|
19
|
+
const service = yield* Mcp.Service;
|
|
20
|
+
yield* service.add(ctx.params.server, ctx.payload.config);
|
|
21
|
+
return HttpApiSchema.NoContent.make();
|
|
22
|
+
})).handle("mcp.remove", Effect.fn(function* (ctx) {
|
|
23
|
+
const service = yield* Mcp.Service;
|
|
24
|
+
yield* notFound(service.remove(ctx.params.server));
|
|
25
|
+
return HttpApiSchema.NoContent.make();
|
|
26
|
+
})).handle("mcp.connect", Effect.fn(function* (ctx) {
|
|
27
|
+
const service = yield* Mcp.Service;
|
|
28
|
+
yield* notFound(service.connect(ctx.params.server));
|
|
29
|
+
return HttpApiSchema.NoContent.make();
|
|
30
|
+
})).handle("mcp.disconnect", Effect.fn(function* (ctx) {
|
|
31
|
+
const service = yield* Mcp.Service;
|
|
32
|
+
yield* notFound(service.disconnect(ctx.params.server));
|
|
33
|
+
return HttpApiSchema.NoContent.make();
|
|
34
|
+
})).handle("mcp.resource.catalog", Effect.fn(function* () {
|
|
35
|
+
const service = yield* Mcp.Service;
|
|
36
|
+
return yield* response2(service.resourceCatalog());
|
|
37
|
+
}));
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
export { McpHandler2 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __returnValue = (v) => v;
|
|
3
|
+
function __exportSetter(name, newValue) {
|
|
4
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
5
|
+
}
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
set: __exportSetter.bind(all, name)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { __export };
|