@opencode/server 2.2.7 → 2.3.1
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 +148 -1
- package/dist/api.js +5 -5
- package/dist/auth.js +1 -1
- package/dist/chunks/{process-zmgfywqd.js → request-tracing-05c5061t.js} +1 -1
- package/dist/chunks/{process-r5696se6.js → request-tracing-0e81et3m.js} +3 -3
- package/dist/chunks/{process-mx6chrwy.js → request-tracing-0gf4dfn8.js} +35 -35
- package/dist/chunks/{process-amndpc82.js → request-tracing-2pbbrzpp.js} +2 -2
- package/dist/chunks/{process-e6e4kz0w.js → request-tracing-39nnfjx1.js} +4 -4
- package/dist/chunks/{process-5pdfedjd.js → request-tracing-3te71694.js} +4 -4
- package/dist/chunks/{process-jqvq1ywe.js → request-tracing-4ed680xg.js} +2 -2
- package/dist/chunks/{process-370cpmna.js → request-tracing-4p2y0qs3.js} +2 -2
- package/dist/chunks/{process-gqq6kfhc.js → request-tracing-50bbk3b2.js} +3 -3
- package/dist/chunks/{process-78rcgzsr.js → request-tracing-78rcgzsr.js} +1 -1
- package/dist/chunks/{process-7b9xm1qg.js → request-tracing-7b9xm1qg.js} +1 -1
- package/dist/chunks/{process-fszbw5sk.js → request-tracing-7nb2rv11.js} +4 -4
- package/dist/chunks/{process-zds85vps.js → request-tracing-861wfsmy.js} +1 -1
- package/dist/chunks/request-tracing-8sb6qqpn.js +28 -0
- package/dist/chunks/request-tracing-9cd3a4b8.js +69 -0
- package/dist/chunks/{process-vtfzy3at.js → request-tracing-9grnt8dc.js} +2 -2
- package/dist/chunks/{process-5553qfcy.js → request-tracing-ap1t95t8.js} +3 -3
- package/dist/chunks/{process-wqv43pj9.js → request-tracing-ayveq98d.js} +23 -3
- package/dist/chunks/{process-yet0vexm.js → request-tracing-b3bmdkga.js} +1 -1
- package/dist/chunks/{process-xpg37vzc.js → request-tracing-b4mqtccx.js} +2 -2
- package/dist/chunks/{process-4z8yg1dv.js → request-tracing-d4534456.js} +4 -4
- package/dist/chunks/{process-rcmctvp9.js → request-tracing-d8b9pm2q.js} +1 -1
- package/dist/chunks/{process-p3f060n2.js → request-tracing-dezpcckc.js} +2 -2
- package/dist/chunks/{process-djr0jy89.js → request-tracing-djr0jy89.js} +1 -1
- package/dist/chunks/{process-7cd61xtm.js → request-tracing-dx89xydc.js} +2 -2
- package/dist/chunks/{process-2835150m.js → request-tracing-et00mhwf.js} +2 -2
- package/dist/chunks/{process-rxyx8sa0.js → request-tracing-f8r9p2vr.js} +2 -2
- package/dist/chunks/{process-wecgp61r.js → request-tracing-fvpjvjpp.js} +7 -7
- package/dist/chunks/{process-zgw0abca.js → request-tracing-g6yhb3a8.js} +16 -22
- package/dist/chunks/{process-jc2vwkyw.js → request-tracing-h1thjy6x.js} +2 -2
- package/dist/chunks/{process-agenqygg.js → request-tracing-h286a6py.js} +2 -2
- package/dist/chunks/{process-gk0yxcp6.js → request-tracing-htyf2qs7.js} +1 -1
- package/dist/chunks/{process-0e4fm4yw.js → request-tracing-hx8bsq9d.js} +1 -1
- package/dist/chunks/{process-j4at0y5c.js → request-tracing-j4at0y5c.js} +1 -1
- package/dist/chunks/{process-r2veymj8.js → request-tracing-jjvpqmx6.js} +4 -4
- package/dist/chunks/{process-50xc6x42.js → request-tracing-kg0ybx4v.js} +3 -3
- package/dist/chunks/{process-myqk22k5.js → request-tracing-myqk22k5.js} +2 -2
- package/dist/chunks/{process-kqr36gas.js → request-tracing-mzs0n5xz.js} +7 -7
- package/dist/chunks/request-tracing-n26yr6pw.js +21 -0
- package/dist/chunks/{process-5kr30cfc.js → request-tracing-n5et0xgm.js} +8 -8
- package/dist/chunks/{process-w5yp0ga8.js → request-tracing-p86kew8c.js} +2 -2
- package/dist/chunks/{process-xbqm7mpj.js → request-tracing-q44yktpv.js} +2 -2
- package/dist/chunks/{process-zgvwy66h.js → request-tracing-r7knxm63.js} +7 -20
- package/dist/chunks/{process-dfxfd950.js → request-tracing-rd9e3qfx.js} +4 -4
- package/dist/chunks/{process-skcryrty.js → request-tracing-s9tkswmw.js} +2 -2
- package/dist/chunks/request-tracing-sy2e93cn.js +46 -0
- package/dist/chunks/{process-t32e1bbt.js → request-tracing-t32e1bbt.js} +1 -1
- package/dist/chunks/{process-1vxxxmgg.js → request-tracing-tk56ffsq.js} +2 -2
- package/dist/chunks/{process-xjbee3xk.js → request-tracing-v0r38a4t.js} +31 -19
- package/dist/chunks/{process-7x1re4zg.js → request-tracing-v8aqacn3.js} +2 -2
- package/dist/chunks/{process-sqxx1p54.js → request-tracing-vbgqk0mr.js} +2 -2
- package/dist/chunks/{process-vvp99hc9.js → request-tracing-x4b2rtcb.js} +1 -1
- package/dist/chunks/{process-f3xrm535.js → request-tracing-z2ndp6vh.js} +6 -6
- package/dist/chunks/{process-74kxthdf.js → request-tracing-zbe9jfhy.js} +1 -1
- package/dist/content-headers.js +1 -1
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.d.ts +3 -0
- package/dist/fetch.js +61 -58
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/artifact.js +3 -3
- package/dist/handlers/automation.d.ts +25 -0
- package/dist/handlers/automation.js +7 -0
- package/dist/handlers/blob.d.ts +7 -0
- package/dist/handlers/blob.js +8 -0
- 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 -7
- package/dist/handlers/generate.d.ts +2 -1
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/job.d.ts +11 -1
- package/dist/handlers/job.js +2 -2
- package/dist/handlers/location.js +6 -6
- 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 +15 -13
- 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 +52 -50
- package/dist/location.js +4 -4
- package/dist/media-uri.js +1 -1
- package/dist/middleware/authorization.js +2 -2
- package/dist/middleware/defect-response.d.ts +2 -0
- package/dist/middleware/defect-response.js +6 -0
- 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/options.d.ts +3 -0
- package/dist/options.js +3 -0
- package/dist/pairing.js +3 -3
- package/dist/process.d.ts +3 -0
- package/dist/process.js +64 -61
- package/dist/range.d.ts +6 -0
- package/dist/range.js +8 -0
- package/dist/request-site.js +2 -2
- package/dist/request-tracing.js +1 -1
- package/dist/routes.d.ts +6 -3
- package/dist/routes.js +56 -53
- package/dist/server-info.js +3 -3
- package/dist/service-status.js +3 -3
- package/dist/workerd.d.ts +1 -0
- package/dist/workerd.js +66 -59
- package/package.json +9 -9
- package/dist/chunks/process-059rbh9c.js +0 -43
- package/dist/handlers/schedule.d.ts +0 -314
- package/dist/handlers/schedule.js +0 -7
- /package/dist/chunks/{process-9rqn6x4v.js → request-tracing-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{process-bd8755ek.js → request-tracing-bd8755ek.js} +0 -0
- /package/dist/chunks/{process-q187pxxd.js → request-tracing-q187pxxd.js} +0 -0
- /package/dist/chunks/{process-q4bn6dy8.js → request-tracing-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{process-smaf4a18.js → request-tracing-smaf4a18.js} +0 -0
- /package/dist/chunks/{process-xthc02cw.js → request-tracing-xthc02cw.js} +0 -0
- /package/dist/chunks/{process-yc7nft6q.js → request-tracing-yc7nft6q.js} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
missingSession2
|
|
3
|
+
} from "./request-tracing-smaf4a18.js";
|
|
4
|
+
|
|
5
|
+
// src/handlers/automation.ts
|
|
6
|
+
import { Automation } from "@opencode/core/automation";
|
|
7
|
+
import { Permission } from "@opencode/core/permission";
|
|
8
|
+
import { Project } from "@opencode/core/project";
|
|
9
|
+
import { Session } from "@opencode/core/session";
|
|
10
|
+
import { AbsolutePath } from "@opencode/core/schema";
|
|
11
|
+
import { AutomationNotFoundError, ForbiddenError, InvalidRequestError } from "@opencode/protocol/errors";
|
|
12
|
+
import { Effect } from "effect";
|
|
13
|
+
import path from "node:path";
|
|
14
|
+
import { HttpApiSchema } from "effect/http-api";
|
|
15
|
+
var makeAutomation2 = Effect.gen(function* () {
|
|
16
|
+
const automations = yield* Automation.Service;
|
|
17
|
+
const sessions = yield* Session.Service;
|
|
18
|
+
const projects = yield* Project.Service;
|
|
19
|
+
const enabled = (directory) => automations.enabled(directory).pipe(Effect.catchTag("FileSystem.DirectoryNotFoundError", () => Effect.succeed(true)));
|
|
20
|
+
const allowed = (directory) => enabled(directory).pipe(Effect.flatMap((on) => on ? Effect.void : Effect.fail(disabled())));
|
|
21
|
+
const find = (id) => Effect.gen(function* () {
|
|
22
|
+
const info = yield* automations.get(id).pipe(Effect.mapError(missingAutomation));
|
|
23
|
+
yield* allowed(info.directory);
|
|
24
|
+
return info;
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
create: (payload) => automations.create(payload).pipe(Effect.provideService(Permission.Unattended, []), Effect.map((data) => ({ data })), Effect.catchTags({
|
|
28
|
+
"Automation.InvalidError": (error) => Effect.fail(new InvalidRequestError({ message: error.message, kind: "automation" })),
|
|
29
|
+
"Automation.DisabledError": () => Effect.fail(disabled()),
|
|
30
|
+
"Permission.BlockedError": (error) => Effect.fail(new ForbiddenError({ message: error.message })),
|
|
31
|
+
"Permission.CorrectedError": (error) => Effect.fail(new ForbiddenError({ message: error.feedback })),
|
|
32
|
+
"Session.NotFoundError": (error) => Effect.fail(missingSession2(error))
|
|
33
|
+
})),
|
|
34
|
+
list: (query) => Effect.gen(function* () {
|
|
35
|
+
const session = query.sessionID === undefined ? undefined : yield* sessions.get(query.sessionID).pipe(Effect.mapError(missingSession2));
|
|
36
|
+
if (session !== undefined)
|
|
37
|
+
yield* allowed(session.location.directory);
|
|
38
|
+
const directory = query.directory;
|
|
39
|
+
if (directory !== undefined && !path.isAbsolute(directory))
|
|
40
|
+
return yield* new InvalidRequestError({
|
|
41
|
+
message: `Directory must be an absolute path: ${directory}`,
|
|
42
|
+
kind: "automation"
|
|
43
|
+
});
|
|
44
|
+
if (directory !== undefined)
|
|
45
|
+
yield* allowed(directory);
|
|
46
|
+
const projectID = directory === undefined ? undefined : (yield* projects.resolve(AbsolutePath.make(directory), { persist: false })).id;
|
|
47
|
+
const rows = yield* automations.list({ sessionID: query.sessionID });
|
|
48
|
+
const matching = rows.filter((row) => directory === undefined || row.projectID === projectID || row.directory === directory);
|
|
49
|
+
const directories = new Set(matching.map((row) => row.directory));
|
|
50
|
+
const visible = new Set(yield* Effect.filter(directories, enabled));
|
|
51
|
+
return { data: matching.filter((row) => visible.has(row.directory)) };
|
|
52
|
+
}),
|
|
53
|
+
get: (id) => find(id).pipe(Effect.map((data) => ({ data }))),
|
|
54
|
+
pause: (id) => find(id).pipe(Effect.andThen(automations.pause(id).pipe(Effect.mapError(missingAutomation))), Effect.map((data) => ({ data }))),
|
|
55
|
+
resume: (id) => find(id).pipe(Effect.andThen(automations.resume(id).pipe(Effect.mapError(missingAutomation))), Effect.map((data) => ({ data }))),
|
|
56
|
+
remove: (id) => find(id).pipe(Effect.andThen(automations.remove(id).pipe(Effect.mapError(missingAutomation))), Effect.as(HttpApiSchema.NoContent.make()))
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
function missingAutomation(error) {
|
|
60
|
+
return new AutomationNotFoundError({
|
|
61
|
+
automationID: error.automationID,
|
|
62
|
+
message: `Automation not found: ${error.automationID}`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function disabled() {
|
|
66
|
+
return new ForbiddenError({ message: new Automation.DisabledError().message });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { makeAutomation2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-0e81et3m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/provider.ts
|
|
10
10
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2,
|
|
3
3
|
failedMessageDecode2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./request-tracing-smaf4a18.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-0e81et3m.js";
|
|
8
8
|
import {
|
|
9
9
|
wantsMediaRefs2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./request-tracing-xthc02cw.js";
|
|
11
11
|
|
|
12
12
|
// src/handlers/message.ts
|
|
13
13
|
import { SessionMessage } from "@opencode/core/session/message";
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-0e81et3m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/generate.ts
|
|
10
|
+
import { Flag } from "@opencode/core/flag";
|
|
10
11
|
import { Generate } from "@opencode/core/generate";
|
|
12
|
+
import { VideoGeneration } from "@opencode/core/video-generation";
|
|
11
13
|
import { Location } from "@opencode/core/location";
|
|
12
14
|
import { LocationServiceMap } from "@opencode/core/location-services";
|
|
13
15
|
import { AbsolutePath } from "@opencode/core/schema";
|
|
14
16
|
import {
|
|
17
|
+
ForbiddenError,
|
|
18
|
+
VideoNotFoundError,
|
|
15
19
|
InvalidRequestError,
|
|
16
20
|
ModelNotFoundError,
|
|
17
21
|
ProviderRequestError,
|
|
@@ -24,6 +28,7 @@ import { HttpApiBuilder } from "effect/http-api";
|
|
|
24
28
|
var GenerateHandler2 = HttpApiBuilder.group(Api2, "server.generate", (handlers) => Effect.gen(function* () {
|
|
25
29
|
const global = yield* Global.Service;
|
|
26
30
|
const locations = yield* LocationServiceMap.Service;
|
|
31
|
+
const videos = yield* VideoGeneration.Service;
|
|
27
32
|
const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }));
|
|
28
33
|
const text = Effect.fn("server.generate.text")(function* (request) {
|
|
29
34
|
yield* awaitPlugins2;
|
|
@@ -46,7 +51,22 @@ var GenerateHandler2 = HttpApiBuilder.group(Api2, "server.generate", (handlers)
|
|
|
46
51
|
const generate = yield* Generate.Service;
|
|
47
52
|
return { data: yield* generate.decisions(request.payload).pipe(Effect.mapError(generateError)) };
|
|
48
53
|
}, Effect.provide(services), locationErrors2);
|
|
49
|
-
|
|
54
|
+
const videoEnabled = Effect.gen(function* () {
|
|
55
|
+
if (yield* Flag.enabled("video_generate"))
|
|
56
|
+
return;
|
|
57
|
+
return yield* new ForbiddenError({ message: "Video generation is disabled; enable experimental.video_generate" });
|
|
58
|
+
});
|
|
59
|
+
const videoCreate = Effect.fn("server.generate.video.create")(function* (request) {
|
|
60
|
+
yield* videoEnabled;
|
|
61
|
+
yield* awaitPlugins2;
|
|
62
|
+
return { data: yield* videos.start(request.payload).pipe(Effect.mapError(generateError)) };
|
|
63
|
+
}, Effect.provide(services), locationErrors2);
|
|
64
|
+
const videoGet = Effect.fn("server.generate.video.get")(function* (request) {
|
|
65
|
+
yield* videoEnabled;
|
|
66
|
+
const job = yield* videos.get(request.params.id).pipe(Effect.mapError((error) => new VideoNotFoundError({ videoID: error.id, message: error.message })));
|
|
67
|
+
return { data: job };
|
|
68
|
+
}, Effect.provide(services), locationErrors2);
|
|
69
|
+
return handlers.handle("generate.text", text).handle("generate.textLegacy", text).handle("generate.image", image).handle("generate.decisions", decisions).handle("generate.video.create", videoCreate).handle("generate.video.get", videoGet);
|
|
50
70
|
}));
|
|
51
71
|
function generateError(error) {
|
|
52
72
|
switch (error._tag) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-0e81et3m.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/command.ts
|
|
9
9
|
import { Command } from "@opencode/core/command";
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
locationErrors2,
|
|
3
3
|
response2,
|
|
4
4
|
requestRef2
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./request-tracing-0e81et3m.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./request-tracing-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2,
|
|
15
15
|
holdLocation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./request-tracing-q187pxxd.js";
|
|
17
17
|
|
|
18
18
|
// src/handlers/mcp.ts
|
|
19
19
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-0e81et3m.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/agent.ts
|
|
9
9
|
import { Agent } from "@opencode/core/agent";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-0e81et3m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/websearch.ts
|
|
10
10
|
import { WebSearch } from "@opencode/core/websearch";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-0e81et3m.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/voice.ts
|
|
10
10
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-0e81et3m.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/shell.ts
|
|
9
9
|
import { Shell } from "@opencode/core/shell";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-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: () => Service2,
|
|
11
11
|
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
12
|
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
13
|
frame: () => frame2,
|
|
14
|
-
layer: () =>
|
|
14
|
+
layer: () => layer2,
|
|
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 Service2 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 Service2.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 layer2 = Layer.effect(Service2, 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, Service2, frame2, make4, layer2, exports_event_feed };
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-0e81et3m.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./request-tracing-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
makeArtifact2
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./request-tracing-p86kew8c.js";
|
|
11
|
+
import {
|
|
12
|
+
makeBlobGet2
|
|
13
|
+
} from "./request-tracing-sy2e93cn.js";
|
|
14
|
+
import {
|
|
15
|
+
makeAutomation2
|
|
16
|
+
} from "./request-tracing-9cd3a4b8.js";
|
|
11
17
|
import {
|
|
12
18
|
makeJob2
|
|
13
|
-
} from "./
|
|
19
|
+
} from "./request-tracing-78rcgzsr.js";
|
|
14
20
|
import {
|
|
15
21
|
makeMediaGet2
|
|
16
|
-
} from "./
|
|
22
|
+
} from "./request-tracing-djr0jy89.js";
|
|
17
23
|
import {
|
|
18
24
|
runPtySocket2
|
|
19
|
-
} from "./
|
|
20
|
-
import {
|
|
21
|
-
makeSchedule2
|
|
22
|
-
} from "./process-059rbh9c.js";
|
|
25
|
+
} from "./request-tracing-q187pxxd.js";
|
|
23
26
|
|
|
24
27
|
// src/handlers/persistent-pty.ts
|
|
25
28
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
@@ -27,7 +30,6 @@ import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
|
27
30
|
import {
|
|
28
31
|
ForbiddenError,
|
|
29
32
|
InvalidRequestError,
|
|
30
|
-
PtyFeatureUnsupportedError,
|
|
31
33
|
PtyNotFoundError,
|
|
32
34
|
ServiceUnavailableError
|
|
33
35
|
} from "@opencode/protocol/errors";
|
|
@@ -47,8 +49,9 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
|
|
|
47
49
|
const artifact = yield* makeArtifact2;
|
|
48
50
|
const job = yield* makeJob2;
|
|
49
51
|
const mediaGet = yield* makeMediaGet2;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
+
const blobGet = yield* makeBlobGet2;
|
|
53
|
+
const automation = yield* makeAutomation2;
|
|
54
|
+
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("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) {
|
|
52
55
|
return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
|
|
53
56
|
})).handle("persistentPty.list", Effect.fn(function* (ctx) {
|
|
54
57
|
return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
|
|
@@ -79,16 +82,7 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
|
|
|
79
82
|
yield* pty.resize(ctx.params.ptyID, ctx.payload.size.cols, ctx.payload.size.rows, ctx.payload.attachmentID).pipe(mapTerminalError);
|
|
80
83
|
if (ctx.payload.title === undefined)
|
|
81
84
|
return { data: yield* pty.get(ctx.params.ptyID).pipe(mapTerminalError) };
|
|
82
|
-
return {
|
|
83
|
-
data: yield* pty.rename(ctx.params.ptyID, ctx.payload.title).pipe(Effect.catchTags({
|
|
84
|
-
"PersistentPty.NotFoundError": notFound,
|
|
85
|
-
"PersistentPty.UnsupportedError": (error) => new PtyFeatureUnsupportedError({
|
|
86
|
-
feature: error.feature,
|
|
87
|
-
message: "Terminal renaming will be available after OpenCode's terminal service restarts"
|
|
88
|
-
}),
|
|
89
|
-
"PersistentPty.UnavailableError": unavailable
|
|
90
|
-
}))
|
|
91
|
-
};
|
|
85
|
+
return { data: yield* pty.rename(ctx.params.ptyID, ctx.payload.title).pipe(mapTerminalError) };
|
|
92
86
|
})).handle("persistentPty.snapshot", Effect.fn(function* (ctx) {
|
|
93
87
|
return { data: yield* pty.snapshot(ctx.params.ptyID).pipe(mapTerminalError) };
|
|
94
88
|
})).handle("persistentPty.remove", Effect.fn(function* (ctx) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
requestRef2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-0e81et3m.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/debug.ts
|
|
9
9
|
import { LocationServiceMap } from "@opencode/core/location-service-map";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-0e81et3m.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/vcs.ts
|
|
9
9
|
import { Vcs } from "@opencode/core/vcs";
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
locationErrors2,
|
|
3
3
|
response2,
|
|
4
4
|
requestRef2
|
|
5
|
-
} from "./
|
|
5
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
6
6
|
import {
|
|
7
7
|
Api2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./request-tracing-0e81et3m.js";
|
|
9
9
|
import {
|
|
10
10
|
CorsConfig2,
|
|
11
11
|
isAllowedRequestOrigin2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./request-tracing-q4bn6dy8.js";
|
|
13
13
|
import {
|
|
14
14
|
runPtySocket2,
|
|
15
15
|
holdLocation2
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./request-tracing-q187pxxd.js";
|
|
17
17
|
|
|
18
18
|
// src/handlers/pty.ts
|
|
19
19
|
import { Pty } from "@opencode/core/pty";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-smaf4a18.js";
|
|
4
4
|
import {
|
|
5
5
|
locationErrors2,
|
|
6
6
|
response2,
|
|
7
7
|
sessionInfo2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
9
9
|
import {
|
|
10
10
|
Api2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./request-tracing-0e81et3m.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
|
isAllowedRequestOrigin2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-9rqn6x4v.js";
|
|
7
7
|
|
|
8
8
|
// src/request-site.ts
|
|
9
9
|
var exports_request_site = {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/pairing.ts
|
|
6
6
|
var exports_pairing = {};
|
|
7
7
|
__export(exports_pairing, {
|
|
8
8
|
ServerPairing: () => exports_pairing,
|
|
9
|
-
Service: () =>
|
|
9
|
+
Service: () => Service4,
|
|
10
10
|
node: () => node2
|
|
11
11
|
});
|
|
12
12
|
import { Cache, Context, Duration, Effect, Layer } from "effect";
|
|
@@ -14,12 +14,12 @@ import { makeGlobalNode } from "@opencode/util/effect/app-node";
|
|
|
14
14
|
import { randomBytes } from "node:crypto";
|
|
15
15
|
var TTL = Duration.minutes(5);
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class Service4 extends Context.Service()("@opencode/ServerPairing") {
|
|
18
18
|
}
|
|
19
19
|
var noLookup = () => Effect.die(new Error("ServerPairing cache must be used via set/invalidateWhen, never get"));
|
|
20
|
-
var layer = Layer.effect(
|
|
20
|
+
var layer = Layer.effect(Service4, Effect.gen(function* () {
|
|
21
21
|
const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
|
|
22
|
-
return
|
|
22
|
+
return Service4.of({
|
|
23
23
|
issue: Effect.fn("ServerPairing.issue")(function* () {
|
|
24
24
|
const code = randomBytes(16).toString("base64url");
|
|
25
25
|
yield* Cache.set(cache, code, true);
|
|
@@ -30,6 +30,6 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
}));
|
|
33
|
-
var node2 = makeGlobalNode({ service:
|
|
33
|
+
var node2 = makeGlobalNode({ service: Service4, layer, deps: [] });
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { Service4, node2, exports_pairing };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/middleware/defect-response.ts
|
|
2
|
+
import { StorageFailure } from "@opencode/core/database/storage-failure";
|
|
3
|
+
import { UnknownError } from "@opencode/protocol/errors";
|
|
4
|
+
import { Cause, Effect } from "effect";
|
|
5
|
+
import { HttpRouter, HttpServerError, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
6
|
+
var respond = HttpServerResponse.schemaJson(UnknownError);
|
|
7
|
+
var defectResponseLayer2 = HttpRouter.middleware((effect) => effect.pipe(Effect.catchCause((cause) => Effect.gen(function* () {
|
|
8
|
+
const [response] = yield* HttpServerError.causeResponse(cause);
|
|
9
|
+
if (response.status !== 500 || response.body._tag !== "Empty")
|
|
10
|
+
return yield* Effect.failCause(cause);
|
|
11
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
12
|
+
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
13
|
+
yield* Effect.logError("request failed", cause).pipe(Effect.annotateLogs({ ref, route: `${request.method} ${request.url}` }));
|
|
14
|
+
const body = yield* respond(new UnknownError({
|
|
15
|
+
message: StorageFailure.message(cause) ?? "Server failed to handle the request. Check server logs for details.",
|
|
16
|
+
ref
|
|
17
|
+
}), { status: 500 }).pipe(Effect.orDie);
|
|
18
|
+
return yield* Effect.failCause(Cause.combine(cause, Cause.die(body)));
|
|
19
|
+
}))), { global: true });
|
|
20
|
+
|
|
21
|
+
export { defectResponseLayer2 };
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAllowedCorsOrigin2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
middleware2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./request-tracing-myqk22k5.js";
|
|
7
7
|
import {
|
|
8
8
|
withoutParentSpan2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./request-tracing-yc7nft6q.js";
|
|
10
10
|
import {
|
|
11
11
|
createRoutes2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./request-tracing-v0r38a4t.js";
|
|
13
13
|
import {
|
|
14
14
|
__export
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./request-tracing-9rqn6x4v.js";
|
|
16
16
|
|
|
17
17
|
// src/fetch.ts
|
|
18
18
|
var exports_fetch = {};
|
|
19
19
|
__export(exports_fetch, {
|
|
20
20
|
ServerFetch: () => exports_fetch,
|
|
21
|
-
make: () =>
|
|
21
|
+
make: () => make3
|
|
22
22
|
});
|
|
23
23
|
import { Context, Effect, Layer } from "effect";
|
|
24
24
|
import { HttpEffect, HttpMiddleware, HttpRouter, HttpServer } from "effect/http";
|
|
25
25
|
import { SessionRestart } from "@opencode/core/session/execution/restart";
|
|
26
|
-
var
|
|
26
|
+
var make3 = Effect.fn("ServerFetch.make")(function* (options = {}, boot = {}) {
|
|
27
27
|
const context = yield* Layer.build(createRoutes2(options, () => [], boot.overrides ?? []).pipe(Layer.provide(HttpServer.layerServices))).pipe(withoutParentSpan2);
|
|
28
28
|
yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions);
|
|
29
29
|
return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(middleware2(options), HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin2(origin, options), maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { make3, exports_fetch };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./request-tracing-smaf4a18.js";
|
|
4
4
|
import {
|
|
5
5
|
locationErrors2,
|
|
6
6
|
response2,
|
|
7
7
|
requestRef2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./request-tracing-50bbk3b2.js";
|
|
9
9
|
|
|
10
10
|
// src/handlers/artifact.ts
|
|
11
11
|
import { Artifact } from "@opencode/core/artifact";
|