@opencode/server 0.0.0-dev-1301 → 0.0.0-dev-1303
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 +4 -4
- package/dist/chunks/{api-b0sezs8j.js → api-09kw3a77.js} +2 -2
- package/dist/chunks/{api-c6sjpm0r.js → api-1h6b4sc5.js} +23 -3
- package/dist/chunks/{api-qn8kkfq6.js → api-2eaky32g.js} +2 -2
- package/dist/chunks/{api-wecgp61r.js → api-3p9jwgak.js} +6 -6
- package/dist/chunks/{api-z59gyc0x.js → api-4q6e7fh8.js} +2 -2
- package/dist/chunks/{api-gqq6kfhc.js → api-50bbk3b2.js} +2 -2
- package/dist/chunks/{api-0n1e9dnh.js → api-58psf7ej.js} +1 -1
- package/dist/chunks/{api-z7gkfgax.js → api-5cpb32hf.js} +1 -1
- package/dist/chunks/{api-84dqjc6j.js → api-6kawhtwy.js} +2 -2
- package/dist/chunks/{api-1je14sn4.js → api-6z9pvq7p.js} +1 -1
- package/dist/chunks/{api-np3ws677.js → api-8mj7kvhm.js} +2 -2
- package/dist/chunks/api-8sb6qqpn.js +28 -0
- package/dist/chunks/{api-r3h1014p.js → api-91858wp1.js} +2 -2
- package/dist/chunks/{api-qs427q2r.js → api-99d31s2b.js} +7 -7
- package/dist/chunks/api-9cd3a4b8.js +69 -0
- package/dist/chunks/{api-dk68ymtv.js → api-a8jcac9a.js} +1 -1
- package/dist/chunks/{api-hax1v4bv.js → api-az0609r6.js} +2 -2
- package/dist/chunks/{api-yet0vexm.js → api-b3bmdkga.js} +1 -1
- package/dist/chunks/{api-ppma8fcc.js → api-btahnm2b.js} +2 -2
- package/dist/chunks/{api-b2k9041j.js → api-cezwbsk5.js} +1 -1
- package/dist/chunks/{api-q93ntzen.js → api-cjmzjx21.js} +11 -7
- package/dist/chunks/api-cr5sd8bz.js +46 -0
- package/dist/chunks/{api-wxj3d9av.js → api-d0edqfxx.js} +2 -2
- package/dist/chunks/{api-27hs38qv.js → api-ea796ghj.js} +6 -19
- package/dist/chunks/{api-41yet3w7.js → api-enp1bp7r.js} +1 -1
- package/dist/chunks/{api-m5rae7m4.js → api-f559fakr.js} +2 -2
- package/dist/chunks/{api-gk0yxcp6.js → api-htyf2qs7.js} +1 -1
- package/dist/chunks/{api-9c4eyh8m.js → api-j87xz9bt.js} +3 -3
- package/dist/chunks/{api-e46y0tfd.js → api-kkdkqt8j.js} +2 -2
- package/dist/chunks/{api-w9jcwh65.js → api-kqr36gas.js} +6 -6
- package/dist/chunks/{api-vhwcrt1z.js → api-n2sc8d5v.js} +17 -13
- package/dist/chunks/{api-6vs5sqy6.js → api-ny1j968n.js} +2 -2
- package/dist/chunks/{api-w5yp0ga8.js → api-p86kew8c.js} +1 -1
- package/dist/chunks/{api-ppqp5pr2.js → api-qa6gkrme.js} +35 -35
- package/dist/chunks/{api-x8dgc261.js → api-qcg3sqtb.js} +2 -2
- package/dist/chunks/{api-22wspztn.js → api-qd0r787n.js} +2 -2
- package/dist/chunks/{api-e9906t2e.js → api-r7kkkqba.js} +4 -4
- package/dist/chunks/{api-0a5jm2na.js → api-rha2aq18.js} +2 -2
- package/dist/chunks/{api-4vqvqsgg.js → api-rs3v36hp.js} +2 -2
- package/dist/chunks/{api-595kch50.js → api-s6t7ne1d.js} +1 -1
- package/dist/chunks/{api-yr4wsvrw.js → api-te8jwba1.js} +2 -2
- package/dist/chunks/{api-mmvhrf5s.js → api-vdvwckee.js} +2 -2
- package/dist/chunks/{api-z3e7v67k.js → api-yjbzmfhm.js} +6 -6
- package/dist/chunks/{api-452na7zm.js → api-yk755swr.js} +2 -2
- package/dist/chunks/{api-34xzc0ha.js → api-z9zyd4qg.js} +2 -2
- package/dist/chunks/{api-h072q2hm.js → api-zcvan105.js} +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +52 -50
- package/dist/handlers/agent.js +5 -5
- package/dist/handlers/artifact.js +2 -2
- 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 +5 -5
- package/dist/handlers/config.js +5 -5
- package/dist/handlers/credential.js +6 -6
- package/dist/handlers/debug.js +5 -5
- package/dist/handlers/event.js +6 -6
- package/dist/handlers/form.js +5 -5
- package/dist/handlers/fs.js +6 -5
- package/dist/handlers/generate.d.ts +2 -1
- package/dist/handlers/generate.js +5 -5
- package/dist/handlers/integration.js +5 -5
- package/dist/handlers/location.js +5 -5
- package/dist/handlers/mcp.js +6 -6
- package/dist/handlers/message.js +5 -5
- package/dist/handlers/migration.js +5 -5
- package/dist/handlers/model.js +5 -5
- package/dist/handlers/permission.js +5 -5
- package/dist/handlers/persistent-pty.d.ts +1 -1
- package/dist/handlers/persistent-pty.js +11 -9
- package/dist/handlers/plugin.js +5 -5
- package/dist/handlers/project.js +5 -5
- package/dist/handlers/provider.js +5 -5
- package/dist/handlers/pty.js +6 -6
- package/dist/handlers/reference.js +5 -5
- package/dist/handlers/rpc.js +5 -5
- package/dist/handlers/server.js +7 -7
- package/dist/handlers/session.js +5 -5
- package/dist/handlers/shell.js +5 -5
- package/dist/handlers/skill.js +5 -5
- package/dist/handlers/usage.js +5 -5
- package/dist/handlers/vcs.js +5 -5
- package/dist/handlers/voice.js +5 -5
- package/dist/handlers/websearch.js +5 -5
- package/dist/handlers/worktree.js +5 -5
- package/dist/handlers.d.ts +1 -1
- package/dist/handlers.js +47 -45
- package/dist/location.js +3 -3
- package/dist/middleware/form-location.js +2 -2
- package/dist/middleware/session-location.js +2 -2
- package/dist/pairing.js +3 -3
- package/dist/process.js +47 -45
- package/dist/range.d.ts +6 -0
- package/dist/range.js +8 -0
- package/dist/routes.d.ts +5 -3
- package/dist/routes.js +49 -47
- package/dist/server-info.js +5 -5
- package/dist/workerd.d.ts +1 -0
- package/dist/workerd.js +50 -44
- package/package.json +9 -9
- package/dist/chunks/api-059rbh9c.js +0 -43
- package/dist/handlers/schedule.d.ts +0 -314
- package/dist/handlers/schedule.js +0 -7
package/dist/api.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./chunks/api-
|
|
4
|
-
import"./chunks/api-
|
|
5
|
-
import"./chunks/api-
|
|
6
|
-
import"./chunks/api-
|
|
3
|
+
} from "./chunks/api-j87xz9bt.js";
|
|
4
|
+
import"./chunks/api-htyf2qs7.js";
|
|
5
|
+
import"./chunks/api-b3bmdkga.js";
|
|
6
|
+
import"./chunks/api-50bbk3b2.js";
|
|
7
7
|
import"./chunks/api-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./api-
|
|
4
|
+
} from "./api-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./api-
|
|
7
|
+
} from "./api-j87xz9bt.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) {
|
|
@@ -7,11 +7,11 @@ 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: () =>
|
|
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 Service3 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 Service3.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(Service3, 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, Service3, frame2, make4, layer2, exports_event_feed };
|
|
@@ -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 };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./api-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/range.ts
|
|
6
|
+
var exports_range = {};
|
|
7
|
+
__export(exports_range, {
|
|
8
|
+
ByteRange: () => exports_range,
|
|
9
|
+
parse: () => parse2
|
|
10
|
+
});
|
|
11
|
+
function parse2(header, size) {
|
|
12
|
+
const match = header === undefined ? null : /^bytes=\s*(\d*)\s*-\s*(\d*)\s*$/i.exec(header.trim());
|
|
13
|
+
if (match === null || match[1] === "" && match[2] === "")
|
|
14
|
+
return;
|
|
15
|
+
if (match[1] === "") {
|
|
16
|
+
const suffix = Number(match[2]);
|
|
17
|
+
if (suffix === 0 || size === 0)
|
|
18
|
+
return "unsatisfiable";
|
|
19
|
+
return { start: Math.max(size - suffix, 0), end: size - 1 };
|
|
20
|
+
}
|
|
21
|
+
const start = Number(match[1]);
|
|
22
|
+
const end = match[2] === "" ? size - 1 : Number(match[2]);
|
|
23
|
+
if (start > end || start >= size)
|
|
24
|
+
return "unsatisfiable";
|
|
25
|
+
return { start, end: Math.min(end, size - 1) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { parse2, exports_range };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./api-
|
|
3
|
+
} from "./api-j87xz9bt.js";
|
|
4
4
|
import {
|
|
5
5
|
SESSION_TTL_SECONDS2,
|
|
6
6
|
Config2,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
sessionCookieName2
|
|
9
9
|
} from "./api-j4at0y5c.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./api-
|
|
11
|
+
Service4
|
|
12
|
+
} from "./api-yjbzmfhm.js";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./api-
|
|
14
|
+
Service2
|
|
15
|
+
} from "./api-kqr36gas.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/server.ts
|
|
18
18
|
import { hostname } from "node:os";
|
|
@@ -22,10 +22,10 @@ import { HttpApiBuilder } from "effect/http-api";
|
|
|
22
22
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
23
23
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
24
24
|
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
25
|
-
const pairing = yield*
|
|
25
|
+
const pairing = yield* Service2;
|
|
26
26
|
const auth = yield* Config2;
|
|
27
27
|
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
28
|
-
const info = yield*
|
|
28
|
+
const info = yield* Service4;
|
|
29
29
|
return {
|
|
30
30
|
version: info.app.version ?? "unknown",
|
|
31
31
|
pid: process.pid ?? 0,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
missingSession2
|
|
3
|
+
} from "./api-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 "./api-
|
|
4
|
+
} from "./api-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./api-
|
|
7
|
+
} from "./api-j87xz9bt.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/provider.ts
|
|
10
10
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
locationErrors2,
|
|
6
6
|
response2,
|
|
7
7
|
sessionInfo2
|
|
8
|
-
} from "./api-
|
|
8
|
+
} from "./api-50bbk3b2.js";
|
|
9
9
|
import {
|
|
10
10
|
Api2
|
|
11
|
-
} from "./api-
|
|
11
|
+
} from "./api-j87xz9bt.js";
|
|
12
12
|
|
|
13
13
|
// src/handlers/permission.ts
|
|
14
14
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./api-
|
|
3
|
+
} from "./api-j87xz9bt.js";
|
|
4
4
|
import {
|
|
5
5
|
CorsConfig2,
|
|
6
6
|
isAllowedRequestOrigin2
|
|
7
7
|
} from "./api-q4bn6dy8.js";
|
|
8
8
|
import {
|
|
9
9
|
makeArtifact2
|
|
10
|
-
} from "./api-
|
|
10
|
+
} from "./api-p86kew8c.js";
|
|
11
|
+
import {
|
|
12
|
+
makeBlobGet2
|
|
13
|
+
} from "./api-cr5sd8bz.js";
|
|
14
|
+
import {
|
|
15
|
+
makeAutomation2
|
|
16
|
+
} from "./api-9cd3a4b8.js";
|
|
11
17
|
import {
|
|
12
18
|
makeJob2
|
|
13
19
|
} from "./api-78rcgzsr.js";
|
|
@@ -17,9 +23,6 @@ import {
|
|
|
17
23
|
import {
|
|
18
24
|
runPtySocket2
|
|
19
25
|
} from "./api-q187pxxd.js";
|
|
20
|
-
import {
|
|
21
|
-
makeSchedule2
|
|
22
|
-
} from "./api-059rbh9c.js";
|
|
23
26
|
|
|
24
27
|
// src/handlers/persistent-pty.ts
|
|
25
28
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
@@ -46,8 +49,9 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
|
|
|
46
49
|
const artifact = yield* makeArtifact2;
|
|
47
50
|
const job = yield* makeJob2;
|
|
48
51
|
const mediaGet = yield* makeMediaGet2;
|
|
49
|
-
const
|
|
50
|
-
|
|
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) {
|
|
51
55
|
return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
|
|
52
56
|
})).handle("persistentPty.list", Effect.fn(function* (ctx) {
|
|
53
57
|
return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
download2
|
|
3
|
+
} from "./api-t32e1bbt.js";
|
|
4
|
+
import {
|
|
5
|
+
parse2
|
|
6
|
+
} from "./api-8sb6qqpn.js";
|
|
7
|
+
|
|
8
|
+
// src/handlers/blob.ts
|
|
9
|
+
import { BlobStore } from "@opencode/core/blob-store";
|
|
10
|
+
import { BlobNotFoundError } from "@opencode/protocol/errors";
|
|
11
|
+
import { FSUtil } from "@opencode/util/fs-util";
|
|
12
|
+
import { Effect } from "effect";
|
|
13
|
+
import { HttpServerResponse } from "effect/http";
|
|
14
|
+
var makeBlobGet2 = Effect.gen(function* () {
|
|
15
|
+
const blobs = yield* BlobStore.Service;
|
|
16
|
+
const fs = yield* FSUtil.Service;
|
|
17
|
+
return (id, request) => Effect.gen(function* () {
|
|
18
|
+
const blob = yield* blobs.read(id).pipe(Effect.mapError((error) => new BlobNotFoundError({ blobID: error.id, message: error.message })));
|
|
19
|
+
const etag = `"${id}"`;
|
|
20
|
+
const headers = {
|
|
21
|
+
...download2({ mime: blob.mime }),
|
|
22
|
+
"cache-control": "private, max-age=604800, immutable",
|
|
23
|
+
etag,
|
|
24
|
+
"accept-ranges": "bytes"
|
|
25
|
+
};
|
|
26
|
+
if (request.headers["if-none-match"]?.split(",").some((tag) => tag.trim() === "*" || tag.trim().replace(/^w\//i, "") === etag))
|
|
27
|
+
return HttpServerResponse.empty({ status: 304, headers });
|
|
28
|
+
const ifRange = request.headers["if-range"];
|
|
29
|
+
const range = ifRange === undefined || ifRange.trim() === etag ? parse2(request.headers["range"], blob.bytes) : undefined;
|
|
30
|
+
if (range === "unsatisfiable")
|
|
31
|
+
return HttpServerResponse.empty({
|
|
32
|
+
status: 416,
|
|
33
|
+
headers: { ...headers, "content-range": `bytes */${blob.bytes}` }
|
|
34
|
+
});
|
|
35
|
+
const offset = range?.start ?? 0;
|
|
36
|
+
const length = range === undefined ? blob.bytes : range.end - range.start + 1;
|
|
37
|
+
return HttpServerResponse.stream(fs.stream(blob.path, { offset, bytesToRead: length }), {
|
|
38
|
+
status: range === undefined ? 200 : 206,
|
|
39
|
+
contentType: headers["content-type"],
|
|
40
|
+
contentLength: length,
|
|
41
|
+
headers: range === undefined ? headers : { ...headers, "content-range": `bytes ${range.start}-${range.end}/${blob.bytes}` }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export { makeBlobGet2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
locationErrors2,
|
|
3
3
|
awaitPlugins2
|
|
4
|
-
} from "./api-
|
|
4
|
+
} from "./api-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./api-
|
|
7
|
+
} from "./api-j87xz9bt.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/voice.ts
|
|
10
10
|
import { Location } from "@opencode/core/location";
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./api-
|
|
3
|
+
} from "./api-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./api-
|
|
6
|
+
} from "./api-j87xz9bt.js";
|
|
7
7
|
import {
|
|
8
8
|
download2
|
|
9
9
|
} from "./api-t32e1bbt.js";
|
|
10
|
+
import {
|
|
11
|
+
parse2
|
|
12
|
+
} from "./api-8sb6qqpn.js";
|
|
10
13
|
|
|
11
14
|
// src/handlers/fs.ts
|
|
12
15
|
import { FileSystem } from "@opencode/core/filesystem";
|
|
@@ -71,7 +74,7 @@ function serveFile(request, file, content) {
|
|
|
71
74
|
if (isNotModified(request, etag, lastModified))
|
|
72
75
|
return HttpServerResponse.empty({ status: 304, headers: { ...validators, ...content } });
|
|
73
76
|
const rangeHeader = request.method === "GET" ? request.headers["range"] : undefined;
|
|
74
|
-
const range = rangeHeader !== undefined && matchesIfRange(request.headers["if-range"], etag, lastModified) ?
|
|
77
|
+
const range = rangeHeader !== undefined && matchesIfRange(request.headers["if-range"], etag, lastModified) ? parse2(rangeHeader, file.size) : undefined;
|
|
75
78
|
if (range === "unsatisfiable")
|
|
76
79
|
return HttpServerResponse.empty({
|
|
77
80
|
status: 416,
|
|
@@ -107,21 +110,5 @@ function matchesIfRange(ifRange, etag, lastModified) {
|
|
|
107
110
|
function stripWeak(etag) {
|
|
108
111
|
return etag.trim().replace(/^w\//i, "");
|
|
109
112
|
}
|
|
110
|
-
function parseRange(header, size) {
|
|
111
|
-
const match = /^bytes=\s*(\d*)\s*-\s*(\d*)\s*$/i.exec(header.trim());
|
|
112
|
-
if (match === null || match[1] === "" && match[2] === "")
|
|
113
|
-
return;
|
|
114
|
-
if (match[1] === "") {
|
|
115
|
-
const suffix = Number(match[2]);
|
|
116
|
-
if (suffix === 0 || size === 0)
|
|
117
|
-
return "unsatisfiable";
|
|
118
|
-
return { start: Math.max(size - suffix, 0), end: size - 1 };
|
|
119
|
-
}
|
|
120
|
-
const start = Number(match[1]);
|
|
121
|
-
const end = match[2] === "" ? size - 1 : Number(match[2]);
|
|
122
|
-
if (start > end || start >= size)
|
|
123
|
-
return "unsatisfiable";
|
|
124
|
-
return { start, end: Math.min(end, size - 1) };
|
|
125
|
-
}
|
|
126
113
|
|
|
127
114
|
export { FileSystemHandler2 };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LocationMiddleware2
|
|
3
|
-
} from "./api-
|
|
3
|
+
} from "./api-50bbk3b2.js";
|
|
4
4
|
import {
|
|
5
5
|
FormLocationMiddleware2
|
|
6
|
-
} from "./api-
|
|
6
|
+
} from "./api-htyf2qs7.js";
|
|
7
7
|
import {
|
|
8
8
|
SessionLocationMiddleware2
|
|
9
|
-
} from "./api-
|
|
9
|
+
} from "./api-b3bmdkga.js";
|
|
10
10
|
|
|
11
11
|
// src/api.ts
|
|
12
12
|
import { makeDefaultApi } from "@opencode/protocol/api";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
awaitPlugins2,
|
|
3
3
|
response2
|
|
4
|
-
} from "./api-
|
|
4
|
+
} from "./api-50bbk3b2.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./api-
|
|
7
|
+
} from "./api-j87xz9bt.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/websearch.ts
|
|
10
10
|
import { WebSearch } from "@opencode/core/websearch";
|